Commit c91c900c authored by KeYong's avatar KeYong

预案步骤查询优化

parent 4b49dd73
...@@ -85,5 +85,7 @@ public interface IContingencyPlanInstanceRepository extends BaseDao<ContingencyP ...@@ -85,5 +85,7 @@ public interface IContingencyPlanInstanceRepository extends BaseDao<ContingencyP
@Query(value = "SELECT * FROM `contingency_plan_instance` WHERE batch_no = ?1", nativeQuery = true) @Query(value = "SELECT * FROM `contingency_plan_instance` WHERE batch_no = ?1", nativeQuery = true)
List<ContingencyPlanInstance> findByBatchNo(String batchNo); List<ContingencyPlanInstance> findByBatchNo(String batchNo);
@Query(value = "SELECT id FROM `contingency_plan_instance` WHERE batch_no = ?1 AND record_type = ?2 ORDER BY sort DESC LIMIT 1", nativeQuery = true)
String findByBatchNoAndRecordType(String batchNo, String recordType);
} }
...@@ -246,8 +246,6 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -246,8 +246,6 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
@Override @Override
public ToipResponse getPlanStepByBatchNo(String batchNo) { public ToipResponse getPlanStepByBatchNo(String batchNo) {
ToipResponse toipResponse = new ToipResponse(); ToipResponse toipResponse = new ToipResponse();
// 根据批次号查询预案步骤
// String planStep = planOperationRecordMapper.getPlanStepByBatchNo(batchNo);
String planStep = ""; String planStep = "";
if (redisTemplate.hasKey("planStep")) { if (redisTemplate.hasKey("planStep")) {
planStep = Objects.requireNonNull(redisTemplate.opsForValue().get("planStep")).toString(); planStep = Objects.requireNonNull(redisTemplate.opsForValue().get("planStep")).toString();
...@@ -265,12 +263,9 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService { ...@@ -265,12 +263,9 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
msgContext.put("currentStep", contingencyOriginalData.getStep()); msgContext.put("currentStep", contingencyOriginalData.getStep());
msgContext.put("confirm", contingencyOriginalData.getConfirm()); msgContext.put("confirm", contingencyOriginalData.getConfirm());
msgContext.put("createDate", contingencyOriginalData.getCreateDate()); msgContext.put("createDate", contingencyOriginalData.getCreateDate());
List<ContingencyPlanInstance> list = contingencyPlanInstanceRepository.findByBatchNo(batchNo); String caseId = contingencyPlanInstanceRepository.findByBatchNoAndRecordType(batchNo, "OPERATE");
if (!CollectionUtils.isEmpty(list)) { if (StringUtils.isNotEmpty(caseId)) {
List<ContingencyPlanInstance> collect = list.stream().filter(x -> "OPERATE".equals(x.getRecordType())).collect(Collectors.toList()); msgContext.put("caseId", caseId);
if (!CollectionUtils.isEmpty(collect)) {
msgContext.put("caseId", collect.get(0).getId());
}
} }
toipResponse.setMsgType("steparea"); toipResponse.setMsgType("steparea");
toipResponse.setContingency(contingencyOriginalData); toipResponse.setContingency(contingencyOriginalData);
......
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