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,33 +212,32 @@ public class ContingencyAction implements CustomerAction { ...@@ -219,33 +212,32 @@ 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;
stopSnapshop(contingencyRo); String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
SafteyPlanResult result = new SafteyPlanResult(); stopSnapshop(contingencyRo);
Map<String, Object> tempmap1 = new HashMap<>();
ArrayList list = new ArrayList(); SafteyPlanResult result = new SafteyPlanResult();
HashMap step = new HashMap(); Map<String, Object> tempmap1 = new HashMap<>();
ArrayList list = new ArrayList();
step.put("stepCode", stepCode); HashMap step = new HashMap();
step.put("stepName", stepName);
step.put("stepCode", stepCode);
HashMap nextmap = new HashMap(); step.put("stepName", stepName);
nextmap.put("stepCode", nextStepCode);
nextmap.put("stepName", nextStepName); HashMap nextmap = new HashMap();
list.add(step); nextmap.put("stepCode", nextStepCode);
list.add(nextmap); nextmap.put("stepName", nextStepName);
list.add(step);
tempmap1.put("step", list); list.add(nextmap);
tempmap1.put("preStep", new HashMap());
result.add(tempmap1); tempmap1.put("step", list);
log.info("步骤更新(new)" + JSONObject.toJSONString(result)); tempmap1.put("preStep", new HashMap());
this.sendcmd("steparea", contingencyRo, result); result.add(tempmap1);
log.info("步骤更新(new)" + JSONObject.toJSONString(result));
this.sendcmd("steparea", contingencyRo, result);
}
} }
/** /**
...@@ -253,42 +245,11 @@ public class ContingencyAction implements CustomerAction { ...@@ -253,42 +245,11 @@ public class ContingencyAction implements CustomerAction {
* @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,7 +325,10 @@ public class ContingencyAction implements CustomerAction { ...@@ -368,7 +325,10 @@ 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;
iContingencyInstance.updateStep(stepCode, contingencyRo.getBatchNo()); String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
iContingencyInstance.updateStep(stepCode, contingencyRo.getBatchNo());
}
} }
...@@ -379,35 +339,38 @@ public class ContingencyAction implements CustomerAction { ...@@ -379,35 +339,38 @@ 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;
stopSnapshop(contingencyRo); String batchNo = contingencyRo.getBatchNo();
//转换content中的变量 if (!findByBatchNoAndStatus(batchNo)) {
content = instedParams(content, contingencyRo); stopSnapshop(contingencyRo);
iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", content, "MESSAGE", ""); //转换content中的变量
content = instedParams(content, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", content, "MESSAGE", "");
Map<String, Object> tempmap1 = new HashMap<>();
try { SafteyPlanResult result = new SafteyPlanResult();
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Map<String, Object> tempmap1 = new HashMap<>();
List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE"); try {
ArrayList records = new ArrayList<>(); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (!ObjectUtils.isEmpty(list)) { List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
list.forEach(action -> { ArrayList records = new ArrayList<>();
HashMap map = new HashMap(); if (!ObjectUtils.isEmpty(list)) {
map.put("time", sdf1.format(action.getCreateDate().getTime())); list.forEach(action -> {
map.put("stepName", action.getContent()); HashMap map = new HashMap();
records.add(map); map.put("time", sdf1.format(action.getCreateDate().getTime()));
}); map.put("stepName", action.getContent());
records.add(map);
});
}
tempmap1.put("content", records);
tempmap1.put("status", PlanRecordStatusEnum.OPERATION.getCode());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
tempmap1.put("content", records); result.add(tempmap1);
tempmap1.put("status", PlanRecordStatusEnum.OPERATION.getCode()); System.out.println("--------------------messageRecord----------------------" + result);
} catch (Exception e) { this.sendcmd("recordarea", paramObj, result);
// TODO Auto-generated catch block this.sendweb("recordarea", paramObj, result);
e.printStackTrace();
} }
result.add(tempmap1);
System.out.println("--------------------messageRecord----------------------" + result);
this.sendcmd("recordarea", paramObj, result);
this.sendweb("recordarea", paramObj, result);
} }
/** /**
...@@ -424,34 +387,29 @@ public class ContingencyAction implements CustomerAction { ...@@ -424,34 +387,29 @@ 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;
stopSnapshop(contingencyRo); String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo);
//转换智能辅助中的变量 //转换智能辅助中的变量
content = instedParams(content, contingencyRo); content = instedParams(content, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("icon", icon); tempmap1.put("icon", icon);
tempmap1.put("step", step); tempmap1.put("step", step);
tempmap1.put("title", title); tempmap1.put("title", title);
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()); result.add(tempmap1);
// tempmap1.put("contingencyRo", contingencyRo);
result.add(tempmap1);
this.sendcmd("helparea", paramObj, result); this.sendcmd("helparea", paramObj, result);
}
} }
...@@ -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,49 +460,34 @@ public class ContingencyAction implements CustomerAction { ...@@ -505,49 +460,34 @@ 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;
stopSnapshop(contingencyRo); String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
//转换content中的变量 stopSnapshop(contingencyRo);
tips = instedParams(tips, contingencyRo);
//转换content中的变量
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("icon", icon);
tempmap1.put("tips", tips);
tempmap1.put("button", buttonJson);
tempmap1.put("caseId", contingencyPlanId);
result.add(tempmap1);
tempmap1.put("actionName", actionName); this.sendcmd("optionarea", paramObj, result);
tempmap1.put("icon", icon); }
tempmap1.put("tips", tips);
tempmap1.put("button", buttonJson);
tempmap1.put("caseId", contingencyPlanId);
result.add(tempmap1);
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,39 +517,35 @@ public class ContingencyAction implements CustomerAction { ...@@ -579,39 +517,35 @@ 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;
stopSnapshop(contingencyRo); String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo);
//转换content中的变量 //转换content中的变量
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
try { try {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE"); List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
ArrayList records = new ArrayList<>(); ArrayList records = new ArrayList<>();
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); });
}); }
tempmap1.put("content", records);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
tempmap1.put("content", records); result.add(tempmap1);
} catch (Exception e) { this.sendcmd("recordarea", paramObj, result);
// TODO Auto-generated catch block
e.printStackTrace();
} }
result.add(tempmap1);
System.out.println("--------------------saveOperation----------------------" + 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) {
...@@ -639,44 +573,42 @@ public class ContingencyAction implements CustomerAction { ...@@ -639,44 +573,42 @@ 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();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("key", actionName); tempmap1.put("key", actionName);
tempmap1.put("content", paramJSON); tempmap1.put("content", paramJSON);
if (isArea.contains(paramJSON)) { if (isArea.contains(paramJSON)) {
tempmap1.put("isArea", true); tempmap1.put("isArea", true);
} else { } else {
tempmap1.put("isArea", false); tempmap1.put("isArea", false);
}
result.add(tempmap1);
this.sendcmd("maparea", paramObj, result);
} }
result.add(tempmap1);
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);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("key", actionName); tempmap1.put("key", actionName);
tempmap1.put("content", actionType); tempmap1.put("content", actionType);
tempmap1.put("parameter", parameter); tempmap1.put("parameter", parameter);
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("maparea", paramObj, result); this.sendcmd("maparea", paramObj, result);
}
} }
/** /**
...@@ -687,27 +619,25 @@ public class ContingencyAction implements CustomerAction { ...@@ -687,27 +619,25 @@ 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;
stopSnapshop(contingencyRo); String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult(); SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>(); Map<String, Object> tempmap1 = new HashMap<>();
//转换content中的变量 //转换content中的变量
content = instedParams(content, contingencyRo); content = instedParams(content, contingencyRo);
tempmap1.put("content", content); tempmap1.put("content", content);
tempmap1.put("type", messageType);//消息类型 messageType 黑色框消息类型 CONTINGENCY,,滚动消息:CURRENTMESSAGE tempmap1.put("type", messageType);//消息类型 messageType 黑色框消息类型 CONTINGENCY,,滚动消息:CURRENTMESSAGE
tempmap1.put("title", title); tempmap1.put("title", title);
tempmap1.put("icon", icon); tempmap1.put("icon", icon);
result.add(tempmap1); result.add(tempmap1);
this.sendcmd("message", paramObj, result); this.sendcmd("message", paramObj, result);
}
} }
/** /**
...@@ -820,55 +750,51 @@ public class ContingencyAction implements CustomerAction { ...@@ -820,55 +750,51 @@ 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;
ContingencyPlanInstance contingencyPlanInstance = iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), actionName, "DEFAULT", "", "OPERATE", ""); String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
ContingencyPlanInstance contingencyPlanInstance = iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), actionName, "DEFAULT", "", "OPERATE", "");
Toke toke = remoteSecurityService.getServerToken(); Toke toke = remoteSecurityService.getServerToken();
RequestContext.setToken(toke.getToke()); RequestContext.setToken(toke.getToke());
RequestContext.setProduct(toke.getProduct()); RequestContext.setProduct(toke.getProduct());
try { try {
iContingencyInstance.setButtonExecuted(contingencyRo.getBatchNo(), contingencyPlanInstance.getId(), buttonCode, "CONFIRM"); iContingencyInstance.setButtonExecuted(contingencyRo.getBatchNo(), contingencyPlanInstance.getId(), buttonCode, "CONFIRM");
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();
}
} }
} }
@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<>();
content.put("stepCode", stepCode); content.put("stepCode", stepCode);
content.put("buttonCode", buttonCode); content.put("buttonCode", buttonCode);
DeviceRo ro = (DeviceRo) paramObj; DeviceRo ro = (DeviceRo) paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId()); Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId());
if (ObjectUtils.isEmpty(equipemtnPoints)) { if (ObjectUtils.isEmpty(equipemtnPoints)) {
equipemtnPoints = new HashMap<>(); equipemtnPoints = new HashMap<>();
}
equipemtnPoints.put(stepCode + "-" + buttonCode, content);
tempmap1.put("type", "buttonCache");
tempmap1.put("content", equipemtnPoints.values());
result.add(tempmap1);
this.sendcmd("message", ro, result);
} }
equipemtnPoints.put(stepCode + "-" + buttonCode, content);
tempmap1.put("type", "buttonCache");
tempmap1.put("content", equipemtnPoints.values());
result.add(tempmap1);
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,45 +819,38 @@ public class ContingencyAction implements CustomerAction { ...@@ -893,45 +819,38 @@ 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) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
ContingencyRo contingencyRo = (ContingencyRo) paramObj; ContingencyRo contingencyRo = (ContingencyRo) paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(contingencyRo.getEquipmentId()); String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
tempmap1.put("type", "buttonCache"); SafteyPlanResult result = new SafteyPlanResult();
tempmap1.put("content", ObjectUtils.isEmpty(equipemtnPoints) ? new ArrayList<>() : equipemtnPoints.values()); Map<String, Object> tempmap1 = new HashMap<>();
result.add(tempmap1); Map<String, Object> equipemtnPoints = pointCache.get(contingencyRo.getEquipmentId());
tempmap1.put("type", "buttonCache");
this.sendcmd("message", paramObj, result); tempmap1.put("content", ObjectUtils.isEmpty(equipemtnPoints) ? new ArrayList<>() : equipemtnPoints.values());
result.add(tempmap1);
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 contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson); String batchNo = contingencyRo.getBatchNo();
try { if (!findByBatchNoAndStatus(batchNo)) {
contingencyInstance.fire(contingencyRo.getBatchNo(), stepCode, contingencyPlanId, buttonCode, confirm, stepState, RequestContext.getToken(), RequestContext.getProduct()); String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson);
} catch (Exception e) { try {
e.printStackTrace(); contingencyInstance.fire(contingencyRo.getBatchNo(), stepCode, contingencyPlanId, buttonCode, confirm, stepState, RequestContext.getToken(), RequestContext.getProduct());
} catch (Exception e) {
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