From 2226c83bff81543472286adea44638e8def2d1bf Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期五, 12 六月 2020 09:00:55 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/service/CommonService.java |   38 ++++++++++++++++++++++++++------------
 1 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/zy/common/service/CommonService.java b/src/main/java/com/zy/common/service/CommonService.java
index 062b200..2f22fbd 100644
--- a/src/main/java/com/zy/common/service/CommonService.java
+++ b/src/main/java/com/zy/common/service/CommonService.java
@@ -7,6 +7,7 @@
 import com.zy.asrs.entity.*;
 import com.zy.asrs.service.*;
 import com.zy.common.model.Shelves;
+import com.zy.common.model.StartupDto;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -76,20 +77,20 @@
      * @param sourceStaNo 婧愮珯
      * @return locNo 妫�绱㈠埌鐨勫簱浣嶅彿
      */
-    public String getLocNo(Integer whsType, String sourceStaNo) {
+    public StartupDto getLocNo(Integer whsType, Integer sourceStaNo) {
+        StartupDto startupDto = new StartupDto();
         RowLastno rowLastno = rowLastnoService.selectById(whsType);
         if (Cools.isEmpty(rowLastno)) {
             throw new CoolException("鏁版嵁寮傚父锛岃鑱旂郴绠$悊鍛�");
         }
-        String locNo = null;
         if (rowLastno.getWhsType() == 1){
             int curRow = rowLastno.getCurrentRow();
             int sRow = rowLastno.getsRow();
             int eRow = rowLastno.geteRow();
             int crn_qty = rowLastno.getCrnQty();
-
+            int rowCount = eRow - sRow + 1;
             // 鑾峰彇鐩爣绔欐墍鍦ㄨ揣鏋舵帓鍙�
-            Shelves shelves = new Shelves(8, crn_qty);
+            Shelves shelves = new Shelves(rowCount, crn_qty);
             curRow = shelves.start(curRow);
             if (curRow < 0) {
                 throw new CoolException("妫�绱㈠簱浣嶅け璐ワ紝璇疯仈绯荤鐞嗗憳");
@@ -111,7 +112,7 @@
             // 鑾峰彇鐩爣绔�
             Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
                     .eq("type_no", 1)
-                    .eq("stnNo", sourceStaNo)
+                    .eq("stn_no", sourceStaNo)
                     .eq("crn_no", crnNo);
             StaDesc staDesc = staDescService.selectOne(wrapper);
             if (Cools.isEmpty(staDesc)) {
@@ -120,15 +121,28 @@
             BasDevp staNo = basDevpService.selectById(staDesc.getCrnStn());
             int inQty = staNo.getInQty();
             if (staNo.getInEnable().equals("Y") && staNo.getAutoing().equals("Y") && inQty<2) {
-                // 鏌ユ壘搴撲綅 todo
-                LocMast locMast = locMastService.queryFreeLocMast(curRow, 1);
+                // 鏌ユ壘搴撲綅
+                LocMast locMast = locMastService.queryFreeLocMast(curRow);
+                if (Cools.isEmpty(locMast)) {
+                    throw new CoolException("娌℃湁绌哄簱浣�");
+                }
+                String locNo = locMast.getLocNo();
+
+                // 鏇存柊搴撲綅鎺掑彿
+                rowLastno.setCurrentRow(curRow);
+                rowLastnoService.updateById(rowLastno);
+
+                // 杩斿洖dto
+                startupDto.setCrnNo(crnNo);
+                startupDto.setShelves(shelves);
+                startupDto.setSourceStaNo(sourceStaNo);
+                startupDto.setStaNo(staNo.getDevNo());
+                startupDto.setLocNo(locNo);
+            } else {
+                throw new CoolException("鐩爣绔欎笉鍙敤");
             }
-
-
-            rowLastno.setCurrentRow(curRow);
-            rowLastnoService.updateById(rowLastno);
         }
-        return locNo;
+        return startupDto;
     }
 
 }
\ No newline at end of file

--
Gitblit v1.9.1