From 540a50281d9995653f3a4541eefec56648a79f2c Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期一, 28 四月 2025 15:41:17 +0800
Subject: [PATCH] #找库位优化

---
 rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java |   32 ++++++++++++++------------------
 1 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
index 295ccdf..8bd62d6 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/WcsServiceImpl.java
@@ -316,7 +316,11 @@
         if (Cools.isEmpty(deviceSites)) {
             throw new CoolException("鏈壘鍒扮珯鐐硅矾寰勪俊鎭�");
         }
-        WarehouseAreas warehouseArea = warehouseAreasService.getById(param.getArea());
+        DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(param.getSourceStaNo()));
+        if (Cools.isEmpty(deviceBind)) {
+            throw new CoolException("鏁版嵁寮傚父锛岃鑱旂郴绠$悊鍛�===>搴撲綅瑙勫垯鏈煡");
+        }
+        WarehouseAreas warehouseArea = warehouseAreasService.getById(deviceBind.getTypeId());
         if (Cools.isEmpty(warehouseArea)) {
             throw new CoolException("鏈壘鍒版墍灞炲簱鍖轰俊鎭�");
         }
@@ -324,18 +328,18 @@
         InTaskMsgDto dto = null;
         switch (warehouseArea.getType()) {
             case "CRN": //鍫嗗灈鏈�
-                dto = getLocNoCrn(param.getArea(), param.getSourceStaNo(), matnr,batch, locTypeDto, 0, param.getIoType());
+                dto = getLocNoCrn(deviceBind,warehouseArea.getId(), param.getSourceStaNo(), matnr,batch, locTypeDto, 0, param.getIoType());
                 break;
             case "SXC": //鍥涘悜搴�
                 break;
             case "CTU": //ctu
-                dto = getLocNoCtu(param.getArea(), param.getSourceStaNo(), matnr,batch, locTypeDto, 0, param.getIoType());
+                dto = getLocNoCtu(deviceBind,warehouseArea.getId(), param.getSourceStaNo(), matnr,batch, locTypeDto, 0, param.getIoType());
                 break;
         }
         return dto;
     }
 
-    private InTaskMsgDto getLocNoCrn(Integer area,Integer sourceStaNo, String matnr, String batch,LocTypeDto locTypeDto, int times,Integer ioType){
+    private InTaskMsgDto getLocNoCrn(DeviceBind deviceBind,Long area,Integer sourceStaNo, String matnr, String batch,LocTypeDto locTypeDto, int times,Integer ioType){
         if (Cools.isEmpty(matnr)) {  //鐗╂枡鍙�
             matnr = "";
         }
@@ -350,10 +354,7 @@
         Loc loc = null;     // 鐩爣搴撲綅
 
         InTaskMsgDto inTaskMsgDto = new InTaskMsgDto();
-        DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(sourceStaNo));
-        if (Cools.isEmpty(deviceBind)) {
-            throw new CoolException("鏁版嵁寮傚父锛岃鑱旂郴绠$悊鍛�===>搴撲綅瑙勫垯鏈煡");
-        }
+
         int sRow = deviceBind.getStartRow();
         int eRow = deviceBind.getEndRow();
         int deviceQty = deviceBind.getDeviceQty();
@@ -540,14 +541,14 @@
             // 褰撳墠宸烽亾鏃犵┖搴撲綅鏃讹紝閫掑綊璋冩暣鑷充笅涓�宸烽亾锛屾绱㈠叏閮ㄥ贩閬撴棤鏋滃悗锛岃烦鍑洪�掑綊
             if (times < rowCount * 2) {
                 times = times + 1;
-                return getLocNoCrn(area,sourceStaNo,matnr,batch,locTypeDto,times, ioType);
+                return getLocNoCrn(deviceBind,area,sourceStaNo,matnr,batch,locTypeDto,times, ioType);
 
             }
             // 2.搴撲綅褰撳墠鎵�灞炲昂瀵告棤绌哄簱浣嶆椂锛岃皟鏁村昂瀵稿弬鏁帮紝鍚戜笂鍏煎妫�绱㈠簱浣�
             if (locTypeDto.getLocType1() < 3) {
                 int i = locTypeDto.getLocType1() + 1;
                 locTypeDto.setLocType1(i);
-                return getLocNoCrn(area,sourceStaNo,matnr,batch,locTypeDto,0, ioType);
+                return getLocNoCrn(deviceBind,area,sourceStaNo,matnr,batch,locTypeDto,0, ioType);
             }
             throw new CoolException("娌℃湁绌哄簱浣�");
         }
@@ -561,7 +562,7 @@
         return inTaskMsgDto;
     }
 
-    private InTaskMsgDto getLocNoCtu(Integer area,Integer sourceStaNo, String matnr, String batch,LocTypeDto locTypeDto, int times,Integer ioType){
+    private InTaskMsgDto getLocNoCtu(DeviceBind deviceBind,Long area,Integer sourceStaNo, String matnr, String batch,LocTypeDto locTypeDto, int times,Integer ioType){
         if (Cools.isEmpty(matnr)) {  //鐗╂枡鍙�
             matnr = "";
         }
@@ -571,11 +572,6 @@
         int deviceNo = 0;
         Loc loc = new Loc();
         InTaskMsgDto inTaskMsgDto = new InTaskMsgDto();
-        DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(sourceStaNo));
-        if (Cools.isEmpty(deviceBind)) {
-            throw new CoolException("鏁版嵁寮傚父锛岃鑱旂郴绠$悊鍛�===>搴撲綅瑙勫垯鏈煡");
-        }
-
         List<Loc> loc1 = locService.list(new LambdaQueryWrapper<Loc>()
                 .eq(Loc::getAreaId, area)
                 .eq(Loc::getUseStatus, LocUseStatusType.Empty_Slot.type)
@@ -608,14 +604,14 @@
             // 褰撳墠宸烽亾鏃犵┖搴撲綅鏃讹紝閫掑綊璋冩暣鑷充笅涓�宸烽亾锛屾绱㈠叏閮ㄥ贩閬撴棤鏋滃悗锛岃烦鍑洪�掑綊
             if (times < 5) {
                 times = times + 1;
-                return getLocNoCrn(area,sourceStaNo,matnr,batch,locTypeDto,times, ioType);
+                return getLocNoCtu(deviceBind,area,sourceStaNo,matnr,batch,locTypeDto,times, ioType);
 
             }
             // 2.搴撲綅褰撳墠鎵�灞炲昂瀵告棤绌哄簱浣嶆椂锛岃皟鏁村昂瀵稿弬鏁帮紝鍚戜笂鍏煎妫�绱㈠簱浣�
             if (locTypeDto.getLocType1() < 3) {
                 int i = locTypeDto.getLocType1() + 1;
                 locTypeDto.setLocType1(i);
-                return getLocNoCrn(area,sourceStaNo,matnr,batch,locTypeDto,0, ioType);
+                return getLocNoCtu(deviceBind,area,sourceStaNo,matnr,batch,locTypeDto,0, ioType);
             }
             throw new CoolException("娌℃湁绌哄簱浣�");
         }

--
Gitblit v1.9.1