| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int complete(Long id) { |
| | | InspectionTask task = inspectionTaskMapper.selectById(id); |
| | | if (task == null) { |
| | | throw new IllegalArgumentException("巡检任务不存在"); |
| | | } |
| | | if (task.getStatus() != null && task.getStatus() == 1) { |
| | | throw new IllegalArgumentException("该巡检任务已完成"); |
| | | } |
| | | task.setStatus(1); |
| | | if (task.getInspectionResult() == null) { |
| | | task.setInspectionResult("1"); |
| | | } |
| | | return inspectionTaskMapper.updateById(task); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int batchComplete(String dateStr) { |
| | | if (StringUtils.isBlank(dateStr)) { |
| | | throw new IllegalArgumentException("日期参数不能为空"); |
| | | } |
| | | java.time.LocalDate date = java.time.LocalDate.parse(dateStr); |
| | | java.time.LocalDateTime startOfDay = date.atStartOfDay(); |
| | | java.time.LocalDateTime endOfDay = date.atTime(java.time.LocalTime.MAX); |
| | | List<InspectionTask> tasks = inspectionTaskMapper.selectList( |
| | | new LambdaQueryWrapper<InspectionTask>() |
| | | .eq(InspectionTask::getStatus, 0) |
| | | .ge(InspectionTask::getCreateTime, startOfDay) |
| | | .le(InspectionTask::getCreateTime, endOfDay)); |
| | | if (tasks.isEmpty()) { |
| | | throw new IllegalArgumentException("该日期下没有待完成的巡检记录"); |
| | | } |
| | | int count = 0; |
| | | for (InspectionTask task : tasks) { |
| | | task.setStatus(1); |
| | | if (task.getInspectionResult() == null) { |
| | | task.setInspectionResult("1"); |
| | | } |
| | | inspectionTaskMapper.updateById(task); |
| | | count++; |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int delByIds(Long[] ids) { |
| | | // 检查参数 |
| | | if (ids == null || ids.length == 0) { |