From fd1bfa1163d438ec6cabfdd6e01e632d31189c80 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 12 五月 2023 12:34:10 +0800
Subject: [PATCH] 库位规则、混载库位

---
 src/main/java/com/zy/asrs/service/impl/LocMastServiceImpl.java |   13 +
 src/main/java/com/zy/asrs/service/impl/LocRuleServiceImpl.java |   62 ++++++--
 src/main/java/com/zy/asrs/service/LocRuleService.java          |   11 +
 src/main/resources/mapper/LocMastMapper.xml                    |   41 +++++
 src/main/webapp/views/locRule/locRule.html                     |   18 ++
 src/main/webapp/static/js/locRule/locRule.js                   |    2 
 src/main/java/com/zy/asrs/utils/Utils.java                     |    4 
 src/main/java/com/zy/asrs/mapper/LocRuleMapper.java            |    6 
 src/main/java/com/zy/asrs/mapper/LocMastMapper.java            |    4 
 src/main/java/com/zy/asrs/entity/LocRule.java                  |   29 ++++
 src/main/resources/mapper/LocRuleMapper.xml                    |   15 ++
 src/main/java/com/zy/asrs/service/LocMastService.java          |    4 
 src/main/java/com/zy/common/service/CommonService.java         |  194 +++++++++++++++++++++++----
 13 files changed, 344 insertions(+), 59 deletions(-)

diff --git a/src/main/java/com/zy/asrs/entity/LocRule.java b/src/main/java/com/zy/asrs/entity/LocRule.java
index 12d5d00..7449fae 100644
--- a/src/main/java/com/zy/asrs/entity/LocRule.java
+++ b/src/main/java/com/zy/asrs/entity/LocRule.java
@@ -159,9 +159,22 @@
     @ApiModelProperty(value= "澶囨敞")
     private String memo;
 
+    /**
+     * 鏄惁鏀寔娣疯浇{0:涓嶆敮鎸�,1:鏀寔}
+     */
+    @ApiModelProperty(value= "鏄惁鏀寔娣疯浇")
+    private Integer mixed;
+
+    /**
+     * 鏀寔娣疯浇鎯呭喌涓�,娌℃壘鍒板簱浣嶆槸鍚︾户缁鎵緖0:鍚�,1:鏄瘆
+     */
+    @ApiModelProperty(value= "鏄惁缁х画瀵绘壘")
+    @TableField("keep_go")
+    private Integer keepGo;
+
     public LocRule() {}
 
-    public LocRule(String matnr,String specs,String model,String cstmr,String batch,String other,Integer rowBeg,Integer rowEnd,Integer bayBeg,Integer bayEnd,Integer levBeg,Integer levEnd,Integer limit,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) {
+    public LocRule(String matnr,String specs,String model,String cstmr,String batch,String other,Integer rowBeg,Integer rowEnd,Integer bayBeg,Integer bayEnd,Integer levBeg,Integer levEnd,Integer limit,Integer status,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo,Integer mixed) {
         this.matnr = matnr;
         this.specs = specs;
         this.model = model;
@@ -181,6 +194,7 @@
         this.updateBy = updateBy;
         this.updateTime = updateTime;
         this.memo = memo;
+        this.mixed = mixed;
     }
 
 //    LocRule locRule = new LocRule(
@@ -249,5 +263,18 @@
         return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.updateTime);
     }
 
+    public String getMixed$() {
+        if (this.mixed == null) {
+            return "";
+        }
+        return this.mixed == 1 ? "鏄�" : "鍚�";
+    }
+
+    public String getKeepGo$() {
+        if (this.keepGo == null) {
+            return "";
+        }
+        return this.keepGo == 1 ? "鏄�" : "鍚�";
+    }
 
 }
