| | |
| | | import com.ruoyi.device.service.IDeviceLedgerService; |
| | | import com.ruoyi.device.service.IDeviceRepairService; |
| | | import com.ruoyi.device.vo.DeviceRepairVo; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.measuringinstrumentledger.mapper.SparePartsMapper; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.SpareParts; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.SparePartsRequisitionRecord; |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult saveDeviceRepair(DeviceRepairDto deviceRepairDto) { |
| | | public R<?> saveDeviceRepair(DeviceRepairDto deviceRepairDto) { |
| | | DeviceLedger byId = deviceLedgerService.getById(deviceRepairDto.getDeviceLedgerId()); |
| | | deviceRepairDto.setDeviceName(byId.getDeviceName()); |
| | | deviceRepairDto.setDeviceModel(byId.getDeviceModel()); |
| | |
| | | if (save) { |
| | | // 处理图片上传 |
| | | fileUtil.saveStorageAttachmentByRecordTypeAndRecordId("file", RecordTypeEnum.DEVICE_REPAIR, deviceRepairDto.getId(), deviceRepairDto.getStorageBlobDTOs()); |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | return AjaxResult.error("保存失败"); |
| | | return R.fail("保存失败"); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult updateDeviceRepair(DeviceRepairDto deviceRepairDto) { |
| | | public R<?> updateDeviceRepair(DeviceRepairDto deviceRepairDto) { |
| | | DeviceRepair oldDeviceRepair = this.getById(deviceRepairDto.getId()); |
| | | if (oldDeviceRepair == null) { |
| | | return AjaxResult.error("报修记录不存在"); |
| | | return R.fail("报修记录不存在"); |
| | | } |
| | | if (deviceRepairDto.getStatus() != null |
| | | && deviceRepairDto.getStatus() == STATUS_COMPLETED |
| | | && (oldDeviceRepair.getStatus() == null |
| | | || oldDeviceRepair.getStatus() != STATUS_COMPLETED)) { |
| | | return AjaxResult.error("请先提交验收审批,验收通过后才可完结"); |
| | | return R.fail("请先提交验收审批,验收通过后才可完结"); |
| | | } |
| | | // 处理备件使用情况 |
| | | if (CollectionUtils.isNotEmpty(deviceRepairDto.getSparePartsUseList())) { |
| | |
| | | record.setQuantity(sparePartUse.getQuantity()); |
| | | sparePartsRequisitionRecordService.save(record); |
| | | } else { |
| | | return AjaxResult.error("备件 " + spareParts.getName() + " 数量不足"); |
| | | return R.fail("备件 " + spareParts.getName() + " 数量不足"); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (deviceRepairDto.getStorageBlobDTOs() != null) { |
| | | fileUtil.saveStorageAttachmentByRecordTypeAndRecordId("file", RecordTypeEnum.DEVICE_REPAIR, id, deviceRepairDto.getStorageBlobDTOs()); |
| | | } |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | return AjaxResult.error(); |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult confirmRepair(DeviceRepairDto deviceRepairDto) { |
| | | public R<?> confirmRepair(DeviceRepairDto deviceRepairDto) { |
| | | DeviceRepair oldDeviceRepair = this.getById(deviceRepairDto.getId()); |
| | | if (oldDeviceRepair == null) { |
| | | return AjaxResult.error("报修记录不存在"); |
| | | return R.fail("报修记录不存在"); |
| | | } |
| | | if (oldDeviceRepair.getStatus() != null && oldDeviceRepair.getStatus() == STATUS_COMPLETED) { |
| | | return AjaxResult.error("该报修已完结,不能重复确认维修"); |
| | | return R.fail("该报修已完结,不能重复确认维修"); |
| | | } |
| | | if (oldDeviceRepair.getStatus() != null && oldDeviceRepair.getStatus() == STATUS_PENDING_ACCEPTANCE) { |
| | | return AjaxResult.error("该报修已提交验收审批"); |
| | | return R.fail("该报修已提交验收审批"); |
| | | } |
| | | deviceRepairDto.setStatus(STATUS_PENDING_ACCEPTANCE); |
| | | return updateDeviceRepair(deviceRepairDto); |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult approveRepairAcceptance(DeviceRepairDto deviceRepairDto) { |
| | | public R<?> approveRepairAcceptance(DeviceRepairDto deviceRepairDto) { |
| | | if (deviceRepairDto.getId() == null) { |
| | | return AjaxResult.error("报修记录id不能为空"); |
| | | return R.fail("报修记录id不能为空"); |
| | | } |
| | | DeviceRepair oldDeviceRepair = this.getById(deviceRepairDto.getId()); |
| | | if (oldDeviceRepair == null) { |
| | | return AjaxResult.error("报修记录不存在"); |
| | | return R.fail("报修记录不存在"); |
| | | } |
| | | if (oldDeviceRepair.getStatus() == null || oldDeviceRepair.getStatus() != STATUS_PENDING_ACCEPTANCE) { |
| | | return AjaxResult.error("该报修未进入待验收状态,不能审批"); |
| | | return R.fail("该报修未进入待验收状态,不能审批"); |
| | | } |
| | | if (StringUtils.isBlank(deviceRepairDto.getAcceptanceName())) { |
| | | return AjaxResult.error("验收人不能为空"); |
| | | return R.fail("验收人不能为空"); |
| | | } |
| | | if (deviceRepairDto.getAcceptanceTime() == null) { |
| | | return AjaxResult.error("验收时间不能为空"); |
| | | return R.fail("验收时间不能为空"); |
| | | } |
| | | if (StringUtils.isBlank(deviceRepairDto.getAcceptanceRemark())) { |
| | | return AjaxResult.error("验收备注不能为空"); |
| | | return R.fail("验收备注不能为空"); |
| | | } |
| | | |
| | | DeviceRepair update = new DeviceRepair(); |
| | |
| | | update.setAcceptanceRemark(deviceRepairDto.getAcceptanceRemark()); |
| | | update.setStatus(STATUS_COMPLETED); |
| | | if (this.updateById(update)) { |
| | | return AjaxResult.success(); |
| | | return R.ok(); |
| | | } |
| | | return AjaxResult.error("验收审批失败"); |
| | | return R.fail("验收审批失败"); |
| | | } |
| | | |
| | | @Override |