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

预案JSON迁移为表数据

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