diff --git a/src/main/java/com/zy/asrs/mapper/LocMastMapper.java b/src/main/java/com/zy/asrs/mapper/LocMastMapper.java
index 33227ea..2a59f36 100644
--- a/src/main/java/com/zy/asrs/mapper/LocMastMapper.java
+++ b/src/main/java/com/zy/asrs/mapper/LocMastMapper.java
@@ -23,7 +23,7 @@
     @Select("select count(*) as count from asr_loc_mast where 1=1 and loc_sts = 'O' and crn_no = #{crnNo}")
     Integer selectEmptyLocCount(@Param("crnNo") Integer crnNo);
 
-    List<LocMast> queryFreeLocMast2(@Param("rows") List<Integer> rows, @Param("rowsLen") Integer rowsLen, @Param("locType1") Short locType1);
+    List<LocMast> queryFreeLocMast2(Short locType1, Integer rowBeg, Integer rowEnd, Integer bayBeg, Integer bayEnd, Integer levBeg, Integer levEnd);
 
     LocMast selectAvailableNearLocDesc(@Param("groupLoc") List<String> groupOuterLoc);
 
@@ -35,4 +35,6 @@
 
     List<LocMast> selectLocByLev(Integer lev);
 
+    List<LocMast> selectEmptyByLocNos(@Param("locNos") List<String> locNos);
+
 }
diff --git a/src/main/java/com/zy/asrs/mapper/LocRuleMapper.java b/src/main/java/com/zy/asrs/mapper/LocRuleMapper.java
index b726edb..fe8dd2a 100644
--- a/src/main/java/com/zy/asrs/mapper/LocRuleMapper.java
+++ b/src/main/java/com/zy/asrs/mapper/LocRuleMapper.java
@@ -5,8 +5,14 @@
 import org.apache.ibatis.annotations.Mapper;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 @Mapper
 @Repository
 public interface LocRuleMapper extends BaseMapper<LocRule> {
 
+    LocRule selectByMatnr(String matnr);
+
+    LocRule selectByMixed(Integer mixed);
+
 }
diff --git a/src/main/java/com/zy/asrs/service/LocMastService.java b/src/main/java/com/zy/asrs/service/LocMastService.java
index b57520d..8d27adf 100644
--- a/src/main/java/com/zy/asrs/service/LocMastService.java
+++ b/src/main/java/com/zy/asrs/service/LocMastService.java
@@ -12,7 +12,7 @@
      * 妫�绱㈠彲鐢ㄥ簱浣�
      */
     List<LocMast> queryFreeLocMast(List<Integer> rows, Integer rowsLen, Short locType1);
