Commit 02fe2ef2 authored by 高建强's avatar 高建强

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

parent 9b17fec7
...@@ -467,9 +467,6 @@ public class ContingencyAction implements CustomerAction { ...@@ -467,9 +467,6 @@ public class ContingencyAction implements CustomerAction {
tempmap1.put("caseId", contingencyPlanId); tempmap1.put("caseId", contingencyPlanId);
result.add(tempmap1); result.add(tempmap1);
// 更新预案执行Json串
iPlanVisual3dService.updatePlanStep(batchNo, stepCode, contingencyPlanId, buttonCode, false);
this.sendcmd("optionarea", paramObj, result); this.sendcmd("optionarea", paramObj, result);
ContingencyPlanInstance instance = contingencyInstance.getMessageById(contingencyPlanId); ContingencyPlanInstance instance = contingencyInstance.getMessageById(contingencyPlanId);
...@@ -492,7 +489,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -492,7 +489,7 @@ public class ContingencyAction implements CustomerAction {
System.out.println("stepCodeNew-->" + buttonJsonVO.getStepCode()); System.out.println("stepCodeNew-->" + buttonJsonVO.getStepCode());
System.out.println("contingencyPlanId-->" + contingencyPlanId); System.out.println("contingencyPlanId-->" + contingencyPlanId);
System.out.println("buttonCode-->" + map.get("code").toString()); System.out.println("buttonCode-->" + map.get("code").toString());
iContingencyInstance.fire(batchNo, buttonJsonVO.getStepCode(), contingencyPlanId, map.get("code").toString(), "CANCEL_0", "A", RequestContext.getToken(), RequestContext.getProduct(), RequestContext.getAppKey()); iContingencyInstance.fire(batchNo, buttonJsonVO.getStepCode(), contingencyPlanId, map.get("code").toString(), "CANCEL_0", "A", "false", RequestContext.getToken(), RequestContext.getProduct(), RequestContext.getAppKey());
} catch (Exception e) { } catch (Exception e) {
log.error("optionarea 加入队列失败-->" + e.getMessage()); log.error("optionarea 加入队列失败-->" + e.getMessage());
} }
...@@ -871,7 +868,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -871,7 +868,7 @@ public class ContingencyAction implements CustomerAction {
instance.setRoleCode(contingencyInstance.getPlanStepRoleCodeByButtonCode(buttonCode)); instance.setRoleCode(contingencyInstance.getPlanStepRoleCodeByButtonCode(buttonCode));
contingencyPlanInstanceMapper.updateMessageById(instance); contingencyPlanInstanceMapper.updateMessageById(instance);
} }
contingencyInstance.fire(contingencyRo.getBatchNo(), stepCode, contingencyPlanId, buttonCode, confirm, stepState, RequestContext.getToken(), RequestContext.getProduct(), RequestContext.getAppKey()); contingencyInstance.fire(contingencyRo.getBatchNo(), stepCode, contingencyPlanId, buttonCode, confirm, stepState, "true", RequestContext.getToken(), RequestContext.getProduct(), RequestContext.getAppKey());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -75,7 +75,7 @@ public class TimeLineController extends BaseController { ...@@ -75,7 +75,7 @@ public class TimeLineController extends BaseController {
@RequestParam("confirm") String confirm, @RequestParam("confirm") String confirm,
@RequestParam("contingencyPlanId") String contingencyPlanId, @RequestParam("contingencyPlanId") String contingencyPlanId,
@RequestParam("stepState") String stepState) throws Exception { @RequestParam("stepState") String stepState) throws Exception {
iContingencyInstance.fire(batchNo, stepCode, contingencyPlanId, buttonCode, confirm, stepState, getToken(), getProduct(), getAppKey()); iContingencyInstance.fire(batchNo, stepCode, contingencyPlanId, buttonCode, confirm, stepState, "true", getToken(), getProduct(), getAppKey());
return CommonResponseUtil.success("SUCCESS"); return CommonResponseUtil.success("SUCCESS");
} }
......
...@@ -42,6 +42,8 @@ import org.springframework.data.redis.core.RedisTemplate; ...@@ -42,6 +42,8 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
...@@ -344,7 +346,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -344,7 +346,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
if (!CollectionUtils.isEmpty(operates)) { if (!CollectionUtils.isEmpty(operates)) {
for (Operate operate : operates) { for (Operate operate : operates) {
if (code.equals(operate.getCode()) && ("executed".equals(operate.getState()) || "disable".equals(operate.getState()))) { // if (code.equals(operate.getCode()) && ("executed".equals(operate.getState()) || "disable".equals(operate.getState()))) {
if (code.equals(operate.getCode()) && ("executed".equals(operate.getState()))) {
if ("FIRE_CANCEL".equals(code) || "END_EMERGENCY".equals(code)) { if ("FIRE_CANCEL".equals(code) || "END_EMERGENCY".equals(code)) {
redisTemplate.delete(RiskSourceServiceImpl.cacheKeyForCanBeRunning()); redisTemplate.delete(RiskSourceServiceImpl.cacheKeyForCanBeRunning());
} }
...@@ -372,13 +375,14 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -372,13 +375,14 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
contingencyPlanInstance.setContent(operateJson); contingencyPlanInstance.setContent(operateJson);
if (buttonState.equals("CONFIRM")) { if (buttonState.equals("CONFIRM")) {
contingencyPlanInstance.setRunstate(true); contingencyPlanInstance.setRunstate(true);
// 满足移动端确认按钮展示,确认后,多按钮json只保留最后一个按钮 if (code.endsWith("_NOT")) {
planVisual3dService.updateStatusById(contingencyPlanId, true); contingencyPlanInstance.setRunstate(false);
} // 满足移动端确认按钮展示,确认后,多按钮json只保留最后一个按钮
if (buttonState.equals("CONFIRM_NOT")) { planVisual3dService.updateStatusById(contingencyPlanId, false);
contingencyPlanInstance.setRunstate(false); } else {
// 满足移动端确认按钮展示,确认后,多按钮json只保留最后一个按钮 // 满足移动端确认按钮展示,确认后,多按钮json只保留最后一个按钮
planVisual3dService.updateStatusById(contingencyPlanId, false); planVisual3dService.updateStatusById(contingencyPlanId, true);
}
} }
ContingencyPlanInstance instance = repository.save(contingencyPlanInstance); ContingencyPlanInstance instance = repository.save(contingencyPlanInstance);
if (buttonState.equals("CONFIRM")) { if (buttonState.equals("CONFIRM")) {
...@@ -445,7 +449,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -445,7 +449,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
} }
@Override @Override
public Optional<Equipment> fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton, String token, String product, String appKey) throws Exception { public Optional<Equipment> fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton, String isExecute, String token, String product, String appKey) throws Exception {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("batchNo", batchNo); map.put("batchNo", batchNo);
map.put("stepCode", stepCode); map.put("stepCode", stepCode);
...@@ -453,14 +457,21 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -453,14 +457,21 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
map.put("confirm", buttonState); map.put("confirm", buttonState);
map.put("contingencyPlanId", contingencyPlanId); map.put("contingencyPlanId", contingencyPlanId);
map.put("stepState", stepStateOnbutton); map.put("stepState", stepStateOnbutton);
map.put("isExecute", isExecute);
System.out.println("======加入队列参数=====fire===1===");
System.out.println("fireQueue-size:-->" + fireQueue.size());
System.out.println("batchNo-->" + batchNo); System.out.println("batchNo-->" + batchNo);
System.out.println("stepCode-->" + stepCode); System.out.println("stepCode-->" + stepCode);
System.out.println("contingencyPlanId-->" + contingencyPlanId);
System.out.println("buttonCode-->" + buttonCode); System.out.println("buttonCode-->" + buttonCode);
System.out.println("buttonState-->" + buttonState); System.out.println("confirm-->" + buttonState);
System.out.println("stepStateOnbutton-->" + stepStateOnbutton); System.out.println("contingencyPlanId-->" + contingencyPlanId);
System.out.println("======optionarea 加入队列参数=====fire======"); System.out.println("stepState-->" + stepStateOnbutton);
System.out.println("isExecute-->" + isExecute);
System.out.println("appKey-->" + appKey);
System.out.println("product-->" + product);
System.out.println("token-->" + token);
System.out.println("======加入队列参数=====fire===2===");
if (StringUtils.isBlank(token) || StringUtils.isBlank(product)) { if (StringUtils.isBlank(token) || StringUtils.isBlank(product)) {
Toke serverToken = remoteSecurityService.getServerToken(); Toke serverToken = remoteSecurityService.getServerToken();
map.put("token", serverToken.getToke()); map.put("token", serverToken.getToke());
...@@ -569,22 +580,46 @@ public class ContingencyInstanceImpl implements IContingencyInstance { ...@@ -569,22 +580,46 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
String confirm = map.get("confirm"); String confirm = map.get("confirm");
String contingencyPlanId = map.get("contingencyPlanId"); String contingencyPlanId = map.get("contingencyPlanId");
String stepState = map.get("stepState"); String stepState = map.get("stepState");
String isExecute = map.get("isExecute");
String appKey = map.get("appKey"); String appKey = map.get("appKey");
String product = map.get("product"); String product = map.get("product");
String token = map.get("token"); String token = map.get("token");
try { try {
log.info("fireQueue-size:" + fireQueue.size()); System.out.println("======加入队列参数=====fireQueue===1===");
log.info("stepCode:" + map.get("stepCode")); System.out.println("fireQueue-size:-->" + fireQueue.size());
log.info("buttonCode:" + map.get("buttonCode")); System.out.println("batchNo-->" + batchNo);
log.info("confirm:" + map.get("confirm")); System.out.println("stepCode-->" + stepCode);
log.info("stepState:" + map.get("stepState")); System.out.println("buttonCode-->" + buttonCode);
System.out.println("confirm-->" + confirm);
System.out.println("contingencyPlanId-->" + contingencyPlanId);
System.out.println("stepState-->" + stepState);
System.out.println("isExecute-->" + isExecute);
System.out.println("appKey-->" + appKey);
System.out.println("product-->" + product);
System.out.println("token-->" + token);
System.out.println("======加入队列参数=====fireQueue===2===");
RequestContext.setAppKey(appKey); RequestContext.setAppKey(appKey);
RequestContext.setProduct(product); RequestContext.setProduct(product);
RequestContext.setToken(token); RequestContext.setToken(token);
setButtonExecuted(batchNo, contingencyPlanId, buttonCode, confirm); setButtonExecuted(batchNo, contingencyPlanId, buttonCode, confirm);
fire(batchNo, stepCode, contingencyPlanId, buttonCode, confirm, stepState); fire(batchNo, stepCode, contingencyPlanId, buttonCode, confirm, stepState);
// 更新预案执行Json串s planVisual3dService.updatePlanStep(batchNo, stepCode, contingencyPlanId, buttonCode, isExecute);
planVisual3dService.updatePlanStep(batchNo, stepCode, contingencyPlanId, buttonCode, true); // TODO 数字化换流站组态屏数据推送,需要在事务提交之后,否侧事务隔离查询不出数据
// TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
// @Override
// public void afterCommit() {
// // 事物提交后业务逻辑
// // 更新预案执行Json串
//// ToipResponse byBatchNo = planVisual3dService.getPlanStepByBatchNo(batchNo);
// try {
// setButtonExecuted(batchNo, contingencyPlanId, buttonCode, confirm);
// fire(batchNo, stepCode, contingencyPlanId, buttonCode, confirm, stepState);
// planVisual3dService.updatePlanStep(batchNo, stepCode, contingencyPlanId, buttonCode, isExecute);
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// }
// });
} catch (Exception e) { } catch (Exception e) {
throw e; throw e;
} finally { } finally {
......
...@@ -395,42 +395,45 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -395,42 +395,45 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
@Override @Override
@Transactional @Transactional
public void updatePlanStep(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, Boolean isExecute) { public void updatePlanStep(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String isExecute) {
if (StringUtils.isNotBlank(batchNo) && StringUtils.isNotBlank(contingencyPlanId) && StringUtils.isNotBlank(buttonCode)) { if (StringUtils.isNotBlank(batchNo) && StringUtils.isNotBlank(contingencyPlanId) && StringUtils.isNotBlank(buttonCode)) {
// 根据批次号查询预案步骤 // 根据批次号查询预案步骤
PlanRule planRule = planOperationRecordMapper.getPlanRuleByBatchNo(batchNo); PlanRule planRule = planOperationRecordMapper.getPlanRuleByBatchNo(batchNo);
System.out.println("======updatePlanStep==前===" + JSON.toJSONString(planRule));
if (planRule != null) { if (planRule != null) {
List<PlanStepJsonVO> list = JSONObject.parseArray(planRule.getPlanStep(), PlanStepJsonVO.class); List<PlanStepJsonVO> list = JSONObject.parseArray(planRule.getPlanStep(), PlanStepJsonVO.class);
List<PlanStepJsonVO> collect = list.stream().peek(x -> { List<PlanStepJsonVO> collect = list.stream().peek(x -> {
if ("true".equals(isExecute)) {
// 更新进度条标志位
if (StringUtils.isBlank(x.getTime()) && Integer.parseInt(x.getStepCode()) <= Integer.parseInt(stepCode)) {
x.setShowLine(true);
}
}
}).collect(Collectors.toList());
List<PlanStepJsonVO> collect1 = collect.stream().peek(x -> {
String code = x.getStepCode(); String code = x.getStepCode();
if (code.equals(stepCode)) { if (code.equals(stepCode)) {
if (isExecute) { if ("true".equals(isExecute)) {
x.setTime(DateFormatUtils.format(new Date(), "HH:mm:ss"));
x.setBatchNo(batchNo);
x.setCaseId(contingencyPlanId);
if (buttonCode.endsWith("_NOT")) { if (buttonCode.endsWith("_NOT")) {
x.setCheckYesOrNo("0"); x.setCheckYesOrNo("0");
} else { } else {
x.setCheckYesOrNo("1"); x.setCheckYesOrNo("1");
if (StringUtils.isNotBlank(x.getTime())) {
x.setShowLine(true);
}
} }
x.setTime(DateFormatUtils.format(new Date(), "HH:mm:ss"));
} }
// 通过contingencyPlanId获取buttonJson数据 // 通过contingencyPlanId获取buttonJson数据
x.setBatchNo(batchNo);
x.setCaseId(contingencyPlanId);
ContingencyPlanInstance planInstance = iContingencyPlanInstanceRepository.getOne(contingencyPlanId); ContingencyPlanInstance planInstance = iContingencyPlanInstanceRepository.getOne(contingencyPlanId);
x.setButtonJson(planInstance.getContent()); x.setButtonJson(planInstance.getContent());
} }
}).collect(Collectors.toList()); }).collect(Collectors.toList());
List<PlanStepJsonVO> collect1 = collect.stream().peek(x -> { planRule.setPlanStep(JSON.toJSONString(collect1));
if (isExecute) { planRuleDao.save(planRule);
if (Integer.parseInt(x.getStepCode()) <= Integer.parseInt(stepCode)) { System.out.println("======updatePlanStep==后===" + JSON.toJSONString(planRule));
// 更新进度条标志位
x.setShowLine(Integer.parseInt(x.getStepCode()) <= Integer.parseInt(stepCode));
}
}
}).collect(Collectors.toList());
PlanStepVo planStepVo = new PlanStepVo();
planStepVo.setBatchNo(batchNo);
planStepVo.setPlanStep(JSON.toJSONString(collect1));
updatePlanStep(planStepVo);
} }
} }
} }
......
...@@ -24,7 +24,7 @@ public interface IContingencyInstance { ...@@ -24,7 +24,7 @@ public interface IContingencyInstance {
void updateStep(String step, String batchNo); void updateStep(String step, String batchNo);
Optional<Equipment> fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton, String token, String product, String appKey) throws Exception; Optional<Equipment> fire(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String buttonState, String stepStateOnbutton, String isExecute, String token, String product, String appKey) throws Exception;
/** /**
* 扩展属性赋值 * 扩展属性赋值
......
...@@ -90,7 +90,7 @@ public interface IPlanVisual3dService { ...@@ -90,7 +90,7 @@ public interface IPlanVisual3dService {
PlanStepVo updatePlanStep(PlanStepVo planStepVo); PlanStepVo updatePlanStep(PlanStepVo planStepVo);
void updatePlanStep(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, Boolean isExecute); void updatePlanStep(String batchNo, String stepCode, String contingencyPlanId, String buttonCode, String isExecute);
Page<ContingencyPlanInstanceVO> selectDisposalActionPage(int current, int size, String batchNo, List<RoleModel> roleModelList, int dataType); Page<ContingencyPlanInstanceVO> selectDisposalActionPage(int current, int size, String batchNo, List<RoleModel> roleModelList, int dataType);
......
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