|
|
@@ -1,10 +1,12 @@
|
|
|
package com.zd.laboratory.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.zd.common.core.annotation.Log;
|
|
|
import com.zd.common.core.annotation.PreAuthorize;
|
|
|
import com.zd.common.core.exception.ServiceException;
|
|
|
import com.zd.common.core.log.BusinessType;
|
|
|
+import com.zd.common.core.redis.RedisService;
|
|
|
import com.zd.common.core.web.controller.BaseController;
|
|
|
import com.zd.laboratory.domain.LabFireDevice;
|
|
|
import com.zd.laboratory.domain.LabMold;
|
|
|
@@ -12,6 +14,7 @@ import com.zd.laboratory.domain.vo.LabFireDeviceVO;
|
|
|
import com.zd.laboratory.service.ILabExitLineService;
|
|
|
import com.zd.laboratory.service.ILabFireDeviceService;
|
|
|
import com.zd.laboratory.utils.FireLaborUtil;
|
|
|
+import com.zd.model.constant.MqttConstants;
|
|
|
import com.zd.model.domain.AjaxResult;
|
|
|
import com.zd.model.domain.ResultData;
|
|
|
import com.zd.model.domain.per.PerFun;
|
|
|
@@ -22,7 +25,9 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 灭火装置
|
|
|
@@ -38,27 +43,51 @@ public class labFireDeviceController extends BaseController {
|
|
|
@Autowired
|
|
|
private ILabFireDeviceService labFireDeviceService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisService redisService;
|
|
|
+
|
|
|
/**
|
|
|
* 获取主机状态
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- @GetMapping(value = "/status")
|
|
|
- public AjaxResult getStatus() {
|
|
|
- //根据主机地址-位获取主机状态指令
|
|
|
- String activeCode = FireLaborUtil.getFireActiveOrder(2);
|
|
|
- //根据状态指令获取主机状态
|
|
|
- JSONObject jsonObject = FireLaborUtil.getFireStatus("0");
|
|
|
- System.out.println(jsonObject.toJSONString());
|
|
|
+ @GetMapping(value = "/getStatus")
|
|
|
+ public ResultData getStatus(String deviceCode,Integer subjectId) {
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ //烟雾
|
|
|
+ boolean smoke=false;
|
|
|
+ //温度
|
|
|
+ boolean temperature=false;
|
|
|
+ //火焰
|
|
|
+ boolean fire=false;
|
|
|
+
|
|
|
+ //根据编码从redis获取该设备状态
|
|
|
+ JSON strStatus= redisService.getCacheObject(MqttConstants.TOPIC_FIRE_DEVICE_RECEIVE+deviceCode);
|
|
|
+ if(strStatus==null){
|
|
|
+ strStatus=new JSONObject();
|
|
|
+ }
|
|
|
+ map.put("smoke",smoke);
|
|
|
+ map.put("temperature",temperature);
|
|
|
+ map.put("fire",fire);
|
|
|
+ return ResultData.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * 发送灭火请求
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/sendRequest")
|
|
|
+ public AjaxResult sendRequest() {
|
|
|
+ //待对接
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询实验室灭火设备列表
|
|
|
*/
|
|
|
- @PreAuthorize(hasPermi = PerPrefix.LABORATORY_FIREDEVICE + PerFun.LIST)
|
|
|
+ @PreAuthorize(hasPermi = PerPrefix.ALGORITHM_FIREDEVICE + PerFun.LIST)
|
|
|
@GetMapping("/list")
|
|
|
- @ApiOperation(value = "查询实验室灭火设备列表", notes = "权限字符:" + PerPrefix.LABORATORY_FIREDEVICE + PerFun.LIST)
|
|
|
+ @ApiOperation(value = "查询实验室灭火设备列表", notes = "权限字符:" + PerPrefix.ALGORITHM_FIREDEVICE + PerFun.LIST)
|
|
|
public TableDataInfo<LabFireDeviceVO> list(LabFireDeviceVO labFireDeviceVO) {
|
|
|
startPage();
|
|
|
List<LabFireDeviceVO> list = labFireDeviceService.selectLabFireDeviceList(labFireDeviceVO);
|
|
|
@@ -69,8 +98,8 @@ public class labFireDeviceController extends BaseController {
|
|
|
/**
|
|
|
* 获取实验室灭火设备详细信息
|
|
|
*/
|
|
|
- @ApiOperation(value = "获取实验室灭火设备详细信息", notes = "权限字符:" + PerPrefix.LABORATORY_FIREDEVICE + PerFun.QUERY)
|
|
|
- @PreAuthorize(hasPermi = PerPrefix.LABORATORY_FIREDEVICE + PerFun.QUERY)
|
|
|
+ @ApiOperation(value = "获取实验室灭火设备详细信息", notes = "权限字符:" + PerPrefix.ALGORITHM_FIREDEVICE + PerFun.QUERY)
|
|
|
+ @PreAuthorize(hasPermi = PerPrefix.ALGORITHM_FIREDEVICE + PerFun.QUERY)
|
|
|
@GetMapping(value = "/{id}")
|
|
|
public ResultData<LabFireDeviceVO> getInfo(@PathVariable("id") Long id) {
|
|
|
return ResultData.success(labFireDeviceService.selectLabFireDeviceById(id));
|
|
|
@@ -79,8 +108,8 @@ public class labFireDeviceController extends BaseController {
|
|
|
/**
|
|
|
* 新增实验室灭火设备
|
|
|
*/
|
|
|
- @ApiOperation(value = "新增实验室灭火设备", notes = "权限字符:" + PerPrefix.LABORATORY_FIREDEVICE + PerFun.ADD)
|
|
|
- @PreAuthorize(hasPermi = PerPrefix.LABORATORY_FIREDEVICE + PerFun.ADD)
|
|
|
+ @ApiOperation(value = "新增实验室灭火设备", notes = "权限字符:" + PerPrefix.ALGORITHM_FIREDEVICE + PerFun.ADD)
|
|
|
+ @PreAuthorize(hasPermi = PerPrefix.ALGORITHM_FIREDEVICE + PerFun.ADD)
|
|
|
@Log(title = "灭火设备", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
public ResultData add(@RequestBody LabFireDevice labFireDevice) {
|
|
|
@@ -90,8 +119,8 @@ public class labFireDeviceController extends BaseController {
|
|
|
/**
|
|
|
* 修改实验室灭火设备
|
|
|
*/
|
|
|
- @ApiOperation(value = "修改实验室灭火设备", notes = "权限字符:" + PerPrefix.LABORATORY_FIREDEVICE + PerFun.EDIT)
|
|
|
- @PreAuthorize(hasPermi = PerPrefix.LABORATORY_FIREDEVICE + PerFun.EDIT)
|
|
|
+ @ApiOperation(value = "修改实验室灭火设备", notes = "权限字符:" + PerPrefix.ALGORITHM_FIREDEVICE + PerFun.EDIT)
|
|
|
+ @PreAuthorize(hasPermi = PerPrefix.ALGORITHM_FIREDEVICE + PerFun.EDIT)
|
|
|
@Log(title = "灭火设备", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
public ResultData edit(@RequestBody LabFireDevice labFireDevice) {
|