| | |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.safe.dto.SafeLineInspectionExecuteDto; |
| | | import com.ruoyi.safe.pojo.SafeLineInspection; |
| | | import com.ruoyi.safe.pojo.SafeLineInspectionHazard; |
| | | import com.ruoyi.safe.pojo.SafeLineInspectionRecord; |
| | |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | .count() > 0; |
| | | } |
| | | |
| | | @Operation(summary = "完成巡检") |
| | | @Operation(summary = "废弃旧巡检完成接口") |
| | | @Log(title = "线路巡检", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/complete/{id}") |
| | | public R complete(@PathVariable Integer id) { |
| | |
| | | if ("已完成".equals(inspection.getStatus())) { |
| | | return R.fail("巡检任务已完成,请勿重复操作"); |
| | | } |
| | | |
| | | // 校验是否有未整改的隐患 |
| | | List<SafeLineInspectionHazard> hazards = safeLineInspectionHazardService.listByInspectionId(id); |
| | | boolean hasUnrectified = hazards.stream() |
| | | .anyMatch(h -> !"已整改".equals(h.getStatus())); |
| | | if (hasUnrectified) { |
| | | return R.fail("存在未整改的隐患,请先完成隐患整改"); |
| | | return R.fail("请通过执行巡检提交正常结果;异常记录请在整改跟踪中由整改责任人完成整改"); |
| | | } |
| | | |
| | | Long currentUserId = SecurityUtils.getUserId(); |
| | | inspection.setStatus("已完成"); |
| | | inspection.setUpdateTime(LocalDateTime.now()); |
| | | inspection.setUpdateUser(currentUserId.intValue()); |
| | | |
| | | return R.ok(safeLineInspectionService.updateById(inspection)); |
| | | @Operation(summary = "执行巡检") |
| | | @Log(title = "线路巡检", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/execute") |
| | | public R execute(@RequestBody SafeLineInspectionExecuteDto executeDto) { |
| | | try { |
| | | return R.ok(safeLineInspectionService.executeInspection(executeDto)); |
| | | } catch (IllegalArgumentException e) { |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Operation(summary = "删除线路巡检任务") |