-    List<LocMast> queryFreeLocMast2(List<Integer> rows, Integer rowsLen, Short locType1);
+    List<LocMast> queryFreeLocMast2(Short locType1, Integer rowBeg, Integer rowEnd, Integer bayBeg, Integer bayEnd, Integer levBeg, Integer levEnd);
 
     /**
      * 妫�绱㈠彲鐢ㄥ簱浣�0
@@ -63,4 +63,6 @@
     //鏌ヨ鎸囧畾妤煎眰鐨勫簱浣嶆暟鎹�
     List<LocMast> selectLocByLev(Integer lev);
 
+    List<LocMast> selectEmptyByLocNos(List<String> locNos);
+
 }
diff --git a/src/main/java/com/zy/asrs/service/LocRuleService.java b/src/main/java/com/zy/asrs/service/LocRuleService.java
index 24c3490..f793151 100644
--- a/src/main/java/com/zy/asrs/service/LocRuleService.java
+++ b/src/main/java/com/zy/asrs/service/LocRuleService.java
@@ -1,10 +1,19 @@
 package com.zy.asrs.service;
 
+import com.zy.asrs.entity.LocMast;
 import com.zy.asrs.entity.LocRule;
 import com.baomidou.mybatisplus.service.IService;
 
+import java.util.List;
+
 public interface LocRuleService extends IService<LocRule> {
 
-    LocRule find(String matnr, String batch, int startRow, int endRow);
+    LocRule find(String matnr);
+
+    //鎵炬贩杞藉簱浣嶈鍒�
+    LocRule findMixed();
+
+    //灏嗗簱浣嶈鍒欑粍杞崲涓哄簱浣嶇粍
+    List<LocMast> locRuleToLocNos(LocRule locRule);
 
 }
diff --git a/src/main/java/com/zy/asrs/service/impl/LocMastServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/LocMastServiceImpl.java
index 6294b1e..583e3b1 100644
--- a/src/main/java/com/zy/asrs/service/impl/LocMastServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/LocMastServiceImpl.java
@@ -34,8 +34,8 @@
     }
 
     @Override
-    public List<LocMast> queryFreeLocMast2(List<Integer> rows, Integer rowsLen, Short locType1) {
-        return this.baseMapper.queryFreeLocMast(rows, rowsLen, locType1);
+    public List<LocMast> queryFreeLocMast2(Short locType1, Integer rowBeg, Integer rowEnd, Integer bayBeg, Integer bayEnd, Integer levBeg, Integer levEnd) {
+        return this.baseMapper.queryFreeLocMast2(locType1, rowBeg, rowEnd, bayBeg, bayEnd, levBeg, levEnd);
     }
 
     @Override
@@ -94,6 +94,10 @@
         LocMast finalRes = null;
         for (String locNo0 : locNos) {
             LocMast locMast = this.selectById(locNo0);
+            if (locMast == null) {
+                continue;
+            }
+            
             if (locMast.getLocSts().equals("O")) {
                 if (finalRes == null) {
                     finalRes = locMast;
@@ -180,4 +184,9 @@
     public List<LocMast> selectLocByLev(Integer lev) {
         return this.baseMapper.selectLocByLev(lev);
     }
+
+    @Override
+    public List<LocMast> selectEmptyByLocNos(List<String> locNos) {
+        return this.baseMapper.selectEmptyByLocNos(locNos);
+    }
 }
diff --git a/src/main/java/com/zy/asrs/service/impl/LocRuleServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/LocRuleServiceImpl.java
index 4e01f89..79ab983 100644
--- a/src/main/java/com/zy/asrs/service/impl/LocRuleServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/LocRuleServiceImpl.java
@@ -2,23 +2,31 @@
 
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.core.common.Cools;
+import com.zy.asrs.entity.LocMast;
 import com.zy.asrs.entity.Mat;
 import com.zy.asrs.mapper.LocRuleMapper;
 import com.zy.asrs.entity.LocRule;
+import com.zy.asrs.service.LocMastService;
 import com.zy.asrs.service.LocRuleService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
 import com.zy.asrs.service.MatService;
+import com.zy.asrs.utils.Utils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
 
 @Service("locRuleService")
 public class LocRuleServiceImpl extends ServiceImpl<LocRuleMapper, LocRule> implements LocRuleService {
 
     @Autowired
     private MatService matService;
+    @Autowired
+    private LocMastService locMastService;
 
     @Override
-    public LocRule find(String matnr, String batch, int startRow, int endRow) {
+    public LocRule find(String matnr) {
         if (Cools.isEmpty(matnr)) {
             return null;
         }
@@ -26,25 +34,39 @@
         if (Cools.isEmpty(mat)) {
             return null;
         }
-        LocRule locRule = null;
-        do {
-            locRule = this.selectOne(new EntityWrapper<LocRule>().eq("matnr", matnr).ge("row_beg", startRow).le("row_end", endRow).eq("status", 1));
-            if (null != locRule) {
-                break;
+
+        return this.baseMapper.selectByMatnr(matnr);
+    }
+
+    //鎵炬贩杞藉簱浣嶈鍒�
+    @Override
+    public LocRule findMixed() {
+        return this.baseMapper.selectByMixed(1);//鎼滅储娣疯浇搴撲綅瑙勫垯
+    }
+
+    //灏嗗簱浣嶈鍒欒浆鎹负搴撲綅缁�
+    @Override
+    public List<LocMast> locRuleToLocNos(LocRule locRule) {
+        ArrayList<String> locNos = new ArrayList<>();
+        //灏嗘墍鏈夌鍚堟贩杞借鍒欑殑搴撲綅鍙疯繘琛屽瓨鍌�
+        Integer rowBeg = locRule.getRowBeg();
+        Integer rowEnd = locRule.getRowEnd();
+
+        Integer bayBeg = locRule.getBayBeg();
+        Integer bayEnd = locRule.getBayEnd();
+
+        Integer levBeg = locRule.getLevBeg();
+        Integer levEnd = locRule.getLevEnd();
+
+        for (int i = rowBeg; i <= rowEnd; i++) {
+            for (int j = bayBeg; j <= bayEnd; j++) {
+                for (int k = levBeg; k <= levEnd; k++) {
+                    String locNo = Utils.getLocNo(i, j, k);
+                    locNos.add(locNo);
+                }
             }
-            locRule = this.selectOne(new EntityWrapper<LocRule>().eq("specs", mat.getSpecs()).ge("row_beg", startRow).le("row_end", endRow).eq("status", 1));
-            if (null != locRule) {
-                break;
-            }
-            locRule = this.selectOne(new EntityWrapper<LocRule>().eq("model", mat.getModel()).ge("row_beg", startRow).le("row_end", endRow).eq("status", 1));
-            if (null != locRule) {
-                break;
-            }
-            locRule = this.selectOne(new EntityWrapper<LocRule>().eq("batch", batch).ge("row_beg", startRow).le("row_end", endRow).eq("status", 1));
-            if (null != locRule) {
-                break;
-            }
-        } while (false);
-        return locRule;
+        }
+
+        return locMastService.selectEmptyByLocNos(locNos);
     }
 }
diff --git a/src/main/java/com/zy/asrs/utils/Utils.java b/src/main/java/com/zy/asrs/utils/Utils.java
index 5a0214c..250745d 100644
--- a/src/main/java/com/zy/asrs/utils/Utils.java
+++ b/src/main/java/com/zy/asrs/utils/Utils.java
@@ -185,7 +185,9 @@
 
     }
 
-
+    public static String getLocNo(Number row, Number bay, Number lev) {
+        return zerofill(String.valueOf(row), 2) + zerofill(String.valueOf(bay), 3) + zerofill(String.valueOf(lev), 2);
+    }
 
     public static List<String> getGroupLoc(String locNo){
         int row = getRow(locNo);
diff --git a/src/main/java/com/zy/common/service/CommonService.java b/src/main/java/com/zy/common/service/CommonService.java
index 3f4744f..d62cd45 100644
--- a/src/main/java/com/zy/common/service/CommonService.java
+++ b/src/main/java/com/zy/common/service/CommonService.java
@@ -59,6 +59,8 @@
     private LocDetlService locDetlService;
     @Autowired
     private SlaveProperties slaveProperties;
+    @Autowired
+    private LocRuleService locRuleService;
 
     /**
      * 鐢熸垚宸ヤ綔鍙�
@@ -112,13 +114,132 @@
      * @return locNo 妫�绱㈠埌鐨勫簱浣嶅彿
      */
     public StartupDto getLocNo(Integer staDescId, Integer sourceStaNo, List<String> matNos, LocTypeDto locTypeDto,int times) {
-
-        StartupDto startupDto = new StartupDto();
-
         // 鐩爣搴撲綅
         LocMast locMast = null;
 
+        //娣疯浇鎵惧簱浣�
+        locMast = getLocNoStep1(matNos, locTypeDto);
+        if (locMast != null) {
+            //鎵惧埌搴撲綅锛岃繑鍥瀌to
+            return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
+        }
+
+        //搴撲綅瑙勫垯
+        locMast = getLocNoStep2(matNos, locTypeDto);
+        if (locMast != null) {
+            //鎵惧埌搴撲綅锛岃繑鍥瀌to
+            return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
+        }
+
         // 闈犺繎鎽嗘斁瑙勫垯 --- 鐩稿悓璁㈠崟鍙�, 鍚屽ぉ鍚岃鏍肩墿鏂�
+        locMast = getLocNoStep3(staDescId, matNos, locTypeDto);
+        if (locMast != null) {
+            //鎵惧埌搴撲綅锛岃繑鍥瀌to
+            return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
+        }
+
+        // 闈犺繎鎽嗘斁瑙勫垯 --- 绌烘墭
+        locMast = getLocNoStep4(staDescId, locTypeDto);
+        if (locMast != null) {
+            //鎵惧埌搴撲綅锛岃繑鍥瀌to
+            return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
+        }
+
+        // 濡傛灉娌℃湁鐩歌繎鐗╂枡锛屽垯鎸夎鍒欒疆璇㈣揣鏋�
+        // 寮�濮嬫煡鎵惧簱浣� ==============================>>
+        locMast = getLocNoStep5(locTypeDto, times);
+        if (locMast != null) {
+            //鎵惧埌搴撲綅锛岃繑鍥瀌to
+            return getLocNoStep6(staDescId, sourceStaNo, locMast);//杩斿洖dto
+        }
+
+        //鎵句笉鍒板簱浣嶏紝鎶涘嚭寮傚父
+        throw new CoolException("娌℃湁绌哄簱浣�");
+    }
+
+    /**
+     * 娣疯浇鎵惧簱浣�
+     */
+    private LocMast getLocNoStep1(List<String> matNos, LocTypeDto locTypeDto) {
+        LocMast locMast = null;
+
+        //鍒ゆ柇褰撳墠璐х墿鏄惁涓烘贩杞借揣鐗�
+        String firstMatNos = matNos.get(0);
+        boolean mixed = false;//榛樿涓嶆槸娣疯浇璐х墿
+        for (String matNo : matNos) {
+            if (!firstMatNos.equals(matNo)) {
+                mixed = true;//娣疯浇璐х墿
+                break;
+            }
+        }
+
+        if (!mixed) {
+            return locMast;//涓嶆槸娣疯浇璐х墿锛岀洿鎺ヨ烦鍑哄綋鍓嶄换鍔�
+        }
+
+        // 鎵炬贩杞藉簱浣嶈鍒�
+        LocRule locRule = locRuleService.findMixed();
+        if (locRule == null) {
+            return locMast;//娌℃湁娣疯浇瑙勫垯锛岃烦鍑哄綋鍓嶄换鍔�
+        }
+
+        //灏嗗簱浣嶈鍒欑粍杞崲涓哄簱浣嶇粍
+        List<LocMast> locMasts = locRuleService.locRuleToLocNos(locRule);
+        if (locMasts == null || locMasts.size() == 0) {
+            if (locRule.getKeepGo() == 0) {
+                //鎵句笉鍒扮┖搴撲綅锛屼笖绂佹缁х画瀵绘壘鍏朵粬闈炴贩杞藉尯鍩熷簱浣�
+                //鎵句笉鍒板簱浣嶏紝鎶涘嚭寮傚父
+                throw new CoolException("娣疯浇鍖哄煙娌℃湁绌哄簱浣�");
+            }
+            return locMast;//娌℃湁娣疯浇瑙勫垯锛岃烦鍑哄綋鍓嶄换鍔�
+        }
+
+        for (LocMast one : locMasts) {
+            LocMast locMast0 = locMastService.findOutMost(one.getLocNo());
+            if (null != locMast0) {
+                // 娴呭簱浣嶇鍚堝昂瀵告娴�
+                if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) {
+                    // 鍥犲簱浣嶇Щ杞�侀渶棰勭暀绌哄簱浣�
+                    if (locMastService.checkEmptyCount(locMast0, 10)) {
+                        locMast = locMast0;
+                        break;
+                    }
+                }
+            }
+        }
+
+        return locMast;
+    }
+
+    /**
+     * 搴撲綅瑙勫垯
+     */
+    private LocMast getLocNoStep2(List<String> matNos, LocTypeDto locTypeDto) {
+        LocMast locMast = null;
+        // 搴撳尯閿佸畾
+        LocRule locRule = locRuleService.find(Cools.isEmpty(matNos) ? null : matNos.get(0));
+        if (!Cools.isEmpty(locRule)) {
+            List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd());
+            for (LocMast one : locMasts) {
+                LocMast locMast0 = locMastService.findOutMost(one.getLocNo());
+                if (null != locMast0) {
+                    // 娴呭簱浣嶇鍚堝昂瀵告娴�
+                    if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) {
+                        // 鍥犲簱浣嶇Щ杞�侀渶棰勭暀绌哄簱浣�
+                        if (locMastService.checkEmptyCount(locMast0, 10)) {
+                            locMast = locMast0;
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+        return locMast;
+    }
+
+    // 闈犺繎鎽嗘斁瑙勫垯 --- 鐩稿悓璁㈠崟鍙�, 鍚屽ぉ鍚岃鏍肩墿鏂�
+    private LocMast getLocNoStep3(Integer staDescId, List<String> matNos, LocTypeDto locTypeDto) {
+        LocMast locMast = null;
         if (!Cools.isEmpty(matNos) && matNos.size() == 1 && staDescId == 1) {
             //鍏堝垽鏂伐浣滄。锛屾煡鎵句富妗OType=1锛� wrkSts < 10鐨勫伐浣滄槑缁嗭紝鏂欏彿鐩稿悓鐨勬槑缁嗗簱浣�
             List<WrkMast> wrkMasts = wrkMastService.selectSameMatnrs(matNos.get(0));
@@ -128,7 +249,6 @@
                     // 娴呭簱浣嶇鍚堝昂瀵告娴�
                     if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) {
                         locMast = locMast0;
-                        break;
                     }
                 }
             }
@@ -148,7 +268,12 @@
             }
         }
 
