Commit 45faffa0 authored by 高建强's avatar 高建强

item:数据同步,修改类名

parent 8db56518
...@@ -15,8 +15,8 @@ import java.util.Date; ...@@ -15,8 +15,8 @@ import java.util.Date;
@Data @Data
@Entity @Entity
@Table(name="c_plan_operation_record") @Table(name="c_plan_operation_record")
@NamedQuery(name="PlanOperationRecord.findAll", query="SELECT e FROM PlanOperationRecord e") @NamedQuery(name="PlanOperationRecord.findAll", query="SELECT e FROM CPlanOperationRecord e")
public class PlanOperationRecord extends BasicEntity { public class CPlanOperationRecord extends BasicEntity {
/** /**
* 预案ID * 预案ID
......
...@@ -38,7 +38,7 @@ import com.yeejoin.amos.fas.core.util.DateUtil; ...@@ -38,7 +38,7 @@ import com.yeejoin.amos.fas.core.util.DateUtil;
import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance; import com.yeejoin.amos.fas.dao.entity.ContingencyPlanInstance;
import com.yeejoin.amos.fas.dao.entity.Equipment; import com.yeejoin.amos.fas.dao.entity.Equipment;
import com.yeejoin.amos.fas.dao.entity.PlanDetail; import com.yeejoin.amos.fas.dao.entity.PlanDetail;
import com.yeejoin.amos.fas.dao.entity.PlanOperationRecord; import com.yeejoin.amos.fas.dao.entity.CPlanOperationRecord;
import com.yeejoin.amos.fas.datasync.bo.PlanDetailSyncBo; import com.yeejoin.amos.fas.datasync.bo.PlanDetailSyncBo;
import com.yeejoin.amos.fas.datasync.bo.PlanOperationRecordSyncBo; import com.yeejoin.amos.fas.datasync.bo.PlanOperationRecordSyncBo;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -754,14 +754,14 @@ public class ContingencyAction implements CustomerAction { ...@@ -754,14 +754,14 @@ public class ContingencyAction implements CustomerAction {
} }
// 结束预案 更新预案记录表,预案状态 // 结束预案 更新预案记录表,预案状态
PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(contingencyRo.getBatchNo()); CPlanOperationRecord CPlanOperationRecord = planOperationRecordDao.findByBatchNo(contingencyRo.getBatchNo());
if (planOperationRecord != null && planOperationRecord.getStatus() == PlanRecordStatusEnum.OPERATION.getCode()) { if (CPlanOperationRecord != null && CPlanOperationRecord.getStatus() == PlanRecordStatusEnum.OPERATION.getCode()) {
planOperationRecord.setStatus(PlanRecordStatusEnum.COMPLETE.getCode()); CPlanOperationRecord.setStatus(PlanRecordStatusEnum.COMPLETE.getCode());
planOperationRecord.setEndTime(new Date()); CPlanOperationRecord.setEndTime(new Date());
PlanOperationRecord record = planOperationRecordDao.save(planOperationRecord); CPlanOperationRecord record = planOperationRecordDao.save(CPlanOperationRecord);
// 异步数据同步之消息发送 // 异步数据同步之消息发送
planOperationRecordDataSync(record); planOperationRecordDataSync(record);
Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(planOperationRecord.getPlanId()); Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(CPlanOperationRecord.getPlanId());
if (optionalPlanDetail.get() != null) { if (optionalPlanDetail.get() != null) {
PlanDetail planDetail = optionalPlanDetail.get(); PlanDetail planDetail = optionalPlanDetail.get();
planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode()); planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode());
...@@ -790,7 +790,7 @@ public class ContingencyAction implements CustomerAction { ...@@ -790,7 +790,7 @@ public class ContingencyAction implements CustomerAction {
} }
} }
private void planOperationRecordDataSync(PlanOperationRecord record) { private void planOperationRecordDataSync(CPlanOperationRecord record) {
// 异步数据同步之消息发送 // 异步数据同步之消息发送
if (dataSyncSwitch) { if (dataSyncSwitch) {
try { try {
...@@ -975,14 +975,14 @@ public class ContingencyAction implements CustomerAction { ...@@ -975,14 +975,14 @@ public class ContingencyAction implements CustomerAction {
*/ */
public void updateNumberPlan(String batchNo) { public void updateNumberPlan(String batchNo) {
// 结束预案 更新预案记录表,预案状态 // 结束预案 更新预案记录表,预案状态
PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(batchNo); CPlanOperationRecord CPlanOperationRecord = planOperationRecordDao.findByBatchNo(batchNo);
if (planOperationRecord != null) { if (CPlanOperationRecord != null) {
planOperationRecord.setStatus(PlanRecordStatusEnum.INTERRUPT.getCode()); CPlanOperationRecord.setStatus(PlanRecordStatusEnum.INTERRUPT.getCode());
planOperationRecord.setEndTime(new Date()); CPlanOperationRecord.setEndTime(new Date());
PlanOperationRecord record = planOperationRecordDao.save(planOperationRecord); CPlanOperationRecord record = planOperationRecordDao.save(CPlanOperationRecord);
// 异步数据同步之消息发送 // 异步数据同步之消息发送
planOperationRecordDataSync(record); planOperationRecordDataSync(record);
Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(planOperationRecord.getPlanId()); Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(CPlanOperationRecord.getPlanId());
if (optionalPlanDetail.get() != null) { if (optionalPlanDetail.get() != null) {
PlanDetail planDetail = optionalPlanDetail.get(); PlanDetail planDetail = optionalPlanDetail.get();
planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode()); planDetail.setStatus(ContingencyPlanStatusEnum.AVAILABLE.getCode());
......
package com.yeejoin.amos.fas.business.dao.repository; package com.yeejoin.amos.fas.business.dao.repository;
import com.yeejoin.amos.fas.dao.entity.PlanOperationRecord; import com.yeejoin.amos.fas.dao.entity.CPlanOperationRecord;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -13,12 +13,12 @@ import java.util.List; ...@@ -13,12 +13,12 @@ import java.util.List;
* @date 2021/1/15 10:36 * @date 2021/1/15 10:36
*/ */
@Repository @Repository
public interface IPlanOperationRecordDao extends BaseDao<PlanOperationRecord, Long> { public interface IPlanOperationRecordDao extends BaseDao<CPlanOperationRecord, Long> {
@Query(value="SELECT * from c_plan_operation_record where batch_no = ?1 AND is_delete = 0 ", nativeQuery = true) @Query(value="SELECT * from c_plan_operation_record where batch_no = ?1 AND is_delete = 0 ", nativeQuery = true)
PlanOperationRecord findByBatchNo(String batchNo); CPlanOperationRecord findByBatchNo(String batchNo);
@Query(value="SELECT * from c_plan_operation_record where plan_id = ?1 AND is_delete = 0 AND status = 0 ORDER BY create_date DESC", nativeQuery = true) @Query(value="SELECT * from c_plan_operation_record where plan_id = ?1 AND is_delete = 0 AND status = 0 ORDER BY create_date DESC", nativeQuery = true)
List<PlanOperationRecord> findByPlanId1(Long planId); List<CPlanOperationRecord> findByPlanId1(Long planId);
int countByPlanId(Long planId); int countByPlanId(Long planId);
...@@ -28,6 +28,6 @@ public interface IPlanOperationRecordDao extends BaseDao<PlanOperationRecord, Lo ...@@ -28,6 +28,6 @@ public interface IPlanOperationRecordDao extends BaseDao<PlanOperationRecord, Lo
* @param status 状态 * @param status 状态
* @return list * @return list
*/ */
List<PlanOperationRecord> findByStatus(Integer status); List<CPlanOperationRecord> findByStatus(Integer status);
} }
...@@ -120,7 +120,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -120,7 +120,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
ReserveEnum reserveEnum = this.runCheck(vo); ReserveEnum reserveEnum = this.runCheck(vo);
result.setMessage(reserveEnum.getText()); result.setMessage(reserveEnum.getText());
if (ReserveEnum.THISRUNNING.getStatus().equals(reserveEnum.getStatus())) { if (ReserveEnum.THISRUNNING.getStatus().equals(reserveEnum.getStatus())) {
List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId())); List<CPlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId()));
result.setMessage(ReserveEnum.THISRUNNING.getText()); result.setMessage(ReserveEnum.THISRUNNING.getText());
result.setBatchNo(recordList.get(0).getBatchNo()); result.setBatchNo(recordList.get(0).getBatchNo());
return result; return result;
...@@ -166,24 +166,24 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -166,24 +166,24 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
} }
//插入运行记录表 //插入运行记录表
PlanOperationRecord planOperationRecord = new PlanOperationRecord(); CPlanOperationRecord CPlanOperationRecord = new CPlanOperationRecord();
planOperationRecord.setStatus(PlanRecordStatusEnum.OPERATION.getCode()); CPlanOperationRecord.setStatus(PlanRecordStatusEnum.OPERATION.getCode());
planOperationRecord.setPlanId(PlanDetailOp.get().getId()); CPlanOperationRecord.setPlanId(PlanDetailOp.get().getId());
planOperationRecord.setIsDelete(false); CPlanOperationRecord.setIsDelete(false);
planOperationRecord.setStartTime(new Date()); CPlanOperationRecord.setStartTime(new Date());
planOperationRecord.setPlanPattern(vo.getStatus()); CPlanOperationRecord.setPlanPattern(vo.getStatus());
planOperationRecord.setStartUserId(vo.getUserId()); CPlanOperationRecord.setStartUserId(vo.getUserId());
planOperationRecord.setStartUserName(vo.getUserName()); CPlanOperationRecord.setStartUserName(vo.getUserName());
planOperationRecord.setEquipmentCode(equipmentSpecific.getCode()); CPlanOperationRecord.setEquipmentCode(equipmentSpecific.getCode());
planOperationRecord.setEquipmentName(equipmentSpecific.getName()); CPlanOperationRecord.setEquipmentName(equipmentSpecific.getName());
planOperationRecord.setEquipmentId(equipmentSpecific.getId()); CPlanOperationRecord.setEquipmentId(equipmentSpecific.getId());
planOperationRecord.setFireEquipmentId(equipment.getId()); CPlanOperationRecord.setFireEquipmentId(equipment.getId());
if (ContingencyPlanStatusEnum.SIMULATION_START.getCode().equals(vo.getStatus())) { if (ContingencyPlanStatusEnum.SIMULATION_START.getCode().equals(vo.getStatus())) {
planOperationRecord.setExecutionType(ExecutionTypeEnum.PLANCHECK.getCode()); CPlanOperationRecord.setExecutionType(ExecutionTypeEnum.PLANCHECK.getCode());
} else { } else {
planOperationRecord.setExecutionType(ExecutionTypeEnum.FIREMANAGEMENT.getCode()); CPlanOperationRecord.setExecutionType(ExecutionTypeEnum.FIREMANAGEMENT.getCode());
} }
PlanOperationRecord operationRecord = planOperationRecordDao.save(planOperationRecord); CPlanOperationRecord operationRecord = planOperationRecordDao.save(CPlanOperationRecord);
// 异步数据同步之消息发送 // 异步数据同步之消息发送
planOperationRecordDataSync(operationRecord); planOperationRecordDataSync(operationRecord);
//预案启动 //预案启动
...@@ -200,7 +200,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -200,7 +200,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
planDetailDataSync(detail); planDetailDataSync(detail);
//更新预案执行记录表的批次号 //更新预案执行记录表的批次号
operationRecord.setBatchNo(batchNo); operationRecord.setBatchNo(batchNo);
PlanOperationRecord record = planOperationRecordDao.save(operationRecord); CPlanOperationRecord record = planOperationRecordDao.save(operationRecord);
// 异步数据同步之消息发送 // 异步数据同步之消息发送
planOperationRecordDataSync(record); planOperationRecordDataSync(record);
result.setMessage(ReserveEnum.RUN.getText()); result.setMessage(ReserveEnum.RUN.getText());
...@@ -209,7 +209,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -209,7 +209,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
return result; return result;
} }
private void planOperationRecordDataSync(PlanOperationRecord operationRecord) { private void planOperationRecordDataSync(CPlanOperationRecord operationRecord) {
if (dataSyncSwitch) { if (dataSyncSwitch) {
try { try {
dataSyncService.asyncInvoke(() -> { dataSyncService.asyncInvoke(() -> {
...@@ -227,30 +227,30 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -227,30 +227,30 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
@Override @Override
public Map<String, Object> firstGetRecord(String batchNo) { public Map<String, Object> firstGetRecord(String batchNo) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(batchNo); CPlanOperationRecord CPlanOperationRecord = planOperationRecordDao.findByBatchNo(batchNo);
if (planOperationRecord == null) { if (CPlanOperationRecord == null) {
throw new YeeException("执行记录不存在"); throw new YeeException("执行记录不存在");
} else { } else {
PlanDetail planDetail = planDetailDao.getOne(planOperationRecord.getPlanId()); PlanDetail planDetail = planDetailDao.getOne(CPlanOperationRecord.getPlanId());
if (planDetail == null) { if (planDetail == null) {
throw new YeeException("数字预案模型被删除"); throw new YeeException("数字预案模型被删除");
} }
map.put("status", planOperationRecord.getStatus()); map.put("status", CPlanOperationRecord.getStatus());
if (PlanRecordStatusEnum.OPERATION == PlanRecordStatusEnum.getEnum(planOperationRecord.getStatus())) { if (PlanRecordStatusEnum.OPERATION == PlanRecordStatusEnum.getEnum(CPlanOperationRecord.getStatus())) {
map.put("executionTime", (System.currentTimeMillis() - planOperationRecord.getStartTime().getTime()) / 1000); map.put("executionTime", (System.currentTimeMillis() - CPlanOperationRecord.getStartTime().getTime()) / 1000);
} else { } else {
map.put("executionTime", (planOperationRecord.getEndTime().getTime() - planOperationRecord.getStartTime().getTime()) / 1000); map.put("executionTime", (CPlanOperationRecord.getEndTime().getTime() - CPlanOperationRecord.getStartTime().getTime()) / 1000);
} }
map.put("crateDate", planOperationRecord.getStartTime()); map.put("crateDate", CPlanOperationRecord.getStartTime());
if (ContingencyPlanStatusEnum.getEnum(planOperationRecord.getPlanPattern()) == ContingencyPlanStatusEnum.SIMULATION_START) { if (ContingencyPlanStatusEnum.getEnum(CPlanOperationRecord.getPlanPattern()) == ContingencyPlanStatusEnum.SIMULATION_START) {
map.put("userName", planOperationRecord.getStartUserName()); map.put("userName", CPlanOperationRecord.getStartUserName());
map.put("startType", "手动"); map.put("startType", "手动");
} else { } else {
map.put("userName", "系统"); map.put("userName", "系统");
map.put("startType", "自动"); map.put("startType", "自动");
} }
map.put("executionType", planOperationRecord.getExecutionType()); map.put("executionType", CPlanOperationRecord.getExecutionType());
map.put("equipmentName", planOperationRecord.getEquipmentName()); map.put("equipmentName", CPlanOperationRecord.getEquipmentName());
map.put("PlanName", planDetail.getPlanName()); map.put("PlanName", planDetail.getPlanName());
} }
return map; return map;
...@@ -289,7 +289,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -289,7 +289,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
if (planEquipments.isEmpty()) { if (planEquipments.isEmpty()) {
return ReserveEnum.PLAN_EQUIP_IS_DELETE; return ReserveEnum.PLAN_EQUIP_IS_DELETE;
} }
List<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId())); List<CPlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId()));
if (recordList.size() > 0 && !vo.getStatus().equals(ContingencyPlanStatusEnum.ONGOING.getCode())) { if (recordList.size() > 0 && !vo.getStatus().equals(ContingencyPlanStatusEnum.ONGOING.getCode())) {
return ReserveEnum.THISRUNNING; return ReserveEnum.THISRUNNING;
} }
...@@ -308,9 +308,9 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -308,9 +308,9 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
} }
List<PlanDetail> countMn = planDetailDao.findByStatus((Integer[]) Arrays.asList(ContingencyPlanStatusEnum.SIMULATION_START.getCode()).toArray()); List<PlanDetail> countMn = planDetailDao.findByStatus((Integer[]) Arrays.asList(ContingencyPlanStatusEnum.SIMULATION_START.getCode()).toArray());
if (countMn.size() > NumberEnum.ZERO.getValue()) { if (countMn.size() > NumberEnum.ZERO.getValue()) {
List<PlanOperationRecord> planOperationRecordList = planOperationRecordDao.findByPlanId1(countMn.get(0).getId()); List<CPlanOperationRecord> CPlanOperationRecordList = planOperationRecordDao.findByPlanId1(countMn.get(0).getId());
if (planOperationRecordList.size() > 0) { if (CPlanOperationRecordList.size() > 0) {
Optional<Equipment> equipment = iContingencyInstance.fire(planOperationRecordList.get(0).getBatchNo(), "0", "", "FIRE_CANCEL", "CONFIRM", "B"); Optional<Equipment> equipment = iContingencyInstance.fire(CPlanOperationRecordList.get(0).getBatchNo(), "0", "", "FIRE_CANCEL", "CONFIRM", "B");
// 结束预案,更新设备重点设备参数 // 结束预案,更新设备重点设备参数
equipment.ifPresent(equip -> { equipment.ifPresent(equip -> {
equip.setStartTime(DateUtil.getDateNow()); equip.setStartTime(DateUtil.getDateNow());
...@@ -319,7 +319,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -319,7 +319,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
equip.setStatus(NumberEnum.ONE.getValue()); equip.setStatus(NumberEnum.ONE.getValue());
equipmentService.save(equip); equipmentService.save(equip);
}); });
customerAction.intreeuptPlan(planOperationRecordList.get(0).getBatchNo()); customerAction.intreeuptPlan(CPlanOperationRecordList.get(0).getBatchNo());
} }
} }
...@@ -749,10 +749,10 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService { ...@@ -749,10 +749,10 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
AtomicBoolean bool = new AtomicBoolean(true); AtomicBoolean bool = new AtomicBoolean(true);
try { try {
// 运行中的设置为重置 // 运行中的设置为重置
List<PlanOperationRecord> planList = planOperationRecordDao.findByStatus(0); List<CPlanOperationRecord> planList = planOperationRecordDao.findByStatus(0);
if (!planList.isEmpty()) { if (!planList.isEmpty()) {
planList.forEach(planOperationRecord -> { planList.forEach(CPlanOperationRecord -> {
String batchNo = planOperationRecord.getBatchNo(); String batchNo = CPlanOperationRecord.getBatchNo();
redisTemplate.delete(RiskSourceServiceImpl.cacheKeyForCanBeRunning()); redisTemplate.delete(RiskSourceServiceImpl.cacheKeyForCanBeRunning());
Optional<Equipment> equipment; Optional<Equipment> equipment;
try { try {
......
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