From 1d471a9b8269525a8f95dc51f587aa6c3a3bda2f Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期一, 27 一月 2025 09:56:39 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/service/CommonService.java |   87 +++++++++++++++++++++++--------------------
 1 files changed, 47 insertions(+), 40 deletions(-)

diff --git a/src/main/java/com/zy/common/service/CommonService.java b/src/main/java/com/zy/common/service/CommonService.java
index 0a54bcf..f8f4146 100644
--- a/src/main/java/com/zy/common/service/CommonService.java
+++ b/src/main/java/com/zy/common/service/CommonService.java
@@ -50,6 +50,7 @@
 
     /**
      * 鐢熸垚宸ヤ綔鍙�
+     *
      * @param wrkMk
      * @return workNo(宸ヤ綔鍙�)
      */
@@ -62,17 +63,17 @@
         int workNo = wrkLastno.getWrkNo();
         int sNo = wrkLastno.getSNo();
         int eNo = wrkLastno.getENo();
-        workNo = workNo>=eNo ? sNo : workNo+1;
+        workNo = workNo >= eNo ? sNo : workNo + 1;
         while (true) {
             WrkMast wrkMast = wrkMastService.selectById(workNo);
             if (null != wrkMast) {
-                workNo = workNo>=eNo ? sNo : workNo+1;
+                workNo = workNo >= eNo ? sNo : workNo + 1;
             } else {
                 break;
             }
         }
         // 淇敼搴忓彿璁板綍
