Commit d5a47667 authored by 高建强's avatar 高建强

item:同步修改三维消息重复推送

parent 9ae17467
......@@ -8,6 +8,7 @@ import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.action.mq.WebMqttSubscribe;
import com.yeejoin.amos.fas.business.bo.SafetyExecuteBo;
import com.yeejoin.amos.fas.business.dao.mapper.*;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao;
import com.yeejoin.amos.fas.business.dao.repository.IEvaluationModelDao;
......@@ -136,10 +137,14 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
EquipmentSpecificIndexVo equipmentSpecificIndex = JSONObject.parseObject(topicEntity.getMessage(), EquipmentSpecificIndexVo.class);
long eqSpecId = equipmentSpecificIndex.getEquipmentSpecificId();
String nameKey = equipmentSpecificIndex.getNameKey();
if(topicEntity.getSimulationDate().equals("false") && !indexStateIsChange(equipmentSpecificIndex)){
log.info("指标值没有发生变化: " + equipmentSpecificIndex.getIotCode()+"-"+equipmentSpecificIndex.getNameKey()+":"+equipmentSpecificIndex.getValue());
return;
}
EquipmentSpecificForRiskVo equipmentSpecific = equipmentSpecificMapper.getOneById(eqSpecId);
// 三维屏指标状态推送
String specificIndexType = equipmentSpecificIndex.getType();
//
String typeCode = equipmentSpecificIndex.getTypeCode();
if (nameKey !=null && nameKeys.contains(nameKey)) {
if (equipmentSpecific != null) {
......@@ -165,10 +170,16 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
* 影响区域:消防安全=>火灾告警
*/
String title = String.format("/%s/%s/%s/%s", serviceName, stationName,"data/refresh","fireSafety");
webMqttComponent.publish(title, JSON.toJSONString(view3dService.getSafetyExecuteListTop5("fire", equipmentSpecific.getOrgCode())));
List<SafetyExecuteBo> dataList = view3dService.getSafetyExecuteListTop5("fire", equipmentSpecific.getOrgCode());
Map<String,Object> result = new HashMap<>();
result.put("type","fire");
result.put("dataList", dataList);
webMqttComponent.publish(title, JSON.toJSONString(result));
// 报警触发调用规则服务
//注释自动触发预案
//executeDynamicPlan(deviceData, equipment, equipmentSpecific, toke,topicEntity.getRecordId());
if(EquipmentRiskTypeEnum.HZGJ.getCode().equals(specificIndexType)&&!ObjectUtils.isEmpty(equipment) && !ObjectUtils.isEmpty(equipment.getReservePlan())){
executeDynamicPlan(deviceData, equipment, equipmentSpecific, toke, null);
}
} else if (EquipmentRiskTypeEnum.GZ.getCode().equals(typeCode)) {
// 设备故障处理逻辑
log.info("(故障)Message typeCode is: " +typeCode);
......@@ -198,13 +209,13 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
fireEquipRuleMessagePush(deviceData, toke);
}
}
} else {
// 监测数据逻辑
log.info("(监测)Message type is: " + specificIndexType);
Map<String, Object> content = new HashMap<>();
String location = equipmentSpecific.getLocation()+" "+equipmentSpecific.getDescription();
content.put("id", equipmentSpecific.getId());
content.put("label", equipmentSpecific.getName()+" "+equipmentSpecificIndex.getEquipmentIndexName());
content.put("label", equipmentSpecific.getName()+" "+equipmentSpecificIndex.getEquipmentIndexName() + (ObjectUtils.isEmpty(location)?("【" +location+"】"):""));
content.put("code", equipmentSpecific.getCode());
content.put("changeDate", new Date());
content.put("orgCode", equipmentSpecific.getOrgCode());
......@@ -215,6 +226,21 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
}
}
private boolean indexStateIsChange(EquipmentSpecificIndexVo equipmentSpecificIndex){
if(ObjectUtils.isEmpty(equipmentSpecificIndex.getValue())){
return false;
}
String key = equipmentSpecificIndex.getIotCode()+"-"+equipmentSpecificIndex.getNameKey();
if(redisTemplate.hasKey(key)){
EquipmentSpecificIndexVo equipmentSpecificIndexVo = JSON.parseObject(redisTemplate.opsForValue().get(key).toString(), EquipmentSpecificIndexVo.class);
if(equipmentSpecificIndex.getValue().equals(equipmentSpecificIndexVo.getValue())){
return false;
}
}
redisTemplate.opsForValue().set(key, JSONObject.toJSONString(equipmentSpecificIndex));
return true;
}
/**
* <pre>
* @Description: rpn,rpni值修改
......
......@@ -43,4 +43,14 @@ public class EquipmentSpecificForRiskVo {
@ApiModelProperty(value = "orgCode")
private String orgCode;
/**
* 位置
*/
private String location;
/**
* 位置详情
*/
private String description;
}
......@@ -28,4 +28,9 @@ public class TopicEntityVo {
private Long recordId;
private Equipment equipment;
/**
* 是否模拟发送的数据,初始值为false
*/
private String simulationDate = "false";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment