From a68a6de7f27e035beb2a141d895dd7e44ae9e659 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期六, 21 三月 2026 10:22:02 +0800
Subject: [PATCH] 完善找库位规则
---
src/main/java/com/zy/common/service/CommonService.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 50 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/zy/common/service/CommonService.java b/src/main/java/com/zy/common/service/CommonService.java
index 6aa6b8c..68548cb 100644
--- a/src/main/java/com/zy/common/service/CommonService.java
+++ b/src/main/java/com/zy/common/service/CommonService.java
@@ -538,6 +538,30 @@
return orderedCrnNos;
}
+ /**
+ * 浼樺厛鎸� s_crn_no/e_crn_no 鍙嶆帹鐪熷疄鍫嗗灈鏈烘暟閲忋��
+ *
+ * 涔嬪墠鏈夐�昏緫閿欒鎶� asr_row_lastno.crn_qty 褰撴垚杞娓告爣鍐欏洖锛�
+ * 瀵艰嚧鈥滃爢鍨涙満鏁伴噺鈥濆瓧娈佃姹℃煋銆傚悗缁壘浣嶄笉鑳藉啀鐩存帴淇′换 crn_qty锛�
+ * 鍚﹀垯浼氬皯鎵爢鍨涙満锛岃〃鐜板嚭鏉ュ氨鏄换鍔¢暱鏈熷亸鍚戞煇鍑犲彴鍫嗗灈鏈恒��
+ */
+ private int resolveCrnCount(RowLastno rowLastno) {
+ if (rowLastno == null) {
+ return 0;
+ }
+ if (rowLastno.getsCrnNo() != null && rowLastno.geteCrnNo() != null && rowLastno.geteCrnNo() >= rowLastno.getsCrnNo()) {
+ return rowLastno.geteCrnNo() - rowLastno.getsCrnNo() + 1;
+ }
+ if (rowLastno.getCrnQty() != null && rowLastno.getCrnQty() > 0) {
+ return rowLastno.getCrnQty();
+ }
+ Integer rowSpan = getCrnRowSpan(rowLastno.getTypeId());
+ if (rowSpan != null && rowSpan > 0 && rowLastno.getsRow() != null && rowLastno.geteRow() != null && rowLastno.geteRow() >= rowLastno.getsRow()) {
+ return (rowLastno.geteRow() - rowLastno.getsRow() + 1 + rowSpan - 1) / rowSpan;
+ }
+ return 0;
+ }
+
private Integer getCrnStartRow(RowLastno rowLastno, Integer crnNo) {
if (rowLastno == null || crnNo == null) {
return null;
@@ -729,6 +753,11 @@
*
* 鎺ㄨ崘鎺掑彧瀵规櫘閫氱墿鏂欑敓鏁堬紝绌烘墭鐩樺凡缁忓垏鎹㈡垚鈥滄寜搴撳尯杞鍫嗗灈鏈衡�濈殑瑙勫垯锛�
* 鍥犳杩欓噷浼氱洿鎺ヨ烦杩囩┖鎵樼洏璇锋眰锛岄伩鍏� row 鍙傛暟鎶婄┖鎵樼洏閲嶆柊甯﹀洖鏃ч�昏緫銆�
+ *
+ * 鍙﹀锛屽崟鎺掓帹鑽愪笉鍐嶄綔涓衡�滃己缁戝畾鍗曞彴鍫嗗灈鏈衡�濆鐞嗐��
+ * 鐜板満涓婃父缁忓父鍙紶涓�涓帹鑽愭帓锛屼緥濡� row=[1]锛屽鏋滆繖閲岀洿鎺ョ煭璺懡涓紝
+ * 婊℃澘浠诲姟灏变細闀挎湡鍘嬪湪鍚屼竴鍙板爢鍨涙満涓娿�傜幇鍦ㄥ彧鏈夊綋鎺ㄨ崘鎺掕兘瑕嗙洊澶氬彴鍫嗗灈鏈烘椂锛�
+ * 鎵嶆妸瀹冨綋浣滅湡姝g殑浼樺厛鍊欓�夐泦鍚堛��
*/
private LocMast findRun2RecommendLoc(RowLastno rowLastno, RowLastnoType rowLastnoType, boolean emptyPalletRequest,
List<Integer> recommendRows, LocTypeDto locTypeDto, Integer staDescId,
@@ -738,7 +767,7 @@
return null;
}
List<Integer> recommendCrnNos = mapRowsToCrnNos(rowLastno, recommendRows);
- if (Cools.isEmpty(recommendCrnNos)) {
+ if (Cools.isEmpty(recommendCrnNos) || recommendCrnNos.size() <= 1) {
return null;
}
LocMast locMast = findRun2EmptyLocByCrnNos(rowLastno, rowLastnoType, recommendCrnNos, locTypeDto,
@@ -791,11 +820,25 @@
* 鏅�氱墿鏂欏懡涓簱浣嶅悗锛屾部鐢� run2 鍘熸湁鐨勫叏浠撹疆璇㈡父鏍囨帹杩涙柟寮忋��
*/
private void advanceNormalRun2Cursor(RowLastno rowLastno, int curRow) {
+ advanceNormalRun2Cursor(rowLastno, curRow, null, null);
+ }
+
+ /**
+ * 鏅�氱墿鏂欐父鏍囦紭鍏堟寜鈥滄湰娆$湡姝e彲鐢ㄧ殑鍫嗗灈鏈洪泦鍚堚�濇帹杩涖��
+ *
+ * 杩欐牱鍗充娇搴撳尯瀹氫箟閲屽瓨鍦ㄤ笉瀛樺湪鐨勫爢鍨涙満锛屾垨鑰呰矾寰勪富鏁版嵁鍙鐩栭儴鍒嗗爢鍨涙満锛�
+ * 婊℃澘浠诲姟涔熶細鍦ㄧ湡瀹炲彲浣滀笟鐨勫爢鍨涙満涔嬮棿杞锛屼笉浼氬洜涓虹悊璁哄爢鍨涙満鍙风殑绌烘礊鑰岄暱鏈熷洖钀藉埌鍚屼竴鍙般��
+ */
+ 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;
- updateCurRow = getNextRun2CurrentRow(rowLastno, updateCurRow);
+ if (!Cools.isEmpty(runnableCrnNos) && selectedCrnNo != null) {
+ updateCurRow = getNextRun2CurrentRow(rowLastno, runnableCrnNos, selectedCrnNo, updateCurRow);
+ } else {
+ updateCurRow = getNextRun2CurrentRow(rowLastno, updateCurRow);
+ }
rowLastno.setCurrentRow(updateCurRow);
rowLastnoService.updateById(rowLastno);
}
@@ -1471,7 +1514,7 @@
}
int sRow = rowLastno.getsRow();
int eRow = rowLastno.geteRow();
- int crnNumber = rowLastno.getCrnQty();
+ int crnNumber = resolveCrnCount(rowLastno);
// ===============>>>> 寮�濮嬫墽琛�
@@ -1691,7 +1734,7 @@
if (Cools.isEmpty(rowLastnoType)) {
throw new CoolException("鏁版嵁寮傚父锛岃鑱旂郴绠$悊鍛�===銆嬪簱浣嶈鍒欑被鍨嬫湭鐭�");
}
- int crnNumber = rowLastno.getCrnQty();
+ int crnNumber = resolveCrnCount(rowLastno);
rowCount = crnNumber;
curRow = rowLastno.getCurrentRow();
@@ -1701,6 +1744,7 @@
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);
@@ -1727,7 +1771,7 @@
if (emptyPalletRequest) {
advanceEmptyPalletRun2Cursor(emptyPalletAreaSearchResult, locMast);
} else {
- advanceNormalRun2Cursor(rowLastno, curRow);
+ advanceNormalRun2Cursor(rowLastno, curRow, orderedRunnableCrnNos, locMast == null ? null : locMast.getCrnNo());
}
if (Cools.isEmpty(locMast) || !locMast.getLocSts().equals("O")) {
@@ -1789,7 +1833,7 @@
}
int sRow = rowLastno.getsRow();
int eRow = rowLastno.geteRow();
- int crnNumber = rowLastno.getCrnQty();
+ int crnNumber = resolveCrnCount(rowLastno);
// ===============>>>> 寮�濮嬫墽琛�
curRow = rowLastno.getCurrentRow();
--
Gitblit v1.9.1