Commit 89cb794b authored by 高建强's avatar 高建强

item:优化planStep初始化

parent 8ab92fab
......@@ -926,7 +926,7 @@ public class ContingencyAction implements CustomerAction {
updateNumberPlan(batchNo);
// 应急处置中断,初始化planStep,json数据;更新预案结束时间
// planRuleService.updatePlanRuleByBatchNo(batchNo);
planVisual3dService.initPlanStep();
planStepService.initPlanStep();
contingencyInstanceInfoService.updateEndTimeById(batchNo);
}
......
......@@ -391,7 +391,7 @@ public class ContingencyInstanceImpl implements IContingencyInstance {
redisTemplate.delete(RiskSourceServiceImpl.cacheKeyForCanBeRunning());
// 应急处置中断,初始化planStep,json数据
// planRuleService.updatePlanRuleByBatchNo(batchNo);
planVisual3dService.initPlanStep();
planStepService.initPlanStep();
// 应急处置中断,更新预案信息表结束时间
contingencyInstanceInfoService.updateEndTimeById(batchNo);
String topic = String.format("/%s/%s/%s", serviceName, stationName, "plan");
......
......@@ -68,6 +68,8 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
private IContingencyPlanInstanceRepository repository;
@Autowired
private IPlanVisual3dService planVisual3dService;
@Autowired
private IPlanStepService planStepService;
@Qualifier("contingencyAction")
@Autowired
private CustomerAction customerAction;
......@@ -127,7 +129,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
logger.info("========状态校验===========");
ReserveEnum reserveEnum = this.runCheck(vo);
result.setMessage(reserveEnum.getText());
planVisual3dService.initPlanStep();
planStepService.initPlanStep();
if (ReserveEnum.THISRUNNING.getStatus().equals(reserveEnum.getStatus())) {
List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId()));
result.setMessage(ReserveEnum.THISRUNNING.getText());
......
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.data.redis.core.RedisTemplate;
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;
@Autowired
private RedisTemplate redisTemplate;
@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);
redisTemplate.delete("isMock");
} catch (IOException e) {
throw new RuntimeException("初始化预案规则planStep数据失败!");
}
}
}
package com.yeejoin.amos.fas.business.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.rule.RuleTrigger;
import com.yeejoin.amos.fas.business.action.ContingencyAction;
import com.yeejoin.amos.fas.business.action.model.ContingencyEvent;
import com.yeejoin.amos.fas.business.action.model.ContingencyRo;
import com.yeejoin.amos.fas.business.action.mq.WebMqttComponent;
import com.yeejoin.amos.fas.business.action.util.ContingencyLogPublisher;
import com.yeejoin.amos.fas.business.bo.FirePlanAlarmBo;
import com.yeejoin.amos.fas.business.dao.mapper.*;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyOriginalDataDao;
import com.yeejoin.amos.fas.business.dao.repository.IContingencyPlanInstanceRepository;
import com.yeejoin.amos.fas.business.feign.RemoteSecurityService;
import com.yeejoin.amos.fas.business.service.intfc.*;
import com.yeejoin.amos.fas.business.service.model.Operate;
import com.yeejoin.amos.fas.business.service.model.OperateGroup;
import com.yeejoin.amos.fas.business.util.DateUtils;
import com.yeejoin.amos.fas.business.vo.ButtonJsonVO;
import com.yeejoin.amos.fas.business.service.intfc.IPlanStepService;
import com.yeejoin.amos.fas.business.vo.PlanStepJsonVO;
import com.yeejoin.amos.fas.business.vo.Toke;
import com.yeejoin.amos.fas.common.enums.PlanReplyMessageEnum;
import com.yeejoin.amos.fas.dao.entity.ContingencyOriginalData;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.Equipment;
import com.yeejoin.amos.fas.datasync.bo.ContingencyOriginalDataSyncBo;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
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.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class PlanStepServiceImpl implements IPlanStepService {
@Autowired
private RedisTemplate redisTemplate;
@Value("classpath:/json/plan-step.json")
private Resource planStepResource;
......@@ -102,4 +70,11 @@ public class PlanStepServiceImpl implements IPlanStepService {
throw new RuntimeException("获取预案初始化planStep信息失败!");
}
}
@Override
public void initPlanStep() {
redisTemplate.delete("planStep");
redisTemplate.opsForValue().set("planStep", getPlanStep());
redisTemplate.delete("isMock");
}
}
......@@ -28,13 +28,11 @@ import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.BeanUtils;
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.transaction.annotation.Transactional;
......@@ -42,8 +40,6 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
......@@ -395,11 +391,11 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
return planStepVo;
}
@Override
public void initPlanStep() {
redisTemplate.opsForValue().set("planStep", planStepService.getPlanStep());
redisTemplate.delete("isMock");
}
// @Override
// public void initPlanStep() {
// redisTemplate.opsForValue().set("planStep", planStepService.getPlanStep());
// redisTemplate.delete("isMock");
// }
@Override
@Transactional
......@@ -625,22 +621,22 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
}
}
private void sendMessage(MessageVO messageVO){
private void sendMessage(MessageVO messageVO) {
try {
MessageModel model = new MessageModel();
model.setMsgType(messageVO.getMsgType());
// 关联id
if (!ObjectUtils.isEmpty(messageVO.getRelationId())){
if (!ObjectUtils.isEmpty(messageVO.getRelationId())) {
model.setRelationId(messageVO.getRelationId());
}
// 发送人ids
model.setRecivers(messageVO.getRecivers());
model.setIsSendApp(messageVO.getIsSendApp());
model.setIsSendWeb(messageVO.getIsSendWeb());
if (!ObjectUtils.isEmpty(messageVO) && !ObjectUtils.isEmpty(messageVO.getTitle())){
if (!ObjectUtils.isEmpty(messageVO) && !ObjectUtils.isEmpty(messageVO.getTitle())) {
model.setTitle(messageVO.getTitle());
}
if (!ObjectUtils.isEmpty(messageVO) && !ObjectUtils.isEmpty(messageVO.getBody())){
if (!ObjectUtils.isEmpty(messageVO) && !ObjectUtils.isEmpty(messageVO.getBody())) {
model.setBody(messageVO.getBody());
}
model.setTerminal(messageVO.getTerminal());
......@@ -677,7 +673,7 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
return contingencyPlanInstance;
}
private ContingencyPlanInstance deleteButton(ContingencyPlanInstance contingencyPlanInstance){
private ContingencyPlanInstance deleteButton(ContingencyPlanInstance contingencyPlanInstance) {
// 按钮去除
String content = null;
ButtonJsonVO buttonJsonVO;
......@@ -694,6 +690,7 @@ public class PlanVisual3dServiceImpl implements IPlanVisual3dService {
}
return contingencyPlanInstance;
}
private List<String> getUserIds(String buttonCode) {
String planStepJson = planStepService.getPlanStep();
List<PlanStepJsonVO> planStepJsonList = JSONObject.parseArray(planStepJson, PlanStepJsonVO.class);
......
package com.yeejoin.amos.fas.business.service.intfc;
import com.yeejoin.amos.fas.dao.entity.PlanRule;
public interface IPlanRuleService {
void updatePlanRuleByBatchNo(String batchNo);
}
......@@ -25,4 +25,6 @@ public interface IPlanStepService {
List<PlanStepJsonVO> getPlanStepJsonVOS();
String getPlanStep();
void initPlanStep();
}
......@@ -90,7 +90,7 @@ public interface IPlanVisual3dService {
PlanStepVo updatePlanStep(PlanStepVo planStepVo);
void initPlanStep();
// void initPlanStep();
void updatePlanStep(String batchNo, String stepCode, String buttonJson, String contingencyPlanId, String buttonCode, String isExecute);
......
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