| | |
| | | private WaveService waveService; |
| | | @Autowired |
| | | private BasStationService basStationService; |
| | | @Autowired |
| | | private MatnrService matnrService; |
| | | |
| | | /** 入库/出库保存前:若规格或型号为空则从物料带出 */ |
| | | private void fillSpecModelFromMatnr(LocItem item) { |
| | | if (item == null || item.getMatnrId() == null) { |
| | | return; |
| | | } |
| | | if (StringUtils.isNotBlank(item.getSpec()) && StringUtils.isNotBlank(item.getModel())) { |
| | | return; |
| | | } |
| | | Matnr matnr = matnrService.getById(item.getMatnrId()); |
| | | if (matnr == null) { |
| | | return; |
| | | } |
| | | if (StringUtils.isBlank(item.getSpec())) { |
| | | item.setSpec(matnr.getSpec()); |
| | | } |
| | | if (StringUtils.isBlank(item.getModel())) { |
| | | item.setModel(matnr.getModel()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean save(LocItem entity) { |
| | | fillSpecModelFromMatnr(entity); |
| | | return super.save(entity); |
| | | } |
| | | |
| | | @Override |
| | | public boolean saveBatch(Collection<LocItem> entityList) { |
| | | if (entityList != null) { |
| | | entityList.forEach(this::fillSpecModelFromMatnr); |
| | | } |
| | | return super.saveBatch(entityList); |
| | | } |
| | | |
| | | @Override |
| | | public boolean saveBatch(Collection<LocItem> entityList, int batchSize) { |
| | | if (entityList != null) { |
| | | entityList.forEach(this::fillSpecModelFromMatnr); |
| | | } |
| | | return super.saveBatch(entityList, batchSize); |
| | | } |
| | | |
| | | @Override |
| | | public void fillSpecModelFromMatnrForRecords(List<LocItem> records) { |
| | | if (records == null || records.isEmpty()) { |
| | | return; |
| | | } |
| | | Set<Long> matnrIds = new HashSet<>(); |
| | | for (LocItem r : records) { |
| | | if (r.getMatnrId() != null && (StringUtils.isBlank(r.getSpec()) || StringUtils.isBlank(r.getModel()))) { |
| | | matnrIds.add(r.getMatnrId()); |
| | | } |
| | | } |
| | | if (matnrIds.isEmpty()) { |
| | | return; |
| | | } |
| | | Map<Long, Matnr> matnrMap = matnrService.listByIds(matnrIds).stream() |
| | | .collect(Collectors.toMap(Matnr::getId, m -> m)); |
| | | for (LocItem r : records) { |
| | | if (r.getMatnrId() == null) { |
| | | continue; |
| | | } |
| | | Matnr m = matnrMap.get(r.getMatnrId()); |
| | | if (m == null) { |
| | | continue; |
| | | } |
| | | if (StringUtils.isBlank(r.getSpec())) { |
| | | r.setSpec(m.getSpec()); |
| | | } |
| | | if (StringUtils.isBlank(r.getModel())) { |
| | | r.setModel(m.getModel()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 库存出库生成出库任务 |
| | |
| | | if (barcodeToUse == null && !existTasks.isEmpty()) { |
| | | barcodeToUse = existTasks.get(0).getBarcode(); |
| | | if (StringUtils.isNotBlank(barcodeToUse)) { |
| | | locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getId, loc.getId()) |
| | | .set(Loc::getBarcode, barcodeToUse).set(Loc::getUpdateBy, loginUserId).set(Loc::getUpdateTime, new Date())); |
| | | Task refTask = existTasks.get(0); |
| | | LambdaUpdateWrapper<Loc> locUw = new LambdaUpdateWrapper<Loc>().eq(Loc::getId, loc.getId()) |
| | | .set(Loc::getBarcode, barcodeToUse) |
| | | .set(Loc::getUpdateBy, loginUserId) |
| | | .set(Loc::getUpdateTime, new Date()); |
| | | if (refTask.getWeight() != null) { |
| | | locUw.set(Loc::getWeight, refTask.getWeight()); |
| | | } |
| | | locService.update(locUw); |
| | | } |
| | | } |
| | | if (barcodeToUse == null) { |
| | |
| | | throw new CoolException("目标库位不存在!!"); |
| | | } |
| | | |
| | | targetLoc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type); |
| | | targetLoc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type) |
| | | .setWeight(orgLoc.getWeight()); |
| | | |
| | | if (!locService.updateById(targetLoc)) { |
| | | throw new CoolException("目标库位预约失败!!"); |