From 7600059f8037f804b19d0da008ba34d62c43296d Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期四, 11 十二月 2025 17:27:57 +0800
Subject: [PATCH] Merge branch 'jsxswms' of http://47.97.1.152:5880/r/zy-asrs into jsxswms
---
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 448 +++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 365 insertions(+), 83 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 f703d75..d72316d 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -6,6 +6,8 @@
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.core.common.*;
import com.core.exception.CoolException;
+import com.zy.api.enums.MatLocType;
+import com.zy.api.enums.MatType;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.*;
import com.zy.asrs.entity.result.FindLocNoAttributeVo;
@@ -589,13 +591,21 @@
throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱");
}
- if (param.getBarcode().length() != 8) {
- throw new CoolException("鏉$爜闀垮害涓嶆槸8浣�===>>" + param.getBarcode());
+ if (Objects.isNull(param.getBarcode())) {
+ throw new CoolException("鎵樼洏鐮佷笉鑳戒负绌猴紒锛�");
}
+// if (param.getBarcode().length() != 8) {
+// throw new CoolException("鏉$爜闀垮害涓嶆槸8浣�===>>" + param.getBarcode());
+// }
+ if (Objects.isNull(param.getType())) {
+ param.setType("0");
+ }
int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", param.getBarcode()));
int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", param.getBarcode()));
- int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode()));
+ int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>()
+ .eq(!Objects.isNull(param.getType()), "type", param.getType())
+ .eq("zpallet", param.getBarcode()));
if (countLoc > 0 || countWrk > 0 || countwait > 0) {
throw new CoolException("缁勬墭妗�/宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
}
@@ -686,46 +696,49 @@
}
});
- BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode()));
- if (Objects.isNull(container)) {
- throw new CoolException("鏁版嵁閿欒锛氬鍣ㄧ爜涓嶅瓨鍦紒锛�");
- }
- if (container.getMixMax() < detlDtos.size()) {
- throw new CoolException("瓒呭嚭瀹瑰櫒鏈�澶ф贩瑁呮暟閲忥紝褰撳墠瀹瑰櫒鏈�澶ф暟閲忎负锛�" + container.getMixMax() + "!!");
- }
Set<String> matnrs = detlDtos.stream().map(DetlDto::getMatnr).collect(Collectors.toSet());
List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr", matnrs));
Set<Long> tagIds = mats.stream().map(Mat::getTagId).collect(Collectors.toSet());
if (tagIds.size() > 1) {
throw new CoolException("缁勬墭鐗╂枡绫诲瀷涓嶄竴鑷达紝鍙湁鐩稿悓鐨勭墿鏂欏垎绫绘墠鍙互缁勬墭锛侊紒");
}
+
+// BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode()));
+// if (Objects.isNull(container)) {
+// throw new CoolException("鏁版嵁閿欒锛氬鍣ㄧ爜涓嶅瓨鍦紒锛�");
+// }
+// if (container.getMixMax() < detlDtos.size()) {
+// throw new CoolException("瓒呭嚭瀹瑰櫒鏈�澶ф贩瑁呮暟閲忥紝褰撳墠瀹瑰櫒鏈�澶ф暟閲忎负锛�" + container.getMixMax() + "!!");
+// }
//杩樺彲浠ユ斁鍏ュ灏戠鐗╂枡
- Integer suplus = container.getMixMax();
+// Integer suplus = container.getMixMax();
for (DetlDto detlDto : detlDtos) {
Mat mat = matService.selectByMatnr(detlDto.getMatnr());
if (Cools.isEmpty(mat)) {
throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
}
- //鏈�澶氬彲鏀炬暟閲�
- Double singleMax = mat.getUpQty() * suplus;
- if (singleMax.compareTo(detlDto.getAnfme()) < 0) {
- throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟缁勬墭涓婇檺涓猴細" + mat.getUpQty() + ",褰撳墠鎬婚噺瓒呭嚭鎵樼洏瑁呰浇涓婇檺!!");
- }
- BigDecimal decimal = new BigDecimal(detlDto.getAnfme() / mat.getUpQty());
- //褰撳墠鐗╂枡闇�瑕佸崰鐢ㄦ枡绠辨牸鏁�
- Integer curr = decimal.setScale(0, RoundingMode.CEILING).intValue();
- suplus = suplus - curr;
- if (suplus < 0) {
- throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + ", 瓒呭嚭褰撳墠鎵樼洏瑁呰浇涓婇檺锛侊紒");
- }
+// //鏈�澶氬彲鏀炬暟閲�
+// Double singleMax = mat.getUpQty() * suplus;
+// if (singleMax.compareTo(detlDto.getAnfme()) < 0) {
+// throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟缁勬墭涓婇檺涓猴細" + mat.getUpQty() + ",褰撳墠鎬婚噺瓒呭嚭鎵樼洏瑁呰浇涓婇檺!!");
+// }
+// BigDecimal decimal = new BigDecimal(detlDto.getAnfme() / mat.getUpQty());
+// //褰撳墠鐗╂枡闇�瑕佸崰鐢ㄦ枡绠辨牸鏁�
+// Integer curr = decimal.setScale(0, RoundingMode.CEILING).intValue();
+// suplus = suplus - curr;
+// if (suplus < 0) {
+// throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + ", 瓒呭嚭褰撳墠鎵樼洏瑁呰浇涓婇檺锛侊紒");
+// }
WaitPakin waitPakin = new WaitPakin();
BeanUtils.copyProperties(mat, waitPakin);
-// waitPakin.sync(mat);
waitPakin.setOrderNo(detlDto.getOrderNo()); // 鍗曟嵁缂栧彿
+ waitPakin.setType(param.getType());
waitPakin.setOrderId(detlDto.getOrderId());
waitPakin.setBatch(detlDto.getBatch()); // 搴忓垪鐮�
waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮�
+ waitPakin.setThreeCode(detlDto.getThreeCode());
+ waitPakin.setSuppCode(detlDto.getStandby1());
waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵��
waitPakin.setAnfme(detlDto.getAnfme()); // 鏁伴噺
waitPakin.setStatus("Y"); // 鐘舵��
@@ -1215,17 +1228,14 @@
* @version 1.0
*/
@Override
- public R callAgvMove(AgvCallParams params, Long userId) {
- if (Objects.isNull(params.getTarSite())) {
- throw new CoolException("鐩爣鍙傛暟涓嶈兘涓虹┖锛侊紒");
- }
+ public synchronized R callAgvMove(AgvCallParams params, Long userId) {
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())
+// .eq("loc_no", params.getTarSite())
.orderAsc(Arrays.asList("loc_no"))
.last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
if (Objects.isNull(locCache)) {
@@ -1272,6 +1282,7 @@
* @version 1.0
*/
@Override
+ @Transactional(rollbackFor = Exception.class)
public R OutCallAgv(AgvCallParams params, Long userId) {
/**鑾峰彇鍏ュ簱鏈�鏃╃殑涓�鏉℃暟鎹�**/
LocCache locCaches = locCacheService.selectOne(new EntityWrapper<LocCache>()
@@ -1282,8 +1293,35 @@
if (Objects.isNull(locCaches)) {
throw new CoolException("鏆傛棤婊¤冻闇�姹傚簱浣嶏紒");
}
+
+ //鑾峰彇缂撳瓨鍖轰俊鎭�
+ BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_IN_CACHE.type));
+ if (Objects.isNull(basAreas)) {
+ throw new CoolException("搴撳尯涓嶅瓨鍦紒锛�");
+ }
+
+ List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>()
+ .eq("area_id", basAreas.getId())
+ .eq("loc_no", locCaches.getLocNo()));
+ if (Objects.isNull(locDetls) || locDetls.isEmpty()) {
+ throw new CoolException("搴撳瓨鏄庣粏涓嶅瓨鍦紒锛�");
+ }
+
+ Set<String> set = locDetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet());
+ List<Mat> matList = matService.selectList(new EntityWrapper<Mat>().in("matnr", set));
+ if (Objects.isNull(matList) || matList.isEmpty()) {
+ throw new CoolException("鐗╂枡搴撲笉瀛樺湪璇ョ墿鏂�!!");
+ }
+ Set<Long> longs = matList.stream().map(Mat::getTagId).collect(Collectors.toSet());
+ if (!longs.isEmpty() && longs.size() > 1) {
+ throw new CoolException("鐗╂枡绫诲瀷涓嶄竴鑷�,璇锋鏌ユ暟鎹槸鍚︽纭�!!");
+ }
+
+ Mat mat = matList.stream().findFirst().get();
+
BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>()
.eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
+ .eq("crn_type", mat.getTagId())
.eq("dev_no", params.getTarSite()));
if (Objects.isNull(station)) {
throw new CoolException("绔欑偣姝e湪鎵ц浠诲姟锛侊紒");
@@ -1339,29 +1377,121 @@
}
@Override
-// @Transactional(rollbackFor = Exception.class)
+ @Transactional(rollbackFor = Exception.class)
public R collectionInCall(AgvCallParams params, Long userId) {
if (Objects.isNull(params.getOrgSite())) {
throw new CoolException("婧愮珯鐐逛笉鑳戒负绌猴紒锛�");
}
- List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", params.getBarcode()));
- if (!tasks.isEmpty()) {
- throw new CoolException("鎵樼洏鐮佸凡鐢熸垚浠诲姟");
- }
-
BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("name", params.getTarSite()));
List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>()
- .in("loc_sts", LocStsType.LOC_STS_TYPE_O.type, LocStsType.LOC_STS_TYPE_D.type)
+ .in("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
.eq("area_id", basAreas.getId()));
if (locCaches.isEmpty()) {
throw new CoolException("褰撳墠鏆傛棤绌哄簱浣嶏紒锛�");
}
- generateAgvTask("agv", locCaches.get(0), params.getOrgSite(), params.getBarcode(), userId);
+ BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", params.getOrgSite()));
+ if (Objects.isNull(station)) {
+ throw new CoolException("婧愮珯鐐规湭妫�绱㈠埌鏁版嵁锛侊紒");
+ }
+
+ generateSOEOInTask("agv", locCaches.get(0), params.getOrgSite(), station.getBarcode(), userId);
return R.ok();
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ public void generateSOEOInTask(String type, LocCache loc, String orgSite, String barcode, Long userId) {
+ List<BasStationDetl> basStationDetls = basStationDetlService.selectList(new EntityWrapper<BasStationDetl>().eq("dev_no", orgSite));
+ if (Objects.isNull(basStationDetls) || basStationDetls.isEmpty()) {
+ throw new CoolException("绔欑偣淇℃伅涓嶅瓨鍦紒锛�");
+ }
+
+ List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", barcode));
+ if (!tasks.isEmpty()) {
+ throw new CoolException("鎵樼洏宸插湪浠诲姟鎵ц涓�..");
+ }
+ // 鑾峰彇宸ヤ綔鍙�
+ int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
+ // 淇濆瓨宸ヤ綔妗�
+ Task task = new Task();
+ task.setWrkNo(workNo)
+ .setIoTime(new Date())
+ .setWrkSts(1L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+ .setIoType(1) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
+ .setTaskType("agv")
+ .setIoPri(10D)
+ .setLocNo(loc.getLocNo()) // 鐩爣搴撲綅
+ .setFullPlt("Y") // 婊℃澘锛歒
+ .setPicking("N") // 鎷f枡
+ .setExitMk("N")// 閫�鍑�
+ .setSourceStaNo(orgSite)
+ .setEmptyMk(loc.getLocSts().equals("D") ? "Y" : "N")// 绌烘澘
+ .setBarcode(barcode)// 鎵樼洏鐮�
+ .setLinkMis("N")
+ .setAppeUser(userId)
+ .setAppeTime(new Date())
+ .setModiUser(userId)
+ .setModiTime(new Date());
+ if (!taskService.insert(task)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+ }
+
+ for (BasStationDetl basStationDetl : basStationDetls) {
+ TaskDetl wrkDetl = new TaskDetl();
+ BeanUtils.copyProperties(basStationDetl, wrkDetl);
+ wrkDetl.setWrkNo(workNo)
+ .setIoTime(new Date())
+ .setOrderNo(basStationDetl.getOrderNo())
+ .setAnfme(basStationDetl.getAnfme())
+ .setZpallet(basStationDetl.getBarcode())
+ .setBatch(basStationDetl.getBatch())
+ .setMatnr(basStationDetl.getMatnr())
+ .setMaktx(basStationDetl.getMaktx())
+ .setStandby1(basStationDetl.getStandby1())
+ .setAppeUser(userId)
+ .setUnit(basStationDetl.getUnit())
+ .setModel(basStationDetl.getModel())
+ .setAppeTime(new Date())
+ .setModiUser(userId);
+
+ //淇濆瓨宸ヤ綔妗f槑缁�
+ if (!taskDetlService.insert(wrkDetl)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+ }
+ }
+
+ // 淇敼鐩爣搴撲綅鐘舵��
+ if (loc.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+ loc.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.鍏ュ簱棰勭害
+ loc.setModiTime(new Date());
+ loc.setModiUser(userId);
+ if (!locCacheService.updateById(loc)) {
+ throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+ }
+ } else {
+ throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + loc.getLocSts$());
+ }
+
+ // 淇敼鐩爣绔欑偣淇℃伅
+ BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", orgSite));
+ if (Objects.isNull(station)) {
+ throw new CoolException("绔欑偣涓嶅瓨鍦�!!");
+ }
+
+ if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_F.type)) {
+ station.setLocSts("R"); // S.鍏ュ簱棰勭害
+ station.setBarcode(barcode);
+ station.setModiTime(new Date());
+ station.setModiUser(userId);
+ if (!basStationService.updateById(station)) {
+ throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+ }
+ } else {
+ throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + station.getLocSts());
+ }
}
/**
@@ -1388,8 +1518,8 @@
*/
@Override
public R combCacehList(AgvCallParams params) {
- if (Objects.isNull(params.getBarcode())) {
- throw new CoolException("鎵樼洏鐮佷笉鑳戒负绌猴紒锛�");
+ if (Objects.isNull(params.getCarBarcode())) {
+ throw new CoolException("鍙拌溅鎵樼洏鐮佷笉鑳戒负绌猴紒锛�");
}
if (Objects.isNull(params.getBsCode())) {
throw new CoolException("BS鐮佷笉鑳戒负绌猴紒锛�");
@@ -1397,14 +1527,15 @@
Task task = taskService.selectOne(new EntityWrapper<Task>()
.eq("io_type", TaskIOType.PICK_OUT.type)
.eq("wrk_sts", 14)
- .eq("barcode", params.getBarcode()));
+ .eq("barcode", params.getCarBarcode()));
if (Objects.isNull(task)) {
throw new CoolException("鏁版嵁閿欒锛氫换鍔′俊鎭瓨鍦紒锛�");
}
List<TaskDetl> taskDetl = taskDetlService.selectList(new EntityWrapper<TaskDetl>()
.eq("three_code", params.getBsCode())
- .eq("zpallet", params.getBarcode()));
+ .eq("wrk_no", task.getWrkNo())
+ .eq("zpallet", params.getCarBarcode()));
if (Objects.isNull(taskDetl) || taskDetl.isEmpty()) {
throw new CoolException("褰撳墠BS缂栫爜涓嶅瓨鍦紒锛�");
@@ -1457,22 +1588,46 @@
detlDtos.add(detlDto);
}
});
-
+ BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode()));
+ if (Objects.isNull(container)) {
+ throw new CoolException("鏁版嵁閿欒锛氬鍣ㄧ爜涓嶅瓨鍦紒锛�");
+ }
+ if (container.getMixMax() < detlDtos.size()) {
+ throw new CoolException("瓒呭嚭瀹瑰櫒鏈�澶ф贩瑁呮暟閲忥紝褰撳墠瀹瑰櫒鏈�澶ф暟閲忎负锛�" + container.getMixMax() + "!!");
+ }
+ Set<String> matnrs = detlDtos.stream().map(DetlDto::getMatnr).collect(Collectors.toSet());
+ List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr", matnrs));
+ Set<Long> tagIds = mats.stream().map(Mat::getTagId).collect(Collectors.toSet());
+ if (tagIds.size() > 1) {
+ throw new CoolException("缁勬墭鐗╂枡绫诲瀷涓嶄竴鑷达紝鍙湁鐩稿悓鐨勭墿鏂欏垎绫绘墠鍙互缁勬墭锛侊紒");
+ }
+ //杩樺彲浠ユ斁鍏ュ灏戠鐗╂枡
+ Integer suplus = container.getMixMax();
Date now = new Date();
for (DetlDto detlDto : detlDtos) {
Mat mat = matService.selectByMatnr(detlDto.getMatnr());
if (Cools.isEmpty(mat)) {
throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
}
- if (mat.getUpQty().compareTo(detlDto.getAnfme()) < 0) {
- throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟鏈�澶х粍鎵樹笂闄愪负锛�" + mat.getUpQty());
+ //鏈�澶氬彲鏀炬暟閲�
+ Double singleMax = mat.getUpQty() * suplus;
+ if (singleMax.compareTo(detlDto.getAnfme()) < 0) {
+ throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟缁勬墭涓婇檺涓猴細" + mat.getUpQty() + ",褰撳墠鎬婚噺瓒呭嚭鎵樼洏瑁呰浇涓婇檺!!");
}
+ BigDecimal decimal = new BigDecimal(detlDto.getAnfme() / mat.getUpQty());
+ //褰撳墠鐗╂枡闇�瑕佸崰鐢ㄦ枡绠辨牸鏁�
+ Integer curr = decimal.setScale(0, RoundingMode.CEILING).intValue();
+ suplus = suplus - curr;
+ if (suplus < 0) {
+ throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + ", 瓒呭嚭褰撳墠鎵樼洏瑁呰浇涓婇檺锛侊紒");
+ }
+
WaitPakin waitPakin = new WaitPakin();
BeanUtils.copyProperties(mat, waitPakin);
waitPakin.setBatch(detlDto.getBatch());
waitPakin.setZpallet(param.getBarcode());
//璁剧疆缁勬墭绫诲瀷
- waitPakin.setType(CommonEnum.COMMON_ENUM_Y.type + "");
+ waitPakin.setType(param.getType());
waitPakin.setIoStatus("N");
waitPakin.setAnfme(detlDto.getAnfme());
waitPakin.setThreeCode(detlDto.getThreeCode());
@@ -1511,7 +1666,9 @@
throw new CoolException("绔欑偣涓嶈兘涓虹┖!!");
}
//TODO 淇敼缂撳瓨绔欑偣鐘舵�佸強鏁版嵁
- Task task = taskService.selectOne(new EntityWrapper<Task>().eq("barcode", param.getBarcode()));
+ Task task = taskService.selectOne(new EntityWrapper<Task>()
+ .eq("wrk_sts", 14L)
+ .eq("barcode", param.getCarBarcode()));
if (Objects.isNull(task)) {
throw new CoolException("鏁版嵁閿欒,浠诲姟涓嶅瓨鍦�!!");
}
@@ -1530,10 +1687,7 @@
if (!basStationService.updateById(station)) {
throw new CoolException("绔欑偣鐘舵�佷慨鏀瑰け璐�!");
}
-
- if (!basStationDetlService.delete(new EntityWrapper<BasStationDetl>().eq("dev_no", station.getDevNo()))) {
- throw new CoolException("绔欑偣鍒犻櫎澶辫触!");
- }
+ basStationDetlService.delete(new EntityWrapper<BasStationDetl>().eq("dev_no", station.getDevNo()));
//浠诲姟瀹屾垚
task.setWrkSts(15L);
@@ -1542,12 +1696,131 @@
throw new CoolException("AGV浠诲姟瀹屾垚澶辫触!!");
}
- List<WaitPakin> waitPakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("barcodee", param.getBarcode()));
+ List<WaitPakin> waitPakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode()));
if (Objects.isNull(waitPakins) || waitPakins.isEmpty()) {
throw new CoolException("鏁版嵁閿欒,缁勬嫋妗e凡涓嶅瓨鍦�!!");
}
generateCrnInTask(waitPakins, station, param.getLocType1(), userId);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public R collectionPakin(CollectionPakinParams params, Long userId) {
+ List<BasStation> basStations = basStationService.selectList(new EntityWrapper<BasStation>().eq("barcode", params.getTarBarcode()));
+ if (basStations.isEmpty() && Cools.isEmpty(params.getDevNo())) {
+ throw new CoolException("璇疯緭鍏ョ珯鐐瑰彿");
+ }
+ BasStation basStation = null;
+ if (!basStations.isEmpty()) {
+ basStation = basStations.get(0);
+ }else {
+ basStation = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", params.getDevNo()));
+ }
+ if (Cools.isEmpty(basStation)){
+ throw new CoolException("璇疯緭鍏ユ纭殑绔欑偣鍙�");
+ }
+ for (CollectionPakinParams.CombMat combMat : params.getCombMats()) {
+ if (combMat.getWorkQty().compareTo(BigDecimal.ZERO) == 0) {
+ continue;
+ }
+
+ OrderPakin orderPakin = orderPakinService.selectByNo(combMat.getOrderNo());
+ if (Cools.isEmpty(orderPakin)) {
+ throw new CoolException("鏈壘鍒板璐у叆搴撳崟");
+ }
+
+ UpdateDetailsOfPakin(orderPakin,combMat);
+
+ BasStationDetl basStationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>()
+ .eq("dev_no", basStation.getDevNo())
+ .eq("matnr", combMat.getMatnr())
+ .eq("batch", combMat.getBatch())
+ .eq("standby1", combMat.getStandby1())
+ );
+ if (Cools.isEmpty(basStationDetl)) {
+ basStationDetl = new BasStationDetl();
+ Mat mat = matService.selectByMatnr(combMat.getMatnr());
+ BeanUtils.copyProperties(mat,basStationDetl);
+ basStationDetl
+ .setOrderNo(orderPakin.getOrderNo())
+ .setDevNo(basStation.getDevNo())
+ .setBarcode(params.getTarBarcode())
+ .setBatch(combMat.getBatch())
+ .setStandby1(combMat.getStandby1())
+ .setAnfme(combMat.getWorkQty().doubleValue())
+ ;
+ if (!basStationDetlService.insert(basStationDetl)){
+ throw new CoolException("鎻掑叆鏄庣粏澶辫触");
+ }
+
+
+ }else {
+ BigDecimal anfme = new BigDecimal(basStationDetl.getAnfme().toString()).add(combMat.getWorkQty());
+ basStationDetl.setAnfme(anfme.doubleValue());
+ if (!basStationDetlService.updateById(basStationDetl)){
+ throw new CoolException("鏇存柊鏄庣粏鏁版嵁澶辫触");
+ }
+
+ }
+ }
+ if (basStation.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type) || basStation.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+ basStation.setBarcode(params.getTarBarcode());
+ basStation.setLocSts(LocStsType.LOC_STS_TYPE_F.type);
+ basStationService.updateById(basStation);
+ }
+
+ return R.ok();
+ }
+
+ @Transactional(rollbackFor = Exception.class)
+ public void UpdateDetailsOfPakin(OrderPakin orderPakin,CollectionPakinParams.CombMat combMat){
+ OrderDetlPakin orderDetlPakin = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>()
+ .eq("order_id", orderPakin.getId())
+ .eq("matnr", combMat.getMatnr())
+ .eq("batch", combMat.getBatch())
+ .eq("standby1", combMat.getStandby1())
+ );
+ if (Cools.isEmpty(orderDetlPakin)) {
+ throw new CoolException("妫�绱㈠崟鎹槑缁嗘暟鎹け璐�");
+ }
+ if (orderDetlPakin.getWorkQty() >= orderDetlPakin.getAnfme()) {
+ throw new CoolException("璇峰嬁瓒呭嚭璁㈠崟鏄庣粏鏁伴噺");
+ }
+ BigDecimal workQty = new BigDecimal(orderDetlPakin.getWorkQty().toString()).add(combMat.getWorkQty());
+ orderDetlPakin.setWorkQty(workQty.doubleValue());
+ if (!orderDetlPakinService.updateById(orderDetlPakin)){
+ throw new CoolException("鏇存柊鍗曟嵁鏄庣粏鏁版嵁澶辫触");
+ }
+ if (!orderPakin.getSettle().equals(2L)){
+ orderPakin.setSettle(2L);
+ if (!orderPakinService.updateById(orderPakin)){
+ throw new CoolException("鏇存柊鍗曟嵁鐘舵�佸け璐�");
+ }
+ }
+
+
+ }
+
+ @Override
+ public R collectionPakinView(CollectionPakinParams params) {
+
+ WrkMast wrkMast = wrkMastService.selectByBarcode(params.getOrgBarcode());
+ if (Cools.isEmpty(wrkMast)) {
+ throw new CoolException("鏈壘鍒颁换鍔�");
+ }
+
+ if (wrkMast.getIoType().equals(TaskIOType.ALL_OUT.type) && wrkMast.getIoType().equals(TaskIOType.PICK_OUT.type)){
+ throw new CoolException("浜虹墿绫诲瀷閿欒");
+ }
+
+ List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo());
+ if (Cools.isEmpty(wrkDetls)) {
+ throw new CoolException("鏈壘鍒颁换鍔℃槑缁�");
+ }
+
+
+ return R.ok(wrkDetls);
}
/**
@@ -1558,10 +1831,11 @@
* @date 2025/12/9 13:54
*/
@Transactional(rollbackFor = Exception.class)
- public void generateCrnInTask(List<WaitPakin> waitPakins, BasStation station, Short locType, Long userId) {
+ public void generateCrnInTask(List<WaitPakin> waitPakins, BasStation station, Short locType, Long userId) {
Date now = new Date();
StationRela rela = stationRelaService.selectOne(new EntityWrapper<StationRela>()
- .eq("dev_no", station.getDevNo())
+ .eq("agv_sta", station.getDevNo())
+ .orderAsc(Arrays.asList("crn_sta"))
.last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
if (Objects.isNull(rela)) {
@@ -1574,7 +1848,7 @@
LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo);
WaitPakin pakin = waitPakins.stream().findFirst().get();
FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo(pakin);
- StartupDto dto = commonService.getLocNo( 1, sourceStaNo.getDevNo(),findLocNoAttributeVo, locTypeDto);
+ StartupDto dto = commonService.getLocNo(1, sourceStaNo.getDevNo(), findLocNoAttributeVo, locTypeDto);
int workNo = dto.getWorkNo();
// 鐢熸垚宸ヤ綔妗�
WrkMast wrkMast = new WrkMast();
@@ -1617,7 +1891,7 @@
});
// 鏇存柊鍏ュ簱閫氱煡妗� ioStatus ===>> Y
Wrapper<WaitPakin> wrapper = new EntityWrapper<WaitPakin>()
- .eq("zpallet", pakin.getBarcode());
+ .eq("zpallet", pakin.getZpallet());
WaitPakin setParam = new WaitPakin();
setParam.setLocNo(dto.getLocNo());
setParam.setIoStatus("Y");
@@ -1628,19 +1902,19 @@
// 鏇存柊婧愮珯鐐逛俊鎭�
sourceStaNo.setWrkNo(workNo);
sourceStaNo.setModiTime(now);
- if (!basDevpService.updateById(sourceStaNo)){
+ if (!basDevpService.updateById(sourceStaNo)) {
throw new CoolException("鏇存柊婧愮珯澶辫触");
}
// 鏇存柊鐩爣搴撲綅鐘舵��
LocMast locMast = locMastService.selectById(dto.getLocNo());
- if (locMast.getLocSts().equals("O")){
+ if (locMast.getLocSts().equals("O")) {
locMast.setLocSts("S"); // S.鍏ュ簱棰勭害
locMast.setModiTime(now);
- if (!locMastService.updateById(locMast)){
+ if (!locMastService.updateById(locMast)) {
throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�");
}
} else {
- throw new CoolException(dto.getLocNo()+"鐩爣搴撲綅宸茶鍗犵敤");
+ throw new CoolException(dto.getLocNo() + "鐩爣搴撲綅宸茶鍗犵敤");
}
}
@@ -1666,20 +1940,21 @@
}
List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>()
.eq("area_id", basAreas.getId())
- .eq("loc_id", locCaches.getId()));
+ .eq("loc_no", locCaches.getLocNo()));
if (Objects.isNull(locDetls) || locDetls.isEmpty()) {
throw new CoolException("搴撳瓨鏄庣粏涓嶅瓨鍦紒锛�");
}
- Set<String> set = locDetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet());
- List<Mat> matList = matService.selectList(new EntityWrapper<Mat>().in("matnr", set));
- if (Objects.isNull(matList) || matList.isEmpty()) {
- throw new CoolException("鐗╂枡搴撲笉瀛樺湪璇ョ墿鏂�!!");
- }
- Set<Long> longs = matList.stream().map(Mat::getTagId).collect(Collectors.toSet());
- if (!longs.isEmpty() && longs.size() > 1) {
- throw new CoolException("鐗╂枡绫诲瀷涓嶄竴鑷�,璇锋鏌ユ暟鎹槸鍚︽纭�!!");
- }
+// Set<String> set = locDetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet());
+// List<Mat> matList = matService.selectList(new EntityWrapper<Mat>().in("matnr", set));
+//
+// if (Objects.isNull(matList) || matList.isEmpty()) {
+// throw new CoolException("鐗╂枡搴撲笉瀛樺湪璇ョ墿鏂�!!");
+// }
+// Set<Long> longs = matList.stream().map(Mat::getTagId).collect(Collectors.toSet());
+// if (!longs.isEmpty() && longs.size() > 1) {
+// throw new CoolException("鐗╂枡绫诲瀷涓嶄竴鑷�,璇锋鏌ユ暟鎹槸鍚︽纭�!!");
+// }
//鑾峰彇绔嬪簱鍖轰俊鎭�
BasAreas one = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_CRN.type));
@@ -1756,15 +2031,14 @@
.orderAsc(Arrays.asList("row1", "bay1", "lev1"))
.last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
locMasts.add(locMast);
-
//绌烘澘鍑哄簱
generateTask(locMasts, TaskIOType.EMPTY_OUT.type, basDevp, userId);
-
} else {
- if (!locMasts.isEmpty()) {
- //鐢熸垚鍫嗗灈鏈哄嚭搴撲换鍔�
- generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId);
- }
+ //鐢熸垚鍫嗗灈鏈哄嚭搴撲换鍔�
+ generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId);
+// if (!locMasts.isEmpty()) {
+//
+// }
}
}
@@ -1832,7 +2106,7 @@
}
// 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓�
locMast = locMastService.selectById(locMast.getLocNo());
- if (locMast.getLocSts().equals(LocStsType.LOC_STS_TYPE_F.type)) {
+ if (locMast.getLocSts().equals(LocStsType.LOC_STS_TYPE_F.type) || locMast.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type)) {
locMast.setLocSts(ioType == 101 ? "R" : "P");
locMast.setModiUser(userId);
locMast.setModiTime(now);
@@ -1900,12 +2174,11 @@
.setModel(pakin.getModel())
.setAppeTime(new Date())
.setModiUser(userId);
- taskDetls.add(wrkDetl);
+ //淇濆瓨宸ヤ綔妗f槑缁�
+ if (!taskDetlService.insert(wrkDetl)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+ }
});
- //淇濆瓨宸ヤ綔妗f槑缁�
- if (!taskDetlService.insertBatch(taskDetls)) {
- throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
- }
}
loc.setLocSts(LocStsType.LOC_STS_TYPE_R.type);
@@ -1936,10 +2209,15 @@
* @version 1.0
*/
@Transactional(rollbackFor = Exception.class)
- public void generateAgvTask(String type, LocCache loc, String orgSite, String barcode, Long userId) {
+ public synchronized 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("鎵樼洏宸插湪浠诲姟鎵ц涓�..");
}
// 鑾峰彇宸ヤ綔鍙�
int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
@@ -2014,7 +2292,11 @@
// 淇敼鐩爣绔欑偣淇℃伅
BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", orgSite));
- if (station.getLocSts().equals("O")) {
+ if (Objects.isNull(station)) {
+ throw new CoolException("绔欑偣涓嶅瓨鍦�!!");
+ }
+
+ if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
station.setLocSts("R"); // S.鍏ュ簱棰勭害
station.setBarcode(barcode);
station.setModiTime(new Date());
--
Gitblit v1.9.1