From 9f095733d13185290cfedd242b5f299585fbcad0 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期一, 07 四月 2025 10:05:34 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java | 93 ++++++++++++++++++++++++++++------------------
1 files changed, 56 insertions(+), 37 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 92dda9f..41918fd 100644
--- a/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java
@@ -15,9 +15,7 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -40,6 +38,8 @@
private AgvBasDevpService agvBasDevpService;
@Autowired
private AgvLocDetlService agvLocDetlService;
+ @Autowired
+ private AgvWrkMastService agvWrkMastService;
/*
@@ -54,26 +54,41 @@
//妫�鏌ユ槸鍚﹀凡瀛樺湪鐩稿悓鐨勬墭鐩樻潯鐮侊紝瀛樺湪鍒欐姏鍑哄紓甯�
if (agvWaitPakinService.selectCount(new EntityWrapper<AgvWaitPakin>().eq("supp_code", param.getBarcode())) > 0) {
- throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱");
+ throw new CoolException(param.getBarcode() + "鏂欐兂鐮佸凡瀛樺湪AGV鍏ュ簱閫氱煡妗d腑");
}
//妫�鏌ュ簱瀛樻槸鍚︽湁鐩稿悓鏂欑锛屽瓨鍦ㄥ垯鎶涘嚭寮傚父
- if(!Cools.isEmpty(agvLocDetlService.selectOne(new EntityWrapper<AgvLocDetl>().eq("supp_code",param.getBarcode())))){
- throw new CoolException(param.getBarcode() + "鏂欑鐮佸凡鍦ㄥ簱瀛樹腑");
+ if (!Cools.isEmpty(agvLocDetlService.selectOne(new EntityWrapper<AgvLocDetl>().eq("supp_code", param.getBarcode())))) {
+ throw new CoolException(param.getBarcode() + "鏂欑鐮佸凡瀛樺湪AGV搴撳瓨鏄庣粏涓�");
+ }
+
+ //鏌ョ湅宸ヤ綔妗f槸鍚︽湁鐩稿悓鏂欑锛屽瓨鍦ㄥ垯鎶涘嚭寮傚父
+ if (!Cools.isEmpty(agvWrkMastService.selectByContainerCode(param.getBarcode()))) {
+ throw new CoolException(param.getBarcode() + "鏂欑鐮佸凡瀛樺湪AGV宸ヤ綔妗d腑");
+ }
+ List<CombParam.CombMat> combMats = param.getCombMats();
+ Map<String, String> map = new HashMap<>();
+ for (CombParam.CombMat combMat : combMats) {
+ String batch = Cools.isEmpty(combMat.getBatch()) ? "" : combMat.getBatch();
+ if (!Cools.isEmpty(map.get(combMat.getMatnr() + batch))) {
+ throw new CoolException(param.getBarcode() + "缁勬墭鐨勭墿鏂欐槑缁嗛噸澶�,璇锋鏌ユ槸鍚﹂噸澶嶆壂鐮�");
+ } else {
+ map.put(combMat.getMatnr() + batch, combMat.getMatnr());
+ }
}
if (Cools.isEmpty(param.getOrderNo())) {
//鏃犲崟缁勬墭
- NoOrderComb(param,userId);
- }else {
+ NoOrderComb(param, userId);
+ } else {
//鏈夊崟缁勬墭
- OrderComb(param,userId);
+ OrderComb(param, userId);
}
- if(StringUtils.isEmpty(param.getLocno())){
+ if (StringUtils.isEmpty(param.getLocno())) {
return "缁勬墭鎴愬姛";
- }else {
- combBinding(param.getBarcode(),param.getLocno());
+ } else {
+ combBinding(param.getBarcode(), param.getLocno());
return "缁勬墭鎴愬姛锛岀粦瀹氱珯鐐规垚鍔�";
}
@@ -82,23 +97,23 @@
/*
AGV鏃犲崟缁勬墭
*/
- private void NoOrderComb(CombParam param, Long userId){
- List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param,null);
+ private void NoOrderComb(CombParam param, Long userId) {
+ List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param, null);
//鐢ㄤ簬缁熶竴涓�涓墭鐩樹笅鐨勫叆搴撻�氱煡妗g殑鐢熸垚鏃堕棿
Date now = new Date();
detlDtos.forEach(detlDto -> {
- syncWaitPakin(detlDto,"",param.getBarcode(),userId,now);
+ syncWaitPakin(detlDto, "", param.getBarcode(), userId, now);
});
}
/*
AGV鏈夊崟缁勬墭
*/
- private void OrderComb(CombParam param, Long userId){
+ private void OrderComb(CombParam param, Long userId) {
//鍏宠仈缁勬墭
Order order = orderService.selectByNo(param.getOrderNo());
- if(Cools.isEmpty(order)){
+ if (Cools.isEmpty(order)) {
throw new CoolException("鍗曟嵁缂栧彿涓嶅瓨鍦�");
}
//璁㈠崟鐘舵��2浠ヤ笂涓哄畬鎴愭垨鑰呭彇娑堢殑璁㈠崟
@@ -106,12 +121,12 @@
throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�");
}
// 鐢ㄤ簬鐢熸垚鍏ュ簱閫氱煡妗f墍闇�鍙傛暟
- List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param,order);
+ List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param, order);
//鐢ㄤ簬缁熶竴涓�涓墭鐩樹笅鐨勫叆搴撻�氱煡妗g殑鐢熸垚鏃堕棿
Date now = new Date();
for (DetlDto detlDto : detlDtos) {
//鍚屾鐢熸垚鍏ュ簱閫氱煡妗�
- syncWaitPakin(detlDto,order.getOrderNo(),param.getBarcode(),userId,now);
+ syncWaitPakin(detlDto, order.getOrderNo(), param.getBarcode(), userId, now);
}
//淇敼鍗曟嵁鐘舵�佷负2.浣滀笟涓�
orderService.updateSettle(order.getId(), 2L, userId);
@@ -120,19 +135,19 @@
/*
鏍规嵁PDA鎵爜鎵�浼犵殑鐗╂枡淇℃伅鍙傛暟鏄犲皠涓篋etlDto
*/
- private List<DetlDto> mappingDetlDtoByCombMat(CombParam param, Order order){
+ private List<DetlDto> mappingDetlDtoByCombMat(CombParam param, Order order) {
List<DetlDto> detlDtos = new ArrayList<>();
param.getCombMats().forEach(combMat -> {
- if(!Cools.isEmpty(order)){
+ if (!Cools.isEmpty(order)) {
//妫�鏌ュ叆搴撴暟閲�
- checkOrderQty(order,combMat);
+ checkOrderQty(order, combMat);
}
- DetlDto detlDto = new DetlDto(combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(), combMat.getIsoseq(),combMat.getContainerCode());
+ DetlDto detlDto = new DetlDto(combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(), combMat.getIsoseq(), combMat.getContainerCode());
//鍚屼竴鎵樼洏涓嬬浉鍚岀墿鏂欎俊鎭拰鎵瑰彿杞负涓�涓叆搴撻�氱煡妗�
if (DetlDto.has(detlDtos, detlDto)) {
- DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(), detlDto.getCsocode(), detlDto.getIsoseq(),null);
+ DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(), detlDto.getCsocode(), detlDto.getIsoseq(), null);
assert one != null;
one.setAnfme(one.getAnfme() + detlDto.getAnfme());
} else {
@@ -146,17 +161,17 @@
/*
妫�鏌ュ叆搴撴暟閲忔槸鍚﹀皬浜庣瓑浜庡崟鎹暟閲忥紝鍚堢悊鍒欎慨鏀筄rderDetl浣滀笟鏁伴噺淇℃伅锛屽惁鍒欐姏鍑哄紓甯�
*/
- private void checkOrderQty(Order order, CombParam.CombMat combMat){
+ private void checkOrderQty(Order order, CombParam.CombMat combMat) {
// 璁㈠崟鏄庣粏鏁伴噺鏍¢獙锛屽鏋滀綔涓氭暟閲忓ぇ浜庡崟鎹暟閲忓垯鎶涘嚭寮傚父
- OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getCsocode(),combMat.getIsoseq());
- if(Cools.isEmpty(orderDetl)){
+ OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getCsocode(), combMat.getIsoseq());
+ if (Cools.isEmpty(orderDetl)) {
throw new CoolException("鏈尮閰嶅埌璇ュ崟鎹笅鐨勭墿鏂�");
}
if (combMat.getAnfme() > orderDetl.getEnableQty()) {
throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
}
// 淇敼璁㈠崟鏄庣粏鏁伴噺
- if (!orderDetlService.increase(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(),combMat.getIsoseq())) {
+ if (!orderDetlService.increase(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(), combMat.getIsoseq())) {
throw new CoolException("淇敼鍗曟嵁鏄庣粏鏁伴噺澶辫触");
}
}
@@ -164,7 +179,7 @@
/*
鍚屾鐢熸垚AGV鍏ュ簱閫氱煡妗f暟鎹�
*/
- private void syncWaitPakin(DetlDto detlDto, String orderNo, String zpallet, Long userId, Date now ){
+ private void syncWaitPakin(DetlDto detlDto, String orderNo, String zpallet, Long userId, Date now) {
Mat mat = matService.selectByMatnr(detlDto.getMatnr());
if (Cools.isEmpty(mat)) {
throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
@@ -210,32 +225,36 @@
@Override
public void combBinding(String barcode, String stationCode) {
- if(Cools.isEmpty(agvWaitPakinService.selectByContainerCode(barcode))){
+ if (Cools.isEmpty(agvWaitPakinService.selectByContainerCode(barcode))) {
throw new CoolException("璇ユ枡绠辨湭缁勬墭锛屾棤娉曠粦瀹氱珯鐐�");
}
AgvBasDevp agvBasDevp = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>().eq("barcode", barcode));
- if(!Cools.isEmpty(agvBasDevp)){
- throw new CoolException(barcode + "宸茬粡缁戝畾鍦�"+ agvBasDevp.getDevNo() +"绔欑偣");
+ if (!Cools.isEmpty(agvBasDevp)) {
+ throw new CoolException(barcode + "宸茬粡缁戝畾鍦�" + agvBasDevp.getDevNo() + "绔欑偣");
}
- agvBasDevp = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>().eq("dev_no",stationCode));
- if(agvBasDevp == null){
+ agvBasDevp = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>().eq("dev_no", stationCode));
+ if (agvBasDevp == null) {
throw new CoolException(stationCode + "绔欑偣淇℃伅閿欒");
}
- if(!"O".equals(agvBasDevp.getLocSts())){
+ if (!"O".equals(agvBasDevp.getLocSts())) {
throw new CoolException(stationCode + "璇ョ珯鐐硅揣浣嶇姸鎬侀潪绌�");
+ }
+ AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", agvBasDevp.getDevNo()));
+ if (!Cools.isEmpty(agvWrkMast)) {
+ throw new CoolException(stationCode + "璇ョ珯鐐瑰凡琚伐浣滃彿涓�" + agvWrkMast.getWrkNo() + "鍗犵敤锛屾棤娉曠粦瀹�");
}
agvBasDevp.setBarcode(barcode);
agvBasDevp.setLocSts("F");
- agvBasDevpService.update(agvBasDevp,(new EntityWrapper<AgvBasDevp>().eq("dev_no",stationCode)));
+ agvBasDevpService.update(agvBasDevp, (new EntityWrapper<AgvBasDevp>().eq("dev_no", stationCode)));
}
public List<AgvBasDevp> getAgvBasDevpByFloor(int floor) {
EntityWrapper<AgvBasDevp> wrapper = new EntityWrapper<>();
- wrapper.eq("floor",floor).eq("cache_shelves","Y").eq("loc_sts","F");
+ wrapper.eq("floor", floor).eq("cache_shelves", "Y").eq("loc_sts", "F");
List<AgvBasDevp> agvBasDevpList = agvBasDevpService.selectList(wrapper);
return agvBasDevpList.stream().filter(agvBasDevp -> {
return !Cools.isEmpty(agvWaitPakinService.selectByContainerCode(agvBasDevp.getBarcode()));
--
Gitblit v1.9.1