|
|
@ -12,10 +12,14 @@ import com.inspect.base.core.utils.DateUtils; |
|
|
import com.inspect.base.core.utils.HttpClientUtils; |
|
|
import com.inspect.base.core.utils.HttpClientUtils; |
|
|
import com.inspect.base.core.utils.StringUtils; |
|
|
import com.inspect.base.core.utils.StringUtils; |
|
|
import com.inspect.calender.service.TaskCalendarGenerator; |
|
|
import com.inspect.calender.service.TaskCalendarGenerator; |
|
|
|
|
|
import com.inspect.partrolresult.mapper.PatrolResultMapper; |
|
|
import com.inspect.partrolresult.util.PrintUtil; |
|
|
import com.inspect.partrolresult.util.PrintUtil; |
|
|
|
|
|
import com.inspect.partrolresultAux.mapper.PatrolResultAuxMapper; |
|
|
import com.inspect.resultmain.controller.PatrolTaskResultMainController; |
|
|
import com.inspect.resultmain.controller.PatrolTaskResultMainController; |
|
|
import com.inspect.resultmain.domain.PatrolTaskResultMain; |
|
|
import com.inspect.resultmain.domain.PatrolTaskResultMain; |
|
|
|
|
|
import com.inspect.resultmain.mapper.PatrolTaskResultMainMapper; |
|
|
import com.inspect.task.domain.DeviceConvert; |
|
|
import com.inspect.task.domain.DeviceConvert; |
|
|
|
|
|
import com.inspect.taskinfo.mapper.PatrolTaskInfoMapper; |
|
|
|
|
|
|
|
|
import com.inspect.task.domain.PatrolData; |
|
|
import com.inspect.task.domain.PatrolData; |
|
|
import com.inspect.task.domain.PatrolTask; |
|
|
import com.inspect.task.domain.PatrolTask; |
|
|
@ -34,6 +38,7 @@ import org.springframework.scheduling.annotation.Async; |
|
|
import org.springframework.scheduling.annotation.EnableScheduling; |
|
|
import org.springframework.scheduling.annotation.EnableScheduling; |
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
@ -55,6 +60,18 @@ public class PatrolTaskServiceImpl implements IPatrolTaskService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private SftpClient sftpClient; |
|
|
private SftpClient sftpClient; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private PatrolResultMapper patrolResultMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private PatrolResultAuxMapper patrolResultAuxMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private PatrolTaskResultMainMapper patrolTaskResultMainMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private PatrolTaskInfoMapper patrolTaskInfoMapper; |
|
|
|
|
|
|
|
|
final ResultAnalysisMapper resultAnalysisMapper; |
|
|
final ResultAnalysisMapper resultAnalysisMapper; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
@ -139,6 +156,50 @@ public class PatrolTaskServiceImpl implements IPatrolTaskService { |
|
|
return count; |
|
|
return count; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 删除巡视任务,并在同一事务内清理该任务产生的执行与结果数据。 |
|
|
|
|
|
* <p> |
|
|
|
|
|
* 清理范围:patrol_task_status、patrol_result、result_analysis、patrol_result_aux、 |
|
|
|
|
|
* patrol_task_result_main、patrol_analyse_log、patrol_task_info。 |
|
|
|
|
|
* 报告(inspection_report)可能由多个任务合并生成,未做级联删除。 |
|
|
|
|
|
* <p> |
|
|
|
|
|
* 兼容新建后立即删除:此时任务没有任何执行/结果数据,关联删除均按空集合跳过, |
|
|
|
|
|
* 仅删除任务本身和任务点位。 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public int deletePatrolTaskWithRelatedData(Long[] taskIds) { |
|
|
|
|
|
if (taskIds == null || taskIds.length == 0) { |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
List<String> taskCodes = this.patrolTaskMapper.selectTaskCodesByTaskIds(taskIds).stream() |
|
|
|
|
|
.filter(StringUtils::isNotEmpty) |
|
|
|
|
|
.distinct() |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
if (!taskCodes.isEmpty()) { |
|
|
|
|
|
List<String> taskPatrolledIds = this.patrolTaskStatusMapper.selectTaskPatrolledIdsByTaskCodes(taskCodes).stream() |
|
|
|
|
|
.filter(StringUtils::isNotEmpty) |
|
|
|
|
|
.distinct() |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
// 结果分析先删:按任务编码兜底清理 patrol_result.line_id 关联数据,再按执行ID直删 |
|
|
|
|
|
this.resultAnalysisMapper.deleteResultAnalysisByTaskCodes(taskCodes); |
|
|
|
|
|
if (!taskPatrolledIds.isEmpty()) { |
|
|
|
|
|
this.resultAnalysisMapper.deleteResultAnalysisByTaskPatrolledIds(taskPatrolledIds); |
|
|
|
|
|
this.resultAnalysisMapper.deleteAnalyseLogByTaskPatrolledIds(taskPatrolledIds); |
|
|
|
|
|
} |
|
|
|
|
|
this.patrolResultMapper.deletePatrolResultByTaskCodes(taskCodes, taskPatrolledIds); |
|
|
|
|
|
this.patrolResultAuxMapper.deletePatrolResultAuxByTaskCodes(taskCodes, taskPatrolledIds); |
|
|
|
|
|
this.patrolTaskResultMainMapper.deletePatrolTaskResultMainByTaskCodes(taskCodes); |
|
|
|
|
|
this.patrolTaskStatusMapper.deletePatrolTaskStatusByTaskCodes(taskCodes); |
|
|
|
|
|
} |
|
|
|
|
|
this.patrolTaskInfoMapper.deletePatrolTaskInfoByMajorIds(taskIds); |
|
|
|
|
|
int count = this.patrolTaskMapper.deletePatrolTaskByTaskIds(taskIds); |
|
|
|
|
|
taskCalendarGenerator.onTaskChange(); |
|
|
|
|
|
log.info("[TASK_DELETE] 任务及关联数据删除完成, taskIds: {}, taskCodes: {}, deleteCount: {}", taskIds, taskCodes, count); |
|
|
|
|
|
return count; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public List<Map<String, Long>> selectTaskRationalGroupByType() { |
|
|
public List<Map<String, Long>> selectTaskRationalGroupByType() { |
|
|
return patrolTaskMapper.selectTaskRationalGroupByType(); |
|
|
return patrolTaskMapper.selectTaskRationalGroupByType(); |
|
|
} |
|
|
} |
|
|
|