+        return locMast;
+    }
 
+    // 闈犺繎鎽嗘斁瑙勫垯 --- 绌烘墭
+    private LocMast getLocNoStep4(Integer staDescId, LocTypeDto locTypeDto) {
+        LocMast locMast = null;
         // 闈犺繎鎽嗘斁瑙勫垯 --- 绌烘墭
         if (staDescId == 10) {
             //鍏堝垽鏂伐浣滄。锛屾煡鎵句富妗OType=1锛� wrkSts < 10鐨勫伐浣滄槑缁嗭紝鏂欏彿鐩稿悓鐨勬槑缁嗗簱浣�
@@ -174,7 +299,6 @@
                             if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) {
                                 locMast = locMast0;
                                 break;
-
                             }
                         }
                     }
@@ -182,7 +306,38 @@
             }
         }
 
-        // 濡傛灉娌℃湁鐩歌繎鐗╂枡锛屽垯鎸夎鍒欒疆璇㈣揣鏋�
+        return locMast;
+    }
+
+    // 濡傛灉娌℃湁鐩歌繎鐗╂枡锛屽垯鎸夎鍒欒疆璇㈣揣鏋�
+    private LocMast getLocNoStep5(LocTypeDto locTypeDto, int times) {
+        LocMast locMast = null;
+        // 1.褰撴绱㈠簱鎺掍负娴呭簱浣嶆帓鏃讹紝浼樺厛瀵绘壘褰撳墠搴撴帓鐨勬繁搴撲綅鎺�
+        List<LocMast> peakLocs = locMastService.selectAllPeakLoc();
+        for (LocMast peakLoc : peakLocs) {
+            List<String> groupInsideLoc = Utils.getGroupInsideLoc(peakLoc.getLocNo());
+            if (!Cools.isEmpty(groupInsideLoc)) {
+                if (!locMastService.checkAllLocEmpty(groupInsideLoc)) continue;
+                locMast = peakLoc;
+                break;
+            } else {
+                locMast = peakLoc;
+                break;
+            }
+        }
+
+        // 2.搴撲綅褰撳墠鎵�灞炲昂瀵告棤绌哄簱浣嶆椂锛岃皟鏁村昂瀵稿弬鏁帮紝鍚戜笂鍏煎妫�绱㈠簱浣�
+        if (Cools.isEmpty(locMast)) {
+            log.error("绯荤粺娌℃湁绌哄簱浣嶏紒锛侊紒 灏哄瑙勬牸锛� {}锛� 杞娆℃暟锛歿}", JSON.toJSONString(locTypeDto), times);
+        }
+
+        return locMast;
+    }
+
+    //杩斿洖dto
+    private StartupDto getLocNoStep6(Integer staDescId, Integer sourceStaNo, LocMast locMast) {
+        StartupDto startupDto = new StartupDto();
+
         // 鑾峰彇鐩爣绔�
         Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
                 .eq("type_no", staDescId)
@@ -199,38 +354,13 @@
             throw new CoolException("鐩爣绔�" + staDesc.getCrnStn() + "涓嶅彲鐢�");
         }
 
