From 2ede5469ff64257e97ab92825261afeb643d7b82 Mon Sep 17 00:00:00 2001 From: lty <876263681@qq.com> Date: 星期四, 28 八月 2025 15:56:05 +0800 Subject: [PATCH] #订单出库agv库位锁定,取消,配置 --- src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java | 205 +++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 183 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java index d59bab5..bddeb9e 100644 --- a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java @@ -23,6 +23,8 @@ import com.zy.common.properties.SlaveProperties; import com.zy.common.service.CommonService; import com.zy.common.web.WcsController; +import com.zy.system.entity.Config; +import com.zy.system.service.ConfigService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -74,6 +76,8 @@ @Autowired private OrderDetlService orderDetlService; @Autowired + private ConfigService configService; + @Autowired private WcsController wcsController; @Autowired private RowLastnoService rowLastnoService; @@ -91,6 +95,9 @@ @Resource private LocMastMapper locMastMapper; + @Resource + private OrderPakoutService orderPakOutService; + @Override @Transactional public String startupFullPutStore(FullStoreParam param, Long userId) { @@ -103,9 +110,9 @@ BasDevp sourceStaNo = basDevpService.checkSiteStatus(param.getDevpNo(), true); // 妫�绱㈠簱浣� LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); - List<String> matnrs = param.getList().stream().map(FullStoreParam.MatCodeStore::getMatnr).distinct().collect(Collectors.toList()); +// List<String> matnrs = param.getList().stream().map(FullStoreParam.MatCodeStore::getMatnr).distinct().collect(Collectors.toList()); // List<String> batchs = param.getList().stream().map(FullStoreParam.MatCodeStore::getBatch).distinct().collect(Collectors.toList()); - FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo(matnrs.get(0)); + FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo(param.getList().get(0)); StartupDto dto = commonService.getLocNo(1, param.getDevpNo(), findLocNoAttributeVo,locTypeDto); if (Cools.isEmpty(dto)){ throw new CoolException("鏌ヨ搴撲綅澶辫触锛侊紒==銆媠tartupFullPutStore ==銆� commonService.getLocNo"); @@ -140,9 +147,9 @@ // 鐢熸垚宸ヤ綔妗f槑缁� List<DetlDto> detlDtos = new ArrayList<>(); param.getList().forEach(elem -> { - DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(), elem.getAnfme()); + DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(),elem.getBrand(),elem.getStandby1(),elem.getStandby2(),elem.getStandby3(),elem.getBoxType1(),elem.getBoxType2(),elem.getBoxType3(), elem.getAnfme()); if (DetlDto.has(detlDtos, detlDto)) { - DetlDto detlDto1 = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(),detlDto.getBrand(),detlDto.getStandby1(),detlDto.getStandby2(),detlDto.getStandby3()); + DetlDto detlDto1 = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(),detlDto.getBrand(),detlDto.getStandby1(),detlDto.getStandby2(),detlDto.getStandby3(),detlDto.getBoxType1(),detlDto.getBoxType2(),detlDto.getBoxType3()); assert detlDto1 != null; detlDto1.setAnfme(detlDto1.getAnfme() + detlDto.getAnfme()); } else { @@ -181,7 +188,8 @@ List<LocDetlDto> locDetlDtos = new ArrayList<>(); for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) { - LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch()); + LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch(),paramLocDetl.getBrand() + ,paramLocDetl.getStandby1(),paramLocDetl.getStandby2(),paramLocDetl.getStandby3(),paramLocDetl.getBoxType1(),paramLocDetl.getBoxType2(),paramLocDetl.getBoxType3()); if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); } } @@ -244,7 +252,9 @@ if (Cools.isEmpty(owner)) { owner = manLocDetl.getOwner$(); } - detlDtos.add(new DetlDto(manLocDetl.getMatnr(), manLocDetl.getBatch(), manLocDetl.getAnfme())); +// detlDtos.add(new DetlDto(manLocDetl.getMatnr(), manLocDetl.getBatch(),manLocDetl.getBrand(), +// manLocDetl.getStandby1(),manLocDetl.getStandby2(),manLocDetl.getStandby3(), +// manLocDetl.getBoxType1(),manLocDetl.getBoxType2(),manLocDetl.getBoxType3(), manLocDetl.getAnfme())); manLocDetl.setOwner(param.getOwnerId()); try{ manLocDetlService.update(manLocDetl,new EntityWrapper<ManLocDetl>().eq("loc_no", locNo).eq("matnr",manLocDetl.getMatnr())); @@ -261,7 +271,9 @@ if (Cools.isEmpty(owner)) { owner = locDetl.getOwner$(); } - detlDtos.add(new DetlDto(locDetl.getMatnr(), locDetl.getBatch(), locDetl.getAnfme())); + detlDtos.add(new DetlDto(locDetl.getMatnr(), locDetl.getBatch(),locDetl.getBrand(), + locDetl.getStandby1(),locDetl.getStandby2(),locDetl.getStandby3(), + locDetl.getBoxType1(),locDetl.getBoxType2(),locDetl.getBoxType3(), locDetl.getAnfme())); locDetl.setOwner(param.getOwnerId()); try{ locDetlService.update(locDetl,new EntityWrapper<LocDetl>().eq("loc_no", locNo).eq("matnr",locDetl.getMatnr())); @@ -389,11 +401,25 @@ throw new CoolException("璁㈠崟鍑哄簱寮傚父锛岃鑱旂郴绠$悊鍛�"); } } + Config config = configService.selectConfigByCode("AutoMPArea"); + // 鑾峰彇搴撲綅 LocMast locMast = locMastService.selectById(taskDto.getLocNo()); - // 鑾峰彇璺緞 - int ioType = taskDto.isAll() ? 101 : 103; + // 鍒ゆ柇鏄惁鏄洏鐐瑰崟 + String orderNo = taskDto.getLocDtos().get(0).getOrderNo(); + OrderPakout orderPakout = orderPakOutService.selectByNo(orderNo); + int ioType = orderPakout.getDocType() == 8 ? 107 : (taskDto.isAll() ? 101 : 103); StaDesc staDesc = staDescService.queryCrnStnAuto(ioType, locMast.getCrnNo(), staNo.getDevNo()); + List<LocMast> list = locMastMapper.selectList( + new EntityWrapper<LocMast>() + .eq("whs_type", 5) + .eq("loc_sts", "O") + ); + LocMast locMastRgv = list.isEmpty() ? null : list.get(0); + + + + // 鐢熸垚宸ヤ綔鍙� int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); // 鐢熸垚宸ヤ綔妗� @@ -407,6 +433,10 @@ wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯 wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔� wrkMast.setSourceLocNo(taskDto.getLocNo()); // 婧愬簱浣� + if (Boolean.parseBoolean(config.getValue()) && locMastRgv.getLocNo() != null) { //鑻ユ湁绌哄簱浣嶄笖閰嶇疆鍏佽鍒欑粦瀹氬叾澶囨枡搴撲綅鍙� + wrkMast.setLocNo(locMastRgv.getLocNo()); + wrkMast.setTakeNone("0"); //0rgv鏈彇锛�1rgv宸插彇璐� + } wrkMast.setFullPlt("Y"); // 婊℃澘锛歒 wrkMast.setPicking("N"); // 鎷f枡 wrkMast.setExitMk("N"); // 閫�鍑� @@ -424,7 +454,8 @@ for (LocDto locDto : taskDto.getLocDtos()) { if (locDto.getAnfme()==null || locDto.getAnfme() <= 0.0D) { continue; } // OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch()); - OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.FALSE, locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch(),locDto.getBrand(),locDto.getStandby1(),locDto.getStandby2(),locDto.getStandby3()); + OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.FALSE, locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch(),locDto.getBrand() + ,locDto.getStandby1(),locDto.getStandby2(),locDto.getStandby3(),locDto.getBoxType1(),locDto.getBoxType2(),locDto.getBoxType3()); // if (orderDetl == null) { //// orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null); // orderDetl = OrderInAndOutUtil.selectItem(Boolean.FALSE, locDto.getOrderNo(), locDto.getMatnr(), null); @@ -450,8 +481,23 @@ // throw new CoolException("淇敼璁㈠崟鏄庣粏鏁伴噺澶辫触"); // } // orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); - OrderInAndOutUtil.increaseWorkQty(Boolean.FALSE,orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(),orderDetl.getBrand(),orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(), locDto.getAnfme()); + OrderInAndOutUtil.increaseWorkQty(Boolean.FALSE,orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), + orderDetl.getBrand(),orderDetl.getStandby1(),orderDetl.getStandby2(),orderDetl.getStandby3(), + orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3() + , locDto.getAnfme()); OrderInAndOutUtil.updateOrder(Boolean.FALSE,orderDetl.getOrderId(), 2L, userId); + } + //淇敼agv澶囨枡鍖虹姸鎬� + if(locMastRgv.getLocSts().equals("O")){ + locMastRgv.setLocSts("S"); + locMastRgv.setModiUser(userId); + locMastRgv.setModiTime(now); + if (!locMastService.updateById(locMastRgv)) { + throw new CoolException("棰勭害agv澶囨枡鍖哄簱浣嶇姸鎬佸け璐ワ紝搴撲綅鍙凤細"+taskDto.getLocNo()); + } + }else{ + throw new CoolException(taskDto.getLocNo() + "澶囨枡鍖轰笉鏄┖搴撲綅鐘舵��"); + } // 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓� locMast = locMastService.selectById(taskDto.getLocNo()); @@ -671,7 +717,8 @@ List<LocDetlDto> locDetlDtos = new ArrayList<>(); for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) { - LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch()); + LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch(),paramLocDetl.getBrand() + ,paramLocDetl.getStandby1(),paramLocDetl.getStandby2(),paramLocDetl.getStandby3(),paramLocDetl.getBoxType1(),paramLocDetl.getBoxType2(),paramLocDetl.getBoxType3()); if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); } } @@ -837,6 +884,31 @@ List<LocDetlAdjustParam.LocDetlAdjust> list = param.getList(); + // 娣诲姞鍘嗗彶宸ヤ綔涓绘。 + WrkMastLog wrkMast = new WrkMastLog(); + wrkMast.setIoTime(now); + wrkMast.setWrkSts(5); + wrkMast.setIoPri(13D); // 浼樺厛绾� + wrkMast.setCrnNo(locMast.getCrnNo()); + wrkMast.setSourceLocNo(locMast.getLocNo()); + wrkMast.setLocNo(locMast.getLocNo()); + wrkMast.setBarcode(locMast.getBarcode()); // 鎵樼洏鐮� + wrkMast.setFullPlt("Y"); // 婊℃澘锛歒 + wrkMast.setPicking("N"); // 鎷f枡 + wrkMast.setExitMk("N"); // 閫�鍑� + wrkMast.setEmptyMk("N"); // 绌烘澘 + wrkMast.setLinkMis("Y"); + // 鎿嶄綔浜哄憳鏁版嵁 + wrkMast.setAppeTime(now); + wrkMast.setModiTime(now); + wrkMast.setAppeUser(userId); + wrkMast.setModiUser(userId); + + // 澧炲垹鏀瑰彧鍒涘缓涓�娆″伐浣滀富妗� + boolean updateFlag = true; + boolean deleteFlag = true; + boolean addFlag = true; + // 淇敼鏁伴噺 Iterator<LocDetl> iterator = locDetls.iterator(); while (iterator.hasNext()) { @@ -850,7 +922,8 @@ if (!locDetl.getAnfme().equals(adjust.getCount())) { // todo 鐩樼偣璁板綍 // 淇敼搴撳瓨 - if (!locDetlService.updateAnfme(adjust.getCount(), locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch())) { + if (!locDetlService.updateAnfme(adjust.getCount(), locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(),locDetl.getBrand(), + locDetl.getStandby1(),locDetl.getStandby2(),locDetl.getStandby3(),locDetl.getBoxType1(),locDetl.getBoxType2(),locDetl.getBoxType3())) { throw new CoolException(locDetl.getLocNo() + "搴撲綅锛�" + locDetl.getMatnr() + "鍟嗗搧锛�" + locDetl.getBatch() + "鎵瑰彿淇敼鏁伴噺澶辫触"); } // 淇濆瓨璋冩暣璁板綍 @@ -865,6 +938,30 @@ adjDetl.setAppeTime(now); adjDetl.setAppeUser(userId); adjDetlService.save(adjDetl, userId); + + if (updateFlag) { + wrkMast.setWrkNo(commonService.getWorkNo(3)); + wrkMast.setIoType(23); + boolean res = wrkMastLogService.insert(wrkMast); + if (!res) { + throw new CoolException("搴撳瓨璋冩暣-淇敼 淇濆瓨宸ヤ綔妗eけ璐�"); + } + updateFlag = false; + } + + // 娣诲姞鍘嗗彶宸ヤ綔鏄庣粏 + WrkDetlLog wrkDetl = new WrkDetlLog(); + wrkDetl.sync(locDetl); + wrkDetl.setWrkNo(wrkMast.getWrkNo()); + wrkDetl.setIoTime(wrkMast.getIoTime()); + wrkDetl.setAnfme(adjust.getCount()); + wrkDetl.setAppeTime(now); + wrkDetl.setModiTime(now); + wrkMast.setAppeUser(userId); + wrkMast.setModiUser(userId); + if (!wrkDetlLogService.insert(wrkDetl)) { + throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏澶辫触"); + } } iterator.remove(); iterator1.remove(); @@ -875,7 +972,8 @@ // 鍒犻櫎搴撳瓨 for (LocDetl locDetl : locDetls) { // todo 鐩樼偣璁板綍 - if (!locDetlService.updateAnfme(-1.0D, locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch())) { + if (!locDetlService.updateAnfme(-1.0D, locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(),locDetl.getBrand(), + locDetl.getStandby1(),locDetl.getStandby2(),locDetl.getStandby3(),locDetl.getBoxType1(),locDetl.getBoxType2(),locDetl.getBoxType3())) { throw new CoolException("鍒犻櫎" + locDetl.getLocNo() + "搴撲綅锛�" + locDetl.getMatnr() + "鍟嗗搧锛�" + locDetl.getBatch() + "鎵瑰彿搴撳瓨鏄庣粏澶辫触"); } // 淇濆瓨璋冩暣璁板綍 @@ -890,6 +988,30 @@ adjDetl.setAppeTime(now); adjDetl.setAppeUser(userId); adjDetlService.save(adjDetl, userId); + + if (deleteFlag) { + wrkMast.setWrkNo(commonService.getWorkNo(3)); + wrkMast.setIoType(22); + boolean res = wrkMastLogService.insert(wrkMast); + if (!res) { + throw new CoolException("搴撳瓨璋冩暣-鍒犻櫎 淇濆瓨宸ヤ綔妗eけ璐�"); + } + deleteFlag = false; + } + + // 娣诲姞鍘嗗彶宸ヤ綔鏄庣粏 + WrkDetlLog wrkDetl = new WrkDetlLog(); + wrkDetl.sync(locDetl); + wrkDetl.setWrkNo(wrkMast.getWrkNo()); + wrkDetl.setIoTime(wrkMast.getIoTime()); + wrkDetl.setAnfme(0.0); + wrkDetl.setAppeTime(now); + wrkDetl.setModiTime(now); + wrkMast.setAppeUser(userId); + wrkMast.setModiUser(userId); + if (!wrkDetlLogService.insert(wrkDetl)) { + throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏澶辫触"); + } } // 娣诲姞搴撳瓨 @@ -900,6 +1022,7 @@ locDetl.sync(mat); locDetl.setBatch(adjust.getBatch()); locDetl.setLocNo(locMast.getLocNo()); + locDetl.setZpallet(locMast.getBarcode()); locDetl.setAnfme(adjust.getCount()); // 鏁伴噺 locDetl.setModiUser(userId); // 鎿嶄綔浜哄憳淇℃伅 locDetl.setModiTime(now); @@ -920,6 +1043,30 @@ adjDetl.setAppeTime(now); adjDetl.setAppeUser(userId); adjDetlService.save(adjDetl, userId); + + if (addFlag) { + wrkMast.setWrkNo(commonService.getWorkNo(3)); + wrkMast.setIoType(21); + boolean res = wrkMastLogService.insert(wrkMast); + if (!res) { + throw new CoolException("搴撳瓨璋冩暣-鏂板 淇濆瓨宸ヤ綔妗eけ璐�"); + } + addFlag = false; + } + + // 娣诲姞鍘嗗彶宸ヤ綔鏄庣粏 + WrkDetlLog wrkDetl = new WrkDetlLog(); + wrkDetl.sync(locDetl); + wrkDetl.setWrkNo(wrkMast.getWrkNo()); + wrkDetl.setIoTime(wrkMast.getIoTime()); + wrkDetl.setAnfme(adjust.getCount()); + wrkDetl.setAppeTime(now); + wrkDetl.setModiTime(now); + wrkMast.setAppeUser(userId); + wrkMast.setModiUser(userId); + if (!wrkDetlLogService.insert(wrkDetl)) { + throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏澶辫触"); + } } // 淇敼搴撲綅鐘舵�� int count = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo())); @@ -1013,12 +1160,24 @@ //鍙栨秷鍑哄簱宸ヤ綔妗f椂锛屾煡璇㈠崟鎹鐞嗚〃锛屽洖婊氫綔涓氫腑鏁伴噺 if(wrkMast.getIoType() == 101 || wrkMast.getIoType() == 103) { List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); + if(wrkMast.getLocNo() != null){ + LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); + locMast.setLocSts("O"); + locMast.setModiTime(now); + locMast.setModiUser(userId); + boolean locMastRes = locMastService.updateById(locMast); + if (!locMastRes) { + throw new CoolException("淇濆瓨鏁版嵁澶辫触"); + } + } for (WrkDetl wrkDetl : wrkDetls) { if (!Cools.isEmpty(wrkDetl.getOrderNo())) { // if (!orderDetlService.decrease(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) { // throw new CoolException("璁㈠崟鏁版嵁鍥炴粴澶辫触"); // } - OrderInAndOutUtil.decrease(Boolean.FALSE,wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(),wrkDetl.getBrand(),wrkDetl.getStandby1(),wrkDetl.getStandby2(),wrkDetl.getStandby3(), wrkDetl.getAnfme()); + OrderInAndOutUtil.decrease(Boolean.FALSE,wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(),wrkDetl.getBrand(), + wrkDetl.getStandby1(),wrkDetl.getStandby2(),wrkDetl.getStandby3(), + wrkDetl.getBoxType1(),wrkDetl.getBoxType2(),wrkDetl.getBoxType3(), wrkDetl.getAnfme()); //淇敼璁㈠崟涓昏〃鐘舵��,娌℃湁浣滀笟鏁伴噺鏃舵墠鍙互淇敼 boolean flag = true; @@ -1084,15 +1243,17 @@ // 淇敼搴撲綅鐘舵�� LocMast locMast = locMastService.selectById(locNo); - if (Cools.isEmpty(locMast)) { + if (Cools.isEmpty(locMast) && wrkMast.getIoType() != 12) { throw new CoolException("鍙栨秷宸ヤ綔妗eけ璐ワ紝搴撲綅涓嶅瓨鍦�:"+ locNo); } - locMast.setLocSts(locSts); - locMast.setModiTime(now); - locMast.setModiUser(userId); - boolean locMastRes = locMastService.updateById(locMast); - if (!wrkMastRes || !locMastRes) { - throw new CoolException("淇濆瓨鏁版嵁澶辫触"); + if(wrkMast.getIoType() != 12){ + locMast.setLocSts(locSts); + locMast.setModiTime(now); + locMast.setModiUser(userId); + boolean locMastRes = locMastService.updateById(locMast); + if (!wrkMastRes || !locMastRes) { + throw new CoolException("淇濆瓨鏁版嵁澶辫触"); + } } } -- Gitblit v1.9.1