cnas-device/src/main/java/com/ruoyi/device/controller/DeviceMaintenancePlanController.java
@@ -3,16 +3,21 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.device.dto.DeviceMaintenancePlanDetailsDto;
import com.ruoyi.device.dto.DeviceMaintenancePlanDto;
import com.ruoyi.device.pojo.DeviceMaintenanceAttachment;
import com.ruoyi.device.pojo.DeviceMaintenancePlan;
import com.ruoyi.device.pojo.DeviceMaintenancePlanDetails;
import com.ruoyi.device.service.DeviceMaintenancePlanService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.SneakyThrows;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
@@ -80,11 +85,57 @@
    }
    /**
     * 按年份查询设备保养计划(不存在则自动创建),并自动补全已到点的设备明细
     */
    @Operation(summary = "按年份查询设备保养计划(自动创建并补全到点明细)")
    @GetMapping("/getPlanByYear")
    public Result<DeviceMaintenancePlanDto> getPlanByYear(String planYear) {
        return Result.success(deviceMaintenancePlanService.getOrCreatePlanByYear(planYear));
    }
    /**
     * 保养计划年份列表(自动删除没有明细的空年份计划)
     */
    @Operation(summary = "保养计划年份列表")
    @GetMapping("/getPlanYears")
    public Result<List<String>> getPlanYears() {
        return Result.success(deviceMaintenancePlanService.getMaintenancePlanYears());
    }
    /**
     * 设备保养计划详情列表(含到点标红)
     */
    @Operation(summary = "设备保养计划详情列表")
    @GetMapping("/pageMaintenancePlanDetail")
    public Result<IPage<DeviceMaintenancePlanDetailsDto>> pageMaintenancePlanDetail(Page page, Integer planId, String deviceName, String deviceNumber) {
        return Result.success(deviceMaintenancePlanService.pageMaintenancePlanDetail(page, planId, deviceName, deviceNumber));
    }
    /**
     * 修改设备保养计划详情
     */
    @Operation(summary = "修改设备保养计划详情")
    @PostMapping("/updateMaintenancePlanDetail")
    public Result updateMaintenancePlanDetail(@RequestBody DeviceMaintenancePlanDetails deviceMaintenancePlanDetails) {
        return Result.success(deviceMaintenancePlanService.updateMaintenancePlanDetail(deviceMaintenancePlanDetails));
    }
    /**
     * 删除设备保养计划详情
     */
    @Operation(summary = "删除设备保养计划详情")
    @DeleteMapping("/delMaintenancePlanDetail")
    public Result delMaintenancePlanDetail(Integer maintenancePlanDetailId) {
        return Result.success(deviceMaintenancePlanService.removeMaintenancePlanDetail(maintenancePlanDetailId));
    }
    /**
     * 导出设备保养计划
     */
    @Operation(summary = "导出设备保养计划")
    @GetMapping("/exportDeviceMaintenancePlan")
    public Result exportDeviceMaintenancePlan(@RequestParam("maintenancePlanId") Integer maintenancePlanId, HttpServletResponse response) {
    public Result exportDeviceMaintenancePlan(@RequestParam("maintenancePlanId") Integer maintenancePlanId,
                                              HttpServletResponse response) {
        return deviceMaintenancePlanService.exportDeviceMaintenancePlanDto(maintenancePlanId, response);
    }
@@ -105,4 +156,32 @@
    public Result reviewMaintenancePlanStatus(@RequestBody DeviceMaintenancePlanDto deviceMaintenancePlanDto) {
        return deviceMaintenancePlanService.reviewMaintenancePlanStatus(deviceMaintenancePlanDto);
    }
    /**
     * 查询保养计划明细附件
     */
    @Operation(summary = "查询保养计划明细附件")
    @GetMapping("/selectAttachments")
    public Result<List<DeviceMaintenanceAttachment>> selectAttachments(Integer maintenancePlanDetailId) {
        return Result.success(deviceMaintenancePlanService.selectAttachments(maintenancePlanDetailId));
    }
    /**
     * 上传保养计划明细附件
     */
    @Operation(summary = "上传保养计划明细附件")
    @PostMapping("/uploadAttachment")
    public Result uploadAttachment(@RequestParam("maintenancePlanDetailId") Integer maintenancePlanDetailId,
                                   @RequestParam("file") MultipartFile file) {
        return Result.success(deviceMaintenancePlanService.uploadAttachment(maintenancePlanDetailId, file));
    }
    /**
     * 删除保养计划明细附件
     */
    @Operation(summary = "删除保养计划明细附件")
    @DeleteMapping("/deleteAttachment")
    public Result deleteAttachment(Long id) {
        return Result.success(deviceMaintenancePlanService.deleteAttachment(id));
    }
}