Commit 4a95ea97 authored by 田涛's avatar 田涛

代码合并

parent 3286e4a3
......@@ -101,131 +101,129 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
ContingencyPlanResponseVo result = new ContingencyPlanResponseVo();
//状态校验
ReserveEnum reserveEnum = this.runCheck(vo);
if(ReserveEnum.THISRUNNING.getStatus() ==reserveEnum.getStatus()){
List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId()));
if (ReserveEnum.THISRUNNING.getStatus() == reserveEnum.getStatus()) {
List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId()));
result.setMessage(ReserveEnum.THISRUNNING.getText());
result.setBatchNo(recordList.get(0).getBatchNo());
return result;
}else if(ReserveEnum.RUN.getStatus() == reserveEnum.getStatus()){
Optional<PlanDetail> PlanDetailOp = planDetailDao.findById(Long.valueOf(vo.getPlanId()));
List<PlanEquipment> equipmentList= planEquipmentDao.findByPlanId(PlanDetailOp.get().getId());
//预案启动
if (PlanDetailOp.get() != null) {
//电力设备
Equipment equipment = equipmentService.queryOne(equipmentList.get(0).getFireEquipmentId());
//获取规则名称
List<PlanRule> planRuleList = planRuleDao.getPlanDocsByPlanId(Long.valueOf(vo.getPlanId()));
if(planRuleList.size()==0){
result.setMessage(ReserveEnum.NOPLAN.getText());
}
equipment.setReservePlan("换流站消防专项预案"+"/"+planRuleList.get(0).getRuleId());
if(equipment==null){
result.setMessage(ReserveEnum.NOEQUIP.getText());
}
//电力设备绑定装备
List<EquipmentFireEquipment> equipmentFireEquipmentList = equipmentFireEquipmentDao.findAllByEquipmentId(equipmentList.get(0).getFireEquipmentId());
if(equipmentFireEquipmentList.size()==0){
result.setMessage(ReserveEnum.NOFIRE.getText());
}
//查询设备
EquipmentSpecificForRiskVo equipmentSpecific = equipmentSpecificMapper.getOneById(equipmentFireEquipmentList.get(0).getFireEquipmentId());
if(equipmentSpecific==null){
result.setMessage(ReserveEnum.NOFIRE.getText());
}
//插入运行记录表
PlanOperationRecord planOperationRecord = new PlanOperationRecord();
planOperationRecord.setStatus(PlanRecordStatusEnum.OPERATION.getCode());
planOperationRecord.setPlanId(PlanDetailOp.get().getId());
planOperationRecord.setIsDelete(false);
planOperationRecord.setStartTime(new Date());
planOperationRecord.setPlanPattern(vo.getStatus());
planOperationRecord.setStartUserId(vo.getUserId());
planOperationRecord.setStartUserName(vo.getUserName());
planOperationRecord.setEquipmentCode(equipmentSpecific.getCode());
planOperationRecord.setEquipmentName(equipmentSpecific.getName());
if(ContingencyPlanStatusEnum.SIMULATION_START.getCode()==vo.getStatus()){
planOperationRecord.setExecutionType(ExecutionTypeEnum.PLANCHECK.getCode());
}else{
planOperationRecord.setExecutionType(ExecutionTypeEnum.FIREMANAGEMENT.getCode());
}
PlanOperationRecord operationRecord = planOperationRecordDao.save(planOperationRecord);
//预案启动
AlarmParam deviceData = new AlarmParam();
deviceData.setMonitor(equipment != null ? equipment.getName() : "");
deviceData.setId(String.valueOf(equipmentSpecific.getId()));
deviceData.setCode(equipmentSpecific.getCode());
String batchNo = equipmentHandlerService.executeDynamicPlan(deviceData,equipment,equipmentSpecific,toke,operationRecord.getId());
//更新模型状态
PlanDetail planDetail = PlanDetailOp.get();
planDetail.setStatus(ContingencyPlanStatusEnum.SIMULATION_START.getCode());
planDetailDao.save(planDetail);
//更新预案执行记录表的批次号
operationRecord.setBatchNo(batchNo);
planOperationRecordDao.save(operationRecord);
result.setMessage(ReserveEnum.RUN.getText());
result.setBatchNo(batchNo);
}
}
} else if (ReserveEnum.RUN.getStatus() == reserveEnum.getStatus()) {
Optional<PlanDetail> PlanDetailOp = planDetailDao.findById(Long.valueOf(vo.getPlanId()));
List<PlanEquipment> equipmentList = planEquipmentDao.findByPlanId(PlanDetailOp.get().getId());
//预案启动
if (PlanDetailOp.get() != null) {
//电力设备
Equipment equipment = equipmentService.queryOne(equipmentList.get(0).getFireEquipmentId());
//获取规则名称
List<PlanRule> planRuleList = planRuleDao.getPlanDocsByPlanId(Long.valueOf(vo.getPlanId()));
if (planRuleList.size() == 0) {
result.setMessage(ReserveEnum.NOPLAN.getText());
}
equipment.setReservePlan("换流站消防专项预案" + "/" + planRuleList.get(0).getRuleId());
if (equipment == null) {
result.setMessage(ReserveEnum.NOEQUIP.getText());
}
//电力设备绑定装备
List<EquipmentFireEquipment> equipmentFireEquipmentList = equipmentFireEquipmentDao.findAllByEquipmentId(equipmentList.get(0).getFireEquipmentId());
if (equipmentFireEquipmentList.size() == 0) {
result.setMessage(ReserveEnum.NOFIRE.getText());
}
//查询设备
EquipmentSpecificForRiskVo equipmentSpecific = equipmentSpecificMapper.getOneById(equipmentFireEquipmentList.get(0).getFireEquipmentId());
if (equipmentSpecific == null) {
result.setMessage(ReserveEnum.NOFIRE.getText());
}
//插入运行记录表
PlanOperationRecord planOperationRecord = new PlanOperationRecord();
planOperationRecord.setStatus(PlanRecordStatusEnum.OPERATION.getCode());
planOperationRecord.setPlanId(PlanDetailOp.get().getId());
planOperationRecord.setIsDelete(false);
planOperationRecord.setStartTime(new Date());
planOperationRecord.setPlanPattern(vo.getStatus());
planOperationRecord.setStartUserId(vo.getUserId());
planOperationRecord.setStartUserName(vo.getUserName());
planOperationRecord.setEquipmentCode(equipmentSpecific.getCode());
planOperationRecord.setEquipmentName(equipmentSpecific.getName());
if (ContingencyPlanStatusEnum.SIMULATION_START.getCode() == vo.getStatus()) {
planOperationRecord.setExecutionType(ExecutionTypeEnum.PLANCHECK.getCode());
} else {
planOperationRecord.setExecutionType(ExecutionTypeEnum.FIREMANAGEMENT.getCode());
}
PlanOperationRecord operationRecord = planOperationRecordDao.save(planOperationRecord);
//预案启动
AlarmParam deviceData = new AlarmParam();
deviceData.setMonitor(equipment != null ? equipment.getName() : "");
deviceData.setId(String.valueOf(equipmentSpecific.getId()));
deviceData.setCode(equipmentSpecific.getCode());
String batchNo = equipmentHandlerService.executeDynamicPlan(deviceData, equipment, equipmentSpecific, toke, operationRecord.getId());
//更新模型状态
PlanDetail planDetail = PlanDetailOp.get();
planDetail.setStatus(ContingencyPlanStatusEnum.SIMULATION_START.getCode());
planDetailDao.save(planDetail);
//更新预案执行记录表的批次号
operationRecord.setBatchNo(batchNo);
planOperationRecordDao.save(operationRecord);
result.setMessage(ReserveEnum.RUN.getText());
result.setBatchNo(batchNo);
}
}
return result;
}
@Override
public Map<String, Object> firstGetRecord(String batchNo) {
Map<String, Object> map = new HashMap<>();
PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(batchNo);
if(planOperationRecord==null){
PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(batchNo);
if (planOperationRecord == null) {
throw new YeeException("执行记录不存在");
}else{
PlanDetail planDetail = planDetailDao.getOne(planOperationRecord.getPlanId());
if(planDetail==null){
throw new YeeException("数字预案模型被删除");
}
List<PlanEquipment> equipmentList= planEquipmentDao.findByPlanId(planDetail.getId());
Equipment equipment = equipmentService.queryOne(equipmentList.get(0).getFireEquipmentId());
map.put("status",planOperationRecord.getStatus());
if(PlanRecordStatusEnum.OPERATION.getCode()==planOperationRecord.getStatus()){
map.put("executionTime",(new Date().getTime()-planOperationRecord.getStartTime().getTime())/1000);
}else{
map.put("executionTime",(planOperationRecord.getEndTime().getTime()-planOperationRecord.getStartTime().getTime())/1000);
} else {
PlanDetail planDetail = planDetailDao.getOne(planOperationRecord.getPlanId());
if (planDetail == null) {
throw new YeeException("数字预案模型被删除");
}
map.put("crateDate",planOperationRecord.getStartTime());
if(planOperationRecord.getPlanPattern()==ContingencyPlanStatusEnum.SIMULATION_START.getCode()){
map.put("userName",planOperationRecord.getStartUserName());
map.put("startType","手动");
}else{
map.put("userName","系统");
map.put("startType","自动");
map.put("status", planOperationRecord.getStatus());
if (PlanRecordStatusEnum.OPERATION == PlanRecordStatusEnum.getEnum(planOperationRecord.getStatus())) {
map.put("executionTime", (System.currentTimeMillis() - planOperationRecord.getStartTime().getTime()) / 1000);
} else {
map.put("executionTime", (planOperationRecord.getEndTime().getTime() - planOperationRecord.getStartTime().getTime()) / 1000);
}
map.put("crateDate", planOperationRecord.getStartTime());
if (ContingencyPlanStatusEnum.getEnum(planOperationRecord.getPlanPattern()) == ContingencyPlanStatusEnum.SIMULATION_START) {
map.put("userName", planOperationRecord.getStartUserName());
map.put("startType", "手动");
} else {
map.put("userName", "系统");
map.put("startType", "自动");
}
map.put("executionType",planOperationRecord.getExecutionType());
map.put("equipmentName",planOperationRecord.getEquipmentName());
map.put("PlanName",planDetail.getPlanName());
map.put("executionType", planOperationRecord.getExecutionType());
map.put("equipmentName", planOperationRecord.getEquipmentName());
map.put("PlanName", planDetail.getPlanName());
}
return map;
}
@Override
public List<HashMap<String,Object>> getRecordList(String batchNo){
List<HashMap<String,Object>> list = new ArrayList<>();
List<ContingencyPlanInstance> instancesList = repository.queryForCategory(batchNo,"MESSAGE");
instancesList.forEach( contingencyPlanInstance -> {
HashMap<String,Object> map = new HashMap<>();
map.put("crateDate",contingencyPlanInstance.getCreateDate());
map.put("content",contingencyPlanInstance.getContent());
list.add(map);
});
return list;
}
public List<HashMap<String, Object>> getRecordList(String batchNo) {
List<HashMap<String, Object>> list = new ArrayList<>();
List<ContingencyPlanInstance> instancesList = repository.queryForCategory(batchNo, "MESSAGE");
instancesList.forEach(contingencyPlanInstance -> {
HashMap<String, Object> map = new HashMap<>();
map.put("crateDate", contingencyPlanInstance.getCreateDate());
map.put("content", contingencyPlanInstance.getContent());
list.add(map);
});
return list;
}
//启动状态校验
public ReserveEnum runCheck(ContingencyPlanParamVo vo){
if(EquipmentRiskTypeEnum.HZGJ.getCode().equals(vo.getRiskType()) || StringUtils.isBlank(vo.getRiskType())) {
public ReserveEnum runCheck(ContingencyPlanParamVo vo) {
if (EquipmentRiskTypeEnum.HZGJ.getCode().equals(vo.getRiskType()) || StringUtils.isBlank(vo.getRiskType())) {
List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId()));
if(recordList.size()>0){
return ReserveEnum.THISRUNNING;
}
List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId()));
if (recordList.size() > 0) {
return ReserveEnum.THISRUNNING;
}
if (ContingencyPlanStatusEnum.SIMULATION_START.getCode().equals(vo.getStatus())) {
Integer[] statusArray = (Integer[]) Arrays.asList(ContingencyPlanStatusEnum.SIMULATION_START.getCode(), ContingencyPlanStatusEnum.ONGOING.getCode()).toArray();
int count = planDetailDao.findByStatus(statusArray);
......@@ -243,15 +241,16 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
} else {
return ReserveEnum.PLANSTATUSERROR;
}
}else {
} else {
}
return ReserveEnum.RUN;
}
@Override
public ContingencyPlanParamVo equipmentScene(Long equipmentId,String riskType) {
public ContingencyPlanParamVo equipmentScene(Long equipmentId, String riskType) {
ContingencyPlanParamVo vo = null;
if(EquipmentRiskTypeEnum.HZGJ.getCode().equals(riskType)) {
if (EquipmentRiskTypeEnum.HZGJ.getCode().equals(riskType)) {
List<EquipmentFireEquipment> equipmentFireEquipmentList = equipmentFireEquipmentDao.findAllByFireEquipmentId(equipmentId);
if (equipmentFireEquipmentList.size() > 0) {
Equipment equipment = equipmentDao.findById(equipmentFireEquipmentList.get(0).getEquipmentId()).orElse(null);
......
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