-        if (workNo > 0){
+        if (workNo > 0) {
             wrkLastno.setWrkNo(workNo);
             wrkLastnoService.updateById(wrkLastno);
         }
@@ -80,7 +81,7 @@
         if (workNo == 0) {
             throw new CoolException("鐢熸垚宸ヤ綔鍙峰け璐ワ紝璇疯仈绯荤鐞嗗憳");
         } else {
-            if (wrkMastService.selectById(workNo)!=null) {
+            if (wrkMastService.selectById(workNo) != null) {
                 throw new CoolException("鐢熸垚宸ヤ綔鍙�" + workNo + "鍦ㄥ伐浣滄。涓凡瀛樺湪");
             }
         }
@@ -89,10 +90,10 @@
 
     /**
      * 妫�绱㈠簱浣嶅彿
-     * @param whsType 绫诲瀷 1:鍙屾繁寮忚揣鏋�
-     * @param staDescId 璺緞宸ヤ綔绫诲瀷
+     *
+     * @param whsType     绫诲瀷 1:鍙屾繁寮忚揣鏋�
+     * @param staDescId   璺緞宸ヤ綔绫诲瀷
      * @param sourceStaNo 婧愮珯
-
      * @return locNo 妫�绱㈠埌鐨勫簱浣嶅彿
      */
     @Transactional
@@ -115,7 +116,7 @@
 //        }
 
         // 闈犺繎鎽嗘斁瑙勫垯 --- 鐩稿悓璁㈠崟鍙�, 鍚屽ぉ鍚岃鏍肩墿鏂�
-        locMast = getLocNoStep3(staDescId, matnr, batch, grade, locTypeDto,sourceStaNo);
+        locMast = getLocNoStep3(staDescId, matnr, batch, grade, locTypeDto, sourceStaNo);
         if (locMast != null) {
             //鎵惧埌搴撲綅锛岃繑鍥瀌to
             return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
@@ -134,43 +135,49 @@
     }
 
     // 鎼滅储鍗曞搧(鏁翠釜搴撲綅缁�)
-    private LocMast getLocNoStepSingle(LocTypeDto locTypeDto,Integer sourceStaNo) {
+    private LocMast getLocNoStepSingle(LocTypeDto locTypeDto, Integer sourceStaNo) {
         LocMast locMast = null;
 
-        StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>().eq("type_no", 1).eq("stn_no", sourceStaNo));
-        //鍗曞搧
-        List<LocMast> locMasts = locMastService.selectAreaEmpty(locTypeDto.getLocType1(),staDesc.getCrnNo());//鎼滅储璐х墿
+        List<StaDesc> staDescs = staDescService.selectList(new EntityWrapper<StaDesc>().eq("type_no", 1).eq("stn_no", sourceStaNo));
 
-        for (LocMast mast : locMasts) {
-            LocMast tmp = null;
-            boolean groupLoc = Utils.isShallowLoc(slaveProperties,mast.getLocNo());
-            if (groupLoc) {
-                String shallowLoc = Utils.getDeepLoc(slaveProperties, mast.getLocNo());
-                LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>()
-                        .eq("loc_no", shallowLoc));
-                if (!Cools.isEmpty(locMast2)) {
-                    if (locMast2.getLocSts().equals("F") || locMast2.getLocSts().equals("D")){
-                        tmp = mast;
+        for (StaDesc staDesc : staDescs) {
+            //鍗曞搧
+            List<LocMast> locMasts = locMastService.selectAreaEmpty(locTypeDto.getLocType1(), staDesc.getCrnNo());//鎼滅储璐х墿
+
+            for (LocMast mast : locMasts) {
+                LocMast tmp = null;
+                boolean groupLoc = Utils.isShallowLoc(slaveProperties, mast.getLocNo());
+                if (groupLoc) {
+                    String shallowLoc = Utils.getDeepLoc(slaveProperties, mast.getLocNo());
+                    LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>()
+                            .eq("loc_no", shallowLoc));
+                    if (!Cools.isEmpty(locMast2)) {
+                        if (locMast2.getLocSts().equals("F") || locMast2.getLocSts().equals("D")) {
+                            tmp = mast;
+                            if (!Cools.isEmpty(mast)) {
+                                if (mast.getLocSts().equals("O")) {
+                                    tmp = mast;
+                                }
+                            }
+                        }
+                        //棰勭暀绌哄簱浣�
+                        if (tmp != null && locMastService.checkEmptyCount(mast, 10)) {
+                            locMast = tmp;
+                            break;
+                        }
                     }
+
                 }
-            }else {
-                if (!Cools.isEmpty(mast)) {
-                    if (mast.getLocSts().equals("O")){
-                        tmp = mast;
-                    }
-                }
-            }
-            //棰勭暀绌哄簱浣�
-            if (tmp != null && locMastService.checkEmptyCount(mast, 10)) {
-                locMast = tmp;
-                break;
+
+                return locMast;
             }
         }
-
         return locMast;
     }
+
     // 闈犺繎鎽嗘斁瑙勫垯 --- 鐩稿悓璁㈠崟鍙�, 鍚屽ぉ鍚岃鏍肩墿鏂�
-    private LocMast getLocNoStep3(Integer staDescId, String matnr, String batch, String grade, LocTypeDto locTypeDto,Integer sourceStaNo) {
+    private LocMast getLocNoStep3(Integer staDescId, String matnr, String batch, String grade, LocTypeDto
+            locTypeDto, Integer sourceStaNo) {
         LocMast locMast = null;
         StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>().eq("type_no", 1).eq("stn_no", sourceStaNo));
         if (staDescId == 1) {
@@ -179,7 +186,7 @@
             for (WrkMast wrkMast : wrkMasts) {
                 LocMast locMast0 = locMastService.findNearloc(wrkMast.getLocNo());
                 if (null != locMast0) {
-                    if (!staDesc.getCrnNo().equals(locMast0.getCrnNo())){
+                    if (!staDesc.getCrnNo().equals(locMast0.getCrnNo())) {
                         continue;
                     }
                     // 娴呭簱浣嶇鍚堝昂瀵告娴�
@@ -194,7 +201,7 @@
                 for (String locNo : locNos) {
                     LocMast locMast0 = locMastService.findNearloc(locNo);
                     if (null != locMast0) {
-                        if (!staDesc.getCrnNo().equals(locMast0.getCrnNo())){
+                        if (!staDesc.getCrnNo().equals(locMast0.getCrnNo())) {
                             continue;
                         }
                         // 娴呭簱浣嶇鍚堝昂瀵告娴�
@@ -218,7 +225,7 @@
         Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
                 .eq("type_no", staDescId)
                 .eq("stn_no", sourceStaNo)
-                .eq("crn_no",locMast.getCrnNo());
+                .eq("crn_no", locMast.getCrnNo());
         StaDesc staDesc = staDescService.selectOne(wrapper);
         if (Cools.isEmpty(staDesc)) {
             log.error("鍏ュ簱璺緞涓嶅瓨鍦�, staDescId={}, sourceStaNo={}", staDescId, sourceStaNo);
@@ -259,7 +266,7 @@
             List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
                     .eq("loc_sts", "O")
                     .eq("crn_no", staDesc.getCrnNo())
-                    .eq("loc_type1",locTypeDto.getLocType1())
+                    .eq("loc_type1", locTypeDto.getLocType1())
                     .orderBy("lev1,bay1,row1"));
             if (!locMasts.isEmpty()) {
                 for (LocMast loc : locMasts) {
@@ -287,7 +294,7 @@
             return msg.substring(0, 16);
         } else {
             StringBuilder msgBuilder = new StringBuilder(msg);
-            for(int i = 0; i < count - msg.length(); ++i) {
+            for (int i = 0; i < count - msg.length(); ++i) {
                 msgBuilder.insert(0, "0");
             }
             return msgBuilder.toString();

--
Gitblit v1.9.1