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

item:数据同步,修改类名

parent 8db56518
......@@ -15,8 +15,8 @@ import java.util.Date;
@Data
@Entity
@Table(name="c_plan_operation_record")
@NamedQuery(name="PlanOperationRecord.findAll", query="SELECT e FROM PlanOperationRecord e")
public class PlanOperationRecord extends BasicEntity {
@NamedQuery(name="PlanOperationRecord.findAll", query="SELECT e FROM CPlanOperationRecord e")
public class CPlanOperationRecord 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.PlanOperationRecord;
import com.yeejoin.amos.fas.dao.entity.CPlanOperationRecord;
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 {
}
// 结束预案 更新预案记录表,预案状态
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);
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);
// 异步数据同步之消息发送
planOperationRecordDataSync(record);
Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(planOperationRecord.getPlanId());
Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(CPlanOperationRecord.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(PlanOperationRecord record) {
private void planOperationRecordDataSync(CPlanOperationRecord record) {
// 异步数据同步之消息发送
if (dataSyncSwitch) {
try {
......@@ -975,14 +975,14 @@ public class ContingencyAction implements CustomerAction {
*/
public void updateNumberPlan(String batchNo) {
// 结束预案 更新预案记录表,预案状态
PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(batchNo);
if (planOperationRecord != null) {
planOperationRecord.setStatus(PlanRecordStatusEnum.INTERRUPT.getCode());
planOperationRecord.setEndTime(new Date());
PlanOperationRecord record = planOperationRecordDao.save(planOperationRecord);
CPlanOperationRecord CPlanOperationRecord = planOperationRecordDao.findByBatchNo(batchNo);
if (CPlanOperationRecord != null) {
CPlanOperationRecord.setStatus(PlanRecordStatusEnum.INTERRUPT.getCode());
CPlanOperationRecord.setEndTime(new Date());
CPlanOperationRecord record = planOperationRecordDao.save(CPlanOperationRecord);
// 异步数据同步之消息发送
planOperationRecordDataSync(record);
Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(planOperationRecord.getPlanId());
Optional<PlanDetail> optionalPlanDetail = planDetailDao.findById(CPlanOperationRecord.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.PlanOperationRecord;
import com.yeejoin.amos.fas.dao.entity.CPlanOperationRecord;
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<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)
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)
List<PlanOperationRecord> findByPlanId1(Long planId);
List<CPlanOperationRecord> findByPlanId1(Long planId);
int countByPlanId(Long planId);
......@@ -28,6 +28,6 @@ public interface IPlanOperationRecordDao extends BaseDao<PlanOperationRecord, Lo
* @param status 状态
* @return list
*/
List<PlanOperationRecord> findByStatus(Integer status);
List<CPlanOperationRecord> 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<PlanOperationRecord> recordList = planOperationRecordDao.findByPlanId1(Long.valueOf(vo.getPlanId()));
List<CPlanOperationRecord> 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 {
}
//插入运行记录表
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());
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());
if (ContingencyPlanStatusEnum.SIMULATION_START.getCode().equals(vo.getStatus())) {
planOperationRecord.setExecutionType(ExecutionTypeEnum.PLANCHECK.getCode());
CPlanOperationRecord.setExecutionType(ExecutionTypeEnum.PLANCHECK.getCode());
} else {
planOperationRecord.setExecutionType(ExecutionTypeEnum.FIREMANAGEMENT.getCode());
CPlanOperationRecord.setExecutionType(ExecutionTypeEnum.FIREMANAGEMENT.getCode());
}
PlanOperationRecord operationRecord = planOperationRecordDao.save(planOperationRecord);
CPlanOperationRecord operationRecord = planOperationRecordDao.save(CPlanOperationRecord);
// 异步数据同步之消息发送
planOperationRecordDataSync(operationRecord);
//预案启动
......@@ -200,7 +200,7 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
planDetailDataSync(detail);
//更新预案执行记录表的批次号
operationRecord.setBatchNo(batchNo);
PlanOperationRecord record = planOperationRecordDao.save(operationRecord);
CPlanOperationRecord 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(PlanOperationRecord operationRecord) {
private void planOperationRecordDataSync(CPlanOperationRecord 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<>();
PlanOperationRecord planOperationRecord = planOperationRecordDao.findByBatchNo(batchNo);
if (planOperationRecord == null) {
CPlanOperationRecord CPlanOperationRecord = planOperationRecordDao.findByBatchNo(batchNo);
if (CPlanOperationRecord == null) {
throw new YeeException("执行记录不存在");
} else {
PlanDetail planDetail = planDetailDao.getOne(planOperationRecord.getPlanId());
PlanDetail planDetail = planDetailDao.getOne(CPlanOperationRecord.getPlanId());
if (planDetail == null) {
throw new YeeException("数字预案模型被删除");
}
map.put("status", planOperationRecord.getStatus());
if (PlanRecordStatusEnum.OPERATION == PlanRecordStatusEnum.getEnum(planOperationRecord.getStatus())) {
map.put("executionTime", (System.currentTimeMillis() - planOperationRecord.getStartTime().getTime()) / 1000);
map.put("status", CPlanOperationRecord.getStatus());
if (PlanRecordStatusEnum.OPERATION == PlanRecordStatusEnum.getEnum(CPlanOperationRecord.getStatus())) {
map.put("executionTime", (System.currentTimeMillis() - CPlanOperationRecord.getStartTime().getTime()) / 1000);
} 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());
if (ContingencyPlanStatusEnum.getEnum(planOperationRecord.getPlanPattern()) == ContingencyPlanStatusEnum.SIMULATION_START) {
map.put("userName", planOperationRecord.getStartUserName());
map.put("crateDate", CPlanOperationRecord.getStartTime());
if (ContingencyPlanStatusEnum.getEnum(CPlanOperationRecord.getPlanPattern()) == ContingencyPlanStatusEnum.SIMULATION_START) {
map.put("userName", CPlanOperationRecord.getStartUserName());
map.put("startType", "手动");
} else {
map.put("userName", "系统");
map.put("startType", "自动");
}
map.put("executionType", planOperationRecord.getExecutionType());
map.put("equipmentName", planOperationRecord.getEquipmentName());
map.put("executionType", CPlanOperationRecord.getExecutionType());
map.put("equipmentName", CPlanOperationRecord.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<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())) {
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<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");
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");
// 结束预案,更新设备重点设备参数
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(planOperationRecordList.get(0).getBatchNo());
customerAction.intreeuptPlan(CPlanOperationRecordList.get(0).getBatchNo());
}
}
......@@ -749,10 +749,10 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
AtomicBoolean bool = new AtomicBoolean(true);
try {
// 运行中的设置为重置
List<PlanOperationRecord> planList = planOperationRecordDao.findByStatus(0);
List<CPlanOperationRecord> planList = planOperationRecordDao.findByStatus(0);
if (!planList.isEmpty()) {
planList.forEach(planOperationRecord -> {
String batchNo = planOperationRecord.getBatchNo();
planList.forEach(CPlanOperationRecord -> {
String batchNo = CPlanOperationRecord.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