From dd78a469b3167d5c0251427dcaab82f81bb3f3a5 Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期一, 22 一月 2024 15:03:09 +0800 Subject: [PATCH] #检料再入库逻辑修改,定时器检测是否存在在库无资料数据 --- src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java | 256 ++++++++++++++++++++++++++++++++------------------ 1 files changed, 163 insertions(+), 93 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 0a5fcc4..982fcbf 100644 --- a/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/AgvMobileServiceImpl.java @@ -18,6 +18,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; /** * 绉诲姩绔湇鍔℃牳蹇冪被 @@ -37,8 +38,15 @@ private OrderDetlService orderDetlService; @Autowired private AgvBasDevpService agvBasDevpService; + @Autowired + private AgvLocDetlService agvLocDetlService; + @Autowired + private AgvWrkMastService agvWrkMastService; + /* + 缁勬墭 + 缁戝畾鏆傚瓨浣� + */ @Override @Transactional public String comb(CombParam param, Long userId) { @@ -46,97 +54,27 @@ throw new CoolException(BaseRes.PARAM); } - if (agvWaitPakinService.selectCount(new EntityWrapper<AgvWaitPakin>(). - eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { - throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱"); + //妫�鏌ユ槸鍚﹀凡瀛樺湪鐩稿悓鐨勬墭鐩樻潯鐮侊紝瀛樺湪鍒欐姏鍑哄紓甯� + if (agvWaitPakinService.selectCount(new EntityWrapper<AgvWaitPakin>().eq("supp_code", param.getBarcode())) > 0) { + throw new CoolException(param.getBarcode() + "鏂欐兂鐮佸凡瀛樺湪AGV鍏ュ簱閫氱煡妗d腑"); } - Date now = new Date(); - //鏃犲崟缁勬墭 + //妫�鏌ュ簱瀛樻槸鍚︽湁鐩稿悓鏂欑锛屽瓨鍦ㄥ垯鎶涘嚭寮傚父 + 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腑"); + } + if (Cools.isEmpty(param.getOrderNo())) { - List<DetlDto> detlDtos = new ArrayList<>(); - param.getCombMats().forEach(elem -> { - DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); - if (DetlDto.has(detlDtos, detlDto)) { - DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); - assert one != null; - one.setAnfme(one.getAnfme() + detlDto.getAnfme()); - } else { - detlDtos.add(detlDto); - } - }); - - detlDtos.forEach(detlDto -> { - Mat mat = matService.selectByMatnr(detlDto.getMatnr()); - if (Cools.isEmpty(mat)) { - throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�"); - } - AgvWaitPakin waitPakin = new AgvWaitPakin(); - waitPakin.sync(mat); - waitPakin.setBatch(detlDto.getBatch()); - waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮� - waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵�� - waitPakin.setAnfme(detlDto.getAnfme()); // 鏁伴噺 - waitPakin.setStatus("Y"); // 鐘舵�� - waitPakin.setAppeUser(userId); - waitPakin.setAppeTime(now); - waitPakin.setModiUser(userId); - waitPakin.setModiTime(now); - if (!agvWaitPakinService.insert(waitPakin)) { - throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); - } - }); + //鏃犲崟缁勬墭 + NoOrderComb(param,userId); }else { - //鍏宠仈缁勬墭 - Order order = orderService.selectByNo(param.getOrderNo()); - if (order.getSettle() > 2) { - throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�"); - } - // 鐢熸垚鍏ュ簱閫氱煡妗� - List<DetlDto> detlDtos = new ArrayList<>(); - param.getCombMats().forEach(elem -> { - - // 璁㈠崟鏄庣粏鏁伴噺鏍¢獙 - OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch()); - if (elem.getAnfme() > orderDetl.getEnableQty()) { - throw new CoolException(orderDetl.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�"); - } - // 淇敼璁㈠崟鏄庣粏鏁伴噺 - if (!orderDetlService.increase(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) { - throw new CoolException("淇敼鍗曟嵁鏄庣粏鏁伴噺澶辫触"); - } - - DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); - if (DetlDto.has(detlDtos, detlDto)) { - DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); - assert one != null; - one.setAnfme(one.getAnfme() + detlDto.getAnfme()); - } else { - detlDtos.add(detlDto); - } - }); - for (DetlDto detlDto : detlDtos) { - Mat mat = matService.selectByMatnr(detlDto.getMatnr()); - if (Cools.isEmpty(mat)) { - throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�"); - } - AgvWaitPakin waitPakin = new AgvWaitPakin(); - waitPakin.sync(mat); - waitPakin.setOrderNo(order.getOrderNo()); // 鍗曟嵁缂栧彿 - waitPakin.setBatch(detlDto.getBatch()); // 搴忓垪鐮� - waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮� - waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵�� - waitPakin.setAnfme(detlDto.getAnfme()); // 鏁伴噺 - waitPakin.setStatus("Y"); // 鐘舵�� - waitPakin.setAppeUser(userId); - waitPakin.setAppeTime(now); - waitPakin.setModiUser(userId); - waitPakin.setModiTime(now); - if (!agvWaitPakinService.insert(waitPakin)) { - throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); - } - } - orderService.updateSettle(order.getId(), 2L, userId); + //鏈夊崟缁勬墭 + OrderComb(param,userId); } if(StringUtils.isEmpty(param.getLocno())){ @@ -147,6 +85,122 @@ } } + + /* + AGV鏃犲崟缁勬墭 + */ + 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); + }); + } + + /* + AGV鏈夊崟缁勬墭 + */ + private void OrderComb(CombParam param, Long userId){ + //鍏宠仈缁勬墭 + Order order = orderService.selectByNo(param.getOrderNo()); + if(Cools.isEmpty(order)){ + throw new CoolException("鍗曟嵁缂栧彿涓嶅瓨鍦�"); + } + //璁㈠崟鐘舵��2浠ヤ笂涓哄畬鎴愭垨鑰呭彇娑堢殑璁㈠崟 + if (order.getSettle() > 2) { + throw new CoolException("鍗曟嵁缂栧彿宸茶繃鏈�"); + } + // 鐢ㄤ簬鐢熸垚鍏ュ簱閫氱煡妗f墍闇�鍙傛暟 + List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param,order); + //鐢ㄤ簬缁熶竴涓�涓墭鐩樹笅鐨勫叆搴撻�氱煡妗g殑鐢熸垚鏃堕棿 + Date now = new Date(); + for (DetlDto detlDto : detlDtos) { + //鍚屾鐢熸垚鍏ュ簱閫氱煡妗� + syncWaitPakin(detlDto,order.getOrderNo(),param.getBarcode(),userId,now); + } + //淇敼鍗曟嵁鐘舵�佷负2.浣滀笟涓� + orderService.updateSettle(order.getId(), 2L, userId); + } + + /* + 鏍规嵁PDA鎵爜鎵�浼犵殑鐗╂枡淇℃伅鍙傛暟鏄犲皠涓篋etlDto + */ + private List<DetlDto> mappingDetlDtoByCombMat(CombParam param, Order order){ + List<DetlDto> detlDtos = new ArrayList<>(); + param.getCombMats().forEach(combMat -> { + + if(!Cools.isEmpty(order)){ + //妫�鏌ュ叆搴撴暟閲� + checkOrderQty(order,combMat); + } + + 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); + assert one != null; + one.setAnfme(one.getAnfme() + detlDto.getAnfme()); + } else { + detlDtos.add(detlDto); + } + }); + + return detlDtos; + } + + /* + 妫�鏌ュ叆搴撴暟閲忔槸鍚﹀皬浜庣瓑浜庡崟鎹暟閲忥紝鍚堢悊鍒欎慨鏀筄rderDetl浣滀笟鏁伴噺淇℃伅锛屽惁鍒欐姏鍑哄紓甯� + */ + 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)){ + 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())) { + throw new CoolException("淇敼鍗曟嵁鏄庣粏鏁伴噺澶辫触"); + } + } + + /* + 鍚屾鐢熸垚AGV鍏ュ簱閫氱煡妗f暟鎹� + */ + 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涓嶅瓨鍦�"); + } + AgvWaitPakin waitPakin = new AgvWaitPakin(); + waitPakin.sync(mat); + waitPakin.setOrderNo(orderNo); // 鍗曟嵁缂栧彿 + waitPakin.setBatch(detlDto.getBatch()); // 搴忓垪鐮� + //waitPakin.setZpallet(zpallet); // 鎵樼洏鐮� + waitPakin.setSuppCode(zpallet); // 鎵樼洏鐮� + waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵�� + waitPakin.setAnfme(detlDto.getAnfme()); // 鏁伴噺 + waitPakin.setStatus("Y"); // 鐘舵�� + + ////閿�鍞鍗曞彿 + waitPakin.setThreeCode(detlDto.getCsocode()); + //閿�鍞鍗曡鍙� + waitPakin.setDeadTime(detlDto.getIsoseq()); + + + waitPakin.setAppeUser(userId); + waitPakin.setAppeTime(now); + waitPakin.setModiUser(userId); + waitPakin.setModiTime(now); + if (!agvWaitPakinService.insert(waitPakin)) { + throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); + } + } + @Override @Transactional @@ -162,25 +216,41 @@ @Override public void combBinding(String barcode, String stationCode) { - EntityWrapper<AgvBasDevp> wrapper = new EntityWrapper<>(); - wrapper.eq("dev_no",stationCode); - AgvBasDevp agvBasDevp = agvBasDevpService.selectOne(wrapper); + + 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() +"绔欑偣"); + } + + agvBasDevp = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>().eq("dev_no",stationCode)); if(agvBasDevp == null){ throw new CoolException(stationCode + "绔欑偣淇℃伅閿欒"); } 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,wrapper); + 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"); - return agvBasDevpService.selectList(wrapper); + 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())); + }).collect(Collectors.toList()); } } -- Gitblit v1.9.1