Commit 8646f87c authored by 高建强's avatar 高建强

item:数据同步,还原类名

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