| | |
| | | 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: 孙河滨 |
| | |
| | | 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); |
| | | } |
| | | |
| | | } |