|
|
@@ -2,6 +2,7 @@ package com.ruoyi.data.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.json.JSON;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.core.lang.UUID;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
@@ -67,6 +68,10 @@ public class MqttServiceImpl implements MqttService {
|
|
|
|
|
|
private final ITblRuleExecuteService iTblRuleExecuteService;
|
|
|
|
|
|
+ private final TblWarnMapper tblWarnMapper;
|
|
|
+
|
|
|
+ private final TblBreakdownMapper tblBreakdownMapper;
|
|
|
+
|
|
|
@Value("${mqtt.url}")
|
|
|
private String mqttUrl;
|
|
|
|
|
|
@@ -300,9 +305,36 @@ public class MqttServiceImpl implements MqttService {
|
|
|
warn.setVal(bo.getValue());
|
|
|
warn.setEquipmentId(tblEquipment.getId());
|
|
|
warn.setEquipmentName(tblEquipment.getName());
|
|
|
- warn.setContent("设备"+tblEquipment.getName()+"传感器"+tblSensor.getName()+"数据异常,请注意");
|
|
|
+ warn.setContent("设备"+tblEquipment.getName()+"传感器"+tblSensor.getName()+vo.getRemark());
|
|
|
warn.setAlarmTime(new Date());
|
|
|
- iTblWarnService.insertByBo(warn);
|
|
|
+ if(StringUtils.isNotBlank(vo.getExpr1()) && vo.getExpr1() != null){
|
|
|
+ JSONObject jsonObject = new JSONObject(vo.getExpr1());
|
|
|
+ if(StringUtils.isNotBlank(jsonObject.getStr("postpone")) && jsonObject.getStr("postpone") != null){
|
|
|
+ Long postpone = Long.valueOf(jsonObject.getStr("postpone"));
|
|
|
+ try{
|
|
|
+ Thread.sleep(postpone);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(jsonObject.getStr("frequency") != null && jsonObject.getStr("interval") != null && jsonObject.getStr("invalidation") != null){
|
|
|
+ TblWarn tblWarn = new TblWarn();
|
|
|
+ tblWarn.setEquipmentId(tblEquipment.getId());
|
|
|
+ tblWarn.setStatus(jsonObject.getStr("interval"));
|
|
|
+ List<TblWarn> warnList = tblWarnMapper.getWarnDeviceList(tblWarn);
|
|
|
+ Integer frequency = Integer.valueOf(jsonObject.getStr("frequency"));
|
|
|
+ Integer interval = Integer.valueOf(jsonObject.getStr("interval"));
|
|
|
+ Integer invalidation = Integer.valueOf(jsonObject.getStr("invalidation"));
|
|
|
+ Integer time = frequency*interval + invalidation + 100;
|
|
|
+ tblWarn.setStatus(String.valueOf(time));
|
|
|
+ List<TblWarn> totalWarnList = tblWarnMapper.getWarnDeviceList(tblWarn);
|
|
|
+ if(warnList.size() == 0 && totalWarnList.size() < frequency){
|
|
|
+ iTblWarnService.insertByBo(warn);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ iTblWarnService.insertByBo(warn);
|
|
|
+ }
|
|
|
} else if (vo.getExecuteAction().equals("breakbown")) {
|
|
|
TblBreakdownBo tblBreakdownBo = new TblBreakdownBo();
|
|
|
TblEquipmentSbookVo tblEquipment = equipmentSbookService.queryById(tblSensor.getDeviceId());
|
|
|
@@ -310,9 +342,36 @@ public class MqttServiceImpl implements MqttService {
|
|
|
tblBreakdownBo.setVal(bo.getValue());
|
|
|
tblBreakdownBo.setEquipmentId(tblEquipment.getId());
|
|
|
tblBreakdownBo.setEquipmentName(tblEquipment.getName());
|
|
|
- tblBreakdownBo.setContent("设备"+tblEquipment.getName()+"传感器"+tblSensor.getName()+"故障,请注意");
|
|
|
+ tblBreakdownBo.setContent("设备"+tblEquipment.getName()+"传感器"+tblSensor.getName()+vo.getRemark());
|
|
|
tblBreakdownBo.setFaultTime(new Date());
|
|
|
- iTblBreakdownService.insertByBo(tblBreakdownBo);
|
|
|
+ if(StringUtils.isNotBlank(vo.getExpr1()) && vo.getExpr1() != null){
|
|
|
+ JSONObject jsonObject = new JSONObject(vo.getExpr1());
|
|
|
+ if(StringUtils.isNotBlank(jsonObject.getStr("postpone")) && jsonObject.getStr("postpone") != null){
|
|
|
+ Long postpone = Long.valueOf(jsonObject.getStr("postpone"));
|
|
|
+ try{
|
|
|
+ Thread.sleep(postpone);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(jsonObject.getStr("frequency") != null && jsonObject.getStr("interval") != null && jsonObject.getStr("invalidation") != null){
|
|
|
+ TblBreakdown tblBreakdown = new TblBreakdown();
|
|
|
+ tblBreakdown.setEquipmentId(tblEquipment.getId());
|
|
|
+ tblBreakdown.setStatus(jsonObject.getStr("interval"));
|
|
|
+ List<TblBreakdown> breakList = tblBreakdownMapper.getBreakdownList(tblBreakdown);
|
|
|
+ Integer frequency = Integer.valueOf(jsonObject.getStr("frequency"));
|
|
|
+ Integer interval = Integer.valueOf(jsonObject.getStr("interval"));
|
|
|
+ Integer invalidation = Integer.valueOf(jsonObject.getStr("invalidation"));
|
|
|
+ Integer time = frequency*interval + invalidation + 100;
|
|
|
+ tblBreakdown.setStatus(String.valueOf(time));
|
|
|
+ List<TblBreakdown> totalbreakList = tblBreakdownMapper.getBreakdownList(tblBreakdown);
|
|
|
+ if(breakList.size() == 0 && totalbreakList.size() < frequency){
|
|
|
+ iTblBreakdownService.insertByBo(tblBreakdownBo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ iTblBreakdownService.insertByBo(tblBreakdownBo);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|