From c28812eb7e5afa79cb5e2f4fbee7f96c7d7767ed Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期五, 03 四月 2026 14:33:22 +0800
Subject: [PATCH] AGV出库,立库查询库存优化
---
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 69 +++++++++++++++++++++++++++-------
1 files changed, 54 insertions(+), 15 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
index a900c9f..c6c3eea 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -1740,7 +1740,7 @@
double val = Math.round((combMat.getAnfme() + wrkDetl.getAnfme()) * 10000) / 10000.0;
WrkDetl detl = new WrkDetl();
detl.setOrderNo(stationDetl.getOrderNo());
- detl.setBoxType1(wrkDetl.getBoxType1());
+ detl.setBoxType1(param.getBoxType1());
detl.setZpallet(param.getBarcode());
detl.setBarcode(param.getBarcode());
detl.setThreeCode(combMat.getThreeCode());
@@ -2250,7 +2250,16 @@
AtomicReference<Double> totalOut = new AtomicReference<>(0.0);
listMap.forEach((matnr, detls) -> {
Map<String, List<LocDetl>> supIds = detls.stream().collect(Collectors.groupingBy(LocDetl::getStandby1));
- supIds.forEach((supId, sups) -> {
+ for (String supId : supIds.keySet()) {
+ List<LocDetl> sups = supIds.get(supId);
+// }
+// supIds.forEach((supId, sups) -> {
+ Mat mats = matService.selectOne(new EntityWrapper<Mat>()
+ .eq("supp_code", supId)
+ .eq("matnr", matnr));
+ if (Objects.isNull(mats)) {
+ throw new CoolException("鐗╂枡涓嶅瓨鍦紒锛�");
+ }
// 鏍规嵁supId(渚涘簲鍟�)鍒嗙被锛屽緱鍒伴渶瑕佸瓨鏀剧殑鎬荤┖搴撳瓨鏁伴噺
Double sum = sups.stream().mapToDouble(LocDetl::getAnfme).sum();
AtomicReference<Double> itemed = new AtomicReference<>(0.0);
@@ -2278,12 +2287,6 @@
if (container.getMixMax() > sets.size()) {
//浣欎笅鍙贩鏀剧绫�
long suplus = Math.round((container.getMixMax() - sets.size()) * 10000) / 10000;
- Mat mats = matService.selectOne(new EntityWrapper<Mat>()
- .eq("supp_code", supId)
- .eq("matnr", matnr));
- if (Objects.isNull(mats)) {
- throw new CoolException("鐗╂枡涓嶅瓨鍦紒锛�");
- }
//浣欎笅鏈�澶у彲鏀炬暟閲�
Double v = Math.round((mats.getUpQty() * suplus) * 10000) / 10000.0;
// 鍏ュ簱鏁伴噺灏忎簬闆朵笖鍏ュ簱鏁伴噺鍑忓幓宸茶鍒掑嚭鏁伴噺澶т簬闆讹紙锛�
@@ -2296,8 +2299,46 @@
}
}
});
+ } else {
+ // 鑾峰彇褰撳墠渚涘簲鍟�+ 鐗╂枡鍦ㄥ簱
+ LocMast notFullList = locMastService.selectNotFull(mats.getLocType(), one.getId());
+ if (Objects.isNull(notFullList)) {
+ continue;
+ }
+ BasContainer container = basContainerService
+ .selectOne(new EntityWrapper<BasContainer>().eq("barcode", notFullList.getBarcode()));
+ if (Objects.isNull(container)) {
+ throw new CoolException("鏁版嵁閿欒锛屽鍣ㄤ笉瀛樺湪锛侊紒");
+ }
+ List<LocDetl> adetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", notFullList.getLocNo()));
+ Set<String> sets = adetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet());
+ List<LocDetl> locDtls = new ArrayList<>();
+ // 鍒ゆ柇瀹瑰櫒鏄惁杩樺彲娣锋斁,鍙婂綋鍓嶇墿鏂欏彲鏀惧灏�
+ if (container.getMixMax() > sets.size()) {
+ //浣欎笅鍙贩鏀剧绫�
+ long suplus = Math.round((container.getMixMax() - sets.size()) * 10000) / 10000;
+ //浣欎笅鏈�澶у彲鏀炬暟閲�
+ Double v = Math.round((mats.getUpQty() * suplus) * 10000) / 10000.0;
+ // 鍏ュ簱鏁伴噺灏忎簬闆朵笖鍏ュ簱鏁伴噺鍑忓幓宸茶鍒掑嚭鏁伴噺澶т簬闆讹紙锛�
+ if (sum.compareTo(v) <= 0 && sum.compareTo(itemed.get()) > 0) {
+ itemed.set(Math.round((itemed.get() + v) * 10000) / 10000.0);
+ // 鍙斁涓�
+ LocDetl locDetl = new LocDetl();
+ BeanUtils.copyProperties(mats, locDetl);
+ locDetl.setLocNo(notFullList.getLocNo());
+ locDetl.setAnfme(0.0);
+ locDetl.setMatnr(mats.getMatnr());
+ locDetl.setZpallet(notFullList.getBarcode());
+ locDetl.setSuppCode(mats.getSuppCode());
+ locDetl.setMaktx(mats.getMaktx());
+ locDtls.add(locDetl);
+ CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(notFullList.getLocNo()).setLocDetlList(locDtls);
+ locMasts.add(crnTaskDetlDTO);
+ totalOut.set(Math.round((totalOut.get() + itemed.get()) * 10000) / 10000.0);
+ }
+ }
}
- });
+ }
});
/**鏄惁浼樺厛绌烘澘鍑哄簱*/
@@ -2314,7 +2355,6 @@
}
CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(new ArrayList<>());
locMasts.add(crnTaskDetlDTO);
-
// 绌烘澘鍑哄簱
generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station);
} else {
@@ -2626,14 +2666,14 @@
if (Objects.isNull(station)) {
throw new CoolException("绔欑偣涓嶅瓨鍦�!!");
}
-
- station.setLocSts("O"); // S.鍏ュ簱棰勭害
+ station.setLocSts("O");
station.setBarcode(barcode);
station.setModiTime(new Date());
station.setModiUser(userId);
if (!basStationService.updateById(station)) {
throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
}
+ basStationDetlService.delete(new EntityWrapper<BasStationDetl>().eq("dev_no", station.getDevNo()));
}
}
@@ -2718,13 +2758,12 @@
if (Objects.isNull(station)) {
throw new CoolException("绔欑偣涓嶅瓨鍦�!!");
}
-
try {
//绌哄彴杞﹀洖搴�
generateAgvTask("agv_back", locCache, callAgvBackParam.getOrgSite(), station.getBarcode(), userId, "M2");
} catch (Exception e) {
- e.printStackTrace();
- return R.error(e.getMessage());
+ log.error(e.getMessage());
+ throw new CoolException(e.getMessage());
}
return R.ok(locCache);
--
Gitblit v1.9.1