Commit 6f5819ae authored by suhuiguang's avatar suhuiguang

1.修改消息

parent f2771e3f
...@@ -45,4 +45,8 @@ public interface PlanDetailMapper { ...@@ -45,4 +45,8 @@ public interface PlanDetailMapper {
List<PlanDetailVo> filterList(@Param("planName") String planName, @Param("classifyId") List<Long> classifyId, @Param("planRange") List<String> planRange, @Param("editOrgName") String editOrgName, @Param("implementationTimeLeft") Date implementationTimeLeft, @Param("implementationTimeRight") Date implementationTimeRight, @Param("start") int start, @Param("size") int size); List<PlanDetailVo> filterList(@Param("planName") String planName, @Param("classifyId") List<Long> classifyId, @Param("planRange") List<String> planRange, @Param("editOrgName") String editOrgName, @Param("implementationTimeLeft") Date implementationTimeLeft, @Param("implementationTimeRight") Date implementationTimeRight, @Param("start") int start, @Param("size") int size);
List<String> getRuleIdByEquipment(@Param("id") Long id); List<String> getRuleIdByEquipment(@Param("id") Long id);
PlanDetailVo getPlanDetailByEquipmentId(@Param("fire_equipment_id") Long fireEquipmentId);
} }
package com.yeejoin.amos.fas.business.service.impl; package com.yeejoin.amos.fas.business.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.component.rule.config.ClazzUtils; import com.yeejoin.amos.component.rule.config.ClazzUtils;
import com.yeejoin.amos.fas.business.action.CustomerAction; import com.yeejoin.amos.fas.business.action.CustomerAction;
...@@ -26,6 +27,7 @@ import org.springframework.beans.BeanUtils; ...@@ -26,6 +27,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
...@@ -44,18 +46,12 @@ import java.util.*; ...@@ -44,18 +46,12 @@ import java.util.*;
public class ContingencyPlanServiceImpl implements IContingencyPlanService { public class ContingencyPlanServiceImpl implements IContingencyPlanService {
private final Logger logger = LogManager.getLogger(ContingencyPlanServiceImpl.class); private final Logger logger = LogManager.getLogger(ContingencyPlanServiceImpl.class);
@Autowired @Autowired
private IEquipmentService equipmentService; private IEquipmentService equipmentService;
@Autowired @Autowired
private IRiskSourceService riskSourceService;
@Autowired
private IPlanOperationRecordDao planOperationRecordDao; private IPlanOperationRecordDao planOperationRecordDao;
@Autowired @Autowired
private IEquipmentFireEquipmentDao equipmentFireEquipmentDao; private IEquipmentFireEquipmentDao equipmentFireEquipmentDao;
@Qualifier("iEquipmentDao")
@Autowired
private IEquipmentDao equipmentDao;
@Autowired @Autowired
private EquipmentSpecificMapper equipmentSpecificMapper; private EquipmentSpecificMapper equipmentSpecificMapper;
@Autowired @Autowired
...@@ -67,8 +63,6 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -67,8 +63,6 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
private CustomerAction customerAction; private CustomerAction customerAction;
@Value("${now.gateway.address}") @Value("${now.gateway.address}")
private String gateWayAddress; private String gateWayAddress;
// @Value("${number.plan.projectName}")
// private String projectName;
private final PlanOperationRecordMapper planOperationRecordMapper; private final PlanOperationRecordMapper planOperationRecordMapper;
private final IPlanDetailDao planDetailDao; private final IPlanDetailDao planDetailDao;
private final IPlanDocDao planDocDao; private final IPlanDocDao planDocDao;
...@@ -84,6 +78,11 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -84,6 +78,11 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
@Autowired @Autowired
IContingencyInstance iContingencyInstance; IContingencyInstance iContingencyInstance;
@Autowired @Autowired
private RedisTemplate<String, String> redisTemplate;
@Autowired
public ContingencyPlanServiceImpl(IPlanDetailDao planDetailDao, IPlanDocDao planDocDao, IPlanEquipmentDao planEquipmentDao, public ContingencyPlanServiceImpl(IPlanDetailDao planDetailDao, IPlanDocDao planDocDao, IPlanEquipmentDao planEquipmentDao,
IPlanRuleDao planRuleDao, IPlanClassifyTreeDao classifyTreeDao, PlanDetailMapper planDetailMapper, IPlanRuleDao planRuleDao, IPlanClassifyTreeDao classifyTreeDao, PlanDetailMapper planDetailMapper,
PlanEquipmentMapper planEquipmentMapper, PlanRuleMapper planRuleMapper, PlanDocMapper planDocMapper, PlanEquipmentMapper planEquipmentMapper, PlanRuleMapper planRuleMapper, PlanDocMapper planDocMapper,
...@@ -119,7 +118,6 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -119,7 +118,6 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
Optional<PlanDetail> PlanDetailOp = planDetailDao.findById(Long.valueOf(vo.getPlanId())); Optional<PlanDetail> PlanDetailOp = planDetailDao.findById(Long.valueOf(vo.getPlanId()));
List<PlanEquipment> equipmentList = planEquipmentDao.findByPlanId(PlanDetailOp.get().getId()); List<PlanEquipment> equipmentList = planEquipmentDao.findByPlanId(PlanDetailOp.get().getId());
//预案启动 //预案启动
if (PlanDetailOp.get() != null) {
//获取规则名称 //获取规则名称
List<PlanRule> planRuleList = planRuleDao.getPlanDocsByPlanId(Long.valueOf(vo.getPlanId())); List<PlanRule> planRuleList = planRuleDao.getPlanDocsByPlanId(Long.valueOf(vo.getPlanId()));
if (planRuleList.size() == 0) { if (planRuleList.size() == 0) {
...@@ -135,17 +133,27 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -135,17 +133,27 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
equipment.setReservePlan("换流站消防专项预案" + "/" + planRuleList.get(0).getRuleId()); equipment.setReservePlan("换流站消防专项预案" + "/" + planRuleList.get(0).getRuleId());
//电力设备绑定装备 //电力设备绑定装备
EquipmentSpecificForRiskVo equipmentSpecific;
if(vo.getFireEquipmentId() != null){
equipmentSpecific = equipmentSpecificMapper.getOneById(vo.getFireEquipmentId());
//不会为null 在告警处理时已经判断过
if (equipmentSpecific == null) {
result.setMessage("该预案保护的电力设备尚未绑定配套的火灾报警设备");
return result;
}
} else {
List<EquipmentFireEquipment> equipmentFireEquipmentList = equipmentFireEquipmentDao.findAllByEquipmentId(equipmentList.get(0).getFireEquipmentId()); List<EquipmentFireEquipment> equipmentFireEquipmentList = equipmentFireEquipmentDao.findAllByEquipmentId(equipmentList.get(0).getFireEquipmentId());
if (equipmentFireEquipmentList.size() == 0) { if (equipmentFireEquipmentList.size() == 0) {
result.setMessage("该预案保护的电力设备尚未绑定配套的火灾报警设备"); result.setMessage("该预案保护的电力设备尚未绑定配套的火灾报警设备");
return result; return result;
} }
//查询设备 //查询设备
EquipmentSpecificForRiskVo equipmentSpecific = equipmentSpecificMapper.getOneById(equipmentFireEquipmentList.get(0).getFireEquipmentId()); equipmentSpecific = equipmentSpecificMapper.getOneById(equipmentFireEquipmentList.get(0).getFireEquipmentId());
if (equipmentSpecific == null) { if (equipmentSpecific == null) {
result.setMessage("该预案保护的电力设备尚未绑定配套的火灾报警设备"); result.setMessage("该预案保护的电力设备尚未绑定配套的火灾报警设备");
return result; return result;
} }
}
//插入运行记录表 //插入运行记录表
PlanOperationRecord planOperationRecord = new PlanOperationRecord(); PlanOperationRecord planOperationRecord = new PlanOperationRecord();
...@@ -168,7 +176,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -168,7 +176,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
PlanOperationRecord operationRecord = planOperationRecordDao.save(planOperationRecord); PlanOperationRecord operationRecord = planOperationRecordDao.save(planOperationRecord);
//预案启动 //预案启动
AlarmParam deviceData = new AlarmParam(); AlarmParam deviceData = new AlarmParam();
deviceData.setMonitor(equipment != null ? equipment.getName() : ""); deviceData.setMonitor(equipment.getName());
deviceData.setId(String.valueOf(equipmentSpecific.getId())); deviceData.setId(String.valueOf(equipmentSpecific.getId()));
deviceData.setCode(equipmentSpecific.getCode()); deviceData.setCode(equipmentSpecific.getCode());
String batchNo = equipmentHandlerService.executeDynamicPlan(deviceData, equipment, equipmentSpecific, toke, operationRecord.getId()); String batchNo = equipmentHandlerService.executeDynamicPlan(deviceData, equipment, equipmentSpecific, toke, operationRecord.getId());
...@@ -182,7 +190,6 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -182,7 +190,6 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
result.setMessage(ReserveEnum.RUN.getText()); result.setMessage(ReserveEnum.RUN.getText());
result.setBatchNo(batchNo); result.setBatchNo(batchNo);
} }
}
return result; return result;
} }
...@@ -644,21 +651,23 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -644,21 +651,23 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
} catch (MqttException e) { } catch (MqttException e) {
logger.fatal("订阅规则删除同步消息失败,资源删除或取消无法同步", e); logger.fatal("订阅规则删除同步消息失败,资源删除或取消无法同步", e);
} }
/*try {
emqKeeper.getMqttClient().subscribe(DELETE_SYNC_PLAN_EQUIP, (s, mqttMessage) -> {
byte[] payload = mqttMessage.getPayload();
try { try {
List<Long> ids = (List<Long>) ClazzUtils.deserializableObject(payload); emqKeeper.getMqttClient().subscribe(VIEW_3D_OPEN_STATUS, (s, mqttMessage) -> {
if (!ValidationUtil.isEmpty(ids)) { Map msg = JSON.parseObject(mqttMessage.toString());
planEquipmentMapper.logicDeleteByEquipIdList(ids); if(msg.containsKey("status") && msg.containsKey("seq")){
String seq = msg.get("seq").toString();
String status = msg.get("status").toString();
String key = KEY_VIEW_3D_PAGE + seq;
if("offLine".equals(status)){
redisTemplate.delete(key);
} else {
redisTemplate.opsForValue().set(key,status);
} }
} catch (Exception e) {
logger.error("预案保护对象删除同步出错", e);
} }
}); });
} catch (MqttException e) { } catch (MqttException e) {
logger.fatal("订阅保护对象删除同步消息失败,资源删除或取消无法同步", e); logger.fatal("订阅规则删除同步消息失败,资源删除或取消无法同步", e);
}*/ }
} }
} }
\ No newline at end of file
...@@ -12,19 +12,15 @@ import com.yeejoin.amos.fas.business.bo.SafetyExecuteBo; ...@@ -12,19 +12,15 @@ import com.yeejoin.amos.fas.business.bo.SafetyExecuteBo;
import com.yeejoin.amos.fas.business.dao.mapper.*; 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.IContingencyOriginalDataDao;
import com.yeejoin.amos.fas.business.dao.repository.IEvaluationModelDao; import com.yeejoin.amos.fas.business.dao.repository.IEvaluationModelDao;
import com.yeejoin.amos.fas.business.dao.repository.IPlanOperationRecordDao;
import com.yeejoin.amos.fas.business.dao.repository.IPreplanPictureDao; import com.yeejoin.amos.fas.business.dao.repository.IPreplanPictureDao;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService; import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.param.AlarmParam; import com.yeejoin.amos.fas.business.param.AlarmParam;
import com.yeejoin.amos.fas.business.service.intfc.IDataRefreshService; import com.yeejoin.amos.fas.business.service.intfc.IContingencyPlanService;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentHandlerService; import com.yeejoin.amos.fas.business.service.intfc.IEquipmentHandlerService;
import com.yeejoin.amos.fas.business.service.intfc.IView3dService; import com.yeejoin.amos.fas.business.service.intfc.IView3dService;
import com.yeejoin.amos.fas.business.util.JexlUtil; import com.yeejoin.amos.fas.business.util.JexlUtil;
import com.yeejoin.amos.fas.business.util.RpnUtils; import com.yeejoin.amos.fas.business.util.RpnUtils;
import com.yeejoin.amos.fas.business.vo.EquipmentSpecificForRiskVo; import com.yeejoin.amos.fas.business.vo.*;
import com.yeejoin.amos.fas.business.vo.EquipmentSpecificIndexVo;
import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.business.vo.TopicEntityVo;
import com.yeejoin.amos.fas.client.invoke.RsDataQueue; import com.yeejoin.amos.fas.client.invoke.RsDataQueue;
import com.yeejoin.amos.fas.common.enums.EquipmentRiskTypeEnum; import com.yeejoin.amos.fas.common.enums.EquipmentRiskTypeEnum;
import com.yeejoin.amos.fas.core.util.StringUtil; import com.yeejoin.amos.fas.core.util.StringUtil;
...@@ -35,6 +31,7 @@ import org.slf4j.LoggerFactory; ...@@ -35,6 +31,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -98,9 +95,6 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -98,9 +95,6 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
IContingencyOriginalDataDao iContingencyOriginalDataDao; IContingencyOriginalDataDao iContingencyOriginalDataDao;
@Autowired @Autowired
private IDataRefreshService iDataRefreshService;
@Autowired
private IView3dService view3dService; private IView3dService view3dService;
@Autowired @Autowired
...@@ -118,18 +112,25 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -118,18 +112,25 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
@Autowired @Autowired
private FmeaMapper fmeaMapper; private FmeaMapper fmeaMapper;
@Value("${station.name}") @Value("${station.name}")
private String stationName; private String stationName;
@Value("${spring.application.name}") @Value("${spring.application.name}")
private String serviceName; private String serviceName;
@Autowired
private IPlanOperationRecordDao planOperationRecordDao;
@Value("${autoSys.alarm.nameKeys}") @Value("${autoSys.alarm.nameKeys}")
private String nameKeys; private String nameKeys;
@Value("${security.loginId}")
private String loginId;
@Autowired
PlanDetailMapper planDetailMapper;
@Lazy
@Autowired
IContingencyPlanService iContingencyPlanService;
@Override @Override
public void handlerMqttMessage(String topic, String data) { public void handlerMqttMessage(String topic, String data) {
...@@ -140,16 +141,12 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -140,16 +141,12 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
EquipmentSpecificIndexVo equipmentSpecificIndex = JSONObject.parseObject(topicEntity.getMessage(), EquipmentSpecificIndexVo.class); EquipmentSpecificIndexVo equipmentSpecificIndex = JSONObject.parseObject(topicEntity.getMessage(), EquipmentSpecificIndexVo.class);
long eqSpecId = equipmentSpecificIndex.getEquipmentSpecificId(); long eqSpecId = equipmentSpecificIndex.getEquipmentSpecificId();
String nameKey = equipmentSpecificIndex.getNameKey(); 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); EquipmentSpecificForRiskVo equipmentSpecific = equipmentSpecificMapper.getOneById(eqSpecId);
// 三维屏指标状态推送 // 三维屏指标状态推送
String specificIndexType = equipmentSpecificIndex.getType(); String specificIndexType = equipmentSpecificIndex.getType();
String typeCode = equipmentSpecificIndex.getTypeCode(); String typeCode = equipmentSpecificIndex.getTypeCode();
if (nameKey !=null && nameKeys.contains(nameKey)) { if (nameKey != null && nameKeys.contains(nameKey)) {
if (equipmentSpecific != null) { if (equipmentSpecific != null) {
equipmentSpecificIndex.setId(equipmentSpecific.getId()); equipmentSpecificIndex.setId(equipmentSpecific.getId());
equipmentSpecificIndex.setName(equipmentSpecific.getName()); equipmentSpecificIndex.setName(equipmentSpecific.getName());
...@@ -159,7 +156,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -159,7 +156,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
String title = String.format("/%s/%s", serviceName, "data/refresh/indexStatus"); String title = String.format("/%s/%s", serviceName, "data/refresh/indexStatus");
webMqttComponent.publish(title, JSON.toJSONString(equipmentSpecificIndex)); webMqttComponent.publish(title, JSON.toJSONString(equipmentSpecificIndex));
} }
Equipment equipment = topicEntity.getEquipment()==null?impAndFireEquipMapper.queryImpEqumtByFireEquipmt(eqSpecId):topicEntity.getEquipment(); Equipment equipment = topicEntity.getEquipment() == null ? impAndFireEquipMapper.queryImpEqumtByFireEquipmt(eqSpecId) : topicEntity.getEquipment();
Toke toke = remoteSecurityService.getServerToken(); Toke toke = remoteSecurityService.getServerToken();
AlarmParam deviceData = new AlarmParam(); AlarmParam deviceData = new AlarmParam();
log.info("========equipmentSpecific==========: " + JSON.toJSONString(equipmentSpecific)); log.info("========equipmentSpecific==========: " + JSON.toJSONString(equipmentSpecific));
...@@ -173,20 +170,19 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -173,20 +170,19 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
* 推送告警数据 * 推送告警数据
* 影响区域:消防安全=>火灾告警 * 影响区域:消防安全=>火灾告警
*/ */
String title = String.format("/%s/%s/%s/%s", serviceName, stationName,"data/refresh","fireSafety"); String title = String.format("/%s/%s/%s/%s", serviceName, stationName, "data/refresh", "fireSafety");
List<SafetyExecuteBo> dataList = view3dService.getSafetyExecuteListTop5("fire", equipmentSpecific.getOrgCode()); List<SafetyExecuteBo> dataList = view3dService.getSafetyExecuteListTop5("fire", equipmentSpecific.getOrgCode());
Map<String,Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put("type","fire"); result.put("type", "fire");
result.put("dataList", dataList); result.put("dataList", dataList);
webMqttComponent.publish(title, JSON.toJSONString(result)); webMqttComponent.publish(title, JSON.toJSONString(result));
// 报警触发调用规则服务 // 报警触发调用规则服务
if(EquipmentRiskTypeEnum.HZGJ.getCode().equals(specificIndexType)&&!ObjectUtils.isEmpty(equipment) && !ObjectUtils.isEmpty(equipment.getReservePlan())){ if (EquipmentRiskTypeEnum.HZGJ.getCode().equals(specificIndexType) && !ObjectUtils.isEmpty(equipment)) {
executeDynamicPlan(deviceData, equipment, equipmentSpecific, toke, null); this.startPlan(equipment, toke, eqSpecId);
} }
} else if (EquipmentRiskTypeEnum.GZ.getCode().equals(typeCode)) { } else if (EquipmentRiskTypeEnum.GZ.getCode().equals(typeCode)) {
// 设备故障处理逻辑 // 设备故障处理逻辑
log.info("(故障)Message typeCode is: " +typeCode); log.info("(故障)Message typeCode is: " + typeCode);
final String stateTrue = "true"; final String stateTrue = "true";
final String stateFalse = "false"; final String stateFalse = "false";
String state = equipmentSpecificIndex.getValue(); String state = equipmentSpecificIndex.getValue();
...@@ -198,11 +194,11 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -198,11 +194,11 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
notifyAlarm(equipmentSpecificIndex, 0); notifyAlarm(equipmentSpecificIndex, 0);
} }
long equipId = 0; long equipId = 0;
if(StringUtil.isNotEmpty(equipment)) { if (StringUtil.isNotEmpty(equipment)) {
equipId = equipment.getId(); equipId = equipment.getId();
// 是否关联风险点 // 是否关联风险点
List<FmeaEquipmentPoint> list = fmeaEquipmentPointMapper.listFmeaByEquipIndexIdAndEquipId(equipmentSpecificIndex.getId(), equipId); List<FmeaEquipmentPoint> list = fmeaEquipmentPointMapper.listFmeaByEquipIndexIdAndEquipId(equipmentSpecificIndex.getId(), equipId);
if(list.size() > 0) { if (list.size() > 0) {
// 关联风险点进行rpn,rpni值的修改 // 关联风险点进行rpn,rpni值的修改
list.forEach(fmeaEqPoint -> { list.forEach(fmeaEqPoint -> {
long fmeaId = fmeaEqPoint.getFmeaId(); long fmeaId = fmeaEqPoint.getFmeaId();
...@@ -222,27 +218,50 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -222,27 +218,50 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
// 监测数据逻辑 // 监测数据逻辑
log.info("(监测)Message type is: " + specificIndexType); log.info("(监测)Message type is: " + specificIndexType);
Map<String, Object> content = new HashMap<>(); Map<String, Object> content = new HashMap<>();
String location = equipmentSpecific.getLocation()+" "+equipmentSpecific.getDescription(); String location = equipmentSpecific.getLocation() + " " + equipmentSpecific.getDescription();
content.put("id", equipmentSpecific.getId()); content.put("id", equipmentSpecific.getId());
content.put("label", equipmentSpecific.getName()+" "+equipmentSpecificIndex.getEquipmentIndexName() + (ObjectUtils.isEmpty(location)?("【" +location+"】"):"")); content.put("label", equipmentSpecific.getName() + " " + equipmentSpecificIndex.getEquipmentIndexName() + (ObjectUtils.isEmpty(location) ? ("【" + location + "】") : ""));
content.put("code", equipmentSpecific.getCode()); content.put("code", equipmentSpecific.getCode());
content.put("changeDate", new Date()); content.put("changeDate", new Date());
content.put("orgCode", equipmentSpecific.getOrgCode()); content.put("orgCode", equipmentSpecific.getOrgCode());
content.put("indexKey", equipmentSpecificIndex.getNameKey()); content.put("indexKey", equipmentSpecificIndex.getNameKey());
content.put("status", equipmentSpecificIndex.getValue()); content.put("status", equipmentSpecificIndex.getValue());
String title = String.format("/%s/%s/%s", serviceName, stationName,"data/refresh/monitorData"); String title = String.format("/%s/%s/%s", serviceName, stationName, "data/refresh/monitorData");
webMqttComponent.publish(title, JSON.toJSONString(view3dService.getEquipStatusList(equipmentSpecific.getOrgCode()))); webMqttComponent.publish(title, JSON.toJSONString(view3dService.getEquipStatusList(equipmentSpecific.getOrgCode())));
} }
} }
private boolean indexStateIsChange(EquipmentSpecificIndexVo equipmentSpecificIndex){ private void startPlan(Equipment equipment, Toke toke, long fireEquipmentId) {
if(ObjectUtils.isEmpty(equipmentSpecificIndex.getValue())){ PlanDetailVo planDetailVo = planDetailMapper.getPlanDetailByEquipmentId(equipment.getId());
//3d页面打开且存在预案,套用之前数字源码启动逻辑 进行预案的启动
boolean isOnLine = this.getOpen3dUser();
if (planDetailVo != null && isOnLine) {
ContingencyPlanParamVo vo = new ContingencyPlanParamVo();
vo.setUserId(loginId);
//TODO 待优化为调用平台进行查询
vo.setUserName("系统用户");
vo.setFireEquipmentId(fireEquipmentId);
try {
iContingencyPlanService.planStart(vo, toke);
} catch (Exception e) {
log.error("启动预案失败", e);
}
}
}
private boolean getOpen3dUser() {
Set keys = redisTemplate.keys(IContingencyPlanService.KEY_VIEW_3D_PAGE);
return !CollectionUtils.isEmpty(keys);
}
private boolean indexStateIsChange(EquipmentSpecificIndexVo equipmentSpecificIndex) {
if (ObjectUtils.isEmpty(equipmentSpecificIndex.getValue())) {
return false; return false;
} }
String key = equipmentSpecificIndex.getIotCode()+"-"+equipmentSpecificIndex.getNameKey(); String key = equipmentSpecificIndex.getIotCode() + "-" + equipmentSpecificIndex.getNameKey();
if(redisTemplate.hasKey(key)){ if (redisTemplate.hasKey(key)) {
EquipmentSpecificIndexVo equipmentSpecificIndexVo = JSON.parseObject(redisTemplate.opsForValue().get(key).toString(), EquipmentSpecificIndexVo.class); EquipmentSpecificIndexVo equipmentSpecificIndexVo = JSON.parseObject(redisTemplate.opsForValue().get(key).toString(), EquipmentSpecificIndexVo.class);
if(equipmentSpecificIndex.getValue().equals(equipmentSpecificIndexVo.getValue())){ if (equipmentSpecificIndex.getValue().equals(equipmentSpecificIndexVo.getValue())) {
return false; return false;
} }
} }
...@@ -252,7 +271,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -252,7 +271,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
/** /**
* <pre> * <pre>
* @Description: rpn,rpni值修改 * @Description: rpn, rpni值修改
* </pre> * </pre>
* *
* @MethodName: * @MethodName:
...@@ -291,7 +310,6 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -291,7 +310,6 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
} }
@Override @Override
public void subscribeTopic() { public void subscribeTopic() {
// 若登录系统则订阅装备数据 // 若登录系统则订阅装备数据
...@@ -299,9 +317,9 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -299,9 +317,9 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
String topic = String.format("%s.%s%s", serverName, "equipment", "/#"); String topic = String.format("%s.%s%s", serverName, "equipment", "/#");
String[] strs = webMqttSubscribe.adapter.getTopic(); String[] strs = webMqttSubscribe.adapter.getTopic();
List<String> list = Stream.of(strs).collect(Collectors.toList()); List<String> list = Stream.of(strs).collect(Collectors.toList());
if(list.size() > 0) { if (list.size() > 0) {
list.forEach(x -> { list.forEach(x -> {
if(!(x.equals(topic))) { if (!(x.equals(topic))) {
webMqttSubscribe.adapter.addTopic(topic); webMqttSubscribe.adapter.addTopic(topic);
} }
}); });
...@@ -393,20 +411,19 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -393,20 +411,19 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
*/ */
// @Async // @Async
@Override @Override
public String executeDynamicPlan(AlarmParam deviceData, Equipment equipment, EquipmentSpecificForRiskVo equipmentSpecific, Toke toke,Long recordId) { public String executeDynamicPlan(AlarmParam deviceData, Equipment equipment, EquipmentSpecificForRiskVo equipmentSpecific, Toke toke, Long recordId) {
String batchNo = UUID.randomUUID().toString(); String batchNo = UUID.randomUUID().toString();
RequestContext.setToken(toke.getToke()); RequestContext.setToken(toke.getToke());
RequestContext.setProduct(toke.getProduct()); RequestContext.setProduct(toke.getProduct());
try { try {
alarmContingency(batchNo, equipmentSpecific, equipment,recordId); alarmContingency(batchNo, equipmentSpecific, equipment, recordId);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return batchNo; return batchNo;
} }
public void alarmContingency(String batchNo, EquipmentSpecificForRiskVo equipmentSpecific, Equipment equipment,Long recordId) throws Exception { public void alarmContingency(String batchNo, EquipmentSpecificForRiskVo equipmentSpecific, Equipment equipment, Long recordId) throws Exception {
// Object oldContingencyRo = redisTemplate.opsForValue().get("contingencyRo");
ContingencyRo contingencyRo = new ContingencyRo(); ContingencyRo contingencyRo = new ContingencyRo();
contingencyRo.setBatchNo(batchNo); contingencyRo.setBatchNo(batchNo);
contingencyRo.setEquipmentId(String.valueOf(equipment.getId())); contingencyRo.setEquipmentId(String.valueOf(equipment.getId()));
...@@ -422,7 +439,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -422,7 +439,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
contingencyRo.setEquipmentOrgCode(equipment.getOrgCode()); contingencyRo.setEquipmentOrgCode(equipment.getOrgCode());
//查询重点设备关联视频点位 //查询重点设备关联视频点位
Map<String,Object> cameraInfo = impAndFireEquipMapper.queryCamera(String.valueOf(equipment.getId())); Map<String, Object> cameraInfo = impAndFireEquipMapper.queryCamera(String.valueOf(equipment.getId()));
if (cameraInfo != null && !cameraInfo.isEmpty()) { if (cameraInfo != null && !cameraInfo.isEmpty()) {
contingencyRo.setCameraCodes(String.valueOf(cameraInfo.get("codes"))); contingencyRo.setCameraCodes(String.valueOf(cameraInfo.get("codes")));
contingencyRo.setCameraIds(String.valueOf(cameraInfo.get("ids"))); contingencyRo.setCameraIds(String.valueOf(cameraInfo.get("ids")));
...@@ -468,9 +485,9 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -468,9 +485,9 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
} }
contingencyRo.setTelemetryMap(telemetryMap); contingencyRo.setTelemetryMap(telemetryMap);
log.info("开始调用规则 参数 contingencyRo{},reservePlan{},equipmentNames"+contingencyRo.toString()+","+equipment.getReservePlan()+","+ ArrayUtils.toArray(equipment.getName())); log.info("开始调用规则 参数 contingencyRo{},reservePlan{},equipmentNames" + contingencyRo.toString() + "," + equipment.getReservePlan() + "," + ArrayUtils.toArray(equipment.getName()));
Object result = ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName())); Object result = ruleTrigger.publish(contingencyRo, equipment.getReservePlan(), ArrayUtils.toArray(equipment.getName()));
log.info("规则调用返回==",result); log.info("规则调用返回==", result);
ContingencyOriginalData contingencyOriginalData = new ContingencyOriginalData(); ContingencyOriginalData contingencyOriginalData = new ContingencyOriginalData();
BeanUtils.copyProperties(contingencyRo, contingencyOriginalData); BeanUtils.copyProperties(contingencyRo, contingencyOriginalData);
......
...@@ -23,14 +23,19 @@ public interface IContingencyPlanService { ...@@ -23,14 +23,19 @@ public interface IContingencyPlanService {
String DELETE_SYNC_PLAN_DOC = "DELETE_SYNC_PLAN_DOC"; String DELETE_SYNC_PLAN_DOC = "DELETE_SYNC_PLAN_DOC";
String DELETE_SYNC_PLAN_RULE = "urule/package/remove"; String DELETE_SYNC_PLAN_RULE = "urule/package/remove";
String DELETE_SYNC_PLAN_EQUIP = "DELETE_SYNC_PLAN_EQUIP"; String VIEW_3D_OPEN_STATUS = "/view/3d/page";
/**
* 3d用戶在线redis key前缀
*/
String KEY_VIEW_3D_PAGE = "KEY_VIEW_3D_PAGE_";
ContingencyPlanResponseVo planStart(ContingencyPlanParamVo vo, Toke toke) throws Exception; ContingencyPlanResponseVo planStart(ContingencyPlanParamVo vo, Toke toke) throws Exception;
ContingencyPlanParamVo equipmentScene(Long equipmentId,String riskType ); ContingencyPlanParamVo equipmentScene(Long equipmentId, String riskType);
/** /**
* 创建 * 创建
*
* @param planDetail * @param planDetail
* @return * @return
*/ */
...@@ -39,6 +44,7 @@ public interface IContingencyPlanService { ...@@ -39,6 +44,7 @@ public interface IContingencyPlanService {
/** /**
* 编辑 * 编辑
*
* @param planDetail * @param planDetail
* @return * @return
*/ */
...@@ -47,6 +53,7 @@ public interface IContingencyPlanService { ...@@ -47,6 +53,7 @@ public interface IContingencyPlanService {
/** /**
* 单个详情 * 单个详情
*
* @param id * @param id
* @return * @return
*/ */
...@@ -54,6 +61,7 @@ public interface IContingencyPlanService { ...@@ -54,6 +61,7 @@ public interface IContingencyPlanService {
/** /**
* 启用 * 启用
*
* @param idList * @param idList
* @return * @return
*/ */
...@@ -61,6 +69,7 @@ public interface IContingencyPlanService { ...@@ -61,6 +69,7 @@ public interface IContingencyPlanService {
/** /**
* 停用 * 停用
*
* @param idList * @param idList
* @return * @return
*/ */
...@@ -68,6 +77,7 @@ public interface IContingencyPlanService { ...@@ -68,6 +77,7 @@ public interface IContingencyPlanService {
/** /**
* 删除 * 删除
*
* @param idList * @param idList
* @return * @return
*/ */
...@@ -76,6 +86,7 @@ public interface IContingencyPlanService { ...@@ -76,6 +86,7 @@ public interface IContingencyPlanService {
/** /**
* 分页查询 * 分页查询
*
* @param page 分页 * @param page 分页
* @param planName 预案名称 * @param planName 预案名称
* @param classifyId 预案类型 * @param classifyId 预案类型
...@@ -89,18 +100,21 @@ public interface IContingencyPlanService { ...@@ -89,18 +100,21 @@ public interface IContingencyPlanService {
/** /**
* 查询预案使用的文档ID * 查询预案使用的文档ID
*
* @return * @return
*/ */
Map<Long, Long> getPlanUsedDocs(); Map<Long, Long> getPlanUsedDocs();
/** /**
* 查询预案使用的规则ID * 查询预案使用的规则ID
*
* @return * @return
*/ */
Map<String, Long> getPlanUsedRules(); Map<String, Long> getPlanUsedRules();
/** /**
* 查询预案使用的装备ID * 查询预案使用的装备ID
*
* @return * @return
*/ */
Map<Long, Long> getPlanUsedEquipments(); Map<Long, Long> getPlanUsedEquipments();
...@@ -112,7 +126,7 @@ public interface IContingencyPlanService { ...@@ -112,7 +126,7 @@ public interface IContingencyPlanService {
Map<String, Object> firstGetRecord(String batchNo); Map<String, Object> firstGetRecord(String batchNo);
List<HashMap<String,Object>> getRecordList(String batchNo); List<HashMap<String, Object>> getRecordList(String batchNo);
Page recordListByPage(Page page, Long planId, String planName, List<Long> classifyId, Date startTimeLeft, Date startTimeRight, Integer executionType, Integer planPattern); Page recordListByPage(Page page, Long planId, String planName, List<Long> classifyId, Date startTimeLeft, Date startTimeRight, Integer executionType, Integer planPattern);
......
package com.yeejoin.amos.fas.business.vo; package com.yeejoin.amos.fas.business.vo;
//请求参数 import lombok.Data;
/**
* @author DELL
*/
@Data
public class ContingencyPlanParamVo { public class ContingencyPlanParamVo {
public Long fireEquipmentId;
public String planId; public String planId;
public Integer status; public Integer status;
...@@ -11,44 +18,5 @@ public class ContingencyPlanParamVo { ...@@ -11,44 +18,5 @@ public class ContingencyPlanParamVo {
public String riskType; public String riskType;
public String userName; public String userName;
public String userId; public String userId;
public String getPlanId() {
return planId;
}
public void setPlanId(String planId) {
this.planId = planId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getRiskType() {
return riskType;
}
public void setRiskType(String riskType) {
this.riskType = riskType;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
} }
...@@ -24,7 +24,7 @@ public class ApplicationRunnerImpl implements ApplicationRunner { ...@@ -24,7 +24,7 @@ public class ApplicationRunnerImpl implements ApplicationRunner {
private IContingencyPlanService contingencyPlanService; private IContingencyPlanService contingencyPlanService;
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) {
equipmentHandlerService.subscribeTopic(); equipmentHandlerService.subscribeTopic();
contingencyPlanService.subscribeTopic(); contingencyPlanService.subscribeTopic();
} }
......
...@@ -121,4 +121,16 @@ ...@@ -121,4 +121,16 @@
AND equip.is_delete != 1 AND equip.is_delete != 1
AND rule.is_delete !=1 AND rule.is_delete !=1
</select> </select>
<select id="getPlanDetailByEquipmentId" resultType="com.yeejoin.amos.fas.business.vo.PlanDetailVo">
select
d.id,
d.status
from
c_plan_detail d,
c_plan_equipment e
where e.plan_id = d.id
and e.fire_equipment_id=#{fireEquipmentId}
and d.is_delete = false
limit 1
</select>
</mapper> </mapper>
\ No newline at end of file
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