| | |
| | | import com.ruoyi.device.service.IDeviceMaintenanceService; |
| | | import com.ruoyi.device.vo.DeviceMaintenanceVo; |
| | | import com.ruoyi.device.vo.DeviceRepairVo; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.measuringinstrumentledger.mapper.SparePartsMapper; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.SpareParts; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.SparePartsRecord; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.SparePartsRequisitionRecord; |
| | | import com.ruoyi.measuringinstrumentledger.service.SparePartsRecordService; |
| | | import com.ruoyi.measuringinstrumentledger.service.SparePartsRequisitionRecordService; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | private final DeviceMaintenanceMapper deviceMaintenanceMapper; |
| | | private final SparePartsMapper sparePartsMapper; |
| | | private final SparePartsRequisitionRecordService sparePartsRequisitionRecordService; |
| | | private final SparePartsRecordService sparePartsRecordService; |
| | | private final FileUtil fileUtil; |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<?> saveDeviceRepair(DeviceMaintenanceDto deviceMaintenance) { |
| | | public AjaxResult saveDeviceRepair(DeviceMaintenanceDto deviceMaintenance) { |
| | | boolean save = this.save(deviceMaintenance); |
| | | if (save){ |
| | | // 处理图片上传 |
| | | fileUtil.saveStorageAttachmentByRecordTypeAndRecordId("file", RecordTypeEnum.DEVICE_MAINTENANCE, deviceMaintenance.getId(), deviceMaintenance.getStorageBlobDTOs()); |
| | | return R.ok(); |
| | | return AjaxResult.success(); |
| | | } |
| | | return R.fail(); |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<?> updateDeviceDeviceMaintenance(DeviceMaintenanceDto deviceMaintenance) { |
| | | public AjaxResult updateDeviceDeviceMaintenance(DeviceMaintenanceDto deviceMaintenance) { |
| | | DeviceMaintenance oldDeviceMaintenance = this.getById(deviceMaintenance.getId()); |
| | | // 处理备件使用情况 |
| | | if (com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(deviceMaintenance.getSparePartsUseList())) { |
| | |
| | | record.setSparePartsId(sparePartUse.getId()); |
| | | record.setQuantity(sparePartUse.getQuantity()); |
| | | sparePartsRequisitionRecordService.save(record); |
| | | |
| | | // 追加备件出库流水(3 保养领用) |
| | | SparePartsRecord outRecord = new SparePartsRecord(); |
| | | outRecord.setSparePartsId(sparePartUse.getId()); |
| | | outRecord.setDirection(2); |
| | | outRecord.setQuantity(new BigDecimal(sparePartUse.getQuantity())); |
| | | outRecord.setSourceType(3); |
| | | outRecord.setSourceId(deviceMaintenance.getId()); |
| | | // 保养单没有单号,来源单号用设备名称,流水页才看得出备件用在哪台设备上 |
| | | outRecord.setSourceNo(oldDeviceMaintenance.getDeviceName()); |
| | | sparePartsRecordService.save(outRecord); |
| | | } else { |
| | | return R.fail("备件 " + spareParts.getName() + " 数量不足"); |
| | | return AjaxResult.error("备件 " + spareParts.getName() + " 数量不足"); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (this.updateById(deviceMaintenance)) { |
| | | // 处理图片上传 |
| | | fileUtil.saveStorageAttachmentByRecordTypeAndRecordId("file", RecordTypeEnum.DEVICE_MAINTENANCE, deviceMaintenance.getId(), deviceMaintenance.getStorageBlobDTOs()); |
| | | return R.ok(); |
| | | return AjaxResult.success(); |
| | | } |
| | | return R.fail(); |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | @Override |