From 3eb25a0bb9b4bd0b914cf2cba60ecb8cc404fac9 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期二, 10 六月 2025 16:01:56 +0800 Subject: [PATCH] 任务取消功能优化 --- rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java | 49 +++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 41 insertions(+), 8 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 9ad72a4..aaa683a 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 @@ -79,6 +79,10 @@ private LocItemWorkingService locItemWorkingService; @Autowired private WcsService wcsService; + @Autowired + private OutStockService outStockService; + @Autowired + private OutStockItemService outStockItemService; @Override @Transactional(rollbackFor = Exception.class) @@ -519,6 +523,7 @@ /** * 浠诲姟瀹屾垚鍚庯紝鍒ゆ柇娣卞簱浣嶆槸鍚︿负绌猴紝濡傛灉涓虹┖鐢熸垚绉诲簱浠诲姟 + * * @param loginUserId * @param curLoc */ @@ -753,8 +758,6 @@ if (!this.updateById(outTask)) { throw new CoolException("浠诲姟淇℃伅淇敼澶辫触锛侊紒"); } - } else { -// throw new CoolException("鏃犳硶鐢熸垚鏂扮殑绉诲簱浠诲姟锛屽彇娑堝け璐ワ紒锛�"); } } @@ -787,17 +790,47 @@ if (!taskItems.isEmpty()) { for (TaskItem item : taskItems) { if (item.getOrderType().equals(OrderType.ORDER_OUT.type)) { + Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc())); + if (Objects.isNull(loc)) { + throw new CoolException("鏁版嵁閿欒锛氬簱浣嶄俊鎭笉瀛樺湪锛侊紒"); + } + + loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type).setBarcode(task.getBarcode()).setUpdateBy(loginUserId).setUpdateTime(new Date()); + if (!locService.updateById(loc)) { + throw new CoolException("搴撲綅淇℃伅淇敼澶辫触锛侊紒"); + } + //鍑哄簱 if (item.getWkType().equals(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type))) { //搴撳瓨鍑哄簱 - Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getId, item.getSourceId())); - if (Objects.isNull(loc)) { - throw new CoolException("鏁版嵁閿欒锛氬簱浣嶄俊鎭笉瀛樺湪锛侊紒"); + } else if (item.getWkType().equals(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_OTHER.type))) { + //鍏跺畠鍑哄簱 + } else { + //鍑哄簱鍗曞嚭搴� + AsnOrder asnOrder = outStockService.getById(item.getSourceId()); + if (Objects.isNull(asnOrder)) { + throw new CoolException("鏁版嵁閿欒锛氬崟鎹凡涓嶅瓨鍦紒锛�"); + } + Double workQty = Math.round((asnOrder.getWorkQty() - item.getAnfme()) * 10000) / 10000.0; + + asnOrder.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_INIT.val) + .setWorkQty(workQty.compareTo(0.00) > 0 ? workQty : 0.00 ) + .setUpdateBy(loginUserId) + .setUpdateTime(new Date()); + if (!outStockService.updateById(asnOrder)) { + throw new CoolException("鍘熷崟鎹姸鎬佷慨鏀瑰け璐ワ紒锛�"); } - loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type).setBarcode(task.getBarcode()).setUpdateBy(loginUserId).setUpdateTime(new Date()); - if (!locService.updateById(loc)) { - throw new CoolException("搴撲綅淇℃伅淇敼澶辫触锛侊紒"); + AsnOrderItem orderItem = outStockItemService.getById(item.getSource()); + if (Objects.isNull(orderItem)) { + throw new CoolException("鏁版嵁閿欒锛氬崟鎹槑缁嗗凡涓嶅瓨鍦紒锛�"); + } + + Double workItmQty = Math.round((orderItem.getWorkQty() - item.getAnfme()) * 10000) / 10000.0; + orderItem.setWorkQty(workItmQty); + + if (!outStockItemService.updateById(orderItem)) { + throw new CoolException("鍘熷崟鎹槑缁嗕慨鏀瑰け璐ワ紒锛�"); } } } else { -- Gitblit v1.9.1