From 14129e42408efdd6c1678f44304c0585273d7e85 Mon Sep 17 00:00:00 2001 From: lty <876263681@qq.com> Date: 星期四, 28 八月 2025 15:59:58 +0800 Subject: [PATCH] #手动出库agv库位锁定 --- src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java | 206 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 191 insertions(+), 15 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 fbb683d..c41d17a 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"); @@ -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())); } } @@ -303,6 +311,15 @@ dtos.add(new OutLocDto(locNo, locDetlDto)); } } + Config config = configService.selectConfigByCode("AutoMPArea"); + + List<LocMast> list = locMastMapper.selectList( + new EntityWrapper<LocMast>() + .eq("whs_type", 5) + .eq("loc_sts", "O") + ); + LocMast locMastRgv = list.isEmpty() ? null : list.get(0); + Integer ioType = null; // 鐢熸垚宸ヤ綔妗� for (OutLocDto dto : dtos) { @@ -343,6 +360,10 @@ wrkMast.setEmptyMk("N"); // 绌烘澘 wrkMast.setLinkMis("N"); wrkMast.setBarcode(locMast.getBarcode()); + if (Boolean.parseBoolean(config.getValue()) && locMastRgv.getLocNo() != null) { //鑻ユ湁绌哄簱浣嶄笖閰嶇疆鍏佽鍒欑粦瀹氬叾澶囨枡搴撲綅鍙� + wrkMast.setLocNo(locMastRgv.getLocNo()); + wrkMast.setTakeNone("0"); //0rgv鏈彇锛�1rgv宸插彇璐� + } wrkMast.setAppeUser(userId); // 鎿嶄綔浜哄憳鏁版嵁 wrkMast.setAppeTime(now); wrkMast.setModiUser(userId); @@ -367,6 +388,18 @@ if (!wrkDetlService.insert(wrkDetl)) { throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); } + } + //淇敼agv澶囨枡鍖虹姸鎬� + if(locMastRgv.getLocSts().equals("O")){ + locMastRgv.setLocSts("S"); + locMastRgv.setModiUser(userId); + locMastRgv.setModiTime(now); + if (!locMastService.updateById(locMastRgv)) { + throw new CoolException("棰勭害agv澶囨枡鍖哄簱浣嶇姸鎬佸け璐ワ紝搴撲綅鍙凤細"+locMastRgv.getLocNo()); + } + }else{ + throw new CoolException(locMastRgv.getLocNo() + "澶囨枡鍖轰笉鏄┖搴撲綅鐘舵��"); + } // 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓� locMast = locMastService.selectById(dto.getLocNo()); @@ -393,11 +426,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)); // 鐢熸垚宸ヤ綔妗� @@ -411,6 +458,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"); // 閫�鍑� @@ -460,6 +511,18 @@ 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澶囨枡鍖哄簱浣嶇姸鎬佸け璐ワ紝搴撲綅鍙凤細"+locMastRgv.getLocNo()); + } + }else{ + throw new CoolException(locMastRgv.getLocNo() + "澶囨枡鍖轰笉鏄┖搴撲綅鐘舵��"); + } // 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓� locMast = locMastService.selectById(taskDto.getLocNo()); @@ -679,7 +742,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())); } } @@ -845,6 +909,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()) { @@ -858,7 +947,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() + "鎵瑰彿淇敼鏁伴噺澶辫触"); } // 淇濆瓨璋冩暣璁板綍 @@ -873,6 +963,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(); @@ -883,7 +997,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() + "鎵瑰彿搴撳瓨鏄庣粏澶辫触"); } // 淇濆瓨璋冩暣璁板綍 @@ -898,6 +1013,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("淇濆瓨宸ヤ綔鏄庣粏澶辫触"); + } } // 娣诲姞搴撳瓨 @@ -908,6 +1047,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); @@ -928,6 +1068,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())); @@ -1021,6 +1185,16 @@ //鍙栨秷鍑哄簱宸ヤ綔妗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())) { @@ -1094,15 +1268,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