Commit 54706852 authored by xixinzhao's avatar xixinzhao

修改预案重置

parent 459d0f2c
......@@ -23,4 +23,11 @@ public interface IPlanOperationRecordDao extends BaseDao<PlanOperationRecord, Lo
int countByPlanId(Long planId);
/**
* 根据状态查找
* @param status 状态
* @return list
*/
List<PlanOperationRecord> findByStatus(Integer status);
}
......@@ -73,7 +73,6 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
@Autowired
private IDataSyncService dataSyncService;
private final PlanOperationRecordMapper planOperationRecordMapper;
private final IPlanDetailDao planDetailDao;
private final IPlanDocDao planDocDao;
......@@ -749,10 +748,33 @@ public class ContingencyPlanServiceImpl implements IContingencyPlanService {
public AtomicBoolean planReset() {
AtomicBoolean bool = new AtomicBoolean(true);
try {
Date date = new Date();
Integer update = planDetailMapper.planReset(date);
// 运行中的设置为重置
List<PlanOperationRecord> planList = planOperationRecordDao.findByStatus(0);
if (!planList.isEmpty()) {
planList.forEach(planOperationRecord -> {
String batchNo = planOperationRecord.getBatchNo();
redisTemplate.delete(RiskSourceServiceImpl.cacheKeyForCanBeRunning());
Optional<Equipment> equipment;
try {
equipment = iContingencyInstance.fire(batchNo, "0", "", "FIRE_CANCEL", "CONFIRM", "B");
// 结束预案,更新设备重点设备参数
equipment.ifPresent(equip -> {
equip.setEndTime(null);
equip.setReserveSource(NumberEnum.ONE.getValue());
equip.setStartTime(DateUtil.getDateNow());
equip.setStatus(NumberEnum.ONE.getValue());
equipmentService.save(equip);
});
customerAction.intreeuptPlan(batchNo);
} catch (Exception e) {
logger.info("预案重置失败batchNo:{}", batchNo, e);
e.printStackTrace();
}
});
}
// 异步数据同步之消息发送
if (update > 0 && dataSyncSwitch) {
if (!planList.isEmpty() && dataSyncSwitch) {
try {
dataSyncService.asyncInvoke(() -> {
Map<String, Object> map = new HashMap<>();
......
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