Commit 5eb576ec authored by maoying's avatar maoying

双预案修改

parent 8ba5d81b
...@@ -45,6 +45,8 @@ public class ContingencyInstanceInfo extends Model<ContingencyInstanceInfo>{ ...@@ -45,6 +45,8 @@ public class ContingencyInstanceInfo extends Model<ContingencyInstanceInfo>{
@TableField @TableField
private String duration; private String duration;
private String planRuleNo;
} }
...@@ -99,6 +99,9 @@ public class ContingencyOriginalData extends BusinessEntity { ...@@ -99,6 +99,9 @@ public class ContingencyOriginalData extends BusinessEntity {
@Column(name = "equipment_code") @Column(name = "equipment_code")
private String equipmentCode; private String equipmentCode;
@Column(name = "plan_rule_no")
private String planRuleNo;
/** /**
* 位置 * 位置
...@@ -107,7 +110,15 @@ public class ContingencyOriginalData extends BusinessEntity { ...@@ -107,7 +110,15 @@ public class ContingencyOriginalData extends BusinessEntity {
private String position; private String position;
public String getPosition() { public String getPlanRuleNo() {
return planRuleNo;
}
public void setPlanRuleNo(String planRuleNo) {
this.planRuleNo = planRuleNo;
}
public String getPosition() {
return position; return position;
} }
......
...@@ -84,6 +84,12 @@ public class ContingencyPlanInstance extends BusinessEntity{ ...@@ -84,6 +84,12 @@ public class ContingencyPlanInstance extends BusinessEntity{
@Column(name = "step_code") @Column(name = "step_code")
private String stepCode; private String stepCode;
/**
* 当前预案执行的序号
*/
@Column(name = "plan_rule_no")
private String planRuleNo;
public void setTaskSort(Integer taskSort) { public void setTaskSort(Integer taskSort) {
this.taskSort = taskSort; this.taskSort = taskSort;
...@@ -238,4 +244,12 @@ public class ContingencyPlanInstance extends BusinessEntity{ ...@@ -238,4 +244,12 @@ public class ContingencyPlanInstance extends BusinessEntity{
public void setBatchNo(String batchNo) { public void setBatchNo(String batchNo) {
this.batchNo = batchNo; this.batchNo = batchNo;
} }
public String getPlanRuleNo() {
return planRuleNo;
}
public void setPlanRuleNo(String planRuleNo) {
this.planRuleNo = planRuleNo;
}
} }
...@@ -149,6 +149,46 @@ public class Equipment extends BasicEntity { ...@@ -149,6 +149,46 @@ public class Equipment extends BasicEntity {
*/ */
@Column(name="reserve_source") @Column(name="reserve_source")
private Integer reserveSource; private Integer reserveSource;
/**
* 第二个预案相关参数
*/
private Integer secStatus;
/**
* 预案开始时间
*/
@Column(name="sec_start_time")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date secStartTime;
/**
* 预案结束时间
*/
@Column(name="sec_end_time")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date secEndTime;
/**
* 预案来源:1-手动触发,0-自动触发(默认)
*/
@Column(name="sec_reserve_source")
private Integer secReserveSource;
/**
* 当前设备预案执行的序号
*/
private String planRuleNo;
@Transient
public String getPlanRuleNo() {
return this.planRuleNo;
}
public void setPlanRuleNo(String planRuleNo) {
this.planRuleNo = planRuleNo;
}
public Equipment() { public Equipment() {
} }
......
...@@ -64,9 +64,14 @@ public class PlanDetail extends BasicEntity { ...@@ -64,9 +64,14 @@ public class PlanDetail extends BasicEntity {
private String remark; private String remark;
/** /**
* 预案状态 * 第一个预案状态
*/ */
private Integer status; private Integer status;
/**
* 第二个预案状态
*/
private Integer secStatus;
/** /**
* 创建人 * 创建人
...@@ -102,5 +107,11 @@ public class PlanDetail extends BasicEntity { ...@@ -102,5 +107,11 @@ public class PlanDetail extends BasicEntity {
@Column(name="input_time") @Column(name="input_time")
private Date inputTime; private Date inputTime;
/**
* 当前预案执行的序号
*/
@Column(name = "plan_rule_no")
private String planRuleNo;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
\ No newline at end of file
...@@ -96,5 +96,12 @@ public class PlanOperationRecord extends BasicEntity { ...@@ -96,5 +96,12 @@ public class PlanOperationRecord extends BasicEntity {
*/ */
@Column(name="fire_equipment_id") @Column(name="fire_equipment_id")
private Long fireEquipmentId; private Long fireEquipmentId;
/**
* 预案编号,默认为1,若一个设备有多个预案模型依次递增
*/
@Column(name="plan_rule_no")
private String planRuleNo = "1";
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
\ No newline at end of file
...@@ -26,6 +26,12 @@ public class PlanRule extends BasicEntity { ...@@ -26,6 +26,12 @@ public class PlanRule extends BasicEntity {
*/ */
@Column(name="rule_id") @Column(name="rule_id")
private String ruleId; private String ruleId;
/**
* 第二个规则ID
*/
@Column(name="sec_rule_id")
private String secRuleId;
/** /**
* 预案ID * 预案ID
...@@ -56,6 +62,7 @@ public class PlanRule extends BasicEntity { ...@@ -56,6 +62,7 @@ public class PlanRule extends BasicEntity {
*/ */
@Column(name="plan_step") @Column(name="plan_step")
private String planStep; private String planStep;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
\ No newline at end of file
...@@ -69,4 +69,10 @@ public class BubbleTipAction implements CustomerAction ...@@ -69,4 +69,10 @@ public class BubbleTipAction implements CustomerAction
public void intreeuptPlan(String batchNo) { public void intreeuptPlan(String batchNo) {
} }
@Override
public void secIntreeuptPlan(String batchNo) {
// TODO Auto-generated method stub
}
} }
package com.yeejoin.amos.fas.business.action; package com.yeejoin.amos.fas.business.action;
import static org.typroject.tyboot.core.foundation.context.RequestContext.getAppKey;
import static org.typroject.tyboot.core.foundation.context.RequestContext.getProduct;
import static org.typroject.tyboot.core.foundation.context.RequestContext.getToken;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.component.rule.MethodParam; import com.yeejoin.amos.component.rule.MethodParam;
import com.yeejoin.amos.component.rule.RuleActionBean; import com.yeejoin.amos.component.rule.RuleActionBean;
import com.yeejoin.amos.component.rule.RuleMethod; import com.yeejoin.amos.component.rule.RuleMethod;
import com.yeejoin.amos.component.rule.config.ClazzUtils;
import com.yeejoin.amos.component.rule.model.FactModel;
import com.yeejoin.amos.fas.business.action.el.ELEvaluationContext; import com.yeejoin.amos.fas.business.action.el.ELEvaluationContext;
import com.yeejoin.amos.fas.business.action.model.ContingencyEvent; import com.yeejoin.amos.fas.business.action.model.ContingencyEvent;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo; import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
...@@ -25,53 +57,27 @@ import com.yeejoin.amos.fas.business.dao.repository.IPlanDetailDao; ...@@ -25,53 +57,27 @@ import com.yeejoin.amos.fas.business.dao.repository.IPlanDetailDao;
import com.yeejoin.amos.fas.business.dao.repository.IPlanOperationRecordDao; import com.yeejoin.amos.fas.business.dao.repository.IPlanOperationRecordDao;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService; import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.service.impl.RuleRunigSnapshotServiceImpl; import com.yeejoin.amos.fas.business.service.impl.RuleRunigSnapshotServiceImpl;
import com.yeejoin.amos.fas.business.service.intfc.*; import com.yeejoin.amos.fas.business.service.intfc.ContingencyInstanceInfoService;
import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance;
import com.yeejoin.amos.fas.business.service.intfc.IEmergencyTaskService;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentFireEquipmentService;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentService;
import com.yeejoin.amos.fas.business.service.intfc.IPlanStepService;
import com.yeejoin.amos.fas.business.service.intfc.IPlanVisual3dService;
import com.yeejoin.amos.fas.business.service.intfc.IRocketMQService;
import com.yeejoin.amos.fas.business.service.model.ToipResponse; import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import com.yeejoin.amos.fas.business.util.JSONUtil; import com.yeejoin.amos.fas.business.util.JSONUtil;
import com.yeejoin.amos.fas.business.vo.*; import com.yeejoin.amos.fas.business.vo.ButtonJsonVO;
import com.yeejoin.amos.fas.business.vo.PlanStepJsonVO;
import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.common.enums.ContingencyPlanStatusEnum; import com.yeejoin.amos.fas.common.enums.ContingencyPlanStatusEnum;
import com.yeejoin.amos.fas.common.enums.PlanRecordStatusEnum; import com.yeejoin.amos.fas.common.enums.PlanRecordStatusEnum;
import com.yeejoin.amos.fas.common.enums.PlanTypeEnum;
import com.yeejoin.amos.fas.core.enums.NumberEnum; import com.yeejoin.amos.fas.core.enums.NumberEnum;
import com.yeejoin.amos.fas.core.util.DateUtil; import com.yeejoin.amos.fas.core.util.DateUtil;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance; import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.Equipment; import com.yeejoin.amos.fas.dao.entity.Equipment;
import com.yeejoin.amos.fas.dao.entity.PlanDetail; import com.yeejoin.amos.fas.dao.entity.PlanDetail;
import com.yeejoin.amos.fas.dao.entity.PlanOperationRecord; import com.yeejoin.amos.fas.dao.entity.PlanOperationRecord;
import com.yeejoin.amos.fas.datasync.bo.PlanDetailSyncBo;
import com.yeejoin.amos.fas.datasync.bo.PlanOperationRecordSyncBo;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.io.Resource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static org.typroject.tyboot.core.foundation.context.RequestContext.*;
@Component @Component
...@@ -213,14 +219,15 @@ public class ContingencyAction implements CustomerAction { ...@@ -213,14 +219,15 @@ public class ContingencyAction implements CustomerAction {
this.sendcmd("steparea", contingencyRo, result); this.sendcmd("steparea", contingencyRo, result);
} }
public void sendcmdT(String msgType, Object contingency, SafteyPlanResult result) { public void sendcmdT(String msgType, ContingencyRo contingency, SafteyPlanResult result) {
ToipResponse toipResponse = new ToipResponse(); ToipResponse toipResponse = new ToipResponse();
toipResponse.setMsgType(msgType); toipResponse.setMsgType(msgType);
toipResponse.setMsgContext(result.toJson()); toipResponse.setMsgContext(result.toJson());
toipResponse.setContingency(contingency); toipResponse.setContingency(contingency);
toipResponse.setPlanRuleNo(contingency.getPlanRuleNo());
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); log.info("===============sendcmdT==contingency=,{}",JSONObject.toJSONString(contingency));
String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(contingency.getPlanRuleNo())?"plan":"secPlan"));
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr())); log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr()); webMqttComponent.publish(topic, toipResponse.toJsonStr());
} }
...@@ -229,13 +236,16 @@ public class ContingencyAction implements CustomerAction { ...@@ -229,13 +236,16 @@ public class ContingencyAction implements CustomerAction {
ContingencyRo ro = (ContingencyRo) contingency; ContingencyRo ro = (ContingencyRo) contingency;
ro.setTelemetryMap(null); ro.setTelemetryMap(null);
ro.setTelesignallingMap(null); ro.setTelesignallingMap(null);
Constructor<?> constructor; Constructor<?> constructor;
try { try {
constructor = Class.forName(PACKAGEURL + result.getClass().getSimpleName() + "Message").getConstructor(ActionResult.class); constructor = Class.forName(PACKAGEURL + result.getClass().getSimpleName() + "Message").getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result); AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
if ("mqtt".equals(pushType.toLowerCase())) { if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson()); ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); log.info("===============sendcmd==ro=,{}",JSONObject.toJSONString(ro));
String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(ro.getPlanRuleNo())?"plan":"secPlan"));
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr())); log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr()); webMqttComponent.publish(topic, toipResponse.toJsonStr());
...@@ -289,6 +299,30 @@ public class ContingencyAction implements CustomerAction { ...@@ -289,6 +299,30 @@ public class ContingencyAction implements CustomerAction {
e.printStackTrace(); e.printStackTrace();
} }
} }
public void secSendweb(String msgType, Object contingency, SafteyPlanResult result) {
ContingencyRo ro = (ContingencyRo) contingency;
ro.setTelemetryMap(null);
ro.setTelesignallingMap(null);
Constructor<?> constructor;
try {
constructor = Class.forName(PACKAGEURL + result.getClass().getSimpleName() + "Message").getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName, "secNumberPlan");
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr());
ContingencyEvent event = new ContingencyEvent(this);
event.setMsgBody(toipResponse.toJsonStr());
event.setTopic(topic);
event.setMsgType(msgType);
event.setContingency(contingency);
contingencyLogPublisher.publish(event);
} catch (Exception e) {
e.printStackTrace();
}
}
/** /**
* @param stepCode 当前步骤编号 * @param stepCode 当前步骤编号
...@@ -298,8 +332,9 @@ public class ContingencyAction implements CustomerAction { ...@@ -298,8 +332,9 @@ public class ContingencyAction implements CustomerAction {
public void saveStepInfo(@MethodParam(paramLabel = "当前编号") String stepCode, @MethodParam(paramLabel = "对象") Object paramObj) { public void saveStepInfo(@MethodParam(paramLabel = "当前编号") String stepCode, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
String batchNo = contingencyRo.getBatchNo(); String batchNo = contingencyRo.getBatchNo();
String planRuleNo = contingencyRo.getPlanRuleNo();
if (!findByBatchNoAndStatus(batchNo)) { if (!findByBatchNoAndStatus(batchNo)) {
iContingencyInstance.updateStep(stepCode, contingencyRo.getBatchNo()); iContingencyInstance.updateStep(stepCode, batchNo, planRuleNo);
} }
} }
...@@ -313,6 +348,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -313,6 +348,7 @@ public class ContingencyAction implements CustomerAction {
public void messageRecord(@MethodParam(paramLabel = "消息内容") String content, @MethodParam(paramLabel = "对象") Object paramObj) { public void messageRecord(@MethodParam(paramLabel = "消息内容") String content, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
String batchNo = contingencyRo.getBatchNo(); String batchNo = contingencyRo.getBatchNo();
String planRuleNo = contingencyRo.getPlanRuleNo();
if (!findByBatchNoAndStatus(batchNo)) { if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
Map<String, Object> params = contingencyRo.getParams(); Map<String, Object> params = contingencyRo.getParams();
...@@ -327,7 +363,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -327,7 +363,7 @@ public class ContingencyAction implements CustomerAction {
//转换content中的变量 //转换content中的变量
content = instedParams(content, contingencyRo); content = instedParams(content, contingencyRo);
iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", content, "MESSAGE", ""); iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", content, "MESSAGE", "", planRuleNo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
...@@ -377,6 +413,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -377,6 +413,7 @@ public class ContingencyAction implements CustomerAction {
public void help(@MethodParam(paramLabel = "当前步骤") String step, @MethodParam(paramLabel = "图标") String icon, @MethodParam(paramLabel = "标题") String title, @MethodParam(paramLabel = "图片集") String image, @MethodParam(paramLabel = "表格数据") String table, @MethodParam(paramLabel = "文本内容") String content, @MethodParam(paramLabel = "对象") Object paramObj) { public void help(@MethodParam(paramLabel = "当前步骤") String step, @MethodParam(paramLabel = "图标") String icon, @MethodParam(paramLabel = "标题") String title, @MethodParam(paramLabel = "图片集") String image, @MethodParam(paramLabel = "表格数据") String table, @MethodParam(paramLabel = "文本内容") String content, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
String batchNo = contingencyRo.getBatchNo(); String batchNo = contingencyRo.getBatchNo();
String planRuleNo = contingencyRo.getPlanRuleNo();
if (!findByBatchNoAndStatus(batchNo)) { if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
...@@ -392,11 +429,11 @@ public class ContingencyAction implements CustomerAction { ...@@ -392,11 +429,11 @@ public class ContingencyAction implements CustomerAction {
tempmap1.put("content", content); tempmap1.put("content", content);
tempmap1.put("image", image); tempmap1.put("image", image);
tempmap1.put("table", table); tempmap1.put("table", table);
iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", JSONUtil.toJson(tempmap1), "HELPAREA", ""); iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", JSONUtil.toJson(tempmap1), "HELPAREA", "", planRuleNo);
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("helparea", paramObj, result); this.sendcmd("helparea", paramObj, result);
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(contingencyRo.getPlanRuleNo())?"plan":"secPlan"));
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("contingency", new ContingencyRo()); map.put("contingency", new ContingencyRo());
map.put("msgContext", Collections.EMPTY_MAP); map.put("msgContext", Collections.EMPTY_MAP);
...@@ -455,10 +492,12 @@ public class ContingencyAction implements CustomerAction { ...@@ -455,10 +492,12 @@ public class ContingencyAction implements CustomerAction {
String batchNo = contingencyRo.getBatchNo(); String batchNo = contingencyRo.getBatchNo();
String buttonCode = contingencyRo.getButtonCode(); String buttonCode = contingencyRo.getButtonCode();
String stepCode = contingencyRo.getStep(); String stepCode = contingencyRo.getStep();
String planRuleNo = contingencyRo.getPlanRuleNo();
log.info(String.format("=====jhdz====planRuleNo1==[%s]",planRuleNo));
if (StringUtils.isBlank(buttonCode)) { if (StringUtils.isBlank(buttonCode)) {
// 根据步骤,取按钮编码 // 根据步骤,取按钮编码
List<PlanStepJsonVO> planStepJsonVOList = planStepService.getPlanStepJsonVOS(); List<PlanStepJsonVO> planStepJsonVOList = planStepService.getPlanStepJsonVOS();
log.info(String.format("=====jhdz====planStepJsonVOList==[%s]",JSONObject.toJSONString(planStepJsonVOList)));
List<PlanStepJsonVO> collect = planStepJsonVOList.stream().filter(x -> x.getStepCode().equals(stepCode)).collect(Collectors.toList()); List<PlanStepJsonVO> collect = planStepJsonVOList.stream().filter(x -> x.getStepCode().equals(stepCode)).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(collect)) { if (!CollectionUtils.isEmpty(collect)) {
buttonCode = collect.get(0).getButtonCode(); buttonCode = collect.get(0).getButtonCode();
...@@ -470,10 +509,12 @@ public class ContingencyAction implements CustomerAction { ...@@ -470,10 +509,12 @@ public class ContingencyAction implements CustomerAction {
//转换content中的变量 //转换content中的变量
tips = instedParams(tips, contingencyRo); tips = instedParams(tips, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
ContingencyPlanInstance contingencyPlanInstance = getContingencyPlan(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson); ContingencyPlanInstance contingencyPlanInstance = getContingencyPlan(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson, planRuleNo);
log.info(String.format("=====jhdz====contingencyPlanInstance==[%s]",JSONObject.toJSONString(contingencyPlanInstance)));
String contingencyPlanId = contingencyPlanInstance.getId(); String contingencyPlanId = contingencyPlanInstance.getId();
tempmap1.put("actionName", actionName); tempmap1.put("actionName", actionName);
tempmap1.put("icon", icon); tempmap1.put("icon", icon);
...@@ -486,8 +527,10 @@ public class ContingencyAction implements CustomerAction { ...@@ -486,8 +527,10 @@ public class ContingencyAction implements CustomerAction {
// 默认调用当前动作 // 默认调用当前动作
try { try {
ButtonJsonVO buttonJsonVO = JSONObject.parseObject(buttonJson, ButtonJsonVO.class); ButtonJsonVO buttonJsonVO = JSONObject.parseObject(buttonJson, ButtonJsonVO.class);
log.info(String.format("=====jhdz====buttonJsonVO==[%s]",JSONObject.toJSONString(buttonJsonVO)));
Map<String, Object> map = buttonJsonVO.getOperate().get(buttonJsonVO.getOperate().size() - 1); Map<String, Object> map = buttonJsonVO.getOperate().get(buttonJsonVO.getOperate().size() - 1);
iContingencyInstance.fire(batchNo, buttonJsonVO.getStepCode(), buttonJson, contingencyPlanId, map.get("code").toString(), "CANCEL_0", "A", "false", "false", getToken(), getProduct(), getAppKey(), null); iContingencyInstance.fire(batchNo, buttonJsonVO.getStepCode(), buttonJson, contingencyPlanId, map.get("code").toString()
, "CANCEL_0", "A", "false", "false", getToken(), getProduct(), getAppKey(), null, planRuleNo);
} catch (Exception e) { } catch (Exception e) {
log.error("optionarea 加入队列失败-->" + e.getMessage()); log.error("optionarea 加入队列失败-->" + e.getMessage());
} }
...@@ -557,26 +600,26 @@ public class ContingencyAction implements CustomerAction { ...@@ -557,26 +600,26 @@ public class ContingencyAction implements CustomerAction {
} }
} }
private String getContingencyPlanId(String batchNo, String actionName, String icon, String tips, String buttonJson) { // private String getContingencyPlanId(String batchNo, String actionName, String icon, String tips, String buttonJson) {
String cacheKey = batchNo + actionName; // String cacheKey = batchNo + actionName;
String contingencyPlanId = null; // String contingencyPlanId = null;
ContingencyPlanInstance contingencyPlanInstance = null; // ContingencyPlanInstance contingencyPlanInstance = null;
if (OPERATE_RECORD_ID.get(cacheKey) == null) { // if (OPERATE_RECORD_ID.get(cacheKey) == null) {
contingencyPlanInstance = iContingencyInstance.createInstanceRecord(batchNo, actionName, "DEFAULT", buttonJson, "OPERATE", icon); // contingencyPlanInstance = iContingencyInstance.createInstanceRecord(batchNo, actionName, "DEFAULT", buttonJson, "OPERATE", icon);
contingencyPlanId = contingencyPlanInstance.getId(); // contingencyPlanId = contingencyPlanInstance.getId();
OPERATE_RECORD_ID.put(cacheKey, contingencyPlanId); // OPERATE_RECORD_ID.put(cacheKey, contingencyPlanId);
} else { // } else {
contingencyPlanId = OPERATE_RECORD_ID.get(cacheKey); // contingencyPlanId = OPERATE_RECORD_ID.get(cacheKey);
OPERATE_RECORD_ID.remove(cacheKey); // OPERATE_RECORD_ID.remove(cacheKey);
} // }
return contingencyPlanId; // return contingencyPlanId;
} // }
private ContingencyPlanInstance getContingencyPlan(String batchNo, String actionName, String icon, String tips, String buttonJson) { private ContingencyPlanInstance getContingencyPlan(String batchNo, String actionName, String icon, String tips, String buttonJson, String planRuleNo) {
String cacheKey = batchNo + actionName; String cacheKey = batchNo + actionName;
ContingencyPlanInstance contingencyPlanInstance = null; ContingencyPlanInstance contingencyPlanInstance = null;
if (OPERATE_CONTINGENCYPLAN_INSTANCE.get(cacheKey) == null) { if (OPERATE_CONTINGENCYPLAN_INSTANCE.get(cacheKey) == null) {
contingencyPlanInstance = iContingencyInstance.createInstanceRecord(batchNo, actionName, "DEFAULT", buttonJson, "OPERATE", icon); contingencyPlanInstance = iContingencyInstance.createInstanceRecord(batchNo, actionName, "DEFAULT", buttonJson, "OPERATE", icon, planRuleNo);
OPERATE_CONTINGENCYPLAN_INSTANCE.put(cacheKey, contingencyPlanInstance); OPERATE_CONTINGENCYPLAN_INSTANCE.put(cacheKey, contingencyPlanInstance);
} else { } else {
contingencyPlanInstance = OPERATE_CONTINGENCYPLAN_INSTANCE.get(cacheKey); contingencyPlanInstance = OPERATE_CONTINGENCYPLAN_INSTANCE.get(cacheKey);
...@@ -596,6 +639,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -596,6 +639,7 @@ public class ContingencyAction implements CustomerAction {
public void mapAction(@MethodParam(paramLabel = "动作名称标识") String actionName, @MethodParam(paramLabel = "参数") String paramJSON, @MethodParam(paramLabel = "对象") Object paramObj) { public void mapAction(@MethodParam(paramLabel = "动作名称标识") String actionName, @MethodParam(paramLabel = "参数") String paramJSON, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
String batchNo = contingencyRo.getBatchNo(); String batchNo = contingencyRo.getBatchNo();
String planRuleNo = contingencyRo.getPlanRuleNo();
if (!findByBatchNoAndStatus(batchNo)) { if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
...@@ -708,9 +752,16 @@ public class ContingencyAction implements CustomerAction { ...@@ -708,9 +752,16 @@ public class ContingencyAction implements CustomerAction {
if (contingencyRo != null) { if (contingencyRo != null) {
Equipment equipment = equipmentService.queryOne(Long.parseLong(contingencyRo.getEquipmentId())); Equipment equipment = equipmentService.queryOne(Long.parseLong(contingencyRo.getEquipmentId()));
if (equipment != null) { if (equipment != null) {
equipment.setEndTime(DateUtil.getDateNow()); if("1".equals(contingencyRo.getPlanRuleNo())){
equipment.setReserveSource(NumberEnum.ZERO.getValue()); equipment.setEndTime(DateUtil.getDateNow());
equipment.setStatus(NumberEnum.ZERO.getValue()); equipment.setReserveSource(NumberEnum.ZERO.getValue());
equipment.setStatus(NumberEnum.ZERO.getValue());
}else{
equipment.setSecEndTime(DateUtil.getDateNow());
equipment.setSecReserveSource(NumberEnum.ZERO.getValue());
equipment.setSecStatus(NumberEnum.ZERO.getValue());
}
equipmentService.save(equipment); equipmentService.save(equipment);
} }
} }
...@@ -746,8 +797,9 @@ public class ContingencyAction implements CustomerAction { ...@@ -746,8 +797,9 @@ public class ContingencyAction implements CustomerAction {
public void autoExecute(@MethodParam(paramLabel = "动作名称") String actionName, @MethodParam(paramLabel = "步骤编号") String stepCode, @MethodParam(paramLabel = "按钮编码") String buttonCode, @MethodParam(paramLabel = "步骤状态") String stepState, @MethodParam(paramLabel = "预案对象") Object paramObj) { public void autoExecute(@MethodParam(paramLabel = "动作名称") String actionName, @MethodParam(paramLabel = "步骤编号") String stepCode, @MethodParam(paramLabel = "按钮编码") String buttonCode, @MethodParam(paramLabel = "步骤状态") String stepState, @MethodParam(paramLabel = "预案对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
String batchNo = contingencyRo.getBatchNo(); String batchNo = contingencyRo.getBatchNo();
String planRuleNo = contingencyRo.getPlanRuleNo();
if (!findByBatchNoAndStatus(batchNo)) { if (!findByBatchNoAndStatus(batchNo)) {
ContingencyPlanInstance contingencyPlanInstance = iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), actionName, "DEFAULT", "", "OPERATE", ""); ContingencyPlanInstance contingencyPlanInstance = iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), actionName, "DEFAULT", "", "OPERATE", "", planRuleNo);
Toke toke = remoteSecurityService.getServerToken(); Toke toke = remoteSecurityService.getServerToken();
RequestContext.setToken(toke.getToke()); RequestContext.setToken(toke.getToke());
...@@ -755,7 +807,8 @@ public class ContingencyAction implements CustomerAction { ...@@ -755,7 +807,8 @@ public class ContingencyAction implements CustomerAction {
try { try {
iContingencyInstance.setButtonExecuted(contingencyRo.getBatchNo(), contingencyPlanInstance.getId(), buttonCode, "CONFIRM", null); iContingencyInstance.setButtonExecuted(contingencyRo.getBatchNo(), contingencyPlanInstance.getId(), buttonCode, "CONFIRM", null);
iContingencyInstance.fire(contingencyRo.getBatchNo(), stepCode, contingencyPlanInstance.getId(), buttonCode, "CONFIRM", stepState); iContingencyInstance.fire(contingencyRo.getBatchNo(), stepCode, contingencyPlanInstance.getId(), buttonCode, "CONFIRM"
, stepState);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -798,7 +851,11 @@ public class ContingencyAction implements CustomerAction { ...@@ -798,7 +851,11 @@ public class ContingencyAction implements CustomerAction {
if (ObjectUtils.isEmpty(fireEquipmentId)) { if (ObjectUtils.isEmpty(fireEquipmentId)) {
return; return;
} }
String batchNo = planDetailMapper.queryBatchNoByFireEquipmentId(fireEquipmentId); // String batchNo = planDetailMapper.queryBatchNoByFireEquipmentId(fireEquipmentId);
Map<String,String> planOperationRecord = planDetailMapper.queryBatchNoAndRuleNoByFireEquipmentId(fireEquipmentId);
log.info(String.format("===ContingencyAction==clearExecute====planOperationRecord==[%s]",JSONObject.toJSONString(planOperationRecord)));
String batchNo = planOperationRecord.get("batchNo");
String planRuleNo = planOperationRecord.get("planRuleNo");
if (ObjectUtils.isEmpty(batchNo)) { if (ObjectUtils.isEmpty(batchNo)) {
return; return;
} }
...@@ -815,9 +872,9 @@ public class ContingencyAction implements CustomerAction { ...@@ -815,9 +872,9 @@ public class ContingencyAction implements CustomerAction {
if (Boolean.TRUE == obj) { if (Boolean.TRUE == obj) {
iContingencyInstance.fire(batchNo, stepCode, buttonJson, instanceId, iContingencyInstance.fire(batchNo, stepCode, buttonJson, instanceId,
buttonCode, buttonState, stepState, "true", "true", getToken(), buttonCode, buttonState, stepState, "true", "true", getToken(),
getProduct(), getAppKey(), "系统执行自动步骤"); getProduct(), getAppKey(), "系统执行自动步骤", planRuleNo);
} }
this.sendcmd("message", result); this.sendcmd("message", result, planRuleNo);
} }
@RuleMethod(methodLabel = "同步自动执行步骤", project = "换流站消防专项预案") @RuleMethod(methodLabel = "同步自动执行步骤", project = "换流站消防专项预案")
...@@ -840,30 +897,30 @@ public class ContingencyAction implements CustomerAction { ...@@ -840,30 +897,30 @@ public class ContingencyAction implements CustomerAction {
public void autoExecuteActionV2(@MethodParam(paramLabel = "步骤编码") String stepCode, @MethodParam(paramLabel = "按钮编码") String buttonCode, @MethodParam(paramLabel = "按钮状态") String confirm, @MethodParam(paramLabel = "步骤状态") String stepState, @MethodParam(paramLabel = "动作名称") String actionName, @MethodParam(paramLabel = "图标") String icon, @MethodParam(paramLabel = "提示信息") String tips, @MethodParam(paramLabel = "按钮json字符串") String buttonJson, @MethodParam(paramLabel = "预案对象") Object paramObj) { public void autoExecuteActionV2(@MethodParam(paramLabel = "步骤编码") String stepCode, @MethodParam(paramLabel = "按钮编码") String buttonCode, @MethodParam(paramLabel = "按钮状态") String confirm, @MethodParam(paramLabel = "步骤状态") String stepState, @MethodParam(paramLabel = "动作名称") String actionName, @MethodParam(paramLabel = "图标") String icon, @MethodParam(paramLabel = "提示信息") String tips, @MethodParam(paramLabel = "按钮json字符串") String buttonJson, @MethodParam(paramLabel = "预案对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
String batchNo = contingencyRo.getBatchNo(); String batchNo = contingencyRo.getBatchNo();
String planRuleNo = contingencyRo.getPlanRuleNo();
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
if (!findByBatchNoAndStatus(batchNo)) { if (!findByBatchNoAndStatus(batchNo)) {
ContingencyPlanInstance contingencyPlanInstance = getContingencyPlan(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson); ContingencyPlanInstance contingencyPlanInstance = getContingencyPlan(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson, planRuleNo);
String contingencyPlanId = contingencyPlanInstance.getId(); String contingencyPlanId = contingencyPlanInstance.getId();
try { try {
contingencyPlanInstance.setRoleCode(planStepService.getPlanStepRoleCodeByButtonCode(buttonCode)); contingencyPlanInstance.setRoleCode(planStepService.getPlanStepRoleCodeByButtonCode(buttonCode));
contingencyPlanInstanceRepository.save(contingencyPlanInstance); contingencyPlanInstanceRepository.save(contingencyPlanInstance);
contingencyInstance.fire(contingencyRo.getBatchNo(), stepCode, buttonJson, contingencyPlanId, buttonCode, confirm, stepState, "true", "true", getToken(), getProduct(), getAppKey(), null); contingencyInstance.fire(contingencyRo.getBatchNo(), stepCode, buttonJson, contingencyPlanId, buttonCode, confirm, stepState, "true", "true", getToken(), getProduct(), getAppKey(), null, contingencyPlanInstance.getPlanRuleNo());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
log.warn("自动执行动作V2耗时+++++++++++++++++++++++++++++++++" + (endTime - startTime) / 1000 + "秒" + ", 当前步骤编号: " + stepCode);
} }
public void sendcmd(String msgType, SafteyPlanResult result) { public void sendcmd(String msgType, SafteyPlanResult result, String planRuleNo) {
Constructor<?> constructor; Constructor<?> constructor;
try { try {
constructor = Class.forName(PACKAGEURL + result.getClass().getSimpleName() + "Message").getConstructor(ActionResult.class); constructor = Class.forName(PACKAGEURL + result.getClass().getSimpleName() + "Message").getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result); AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
if ("mqtt".equals(pushType.toLowerCase())) { if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, null, result.toJson()); ToipResponse toipResponse = action.buildResponse(msgType, null, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(planRuleNo)?"plan":"secPlan"));
log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr())); log.info(String.format("mqtt[%s]:【 %s 】", topic, toipResponse.toJsonStr()));
webMqttComponent.publish(topic, toipResponse.toJsonStr()); webMqttComponent.publish(topic, toipResponse.toJsonStr());
...@@ -909,6 +966,30 @@ public class ContingencyAction implements CustomerAction { ...@@ -909,6 +966,30 @@ public class ContingencyAction implements CustomerAction {
contingencyInstanceInfoService.updateEndTimeById(batchNo); contingencyInstanceInfoService.updateEndTimeById(batchNo);
} }
@Override
public void secIntreeuptPlan(String batchNo) {
ContingencyRo contingencyRo = new ContingencyRo();
contingencyRo.setBatchNo(batchNo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("type", "event");
ArrayList records = new ArrayList<>();
HashMap map = new HashMap();
map.put("time", sdf.format(new Date()));
map.put("stepName", "应急处置中断");
records.add(map);
tempmap1.put("content", records);
//数字预案结束状态
tempmap1.put("status", PlanRecordStatusEnum.INTERRUPT.getCode());
result.add(tempmap1);
//数字预案业务屏web端发送消息
this.secSendweb("recordarea", contingencyRo, result);
updateNumberPlan(batchNo);
// 更新预案结束时间
contingencyInstanceInfoService.updateEndTimeById(batchNo);
}
/** /**
* 修改数字预案状态 * 修改数字预案状态
*/ */
...@@ -922,7 +1003,12 @@ public class ContingencyAction implements CustomerAction { ...@@ -922,7 +1003,12 @@ public class ContingencyAction implements CustomerAction {
Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(PlanOperationRecord.getPlanId()); Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(PlanOperationRecord.getPlanId());
if (optionalPlanDetail.get() != null) { if (optionalPlanDetail.get() != null) {
PlanDetail planDetail = optionalPlanDetail.get(); PlanDetail planDetail = optionalPlanDetail.get();
planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode()); if("1".equals(PlanOperationRecord.getPlanRuleNo())){
planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode());
}else{
planDetail.setSecStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode());
}
PlanDetail detail = planDetailDao.save(planDetail); PlanDetail detail = planDetailDao.save(planDetail);
} }
} }
...@@ -948,12 +1034,13 @@ public class ContingencyAction implements CustomerAction { ...@@ -948,12 +1034,13 @@ public class ContingencyAction implements CustomerAction {
public void saveTaskInfo(@MethodParam(paramLabel = "任务名称") String taskName, @MethodParam(paramLabel = "角色编码") String roleCode, @MethodParam(paramLabel = "任务编号") Integer taskNum, @MethodParam(paramLabel = "步骤编码") String stepCode, @MethodParam(paramLabel = "按钮json字符串") String buttonJson, @MethodParam(paramLabel = "预案对象") Object paramObj) { public void saveTaskInfo(@MethodParam(paramLabel = "任务名称") String taskName, @MethodParam(paramLabel = "角色编码") String roleCode, @MethodParam(paramLabel = "任务编号") Integer taskNum, @MethodParam(paramLabel = "步骤编码") String stepCode, @MethodParam(paramLabel = "按钮json字符串") String buttonJson, @MethodParam(paramLabel = "预案对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
String batchNo = contingencyRo.getBatchNo(); String batchNo = contingencyRo.getBatchNo();
String planRuleNo = contingencyRo.getPlanRuleNo();
if (!findByBatchNoAndStatus(batchNo)) { if (!findByBatchNoAndStatus(batchNo)) {
String instanceId = iContingencyInstance.getInstanceIdByBatchNOAndCategory("TASKOPERATE", taskName, batchNo); String instanceId = iContingencyInstance.getInstanceIdByBatchNOAndCategory("TASKOPERATE", taskName, batchNo);
if (!StringUtils.isEmpty(instanceId)) { if (!StringUtils.isEmpty(instanceId)) {
return; return;
} }
emergencyTaskService.saveTask("-2", batchNo); emergencyTaskService.saveTask("-2", batchNo, planRuleNo);
} }
} }
} }
...@@ -6,4 +6,9 @@ public interface CustomerAction { ...@@ -6,4 +6,9 @@ public interface CustomerAction {
*数字预案中断 *数字预案中断
*/ */
void intreeuptPlan(String batchNo); void intreeuptPlan(String batchNo);
/**
*数字预案2中断
*/
void secIntreeuptPlan(String batchNo);
} }
...@@ -153,4 +153,10 @@ public class RiskSituationAction implements CustomerAction ...@@ -153,4 +153,10 @@ public class RiskSituationAction implements CustomerAction
public void intreeuptPlan(String batchNo) { public void intreeuptPlan(String batchNo) {
} }
@Override
public void secIntreeuptPlan(String batchNo) {
// TODO Auto-generated method stub
}
} }
...@@ -88,6 +88,12 @@ public class SimpleTipAction implements CustomerAction ...@@ -88,6 +88,12 @@ public class SimpleTipAction implements CustomerAction
} }
@Override
public void secIntreeuptPlan(String batchNo) {
// TODO Auto-generated method stub
}
// @SuppressWarnings("unchecked") // @SuppressWarnings("unchecked")
// private void saveMessageAction(AbstractActionResult abstractActionResult,String type) // private void saveMessageAction(AbstractActionResult abstractActionResult,String type)
// { // {
......
...@@ -105,4 +105,8 @@ public class ContingencyRo implements Serializable { ...@@ -105,4 +105,8 @@ public class ContingencyRo implements Serializable {
@Label("位置") @Label("位置")
private String position; private String position;
@Label("预案序号")
private String planRuleNo;
} }
...@@ -91,14 +91,15 @@ public class ContingencyPlanController extends BaseController { ...@@ -91,14 +91,15 @@ public class ContingencyPlanController extends BaseController {
@RequestParam(value = "editOrgName", required = false) String editOrgName, @RequestParam(value = "editOrgName", required = false) String editOrgName,
@RequestParam(value = "implementationTimeLeft", required = false) Long implementationTimeLeftStamp, @RequestParam(value = "implementationTimeLeft", required = false) Long implementationTimeLeftStamp,
@RequestParam(value = "implementationTimeRight", required = false) Long implementationTimeRightStamp, @RequestParam(value = "implementationTimeRight", required = false) Long implementationTimeRightStamp,
@RequestParam(value = "size") int size) { @RequestParam(value = "size") int size,
@RequestParam(value = "planRuleNo", required = false) String planRuleNo) {
if (current < 1 || size < 1) { if (current < 1 || size < 1) {
throw new YeeException("分页参数有误"); throw new YeeException("分页参数有误");
} }
Date implementationTimeLeft = implementationTimeLeftStamp == null ? null : new Date(implementationTimeLeftStamp); Date implementationTimeLeft = implementationTimeLeftStamp == null ? null : new Date(implementationTimeLeftStamp);
Date implementationTimeRight = implementationTimeRightStamp == null ? null : new Date(implementationTimeRightStamp); Date implementationTimeRight = implementationTimeRightStamp == null ? null : new Date(implementationTimeRightStamp);
Page page = new Page(current, size); Page page = new Page(current, size);
return CommonResponseUtil2.success(contingencyPlanService.pageFilter(page, planName, classifyId, planRange, editOrgName, implementationTimeLeft, implementationTimeRight)); return CommonResponseUtil2.success(contingencyPlanService.pageFilter(page, planName, classifyId, planRange, editOrgName, implementationTimeLeft, implementationTimeRight, planRuleNo));
} }
/** /**
......
...@@ -227,7 +227,7 @@ public class EmergencyTaskController extends BaseController{ ...@@ -227,7 +227,7 @@ public class EmergencyTaskController extends BaseController{
@ApiOperation(httpMethod = "POST",value = "新增流程任务", notes = "新增流程任务") @ApiOperation(httpMethod = "POST",value = "新增流程任务", notes = "新增流程任务")
@PostMapping(value = "/task/add", produces = "application/json; charset=UTF-8") @PostMapping(value = "/task/add", produces = "application/json; charset=UTF-8")
public CommonResponse addTaskContent(@RequestBody String stepCode){ public CommonResponse addTaskContent(@RequestBody String stepCode){
iEmergencyTaskService.saveTask(stepCode, null); iEmergencyTaskService.saveTask(stepCode, null, null);
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
......
package com.yeejoin.amos.fas.business.controller; package com.yeejoin.amos.fas.business.controller;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.yeejoin.amos.fas.business.action.CustomerAction; import com.yeejoin.amos.fas.business.action.CustomerAction;
import com.yeejoin.amos.fas.business.service.impl.RiskSourceServiceImpl; import com.yeejoin.amos.fas.business.service.impl.RiskSourceServiceImpl;
import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance; import com.yeejoin.amos.fas.business.service.intfc.IContingencyInstance;
...@@ -15,6 +16,7 @@ import com.yeejoin.amos.fas.core.enums.NumberEnum; ...@@ -15,6 +16,7 @@ import com.yeejoin.amos.fas.core.enums.NumberEnum;
import com.yeejoin.amos.fas.core.util.CommonResponse; import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil; import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.core.util.DateUtil; import com.yeejoin.amos.fas.core.util.DateUtil;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.Equipment; import com.yeejoin.amos.fas.dao.entity.Equipment;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -49,6 +51,9 @@ public class TimeLineController extends BaseController { ...@@ -49,6 +51,9 @@ public class TimeLineController extends BaseController {
@Autowired @Autowired
IRuleRunningSnapshotService iRuleRunningSnapshotService; IRuleRunningSnapshotService iRuleRunningSnapshotService;
@Autowired
IContingencyInstance iContingencyInstanceImpl;
@Autowired @Autowired
IEquipmentService equipmentService; IEquipmentService equipmentService;
...@@ -72,9 +77,14 @@ public class TimeLineController extends BaseController { ...@@ -72,9 +77,14 @@ public class TimeLineController extends BaseController {
@ApiOperation(httpMethod = "POST", value = "点击按钮", notes = "点击按钮") @ApiOperation(httpMethod = "POST", value = "点击按钮", notes = "点击按钮")
@RequestMapping(value = "/fire", produces = "application/json;charset=UTF-8", method = RequestMethod.POST) @RequestMapping(value = "/fire", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse fire(@RequestBody PlanExecuteVo vo) throws Exception { public CommonResponse fire(@RequestBody PlanExecuteVo vo) throws Exception {
AgencyUserModel userInfo = getUserInfo(); ContingencyPlanInstance instance = iContingencyInstanceImpl.getMessageById(vo.getContingencyPlanId());
if(ObjectUtils.isEmpty(instance)){
return CommonResponseUtil.failure("预案不存在");
}
AgencyUserModel userInfo = getUserInfo();
String user = userInfo.getRealName(); String user = userInfo.getRealName();
iContingencyInstance.fire(vo.getBatchNo(), vo.getStepCode(), vo.getButtonJson(), vo.getContingencyPlanId(), vo.getButtonCode(), vo.getConfirm(), vo.getStepState(), "true", "false", getToken(), getProduct(), getAppKey(), user); iContingencyInstance.fire(vo.getBatchNo(), vo.getStepCode(), vo.getButtonJson(), vo.getContingencyPlanId(), vo.getButtonCode(), vo.getConfirm(), vo.getStepState()
, "true", "false", getToken(), getProduct(), getAppKey(), user, instance.getPlanRuleNo());
return CommonResponseUtil.success("SUCCESS"); return CommonResponseUtil.success("SUCCESS");
} }
...@@ -84,7 +94,8 @@ public class TimeLineController extends BaseController { ...@@ -84,7 +94,8 @@ public class TimeLineController extends BaseController {
public CommonResponse clickButton(@RequestBody PlanExecuteVo vo) throws Exception { public CommonResponse clickButton(@RequestBody PlanExecuteVo vo) throws Exception {
AgencyUserModel userInfo = getUserInfo(); AgencyUserModel userInfo = getUserInfo();
String user = userInfo.getRealName(); String user = userInfo.getRealName();
iContingencyInstance.clickButton(vo.getBatchNo(), vo.getStepCode(), vo.getButtonJson(), vo.getContingencyPlanId(), vo.getButtonCode(), vo.getConfirm(), vo.getStepState(), "true", "false", getToken(), getProduct(), getAppKey(), user); iContingencyInstance.clickButton(vo.getBatchNo(), vo.getStepCode(), vo.getButtonJson(), vo.getContingencyPlanId()
, vo.getButtonCode(), vo.getConfirm(), vo.getStepState(), "true", "false", getToken(), getProduct(), getAppKey(), user);
return CommonResponseUtil.success("SUCCESS"); return CommonResponseUtil.success("SUCCESS");
} }
...@@ -102,10 +113,18 @@ public class TimeLineController extends BaseController { ...@@ -102,10 +113,18 @@ public class TimeLineController extends BaseController {
Optional<Equipment> equipment = iContingencyInstance.fire(batchNo, stepCode, "", buttonCode, confirm, stepState); Optional<Equipment> equipment = iContingencyInstance.fire(batchNo, stepCode, "", buttonCode, confirm, stepState);
// 结束预案,更新设备重点设备参数 // 结束预案,更新设备重点设备参数
equipment.ifPresent(equip -> { equipment.ifPresent(equip -> {
equip.setStartTime(DateUtil.getDateNow()); if("1".equals(equip.getPlanRuleNo())){
equip.setEndTime(null); equip.setStartTime(DateUtil.getDateNow());
equip.setReserveSource(NumberEnum.ONE.getValue()); equip.setEndTime(null);
equip.setStatus(NumberEnum.ONE.getValue()); equip.setReserveSource(NumberEnum.ONE.getValue());
equip.setStatus(NumberEnum.ONE.getValue());
}else{
equip.setSecStartTime(DateUtil.getDateNow());
equip.setSecEndTime(null);
equip.setSecReserveSource(NumberEnum.ONE.getValue());
equip.setSecStatus(NumberEnum.ONE.getValue());
}
equipmentService.save(equip); equipmentService.save(equip);
}); });
customerAction.intreeuptPlan(batchNo); customerAction.intreeuptPlan(batchNo);
......
...@@ -47,6 +47,9 @@ public interface PlanDetailMapper { ...@@ -47,6 +47,9 @@ 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);
List<String> getSecRuleIdByEquipment(@Param("id") Long id);
PlanDetailVo getPlanDetailByEquipmentId(@Param("fireEquipmentId") Long fireEquipmentId); PlanDetailVo getPlanDetailByEquipmentId(@Param("fireEquipmentId") Long fireEquipmentId);
...@@ -57,6 +60,8 @@ public interface PlanDetailMapper { ...@@ -57,6 +60,8 @@ public interface PlanDetailMapper {
String queryBatchNoByFireEquipmentId(@Param("fireEquipmentId") String fireEquipmentId); String queryBatchNoByFireEquipmentId(@Param("fireEquipmentId") String fireEquipmentId);
Map<String,String> queryBatchNoAndRuleNoByFireEquipmentId(@Param("fireEquipmentId") String fireEquipmentId);
PlanDetailVo getPlanDetailById(@Param("id") String id); PlanDetailVo getPlanDetailById(@Param("id") String id);
} }
...@@ -20,6 +20,9 @@ public interface IPlanDetailDao extends BaseDao<PlanDetail, Long> { ...@@ -20,6 +20,9 @@ public interface IPlanDetailDao extends BaseDao<PlanDetail, Long> {
@Query(value="SELECT * from c_plan_detail where status in (?1) AND is_delete = 0 ", nativeQuery = true) @Query(value="SELECT * from c_plan_detail where status in (?1) AND is_delete = 0 ", nativeQuery = true)
List<PlanDetail> findByStatus(Integer[] status); List<PlanDetail> findByStatus(Integer[] status);
@Query(value="SELECT * from c_plan_detail where sec_status in (?1) AND is_delete = 0 ", nativeQuery = true)
List<PlanDetail> findBySecStatus(Integer[] status);
List<PlanDetail> getPlanDetailsByIdInAndIsDelete(List<Long> idList, Boolean isDelete); List<PlanDetail> getPlanDetailsByIdInAndIsDelete(List<Long> idList, Boolean isDelete);
......
...@@ -19,6 +19,10 @@ public interface IPlanOperationRecordDao extends BaseDao<PlanOperationRecord, Lo ...@@ -19,6 +19,10 @@ public interface IPlanOperationRecordDao extends BaseDao<PlanOperationRecord, Lo
@Query(value="SELECT * from c_plan_operation_record where plan_id = ?1 AND is_delete = 0 AND status = 0 ORDER BY create_date DESC", nativeQuery = true) @Query(value="SELECT * from c_plan_operation_record where plan_id = ?1 AND is_delete = 0 AND status = 0 ORDER BY create_date DESC", nativeQuery = true)
List<PlanOperationRecord> findByPlanId1(Long planId); List<PlanOperationRecord> findByPlanId1(Long planId);
@Query(value="SELECT * from c_plan_operation_record where is_delete = 0 AND status = 0 AND plan_id = ?1 AND plan_rule_no = ?2 ORDER BY create_date DESC", nativeQuery = true)
List<PlanOperationRecord> findByPlanIdAndPlanRuleNo(Long planId, String PlanRuleNo);
int countByPlanId(Long planId); int countByPlanId(Long planId);
......
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.fas.business.event; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.fas.business.event;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.fas.business.action.ContingencyAction; import com.yeejoin.amos.fas.business.action.ContingencyAction;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo; import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent; import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
...@@ -16,6 +17,8 @@ import com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData; ...@@ -16,6 +17,8 @@ import com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance; import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.Equipment; import com.yeejoin.amos.fas.dao.entity.Equipment;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
...@@ -39,7 +42,7 @@ import java.util.*; ...@@ -39,7 +42,7 @@ import java.util.*;
@Component @Component
public class BizContingencyHandler implements EventHandler{ public class BizContingencyHandler implements EventHandler{
private final Logger log = LoggerFactory.getLogger(BizContingencyHandler.class);
@Autowired @Autowired
...@@ -101,13 +104,8 @@ public class BizContingencyHandler implements EventHandler{ ...@@ -101,13 +104,8 @@ public class BizContingencyHandler implements EventHandler{
public void updateData(ContingecyExecEvent event) throws Exception { public void updateData(ContingecyExecEvent event) throws Exception {
try { try {
// fire(event.getPlanExecute().getBatchNo(),
// event.getPlanExecute().getStepCode(),
// event.getPlanExecute().getContingencyPlanId(),
// event.getPlanExecute().getButtonCode(),
// event.getPlanExecute().getConfirm(),
// event.getPlanExecute().getStepState());
log.info(String.format("==BizContingencyHandler===fire====updateData==[%s]",JSONObject.toJSONString(event)));
// 更新redis中预案步骤数据 // 更新redis中预案步骤数据
planVisual3dService.updatePlanStepToRedis( planVisual3dService.updatePlanStepToRedis(
event.getPlanExecute().getBatchNo(), event.getPlanExecute().getBatchNo(),
...@@ -115,18 +113,21 @@ public class BizContingencyHandler implements EventHandler{ ...@@ -115,18 +113,21 @@ public class BizContingencyHandler implements EventHandler{
event.getPlanExecute().getButtonJson(), event.getPlanExecute().getButtonJson(),
event.getPlanExecute().getContingencyPlanId(), event.getPlanExecute().getContingencyPlanId(),
event.getPlanExecute().getButtonCode(), event.getPlanExecute().getButtonCode(),
event.getPlanExecute().getIsExecute(), event.getPlanExecute().getIsExecute(),
event.getPlanExecute().getPlanRuleNo(),
event.getPlanExecute().getIsAuto()); event.getPlanExecute().getIsAuto());
setButtonExecuted(event.getPlanExecute().getBatchNo(), setButtonExecuted(event.getPlanExecute().getBatchNo(),
event.getPlanExecute().getContingencyPlanId(), event.getPlanExecute().getContingencyPlanId(),
event.getPlanExecute().getButtonCode(), event.getPlanExecute().getButtonCode(),
event.getPlanExecute().getConfirm(), event.getPlanExecute().getConfirm(),
event.getPlanExecute().getPlanRuleNo(),
RequestContext.getLoginId()); RequestContext.getLoginId());
log.info("========BizContingencyHandler=======> updateData==PlanRuleNo===="+JSON.toJSONString(event.getPlanExecute().getPlanRuleNo()).toString());
} catch (Exception e) { } catch (Exception e) {
throw e; throw e;
} finally { } finally {
// 更新记录之后发送消息刷新 // 更新记录之后发送消息刷新
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(event.getPlanExecute().getPlanRuleNo())?"plan":"secPlan"));
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put("contingency", new ContingencyRo()); result.put("contingency", new ContingencyRo());
result.put("msgContext", Collections.EMPTY_MAP); result.put("msgContext", Collections.EMPTY_MAP);
...@@ -137,9 +138,10 @@ public class BizContingencyHandler implements EventHandler{ ...@@ -137,9 +138,10 @@ public class BizContingencyHandler implements EventHandler{
@Transactional @Transactional
public void setButtonExecuted(String batchNo, String contingencyPlanId, String code, String buttonState,String user) throws Exception { public void setButtonExecuted(String batchNo, String contingencyPlanId, String code, String buttonState, String planRuleNo, String user) throws Exception {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
ContingencyPlanInstance contingencyPlanInstance = contingencyInstance.getMessageById(contingencyPlanId); ContingencyPlanInstance contingencyPlanInstance = contingencyInstance.getMessageById(contingencyPlanId);
log.info("===============setButtonExecuted=planRuleNo==,{}",JSON.toJSONString(planRuleNo));
if (contingencyPlanInstance != null) { if (contingencyPlanInstance != null) {
if ("OPERATE".equals(contingencyPlanInstance.getRecordType())) { if ("OPERATE".equals(contingencyPlanInstance.getRecordType())) {
...@@ -176,8 +178,9 @@ public class BizContingencyHandler implements EventHandler{ ...@@ -176,8 +178,9 @@ public class BizContingencyHandler implements EventHandler{
} }
} }
ContingencyPlanInstance instance = repository.save(contingencyPlanInstance); ContingencyPlanInstance instance = repository.save(contingencyPlanInstance);
if (buttonState.equals("CONFIRM")) { if (buttonState.equals("CONFIRM")) {
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(planRuleNo)?"plan":"secPlan"));
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("contingency", new ContingencyRo()); map.put("contingency", new ContingencyRo());
map.put("msgContext", Collections.EMPTY_MAP); map.put("msgContext", Collections.EMPTY_MAP);
...@@ -185,7 +188,7 @@ public class BizContingencyHandler implements EventHandler{ ...@@ -185,7 +188,7 @@ public class BizContingencyHandler implements EventHandler{
webMqttComponent.publish(topic, JSON.toJSONString(map)); webMqttComponent.publish(topic, JSON.toJSONString(map));
} }
if (buttonState.equals("CANCEL_0")) { if (buttonState.equals("CANCEL_0")) {
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(planRuleNo)?"plan":"secPlan"));
System.out.println("=========================> 规则触发 初始化动作 initOperate "); System.out.println("=========================> 规则触发 初始化动作 initOperate ");
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("contingency", new ContingencyRo()); map.put("contingency", new ContingencyRo());
...@@ -215,7 +218,7 @@ public class BizContingencyHandler implements EventHandler{ ...@@ -215,7 +218,7 @@ public class BizContingencyHandler implements EventHandler{
planStep = planStepService.getPlanStep(); planStep = planStepService.getPlanStep();
} }
JSONArray objects = JSON.parseArray(planStep); JSONArray objects = JSON.parseArray(planStep);
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(planRuleNo)?"plan":"secPlan"));
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put("contingency", new ContingencyRo()); result.put("contingency", new ContingencyRo());
result.put("msgContext", Collections.EMPTY_MAP); result.put("msgContext", Collections.EMPTY_MAP);
......
...@@ -101,9 +101,11 @@ public class FireContingencyHandler implements EventHandler{ ...@@ -101,9 +101,11 @@ public class FireContingencyHandler implements EventHandler{
@Override @Override
public void handler(ContingecyExecEvent event) throws Exception { public void handler(ContingecyExecEvent event) throws Exception {
/** /**
* TODO 只处理调用触发下次原,不错业务数据更新 * TODO 只处理调用触发下次原,不错业务数据更新
*/ */
log.info(String.format("=====FireContingencyHandler===ContingecyExecEvent==[%s]",JSONObject.toJSONString(event)));
fire(event.getPlanExecute().getBatchNo(), fire(event.getPlanExecute().getBatchNo(),
event.getPlanExecute().getStepCode(), event.getPlanExecute().getStepCode(),
event.getPlanExecute().getContingencyPlanId(), event.getPlanExecute().getContingencyPlanId(),
...@@ -122,7 +124,8 @@ public class FireContingencyHandler implements EventHandler{ ...@@ -122,7 +124,8 @@ public class FireContingencyHandler implements EventHandler{
public void fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton, String isAuto) throws Exception { public void fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton, String isAuto) throws Exception {
//火灾误报 //火灾误报
ContingencyOriginalData contingencyOriginalData = iContingencyOriginalDataDao.findByBatchNo(batchNo); ContingencyOriginalData contingencyOriginalData = iContingencyOriginalDataDao.findByBatchNo(batchNo);
log.info(String.format("=====FireContingencyHandler===fire==[%s]",JSONObject.toJSONString(contingencyOriginalData)));
String planRuleNo = contingencyOriginalData.getPlanRuleNo();
String stepKey = batchNo + "_" + stepCode; String stepKey = batchNo + "_" + stepCode;
if (stepMap.get(stepKey) == null) if (stepMap.get(stepKey) == null)
stepMap.put(stepKey, ""); stepMap.put(stepKey, "");
...@@ -139,11 +142,7 @@ public class FireContingencyHandler implements EventHandler{ ...@@ -139,11 +142,7 @@ public class FireContingencyHandler implements EventHandler{
&& stepCode.equals(contingencyOriginalData.getStep())) && stepCode.equals(contingencyOriginalData.getStep()))
contingencyOriginalData.setStepState(contingencyOriginalData.getStepState() + stepStateOnbutton); contingencyOriginalData.setStepState(contingencyOriginalData.getStepState() + stepStateOnbutton);
//请求中的步骤小于以保存的步骤
// if (Integer.parseInt(stepCode) < Integer.parseInt(contingencyOriginalData.getStep()) ) {
// contingencyOriginalData.setRunstep(true);
// }
if (Integer.parseInt(stepCode) > Integer.parseInt(contingencyOriginalData.getStep())) { if (Integer.parseInt(stepCode) > Integer.parseInt(contingencyOriginalData.getStep())) {
contingencyOriginalData.setStepState(stepStateOnbutton); contingencyOriginalData.setStepState(stepStateOnbutton);
} }
...@@ -163,12 +162,7 @@ public class FireContingencyHandler implements EventHandler{ ...@@ -163,12 +162,7 @@ public class FireContingencyHandler implements EventHandler{
} else { } else {
contingencyRo.setFireTruckRoute("false"); contingencyRo.setFireTruckRoute("false");
} }
// //需要优化
// ContingencyInstanceInfoVO infoVO = contingencyInstanceInfoService.selectDisposalDetails(batchNo);
// if (!ObjectUtils.isEmpty(infoVO.getPosition())) {
// contingencyOriginalData.setPosition(infoVO.getPosition());
// }
contingencyOriginalData.setPosition(contingencyOriginalData.getFireEquipmentPosition()); contingencyOriginalData.setPosition(contingencyOriginalData.getFireEquipmentPosition());
BeanUtils.copyProperties(contingencyOriginalData, contingencyRo); BeanUtils.copyProperties(contingencyOriginalData, contingencyRo);
...@@ -182,20 +176,6 @@ public class FireContingencyHandler implements EventHandler{ ...@@ -182,20 +176,6 @@ public class FireContingencyHandler implements EventHandler{
} }
log.info("stepstate:" + contingencyRo.getStepState()); log.info("stepstate:" + contingencyRo.getStepState());
log.info("stepCode:" + stepCode); log.info("stepCode:" + stepCode);
// equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(Long.parseLong(contingencyRo.getFireEquipmentId()));
// if (equipment != null) {
// contingencyRo.setEquipmentCode(equipment.getCode());
// Map<String, Object> params = contingencyRo.getParams();
// params.put("appKey", RequestContext.getAppKey());
// params.put("product", RequestContext.getProduct());
// params.put("token", RequestContext.getToken());
//
// contingencyRo.setParams(params);
//
// List<String> plan = this.getNumberPlan(Long.parseLong(contingencyRo.getEquipmentId()));
//
// ruleTrigger.publish(contingencyRo, "换流站消防专项预案/" + plan.get(0), ArrayUtils.toArray(equipment.getName()));
// }
if (StringUtils.isNotEmpty(contingencyOriginalData.getEquipmentName())) { if (StringUtils.isNotEmpty(contingencyOriginalData.getEquipmentName())) {
Map<String, Object> params = contingencyRo.getParams(); Map<String, Object> params = contingencyRo.getParams();
...@@ -206,12 +186,9 @@ public class FireContingencyHandler implements EventHandler{ ...@@ -206,12 +186,9 @@ public class FireContingencyHandler implements EventHandler{
params.put("product", amosRequestContext.getProduct()); params.put("product", amosRequestContext.getProduct());
params.put("token", amosRequestContext.getToken()); params.put("token", amosRequestContext.getToken());
log.info("appKey===,{}", amosRequestContext.getAppKey());
log.info("product====,{}", amosRequestContext.getProduct());
log.info("token====,{}", amosRequestContext.getToken());
contingencyRo.setParams(params); contingencyRo.setParams(params);
List<String> plan = this.getNumberPlan(Long.parseLong(contingencyRo.getEquipmentId())); List<String> plan = "1".equals(planRuleNo)?this.getNumberPlan(Long.parseLong(contingencyRo.getEquipmentId())):
planDetailMapper.getSecRuleIdByEquipment(Long.parseLong(contingencyRo.getEquipmentId()));
ruleTrigger.publish(contingencyRo, "换流站消防专项预案/" + plan.get(0), ArrayUtils.toArray(contingencyOriginalData.getEquipmentName())); ruleTrigger.publish(contingencyRo, "换流站消防专项预案/" + plan.get(0), ArrayUtils.toArray(contingencyOriginalData.getEquipmentName()));
} }
...@@ -246,9 +223,10 @@ public class FireContingencyHandler implements EventHandler{ ...@@ -246,9 +223,10 @@ public class FireContingencyHandler implements EventHandler{
ContingencyRo paramObj = new ContingencyRo(); ContingencyRo paramObj = new ContingencyRo();
paramObj.setBatchNo(contingencyRo.getBatchNo()); paramObj.setBatchNo(contingencyRo.getBatchNo());
paramObj.setEquipmentId(contingencyRo.getEquipmentId()); paramObj.setEquipmentId(contingencyRo.getEquipmentId());
paramObj.setPlanRuleNo(contingencyRo.getPlanRuleNo());
contingencyAction.sendcmdT("recordarea", paramObj, result); contingencyAction.sendcmdT("recordarea", paramObj, result);
if (StringUtils.isNotEmpty(contingencyOriginalData.getEquipmentName())) { if (StringUtils.isNotEmpty(contingencyOriginalData.getEquipmentName())) {
publisherPlanLog(stepCode, buttonCode, batchNo); publisherPlanLog(stepCode, buttonCode, batchNo, planRuleNo);
} }
} else { } else {
throw new Exception("数据异常,请联系管理员."); throw new Exception("数据异常,请联系管理员.");
...@@ -261,7 +239,7 @@ public class FireContingencyHandler implements EventHandler{ ...@@ -261,7 +239,7 @@ public class FireContingencyHandler implements EventHandler{
return ruleId; return ruleId;
} }
private void publisherPlanLog(String stepCode, String buttonCode, String batchNo) { private void publisherPlanLog(String stepCode, String buttonCode, String batchNo, String planRuleNo) {
ContingencyEvent event = new ContingencyEvent(this); ContingencyEvent event = new ContingencyEvent(this);
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
JSONObject msgContext = new JSONObject(); JSONObject msgContext = new JSONObject();
...@@ -273,7 +251,7 @@ public class FireContingencyHandler implements EventHandler{ ...@@ -273,7 +251,7 @@ public class FireContingencyHandler implements EventHandler{
json.put("msgType", "message"); json.put("msgType", "message");
json.put("msgContext", msgContext); json.put("msgContext", msgContext);
event.setMsgBody(json.toJSONString()); event.setMsgBody(json.toJSONString());
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(planRuleNo)?"plan":"secPlan"));
event.setTopic(topic); event.setTopic(topic);
event.setMsgType("clickEvent"); event.setMsgType("clickEvent");
event.setContingency(batchNo); event.setContingency(batchNo);
......
...@@ -155,7 +155,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -155,7 +155,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
* @param icon 信息显示图标 * @param icon 信息显示图标
*/ */
@Transactional @Transactional
public ContingencyPlanInstance createInstanceRecord(String instanceNo, String category, String subCategory, String content, String recordType, String icon) { public ContingencyPlanInstance createInstanceRecord(String instanceNo, String category, String subCategory, String content, String recordType, String icon, String planRuleNo) {
ContingencyPlanInstance planInstance = new ContingencyPlanInstance(); ContingencyPlanInstance planInstance = new ContingencyPlanInstance();
if ("MESSAGE".equalsIgnoreCase(recordType)) { if ("MESSAGE".equalsIgnoreCase(recordType)) {
planInstance.setFileType(PlanReplyMessageEnum.TEXT.getCode()); planInstance.setFileType(PlanReplyMessageEnum.TEXT.getCode());
...@@ -166,6 +166,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -166,6 +166,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
planInstance.setCategory(category); planInstance.setCategory(category);
planInstance.setBatchNo(instanceNo); planInstance.setBatchNo(instanceNo);
planInstance.setCreateDate(new Date()); planInstance.setCreateDate(new Date());
planInstance.setPlanRuleNo(planRuleNo);
if ("OPERATE".equalsIgnoreCase(recordType)) { if ("OPERATE".equalsIgnoreCase(recordType)) {
JSONObject obj = JSON.parseObject(content); JSONObject obj = JSON.parseObject(content);
planInstance.setStepCode(String.valueOf(obj.get("stepCode"))); planInstance.setStepCode(String.valueOf(obj.get("stepCode")));
...@@ -201,7 +202,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -201,7 +202,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
} }
@Transactional @Transactional
public Optional<Equipment> fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton) throws Exception { public Optional<Equipment> fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState
, String stepStateOnbutton) throws Exception {
//火灾误报 //火灾误报
ContingencyOriginalData contingencyOriginalData = iContingencyOriginalDataDao.findByBatchNo(batchNo); ContingencyOriginalData contingencyOriginalData = iContingencyOriginalDataDao.findByBatchNo(batchNo);
...@@ -266,7 +268,9 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -266,7 +268,9 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
log.info("stepCode:" + stepCode); log.info("stepCode:" + stepCode);
equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(Long.parseLong(contingencyRo.getFireEquipmentId())); equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(Long.parseLong(contingencyRo.getFireEquipmentId()));
if (equipment != null) { if (equipment != null) {
contingencyRo.setEquipmentCode(equipment.getCode()); equipment.setPlanRuleNo(contingencyOriginalData.getPlanRuleNo());
contingencyRo.setEquipmentCode(equipment.getCode());
Map<String, Object> params = contingencyRo.getParams(); Map<String, Object> params = contingencyRo.getParams();
Toke toke = remoteSecurityService.getTokenS(); Toke toke = remoteSecurityService.getTokenS();
RequestContext.setProduct(toke.getProduct()); RequestContext.setProduct(toke.getProduct());
...@@ -276,18 +280,13 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -276,18 +280,13 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
params.put("product", toke.getProduct()); params.put("product", toke.getProduct());
params.put("token", toke.getAppKey()); params.put("token", toke.getAppKey());
log.info("appKey===11,{}", toke.getAppKey());
log.info("product====11,{}", toke.getProduct());
log.info("token====11,{}", toke.getToke());
contingencyRo.setParams(params); contingencyRo.setParams(params);
List<String> plan = this.getNumberPlan(Long.parseLong(contingencyRo.getEquipmentId())); List<String> plan = "1".equals(contingencyOriginalData.getPlanRuleNo())?this.getNumberPlan(Long.parseLong(contingencyRo.getEquipmentId())):
// contingencyRo.setRunstep(false); planDetailMapper.getSecRuleIdByEquipment(Long.parseLong(contingencyRo.getEquipmentId()));
ruleTrigger.publish(contingencyRo, "换流站消防专项预案/" + plan.get(0), ArrayUtils.toArray(equipment.getName())); ruleTrigger.publish(contingencyRo, "换流站消防专项预案/" + plan.get(0), ArrayUtils.toArray(equipment.getName()));
publisherPlanLog(stepCode, buttonCode, batchNo); publisherPlanLog(stepCode, buttonCode, batchNo, contingencyOriginalData.getPlanRuleNo());
} }
} else { } else {
throw new Exception("数据异常,请联系管理员."); throw new Exception("数据异常,请联系管理员.");
...@@ -295,7 +294,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -295,7 +294,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
return Optional.ofNullable(equipment); return Optional.ofNullable(equipment);
} }
private void publisherPlanLog(String stepCode, String buttonCode, String batchNo) { private void publisherPlanLog(String stepCode, String buttonCode, String batchNo, String planRuleNo) {
ContingencyEvent event = new ContingencyEvent(this); ContingencyEvent event = new ContingencyEvent(this);
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
JSONObject msgContext = new JSONObject(); JSONObject msgContext = new JSONObject();
...@@ -307,7 +306,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -307,7 +306,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
json.put("msgType", "message"); json.put("msgType", "message");
json.put("msgContext", msgContext); json.put("msgContext", msgContext);
event.setMsgBody(json.toJSONString()); event.setMsgBody(json.toJSONString());
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(planRuleNo)?"plan":"secPlan"));
event.setTopic(topic); event.setTopic(topic);
event.setMsgType("clickEvent"); event.setMsgType("clickEvent");
event.setContingency(batchNo); event.setContingency(batchNo);
...@@ -319,6 +318,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -319,6 +318,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
ContingencyPlanInstance contingencyPlanInstance = contingencyInstance.getMessageById(contingencyPlanId); ContingencyPlanInstance contingencyPlanInstance = contingencyInstance.getMessageById(contingencyPlanId);
if (contingencyPlanInstance != null) { if (contingencyPlanInstance != null) {
String planRuleNo = contingencyPlanInstance.getPlanRuleNo();
if ("OPERATE".equals(contingencyPlanInstance.getRecordType())) { if ("OPERATE".equals(contingencyPlanInstance.getRecordType())) {
String operateJson = contingencyPlanInstance.getContent(); String operateJson = contingencyPlanInstance.getContent();
...@@ -355,7 +356,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -355,7 +356,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
} }
ContingencyPlanInstance instance = repository.save(contingencyPlanInstance); ContingencyPlanInstance instance = repository.save(contingencyPlanInstance);
if (buttonState.equals("CONFIRM")) { if (buttonState.equals("CONFIRM")) {
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(planRuleNo)?"plan":"secPlan"));
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("contingency", new ContingencyRo()); map.put("contingency", new ContingencyRo());
map.put("msgContext", Collections.EMPTY_MAP); map.put("msgContext", Collections.EMPTY_MAP);
...@@ -363,7 +364,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -363,7 +364,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
webMqttComponent.publish(topic, JSON.toJSONString(map)); webMqttComponent.publish(topic, JSON.toJSONString(map));
} }
if (buttonState.equals("CANCEL_0")) { if (buttonState.equals("CANCEL_0")) {
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(planRuleNo)?"plan":"secPlan"));
System.out.println("=========================> 规则触发 初始化动作 initOperate "); System.out.println("=========================> 规则触发 初始化动作 initOperate ");
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("contingency", new ContingencyRo()); map.put("contingency", new ContingencyRo());
...@@ -421,16 +422,18 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -421,16 +422,18 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
@Override @Override
public void updateStep(String step, String batchNo) { public void updateStep(String step, String batchNo, String planRuleNo) {
int update = iContingencyOriginalDataDao.updateByButtonStep(step, batchNo); int update = iContingencyOriginalDataDao.updateByButtonStep(step, batchNo);
emergencyTaskService.saveTask(step, batchNo); emergencyTaskService.saveTask(step, batchNo, planRuleNo);
// 异步数据同步之消息发送 // 异步数据同步之消息发送
// contingencyOriginalDataDataSync(batchNo, update); // contingencyOriginalDataDataSync(batchNo, update);
} }
@Override @Override
public Optional<Equipment> fire(String batchNo, String stepCode, String buttonJson, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton, String isExecute, String isAuto, String token, String product, String appKey,String startUserName) throws Exception { public Optional<Equipment> fire(String batchNo, String stepCode, String buttonJson, String contingencyPlanId, String buttonCode
, String buttonState, String stepStateOnbutton, String isExecute, String isAuto, String token, String product, String appKey
,String startUserName, String planRuleNo) throws Exception {
log.info(String.format("=====ContingencyInstanceImpl=fire====buttonJson==[%s]",JSONObject.toJSONString(buttonJson)));
PlanExecuteVo vo = new PlanExecuteVo(); PlanExecuteVo vo = new PlanExecuteVo();
vo.setConfirm(buttonState); vo.setConfirm(buttonState);
vo.setStepState(stepStateOnbutton); vo.setStepState(stepStateOnbutton);
...@@ -441,11 +444,13 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -441,11 +444,13 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
vo.setButtonJson(buttonJson); vo.setButtonJson(buttonJson);
vo.setIsAuto(isAuto); vo.setIsAuto(isAuto);
vo.setIsExecute(isExecute); vo.setIsExecute(isExecute);
vo.setPlanRuleNo(planRuleNo);
ContingecyExecEvent fireEvent = new ContingecyExecEvent(this); ContingecyExecEvent fireEvent = new ContingecyExecEvent(this);
fireEvent.setEventType(EventType.FIRE_NEXT_RULE.name()); fireEvent.setEventType(EventType.FIRE_NEXT_RULE.name());
fireEvent.setPlanExecute(vo); fireEvent.setPlanExecute(vo);
fireEvent.setContext(RequestContext.cloneRequestContext()); fireEvent.setContext(RequestContext.cloneRequestContext());
log.info(String.format("===ContingencyInstanceImpl==fire====fireEvent==[%s]",JSONObject.toJSONString(fireEvent)));
applicationContext.publishEvent(fireEvent); applicationContext.publishEvent(fireEvent);
ContingecyExecEvent updateEvent = new ContingecyExecEvent(this); ContingecyExecEvent updateEvent = new ContingecyExecEvent(this);
updateEvent.setEventType(EventType.UPDATE_CONTINGENCY_DATE.name()); updateEvent.setEventType(EventType.UPDATE_CONTINGENCY_DATE.name());
...@@ -453,6 +458,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -453,6 +458,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
updateEvent.setContext(RequestContext.cloneRequestContext()); updateEvent.setContext(RequestContext.cloneRequestContext());
// TODO 构建event对象, // TODO 构建event对象,
try { try {
log.info(String.format("===ContingencyInstanceImpl==fire====updateEvent==[%s]",JSONObject.toJSONString(updateEvent)));
applicationContext.publishEvent(updateEvent); applicationContext.publishEvent(updateEvent);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -467,7 +473,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -467,7 +473,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
} }
@Override @Override
public Optional<Equipment> clickButton(String batchNo, String stepCode, String buttonJson, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton, String isExecute, String isAuto, String token, String product, String appKey,String startUserName) throws Exception { public Optional<Equipment> clickButton(String batchNo, String stepCode, String buttonJson, String contingencyPlanId
, String buttonCode, String buttonState, String stepStateOnbutton, String isExecute, String isAuto, String token, String product, String appKey,String startUserName) throws Exception {
String planType = null; String planType = null;
if (redisTemplate.hasKey("planType")) { if (redisTemplate.hasKey("planType")) {
planType = redisTemplate.boundValueOps("planType").get(0, -1); planType = redisTemplate.boundValueOps("planType").get(0, -1);
...@@ -475,13 +482,14 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -475,13 +482,14 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
// 此处逻辑修改为所有任务执行完成才会点亮节点 // 此处逻辑修改为所有任务执行完成才会点亮节点
List<EmergencyTaskContentVo> tasks = emergencyTaskService.getMustTaskList(stepCode, planType); List<EmergencyTaskContentVo> tasks = emergencyTaskService.getMustTaskList(stepCode, planType);
boolean flag = judgeIfConfirmed(tasks, batchNo); boolean flag = judgeIfConfirmed(tasks, batchNo);
ContingencyPlanInstance instance = contingencyPlanInstanceMapper.getMessageById(contingencyPlanId);
log.info(String.format("===ContingencyInstanceImpl==clickButton====instance==[%s]",JSONObject.toJSONString(instance)));
if ("0".equals(stepCode) && flag) { if ("0".equals(stepCode) && flag) {
contingencyInstance.fire(batchNo, stepCode, buttonJson, contingencyPlanId, contingencyInstance.fire(batchNo, stepCode, buttonJson, contingencyPlanId,
"FIRE_CONFIRM", buttonState, stepStateOnbutton, "true", "false", token, "FIRE_CONFIRM", buttonState, stepStateOnbutton, "true", "false", token,
product, appKey, startUserName); product, appKey, startUserName, instance.getPlanRuleNo());
} }
ContingencyPlanInstance instance = contingencyPlanInstanceMapper.getMessageById(contingencyPlanId);
instance.setId(null); instance.setId(null);
instance.setRecordType("REPLYMESSAGE"); instance.setRecordType("REPLYMESSAGE");
instance.setCreateDate(new Date()); instance.setCreateDate(new Date());
...@@ -499,6 +507,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -499,6 +507,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
vo.setButtonJson(buttonJson); vo.setButtonJson(buttonJson);
vo.setIsAuto(isAuto); vo.setIsAuto(isAuto);
vo.setIsExecute(isExecute); vo.setIsExecute(isExecute);
vo.setPlanRuleNo(res.getPlanRuleNo());
ContingecyExecEvent fireEvent = new ContingecyExecEvent(this); ContingecyExecEvent fireEvent = new ContingecyExecEvent(this);
fireEvent.setEventType(EventType.FIRE_NEXT_RULE.name()); fireEvent.setEventType(EventType.FIRE_NEXT_RULE.name());
...@@ -522,7 +531,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -522,7 +531,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
planStep = planStepService.getPlanStep(); planStep = planStepService.getPlanStep();
} }
JSONArray objects = JSON.parseArray(planStep); JSONArray objects = JSON.parseArray(planStep);
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(res.getPlanRuleNo())?"plan":"secPlan"));
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put("contingency", new ContingencyRo()); result.put("contingency", new ContingencyRo());
result.put("msgContext", Collections.EMPTY_MAP); result.put("msgContext", Collections.EMPTY_MAP);
...@@ -540,7 +549,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -540,7 +549,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
webMqttComponent.publish(topic, JSON.toJSONString(result)); webMqttComponent.publish(topic, JSON.toJSONString(result));
} }
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(res.getPlanRuleNo())?"plan":"secPlan"));
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("contingency", new ContingencyRo()); map.put("contingency", new ContingencyRo());
map.put("msgContext", Collections.EMPTY_MAP); map.put("msgContext", Collections.EMPTY_MAP);
...@@ -676,6 +685,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -676,6 +685,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
String product = map.get("product"); String product = map.get("product");
String token = map.get("token"); String token = map.get("token");
String user = map.containsKey("startUserName") ? map.get("startUserName") : null; String user = map.containsKey("startUserName") ? map.get("startUserName") : null;
String planRuleNo = map.get("planRuleNo");
log.info("===============> runFireQueue==PlanRuleNo===="+JSON.toJSONString(planRuleNo).toString());
try { try {
RequestContext.setAppKey(appKey); RequestContext.setAppKey(appKey);
RequestContext.setProduct(product); RequestContext.setProduct(product);
...@@ -683,13 +694,13 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -683,13 +694,13 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
fire(batchNo, stepCode, contingencyPlanId, buttonCode, confirm, stepState); fire(batchNo, stepCode, contingencyPlanId, buttonCode, confirm, stepState);
// 更新redis中预案步骤数据 // 更新redis中预案步骤数据
planVisual3dService.updatePlanStepToRedis(batchNo, stepCode, buttonJson, contingencyPlanId, buttonCode, isExecute, isAuto); planVisual3dService.updatePlanStepToRedis(batchNo, stepCode, buttonJson, contingencyPlanId, buttonCode, isExecute, planRuleNo,isAuto);
setButtonExecuted(batchNo, contingencyPlanId, buttonCode, confirm, user); setButtonExecuted(batchNo, contingencyPlanId, buttonCode, confirm, user);
} catch (Exception e) { } catch (Exception e) {
throw e; throw e;
} finally { } finally {
// 更新记录之后发送消息刷新 // 更新记录之后发送消息刷新
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(planRuleNo)?"plan":"secPlan"));
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put("contingency", new ContingencyRo()); result.put("contingency", new ContingencyRo());
result.put("msgContext", Collections.EMPTY_MAP); result.put("msgContext", Collections.EMPTY_MAP);
......
...@@ -19,6 +19,7 @@ import com.yeejoin.amos.fas.common.enums.*; ...@@ -19,6 +19,7 @@ import com.yeejoin.amos.fas.common.enums.*;
import com.yeejoin.amos.fas.core.enums.NumberEnum; import com.yeejoin.amos.fas.core.enums.NumberEnum;
import com.yeejoin.amos.fas.core.enums.ReserveEnum; import com.yeejoin.amos.fas.core.enums.ReserveEnum;
import com.yeejoin.amos.fas.core.util.DateUtil; import com.yeejoin.amos.fas.core.util.DateUtil;
import com.yeejoin.amos.fas.core.util.StringUtil;
import com.yeejoin.amos.fas.dao.entity.*; import com.yeejoin.amos.fas.dao.entity.*;
import com.yeejoin.amos.fas.datasync.bo.PlanDetailSyncBo; import com.yeejoin.amos.fas.datasync.bo.PlanDetailSyncBo;
import com.yeejoin.amos.fas.datasync.bo.PlanOperationRecordSyncBo; import com.yeejoin.amos.fas.datasync.bo.PlanOperationRecordSyncBo;
...@@ -143,7 +144,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -143,7 +144,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
ContingencyPlanResponseVo result = new ContingencyPlanResponseVo(); ContingencyPlanResponseVo result = new ContingencyPlanResponseVo();
//状态校验 //状态校验
logger.info("========状态校验==========="); logger.info("========状态校验===========");
ReserveEnum reserveEnum = this.runCheck(vo); ReserveEnum reserveEnum = "1".equals(vo.getPlanRuleNo())?this.runCheck(vo):this.secRunCheck(vo);
result.setMessage(reserveEnum.getText()); result.setMessage(reserveEnum.getText());
PlanDetailVo detailVo = planDetailMapper.getPlanDetailById(vo.getPlanId()); PlanDetailVo detailVo = planDetailMapper.getPlanDetailById(vo.getPlanId());
Optional<PlanClassifyTree> tree = classifyTreeDao.findById(detailVo.getClassifyId()); Optional<PlanClassifyTree> tree = classifyTreeDao.findById(detailVo.getClassifyId());
...@@ -153,7 +154,8 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -153,7 +154,8 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
planStepService.initPlanStep(); planStepService.initPlanStep();
} }
if (ReserveEnum.THISRUNNING.getStatus().equals(reserveEnum.getStatus())) { if (ReserveEnum.THISRUNNING.getStatus().equals(reserveEnum.getStatus())) {
List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId())); List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanIdAndPlanRuleNo(Long.valueOf(vo.getPlanId()), vo.getPlanRuleNo());
// planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId()));
result.setMessage(ReserveEnum.THISRUNNING.getText()); result.setMessage(ReserveEnum.THISRUNNING.getText());
result.setBatchNo(recordList.get(0).getBatchNo()); result.setBatchNo(recordList.get(0).getBatchNo());
return result; return result;
...@@ -173,7 +175,12 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -173,7 +175,12 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
result.setMessage(ReserveEnum.NOEQUIP.getText()); result.setMessage(ReserveEnum.NOEQUIP.getText());
return result; return result;
} }
equipment.setReservePlan("换流站消防专项预案" + "/" + planRuleList.get(0).getRuleId()); String rule = ("1".equals(vo.getPlanRuleNo())?planRuleList.get(0).getRuleId():planRuleList.get(0).getSecRuleId());
if(!StringUtil.isNotEmpty(rule)){
result.setMessage("该预案规则文件不存在,请核实后再试!");
return result;
}
equipment.setReservePlan("换流站消防专项预案" + "/" + rule);
//电力设备绑定装备 //电力设备绑定装备
EquipmentSpecificForRiskVo equipmentSpecific; EquipmentSpecificForRiskVo equipmentSpecific;
...@@ -218,6 +225,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -218,6 +225,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
PlanOperationRecord.setEquipmentName(specificName); PlanOperationRecord.setEquipmentName(specificName);
PlanOperationRecord.setEquipmentId(equipmentSpecific.getId()); PlanOperationRecord.setEquipmentId(equipmentSpecific.getId());
PlanOperationRecord.setFireEquipmentId(equipment.getId()); PlanOperationRecord.setFireEquipmentId(equipment.getId());
PlanOperationRecord.setPlanRuleNo(vo.getPlanRuleNo());
if (ContingencyPlanStatusEnum.SIMULATION_START.getCode().equals(vo.getStatus())) { if (ContingencyPlanStatusEnum.SIMULATION_START.getCode().equals(vo.getStatus())) {
PlanOperationRecord.setExecutionType(ExecutionTypeEnum.PLANCHECK.getCode()); PlanOperationRecord.setExecutionType(ExecutionTypeEnum.PLANCHECK.getCode());
} else { } else {
...@@ -237,7 +245,12 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -237,7 +245,12 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
//更新模型状态 //更新模型状态
PlanDetail planDetail = PlanDetailOp.get(); PlanDetail planDetail = PlanDetailOp.get();
planDetail.setStatus(vo.getStatus()); if("1".equals(vo.getPlanRuleNo())){
planDetail.setStatus(vo.getStatus());
}else{
planDetail.setSecStatus(vo.getStatus());
}
planDetail.setPlanRuleNo(vo.getPlanRuleNo());
PlanDetail detail = planDetailDao.saveAndFlush(planDetail); PlanDetail detail = planDetailDao.saveAndFlush(planDetail);
//更新预案执行记录表的批次号 //更新预案执行记录表的批次号
operationRecord.setBatchNo(batchNo); operationRecord.setBatchNo(batchNo);
...@@ -247,6 +260,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -247,6 +260,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
instanceInfo.setName(detail.getPlanName()); instanceInfo.setName(detail.getPlanName());
instanceInfo.setOrgCode(detail.getOrgCode()); instanceInfo.setOrgCode(detail.getOrgCode());
instanceInfo.setPosition(equipmentSpecific.getPosition()); instanceInfo.setPosition(equipmentSpecific.getPosition());
instanceInfo.setPlanRuleNo(vo.getPlanRuleNo());
contingencyInstanceInfoService.addDisposalDetails(instanceInfo); contingencyInstanceInfoService.addDisposalDetails(instanceInfo);
result.setMessage(ReserveEnum.RUN.getText()); result.setMessage(ReserveEnum.RUN.getText());
...@@ -255,8 +269,8 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -255,8 +269,8 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override @Override
public void afterCommit() { public void afterCommit() {
equipmentHandlerService.executeDynamicPlan(batchNo, deviceData, equipment, equipmentSpecific, toke, operationRecord.getId()); equipmentHandlerService.executeDynamicPlan(batchNo, deviceData, equipment, equipmentSpecific, toke, operationRecord.getId(), vo.getPlanRuleNo());
emergencyTaskService.saveTask("0", batchNo); emergencyTaskService.saveTask("0", batchNo, vo.getPlanRuleNo());
} }
}); });
...@@ -277,7 +291,9 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -277,7 +291,9 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
contingencyRo.setEquipmentOrgCode(equipment.getOrgCode()); contingencyRo.setEquipmentOrgCode(equipment.getOrgCode());
contingencyRo.getParams().put("equipmentId", equipment.getId()); contingencyRo.getParams().put("equipmentId", equipment.getId());
contingencyRo.setPosition(equipmentSpecific.getPosition()); contingencyRo.setPosition(equipmentSpecific.getPosition());
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); contingencyRo.setPlanRuleNo(vo.getPlanRuleNo());
logger.info("===============> planStart==PlanRuleNo===="+JSON.toJSONString(vo.getPlanRuleNo()).toString());
String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(vo.getPlanRuleNo())?"plan":"secPlan"));
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
JSONObject msgContext = new JSONObject(); JSONObject msgContext = new JSONObject();
msgContext.put("content", "startPlanFirst"); msgContext.put("content", "startPlanFirst");
...@@ -285,17 +301,10 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -285,17 +301,10 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
msgContext.put("isShowAlertBox", "true"); msgContext.put("isShowAlertBox", "true");
} }
map.put("contingency", new ContingencyRo()); map.put("contingency", new ContingencyRo());
// map.put("msgContext", "{\"content\":\"startPlan\"}");
// msgContext.put("content", "startPlan");
map.put("contingency", contingencyRo); map.put("contingency", contingencyRo);
map.put("msgContext", msgContext); map.put("msgContext", msgContext);
map.put("msgType", "refreshRecord"); map.put("msgType", "refreshRecord");
webMqttComponent.publish(topic, JSON.toJSONString(map)); webMqttComponent.publish(topic, JSON.toJSONString(map));
// if(vo.getTriggerMode().equals("automatic")) {
// logger.info("===============开始查询ButtonJson");
// getStepButtonJson(batchNo, toke);
// }
} }
return result; return result;
} }
...@@ -303,18 +312,19 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -303,18 +312,19 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
@Override @Override
public ContingencyPlanResponseVo planStartFirst(String batchNo, Toke toke) { public ContingencyPlanResponseVo planStartFirst(String batchNo, Toke toke) {
logger.info("开始查询Step============="); logger.info("开始查询Step=============");
for (int i =0; i < 120 ; i++) { for (int i =0; i < 20 ; i++) {
ToipResponse planStepByBatchNo = planVisual3dService.getPlanStepByBatchNo(batchNo); ToipResponse planStepByBatchNo = planVisual3dService.getPlanStepByBatchNo(batchNo);
logger.info("===============1111111,{}", planStepByBatchNo); logger.info("===============planStartFirst==planStepByBatchNo=,{}",JSONObject.toJSONString(planStepByBatchNo));
if(null != planStepByBatchNo && null != planStepByBatchNo.getMsgContext()) { if(null != planStepByBatchNo && null != planStepByBatchNo.getMsgContext()) {
String str = JSONObject.toJSONString(planStepByBatchNo.getMsgContext()); String str = JSONObject.toJSONString(planStepByBatchNo.getMsgContext());
JSONObject obj = JSON.parseObject(str); JSONObject obj = JSON.parseObject(str);
JSONArray arr = obj.getJSONArray("step"); JSONArray arr = obj.getJSONArray("step");
JSONObject step = arr.getJSONObject(0); JSONObject step = arr.getJSONObject(0);
logger.info("===============查询到step===,{}",step);
if (!ObjectUtils.isEmpty(step.get("buttonJson"))) { if (!ObjectUtils.isEmpty(step.get("buttonJson"))) {
logger.info("===============查询到ButtonJson"); logger.info("===============查询到ButtonJson");
try { try {
iContingencyInstance.fire(batchNo, "0", step.get("buttonJson").toString(), step.get("caseId").toString(), "FIRE_CONFIRM", "CONFIRM", "0", "true", "false", toke.getToke(), toke.getProduct(), toke.getAppKey(), null); iContingencyInstance.fire(batchNo, "0", step.get("buttonJson").toString(), step.get("caseId").toString(), "FIRE_CONFIRM", "CONFIRM", "0", "true", "false", toke.getToke(), toke.getProduct(), toke.getAppKey(), null, planStepByBatchNo.getPlanRuleNo());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -419,7 +429,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -419,7 +429,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
if (planEquipments.isEmpty()) { if (planEquipments.isEmpty()) {
return ReserveEnum.PLAN_EQUIP_IS_DELETE; return ReserveEnum.PLAN_EQUIP_IS_DELETE;
} }
List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId())); List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanIdAndPlanRuleNo(Long.valueOf(vo.getPlanId()), vo.getPlanRuleNo());
if (recordList.size() > 0 && !vo.getStatus().equals(ContingencyPlanStatusEnum.ONGOING.getCode())) { if (recordList.size() > 0 && !vo.getStatus().equals(ContingencyPlanStatusEnum.ONGOING.getCode())) {
return ReserveEnum.THISRUNNING; return ReserveEnum.THISRUNNING;
} }
...@@ -427,7 +437,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -427,7 +437,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
Integer[] statusArray = (Integer[]) Arrays.asList(ContingencyPlanStatusEnum.SIMULATION_START.getCode(), ContingencyPlanStatusEnum.ONGOING.getCode()).toArray(); Integer[] statusArray = (Integer[]) Arrays.asList(ContingencyPlanStatusEnum.SIMULATION_START.getCode(), ContingencyPlanStatusEnum.ONGOING.getCode()).toArray();
List<PlanDetail> count = planDetailDao.findByStatus(statusArray); List<PlanDetail> count = planDetailDao.findByStatus(statusArray);
if (count.size() > NumberEnum.ZERO.getValue()) { if (count.size() > NumberEnum.ZERO.getValue()) {
return ReserveEnum.RUNNING; // return ReserveEnum.RUNNING;
} }
} else if (ContingencyPlanStatusEnum.ONGOING.getCode().equals(vo.getStatus())) { } else if (ContingencyPlanStatusEnum.ONGOING.getCode().equals(vo.getStatus())) {
...@@ -443,10 +453,18 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -443,10 +453,18 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
Optional<Equipment> equipment = iContingencyInstance.fire(PlanOperationRecordList.get(0).getBatchNo(), "0", "", "FIRE_CANCEL", "CONFIRM", "B"); Optional<Equipment> equipment = iContingencyInstance.fire(PlanOperationRecordList.get(0).getBatchNo(), "0", "", "FIRE_CANCEL", "CONFIRM", "B");
// 结束预案,更新设备重点设备参数 // 结束预案,更新设备重点设备参数
equipment.ifPresent(equip -> { equipment.ifPresent(equip -> {
equip.setStartTime(DateUtil.getDateNow()); if("1".equals(equip.getPlanRuleNo())){
equip.setEndTime(null); equip.setStartTime(DateUtil.getDateNow());
equip.setReserveSource(NumberEnum.ONE.getValue()); equip.setEndTime(null);
equip.setStatus(NumberEnum.ONE.getValue()); equip.setReserveSource(NumberEnum.ONE.getValue());
equip.setStatus(NumberEnum.ONE.getValue());
}else{
equip.setSecStartTime(DateUtil.getDateNow());
equip.setSecEndTime(null);
equip.setSecReserveSource(NumberEnum.ONE.getValue());
equip.setSecStatus(NumberEnum.ONE.getValue());
}
equipmentService.save(equip); equipmentService.save(equip);
}); });
customerAction.intreeuptPlan(PlanOperationRecordList.get(0).getBatchNo()); customerAction.intreeuptPlan(PlanOperationRecordList.get(0).getBatchNo());
...@@ -461,6 +479,69 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -461,6 +479,69 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
} }
return ReserveEnum.RUN; return ReserveEnum.RUN;
} }
//启动状态校验
public ReserveEnum secRunCheck(ContingencyPlanParamVo vo) throws Exception {
logger.info("========vo===========" + JSONObject.toJSONString(vo));
if (EquipmentRiskTypeEnum.HZGJ.getCode().equals(vo.getRiskType()) || StringUtils.isBlank(vo.getRiskType())) {
//判断预案文档是否删除
List<PlanDoc> planDocs = planDocDao.findAllByPlanId(Long.valueOf(vo.getPlanId()));
if (planDocs.size() == 0) {
return ReserveEnum.PLAN_DOC_IS_DELETE;
}
List<PlanRule> planRules = planRuleDao.findAllByPlanId(Long.valueOf(vo.getPlanId()));
if (planRules.size() == 0) {
return ReserveEnum.PLAN_RULE_IS_DELETE;
}
//判断预案装备是否删除
List<PlanEquipment> planEquipments = planEquipmentDao.findByPlanId(Long.valueOf(vo.getPlanId()));
if (planEquipments.isEmpty()) {
return ReserveEnum.PLAN_EQUIP_IS_DELETE;
}
List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanIdAndPlanRuleNo(Long.valueOf(vo.getPlanId()), vo.getPlanRuleNo());
if (recordList.size() > 0 && !vo.getStatus().equals(ContingencyPlanStatusEnum.ONGOING.getCode())) {
return ReserveEnum.THISRUNNING;
}
if (ContingencyPlanStatusEnum.SIMULATION_START.getCode().equals(vo.getStatus())) {
Integer[] statusArray = (Integer[]) Arrays.asList(ContingencyPlanStatusEnum.SIMULATION_START.getCode(), ContingencyPlanStatusEnum.ONGOING.getCode()).toArray();
List<PlanDetail> count = planDetailDao.findBySecStatus(statusArray);
if (count.size() > NumberEnum.ZERO.getValue()) {
return ReserveEnum.RUNNING;
}
} else if (ContingencyPlanStatusEnum.ONGOING.getCode().equals(vo.getStatus())) {
//自动启动
List<PlanDetail> countZd = planDetailDao.findBySecStatus((Integer[]) Arrays.asList(ContingencyPlanStatusEnum.ONGOING.getCode()).toArray());
if (countZd.size() > NumberEnum.ZERO.getValue()) {
return ReserveEnum.RUNNING;
}
List<PlanDetail> countMn = planDetailDao.findBySecStatus((Integer[]) Arrays.asList(ContingencyPlanStatusEnum.SIMULATION_START.getCode()).toArray());
if (countMn.size() > NumberEnum.ZERO.getValue()) {
List<PlanOperationRecord> PlanOperationRecordList = planOperationRecordDao.findByPlanIdAndPlanRuleNo(countMn.get(0).getId(), vo.getPlanRuleNo());
if (PlanOperationRecordList.size() > 0) {
Optional<Equipment> equipment = iContingencyInstance.fire(PlanOperationRecordList.get(0).getBatchNo(), "0", "", "FIRE_CANCEL", "CONFIRM", "B");
// 结束预案,更新设备重点设备参数
equipment.ifPresent(equip -> {
equip.setSecStartTime(DateUtil.getDateNow());
equip.setSecEndTime(null);
equip.setSecReserveSource(NumberEnum.ONE.getValue());
equip.setSecStatus(NumberEnum.ONE.getValue());
equipmentService.save(equip);
});
customerAction.secIntreeuptPlan(PlanOperationRecordList.get(0).getBatchNo());
}
}
} else {
return ReserveEnum.PLANSTATUSERROR;
}
} else {
}
return ReserveEnum.RUN;
}
@Override @Override
public ContingencyPlanParamVo equipmentScene(Long equipmentId, String riskType) { public ContingencyPlanParamVo equipmentScene(Long equipmentId, String riskType) {
...@@ -681,7 +762,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -681,7 +762,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
@Override @Override
public Page<PlanDetailVo> pageFilter(Page page, String planName, Long public Page<PlanDetailVo> pageFilter(Page page, String planName, Long
classifyId, List<String> planRange, String editOrgName, Date implementationTimeLeft, Date classifyId, List<String> planRange, String editOrgName, Date implementationTimeLeft, Date
implementationTimeRight) { implementationTimeRight, String planRuleNo) {
List<Long> classifyIdList = new ArrayList<>(); List<Long> classifyIdList = new ArrayList<>();
if (classifyId != null) { if (classifyId != null) {
Collection<PlanClassifyTreeVo> classifyTreeList = planClassifyTreeService.getAllChildIncludeMe(classifyId); Collection<PlanClassifyTreeVo> classifyTreeList = planClassifyTreeService.getAllChildIncludeMe(classifyId);
...@@ -702,13 +783,13 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -702,13 +783,13 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
} }
List<PlanDetailVo> planList = planDetailMapper.filterList(planName, classifyIdList, planRange, editOrgName, implementationTimeLeft, implementationTimeRight, (int) start, (int) page.getSize()); List<PlanDetailVo> planList = planDetailMapper.filterList(planName, classifyIdList, planRange, editOrgName, implementationTimeLeft, implementationTimeRight, (int) start, (int) page.getSize());
// 查询并插入绑定数据的信息 // 查询并插入绑定数据的信息
fillBindingInfo(planList); fillBindingInfo(planList, planRuleNo);
page.setRecords(planList); page.setRecords(planList);
} }
return page; return page;
} }
private void fillBindingInfo(List<PlanDetailVo> planList) { private void fillBindingInfo(List<PlanDetailVo> planList, String planRuleNo) {
if (ValidationUtil.isEmpty(planList)) { if (ValidationUtil.isEmpty(planList)) {
return; return;
} }
...@@ -742,6 +823,9 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -742,6 +823,9 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
if (finalEquipMapList != null && finalEquipMapList.get(plan.getId()) != null) { if (finalEquipMapList != null && finalEquipMapList.get(plan.getId()) != null) {
plan.setPlanEquipment(finalEquipMapList.get(plan.getId())); plan.setPlanEquipment(finalEquipMapList.get(plan.getId()));
} }
if("2".equals(planRuleNo)){
plan.setStatus(plan.getSecStatus());
}
}); });
} }
...@@ -852,10 +936,18 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -852,10 +936,18 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
equipment = iContingencyInstance.fire(batchNo, "0", "", "FIRE_CANCEL", "CONFIRM", "B"); equipment = iContingencyInstance.fire(batchNo, "0", "", "FIRE_CANCEL", "CONFIRM", "B");
// 结束预案,更新设备重点设备参数 // 结束预案,更新设备重点设备参数
equipment.ifPresent(equip -> { equipment.ifPresent(equip -> {
equip.setEndTime(null); if("1".equals(equip.getPlanRuleNo())){
equip.setReserveSource(NumberEnum.ONE.getValue()); equip.setStartTime(DateUtil.getDateNow());
equip.setStartTime(DateUtil.getDateNow()); equip.setEndTime(null);
equip.setStatus(NumberEnum.ONE.getValue()); equip.setReserveSource(NumberEnum.ONE.getValue());
equip.setStatus(NumberEnum.ONE.getValue());
}else{
equip.setSecStartTime(DateUtil.getDateNow());
equip.setSecEndTime(null);
equip.setSecReserveSource(NumberEnum.ONE.getValue());
equip.setSecStatus(NumberEnum.ONE.getValue());
}
equipmentService.save(equip); equipmentService.save(equip);
}); });
} catch (Exception e) { } catch (Exception e) {
......
...@@ -143,7 +143,7 @@ public class EmergencyTaskServiceImpl implements IEmergencyTaskService { ...@@ -143,7 +143,7 @@ public class EmergencyTaskServiceImpl implements IEmergencyTaskService {
@Async @Async
@Transactional @Transactional
@Override @Override
public void saveTask(String stepCode, String batchId) { public void saveTask(String stepCode, String batchId, String planRuleNo) {
String planType = null; String planType = null;
if (redisTemplate.hasKey("planType")) { if (redisTemplate.hasKey("planType")) {
planType = redisTemplate.boundValueOps("planType").get(0, -1); planType = redisTemplate.boundValueOps("planType").get(0, -1);
...@@ -170,6 +170,7 @@ public class EmergencyTaskServiceImpl implements IEmergencyTaskService { ...@@ -170,6 +170,7 @@ public class EmergencyTaskServiceImpl implements IEmergencyTaskService {
contingencyPlanInstance.setTaskSort(taskNum); contingencyPlanInstance.setTaskSort(taskNum);
contingencyPlanInstance.setStepCode(stepCode); contingencyPlanInstance.setStepCode(stepCode);
contingencyPlanInstance.setContent(buttonJson); contingencyPlanInstance.setContent(buttonJson);
contingencyPlanInstance.setPlanRuleNo(planRuleNo);
contingencyPlanInstanceRepository.saveAndFlush(contingencyPlanInstance); contingencyPlanInstanceRepository.saveAndFlush(contingencyPlanInstance);
if ("0".equals(stepCode)) { if ("0".equals(stepCode)) {
...@@ -183,7 +184,7 @@ public class EmergencyTaskServiceImpl implements IEmergencyTaskService { ...@@ -183,7 +184,7 @@ public class EmergencyTaskServiceImpl implements IEmergencyTaskService {
planStep = planStepService.getPlanStep(); planStep = planStepService.getPlanStep();
} }
JSONArray objects = JSON.parseArray(planStep); JSONArray objects = JSON.parseArray(planStep);
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(planRuleNo)?"plan":"secPlan"));
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put("contingency", new ContingencyRo()); result.put("contingency", new ContingencyRo());
result.put("msgContext", Collections.EMPTY_MAP); result.put("msgContext", Collections.EMPTY_MAP);
......
...@@ -543,20 +543,20 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -543,20 +543,20 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
*/ */
@Async @Async
@Override @Override
public String executeDynamicPlan(String batchNo, AlarmParam deviceData, Equipment equipment, EquipmentSpecificForRiskVo equipmentSpecific, Toke toke, Long recordId) { public String executeDynamicPlan(String batchNo, AlarmParam deviceData, Equipment equipment, EquipmentSpecificForRiskVo equipmentSpecific, Toke toke, Long recordId, String planRuleNo) {
RequestContext.setToken(toke.getToke()); RequestContext.setToken(toke.getToke());
RequestContext.setProduct(toke.getProduct()); RequestContext.setProduct(toke.getProduct());
try { try {
sleep(1000); sleep(1000);
alarmContingency(batchNo, equipmentSpecific, equipment, recordId, deviceData.getIsMock()); alarmContingency(batchNo, equipmentSpecific, equipment, recordId, deviceData.getIsMock(), planRuleNo);
} 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, Boolean isMock) throws Exception { public void alarmContingency(String batchNo, EquipmentSpecificForRiskVo equipmentSpecific, Equipment equipment, Long recordId, Boolean isMock, String planRuleNo) throws Exception {
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()));
...@@ -574,6 +574,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService { ...@@ -574,6 +574,7 @@ public class HandlerMqttMessageImpl implements IEquipmentHandlerService {
contingencyRo.getParams().put("equipmentId", equipment.getId()); contingencyRo.getParams().put("equipmentId", equipment.getId());
contingencyRo.setIsMock(isMock); contingencyRo.setIsMock(isMock);
contingencyRo.setPosition(equipmentSpecific.getPosition()); contingencyRo.setPosition(equipmentSpecific.getPosition());
contingencyRo.setPlanRuleNo(planRuleNo);
ContingencyOriginalData contingencyOriginalData = new ContingencyOriginalData(); ContingencyOriginalData contingencyOriginalData = new ContingencyOriginalData();
BeanUtils.copyProperties(contingencyRo, contingencyOriginalData); BeanUtils.copyProperties(contingencyRo, contingencyOriginalData);
......
package com.yeejoin.amos.fas.business.service.impl; package com.yeejoin.amos.fas.business.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -7,8 +33,17 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -7,8 +33,17 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo; import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent; import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.constants.FasConstant; import com.yeejoin.amos.fas.business.constants.FasConstant;
import com.yeejoin.amos.fas.business.dao.mapper.*; import com.yeejoin.amos.fas.business.dao.mapper.ContingencyInstanceInfoMapper;
import com.yeejoin.amos.fas.business.dao.repository.*; import com.yeejoin.amos.fas.business.dao.mapper.ContingencyPlanInstanceMapper;
import com.yeejoin.amos.fas.business.dao.mapper.DictMapper;
import com.yeejoin.amos.fas.business.dao.mapper.PlanOperationRecordMapper;
import com.yeejoin.amos.fas.business.dao.mapper.PlanVisual3dMapper;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyPlanInstanceRepository;
import com.yeejoin.amos.fas.business.dao.repository.IPlanDetailDao;
import com.yeejoin.amos.fas.business.dao.repository.IPlanOperationRecordDao;
import com.yeejoin.amos.fas.business.dao.repository.IPlanRuleDao;
import com.yeejoin.amos.fas.business.dao.repository.ITextPlanDao;
import com.yeejoin.amos.fas.business.feign.JcsFeign; import com.yeejoin.amos.fas.business.feign.JcsFeign;
import com.yeejoin.amos.fas.business.feign.PrivilegeFeign; import com.yeejoin.amos.fas.business.feign.PrivilegeFeign;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService; import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
...@@ -19,37 +54,34 @@ import com.yeejoin.amos.fas.business.service.intfc.IPlanVisual3dService; ...@@ -19,37 +54,34 @@ import com.yeejoin.amos.fas.business.service.intfc.IPlanVisual3dService;
import com.yeejoin.amos.fas.business.service.model.ToipResponse; import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import com.yeejoin.amos.fas.business.util.JSONUtil; import com.yeejoin.amos.fas.business.util.JSONUtil;
import com.yeejoin.amos.fas.business.util.StringUtil; import com.yeejoin.amos.fas.business.util.StringUtil;
import com.yeejoin.amos.fas.business.vo.*; import com.yeejoin.amos.fas.business.vo.ButtonJsonVO;
import com.yeejoin.amos.fas.business.vo.ContingencyInstanceInfoVO;
import com.yeejoin.amos.fas.business.vo.ContingencyPlanInstanceVO;
import com.yeejoin.amos.fas.business.vo.MessageVO;
import com.yeejoin.amos.fas.business.vo.PlanStepVo;
import com.yeejoin.amos.fas.business.vo.TreeSubjectVo;
import com.yeejoin.amos.fas.common.enums.PlanReplyMessageEnum; import com.yeejoin.amos.fas.common.enums.PlanReplyMessageEnum;
import com.yeejoin.amos.fas.core.util.CommonResponse; import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil; import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.core.util.ResponseModel; import com.yeejoin.amos.fas.core.util.ResponseModel;
import com.yeejoin.amos.fas.dao.entity.*;
import com.yeejoin.amos.fas.dao.dto.PlanStepJsonVO; import com.yeejoin.amos.fas.dao.dto.PlanStepJsonVO;
import com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.Dict;
import com.yeejoin.amos.fas.dao.entity.PlanOperationRecord;
import com.yeejoin.amos.fas.dao.entity.PlanRule;
import com.yeejoin.amos.fas.dao.entity.TextPlan;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel; import com.yeejoin.amos.feign.privilege.model.RoleModel;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.MessageModel; import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;
@Service("planVisual3dService") @Service("planVisual3dService")
public class PlanVisual3dServiceImpl implements IPlanVisual3dService { public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
@Autowired private final Logger logger = LogManager.getLogger(PlanVisual3dServiceImpl.class);
@Autowired
ITextPlanDao iTextPlanDao; ITextPlanDao iTextPlanDao;
@Autowired @Autowired
...@@ -255,9 +287,11 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -255,9 +287,11 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
} }
JSONArray objects = JSON.parseArray(planStep); JSONArray objects = JSON.parseArray(planStep);
Map<String, Object> msgContext = new HashMap<>(2); Map<String, Object> msgContext = new HashMap<>(2);
logger.info("===============查询到planStep===,{}",JSONObject.toJSONString(planStep));
if (StringUtil.isNotEmpty(planStep) && StringUtils.isNotBlank(batchNo)) { if (StringUtil.isNotEmpty(planStep) && StringUtils.isNotBlank(batchNo)) {
// 查询当前步骤 // 查询当前步骤
ContingencyOriginalData contingencyOriginalData = contingencyOriginalDataDao.findByBatchNo(batchNo); ContingencyOriginalData contingencyOriginalData = contingencyOriginalDataDao.findByBatchNo(batchNo);
logger.info("===============查询到contingencyOriginalData===,{}",JSONObject.toJSONString(contingencyOriginalData));
if( null == contingencyOriginalData) { if( null == contingencyOriginalData) {
return null; return null;
} }
...@@ -270,6 +304,7 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -270,6 +304,7 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
} }
toipResponse.setMsgType("steparea"); toipResponse.setMsgType("steparea");
toipResponse.setContingency(contingencyOriginalData); toipResponse.setContingency(contingencyOriginalData);
toipResponse.setPlanRuleNo(contingencyOriginalData.getPlanRuleNo());
} }
msgContext.put("step", objects); msgContext.put("step", objects);
toipResponse.setMsgContext(msgContext); toipResponse.setMsgContext(msgContext);
...@@ -416,10 +451,14 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -416,10 +451,14 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
} }
@Override @Override
public void updatePlanStepToRedis(String batchNo, String stepCode, String buttonJson, String contingencyPlanId, String buttonCode, String isExecute, String isAuto) { public void updatePlanStepToRedis(String batchNo, String stepCode, String buttonJson, String contingencyPlanId, String buttonCode
, String isExecute, String planRuleNo, String isAuto) {
logger.info("===============updatePlanStepToRedis2=planRuleNo==,{}",JSON.toJSONString(planRuleNo));
if (StringUtils.isNotBlank(batchNo) && StringUtils.isNotBlank(contingencyPlanId) && StringUtils.isNotBlank(buttonCode)) { if (StringUtils.isNotBlank(batchNo) && StringUtils.isNotBlank(contingencyPlanId) && StringUtils.isNotBlank(buttonCode)) {
// 根据批次号查询预案步骤 // 根据批次号查询预案步骤
String planStep = Objects.requireNonNull(redisTemplate.opsForValue().get("planStep")).toString(); String planStep = Objects.requireNonNull(redisTemplate.opsForValue().get("planStep")).toString();
logger.info("===============updatePlanStepToRedis1===,{}",planStep);
if (StringUtils.isNotBlank(planStep)) { if (StringUtils.isNotBlank(planStep)) {
List<PlanStepJsonVO> list = JSONObject.parseArray(planStep, PlanStepJsonVO.class); List<PlanStepJsonVO> list = JSONObject.parseArray(planStep, PlanStepJsonVO.class);
List<PlanStepJsonVO> collect = list.stream().peek(x -> { List<PlanStepJsonVO> collect = list.stream().peek(x -> {
...@@ -456,10 +495,11 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -456,10 +495,11 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
} }
}).collect(Collectors.toList()); }).collect(Collectors.toList());
redisTemplate.opsForValue().set("planStep", JSON.toJSONString(collect1)); redisTemplate.opsForValue().set("planStep", JSON.toJSONString(collect1));
logger.info("===============updatePlanStepToRedis2===,{}",JSON.toJSONString(collect1));
if(stepCode.equals("0")) { if(stepCode.equals("0")) {
PlanStepJsonVO planStepJsonVO = collect1.get(0); PlanStepJsonVO planStepJsonVO = collect1.get(0);
if(!StringUtils.isEmpty(planStepJsonVO.getButtonJson())) { if(!StringUtils.isEmpty(planStepJsonVO.getButtonJson())) {
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(planRuleNo)?"plan":"secPlan"));
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
JSONObject msgContext = new JSONObject(); JSONObject msgContext = new JSONObject();
msgContext.put("tips", "alertAlarm"); msgContext.put("tips", "alertAlarm");
...@@ -500,32 +540,13 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -500,32 +540,13 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
@Override @Override
public ContingencyPlanInstance replyMessage(AgencyUserModel user, ContingencyPlanInstance dto) { public ContingencyPlanInstance replyMessage(AgencyUserModel user, ContingencyPlanInstance dto) {
// String json = planStepService.getPlanStep();
// List<PlanStepJsonVO> result = JSONObject.parseArray(json, PlanStepJsonVO.class);
// List<String> roleCode = result.stream().map(PlanStepJsonVO::getRoleCode).distinct().collect(Collectors.toList());
String roleCodes = emergencyTaskService.getRolesByUserId(user.getUserId()); String roleCodes = emergencyTaskService.getRolesByUserId(user.getUserId());
String roleNames = emergencyTaskService.getRolesNameByUserId(user.getUserId()); String roleNames = emergencyTaskService.getRolesNameByUserId(user.getUserId());
List<String> roleModelList = Arrays.asList(roleCodes.split(",")); List<String> roleModelList = Arrays.asList(roleCodes.split(","));
List<String> roleNameList = Arrays.asList(roleNames.split(",")); List<String> roleNameList = Arrays.asList(roleNames.split(","));
// List<RoleModel> roleModelList = new ArrayList<>();
// for (Long key : user.getOrgRoles().keySet()) {
// roleModelList.addAll(user.getOrgRoles().get(key));
// }
// List<String> roleCodeList = new ArrayList<>();
// List<String> roleNameList = new ArrayList<>();
// List<String> realRoleCode = roleModelList.stream().map(RoleModel::getRoleName).distinct().collect(Collectors.toList());
// realRoleCode.forEach(item -> {
// if (roleCode.contains(item)) {
// roleCodeList.add(item);
// }
// });
// roleModelList.forEach(item -> {
// if (!roleNameList.contains(item.getRoleDesc()) && roleCode.contains(item.getRoleName())) {
// roleNameList.add(item.getRoleDesc());
// }
// });
dto.setRoleCode(String.join("-", roleModelList)); dto.setRoleCode(String.join("-", roleModelList));
dto.setRoleName(String.join("-", roleNameList)); dto.setRoleName(String.join("-", roleNameList));
dto.setStartUserId(user.getUserId()); dto.setStartUserId(user.getUserId());
...@@ -544,18 +565,11 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -544,18 +565,11 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
img = "null".equalsIgnoreCase(resStr) ? null : img; img = "null".equalsIgnoreCase(resStr) ? null : img;
} }
img = StringUtils.isEmpty(img) ? personImg : img; img = StringUtils.isEmpty(img) ? personImg : img;
// Map<String, String> userInfo = contingencyPlanInstanceMapper.getUserByUserId(user.getUserId());
// if (!ObjectUtils.isEmpty(userInfo)) {
// String img = userInfo.get("personImg");
// dto.setPersonImg(StringUtils.isBlank(img) ? personImg : img);
// } else {
// dto.setPersonImg(personImg);
// }
dto.setPersonImg(img); dto.setPersonImg(img);
dto.setContent(StringUtil.isNotEmpty(dto.getContent()) ? dto.getContent() : ""); dto.setContent(StringUtil.isNotEmpty(dto.getContent()) ? dto.getContent() : "");
ContingencyPlanInstance instance = repository.save(dto); ContingencyPlanInstance instance = repository.save(dto);
if (!ObjectUtils.isEmpty(instance)) { if (!ObjectUtils.isEmpty(instance)) {
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, ("1".equals(instance.getPlanRuleNo())?"plan":"secPlan"));
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("contingency", new ContingencyRo()); map.put("contingency", new ContingencyRo());
map.put("msgContext", Collections.EMPTY_MAP); map.put("msgContext", Collections.EMPTY_MAP);
......
...@@ -8,7 +8,7 @@ import java.util.Optional; ...@@ -8,7 +8,7 @@ import java.util.Optional;
public interface IContingencyInstance { public interface IContingencyInstance {
ContingencyPlanInstance createInstanceRecord(String instanceNo, String category, String subCategory, String content, String recordType, String icon); ContingencyPlanInstance createInstanceRecord(String instanceNo, String category, String subCategory, String content, String recordType, String icon, String planRuleNo);
...@@ -19,13 +19,17 @@ public interface IContingencyInstance { ...@@ -19,13 +19,17 @@ public interface IContingencyInstance {
void setButtonWait(String batchNo,String contingencyPlanId,String buttonState) throws Exception; void setButtonWait(String batchNo,String contingencyPlanId,String buttonState) throws Exception;
Optional<Equipment> fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton) throws Exception; Optional<Equipment> fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState
, String stepStateOnbutton) throws Exception;
void updateStep(String step, String batchNo); void updateStep(String step, String batchNo, String planRuleNo);
Optional<Equipment> fire(String batchNo, String stepCode, String buttonJson, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton, String isExecute, String isAuto, String token, String product, String appKey,String startUserName) throws Exception; Optional<Equipment> fire(String batchNo, String stepCode, String buttonJson, String contingencyPlanId, String buttonCode
, String buttonState, String stepStateOnbutton, String isExecute, String isAuto, String token, String product
, String appKey,String startUserName, String planRuleNo) throws Exception;
Optional<Equipment> clickButton(String batchNo, String stepCode, String buttonJson, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton, String isExecute, String isAuto, String token, String product, String appKey,String startUserName) throws Exception; Optional<Equipment> clickButton(String batchNo, String stepCode, String buttonJson, String contingencyPlanId, String buttonCode
, String buttonState, String stepStateOnbutton, String isExecute, String isAuto, String token, String product, String appKey,String startUserName) throws Exception;
/** /**
* 扩展属性赋值 * 扩展属性赋值
......
...@@ -98,7 +98,7 @@ public interface IContingencyPlanService { ...@@ -98,7 +98,7 @@ public interface IContingencyPlanService {
* @param implementationTimeRight 实施时间右界限 * @param implementationTimeRight 实施时间右界限
* @return Page * @return Page
*/ */
Page<PlanDetailVo> pageFilter(Page page, String planName, Long classifyId, List<String> planRange, String editOrgName, Date implementationTimeLeft, Date implementationTimeRight); Page<PlanDetailVo> pageFilter(Page page, String planName, Long classifyId, List<String> planRange, String editOrgName, Date implementationTimeLeft, Date implementationTimeRight, String planRuleNo);
/** /**
* 查询预案使用的文档ID * 查询预案使用的文档ID
......
...@@ -28,7 +28,7 @@ public interface IEmergencyTaskService { ...@@ -28,7 +28,7 @@ public interface IEmergencyTaskService {
String getRolesNameByUserId(String userId); String getRolesNameByUserId(String userId);
void saveTask(String stepCode, String batchNo); void saveTask(String stepCode, String batchNo, String planRuleNo);
List<EmergencyTaskContentVo> getMustTaskList(String stepCode, String planType); List<EmergencyTaskContentVo> getMustTaskList(String stepCode, String planType);
} }
...@@ -20,5 +20,5 @@ public interface IEquipmentHandlerService { ...@@ -20,5 +20,5 @@ public interface IEquipmentHandlerService {
void subscribeTopic(); void subscribeTopic();
String executeDynamicPlan(String batchNO, AlarmParam deviceData, Equipment equipment, EquipmentSpecificForRiskVo equipmentSpecific, Toke toke, Long recordId); String executeDynamicPlan(String batchNO, AlarmParam deviceData, Equipment equipment, EquipmentSpecificForRiskVo equipmentSpecific, Toke toke, Long recordId, String planRuleNo);
} }
...@@ -87,7 +87,7 @@ public interface IPlanVisual3dService { ...@@ -87,7 +87,7 @@ public interface IPlanVisual3dService {
void updatePlanStep(String batchNo, String stepCode, String buttonJson, String contingencyPlanId, String buttonCode, String isExecute); void updatePlanStep(String batchNo, String stepCode, String buttonJson, String contingencyPlanId, String buttonCode, String isExecute);
void updatePlanStepToRedis(String batchNo, String stepCode, String buttonJson, String contingencyPlanId, String buttonCode, String isExecute, String isAuto); void updatePlanStepToRedis(String batchNo, String stepCode, String buttonJson, String contingencyPlanId, String buttonCode, String isExecute, String planRuleNo,String isAuto);
Page<ContingencyPlanInstanceVO> selectDisposalActionPage(int current, int size, String batchNo, List<RoleModel> roleModelList, int dataType); Page<ContingencyPlanInstanceVO> selectDisposalActionPage(int current, int size, String batchNo, List<RoleModel> roleModelList, int dataType);
......
...@@ -54,6 +54,9 @@ public class ToipResponse implements Serializable ...@@ -54,6 +54,9 @@ public class ToipResponse implements Serializable
private boolean mockData; private boolean mockData;
public String planRuleNo = "1";
public String toJsonStr() { public String toJsonStr() {
return JSON.toJSONString(this,SerializerFeature.WriteMapNullValue,SerializerFeature.DisableCircularReferenceDetect,SerializerFeature.SkipTransientField); return JSON.toJSONString(this,SerializerFeature.WriteMapNullValue,SerializerFeature.DisableCircularReferenceDetect,SerializerFeature.SkipTransientField);
} }
......
...@@ -23,6 +23,8 @@ public class ContingencyPlanParamVo { ...@@ -23,6 +23,8 @@ public class ContingencyPlanParamVo {
*/ */
public String triggerMode = "manual"; public String triggerMode = "manual";
public String planRuleNo = "1";
} }
...@@ -14,4 +14,5 @@ public class PlanExecuteVo { ...@@ -14,4 +14,5 @@ public class PlanExecuteVo {
private String stepState; private String stepState;
private String isAuto; private String isAuto;
private String isExecute; private String isExecute;
private String planRuleNo = "1";
} }
...@@ -1018,4 +1018,111 @@ ...@@ -1018,4 +1018,111 @@
ALTER TABLE `c_plan_classify_tree` ADD COLUMN plan_type varchar(100) NULL COMMENT '分类TYPE'; ALTER TABLE `c_plan_classify_tree` ADD COLUMN plan_type varchar(100) NULL COMMENT '分类TYPE';
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="my" id="2024091301-1">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="c_plan_operation_record" columnName="plan_rule_no" />
</not>
</preConditions>
<comment>c_plan_operation_record.plan_rule_no</comment>
<sql>
ALTER TABLE `c_plan_operation_record`
ADD COLUMN `plan_rule_no` varchar(5) NULL DEFAULT 1 COMMENT '预案编号,默认为1,若一个设备有多个预案模型依次递增';
</sql>
</changeSet>
<changeSet author="my" id="2024091301-2">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="c_plan_detail" columnName="sec_status" />
</not>
</preConditions>
<comment>c_plan_detail.sec_status</comment>
<sql>
ALTER TABLE `c_plan_detail`
ADD COLUMN `sec_status` int(0) NULL COMMENT '第二个预案运行状态' AFTER `status`;
</sql>
</changeSet>
<changeSet author="my" id="2024091301-3">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="f_equipment" columnName="sec_status" />
</not>
</preConditions>
<comment>f_equipment.sec_status</comment>
<sql>
ALTER TABLE `f_equipment`
ADD COLUMN `sec_status` int(0) NULL COMMENT '第二个预案状态 1-启动 0 未启动' ,
ADD COLUMN `sec_start_time` datetime(0) NULL COMMENT '第二个预案启动时间',
ADD COLUMN `sec_end_time` datetime(0) NULL COMMENT '第二个预案结束时间',
ADD COLUMN `sec_reserve_source` int(0) NULL COMMENT '预案来源:1-手动触发,0-自动触发(默认)';
</sql>
</changeSet>
<changeSet author="my" id="2024091301-4">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="c_plan_rule" columnName="sec_rule_id" />
</not>
</preConditions>
<comment>c_plan_rule.sec_rule_id</comment>
<sql>
ALTER TABLE `c_plan_rule`
ADD COLUMN `sec_rule_id` varchar(32) NULL COMMENT '第二个预案规则id' AFTER `rule_id`;
</sql>
</changeSet>
<changeSet author="my" id="2024091301-5">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="contingency_instance_info" columnName="plan_rule_no" />
</not>
</preConditions>
<comment>contingency_instance_info.plan_rule_no</comment>
<sql>
ALTER TABLE `contingency_instance_info`
ADD COLUMN `plan_rule_no` varchar(5) NULL DEFAULT 1 COMMENT '预案规则执行号默认1执行第一个预案,自动化可执行2第二个';
</sql>
</changeSet>
<changeSet author="my" id="2024091301-6">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="contingency_original_data" columnName="plan_rule_no" />
</not>
</preConditions>
<comment>contingency_original_data.plan_rule_no</comment>
<sql>
ALTER TABLE `contingency_original_data`
ADD COLUMN `plan_rule_no` varchar(5) NULL DEFAULT 1 COMMENT '预案规则执行号默认1执行第一个预案,自动化可执行2第二个';
</sql>
</changeSet>
<changeSet author="my" id="2024091301-7">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="c_plan_detail" columnName="plan_rule_no" />
</not>
</preConditions>
<comment>c_plan_detail.plan_rule_no</comment>
<sql>
ALTER TABLE `c_plan_detail`
ADD COLUMN `plan_rule_no` varchar(5) NULL DEFAULT 1 COMMENT '预案规则执行号默认1执行第一个预案,自动化可执行2第二个';
</sql>
</changeSet>
<changeSet author="my" id="2024091301-8">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="contingency_plan_instance" columnName="plan_rule_no" />
</not>
</preConditions>
<comment>contingency_plan_instance.plan_rule_no</comment>
<sql>
ALTER TABLE `contingency_plan_instance`
ADD COLUMN `plan_rule_no` varchar(5) NULL DEFAULT 1 COMMENT '预案规则执行号默认1执行第一个预案,自动化可执行2第二个';
</sql>
</changeSet>
</databaseChangeLog> </databaseChangeLog>
\ No newline at end of file
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
, implementation_time implementationTime , implementation_time implementationTime
, cpd.remark , cpd.remark
, status , status
, sec_status
, creator , creator
, reviser , reviser
, update_time updateTime , update_time updateTime
...@@ -122,6 +123,21 @@ ...@@ -122,6 +123,21 @@
AND equip.is_delete != 1 AND equip.is_delete != 1
AND rule.is_delete !=1 AND rule.is_delete !=1
</select> </select>
<select id="getSecRuleIdByEquipment" parameterType="java.lang.Long" resultType="java.lang.String">
SELECT
sec_rule_id
FROM
c_plan_detail cpd
LEFT JOIN c_plan_rule rule ON rule.plan_id = cpd.id
LEFT JOIN c_plan_equipment equip ON equip.plan_id = cpd.id
LEFT JOIN f_equipment equipment ON equipment.id = equip.fire_equipment_id
where
equipment.id = #{id}
AND equip.is_delete != 1
AND rule.is_delete !=1
</select>
<select id="getPlanDetailByEquipmentId" resultType="com.yeejoin.amos.fas.business.vo.PlanDetailVo"> <select id="getPlanDetailByEquipmentId" resultType="com.yeejoin.amos.fas.business.vo.PlanDetailVo">
select select
d.id, d.id,
...@@ -188,4 +204,21 @@ ...@@ -188,4 +204,21 @@
limit 0, 1 limit 0, 1
</select> </select>
<select id="queryBatchNoAndRuleNoByFireEquipmentId" resultType="Map" >
SELECT
p.batch_no as batchNo,p.plan_rule_no as planRuleNo
FROM
f_equipment_fire_equipment fe
RIGHT JOIN f_equipment e ON fe.equipment_id = e.id
RIGHT JOIN c_plan_operation_record p ON e.id = p.fire_equipment_id
WHERE
fe.fire_equipment_id = #{fireEquipmentId}
AND p.end_time is null
AND p.`status` = 0
ORDER BY p.start_time desc
limit 0, 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