| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | 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.DeviceMaintenancePlanService; |
| | | import com.ruoyi.device.service.DeviceMaintenanceService; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @Autowired |
| | | private DeviceMaintenanceService deviceMaintenanceService; |
| | | |
| | | @Autowired |
| | | private UserMapper userMapper; |
| | | |
| | | @Autowired |
| | | private DeviceMaintenancePlanService deviceMaintenancePlanService; |
| | | |
| | | |
| | | /** |
| | |
| | | @Operation(summary = "新增修改设备维护保养") |
| | | @PostMapping("/addDeviceMaintenance") |
| | | public Result addDeviceMaintenance(@RequestBody DeviceMaintenance deviceMaintenance){ |
| | | if (deviceMaintenance.getDeviceId() == null) { |
| | | throw new RuntimeException("缺少设备id"); |
| | | return Result.success(deviceMaintenanceService.saveDeviceMaintenance(deviceMaintenance)); |
| | | } |
| | | User user = userMapper.selectById(deviceMaintenance.getMaintenanceUserId()); |
| | | deviceMaintenance.setMaintenanceUserName(user.getName()); |
| | | |
| | | boolean saved = deviceMaintenanceService.saveOrUpdate(deviceMaintenance); |
| | | // 保养完成后,把设备档案的最近/下次保养日期滚动到本轮 |
| | | if (saved && deviceMaintenance.getMaintenanceDate() != null) { |
| | | deviceMaintenancePlanService.updateDeviceMaintenanceDate(deviceMaintenance.getDeviceId(), deviceMaintenance.getMaintenanceDate()); |
| | | } |
| | | return Result.success(saved); |
| | | /** |
| | | * 审核保养记录 |
| | | */ |
| | | @Operation(summary = "审核保养记录") |
| | | @PostMapping("/reviewDeviceMaintenance") |
| | | public Result reviewDeviceMaintenance(@RequestBody DeviceMaintenanceDto deviceMaintenanceDto) { |
| | | return Result.success(deviceMaintenanceService.reviewDeviceMaintenance(deviceMaintenanceDto)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Operation(summary = "删除修改设备维护保养") |
| | | @DeleteMapping("/deleteDeviceMaintenance") |
| | | public Result deleteDeviceMaintenance(Integer id){ |
| | | return Result.success(deviceMaintenanceService.removeById(id)); |
| | | return Result.success(deviceMaintenanceService.deleteDeviceMaintenance(id)); |
| | | } |
| | | |
| | | /** |