From 234b0ac195934b34c06045b2d2ef0f10e239dd8e Mon Sep 17 00:00:00 2001 From: zhuo <2089219845@qq.com> Date: 星期三, 23 四月 2025 00:06:54 +0800 Subject: [PATCH] 系统合并 --- cnas-device/src/main/java/com/ruoyi/device/controller/DeviceMaintenanceController.java | 74 +++++++++++++++++------------------- 1 files changed, 35 insertions(+), 39 deletions(-) diff --git a/cnas-device/src/main/java/com/ruoyi/device/controller/DeviceMaintenanceController.java b/cnas-device/src/main/java/com/ruoyi/device/controller/DeviceMaintenanceController.java index 44cf11a..46fadff 100644 --- a/cnas-device/src/main/java/com/ruoyi/device/controller/DeviceMaintenanceController.java +++ b/cnas-device/src/main/java/com/ruoyi/device/controller/DeviceMaintenanceController.java @@ -1,27 +1,18 @@ package com.ruoyi.device.controller; -import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.write.metadata.style.WriteCellStyle; -import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.Result; -import com.ruoyi.common.numgen.NumberGenerator; -import com.ruoyi.device.excel.DeviceMaintenanceExport; +import com.ruoyi.common.core.domain.entity.User; +import com.ruoyi.device.dto.DeviceMaintenanceDto; import com.ruoyi.device.pojo.DeviceMaintenance; import com.ruoyi.device.service.DeviceMaintenanceService; +import com.ruoyi.system.mapper.UserMapper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.apache.poi.ss.usermodel.HorizontalAlignment; -import org.apache.poi.ss.usermodel.VerticalAlignment; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; -import java.util.Locale; /** * todo: 瀛欐渤婊� @@ -35,51 +26,56 @@ private DeviceMaintenanceService deviceMaintenanceService; @Autowired - private NumberGenerator<DeviceMaintenance> numberGenerator; + private UserMapper userMapper; + /** - * 鏂板璁惧缁存姢淇濆吇 + * 璁惧缁存姢鍒嗛〉鏌ヨ * @param deviceMaintenance * @return */ - @ApiOperation(value = "鏂板璁惧缁存姢淇濆吇") - @PostMapping("/addDeviceMaintenance") - public Result addDeviceMaintenance(@RequestBody DeviceMaintenance deviceMaintenance){ - String year = new SimpleDateFormat("yy", Locale.CHINESE).format(new Date()); - String month = new SimpleDateFormat("MM", Locale.CHINESE).format(new Date()); - String processNumber = numberGenerator.generateNumberWithPrefix(3, "DG-TC-23FM " + month + "-" + year + month, DeviceMaintenance::getDeviceNumber); - deviceMaintenance.setDeviceNumber(processNumber); - return Result.success(deviceMaintenanceService.save(deviceMaintenance)); + @ApiOperation(value = "璁惧缁存姢鍒嗛〉鏌ヨ") + @GetMapping("/selectDeviceMaintenancePage") + public Result selectDeviceMaintenancePage(Page page, DeviceMaintenanceDto deviceMaintenance){ + return Result.success(deviceMaintenanceService.selectDeviceMaintenancePage(page, deviceMaintenance)); } + /** - * 閫氳繃璁惧id鏌ヨ璁惧缁存姢淇濆吇淇℃伅 - * @param deviceId - * @param page - * @param deviceNumber + * 鏂板淇敼璁惧缁存姢淇濆吇 + * @param deviceMaintenance * @return */ - @ApiOperation(value = "閫氳繃璁惧id鏌ヨ璁惧缁存姢淇濆吇淇℃伅") - @GetMapping("/getDeviceMaintenancePage") - public Result getDeviceMaintenancePage(@RequestParam("deviceId") Integer deviceId, Page page, String deviceNumber){ - return Result.success(deviceMaintenanceService.getDeviceMaintenancePage(page, deviceId, deviceNumber)); + @ApiOperation(value = "鏂板淇敼璁惧缁存姢淇濆吇") + @PostMapping("/addDeviceMaintenance") + public Result addDeviceMaintenance(@RequestBody DeviceMaintenance deviceMaintenance){ + if (deviceMaintenance.getDeviceId() == null) { + throw new RuntimeException("缂哄皯璁惧id"); + } + User user = userMapper.selectById(deviceMaintenance.getMaintenanceUserId()); + deviceMaintenance.setMaintenanceUserName(user.getName()); + + return Result.success(deviceMaintenanceService.saveOrUpdate(deviceMaintenance)); } /** - * 鍒犻櫎璁惧缁存姢淇濆吇 + * 鍒犻櫎淇敼璁惧缁存姢淇濆吇 * @param id + * @return */ - @ApiOperation(value = "鏂板璁惧缁存姢淇濆吇") + @ApiOperation(value = "鍒犻櫎淇敼璁惧缁存姢淇濆吇") @DeleteMapping("/deleteDeviceMaintenance") - public void deleteDeviceMaintenance( Integer id) { - deviceMaintenanceService.removeById(id); + public Result deleteDeviceMaintenance(Integer id){ + return Result.success(deviceMaintenanceService.removeById(id)); } - - @ApiOperation(value = "璁惧缁存姢璁板綍瀵煎嚭") - @GetMapping("/exportMaintenanceRecord") - public void exportMaintenanceRecord(@RequestParam("deviceId") Integer deviceId, HttpServletResponse response) throws Exception { - deviceMaintenanceService.exportMaintenanceRecord(deviceId, response); + /** + * 瀵煎嚭璁惧缁存姢淇濆吇 + */ + @ApiOperation("瀵煎嚭璁惧缁存姢淇濆吇") + @GetMapping("/exportDeviceMaintenance") + public void exportDeviceMaintenance(@RequestParam("deviceId") Integer deviceId, HttpServletResponse response) { + deviceMaintenanceService.exportDeviceMaintenance(deviceId, response); } } -- Gitblit v1.9.3