From ac78112a61f2b6350ef3064edfc148ba572046d4 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期三, 24 九月 2025 08:43:51 +0800
Subject: [PATCH] AGV任务日志
---
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 191 +++++++++++++++++++++++++++++++++++++++++------
1 files changed, 165 insertions(+), 26 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 09fcff6..b01b75f 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -8,6 +8,7 @@
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.*;
+import com.zy.asrs.enums.LocStsType;
import com.zy.asrs.mapper.LocMastMapper;
import com.zy.asrs.mapper.ManLocDetlMapper;
import com.zy.asrs.service.*;
@@ -21,6 +22,7 @@
import com.zy.common.service.CommonService;
import com.zy.common.utils.HttpHandler;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -96,6 +98,15 @@
@Resource
private OrderDetlPakoutService orderDetlPakoutService;
+ @Autowired
+ private LocCacheService locCacheService;
+
+ @Autowired
+ private TaskService taskService;
+
+ @Autowired
+ private TaskDetlService taskDetlService;
+
@Override
@Transactional
public R WarehouseOutPickMergeV1(WarehouseOutPickMergeParam param, Long hostId, Long userId) {
@@ -117,8 +128,8 @@
wrkMast.setIoType(8); // 鍏ュ嚭搴撶姸鎬侊細8.鎷f枡閫斾腑骞舵澘
wrkMast.setIoPri(13D); // 浼樺厛绾�
wrkMast.setCrnNo(1);
- wrkMast.setSourceStaNo(1);
- wrkMast.setStaNo(1);
+ wrkMast.setSourceStaNo(1 + "");
+ wrkMast.setStaNo(1 + "");
wrkMast.setLocNo(param.getLocNo());
wrkMast.setBarcode(param.getBarcode()); // 鎵樼洏鐮�
wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
@@ -244,8 +255,8 @@
wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細101.鐢熸垚鍑哄簱
wrkMast.setIoType(104); // 鍏ュ嚭搴撶姸鎬�
wrkMast.setIoPri(13D); // 浼樺厛绾э細13
- wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯
- wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔�
+ wrkMast.setSourceStaNo(staDesc.getCrnStn() + ""); // 婧愮珯
+ wrkMast.setStaNo(staDesc.getStnNo() + ""); // 鐩爣绔�
wrkMast.setSourceLocNo(param.getLocNo()); // 婧愬簱浣�
wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
wrkMast.setPicking("Y"); // 鎷f枡
@@ -378,8 +389,8 @@
wrkMast.setIoType(108); // 鍏ュ嚭搴撶姸鎬侊細鍑哄簱锛屾嫞鏂欏叆搴�
wrkMast.setIoPri(13D); // 浼樺厛绾�
wrkMast.setCrnNo(1);
- wrkMast.setSourceStaNo(1);
- wrkMast.setStaNo(1);
+ wrkMast.setSourceStaNo(1 + "");
+ wrkMast.setStaNo(1 + "");
wrkMast.setSourceLocNo(combParam.getLocNo());
wrkMast.setBarcode(combParam.getBarcode()); // 鎵樼洏鐮�
wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
@@ -544,7 +555,7 @@
if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) {
throw new CoolException(BaseRes.PARAM);
}
- if (param.getCombMats().size() > 1) {
+ if (param.getCombMats().size() < 1) {
throw new CoolException("璇锋彁鍙栦竴涓晢鍝侊紝鎴栬�呭埛鏂伴噸鏂扮粍鎵橈紒");
}
// 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁
@@ -555,9 +566,6 @@
if (param.getBarcode().length() != 8) {
throw new CoolException("鏉$爜闀垮害涓嶆槸8浣�===>>" + param.getBarcode());
- }
- if (param.getCombMats().size() > 1) {
- throw new CoolException("涓嶅厑璁告贩鏂�===>>" + param.getBarcode());
}
int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", param.getBarcode()));
@@ -571,7 +579,6 @@
// 鏃犲崟缁勬墭
if (Cools.isEmpty(param.getOrderNo())) {
-
// 鐢熸垚鍏ュ簱閫氱煡妗�
List<DetlDto> detlDtos = new ArrayList<>();
param.getCombMats().forEach(elem -> {
@@ -593,7 +600,7 @@
throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
}
WaitPakin waitPakin = new WaitPakin();
- waitPakin.sync(mat);
+ BeanUtils.copyProperties(mat, waitPakin);
waitPakin.setBatch(detlDto.getBatch());
waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮�
waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵��
@@ -617,18 +624,20 @@
// 鐢熸垚鍏ュ簱閫氱煡妗�
List<DetlDto> detlDtos = new ArrayList<>();
param.getCombMats().forEach(elem -> {
-
// 璁㈠崟鏄庣粏鏁伴噺鏍¢獙
-// OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch());
- OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.TRUE, order.getId(), elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(),
- elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3());
- if (elem.getAnfme() > orderDetl.getEnableQty()) {
- throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
+// OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.TRUE, order.getId(), elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(),
+// elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3());
+ OrderDetlPakin detls = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>()
+ .eq("order_id", order.getId())
+ .eq("matnr", elem.getMatnr()));
+
+ if (Objects.isNull(detls)) {
+ throw new CoolException("鏁版嵁閿欒锛氬崟鎹槑缁嗕笉瀛樺湪锛侊紒");
}
- // 淇敼璁㈠崟浣滀笟鏁伴噺
-// if (!orderDetlService.increaseWorkQty(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) {
-// throw new CoolException("淇敼鍗曟嵁浣滀笟鏁伴噺澶辫触");
-// }
+
+ if (elem.getAnfme() > detls.getEnableQty()) {
+ throw new CoolException(detls.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
+ }
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(), elem.getStandby2(), elem.getStandby3(),
@@ -647,8 +656,10 @@
throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
}
WaitPakin waitPakin = new WaitPakin();
- waitPakin.sync(mat);
+ BeanUtils.copyProperties(mat, waitPakin);
+// waitPakin.sync(mat);
waitPakin.setOrderNo(order.getOrderNo()); // 鍗曟嵁缂栧彿
+ waitPakin.setOrderId(order.getId());
waitPakin.setBatch(detlDto.getBatch()); // 搴忓垪鐮�
waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮�
waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵��
@@ -945,7 +956,7 @@
throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
}
WaitPakin waitPakin = new WaitPakin();
- waitPakin.sync(mat);
+ BeanUtils.copyProperties(mat, waitPakin);
waitPakin.setOrderNo(orderNo);
waitPakin.setBatch(detlDto.getBatch());
waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮�
@@ -1071,8 +1082,8 @@
wrkMast.setIoType(ioType); // 鍏ュ嚭搴撶姸鎬�
wrkMast.setIoPri(13D); // 浼樺厛绾э細13
wrkMast.setCrnNo(locMast.getCrnNo());
- wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯
- wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔�
+ wrkMast.setSourceStaNo(staDesc.getCrnStn() + ""); // 婧愮珯
+ wrkMast.setStaNo(staDesc.getStnNo() + ""); // 鐩爣绔�
wrkMast.setSourceLocNo(locDetl.getLocNo()); // 婧愬簱浣�
wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
wrkMast.setPicking("N"); // 鎷f枡
@@ -1115,4 +1126,132 @@
throw new CoolException(locDetl.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��");
}
}
+
+ /**
+ * @author Ryan
+ * @date 2025/9/22
+ * @description: 鑾峰彇缂撳啿鍖哄簱浣嶄俊鎭�
+ * @version 1.0
+ */
+ @Override
+ public R getCacheLocs() {
+ return R.ok().add(locCacheService.selectList(new EntityWrapper<LocCache>()
+ .eq("frozen", 0)
+ .ne("full_plt", "Y")
+ .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type).orderAsc(Arrays.asList("row1"))));
+
+ }
+
+ /**
+ * @author Ryan
+ * @date 2025/9/22
+ * @description: 鍛煎彨AGV鎼繍
+ * @version 1.0
+ */
+ @Override
+ public R callAgvMove(AgvCallParams params, Long userId) {
+ if (Objects.isNull(params.getTarSite())) {
+ throw new CoolException("鐩爣鍙傛暟涓嶈兘涓虹┖锛侊紒");
+ }
+ if (Objects.isNull(params.getOrgSite())) {
+ throw new CoolException("婧愮珯鐐逛笉鑳戒负绌猴紒锛�");
+ }
+ LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>()
+ .eq("frozen", 0)
+ .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
+ .eq("loc_no", params.getTarSite())
+ .orderAsc(Arrays.asList("loc_no"))
+ .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
+ if (Objects.isNull(locCache)) {
+ throw new CoolException("璇锋鏌ョ洰鏍囧簱浣嶆槸鍚﹂棽缃腑锛侊紒");
+ }
+
+ generateAgvTask("agv", locCache, params.getOrgSite(), params.getBarcode(), userId);
+
+ return R.ok();
+ }
+
+ /**
+ * @author Ryan
+ * @date 2025/9/22
+ * @description: 鐢熸垚AGV鎼繍浠诲姟
+ * @version 1.0
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public void generateAgvTask(String type, LocCache loc, String orgSite, String barcode, Long userId) {
+ WaitPakin pakin = waitPakinService.selectOne(new EntityWrapper<WaitPakin>().eq("zpallet", barcode));
+ if (Objects.isNull(pakin)) {
+ throw new CoolException("缁勬墭淇℃伅涓嶅瓨鍦紒锛�");
+ }
+ OrderPakin orderPakin = orderPakinService.selectById(pakin.getOrderId());
+ if (Objects.isNull(orderPakin)) {
+ throw new CoolException("鍗曟嵁涓嶈兘涓虹┖锛侊紒");
+ }
+
+ List<OrderDetlPakin> detls = orderDetlPakinService.selectList(new EntityWrapper<OrderDetlPakin>().eq("order_id", pakin.getOrderId()));
+ if (Objects.isNull(detls) || detls.isEmpty()) {
+ throw new CoolException("鏁版嵁閿欒锛氬崟鎹槑缁嗕笉瀛樺湪锛侊紒");
+ }
+
+ Date now = new Date();
+ // 鑾峰彇宸ヤ綔鍙�
+ int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
+ // 淇濆瓨宸ヤ綔妗�
+ Task task = new Task();
+ task.setWrkNo(workNo)
+ .setIoTime(now)
+ .setWrkSts(11L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+ .setIoType(11) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
+ .setTaskType("agv")
+ .setIoPri(10D)
+ .setLocNo(loc.getLocNo()) // 鐩爣搴撲綅
+ .setFullPlt("Y") // 婊℃澘锛歒
+ .setPicking("N") // 鎷f枡
+ .setExitMk("N")// 閫�鍑�
+ .setSourceLocNo(orgSite)
+ .setEmptyMk(loc.getLocSts().equals("D") ? "Y" : "N")// 绌烘澘
+ .setBarcode(barcode)// 鎵樼洏鐮�
+ .setLinkMis("N")
+ .setAppeUser(userId)
+ .setAppeTime(now)
+ .setModiUser(userId)
+ .setModiTime(now);
+ if (!taskService.insert(task)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+ }
+
+ List<TaskDetl> taskDetls = new ArrayList<>();
+ detls.forEach(detl -> {
+ TaskDetl wrkDetl = new TaskDetl();
+ BeanUtils.copyProperties(detl, wrkDetl);
+ wrkDetl.setWrkNo(workNo)
+ .setIoTime(new Date())
+ .setAnfme(detl.getAnfme())
+ .setZpallet(pakin.getZpallet())
+ .setBatch(detl.getBatch())
+ .setMatnr(detl.getMatnr())
+ .setMaktx(detl.getMaktx())
+ .setAppeUser(userId)
+ .setUnit(detl.getUnit())
+ .setModel(detl.getModel())
+ .setAppeTime(new Date())
+ .setModiUser(userId);
+ taskDetls.add(wrkDetl);
+ });
+ //淇濆瓨宸ヤ綔妗f槑缁�
+ if (!taskDetlService.insertBatch(taskDetls)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+ }
+ // 淇敼鐩爣搴撲綅鐘舵��
+ if (loc.getLocSts().equals("O")) {
+ loc.setLocSts("S"); // S.鍏ュ簱棰勭害
+ loc.setModiTime(now);
+ loc.setModiUser(userId);
+ if (!locCacheService.updateById(loc)) {
+ throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+ }
+ } else {
+ throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + loc.getLocSts$());
+ }
+ }
}
--
Gitblit v1.9.1