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

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

parent afba4432
......@@ -186,24 +186,17 @@ public class ContingencyAction implements CustomerAction {
Toke toke = remoteSecurityService.getServerToken();
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());
JSONArray dataList = JSONObject.parseArray(JSONStr);
log.info(String.format("请求值班系统返回dataList:%s", dataList));
if (!ObjectUtils.isEmpty(dataList)) {
Map<String, String> finalReturnMap = returnMap;
dataList.forEach(
x -> {
JSONObject obj = (JSONObject) x;
String name = obj.getString("position");
finalReturnMap.put(name, obj.getString("dutyName"));
}
);
dataList.forEach(x -> {
JSONObject obj = (JSONObject) x;
String name = obj.getString("position");
finalReturnMap.put(name, obj.getString("dutyName"));
});
}
stringStringMap.put(batchNo, returnMap);
}
......@@ -219,33 +212,32 @@ public class ContingencyAction implements CustomerAction {
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "步骤更新", project = "换流站消防专项预案")
public void stepInfo(@MethodParam(paramLabel = "当前步骤编号") String stepCode,
@MethodParam(paramLabel = "当前步骤名称") String stepName,
@MethodParam(paramLabel = "下一步编号") String nextStepCode,
@MethodParam(paramLabel = "下一步名称") String nextStepName,
@MethodParam(paramLabel = "对象") Object paramObj) {
public void stepInfo(@MethodParam(paramLabel = "当前步骤编号") String stepCode, @MethodParam(paramLabel = "当前步骤名称") String stepName, @MethodParam(paramLabel = "下一步编号") String nextStepCode, @MethodParam(paramLabel = "下一步名称") String nextStepName, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
ArrayList list = new ArrayList();
HashMap step = new HashMap();
step.put("stepCode", stepCode);
step.put("stepName", stepName);
HashMap nextmap = new HashMap();
nextmap.put("stepCode", nextStepCode);
nextmap.put("stepName", nextStepName);
list.add(step);
list.add(nextmap);
tempmap1.put("step", list);
tempmap1.put("preStep", new HashMap());
result.add(tempmap1);
log.info("步骤更新(new)" + JSONObject.toJSONString(result));
this.sendcmd("steparea", contingencyRo, result);
String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
ArrayList list = new ArrayList();
HashMap step = new HashMap();
step.put("stepCode", stepCode);
step.put("stepName", stepName);
HashMap nextmap = new HashMap();
nextmap.put("stepCode", nextStepCode);
nextmap.put("stepName", nextStepName);
list.add(step);
list.add(nextmap);
tempmap1.put("step", list);
tempmap1.put("preStep", new HashMap());
result.add(tempmap1);
log.info("步骤更新(new)" + JSONObject.toJSONString(result));
this.sendcmd("steparea", contingencyRo, result);
}
}
/**
......@@ -253,42 +245,11 @@ public class ContingencyAction implements CustomerAction {
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "步骤更新(旧)", project = "换流站消防专项预案")
public void stepInfoOld(@MethodParam(paramLabel = "当前编号") String stepCode,
@MethodParam(paramLabel = "对象") Object paramObj) {
public void stepInfoOld(@MethodParam(paramLabel = "当前编号") String stepCode, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
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);
}
......@@ -299,9 +260,7 @@ public class ContingencyAction implements CustomerAction {
ro.setTelesignallingMap(null);
Constructor<?> constructor;
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);
if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson());
......@@ -341,9 +300,7 @@ public class ContingencyAction implements CustomerAction {
ro.setTelesignallingMap(null);
Constructor<?> constructor;
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);
ToipResponse toipResponse = action.buildResponse(msgType, contingency, result.toJson());
String topic = String.format("/%s/%s/%s", serviceName, stationName, "numberPlan");
......@@ -368,7 +325,10 @@ public class ContingencyAction implements CustomerAction {
@RuleMethod(methodLabel = "步骤更新保存", project = "换流站消防专项预案")
public void saveStepInfo(@MethodParam(paramLabel = "当前编号") String stepCode, @MethodParam(paramLabel = "对象") Object 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 {
@RuleMethod(methodLabel = "执行记录", project = "换流站消防专项预案")
public void messageRecord(@MethodParam(paramLabel = "消息内容") String content, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
//转换content中的变量
content = instedParams(content, contingencyRo);
iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", content, "MESSAGE", "");
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
try {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
ArrayList records = new ArrayList<>();
if (!ObjectUtils.isEmpty(list)) {
list.forEach(action -> {
HashMap map = new HashMap();
map.put("time", sdf1.format(action.getCreateDate().getTime()));
map.put("stepName", action.getContent());
records.add(map);
});
String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo);
//转换content中的变量
content = instedParams(content, contingencyRo);
iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", content, "MESSAGE", "");
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
try {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
ArrayList records = new ArrayList<>();
if (!ObjectUtils.isEmpty(list)) {
list.forEach(action -> {
HashMap map = new HashMap();
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);
tempmap1.put("status", PlanRecordStatusEnum.OPERATION.getCode());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
result.add(tempmap1);
System.out.println("--------------------messageRecord----------------------" + result);
this.sendcmd("recordarea", paramObj, result);
this.sendweb("recordarea", paramObj, result);
}
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 {
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "智能辅助", project = "换流站消防专项预案")
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;
stopSnapshop(contingencyRo);
String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo);
//转换智能辅助中的变量
content = instedParams(content, contingencyRo);
//转换智能辅助中的变量
content = instedParams(content, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("icon", icon);
tempmap1.put("step", step);
tempmap1.put("title", title);
tempmap1.put("content", content);
tempmap1.put("image", image);
tempmap1.put("table", table);
iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", /*JSONObject.toJSONString(tempmap1)*/JSONUtil.toJson(tempmap1), "HELPAREA", "");
// tempmap1.put("batchNo", contingencyRo.getBatchNo());
// tempmap1.put("contingencyRo", contingencyRo);
result.add(tempmap1);
tempmap1.put("icon", icon);
tempmap1.put("step", step);
tempmap1.put("title", title);
tempmap1.put("content", content);
tempmap1.put("image", image);
tempmap1.put("table", table);
iContingencyInstance.createInstanceRecord(contingencyRo.getBatchNo(), "", "DEFAULT", JSONUtil.toJson(tempmap1), "HELPAREA", "");
result.add(tempmap1);
this.sendcmd("helparea", paramObj, result);
this.sendcmd("helparea", paramObj, result);
}
}
......@@ -465,8 +423,7 @@ public class ContingencyAction implements CustomerAction {
Method getMethod = null;
try {
for (Field field : fields) {
if (field.getName().equals("serialVersionUID"))
continue;
if (field.getName().equals("serialVersionUID")) continue;
String fileNameInMethod = String.valueOf(field.getName().charAt(0)).toUpperCase() + field.getName().substring(1);
getMethod = contingencyRo.getClass().getMethod("get" + fileNameInMethod);
String value = String.valueOf(getMethod.invoke(contingencyRo));
......@@ -486,11 +443,9 @@ public class ContingencyAction implements CustomerAction {
while (m.find()) {
String parameter = m.group();
Object parametervalue = ELEvaluationContext
.getValue(parameter.substring(1, parameter.length() - 1));
Object parametervalue = ELEvaluationContext.getValue(parameter.substring(1, parameter.length() - 1));
if (parametervalue != null)
str = str.replace(parameter,
parametervalue != null ? parametervalue.toString() : null);
str = str.replace(parameter, parametervalue != null ? parametervalue.toString() : null);
}
return str;
}
......@@ -505,49 +460,34 @@ public class ContingencyAction implements CustomerAction {
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "交互动作", project = "换流站消防专项预案")
public void operation(@MethodParam(paramLabel = "动作名称") String actionName,
@MethodParam(paramLabel = "图标") String icon,
@MethodParam(paramLabel = "提示信息") String tips,
@MethodParam(paramLabel = "按钮json字符串") String buttonJson,
@MethodParam(paramLabel = "预案对象") Object paramObj) {
public void operation(@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;
stopSnapshop(contingencyRo);
//转换content中的变量
tips = instedParams(tips, contingencyRo);
String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo);
//转换content中的变量
tips = instedParams(tips, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
SafteyPlanResult result = new SafteyPlanResult();
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);
tempmap1.put("icon", icon);
tempmap1.put("tips", tips);
tempmap1.put("button", buttonJson);
tempmap1.put("caseId", contingencyPlanId);
result.add(tempmap1);
this.sendcmd("optionarea", paramObj, result);
this.sendcmd("optionarea", paramObj, result);
}
}
private boolean sendButton(String batchNo, String contingencyPlanId, String equipmentId, String actionName, String buttonJson) {
ObjectMapper objectMapper = new ObjectMapper();
/**
* batchNo
* stepCode
* buttonCode
* confirm
* contingencyPlanId
* stepState
*/
try {
Map button = objectMapper.readValue(buttonJson, Map.class);
Map operateInstance = (Map) ((List) button.get("operate")).get(0);
......@@ -560,11 +500,9 @@ public class ContingencyAction implements CustomerAction {
contingencyDeviceStatus.setStepCode(String.valueOf(button.get("stepCode")));
contingencyDeviceStatus.setStepState(String.valueOf(operateInstance.get("stepState")));
riskSourceService.queryContingencyDeviceStatus(contingencyDeviceStatus);
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
......@@ -579,39 +517,35 @@ public class ContingencyAction implements CustomerAction {
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "保存交互动作", project = "换流站消防专项预案")
public void saveOperation(@MethodParam(paramLabel = "动作名称") String actionName,
@MethodParam(paramLabel = "图标") String icon,
@MethodParam(paramLabel = "提示信息") String tips,
@MethodParam(paramLabel = "按钮json字符串") String buttonJson,
@MethodParam(paramLabel = "对象") Object paramObj) {
public void saveOperation(@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;
stopSnapshop(contingencyRo);
String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo);
//转换content中的变量
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
try {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
ArrayList records = new ArrayList<>();
if (!ObjectUtils.isEmpty(list)) {
list.forEach(action -> {
HashMap map = new HashMap();
// map.put("time", sdf.format(action.getCreateDate()));
map.put("time", sdf1.format(action.getCreateDate().getTime()));
map.put("stepName", action.getContent());
records.add(map);
});
//转换content中的变量
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
try {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<ContingencyPlanInstance> list = iContingencyInstance.queryForTimeLine(contingencyRo.getBatchNo(), "MESSAGE");
ArrayList records = new ArrayList<>();
if (!ObjectUtils.isEmpty(list)) {
list.forEach(action -> {
HashMap map = new HashMap();
map.put("time", sdf1.format(action.getCreateDate().getTime()));
map.put("stepName", action.getContent());
records.add(map);
});
}
tempmap1.put("content", records);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
tempmap1.put("content", records);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
result.add(tempmap1);
this.sendcmd("recordarea", paramObj, result);
}
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) {
......@@ -639,44 +573,42 @@ public class ContingencyAction implements CustomerAction {
@RuleMethod(methodLabel = "地图动作", project = "换流站消防专项预案")
public void mapAction(@MethodParam(paramLabel = "动作名称标识") String actionName, @MethodParam(paramLabel = "参数") String paramJSON, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
log.error("=======================================================================================");
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("key", actionName);
tempmap1.put("content", paramJSON);
if (isArea.contains(paramJSON)) {
tempmap1.put("isArea", true);
} else {
tempmap1.put("isArea", false);
String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("key", actionName);
tempmap1.put("content", paramJSON);
if (isArea.contains(paramJSON)) {
tempmap1.put("isArea", true);
} else {
tempmap1.put("isArea", false);
}
result.add(tempmap1);
this.sendcmd("maparea", paramObj, result);
}
result.add(tempmap1);
this.sendcmd("maparea", paramObj, result);
}
@RuleMethod(methodLabel = "地图动画", project = "换流站消防专项预案")
public void mapCartoonAction(
@MethodParam(paramLabel = "动作名称标识") String actionName,
@MethodParam(paramLabel = "动作类型") String actionType,
@MethodParam(paramLabel = "动作类型参数") String paramJSON,
@MethodParam(paramLabel = "对象") Object paramObj) {
public void mapCartoonAction(@MethodParam(paramLabel = "动作名称标识") String actionName, @MethodParam(paramLabel = "动作类型") String actionType, @MethodParam(paramLabel = "动作类型参数") String paramJSON, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
log.error("=======================================================================================");
stopSnapshop(contingencyRo);
String parameter = instedParams(paramJSON, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("key", actionName);
tempmap1.put("content", actionType);
tempmap1.put("parameter", parameter);
result.add(tempmap1);
this.sendcmd("maparea", paramObj, result);
String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo);
String parameter = instedParams(paramJSON, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
tempmap1.put("key", actionName);
tempmap1.put("content", actionType);
tempmap1.put("parameter", parameter);
result.add(tempmap1);
this.sendcmd("maparea", paramObj, result);
}
}
/**
......@@ -687,27 +619,25 @@ public class ContingencyAction implements CustomerAction {
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "消息提示", project = "换流站消防专项预案")
public void topMessage(
@MethodParam(paramLabel = "标题") String title,
@MethodParam(paramLabel = "内容") String content,
@MethodParam(paramLabel = "图标") String icon,
@MethodParam(paramLabel = "类型") String messageType,
@MethodParam(paramLabel = "对象") Object paramObj) {
public void topMessage(@MethodParam(paramLabel = "标题") String title, @MethodParam(paramLabel = "内容") String content, @MethodParam(paramLabel = "图标") String icon, @MethodParam(paramLabel = "类型") String messageType, @MethodParam(paramLabel = "对象") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
stopSnapshop(contingencyRo);
String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
//转换content中的变量
content = instedParams(content, contingencyRo);
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
//转换content中的变量
content = instedParams(content, contingencyRo);
tempmap1.put("content", content);
tempmap1.put("type", messageType);//消息类型 messageType 黑色框消息类型 CONTINGENCY,,滚动消息:CURRENTMESSAGE
tempmap1.put("title", title);
tempmap1.put("icon", icon);
result.add(tempmap1);
tempmap1.put("content", content);
tempmap1.put("type", messageType);//消息类型 messageType 黑色框消息类型 CONTINGENCY,,滚动消息:CURRENTMESSAGE
tempmap1.put("title", title);
tempmap1.put("icon", icon);
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
this.sendcmd("message", paramObj, result);
}
}
/**
......@@ -820,55 +750,51 @@ public class ContingencyAction implements CustomerAction {
@RuleMethod(methodLabel = "自动执行步骤", project = "换流站消防专项预案")
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;
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();
RequestContext.setToken(toke.getToke());
RequestContext.setProduct(toke.getProduct());
try {
iContingencyInstance.setButtonExecuted(contingencyRo.getBatchNo(), contingencyPlanInstance.getId(), buttonCode, "CONFIRM");
iContingencyInstance.fire(contingencyRo.getBatchNo(), stepCode, contingencyPlanInstance.getId(), buttonCode, "CONFIRM", stepState);
} catch (Exception e) {
e.printStackTrace();
Toke toke = remoteSecurityService.getServerToken();
RequestContext.setToken(toke.getToke());
RequestContext.setProduct(toke.getProduct());
try {
iContingencyInstance.setButtonExecuted(contingencyRo.getBatchNo(), contingencyPlanInstance.getId(), buttonCode, "CONFIRM");
iContingencyInstance.fire(contingencyRo.getBatchNo(), stepCode, contingencyPlanInstance.getId(), buttonCode, "CONFIRM", stepState);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@RuleMethod(methodLabel = "添加步骤执行", project = "换流站消防专项预案")
public void addExecute(
@MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "设备数据") Object paramObj) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>();
content.put("stepCode", stepCode);
content.put("buttonCode", buttonCode);
DeviceRo ro = (DeviceRo) paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId());
if (ObjectUtils.isEmpty(equipemtnPoints)) {
equipemtnPoints = new HashMap<>();
public void addExecute(@MethodParam(paramLabel = "步骤编号") String stepCode, @MethodParam(paramLabel = "按钮编码") String buttonCode, @MethodParam(paramLabel = "设备数据") Object paramObj) {
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>();
content.put("stepCode", stepCode);
content.put("buttonCode", buttonCode);
DeviceRo ro = (DeviceRo) paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(ro.getEquipmentId());
if (ObjectUtils.isEmpty(equipemtnPoints)) {
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 = "换流站消防专项预案")
public void clearExecute(
@MethodParam(paramLabel = "步骤编号") String stepCode,
@MethodParam(paramLabel = "按钮编码") String buttonCode,
@MethodParam(paramLabel = "重点设备ID") String fireEquipmentId) {
public void clearExecute(@MethodParam(paramLabel = "步骤编号") String stepCode, @MethodParam(paramLabel = "按钮编码") String buttonCode, @MethodParam(paramLabel = "重点设备ID") String fireEquipmentId) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> content = new HashMap<>();
......@@ -893,45 +819,38 @@ public class ContingencyAction implements CustomerAction {
@RuleMethod(methodLabel = "同步自动执行步骤", project = "换流站消防专项预案")
public void sendExecute(@MethodParam(paramLabel = "预案对象") Object paramObj) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
ContingencyRo contingencyRo = (ContingencyRo) paramObj;
Map<String, Object> equipemtnPoints = pointCache.get(contingencyRo.getEquipmentId());
tempmap1.put("type", "buttonCache");
tempmap1.put("content", ObjectUtils.isEmpty(equipemtnPoints) ? new ArrayList<>() : equipemtnPoints.values());
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
SafteyPlanResult result = new SafteyPlanResult();
Map<String, Object> tempmap1 = new HashMap<>();
Map<String, Object> equipemtnPoints = pointCache.get(contingencyRo.getEquipmentId());
tempmap1.put("type", "buttonCache");
tempmap1.put("content", ObjectUtils.isEmpty(equipemtnPoints) ? new ArrayList<>() : equipemtnPoints.values());
result.add(tempmap1);
this.sendcmd("message", paramObj, result);
}
}
@RuleMethod(methodLabel = "自动执行动作V2", project = "换流站消防专项预案")
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;
String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson);
try {
contingencyInstance.fire(contingencyRo.getBatchNo(), stepCode, contingencyPlanId, buttonCode, confirm, stepState, RequestContext.getToken(), RequestContext.getProduct());
} catch (Exception e) {
e.printStackTrace();
String batchNo = contingencyRo.getBatchNo();
if (!findByBatchNoAndStatus(batchNo)) {
String contingencyPlanId = getContingencyPlanId(contingencyRo.getBatchNo(), actionName, icon, tips, buttonJson);
try {
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) {
Constructor<?> constructor;
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);
if ("mqtt".equals(pushType.toLowerCase())) {
ToipResponse toipResponse = action.buildResponse(msgType, null, result.toJson());
......@@ -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
*/
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