Commit 2dc745f6 authored by 高建强's avatar 高建强

item:修改无预案启动,不接收流程动作

parent afba4432
...@@ -186,24 +186,17 @@ public class ContingencyAction implements CustomerAction { ...@@ -186,24 +186,17 @@ public class ContingencyAction implements CustomerAction {
Toke toke = remoteSecurityService.getServerToken(); Toke toke = remoteSecurityService.getServerToken();
CommonResponse commonResponse = dutyModeServer.dutyListByDate(toke.getAppKey(), toke.getProduct(), toke.getToke(), orgCode, param.toJSONString()); CommonResponse commonResponse = dutyModeServer.dutyListByDate(toke.getAppKey(), toke.getProduct(), toke.getToke(), orgCode, param.toJSONString());
// String result = HttpUtil.appendPostJson("duty/dutyListByDate", param.toJSONString());
// JSONObject jsonObject = JSONObject.parseObject(result);
// JSONArray dataList = JSONObject.parseObject(commonResponse.getDataList().toString());
String JSONStr = JSON.toJSONString(commonResponse.getDataList()); String JSONStr = JSON.toJSONString(commonResponse.getDataList());
JSONArray dataList = JSONObject.parseArray(JSONStr); JSONArray dataList = JSONObject.parseArray(JSONStr);
log.info(String.format("请求值班系统返回dataList:%s", dataList)); log.info(String.format("请求值班系统返回dataList:%s", dataList));
if (!ObjectUtils.isEmpty(dataList)) { if (!ObjectUtils.isEmpty(dataList)) {
Map<String, String> finalReturnMap = returnMap; Map<String, String> finalReturnMap = returnMap;
dataList.forEach( dataList.forEach(x -> {
x -> {
JSONObject obj = (JSONObject) x; JSONObject obj = (JSONObject) x;
String name = obj.getString("position"); String name = obj.getString("position");
finalReturnMap.put(name, obj.getString("dutyName")); finalReturnMap.put(name, obj.getString("dutyName"));
} });
);
} }
stringStringMap.put(batchNo, returnMap); stringStringMap.put(batchNo, returnMap);
} }
...@@ -219,12 +212,10 @@ public class ContingencyAction implements CustomerAction { ...@@ -219,12 +212,10 @@ public class ContingencyAction implements CustomerAction {
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "步骤更新", project = "换流站消防专项预案") @RuleMethod(methodLabel = "步骤更新", project = "换流站消防专项预案")
public void stepInfo(@MethodParam(paramLabel = "当前步骤编号") String stepCode, public void stepInfo(@MethodParam(paramLabel = "当前步骤编号") String stepCode, @MethodParam(paramLabel = "当前步骤名称") String stepName, @MethodParam(paramLabel = "下一步编号") String nextStepCode, @MethodParam(paramLabel = "下一步名称") String nextStepName, @MethodParam(paramLabel = "对象") Object paramObj) {
@MethodParam(paramLabel = "当前步骤名称") String stepName,
@MethodParam(paramLabel = "下一步编号") String nextStepCode,
@MethodParam(paramLabel = "下一步名称") String nextStepName,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
...@@ -247,48 +238,18 @@ public class ContingencyAction implements CustomerAction { ...@@ -247,48 +238,18 @@ public class ContingencyAction implements CustomerAction {
log.info("步骤更新(new)" + JSONObject.toJSONString(result)); log.info("步骤更新(new)" + JSONObject.toJSONString(result));
this.sendcmd("steparea", contingencyRo, result); this.sendcmd("steparea", contingencyRo, result);
} }
}
/** /**
* @param stepCode 当前步骤编号 * @param stepCode 当前步骤编号
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "步骤更新(旧)", project = "换流站消防专项预案") @RuleMethod(methodLabel = "步骤更新(旧)", project = "换流站消防专项预案")
public void stepInfoOld(@MethodParam(paramLabel = "当前编号") String stepCode, public void stepInfoOld(@MethodParam(paramLabel = "当前编号") String stepCode, @MethodParam(paramLabel = "对象") Object paramObj) {
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
// Map<String, Object> tempmap1 = new HashMap<>();
// SetpEnum[] stepArr = SetpEnum.values();
// ArrayList list = new ArrayList();
// HashMap preStep = new HashMap();
// StepComparator comparator = new StepComparator();
// Arrays.sort(stepArr, comparator);
//
// boolean flage = false;
// SetpEnum pstep = null;
// for (SetpEnum step : stepArr) {
// if (Long.valueOf(step.getValue()) == Long.valueOf(stepCode)) {
// if (!ObjectUtils.isEmpty(pstep)) {
// preStep.put("stepCode", pstep.getValue());
// preStep.put("stepName", pstep.getTitle());
// }
// flage = true;
// }
// if (flage) {
// HashMap map = new HashMap();
// map.put("stepCode", step.getValue());
// map.put("stepName", step.getTitle());
// list.add(map);
// }
// pstep = step;
// }
//
// tempmap1.put("step", list);
// tempmap1.put("preStep", preStep);
// result.add(tempmap1);
// log.info("巡检消息发送规则" + JSONObject.toJSONString(result));
this.sendcmd("steparea", contingencyRo, result); this.sendcmd("steparea", contingencyRo, result);
} }
...@@ -299,9 +260,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -299,9 +260,7 @@ public class ContingencyAction implements CustomerAction {
ro.setTelesignallingMap(null); ro.setTelesignallingMap(null);
Constructor<?> constructor; Constructor<?> constructor;
try { try {
constructor = Class.forName( constructor = Class.forName(PACKAGEURL + result.getClass().getSimpleName() + "Message").getConstructor(ActionResult.class);
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());
...@@ -341,9 +300,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -341,9 +300,7 @@ public class ContingencyAction implements CustomerAction {
ro.setTelesignallingMap(null); ro.setTelesignallingMap(null);
Constructor<?> constructor; Constructor<?> constructor;
try { try {
constructor = Class.forName( constructor = Class.forName(PACKAGEURL + result.getClass().getSimpleName() + "Message").getConstructor(ActionResult.class);
PACKAGEURL + result.getClass().getSimpleName() + "Message")
.getConstructor(ActionResult.class);
AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result); AbstractActionResultMessage<?> action = (AbstractActionResultMessage<?>) constructor.newInstance(result);
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, "numberPlan"); String topic = String.format("/%s/%s/%s", serviceName, stationName, "numberPlan");
...@@ -368,8 +325,11 @@ public class ContingencyAction implements CustomerAction { ...@@ -368,8 +325,11 @@ public class ContingencyAction implements CustomerAction {
@RuleMethod(methodLabel = "步骤更新保存", project = "换流站消防专项预案") @RuleMethod(methodLabel = "步骤更新保存", project = "换流站消防专项预案")
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();
if (!findByBatchNoAndStatus(batchNo)) {
iContingencyInstance.updateStep(stepCode, contingencyRo.getBatchNo()); iContingencyInstance.updateStep(stepCode, contingencyRo.getBatchNo());
} }
}
/** /**
...@@ -379,6 +339,8 @@ public class ContingencyAction implements CustomerAction { ...@@ -379,6 +339,8 @@ public class ContingencyAction implements CustomerAction {
@RuleMethod(methodLabel = "执行记录", project = "换流站消防专项预案") @RuleMethod(methodLabel = "执行记录", project = "换流站消防专项预案")
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();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
//转换content中的变量 //转换content中的变量
content = instedParams(content, contingencyRo); content = instedParams(content, contingencyRo);
...@@ -409,6 +371,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -409,6 +371,7 @@ public class ContingencyAction implements CustomerAction {
this.sendcmd("recordarea", paramObj, result); this.sendcmd("recordarea", paramObj, result);
this.sendweb("recordarea", paramObj, result); this.sendweb("recordarea", paramObj, result);
} }
}
/** /**
* <pre> * <pre>
...@@ -424,14 +387,10 @@ public class ContingencyAction implements CustomerAction { ...@@ -424,14 +387,10 @@ public class ContingencyAction implements CustomerAction {
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "智能辅助", project = "换流站消防专项预案") @RuleMethod(methodLabel = "智能辅助", project = "换流站消防专项预案")
public void help(@MethodParam(paramLabel = "当前步骤") String step, 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) {
@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();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
//转换智能辅助中的变量 //转换智能辅助中的变量
...@@ -446,13 +405,12 @@ public class ContingencyAction implements CustomerAction { ...@@ -446,13 +405,12 @@ 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", /*JSONObject.toJSONString(tempmap1)*/JSONUtil.toJson(tempmap1), "HELPAREA", ""); iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", JSONUtil.toJson(tempmap1), "HELPAREA", "");
// tempmap1.put("batchNo", contingencyRo.getBatchNo());
// tempmap1.put("contingencyRo", contingencyRo);
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("helparea", paramObj, result); this.sendcmd("helparea", paramObj, result);
} }
}
private String instedParams(String content, ContingencyRo contingencyRo) { private String instedParams(String content, ContingencyRo contingencyRo) {
...@@ -465,8 +423,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -465,8 +423,7 @@ public class ContingencyAction implements CustomerAction {
Method getMethod = null; Method getMethod = null;
try { try {
for (Field field : fields) { for (Field field : fields) {
if (field.getName().equals("serialVersionUID")) if (field.getName().equals("serialVersionUID")) continue;
continue;
String fileNameInMethod = String.valueOf(field.getName().charAt(0)).toUpperCase() + field.getName().substring(1); String fileNameInMethod = String.valueOf(field.getName().charAt(0)).toUpperCase() + field.getName().substring(1);
getMethod = contingencyRo.getClass().getMethod("get" + fileNameInMethod); getMethod = contingencyRo.getClass().getMethod("get" + fileNameInMethod);
String value = String.valueOf(getMethod.invoke(contingencyRo)); String value = String.valueOf(getMethod.invoke(contingencyRo));
...@@ -486,11 +443,9 @@ public class ContingencyAction implements CustomerAction { ...@@ -486,11 +443,9 @@ public class ContingencyAction implements CustomerAction {
while (m.find()) { while (m.find()) {
String parameter = m.group(); String parameter = m.group();
Object parametervalue = ELEvaluationContext Object parametervalue = ELEvaluationContext.getValue(parameter.substring(1, parameter.length() - 1));
.getValue(parameter.substring(1, parameter.length() - 1));
if (parametervalue != null) if (parametervalue != null)
str = str.replace(parameter, str = str.replace(parameter, parametervalue != null ? parametervalue.toString() : null);
parametervalue != null ? parametervalue.toString() : null);
} }
return str; return str;
} }
...@@ -505,22 +460,18 @@ public class ContingencyAction implements CustomerAction { ...@@ -505,22 +460,18 @@ public class ContingencyAction implements CustomerAction {
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "交互动作", project = "换流站消防专项预案") @RuleMethod(methodLabel = "交互动作", project = "换流站消防专项预案")
public void operation(@MethodParam(paramLabel = "动作名称") String actionName, public void operation(@MethodParam(paramLabel = "动作名称") String actionName, @MethodParam(paramLabel = "图标") String icon, @MethodParam(paramLabel = "提示信息") String tips, @MethodParam(paramLabel = "按钮json字符串") String buttonJson, @MethodParam(paramLabel = "预案对象") Object paramObj) {
@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();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
//转换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<>();
String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson); String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson);
tempmap1.put("actionName", actionName); tempmap1.put("actionName", actionName);
...@@ -532,22 +483,11 @@ public class ContingencyAction implements CustomerAction { ...@@ -532,22 +483,11 @@ public class ContingencyAction implements CustomerAction {
this.sendcmd("optionarea", paramObj, result); this.sendcmd("optionarea", paramObj, result);
} }
}
private boolean sendButton(String batchNo, String contingencyPlanId, String equipmentId, String actionName, String buttonJson) { private boolean sendButton(String batchNo, String contingencyPlanId, String equipmentId, String actionName, String buttonJson) {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
/**
* batchNo
* stepCode
* buttonCode
* confirm
* contingencyPlanId
* stepState
*/
try { try {
Map button = objectMapper.readValue(buttonJson, Map.class); Map button = objectMapper.readValue(buttonJson, Map.class);
Map operateInstance = (Map) ((List) button.get("operate")).get(0); Map operateInstance = (Map) ((List) button.get("operate")).get(0);
...@@ -560,11 +500,9 @@ public class ContingencyAction implements CustomerAction { ...@@ -560,11 +500,9 @@ public class ContingencyAction implements CustomerAction {
contingencyDeviceStatus.setStepCode(String.valueOf(button.get("stepCode"))); contingencyDeviceStatus.setStepCode(String.valueOf(button.get("stepCode")));
contingencyDeviceStatus.setStepState(String.valueOf(operateInstance.get("stepState"))); contingencyDeviceStatus.setStepState(String.valueOf(operateInstance.get("stepState")));
riskSourceService.queryContingencyDeviceStatus(contingencyDeviceStatus); riskSourceService.queryContingencyDeviceStatus(contingencyDeviceStatus);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return false; return false;
} }
...@@ -579,13 +517,10 @@ public class ContingencyAction implements CustomerAction { ...@@ -579,13 +517,10 @@ public class ContingencyAction implements CustomerAction {
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "保存交互动作", project = "换流站消防专项预案") @RuleMethod(methodLabel = "保存交互动作", project = "换流站消防专项预案")
public void saveOperation(@MethodParam(paramLabel = "动作名称") String actionName, public void saveOperation(@MethodParam(paramLabel = "动作名称") String actionName, @MethodParam(paramLabel = "图标") String icon, @MethodParam(paramLabel = "提示信息") String tips, @MethodParam(paramLabel = "按钮json字符串") String buttonJson, @MethodParam(paramLabel = "对象") Object paramObj) {
@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();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
//转换content中的变量 //转换content中的变量
...@@ -598,7 +533,6 @@ public class ContingencyAction implements CustomerAction { ...@@ -598,7 +533,6 @@ public class ContingencyAction implements CustomerAction {
if (!ObjectUtils.isEmpty(list)) { if (!ObjectUtils.isEmpty(list)) {
list.forEach(action -> { list.forEach(action -> {
HashMap map = new HashMap(); HashMap map = new HashMap();
// map.put("time", sdf.format(action.getCreateDate()));
map.put("time", sdf1.format(action.getCreateDate().getTime())); map.put("time", sdf1.format(action.getCreateDate().getTime()));
map.put("stepName", action.getContent()); map.put("stepName", action.getContent());
records.add(map); records.add(map);
...@@ -610,9 +544,9 @@ public class ContingencyAction implements CustomerAction { ...@@ -610,9 +544,9 @@ public class ContingencyAction implements CustomerAction {
e.printStackTrace(); e.printStackTrace();
} }
result.add(tempmap1); result.add(tempmap1);
System.out.println("--------------------saveOperation----------------------" + result);
this.sendcmd("recordarea", paramObj, result); this.sendcmd("recordarea", paramObj, result);
} }
}
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;
...@@ -639,8 +573,8 @@ public class ContingencyAction implements CustomerAction { ...@@ -639,8 +573,8 @@ public class ContingencyAction implements CustomerAction {
@RuleMethod(methodLabel = "地图动作", project = "换流站消防专项预案") @RuleMethod(methodLabel = "地图动作", project = "换流站消防专项预案")
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();
log.error("======================================================================================="); if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
...@@ -656,16 +590,13 @@ public class ContingencyAction implements CustomerAction { ...@@ -656,16 +590,13 @@ public class ContingencyAction implements CustomerAction {
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("maparea", paramObj, result); this.sendcmd("maparea", paramObj, result);
} }
}
@RuleMethod(methodLabel = "地图动画", project = "换流站消防专项预案") @RuleMethod(methodLabel = "地图动画", project = "换流站消防专项预案")
public void mapCartoonAction( public void mapCartoonAction(@MethodParam(paramLabel = "动作名称标识") String actionName, @MethodParam(paramLabel = "动作类型") String actionType, @MethodParam(paramLabel = "动作类型参数") String paramJSON, @MethodParam(paramLabel = "对象") Object paramObj) {
@MethodParam(paramLabel = "动作名称标识") String actionName,
@MethodParam(paramLabel = "动作类型") String actionType,
@MethodParam(paramLabel = "动作类型参数") String paramJSON,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
String batchNo = contingencyRo.getBatchNo();
log.error("======================================================================================="); if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
String parameter = instedParams(paramJSON, contingencyRo); String parameter = instedParams(paramJSON, contingencyRo);
...@@ -678,6 +609,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -678,6 +609,7 @@ public class ContingencyAction implements CustomerAction {
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("maparea", paramObj, result); this.sendcmd("maparea", paramObj, result);
} }
}
/** /**
* 顶部消息提示 * 顶部消息提示
...@@ -687,13 +619,10 @@ public class ContingencyAction implements CustomerAction { ...@@ -687,13 +619,10 @@ public class ContingencyAction implements CustomerAction {
* @param paramObj 预案对象 * @param paramObj 预案对象
*/ */
@RuleMethod(methodLabel = "消息提示", project = "换流站消防专项预案") @RuleMethod(methodLabel = "消息提示", project = "换流站消防专项预案")
public void topMessage( public void topMessage(@MethodParam(paramLabel = "标题") String title, @MethodParam(paramLabel = "内容") String content, @MethodParam(paramLabel = "图标") String icon, @MethodParam(paramLabel = "类型") String messageType, @MethodParam(paramLabel = "对象") Object paramObj) {
@MethodParam(paramLabel = "标题") String title,
@MethodParam(paramLabel = "内容") String content,
@MethodParam(paramLabel = "图标") String icon,
@MethodParam(paramLabel = "类型") String messageType,
@MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo); stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
...@@ -709,6 +638,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -709,6 +638,7 @@ public class ContingencyAction implements CustomerAction {
this.sendcmd("message", paramObj, result); this.sendcmd("message", paramObj, result);
} }
}
/** /**
* 启动预案 * 启动预案
...@@ -820,13 +750,10 @@ public class ContingencyAction implements CustomerAction { ...@@ -820,13 +750,10 @@ public class ContingencyAction implements CustomerAction {
@RuleMethod(methodLabel = "自动执行步骤", project = "换流站消防专项预案") @RuleMethod(methodLabel = "自动执行步骤", project = "换流站消防专项预案")
public void autoExecute( public void autoExecute(@MethodParam(paramLabel = "动作名称") String actionName, @MethodParam(paramLabel = "步骤编号") String stepCode, @MethodParam(paramLabel = "按钮编码") String buttonCode, @MethodParam(paramLabel = "步骤状态") String stepState, @MethodParam(paramLabel = "预案对象") Object paramObj) {
@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();
if (!findByBatchNoAndStatus(batchNo)) {
ContingencyPlanInstance contingencyPlanInstance = iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), actionName, "DEFAULT", "", "OPERATE", ""); ContingencyPlanInstance contingencyPlanInstance = iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), actionName, "DEFAULT", "", "OPERATE", "");
Toke toke = remoteSecurityService.getServerToken(); Toke toke = remoteSecurityService.getServerToken();
...@@ -839,12 +766,13 @@ public class ContingencyAction implements CustomerAction { ...@@ -839,12 +766,13 @@ public class ContingencyAction implements CustomerAction {
e.printStackTrace(); e.printStackTrace();
} }
} }
}
@RuleMethod(methodLabel = "添加步骤执行", project = "换流站消防专项预案") @RuleMethod(methodLabel = "添加步骤执行", project = "换流站消防专项预案")
public void addExecute( public void addExecute(@MethodParam(paramLabel = "步骤编号") String stepCode, @MethodParam(paramLabel = "按钮编码") String buttonCode, @MethodParam(paramLabel = "设备数据") Object paramObj) {
@MethodParam(paramLabel = "步骤编号") String stepCode, ContingencyRo contingencyRo = (ContingencyRo) paramObj;
@MethodParam(paramLabel = "按钮编码") String buttonCode, String batchNo = contingencyRo.getBatchNo();
@MethodParam(paramLabel = "设备数据") Object paramObj) { if (!findByBatchNoAndStatus(batchNo)) {
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>(); Map<String, Object> content = new HashMap<>();
...@@ -863,12 +791,10 @@ public class ContingencyAction implements CustomerAction { ...@@ -863,12 +791,10 @@ public class ContingencyAction implements CustomerAction {
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("message", ro, result); this.sendcmd("message", ro, result);
} }
}
@RuleMethod(methodLabel = "清除步骤执行", project = "换流站消防专项预案") @RuleMethod(methodLabel = "清除步骤执行", project = "换流站消防专项预案")
public void clearExecute( public void clearExecute(@MethodParam(paramLabel = "步骤编号") String stepCode, @MethodParam(paramLabel = "按钮编码") String buttonCode, @MethodParam(paramLabel = "重点设备ID") String fireEquipmentId) {
@MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "重点设备ID") String fireEquipmentId) {
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>(); Map<String, Object> content = new HashMap<>();
...@@ -893,31 +819,25 @@ public class ContingencyAction implements CustomerAction { ...@@ -893,31 +819,25 @@ public class ContingencyAction implements CustomerAction {
@RuleMethod(methodLabel = "同步自动执行步骤", project = "换流站消防专项预案") @RuleMethod(methodLabel = "同步自动执行步骤", project = "换流站消防专项预案")
public void sendExecute(@MethodParam(paramLabel = "预案对象") Object paramObj) { public void sendExecute(@MethodParam(paramLabel = "预案对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(contingencyRo.getEquipmentId()); Map<String, Object> equipemtnPoints = pointCache.get(contingencyRo.getEquipmentId());
tempmap1.put("type", "buttonCache"); tempmap1.put("type", "buttonCache");
tempmap1.put("content", ObjectUtils.isEmpty(equipemtnPoints) ? new ArrayList<>() : equipemtnPoints.values()); tempmap1.put("content", ObjectUtils.isEmpty(equipemtnPoints) ? new ArrayList<>() : equipemtnPoints.values());
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("message", paramObj, result); this.sendcmd("message", paramObj, result);
} }
}
@RuleMethod(methodLabel = "自动执行动作V2", project = "换流站消防专项预案") @RuleMethod(methodLabel = "自动执行动作V2", project = "换流站消防专项预案")
public void autoExecuteActionV2( 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) {
@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();
if (!findByBatchNoAndStatus(batchNo)) {
String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson); String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson);
try { try {
contingencyInstance.fire(contingencyRo.getBatchNo(), stepCode, contingencyPlanId, buttonCode, confirm, stepState, RequestContext.getToken(), RequestContext.getProduct()); contingencyInstance.fire(contingencyRo.getBatchNo(), stepCode, contingencyPlanId, buttonCode, confirm, stepState, RequestContext.getToken(), RequestContext.getProduct());
...@@ -925,13 +845,12 @@ public class ContingencyAction implements CustomerAction { ...@@ -925,13 +845,12 @@ public class ContingencyAction implements CustomerAction {
e.printStackTrace(); e.printStackTrace();
} }
} }
}
public void sendcmd(String msgType, SafteyPlanResult result) { public void sendcmd(String msgType, SafteyPlanResult result) {
Constructor<?> constructor; Constructor<?> constructor;
try { try {
constructor = Class.forName( constructor = Class.forName(PACKAGEURL + result.getClass().getSimpleName() + "Message").getConstructor(ActionResult.class);
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());
...@@ -1001,4 +920,13 @@ public class ContingencyAction implements CustomerAction { ...@@ -1001,4 +920,13 @@ public class ContingencyAction implements CustomerAction {
} }
} }
} }
/**
* 通过batchNo获取预案的状态
* @param batchNo
* @return
*/
private Boolean findByBatchNoAndStatus(String batchNo) {
return CollectionUtils.isEmpty(planOperationRecordDao.findByBatchNoAndStatus(batchNo, 0));
}
} }
...@@ -30,4 +30,5 @@ public interface IPlanOperationRecordDao extends BaseDao<PlanOperationRecord, Lo ...@@ -30,4 +30,5 @@ public interface IPlanOperationRecordDao extends BaseDao<PlanOperationRecord, Lo
*/ */
List<PlanOperationRecord> findByStatus(Integer status); List<PlanOperationRecord> findByStatus(Integer status);
List<PlanOperationRecord> findByBatchNoAndStatus(String batchNo, Integer status);
} }
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