From 0d3a8b5ee34708d87c0a60075ed153f828b233be Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期三, 21 一月 2026 11:15:28 +0800
Subject: [PATCH] 添加格层编码入库修改
---
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 181 ++++++++++++++++++++++++++++++++++-----------
1 files changed, 136 insertions(+), 45 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 e2eb19a..4c43fdd 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -605,9 +605,6 @@
if (Objects.isNull(container)) {
throw new CoolException("鏁版嵁閿欒锛氬鍣ㄧ爜涓嶅瓨鍦紒锛�");
}
- // if (param.getBarcode().length() != 8) {
- // throw new CoolException("鏉$爜闀垮害涓嶆槸8浣�===>>" + param.getBarcode());
- // }
if (Objects.isNull(param.getType())) {
param.setType("0");
@@ -689,7 +686,10 @@
OrderDetlPakin detls = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>()
.eq("order_id", order.getId())
.eq("matnr", elem.getMatnr()));
-
+ if (Objects.isNull(elem.getBoxType1())) {
+ throw new CoolException("鏍煎眰缂栫爜涓嶈兘涓虹┖锛侊紒");
+ }
+ detls.setBoxType1(elem.getBoxType1());
if (Objects.isNull(detls)) {
throw new CoolException("鏁版嵁閿欒锛氬崟鎹槑缁嗕笉瀛樺湪锛侊紒");
}
@@ -699,14 +699,14 @@
}
OrderInAndOutUtil.increaseWorkQty(Boolean.TRUE, order.getId(), elem.getMatnr(), elem.getBatch(),
elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(),
- elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme());
- DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(),
+ "1", elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme());
+ DetlDto detlDto = new DetlDto(order.getOrderNo(), elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(),
elem.getStandby2(), elem.getStandby3(),
elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme(),
elem.getThreeCode());
detlDto.setOrderId(order.getId());
detlDto.setOrderNo(order.getOrderNo());
- if (DetlDto.has(detlDtos, detlDto)) {
+ if (DetlDto.hasOrder(detlDtos, detlDto)) {
DetlDto one = DetlDto.findDto(detlDtos, detlDto);
assert one != null;
one.setAnfme(one.getAnfme() + detlDto.getAnfme());
@@ -762,6 +762,7 @@
waitPakin.setThreeCode(detlDto.getThreeCode());
waitPakin.setSuppCode(detlDto.getStandby1());
waitPakin.setStandby1(detlDto.getStandby1());
+ waitPakin.setBoxType1(detlDto.getBoxType1());
waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵��
waitPakin.setAnfme(detlDto.getAnfme()); // 鏁伴噺
waitPakin.setStatus("Y"); // 鐘舵��
@@ -991,7 +992,7 @@
try {
response = new HttpHandler.Builder()
.setUri(MesConstant.URL)
- .setPath(MesConstant.PACK_DOWN_URL)
+ .setPath(MesConstant.IN_DISPATCH_RESULT)
.setJson(JSON.toJSONString(mesCombParam))
.build()
.doPost();
@@ -999,11 +1000,11 @@
if (jsonObject.getInteger("code").equals(200)) {
success = true;
} else if (jsonObject.getInteger("code").equals(500)) {
- log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL + MesConstant.PACK_DOWN_URL,
+ log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL + MesConstant.IN_DISPATCH_RESULT,
JSON.toJSONString(mesCombParam), response);
throw new CoolException(jsonObject.getString("msg"));
} else {
- log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL + MesConstant.PACK_DOWN_URL,
+ log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", MesConstant.URL + MesConstant.IN_DISPATCH_RESULT,
JSON.toJSONString(mesCombParam), response);
throw new CoolException("涓婃姤mes绯荤粺澶辫触");
}
@@ -1015,7 +1016,7 @@
// 淇濆瓨鎺ュ彛鏃ュ織
apiLogService.save(
"鎵撳寘涓嬬嚎甯墭涓婃姤",
- MesConstant.URL + MesConstant.PACK_DOWN_URL,
+ MesConstant.URL + MesConstant.IN_DISPATCH_RESULT,
null,
"127.0.0.1",
JSON.toJSONString(mesCombParam),
@@ -1066,7 +1067,7 @@
// }
OrderInAndOutUtil.increaseWorkQty(Boolean.TRUE, order.getId(), detlDto.getMatnr(), detlDto.getBatch(),
detlDto.getBrand(), detlDto.getStandby1(), detlDto.getStandby2(), detlDto.getStandby3(),
- detlDto.getBoxType1(), detlDto.getBoxType2(), detlDto.getBoxType3(), detlDto.getAnfme());
+ "1", detlDto.getBoxType2(), detlDto.getBoxType3(), detlDto.getAnfme());
// 淇濆瓨鍏ュ簱閫氱煡妗�
Mat mat = matService.selectByMatnr(detlDto.getMatnr());
if (Cools.isEmpty(mat)) {
@@ -1540,7 +1541,7 @@
station.setModiTime(new Date());
station.setModiUser(userId);
if (!basStationService.updateById(station)) {
- throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+ throw new CoolException("鏇存柊鐩爣绔欑偣鐘舵�佸け璐�");
}
} else {
throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + station.getLocSts());
@@ -1741,6 +1742,7 @@
throw new CoolException("鏁版嵁閿欒锛岀珯鐐逛笉瀛樺湪锛侊紒");
}
station.setLocSts(LocStsType.LOC_STS_TYPE_O.type);
+ station.setBarcode("");
if (!basStationService.updateById(station)) {
throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
}
@@ -1785,6 +1787,7 @@
}
station.setLocSts(LocStsType.LOC_STS_TYPE_O.type);
+ station.setBarcode("");
if (!basStationService.updateById(station)) {
throw new CoolException("绔欑偣鐘舵�佷慨鏀瑰け璐�!");
}
@@ -1806,6 +1809,13 @@
generateCrnInTask(waitPakins, station, param.getLocType1(), userId);
}
+ /**
+ * SO/EO 鍖虹粍鎵�
+ * @author Ryan
+ * @date 2025/12/18 15:19
+ * @param params
+ * @return com.core.common.R
+ */
@Override
@Transactional(rollbackFor = Exception.class)
public R collectionPakin(CollectionPakinParams params, Long userId) {
@@ -2186,8 +2196,14 @@
.eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type)
.orderAsc(Arrays.asList("row1", "bay1", "lev1"))
.last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
+
+ if (Objects.isNull(locMast)) {
+ throw new CoolException("鏈煡璇㈠埌鍙敤鐨勭┖鏉夸俊鎭紒锛�");
+ }
+
CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(locDetls);
locMasts.add(crnTaskDetlDTO);
+
// 绌烘澘鍑哄簱
generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station);
}
@@ -2230,7 +2246,8 @@
wrkMast.setStaNo(staDesc.getStnNo() + ""); // 鐩爣绔�
wrkMast.setSourceLocNo(locMast.getLocNo()); // 婧愬簱浣�
//灏忔澗椤圭洰锛岀紦瀛樺嚭搴揂GV绔欑偣锛岀敤浜庢竻绌虹紦瀛樺尯搴撳瓨
- wrkMast.setAvgSta(station.getDevNo());
+ wrkMast.setPauseMk(station.getDevNo());
+// wrkMast.setAvgSta(station.getDevNo());;
wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
wrkMast.setPicking("N"); // 鎷f枡
wrkMast.setExitMk("N"); // 閫�鍑�
@@ -2294,7 +2311,7 @@
Task task = new Task();
task.setWrkNo(workNo)
.setIoTime(new Date())
- .setWrkSts(11L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+ .setWrkSts(301L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
.setIoType(loc.getLocSts().equals("D") ? 110 : 101) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
.setTaskType("agv")
.setIoPri(10D)
@@ -2371,11 +2388,6 @@
*/
@Transactional(rollbackFor = Exception.class)
public void generateAgvTask(String type, LocCache loc, String orgSite, String barcode, Long userId) {
- List<WaitPakin> pakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode));
- if (Objects.isNull(pakins) || pakins.isEmpty()) {
- throw new CoolException("缁勬墭淇℃伅涓嶅瓨鍦紒锛�");
- }
-
List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", barcode));
if (!tasks.isEmpty()) {
throw new CoolException("鎵樼洏宸插湪浠诲姟鎵ц涓�..");
@@ -2386,7 +2398,7 @@
Task task = new Task();
task.setWrkNo(workNo)
.setIoTime(new Date())
- .setWrkSts(1L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+ .setWrkSts(201L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
.setIoType(1) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
.setTaskType("agv")
.setIoPri(10D)
@@ -2406,32 +2418,39 @@
throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
}
- for (WaitPakin pakin : pakins) {
- TaskDetl wrkDetl = new TaskDetl();
- BeanUtils.copyProperties(pakin, wrkDetl);
- wrkDetl.setId(null).setWrkNo(workNo)
- .setIoTime(new Date())
- .setOrderNo(pakin.getOrderNo())
- .setAnfme(pakin.getAnfme())
- .setZpallet(pakin.getZpallet())
- .setBatch(pakin.getBatch())
- .setMatnr(pakin.getMatnr())
- .setMaktx(pakin.getMaktx())
- .setAppeUser(userId)
- .setUnit(pakin.getUnit())
- .setModel(pakin.getModel())
- .setAppeTime(new Date())
- .setModiUser(userId);
- if (!taskDetlService.insert(wrkDetl)) {
- throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+ if (!type.equals("agv_back")) {
+ List<WaitPakin> pakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode));
+ if (Objects.isNull(pakins) || pakins.isEmpty()) {
+ throw new CoolException("缁勬墭淇℃伅涓嶅瓨鍦紒锛�");
}
- }
+ for (WaitPakin pakin : pakins) {
+ TaskDetl wrkDetl = new TaskDetl();
+ BeanUtils.copyProperties(pakin, wrkDetl);
+ wrkDetl.setId(null).setWrkNo(workNo)
+ .setIoTime(new Date())
+ .setOrderNo(pakin.getOrderNo())
+ .setAnfme(pakin.getAnfme())
+ .setZpallet(pakin.getZpallet())
+ .setBatch(pakin.getBatch())
+ .setMatnr(pakin.getMatnr())
+ .setMaktx(pakin.getMaktx())
+ .setAppeUser(userId)
+ .setUnit(pakin.getUnit())
+ .setModel(pakin.getModel())
+ .setAppeTime(new Date())
+ .setModiUser(userId);
+ if (!taskDetlService.insert(wrkDetl)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+ }
- for (WaitPakin pakin : pakins) {
- pakin.setIoStatus("Y");
- if (!waitPakinService.updateById(pakin)) {
- throw new CoolException("鏇存柊缁勬墭淇℃伅澶辫触");
+ }
+
+ for (WaitPakin pakin : pakins) {
+ pakin.setIoStatus("Y");
+ if (!waitPakinService.updateById(pakin)) {
+ throw new CoolException("鏇存柊缁勬墭淇℃伅澶辫触");
+ }
}
}
@@ -2453,7 +2472,7 @@
throw new CoolException("绔欑偣涓嶅瓨鍦�!!");
}
- if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+ if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type) || station.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type)) {
station.setLocSts("R"); // S.鍏ュ簱棰勭害
station.setBarcode(barcode);
station.setModiTime(new Date());
@@ -2519,4 +2538,76 @@
}
return result;
}
+
+ /**
+ * 鍛煎彨AGV绌哄彴杞﹁繑鍥�
+ * @author Ryan
+ * @date 2025/9/24
+ * @param callAgvBackParam
+ * @return com.core.common.R
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public R agvCallback(AgvCallParams callAgvBackParam, Long userId) {
+ if (Objects.isNull(callAgvBackParam.getOrgSite())) {
+ return R.error("鍙傛暟涓嶈兘涓虹┖!!");
+ }
+
+ // 鎸夊綋鍓嶆煡鎵惧簱浣嶉『搴忥紝鏌ュ埌涓�涓悗锛屼笉鍐嶅線涓嬫煡璇�
+ LocCache locCache = findPriorityLocCache();
+
+ if (Objects.isNull(locCache)) {
+ return R.error("鏈煡璇㈠埌鍙敤搴撲綅");
+ }
+
+ // 淇敼鐩爣绔欑偣淇℃伅
+ BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", callAgvBackParam.getOrgSite()));
+ if (Objects.isNull(station)) {
+ throw new CoolException("绔欑偣涓嶅瓨鍦�!!");
+ }
+
+ try {
+ //绌哄彴杞﹀洖搴�
+ generateAgvTask("agv_back", locCache, callAgvBackParam.getOrgSite(), station.getBarcode(), userId);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return R.error(e.getMessage());
+ }
+
+ return R.ok(locCache);
+ }
+
+ /**
+ * 鎸変紭鍏堢骇鏌ユ壘鍙敤搴撲綅
+ * 椤哄簭锛氬叆搴撶紦瀛樺尯 -> SO鍖� -> EO鍖�
+ */
+ private LocCache findPriorityLocCache() {
+ // 1. Try Inbound Cache Area
+ LocCache loc = findAvailableLocByAreaType(LocAreaType.LOC_AREA_TYPE_IN_CACHE);
+ if (loc != null) return loc;
+
+ // 2. Try SO Area
+ loc = findAvailableLocByAreaType(LocAreaType.LOC_AREA_TYPE_SO);
+ if (loc != null) return loc;
+
+ // 3. Try EO Area
+ loc = findAvailableLocByAreaType(LocAreaType.LOC_AREA_TYPE_EO);
+ return loc;
+ }
+
+ /**
+ * 鏍规嵁鍖哄煙绫诲瀷鏌ユ壘鍙敤搴撲綅
+ */
+ private LocCache findAvailableLocByAreaType(LocAreaType areaType) {
+ BasAreas area = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", areaType.type));
+ if (area == null) {
+ return null;
+ }
+ return locCacheService.selectOne(new EntityWrapper<LocCache>()
+ .eq("area_id", area.getId())
+ .eq("frozen", 0)
+ .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
+ .orderAsc(Arrays.asList("loc_no"))
+ .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
+ }
}
--
Gitblit v1.9.1