-        // 寮�濮嬫煡鎵惧簱浣� ==============================>>
-
-        // 1.褰撴绱㈠簱鎺掍负娴呭簱浣嶆帓鏃讹紝浼樺厛瀵绘壘褰撳墠搴撴帓鐨勬繁搴撲綅鎺�
-        if (locMast == null) {
-            List<LocMast> peakLocs = locMastService.selectAllPeakLoc();
-            for (LocMast peakLoc : peakLocs) {
-                List<String> groupInsideLoc = Utils.getGroupInsideLoc(peakLoc.getLocNo());
-                if (!Cools.isEmpty(groupInsideLoc)){
-                    if (!locMastService.checkAllLocEmpty(groupInsideLoc)) continue;
-                    locMast = peakLoc;
-                    break;
-                }else {
-                    locMast=peakLoc;
-                    break;
-                }
-            }
-        }
-
-        // 2.搴撲綅褰撳墠鎵�灞炲昂瀵告棤绌哄簱浣嶆椂锛岃皟鏁村昂瀵稿弬鏁帮紝鍚戜笂鍏煎妫�绱㈠簱浣�
-        if (Cools.isEmpty(locMast)) {
-            log.error("绯荤粺娌℃湁绌哄簱浣嶏紒锛侊紒 灏哄瑙勬牸锛� {}锛� 杞娆℃暟锛歿}", JSON.toJSONString(locTypeDto), times);
-            throw new CoolException("娌℃湁绌哄簱浣�");
-        }
-        String locNo = locMast.getLocNo();
-
         // 鐢熸垚宸ヤ綔鍙�
         int workNo = getWorkNo(0);
         // 杩斿洖dto
         startupDto.setWorkNo(workNo);
         startupDto.setSourceStaNo(sourceStaNo);
         startupDto.setStaNo(staNo.getDevNo());
