Commit fbde6ca3 authored by 田涛's avatar 田涛

Merge remote-tracking branch 'origin/dev_upgrade-1225' into dev_upgrade-1225

parents 884ca37e d1db89e9
package com.yeejoin.dataprocess.common.enums; package com.yeejoin.amos.fas.common.enums;
/** /**
* @ProjectName: YeeFireDataProcessRoot * @ProjectName: YeeFireDataProcessRoot
......
package com.yeejoin.amos.fas.business.action; package com.yeejoin.amos.fas.business.action;
import java.io.IOException; import com.alibaba.fastjson.JSON;
import java.lang.reflect.Constructor; import com.alibaba.fastjson.JSONArray;
import java.lang.reflect.Field; import com.alibaba.fastjson.JSONObject;
import java.lang.reflect.Method; import com.fasterxml.jackson.databind.ObjectMapper;
import java.text.SimpleDateFormat; import com.yeejoin.amos.component.rule.MethodParam;
import java.util.ArrayList; import com.yeejoin.amos.component.rule.RuleActionBean;
import java.util.Arrays; import com.yeejoin.amos.component.rule.RuleMethod;
import java.util.Date; import com.yeejoin.amos.fas.business.action.el.ELEvaluationContext;
import java.util.HashMap; import com.yeejoin.amos.fas.business.action.model.ContingencyEvent;
import java.util.List; import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import java.util.Map; import com.yeejoin.amos.fas.business.action.model.DeviceRo;
import java.util.Optional; import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import java.util.concurrent.ConcurrentHashMap; import com.yeejoin.amos.fas.business.action.result.ActionResult;
import java.util.regex.Matcher; import com.yeejoin.amos.fas.business.action.result.SafteyPlanResult;
import java.util.regex.Pattern; import com.yeejoin.amos.fas.business.action.result.message.AbstractActionResultMessage;
import com.yeejoin.amos.fas.business.action.util.ContingencyLogPublisher;
import org.slf4j.Logger; import com.yeejoin.amos.fas.business.dao.repository.IPlanDetailDao;
import org.slf4j.LoggerFactory; import com.yeejoin.amos.fas.business.dao.repository.IPlanOperationRecordDao;
import org.springframework.beans.factory.annotation.Autowired; import com.yeejoin.amos.fas.business.feign.IDutyModeServer;
import org.springframework.beans.factory.annotation.Value; import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import org.springframework.data.redis.core.RedisTemplate; import com.yeejoin.amos.fas.business.service.impl.RuleRunigSnapshotServiceImpl;
import org.springframework.stereotype.Component; import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance;
import org.springframework.util.CollectionUtils; import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService;
import org.springframework.util.ObjectUtils; import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService;
import org.typroject.tyboot.core.foundation.context.RequestContext; import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import com.alibaba.fastjson.JSON; import com.yeejoin.amos.fas.business.util.CacheFactory;
import com.alibaba.fastjson.JSONArray; import com.yeejoin.amos.fas.business.util.CacheMap;
import com.alibaba.fastjson.JSONObject; import com.yeejoin.amos.fas.business.vo.Toke;
import com.fasterxml.jackson.databind.ObjectMapper; import com.yeejoin.amos.fas.common.enums.ContingencyPlanStatusEnum;
import com.yeejoin.amos.component.rule.MethodParam; import com.yeejoin.amos.fas.common.enums.PlanRecordStatusEnum;
import com.yeejoin.amos.component.rule.RuleActionBean; import com.yeejoin.amos.fas.core.enums.NumberEnum;
import com.yeejoin.amos.component.rule.RuleMethod; import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.business.action.el.ELEvaluationContext; import com.yeejoin.amos.fas.core.util.DateUtil;
import com.yeejoin.amos.fas.business.action.model.ContingencyEvent; import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo; import com.yeejoin.amos.fas.dao.entity.Equipment;
import com.yeejoin.amos.fas.business.action.model.DeviceRo; import com.yeejoin.amos.fas.dao.entity.PlanDetail;
import com.yeejoin.amos.fas.business.action.model.SetpEnum; import com.yeejoin.amos.fas.dao.entity.PlanOperationRecord;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent; import org.slf4j.Logger;
import com.yeejoin.amos.fas.business.action.result.ActionResult; import org.slf4j.LoggerFactory;
import com.yeejoin.amos.fas.business.action.result.SafteyPlanResult; import org.springframework.beans.factory.annotation.Autowired;
import com.yeejoin.amos.fas.business.action.result.message.AbstractActionResultMessage; import org.springframework.beans.factory.annotation.Value;
import com.yeejoin.amos.fas.business.action.util.ContingencyLogPublisher; import org.springframework.data.redis.core.RedisTemplate;
import com.yeejoin.amos.fas.business.dao.repository.IPlanDetailDao; import org.springframework.stereotype.Component;
import com.yeejoin.amos.fas.business.dao.repository.IPlanOperationRecordDao; import org.springframework.util.CollectionUtils;
import com.yeejoin.amos.fas.business.feign.IDutyModeServer; import org.springframework.util.ObjectUtils;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService; import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.yeejoin.amos.fas.business.service.impl.RuleRunigSnapshotServiceImpl;
import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance; import java.io.IOException;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService; import java.lang.reflect.Constructor;
import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService; import java.lang.reflect.Field;
import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus; import java.lang.reflect.Method;
import com.yeejoin.amos.fas.business.service.model.ToipResponse; import java.text.SimpleDateFormat;
import com.yeejoin.amos.fas.business.util.CacheFactory; import java.util.*;
import com.yeejoin.amos.fas.business.util.CacheMap; import java.util.concurrent.ConcurrentHashMap;
import com.yeejoin.amos.fas.business.vo.Toke; import java.util.regex.Matcher;
import com.yeejoin.amos.fas.common.enums.ContingencyPlanStatusEnum; import java.util.regex.Pattern;
import com.yeejoin.amos.fas.common.enums.PlanRecordStatusEnum;
import com.yeejoin.amos.fas.core.enums.NumberEnum; //import com.yeejoin.amos.fas.business.service.intfc.FireStengthService;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.DateUtil; @Component
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance; @RuleActionBean(beanLabel = "动态预案" )
import com.yeejoin.amos.fas.dao.entity.Equipment; public class ContingencyAction implements CustomerAction {
import com.yeejoin.amos.fas.dao.entity.PlanDetail;
import com.yeejoin.amos.fas.dao.entity.PlanOperationRecord;
private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message.";
//import com.yeejoin.amos.fas.business.service.intfc.FireStengthService;
public static final Logger log = LoggerFactory.getLogger(ContingencyAction.class);
@Component
@RuleActionBean(beanLabel = "动态预案" ) @Autowired
public class ContingencyAction implements CustomerAction { private WebMqttComponent webMqttComponent;
@Value("${auto-sys.push.type}")
private static String PACKAGEURL = "com.yeejoin.amos.fas.business.action.result.message."; private String pushType;
@Value("${spring.application.name}")
public static final Logger log = LoggerFactory.getLogger(ContingencyAction.class); private String serviceName;
@Autowired @Value("${station.name}")
private WebMqttComponent webMqttComponent; private String stationName;
@Value("${auto-sys.push.type}") @Autowired
private String pushType; private IContingencyInstance iContingencyInstance;
@Value("${spring.application.name}")
private String serviceName; // @Autowired
// private FireStengthService fireStrengthService;
@Value("${station.name}") @Autowired
private String stationName; private ContingencyLogPublisher contingencyLogPublisher;
@Autowired @Autowired
private IContingencyInstance iContingencyInstance; private IRiskSourceService riskSourceService;
// @Autowired @Autowired
// private FireStengthService fireStrengthService; private IDutyModeServer dutyModeServer;
@Autowired
private ContingencyLogPublisher contingencyLogPublisher; @Autowired
private IEquipmentService equipmentService;
@Autowired
private IRiskSourceService riskSourceService; @Autowired
private RedisTemplate redisTemplate;
@Autowired
private IDutyModeServer dutyModeServer; private static Map<String, String> OPERATE_RECORD_ID = new HashMap<>();
@Autowired private static Map<String, Map<String, String>> stringStringMap = new HashMap<>();
private IEquipmentService equipmentService; static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
@Autowired public static ConcurrentHashMap<String, Map<String, Object>> pointCache = new ConcurrentHashMap<>();
private RedisTemplate redisTemplate;
private static Map<String, String> OPERATE_RECORD_ID = new HashMap<>(); private static CacheMap cacheMap = CacheFactory.newChacheMap();
private static final String TOKE = "TOKE";
private static Map<String, Map<String, String>> stringStringMap = new HashMap<>(); @Autowired
static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); private RemoteSecurityService remoteSecurityService;
public static ConcurrentHashMap<String, Map<String, Object>> pointCache = new ConcurrentHashMap<>(); @Autowired
private IPlanDetailDao planDetailDao;
@Autowired
private static CacheMap cacheMap = CacheFactory.newChacheMap(); private IPlanOperationRecordDao planOperationRecordDao;
private static final String TOKE = "TOKE"; //当值值班长(S1)、副值班长(S2)、值班员(A1,A2,A3)、白班值班员、保安人员、驻站消防队长(F1)
@Autowired /* private static Map<String, String> positionMap = new HashMap<String, String>() {{
private RemoteSecurityService remoteSecurityService; put("S1", "S1");
put("S2", "S2");
@Autowired put("A1", "A1");
private IPlanDetailDao planDetailDao; put("A2", "A2");
@Autowired put("A3", "A3");
private IPlanOperationRecordDao planOperationRecordDao; put("F1", "F1");
//当值值班长(S1)、副值班长(S2)、值班员(A1,A2,A3)、白班值班员、保安人员、驻站消防队长(F1) }};
/* private static Map<String, String> positionMap = new HashMap<String, String>() {{ */
put("S1", "S1");
put("S2", "S2"); /**
put("A1", "A1"); * 预案文件中值为和数据字典中的对应关系
put("A2", "A2"); * 消防
put("A3", "A3"); * F1 消防队长 fireLeader
put("F1", "F1"); * F2..F6 队员 firePerson 规则配置中队员1...6:firePerson1...firePerson6
}}; * FD .... 司机 fireDriver 规则配置中司机 1..6:fireDriver1...fireDriver6
*/ * 运维
* S1 值班长 dutyLeader
/** * S2 副值班长 deputyDutyLeader
* 预案文件中值为和数据字典中的对应关系 * B1..B6 值班员 dutyCivilian 规则配置中值班员1...6:dutyCivilian1...dutyCivilian6
* 消防 * A1...A6 副值班员 deputyDutyCivilian 规则配置中副值班员1...6:deputyDutyCivilian1...deputyDutyCivilian6
* F1 消防队长 fireLeader */
* F2..F6 队员 firePerson 规则配置中队员1...6:firePerson1...firePerson6
* FD .... 司机 fireDriver 规则配置中司机 1..6:fireDriver1...fireDriver6 public Map<String, String> getStrengthMap(ContingencyRo contingencyRo) {
* 运维 String batchNo = contingencyRo.getBatchNo();
* S1 值班长 dutyLeader String orgCode = contingencyRo.getEquipmentOrgCode();
* S2 副值班长 deputyDutyLeader Map<String, String> returnMap = stringStringMap.get(contingencyRo.getBatchNo());
* B1..B6 值班员 dutyCivilian 规则配置中值班员1...6:dutyCivilian1...dutyCivilian6 if (CollectionUtils.isEmpty(returnMap)) {
* A1...A6 副值班员 deputyDutyCivilian 规则配置中副值班员1...6:deputyDutyCivilian1...deputyDutyCivilian6 stringStringMap = new HashMap<>();
*/ returnMap = new HashMap<>();
public Map<String, String> getStrengthMap(ContingencyRo contingencyRo) { Date curDate = new Date();
String batchNo = contingencyRo.getBatchNo(); JSONObject param = new JSONObject();
String orgCode = contingencyRo.getEquipmentOrgCode(); param.put("dutyDate", curDate);
Map<String, String> returnMap = stringStringMap.get(contingencyRo.getBatchNo()); Toke toke = remoteSecurityService.getServerToken();
if (CollectionUtils.isEmpty(returnMap)) { CommonResponse commonResponse = dutyModeServer.dutyListByDate(toke.getAppKey(), toke.getProduct(), toke.getToke(), orgCode, param.toJSONString());
stringStringMap = new HashMap<>();
returnMap = new HashMap<>(); // String result = HttpUtil.appendPostJson("duty/dutyListByDate", param.toJSONString());
// JSONObject jsonObject = JSONObject.parseObject(result);
Date curDate = new Date(); // JSONArray dataList = JSONObject.parseObject(commonResponse.getDataList().toString());
JSONObject param = new JSONObject();
param.put("dutyDate", curDate);
Toke toke = remoteSecurityService.getServerToken(); String JSONStr = JSON.toJSONString(commonResponse.getDataList());
CommonResponse commonResponse = dutyModeServer.dutyListByDate(toke.getAppKey(), toke.getProduct(), toke.getToke(), orgCode, param.toJSONString()); JSONArray dataList = JSONObject.parseArray(JSONStr);
log.info(String.format("请求值班系统返回dataList:%s", dataList));
// String result = HttpUtil.appendPostJson("duty/dutyListByDate", param.toJSONString());
// JSONObject jsonObject = JSONObject.parseObject(result); if (!ObjectUtils.isEmpty(dataList)) {
// JSONArray dataList = JSONObject.parseObject(commonResponse.getDataList().toString()); Map<String, String> finalReturnMap = returnMap;
dataList.forEach(
x -> {
String JSONStr = JSON.toJSONString(commonResponse.getDataList()); JSONObject obj = (JSONObject) x;
JSONArray dataList = JSONObject.parseArray(JSONStr); String name = obj.getString("position");
log.info(String.format("请求值班系统返回dataList:%s", dataList)); finalReturnMap.put(name, obj.getString("dutyName"));
}
if (!ObjectUtils.isEmpty(dataList)) { );
Map<String, String> finalReturnMap = returnMap; }
dataList.forEach( stringStringMap.put(batchNo, returnMap);
x -> { }
JSONObject obj = (JSONObject) x; log.info(String.format("returnMap:【 %s 】", returnMap));
String name = obj.getString("position"); return returnMap;
finalReturnMap.put(name, obj.getString("dutyName")); }
}
); /**
} * @param stepCode 当前步骤编号
stringStringMap.put(batchNo, returnMap); * @param stepName 当前步骤名称
} * @param nextStepCode 下一步编号
log.info(String.format("returnMap:【 %s 】", returnMap)); * @param nextStepName 下一步名称
return returnMap; * @param paramObj 预案对象
} */
@RuleMethod(methodLabel = "步骤更新(新)", project = "换流站消防专项预案")
/** public void stepInfoNew(@MethodParam(paramLabel = "当前步骤编号") String stepCode,
* @param stepCode 当前步骤编号 @MethodParam(paramLabel = "当前步骤名称") String stepName,
* @param stepName 当前步骤名称 @MethodParam(paramLabel = "下一步编号") String nextStepCode,
* @param nextStepCode 下一步编号 @MethodParam(paramLabel = "下一步名称") String nextStepName,
* @param nextStepName 下一步名称 @MethodParam(paramLabel = "对象") Object paramObj) {
* @param paramObj 预案对象 ContingencyRo contingencyRo = (ContingencyRo) paramObj;
*/ stopSnapshop(contingencyRo);
@RuleMethod(methodLabel = "步骤更新(新)", project = "换流站消防专项预案")
public void stepInfoNew(@MethodParam(paramLabel = "当前步骤编号") String stepCode, SafteyPlanResult result = new SafteyPlanResult();
@MethodParam(paramLabel = "当前步骤名称") String stepName, Map<String, Object> tempmap1 = new HashMap<>();
@MethodParam(paramLabel = "下一步编号") String nextStepCode, ArrayList list = new ArrayList();
@MethodParam(paramLabel = "下一步名称") String nextStepName, HashMap step = new HashMap();
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; step.put("stepCode", stepCode);
stopSnapshop(contingencyRo); step.put("stepName", stepName);
SafteyPlanResult result = new SafteyPlanResult(); HashMap nextmap = new HashMap();
Map<String, Object> tempmap1 = new HashMap<>(); nextmap.put("stepCode", nextStepCode);
ArrayList list = new ArrayList(); nextmap.put("stepName", nextStepName);
HashMap step = new HashMap(); list.add(step);
list.add(nextmap);
step.put("stepCode", stepCode);
step.put("stepName", stepName); tempmap1.put("step", list);
tempmap1.put("preStep", new HashMap());
HashMap nextmap = new HashMap(); result.add(tempmap1);
nextmap.put("stepCode", nextStepCode); log.info("步骤更新(new)" + JSONObject.toJSONString(result));
nextmap.put("stepName", nextStepName); this.sendcmd("steparea", contingencyRo, result);
list.add(step); }
list.add(nextmap);
/**
tempmap1.put("step", list); * @param stepCode 当前步骤编号
tempmap1.put("preStep", new HashMap()); * @param paramObj 预案对象
result.add(tempmap1); */
log.info("步骤更新(new)" + JSONObject.toJSONString(result)); @RuleMethod(methodLabel = "步骤更新", project = "换流站消防专项预案")
this.sendcmd("steparea", contingencyRo, result); public void stepInfo(@MethodParam(paramLabel = "当前编号") String stepCode,
} @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
/** stopSnapshop(contingencyRo);
* @param stepCode 当前步骤编号
* @param paramObj 预案对象 SafteyPlanResult result = new SafteyPlanResult();
*/ // Map<String, Object> tempmap1 = new HashMap<>();
@RuleMethod(methodLabel = "步骤更新", project = "换流站消防专项预案") // SetpEnum[] stepArr = SetpEnum.values();
public void stepInfo(@MethodParam(paramLabel = "当前编号") String stepCode, // ArrayList list = new ArrayList();
@MethodParam(paramLabel = "对象") Object paramObj) { // HashMap preStep = new HashMap();
ContingencyRo contingencyRo = (ContingencyRo) paramObj; // StepComparator comparator = new StepComparator();
stopSnapshop(contingencyRo); // Arrays.sort(stepArr, comparator);
//
SafteyPlanResult result = new SafteyPlanResult(); // boolean flage = false;
// Map<String, Object> tempmap1 = new HashMap<>(); // SetpEnum pstep = null;
// SetpEnum[] stepArr = SetpEnum.values(); // for (SetpEnum step : stepArr) {
// ArrayList list = new ArrayList(); // if (Long.valueOf(step.getValue()) == Long.valueOf(stepCode)) {
// HashMap preStep = new HashMap(); // if (!ObjectUtils.isEmpty(pstep)) {
// StepComparator comparator = new StepComparator(); // preStep.put("stepCode", pstep.getValue());
// Arrays.sort(stepArr, comparator); // preStep.put("stepName", pstep.getTitle());
// // }
// boolean flage = false; // flage = true;
// SetpEnum pstep = null; // }
// for (SetpEnum step : stepArr) { // if (flage) {
// if (Long.valueOf(step.getValue()) == Long.valueOf(stepCode)) { // HashMap map = new HashMap();
// if (!ObjectUtils.isEmpty(pstep)) { // map.put("stepCode", step.getValue());
// preStep.put("stepCode", pstep.getValue()); // map.put("stepName", step.getTitle());
// preStep.put("stepName", pstep.getTitle()); // list.add(map);
// } // }
// flage = true; // pstep = step;
// } // }
// if (flage) { //
// HashMap map = new HashMap(); // tempmap1.put("step", list);
// map.put("stepCode", step.getValue()); // tempmap1.put("preStep", preStep);
// map.put("stepName", step.getTitle()); // result.add(tempmap1);
// list.add(map); // log.info("巡检消息发送规则" + JSONObject.toJSONString(result));
// } this.sendcmd("steparea", contingencyRo, result);
// pstep = step; }
// }
//
// tempmap1.put("step", list);
// tempmap1.put("preStep", preStep);
// result.add(tempmap1); public void sendcmd(String msgType, Object contingency, SafteyPlanResult result) {
// log.info("巡检消息发送规则" + JSONObject.toJSONString(result)); ContingencyRo ro = (ContingencyRo)contingency;
this.sendcmd("steparea", contingencyRo, result); ro.setTelemetryMap(null);
} ro.setTelesignallingMap(null);
Constructor<?> constructor;
try {
constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
public void sendcmd(String msgType, Object contingency, SafteyPlanResult result) { .getConstructor(ActionResult.class);
ContingencyRo ro = (ContingencyRo)contingency; AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
ro.setTelemetryMap(null); if ("mqtt".equals(pushType.toLowerCase())) {
ro.setTelesignallingMap(null); ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson());
Constructor<?> constructor; String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan");
try { log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
constructor = Class.forName( webMqttComponent.publish(topic, toipResponse.toJsonStr());
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class); ContingencyEvent event = new ContingencyEvent(this);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result); event.setMsgBody(toipResponse.toJsonStr());
if ("mqtt".equals(pushType.toLowerCase())) { event.setTopic(topic);
ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson()); event.setMsgType(msgType);
String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan"); event.setContingency(contingency);
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr())); contingencyLogPublisher.publish(event);
webMqttComponent.publish(topic, toipResponse.toJsonStr()); } else if ("websocket".equals(pushType.toLowerCase())){
action.execute(msgType, contingency);
ContingencyEvent event = new ContingencyEvent(this); }
event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic); } catch (Exception e) {
event.setMsgType(msgType); e.printStackTrace();
event.setContingency(contingency); }
contingencyLogPublisher.publish(event); }
} else if ("websocket".equals(pushType.toLowerCase())){
action.execute(msgType, contingency); public void sendweb(String msgType, Object contingency, SafteyPlanResult result) {
} ContingencyRo ro = (ContingencyRo)contingency;
ro.setTelemetryMap(null);
} catch (Exception e) { ro.setTelesignallingMap(null);
e.printStackTrace(); Constructor<?> constructor;
} try {
} constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
public void sendweb(String msgType, Object contingency, SafteyPlanResult result) { .getConstructor(ActionResult.class);
ContingencyRo ro = (ContingencyRo)contingency; AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
ro.setTelemetryMap(null); ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson());
ro.setTelesignallingMap(null); String topic = String.format("/%s/%s/%s", serviceName, stationName,"numberPlan");
Constructor<?> constructor; log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
try { webMqttComponent.publish(topic, toipResponse.toJsonStr());
constructor = Class.forName( ContingencyEvent event = new ContingencyEvent(this);
PACKAGEURL + result.getClass().getSimpleName() + "Message") event.setMsgBody(toipResponse.toJsonStr());
.getConstructor(ActionResult.class); event.setTopic(topic);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result); event.setMsgType(msgType);
ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson()); event.setContingency(contingency);
String topic = String.format("/%s/%s/%s", serviceName, stationName,"numberPlan"); contingencyLogPublisher.publish(event);
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr()); } catch (Exception e) {
ContingencyEvent event = new ContingencyEvent(this); e.printStackTrace();
event.setMsgBody(toipResponse.toJsonStr()); }
event.setTopic(topic); }
event.setMsgType(msgType); /**
event.setContingency(contingency); * @param stepCode 当前步骤编号
contingencyLogPublisher.publish(event); * @param paramObj 预案对象
*/
} catch (Exception e) { @RuleMethod(methodLabel = "步骤更新保存", project = "换流站消防专项预案")
e.printStackTrace(); public void saveStepInfo(@MethodParam(paramLabel = "当前编号") String stepCode, @MethodParam(paramLabel = "对象") Object paramObj) {
} ContingencyRo contingencyRo = (ContingencyRo) paramObj;
} iContingencyInstance.updateStep(stepCode, contingencyRo.getBatchNo());
/** }
* @param stepCode 当前步骤编号
* @param paramObj 预案对象
*/ /**
@RuleMethod(methodLabel = "步骤更新保存", project = "换流站消防专项预案") * @param content 消息内容
public void saveStepInfo(@MethodParam(paramLabel = "当前编号") String stepCode, @MethodParam(paramLabel = "对象") Object paramObj) { * @param paramObj 预案对象
ContingencyRo contingencyRo = (ContingencyRo) paramObj; */
iContingencyInstance.updateStep(stepCode, contingencyRo.getBatchNo()); @RuleMethod(methodLabel = "执行记录", project = "换流站消防专项预案")
} public void messageRecord(@MethodParam(paramLabel = "消息内容") String content, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
/** //转换content中的变量
* @param content 消息内容 content = instedParams(content, contingencyRo);
* @param paramObj 预案对象 iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", content, "MESSAGE", "");
*/
@RuleMethod(methodLabel = "执行记录", project = "换流站消防专项预案") SafteyPlanResult result = new SafteyPlanResult();
public void messageRecord(@MethodParam(paramLabel = "消息内容") String content, @MethodParam(paramLabel = "对象") Object paramObj) { Map<String, Object> tempmap1 = new HashMap<>();
ContingencyRo contingencyRo = (ContingencyRo) paramObj; try {
stopSnapshop(contingencyRo); SimpleDateFormat sdf = new SimpleDateFormat("YYYY/MM/DD HH:mm:ss");
//转换content中的变量 List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
content = instedParams(content, contingencyRo); ArrayList records = new ArrayList<>();
iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", content, "MESSAGE", ""); if (!ObjectUtils.isEmpty(list)) {
list.forEach(action -> {
SafteyPlanResult result = new SafteyPlanResult(); HashMap map = new HashMap();
Map<String, Object> tempmap1 = new HashMap<>(); map.put("time", sdf.format(action.getCreateDate()));
try { map.put("stepName", action.getContent());
SimpleDateFormat sdf = new SimpleDateFormat("YYYY/MM/DD HH:mm:ss"); records.add(map);
List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE"); });
ArrayList records = new ArrayList<>(); }
if (!ObjectUtils.isEmpty(list)) { tempmap1.put("content", records);
list.forEach(action -> { tempmap1.put("status",PlanRecordStatusEnum.OPERATION.getCode());
HashMap map = new HashMap(); } catch (Exception e) {
map.put("time", sdf.format(action.getCreateDate())); // TODO Auto-generated catch block
map.put("stepName", action.getContent()); e.printStackTrace();
records.add(map); }
}); result.add(tempmap1);
} System.out.println("--------------------messageRecord----------------------"+result);
tempmap1.put("content", records); this.sendcmd("recordarea", paramObj, result);
tempmap1.put("status",PlanRecordStatusEnum.OPERATION.getCode()); this.sendweb("recordarea", paramObj, result);
} catch (Exception e) { }
// TODO Auto-generated catch block
e.printStackTrace(); /**
} * <pre>
result.add(tempmap1); * 智能辅助
System.out.println("--------------------messageRecord----------------------"+result); * </pre>
this.sendcmd("recordarea", paramObj, result); *
this.sendweb("recordarea", paramObj, result); * @param step 当前步骤
} * @param icon 图标
* @param title 标题
/** * @param image 图片集合
* <pre> * @param table 表格
* 智能辅助 * @param content 内容
* </pre> * @param paramObj 预案对象
* */
* @param step 当前步骤 @RuleMethod(methodLabel = "智能辅助", project = "换流站消防专项预案")
* @param icon 图标 public void help(@MethodParam(paramLabel = "当前步骤") String step,
* @param title 标题 @MethodParam(paramLabel = "图标")String icon,
* @param image 图片集合 @MethodParam(paramLabel = "标题")String title,
* @param table 表格 @MethodParam(paramLabel = "图片集") String image,
* @param content 内容 @MethodParam(paramLabel = "表格数据") String table,
* @param paramObj 预案对象 @MethodParam(paramLabel = "文本内容") String content,
*/ @MethodParam(paramLabel = "对象") Object paramObj) {
@RuleMethod(methodLabel = "智能辅助", project = "换流站消防专项预案") ContingencyRo contingencyRo = (ContingencyRo) paramObj;
public void help(@MethodParam(paramLabel = "当前步骤") String step, stopSnapshop(contingencyRo);
@MethodParam(paramLabel = "图标")String icon,
@MethodParam(paramLabel = "标题")String title, //转换智能辅助中的变量
@MethodParam(paramLabel = "图片集") String image, content = instedParams(content, contingencyRo);
@MethodParam(paramLabel = "表格数据") String table,
@MethodParam(paramLabel = "文本内容") String content, SafteyPlanResult result = new SafteyPlanResult();
@MethodParam(paramLabel = "对象") Object paramObj) { Map<String, Object> tempmap1 = new HashMap<>();
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo); tempmap1.put("icon", icon);
tempmap1.put("step", step);
//转换智能辅助中的变量 tempmap1.put("title", title);
content = instedParams(content, contingencyRo); tempmap1.put("content", content);
tempmap1.put("image", image);
SafteyPlanResult result = new SafteyPlanResult(); tempmap1.put("table", table);
Map<String, Object> tempmap1 = new HashMap<>(); // tempmap1.put("batchNo", contingencyRo.getBatchNo());
// tempmap1.put("contingencyRo", contingencyRo);
tempmap1.put("icon", icon); result.add(tempmap1);
tempmap1.put("step", step);
tempmap1.put("title", title); this.sendcmd("helparea", paramObj, result);
tempmap1.put("content", content); }
tempmap1.put("image", image);
tempmap1.put("table", table);
// tempmap1.put("batchNo", contingencyRo.getBatchNo()); private String instedParams(String content, ContingencyRo contingencyRo) {
// tempmap1.put("contingencyRo", contingencyRo);
result.add(tempmap1); Map<String, String> strengthMap = this.getStrengthMap(contingencyRo);
for (String key : strengthMap.keySet())
this.sendcmd("helparea", paramObj, result); content = content.replaceAll("\\$\\{" + key + "}", strengthMap.get(key));
}
Field[] fields = contingencyRo.getClass().getDeclaredFields();
Method getMethod = null;
private String instedParams(String content, ContingencyRo contingencyRo) { try {
for (Field field : fields) {
Map<String, String> strengthMap = this.getStrengthMap(contingencyRo); if (field.getName().equals("serialVersionUID"))
for (String key : strengthMap.keySet()) continue;
content = content.replaceAll("\\$\\{" + key + "}", strengthMap.get(key)); String fileNameInMethod = String.valueOf(field.getName().charAt(0)).toUpperCase() + field.getName().substring(1);
getMethod = contingencyRo.getClass().getMethod("get" + fileNameInMethod);
Field[] fields = contingencyRo.getClass().getDeclaredFields(); String value = String.valueOf(getMethod.invoke(contingencyRo));
Method getMethod = null; content = content.replaceAll("\\$\\{" + field.getName() + "}", value);
try { }
for (Field field : fields) {
if (field.getName().equals("serialVersionUID")) content = getNative(content);
continue; } catch (Exception e) {
String fileNameInMethod = String.valueOf(field.getName().charAt(0)).toUpperCase() + field.getName().substring(1); e.printStackTrace();
getMethod = contingencyRo.getClass().getMethod("get" + fileNameInMethod); }
String value = String.valueOf(getMethod.invoke(contingencyRo)); return content;
content = content.replaceAll("\\$\\{" + field.getName() + "}", value); }
}
public String getNative(String str)
content = getNative(content); {
} catch (Exception e) { Pattern p = Pattern.compile("\\$\\{(.*?)\\}");
e.printStackTrace(); Matcher m = p.matcher(str);
} while (m.find())
return content; {
} String parameter = m.group();
public String getNative(String str) Object parametervalue = ELEvaluationContext
{ .getValue(parameter.substring(1, parameter.length() - 1));
Pattern p = Pattern.compile("\\$\\{(.*?)\\}"); if(parametervalue != null)
Matcher m = p.matcher(str); str = str.replace(parameter,
while (m.find()) parametervalue != null ? parametervalue.toString() : null);
{ }
String parameter = m.group(); return str;
}
Object parametervalue = ELEvaluationContext
.getValue(parameter.substring(1, parameter.length() - 1)); /**
if(parametervalue != null) * 交互动作
str = str.replace(parameter, *
parametervalue != null ? parametervalue.toString() : null); * @param actionName 动作名称
} * @param icon 图标
return str; * @param tips 提示信息
} * @param buttonJson 按钮json字符串
* @param paramObj 预案对象
/** */
* 交互动作 @RuleMethod(methodLabel = "交互动作", project = "换流站消防专项预案")
* public void operation(@MethodParam(paramLabel = "动作名称") String actionName,
* @param actionName 动作名称 @MethodParam(paramLabel = "图标") String icon,
* @param icon 图标 @MethodParam(paramLabel = "提示信息") String tips,
* @param tips 提示信息 @MethodParam(paramLabel = "按钮json字符串") String buttonJson,
* @param buttonJson 按钮json字符串 @MethodParam(paramLabel = "预案对象") Object paramObj) {
* @param paramObj 预案对象 ContingencyRo contingencyRo = (ContingencyRo) paramObj;
*/ stopSnapshop(contingencyRo);
@RuleMethod(methodLabel = "交互动作", project = "换流站消防专项预案")
public void operation(@MethodParam(paramLabel = "动作名称") String actionName, //转换content中的变量
@MethodParam(paramLabel = "图标") String icon, tips = instedParams(tips, contingencyRo);
@MethodParam(paramLabel = "提示信息") String tips,
@MethodParam(paramLabel = "按钮json字符串") String buttonJson,
@MethodParam(paramLabel = "预案对象") Object paramObj) { SafteyPlanResult result = new SafteyPlanResult();
ContingencyRo contingencyRo = (ContingencyRo) paramObj; Map<String, Object> tempmap1 = new HashMap<>();
stopSnapshop(contingencyRo);
//转换content中的变量 String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson);
tips = instedParams(tips, contingencyRo);
tempmap1.put("actionName", actionName);
tempmap1.put("icon", icon);
SafteyPlanResult result = new SafteyPlanResult(); tempmap1.put("tips", tips);
Map<String, Object> tempmap1 = new HashMap<>(); tempmap1.put("button", buttonJson);
tempmap1.put("caseId", contingencyPlanId);
result.add(tempmap1);
String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson);
this.sendcmd("optionarea", paramObj, result);
tempmap1.put("actionName", actionName);
tempmap1.put("icon", icon); }
tempmap1.put("tips", tips);
tempmap1.put("button", buttonJson);
tempmap1.put("caseId", contingencyPlanId); private boolean sendButton(String batchNo, String contingencyPlanId, String equipmentId, String actionName, String buttonJson) {
result.add(tempmap1);
this.sendcmd("optionarea", paramObj, result); ObjectMapper objectMapper = new ObjectMapper();
} /**
* batchNo
* stepCode
private boolean sendButton(String batchNo, String contingencyPlanId, String equipmentId, String actionName, String buttonJson) { * buttonCode
* confirm
* contingencyPlanId
ObjectMapper objectMapper = new ObjectMapper(); * stepState
*/
/**
* batchNo try {
* stepCode Map button = objectMapper.readValue(buttonJson, Map.class);
* buttonCode Map operateInstance = (Map) ((List) button.get("operate")).get(0);
* confirm ContingencyDeviceStatus contingencyDeviceStatus = new ContingencyDeviceStatus();
* contingencyPlanId contingencyDeviceStatus.setActionName(actionName);
* stepState contingencyDeviceStatus.setButtonCode(String.valueOf(operateInstance.get("code")));
*/ contingencyDeviceStatus.setConfirm("CONFIRM");
contingencyDeviceStatus.setContingencyPlanId(contingencyPlanId);
try { contingencyDeviceStatus.setEquipmentId(equipmentId);
Map button = objectMapper.readValue(buttonJson, Map.class); contingencyDeviceStatus.setStepCode(String.valueOf(button.get("stepCode")));
Map operateInstance = (Map) ((List) button.get("operate")).get(0); contingencyDeviceStatus.setStepState(String.valueOf(operateInstance.get("stepState")));
ContingencyDeviceStatus contingencyDeviceStatus = new ContingencyDeviceStatus(); riskSourceService.queryContingencyDeviceStatus(contingencyDeviceStatus);
contingencyDeviceStatus.setActionName(actionName);
contingencyDeviceStatus.setButtonCode(String.valueOf(operateInstance.get("code"))); } catch (IOException e) {
contingencyDeviceStatus.setConfirm("CONFIRM"); e.printStackTrace();
contingencyDeviceStatus.setContingencyPlanId(contingencyPlanId); }
contingencyDeviceStatus.setEquipmentId(equipmentId);
contingencyDeviceStatus.setStepCode(String.valueOf(button.get("stepCode"))); return false;
contingencyDeviceStatus.setStepState(String.valueOf(operateInstance.get("stepState"))); }
riskSourceService.queryContingencyDeviceStatus(contingencyDeviceStatus);
} catch (IOException e) { /**
e.printStackTrace(); * 保存交互动作
} *
* @param actionName 动作名称
return false; * @param icon 图标
} * @param tips 提示信息
* @param buttonJson 按钮json字符串
* @param paramObj 预案对象
/** */
* 保存交互动作 @RuleMethod(methodLabel = "保存交互动作", project = "换流站消防专项预案")
* public void saveOperation(@MethodParam(paramLabel = "动作名称") String actionName,
* @param actionName 动作名称 @MethodParam(paramLabel = "图标") String icon,
* @param icon 图标 @MethodParam(paramLabel = "提示信息") String tips,
* @param tips 提示信息 @MethodParam(paramLabel = "按钮json字符串") String buttonJson,
* @param buttonJson 按钮json字符串 @MethodParam(paramLabel = "对象") Object paramObj) {
* @param paramObj 预案对象
*/ ContingencyRo contingencyRo = (ContingencyRo) paramObj;
@RuleMethod(methodLabel = "保存交互动作", project = "换流站消防专项预案") stopSnapshop(contingencyRo);
public void saveOperation(@MethodParam(paramLabel = "动作名称") String actionName,
@MethodParam(paramLabel = "图标") String icon, //转换content中的变量
@MethodParam(paramLabel = "提示信息") String tips, SafteyPlanResult result = new SafteyPlanResult();
@MethodParam(paramLabel = "按钮json字符串") String buttonJson, Map<String, Object> tempmap1 = new HashMap<>();
@MethodParam(paramLabel = "对象") Object paramObj) { try {
SimpleDateFormat sdf = new SimpleDateFormat("YYYY/MM/DD HH:mm:ss");
ContingencyRo contingencyRo = (ContingencyRo) paramObj; List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
stopSnapshop(contingencyRo); ArrayList records = new ArrayList<>();
if (!ObjectUtils.isEmpty(list)) {
//转换content中的变量 list.forEach(action -> {
SafteyPlanResult result = new SafteyPlanResult(); HashMap map = new HashMap();
Map<String, Object> tempmap1 = new HashMap<>(); map.put("time", sdf.format(action.getCreateDate()));
try { map.put("stepName", action.getContent());
SimpleDateFormat sdf = new SimpleDateFormat("YYYY/MM/DD HH:mm:ss"); records.add(map);
List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE"); });
ArrayList records = new ArrayList<>(); }
if (!ObjectUtils.isEmpty(list)) { tempmap1.put("content", records);
list.forEach(action -> { } catch (Exception e) {
HashMap map = new HashMap(); // TODO Auto-generated catch block
map.put("time", sdf.format(action.getCreateDate())); e.printStackTrace();
map.put("stepName", action.getContent()); }
records.add(map); result.add(tempmap1);
}); System.out.println("--------------------saveOperation----------------------"+result);
} this.sendcmd("recordarea", paramObj, result);
tempmap1.put("content", records); }
} catch (Exception e) {
// TODO Auto-generated catch block private String getContingencyPlanId(String batchNo, String actionName, String icon, String tips, String buttonJson) {
e.printStackTrace(); String cacheKey = batchNo + actionName;
} String contingencyPlanId = null;
result.add(tempmap1); ContingencyPlanInstance contingencyPlanInstance = null;
System.out.println("--------------------saveOperation----------------------"+result); if (OPERATE_RECORD_ID.get(cacheKey) == null) {
this.sendcmd("recordarea", paramObj, result); contingencyPlanInstance = iContingencyInstance.createInstanceRecord(batchNo, actionName, "DEFAULT", buttonJson, "OPERATE", icon);
} contingencyPlanId = contingencyPlanInstance.getId();
OPERATE_RECORD_ID.put(cacheKey, contingencyPlanId);
private String getContingencyPlanId(String batchNo, String actionName, String icon, String tips, String buttonJson) { } else {
String cacheKey = batchNo + actionName; contingencyPlanId = OPERATE_RECORD_ID.get(cacheKey);
String contingencyPlanId = null; OPERATE_RECORD_ID.remove(cacheKey);
ContingencyPlanInstance contingencyPlanInstance = null; }
if (OPERATE_RECORD_ID.get(cacheKey) == null) { return contingencyPlanId;
contingencyPlanInstance = iContingencyInstance.createInstanceRecord(batchNo, actionName, "DEFAULT", buttonJson, "OPERATE", icon); }
contingencyPlanId = contingencyPlanInstance.getId();
OPERATE_RECORD_ID.put(cacheKey, contingencyPlanId);
} else { /**
contingencyPlanId = OPERATE_RECORD_ID.get(cacheKey); * 地图动作推送
OPERATE_RECORD_ID.remove(cacheKey); *
} * @param actionName 动作名称标识
return contingencyPlanId; * @param paramObj 预案对象
} */
@RuleMethod(methodLabel = "地图动作", project = "换流站消防专项预案")
public void mapAction(@MethodParam(paramLabel = "动作名称标识") String actionName, @MethodParam(paramLabel = "参数") String paramJSON, @MethodParam(paramLabel = "对象") Object paramObj) {
/** ContingencyRo contingencyRo = (ContingencyRo) paramObj;
* 地图动作推送
* log.error("=======================================================================================");
* @param actionName 动作名称标识 stopSnapshop(contingencyRo);
* @param paramObj 预案对象
*/ SafteyPlanResult result = new SafteyPlanResult();
@RuleMethod(methodLabel = "地图动作", project = "换流站消防专项预案") Map<String, Object> tempmap1 = new HashMap<>();
public void mapAction(@MethodParam(paramLabel = "动作名称标识") String actionName, @MethodParam(paramLabel = "参数") String paramJSON, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; tempmap1.put("key", actionName);
tempmap1.put("content",paramJSON);
log.error("======================================================================================="); result.add(tempmap1);
stopSnapshop(contingencyRo); this.sendcmd("maparea", paramObj, result);
}
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); @RuleMethod(methodLabel = "地图动画", project = "换流站消防专项预案")
public void mapCartoonAction(
tempmap1.put("key", actionName); @MethodParam(paramLabel = "动作名称标识") String actionName,
tempmap1.put("content",paramJSON); @MethodParam(paramLabel = "动作类型") String actionType,
result.add(tempmap1); @MethodParam(paramLabel = "动作类型参数") String paramJSON,
this.sendcmd("maparea", paramObj, result); @MethodParam(paramLabel = "对象") Object paramObj) {
} ContingencyRo contingencyRo = (ContingencyRo) paramObj;
@RuleMethod(methodLabel = "地图动画", project = "换流站消防专项预案") log.error("=======================================================================================");
public void mapCartoonAction( stopSnapshop(contingencyRo);
@MethodParam(paramLabel = "动作名称标识") String actionName, String parameter = instedParams(paramJSON, contingencyRo);
@MethodParam(paramLabel = "动作类型") String actionType,
@MethodParam(paramLabel = "动作类型参数") String paramJSON, SafteyPlanResult result = new SafteyPlanResult();
@MethodParam(paramLabel = "对象") Object paramObj) { Map<String, Object> tempmap1 = new HashMap<>();
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
tempmap1.put("key", actionName);
log.error("======================================================================================="); tempmap1.put("content",actionType);
stopSnapshop(contingencyRo); tempmap1.put("parameter",parameter);
String parameter = instedParams(paramJSON, contingencyRo); result.add(tempmap1);
this.sendcmd("maparea", paramObj, result);
SafteyPlanResult result = new SafteyPlanResult(); }
Map<String, Object> tempmap1 = new HashMap<>();
/**
tempmap1.put("key", actionName); * 顶部消息提示
tempmap1.put("content",actionType); *
tempmap1.put("parameter",parameter); * @param content 消息内容
result.add(tempmap1); * @param messageType 消息类型 messageType 黑色框消息类型CONTINGENCY,,滚动消息:CURRENTMESSAGE
this.sendcmd("maparea", paramObj, result); * @param paramObj 预案对象
} */
@RuleMethod(methodLabel = "消息提示", project = "换流站消防专项预案")
/** public void topMessage(
* 顶部消息提示 @MethodParam(paramLabel = "标题") String title,
* @MethodParam(paramLabel = "内容") String content,
* @param content 消息内容 @MethodParam(paramLabel = "图标") String icon,
* @param messageType 消息类型 messageType 黑色框消息类型CONTINGENCY,,滚动消息:CURRENTMESSAGE @MethodParam(paramLabel = "类型") String messageType,
* @param paramObj 预案对象 @MethodParam(paramLabel = "对象") Object paramObj) {
*/ ContingencyRo contingencyRo = (ContingencyRo) paramObj;
@RuleMethod(methodLabel = "消息提示", project = "换流站消防专项预案") stopSnapshop(contingencyRo);
public void topMessage(
@MethodParam(paramLabel = "标题") String title, SafteyPlanResult result = new SafteyPlanResult();
@MethodParam(paramLabel = "内容") String content, Map<String, Object> tempmap1 = new HashMap<>();
@MethodParam(paramLabel = "图标") String icon, //转换content中的变量
@MethodParam(paramLabel = "类型") String messageType, content = instedParams(content, contingencyRo);
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; tempmap1.put("content", content);
stopSnapshop(contingencyRo); tempmap1.put("type", messageType);//消息类型 messageType 黑色框消息类型 CONTINGENCY,,滚动消息:CURRENTMESSAGE
tempmap1.put("title", title);
SafteyPlanResult result = new SafteyPlanResult(); tempmap1.put("icon", icon);
Map<String, Object> tempmap1 = new HashMap<>(); result.add(tempmap1);
//转换content中的变量
content = instedParams(content, contingencyRo); this.sendcmd("message", paramObj, result);
}
tempmap1.put("content", content);
tempmap1.put("type", messageType);//消息类型 messageType 黑色框消息类型 CONTINGENCY,,滚动消息:CURRENTMESSAGE /**
tempmap1.put("title", title); * 启动预案
tempmap1.put("icon", icon); *
result.add(tempmap1); * @param paramObj 预案对象
*/
this.sendcmd("message", paramObj, result); @RuleMethod(methodLabel = "启动预案", project = "换流站消防专项预案")
} public void startPlan(@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
/** stopSnapshop(contingencyRo);
* 启动预案
* SafteyPlanResult result = new SafteyPlanResult();
* @param paramObj 预案对象 Map<String, Object> tempmap1 = new HashMap<>();
*/
@RuleMethod(methodLabel = "启动预案", project = "换流站消防专项预案") tempmap1.put("type", "event");
public void startPlan(@MethodParam(paramLabel = "对象") Object paramObj) { tempmap1.put("content", "startPlan");
ContingencyRo contingencyRo = (ContingencyRo) paramObj; result.add(tempmap1);
stopSnapshop(contingencyRo);
this.sendcmd("message", paramObj, result);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); redisTemplate.opsForValue().set("contingencyRo", contingencyRo);
}
tempmap1.put("type", "event");
tempmap1.put("content", "startPlan");
result.add(tempmap1); /**
* 启动预案
this.sendcmd("message", paramObj, result); *
* @param paramObj 预案对象
redisTemplate.opsForValue().set("contingencyRo", contingencyRo); */
} @RuleMethod(methodLabel = "结束预案", project = "换流站消防专项预案")
public void stopPlan(@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
/** stopSnapshop(contingencyRo);
* 启动预案
* SafteyPlanResult result = new SafteyPlanResult();
* @param paramObj 预案对象 Map<String, Object> tempmap1 = new HashMap<>();
*/
@RuleMethod(methodLabel = "结束预案", project = "换流站消防专项预案") tempmap1.put("type", "event");
public void stopPlan(@MethodParam(paramLabel = "对象") Object paramObj) { tempmap1.put("content", "stopPlan");
ContingencyRo contingencyRo = (ContingencyRo) paramObj; //数字预案结束状态
stopSnapshop(contingencyRo); tempmap1.put("status",PlanRecordStatusEnum.COMPLETE.getCode());
result.add(tempmap1);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); this.sendcmd("message", paramObj, result);
redisTemplate.delete("contingencyRo");
tempmap1.put("type", "event");
tempmap1.put("content", "stopPlan"); // 结束预案,更新设备重点设备参数
//数字预案结束状态 if (contingencyRo != null) {
tempmap1.put("status",PlanRecordStatusEnum.COMPLETE.getCode()); Equipment equipment = equipmentService.queryOne(Long.parseLong(contingencyRo.getEquipmentId()));
result.add(tempmap1); if (equipment != null) {
equipment.setEndTime(DateUtil.getDateNow());
this.sendcmd("message", paramObj, result); equipment.setReserveSource(NumberEnum.ZERO.getValue());
redisTemplate.delete("contingencyRo"); equipment.setStatus(NumberEnum.ZERO.getValue());
equipmentService.save(equipment);
// 结束预案,更新设备重点设备参数 }
if (contingencyRo != null) { }
Equipment equipment = equipmentService.queryOne(Long.parseLong(contingencyRo.getEquipmentId()));
if (equipment != null) { // 结束预案 更新预案记录表,预案状态
equipment.setEndTime(DateUtil.getDateNow()); PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(contingencyRo.getBatchNo());
equipment.setReserveSource(NumberEnum.ZERO.getValue()); if(planOperationRecord!=null && planOperationRecord.getStatus()==PlanRecordStatusEnum.OPERATION.getCode()){
equipment.setStatus(NumberEnum.ZERO.getValue()); planOperationRecord.setStatus(PlanRecordStatusEnum.COMPLETE.getCode());
equipmentService.save(equipment); planOperationRecord.setEndTime(new Date());
} planOperationRecordDao.save(planOperationRecord);
} Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(planOperationRecord.getPlanId());
if(optionalPlanDetail.get()!=null){
// 结束预案 更新预案记录表,预案状态 PlanDetail planDetail = optionalPlanDetail.get();
PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(contingencyRo.getBatchNo()); planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode());
if(planOperationRecord!=null && planOperationRecord.getStatus()==PlanRecordStatusEnum.OPERATION.getCode()){ planDetailDao.save(planDetail);
planOperationRecord.setStatus(PlanRecordStatusEnum.COMPLETE.getCode()); }
planOperationRecord.setEndTime(new Date()); //数字预案业务屏web端发送消息
planOperationRecordDao.save(planOperationRecord); this.sendweb("recordarea", paramObj, result);
Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(planOperationRecord.getPlanId()); }
if(optionalPlanDetail.get()!=null){
PlanDetail planDetail = optionalPlanDetail.get(); }
planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode());
planDetailDao.save(planDetail);
} @RuleMethod(methodLabel = "自动执行步骤", project = "换流站消防专项预案")
//数字预案业务屏web端发送消息 public void autoExecute(
this.sendweb("recordarea", paramObj, result); @MethodParam(paramLabel = "动作名称") String actionName,
} @MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode,
} @MethodParam(paramLabel = "步骤状态") String stepState,
@MethodParam(paramLabel = "预案对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
@RuleMethod(methodLabel = "自动执行步骤", project = "换流站消防专项预案") ContingencyPlanInstance contingencyPlanInstance = iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), actionName, "DEFAULT", "", "OPERATE", "");
public void autoExecute(
@MethodParam(paramLabel = "动作名称") String actionName, Toke toke = remoteSecurityService.getServerToken();
@MethodParam(paramLabel = "步骤编号") String stepCode, RequestContext.setToken(toke.getToke());
@MethodParam(paramLabel = "按钮编码") String buttonCode, RequestContext.setProduct(toke.getProduct());
@MethodParam(paramLabel = "步骤状态") String stepState, try {
@MethodParam(paramLabel = "预案对象") Object paramObj) { iContingencyInstance.setButtonExecuted(contingencyRo.getBatchNo(),contingencyPlanInstance.getId(),buttonCode,"CONFIRM");
ContingencyRo contingencyRo = (ContingencyRo) paramObj; iContingencyInstance.fire(contingencyRo.getBatchNo(),stepCode, contingencyPlanInstance.getId(),buttonCode, "CONFIRM", stepState);
ContingencyPlanInstance contingencyPlanInstance = iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), actionName, "DEFAULT", "", "OPERATE", ""); } catch (Exception e) {
e.printStackTrace();
Toke toke = remoteSecurityService.getServerToken(); }
RequestContext.setToken(toke.getToke()); }
RequestContext.setProduct(toke.getProduct());
try { @RuleMethod(methodLabel = "添加步骤执行", project = "换流站消防专项预案")
iContingencyInstance.setButtonExecuted(contingencyRo.getBatchNo(),contingencyPlanInstance.getId(),buttonCode,"CONFIRM"); public void addExecute(
iContingencyInstance.fire(contingencyRo.getBatchNo(),stepCode, contingencyPlanInstance.getId(),buttonCode, "CONFIRM", stepState); @MethodParam(paramLabel = "步骤编号") String stepCode,
} catch (Exception e) { @MethodParam(paramLabel = "按钮编码") String buttonCode,
e.printStackTrace(); @MethodParam(paramLabel = "设备数据") Object paramObj) {
} SafteyPlanResult result = new SafteyPlanResult();
} Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>();
@RuleMethod(methodLabel = "添加步骤执行", project = "换流站消防专项预案")
public void addExecute( content.put("stepCode", stepCode);
@MethodParam(paramLabel = "步骤编号") String stepCode, content.put("buttonCode", buttonCode);
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "设备数据") Object paramObj) { DeviceRo ro = (DeviceRo)paramObj;
SafteyPlanResult result = new SafteyPlanResult(); Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId());
Map<String, Object> tempmap1 = new HashMap<>(); if (ObjectUtils.isEmpty(equipemtnPoints)) {
Map<String, Object> content = new HashMap<>(); equipemtnPoints = new HashMap<>();
}
content.put("stepCode", stepCode); equipemtnPoints.put(stepCode+"-"+buttonCode, content);
content.put("buttonCode", buttonCode); tempmap1.put("type", "buttonCache");
tempmap1.put("content", equipemtnPoints.values());
DeviceRo ro = (DeviceRo)paramObj; result.add(tempmap1);
Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId()); this.sendcmd("message", ro, result);
if (ObjectUtils.isEmpty(equipemtnPoints)) { }
equipemtnPoints = new HashMap<>();
} @RuleMethod(methodLabel = "清除步骤执行", project = "换流站消防专项预案")
equipemtnPoints.put(stepCode+"-"+buttonCode, content); public void clearExecute(
tempmap1.put("type", "buttonCache"); @MethodParam(paramLabel = "步骤编号") String stepCode,
tempmap1.put("content", equipemtnPoints.values()); @MethodParam(paramLabel = "按钮编码") String buttonCode,
result.add(tempmap1); @MethodParam(paramLabel = "设备数据") Object paramObj) {
this.sendcmd("message", ro, result); SafteyPlanResult result = new SafteyPlanResult();
} Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>();
@RuleMethod(methodLabel = "清除步骤执行", project = "换流站消防专项预案")
public void clearExecute( content.put("stepCode", stepCode);
@MethodParam(paramLabel = "步骤编号") String stepCode, content.put("buttonCode", buttonCode);
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "设备数据") Object paramObj) { DeviceRo ro = (DeviceRo)paramObj;
SafteyPlanResult result = new SafteyPlanResult(); Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId());
Map<String, Object> tempmap1 = new HashMap<>(); if (!ObjectUtils.isEmpty(equipemtnPoints)) {
Map<String, Object> content = new HashMap<>(); equipemtnPoints.remove(stepCode+"-"+buttonCode);
}
content.put("stepCode", stepCode);
content.put("buttonCode", buttonCode); tempmap1.put("type", "buttonCache");
if (!ObjectUtils.isEmpty(equipemtnPoints)) {
DeviceRo ro = (DeviceRo)paramObj; tempmap1.put("content", equipemtnPoints.values());
Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId()); } else {
if (!ObjectUtils.isEmpty(equipemtnPoints)) { tempmap1.put("content", new ArrayList());
equipemtnPoints.remove(stepCode+"-"+buttonCode); }
} result.add(tempmap1);
tempmap1.put("type", "buttonCache"); this.sendcmd("message", ro, result);
if (!ObjectUtils.isEmpty(equipemtnPoints)) { }
tempmap1.put("content", equipemtnPoints.values());
} else { @RuleMethod(methodLabel = "同步自动执行步骤", project = "换流站消防专项预案")
tempmap1.put("content", new ArrayList()); public void sendExecute(@MethodParam(paramLabel = "预案对象") Object paramObj) {
} SafteyPlanResult result = new SafteyPlanResult();
result.add(tempmap1); Map<String, Object> tempmap1 = new HashMap<>();
this.sendcmd("message", ro, result); ContingencyRo contingencyRo = (ContingencyRo) paramObj;
} Map<String, Object> equipemtnPoints = pointCache.get(contingencyRo.getEquipmentId());
@RuleMethod(methodLabel = "同步自动执行步骤", project = "换流站消防专项预案") tempmap1.put("type", "buttonCache");
public void sendExecute(@MethodParam(paramLabel = "预案对象") Object paramObj) { tempmap1.put("content", ObjectUtils.isEmpty(equipemtnPoints) ? new ArrayList<>() : equipemtnPoints.values());
SafteyPlanResult result = new SafteyPlanResult(); result.add(tempmap1);
Map<String, Object> tempmap1 = new HashMap<>();
this.sendcmd("message", paramObj, result);
ContingencyRo contingencyRo = (ContingencyRo) paramObj; }
Map<String, Object> equipemtnPoints = pointCache.get(contingencyRo.getEquipmentId());
public void sendcmd(String msgType, DeviceRo deviceRo, SafteyPlanResult result) {
tempmap1.put("type", "buttonCache"); Constructor<?> constructor;
tempmap1.put("content", ObjectUtils.isEmpty(equipemtnPoints) ? new ArrayList<>() : equipemtnPoints.values()); try {
result.add(tempmap1); constructor = Class.forName(
PACKAGEURL + result.getClass().getSimpleName() + "Message")
this.sendcmd("message", paramObj, result); .getConstructor(ActionResult.class);
} AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
if ("mqtt".equals(pushType.toLowerCase())) {
public void sendcmd(String msgType, DeviceRo deviceRo, SafteyPlanResult result) { ToipResponse toipResponse = action.buildResponse(msgType, deviceRo, result.toJson());
Constructor<?> constructor; String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan");
try { log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
constructor = Class.forName( webMqttComponent.publish(topic, toipResponse.toJsonStr());
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class); ContingencyEvent event = new ContingencyEvent(this);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result); event.setMsgBody(toipResponse.toJsonStr());
if ("mqtt".equals(pushType.toLowerCase())) { event.setTopic(topic);
ToipResponse toipResponse = action.buildResponse(msgType, deviceRo, result.toJson()); event.setMsgType(msgType);
String topic = String.format("/%s/%s/%s", serviceName, stationName,"plan"); event.setContingency(deviceRo);
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr())); contingencyLogPublisher.publish(event);
webMqttComponent.publish(topic, toipResponse.toJsonStr()); } else if ("websocket".equals(pushType.toLowerCase())){
action.execute(msgType, deviceRo);
ContingencyEvent event = new ContingencyEvent(this); }
event.setMsgBody(toipResponse.toJsonStr()); } catch (Exception e) {
event.setTopic(topic); e.printStackTrace();
event.setMsgType(msgType); }
event.setContingency(deviceRo); }
contingencyLogPublisher.publish(event);
} else if ("websocket".equals(pushType.toLowerCase())){ private void stopSnapshop(ContingencyRo contingencyRo) {
action.execute(msgType, deviceRo); if (RuleRunigSnapshotServiceImpl.getReplayBatchNo() != null && !RuleRunigSnapshotServiceImpl.getReplayBatchNo().equals(contingencyRo.getBatchNo()))
} RuleRunigSnapshotServiceImpl.setReplayBatchNoToNull();
} catch (Exception e) { }
e.printStackTrace();
} @Override
} public void intreeuptPlan(String batchNo) {
ContingencyRo contingencyRo = new ContingencyRo();
private void stopSnapshop(ContingencyRo contingencyRo) { contingencyRo.setBatchNo(batchNo);
if (RuleRunigSnapshotServiceImpl.getReplayBatchNo() != null && !RuleRunigSnapshotServiceImpl.getReplayBatchNo().equals(contingencyRo.getBatchNo())) SafteyPlanResult result = new SafteyPlanResult();
RuleRunigSnapshotServiceImpl.setReplayBatchNoToNull(); Map<String, Object> tempmap1 = new HashMap<>();
}
tempmap1.put("type", "event");
@Override ArrayList records = new ArrayList<>();
public void intreeuptPlan(String batchNo) { HashMap map = new HashMap();
ContingencyRo contingencyRo = new ContingencyRo(); map.put("time", sdf.format(new Date()));
contingencyRo.setBatchNo(batchNo); map.put("stepName","应急处置中断");
SafteyPlanResult result = new SafteyPlanResult(); records.add(map);
Map<String, Object> tempmap1 = new HashMap<>(); tempmap1.put("content", records);
//数字预案结束状态
tempmap1.put("type", "event"); tempmap1.put("status",PlanRecordStatusEnum.INTERRUPT.getCode());
ArrayList records = new ArrayList<>(); result.add(tempmap1);
HashMap map = new HashMap(); //数字预案业务屏web端发送消息
map.put("time", sdf.format(new Date())); this.sendweb("recordarea", contingencyRo, result);
map.put("stepName","应急处置中断"); updateNumberPlan(contingencyRo.getBatchNo());
records.add(map); }
tempmap1.put("content", records);
//数字预案结束状态 /**
tempmap1.put("status",PlanRecordStatusEnum.INTERRUPT.getCode()); * 修改数字预案状态
result.add(tempmap1); * */
//数字预案业务屏web端发送消息 public void updateNumberPlan(String batchNo){
this.sendweb("recordarea", contingencyRo, result); // 结束预案 更新预案记录表,预案状态
updateNumberPlan(contingencyRo.getBatchNo()); PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(batchNo);
} if(planOperationRecord!=null){
planOperationRecord.setStatus(PlanRecordStatusEnum.INTERRUPT.getCode());
/** planOperationRecord.setEndTime(new Date());
* 修改数字预案状态 planOperationRecordDao.save(planOperationRecord);
* */ Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(planOperationRecord.getPlanId());
public void updateNumberPlan(String batchNo){ if(optionalPlanDetail.get()!=null){
// 结束预案 更新预案记录表,预案状态 PlanDetail planDetail = optionalPlanDetail.get();
PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(batchNo); planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode());
if(planOperationRecord!=null){ planDetailDao.save(planDetail);
planOperationRecord.setStatus(PlanRecordStatusEnum.INTERRUPT.getCode()); }
planOperationRecord.setEndTime(new Date()); }
planOperationRecordDao.save(planOperationRecord); }
Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(planOperationRecord.getPlanId()); }
if(optionalPlanDetail.get()!=null){
PlanDetail planDetail = optionalPlanDetail.get();
planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode());
planDetailDao.save(planDetail);
}
}
}
}
...@@ -22,7 +22,8 @@ import java.util.stream.Collectors; ...@@ -22,7 +22,8 @@ import java.util.stream.Collectors;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.yeejoin.amos.fas.business.util.DataSyncUtil; import com.yeejoin.amos.fas.business.util.*;
import com.yeejoin.amos.fas.common.enums.AstDataSyncTopic;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -96,9 +97,6 @@ import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService; ...@@ -96,9 +97,6 @@ import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService;
import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService; import com.yeejoin.amos.fas.business.service.intfc.IRiskSourceService;
import com.yeejoin.amos.fas.business.service.intfc.IView3dService; import com.yeejoin.amos.fas.business.service.intfc.IView3dService;
import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus; import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus;
import com.yeejoin.amos.fas.business.util.DateUtils;
import com.yeejoin.amos.fas.business.util.JexlUtil;
import com.yeejoin.amos.fas.business.util.RpnUtils;
import com.yeejoin.amos.fas.business.vo.EquipCommunicationData; import com.yeejoin.amos.fas.business.vo.EquipCommunicationData;
import com.yeejoin.amos.fas.business.vo.EquipmentSpecificIndexVo; import com.yeejoin.amos.fas.business.vo.EquipmentSpecificIndexVo;
import com.yeejoin.amos.fas.business.vo.Toke; import com.yeejoin.amos.fas.business.vo.Toke;
...@@ -225,7 +223,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -225,7 +223,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
IEquipManageFeign iEquipManageFeign; IEquipManageFeign iEquipManageFeign;
@Autowired @Autowired
private PlanDetailMapper planDetailMapper; private PlanDetailMapper planDetailMapper;
@Autowired @Autowired
private DataSyncUtil dataSyncUtil; private DataSyncUtil dataSyncUtil;
...@@ -266,7 +264,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -266,7 +264,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSource.setStatus(oldRiskSource.getStatus()); riskSource.setStatus(oldRiskSource.getStatus());
} }
iRiskSourceDao.saveAndFlush(riskSource); iRiskSourceDao.saveAndFlush(riskSource);
dataSyncUtil.astDataSync(String.join("_", com.yeejoin.dataprocess.common.enums.AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource)); dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource));
return riskSource; return riskSource;
} }
...@@ -287,17 +285,17 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -287,17 +285,17 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
//1、删除风险点 //1、删除风险点
iRiskSourceDao.deleteById(rId); iRiskSourceDao.deleteById(rId);
dataSyncUtil.astDataSync(String.join("_", com.yeejoin.dataprocess.common.enums.AstDataSyncTopic.AST_REGION_DELETE_BY_ID.getValue(), String.valueOf(rId)), String.valueOf(rId)); dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_DELETE_BY_ID.getValue(), String.valueOf(rId)), String.valueOf(rId));
//2.删除关联建筑关系,防止对站服务有问题,捕获异常,不影响业务正常秩序 //2.删除关联建筑关系,防止对站服务有问题,捕获异常,不影响业务正常秩序
try { try {
rs.ifPresent(r->{ rs.ifPresent(r -> {
if(r.getSourceId() != null){ if (r.getSourceId() != null) {
iEquipManageFeign.unbindRelation(r.getSourceId()); iEquipManageFeign.unbindRelation(r.getSourceId());
} }
}); });
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(),e); log.error(e.getMessage(), e);
} }
} }
//3.重新计算rpn //3.重新计算rpn
...@@ -312,7 +310,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -312,7 +310,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override @Override
public void deleteById(Long id) { public void deleteById(Long id) {
iRiskSourceDao.deleteById(id); iRiskSourceDao.deleteById(id);
dataSyncUtil.astDataSync(String.join("_", com.yeejoin.dataprocess.common.enums.AstDataSyncTopic.AST_REGION_DELETE_BY_ID.getValue(), String.valueOf(id)), String.valueOf(id)); dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_DELETE_BY_ID.getValue(), String.valueOf(id)), String.valueOf(id));
} }
@Override @Override
...@@ -321,7 +319,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -321,7 +319,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
Optional<RiskSource> op = iRiskSourceDao.findBySourceId(synBo.getId()); Optional<RiskSource> op = iRiskSourceDao.findBySourceId(synBo.getId());
RiskSource riskSource; RiskSource riskSource;
//1.同步上级 //1.同步上级
if(op.isPresent()){ if (op.isPresent()) {
//有就更新,业务只能调整上级 //有就更新,业务只能调整上级
riskSource = op.get(); riskSource = op.get();
riskSource.setParentId(synBo.getParentId()); riskSource.setParentId(synBo.getParentId());
...@@ -329,23 +327,23 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -329,23 +327,23 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} else { } else {
//无则插入 //无则插入
riskSource = new RiskSource(); riskSource = new RiskSource();
Bean.copyExistPropertis(synBo,riskSource); Bean.copyExistPropertis(synBo, riskSource);
fillBasicParams(userId, orgCode, synBo.getId(), riskSource); fillBasicParams(userId, orgCode, synBo.getId(), riskSource);
riskSource = iRiskSourceDao.save(riskSource); riskSource = iRiskSourceDao.save(riskSource);
} }
dataSyncUtil.astDataSync(String.join("_", com.yeejoin.dataprocess.common.enums.AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource)); dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource));
//2.同步下级(只有一级) //2.同步下级(只有一级)
if(!CollectionUtils.isEmpty(synBo.getChildren())){ if (!CollectionUtils.isEmpty(synBo.getChildren())) {
RiskSource finalRiskSource = riskSource; RiskSource finalRiskSource = riskSource;
List<RiskSource> children = synBo.getChildren().stream().map(s->{ List<RiskSource> children = synBo.getChildren().stream().map(s -> {
RiskSource t = new RiskSource(); RiskSource t = new RiskSource();
Bean.copyExistPropertis(s,t); Bean.copyExistPropertis(s, t);
fillBasicParams(userId, orgCode, s.getId(), t); fillBasicParams(userId, orgCode, s.getId(), t);
t.setParentId(finalRiskSource.getId()); t.setParentId(finalRiskSource.getId());
return t; return t;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
iRiskSourceDao.saveAll(children); iRiskSourceDao.saveAll(children);
dataSyncUtil.astDataSync(com.yeejoin.dataprocess.common.enums.AstDataSyncTopic.AST_REGION_SAVE_ALL.getValue(), JSON.toJSONString(children)); dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_SAVE_ALL.getValue(), RandomUtil.buildNo()), JSON.toJSONString(children));
} }
return riskSource; return riskSource;
} }
...@@ -363,11 +361,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -363,11 +361,11 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override @Override
public Boolean removeBind(Long instanceId) { public Boolean removeBind(Long instanceId) {
Optional<RiskSource> exist = iRiskSourceDao.findBySourceId(instanceId); Optional<RiskSource> exist = iRiskSourceDao.findBySourceId(instanceId);
if(exist.isPresent()){ if (exist.isPresent()) {
RiskSource riskSource = exist.get(); RiskSource riskSource = exist.get();
riskSource.setSourceId(null); riskSource.setSourceId(null);
iRiskSourceDao.save(riskSource); iRiskSourceDao.save(riskSource);
dataSyncUtil.astDataSync(String.join("_", com.yeejoin.dataprocess.common.enums.AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource)); dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource));
} }
return exist.isPresent(); return exist.isPresent();
} }
...@@ -636,7 +634,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -636,7 +634,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
telesignallingMap.put(map.get("code") + "", (ObjectUtils.isEmpty(map.get("value")) || "false".equals(map.get("value").toString())) ? 0 : 1); telesignallingMap.put(map.get("code") + "", (ObjectUtils.isEmpty(map.get("value")) || "false".equals(map.get("value").toString())) ? 0 : 1);
} }
contingencyRo.setTelesignallingMap(telesignallingMap); contingencyRo.setTelesignallingMap(telesignallingMap);
//获取遥测指标 //获取遥测指标
points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "ANALOGUE"); //物联指标 非 true false points = fireEquipPointMapper.getPointsByEquipmentIdAndType(equipment.getId(), "ANALOGUE"); //物联指标 非 true false
HashMap<String, Double> telemetryMap = new HashMap<>(); HashMap<String, Double> telemetryMap = new HashMap<>();
for (Map map : points) { for (Map map : points) {
...@@ -645,7 +643,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -645,7 +643,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
contingencyRo.setTelemetryMap(telemetryMap); contingencyRo.setTelemetryMap(telemetryMap);
List<String> plan = this.getNumberPlan(Long.parseLong(contingencyRo.getEquipmentId())); List<String> plan = this.getNumberPlan(Long.parseLong(contingencyRo.getEquipmentId()));
if(plan.size()>0){ if (plan.size() > 0) {
log.debug("开始调用规则"); log.debug("开始调用规则");
Object result = ruleTrigger.publish(contingencyRo, "换流站消防专项预案/" + plan.get(0), ArrayUtils.toArray(equipment.getName())); Object result = ruleTrigger.publish(contingencyRo, "换流站消防专项预案/" + plan.get(0), ArrayUtils.toArray(equipment.getName()));
log.debug("规则调用返回==", result); log.debug("规则调用返回==", result);
...@@ -1010,13 +1008,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1010,13 +1008,13 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
@Override @Override
@javax.transaction.Transactional @javax.transaction.Transactional
public String processFireEqumtData(AlarmParam deviceData) throws Exception { public String processFireEqumtData(AlarmParam deviceData) throws Exception {
EquipmentSpecificIndexVo equipmentSpecificIndexVo = impAndFireEquipMapper.findFireEqupmentByCode(deviceData.getPointCode()); EquipmentSpecificIndexVo equipmentSpecificIndexVo = impAndFireEquipMapper.findFireEqupmentByCode(deviceData.getPointCode());
Optional.ofNullable(equipmentSpecificIndexVo).orElseThrow(() -> new Exception("未查询到相关装备")); Optional.ofNullable(equipmentSpecificIndexVo).orElseThrow(() -> new Exception("未查询到相关装备"));
TopicEntityVo topicEntity = new TopicEntityVo(); TopicEntityVo topicEntity = new TopicEntityVo();
topicEntity.setMessage(JSON.toJSONString(equipmentSpecificIndexVo)); topicEntity.setMessage(JSON.toJSONString(equipmentSpecificIndexVo));
String data = JSON.toJSONString(topicEntity); String data = JSON.toJSONString(topicEntity);
System.out.println(data); System.out.println(data);
iEquipmentHandlerService.handlerMqttMessage("",data ); iEquipmentHandlerService.handlerMqttMessage("", data);
return "SUCCESS"; return "SUCCESS";
} }
...@@ -1037,9 +1035,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1037,9 +1035,9 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
TopicEntityVo topicEntity = new TopicEntityVo(); TopicEntityVo topicEntity = new TopicEntityVo();
Equipment equipment = equipmentService.queryOne(id); Equipment equipment = equipmentService.queryOne(id);
topicEntity.setMessage(JSON.toJSONString(equipmentSpecificIndexVo)); topicEntity.setMessage(JSON.toJSONString(equipmentSpecificIndexVo));
topicEntity.setEquipment(equipment); topicEntity.setEquipment(equipment);
String data = JSON.toJSONString(topicEntity); String data = JSON.toJSONString(topicEntity);
iEquipmentHandlerService.handlerMqttMessage("",data ); iEquipmentHandlerService.handlerMqttMessage("", data);
if (equipment != null) { if (equipment != null) {
equipment.setStartTime(DateUtil.getDateNow()); equipment.setStartTime(DateUtil.getDateNow());
equipment.setEndTime(null); equipment.setEndTime(null);
...@@ -1830,7 +1828,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1830,7 +1828,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
riskSource.setRpni(null); riskSource.setRpni(null);
riskSource.setRiskLevelId(null); riskSource.setRiskLevelId(null);
iRiskSourceDao.save(riskSource); iRiskSourceDao.save(riskSource);
dataSyncUtil.astDataSync(String.join("_", com.yeejoin.dataprocess.common.enums.AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource)); dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource));
return; return;
} }
BigDecimal rpn = rpnValueBo.getRpn(); BigDecimal rpn = rpnValueBo.getRpn();
...@@ -1844,7 +1842,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1844,7 +1842,7 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
} }
} }
iRiskSourceDao.save(riskSource); iRiskSourceDao.save(riskSource);
dataSyncUtil.astDataSync(String.join("_", com.yeejoin.dataprocess.common.enums.AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource)); dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource));
this.updateParentRpn(riskSource.getParentId()); this.updateParentRpn(riskSource.getParentId());
} }
} }
...@@ -1985,8 +1983,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService { ...@@ -1985,8 +1983,8 @@ public class RiskSourceServiceImpl implements IRiskSourceService {
return null; return null;
} }
public List<String> getNumberPlan(Long id){ public List<String> getNumberPlan(Long id) {
List<String> ruleId = planDetailMapper.getRuleIdByEquipment(id); List<String> ruleId = planDetailMapper.getRuleIdByEquipment(id);
return ruleId; return ruleId;
} }
} }
......
...@@ -17,6 +17,7 @@ import java.util.function.Function; ...@@ -17,6 +17,7 @@ import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.yeejoin.amos.fas.business.util.DataSyncUtil; import com.yeejoin.amos.fas.business.util.DataSyncUtil;
import com.yeejoin.amos.fas.common.enums.*;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -56,14 +57,6 @@ import com.yeejoin.amos.fas.business.vo.ExceptionRegionVo; ...@@ -56,14 +57,6 @@ import com.yeejoin.amos.fas.business.vo.ExceptionRegionVo;
import com.yeejoin.amos.fas.business.vo.SafetyIndexDetailVo; import com.yeejoin.amos.fas.business.vo.SafetyIndexDetailVo;
import com.yeejoin.amos.fas.business.vo.TodaySafetyIndexVo; import com.yeejoin.amos.fas.business.vo.TodaySafetyIndexVo;
import com.yeejoin.amos.fas.business.vo.View3dNodeVo; import com.yeejoin.amos.fas.business.vo.View3dNodeVo;
import com.yeejoin.amos.fas.common.enums.CheckStatusEnum;
import com.yeejoin.amos.fas.common.enums.DataRefreshTypeEum;
import com.yeejoin.amos.fas.common.enums.PlanTaskDetailStatusEnum;
import com.yeejoin.amos.fas.common.enums.ResourceTypeDefEnum;
import com.yeejoin.amos.fas.common.enums.RiskSourceLevelEum;
import com.yeejoin.amos.fas.common.enums.RiskSourceRegionEum;
import com.yeejoin.amos.fas.common.enums.RpnChangeTypeEum;
import com.yeejoin.amos.fas.common.enums.StatisticsErrorTypeEum;
import com.yeejoin.amos.fas.core.common.request.CommonPageable; import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.common.request.DateUtil; import com.yeejoin.amos.fas.core.common.request.DateUtil;
import com.yeejoin.amos.fas.core.common.response.CoordDTO; import com.yeejoin.amos.fas.core.common.response.CoordDTO;
...@@ -252,7 +245,7 @@ public class View3dServiceImpl implements IView3dService { ...@@ -252,7 +245,7 @@ public class View3dServiceImpl implements IView3dService {
if(ue4Rotation != null) riskSource.setUe4Rotation(pointBo.getUe4Rotation()); if(ue4Rotation != null) riskSource.setUe4Rotation(pointBo.getUe4Rotation());
if(position3d != null) riskSource.setPosition3d(position3d); if(position3d != null) riskSource.setPosition3d(position3d);
iRiskSourceDao.save(riskSource); iRiskSourceDao.save(riskSource);
dataSyncUtil.astDataSync(String.join("_", com.yeejoin.dataprocess.common.enums.AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource)); dataSyncUtil.astDataSync(String.join("_", AstDataSyncTopic.AST_REGION_SAVE.getValue(), String.valueOf(riskSource.getId())), JSON.toJSONString(riskSource));
} }
} }
......
package com.yeejoin.amos.fas.business.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
public class RandomUtil {
private static ThreadLocalRandom threadLocalRandom;
public static String buildOrderNo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String newDate = sdf.format(new Date());
String result = "";
Random random = new Random();
for (int i = 0; i < 3; i++) {
result += random.nextInt(10);
}
return newDate + result;
}
/**
* @param resourceType 资源类型
* @param companyCode 单位编号
* @Description Random存在性能问题可能造成线程阻塞问题,使
* 用性能更加卓越的threadLocalRandom(线程安全的单例模式)生成随机数
* 四位随机数无法保证不可重复性,如果对不可重复要求高,请使用其他工具
* @Author songLei
* @Return String
* @Date 2020/12/18 11:49
*/
public static String buildNo(String resourceType, String companyCode) {
threadLocalRandom = ThreadLocalRandom.current();
int num = threadLocalRandom.nextInt(1000, 9999);
return resourceType + companyCode + num;
}
public static String buildNo() {
threadLocalRandom = ThreadLocalRandom.current();
int num = threadLocalRandom.nextInt(1000, 9999);
return String.valueOf(num);
}
}
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