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

item:优化planStep初始化

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