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

item:修改根据批次号更新预案步骤按钮的状态接口

parent c47c8202
......@@ -119,6 +119,9 @@ public class ContingencyAction implements CustomerAction {
@Autowired
private PlanDetailMapper planDetailMapper;
@Autowired
private IPlanRuleService planRuleService;
@Value("${rocket-plan-topic}")
private String rocketTopic;
......@@ -971,7 +974,9 @@ public class ContingencyAction implements CustomerAction {
result.add(tempmap1);
//数字预案业务屏web端发送消息
this.sendweb("recordarea", contingencyRo, result);
updateNumberPlan(contingencyRo.getBatchNo());
updateNumberPlan(batchNo);
// 应急处置中断,初始化planStep,json数据
planRuleService.updatePlanRuleByBatchNo(batchNo);
}
/**
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.fas.business.controller;
import com.yeejoin.amos.fas.business.service.intfc.IPlanVisual3dService;
import com.yeejoin.amos.fas.business.util.StringUtil;
import com.yeejoin.amos.fas.business.vo.PlanStepVo;
import com.yeejoin.amos.fas.config.Permission;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
......@@ -128,24 +129,24 @@ public class PlanVisual3dController extends BaseController {
List<Map<String, Object>> list = planVisual3dService.getResourceById(type, id);
return CommonResponseUtil.success(list);
}
@Permission
@ApiOperation(value = "预案应用树", notes = "预案应用树")
@GetMapping(value = "/plan/textPlanTree/{appId}")
public CommonResponse getPlanTree(@PathVariable("appId") String appId) {
return CommonResponseUtil.success(planVisual3dService.getTextPlanBySubjectId(appId));
}
@Permission
@ApiOperation(value = "删除预案文件", notes = "删除预案文件")
@DeleteMapping(value = "/plan/textPlan/{id}")
public CommonResponse deleteTextPlanFile(@PathVariable("id") Long id) {
try {
planVisual3dService.deleteTextPlanFile(id);
return CommonResponseUtil.success();
} catch (Exception e) {
return CommonResponseUtil.failure(e.getMessage());
}
try {
planVisual3dService.deleteTextPlanFile(id);
return CommonResponseUtil.success();
} catch (Exception e) {
return CommonResponseUtil.failure(e.getMessage());
}
}
@Permission
......@@ -162,10 +163,10 @@ public class PlanVisual3dController extends BaseController {
}
@Permission
@ApiOperation(value = "根据批次号更新预案步骤按钮的状态", notes = "根据批次号更新预案步骤按钮的状态")
@GetMapping(value = "/plan/updatePlanStepStatus")
public ResponseModel updatePlanStepStatus(@RequestParam("batchNo") String batchNo, @RequestParam("buttonCode") String buttonCode, @RequestParam("status") String status) {
return CommonResponseUtil.successNew(planVisual3dService.updatePlanStepStatus(batchNo, buttonCode, status));
@ApiOperation(value = "根据批次号更新预案的步骤", notes = "根据批次号更新预案的步骤")
@PostMapping(value = "/plan/updatePlanStep")
public ResponseModel updatePlanStep(@RequestBody PlanStepVo planStepVo) {
return CommonResponseUtil.successNew(planVisual3dService.updatePlanStep(planStepVo));
}
@Permission
......
......@@ -81,4 +81,7 @@ public interface IContingencyPlanInstanceRepository extends BaseDao<ContingencyP
" ORDER BY" +
" t.create_date DESC limit 1", nativeQuery = true)
String queryRecordOne(String batchNo, String recordType);
@Query(value = "SELECT * FROM `contingency_plan_instance` WHERE batch_no = ?1", nativeQuery = true)
List<ContingencyPlanInstance> findByBatchNo(String batchNo);
}
......@@ -8,6 +8,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import com.yeejoin.amos.fas.business.service.intfc.IPlanRuleService;
import com.yeejoin.amos.fas.datasync.bo.ContingencyOriginalDataSyncBo;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -92,6 +93,9 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
@Autowired
private ContingencyOriginalMapper contingencyOriginalMapper;
@Autowired
private IPlanRuleService planRuleService;
private static Map<String, String> stepMap = new HashMap<>();
......@@ -313,8 +317,13 @@ public class ContingencyInstanceImpl /*extends GenericManagerImpl<ContingencyPla
if ("CONFIRM".equals(buttonState)) {
if (code.equals(operate.getCode())) {
operate.setState("executed");
if ("FIRE_CANCEL".equals(code) || "END_EMERGENCY".equals(code))
if ("FIRE_CANCEL".equals(code) || "END_EMERGENCY".equals(code)) {
redisTemplate.delete(RiskSourceServiceImpl.cacheKeyForCanBeRunning());
}
if ("END_EMERGENCY".equals(code)) {
// 应急处置中断,初始化planStep,json数据
planRuleService.updatePlanRuleByBatchNo(batchNo);
}
} else {
operate.setState("disable");
}
......
package com.yeejoin.amos.fas.business.service.impl;
import com.yeejoin.amos.fas.business.dao.mapper.PlanOperationRecordMapper;
import com.yeejoin.amos.fas.business.dao.repository.IPlanRuleDao;
import com.yeejoin.amos.fas.business.service.intfc.IPlanRuleService;
import com.yeejoin.amos.fas.dao.entity.PlanRule;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@Service
public class PlanRuleServiceImpl implements IPlanRuleService {
@Autowired
private IPlanRuleDao planRuleDao;
@Autowired
private PlanOperationRecordMapper planOperationRecordMapper;
@Value("classpath:/json/plan-step.json")
private Resource planStepResource;
@Override
public void updatePlanRuleByBatchNo(String batchNo) {
try {
// 根据批次号查询预案步骤
PlanRule planRule = planOperationRecordMapper.getPlanRuleByBatchNo(batchNo);
String json = IOUtils.toString(planStepResource.getInputStream(), String.valueOf(StandardCharsets.UTF_8));
planRule.setPlanStep(json);
planRuleDao.save(planRule);
} catch (IOException e) {
throw new RuntimeException("初始化预案规则planStep数据失败!");
}
}
}
......@@ -21,10 +21,7 @@ import com.yeejoin.amos.fas.business.vo.PlanStepVo;
import com.yeejoin.amos.fas.business.vo.TreeSubjectVo;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData;
import com.yeejoin.amos.fas.dao.entity.Dict;
import com.yeejoin.amos.fas.dao.entity.PlanRule;
import com.yeejoin.amos.fas.dao.entity.TextPlan;
import com.yeejoin.amos.fas.dao.entity.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -274,7 +271,13 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
msgContext.put("currentStep", contingencyOriginalData.getStep());
msgContext.put("confirm", contingencyOriginalData.getConfirm());
msgContext.put("createDate", contingencyOriginalData.getCreateDate());
msgContext.put("batchNo", contingencyOriginalData.getBatchNo());
List<ContingencyPlanInstance> list = contingencyPlanInstanceRepository.findByBatchNo(batchNo);
if (!CollectionUtils.isEmpty(list)) {
List<ContingencyPlanInstance> collect = list.stream().filter(x -> "OPERATE".equals(x.getRecordType())).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(collect)) {
msgContext.put("caseId", collect.get(0).getId());
}
}
toipResponse.setMsgType("steparea");
toipResponse.setMsgContext(msgContext);
toipResponse.setContingency(contingencyOriginalData);
......@@ -315,21 +318,10 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
@Override
@Transactional
public ToipResponse updatePlanStepStatus(String batchNo, String buttonCode, String status) {
ToipResponse toipResponse = new ToipResponse();
public PlanRule updatePlanStep(PlanStepVo planStepVo) {
// 根据批次号查询预案步骤
PlanRule planRule = planOperationRecordMapper.getPlanRuleByBatchNo(batchNo);
String planStep = planRule.getPlanStep();
if (StringUtil.isNotEmpty(planStep)) {
List<PlanStepVo> list = JSON.parseArray(planStep, PlanStepVo.class);
List<PlanStepVo> collect = list.stream().peek(x -> {
if (StringUtils.isNotBlank(buttonCode) && buttonCode.equalsIgnoreCase(x.getButtonCode())) {
x.setStepStatus(status);
}
}).collect(Collectors.toList());
planRule.setPlanStep(JSON.toJSONString(collect));
planRuleDao.save(planRule);
}
return toipResponse;
PlanRule planRule = planOperationRecordMapper.getPlanRuleByBatchNo(planStepVo.getBatchNo());
planRule.setPlanStep(planStepVo.getPlanStep());
return planRuleDao.save(planRule);
}
}
package com.yeejoin.amos.fas.business.service.intfc;
import com.yeejoin.amos.fas.dao.entity.PlanRule;
public interface IPlanRuleService {
void updatePlanRuleByBatchNo(String batchNo);
}
package com.yeejoin.amos.fas.business.service.intfc;
import com.yeejoin.amos.fas.business.service.model.ToipResponse;
import com.yeejoin.amos.fas.business.vo.PlanStepVo;
import com.yeejoin.amos.fas.business.vo.TreeSubjectVo;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.dao.entity.PlanRule;
import com.yeejoin.amos.fas.dao.entity.TextPlan;
import java.util.List;
......@@ -69,12 +71,5 @@ public interface IPlanVisual3dService {
*/
ToipResponse getPlaneRecordOneByBatchNo(String batchNo);
/**
* 根据批次号更新预案步骤按钮的状态
* @param batchNo 批次号
* @param buttonCode 按钮编码
* @param status 按钮状态:0-点击,1-已执行,2-点击未执行
* @return ToipResponse
*/
ToipResponse updatePlanStepStatus(String batchNo, String buttonCode, String status);
PlanRule updatePlanStep(PlanStepVo planStepVo);
}
......@@ -5,8 +5,6 @@ import lombok.Data;
@Data
public class PlanStepVo {
private String stepCode;
private String stepName;
private String stepStatus;
private String buttonCode;
private String batchNo;
private String planStep;
}
[
{
"stepCode": "0",
"stepName": "确认灾情",
"stepStatus": "0",
"buttonCode": "FIRE_CONFIRM"
},
{
"stepCode": "1",
"stepName": "停运换流阀",
"stepStatus": "0",
"buttonCode": "STOP_COMMUTATION"
},
{
"stepCode": "2",
"stepName": "拨打报警电话",
"stepStatus": "0",
"buttonCode": "CALL_PHONE"
},
{
"stepCode": "3",
"stepName": "确认油枕排油系统已开启",
"stepStatus": "0",
"buttonCode": "DRAIN_OIL_CONFIRM"
},
{
"stepCode": "4",
"stepName": "确认水喷雾系统已开启",
"stepStatus": "0",
"buttonCode": "OPEN_WATERSYSTEM"
},
{
"stepCode": "5",
"stepName": "断开上级电源",
"stepStatus": "0",
"buttonCode": "OFF_POWER"
},
{
"stepCode": "6",
"stepName": "停运阀厅空调系统",
"stepStatus": "0",
"buttonCode": "STOP_AIRCON"
},
{
"stepCode": "7",
"stepName": "一键开启消防炮",
"stepStatus": "0",
"buttonCode": "MONITOR_START"
},
{
"stepCode": "8",
"stepName": "驻站消防队指挥权交接",
"stepStatus": "0",
"buttonCode": "HANDOVER_COMMAND"
},
{
"stepCode": "9",
"stepName": "确认本体排油已开启",
"stepStatus": "0",
"buttonCode": "OWNER_DRAIN_OIL"
},
{
"stepCode": "10",
"stepName": "启动阀厅应急预案",
"stepStatus": "0",
"buttonCode": "START_VALVE_HALL_CONTINGENCY"
},
{
"stepCode": "11",
"stepName": "电缆沟封堵",
"stepStatus": "0",
"buttonCode": "PLUG_CABLETRENCH"
},
{
"stepCode": "12",
"stepName": "政府消防队指挥权交接",
"stepStatus": "0",
"buttonCode": "HANDOVER_FIGTHHING"
},
{
"stepCode": "13",
"stepName": "确认明火扑灭",
"stepStatus": "0",
"buttonCode": "FIRE_EXTINCT"
},
{
"stepCode": "14",
"stepName": "应急处置结束",
"stepStatus": "0",
"buttonCode": "END_EMERGENCY"
}
]
\ No newline at end of file
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