From 03f63637e706283f1a95b7d0d6d631901ae359b2 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期一, 21 七月 2025 13:24:00 +0800 Subject: [PATCH] 盘点单功能优化 --- rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java | 108 +++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 78 insertions(+), 30 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 6577655..a9b1461 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 @@ -83,6 +83,14 @@ private OutStockService outStockService; @Autowired private OutStockItemService outStockItemService; + @Autowired + private CheckOrderItemService checkOrderItemService; + @Autowired + private CheckOrderService checkOrderService; + @Autowired + private CheckDiffService checkDiffService; + @Autowired + private CheckDiffItemService checkDiffItemService; @Override @Transactional(rollbackFor = Exception.class) @@ -681,7 +689,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 +750,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("绉诲簱鐩爣搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�"); } @@ -761,7 +771,41 @@ throw new CoolException("浠诲姟淇℃伅淇敼澶辫触锛侊紒"); } } + } 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("鐩樼偣鍗曟墽琛屾暟閲忎慨鏀瑰け璐ワ紒锛�"); + } + + List<CheckDiffItem> diffItems = checkDiffItemService + .list(new LambdaQueryWrapper<CheckDiffItem>() + .eq(CheckDiffItem::getTaskItemId, taskItem.getTaskId())); + if (!diffItems.isEmpty()) { + CheckDiffItem item = diffItems.stream().findFirst().get(); + List<CheckDiffItem> items = checkDiffItemService.list(new LambdaQueryWrapper<CheckDiffItem>() + .eq(CheckDiffItem::getId, item.getCheckId())); + if (items.isEmpty()) { + checkDiffService.removeById(item.getCheckId()); + } + } + }); + } + + 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)) { @@ -796,7 +840,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("搴撲綅淇℃伅淇敼澶辫触锛侊紒"); } @@ -867,7 +914,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("鏇存柊搴撲綅鐘舵�佸け璐ワ紒锛�"); @@ -950,7 +998,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("鏁版嵁閿欒锛屼綔涓氫腑搴撳瓨鏁版嵁涓㈠け锛侊紒"); @@ -1050,32 +1098,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