-        startupDto.setLocNo(locNo);
+        startupDto.setLocNo(locMast.getLocNo());
         return startupDto;
     }
 
diff --git a/src/main/resources/mapper/LocMastMapper.xml b/src/main/resources/mapper/LocMastMapper.xml
index d424cb2..03f0729 100644
--- a/src/main/resources/mapper/LocMastMapper.xml
+++ b/src/main/resources/mapper/LocMastMapper.xml
@@ -156,4 +156,45 @@
     <select id="selectLocByLev" resultMap="BaseResultMap">
         SELECT * FROM asr_loc_mast WHERE lev1 = #{lev}
     </select>
+
+    <select id="queryFreeLocMast2" resultMap="BaseResultMap">
+        select *
+        from asr_loc_mast
+        where 1=1
+        and loc_sts='O'
+        <if test="locType1 != null">
+            and loc_type1 = #{locType1}
+        </if>
+        <if test="rowBeg != null">
+            and row1 >= #{rowBeg}
+        </if>
+        <if test="rowEnd != null">
+            and row1 &lt;= #{rowEnd}
+        </if>
+        <if test="bayBeg != null">
+            and bay1 >= #{bayBeg}
+        </if>
+        <if test="bayEnd != null">
+            and bay1 &lt;= #{bayEnd}
+        </if>
+        <if test="levBeg != null">
+            and lev1 >= #{levBeg}
+        </if>
+        <if test="levEnd != null">
+            and lev1 &lt;= #{levEnd}
+        </if>
+        and loc_no not in ('0100101')
+        order by loc_sts desc ,lev1 asc,bay1 asc
+    </select>
+
+    <select id="selectEmptyByLocNos" resultMap="BaseResultMap">
+        SELECT * FROM asr_loc_mast
+        WHERE loc_sts IN ('O')
+        AND loc_no IN
+        <foreach collection="locNos" item="loc" index="index" open="(" close=")" separator=",">
+            #{loc}
+        </foreach>
+        ORDER BY
+        row1 ASC
+    </select>
 </mapper>
diff --git a/src/main/resources/mapper/LocRuleMapper.xml b/src/main/resources/mapper/LocRuleMapper.xml
index 02d6fb5..781ad78 100644
--- a/src/main/resources/mapper/LocRuleMapper.xml
+++ b/src/main/resources/mapper/LocRuleMapper.xml
@@ -24,7 +24,22 @@
         <result column="update_by" property="updateBy" />
         <result column="update_time" property="updateTime" />
         <result column="memo" property="memo" />
+        <result column="mixed" property="mixed" />
+        <result column="keep_go" property="keepGo" />
 
     </resultMap>
 
+    <select id="selectByMatnr" resultMap="BaseResultMap">
+        select * from asr_loc_rule
+        where matnr = #{matnr}
+        and mixed = 0
+        and status = 1
+    </select>
+
+    <select id="selectByMixed" resultMap="BaseResultMap">
+        select top 1 * from asr_loc_rule
+        where mixed = #{mixed}
+        and status = 1
+    </select>
+
 </mapper>
diff --git a/src/main/webapp/static/js/locRule/locRule.js b/src/main/webapp/static/js/locRule/locRule.js
index 6234b7e..0bc8de9 100644
--- a/src/main/webapp/static/js/locRule/locRule.js
+++ b/src/main/webapp/static/js/locRule/locRule.js
@@ -42,6 +42,8 @@
             ,{field: 'updateBy$', align: 'center',title: '淇敼浜哄憳', hide: true}
             ,{field: 'updateTime$', align: 'center',title: '淇敼鏃堕棿', hide: true}
             ,{field: 'memo', align: 'center',title: '澶囨敞', hide: true}
+            ,{field: 'mixed$', align: 'center',title: '娣疯浇'}
+            ,{field: 'keepGo$', align: 'center',title: '缁х画鎼滅储'}
 
             ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:120}
         ]],
diff --git a/src/main/webapp/views/locRule/locRule.html b/src/main/webapp/views/locRule/locRule.html
index 143c432..4f24e2f 100644
--- a/src/main/webapp/views/locRule/locRule.html
+++ b/src/main/webapp/views/locRule/locRule.html
@@ -114,6 +114,24 @@
                         <input class="layui-input" name="limit" placeholder="璇疯緭鍏ヤ笂闄�">
                     </div>
                 </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">娣疯浇: </label>
+                    <div class="layui-input-block">
+                        <select name="mixed">
+                            <option value="1">鏄�</option>
+                            <option value="0" selected>鍚�</option>
+                        </select>
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">娣疯浇鏈壘鍒板簱浣嶇户缁悳绱�: </label>
+                    <div class="layui-input-block">
+                        <select name="keepGo">
+                            <option value="1">鏄�</option>
+                            <option value="0" selected>鍚�</option>
+                        </select>
+                    </div>
+                </div>
 
              </div>
 

--
Gitblit v1.9.1