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

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

parent 9b17fec7
......@@ -467,9 +467,6 @@ 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);
......@@ -492,7 +489,7 @@ public class ContingencyAction implements CustomerAction {
System.out.println("stepCodeNew-->" + buttonJsonVO.getStepCode());
System.out.println("contingencyPlanId-->" + contingencyPlanId);
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) {
log.error("optionarea 加入队列失败-->" + e.getMessage());
}
......@@ -871,7 +868,7 @@ public class ContingencyAction implements CustomerAction {
instance.setRoleCode(contingencyInstance.getPlanStepRoleCodeByButtonCode(buttonCode));
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) {
e.printStackTrace();
}
......
......@@ -75,7 +75,7 @@ public class TimeLineController extends BaseController {
@RequestParam("confirm") String confirm,
@RequestParam("contingencyPlanId") String contingencyPlanId,
@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");
}
......
......@@ -42,6 +42,8 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
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.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
......@@ -344,7 +346,8 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
if (!CollectionUtils.isEmpty(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)) {
redisTemplate.delete(RiskSourceServiceImpl.cacheKeyForCanBeRunning());
}
......@@ -372,13 +375,14 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
contingencyPlanInstance.setContent(operateJson);
if (buttonState.equals("CONFIRM")) {
contingencyPlanInstance.setRunstate(true);
// 满足移动端确认按钮展示,确认后,多按钮json只保留最后一个按钮
planVisual3dService.updateStatusById(contingencyPlanId, true);
}
if (buttonState.equals("CONFIRM_NOT")) {
contingencyPlanInstance.setRunstate(false);
// 满足移动端确认按钮展示,确认后,多按钮json只保留最后一个按钮
planVisual3dService.updateStatusById(contingencyPlanId, false);
if (code.endsWith("_NOT")) {
contingencyPlanInstance.setRunstate(false);
// 满足移动端确认按钮展示,确认后,多按钮json只保留最后一个按钮
planVisual3dService.updateStatusById(contingencyPlanId, false);
} else {
// 满足移动端确认按钮展示,确认后,多按钮json只保留最后一个按钮
planVisual3dService.updateStatusById(contingencyPlanId, true);
}
}
ContingencyPlanInstance instance = repository.save(contingencyPlanInstance);
if (buttonState.equals("CONFIRM")) {
......@@ -445,7 +449,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
}
@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.put("batchNo", batchNo);
map.put("stepCode", stepCode);
......@@ -453,14 +457,21 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
map.put("confirm", buttonState);
map.put("contingencyPlanId", contingencyPlanId);
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("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======");
System.out.println("confirm-->" + buttonState);
System.out.println("contingencyPlanId-->" + contingencyPlanId);
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)) {
Toke serverToken = remoteSecurityService.getServerToken();
map.put("token", serverToken.getToke());
......@@ -569,22 +580,46 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
String confirm = map.get("confirm");
String contingencyPlanId = map.get("contingencyPlanId");
String stepState = map.get("stepState");
String isExecute = map.get("isExecute");
String appKey = map.get("appKey");
String product = map.get("product");
String token = map.get("token");
try {
log.info("fireQueue-size:" + fireQueue.size());
log.info("stepCode:" + map.get("stepCode"));
log.info("buttonCode:" + map.get("buttonCode"));
log.info("confirm:" + map.get("confirm"));
log.info("stepState:" + map.get("stepState"));
System.out.println("======加入队列参数=====fireQueue===1===");
System.out.println("fireQueue-size:-->" + fireQueue.size());
System.out.println("batchNo-->" + batchNo);
System.out.println("stepCode-->" + stepCode);
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.setProduct(product);
RequestContext.setToken(token);
setButtonExecuted(batchNo, contingencyPlanId, buttonCode, confirm);
fire(batchNo, stepCode, contingencyPlanId, buttonCode, confirm, stepState);
// 更新预案执行Json串s
planVisual3dService.updatePlanStep(batchNo, stepCode, contingencyPlanId, buttonCode, true);
planVisual3dService.updatePlanStep(batchNo, stepCode, contingencyPlanId, buttonCode, isExecute);
// 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) {
throw e;
} finally {
......
......@@ -395,42 +395,45 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
@Override
@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)) {
// 根据批次号查询预案步骤
PlanRule planRule = planOperationRecordMapper.getPlanRuleByBatchNo(batchNo);
System.out.println("======updatePlanStep==前===" + JSON.toJSONString(planRule));
if (planRule != null) {
List<PlanStepJsonVO> list = JSONObject.parseArray(planRule.getPlanStep(), PlanStepJsonVO.class);
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();
if (code.equals(stepCode)) {
if (isExecute) {
x.setTime(DateFormatUtils.format(new Date(), "HH:mm:ss"));
x.setBatchNo(batchNo);
x.setCaseId(contingencyPlanId);
if ("true".equals(isExecute)) {
if (buttonCode.endsWith("_NOT")) {
x.setCheckYesOrNo("0");
} else {
x.setCheckYesOrNo("1");
if (StringUtils.isNotBlank(x.getTime())) {
x.setShowLine(true);
}
}
x.setTime(DateFormatUtils.format(new Date(), "HH:mm:ss"));
}
// 通过contingencyPlanId获取buttonJson数据
x.setBatchNo(batchNo);
x.setCaseId(contingencyPlanId);
ContingencyPlanInstance planInstance = iContingencyPlanInstanceRepository.getOne(contingencyPlanId);
x.setButtonJson(planInstance.getContent());
}
}).collect(Collectors.toList());
List<PlanStepJsonVO> collect1 = collect.stream().peek(x -> {
if (isExecute) {
if (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);
planStepVo.setPlanStep(JSON.toJSONString(collect1));
updatePlanStep(planStepVo);
planRule.setPlanStep(JSON.toJSONString(collect1));
planRuleDao.save(planRule);
System.out.println("======updatePlanStep==后===" + JSON.toJSONString(planRule));
}
}
}
......
......@@ -24,7 +24,7 @@ public interface IContingencyInstance {
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 {
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);
......
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