| | |
| | | import com.ruoyi.device.dto.DeviceMaintenanceDto; |
| | | import com.ruoyi.device.execl.DeviceMaintenanceExeclDto; |
| | | import com.ruoyi.device.mapper.DeviceMaintenanceMapper; |
| | | import com.ruoyi.device.pojo.DeviceLedger; |
| | | import com.ruoyi.device.pojo.DeviceMaintenance; |
| | | import com.ruoyi.device.service.IDeviceLedgerService; |
| | | import com.ruoyi.device.service.IDeviceMaintenanceService; |
| | | import com.ruoyi.device.vo.DeviceMaintenanceVo; |
| | | import com.ruoyi.device.vo.DeviceRepairVo; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.measuringinstrumentledger.mapper.SparePartsMapper; |
| | | import com.ruoyi.project.system.service.ISysNoticeService; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.SpareParts; |
| | | import com.ruoyi.measuringinstrumentledger.pojo.SparePartsRequisitionRecord; |
| | | import com.ruoyi.measuringinstrumentledger.service.SparePartsRequisitionRecordService; |
| | |
| | | public class DeviceMaintenanceServiceImpl extends ServiceImpl<DeviceMaintenanceMapper, DeviceMaintenance> implements IDeviceMaintenanceService { |
| | | |
| | | private final DeviceMaintenanceMapper deviceMaintenanceMapper; |
| | | private final IDeviceLedgerService deviceLedgerService; |
| | | private final SparePartsMapper sparePartsMapper; |
| | | private final SparePartsRequisitionRecordService sparePartsRequisitionRecordService; |
| | | private final FileUtil fileUtil; |
| | | private final ISysNoticeService sysNoticeService; |
| | | |
| | | @Override |
| | | public IPage<DeviceMaintenanceDto> queryPage(Page page, DeviceMaintenanceDto deviceMaintenanceDto) { |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult saveDeviceRepair(DeviceMaintenanceDto deviceMaintenance) { |
| | | DeviceLedger byId = deviceLedgerService.getById(deviceMaintenance.getDeviceLedgerId()); |
| | | if (byId != null) { |
| | | deviceMaintenance.setDeviceName(byId.getDeviceName()); |
| | | deviceMaintenance.setDeviceModel(byId.getDeviceModel()); |
| | | deviceMaintenance.setAreaId(byId.getAreaId()); |
| | | } |
| | | boolean save = this.save(deviceMaintenance); |
| | | if (save){ |
| | | // 处理图片上传 |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult updateDeviceDeviceMaintenance(DeviceMaintenanceDto deviceMaintenance) { |
| | | DeviceMaintenance oldDeviceMaintenance = this.getById(deviceMaintenance.getId()); |
| | | Long effectiveDeviceLedgerId = deviceMaintenance.getDeviceLedgerId() != null |
| | | ? deviceMaintenance.getDeviceLedgerId() |
| | | : oldDeviceMaintenance.getDeviceLedgerId(); |
| | | DeviceLedger byId = deviceLedgerService.getById(effectiveDeviceLedgerId); |
| | | if (byId != null) { |
| | | deviceMaintenance.setDeviceName(byId.getDeviceName()); |
| | | deviceMaintenance.setDeviceModel(byId.getDeviceModel()); |
| | | deviceMaintenance.setAreaId(byId.getAreaId()); |
| | | } |
| | | // 处理备件使用情况 |
| | | if (com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(deviceMaintenance.getSparePartsUseList())) { |
| | | List<Long> sparePartIds = new ArrayList<>(); |
| | |
| | | sparePartsMapper.updateById(spareParts); |
| | | sparePartIds.add(sparePartUse.getId()); |
| | | |
| | | // 库存预警通知 |
| | | if (spareParts.getWarnNum() != null && spareParts.getNotifyPersonId() != null |
| | | && spareParts.getQuantity().compareTo(spareParts.getWarnNum()) < 0) { |
| | | sysNoticeService.simpleNoticeByUser( |
| | | "备件库存预警", |
| | | "备件【" + spareParts.getName() + "】当前库存(" + spareParts.getQuantity() |
| | | + ")已低于预警数量(" + spareParts.getWarnNum() + "),请及时采购补充。", |
| | | List.of(spareParts.getNotifyPersonId()), |
| | | "/equipmentManagement/spareParts" |
| | | ); |
| | | } |
| | | |
| | | // 创建备件领用记录 |
| | | SparePartsRequisitionRecord record = new SparePartsRequisitionRecord(); |
| | | record.setSourceType(1); // 1 保养 |