From 4dfc306f910a8b1ae1a2869bc8ffd38b2faf8f2e Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期五, 24 五月 2024 09:02:27 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java | 184 ++++++++++++++++++++++++++++++++++++---------
1 files changed, 145 insertions(+), 39 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java
index c2200c3..c25cec4 100644
--- a/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java
@@ -11,6 +11,7 @@
import com.zy.asrs.service.*;
import com.zy.common.model.DetlDto;
import com.zy.common.service.AgvCommonService;
+import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -69,7 +70,7 @@
}
param.setContainerType(Short.valueOf(param.getBarcode().substring(0,2)));
-// //妫�鏌ユ槸鍚﹀凡瀛樺湪鐩稿悓鐨勬墭鐩樻潯鐮侊紝瀛樺湪鍒欐姏鍑哄紓甯�
+// //妫�鏌ユ槸鍚﹀凡瀛樺湪鐩稿悓鐨勮揣鏋舵潯鐮侊紝瀛樺湪鍒欐姏鍑哄紓甯�
// if (agvWaitPakinService.selectCount(new EntityWrapper<AgvWaitPakin>().eq("supp_code", param.getBarcode())) > 0) {
// throw new CoolException(param.getBarcode() + "鏂欐兂鐮佸凡瀛樺湪AGV鍏ュ簱閫氱煡妗d腑");
// }
@@ -77,6 +78,11 @@
//妫�鏌ュ簱瀛樻槸鍚︽湁鐩稿悓鏂欑锛屽瓨鍦ㄥ垯鎶涘嚭寮傚父
if(!Cools.isEmpty(agvLocDetlService.selectOne(new EntityWrapper<AgvLocDetl>().eq("supp_code",param.getBarcode())))){
throw new CoolException(param.getBarcode() + "鏂欑鐮佸凡瀛樺湪AGV搴撳瓨鏄庣粏涓�");
+ }
+
+ //妫�鏌ュ簱瀛樻槸鍚︽湁鐩稿悓鏂欑锛屽瓨鍦ㄥ垯鎶涘嚭寮傚父
+ if(!Cools.isEmpty(agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("barcode",param.getBarcode())))){
+ throw new CoolException(param.getBarcode() + "鏂欑鐮佸凡瀛樺湪AGV搴撳瓨涓绘。涓�");
}
//鏌ョ湅宸ヤ綔妗f槸鍚︽湁鐩稿悓鏂欑锛屽瓨鍦ㄥ垯鎶涘嚭寮傚父
@@ -124,7 +130,7 @@
wrkDetl.setOrderNo(pick.getOrderNo());
wrkDetl.setIoTime(now);
wrkDetl.setAnfme(pick.getCount()); // 鏁伴噺
- wrkDetl.setSuppCode(pick.getSuppCode()); // 鎵樼洏鏉$爜
+ wrkDetl.setSuppCode(pick.getSuppCode()); // 璐ф灦鏉$爜
wrkDetl.setAppeUser(userId);
wrkDetl.setAppeTime(now);
wrkDetl.setModiUser(userId);
@@ -175,7 +181,7 @@
private void NoOrderComb(CombParam param, Long userId){
List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param,null);
- //鐢ㄤ簬缁熶竴涓�涓墭鐩樹笅鐨勫叆搴撻�氱煡妗g殑鐢熸垚鏃堕棿
+ //鐢ㄤ簬缁熶竴涓�涓揣鏋朵笅鐨勫叆搴撻�氱煡妗g殑鐢熸垚鏃堕棿
Date now = new Date();
detlDtos.forEach(detlDto -> {
syncWaitPakin(detlDto,"",param.getBarcode(),userId,now);
@@ -199,7 +205,7 @@
}
// 鐢ㄤ簬鐢熸垚鍏ュ簱閫氱煡妗f墍闇�鍙傛暟
List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param,order);
- //鐢ㄤ簬缁熶竴涓�涓墭鐩樹笅鐨勫叆搴撻�氱煡妗g殑鐢熸垚鏃堕棿
+ //鐢ㄤ簬缁熶竴涓�涓揣鏋朵笅鐨勫叆搴撻�氱煡妗g殑鐢熸垚鏃堕棿
Date now = new Date();
for (DetlDto detlDto : detlDtos) {
//鍚屾鐢熸垚鍏ュ簱閫氱煡妗�
@@ -222,7 +228,7 @@
}
DetlDto detlDto = new DetlDto(combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(), combMat.getIsoseq(),combMat.getContainerCode(),param.getLocType());
- //鍚屼竴鎵樼洏涓嬬浉鍚岀墿鏂欎俊鎭拰鎵瑰彿杞负涓�涓叆搴撻�氱煡妗�
+ //鍚屼竴璐ф灦涓嬬浉鍚岀墿鏂欎俊鎭拰鎵瑰彿杞负涓�涓叆搴撻�氱煡妗�
if (DetlDto.has(detlDtos, detlDto)) {
DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(), detlDto.getCsocode(), detlDto.getIsoseq(),detlDto.getContainerCode());
assert one != null;
@@ -265,8 +271,8 @@
waitPakin.sync(mat);
waitPakin.setOrderNo(orderNo); // 鍗曟嵁缂栧彿
waitPakin.setBatch(detlDto.getBatch()); // 搴忓垪鐮�
- //waitPakin.setZpallet(zpallet); // 鎵樼洏鐮�
- waitPakin.setSuppCode(zpallet); // 鎵樼洏鐮�
+ //waitPakin.setZpallet(zpallet); // 璐ф灦鐮�
+ waitPakin.setSuppCode(zpallet); // 璐ф灦鐮�
waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵��
waitPakin.setAnfme(detlDto.getAnfme()); // 鏁伴噺
waitPakin.setStatus("Y"); // 鐘舵��
@@ -412,9 +418,9 @@
mast.setSourceLocNo(agvLocMast.getLocNo());
//鐩爣绔欑偣
mast.setLocNo(locMast.getLocNo());
- //瀹瑰櫒缂栫爜
+ //璐ф灦缂栫爜
mast.setBarcode(agvLocMast.getBarcode());
- //瀹瑰櫒绫诲瀷
+ //璐ф灦绫诲瀷
mast.setWhsType(30);
mast.setAppeUser(userId);
@@ -454,56 +460,119 @@
*/
@Override
@Transactional
+ @Synchronized
public String allocationOut(AgvMobileStartPakin param, Long userId) {
Date now = new Date();
AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", param.getDevNo()));
+ Integer oldWrkNo = agvWrkMast.getWrkNo();
if (Cools.isEmpty(agvWrkMast)) {
throw new CoolException("宸ヤ綔妗d腑娌℃湁姝ょ珯鐐逛换鍔�");
}
+
//鐢熸垚AGV宸ヤ綔鍘嗗彶妗� + 鐢熸垚AGV宸ヤ綔鏄庣粏鍘嗗彶妗�
agvWrkMastLogService.save(agvWrkMast);
agvWrkDetlLogService.save(agvWrkMast.getWrkNo());
-
+ //鍒犻櫎AGV宸ヤ綔妗�
+ agvWrkMastService.deleteById(agvWrkMast);
//鐢熸垚宸ヤ綔妗�
- AgvWrkMast mast = new AgvWrkMast();
- //宸ヤ綔鐘舵��
- mast.setWrkSts(210L);
- //鍏ュ嚭搴撶被鍨�
- mast.setIoType(111);
- mast.setIoTime(now);
- //浼樺厛绾�
- mast.setIoPri(300.0);
- //婧愮珯鐐�
- mast.setSourceLocNo("");
- //鐩爣绔欑偣
- mast.setLocNo("");
- //瀹瑰櫒缂栫爜
- mast.setBarcode(agvWrkMast.getBarcode());
- //瀹瑰櫒绫诲瀷
- mast.setWhsType(30);
- // 鐩爣妤煎眰
- mast.setPauseMk(agvWrkMast.getPauseMk());
- mast.setAppeUser(userId);
- mast.setAppeTime(now);
- mast.setModiUser(userId);
- mast.setModiTime(now);
- if (!agvWrkMastService.insertByIncrease(mast)) {
- throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
- }
+ AgvWrkMast wrkMast = createWrkMast(111, 210L, "", "", agvWrkMast.getBarcode(), now, userId, 30, agvWrkMast.getCrnNo());
// 鏇存柊宸ヤ綔鏄庣粏
- List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("wrk_no", agvWrkMast.getWrkNo()));
+ List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("supp_code", agvWrkMast.getBarcode()));
for (AgvWrkDetl agvWrkDetl : agvWrkDetls) {
- agvWrkDetl.setWrkNo(mast.getWrkNo());
- if (!agvWrkDetlService.update(agvWrkDetl,new EntityWrapper<AgvWrkDetl>().eq("wrk_no", agvWrkMast.getWrkNo()))) {
- throw new CoolException("鏇存柊宸ヤ綔鏄庣粏澶辫触");
+ agvWrkDetl.setWrkNo(wrkMast.getWrkNo());
+ // 淇濇寔宸ヤ綔妗f槑缁�
+ agvWrkDetl.setWrkNo(wrkMast.getWrkNo());
+ agvWrkDetl.setModiUser(userId);
+ agvWrkDetl.setModiTime(now);
+ if (!agvWrkDetlService.insert(agvWrkDetl)) {
+ throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏澶辫触");
}
}
// 鏇存柊绔欑偣鐘舵��
agvLocMastService.updateLocStsByLocNo(agvWrkMast.getSourceLocNo(),"O","",null);
// 鏇存柊婧愬簱浣嶇姸鎬�
agvBasDevpService.updateLocStsAndBarcodeByDevNo(agvWrkMast.getLocNo(),"O","",agvWrkMast.getWhsType().shortValue());
+
+ //鍒犻櫎AGV宸ヤ綔鏄庣粏妗�
+ agvWrkDetlService.delete(new EntityWrapper<AgvWrkDetl>().eq("wrk_no",oldWrkNo));
+ return "ok";
+ }
+ /*
+ 璋冩嫧杩涘満
+ */
+ @Override
+ @Transactional
+ public String allocationIn(AgvMobileStartPakin param, Long userId) {
+ Date now = new Date();
+ AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("barcode", param.getBarcode()));
+ AgvBasDevp agvBasDevp = agvBasDevpService.selectByDevNo(param.getDevNo());
+ if (Cools.isEmpty(agvWrkMast)) {
+ throw new CoolException("宸ヤ綔妗d腑娌℃湁姝よ揣鏋朵换鍔�");
+ }
+ if (agvWrkMast.getCrnNo() != agvBasDevp.getFloor()) {
+ throw new CoolException("璇风Щ鍔ㄥ埌->" + agvWrkMast.getCrnNo() + "妤煎叆搴撶偣鍏ュ簱");
+ }
+ //宸ヤ綔鐘舵��
+ agvWrkMast.setWrkSts(211L);
+ //鍏ュ嚭搴撶被鍨�
+ agvWrkMast.setIoType(112);
+ agvWrkMast.setSourceLocNo(param.getDevNo());
+ agvWrkMast.setModiUser(userId);
+ agvWrkMast.setModiTime(now);
+ if (!agvWrkMastService.update(agvWrkMast,new EntityWrapper<AgvWrkMast>().eq("wrk_no",agvWrkMast.getWrkNo()))) {
+ throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�");
+ }
+ // 鏇存柊婧愬簱浣嶇姸鎬�
+ agvBasDevpService.updateLocStsAndBarcodeByDevNo(param.getDevNo(),"F",agvWrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
+ //鍒犻櫎AGV宸ヤ綔妗�
+ return "ok";
+ }
+ /*
+ * 绔欑偣鍥為��
+ */
+ @Override
+ @Transactional
+ public String doBack(AgvMobileStartPakin param, Long userId) {
+ Date now = new Date();
+ AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", param.getDevNo()));
+ Integer oldWrkNo = agvWrkMast.getWrkNo();
+ if (!agvWrkMast.getBarcode().equals(param.getBarcode())) {
+ throw new CoolException("鍥為��浠诲姟鐨勮揣鏋剁爜涓庡綋鍓嶈揣鏋剁爜涓嶄竴鑷�!");
+ }
+ if (agvWrkMast.getWrkSts() != 205) {
+ throw new CoolException("鍑哄簱浠诲姟鏈畬鎴�!");
+ }
+ // 鏂板缓鍥為��宸ヤ綔妗�
+ AgvWrkMast wrkMast = createWrkMast(58, 201L, agvWrkMast.getLocNo(), agvWrkMast.getSourceLocNo(), agvWrkMast.getBarcode(), now, userId, agvWrkMast.getWhsType(), 0);
+ // 鏇存柊鎺ラ┏浣嶏紝鏇存柊搴撲綅鐘舵��
+ agvLocMastService.updateLocStsByLocNo(wrkMast.getLocNo(),"S",wrkMast.getBarcode(),wrkMast.getWhsType().shortValue());
+ agvBasDevpService.updateLocStsAndBarcodeByDevNo(wrkMast.getSourceLocNo(),"R",wrkMast.getBarcode(),agvWrkMast.getWhsType().shortValue());
+ // 鏇存柊宸ヤ綔鏄庣粏
+ List<AgvWrkDetl> agvWrkDetls = agvWrkDetlService.selectList(new EntityWrapper<AgvWrkDetl>().eq("supp_code", agvWrkMast.getBarcode()));
+ for (AgvWrkDetl agvWrkDetl : agvWrkDetls) {
+ agvWrkDetl.setWrkNo(wrkMast.getWrkNo());
+ // 淇濇寔宸ヤ綔妗f槑缁�
+ agvWrkDetl.setWrkNo(wrkMast.getWrkNo());
+ agvWrkDetl.setModiUser(userId);
+ agvWrkDetl.setModiTime(now);
+ if (!agvWrkDetlService.insert(agvWrkDetl)) {
+ throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏澶辫触");
+ }
+ // 鍚屾璁㈠崟鏁伴噺
+ OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("matnr", agvWrkDetl.getMatnr()).eq("three_code",agvWrkDetl.getThreeCode()).in("source",18,31,34));
+ orderDetl.setQty(orderDetl.getQty() - agvWrkDetl.getAnfme());
+ if (!orderDetlService.update(orderDetl,new EntityWrapper<OrderDetl>().eq("order_no",orderDetl.getOrderNo()).eq("matnr", orderDetl.getMatnr()).eq("three_code",orderDetl.getThreeCode()))){
+ throw new CoolException("淇敼璁㈠崟鏄庣粏澶辫触锛岃鑱旂郴绠$悊鍛�"+orderDetl.getOrderNo()+orderDetl.getMatnr());
+ }
+ }
+
+ //鐢熸垚AGV宸ヤ綔鍘嗗彶妗� + 鐢熸垚AGV宸ヤ綔鏄庣粏鍘嗗彶妗�
+ agvWrkMastLogService.save(agvWrkMast);
+ agvWrkDetlLogService.save(agvWrkMast.getWrkNo());
//鍒犻櫎AGV宸ヤ綔妗�
agvWrkMastService.deleteById(agvWrkMast);
+ //鍒犻櫎AGV宸ヤ綔鏄庣粏妗�
+ agvWrkDetlService.delete(new EntityWrapper<AgvWrkDetl>().eq("wrk_no",oldWrkNo));
return "ok";
}
/*
@@ -514,4 +583,41 @@
agvLocMastService.updateById(locMast);
}
+ /*
+ 鐢熸垚宸ヤ綔妗�
+ */
+ private AgvWrkMast createWrkMast(int ioType, long wrkSts, String sourceLocNo, String locNo, String barcode, Date now, Long userId, int containerType,int floor){
+ AgvWrkMast wrkMast = new AgvWrkMast();
+ //宸ヤ綔鐘舵��
+ wrkMast.setWrkSts(wrkSts);
+ //鍏ュ嚭搴撶被鍨�
+ wrkMast.setIoType(ioType);
+ wrkMast.setIoTime(now);
+ //浼樺厛绾�
+ wrkMast.setIoPri(300.0);
+ //婧愮珯鐐�
+ wrkMast.setSourceLocNo(sourceLocNo);
+ //鐩爣绔欑偣
+ wrkMast.setLocNo(locNo);
+ //璐ф灦缂栫爜
+ wrkMast.setBarcode(barcode);
+ //璐ф灦绫诲瀷
+ wrkMast.setWhsType(containerType);
+ // 鐩爣妤煎眰
+ wrkMast.setCrnNo(floor);
+
+ wrkMast.setAppeUser(userId);
+ wrkMast.setAppeTime(now);
+ wrkMast.setModiUser(userId);
+ wrkMast.setModiTime(now);
+
+ if (!agvWrkMastService.insertByIncrease(wrkMast)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+ }
+
+ wrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", locNo).eq("source_loc_no",sourceLocNo).eq("barcode",barcode).orderBy("modi_time",false));
+
+ return wrkMast;
+ }
+
}
--
Gitblit v1.9.1