package com.ruoyi.safe.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.utils.SecurityUtils; 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.pojo.SafeLineInspection; import com.ruoyi.safe.service.SafeLineInspectionService; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Operation; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.*; import java.time.LocalDateTime; import java.util.List; /** *

* 安全生产--线路巡检任务 前端控制器 *

* * @author 芯导软件(江苏)有限公司 * @since 2026-06-29 */ @RestController @RequestMapping("/safeLineInspection") @AllArgsConstructor @Tag(name = "安全生产--线路巡检任务") public class SafeLineInspectionController { private SafeLineInspectionService safeLineInspectionService; @GetMapping("/page") @Operation(summary = "分页查询") public R page(Page page, SafeLineInspection safeLineInspection) { return R.ok(safeLineInspectionService.pageSafeLineInspection(page, safeLineInspection)); } @GetMapping("/{id}") @Operation(summary = "根据ID查询") public R getById(@PathVariable Integer id) { return R.ok(safeLineInspectionService.getById(id)); } @Operation(summary = "新增线路巡检任务") @Log(title = "线路巡检", businessType = BusinessType.INSERT) @PostMapping() public R add(@RequestBody SafeLineInspection safeLineInspection) { // 新增时默认状态为"待巡检" safeLineInspection.setStatus("待巡检"); return R.ok(safeLineInspectionService.save(safeLineInspection)); } @Operation(summary = "修改线路巡检任务") @Log(title = "线路巡检", businessType = BusinessType.UPDATE) @PutMapping() public R update(@RequestBody SafeLineInspection safeLineInspection) { return R.ok(safeLineInspectionService.updateById(safeLineInspection)); } @Operation(summary = "完成巡检") @Log(title = "线路巡检", businessType = BusinessType.UPDATE) @PutMapping("/complete/{id}") public R complete(@PathVariable Integer id) { SafeLineInspection inspection = safeLineInspectionService.getById(id); if (inspection == null) { 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.DELETE) @DeleteMapping("/{ids}") public R delSafeLineInspection(@RequestBody List ids) { return R.ok(safeLineInspectionService.removeBatchByIds(ids)); } }