From 6e2135203258c92dfcf2df05cdc17ac0c85cb236 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期六, 19 七月 2025 15:12:14 +0800 Subject: [PATCH] 盘点差异单功能优化 --- rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java | 94 +++++++++++++++++++++++++++++++--------------- 1 files changed, 63 insertions(+), 31 deletions(-) diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java index 2e66a96..7ed0dfb 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java @@ -84,6 +84,11 @@ @Autowired private OutStockItemService outStockItemService; + @Autowired + private CheckOrderItemService checkOrderItemService; + @Autowired + private CheckOrderService checkOrderService; + @Override @Transactional(rollbackFor = Exception.class) public synchronized R generateAGVTasks(WaitPakin pakins, String locCode, String orgSta, Long loginUserId) { @@ -681,7 +686,7 @@ LocItemWorking locWorking = locItemWorkingService.getOne(new LambdaQueryWrapper<LocItemWorking>() .eq(LocItemWorking::getTaskId, taskItem.getTaskId()) .eq(StringUtils.isNotBlank(taskItem.getBatch()), LocItemWorking::getBatch, taskItem.getBatch()) - .eq(StringUtils.isNotBlank(taskItem.getFieldsIndex()), LocItemWorking::getFieldsIndex, taskItem.getFieldsIndex()) +// .eq(StringUtils.isNotBlank(taskItem.getFieldsIndex()), LocItemWorking::getFieldsIndex, taskItem.getFieldsIndex()) .eq(LocItemWorking::getMatnrId, taskItem.getMatnrId())); if (Objects.isNull(locWorking)) { throw new CoolException("鏁版嵁閿欒锛屼綔涓氫腑搴撳瓨鏁版嵁涓㈠け锛侊紒"); @@ -742,7 +747,9 @@ .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type))) { throw new CoolException("婧愬簱浣嶇姸鎬佷慨鏀瑰け璐ワ紒锛�"); } - if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc()).set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type))) { + if (!locService.update(new LambdaUpdateWrapper<Loc>() + .eq(Loc::getCode, task.getTargLoc()) + .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type))) { throw new CoolException("绉诲簱鐩爣搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�"); } @@ -762,7 +769,28 @@ } } } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) { - + List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getTaskId, Arrays.asList(ids))); + if (!taskItems.isEmpty()) { + taskItems.forEach(taskItem -> { + if (!checkOrderItemService.update(new LambdaUpdateWrapper<WkOrderItem>() + .eq(WkOrderItem::getId, taskItem.getOrderItemId()) + .setSql("work_qty = work_qty - " + taskItem.getAnfme()))) { + throw new CoolException("鏄庣粏鏁伴噺淇敼澶辫触锛侊紒"); + } + + if (!checkOrderService.update(new LambdaUpdateWrapper<WkOrder>() + .eq(WkOrder::getId, taskItem.getOrderId()) + .setSql("work_qty = work_qty - " + taskItem.getAnfme()))) { + throw new CoolException("鐩樼偣鍗曟墽琛屾暟閲忎慨鏀瑰け璐ワ紒锛�"); + } + }); + } + + if (!locService.update(new LambdaUpdateWrapper<Loc>() + .eq(Loc::getCode, task.getOrgLoc()) + .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type))) { + throw new CoolException("婧愬簱浣嶇姸鎬佷慨鏀瑰け璐ワ紒锛�"); + } } if (!Objects.isNull(task.getWarehType()) && task.getWarehType().equals(WarehType.WAREHOUSE_TYPE_AGV.val)) { @@ -797,7 +825,10 @@ if (Objects.isNull(loc)) { throw new CoolException("鏁版嵁閿欒锛氬簱浣嶄俊鎭笉瀛樺湪锛侊紒"); } - loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type).setBarcode(task.getBarcode()).setUpdateBy(loginUserId).setUpdateTime(new Date()); + loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type) + .setBarcode(task.getBarcode()) + .setUpdateBy(loginUserId) + .setUpdateTime(new Date()); if (!locService.updateById(loc)) { throw new CoolException("搴撲綅淇℃伅淇敼澶辫触锛侊紒"); } @@ -868,7 +899,8 @@ } Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTaskType() < TaskStsType.UPDATED_IN.id ? task.getTargLoc() : task.getOrgLoc())); - if (null != loc && (loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type) || loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type))) { + if (null != loc && (loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type) + || loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type))) { loc.setUseStatus(LocStsType.LOC_STS_TYPE_O.type); if (!locService.updateById(loc)) { throw new CoolException("鏇存柊搴撲綅鐘舵�佸け璐ワ紒锛�"); @@ -951,7 +983,7 @@ LocItemWorking locWorking = locItemWorkingService.getOne(new LambdaQueryWrapper<LocItemWorking>() .eq(LocItemWorking::getTaskId, taskItem.getTaskId()) .eq(StringUtils.isNotBlank(taskItem.getBatch()), LocItemWorking::getBatch, taskItem.getBatch()) - .eq(StringUtils.isNotBlank(taskItem.getFieldsIndex()), LocItemWorking::getFieldsIndex, taskItem.getFieldsIndex()) +// .eq(StringUtils.isNotBlank(taskItem.getFieldsIndex()), LocItemWorking::getFieldsIndex, taskItem.getFieldsIndex()) .eq(LocItemWorking::getMatnrId, taskItem.getMatnrId())); if (Objects.isNull(locWorking)) { throw new CoolException("鏁版嵁閿欒锛屼綔涓氫腑搴撳瓨鏁版嵁涓㈠け锛侊紒"); @@ -1051,32 +1083,32 @@ * */ List<TaskItem> list = listMap.get(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type)); if (Objects.isNull(list) || list.isEmpty()) { - Map<Long, List<TaskItem>> maps = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getSource)); - maps.keySet().forEach(key -> { - if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val)) { - WaveItem waveItem = waveItemService.getById(key); - if (Objects.isNull(waveItem)) { - throw new CoolException("娉㈡鏄庣粏涓嶅瓨鍦紒锛�"); - } - try { - saveOutStockItem(maps.get(key), null, waveItem, loginUserId); - } catch (Exception e) { - throw new CoolException(e.getMessage()); - } - } else if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_ORDER_TYPE.val)) { - WkOrderItem orderItem = asnOrderItemService.getById(key); - if (Objects.isNull(orderItem)) { - throw new CoolException("鍗曟嵁鏄庣粏涓嶅瓨鍦紒锛�"); - } - try { - saveOutStockItem(maps.get(key), orderItem, null, loginUserId); - } catch (Exception e) { - throw new CoolException(e.getMessage()); - } - } else { + Map<Long, List<TaskItem>> maps = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getSource)); + maps.keySet().forEach(key -> { + if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val)) { + WaveItem waveItem = waveItemService.getById(key); + if (Objects.isNull(waveItem)) { + throw new CoolException("娉㈡鏄庣粏涓嶅瓨鍦紒锛�"); + } + try { + saveOutStockItem(maps.get(key), null, waveItem, loginUserId); + } catch (Exception e) { + throw new CoolException(e.getMessage()); + } + } else if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_ORDER_TYPE.val) || task.getResource().equals(TaskResouceType.TASK_RESOUCE_CHECK_TYPE.val)) { + WkOrderItem orderItem = asnOrderItemService.getById(key); + if (Objects.isNull(orderItem)) { + throw new CoolException("鍗曟嵁鏄庣粏涓嶅瓨鍦紒锛�"); + } + try { + saveOutStockItem(maps.get(key), orderItem, null, loginUserId); + } catch (Exception e) { + throw new CoolException(e.getMessage()); + } + } else { - } - }); + } + }); } else { try { saveOutStockItem(taskItems, null, null, loginUserId); -- Gitblit v1.9.1