From 1aa6e5963e5c4eca765924e9b2b094e6e2c525b3 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期二, 10 六月 2025 15:38:33 +0800
Subject: [PATCH] 添加出库单据任务取消功能

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java |   48 ++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 42 insertions(+), 6 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 f0caa13..ae66da5 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
      */
@@ -785,17 +790,48 @@
             if (!taskItems.isEmpty()) {
                 for (TaskItem item : taskItems) {
                     if (item.getOrderType().equals(OrderType.ORDER_OUT.type)) {
+
+                        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getId, item.getSourceId()));
+                        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