| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.github.xiaoymin.knife4j.core.util.CollectionUtils; |
| | | import com.ruoyi.basic.enums.ApplicationTypeEnum; |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.device.dto.DeviceDefectRecordDto; |
| | |
| | | import com.ruoyi.device.service.DeviceDefectRecordService; |
| | | 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.measuringinstrumentledger.mapper.SparePartsMapper; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.SpareParts; |
| | |
| | | private final IDeviceLedgerService deviceLedgerService; |
| | | private final SparePartsMapper sparePartsMapper; |
| | | private final SparePartsRequisitionRecordService sparePartsRequisitionRecordService; |
| | | private final FileUtil fileUtil; |
| | | |
| | | @Override |
| | | public IPage<DeviceRepairDto> queryPage(Page page, DeviceRepairDto deviceRepairDto) { |
| | | |
| | | return deviceRepairMapper.queryPage(page, deviceRepairDto); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult saveDeviceRepair(DeviceRepair deviceRepair) { |
| | | DeviceLedger byId = deviceLedgerService.getById(deviceRepair.getDeviceLedgerId()); |
| | | deviceRepair.setDeviceName(byId.getDeviceName()); |
| | | deviceRepair.setDeviceModel(byId.getDeviceModel()); |
| | | boolean save = this.save(deviceRepair); |
| | | if (save){ |
| | | return AjaxResult.success(); |
| | | public IPage<DeviceRepairVo> queryPage(Page page, DeviceRepairDto deviceRepairDto) { |
| | | IPage<DeviceRepairVo> pageDto = deviceRepairMapper.queryPage(page, deviceRepairDto); |
| | | for (DeviceRepairVo vo : pageDto.getRecords()) { |
| | | vo.setStorageBlobVOs(fileUtil.getStorageBlobVOsByRecordTypeAndRecordId(RecordTypeEnum.DEVICE_REPAIR, vo.getId())); |
| | | } |
| | | return AjaxResult.error(); |
| | | return pageDto; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult updateDeviceRepair(DeviceRepair deviceRepair) { |
| | | DeviceRepair oldDeviceRepair = this.getById(deviceRepair.getId()); |
| | | public AjaxResult saveDeviceRepair(DeviceRepairDto deviceRepairDto) { |
| | | DeviceLedger byId = deviceLedgerService.getById(deviceRepairDto.getDeviceLedgerId()); |
| | | deviceRepairDto.setDeviceName(byId.getDeviceName()); |
| | | deviceRepairDto.setDeviceModel(byId.getDeviceModel()); |
| | | boolean save = this.save(deviceRepairDto); |
| | | if (save) { |
| | | // 处理图片上传 |
| | | fileUtil.saveStorageAttachmentByRecordTypeAndRecordId("file", RecordTypeEnum.DEVICE_REPAIR, deviceRepairDto.getId(), deviceRepairDto.getStorageBlobDTOs()); |
| | | return AjaxResult.success(); |
| | | } |
| | | return AjaxResult.error("保存失败"); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult updateDeviceRepair(DeviceRepairDto deviceRepairDto) { |
| | | DeviceRepair oldDeviceRepair = this.getById(deviceRepairDto.getId()); |
| | | // 处理备件使用情况 |
| | | if (CollectionUtils.isNotEmpty(deviceRepair.getSparePartsUseList())) { |
| | | if (CollectionUtils.isNotEmpty(deviceRepairDto.getSparePartsUseList())) { |
| | | List<Long> sparePartIds = new ArrayList<>(); |
| | | for (DeviceRepair.SparePartUse sparePartUse : deviceRepair.getSparePartsUseList()) { |
| | | for (DeviceRepairDto.SparePartUse sparePartUse : deviceRepairDto.getSparePartsUseList()) { |
| | | // 获取备件信息 |
| | | SpareParts spareParts = sparePartsMapper.selectById(sparePartUse.getId()); |
| | | if (spareParts != null) { |
| | |
| | | // 创建备件领用记录 |
| | | SparePartsRequisitionRecord record = new SparePartsRequisitionRecord(); |
| | | record.setSourceType(0); // 0 维修 |
| | | record.setSourceId(deviceRepair.getId()); |
| | | record.setSourceId(deviceRepairDto.getId()); |
| | | record.setDeviceLedgerId(oldDeviceRepair.getDeviceLedgerId()); |
| | | record.setSparePartsId(sparePartUse.getId()); |
| | | record.setQuantity(sparePartUse.getQuantity()); |
| | |
| | | } |
| | | // 更新备件IDs字段 |
| | | if (!sparePartIds.isEmpty()) { |
| | | deviceRepair.setSparePartsIds(StringUtils.join(sparePartIds, ",")); |
| | | deviceRepairDto.setSparePartsIds(StringUtils.join(sparePartIds, ",")); |
| | | } |
| | | } |
| | | |
| | | if (this.updateById(deviceRepair)) { |
| | | Long id = deviceRepair.getId(); |
| | | if (this.updateById(deviceRepairDto)) { |
| | | Long id = deviceRepairDto.getId(); |
| | | // |
| | | DeviceDefectRecordDto deviceDefectRecordDto = new DeviceDefectRecordDto(); |
| | | deviceDefectRecordDto.setDeviceLedgerId(id); |
| | |
| | | deviceDefectRecordService.updateByDDR(deviceDefectRecord); |
| | | }); |
| | | } |
| | | // 处理图片上传 |
| | | fileUtil.saveStorageAttachmentByRecordTypeAndRecordId("file", RecordTypeEnum.DEVICE_REPAIR, id, deviceRepairDto.getStorageBlobDTOs()); |
| | | return AjaxResult.success(); |
| | | } |
| | | return AjaxResult.error(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public DeviceRepairDto detailById(Long id) { |
| | | |
| | | return deviceRepairMapper.detailById(id); |
| | | public DeviceRepairVo detailById(Long id) { |
| | | DeviceRepairVo vo = deviceRepairMapper.detailById(id); |
| | | vo.setStorageBlobVOs(fileUtil.getStorageBlobVOsByRecordTypeAndRecordId(RecordTypeEnum.DEVICE_REPAIR, id)); |
| | | return vo; |
| | | } |
| | | |
| | | } |