From 3210698902c4e0f3e6f1433d24e62923fbfa794d Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期三, 28 五月 2025 12:59:42 +0800
Subject: [PATCH] 组托IO类型优化

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java |   66 ++++++++++++++-------------------
 1 files changed, 28 insertions(+), 38 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 f62c67a..9c2cab2 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
@@ -82,10 +82,9 @@
             throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
         }
         /**鑾峰彇缁勬嫋*/
-//        List<Long> ids = pakins.stream().map(WaitPakin::getId).collect(Collectors.toList());
         List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
                 .in(WaitPakin::getId, pakins.getId())
-                .eq(WaitPakin::getIoStatus, Short.parseShort(PakinIOStatus.PAKIN_IO_STATUS_DONE.val)));
+                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
         if (waitPakins.isEmpty()) {
             throw new CoolException("璇锋鏌ョ粍鎵樼姸鎬佹槸鍚﹀畬鎴愶紒锛�");
         }
@@ -105,7 +104,7 @@
             task.setTaskCode(ruleCode)
                     .setTaskStatus(TaskStsType.GENERATE_IN.id)
                     .setTaskType(TaskType.TASK_TYPE_IN.type)
-                    .setWarehType(WarehType.WAREHOUSE_TYPE_AGV.id)
+                    .setWarehType(WarehType.WAREHOUSE_TYPE_AGV.val)
                     .setTargLoc(targetLoc)
                     .setOrgSite(orgSta)
                     .setBarcode(pakin.getBarcode())
@@ -170,7 +169,7 @@
         /**鑾峰彇缁勬嫋*/
         List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
                 .in(WaitPakin::getId, pakins.getId())
-                .eq(WaitPakin::getIoStatus, Short.parseShort(PakinIOStatus.PAKIN_IO_STATUS_DONE.val)));
+                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
         if (waitPakins.isEmpty()) {
             throw new CoolException("璇锋鏌ョ粍鎵樼姸鎬佹槸鍚﹀畬鎴愶紒锛�");
         }
@@ -190,7 +189,7 @@
             task.setTaskCode(ruleCode)
                     .setTaskStatus(TaskStsType.COMPLETE_IN.id)
                     .setTaskType(TaskType.TASK_TYPE_IN.type)
-                    .setWarehType(WarehType.WAREHOUSE_TYPE_PLAT.id)
+                    .setWarehType(WarehType.WAREHOUSE_TYPE_PLAT.val)
                     .setTargLoc(targetLoc)
                     .setBarcode(pakin.getBarcode())
                     .setCreateBy(loginUserId)
@@ -277,7 +276,7 @@
         List<Long> ids = waitPakin.getWaitPakins().stream().map(WaitPakin::getId).collect(Collectors.toList());
         List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
                 .in(WaitPakin::getId, ids)
-                .eq(WaitPakin::getIoStatus, Short.parseShort(PakinIOStatus.PAKIN_IO_STATUS_DONE.val)));
+                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
         if (waitPakins.isEmpty()) {
             throw new CoolException("璇锋鏌ョ粍鎷栫姸鎬佹槸鍚﹀畬鎴愶紒锛�");
         }
@@ -426,23 +425,22 @@
         }
 
         List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
-        if (taskItems.isEmpty()) {
-            throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦紒锛�");
+
+        if (!taskItems.isEmpty()) {
+            //绉诲簱鏈夊彲鑳芥槸绌烘澘
+            try {
+                //鏇存柊搴撲綅鏄庣粏
+                saveLocItem(taskItems, task.getId());
+            } catch (Exception e) {
+                throw new CoolException("搴撲綅鏄庣粏鏇存柊澶辫触锛侊紒");
+            }
+
+            if (!locItemService.remove(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocCode, task.getOrgLoc()))) {
+                throw new CoolException("婧愬簱浣嶆槑缁嗗垹闄ゅけ璐ワ紒");
+            }
+
         }
-        try {
-            //鏇存柊搴撲綅鏄庣粏
-            saveLocItem(taskItems, task.getId());
-        } catch (Exception e) {
-            throw new CoolException("搴撲綅鏄庣粏鏇存柊澶辫触锛侊紒");
-        }
-//        /**瀵逛换鍔℃槑缁嗘寜缁勬嫋鏄庣粏杩涜鍒嗙粍*/
-//        try {
-//            //淇濆瓨搴撳瓨鏄庣粏
-//            saveStockItems(taskItems, null, null, pakinItem.getWkType(), pakinItem.getType());
-//        } catch (Exception e) {
-//            log.error("<UNK>", e);
-//            throw new CoolException(e.getMessage());
-//        }
+
         /**淇敼搴撲綅鐘舵�佷负F.鍦ㄥ簱*/
         if (!locService.update(new LambdaUpdateWrapper<Loc>()
                         .set(Loc::getBarcode, task.getBarcode())
@@ -457,9 +455,6 @@
             throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
         }
 
-        if (!locItemService.remove(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocCode, task.getOrgLoc()))) {
-            throw new CoolException("婧愬簱浣嶆槑缁嗗垹闄ゅけ璐ワ紒");
-        }
 
         if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId()).set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) {
             throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
@@ -587,17 +582,15 @@
                     throw new CoolException("鏇存柊缁勬墭鐘舵�佸け璐ワ紒锛�");
                 }
             }
-            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))) {
 
+            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))) {
                 loc.setUseStatus(LocStsType.LOC_STS_TYPE_O.type);
                 if (!locService.updateById(loc)) {
                     throw new CoolException("鏇存柊搴撲綅鐘舵�佸け璐ワ紒锛�");
                 }
             }
-            if (!Objects.isNull(task.getWarehType()) && task.getWarehType().equals(WarehType.WAREHOUSE_TYPE_AGV.id)) {
+            if (!Objects.isNull(task.getWarehType()) && task.getWarehType().equals(WarehType.WAREHOUSE_TYPE_AGV.val)) {
                 BasStation basStation = null;
                 if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
                     basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
@@ -612,8 +605,7 @@
                 ) {
                     basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
                             .eq(BasStation::getStationName, task.getTargLoc())
-                            .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_R.type)
-                    );
+                            .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_R.type));
                 }
                 if (null == basStation) {
                     throw new CoolException("绔欑偣鐘舵�侀敊璇紒锛�");
@@ -622,6 +614,10 @@
                 if (!basStationService.updateById(basStation)) {
                     throw new CoolException("鏇存柊绔欑偣鐘舵�佸け璐ワ紒锛�");
                 }
+            }
+
+            if (!taskItemService.remove(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()))) {
+                throw new CoolException("浠诲姟鏄庣粏鍒犻櫎澶辫触锛侊紒");
             }
         }
         if (!this.removeByIds(Arrays.asList(ids))) {
@@ -743,12 +739,6 @@
     public void complateOutStock(Task task) throws Exception {
         if (Objects.isNull(task)) {
             throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
-        }
-        if (StringUtils.isNotBlank(task.getParentId() + "")) {
-            Task task1 = taskService.getById(task.getParentId());
-            if (!Objects.isNull(task1)) {
-                throw new CoolException("鐖朵换鍔★細" + task1.getTaskCode() + "鏈墽琛屽畬鎴愶紒");
-            }
         }
 
         Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc()));

--
Gitblit v1.9.1