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/asrs/utils/Utils.java | 76 ++++++++-------
src/main/java/com/zy/asrs/controller/OpenController.java | 150 ++++++++++++++++++++++++++++-
src/main/java/com/zy/asrs/entity/param/QueryTaskParam.java | 10 ++
src/main/java/com/zy/common/service/CommonService.java | 56 ++++++++++-
4 files changed, 244 insertions(+), 48 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/OpenController.java b/src/main/java/com/zy/asrs/controller/OpenController.java
index 35c6fe2..4547421 100644
--- a/src/main/java/com/zy/asrs/controller/OpenController.java
+++ b/src/main/java/com/zy/asrs/controller/OpenController.java
@@ -4,18 +4,15 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.plugins.Page;
import com.core.annotations.AppAuth;
import com.core.common.*;
import com.core.exception.CoolException;
import com.google.common.collect.Lists;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.*;
-import com.zy.asrs.service.LocDetlService;
-import com.zy.asrs.service.OpenService;
-import com.zy.asrs.service.WaitPakinService;
-import com.zy.asrs.service.WrkDetlService;
-import com.zy.asrs.service.WrkMastLogService;
-import com.zy.asrs.service.WrkMastService;
+import com.zy.asrs.mapper.ReportQueryMapper;
+import com.zy.asrs.service.*;
import com.zy.common.model.DetlDto;
import com.zy.common.model.LocDetlDto;
import com.zy.common.model.enums.WorkNoType;
@@ -26,6 +23,7 @@
import javax.naming.ldap.HasControls;
import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
import java.util.*;
/**
@@ -55,7 +53,11 @@
private WrkMastService wrkMastService;
@Autowired
private WrkMastLogService wrkMastLogService;
+ @Autowired
+ private MatService matService;
+ @Autowired
+ private ReportQueryMapper reportQueryMapper;
// @PostMapping("/order/matSync/default/v1")
//// @AppAuth(memo = "鍟嗗搧淇℃伅鍚屾鎺ュ彛")
// public synchronized R syncMatInfo(@RequestHeader(required = false) String appkey,
@@ -538,5 +540,141 @@
}
return openService.pakoutOrderPause(param);
}
+
+
+ /*************************************鐢佃鏈虹▼搴�***********************************************/
+
+ @GetMapping("/locDetl/statistics")
+ public R locDetlStatistics(){
+ HashMap<String, Object> param = new HashMap<>();
+ Page<LocDetl> stockStatis = locDetlService.getStockStatis(toPage(1, 100, param, LocDetl.class));
+ for (LocDetl locDetl : stockStatis.getRecords()) {
+ Mat mat = matService.selectByMatnr(locDetl.getMatnr());
+ if (mat != null) {
+ locDetl.sync(mat);
+ }
+ }
+ return R.ok(stockStatis);
+ }
+
+ @GetMapping("/line/charts")
+ public R locIoLineCharts(){
+ Map<String,Object> map=new HashMap<String, Object>();
+ List<AxisBean> list = new ArrayList<AxisBean>();
+
+ List<WorkChartAxis> listChart = reportQueryMapper.getChartAxis();
+
+ if(listChart!=null) {
+ ArrayList<Integer> data1 = new ArrayList<Integer>();
+ ArrayList<Integer> data2 = new ArrayList<Integer>();
+
+ SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
+ Calendar calendar = Calendar.getInstance();
+ calendar.add(Calendar.DATE, -12);
+ for(int i=0;i<12;i++) {
+ boolean flag = true;
+ calendar.add(Calendar.DATE, 1);
+ String str = sf.format(calendar.getTime());
+ for(WorkChartAxis workChart : listChart) {
+ if(str.equals(workChart.getYmd())) {
+ data1.add(workChart.getInqty());
+ data2.add(workChart.getOutqty());
+ flag = false;
+ break;
+ }
+ }
+ if(flag) {
+ data1.add(0);
+ data2.add(0);
+ }
+ }
+ AxisBean inqty = new AxisBean();
+ inqty.setName("鍏ュ簱鏁伴噺");
+ Integer[] array1 = new Integer[data1.size()];
+ inqty.setData(data1.toArray(array1));
+ list.add(inqty);
+ AxisBean outqty = new AxisBean();
+ outqty.setName("鍑哄簱鏁伴噺");
+ Integer[] array2 = new Integer[data2.size()];
+ outqty.setData(data2.toArray(array2));
+ list.add(outqty);
+ }
+ map.put("rows",list);
+ return R.ok(map);
+ }
+
+ /**
+ * 搴撳瓨淇℃伅鏌ヨ鎺ュ彛
+ */
+ @GetMapping("/queryLoc")
+ public synchronized R queryLoc() {
+ List<Map<String, Object>> pie = new ArrayList<>();
+ LocChartPie locUseRate = reportQueryMapper.getLocUseRate();
+
+ if (locUseRate != null) {
+ Map<String, Object> map = new HashMap<>();
+ map.put("name", "鍦ㄥ簱");
+ map.put("value", locUseRate.getFqty());
+ pie.add(map);
+
+ Map<String, Object> map1 = new HashMap<>();
+ map1.put("name", "绌�");
+ map1.put("value", locUseRate.getOqty());
+ pie.add(map1);
+
+ Map<String, Object> map2 = new HashMap<>();
+ map2.put("name", "浣跨敤");
+ map2.put("value", locUseRate.getUqty());
+ pie.add(map2);
+
+ Map<String, Object> map3 = new HashMap<>();
+ map3.put("name", "绂佺敤");
+ map3.put("value", locUseRate.getXqty());
+ pie.add(map3);
+ }
+
+ // 鎬诲簱浣嶆暟
+ Integer total = (int) Arith.add(0, locUseRate.getFqty(), locUseRate.getOqty(), locUseRate.getUqty(), locUseRate.getXqty());
+ // 浣跨敤涓�
+ Integer used = locUseRate.getFqty() + locUseRate.getUqty();
+ // 搴撲綅浣跨敤鐜�
+ double usedDivides = Arith.divides(3, used, total);
+ double usedPr = Arith.multiplys(1, usedDivides, 100);
+
+ return R.ok(
+ Cools.add("pie", pie)
+ .add("stockCount", locUseRate.getFqty())
+ .add("emptyCount", locUseRate.getOqty())
+ .add("disableCount", locUseRate.getXqty())
+ .add("total", total)
+ .add("used", used)
+ .add("usedPr", usedPr)
+ );
+ }
+
+ /**
+ * 浠诲姟鏌ヨ鎺ュ彛
+ */
+ @PostMapping("/queryTask")
+ public synchronized R queryTask(@RequestBody QueryTaskParam param) {
+ if (Cools.isEmpty(param)) {
+ return R.parse(BaseRes.PARAM);
+ }
+ if (Cools.isEmpty(param.getTaskNo())) {
+ return R.error("浠诲姟鍙穂taskNo]涓嶈兘涓虹┖");
+ }
+ WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", param.getTaskNo()));
+ if (wrkMast == null) {
+ return R.error("浠诲姟涓嶅瓨鍦�");
+ }
+
+ List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(Integer.valueOf(param.getTaskNo()));
+
+ HashMap<String, Object> map = new HashMap<>();
+ map.put("taskNo", param.getTaskNo());
+ map.put("ioType", wrkMast.getIoType());
+ map.put("wrkDetls", wrkDetls);
+ return R.ok().add(map);
+ }
}
diff --git a/src/main/java/com/zy/asrs/entity/param/QueryTaskParam.java b/src/main/java/com/zy/asrs/entity/param/QueryTaskParam.java
new file mode 100644
index 0000000..c37e5ae
--- /dev/null
+++ b/src/main/java/com/zy/asrs/entity/param/QueryTaskParam.java
@@ -0,0 +1,10 @@
+package com.zy.asrs.entity.param;
+
+import lombok.Data;
+
+@Data
+public class QueryTaskParam {
+
+ private String taskNo;
+
+}
diff --git a/src/main/java/com/zy/asrs/utils/Utils.java b/src/main/java/com/zy/asrs/utils/Utils.java
index e26c7d0..6e13c42 100644
--- a/src/main/java/com/zy/asrs/utils/Utils.java
+++ b/src/main/java/com/zy/asrs/utils/Utils.java
@@ -152,7 +152,9 @@
* 3. 鑻ュ綋鍓嶅簱鍖烘病鏈夋弧瓒虫潯浠剁殑绌哄簱浣嶏紝鍐嶈ˉ鍏呭叾浠栧簱鍖虹殑鍫嗗灈鏈恒��
* 4. 褰� {@code locType1 = 1} 鏃讹紝鍏堣繑鍥炰綆搴撲綅鍫嗗灈鏈猴紝鍐嶆妸鍚屾壒鍫嗗灈鏈虹殑楂樺簱浣嶈拷鍔犲埌鍚庨潰銆�
* 5. 瀵逛笉瀛樺湪銆佹晠闅溿�佷笉鍙叆浠ュ強鏃犵┖搴撲綅鐨勫爢鍨涙満鐩存帴鍓旈櫎銆�
- * 6. 褰撶墿鏂欎负 {@code emptyPallet} 鏃讹紝鎸夌┖鏉垮叆搴撲紭鍏堣鍒欓噸鏂版帓搴忋��
+ *
+ * <p>杩欓噷鏄彧璇绘帓搴忓伐鍏凤紝涓嶅啀鍐欏洖 {@code asr_row_lastno.crn_qty}銆�
+ * {@code crn_qty} 鍦ㄤ富鏁版嵁閲岃〃绀衡�滃爢鍨涙満鏁伴噺鈥濓紝涓嶈兘鍐嶈鎷挎潵褰撹疆璇㈡父鏍囷紝鍚﹀垯浼氭妸鏁翠粨閰嶇疆鍐欏潖銆�
*
* <p>杩斿洖缁撴灉涓殑姣忎竴椤规牸寮忎负锛�
* {@code {crnNo: 鍫嗗灈鏈哄彿, locType1: 搴撲綅楂樹綆绫诲瀷}}
@@ -321,21 +323,10 @@
if (areaRowLastno == null) {
return new ArrayList<>(crnNos);
}
- Integer startCrnNo = resolveAreaStartCrnNo(areaRowLastno, rowLastno);
- Integer endCrnNo = resolveAreaEndCrnNo(areaRowLastno, rowLastno);
- if (startCrnNo != null && endCrnNo != null && startCrnNo <= endCrnNo) {
- for (int crnNo = startCrnNo; crnNo <= endCrnNo; crnNo++) {
- addAreaCrnNo(crnNos, crnNo, 1, endCrnNo);
- }
- for (int crnNo = areaRowLastno.getsCrnNo(); crnNo <= startCrnNo; crnNo++) {
- addAreaCrnNo(crnNos, crnNo, 1, endCrnNo);
- }
- Integer nextCrnQty = startCrnNo + 1;
- if (areaRowLastno.geteCrnNo() != null && nextCrnQty > areaRowLastno.geteCrnNo()) {
- nextCrnQty = areaRowLastno.getsCrnNo() == null ? 1 : areaRowLastno.getsCrnNo();
- }
- areaRowLastno.setCrnQty(nextCrnQty);
- SpringUtils.getBean(RowLastnoService.class).updateById(areaRowLastno);
+ Integer startCrnNo = resolveAreaStartCrnNo(areaRowLastno);
+ List<Integer> orderedCrnNos = getOrderedCrnNos(areaRowLastno, startCrnNo);
+ if (!orderedCrnNos.isEmpty()) {
+ crnNos.addAll(orderedCrnNos);
}
if (crnNos.isEmpty()) {
@@ -362,34 +353,47 @@
return defaultRowLastno;
}
- private static Integer resolveAreaStartCrnNo(RowLastno areaRowLastno, RowLastno defaultRowLastno) {
- if (areaRowLastno != null && areaRowLastno.getCrnQty() != null && areaRowLastno.getCrnQty() > 0) {
- return areaRowLastno.getCrnQty();
+ private static Integer resolveAreaStartCrnNo(RowLastno areaRowLastno) {
+ if (areaRowLastno == null) {
+ return null;
}
- if (areaRowLastno != null && areaRowLastno.getsCrnNo() != null && areaRowLastno.getsCrnNo() > 0) {
- return areaRowLastno.getsCrnNo();
+ Integer startCrnNo = areaRowLastno.getsCrnNo();
+ Integer endCrnNo = areaRowLastno.geteCrnNo();
+ Integer currentRow = areaRowLastno.getCurrentRow();
+ Integer rowSpan = getCrnRowSpan(areaRowLastno.getTypeId());
+ if (startCrnNo == null || startCrnNo <= 0) {
+ return 1;
}
- if (defaultRowLastno != null && defaultRowLastno.getsCrnNo() != null && defaultRowLastno.getsCrnNo() > 0) {
- return defaultRowLastno.getsCrnNo();
+ if (endCrnNo == null || endCrnNo < startCrnNo || currentRow == null || rowSpan == null || rowSpan <= 0) {
+ return startCrnNo;
}
- return 1;
+ int startRow = areaRowLastno.getsRow() == null ? 1 : areaRowLastno.getsRow();
+ int offset = Math.max(currentRow - startRow, 0) / rowSpan;
+ int resolvedCrnNo = startCrnNo + offset;
+ if (resolvedCrnNo < startCrnNo || resolvedCrnNo > endCrnNo) {
+ return startCrnNo;
+ }
+ return resolvedCrnNo;
}
- private static Integer resolveAreaEndCrnNo(RowLastno areaRowLastno, RowLastno defaultRowLastno) {
- if (areaRowLastno != null && areaRowLastno.geteCrnNo() != null && areaRowLastno.geteCrnNo() > 0) {
- return areaRowLastno.geteCrnNo();
+ private static List<Integer> getOrderedCrnNos(RowLastno rowLastno, Integer startCrnNo) {
+ List<Integer> orderedCrnNos = new ArrayList<>();
+ if (rowLastno == null) {
+ return orderedCrnNos;
}
- return null;
- }
-
- private static void addAreaCrnNo(LinkedHashSet<Integer> crnNos, Integer crnNo, Integer startCrnNo, Integer endCrnNo) {
- if (crnNos == null || crnNo == null || startCrnNo == null || endCrnNo == null) {
- return;
+ int start = rowLastno.getsCrnNo() == null ? 1 : rowLastno.getsCrnNo();
+ int end = rowLastno.geteCrnNo() == null ? start + ((rowLastno.getCrnQty() == null ? 1 : rowLastno.getCrnQty()) - 1) : rowLastno.geteCrnNo();
+ int first = startCrnNo == null ? start : startCrnNo;
+ if (first < start || first > end) {
+ first = start;
}
- if (crnNo < startCrnNo || crnNo > endCrnNo) {
- return;
+ for (int crnNo = first; crnNo <= end; crnNo++) {
+ orderedCrnNos.add(crnNo);
}
- crnNos.add(crnNo);
+ for (int crnNo = start; crnNo < first; crnNo++) {
+ orderedCrnNos.add(crnNo);
+ }
+ return orderedCrnNos;
}
private static List<Integer> getAllCrnNos(RowLastno rowLastno) {
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