Commit 3f9096f1 authored by 张森's avatar 张森

预案JSON迁移为表数据

parent c66e9b33
......@@ -157,14 +157,9 @@ public class ContingencyAction implements CustomerAction {
private com.yeejoin.amos.component.rule.RuleTrigger ruleTrigger;
@Autowired
private IEquipmentFireEquipmentService equipmentFireEquipmentService;
@Value("classpath:/json/plan-step.json")
private Resource planStepResource;
@Value("classpath:/json/plan-step-UHV-zb.json")
private Resource planStepZBResource;
@Value("classpath:/json/plan-step-UHV-gk.json")
private Resource planStepGKResource;
@Autowired
private IPlanStepService iPlanStepService;
/**
* @param stepCode 当前步骤编号
......@@ -810,23 +805,7 @@ public class ContingencyAction implements CustomerAction {
tempmap1.put("content", content);
result.add(tempmap1);
String instanceId = iContingencyInstance.getInstanceIdByBatchNOAndCategory("OPERATE", stepName, batchNo);
String json = null;
try {
if (redisTemplate.hasKey("planType")) {
String planType = redisTemplate.boundValueOps("planType").get(0, -1);
if (PlanTypeEnum.MAINTRANSFORM.getKey().equalsIgnoreCase(planType)) {
json = IOUtils.toString(planStepZBResource.getInputStream(), String.valueOf(StandardCharsets.UTF_8));
} else if (PlanTypeEnum.HIGHRESISTANCE.getKey().equalsIgnoreCase(planType)) {
json = IOUtils.toString(planStepGKResource.getInputStream(), String.valueOf(StandardCharsets.UTF_8));
} else {
json = IOUtils.toString(planStepResource.getInputStream(), String.valueOf(StandardCharsets.UTF_8));
}
}
} catch (IOException e) {
throw new RuntimeException("获取预案节点信息失败!");
}
String json = iPlanStepService.getPlanStep();
List<PlanStepJsonVO> res = JSONObject.parseArray(json, PlanStepJsonVO.class);
PlanStepJsonVO vo = res.stream().filter(x -> x.getStepCode().equals(stepCode)).collect(Collectors.toList()).get(0);
Object obj = equipmentFireEquipmentService.automaticExecutePoint(vo.getIndex());
......
......@@ -3,7 +3,6 @@ package com.yeejoin.amos.fas.business.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.fas.dao.entity.EmergencyTaskRole;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
......@@ -29,4 +28,6 @@ public interface EmergencyTaskRoleMapper extends BaseMapper<EmergencyTaskRole> {
EmergencyTaskRole selectByCode(String code);
List<EmergencyTaskRole> selectList();
String getPlanStepInfoByType(String planType);
}
......@@ -2,36 +2,28 @@ package com.yeejoin.amos.fas.business.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.fas.business.dao.mapper.EquipmentSpecificIndexMapper;
import com.yeejoin.amos.fas.business.dao.mapper.EquipmentSpecificMapper;
import com.yeejoin.amos.fas.business.dao.mapper.PlanMessageMapper;
import com.yeejoin.amos.fas.business.dao.mapper.PlanOperationRecordMapper;
import com.yeejoin.amos.fas.business.dao.mapper.*;
import com.yeejoin.amos.fas.business.dao.repository.IEquipmentDao;
import com.yeejoin.amos.fas.business.dao.repository.IEquipmentFireEquipmentDao;
import com.yeejoin.amos.fas.business.dao.repository.IPlanMessageDao;
import com.yeejoin.amos.fas.business.service.intfc.EquipmentSpecificIndexService;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentFireEquipmentService;
import com.yeejoin.amos.fas.business.service.intfc.IPlanStepService;
import com.yeejoin.amos.fas.business.vo.ConditionVO;
import com.yeejoin.amos.fas.business.vo.PlanStepJsonVO;
import com.yeejoin.amos.fas.common.enums.SqlKeyWordEnum;
import com.yeejoin.amos.fas.dao.entity.Equipment;
import com.yeejoin.amos.fas.dao.entity.EquipmentFireEquipment;
import com.yeejoin.amos.fas.dao.entity.PlanMessage;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.Bean;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -86,10 +78,8 @@ public class EquipmentFireEquipmentServiceImpl implements IEquipmentFireEquipmen
EquipmentSpecificIndexMapper equipmentSpecificIndexMapper;
@Autowired
private EquipmentSpecificMapper equipmentSpecificMapper;
private IPlanStepService iPlanStepService;
@Value("classpath:/json/plan-step.json")
private Resource planStepResource;
@Override
public List<EquipmentFireEquipment> findByEquipmentId(Long equipmentId) {
......@@ -178,13 +168,8 @@ public class EquipmentFireEquipmentServiceImpl implements IEquipmentFireEquipmen
if (ObjectUtils.isEmpty(index)) {
return false;
}
String json;
try {
json = IOUtils.toString(planStepResource.getInputStream(), String.valueOf(StandardCharsets.UTF_8));
} catch (IOException e) {
throw new RuntimeException("获取预案节点信息失败!");
}
List<PlanStepJsonVO> result = JSONObject.parseArray(json, PlanStepJsonVO.class);
String planStep = iPlanStepService.getPlanStep();
List<PlanStepJsonVO> result = JSONObject.parseArray(planStep, PlanStepJsonVO.class);
if (!CollectionUtils.isEmpty(result)) {
// 获取电力设备id及batchNo
Map<String, Object> map = planOperationRecordMapper.getLatestFireEquipId();
......
package com.yeejoin.amos.fas.business.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.fas.business.dao.mapper.EmergencyTaskRoleMapper;
import com.yeejoin.amos.fas.business.service.intfc.IPlanStepService;
import com.yeejoin.amos.fas.business.vo.PlanStepJsonVO;
import com.yeejoin.amos.fas.common.enums.PlanTypeEnum;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@Service
......@@ -26,14 +19,8 @@ public class PlanStepServiceImpl implements IPlanStepService {
@Autowired
private RedisTemplate redisTemplate;
@Value("classpath:/json/plan-step.json")
private Resource planStepResource;
@Value("classpath:/json/plan-step-UHV-zb.json")
private Resource planStepZBResource;
@Value("classpath:/json/plan-step-UHV-gk.json")
private Resource planStepGKResource;
@Autowired
private EmergencyTaskRoleMapper emergencyTaskRoleMapper;
@Override
public String getPlanStepRoleCodeByButtonCode(String buttonCode) {
......@@ -61,31 +48,19 @@ public class PlanStepServiceImpl implements IPlanStepService {
@Override
public List<PlanStepJsonVO> getPlanStepJsonVOS() {
String json = "";
try {
json = IOUtils.toString(planStepResource.getInputStream(), String.valueOf(StandardCharsets.UTF_8));
} catch (IOException e) {
throw new RuntimeException("获取预案相关角色信息失败!");
}
List<PlanStepJsonVO> result = JSONObject.parseArray(json, PlanStepJsonVO.class);
String planStepString = getPlanStep();
List<PlanStepJsonVO> result = JSONObject.parseArray(planStepString, PlanStepJsonVO.class);
return result;
}
@Override
public String getPlanStep() {
try {
String planType = "";
if (redisTemplate.hasKey("planType")) {
String planType = redisTemplate.boundValueOps("planType").get(0, -1);
if (PlanTypeEnum.MAINTRANSFORM.getKey().equalsIgnoreCase(planType)) {
return IOUtils.toString(planStepZBResource.getInputStream(), String.valueOf(StandardCharsets.UTF_8));
} else if (PlanTypeEnum.HIGHRESISTANCE.getKey().equalsIgnoreCase(planType)) {
return IOUtils.toString(planStepGKResource.getInputStream(), String.valueOf(StandardCharsets.UTF_8));
}
}
return IOUtils.toString(planStepResource.getInputStream(), String.valueOf(StandardCharsets.UTF_8));
} catch (IOException e) {
throw new RuntimeException("获取预案初始化planStep信息失败!");
planType = redisTemplate.boundValueOps("planType").get(0, -1);
}
String json = emergencyTaskRoleMapper.getPlanStepInfoByType(planType);
return json;
}
@Override
......
......@@ -991,4 +991,20 @@
</sql>
</changeSet>
<changeSet author="zs" id="20240419-01">
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="c_plan_step_config" />
</not>
</preConditions>
<comment>create table c_plan_step_config</comment>
<sql>
CREATE TABLE `c_plan_step_config` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
`type` varchar(255) DEFAULT NULL COMMENT '类型',
`data` longtext COMMENT 'json数据',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
</sql>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
......@@ -59,4 +59,16 @@
<select id="selectList" resultType="com.yeejoin.amos.fas.dao.entity.EmergencyTaskRole">
select * from c_emergency_task_role where is_delete = 0 order by sort desc
</select>
<select id="getPlanStepInfoByType" resultType="java.lang.String">
select `data` from c_plan_step_config
<where>
1 = 1
<if test="planType != null and planType != ''">
AND type = #{planType}
</if>
</where>
order by id ASC
limit 1
</select>
</mapper>
\ 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