|
|
@@ -3,8 +3,11 @@ package com.tuoheng.admin.service.third; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.tuoheng.admin.entity.domain.ThMission; |
|
|
|
import com.tuoheng.admin.entity.domain.WarningRecord; |
|
|
|
import com.tuoheng.admin.enums.MarkEnum; |
|
|
|
import com.tuoheng.admin.enums.MarkTypeEnum; |
|
|
|
import com.tuoheng.admin.mapper.ThMissionMapper; |
|
|
|
import com.tuoheng.admin.mapper.WarningRecordMapper; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@@ -13,6 +16,9 @@ import org.springframework.stereotype.Service; |
|
|
|
@Service |
|
|
|
public class UpdateEmergencyMissionStatusService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WarningRecordMapper warningRecordMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ThMissionMapper thMissionMapper; |
|
|
|
|
|
|
@@ -23,13 +29,29 @@ public class UpdateEmergencyMissionStatusService { |
|
|
|
*/ |
|
|
|
public void updateStatus(ThMission oldMission, Integer status) { |
|
|
|
log.info("修改应急任务数据, type:{}, emergencyDataMissionId:{}, status={}", oldMission.getType(), oldMission.getEmergencyDataMissionId(), status); |
|
|
|
WarningRecord warningRecord = warningRecordMapper.selectOne(new LambdaQueryWrapper<WarningRecord>() |
|
|
|
.eq(WarningRecord::getMissionId, oldMission.getId()) |
|
|
|
.eq(WarningRecord::getMark, MarkTypeEnum.VALID.getCode()) |
|
|
|
.orderByDesc(WarningRecord::getCreateTime) |
|
|
|
.last(" limit 1")); |
|
|
|
if (ObjectUtil.isNull(warningRecord)) { |
|
|
|
log.info("修改应急任务数据,该巡检任务没有产生预警记录"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
ThMission emergencyMission = thMissionMapper.selectOne(new LambdaQueryWrapper<ThMission>() |
|
|
|
.eq(ThMission::getId, oldMission.getEmergencyDataMissionId()) |
|
|
|
.eq(ThMission::getId, warningRecord.getEmergencyMissionId()) |
|
|
|
.eq(ThMission::getMark, MarkEnum.VALID.getCode())); |
|
|
|
if (ObjectUtil.isNull(emergencyMission)) { |
|
|
|
log.info("修改应急任务数据,应急任务不存在"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (0 == emergencyMission.getEmergencyDataMissionId()) { |
|
|
|
log.info("修改应急任务数据,该应急任务,作为独立的任务"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 在查询一次,保证数据是最新的 |
|
|
|
ThMission mission = thMissionMapper.selectOne(new LambdaQueryWrapper<ThMission>() |
|
|
|
.eq(ThMission::getId, oldMission.getId()) |