|
|
@@ -9,7 +9,6 @@ import com.zd.algorithm.api.fire.entity.HardwareFireDeviceLog;
|
|
|
import com.zd.algorithm.api.fire.entity.vo.HardwareFireDeviceVO;
|
|
|
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.utils.StringUtils;
|
|
|
@@ -67,26 +66,23 @@ public class FireDeviceController extends BaseController {
|
|
|
@GetMapping(value = "/getStatus")
|
|
|
public ResultData getStatus(Long subjectId) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- boolean smoke = false;//烟雾
|
|
|
- boolean temperature = false;//温度
|
|
|
- boolean fire = false;//火焰
|
|
|
- boolean online = false;//是否在线
|
|
|
- boolean isexist = false;//是否配置灭火设备
|
|
|
+ //烟雾
|
|
|
+ boolean smoke = false;
|
|
|
+ //温度
|
|
|
+ boolean temperature = false;
|
|
|
+ //火焰
|
|
|
+ boolean fire = false;
|
|
|
+ //是否在线
|
|
|
+ boolean online = false;
|
|
|
+ //是否配置灭火设备
|
|
|
+ boolean isexist = false;
|
|
|
+ //是否灭火中
|
|
|
+ boolean outfireing =false;
|
|
|
|
|
|
if (StringUtils.isNull(subjectId)) {
|
|
|
return ResultData.fail("实验室id参数为空");
|
|
|
}
|
|
|
|
|
|
- //获取灭火主机最后一次响应时间,判断响应是否超时
|
|
|
- Long timeJson = redisService.getCacheObject(FireDeviceStatusTask.TOPIC_FD_RESPOND_TIME);
|
|
|
- if (StringUtils.isNotNull(timeJson)) {
|
|
|
- Long timeDiff = (System.currentTimeMillis() - timeJson) / 1000;
|
|
|
- //时间差 在设置时间内
|
|
|
- if (timeDiff < onlineTime) {
|
|
|
- online = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
//查询实验室是否配置灭火设备
|
|
|
HardwareFireDeviceVO vo = new HardwareFireDeviceVO();
|
|
|
vo.setSubjectId(subjectId);
|
|
|
@@ -99,33 +95,46 @@ public class FireDeviceController extends BaseController {
|
|
|
return ResultData.success(map);
|
|
|
} else {
|
|
|
isexist = true;
|
|
|
- }
|
|
|
+ //获取灭火主机最后一次响应时间,判断响应是否超时
|
|
|
+ Long timeJson = redisService.getCacheObject(FireDeviceStatusTask.TOPIC_FD_RESPOND_TIME+list.get(0).getDeviceCode());
|
|
|
+ if (StringUtils.isNotNull(timeJson)) {
|
|
|
+ Long timeDiff = (System.currentTimeMillis() - timeJson) / 1000;
|
|
|
+ //时间差 在设置时间内
|
|
|
+ if (timeDiff < onlineTime) {
|
|
|
+ online = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //根据编码从redis获取该设备状态
|
|
|
- //String str = "{\"msg\":\"NO:5号设备故障 NO:10号设备火警 \",\"fireNumber\":1,\"fireStatus\":true,\"startSpray\":\"0\",\"gasSpray\":\"0\"}";
|
|
|
- //JSONObject strJson = JSONObject.parseObject(str);
|
|
|
- JSONObject strJson = redisService.getCacheObject(list.get(0).getDeviceCode());
|
|
|
- if (StringUtils.isNotNull(strJson)) {
|
|
|
- Integer fireNumber = (Integer) strJson.get("fireNumber");
|
|
|
- if (fireNumber == 1) {
|
|
|
- temperature = true;
|
|
|
- } else if (fireNumber == 2) {
|
|
|
- smoke = true;
|
|
|
- temperature = true;
|
|
|
+ //根据编码从redis获取该设备状态
|
|
|
+ //String str = "{\"msg\":\"NO:5号设备故障 NO:10号设备火警 \",\"fireNumber\":1,\"fireStatus\":true,\"startSpray\":\"0\",\"gasSpray\":\"0\"}";
|
|
|
+ //JSONObject strJson = JSONObject.parseObject(str);
|
|
|
+ JSONObject strJson = redisService.getCacheObject(list.get(0).getDeviceCode());
|
|
|
+ if (StringUtils.isNotNull(strJson)) {
|
|
|
+ Integer fireNumber = (Integer) strJson.get("fireNumber");
|
|
|
+ if (fireNumber == 1) {
|
|
|
+ temperature = true;
|
|
|
+ } else if (fireNumber == 2) {
|
|
|
+ smoke = true;
|
|
|
+ temperature = true;
|
|
|
+ }
|
|
|
+ //启动喷洒状态 :1是启动 0未启动
|
|
|
+ Integer startSpray = Integer.valueOf(strJson.get("startSpray").toString());
|
|
|
+ outfireing = startSpray==1?true:false;
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //查询该实验室是否存在火焰摄像头报警
|
|
|
- JSONObject fireJson = redisService.getCacheObject("/lab/fire/85");
|
|
|
- if (StringUtils.isNotNull(fireJson)) {
|
|
|
- fire = true;
|
|
|
+ //查询该实验室是否存在火焰摄像头报警
|
|
|
+ JSONObject fireJson = redisService.getCacheObject("/lab/fire/85");
|
|
|
+ if (StringUtils.isNotNull(fireJson)) {
|
|
|
+ fire = true;
|
|
|
+ }
|
|
|
}
|
|
|
map.put("smoke", smoke);
|
|
|
map.put("temperature", temperature);
|
|
|
map.put("fire", fire);
|
|
|
map.put("online", online);
|
|
|
map.put("isexist", isexist);
|
|
|
- map.put("deviceCode", list.get(0).getDeviceCode());
|
|
|
+ map.put("outfireing", outfireing);
|
|
|
+ map.put("fireDevice", list.get(0));
|
|
|
return ResultData.success(map);
|
|
|
}
|
|
|
|
|
|
@@ -138,17 +147,23 @@ public class FireDeviceController extends BaseController {
|
|
|
@GetMapping(value = "/getStatusDetails")
|
|
|
public ResultData getStatus(String deviceCode) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- boolean smoke = false;//烟雾
|
|
|
- boolean temperature = false;//温度
|
|
|
- boolean fire = false;//火焰
|
|
|
- boolean online = false;//是否在线
|
|
|
+ //烟雾
|
|
|
+ boolean smoke = false;
|
|
|
+ //温度
|
|
|
+ boolean temperature = false;
|
|
|
+ //火焰
|
|
|
+ boolean fire = false;
|
|
|
+ //是否在线
|
|
|
+ boolean online = false;
|
|
|
+ //是否灭火中
|
|
|
+ boolean outfireing =false;
|
|
|
|
|
|
if (StringUtils.isNull(deviceCode)) {
|
|
|
- throw new ServiceException("设备编号参数为空");
|
|
|
+ ResultData.fail("设备编号参数为空");
|
|
|
}
|
|
|
|
|
|
//获取灭火主机最后一次响应时间,判断响应是否超时
|
|
|
- Long timeJson = redisService.getCacheObject(FireDeviceStatusTask.TOPIC_FD_RESPOND_TIME);
|
|
|
+ Long timeJson = redisService.getCacheObject(FireDeviceStatusTask.TOPIC_FD_RESPOND_TIME+deviceCode);
|
|
|
if (StringUtils.isNotNull(timeJson)) {
|
|
|
Long timeDiff = (System.currentTimeMillis() - timeJson) / 1000;
|
|
|
//时间差 在设置时间内
|
|
|
@@ -169,6 +184,9 @@ public class FireDeviceController extends BaseController {
|
|
|
smoke = true;
|
|
|
temperature = true;
|
|
|
}
|
|
|
+ //启动喷洒状态 :1是启动 0未启动
|
|
|
+ Integer startSpray = Integer.valueOf(strJson.get("startSpray").toString());
|
|
|
+ outfireing = startSpray==1?true:false;
|
|
|
}
|
|
|
|
|
|
//查询该实验室是否存在火焰摄像头报警
|
|
|
@@ -180,16 +198,49 @@ public class FireDeviceController extends BaseController {
|
|
|
map.put("temperature", temperature);
|
|
|
map.put("fire", fire);
|
|
|
map.put("online", online);
|
|
|
+ map.put("outfireing", outfireing);
|
|
|
return ResultData.success(map);
|
|
|
}
|
|
|
|
|
|
/***
|
|
|
- * 发送灭火请求
|
|
|
+ * 发送灭火请求-小程序
|
|
|
* @return
|
|
|
*/
|
|
|
- @GetMapping(value = "/outfire")
|
|
|
+ @GetMapping(value = "/outfireapp")
|
|
|
public ResultData outFire(Long subjectId) throws InterruptedException {
|
|
|
- logger.info("=========开始一键灭火=======");
|
|
|
+ logger.info("=========小程序端开始一键灭火=======");
|
|
|
+ Map<String, Object> map = outFireCom(subjectId);
|
|
|
+ if(StringUtils.isNotNull(map.get("check"))){
|
|
|
+ return ResultData.fail(map.get("check").toString());
|
|
|
+ }
|
|
|
+ return ResultData.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ *发送灭火请求-PC
|
|
|
+ * @param subjectId
|
|
|
+ * @return
|
|
|
+ * @throws InterruptedException
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/outfirepc")
|
|
|
+ public ResultData outFirePc(Long subjectId) throws InterruptedException {
|
|
|
+ logger.info("=========PC端开始一键灭火=======");
|
|
|
+ //执行灭火指令
|
|
|
+ Map<String, Object> map = outFireCom(subjectId);
|
|
|
+ if(StringUtils.isNotNull(map.get("check"))){
|
|
|
+ return ResultData.fail(map.get("check").toString());
|
|
|
+ }
|
|
|
+ return ResultData.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ *灭火指令发送方法
|
|
|
+ * @param subjectId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String,Object> outFireCom(Long subjectId) throws InterruptedException {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("check","");
|
|
|
//查询实验室下的硬件
|
|
|
RemoteLabHardware hd = new RemoteLabHardware();
|
|
|
//实验室id
|
|
|
@@ -198,13 +249,15 @@ public class FireDeviceController extends BaseController {
|
|
|
hd.setType(10);
|
|
|
List<RemoteLabHardware> hdlist = remoteLaboratoryService.remoteList(hd).getData();
|
|
|
if (hdlist.size() == 0) {
|
|
|
- return ResultData.fail("该实验室尚未配置关联硬件!");
|
|
|
+ //return ResultData.fail("该实验室尚未配置关联硬件!");
|
|
|
+ map.put("check","该实验室尚未配置关联硬件!");
|
|
|
+ return map;
|
|
|
} else if (hdlist.size() != 2) {
|
|
|
- return ResultData.fail("该实验室尚未配置2路控制器!");
|
|
|
+ //return ResultData.fail("该实验室尚未配置2路控制器!");
|
|
|
+ map.put("check","该实验室尚未配置2路控制器!");
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
//获取当前实验室下灭火设备状态
|
|
|
HardwareFireDeviceVO fireDeviceVO = new HardwareFireDeviceVO();
|
|
|
fireDeviceVO.setSubjectId(subjectId);
|
|
|
@@ -238,7 +291,7 @@ public class FireDeviceController extends BaseController {
|
|
|
fireDeviceLog.setRunResult(map.toString());
|
|
|
fireDeviceLog.setCreateTime(new Date());
|
|
|
fireDeviceLogService.insertFireDeviceLog(fireDeviceLog);
|
|
|
- return ResultData.success(map);
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
/**
|