From b176072388747abb438990157bfa305b215b4b90 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期二, 14 四月 2026 21:59:39 +0800
Subject: [PATCH] 我们现在讨论一下系统找库位方案, 如何实现,对现有找库位规则进行整改,数据库也要整改 1、要能方便的填写单伸堆垛机或双伸堆垛机的深浅库位配置 2、根据设备状态分配库位,离线设备不分配 3、库位分配要均衡到每一个设备 4、库位高度需要匹配到对应库位信息,低库位能向上兼容 5、空托盘优先放在locType2库位=1的库位,没有这种库位了,允许放到其他库位 6、给入库站点设置有限去那些堆垛机,其次去那些堆垛机,弄成页面可以配置入库站点 7、在系统配置新增优先放前几列的配置,当入库的货物是高频货物时放在前几列 8、组托中会标识该托盘是高频还是低频,如果是高频则从前往后找库位,如果是低频则从后往前找库位 9、找库位时locMast中whsType字段无用
---
src/main/java/com/zy/common/service/CommonService.java | 1761 ++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 1,276 insertions(+), 485 deletions(-)
diff --git a/src/main/java/com/zy/common/service/CommonService.java b/src/main/java/com/zy/common/service/CommonService.java
index 68548cb..b0132dd 100644
--- a/src/main/java/com/zy/common/service/CommonService.java
+++ b/src/main/java/com/zy/common/service/CommonService.java
@@ -7,12 +7,14 @@
import com.core.common.Cools;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
+import com.zy.asrs.entity.param.BasCrnDepthRuleRuntimePreviewParam;
import com.zy.asrs.entity.result.FindLocNoAttributeVo;
import com.zy.asrs.entity.result.KeyValueVo;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.Utils;
import com.zy.asrs.utils.VersionUtils;
import com.zy.common.entity.Parameter;
+import com.zy.common.model.CrnDepthRuleProfile;
import com.zy.common.model.LocTypeDto;
import com.zy.common.model.Shelves;
import com.zy.common.model.StartupDto;
@@ -26,11 +28,14 @@
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
/**
@@ -59,6 +64,28 @@
}
}
+ private static class Run2SearchResult {
+ private final LocMast locMast;
+ private final RowLastno rowLastno;
+ private final List<Integer> runnableCrnNos;
+
+ private Run2SearchResult(LocMast locMast, RowLastno rowLastno, List<Integer> runnableCrnNos) {
+ this.locMast = locMast;
+ this.rowLastno = rowLastno;
+ this.runnableCrnNos = runnableCrnNos;
+ }
+ }
+
+ private static class Run2Cursor {
+ private final int currentRow;
+ private final Integer currentCrnNo;
+
+ private Run2Cursor(int currentRow, Integer currentCrnNo) {
+ this.currentRow = currentRow;
+ this.currentCrnNo = currentCrnNo;
+ }
+ }
+
@Autowired
private WrkMastService wrkMastService;
@Autowired
@@ -81,6 +108,8 @@
private SlaveProperties slaveProperties;
@Autowired
private WrkDetlService wrkDetlService;
+ @Autowired
+ private BasCrnDepthRuleService basCrnDepthRuleService;
/**
* 鐢熸垚宸ヤ綔鍙�
@@ -159,6 +188,8 @@
Integer whsType = Utils.GetWhsType(sourceStaNo);
RowLastno rowLastno = rowLastnoService.selectById(whsType);
RowLastnoType rowLastnoType = rowLastnoTypeService.selectById(rowLastno.getTypeId());
+ List<Integer> stationAreas = Utils.getStationStorageAreas(sourceStaNo);
+ findLocNoAttributeVo.setOutAreas(stationAreas);
Integer preferredArea = resolvePreferredArea(sourceStaNo, findLocNoAttributeVo);
if (preferredArea != null) {
findLocNoAttributeVo.setOutArea(preferredArea);
@@ -190,6 +221,51 @@
}
/**
+ * 渚� 6.15 閲嶅垎閰嶆帴鍙e鐢細鎸夊閮ㄦ寚瀹氱殑鍫嗗灈鏈洪『搴忥紝鍦ㄦ寚瀹氬簱鍖哄唴鎵炬柊鐨勫叆搴撲綅銆�
+ *
+ * 杩欓噷涓嶆帹杩� row_lastno 娓告爣锛屽彧璐熻矗涓�娆℃�х殑璺緞鏍¢獙 + 璁惧鏍¢獙 + 绌哄簱浣嶆悳绱€��
+ */
+ public StartupDto findRun2InboundLocByCandidateCrnNos(Integer sourceStaNo, Integer staDescId, Integer preferredArea,
+ List<Integer> candidateCrnNos, LocTypeDto locTypeDto) {
+ if (sourceStaNo == null) {
+ throw new CoolException("婧愮珯涓嶈兘涓虹┖");
+ }
+ if (Cools.isEmpty(candidateCrnNos)) {
+ return null;
+ }
+ Integer whsType = Utils.GetWhsType(sourceStaNo);
+ RowLastno defaultRowLastno = rowLastnoService.selectById(whsType);
+ if (Cools.isEmpty(defaultRowLastno)) {
+ throw new CoolException("绔欑偣=" + sourceStaNo + " 鏈煡璇㈠埌瀵瑰簲鐨勫簱浣嶈鍒�");
+ }
+ RowLastno searchRowLastno = defaultRowLastno;
+ if (preferredArea != null && preferredArea > 0) {
+ RowLastno areaRowLastno = rowLastnoService.selectById(preferredArea);
+ if (Cools.isEmpty(areaRowLastno)) {
+ throw new CoolException("鏈壘鍒板簱鍖鸿疆璇㈣鍒�");
+ }
+ searchRowLastno = areaRowLastno;
+ }
+ RowLastnoType rowLastnoType = rowLastnoTypeService.selectById(searchRowLastno.getTypeId());
+ if (Cools.isEmpty(rowLastnoType)) {
+ throw new CoolException("鏁版嵁寮傚父锛岃鑱旂郴绠$悊鍛�===銆嬪簱浣嶈鍒欑被鍨嬫湭鐭�");
+ }
+ if (rowLastnoType.getType() != 1 && rowLastnoType.getType() != 2) {
+ throw new CoolException("褰撳墠浠撳簱涓嶆敮鎸侀噸鏂板垎閰嶅叆搴撲綅");
+ }
+ StartupDto startupDto = new StartupDto();
+ LocMast locMast = findRun2EmptyLocByCrnNos(searchRowLastno, rowLastnoType, candidateCrnNos, locTypeDto,
+ staDescId, sourceStaNo, startupDto, preferredArea, null, "reassign-inbound");
+ if (Cools.isEmpty(locMast) || !"O".equals(locMast.getLocSts())) {
+ return null;
+ }
+ startupDto.setSourceStaNo(sourceStaNo);
+ startupDto.setCrnNo(locMast.getCrnNo());
+ startupDto.setLocNo(locMast.getLocNo());
+ return startupDto;
+ }
+
+ /**
* 绌烘墭鐩樿瘑鍒鍒欙細
* 1. 浠ョ粍鎵樻。鐗╂枡缂栫爜 matnr=emptyPallet 涓轰富锛屼笉鍐嶄緷璧� ioType=10銆�
* 2. 淇濈暀 staDescId=10 鐨勫吋瀹瑰垽鏂紝閬垮厤鏃ч摼璺繕鏈垏鎹㈡椂琛屼负绐佸彉銆�
@@ -206,25 +282,98 @@
*
* 绌烘墭鐩樼殑搴撲綅绛栫暐鏈変袱娈碉細
* 1. 棣栬疆鍙檺鍒� loc_type2=1锛岃〃绀轰紭鍏堟壘绐勫簱浣嶃��
- * 2. 棣栬疆涓嶉檺鍒� loc_type1锛岄珮浣庝綅閮藉厑璁稿弬涓庢悳绱€��
+ * 2. loc_type1 楂樺害淇℃伅蹇呴』淇濈暀锛屽悗缁啀鎸変綆浣嶅悜楂樹綅鍏煎銆�
*
- * 杩欐牱鍋氱殑鍘熷洜鏄幇鍦哄彛寰勫凡缁忔敼鎴愨�滃厛鎵剧獎搴撲綅鈥濓紝鑰屼笉鏄�滃厛鎵句綆浣嶇獎搴撲綅鈥濄��
- * 鍥犳杩欓噷浼氫富鍔ㄦ竻绌� locType1锛岄槻姝㈣绔欑偣榛樿鍊煎甫鎴愪綆浣嶄紭鍏堛��
+ * 闈炵┖鎵樼洏鍙繚鐣� loc_type1锛屾弧鎵樻壘浣嶄笉鍐嶄娇鐢� loc_type2/loc_type3 杩囨护銆�
*/
private LocTypeDto normalizeLocTypeDto(Integer staDescId, FindLocNoAttributeVo findLocNoAttributeVo, LocTypeDto locTypeDto) {
+ LocTypeDto normalizedLocTypeDto = locTypeDto == null ? new LocTypeDto() : locTypeDto;
if (!isEmptyPalletRequest(staDescId, findLocNoAttributeVo)) {
- return locTypeDto;
+ normalizedLocTypeDto.setLocType2(null);
+ normalizedLocTypeDto.setLocType3(null);
+ return normalizedLocTypeDto;
}
if (findLocNoAttributeVo != null && Cools.isEmpty(findLocNoAttributeVo.getMatnr())) {
findLocNoAttributeVo.setMatnr("emptyPallet");
}
- LocTypeDto normalizedLocTypeDto = locTypeDto == null ? new LocTypeDto() : locTypeDto;
- // 绌烘墭鐩橀杞笉闄愬埗楂樹綆浣嶏紝鍙繚鐣欌�滅獎搴撲綅浼樺厛鈥濈殑绾︽潫銆�
- normalizedLocTypeDto.setLocType1(null);
normalizedLocTypeDto.setLocType2((short) 1);
return normalizedLocTypeDto;
}
+ private LocTypeDto copyLocTypeDto(LocTypeDto locTypeDto) {
+ if (locTypeDto == null) {
+ return null;
+ }
+ LocTypeDto copied = new LocTypeDto();
+ copied.setLocType1(locTypeDto.getLocType1());
+ copied.setLocType2(locTypeDto.getLocType2());
+ copied.setLocType3(locTypeDto.getLocType3());
+ copied.setSiteId(locTypeDto.getSiteId());
+ return copied;
+ }
+
+ /**
+ * 绌烘墭鐩樺浐瀹氭寜 4 娈靛紡鎵句綅锛�
+ * 1. 涓ユ牸楂樺害 + narrow
+ * 2. 鍚戜笂鍏煎楂樺害 + narrow
+ * 3. 涓ユ牸楂樺害 + open
+ * 4. 鍚戜笂鍏煎楂樺害 + open
+ */
+ private List<LocTypeDto> buildEmptyPalletSearchLocTypes(LocTypeDto locTypeDto) {
+ List<LocTypeDto> searchLocTypes = new ArrayList<LocTypeDto>();
+ LocTypeDto baseLocTypeDto = copyLocTypeDto(locTypeDto == null ? new LocTypeDto() : locTypeDto);
+ if (baseLocTypeDto == null) {
+ return searchLocTypes;
+ }
+
+ LocTypeDto narrowStrictLocType = copyLocTypeDto(baseLocTypeDto);
+ narrowStrictLocType.setLocType2((short) 1);
+ searchLocTypes.add(narrowStrictLocType);
+
+ LocTypeDto narrowCompatibleLocType = buildUpwardCompatibleLocTypeDto(narrowStrictLocType);
+ if (narrowCompatibleLocType != null) {
+ narrowCompatibleLocType.setLocType2((short) 1);
+ searchLocTypes.add(narrowCompatibleLocType);
+ }
+
+ LocTypeDto openStrictLocType = copyLocTypeDto(baseLocTypeDto);
+ openStrictLocType.setLocType2((short) 0);
+ searchLocTypes.add(openStrictLocType);
+
+ LocTypeDto openCompatibleLocType = buildUpwardCompatibleLocTypeDto(openStrictLocType);
+ if (openCompatibleLocType != null) {
+ openCompatibleLocType.setLocType2((short) 0);
+ searchLocTypes.add(openCompatibleLocType);
+ }
+ return searchLocTypes;
+ }
+
+ private String buildEmptyPalletStageCode(LocTypeDto baseLocTypeDto, LocTypeDto stageLocTypeDto) {
+ boolean compatibleHeight = baseLocTypeDto != null
+ && baseLocTypeDto.getLocType1() != null
+ && stageLocTypeDto != null
+ && stageLocTypeDto.getLocType1() != null
+ && !baseLocTypeDto.getLocType1().equals(stageLocTypeDto.getLocType1());
+ boolean narrowOnly = stageLocTypeDto != null
+ && stageLocTypeDto.getLocType2() != null
+ && stageLocTypeDto.getLocType2() == 1;
+ return (compatibleHeight ? "compatible-height" : "strict-height")
+ + "-"
+ + (narrowOnly ? "narrow-only" : "all-locType2");
+ }
+
+ /**
+ * 鍒ゆ柇褰撳墠瑙勬牸鏄惁灞炰簬婊℃墭鎵句綅銆�
+ *
+ * 婊℃墭鍙弬鑰� loc_type1锛屼絾浠嶉渶鏄惧紡鎺掗櫎 loc_type2=1 鐨勭獎搴撲綅銆�
+ */
+ private boolean isFullPalletLocTypeSearch(LocTypeDto locTypeDto) {
+ return locTypeDto != null && locTypeDto.getLocType2() == null && locTypeDto.getLocType3() == null;
+ }
+
+ /**
+ * 鎶� locType 鏉′欢杩藉姞鍒板簱浣嶆煡璇㈡潯浠堕噷銆�
+ */
private Wrapper<LocMast> applyLocTypeFilters(Wrapper<LocMast> wrapper, LocTypeDto locTypeDto, boolean includeLocType1) {
if (wrapper == null || locTypeDto == null) {
return wrapper;
@@ -232,54 +381,40 @@
if (includeLocType1 && locTypeDto.getLocType1() != null && locTypeDto.getLocType1() > 0) {
wrapper.eq("loc_type1", locTypeDto.getLocType1());
}
+ if (isFullPalletLocTypeSearch(locTypeDto)) {
+ wrapper.eq("loc_type2", 0);
+ }
if (locTypeDto.getLocType2() != null && locTypeDto.getLocType2() > 0) {
wrapper.eq("loc_type2", locTypeDto.getLocType2());
}
- if (locTypeDto.getLocType3() != null && locTypeDto.getLocType3() > 0) {
- wrapper.eq("loc_type3", locTypeDto.getLocType3());
- }
+// if (locTypeDto.getLocType3() != null && locTypeDto.getLocType3() > 0) {
+// wrapper.eq("loc_type3", locTypeDto.getLocType3());
+// }
return wrapper;
}
+ /**
+ * 瑙f瀽鏈鎵句綅搴斾紭鍏堜娇鐢ㄧ殑搴撳尯锛岀珯鐐圭粦瀹氫紭鍏堜簬鎺ュ彛浼犲弬銆�
+ */
private Integer resolvePreferredArea(Integer sourceStaNo, FindLocNoAttributeVo findLocNoAttributeVo) {
- BasDevp sourceStation = basDevpService.selectById(sourceStaNo);
- Integer stationArea = parseArea(sourceStation == null ? null : sourceStation.getArea());
+ Integer stationArea = Utils.getStationStorageArea(sourceStaNo);
if (stationArea != null) {
return stationArea;
}
Integer requestArea = findLocNoAttributeVo.getOutArea();
- if (requestArea != null && requestArea >= 1 && requestArea <= 3) {
+ if (isValidArea(requestArea)) {
return requestArea;
}
return null;
}
- private Integer parseArea(String area) {
- if (Cools.isEmpty(area)) {
- return null;
- }
- String normalized = area.trim();
- if (normalized.isEmpty()) {
- return null;
- }
- try {
- int areaNo = Integer.parseInt(normalized);
- return areaNo >= 1 && areaNo <= 3 ? areaNo : null;
- } catch (NumberFormatException ignored) {
- }
- String upper = normalized.toUpperCase(Locale.ROOT);
- if ("A".equals(upper) || "A鍖�".equals(upper) || "A搴�".equals(upper) || "A搴撳尯".equals(upper)) {
- return 1;
- }
- if ("B".equals(upper) || "B鍖�".equals(upper) || "B搴�".equals(upper) || "B搴撳尯".equals(upper)) {
- return 2;
- }
- if ("C".equals(upper) || "C鍖�".equals(upper) || "C搴�".equals(upper) || "C搴撳尯".equals(upper)) {
- return 3;
- }
- return null;
+ private boolean isValidArea(Integer area) {
+ return area != null && area >= 1 && area <= 3;
}
+ /**
+ * 璇诲彇 AGV 鍚勫簱鍖哄搴旂殑鎺掗厤缃��
+ */
private String getAgvAreaRowsConfig(Integer area) {
Parameter parameter = Parameter.get();
if (parameter == null || area == null) {
@@ -297,6 +432,9 @@
}
}
+ /**
+ * 瑙f瀽 AGV 鎸囧畾搴撳尯鐨勬帓椤哄簭锛岀己閰嶇疆鏃跺洖閫�鏃ч粯璁ゆ帓銆�
+ */
private List<Integer> getAgvAreaRows(Integer area, RowLastno rowLastno) {
List<Integer> configuredRows = parseAgvRows(getAgvAreaRowsConfig(area), rowLastno);
if (!configuredRows.isEmpty()) {
@@ -305,6 +443,9 @@
return getLegacyAgvRows(rowLastno);
}
+ /**
+ * 姹囨�� AGV 鎵�鏈夊簱鍖虹殑鍥為��鎺掗『搴忋��
+ */
private List<Integer> getAgvFallbackRows(RowLastno rowLastno) {
LinkedHashSet<Integer> rows = new LinkedHashSet<>();
for (int area = 1; area <= 3; area++) {
@@ -314,6 +455,9 @@
return new ArrayList<>(rows);
}
+ /**
+ * 鎶� AGV 搴撳尯鎺掗厤缃В鏋愭垚鏈夊簭鎺掑彿鍒楄〃銆�
+ */
private List<Integer> parseAgvRows(String configValue, RowLastno rowLastno) {
List<Integer> rows = new ArrayList<>();
if (rowLastno == null || Cools.isEmpty(configValue)) {
@@ -350,6 +494,9 @@
return rows;
}
+ /**
+ * 杩斿洖 AGV 鏃ч�昏緫浣跨敤鐨勯粯璁ゆ帓椤哄簭銆�
+ */
private List<Integer> getLegacyAgvRows(RowLastno rowLastno) {
List<Integer> rows = new ArrayList<>();
if (rowLastno == null) {
@@ -371,6 +518,9 @@
return rows;
}
+ /**
+ * 浠呭湪鎺掑彿钀藉湪浠撳簱鑼冨洿鍐呮椂杩藉姞鍒� AGV 鎺掑垪琛ㄣ��
+ */
private void addAgvRow(LinkedHashSet<Integer> rows, Integer row, RowLastno rowLastno) {
if (rows == null || row == null || rowLastno == null) {
return;
@@ -381,6 +531,9 @@
rows.add(row);
}
+ /**
+ * 瀹夊叏瑙f瀽鏁存暟閰嶇疆锛屽け璐ユ椂杩斿洖 null銆�
+ */
private Integer safeParseInt(String value) {
if (Cools.isEmpty(value)) {
return null;
@@ -392,6 +545,9 @@
}
}
+ /**
+ * 杩斿洖 AGV 鍚勫簱鍖哄搴旂殑 bay 鑼冨洿銆�
+ */
private int[] getAgvAreaBayRange(Integer area) {
if (area == null) {
return new int[]{1, 19};
@@ -408,9 +564,18 @@
}
}
+ /**
+ * 鎸夋寚瀹氭帓鍜� bay 鑼冨洿椤哄簭鎼滅储 AGV 鍙敤搴撲綅銆�
+ */
private LocMast findAgvLocByRows(RowLastno rowLastno, RowLastnoType rowLastnoType, List<Integer> rows,
int startBay, int endBay, int curRow, int nearRow,
LocTypeDto locTypeDto, boolean useDeepCheck) {
+ return findAgvLocByRows(rowLastno, rowLastnoType, rows, startBay, endBay, curRow, nearRow, locTypeDto, null, useDeepCheck);
+ }
+
+ private LocMast findAgvLocByRows(RowLastno rowLastno, RowLastnoType rowLastnoType, List<Integer> rows,
+ int startBay, int endBay, int curRow, int nearRow,
+ LocTypeDto locTypeDto, FindLocNoAttributeVo findLocNoAttributeVo, boolean useDeepCheck) {
for (Integer row : rows) {
if (row == null) {
continue;
@@ -423,7 +588,8 @@
applyLocTypeFilters(wrapper, locTypeDto, true);
wrapper.orderBy("lev1", true).orderBy("bay1", true);
List<LocMast> locMasts = locMastService.selectList(wrapper);
- for (LocMast candidate : locMasts) {
+ List<LocMast> sortedLocMasts = sortLocCandidates(locMasts, findLocNoAttributeVo);
+ for (LocMast candidate : sortedLocMasts) {
if (!VersionUtils.locMoveCheckLocTypeComplete(candidate, locTypeDto)) {
continue;
}
@@ -442,6 +608,10 @@
}
return null;
}
+
+ /**
+ * 璇诲彇 run2 鍚勫簱鍖哄搴旂殑鎺掗厤缃紝缂哄け鏃跺鐢� AGV 搴撳尯閰嶇疆銆�
+ */
private String getRun2AreaRowsConfig(Integer area) {
Parameter parameter = Parameter.get();
if (parameter == null || area == null) {
@@ -464,6 +634,9 @@
return Cools.isEmpty(run2Config) ? getAgvAreaRowsConfig(area) : run2Config;
}
+ /**
+ * 瑙f瀽 run2 鎸囧畾搴撳尯鐨勬帓椤哄簭锛岀己閰嶇疆鏃跺洖閫�鏃ч粯璁ゆ帓銆�
+ */
private List<Integer> getRun2AreaRows(Integer area, RowLastno rowLastno) {
List<Integer> configuredRows = parseAgvRows(getRun2AreaRowsConfig(area), rowLastno);
if (!configuredRows.isEmpty()) {
@@ -472,6 +645,9 @@
return getLegacyAgvRows(rowLastno);
}
+ /**
+ * 姹囨�� run2 鍏跺畠搴撳尯鐨勫洖閫�鎺掗『搴忋��
+ */
private List<Integer> getRun2FallbackRows(RowLastno rowLastno) {
LinkedHashSet<Integer> rows = new LinkedHashSet<>();
for (int area = 1; area <= 3; area++) {
@@ -481,29 +657,103 @@
return new ArrayList<>(rows);
}
+ /**
+ * 瑙f瀽 run2 鐨勮捣濮嬪爢鍨涙満鍙凤紝浼樺厛浣跨敤 currentCrnNo銆�
+ */
private Integer resolveRun2CrnNo(RowLastno rowLastno) {
if (rowLastno == null) {
return null;
}
- Integer currentRow = rowLastno.getCurrentRow();
+ Integer startCrnNo = getRun2StartCrnNo(rowLastno);
+ Integer endCrnNo = getRun2EndCrnNo(rowLastno);
+ Integer currentCrnNo = rowLastno.getCurrentCrnNo();
+ if (currentCrnNo == null || currentCrnNo <= 0 || currentCrnNo < startCrnNo) {
+ return startCrnNo;
+ }
+ if (endCrnNo != null && currentCrnNo > endCrnNo) {
+ return startCrnNo;
+ }
+ return currentCrnNo;
+ }
+
+ private Integer getRun2StartCrnNo(RowLastno rowLastno) {
+ if (rowLastno == null || rowLastno.getsCrnNo() == null) {
+ return 1;
+ }
+ return rowLastno.getsCrnNo();
+ }
+
+ private Integer getRun2EndCrnNo(RowLastno rowLastno) {
+ if (rowLastno == null) {
+ return null;
+ }
+ Integer startCrnNo = getRun2StartCrnNo(rowLastno);
+ if (rowLastno.geteCrnNo() != null && rowLastno.geteCrnNo() >= startCrnNo) {
+ return rowLastno.geteCrnNo();
+ }
+ int crnCount = resolveCrnCount(rowLastno);
+ if (crnCount <= 0) {
+ return startCrnNo;
+ }
+ return startCrnNo + crnCount - 1;
+ }
+
+ /**
+ * 鍏煎鏃� currentRow 娓告爣锛屾妸鎺掑彿鎹㈢畻鎴愬搴旂殑鍫嗗灈鏈哄彿銆�
+ */
+ private Integer resolveRun2CrnNoByCurrentRow(RowLastno rowLastno, Integer currentRow) {
+ if (rowLastno == null) {
+ return null;
+ }
Integer rowSpan = getCrnRowSpan(rowLastno.getTypeId());
if (rowSpan == null || rowSpan <= 0) {
rowSpan = 2;
}
int startRow = rowLastno.getsRow() == null ? 1 : rowLastno.getsRow();
- int startCrnNo = rowLastno.getsCrnNo() == null ? 1 : rowLastno.getsCrnNo();
- if (currentRow == null) {
+ int startCrnNo = getRun2StartCrnNo(rowLastno);
+ if (currentRow == null || currentRow <= 0) {
return startCrnNo;
}
int offset = Math.max(currentRow - startRow, 0) / rowSpan;
int crnNo = startCrnNo + offset;
- Integer endCrnNo = rowLastno.geteCrnNo();
+ Integer endCrnNo = getRun2EndCrnNo(rowLastno);
if (endCrnNo != null && crnNo > endCrnNo) {
return startCrnNo;
}
return crnNo;
}
+ private Integer getNextSequentialRun2CrnNo(RowLastno rowLastno, Integer currentCrnNo) {
+ if (rowLastno == null) {
+ return null;
+ }
+ Integer startCrnNo = getRun2StartCrnNo(rowLastno);
+ Integer endCrnNo = getRun2EndCrnNo(rowLastno);
+ if (currentCrnNo == null || currentCrnNo < startCrnNo) {
+ return startCrnNo;
+ }
+ if (endCrnNo != null && currentCrnNo >= endCrnNo) {
+ return startCrnNo;
+ }
+ return currentCrnNo + 1;
+ }
+
+ /**
+ * 瑙f瀽 run2 涓嬩竴杞簲浠庡摢鍙板爢鍨涙満寮�濮嬨��
+ */
+ private Integer getNextRun2CurrentCrnNo(RowLastno rowLastno, List<Integer> runnableCrnNos, Integer selectedCrnNo) {
+ if (!Cools.isEmpty(runnableCrnNos) && selectedCrnNo != null) {
+ int index = runnableCrnNos.indexOf(selectedCrnNo);
+ if (index >= 0) {
+ return runnableCrnNos.get((index + 1) % runnableCrnNos.size());
+ }
+ }
+ return getNextSequentialRun2CrnNo(rowLastno, resolveRun2CrnNo(rowLastno));
+ }
+
+ /**
+ * 鍦ㄦ暣浠撹疆璇㈡ā寮忎笅鎺ㄨ繘鍒颁笅涓�鍙板爢鍨涙満瀵瑰簲鐨勮捣濮嬫帓銆�
+ */
private int getNextRun2CurrentRow(RowLastno rowLastno, int currentRow) {
Integer rowSpan = getCrnRowSpan(rowLastno.getTypeId());
if (rowSpan == null || rowSpan <= 0) {
@@ -518,6 +768,9 @@
return currentRow + rowSpan;
}
+ /**
+ * 浠庢寚瀹氳捣鐐瑰紑濮嬬敓鎴愬畬鏁寸殑鍫嗗灈鏈鸿疆璇㈤『搴忋��
+ */
private List<Integer> getOrderedCrnNos(RowLastno rowLastno, Integer startCrnNo) {
List<Integer> orderedCrnNos = new ArrayList<>();
if (rowLastno == null) {
@@ -579,6 +832,26 @@
}
/**
+ * 鎸夆�滃彲鍏� + 鑷姩杩炵嚎 + 鏃犳晠闅溾�濆垽鏂爢鍨涙満鏄惁鍦ㄧ嚎鍙垎閰嶃��
+ */
+ private boolean isCrnActive(Integer crnNo) {
+ if (crnNo == null) {
+ return false;
+ }
+ BasCrnp basCrnp = basCrnpService.selectById(crnNo);
+ if (Cools.isEmpty(basCrnp)) {
+ return false;
+ }
+ if (!"Y".equalsIgnoreCase(basCrnp.getInEnable())) {
+ return false;
+ }
+ if (basCrnp.getCrnSts() == null || basCrnp.getCrnSts() != 3) {
+ return false;
+ }
+ return basCrnp.getCrnErr() == null || basCrnp.getCrnErr() == 0;
+ }
+
+ /**
* 鍒ゆ柇鏌愬彴鍫嗗灈鏈烘槸鍚﹀彲浠ュ弬涓� run2 鍏ュ簱鎵句綅銆�
*
* routeRequired=true:
@@ -593,20 +866,7 @@
}
private boolean canRun2CrnAcceptPakin(RowLastno rowLastno, Integer staDescId, Integer sourceStaNo, Integer crnNo, boolean routeRequired) {
- if (crnNo == null) {
- return false;
- }
- BasCrnp basCrnp = basCrnpService.selectById(crnNo);
- if (Cools.isEmpty(basCrnp)) {
- return false;
- }
- if (!"Y".equals(basCrnp.getInEnable())) {
- return false;
- }
- if (basCrnp.getCrnSts() != null && basCrnp.getCrnSts() != 3) {
- return false;
- }
- if (basCrnp.getCrnErr() != null && basCrnp.getCrnErr() != 0) {
+ if (!isCrnActive(crnNo)) {
return false;
}
if (!routeRequired) {
@@ -619,11 +879,7 @@
.eq("type_no", staDescId)
.eq("stn_no", sourceStaNo)
.eq("crn_no", crnNo));
- if (Cools.isEmpty(staDesc)) {
- return false;
- }
- BasDevp targetSta = basDevpService.selectById(staDesc.getCrnStn());
- return !Cools.isEmpty(targetSta) && "Y".equals(targetSta.getAutoing());
+ return !Cools.isEmpty(staDesc) && !Cools.isEmpty(staDesc.getCrnStn());
}
/**
@@ -662,19 +918,393 @@
return nextRow == null ? getNextRun2CurrentRow(rowLastno, currentRow) : nextRow;
}
+ private Run2Cursor getNextRun2Cursor(RowLastno rowLastno, List<Integer> runnableCrnNos, Integer selectedCrnNo, int currentRow) {
+ if (rowLastno == null) {
+ return null;
+ }
+ Integer nextCrnNo = getNextRun2CurrentCrnNo(rowLastno, runnableCrnNos, selectedCrnNo);
+ Integer nextRow = nextCrnNo == null ? null : getCrnStartRow(rowLastno, nextCrnNo);
+ if (nextRow == null) {
+ int baseRow = currentRow == 0 ? (rowLastno.getsRow() == null ? 1 : rowLastno.getsRow()) : currentRow;
+ nextRow = getNextRun2CurrentRow(rowLastno, baseRow);
+ nextCrnNo = resolveRun2CrnNoByCurrentRow(rowLastno, nextRow);
+ }
+ return new Run2Cursor(nextRow, nextCrnNo);
+ }
+
+ private void updateRun2Cursor(RowLastno rowLastno, List<Integer> runnableCrnNos, Integer selectedCrnNo, int currentRow) {
+ if (rowLastno == null) {
+ return;
+ }
+ Run2Cursor nextCursor = getNextRun2Cursor(rowLastno, runnableCrnNos, selectedCrnNo, currentRow);
+ if (nextCursor == null) {
+ return;
+ }
+ rowLastno.setCurrentRow(nextCursor.currentRow);
+ rowLastno.setCurrentCrnNo(nextCursor.currentCrnNo);
+ rowLastnoService.updateById(rowLastno);
+ }
+
+ /**
+ * 璇诲彇绔欑偣閰嶇疆鐨勪紭鍏堟睜鍫嗗灈鏈哄彿骞跺仛鍘婚噸銆�
+ */
+ private List<Integer> loadPriorityCrnNos(String csv) {
+ return Utils.distinctCrnNos(csv);
+ }
+
+ /**
+ * 浠庡�欓�夊爢鍨涙満姹犱腑绉婚櫎宸茬粡鍑虹幇鍦ㄦ帓闄ゅ垪琛ㄩ噷鐨勫爢鍨涙満锛屼繚鎸佸師濮嬮『搴忎笉鍙樸��
+ */
+ private List<Integer> excludePriorityCrnNos(List<Integer> crnNos, List<Integer> excludedCrnNos) {
+ List<Integer> result = new ArrayList<Integer>();
+ if (Cools.isEmpty(crnNos)) {
+ return result;
+ }
+ LinkedHashSet<Integer> excludedCrnNoSet = new LinkedHashSet<Integer>(Utils.distinctCrnNos(excludedCrnNos));
+ for (Integer crnNo : Utils.distinctCrnNos(crnNos)) {
+ if (crnNo == null || excludedCrnNoSet.contains(crnNo)) {
+ continue;
+ }
+ result.add(crnNo);
+ }
+ return result;
+ }
+
+ /**
+ * 浠庡綋鍓嶆父鏍囩殑涓嬩竴鍙板爢鍨涙満寮�濮嬭疆杞��
+ */
+ private List<Integer> rotatePriorityCrnNos(List<Integer> crnNos, Integer currentCrnNo) {
+ List<Integer> orderedCrnNos = Utils.distinctCrnNos(crnNos);
+ if (Cools.isEmpty(orderedCrnNos) || currentCrnNo == null) {
+ return orderedCrnNos;
+ }
+ int currentIndex = orderedCrnNos.indexOf(currentCrnNo);
+ if (currentIndex < 0) {
+ return orderedCrnNos;
+ }
+ List<Integer> rotatedCrnNos = new ArrayList<>();
+ for (int index = currentIndex + 1; index < orderedCrnNos.size(); index++) {
+ rotatedCrnNos.add(orderedCrnNos.get(index));
+ }
+ for (int index = 0; index <= currentIndex; index++) {
+ rotatedCrnNos.add(orderedCrnNos.get(index));
+ }
+ return rotatedCrnNos;
+ }
+
+ /**
+ * 鎸夌涓�浼樺厛姹� -> 绗簩浼樺厛姹犵殑椤哄簭鏌ユ壘鍙敤搴撲綅銆�
+ */
+ private LocMast findRun2PriorityLocInPools(BasDevp station, RowLastno rowLastno, RowLastnoType rowLastnoType,
+ Integer staDescId, Integer sourceStaNo, FindLocNoAttributeVo findLocNoAttributeVo,
+ LocTypeDto locTypeDto, StartupDto startupDto, boolean emptyPalletRequest) {
+ if (station == null) {
+ return null;
+ }
+ List<Integer> firstPoolCrnNos = loadPriorityCrnNos(station.getInFirstCrnCsv());
+ List<Integer> secondPoolCrnNos = excludePriorityCrnNos(loadPriorityCrnNos(station.getInSecondCrnCsv()), firstPoolCrnNos);
+ if (Cools.isEmpty(firstPoolCrnNos) && Cools.isEmpty(secondPoolCrnNos)) {
+ throw new CoolException("绔欑偣=" + station.getDevNo() + " 鏈厤缃叆搴撲紭鍏堝爢鍨涙満");
+ }
+
+ if (emptyPalletRequest) {
+ for (int poolNo = 1; poolNo <= 2; poolNo++) {
+ List<Integer> poolCrnNos = poolNo == 1 ? firstPoolCrnNos : secondPoolCrnNos;
+ Integer currentCrnNo = poolNo == 1 ? station.getInFirstCrnCurrentNo() : station.getInSecondCrnCurrentNo();
+ for (LocTypeDto searchLocTypeDto : buildEmptyPalletSearchLocTypes(locTypeDto)) {
+ LocMast locMast = findRun2PriorityLocInPool(rowLastno, rowLastnoType, station, poolCrnNos, currentCrnNo,
+ poolNo, searchLocTypeDto, staDescId, sourceStaNo, findLocNoAttributeVo, startupDto, true);
+ if (locMast != null) {
+ return locMast;
+ }
+ }
+ }
+ return null;
+ }
+
+ LocMast locMast = findRun2PriorityLocInPoolWithCompatibility(rowLastno, rowLastnoType, station, firstPoolCrnNos,
+ station.getInFirstCrnCurrentNo(), 1, locTypeDto, staDescId, sourceStaNo, findLocNoAttributeVo, startupDto, false);
+ if (locMast != null) {
+ return locMast;
+ }
+ return findRun2PriorityLocInPoolWithCompatibility(rowLastno, rowLastnoType, station, secondPoolCrnNos,
+ station.getInSecondCrnCurrentNo(), 2, locTypeDto, staDescId, sourceStaNo, findLocNoAttributeVo, startupDto, false);
+ }
+
+ /**
+ * 鍦ㄥ崟涓紭鍏堟睜鍐呮寜杞浆椤哄簭鎵句綅銆�
+ */
+ private LocMast findRun2PriorityLocInPool(RowLastno rowLastno, RowLastnoType rowLastnoType, BasDevp station,
+ List<Integer> crnNos, Integer currentCrnNo, int poolNo, LocTypeDto locTypeDto,
+ Integer staDescId, Integer sourceStaNo, FindLocNoAttributeVo findLocNoAttributeVo,
+ StartupDto startupDto) {
+ return findRun2PriorityLocInPool(rowLastno, rowLastnoType, station, crnNos, currentCrnNo, poolNo, locTypeDto,
+ staDescId, sourceStaNo, findLocNoAttributeVo, startupDto, false);
+ }
+
+ private LocMast findRun2PriorityLocInPool(RowLastno rowLastno, RowLastnoType rowLastnoType, BasDevp station,
+ List<Integer> crnNos, Integer currentCrnNo, int poolNo, LocTypeDto locTypeDto,
+ Integer staDescId, Integer sourceStaNo, FindLocNoAttributeVo findLocNoAttributeVo,
+ StartupDto startupDto, boolean ignoreFreqType) {
+ if (Cools.isEmpty(crnNos)) {
+ return null;
+ }
+ List<Integer> rotatedCrnNos = rotatePriorityCrnNos(crnNos, currentCrnNo);
+ if (Cools.isEmpty(rotatedCrnNos)) {
+ return null;
+ }
+ for (Integer candidateCrnNo : rotatedCrnNos) {
+ if (candidateCrnNo == null || !basCrnpService.checkSiteError(candidateCrnNo, true)) {
+ continue;
+ }
+ Integer targetStaNo = resolveTargetStaNo(rowLastno, staDescId, sourceStaNo, candidateCrnNo);
+ if (Utils.BooleanWhsTypeSta(rowLastno, staDescId) && targetStaNo == null) {
+ continue;
+ }
+ Integer preferredNearRow = getCrnStartRow(rowLastno, candidateCrnNo);
+ LocMast candidateLoc = findConfiguredEmptyLocForCrn(rowLastno, rowLastnoType, candidateCrnNo,
+ preferredNearRow, locTypeDto, findLocNoAttributeVo, ignoreFreqType);
+ if (Cools.isEmpty(candidateLoc)) {
+ continue;
+ }
+ if (!updatePriorityCursor(station, poolNo, currentCrnNo, candidateCrnNo)) {
+ throw new CoolException("绔欑偣=" + station.getDevNo() + " 浼樺厛姹犺疆杞洿鏂板け璐ワ紝璇烽噸璇�");
+ }
+ if (targetStaNo != null) {
+ startupDto.setStaNo(targetStaNo);
+ }
+ return candidateLoc;
+ }
+ return null;
+ }
+
+ /**
+ * 鍦ㄥ崟涓紭鍏堟睜鍐呭厛鎸夊綋鍓嶈鏍兼壘浣嶏紝澶辫触鍚庡啀鍋氫竴娆� locType1 鍚戜笂鍏煎銆�
+ */
+ private LocMast findRun2PriorityLocInPoolWithCompatibility(RowLastno rowLastno, RowLastnoType rowLastnoType,
+ BasDevp station, List<Integer> crnNos, Integer currentCrnNo,
+ int poolNo, LocTypeDto locTypeDto, Integer staDescId,
+ Integer sourceStaNo, FindLocNoAttributeVo findLocNoAttributeVo,
+ StartupDto startupDto, boolean ignoreFreqType) {
+ LocMast locMast = findRun2PriorityLocInPool(rowLastno, rowLastnoType, station, crnNos, currentCrnNo, poolNo,
+ locTypeDto, staDescId, sourceStaNo, findLocNoAttributeVo, startupDto, ignoreFreqType);
+ if (locMast != null) {
+ return locMast;
+ }
+ LocTypeDto compatibleLocTypeDto = buildRetryCompatibleLocTypeDto(staDescId, findLocNoAttributeVo, locTypeDto);
+ if (compatibleLocTypeDto == null) {
+ return null;
+ }
+ return findRun2PriorityLocInPool(rowLastno, rowLastnoType, station, crnNos, currentCrnNo, poolNo,
+ compatibleLocTypeDto, staDescId, sourceStaNo, findLocNoAttributeVo, startupDto, ignoreFreqType);
+ }
+
+ /**
+ * 浠ヤ箰瑙傛柟寮忓洖鍐欎紭鍏堟睜娓告爣銆�
+ */
+ private boolean updatePriorityCursor(BasDevp station, int poolNo, Integer expectedCurrentNo, Integer selectedCrnNo) {
+ if (station == null || station.getDevNo() == null || selectedCrnNo == null) {
+ return false;
+ }
+ BasDevp updateStation = new BasDevp();
+ String cursorColumn;
+ if (poolNo == 1) {
+ updateStation.setInFirstCrnCurrentNo(selectedCrnNo);
+ cursorColumn = "in_first_crn_current_no";
+ } else {
+ updateStation.setInSecondCrnCurrentNo(selectedCrnNo);
+ cursorColumn = "in_second_crn_current_no";
+ }
+ EntityWrapper<BasDevp> wrapper = new EntityWrapper<>();
+ wrapper.eq("dev_no", station.getDevNo());
+ if (expectedCurrentNo == null) {
+ wrapper.isNull(cursorColumn);
+ } else {
+ wrapper.eq(cursorColumn, expectedCurrentNo);
+ }
+ if (basDevpService.update(updateStation, wrapper)) {
+ return true;
+ }
+ BasDevp latestStation = basDevpService.selectById(station.getDevNo());
+ if (latestStation == null) {
+ return false;
+ }
+ Integer latestCurrentNo = poolNo == 1 ? latestStation.getInFirstCrnCurrentNo() : latestStation.getInSecondCrnCurrentNo();
+ return Objects.equals(latestCurrentNo, selectedCrnNo);
+ }
+
+ /**
+ * 缁勮浼樺厛姹犻瑙堟暟鎹��
+ */
+ private Map<String, Object> buildPriorityPoolPreview(RowLastno rowLastno, RowLastnoType rowLastnoType, int poolNo,
+ List<Integer> crnNos, Integer currentCrnNo, Integer staDescId,
+ Integer sourceStaNo, LocTypeDto locTypeDto,
+ FindLocNoAttributeVo findLocNoAttributeVo) {
+ return buildPriorityPoolPreview(rowLastno, rowLastnoType, poolNo, crnNos, currentCrnNo, staDescId, sourceStaNo,
+ locTypeDto, findLocNoAttributeVo, false);
+ }
+
+ private Map<String, Object> buildPriorityPoolPreview(RowLastno rowLastno, RowLastnoType rowLastnoType, int poolNo,
+ List<Integer> crnNos, Integer currentCrnNo, Integer staDescId,
+ Integer sourceStaNo, LocTypeDto locTypeDto,
+ FindLocNoAttributeVo findLocNoAttributeVo, boolean ignoreFreqType) {
+ Map<String, Object> item = new HashMap<String, Object>();
+ List<Integer> configuredCrnNos = Utils.distinctCrnNos(crnNos);
+ List<Integer> rotatedCrnNos = rotatePriorityCrnNos(configuredCrnNos, currentCrnNo);
+ item.put("poolNo", poolNo);
+ item.put("currentCrnNo", currentCrnNo);
+ item.put("configuredCrnNos", configuredCrnNos);
+ item.put("rotatedCrnNos", rotatedCrnNos);
+ item.put("runnableCrnNos", getOrderedRunnableRun2CrnNos(rowLastno, staDescId, sourceStaNo, rotatedCrnNos));
+ item.put("profiles", buildRun2ProfilePreview(rowLastno, rowLastnoType, rotatedCrnNos, staDescId, sourceStaNo,
+ locTypeDto, findLocNoAttributeVo, ignoreFreqType));
+ return item;
+ }
+
/**
* 鏋勯�犵┖鎵樼洏璺ㄥ簱鍖烘悳绱㈤『搴忥細
- * 鍏堝綋鍓嶅簱鍖猴紝鍐嶄緷娆¤ˉ瓒冲叾瀹冨簱鍖猴紝閬垮厤閲嶅銆�
+ * 鍏堢珯鐐圭粦瀹氬簱鍖猴紝鍐嶈ˉ璇锋眰搴撳尯锛屾渶鍚庡洖閫�鍏ㄤ粨搴撳尯锛岄伩鍏嶉噸澶嶃��
*/
- private List<Integer> buildAreaSearchOrder(Integer preferredArea) {
+ private List<Integer> buildAreaSearchOrder(List<Integer> preferredAreas, Integer requestArea) {
LinkedHashSet<Integer> areaOrder = new LinkedHashSet<>();
- if (preferredArea != null && preferredArea >= 1 && preferredArea <= 3) {
- areaOrder.add(preferredArea);
+ if (!Cools.isEmpty(preferredAreas)) {
+ for (Integer area : preferredAreas) {
+ if (isValidArea(area)) {
+ areaOrder.add(area);
+ }
+ }
+ }
+ if (isValidArea(requestArea)) {
+ areaOrder.add(requestArea);
}
for (int area = 1; area <= 3; area++) {
areaOrder.add(area);
}
return new ArrayList<>(areaOrder);
+ }
+
+ /**
+ * 棰勮 run2 褰撳墠浼氬弬涓庣殑浼樺厛姹犮�佸爢鍨涙満椤哄簭鍜屾繁娴呮帓鐢诲儚锛屼笉钀戒换鍔℃。銆�
+ */
+ public Map<String, Object> previewRun2Allocation(BasCrnDepthRuleRuntimePreviewParam param) {
+ if (param == null || param.getStaDescId() == null || param.getSourceStaNo() == null) {
+ throw new CoolException("璺緞ID鍜屾簮绔欎笉鑳戒负绌�");
+ }
+ FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo();
+ findLocNoAttributeVo.setMatnr(param.getMatnr());
+ findLocNoAttributeVo.setOutArea(param.getOutArea());
+ findLocNoAttributeVo.setFreqType(param.getFreqType());
+
+ LocTypeDto locTypeDto = new LocTypeDto();
+ locTypeDto.setLocType1(param.getLocType1());
+ locTypeDto.setLocType2(param.getLocType2());
+ locTypeDto.setLocType3(param.getLocType3());
+ locTypeDto = normalizeLocTypeDto(param.getStaDescId(), findLocNoAttributeVo, locTypeDto);
+
+ Integer whsType = Utils.GetWhsType(param.getSourceStaNo());
+ RowLastno rowLastno = rowLastnoService.selectById(whsType);
+ if (Cools.isEmpty(rowLastno)) {
+ throw new CoolException("鏈壘鍒颁粨搴撹疆璇㈣鍒�");
+ }
+ RowLastnoType rowLastnoType = rowLastnoTypeService.selectById(rowLastno.getTypeId());
+ List<Integer> stationAreas = Utils.getStationStorageAreas(param.getSourceStaNo());
+ boolean emptyPalletRequest = isEmptyPalletRequest(param.getStaDescId(), findLocNoAttributeVo);
+ BasDevp station = basDevpService.selectById(param.getSourceStaNo());
+ if (Cools.isEmpty(station)) {
+ throw new CoolException("绔欑偣=" + param.getSourceStaNo() + " 鏈厤缃叆搴撲紭鍏堝爢鍨涙満");
+ }
+ List<Integer> firstPoolCrnNos = loadPriorityCrnNos(station.getInFirstCrnCsv());
+ List<Integer> secondPoolCrnNos = excludePriorityCrnNos(loadPriorityCrnNos(station.getInSecondCrnCsv()), firstPoolCrnNos);
+
+ Map<String, Object> result = new HashMap<String, Object>();
+ result.put("whsType", whsType);
+ result.put("preferredArea", findLocNoAttributeVo.getOutArea());
+ result.put("preferredAreas", stationAreas);
+ result.put("emptyPallet", emptyPalletRequest);
+ result.put("locType", locTypeDto);
+ result.put("stationPriorityEntries", Utils.getStationStorageAreaName(
+ param.getSourceStaNo(),
+ locTypeDto == null || locTypeDto.getLocType1() == null ? null : locTypeDto.getLocType1().intValue(),
+ findLocNoAttributeVo.getMatnr()));
+ result.put("firstPriorityCrnNos", firstPoolCrnNos);
+ result.put("secondPriorityCrnNos", secondPoolCrnNos);
+ result.put("firstPriorityCurrentNo", station.getInFirstCrnCurrentNo());
+ result.put("secondPriorityCurrentNo", station.getInSecondCrnCurrentNo());
+ result.put("firstPriorityRotatedCrnNos", rotatePriorityCrnNos(firstPoolCrnNos, station.getInFirstCrnCurrentNo()));
+ result.put("secondPriorityRotatedCrnNos", rotatePriorityCrnNos(secondPoolCrnNos, station.getInSecondCrnCurrentNo()));
+
+ List<Integer> orderedCrnNos = getOrderedCrnNos(rowLastno, resolveRun2CrnNo(rowLastno));
+ List<Integer> runnableCrnNos = getOrderedRunnableRun2CrnNos(rowLastno, param.getStaDescId(), param.getSourceStaNo(), orderedCrnNos);
+ result.put("orderedCrnNos", orderedCrnNos);
+ result.put("runnableCrnNos", runnableCrnNos);
+ List<Map<String, Object>> poolPreviews = new ArrayList<Map<String, Object>>();
+
+ if (emptyPalletRequest) {
+ for (int poolNo = 1; poolNo <= 2; poolNo++) {
+ List<Integer> poolCrnNos = poolNo == 1 ? firstPoolCrnNos : secondPoolCrnNos;
+ Integer currentCrnNo = poolNo == 1 ? station.getInFirstCrnCurrentNo() : station.getInSecondCrnCurrentNo();
+ Map<String, Object> poolPreview = buildPriorityPoolPreview(rowLastno, rowLastnoType, poolNo, poolCrnNos,
+ currentCrnNo, param.getStaDescId(), param.getSourceStaNo(), locTypeDto, findLocNoAttributeVo, true);
+ List<Map<String, Object>> stagePreviews = new ArrayList<Map<String, Object>>();
+ for (LocTypeDto stageLocTypeDto : buildEmptyPalletSearchLocTypes(locTypeDto)) {
+ Map<String, Object> stagePreview = buildPriorityPoolPreview(rowLastno, rowLastnoType, poolNo, poolCrnNos,
+ currentCrnNo, param.getStaDescId(), param.getSourceStaNo(), stageLocTypeDto, findLocNoAttributeVo, true);
+ stagePreview.put("stageCode", buildEmptyPalletStageCode(locTypeDto, stageLocTypeDto));
+ stagePreview.put("locType", stageLocTypeDto);
+ stagePreviews.add(stagePreview);
+ }
+ poolPreview.put("stagePreviews", stagePreviews);
+ poolPreviews.add(poolPreview);
+ }
+ result.put("poolPreviews", poolPreviews);
+ return result;
+ }
+
+ poolPreviews.add(buildPriorityPoolPreview(rowLastno, rowLastnoType, 1, firstPoolCrnNos,
+ station.getInFirstCrnCurrentNo(), param.getStaDescId(), param.getSourceStaNo(), locTypeDto,
+ findLocNoAttributeVo));
+ poolPreviews.add(buildPriorityPoolPreview(rowLastno, rowLastnoType, 2, secondPoolCrnNos,
+ station.getInSecondCrnCurrentNo(), param.getStaDescId(), param.getSourceStaNo(), locTypeDto,
+ findLocNoAttributeVo));
+ result.put("poolPreviews", poolPreviews);
+ return result;
+ }
+
+ /**
+ * 缁勮鏌愭壒鍫嗗灈鏈虹殑杩愯鏃剁敾鍍忛瑙堟暟鎹��
+ */
+ private List<Map<String, Object>> buildRun2ProfilePreview(RowLastno rowLastno, RowLastnoType rowLastnoType, List<Integer> crnNos,
+ Integer staDescId, Integer sourceStaNo, LocTypeDto locTypeDto,
+ FindLocNoAttributeVo findLocNoAttributeVo) {
+ return buildRun2ProfilePreview(rowLastno, rowLastnoType, crnNos, staDescId, sourceStaNo, locTypeDto, findLocNoAttributeVo, false);
+ }
+
+ private List<Map<String, Object>> buildRun2ProfilePreview(RowLastno rowLastno, RowLastnoType rowLastnoType, List<Integer> crnNos,
+ Integer staDescId, Integer sourceStaNo, LocTypeDto locTypeDto,
+ FindLocNoAttributeVo findLocNoAttributeVo, boolean ignoreFreqType) {
+ List<Map<String, Object>> profiles = new ArrayList<Map<String, Object>>();
+ if (Cools.isEmpty(crnNos)) {
+ return profiles;
+ }
+ for (Integer crnNo : crnNos) {
+ CrnDepthRuleProfile profile = basCrnDepthRuleService.resolveProfile(rowLastno, crnNo, getCrnStartRow(rowLastno, crnNo));
+ Map<String, Object> item = new HashMap<String, Object>();
+ item.put("crnNo", crnNo);
+ item.put("active", isCrnActive(crnNo));
+ item.put("targetStaNo", resolveTargetStaNo(rowLastno, staDescId, sourceStaNo, crnNo));
+ item.put("layoutType", profile == null ? null : profile.getLayoutType());
+ item.put("source", profile == null ? null : profile.getSource());
+ item.put("searchRows", profile == null ? null : profile.getSearchRows());
+ item.put("shallowRows", profile == null ? null : profile.getShallowRows());
+ item.put("deepRows", profile == null ? null : profile.getDeepRows());
+ LocMast firstMatchLoc = findConfiguredEmptyLocForCrn(rowLastno, rowLastnoType, crnNo,
+ getCrnStartRow(rowLastno, crnNo), locTypeDto, findLocNoAttributeVo, ignoreFreqType);
+ item.put("firstMatchLocNo", firstMatchLoc == null ? null : firstMatchLoc.getLocNo());
+ item.put("assignableLocCount", countAssignableLocForCrn(rowLastno, rowLastnoType, crnNo,
+ getCrnStartRow(rowLastno, crnNo) == null ? 0 : getCrnStartRow(rowLastno, crnNo), locTypeDto));
+ profiles.add(item);
+ }
+ return profiles;
}
/**
@@ -696,16 +1326,34 @@
* 绌烘墭鐩� run2 涓撶敤鎼滅储閾捐矾銆�
*
* 鎵ц椤哄簭锛�
- * 1. 鍏堟寜绔欑偣缁戝畾搴撳尯鎵� loc_type2=1銆�
- * 2. 褰撳墠搴撳尯娌℃湁锛屽啀鎸夊叾瀹冨簱鍖虹户缁壘 loc_type2=1銆�
+ * 1. 鍏堟寜鍥哄畾瑙勬牸闃舵鏋勯�� 4 娈靛紡 locType 鍥為��椤哄簭銆�
+ * 2. 姣忎釜瑙勬牸闃舵閮芥寜鈥滃綋鍓嶅簱鍖� -> 鍏跺畠搴撳尯鈥濈殑椤哄簭鎼滅储銆�
* 3. 姣忎釜搴撳尯鍐呴儴閮芥寜璇ュ簱鍖鸿嚜宸辩殑 rowLastno/currentRow 鍋氳疆璇㈠潎鍒嗐��
*
* 杩欓噷鏁呮剰涓嶅鐢ㄦ櫘閫� run2 鐨勨�滄帹鑽愭帓 -> 褰撳墠搴撳尯鎺� -> 鍏跺畠鎺掆�濋�昏緫锛�
* 鍥犱负绌烘墭鐩樼殑涓氬姟鍙e緞宸茬粡鍒囨崲鎴愨�滄寜搴撳尯鎵惧爢鍨涙満鈥濓紝涓嶆槸鎸夋帹鑽愭帓鎵惧贩閬撱��
*/
+ private Run2AreaSearchResult findEmptyPalletRun2Loc(RowLastno defaultRowLastno, Integer staDescId, Integer sourceStaNo,
+ StartupDto startupDto, FindLocNoAttributeVo findLocNoAttributeVo,
+ LocTypeDto locTypeDto) {
+ for (LocTypeDto stageLocTypeDto : buildEmptyPalletSearchLocTypes(locTypeDto)) {
+ String stageCode = buildEmptyPalletStageCode(locTypeDto, stageLocTypeDto);
+ Run2AreaSearchResult searchResult = findEmptyPalletRun2AreaLoc(defaultRowLastno, staDescId, sourceStaNo,
+ startupDto, findLocNoAttributeVo, stageLocTypeDto, stageCode);
+ if (!Cools.isEmpty(searchResult) && !Cools.isEmpty(searchResult.locMast)) {
+ return searchResult;
+ }
+ }
+ return null;
+ }
+
private Run2AreaSearchResult findEmptyPalletRun2AreaLoc(RowLastno defaultRowLastno, Integer staDescId, Integer sourceStaNo,
- StartupDto startupDto, Integer preferredArea, LocTypeDto locTypeDto) {
- for (Integer area : buildAreaSearchOrder(preferredArea)) {
+ StartupDto startupDto, FindLocNoAttributeVo findLocNoAttributeVo, LocTypeDto locTypeDto,
+ String stageCode) {
+ List<Integer> areaSearchOrder = buildAreaSearchOrder(
+ findLocNoAttributeVo == null ? null : findLocNoAttributeVo.getOutAreas(),
+ findLocNoAttributeVo == null ? null : findLocNoAttributeVo.getOutArea());
+ for (Integer area : areaSearchOrder) {
RowLastno areaRowLastno = getAreaRowLastno(area, defaultRowLastno);
if (Cools.isEmpty(areaRowLastno)) {
continue;
@@ -718,14 +1366,13 @@
List<Integer> orderedAreaCrnNos = getOrderedCrnNos(areaRowLastno, areaStartCrnNo);
// 绌烘墭鐩樿法搴撳尯鏃跺彧绛涜澶囦富妗e拰鏁呴殰鐘舵�侊紝涓嶅己渚濊禆 sta_desc銆�
List<Integer> runnableAreaCrnNos = getOrderedRunnableRun2CrnNos(areaRowLastno, staDescId, sourceStaNo, orderedAreaCrnNos, false);
- List<Integer> candidateCrnNos = Cools.isEmpty(runnableAreaCrnNos) ? orderedAreaCrnNos : runnableAreaCrnNos;
- if (Cools.isEmpty(candidateCrnNos)) {
+ if (Cools.isEmpty(runnableAreaCrnNos)) {
continue;
}
- LocMast locMast = findRun2EmptyLocByCrnNos(areaRowLastno, areaRowLastnoType, candidateCrnNos, locTypeDto,
- staDescId, sourceStaNo, startupDto, area, "empty-pallet-area-" + area, false);
+ LocMast locMast = findRun2EmptyLocByCrnNos(areaRowLastno, areaRowLastnoType, runnableAreaCrnNos, locTypeDto,
+ staDescId, sourceStaNo, startupDto, area, findLocNoAttributeVo, stageCode + "-area-" + area, false);
if (!Cools.isEmpty(locMast)) {
- return new Run2AreaSearchResult(locMast, areaRowLastno, candidateCrnNos);
+ return new Run2AreaSearchResult(locMast, areaRowLastno, runnableAreaCrnNos);
}
}
return null;
@@ -740,40 +1387,8 @@
return;
}
RowLastno updateRowLastno = searchResult.rowLastno;
- int updateCurRow = updateRowLastno.getCurrentRow() == null || updateRowLastno.getCurrentRow() == 0
- ? (updateRowLastno.getsRow() == null ? 1 : updateRowLastno.getsRow())
- : updateRowLastno.getCurrentRow();
- updateCurRow = getNextRun2CurrentRow(updateRowLastno, searchResult.runnableCrnNos, locMast.getCrnNo(), updateCurRow);
- updateRowLastno.setCurrentRow(updateCurRow);
- rowLastnoService.updateById(updateRowLastno);
- }
-
- /**
- * 鏅�� run2 鐨勬帹鑽愭帓浼樺厛闃舵銆�
- *
- * 鎺ㄨ崘鎺掑彧瀵规櫘閫氱墿鏂欑敓鏁堬紝绌烘墭鐩樺凡缁忓垏鎹㈡垚鈥滄寜搴撳尯杞鍫嗗灈鏈衡�濈殑瑙勫垯锛�
- * 鍥犳杩欓噷浼氱洿鎺ヨ烦杩囩┖鎵樼洏璇锋眰锛岄伩鍏� row 鍙傛暟鎶婄┖鎵樼洏閲嶆柊甯﹀洖鏃ч�昏緫銆�
- *
- * 鍙﹀锛屽崟鎺掓帹鑽愪笉鍐嶄綔涓衡�滃己缁戝畾鍗曞彴鍫嗗灈鏈衡�濆鐞嗐��
- * 鐜板満涓婃父缁忓父鍙紶涓�涓帹鑽愭帓锛屼緥濡� row=[1]锛屽鏋滆繖閲岀洿鎺ョ煭璺懡涓紝
- * 婊℃澘浠诲姟灏变細闀挎湡鍘嬪湪鍚屼竴鍙板爢鍨涙満涓娿�傜幇鍦ㄥ彧鏈夊綋鎺ㄨ崘鎺掕兘瑕嗙洊澶氬彴鍫嗗灈鏈烘椂锛�
- * 鎵嶆妸瀹冨綋浣滅湡姝g殑浼樺厛鍊欓�夐泦鍚堛��
- */
- private LocMast findRun2RecommendLoc(RowLastno rowLastno, RowLastnoType rowLastnoType, boolean emptyPalletRequest,
- List<Integer> recommendRows, LocTypeDto locTypeDto, Integer staDescId,
- Integer sourceStaNo, StartupDto startupDto, Integer preferredArea,
- List<Integer> triedCrnNos) {
- if (emptyPalletRequest) {
- return null;
- }
- List<Integer> recommendCrnNos = mapRowsToCrnNos(rowLastno, recommendRows);
- if (Cools.isEmpty(recommendCrnNos) || recommendCrnNos.size() <= 1) {
- return null;
- }
- LocMast locMast = findRun2EmptyLocByCrnNos(rowLastno, rowLastnoType, recommendCrnNos, locTypeDto,
- staDescId, sourceStaNo, startupDto, preferredArea, "recommend");
- triedCrnNos.addAll(recommendCrnNos);
- return locMast;
+ int currentRow = updateRowLastno.getCurrentRow() == null ? 0 : updateRowLastno.getCurrentRow();
+ updateRun2Cursor(updateRowLastno, searchResult.runnableCrnNos, locMast.getCrnNo(), currentRow);
}
/**
@@ -782,45 +1397,43 @@
* 鎵ц椤哄簭锛�
* 1. 鍏堢湅绔欑偣鏄惁閰嶇疆浜嗏�滃爢鍨涙満 + 搴撲綅绫诲瀷鈥濅紭鍏堢骇銆�
* 2. 娌¢厤搴撳尯鏃讹紝鐩存帴鎸夊綋鍓� run2 杞椤哄簭鎵句綅銆�
- * 3. 閰嶄簡搴撳尯鏃讹紝鍏堝湪褰撳墠搴撳尯鎵撅紝鍐嶅洖閫�鍒板叾瀹冨簱鍖恒��
+ * 3. 閰嶄簡搴撳尯鏃讹紝鍙湪褰撳墠搴撳尯鏌ユ壘锛屾櫘閫氭墭鐩樹笉璺ㄥ簱鍖哄厹搴曘��
*/
- private LocMast findNormalRun2Loc(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer sourceStaNo,
- Integer staDescId, FindLocNoAttributeVo findLocNoAttributeVo, LocTypeDto locTypeDto,
- StartupDto startupDto, Integer preferredArea, List<Integer> orderedCrnNos,
- List<Integer> triedCrnNos) {
+ private Run2SearchResult findNormalRun2Loc(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer sourceStaNo,
+ Integer staDescId, FindLocNoAttributeVo findLocNoAttributeVo, LocTypeDto locTypeDto,
+ StartupDto startupDto, Integer preferredArea, List<Integer> orderedCrnNos) {
List<Map<String, Integer>> stationCrnLocTypes = Utils.getStationStorageAreaName(
sourceStaNo,
locTypeDto == null || locTypeDto.getLocType1() == null ? null : locTypeDto.getLocType1().intValue(),
findLocNoAttributeVo == null ? null : findLocNoAttributeVo.getMatnr());
if (!Cools.isEmpty(stationCrnLocTypes)) {
- return findRun2EmptyLocByCrnLocTypeEntries(rowLastno, rowLastnoType, stationCrnLocTypes,
- locTypeDto, staDescId, sourceStaNo, startupDto, preferredArea, "station-priority");
+ // 绔欑偣浼樺厛绾у彧鏄�滀紭鍏堝皾璇曗�濓紝娌℃湁鍛戒腑鏃跺繀椤荤户缁蛋榛樿/搴撳尯鍥為��锛�
+ // 鍚﹀垯浼氭妸鈥滀紭鍏堝�欓�夋棤浣嶁�濊鍒ゆ垚鈥滄暣浠撴棤浣嶁�濄��
+ LocMast locMast = findRun2EmptyLocByCrnLocTypeEntries(rowLastno, rowLastnoType, stationCrnLocTypes,
+ locTypeDto, staDescId, sourceStaNo, startupDto, preferredArea, "station-priority", findLocNoAttributeVo);
+ if (!Cools.isEmpty(locMast)) {
+ return new Run2SearchResult(locMast, rowLastno,
+ getOrderedRunnableRun2CrnNos(rowLastno, staDescId, sourceStaNo, extractCrnNos(stationCrnLocTypes)));
+ }
}
+ List<Integer> candidateCrnNos;
if (preferredArea == null) {
- List<Integer> defaultCrnNos = new ArrayList<>(orderedCrnNos);
- defaultCrnNos.removeAll(triedCrnNos);
- return findRun2EmptyLocByCrnNos(rowLastno, rowLastnoType, defaultCrnNos, locTypeDto,
- staDescId, sourceStaNo, startupDto, preferredArea, "default");
+ candidateCrnNos = new ArrayList<>(orderedCrnNos);
+ } else {
+ candidateCrnNos = filterCrnNosByRows(rowLastno, orderedCrnNos, getRun2AreaRows(preferredArea, rowLastno));
}
- List<Integer> preferredCrnNos = filterCrnNosByRows(rowLastno, orderedCrnNos, getRun2AreaRows(preferredArea, rowLastno));
- preferredCrnNos.removeAll(triedCrnNos);
- LocMast locMast = findRun2EmptyLocByCrnNos(rowLastno, rowLastnoType, preferredCrnNos, locTypeDto,
- staDescId, sourceStaNo, startupDto, preferredArea, "preferred-area");
- if (!Cools.isEmpty(locMast)) {
- return locMast;
- }
- List<Integer> fallbackCrnNos = filterCrnNosByRows(rowLastno, orderedCrnNos, getRun2FallbackRows(rowLastno));
- fallbackCrnNos.removeAll(triedCrnNos);
- fallbackCrnNos.removeAll(preferredCrnNos);
- return findRun2EmptyLocByCrnNos(rowLastno, rowLastnoType, fallbackCrnNos, locTypeDto,
- staDescId, sourceStaNo, startupDto, preferredArea, "fallback-area");
+ List<Integer> runnableCrnNos = getOrderedRunnableRun2CrnNos(rowLastno, staDescId, sourceStaNo, candidateCrnNos);
+ LocMast locMast = findRun2EmptyLocByCrnNos(rowLastno, rowLastnoType, candidateCrnNos, locTypeDto,
+ staDescId, sourceStaNo, startupDto, preferredArea, findLocNoAttributeVo,
+ preferredArea == null ? "default" : "preferred-area");
+ return new Run2SearchResult(locMast, rowLastno, runnableCrnNos);
}
/**
* 鏅�氱墿鏂欏懡涓簱浣嶅悗锛屾部鐢� run2 鍘熸湁鐨勫叏浠撹疆璇㈡父鏍囨帹杩涙柟寮忋��
*/
private void advanceNormalRun2Cursor(RowLastno rowLastno, int curRow) {
- advanceNormalRun2Cursor(rowLastno, curRow, null, null);
+ updateRun2Cursor(rowLastno, null, null, curRow);
}
/**
@@ -830,19 +1443,12 @@
* 婊℃澘浠诲姟涔熶細鍦ㄧ湡瀹炲彲浣滀笟鐨勫爢鍨涙満涔嬮棿杞锛屼笉浼氬洜涓虹悊璁哄爢鍨涙満鍙风殑绌烘礊鑰岄暱鏈熷洖钀藉埌鍚屼竴鍙般��
*/
private void advanceNormalRun2Cursor(RowLastno rowLastno, int curRow, List<Integer> runnableCrnNos, Integer selectedCrnNo) {
- if (rowLastno == null) {
- return;
- }
- int updateCurRow = curRow == 0 ? (rowLastno.getsRow() == null ? 1 : rowLastno.getsRow()) : curRow;
- if (!Cools.isEmpty(runnableCrnNos) && selectedCrnNo != null) {
- updateCurRow = getNextRun2CurrentRow(rowLastno, runnableCrnNos, selectedCrnNo, updateCurRow);
- } else {
- updateCurRow = getNextRun2CurrentRow(rowLastno, updateCurRow);
- }
- rowLastno.setCurrentRow(updateCurRow);
- rowLastnoService.updateById(rowLastno);
+ updateRun2Cursor(rowLastno, runnableCrnNos, selectedCrnNo, curRow);
}
+ /**
+ * 鏍规嵁鎺掕寖鍥存妸鏁翠粨鍫嗗灈鏈洪『搴忚鍓负鏌愪釜搴撳尯鍐呯殑鍫嗗灈鏈洪泦鍚堛��
+ */
private List<Integer> filterCrnNosByRows(RowLastno rowLastno, List<Integer> orderedCrnNos, List<Integer> rows) {
if (Cools.isEmpty(rows)) {
return new ArrayList<>(orderedCrnNos);
@@ -872,33 +1478,9 @@
return result;
}
- private List<Integer> mapRowsToCrnNos(RowLastno rowLastno, List<Integer> rows) {
- List<Integer> result = new ArrayList<>();
- if (rowLastno == null || Cools.isEmpty(rows)) {
- return result;
- }
- LinkedHashSet<Integer> orderedCrnNos = new LinkedHashSet<>();
- Integer rowSpan = getCrnRowSpan(rowLastno.getTypeId());
- if (rowSpan == null || rowSpan <= 0) {
- rowSpan = 2;
- }
- int startCrnNo = rowLastno.getsCrnNo() == null ? 1 : rowLastno.getsCrnNo();
- int endCrnNo = rowLastno.geteCrnNo() == null ? startCrnNo + rowLastno.getCrnQty() - 1 : rowLastno.geteCrnNo();
- int startRow = rowLastno.getsRow() == null ? 1 : rowLastno.getsRow();
- int endRow = rowLastno.geteRow() == null ? Integer.MAX_VALUE : rowLastno.geteRow();
- for (Integer row : rows) {
- if (row == null || row < startRow || row > endRow) {
- continue;
- }
- int crnNo = startCrnNo + (row - startRow) / rowSpan;
- if (crnNo >= startCrnNo && crnNo <= endCrnNo) {
- orderedCrnNos.add(crnNo);
- }
- }
- result.addAll(orderedCrnNos);
- return result;
- }
-
+ /**
+ * 瑙f瀽褰撳墠婧愮珯鍒扮洰鏍囧爢鍨涙満鐨勫叆搴撶洰鏍囩珯鍙枫��
+ */
private Integer resolveTargetStaNo(RowLastno rowLastno, Integer staDescId, Integer sourceStaNo, Integer crnNo) {
if (!Utils.BooleanWhsTypeSta(rowLastno, staDescId)) {
return null;
@@ -912,8 +1494,8 @@
return null;
}
BasDevp staNo = basDevpService.selectById(staDesc.getCrnStn());
- if (Cools.isEmpty(staNo) || !"Y".equals(staNo.getAutoing())) {
- log.error("鐩爣绔檣}涓嶅彲鐢�", staDesc.getCrnStn());
+ if (Cools.isEmpty(staNo)) {
+ log.error("鐩爣绔檣}涓嶅瓨鍦�", staDesc.getCrnStn());
return null;
}
return staNo.getDevNo();
@@ -941,12 +1523,19 @@
LocTypeDto locTypeDto, Integer staDescId, Integer sourceStaNo, StartupDto startupDto,
Integer preferredArea, String stage) {
return findRun2EmptyLocByCrnNos(rowLastno, rowLastnoType, candidateCrnNos, locTypeDto,
- staDescId, sourceStaNo, startupDto, preferredArea, stage, true);
+ staDescId, sourceStaNo, startupDto, preferredArea, null, stage, true);
}
private LocMast findRun2EmptyLocByCrnNos(RowLastno rowLastno, RowLastnoType rowLastnoType, List<Integer> candidateCrnNos,
LocTypeDto locTypeDto, Integer staDescId, Integer sourceStaNo, StartupDto startupDto,
- Integer preferredArea, String stage, boolean routeRequired) {
+ Integer preferredArea, FindLocNoAttributeVo findLocNoAttributeVo, String stage) {
+ return findRun2EmptyLocByCrnNos(rowLastno, rowLastnoType, candidateCrnNos, locTypeDto,
+ staDescId, sourceStaNo, startupDto, preferredArea, findLocNoAttributeVo, stage, true);
+ }
+
+ private LocMast findRun2EmptyLocByCrnNos(RowLastno rowLastno, RowLastnoType rowLastnoType, List<Integer> candidateCrnNos,
+ LocTypeDto locTypeDto, Integer staDescId, Integer sourceStaNo, StartupDto startupDto,
+ Integer preferredArea, FindLocNoAttributeVo findLocNoAttributeVo, String stage, boolean routeRequired) {
if (Cools.isEmpty(candidateCrnNos)) {
log.warn("run2 skip empty candidate list. stage={}, sourceStaNo={}, preferredArea={}, spec={}",
stage, sourceStaNo, preferredArea, JSON.toJSONString(locTypeDto));
@@ -956,48 +1545,65 @@
List<Integer> routeBlockedCrns = new ArrayList<>();
List<Integer> noEmptyCrns = new ArrayList<>();
List<Integer> locTypeBlockedCrns = new ArrayList<>();
- for (Integer candidateCrnNo : candidateCrnNos) {
- if (candidateCrnNo == null || !basCrnpService.checkSiteError(candidateCrnNo, true)) {
- crnErrorCrns.add(candidateCrnNo);
- continue;
- }
- Integer targetStaNo = resolveTargetStaNo(rowLastno, staDescId, sourceStaNo, candidateCrnNo);
- if (routeRequired && Utils.BooleanWhsTypeSta(rowLastno, staDescId) && targetStaNo == null) {
- routeBlockedCrns.add(candidateCrnNo);
- continue;
- }
- Wrapper<LocMast> openWrapper = new EntityWrapper<LocMast>()
- .eq("crn_no", candidateCrnNo)
- .eq("loc_sts", "O");
- applyLocTypeFilters(openWrapper, locTypeDto, true);
- openWrapper.orderBy("lev1").orderBy("bay1");
- LocMast anyOpenLoc = locMastService.selectOne(openWrapper);
- if (Cools.isEmpty(anyOpenLoc)) {
- noEmptyCrns.add(candidateCrnNo);
- continue;
- }
- Wrapper<LocMast> wrapper = new EntityWrapper<LocMast>()
- .eq("crn_no", candidateCrnNo)
- .eq("loc_sts", "O");
- applyLocTypeFilters(wrapper, locTypeDto, true);
- wrapper.orderBy("lev1").orderBy("bay1");
- LocMast candidateLoc = locMastService.selectOne(wrapper);
- if (Cools.isEmpty(candidateLoc) || (locTypeDto != null && !VersionUtils.locMoveCheckLocTypeComplete(candidateLoc, locTypeDto))) {
- locTypeBlockedCrns.add(candidateCrnNo);
- continue;
- }
- if (targetStaNo != null) {
- startupDto.setStaNo(targetStaNo);
- }
- return candidateLoc;
- }
- logRun2NoMatch(stage, sourceStaNo, preferredArea, candidateCrnNos, locTypeDto, crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns);
- return null;
+ return findRun2EmptyLocByCrnNosRecursively(rowLastno, rowLastnoType, candidateCrnNos, locTypeDto,
+ staDescId, sourceStaNo, startupDto, preferredArea, findLocNoAttributeVo, stage, routeRequired, 0,
+ crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns);
}
+
+ private LocMast findRun2EmptyLocByCrnNosRecursively(RowLastno rowLastno, RowLastnoType rowLastnoType,
+ List<Integer> candidateCrnNos, LocTypeDto locTypeDto,
+ Integer staDescId, Integer sourceStaNo, StartupDto startupDto,
+ Integer preferredArea, FindLocNoAttributeVo findLocNoAttributeVo,
+ String stage, boolean routeRequired, int index,
+ List<Integer> crnErrorCrns, List<Integer> routeBlockedCrns,
+ List<Integer> noEmptyCrns, List<Integer> locTypeBlockedCrns) {
+ if (index >= candidateCrnNos.size()) {
+ logRun2NoMatch(stage, sourceStaNo, preferredArea, candidateCrnNos, locTypeDto,
+ crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns);
+ return null;
+ }
+ Integer candidateCrnNo = candidateCrnNos.get(index);
+ if (!isCrnActive(candidateCrnNo)) {
+ crnErrorCrns.add(candidateCrnNo);
+ return findRun2EmptyLocByCrnNosRecursively(rowLastno, rowLastnoType, candidateCrnNos, locTypeDto,
+ staDescId, sourceStaNo, startupDto, preferredArea, findLocNoAttributeVo, stage, routeRequired, index + 1,
+ crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns);
+ }
+ Integer targetStaNo = routeRequired ? resolveTargetStaNo(rowLastno, staDescId, sourceStaNo, candidateCrnNo) : null;
+ if (routeRequired && Utils.BooleanWhsTypeSta(rowLastno, staDescId) && targetStaNo == null) {
+ routeBlockedCrns.add(candidateCrnNo);
+ return findRun2EmptyLocByCrnNosRecursively(rowLastno, rowLastnoType, candidateCrnNos, locTypeDto,
+ staDescId, sourceStaNo, startupDto, preferredArea, findLocNoAttributeVo, stage, routeRequired, index + 1,
+ crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns);
+ }
+ Integer preferredNearRow = getCrnStartRow(rowLastno, candidateCrnNo);
+ LocMast candidateLoc = findConfiguredEmptyLocForCrn(rowLastno, rowLastnoType, candidateCrnNo,
+ preferredNearRow, locTypeDto, findLocNoAttributeVo);
+ if (Cools.isEmpty(candidateLoc)) {
+ int availableLocCount = countAssignableLocForCrn(rowLastno, rowLastnoType, candidateCrnNo,
+ preferredNearRow == null ? 0 : preferredNearRow, locTypeDto);
+ if (availableLocCount <= 0) {
+ noEmptyCrns.add(candidateCrnNo);
+ } else {
+ locTypeBlockedCrns.add(candidateCrnNo);
+ }
+ return findRun2EmptyLocByCrnNosRecursively(rowLastno, rowLastnoType, candidateCrnNos, locTypeDto,
+ staDescId, sourceStaNo, startupDto, preferredArea, findLocNoAttributeVo, stage, routeRequired, index + 1,
+ crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns);
+ }
+ if (targetStaNo != null) {
+ startupDto.setStaNo(targetStaNo);
+ }
+ return candidateLoc;
+ }
+
+ /**
+ * 鎸夌珯鐐归厤缃殑鈥滃爢鍨涙満 + 楂樹綆绫诲瀷鈥濅紭鍏堢骇鎵句綅锛屽苟濂楃敤缁熶竴鍧囪 绛栫暐銆�
+ */
private LocMast findRun2EmptyLocByCrnLocTypeEntries(RowLastno rowLastno, RowLastnoType rowLastnoType,
List<Map<String, Integer>> crnLocTypeEntries, LocTypeDto locTypeDto,
Integer staDescId, Integer sourceStaNo, StartupDto startupDto,
- Integer preferredArea, String stage) {
+ Integer preferredArea, String stage, FindLocNoAttributeVo findLocNoAttributeVo) {
if (Cools.isEmpty(crnLocTypeEntries)) {
log.warn("run2 skip empty crn-locType list. stage={}, sourceStaNo={}, preferredArea={}, spec={}",
stage, sourceStaNo, preferredArea, JSON.toJSONString(locTypeDto));
@@ -1009,14 +1615,14 @@
List<Integer> noEmptyCrns = new ArrayList<>();
List<Integer> locTypeBlockedCrns = new ArrayList<>();
return findRun2EmptyLocByCrnLocTypeEntriesRecursively(rowLastno, rowLastnoType, crnLocTypeEntries, locTypeDto,
- staDescId, sourceStaNo, startupDto, preferredArea, stage, 0, candidateCrnNos,
+ staDescId, sourceStaNo, startupDto, preferredArea, stage, findLocNoAttributeVo, 0, candidateCrnNos,
crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns);
}
private LocMast findRun2EmptyLocByCrnLocTypeEntriesRecursively(RowLastno rowLastno, RowLastnoType rowLastnoType,
List<Map<String, Integer>> crnLocTypeEntries, LocTypeDto locTypeDto,
Integer staDescId, Integer sourceStaNo, StartupDto startupDto,
- Integer preferredArea, String stage, int index,
+ Integer preferredArea, String stage, FindLocNoAttributeVo findLocNoAttributeVo, int index,
List<Integer> candidateCrnNos, List<Integer> crnErrorCrns,
List<Integer> routeBlockedCrns, List<Integer> noEmptyCrns,
List<Integer> locTypeBlockedCrns) {
@@ -1028,31 +1634,33 @@
Integer candidateCrnNo = crnLocTypeEntry == null ? null : crnLocTypeEntry.get("crnNo");
Short candidateLocType1 = crnLocTypeEntry == null || crnLocTypeEntry.get("locType1") == null
? null : crnLocTypeEntry.get("locType1").shortValue();
- if (candidateCrnNo == null || !basCrnpService.checkSiteError(candidateCrnNo, true)) {
+ if (!isCrnActive(candidateCrnNo)) {
crnErrorCrns.add(candidateCrnNo);
return findRun2EmptyLocByCrnLocTypeEntriesRecursively(rowLastno, rowLastnoType, crnLocTypeEntries, locTypeDto,
- staDescId, sourceStaNo, startupDto, preferredArea, stage, index + 1, candidateCrnNos,
+ staDescId, sourceStaNo, startupDto, preferredArea, stage, findLocNoAttributeVo, index + 1, candidateCrnNos,
crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns);
}
Integer targetStaNo = resolveTargetStaNo(rowLastno, staDescId, sourceStaNo, candidateCrnNo);
if (Utils.BooleanWhsTypeSta(rowLastno, staDescId) && targetStaNo == null) {
routeBlockedCrns.add(candidateCrnNo);
return findRun2EmptyLocByCrnLocTypeEntriesRecursively(rowLastno, rowLastnoType, crnLocTypeEntries, locTypeDto,
- staDescId, sourceStaNo, startupDto, preferredArea, stage, index + 1, candidateCrnNos,
+ staDescId, sourceStaNo, startupDto, preferredArea, stage, findLocNoAttributeVo, index + 1, candidateCrnNos,
crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns);
}
LocTypeDto searchLocTypeDto = buildRun2SearchLocTypeDto(locTypeDto, candidateLocType1);
- LocMast candidateLoc = findRun2OrderedEmptyLocByCrnLocType(rowLastnoType, candidateCrnNo, candidateLocType1, searchLocTypeDto);
+ Integer preferredNearRow = getCrnStartRow(rowLastno, candidateCrnNo);
+ LocMast candidateLoc = findConfiguredEmptyLocForCrn(rowLastno, rowLastnoType, candidateCrnNo,
+ preferredNearRow, searchLocTypeDto, findLocNoAttributeVo);
if (Cools.isEmpty(candidateLoc)) {
- noEmptyCrns.add(candidateCrnNo);
+ int availableLocCount = countAssignableLocForCrn(rowLastno, rowLastnoType, candidateCrnNo,
+ preferredNearRow == null ? 0 : preferredNearRow, searchLocTypeDto);
+ if (availableLocCount <= 0) {
+ noEmptyCrns.add(candidateCrnNo);
+ } else {
+ locTypeBlockedCrns.add(candidateCrnNo);
+ }
return findRun2EmptyLocByCrnLocTypeEntriesRecursively(rowLastno, rowLastnoType, crnLocTypeEntries, locTypeDto,
- staDescId, sourceStaNo, startupDto, preferredArea, stage, index + 1, candidateCrnNos,
- crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns);
- }
- if (searchLocTypeDto != null && !VersionUtils.locMoveCheckLocTypeComplete(candidateLoc, searchLocTypeDto)) {
- locTypeBlockedCrns.add(candidateCrnNo);
- return findRun2EmptyLocByCrnLocTypeEntriesRecursively(rowLastno, rowLastnoType, crnLocTypeEntries, locTypeDto,
- staDescId, sourceStaNo, startupDto, preferredArea, stage, index + 1, candidateCrnNos,
+ staDescId, sourceStaNo, startupDto, preferredArea, stage, findLocNoAttributeVo, index + 1, candidateCrnNos,
crnErrorCrns, routeBlockedCrns, noEmptyCrns, locTypeBlockedCrns);
}
if (targetStaNo != null) {
@@ -1061,6 +1669,9 @@
return candidateLoc;
}
+ /**
+ * 浠庣珯鐐逛紭鍏堢骇閰嶇疆涓娊鍙栦笉閲嶅鐨勫爢鍨涙満椤哄簭銆�
+ */
private List<Integer> extractCrnNos(List<Map<String, Integer>> crnLocTypeEntries) {
LinkedHashSet<Integer> orderedCrnNos = new LinkedHashSet<>();
if (Cools.isEmpty(crnLocTypeEntries)) {
@@ -1075,6 +1686,9 @@
return new ArrayList<>(orderedCrnNos);
}
+ /**
+ * 鐢ㄧ珯鐐逛紭鍏堢骇閲岀殑 locType1 瑕嗙洊鏈鏌ヨ鐨勯珮搴︽潯浠躲��
+ */
private LocTypeDto buildRun2SearchLocTypeDto(LocTypeDto locTypeDto, Short candidateLocType1) {
if (locTypeDto == null && candidateLocType1 == null) {
return null;
@@ -1092,8 +1706,17 @@
return searchLocTypeDto;
}
+ /**
+ * 鎸夌珯鐐逛紭鍏堥厤缃洿鎺ユ煡鏌愬彴鍫嗗灈鏈轰笂鐨勭涓�涓彲鐢ㄧ┖搴撲綅銆�
+ */
private LocMast findRun2OrderedEmptyLocByCrnLocType(RowLastnoType rowLastnoType, Integer candidateCrnNo,
Short candidateLocType1, LocTypeDto locTypeDto) {
+ return findRun2OrderedEmptyLocByCrnLocType(rowLastnoType, candidateCrnNo, candidateLocType1, locTypeDto, null);
+ }
+
+ private LocMast findRun2OrderedEmptyLocByCrnLocType(RowLastnoType rowLastnoType, Integer candidateCrnNo,
+ Short candidateLocType1, LocTypeDto locTypeDto,
+ FindLocNoAttributeVo findLocNoAttributeVo) {
if (candidateCrnNo == null) {
return null;
}
@@ -1104,20 +1727,18 @@
wrapper.eq("loc_type1", candidateLocType1);
}
applyLocTypeFilters(wrapper, locTypeDto, false);
- // 鍗曚几鍫嗗灈鏈烘寜灞傘�佸垪閫掑椤哄簭鎵剧涓�涓┖搴撲綅銆�
- if (rowLastnoType != null && rowLastnoType.getType() != null && (rowLastnoType.getType() == 1 || rowLastnoType.getType() == 2)) {
- wrapper.orderBy("lev1", true).orderBy("bay1", true);
- } else {
- wrapper.orderBy("lev1", true).orderBy("bay1", true);
+ List<LocMast> locMasts = locMastService.selectList(wrapper);
+ List<LocMast> sortedLocMasts = sortLocCandidates(locMasts, findLocNoAttributeVo);
+ for (LocMast candidateLoc : sortedLocMasts) {
+ if (candidateLoc == null) {
+ continue;
+ }
+ if (locTypeDto != null && !VersionUtils.locMoveCheckLocTypeComplete(candidateLoc, locTypeDto)) {
+ continue;
+ }
+ return candidateLoc;
}
- LocMast candidateLoc = locMastService.selectOne(wrapper);
- if (Cools.isEmpty(candidateLoc)) {
- return null;
- }
- if (locTypeDto != null && !VersionUtils.locMoveCheckLocTypeComplete(candidateLoc, locTypeDto)) {
- return null;
- }
- return candidateLoc;
+ return null;
}
private Optional<CrnRowInfo> findAvailableCrnAndNearRow(RowLastno rowLastno, int curRow, int crnNumber, int times,
@@ -1229,27 +1850,347 @@
return offset < bestOffset;
}
- private int countAvailableLocForCrn(RowLastno rowLastno, RowLastnoType rowLastnoType, int crnNo, int preferredNearRow) {
- List<Integer> searchRows = getCrnSearchRows(rowLastno, crnNo, preferredNearRow);
- if (searchRows.isEmpty()) {
- return 0;
+ /**
+ * 鎺ㄥ搴撲綅涓绘。鏌ヨ鏃跺簲浣跨敤鐨� whsType銆�
+ */
+ private Long resolveLocWhsType(RowLastno rowLastno, RowLastnoType rowLastnoType) {
+ if (rowLastno != null && rowLastno.getWhsType() != null) {
+ return rowLastno.getWhsType().longValue();
}
- return locMastService.selectCount(new EntityWrapper<LocMast>()
- .in("row1", searchRows)
- .eq("loc_sts", "O")
- .eq("whs_type", rowLastnoType.getType().longValue()));
+ if (rowLastnoType != null && rowLastnoType.getType() != null) {
+ return rowLastnoType.getType().longValue();
+ }
+ return null;
}
- private int countAvailableSingleExtensionLocForCrn(RowLastno rowLastno, RowLastnoType rowLastnoType, int crnNo, int preferredNearRow, LocTypeDto locTypeDto) {
- List<Integer> searchRows = getCrnSearchRows(rowLastno, crnNo, preferredNearRow);
- if (searchRows.isEmpty()) {
- return 0;
+ /**
+ * 鍒ゆ柇搴撲綅鏄惁婊¤冻鏈瑙勬牸绾︽潫銆�
+ */
+ private boolean matchesLocType(LocMast locMast, LocTypeDto locTypeDto) {
+ if (locMast != null && isFullPalletLocTypeSearch(locTypeDto) && locMast.getLocType2() != null
+ && locMast.getLocType2() == 1) {
+ return false;
+ }
+ return locTypeDto == null || VersionUtils.locMoveCheckLocTypeComplete(locMast, locTypeDto);
+ }
+
+ /**
+ * 鏌ヨ鏌愪竴鎺掍笂鐨勬墍鏈夌┖搴撲綅锛屽苟鎸夊崟浼�/鍙屼几绛栫暐涓庨娆℃帓搴忋��
+ */
+ private List<LocMast> findOpenLocsByRow(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer row,
+ Integer crnNo, LocTypeDto locTypeDto, boolean singleExtension) {
+ return findOpenLocsByRow(rowLastno, rowLastnoType, row, crnNo, locTypeDto, null, singleExtension, false);
+ }
+
+ private List<LocMast> findOpenLocsByRow(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer row,
+ Integer crnNo, LocTypeDto locTypeDto, FindLocNoAttributeVo findLocNoAttributeVo,
+ boolean singleExtension) {
+ return findOpenLocsByRow(rowLastno, rowLastnoType, row, crnNo, locTypeDto, findLocNoAttributeVo, singleExtension, false);
+ }
+
+ private List<LocMast> findOpenLocsByRow(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer row,
+ Integer crnNo, LocTypeDto locTypeDto, FindLocNoAttributeVo findLocNoAttributeVo,
+ boolean singleExtension, boolean ignoreFreqType) {
+ List<LocMast> result = new ArrayList<LocMast>();
+ if (row == null) {
+ return result;
}
Wrapper<LocMast> wrapper = new EntityWrapper<LocMast>()
- .in("row1", searchRows)
.eq("loc_sts", "O");
+ if (crnNo != null) {
+ wrapper.eq("crn_no", crnNo);
+ }
applyLocTypeFilters(wrapper, locTypeDto, true);
- return locMastService.selectCount(wrapper);
+ List<LocMast> locMasts = locMastService.selectList(wrapper);
+ List<LocMast> sortedLocMasts = sortLocCandidates(locMasts, findLocNoAttributeVo, ignoreFreqType);
+ for (LocMast locMast : sortedLocMasts) {
+ if (matchesLocType(locMast, locTypeDto)) {
+ result.add(locMast);
+ }
+ }
+ return result;
+ }
+
+ private List<LocMast> sortLocCandidates(List<LocMast> locMasts, FindLocNoAttributeVo findLocNoAttributeVo) {
+ return sortLocCandidates(locMasts, findLocNoAttributeVo, false);
+ }
+
+ private List<LocMast> sortLocCandidates(List<LocMast> locMasts, FindLocNoAttributeVo findLocNoAttributeVo, boolean ignoreFreqType) {
+ Integer freqType = ignoreFreqType ? null : (findLocNoAttributeVo == null ? null : findLocNoAttributeVo.getFreqType());
+ return sortLocCandidates(locMasts, freqType, getHighFreqFrontBayCount());
+ }
+
+ private List<LocMast> sortLocCandidates(List<LocMast> locMasts, Integer freqType, Integer frontBayCount) {
+ List<LocMast> result = new ArrayList<LocMast>();
+ if (Cools.isEmpty(locMasts)) {
+ return result;
+ }
+ result.addAll(locMasts);
+
+ Integer normalizedFreqType = normalizeFreqType(freqType);
+ if (normalizedFreqType == null) {
+ result.sort(Comparator
+ .comparing(LocMast::getLev1, Comparator.nullsLast(Integer::compareTo))
+ .thenComparing(LocMast::getBay1, Comparator.nullsLast(Integer::compareTo))
+ .thenComparing(LocMast::getLocNo, Comparator.nullsLast(String::compareTo)));
+ return result;
+ }
+
+ if (Objects.equals(normalizedFreqType, 2)) {
+ result.sort(Comparator
+ .comparing(LocMast::getLev1, Comparator.nullsLast(Integer::compareTo))
+ .thenComparing(LocMast::getBay1, Comparator.nullsLast(Comparator.reverseOrder()))
+ .thenComparing(LocMast::getLocNo, Comparator.nullsLast(String::compareTo)));
+ return result;
+ }
+
+ int normalizedFrontBayCount = frontBayCount == null ? 0 : frontBayCount;
+ if (normalizedFrontBayCount > 0) {
+ result.sort(Comparator
+ .comparingInt((LocMast loc) -> resolveFrontBayGroup(loc, normalizedFrontBayCount))
+ .thenComparing(LocMast::getBay1, Comparator.nullsLast(Integer::compareTo))
+ .thenComparing(LocMast::getLev1, Comparator.nullsLast(Integer::compareTo))
+ .thenComparing(LocMast::getLocNo, Comparator.nullsLast(String::compareTo)));
+ } else {
+ result.sort(Comparator
+ .comparing(LocMast::getBay1, Comparator.nullsLast(Integer::compareTo))
+ .thenComparing(LocMast::getLev1, Comparator.nullsLast(Integer::compareTo))
+ .thenComparing(LocMast::getLocNo, Comparator.nullsLast(String::compareTo)));
+ }
+ return result;
+ }
+
+ private int resolveFrontBayGroup(LocMast locMast, int frontBayCount) {
+ if (locMast == null || locMast.getBay1() == null || locMast.getBay1() <= 0) {
+ return 1;
+ }
+ return locMast.getBay1() <= frontBayCount ? 0 : 1;
+ }
+
+ private Integer normalizeFreqType(Integer freqType) {
+ if (freqType == null || (freqType != 1 && freqType != 2)) {
+ return null;
+ }
+ return freqType;
+ }
+
+ private int getHighFreqFrontBayCount() {
+ Parameter parameter = Parameter.get();
+ if (parameter == null || Cools.isEmpty(parameter.getHighFreqFrontBayCount())) {
+ return 0;
+ }
+ Integer parsedCount = safeParseInt(parameter.getHighFreqFrontBayCount());
+ if (parsedCount == null || parsedCount <= 0) {
+ return 0;
+ }
+ return parsedCount;
+ }
+
+ /**
+ * 鎸夋帓銆佸垪銆佸眰绮剧‘瀹氫綅鏌愪釜搴撲綅浣嶇疆涓婄殑鐘舵�佽褰曘��
+ */
+ private LocMast findLocByPosition(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer crnNo,
+ Integer row, Integer bay, Integer lev, String... statuses) {
+ if (row == null || bay == null || lev == null) {
+ return null;
+ }
+ EntityWrapper<LocMast> wrapper = new EntityWrapper<LocMast>();
+ wrapper.eq("row1", row);
+ wrapper.eq("bay1", bay);
+ wrapper.eq("lev1", lev);
+ if (crnNo != null) {
+ wrapper.eq("crn_no", crnNo);
+ }
+ if (statuses != null && statuses.length > 0) {
+ if (statuses.length == 1) {
+ wrapper.eq("loc_sts", statuses[0]);
+ } else {
+ wrapper.in("loc_sts", statuses);
+ }
+ }
+ return locMastService.selectOne(wrapper);
+ }
+
+ /**
+ * 鍦ㄤ竴瀵规祬鎺�/娣辨帓涔嬮棿閫夋嫨鐪熸鍙姇鏀剧殑鐩爣搴撲綅銆�
+ */
+ private LocMast findPairAssignableLoc(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer crnNo,
+ Integer shallowRow, Integer deepRow, LocTypeDto locTypeDto) {
+ return findPairAssignableLoc(rowLastno, rowLastnoType, crnNo, shallowRow, deepRow, locTypeDto, null);
+ }
+
+ private LocMast findPairAssignableLoc(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer crnNo,
+ Integer shallowRow, Integer deepRow, LocTypeDto locTypeDto,
+ FindLocNoAttributeVo findLocNoAttributeVo) {
+ List<LocMast> shallowOpenLocs = findOpenLocsByRow(rowLastno, rowLastnoType, shallowRow, crnNo, locTypeDto, findLocNoAttributeVo, false);
+ if (Cools.isEmpty(shallowOpenLocs)) {
+ return null;
+ }
+ if (deepRow == null) {
+ return shallowOpenLocs.get(0);
+ }
+ for (LocMast shallowLoc : shallowOpenLocs) {
+ LocMast deepOpenLoc = findLocByPosition(rowLastno, rowLastnoType, crnNo, deepRow, shallowLoc.getBay1(), shallowLoc.getLev1(), "O");
+ if (!Cools.isEmpty(deepOpenLoc) && matchesLocType(deepOpenLoc, locTypeDto)) {
+ return deepOpenLoc;
+ }
+ }
+ for (LocMast shallowLoc : shallowOpenLocs) {
+ LocMast deepBlockingLoc = findLocByPosition(rowLastno, rowLastnoType, crnNo, deepRow, shallowLoc.getBay1(), shallowLoc.getLev1(), "F", "D");
+ if (!Cools.isEmpty(deepBlockingLoc)) {
+ return shallowLoc;
+ }
+ if (findLocByPosition(rowLastno, rowLastnoType, crnNo, deepRow, shallowLoc.getBay1(), shallowLoc.getLev1()) == null) {
+ return shallowLoc;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 鎸夋煇鍙板爢鍨涙満鐨勬繁娴呮帓鐢诲儚鎼滅储绗竴涓彲鍒嗛厤绌哄簱浣嶃��
+ */
+ private LocMast findConfiguredEmptyLocForCrn(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer crnNo,
+ Integer preferredNearRow, LocTypeDto locTypeDto) {
+ return findConfiguredEmptyLocForCrn(rowLastno, rowLastnoType, crnNo, preferredNearRow, locTypeDto, null, false);
+ }
+
+ private LocMast findConfiguredEmptyLocForCrn(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer crnNo,
+ Integer preferredNearRow, LocTypeDto locTypeDto, FindLocNoAttributeVo findLocNoAttributeVo) {
+ return findConfiguredEmptyLocForCrn(rowLastno, rowLastnoType, crnNo, preferredNearRow, locTypeDto, findLocNoAttributeVo, false);
+ }
+
+ private LocMast findConfiguredEmptyLocForCrn(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer crnNo,
+ Integer preferredNearRow, LocTypeDto locTypeDto, FindLocNoAttributeVo findLocNoAttributeVo,
+ boolean ignoreFreqType) {
+ if (rowLastno == null || crnNo == null) {
+ return null;
+ }
+ CrnDepthRuleProfile profile = basCrnDepthRuleService.resolveProfile(rowLastno, crnNo, preferredNearRow);
+ if (profile == null || Cools.isEmpty(profile.getSearchRows())) {
+ return null;
+ }
+ LinkedHashSet<Integer> processedShallowRows = new LinkedHashSet<Integer>();
+ boolean singleExtension = profile.isSingleExtension();
+ for (Integer searchRow : profile.getSearchRows()) {
+ if (searchRow == null) {
+ continue;
+ }
+ if (!singleExtension) {
+ if (profile.isShallowRow(searchRow)) {
+ if (!processedShallowRows.add(searchRow)) {
+ continue;
+ }
+ LocMast candidateLoc = findPairAssignableLoc(rowLastno, rowLastnoType, crnNo, searchRow,
+ profile.getPairedDeepRow(searchRow), locTypeDto, findLocNoAttributeVo);
+ if (!Cools.isEmpty(candidateLoc)) {
+ return candidateLoc;
+ }
+ continue;
+ }
+ if (profile.isDeepRow(searchRow)) {
+ Integer shallowRow = profile.getPairedShallowRow(searchRow);
+ if (shallowRow != null) {
+ if (!processedShallowRows.add(shallowRow)) {
+ continue;
+ }
+ LocMast candidateLoc = findPairAssignableLoc(rowLastno, rowLastnoType, crnNo, shallowRow,
+ searchRow, locTypeDto, findLocNoAttributeVo);
+ if (!Cools.isEmpty(candidateLoc)) {
+ return candidateLoc;
+ }
+ continue;
+ }
+ }
+ }
+ List<LocMast> locMasts = findOpenLocsByRow(rowLastno, rowLastnoType, searchRow, crnNo, locTypeDto, findLocNoAttributeVo, singleExtension, ignoreFreqType);
+ if (!Cools.isEmpty(locMasts)) {
+ return locMasts.get(0);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 缁熻鏌愬彴鍫嗗灈鏈哄綋鍓嶇敾鍍忎笅鍙弬涓庡垎閰嶇殑绌哄簱浣嶆暟閲忋��
+ */
+ private int countAssignableLocForCrn(RowLastno rowLastno, RowLastnoType rowLastnoType, int crnNo, int preferredNearRow, LocTypeDto locTypeDto) {
+ CrnDepthRuleProfile profile = basCrnDepthRuleService.resolveProfile(rowLastno, crnNo, preferredNearRow);
+ if (profile == null || Cools.isEmpty(profile.getSearchRows())) {
+ return 0;
+ }
+ int count = 0;
+ LinkedHashSet<Integer> processedShallowRows = new LinkedHashSet<Integer>();
+ boolean singleExtension = profile.isSingleExtension();
+ for (Integer searchRow : profile.getSearchRows()) {
+ if (searchRow == null) {
+ continue;
+ }
+ if (!singleExtension) {
+ if (profile.isShallowRow(searchRow)) {
+ if (!processedShallowRows.add(searchRow)) {
+ continue;
+ }
+ count += countAssignablePairLocs(rowLastno, rowLastnoType, crnNo, searchRow,
+ profile.getPairedDeepRow(searchRow), locTypeDto);
+ continue;
+ }
+ if (profile.isDeepRow(searchRow)) {
+ Integer shallowRow = profile.getPairedShallowRow(searchRow);
+ if (shallowRow != null) {
+ if (!processedShallowRows.add(shallowRow)) {
+ continue;
+ }
+ count += countAssignablePairLocs(rowLastno, rowLastnoType, crnNo, shallowRow, searchRow, locTypeDto);
+ continue;
+ }
+ }
+ }
+ count += findOpenLocsByRow(rowLastno, rowLastnoType, searchRow, crnNo, locTypeDto, singleExtension).size();
+ }
+ return count;
+ }
+
+ /**
+ * 缁熻涓�瀵规祬鎺�/娣辨帓涓婄殑鍙垎閰嶅簱浣嶆暟閲忋��
+ */
+ private int countAssignablePairLocs(RowLastno rowLastno, RowLastnoType rowLastnoType, Integer crnNo,
+ Integer shallowRow, Integer deepRow, LocTypeDto locTypeDto) {
+ List<LocMast> shallowOpenLocs = findOpenLocsByRow(rowLastno, rowLastnoType, shallowRow, crnNo, locTypeDto, false);
+ if (Cools.isEmpty(shallowOpenLocs)) {
+ return 0;
+ }
+ if (deepRow == null) {
+ return shallowOpenLocs.size();
+ }
+ int count = 0;
+ for (LocMast shallowLoc : shallowOpenLocs) {
+ LocMast deepOpenLoc = findLocByPosition(rowLastno, rowLastnoType, crnNo, deepRow, shallowLoc.getBay1(), shallowLoc.getLev1(), "O");
+ if (!Cools.isEmpty(deepOpenLoc) && matchesLocType(deepOpenLoc, locTypeDto)) {
+ count++;
+ continue;
+ }
+ LocMast deepBlockingLoc = findLocByPosition(rowLastno, rowLastnoType, crnNo, deepRow, shallowLoc.getBay1(), shallowLoc.getLev1(), "F", "D");
+ if (!Cools.isEmpty(deepBlockingLoc) ||
+ findLocByPosition(rowLastno, rowLastnoType, crnNo, deepRow, shallowLoc.getBay1(), shallowLoc.getLev1()) == null) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ /**
+ * 缁熻鏌愬彴鍫嗗灈鏈烘墍鏈夊彲鐢ㄧ┖搴撲綅鏁伴噺锛屼笉闄勫甫瑙勬牸杩囨护銆�
+ */
+ private int countAvailableLocForCrn(RowLastno rowLastno, RowLastnoType rowLastnoType, int crnNo, int preferredNearRow) {
+ return countAssignableLocForCrn(rowLastno, rowLastnoType, crnNo, preferredNearRow, null);
+ }
+
+ /**
+ * 缁熻鏌愬彴鍗曚几鍫嗗灈鏈哄湪褰撳墠瑙勬牸绾︽潫涓嬬殑鍙敤绌哄簱浣嶆暟閲忋��
+ */
+ private int countAvailableSingleExtensionLocForCrn(RowLastno rowLastno, RowLastnoType rowLastnoType, int crnNo, int preferredNearRow, LocTypeDto locTypeDto) {
+ return countAssignableLocForCrn(rowLastno, rowLastnoType, crnNo, preferredNearRow, locTypeDto);
}
private Optional<CrnRowInfo> findBalancedSingleExtensionCrnAndNearRow(RowLastno rowLastno, int curRow, int crnNumber, int times,
@@ -1313,35 +2254,20 @@
return Optional.ofNullable(fallbackInfo);
}
+ /**
+ * 杩斿洖鏌愬彴鍫嗗灈鏈烘湰娆℃壘浣嶅簲鎵弿鐨勬帓椤哄簭銆�
+ */
private List<Integer> getCrnSearchRows(RowLastno rowLastno, int crnNo, int preferredNearRow) {
- List<Integer> searchRows = new ArrayList<>();
- addSearchRow(searchRows, preferredNearRow, rowLastno);
-
- Integer rowSpan = getCrnRowSpan(rowLastno.getTypeId());
- if (rowSpan == null) {
- return searchRows;
+ CrnDepthRuleProfile profile = basCrnDepthRuleService.resolveProfile(rowLastno, crnNo, preferredNearRow);
+ if (profile == null || Cools.isEmpty(profile.getSearchRows())) {
+ return new ArrayList<Integer>();
}
-
- int crnOffset = crnNo - rowLastno.getsCrnNo();
- if (crnOffset < 0) {
- return searchRows;
- }
- int startRow = rowLastno.getsRow() + crnOffset * rowSpan;
- switch (rowLastno.getTypeId()) {
- case 1:
- addSearchRow(searchRows, startRow + 1, rowLastno);
- addSearchRow(searchRows, startRow + 2, rowLastno);
- break;
- case 2:
- addSearchRow(searchRows, startRow, rowLastno);
- addSearchRow(searchRows, startRow + 1, rowLastno);
- break;
- default:
- break;
- }
- return searchRows;
+ return new ArrayList<Integer>(profile.getSearchRows());
}
+ /**
+ * 鎸夊簱鍨嬭繑鍥炴瘡鍙板爢鍨涙満鍗犵敤鐨勬帓璺ㄥ害銆�
+ */
private Integer getCrnRowSpan(Integer typeId) {
if (typeId == null) {
return null;
@@ -1356,6 +2282,9 @@
}
}
+ /**
+ * 鍚戞悳绱㈡帓鍒楄〃杩藉姞涓�涓悎娉曚笖涓嶉噸澶嶇殑鎺掑彿銆�
+ */
private void addSearchRow(List<Integer> searchRows, Integer row, RowLastno rowLastno) {
if (row == null) {
return;
@@ -1368,67 +2297,21 @@
}
}
+ /**
+ * run/run2 鏍囧噯鍫嗗灈鏈虹粺涓�鐨勭┖搴撲綅鏌ヨ鍏ュ彛銆�
+ */
private LocMast findStandardEmptyLoc(RowLastno rowLastno, RowLastnoType rowLastnoType, int crnNo, int nearRow, LocTypeDto locTypeDto) {
- for (Integer searchRow : getCrnSearchRows(rowLastno, crnNo, nearRow)) {
- List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
- .eq("row1", searchRow)
- .eq("loc_sts", "O")
- .eq("whs_type", rowLastnoType.getType().longValue())
- .orderBy("lev1", true)
- .orderBy("bay1", true));
- for (LocMast locMast1 : locMasts) {
- if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) {
- continue;
- }
- if (Utils.BooleanWhsTypeStaIoType(rowLastno)) {
- String shallowLoc = Utils.getDeepLoc(slaveProperties, locMast1.getLocNo());
- LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>()
- .eq("loc_no", shallowLoc)
- .eq("loc_sts", "O")
- .eq("whs_type", rowLastnoType.getType().longValue()));
- if (!Cools.isEmpty(locMast2)) {
- return locMast2;
- }
- } else if (!Cools.isEmpty(locMast1)) {
- return locMast1;
- }
- }
-
- if (!Utils.BooleanWhsTypeStaIoType(rowLastno)) {
- continue;
- }
-
- for (LocMast locMast1 : locMasts) {
- if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) {
- continue;
- }
- String shallowLoc = Utils.getDeepLoc(slaveProperties, locMast1.getLocNo());
- LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>()
- .eq("loc_no", shallowLoc)
- .eq("loc_sts", "O")
- .eq("whs_type", rowLastnoType.getType().longValue()));
- if (!Cools.isEmpty(locMast2)) {
- return locMast2;
- }
- locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>()
- .eq("loc_no", shallowLoc)
- .eq("loc_sts", "F")
- .eq("whs_type", rowLastnoType.getType().longValue()));
- if (!Cools.isEmpty(locMast2)) {
- return locMast1;
- }
- locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>()
- .eq("loc_no", shallowLoc)
- .eq("loc_sts", "D")
- .eq("whs_type", rowLastnoType.getType().longValue()));
- if (!Cools.isEmpty(locMast2)) {
- return locMast1;
- }
- }
- }
- return null;
+ return findStandardEmptyLoc(rowLastno, rowLastnoType, crnNo, nearRow, locTypeDto, null);
}
+ private LocMast findStandardEmptyLoc(RowLastno rowLastno, RowLastnoType rowLastnoType, int crnNo, int nearRow,
+ LocTypeDto locTypeDto, FindLocNoAttributeVo findLocNoAttributeVo) {
+ return findConfiguredEmptyLocForCrn(rowLastno, rowLastnoType, crnNo, nearRow, locTypeDto, findLocNoAttributeVo);
+ }
+
+ /**
+ * 鏋勯�犲彧鎻愬崌 locType1 鐨勫悜涓婂吋瀹硅鏍笺��
+ */
private LocTypeDto buildUpwardCompatibleLocTypeDto(LocTypeDto locTypeDto) {
if (locTypeDto == null || locTypeDto.getLocType1() == null || locTypeDto.getLocType1() >= 2) {
return null;
@@ -1442,40 +2325,12 @@
}
/**
- * 绌烘墭鐩樺吋瀹瑰洖閫�瑙勫垯锛�
- * 褰撻杞� loc_type2=1 娌℃湁鍛戒腑绌哄簱浣嶆椂锛屽厑璁搁��鍖栧埌楂樹綅绌哄簱浣� loc_type1=2銆�
- *
- * 娉ㄦ剰杩欓噷涓嶄細缁х画淇濈暀 locType2=1銆�
- * 涔熷氨鏄绗簩杞槸鈥滈珮浣嶄紭鍏堝厹搴曗�濓紝鑰屼笉鏄�滈珮浣嶇獎搴撲綅鍏滃簳鈥濄��
- * 杩欐槸鎸夌収鐜板満鏈�鏂板彛寰勫疄鐜扮殑锛氱獎搴撲綅浼樺厛锛岀獎搴撲綅娌℃湁鏃跺啀鎵鹃珮浣嶇┖搴撲綅銆�
- */
- private LocTypeDto buildEmptyPalletCompatibleLocTypeDto(LocTypeDto locTypeDto) {
- if (locTypeDto == null || locTypeDto.getLocType2() == null || locTypeDto.getLocType2() != 1) {
- return null;
- }
- LocTypeDto compatibleLocTypeDto = new LocTypeDto();
- compatibleLocTypeDto.setLocType1((short) 2);
- compatibleLocTypeDto.setLocType3(locTypeDto.getLocType3());
- compatibleLocTypeDto.setSiteId(locTypeDto.getSiteId());
- return compatibleLocTypeDto;
- }
-
- /**
* 缁熶竴灏佽鎵惧簱浣嶅け璐ュ悗鐨勫吋瀹归噸璇曢『搴忋��
*
- * 绌烘墭鐩橈細
- * 鍏堟寜 loc_type2=1 鏌ユ壘锛屽け璐ュ悗閫�鍒� loc_type1=2銆�
- *
- * 闈炵┖鎵樼洏锛�
- * 缁存寔鍘熻鍒欙紝浣庝綅澶辫触鍚庡啀鍚戦珮浣嶅吋瀹广��
+ * 鍏煎瑙勫垯鍥哄畾涓猴細
+ * 鍙厑璁� loc_type1 浣庝綅鍚戦珮浣嶅吋瀹癸紝loc_type2/loc_type3 涓嶅弬涓庢弧鎵樻壘浣嶃��
*/
private LocTypeDto buildRetryCompatibleLocTypeDto(Integer staDescId, FindLocNoAttributeVo findLocNoAttributeVo, LocTypeDto locTypeDto) {
- if (isEmptyPalletRequest(staDescId, findLocNoAttributeVo)) {
- LocTypeDto emptyPalletCompatibleLocTypeDto = buildEmptyPalletCompatibleLocTypeDto(locTypeDto);
- if (emptyPalletCompatibleLocTypeDto != null) {
- return emptyPalletCompatibleLocTypeDto;
- }
- }
return buildUpwardCompatibleLocTypeDto(locTypeDto);
}
@@ -1567,7 +2422,7 @@
if (signRule1) {
if (nearRow != curRow) {
List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
- .eq("row1", nearRow).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()));
+ .eq("row1", nearRow).eq("loc_sts", "O"));
for (LocMast locMast1 : locMasts) {
//鑾峰彇宸烽亾
// List<String> groupOutsideLocCrn = Utils.getGroupOutLocCrn(curRow,nearRow,locMast1.getLocNo(), curRow>nearRow);
@@ -1609,7 +2464,7 @@
// 闈犺繎鎽嗘斁瑙勫垯 --- 绌烘墭 //浜掗�氱増
if (staDescId == 10 && Utils.BooleanWhsTypeStaIoType(rowLastno)) {
List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
- .eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow).eq("whs_type", rowLastnoType.getType().longValue()));
+ .eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow));
if (!locMasts.isEmpty()) {
for (LocMast loc : locMasts) {
if (Utils.isShallowLoc(slaveProperties, loc.getLocNo())) {
@@ -1664,13 +2519,13 @@
// Search empty location ==============================>>
if (staDescId == 10 && Cools.isEmpty(locMast) && crnNo != 0) {
- locMast = findStandardEmptyLoc(rowLastno, rowLastnoType, crnNo, nearRow, locTypeDto);
+ locMast = findStandardEmptyLoc(rowLastno, rowLastnoType, crnNo, nearRow, locTypeDto, findLocNoAttributeVo);
}
if (Cools.isEmpty(locMast) && crnNo != 0) {
- locMast = findStandardEmptyLoc(rowLastno, rowLastnoType, crnNo, nearRow, locTypeDto);
+ locMast = findStandardEmptyLoc(rowLastno, rowLastnoType, crnNo, nearRow, locTypeDto, findLocNoAttributeVo);
}
if (!Cools.isEmpty(locMast) && !basCrnpService.checkSiteError(crnNo, true)) {
@@ -1712,21 +2567,15 @@
* run2 鍏ュ簱鎵句綅涓绘祦绋嬨��
*
* 褰撳墠鏂规硶鍙繚鐣欌�滅粍缁囨祦绋嬧�濆拰鈥滅粺涓�鏀跺彛鈥濈殑鑱岃矗锛屽叿浣撶瓥鐣ユ媶鎴愮嫭绔嬫柟娉曪細
- * 1. 鏅�氱墿鏂欙細鎺ㄨ崘鎺掍紭鍏� -> 绔欑偣浼樺厛搴撳尯/鍫嗗灈鏈� -> 鍏跺畠搴撳尯銆�
- * 2. 绌烘墭鐩橈細浼樺厛搴撳尯 loc_type2=1 -> 鍏跺畠搴撳尯 loc_type2=1 -> loc_type1=2 鍏煎銆�
- * 3. 鍛戒腑搴撲綅鍚庡垎鍒洖鍐欐櫘閫氱墿鏂欐父鏍囨垨绌烘墭鐩樺簱鍖烘父鏍囥��
+ * 1. 鍏堟寜绔欑偣绗竴浼樺厛姹犳壘浣嶏紝鍐嶆壘绗簩浼樺厛姹犮��
+ * 2. 姹犲唴鎸� current_no 杞浆锛屼粠涓嬩竴鍙板爢鍨涙満寮�濮嬪钩鍧囧垎閰嶃��
+ * 3. 绌烘墭鐩樺厛鎸� loc_type2=1 鎼滅储锛屽悓姹犳棤缁撴灉鍐嶅厑璁稿叾瀹冨簱浣嶃��
+ * 4. 浣庡簱浣嶅彲鍚戜笂鍏煎锛屽吋瀹归噸璇曚粛淇濇寔涓ゅ眰浼樺厛姹犻『搴忋��
*/
+ @Transactional
public StartupDto getLocNoRun2(Integer whsType, Integer staDescId, Integer sourceStaNo, FindLocNoAttributeVo findLocNoAttributeVo, Integer moveCrnNo, LocTypeDto locTypeDto, List<Integer> recommendRows, int times) {
-
- int crnNo = 0;
- int nearRow = 0;
- int curRow = 0;
- int rowCount = 0;
- LocMast locMast = null;
-
StartupDto startupDto = new StartupDto();
RowLastno rowLastno = rowLastnoService.selectById(whsType);
-
if (Cools.isEmpty(rowLastno)) {
throw new CoolException("鏁版嵁寮傚父锛岃鑱旂郴绠$悊鍛�===>搴撲綅瑙勫垯鏈煡");
}
@@ -1734,83 +2583,47 @@
if (Cools.isEmpty(rowLastnoType)) {
throw new CoolException("鏁版嵁寮傚父锛岃鑱旂郴绠$悊鍛�===銆嬪簱浣嶈鍒欑被鍨嬫湭鐭�");
}
- int crnNumber = resolveCrnCount(rowLastno);
- rowCount = crnNumber;
-
- curRow = rowLastno.getCurrentRow();
- crnNo = resolveRun2CrnNo(rowLastno);
- Integer preferredArea = findLocNoAttributeVo.getOutArea();
+ BasDevp station = basDevpService.selectById(sourceStaNo);
+ if (Cools.isEmpty(station)) {
+ throw new CoolException("绔欑偣=" + sourceStaNo + " 鏈厤缃叆搴撲紭鍏堝爢鍨涙満");
+ }
+ List<Integer> firstPoolCrnNos = loadPriorityCrnNos(station.getInFirstCrnCsv());
+ List<Integer> secondPoolCrnNos = loadPriorityCrnNos(station.getInSecondCrnCsv());
+ if (Cools.isEmpty(firstPoolCrnNos) && Cools.isEmpty(secondPoolCrnNos)) {
+ throw new CoolException("绔欑偣=" + sourceStaNo + " 鏈厤缃叆搴撲紭鍏堝爢鍨涙満");
+ }
boolean emptyPalletRequest = isEmptyPalletRequest(staDescId, findLocNoAttributeVo);
- Run2AreaSearchResult emptyPalletAreaSearchResult = null;
-
- List<Integer> orderedCrnNos = getOrderedCrnNos(rowLastno, crnNo);
- List<Integer> orderedRunnableCrnNos = getOrderedRunnableRun2CrnNos(rowLastno, staDescId, sourceStaNo, orderedCrnNos);
- List<Integer> triedCrnNos = new ArrayList<>();
- locMast = findRun2RecommendLoc(rowLastno, rowLastnoType, emptyPalletRequest, recommendRows, locTypeDto,
- staDescId, sourceStaNo, startupDto, preferredArea, triedCrnNos);
- if (Cools.isEmpty(locMast)) {
- if (emptyPalletRequest) {
- // 绌烘墭鐩樺崟鐙寜搴撳尯杞锛�
- // 1. 褰撳墠搴撳尯鍏堟壘 loc_type2=1
- // 2. 褰撳墠搴撳尯娌℃湁锛屽啀鎵惧叾浠栧簱鍖� loc_type2=1
- // 3. 鍏ㄩ儴 narrow 閮芥病鏈夋椂锛屽啀閫�鍒� loc_type1=2
- emptyPalletAreaSearchResult = findEmptyPalletRun2AreaLoc(rowLastno, staDescId, sourceStaNo, startupDto, preferredArea, locTypeDto);
- if (!Cools.isEmpty(emptyPalletAreaSearchResult)) {
- locMast = emptyPalletAreaSearchResult.locMast;
- }
- } else {
- locMast = findNormalRun2Loc(rowLastno, rowLastnoType, sourceStaNo, staDescId, findLocNoAttributeVo,
- locTypeDto, startupDto, preferredArea, orderedCrnNos, triedCrnNos);
- }
- }
-
- if (!Cools.isEmpty(locMast)) {
- crnNo = locMast.getCrnNo();
- nearRow = locMast.getRow1();
- }
- if (emptyPalletRequest) {
- advanceEmptyPalletRun2Cursor(emptyPalletAreaSearchResult, locMast);
- } else {
- advanceNormalRun2Cursor(rowLastno, curRow, orderedRunnableCrnNos, locMast == null ? null : locMast.getCrnNo());
- }
-
+ LocMast locMast = findRun2PriorityLocInPools(station, rowLastno, rowLastnoType, staDescId, sourceStaNo,
+ findLocNoAttributeVo, locTypeDto, startupDto, emptyPalletRequest);
if (Cools.isEmpty(locMast) || !locMast.getLocSts().equals("O")) {
- if (!emptyPalletRequest && times < rowCount * 2) {
- times = times + 1;
- return getLocNoRun2(whsType, staDescId, sourceStaNo, findLocNoAttributeVo, moveCrnNo, locTypeDto, recommendRows, times);
+ if (emptyPalletRequest) {
+ log.error("No empty location found. spec={}, station={}, firstPool={}, secondPool={}",
+ JSON.toJSONString(locTypeDto), sourceStaNo, JSON.toJSONString(firstPoolCrnNos),
+ JSON.toJSONString(secondPoolCrnNos));
+ throw new CoolException("娌℃湁绌哄簱浣�");
}
- LocTypeDto compatibleLocTypeDto = buildRetryCompatibleLocTypeDto(staDescId, findLocNoAttributeVo, locTypeDto);
- if (compatibleLocTypeDto != null) {
- // 绗竴杞叏閮ㄥ爢鍨涙満閮芥病鎵惧埌鏃讹紝鍐嶈繘鍏ヨ鏍煎吋瀹归噸璇曪紝涓嶅湪鍗曚釜鍫嗗灈鏈哄唴灞�閮ㄩ��鍖栥��
- log.warn("locType compatibility retry. source={}, target={}", JSON.toJSONString(locTypeDto), JSON.toJSONString(compatibleLocTypeDto));
- return getLocNoRun2(whsType, staDescId, sourceStaNo, findLocNoAttributeVo, moveCrnNo, compatibleLocTypeDto, recommendRows, 0);
- }
- log.error("No empty location found. spec={}, times={}, preferredArea={}, nearRow={}", JSON.toJSONString(locTypeDto), times, preferredArea, nearRow);
+ log.error("No empty location found. spec={}, station={}, firstPool={}, secondPool={}",
+ JSON.toJSONString(locTypeDto), sourceStaNo, JSON.toJSONString(firstPoolCrnNos), JSON.toJSONString(secondPoolCrnNos));
throw new CoolException("娌℃湁绌哄簱浣�");
}
int workNo = getWorkNo(0);
startupDto.setWorkNo(workNo);
- startupDto.setCrnNo(crnNo);
+ startupDto.setCrnNo(locMast.getCrnNo());
startupDto.setSourceStaNo(sourceStaNo);
startupDto.setLocNo(locMast.getLocNo());
return startupDto;
}
+ /**
+ * 鍗曚几鍫嗗灈鏈哄鐢ㄧ粺涓�鐢诲儚绠楁硶鏌ヨ绌哄簱浣嶃��
+ */
private LocMast findSingleExtensionEmptyLoc(RowLastno rowLastno, int crnNo, int nearRow, RowLastnoType rowLastnoType, LocTypeDto locTypeDto) {
- for (Integer searchRow : getCrnSearchRows(rowLastno, crnNo, nearRow)) {
- List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
- .eq("row1", searchRow)
- .eq("loc_sts", "O")
- .eq("whs_type", rowLastnoType.getType().longValue())
- .orderBy("bay1", true)
- .orderBy("lev1", true));
- for (LocMast locMast : locMasts) {
- if (VersionUtils.locMoveCheckLocTypeComplete(locMast, locTypeDto)) {
- return locMast;
- }
- }
- }
- return null;
+ return findSingleExtensionEmptyLoc(rowLastno, crnNo, nearRow, rowLastnoType, locTypeDto, null);
+ }
+
+ private LocMast findSingleExtensionEmptyLoc(RowLastno rowLastno, int crnNo, int nearRow, RowLastnoType rowLastnoType,
+ LocTypeDto locTypeDto, FindLocNoAttributeVo findLocNoAttributeVo) {
+ return findConfiguredEmptyLocForCrn(rowLastno, rowLastnoType, crnNo, nearRow, locTypeDto, findLocNoAttributeVo);
}
public StartupDto getLocNoRun4(Integer whsType, Integer staDescId, Integer sourceStaNo, FindLocNoAttributeVo findLocNoAttributeVo, Integer moveCrnNo, LocTypeDto locTypeDto, int times) {
@@ -1855,7 +2668,7 @@
crnNo = locNecessaryParameters[2];
nearRow = locNecessaryParameters[3];
List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
- .eq("crn_no", crnNo).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()));
+ .eq("crn_no", crnNo).eq("loc_sts", "O"));
if (locMasts.size() <= 5) {
nearRow = 0;
times++;
@@ -2016,7 +2829,7 @@
if (signRule1) {
if (nearRow != curRow) {
List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
- .eq("row1", nearRow).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()));
+ .eq("row1", nearRow).eq("loc_sts", "O"));
for (LocMast locMast1 : locMasts) {
//鑾峰彇宸烽亾
// List<String> groupOutsideLocCrn = Utils.getGroupOutLocCrn(curRow,nearRow,locMast1.getLocNo(), curRow>nearRow);
@@ -2187,7 +3000,7 @@
if (Cools.isEmpty(locMast) && crnNo != 0) {
List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
.eq("row1", nearRow)
- .eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())
+ .eq("loc_sts", "O")
.orderBy("lev1", true).orderBy("bay1", true));//鏈�娴呭簱浣�
for (LocMast locMast1 : locMasts) {
if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) {
@@ -2264,6 +3077,7 @@
}
public StartupDto getLocNoRun5(Integer whsType, Integer staDescId, Integer sourceStaNo, FindLocNoAttributeVo findLocNoAttributeVo, Integer moveCrnNo, LocTypeDto locTypeDto, List<Integer> recommendRows, int times) {
+ // WCS 浼犲叆鐨勬帹鑽愭帓涓嶅啀鍙備笌 AGV/骞冲簱閫変綅锛岀粺涓�鎸夊簱浣嶆帓鍙疯嚜韬疆璇㈤�昏緫鎵句綅銆�
// 鍒濆鍖栧弬鏁�
int crnNo = 0; //鍫嗗灈鏈哄彿
@@ -2334,50 +3148,27 @@
// 寮�濮嬫煡鎵惧簱浣� ==============================>>
- if (Cools.isEmpty(locMast) && !Cools.isEmpty(recommendRows)) {
- for (Integer recommendRow : recommendRows) {
- if (Cools.isEmpty(recommendRow)) {
+ Integer preferredArea = findLocNoAttributeVo == null ? null : findLocNoAttributeVo.getOutArea();
+ List<Integer> areaSearchOrder = buildAreaSearchOrder(findLocNoAttributeVo == null ? null : findLocNoAttributeVo.getOutAreas(), preferredArea);
+
+ if (Cools.isEmpty(locMast)) {
+ for (Integer area : areaSearchOrder) {
+ int[] bayRange = getAgvAreaBayRange(area);
+ List<Integer> areaRows = getAgvAreaRows(area, rowLastno);
+ if (Cools.isEmpty(areaRows)) {
continue;
}
- LocMast recommendLoc = locMastService.queryFreeLocMast(recommendRow, locTypeDto.getLocType1(), rowLastnoType.getType().longValue());
- if (!Cools.isEmpty(recommendLoc) && VersionUtils.locMoveCheckLocTypeComplete(recommendLoc, locTypeDto)) {
- locMast = recommendLoc;
- crnNo = recommendLoc.getCrnNo();
+ locMast = findAgvLocByRows(rowLastno, rowLastnoType, areaRows,
+ bayRange[0], bayRange[1], curRow, nearRow, locTypeDto, findLocNoAttributeVo, false);
+ if (!Cools.isEmpty(locMast)) {
+ crnNo = locMast.getCrnNo();
+ preferredArea = area;
break;
}
}
- }
-
- Integer preferredArea = findLocNoAttributeVo.getOutArea();
-
- if (Cools.isEmpty(locMast) && preferredArea == null) {
- List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
- .eq("row1", nearRow)
- .eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())
- .orderBy("lev1", true).orderBy("bay1", true)); // 鏈�娴呭簱浣�
- for (LocMast locMast1 : locMasts) {
- if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) {
- continue;
- }
- if (Utils.BooleanWhsTypeStaIoType(rowLastno)) {
- // 鑾峰彇鐩爣搴撲綅鎵�鍦ㄥ贩閬撴渶娣辩┖搴撲綅
- LocMast locMast2 = locMastService.selectLocByLocStsPakInO(curRow, nearRow, locMast1, rowLastnoType.getType().longValue());
- if (!Cools.isEmpty(locMast2) && locMast2.getRow1() == curRow) {
- locMast = locMast2;
- break;
- }
- }
- }
- } else if (Cools.isEmpty(locMast)) {
- int[] bayRange = getAgvAreaBayRange(preferredArea);
- locMast = findAgvLocByRows(rowLastno, rowLastnoType, getAgvAreaRows(preferredArea, rowLastno),
- bayRange[0], bayRange[1], curRow, nearRow, locTypeDto, false);
- if (!Cools.isEmpty(locMast)) {
- crnNo = locMast.getCrnNo();
- }
if (Cools.isEmpty(locMast)) {
locMast = findAgvLocByRows(rowLastno, rowLastnoType, getAgvFallbackRows(rowLastno),
- 1, 19, curRow, nearRow, locTypeDto, true);
+ 1, 19, curRow, nearRow, locTypeDto, findLocNoAttributeVo, true);
if (!Cools.isEmpty(locMast)) {
crnNo = locMast.getCrnNo();
}
--
Gitblit v1.9.1