|
@@ -1,7 +1,10 @@
|
|
|
package com.zd.airbottle.controller;
|
|
package com.zd.airbottle.controller;
|
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.zd.airbottle.domain.DbBluetoothGateway;
|
|
import com.zd.airbottle.domain.DbBluetoothGateway;
|
|
|
|
|
+import com.zd.airbottle.domain.DbStock;
|
|
|
import com.zd.airbottle.service.DbBluetoothGatewayService;
|
|
import com.zd.airbottle.service.DbBluetoothGatewayService;
|
|
|
|
|
+import com.zd.airbottle.service.DbStockService;
|
|
|
import com.zd.common.core.annotation.Log;
|
|
import com.zd.common.core.annotation.Log;
|
|
|
import com.zd.common.core.annotation.PreAuthorize;
|
|
import com.zd.common.core.annotation.PreAuthorize;
|
|
|
import com.zd.common.core.log.BusinessType;
|
|
import com.zd.common.core.log.BusinessType;
|
|
@@ -37,6 +40,9 @@ public class DbBluetoothGatewayController extends BaseController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private RedisService redisService;
|
|
private RedisService redisService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DbStockService dbStockService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询蓝牙网关列表
|
|
* 查询蓝牙网关列表
|
|
|
*/
|
|
*/
|
|
@@ -69,8 +75,15 @@ public class DbBluetoothGatewayController extends BaseController {
|
|
|
@Log(title = "蓝牙网关", businessType = BusinessType.INSERT)
|
|
@Log(title = "蓝牙网关", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
@PostMapping
|
|
|
public ResultData<Boolean> add(@RequestBody DbBluetoothGateway dbBluetoothGateway) {
|
|
public ResultData<Boolean> add(@RequestBody DbBluetoothGateway dbBluetoothGateway) {
|
|
|
|
|
+ int flag = dbBluetoothGatewayService.insertDbBluetoothGateway(dbBluetoothGateway);
|
|
|
|
|
+ LambdaQueryWrapper<DbStock> queryWrapper = new LambdaQueryWrapper();
|
|
|
|
|
+ queryWrapper.eq(DbStock::getSubjectId, dbBluetoothGateway.getSubId());
|
|
|
|
|
+ List<DbStock> list = dbStockService.list(queryWrapper);
|
|
|
|
|
+ for(DbStock stock : list){
|
|
|
|
|
+ redisService.setCacheObject(BaseConstants.BEACON_MATE_DET + "~" + stock.getBeaconTag() + "~" + stock.getSubjectId() + "~" + stock.getGasName(), stock.getBeaconTag(), 120L, TimeUnit.SECONDS);
|
|
|
|
|
+ }
|
|
|
redisService.deleteObject(BaseConstants.BEACON_SUBMAC);
|
|
redisService.deleteObject(BaseConstants.BEACON_SUBMAC);
|
|
|
- return ResultData.result(dbBluetoothGatewayService.insertDbBluetoothGateway(dbBluetoothGateway));
|
|
|
|
|
|
|
+ return ResultData.result(flag);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -81,8 +94,17 @@ public class DbBluetoothGatewayController extends BaseController {
|
|
|
@Log(title = "蓝牙网关", businessType = BusinessType.UPDATE)
|
|
@Log(title = "蓝牙网关", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
@PutMapping
|
|
|
public ResultData<Boolean> edit(@RequestBody DbBluetoothGateway dbBluetoothGateway) {
|
|
public ResultData<Boolean> edit(@RequestBody DbBluetoothGateway dbBluetoothGateway) {
|
|
|
|
|
+ dbBluetoothGateway.setGatewayOnline(0);
|
|
|
|
|
+ int flag = dbBluetoothGatewayService.updateDbBluetoothGateway(dbBluetoothGateway);
|
|
|
|
|
+ LambdaQueryWrapper<DbStock> queryWrapper = new LambdaQueryWrapper();
|
|
|
|
|
+ queryWrapper.eq(DbStock::getSubjectId, dbBluetoothGateway.getSubId());
|
|
|
|
|
+ List<DbStock> list = dbStockService.list(queryWrapper);
|
|
|
|
|
+ for(DbStock stock : list){
|
|
|
|
|
+ redisService.setCacheObject(BaseConstants.BEACON_MATE_DET + "~" + stock.getBeaconTag() + "~" + stock.getSubjectId() + "~" + stock.getGasName(), stock.getBeaconTag(), 120L, TimeUnit.SECONDS);
|
|
|
|
|
+ }
|
|
|
|
|
+ redisService.deleteObject(BaseConstants.BEACON_MAC+"~"+ dbBluetoothGateway.getGatewayMac());
|
|
|
redisService.deleteObject(BaseConstants.BEACON_SUBMAC);
|
|
redisService.deleteObject(BaseConstants.BEACON_SUBMAC);
|
|
|
- return ResultData.result(dbBluetoothGatewayService.updateDbBluetoothGateway(dbBluetoothGateway));
|
|
|
|
|
|
|
+ return ResultData.result(flag);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -93,8 +115,19 @@ public class DbBluetoothGatewayController extends BaseController {
|
|
|
@Log(title = "删除蓝牙网关", businessType = BusinessType.DELETE)
|
|
@Log(title = "删除蓝牙网关", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{ids}")
|
|
@DeleteMapping("/{ids}")
|
|
|
public ResultData<Boolean> remove(@PathVariable Long[] ids) {
|
|
public ResultData<Boolean> remove(@PathVariable Long[] ids) {
|
|
|
|
|
+ DbBluetoothGateway bluetoothGateway = dbBluetoothGatewayService.selectDbBluetoothGatewayById(ids[0]);
|
|
|
|
|
+ int flag = dbBluetoothGatewayService.deleteeDbBluetoothGatewayByIds(ids);
|
|
|
|
|
+ if(bluetoothGateway!=null){
|
|
|
|
|
+ LambdaQueryWrapper<DbStock> queryWrapper = new LambdaQueryWrapper();
|
|
|
|
|
+ queryWrapper.eq(DbStock::getSubjectId, bluetoothGateway.getSubId());
|
|
|
|
|
+ List<DbStock> list = dbStockService.list(queryWrapper);
|
|
|
|
|
+ for(DbStock stock : list){
|
|
|
|
|
+ redisService.setCacheObject(BaseConstants.BEACON_MATE_DET + "~" + stock.getBeaconTag() + "~" + stock.getSubjectId() + "~" + stock.getGasName(), stock.getBeaconTag(), 120L, TimeUnit.SECONDS);
|
|
|
|
|
+ }
|
|
|
|
|
+ redisService.deleteObject(BaseConstants.BEACON_MAC+"~"+ bluetoothGateway.getGatewayMac());
|
|
|
|
|
+ }
|
|
|
redisService.deleteObject(BaseConstants.BEACON_SUBMAC);
|
|
redisService.deleteObject(BaseConstants.BEACON_SUBMAC);
|
|
|
- return ResultData.result(dbBluetoothGatewayService.deleteeDbBluetoothGatewayByIds(ids));
|
|
|
|
|
|
|
+ return ResultData.result(flag);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|