Commit bf2bd3a4 authored by 高建强's avatar 高建强

item:应急处置同步调整提交

parent 9b11b276
......@@ -10,7 +10,6 @@ import com.yeejoin.amos.fas.business.action.el.ELEvaluationContext;
import com.yeejoin.amos.fas.business.action.model.ContingencyEvent;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.model.DeviceRo;
//import com.yeejoin.amos.fas.business.action.mq.IKafkaProducer;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.action.result.ActionResult;
import com.yeejoin.amos.fas.business.action.result.SafteyPlanResult;
......@@ -29,6 +28,7 @@ import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import com.yeejoin.amos.fas.business.util.JSONUtil;
import com.yeejoin.amos.fas.business.vo.MessageVO;
import com.yeejoin.amos.fas.business.vo.PlanStepJsonVO;
import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.common.enums.ContingencyPlanStatusEnum;
import com.yeejoin.amos.fas.common.enums.PlanRecordStatusEnum;
......@@ -62,6 +62,7 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@Component
......@@ -161,16 +162,6 @@ public class ContingencyAction implements CustomerAction {
@Autowired
private com.yeejoin.amos.component.rule.RuleTrigger ruleTrigger;
//当值值班长(S1)、副值班长(S2)、值班员(A1,A2,A3)、白班值班员、保安人员、驻站消防队长(F1)
/* private static Map<String, String> positionMap = new HashMap<String, String>() {{
put("S1", "S1");
put("S2", "S2");
put("A1", "A1");
put("A2", "A2");
put("A3", "A3");
put("F1", "F1");
}};
*/
/**
* @param stepCode 当前步骤编号
......@@ -442,12 +433,23 @@ public class ContingencyAction implements CustomerAction {
* @param paramObj 预案对象
*/
@RuleMethod(methodLabel = "交互动作", project = "换流站消防专项预案")
@Transactional
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;
String batchNo = contingencyRo.getBatchNo();
String buttonCode = contingencyRo.getButtonCode();
String stepCode = contingencyRo.getStep();
if (StringUtils.isBlank(buttonCode)) {
// 根据步骤,取按钮编码
List<PlanStepJsonVO> planStepJsonVOList = iContingencyInstance.getPlanStepJsonVOS();
List<PlanStepJsonVO> collect = planStepJsonVOList.stream().filter(x -> x.getStepCode().equals(stepCode)).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(collect)) {
buttonCode = collect.get(0).getButtonCode();
}
}
if (!findByBatchNoAndStatus(batchNo)) {
stopSnapshop(contingencyRo);
String buttonCode = contingencyRo.getButtonCode();
//转换content中的变量
tips = instedParams(tips, contingencyRo);
......@@ -464,7 +466,11 @@ public class ContingencyAction implements CustomerAction {
tempmap1.put("caseId", contingencyPlanId);
result.add(tempmap1);
// 更新预案执行Json串
iPlanVisual3dService.updatePlanStep(batchNo, stepCode, contingencyPlanId, buttonCode, false);
this.sendcmd("optionarea", paramObj, result);
ContingencyPlanInstance instance = contingencyInstance.getMessageById(contingencyPlanId);
if (instance != null) {
String roleCode = contingencyInstance.getPlanStepRoleCodeByButtonCode(buttonCode);
......@@ -475,6 +481,34 @@ public class ContingencyAction implements CustomerAction {
}
contingencyPlanInstanceMapper.updateMessageById(instance);
}
try {
String code = Objects.requireNonNull(redisTemplate.opsForValue().get("stepCode")).toString();
if (StringUtils.isNotBlank(code)) {
if (Integer.parseInt(stepCode) > Integer.parseInt(code)) {
redisTemplate.opsForValue().set("stepCode", stepCode);
System.out.println("======optionarea 加入队列参数信息======action=====");
System.out.println("batchNo-->" + batchNo);
System.out.println("stepCode-->" + stepCode);
System.out.println("contingencyPlanId-->" + contingencyPlanId);
System.out.println("buttonCode-->" + buttonCode);
iContingencyInstance.fire(batchNo, stepCode, contingencyPlanId, buttonCode, "CANCEL_0", "A", RequestContext.getToken(), RequestContext.getProduct(), RequestContext.getAppKey());
}
} else if (StringUtils.isBlank(code) && "0".equals(stepCode)) {
redisTemplate.opsForValue().set("stepCode", stepCode);
System.out.println("======optionarea 加入队列参数信息======action=====");
System.out.println("batchNo-->" + batchNo);
System.out.println("stepCode-->" + stepCode);
System.out.println("contingencyPlanId-->" + contingencyPlanId);
System.out.println("buttonCode-->" + buttonCode);
iContingencyInstance.fire(batchNo, stepCode, contingencyPlanId, buttonCode, "CANCEL_0", "A", RequestContext.getToken(), RequestContext.getProduct(), RequestContext.getAppKey());
} else if (StringUtils.isBlank(code)) {
redisTemplate.opsForValue().set("stepCode", stepCode);
}
} catch (Exception e) {
log.error("optionarea 加入队列失败-->" + e.getMessage());
}
MessageVO messageVO = new MessageVO();
messageVO.setTitle("应急处置事项提醒");
......@@ -488,7 +522,6 @@ public class ContingencyAction implements CustomerAction {
}
}
private boolean sendButton(String batchNo, String contingencyPlanId, String equipmentId, String actionName, String buttonJson) {
ObjectMapper objectMapper = new ObjectMapper();
try {
......
package com.yeejoin.amos.fas.business.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.rule.RuleTrigger;
......@@ -241,12 +242,12 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
BeanUtils.copyProperties(contingencyOriginalData, contingencyRo);
contingencyRo.setStep(stepCode);
contingencyRo.setStepState(stepMap.get(stepKey));
Object isMock = redisTemplate.opsForValue().get("isMock");
if (isMock != null) {
contingencyRo.setIsMock("1".equals(isMock.toString()));
} else {
contingencyRo.setIsMock(false);
}
// Object isMock = redisTemplate.opsForValue().get("isMock");
// if (isMock != null) {
// contingencyRo.setIsMock("1".equals(isMock.toString()));
// } else {
// contingencyRo.setIsMock(false);
// }
log.info("stepstate:" + contingencyRo.getStepState());
log.info("stepCode:" + stepCode);
equipment = impAndFireEquipMapper.queryImpEqumtByFireEquipmt(Long.parseLong(contingencyRo.getFireEquipmentId()));
......@@ -283,7 +284,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
publisherPlanLog(stepCode, buttonCode, batchNo);
// 更新预案执行Json串
planVisual3dService.updatePlanStep(batchNo, stepCode, contingencyPlanId, buttonCode);
// planVisual3dService.updatePlanStep(batchNo, stepCode, contingencyPlanId, buttonCode);
}
} else {
throw new Exception("数据异常,请联系管理员.");
......@@ -328,12 +329,14 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
@Transactional
public void setButtonExecuted(String batchNo, String contingencyPlanId, String code, String buttonState) throws Exception {
ObjectMapper objectMapper = new ObjectMapper();
Optional<ContingencyPlanInstance> contingencyPlanInstance1 = repository.findById(contingencyPlanId);
ContingencyPlanInstance contingencyPlanInstance = contingencyPlanInstance1.get();
if (contingencyPlanInstance1.isPresent()) {
if (contingencyPlanInstance != null && "OPERATE".equals(contingencyPlanInstance.getRecordType())) {
// Optional<ContingencyPlanInstance> contingencyPlanInstance1 = repository.findById(contingencyPlanId);
System.out.println("=========================setButtonExecuted======================");
ContingencyPlanInstance contingencyPlanInstance = contingencyInstance.getMessageById(contingencyPlanId);
// ContingencyPlanInstance contingencyPlanInstance = contingencyPlanInstance1.get();
System.out.println(JSON.toJSON(contingencyPlanInstance));
if (contingencyPlanInstance != null) {
if ("OPERATE".equals(contingencyPlanInstance.getRecordType())) {
String operateJson = contingencyPlanInstance.getContent();
OperateGroup operateGroup = objectMapper.readValue(operateJson, OperateGroup.class);
......@@ -450,6 +453,14 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
map.put("confirm", buttonState);
map.put("contingencyPlanId", contingencyPlanId);
map.put("stepState", stepStateOnbutton);
System.out.println("batchNo-->" + batchNo);
System.out.println("stepCode-->" + stepCode);
System.out.println("contingencyPlanId-->" + contingencyPlanId);
System.out.println("buttonCode-->" + buttonCode);
System.out.println("buttonState-->" + buttonState);
System.out.println("stepStateOnbutton-->" + stepStateOnbutton);
System.out.println("======optionarea 加入队列参数=====fire======");
if (StringUtils.isBlank(token) || StringUtils.isBlank(product)) {
Toke serverToken = remoteSecurityService.getServerToken();
map.put("token", serverToken.getToke());
......@@ -515,7 +526,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
return contingencyPlanInstance;
}
private List<PlanStepJsonVO> getPlanStepJsonVOS() {
public List<PlanStepJsonVO> getPlanStepJsonVOS() {
String json = "";
try {
json = IOUtils.toString(planStepResource.getInputStream(), String.valueOf(StandardCharsets.UTF_8));
......@@ -572,6 +583,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
RequestContext.setToken(token);
setButtonExecuted(batchNo, contingencyPlanId, buttonCode, confirm);
fire(batchNo, stepCode, contingencyPlanId, buttonCode, confirm, stepState);
// 更新预案执行Json串s
planVisual3dService.updatePlanStep(batchNo, stepCode, contingencyPlanId, buttonCode, true);
} catch (Exception e) {
throw e;
} finally {
......
......@@ -395,8 +395,8 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
@Override
@Transactional
public void updatePlanStep(String batchNo, String stepCode, String contingencyPlanId, String buttonCode) {
if (StringUtils.isNotBlank(batchNo) && StringUtils.isNotBlank(contingencyPlanId)) {
public void updatePlanStep(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, Boolean isExecute) {
if (StringUtils.isNotBlank(batchNo) && StringUtils.isNotBlank(contingencyPlanId) && StringUtils.isNotBlank(buttonCode)) {
// 根据批次号查询预案步骤
PlanRule planRule = planOperationRecordMapper.getPlanRuleByBatchNo(batchNo);
if (planRule != null) {
......@@ -404,20 +404,22 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
List<PlanStepJsonVO> collect = list.stream().peek(x -> {
String code = x.getStepCode();
if (code.equals(stepCode)) {
x.setTime(DateFormatUtils.format(new Date(), "HH:mm:ss"));
x.setBatchNo(batchNo);
x.setCaseId(contingencyPlanId);
if (buttonCode.endsWith("_NOT")) {
x.setCheckYesOrNo("0");
} else {
x.setCheckYesOrNo("1");
if (isExecute) {
x.setTime(DateFormatUtils.format(new Date(), "HH:mm:ss"));
x.setBatchNo(batchNo);
x.setCaseId(contingencyPlanId);
if (buttonCode.endsWith("_NOT")) {
x.setCheckYesOrNo("0");
} else {
x.setCheckYesOrNo("1");
}
}
// 通过contingencyPlanId获取buttonJson数据
ContingencyPlanInstance planInstance = iContingencyPlanInstanceRepository.getOne(contingencyPlanId);
x.setButtonJson(planInstance.getContent());
// 更新进度条标志位
x.setShowLine(Integer.parseInt(x.getStepCode()) <= Integer.parseInt(stepCode));
}
// 更新进度条标志位
x.setShowLine(Integer.parseInt(x.getStepCode()) <= Integer.parseInt(stepCode));
}).collect(Collectors.toList());
PlanStepVo planStepVo = new PlanStepVo();
planStepVo.setBatchNo(batchNo);
......
package com.yeejoin.amos.fas.business.service.intfc;
import com.yeejoin.amos.fas.business.vo.PlanStepJsonVO;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.Equipment;
......@@ -45,4 +46,6 @@ public interface IContingencyInstance {
* @return
*/
String getPlanStepRoleCodeByButtonCode(String buttonCode);
List<PlanStepJsonVO> getPlanStepJsonVOS();
}
......@@ -90,7 +90,7 @@ public interface IPlanVisual3dService {
PlanStepVo updatePlanStep(PlanStepVo planStepVo);
void updatePlanStep(String batchNo, String stepCode, String contingencyPlanId, String buttonCode);
void updatePlanStep(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, Boolean isExecute);
Page<ContingencyPlanInstanceVO> selectDisposalActionPage(int current, int size, String batchNo, List<RoleModel> roleModelList, int dataType);
......
......@@ -14,10 +14,10 @@ public class PlanStepJsonVO {
private String batchNo;
private String caseId;
private String buttonJson;
private String time;
private boolean showLine;
private String time = "";
private boolean showLine = false;
/**
* 1:是,0:否
*/
private String checkYesOrNo;
private String checkYesOrNo = "";
}
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