From 21d0e7ab9d5c7316225a3e9eecf465cd37c9bd85 Mon Sep 17 00:00:00 2001 From: zhang <zc857179121@qq.com> Date: 星期四, 05 六月 2025 14:15:07 +0800 Subject: [PATCH] 123 --- src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java | 1347 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 1,236 insertions(+), 111 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 a13e2c9..1bd9ff9 100644 --- a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java @@ -1,5 +1,7 @@ package com.zy.asrs.service.impl; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.Wrapper; import com.core.common.BaseRes; @@ -8,10 +10,7 @@ import com.core.common.SnowflakeIdWorker; import com.core.exception.CoolException; import com.zy.asrs.entity.*; -import com.zy.asrs.entity.param.EmptyPlateOutParam; -import com.zy.asrs.entity.param.FullStoreParam; -import com.zy.asrs.entity.param.LocDetlAdjustParam; -import com.zy.asrs.entity.param.StockOutParam; +import com.zy.asrs.entity.param.*; import com.zy.asrs.service.*; import com.zy.asrs.utils.Utils; import com.zy.common.model.*; @@ -19,6 +18,7 @@ import com.zy.common.model.enums.WorkNoType; import com.zy.common.properties.SlaveProperties; import com.zy.common.service.CommonService; +import com.zy.common.web.BaseController; import com.zy.common.web.WcsController; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -72,6 +72,8 @@ @Autowired private WcsController wcsController; @Autowired + private WaitPakinService waitPakinService; + @Autowired private RowLastnoService rowLastnoService; @Autowired private SlaveProperties slaveProperties; @@ -98,8 +100,9 @@ wrkMast.setIoTime(new Date()); wrkMast.setWrkSts(1L); // 宸ヤ綔鐘舵�侊細鐢熸垚鍏ュ簱ID wrkMast.setIoType(1); // 鍏ュ嚭搴撶姸鎬侊細1.鍏ュ簱 - wrkMast.setIoPri(13D); // 浼樺厛绾э細13 - wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo(), true)?1:0);; + Double ioPri = wrkMastService.getIoPri(1, dto.getLocNo()); + wrkMast.setIoPri(ioPri); // 浼樺厛绾э細13 + wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo(), true) ? 1 : 0); wrkMast.setCrnNo(dto.getCrnNo()); wrkMast.setSourceStaNo(dto.getSourceStaNo()); wrkMast.setStaNo(dto.getStaNo()); @@ -135,20 +138,20 @@ sourceStaNo.setWrkNo(workNo); sourceStaNo.setModiUser(userId); sourceStaNo.setModiTime(now); - if (!basDevpService.updateById(sourceStaNo)){ + if (!basDevpService.updateById(sourceStaNo)) { throw new CoolException("鏇存柊婧愮珯澶辫触"); } // 鏇存柊鐩爣搴撲綅鐘舵�� LocMast locMast = locMastService.selectById(dto.getLocNo()); - if (locMast.getLocSts().equals("O")){ + if (locMast.getLocSts().equals("O")) { locMast.setLocSts("S"); // S.鍏ュ簱棰勭害 locMast.setModiUser(userId); locMast.setModiTime(now); - if (!locMastService.updateById(locMast)){ + if (!locMastService.updateById(locMast)) { throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�"); } } else { - throw new CoolException(dto.getLocNo()+"鐩爣搴撲綅宸茶鍗犵敤"); + throw new CoolException(dto.getLocNo() + "鐩爣搴撲綅宸茶鍗犵敤"); } return dto.getLocNo(); } @@ -156,27 +159,703 @@ @Override @Transactional public void startupFullTakeStore(StockOutParam param, Long userId) { + List<StockOutParam.LocDetl> locDetls = new ArrayList<>(); + List<String> locs = new ArrayList<>(); + for(StockOutParam.LocDetl one : param.getLocDetls()){ + locs.add(one.getLocNo()); + } + + for (String loc : locs) { + List<LocDetl> detls = locDetlService.selectByLocNo(loc); + for (LocDetl detl : detls) { + for (StockOutParam.LocDetl paramDetls : param.getLocDetls()) { + if (paramDetls.getMatnr().equals(detl.getMatnr()) && paramDetls.getBatch().equals(detl.getBatch()) && paramDetls.getLocNo().equals(detl.getLocNo())) { + locDetls.add(new StockOutParam.LocDetl(detl.getLocNo(), detl.getMatnr(), detl.getBatch(), paramDetls.getCount())); + } + } + + } + } + + // 鐩爣绔欑偣鐘舵�佹娴� BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite()); // 鑾峰彇搴撲綅鏄庣粏 List<LocDetlDto> locDetlDtos = new ArrayList<>(); - for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { + for (StockOutParam.LocDetl paramLocDetl : locDetls) { if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) { LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch()); if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); } } + for (LocDetlDto locDetlDto:locDetlDtos){ + if (locs.contains(locDetlDto.getLocDetl().getLocNo())){ + locDetlDto.setSign(true); + } + } if (!locDetlDtos.isEmpty()) { - // 鍚姩鍑哄簱寮�濮� 101.鍑哄簱 - stockOut(staNo, locDetlDtos, null, userId); + LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetlDtos.get(0).getLocDetl().getLocNo())); + if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D") ){ + // 鍚姩鍑哄簱寮�濮� 101.鍑哄簱 + stockOut2(staNo, locDetlDtos, null, userId); + }else { + throw new CoolException("鎵�閫夊簱浣嶅瓨鍦ㄧ姸鎬佷笉涓篎銆丏鐨勫簱浣嶏紝搴撲綅鍙凤細"+locMast.getLocNo()+" 銆佸綋鍓嶇姸鎬侊細"+locMast.getLocSts()+"-"+locMast.getLocSts$()); + } } else { throw new CoolException("搴撳瓨涓嶅瓨鍦�"); } } + // 澶囦唤涔嬪墠 startupFullTakeStore 鏂规硶 + @Override + @Transactional + public void startupFullTakeStore2(StockOutParam param, Long userId) { + List<StockOutParam.LocDetl> locDetls = new ArrayList<>(); + List<String> locs = new ArrayList<>(); + for(StockOutParam.LocDetl one : param.getLocDetls()){ + locs.add(one.getLocNo()); + } + + List<StockOutParam.LocDetl> stockOutParamLocDetlSort = Utils.getStockOutParamLocDetlSort(param.getLocDetls()); + boolean sign = true; + boolean isfull = false; // 鏄惁澶熸暟閲� + Double isOut = 0.0; + List<String> locNoWeighting = new ArrayList<>(); + for (StockOutParam.LocDetl locDetl : stockOutParamLocDetlSort) { + if (Cools.isEmpty(locNoWeighting)){ + locNoWeighting.add(locDetl.getLocNo()); + }else { + if (!Utils.getLocNoWeighting(locNoWeighting,locDetl.getLocNo())){ + locNoWeighting.add(locDetl.getLocNo()); + sign = true; + } + } + if (sign){ + LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo())); + //鑾峰彇鍚屼竴搴撲綅缁勭殑澶栦晶搴撲綅鍙� + List<String> groupOuterSingleLoc = Utils.getGroupOuterSingleLoc(locDetl.getLocNo()); + if (locMast.getLocType2().equals((short)3)){ + groupOuterSingleLoc = Utils.getGroupOuterSingleLocLowFrequency(locDetl.getLocNo()); + sign = false; + } + for (String locNo : groupOuterSingleLoc) { + //姣忎釜搴撲綅鐨勫簱浣嶆槑缁� + if(locs.contains(locNo)) continue; + LocMast mast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locNo)); + if (mast.getLocSts().equals("P") || mast.getLocSts().equals("Q")){ + throw new CoolException("褰撳墠搴撲綅鐨勬祬搴撲綅鐘舵�佷负" + mast.getLocSts() + "鏆備笉鏀寔鍑哄簱锛�"); + } + for (LocDetl detl : locDetlService.selectByLocNo(locNo)) { + if (!detl.getMatnr().equals(locDetl.getMatnr())) { + //涓嶆槸鐩稿悓鐗╂枡 + if (!sign){ + locDetls.add(new StockOutParam.LocDetl(detl.getLocNo(), detl.getMatnr(), detl.getBatch(), detl.getAnfme())); + } + continue; + } + if (!param.getOutSite().equals(214) && !param.getOutSite().equals(114)){ + if (detl.getAnfme() >= locDetl.getCount()) { + locDetls.add(new StockOutParam.LocDetl(detl.getLocNo(), detl.getMatnr(), detl.getBatch(), locDetl.getCount())); + isOut = locDetl.getCount(); + isfull = true; + break; + } else { + locDetls.add(new StockOutParam.LocDetl(detl.getLocNo(), detl.getMatnr(), detl.getBatch(), detl.getAnfme())); + isOut = detl.getAnfme(); + } + } else { + //寮哄埗涓嶆槸鐩稿悓鐗╂枡 + locDetls.add(new StockOutParam.LocDetl(detl.getLocNo(), detl.getMatnr(), detl.getBatch(), detl.getAnfme())); + } + } + } + } + if (!isfull) { + + locDetls.add(new StockOutParam.LocDetl(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), locDetl.getCount() - isOut)); +// locDetls.add(locDetl); + } + } + //鍑哄簱鏃讹紝濡傛灉褰撳墠搴撲綅缁勬湁鐩稿悓鐨勭墿鏂欙紝鍒欏厛鍑哄渚х墿鏂� 6.30鏃� 娉ㄩ噴 + //for (StockOutParam.LocDetl locDetl : param.getLocDetls()) { + // List<String> outerSingleLoc = Utils.getGroupOuterSingleLoc(locDetl.getLocNo()); + // boolean flag = false; + // Double useCount = 0D; + // for (String locNo : outerSingleLoc) { + // if(locs.contains(locNo)) continue; + // for (LocDetl locDetl0 : locDetlService.selectByLocNo(locNo)) { + // if (!locDetl0.getMatnr().equals(locDetl.getMatnr())) { + // //涓嶆槸鐩稿悓鐗╂枡 + // continue; + // } + // double lastCount = locDetl.getCount() - useCount;//鍓╀綑鎵�闇�鏁伴噺 + // double realCount = 0;//瀹為檯鎻愪緵鏁伴噺 + // if (lastCount==0){ + // continue; + // } + // if (locDetl0.getAnfme() >= lastCount) {//瀹為檯鏁伴噺澶т簬鎵�闇�鏁伴噺锛屾寜鎵�闇�鏁伴噺鎻愪緵 + // realCount = lastCount; + // } else { + // //瀹為檯灏忎簬鎵�闇�鏁伴噺锛屾寜瀹為檯鏁伴噺鎻愪緵 + // realCount = locDetl0.getAnfme(); + // } + // useCount += realCount;//宸蹭娇鐢ㄧ殑鏁伴噺 + // + // locDetls.add(new StockOutParam.LocDetl(locDetl0.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), realCount)); + // flag = true; + // if (useCount >= locDetl.getCount()) { + // //鎵惧埌鐨勫簱瀛� >= 鎵�闇�搴撳瓨锛屾弧瓒虫潯浠� + // break; + // } + // } + // } + // + // if (!flag) { + // locDetls.add(locDetl); + // } + // + //} + + // TODO: 2023/6/28 绛夋潕钖囩‘璁ゆ槸鍚︿娇鐢� + // ---------------------------------------------- + //for(StockOutParam.LocDetl one : param.getLocDetls()){ + // List<String> outerSingleLoc = Utils.getGroupOuterSingleLoc(one.getLocNo()); + // for (String s : outerSingleLoc) { + // if (!locs.contains(s)) { + // throw new CoolException("娴呭簱浣嶆湁鐩稿悓鐗╂枡涓嶆敮鎸佸嚭搴�"); + // } + // } + //} + // ---------------------------------------------- + +// ArrayList<String> locNos = new ArrayList<>(); +// for (StockOutParam.LocDetl locDetl:param.getLocDetls()){ +// if (!locNos.contains(locDetl.getLocNo())){ +// locNos.add(locDetl.getLocNo()); +// } +// } +// List<StockOutParam.LocDetl> locDetls = param.getLocDetls(); + + + +// ArrayList<String> locNos = new ArrayList<>(); +// List<StockOutParam.LocDetl> locDetls = new ArrayList<>(); +// ArrayList<String> matnrs = new ArrayList<>();//鐩殑鍋氭暟鎹幓閲� +// for (StockOutParam.LocDetl locDetl : param.getLocDetls()) { +// if (!matnrs.contains(locDetl.getMatnr())) { +// matnrs.add(locDetl.getMatnr()); +// +// //1.鏍规嵁鐗╂枡鍙峰厛鎼滅储楂橀鍖哄煙鏄惁鏈夊簱瀛� +// List<StockOutParam.LocDetl> locNoStep1 = this.findLocNoStep1(locDetl); +// if (locNoStep1 != null) { +// locDetls.addAll(locNoStep1); +// continue; +// } +// +// //楂橀娣锋斁鍖哄煙娌℃湁婊¤冻鐨勫簱浣嶏紝鍦ㄥ崟鍝佸尯鍩熻繘琛屾悳绱� +// List<StockOutParam.LocDetl> locNoStep2 = this.findLocNoStep2(locDetl); +// if (locNoStep2 != null) { +// locDetls.addAll(locNoStep2); +// continue; +// } +// +// //浣庨娣锋斁鍖哄煙杩涜鎼滅储 +// List<StockOutParam.LocDetl> locNoStep3 = this.findLocNoStep3(locDetl); +// if (locNoStep3 != null) { +// locDetls.addAll(locNoStep3); +// continue; +// } +// +// } +// } +// +// for (StockOutParam.LocDetl locDetl : locDetls) { +// if (!locNos.contains(locDetl.getLocNo())) { +// locNos.add(locDetl.getLocNo()); +// } +// } + +// //妫�娴嬫彁浜ょ殑鍑哄簱搴撲綅鏄惁鍚堟硶(娴呭簱浣嶆湁闈炵┖搴撲綅) +// Utils.checkStockOutLocNo(locNos); + + // 鐩爣绔欑偣鐘舵�佹娴� + BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite()); + // 鑾峰彇搴撲綅鏄庣粏 + List<LocDetlDto> locDetlDtos = new ArrayList<>(); + for (StockOutParam.LocDetl paramLocDetl : locDetls) { + if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) { + LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch()); + if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); + } + } + for (LocDetlDto locDetlDto:locDetlDtos){ + if (locs.contains(locDetlDto.getLocDetl().getLocNo())){ + locDetlDto.setSign(true); + } + } + if (!locDetlDtos.isEmpty()) { + LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetlDtos.get(0).getLocDetl().getLocNo())); + if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D") ){ + // 鍚姩鍑哄簱寮�濮� 101.鍑哄簱 + stockOut2(staNo, locDetlDtos, null, userId); + }else { + throw new CoolException("鎵�閫夊簱浣嶅瓨鍦ㄧ姸鎬佷笉涓篎銆丏鐨勫簱浣嶏紝搴撲綅鍙凤細"+locMast.getLocNo()+" 銆佸綋鍓嶇姸鎬侊細"+locMast.getLocSts()+"-"+locMast.getLocSts$()); + } + } else { + throw new CoolException("搴撳瓨涓嶅瓨鍦�"); + } + } + + //1.鏍规嵁鐗╂枡鍙峰厛鎼滅储楂橀鍖哄煙鏄惁鏈夊簱瀛� + private List<StockOutParam.LocDetl> findLocNoStep1(StockOutParam.LocDetl locDetl) { + List<StockOutParam.LocDetl> locDetlList = new ArrayList<>(); + //1.鏍规嵁鐗╂枡鍙峰厛鎼滅储楂橀鍖哄煙鏄惁鏈夊簱瀛� + List<LocDetl> locDetls = locDetlService.findHighAreaByMatnr(locDetl.getMatnr()); + if (locDetls.size() > 0) { + for (LocDetl locDetl0 : locDetls) { + if (locDetl0.getAnfme() >= locDetl.getCount()) { + //鎵惧埌鐨勫簱瀛� >= 鎵�闇�搴撳瓨锛屾弧瓒虫潯浠� + locDetlList.add(new StockOutParam.LocDetl(locDetl0.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), locDetl.getCount())); + return locDetlList; + } else { + //涓嶆弧瓒冲簱瀛樻潯浠� + //鍒ゆ柇鏈�澶栦晶搴撲綅鐨勬繁澶勬槸鍚︽湁鐩稿悓鐗╂枡 + Double useCount = locDetl0.getAnfme();//宸蹭娇鐢ㄧ殑鏁伴噺 + List<StockOutParam.LocDetl> tmpLocDetlList = new ArrayList<>();//璁板綍缁忚繃鐨勫簱浣� + tmpLocDetlList.add(new StockOutParam.LocDetl(locDetl0.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), locDetl0.getAnfme())); + + List<String> insideLoc = Utils.getGroupInsideLoc(locDetl0.getLocNo()); + List<LocDetl> locDetls1 = locDetlService.selectByLocNosAndMatnr(insideLoc, locDetl.getMatnr()); + if (locDetls1.size() == 0) {//鍐呬晶搴撲綅娌℃湁鐩稿悓鐨勭墿鏂欙紝璺宠繃 + continue; + } + int locRow = Utils.getRow(locDetl0.getLocNo()); + switch (locRow) { + case 3: + case 11: + case 18: + Collections.reverse(locDetls1); + break; + } + for (LocDetl detl : locDetls1) { + double lastCount = locDetl.getCount() - useCount;//鍓╀綑鎵�闇�鏁伴噺 + double realCount = 0;//瀹為檯鎻愪緵鏁伴噺 + if (detl.getAnfme() >= lastCount) {//瀹為檯鏁伴噺澶т簬鎵�闇�鏁伴噺锛屾寜鎵�闇�鏁伴噺鎻愪緵 + realCount = lastCount; + } else { + //瀹為檯灏忎簬鎵�闇�鏁伴噺锛屾寜瀹為檯鏁伴噺鎻愪緵 + realCount = detl.getAnfme(); + } + useCount += realCount; + tmpLocDetlList.add(new StockOutParam.LocDetl(detl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), realCount)); + if (useCount >= locDetl.getCount()) { + //鎵惧埌鐨勫簱瀛� >= 鎵�闇�搴撳瓨锛屾弧瓒虫潯浠� + locDetlList.addAll(tmpLocDetlList); + return locDetlList; + } + } + + } + } + + //鏈�澶栦晶鍖呮嫭鍐呬晶閮芥棤婊¤冻搴撲綅锛屽垯鍒ゆ柇鎼滅储鍑烘潵鐨勫叏閮ㄦ渶澶栦晶搴撲綅鍔犺捣鏉ユ槸鍚︽弧瓒冲嚭搴撴暟閲忚姹� + Double useCount = 0D; + for (LocDetl locDetl0 : locDetls) { + double lastCount = locDetl.getCount() - useCount;//鍓╀綑鎵�闇�鏁伴噺 + double realCount = 0;//瀹為檯鎻愪緵鏁伴噺 + if (locDetl0.getAnfme() >= lastCount) {//瀹為檯鏁伴噺澶т簬鎵�闇�鏁伴噺锛屾寜鎵�闇�鏁伴噺鎻愪緵 + realCount = lastCount; + } else { + //瀹為檯灏忎簬鎵�闇�鏁伴噺锛屾寜瀹為檯鏁伴噺鎻愪緵 + realCount = locDetl0.getAnfme(); + } + useCount += realCount;//宸蹭娇鐢ㄧ殑鏁伴噺 + locDetlList.add(new StockOutParam.LocDetl(locDetl0.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), realCount)); + if (useCount >= locDetl.getCount()) { + //鎵惧埌鐨勫簱瀛� >= 鎵�闇�搴撳瓨锛屾弧瓒虫潯浠� + return locDetlList; + } + } + } + + return null; + } + + //楂橀娣锋斁鍖哄煙娌℃湁婊¤冻鐨勫簱浣嶏紝鍦ㄥ崟鍝佸尯鍩熻繘琛屾悳绱� + private List<StockOutParam.LocDetl> findLocNoStep2(StockOutParam.LocDetl locDetl) { + List<StockOutParam.LocDetl> locDetlList = new ArrayList<>(); + //鍦ㄥ崟鍝佸尯鍩熻繘琛屾悳绱� + List<LocDetl> locDetls = locDetlService.findSingleAreaByMatnr(locDetl.getMatnr()); + if (locDetls.size() > 0) { + Double useCount = 0D; + for (LocDetl locDetl0 : locDetls) { + double lastCount = locDetl.getCount() - useCount;//鍓╀綑鎵�闇�鏁伴噺 + double realCount = 0;//瀹為檯鎻愪緵鏁伴噺 + if (locDetl0.getAnfme() >= lastCount) {//瀹為檯鏁伴噺澶т簬鎵�闇�鏁伴噺锛屾寜鎵�闇�鏁伴噺鎻愪緵 + realCount = lastCount; + } else { + //瀹為檯灏忎簬鎵�闇�鏁伴噺锛屾寜瀹為檯鏁伴噺鎻愪緵 + realCount = locDetl0.getAnfme(); + } + useCount += realCount;//宸蹭娇鐢ㄧ殑鏁伴噺 + + locDetlList.add(new StockOutParam.LocDetl(locDetl0.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), realCount)); + if (useCount >= locDetl.getCount()) { + //鎵惧埌鐨勫簱瀛� >= 鎵�闇�搴撳瓨锛屾弧瓒虫潯浠� + return locDetlList; + } + } + + //搴撳瓨鏁伴噺涓嶆弧瓒� + throw new CoolException("鍗曞搧鍖哄煙鍙湁" + useCount + "涓揣鐗�"); + } + + return null; + } + + //浣庨娣锋斁鍖哄煙杩涜鎼滅储 + private List<StockOutParam.LocDetl> findLocNoStep3(StockOutParam.LocDetl locDetl) { + List<StockOutParam.LocDetl> locDetlList = new ArrayList<>(); + //鍦ㄥ崟鍝佸尯鍩熻繘琛屾悳绱� + List<LocDetl> locDetls = locDetlService.findLowAreaByMatnr(locDetl.getMatnr()); + if (locDetls.size() > 0) { + Double useCount = 0D; + for (LocDetl locDetl0 : locDetls) { + double lastCount = locDetl.getCount() - useCount;//鍓╀綑鎵�闇�鏁伴噺 + double realCount = 0;//瀹為檯鎻愪緵鏁伴噺 + if (locDetl0.getAnfme() >= lastCount) {//瀹為檯鏁伴噺澶т簬鎵�闇�鏁伴噺锛屾寜鎵�闇�鏁伴噺鎻愪緵 + realCount = lastCount; + } else { + //瀹為檯灏忎簬鎵�闇�鏁伴噺锛屾寜瀹為檯鏁伴噺鎻愪緵 + realCount = locDetl0.getAnfme(); + } + useCount += realCount;//宸蹭娇鐢ㄧ殑鏁伴噺 + + locDetlList.add(new StockOutParam.LocDetl(locDetl0.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), realCount)); + if (useCount >= locDetl.getCount()) { + //鎵惧埌鐨勫簱瀛� >= 鎵�闇�搴撳瓨锛屾弧瓒虫潯浠� + return locDetlList; + } + } + } + + return null; + } + @Override @Transactional public void stockOut(BasDevp staNo, List<LocDetlDto> locDetlDtos, IoWorkType ioWorkType, Long userId) { + Integer basDevp = staNo.getDevNo(); + Date now = new Date(); + // 鍚堝苟鍚岀被椤� + Set<String> locNos = new HashSet<>(); + ArrayList<String> locNos2 = new ArrayList<String>(); + List<OutLocDto> dtos = new ArrayList<>(); + for (LocDetlDto locDetlDto : locDetlDtos) { + String locNo = locDetlDto.getLocDetl().getLocNo(); + locNos2.add(locNo); + //if (locNos.contains(locNo)) { + //for (OutLocDto dto : dtos) { + // if (dto.getLocNo().equals(locNo)) { + // dto.getLocDetlDtos().add(locDetlDto); + // break; + // } + //} + //} else { + //locNos.add(locNo); + + //dtos.add(new OutLocDto(locNo, locDetlDto)); + //} + } + List<String> innermostSideLoc = Utils.getInnermostSideLoc(locNos2, true); + System.out.println(innermostSideLoc); + for (LocDetlDto locDetlDto : locDetlDtos) { + String locNo = locDetlDto.getLocDetl().getLocNo(); + if (innermostSideLoc.contains(locNo)) { + if (locNos.contains(locNo)) { + for (OutLocDto dto : dtos) { + if (dto.getLocNo().equals(locNo)) { + dto.getLocDetlDtos().add(locDetlDto); + break; + } + } + } else { + locNos.add(locNo); + dtos.add(new OutLocDto(locNo, locDetlDto)); + } + //dtos.add(new OutLocDto(locNo,locDetlDto)); + } + } + + Integer ioType = null; + List<String> excludeLocNos = dtos.stream().map(OutLocDto::getLocNo).distinct().collect(Collectors.toList()); + // 鐢熸垚宸ヤ綔妗� + for (OutLocDto dto : dtos) { + // 濡傛灉涓烘繁搴撲綅锛屼笖瀵瑰簲娴呭簱浣嶄负X.绂佺敤锛屽垯鐣ヨ繃姝ゅ簱浣� + if (Utils.isDeepLoc(slaveProperties, dto.getLocNo())) { + String shallowLoc = Utils.getShallowLoc(slaveProperties, dto.getLocNo()); + if (locMastService.selectById(shallowLoc).getLocSts().equals("X")) { + continue; + } + } + + //-----------------2023.5.31涓婃灦鍖哄煙鐗堟湰鍏煎浠g爜----------------------- + //鍒ゆ柇褰撳墠搴撲綅缁勬槸鍚﹀潎涓哄悓涓�绉嶇墿鏂欙紝濡備笉鏄紝鍒欒瀹氶渶瑕佹墽琛屽吋瀹逛唬鐮� + //闇�瑕佸皢寰呭嚭搴撳簱浣嶅墠渚у簱浣�(涓嶅寘鍚渶澶栦晶楂橀搴撲綅)鎵ц101鍏ㄦ澘鍑哄簱 + String locNo = dto.getLocNo(); + String matnr = null; + for (LocDetlDto locDetlDto : dto.getLocDetlDtos()) { + LocDetl locDetl = locDetlDto.getLocDetl(); + if (locDetl.getLocNo().equals(locNo)) { + matnr = locDetl.getMatnr(); + } + } + + List<String> outerLocs = Utils.getGroupOuterSingleLoc(locNo); + LocMast locMast1 = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", dto.getLocNo())); + if (locMast1.getLocType2().equals((short) 3)) { + outerLocs = Utils.getGroupOuterSingleLocLowFrequency(locMast1.getLocNo()); + } + Double wrkPri = 15D; + for (String outerLoc : outerLocs) { + LocMast locMast = locMastService.selectById(outerLoc); + if (locMast == null) { + continue; + } + + if (!locMast.getLocSts().equals("F")) { + continue; + } + //if (locMast.getLocSts().equals("F")) { + // throw new CoolException("娴呭簱浣嶅湪搴撲笉鏀寔姝や换鍔�"); + //} + boolean flag = false; + for (LocDetl locDetl : locDetlService.selectByLocNo(locMast.getLocNo())) { + if (!locDetl.getMatnr().equals(matnr)) { + flag = true; + break; + } else if (!Cools.isEmpty(ioWorkType) && ioWorkType.equals(IoWorkType.CHECK_OUT)) { + flag = true; + break; + } + } + + if (flag) { + //褰撳墠宸烽亾瀛樺湪涓嶅悓瑙勬牸鐨勭墿鏂欙紝闇�瑕佽繘琛�101鍏ㄦ澘鍑哄簱 + // 鑾峰彇璺緞 + StaDesc staDesc = staDescService.queryCrnStn(101, locMast.getCrnNo(), locMast.getCrnNo() == 1 ? 100 : 200, locMast.getRow1()); + if (staDesc == null) { + throw new CoolException("鍑哄簱璺緞涓嶅瓨鍦�"); + } + + // 鐢熸垚宸ヤ綔鍙� + int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(101)); + // 鐢熸垚宸ヤ綔妗� + WrkMast wrkMast = new WrkMast(); + wrkMast.setWrkNo(workNo); + wrkMast.setIoTime(now); + wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID + wrkMast.setIoType(101); // 鍏ュ嚭搴撶姸鎬�101鍏ㄦ澘鍑哄簱 + wrkPri += 2D; + + wrkMast.setIoPri(Utils.getIoPri(locMast.getLocNo())); // 浼樺厛绾� + wrkMast.setOutMost(0); + wrkMast.setCrnNo(locMast.getCrnNo()); + wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯 + wrkMast.setStaNo(locMast.getCrnNo() == 1 ? 100 : 200); // 鐩爣绔� + wrkMast.setSourceLocNo(locMast.getLocNo()); // 婧愬簱浣� + wrkMast.setFullPlt("Y"); // 婊℃澘锛歒 + wrkMast.setPicking("N"); // 鎷f枡 + wrkMast.setExitMk("N"); // 閫�鍑� + wrkMast.setEmptyMk("N"); // 绌烘澘 + wrkMast.setLinkMis("N"); + wrkMast.setBarcode(locMast.getBarcode()); + wrkMast.setAppeUser(userId); // 鎿嶄綔浜哄憳鏁版嵁 + wrkMast.setAppeTime(now); + wrkMast.setModiUser(userId); + wrkMast.setModiTime(now); + if (!wrkMastService.insert(wrkMast)) { + throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鍑哄簱搴撲綅鍙凤細" + dto.getLocNo()); + } + // 鐢熸垚宸ヤ綔妗f槑缁� + for (LocDetl locDetl : locDetlService.selectByLocNo(locMast.getLocNo())) { + WrkDetl wrkDetl = new WrkDetl(); + wrkDetl.sync(locDetl); + wrkDetl.setOrderNo(""); // 鎵嬪姩鍑哄簱涓嶉渶瑕佸甫鍑哄簱瀛樹腑鐨勫崟鎹紪鍙� + wrkDetl.setWrkNo(workNo); + wrkDetl.setIoTime(now); + wrkDetl.setAnfme(locDetl.getAnfme()); // 鏁伴噺 + wrkDetl.setAppeTime(now); + wrkDetl.setAppeUser(userId); + wrkDetl.setModiTime(now); + wrkDetl.setModiUser(userId); + wrkDetl.setSpecs(locDetl.getSpecs()); + wrkDetl.setMatType(locDetl.getMatType()); + wrkDetl.setZpallet(locMast.getBarcode()); + if (!wrkDetlService.insert(wrkDetl)) { + throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); + } + + Mat mat = matService.selectByMatnr(locDetl.getMatnr()); + if (Cools.isEmpty(mat)) { + throw new CoolException(locDetl.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�"); + } + int zpallet = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", locDetl.getZpallet()).ne("loc_no", locDetl.getLocNo())); + if (zpallet > 0) { + throw new CoolException(locDetl.getZpallet() + "鍏ュ簱閫氱煡妗d腑宸插瓨鍦�"); + } + WaitPakin waitPakin = new WaitPakin(); + waitPakin.sync(mat); + waitPakin.setBatch(""); + waitPakin.setZpallet(locMast.getBarcode()); // 鎵樼洏鐮� + waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵�� + waitPakin.setAnfme(locDetl.getAnfme()); // 鏁伴噺 + waitPakin.setStatus("Y"); // 鐘舵�� + waitPakin.setAppeUser(userId); + waitPakin.setAppeTime(now); + waitPakin.setModiUser(userId); + waitPakin.setModiTime(now); + waitPakin.setMemo(locDetl.getMemo()); + waitPakin.setFrozen(0); // 鏄惁鍐荤粨 + waitPakin.setManu(locDetl.getManu()); + waitPakin.setMatType(mat.getMatType());//鐗╂枡绫诲瀷 + if (!waitPakinService.insert(waitPakin)) { + throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); + } + } + // 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害 + if (locMast.getLocSts().equals("F")) { + locMast.setLocSts("R"); + locMast.setModiUser(userId); + locMast.setModiTime(now); + if (!locMastService.updateById(locMast)) { + throw new CoolException("棰勭害搴撲綅鐘舵�佸け璐ワ紝搴撲綅鍙凤細" + dto.getLocNo()); + } + } else { + throw new CoolException(dto.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��"); + } + } + + } + //-----------------2023.5.31涓婃灦鍖哄煙鐗堟湰鍏煎浠g爜end----------------------- + + // 鍒ゆ柇鍏ュ嚭搴撶被鍨嬶細101.鍏ㄦ澘鍑哄簱 or 103.鎷f枡鍑哄簱 + if (ioWorkType == null) { + ioType = dto.isAll() ? 101 : 103; + } else if (ioWorkType.equals(IoWorkType.CHECK_OUT)) { + ioType = 107; + // if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 107)) > 0) { + // throw new CoolException("鍙兘瀛樺湪涓�绗旂洏鐐逛换鍔�"); + // } + } + assert ioType != null; + // 鑾峰彇搴撲綅 + LocMast locMast = locMastService.selectById(dto.getLocNo()); + + //-----------------2023.6.2鍑哄簱鍏煎浠g爜----------------------- + if (ioType != 107) { + List<LocDetl> locDetls = locDetlService.selectByLocNo(locMast.getLocNo()); + //if (locMast.getLocType2() == 1 && locDetls.size() > 1) { + // //鍗曞搧鍖哄煙鍑哄簱鐗╂枡澶т簬1绉嶏紝寮哄埗鍙樻垚101鍏ㄦ澘鍑哄簱 + // ioType = 101; + // if (staNo.getDevNo()==300){ + // staNo.setDevNo(200); + // } + //} + if (ioType == 101) { + if (staNo.getDevNo() == 300) { + if (locMast.getCrnNo() == 1) { + staNo.setDevNo(100); + } else { + staNo.setDevNo(200); + } + + } + } else { + staNo.setDevNo(basDevp); + } + + + } + //-----------------2023.6.2鍑哄簱鍏煎浠g爜end----------------------- + + // 鑾峰彇璺緞 + StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), staNo.getDevNo(), locMast.getRow1()); + if (staDesc == null) { + throw new CoolException("鍑哄簱璺緞涓嶅瓨鍦�"); + } + + // 鐢熸垚宸ヤ綔鍙� + int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); + // 鐢熸垚宸ヤ綔妗� + WrkMast wrkMast = new WrkMast(); + wrkMast.setWrkNo(workNo); + wrkMast.setIoTime(now); + wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID + wrkMast.setIoType(ioType); // 鍏ュ嚭搴撶姸鎬� + Double ioPri = wrkMastService.getIoPri(ioType, dto.getLocNo()); + wrkMast.setIoPri(15D); // 浼樺厛绾э細13 + wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo(), false) ? 1 : 0); + wrkMast.setCrnNo(locMast.getCrnNo()); + wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯 + wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔� + wrkMast.setSourceLocNo(dto.getLocNo()); // 婧愬簱浣� + wrkMast.setFullPlt("Y"); // 婊℃澘锛歒 + wrkMast.setPicking("N"); // 鎷f枡 + wrkMast.setExitMk("N"); // 閫�鍑� + wrkMast.setEmptyMk("N"); // 绌烘澘 + wrkMast.setLinkMis("N"); + wrkMast.setBarcode(locMast.getBarcode()); + wrkMast.setAppeUser(userId); // 鎿嶄綔浜哄憳鏁版嵁 + wrkMast.setAppeTime(now); + wrkMast.setModiUser(userId); + wrkMast.setModiTime(now); + if (!wrkMastService.insert(wrkMast)) { + throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鍑哄簱搴撲綅鍙凤細" + dto.getLocNo()); + } + // 鐢熸垚宸ヤ綔妗f槑缁� + for (LocDetlDto detlDto : dto.getLocDetlDtos()) { + if (detlDto.getCount() == null || detlDto.getCount() <= 0.0D) { + continue; + } + WrkDetl wrkDetl = new WrkDetl(); + wrkDetl.sync(detlDto.getLocDetl()); + wrkDetl.setOrderNo(""); // 鎵嬪姩鍑哄簱涓嶉渶瑕佸甫鍑哄簱瀛樹腑鐨勫崟鎹紪鍙� + wrkDetl.setWrkNo(workNo); + wrkDetl.setIoTime(now); + Double anfme = ioType == 101 ? detlDto.getLocDetl().getAnfme() : detlDto.getCount(); + wrkDetl.setAnfme(anfme); // 鏁伴噺 + wrkDetl.setAppeTime(now); + wrkDetl.setAppeUser(userId); + wrkDetl.setModiTime(now); + wrkDetl.setModiUser(userId); + wrkDetl.setSpecs(detlDto.getLocDetl().getSpecs()); + wrkDetl.setMatType(detlDto.getLocDetl().getMatType()); + wrkDetl.setZpallet(locMast.getBarcode()); + if (!wrkDetlService.insert(wrkDetl)) { + throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); + } + } + // 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓� + locMast = locMastService.selectById(dto.getLocNo()); + if (locMast.getLocSts().equals("F")) { + locMast.setLocSts(ioType == 101 ? "R" : "P"); + locMast.setModiUser(userId); + locMast.setModiTime(now); + if (!locMastService.updateById(locMast)) { + throw new CoolException("棰勭害搴撲綅鐘舵�佸け璐ワ紝搴撲綅鍙凤細" + dto.getLocNo()); + } + } else { + throw new CoolException(dto.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��"); + } +// locMastService.breakUp(dto.getLocNo(), excludeLocNos); + } + } + + @Override + @Transactional + public void stockOut2(BasDevp staNo, List<LocDetlDto> locDetlDtos, IoWorkType ioWorkType, Long userId) { + Integer basDevp = staNo.getDevNo(); Date now = new Date(); // 鍚堝苟鍚岀被椤� Set<String> locNos = new HashSet<>(); @@ -186,8 +865,18 @@ if (locNos.contains(locNo)) { for (OutLocDto dto : dtos) { if (dto.getLocNo().equals(locNo)) { - dto.getLocDetlDtos().add(locDetlDto); - break; + boolean signDto = false; + for (LocDetlDto locDetlDto1 : dto.getLocDetlDtos()) { + if (locDetlDto1.getLocDetl().getBatch().equals(locDetlDto.getLocDetl().getBatch()) + && locDetlDto1.getLocDetl().getMatnr().equals(locDetlDto.getLocDetl().getMatnr()) + && locDetlDto1.getLocDetl().getLocNo().equals(locDetlDto.getLocDetl().getLocNo())) { + signDto = true; + } + } + if (!signDto) { + dto.getLocDetlDtos().add(locDetlDto); + break; + } } } } else { @@ -205,18 +894,128 @@ continue; } } + //-----------------2023.5.31涓婃灦鍖哄煙鐗堟湰鍏煎浠g爜----------------------- + //鍒ゆ柇褰撳墠搴撲綅缁勬槸鍚﹀潎涓哄悓涓�绉嶇墿鏂欙紝濡備笉鏄紝鍒欒瀹氶渶瑕佹墽琛屽吋瀹逛唬鐮� + //闇�瑕佸皢寰呭嚭搴撳簱浣嶅墠渚у簱浣�(涓嶅寘鍚渶澶栦晶楂橀搴撲綅)鎵ц101鍏ㄦ澘鍑哄簱 + String locNo = dto.getLocNo(); + String matnr = null; + for (LocDetlDto locDetlDto : dto.getLocDetlDtos()) { + LocDetl locDetl = locDetlDto.getLocDetl(); + if (locDetl.getLocNo().equals(locNo)) { + matnr = locDetl.getMatnr(); + } + } + + List<String> outerLocs = new ArrayList<>(); + if (!dto.isSign()) { + outerLocs.add(dto.getLocNo()); + } + Double wrkPri = 15D; + for (String outerLoc : outerLocs) { + if (!dto.isSign()) { + // 鐢熸垚宸ヤ綔妗f槑缁� + for (LocDetl locDetl : locDetlService.selectByLocNo(outerLoc)) { + + Mat mat = matService.selectByMatnr(locDetl.getMatnr()); + if (Cools.isEmpty(mat)) { + throw new CoolException(locDetl.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�"); + } + int zpallet = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", locDetl.getZpallet()).ne("loc_no", locDetl.getLocNo())); + if (zpallet > 0) { + throw new CoolException(locDetl.getZpallet() + "鍏ュ簱閫氱煡妗d腑宸插瓨鍦�"); + } + WaitPakin waitPakin = new WaitPakin(); + waitPakin.sync(mat); + //waitPakin.setBatch(""); + waitPakin.setZpallet(locDetl.getZpallet()); // 鎵樼洏鐮� + waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵�� + waitPakin.setAnfme(locDetl.getAnfme()); // 鏁伴噺 + waitPakin.setStatus("Y"); // 鐘舵�� + waitPakin.setAppeUser(userId); + waitPakin.setAppeTime(now); + waitPakin.setModiUser(userId); + waitPakin.setModiTime(now); + waitPakin.setMemo(locDetl.getMemo()); + waitPakin.setFrozen(0); // 鏄惁鍐荤粨 + waitPakin.setManu(locDetl.getManu()); + waitPakin.setMatType(mat.getMatType());//鐗╂枡绫诲瀷 + if (!waitPakinService.insert(waitPakin)) { + throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); + } + } + } + } + //-----------------2023.5.31涓婃灦鍖哄煙鐗堟湰鍏煎浠g爜end----------------------- // 鍒ゆ柇鍏ュ嚭搴撶被鍨嬶細101.鍏ㄦ澘鍑哄簱 or 103.鎷f枡鍑哄簱 if (ioWorkType == null) { ioType = dto.isAll() ? 101 : 103; } else if (ioWorkType.equals(IoWorkType.CHECK_OUT)) { ioType = 107; + // if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 107)) > 0) { + // throw new CoolException("鍙兘瀛樺湪涓�绗旂洏鐐逛换鍔�"); + // } } + if (ioType != 101) { + if (basDevp == 114 || basDevp == 214) { + throw new CoolException("2妤煎彧鍏佽鍏ㄦ澘鍑哄簱锛岃閫夋嫨鍏ㄩ儴鐗╂枡"); + } + } + assert ioType != null; // 鑾峰彇搴撲綅 LocMast locMast = locMastService.selectById(dto.getLocNo()); + + //-----------------2023.6.2鍑哄簱鍏煎浠g爜----------------------- + if (ioType != 107) { + List<LocDetl> locDetls = locDetlService.selectByLocNo(locMast.getLocNo()); + //if (locMast.getLocType2() == 1 && locDetls.size() > 1) { + // //鍗曞搧鍖哄煙鍑哄簱鐗╂枡澶т簬1绉嶏紝寮哄埗鍙樻垚101鍏ㄦ澘鍑哄簱 + // ioType = 101; + // if (staNo.getDevNo()==300){ + // staNo.setDevNo(200); + // } + //} + if (ioType == 101) { + if (basDevp == 300) { + if (locMast.getCrnNo() == 1) { + staNo.setDevNo(100); + } else { + staNo.setDevNo(200); + } + } else if (basDevp == 114) { + if (!dto.isSign()) { + staNo.setDevNo(100); + } else { + staNo.setDevNo(basDevp); + } + } else if (basDevp == 214) { + if (!dto.isSign()) { + staNo.setDevNo(200); + } else { + staNo.setDevNo(basDevp); + } + } else { + if (locMast.getCrnNo() == 1) { + staNo.setDevNo(100); + } else { + staNo.setDevNo(200); + } + } + } else { + staNo.setDevNo(basDevp); + } + + + } + //-----------------2023.6.2鍑哄簱鍏煎浠g爜end----------------------- + // 鑾峰彇璺緞 - StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), staNo.getDevNo()); + StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), staNo.getDevNo(), locMast.getRow1()); + if (staDesc == null) { + throw new CoolException("鍑哄簱璺緞涓嶅瓨鍦�"); + } + // 鐢熸垚宸ヤ綔鍙� int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); // 鐢熸垚宸ヤ綔妗� @@ -225,8 +1024,9 @@ wrkMast.setIoTime(now); wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID wrkMast.setIoType(ioType); // 鍏ュ嚭搴撶姸鎬� - wrkMast.setIoPri(13D); // 浼樺厛绾э細13 - wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo(), false)?1:0);; + Double ioPri = wrkMastService.getIoPri(ioType, dto.getLocNo()); + wrkMast.setIoPri(15D); // 浼樺厛绾э細13 + wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo(), false) ? 1 : 0); wrkMast.setCrnNo(locMast.getCrnNo()); wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯 wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔� @@ -242,38 +1042,51 @@ wrkMast.setModiUser(userId); wrkMast.setModiTime(now); if (!wrkMastService.insert(wrkMast)) { - throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鍑哄簱搴撲綅鍙凤細"+dto.getLocNo()); + throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鍑哄簱搴撲綅鍙凤細" + dto.getLocNo()); + } else { + log.info("鍑哄簱鎻掑叆宸ヤ綔涓绘。鎴愬姛===>>" + JSON.toJSONString(wrkMast)); } + // 鐢熸垚宸ヤ綔妗f槑缁� + for (LocDetlDto detlDto : dto.getLocDetlDtos()) { - if (detlDto.getCount()==null || detlDto.getCount() <= 0.0D) {continue;} + log.info("寮�濮嬫彃鍏ュ伐浣滄槑缁�===>>宸ヤ綔鍙凤細" + workNo + "鏄庣粏锛�" + JSON.toJSONString(detlDto)); + if (detlDto.getCount() == null || detlDto.getCount() <= 0.0D) { + continue; + } WrkDetl wrkDetl = new WrkDetl(); wrkDetl.sync(detlDto.getLocDetl()); wrkDetl.setOrderNo(""); // 鎵嬪姩鍑哄簱涓嶉渶瑕佸甫鍑哄簱瀛樹腑鐨勫崟鎹紪鍙� wrkDetl.setWrkNo(workNo); wrkDetl.setIoTime(now); - Double anfme = ioType==101?detlDto.getLocDetl().getAnfme():detlDto.getCount(); + Double anfme = ioType == 101 ? detlDto.getLocDetl().getAnfme() : detlDto.getCount(); wrkDetl.setAnfme(anfme); // 鏁伴噺 wrkDetl.setAppeTime(now); wrkDetl.setAppeUser(userId); wrkDetl.setModiTime(now); wrkDetl.setModiUser(userId); + wrkDetl.setSpecs(detlDto.getLocDetl().getSpecs()); + wrkDetl.setMatType(detlDto.getLocDetl().getMatType()); + wrkDetl.setZpallet(locMast.getBarcode()); if (!wrkDetlService.insert(wrkDetl)) { - throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); + throw new CoolException("stockOut2锛氫繚瀛樺伐浣滄。鏄庣粏澶辫触===>>" + JSON.toJSONString(wrkDetl)); + } else { + log.info("鍑哄簱鎻掑叆宸ヤ綔鏄庣粏鎴愬姛===>>" + JSON.toJSONString(wrkDetl)); } } // 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓� locMast = locMastService.selectById(dto.getLocNo()); if (locMast.getLocSts().equals("F")) { - locMast.setLocSts(ioType==101?"R":"P"); + locMast.setLocSts(ioType == 101 ? "R" : "P"); locMast.setModiUser(userId); locMast.setModiTime(now); if (!locMastService.updateById(locMast)) { - throw new CoolException("棰勭害搴撲綅鐘舵�佸け璐ワ紝搴撲綅鍙凤細"+dto.getLocNo()); + throw new CoolException("棰勭害搴撲綅鐘舵�佸け璐ワ紝搴撲綅鍙凤細" + dto.getLocNo()); } } else { throw new CoolException(dto.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��"); } +// locMastService.breakUp(dto.getLocNo(), excludeLocNos); } } @@ -281,6 +1094,54 @@ @Transactional public void stockOut(BasDevp staNo, TaskDto taskDto, Long userId) { Date now = new Date(); + if (Cools.isEmpty(taskDto.getLocDtos()) || taskDto.getLocDtos().size() == 0) { + // 鑾峰彇搴撲綅 + LocMast locMast = locMastService.selectById(taskDto.getLocNo()); + // 鑾峰彇璺緞 + int ioType = locMast.getLocSts().equals("D") ? 110 : 101; + StaDesc staDesc = staDescService.queryCrnStnAuto(ioType, locMast.getCrnNo(), staNo.getDevNo()); + // 鐢熸垚宸ヤ綔鍙� + int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); + // 鐢熸垚宸ヤ綔妗� + WrkMast wrkMast = new WrkMast(); + wrkMast.setWrkNo(workNo); + wrkMast.setIoTime(now); + wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID + wrkMast.setIoType(ioType); // 鍏ュ嚭搴撶姸鎬� + Double ioPri = wrkMastService.getIoPri(ioType, taskDto.getLocNo()); + wrkMast.setIoPri(ioPri); // 浼樺厛绾э細13 + wrkMast.setOutMost(locMastService.isOutMost(taskDto.getLocNo(), false) ? 1 : 0); + wrkMast.setCrnNo(locMast.getCrnNo()); + wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯 + wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔� + wrkMast.setSourceLocNo(taskDto.getLocNo()); // 婧愬簱浣� + wrkMast.setFullPlt(ioType == 110 ? "N" : "Y"); // 婊℃澘锛歒 + wrkMast.setPicking("N"); // 鎷f枡 + wrkMast.setExitMk("N"); // 閫�鍑� + wrkMast.setEmptyMk(ioType == 110 ? "Y" : "N"); // 绌烘澘 + wrkMast.setLinkMis("N"); + wrkMast.setBarcode(locMast.getBarcode()); + wrkMast.setAppeUser(userId); // 鎿嶄綔浜哄憳鏁版嵁 + wrkMast.setAppeTime(now); + wrkMast.setModiUser(userId); + wrkMast.setModiTime(now); + if (!wrkMastService.insert(wrkMast)) { + throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鍑哄簱搴撲綅鍙凤細" + taskDto.getLocNo()); + } + // 淇敼搴撲綅鐘舵��: F銆丏.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓� + locMast = locMastService.selectById(taskDto.getLocNo()); + if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D")) { + locMast.setLocSts("R"); + locMast.setModiUser(userId); + locMast.setModiTime(now); + if (!locMastService.updateById(locMast)) { + throw new CoolException("棰勭害搴撲綅鐘舵�佸け璐ワ紝搴撲綅鍙凤細" + taskDto.getLocNo()); + } + } else { + throw new CoolException(taskDto.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��"); + } + return; + } List<LocDto> locDtos = taskDto.getLocDtos(); for (LocDto locDto : locDtos) { if (!taskDto.getLocNo().equals(locDto.getLocNo()) && !taskDto.getStaNo().equals(locDto.getStaNo())) { @@ -300,8 +1161,9 @@ wrkMast.setIoTime(now); wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID wrkMast.setIoType(ioType); // 鍏ュ嚭搴撶姸鎬� - wrkMast.setIoPri(13D); // 浼樺厛绾э細13 - wrkMast.setOutMost(locMastService.isOutMost(taskDto.getLocNo(), false)?1:0);; + Double ioPri = wrkMastService.getIoPri(ioType, taskDto.getLocNo()); + wrkMast.setIoPri(ioPri); // 浼樺厛绾э細13 + wrkMast.setOutMost(locMastService.isOutMost(taskDto.getLocNo(), false) ? 1 : 0); wrkMast.setCrnNo(locMast.getCrnNo()); wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯 wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔� @@ -317,21 +1179,21 @@ wrkMast.setModiUser(userId); wrkMast.setModiTime(now); if (!wrkMastService.insert(wrkMast)) { - throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鍑哄簱搴撲綅鍙凤細"+taskDto.getLocNo()); + throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鍑哄簱搴撲綅鍙凤細" + taskDto.getLocNo()); } // 鐢熸垚宸ヤ綔妗f槑缁� for (LocDto locDto : taskDto.getLocDtos()) { - if (locDto.getAnfme()==null || locDto.getAnfme() <= 0.0D) { continue; } - OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch()); - if (orderDetl == null) { - orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null); + if (locDto.getAnfme() == null || locDto.getAnfme() <= 0.0D) { + continue; } LocDetl locDetl = locDetlService.selectItem(locDto.getLocNo(), locDto.getMatnr(), locDto.getBatch()); if (locDetl == null || locDetl.getAnfme() < locDto.getAnfme()) { throw new CoolException(locDto.getLocNo() + "搴撲綅涓�" + locDto.getMatnr() + "鍟嗗搧搴撳瓨涓嶈冻锛�"); } + Mat mat = matService.selectByMatnr(locDto.getMatnr()); + assert mat != null; WrkDetl wrkDetl = new WrkDetl(); - wrkDetl.sync(orderDetl); + wrkDetl.sync(mat); wrkDetl.setZpallet(wrkMast.getBarcode()); wrkDetl.setIoTime(now); wrkDetl.setWrkNo(workNo); @@ -342,27 +1204,127 @@ wrkDetl.setAppeUser(userId); wrkDetl.setModiTime(now); wrkDetl.setModiUser(userId); + wrkDetl.setMatType(locDetl.getMatType()); if (!wrkDetlService.insert(wrkDetl)) { throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); } - // 淇敼璁㈠崟鏄庣粏 - if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme())) { - throw new CoolException("淇敼璁㈠崟鏄庣粏鏁伴噺澶辫触"); + if (!wrkDetl.getOrderNo().equals("浼寸敓鍑哄簱")) { + // 淇敼璁㈠崟鏄庣粏 + if (!BaseController.isJSON(locDto.getOrderNo())) { + String[] orderNos = GetOrderNo(locDto.getOrderNo()); + if (!Cools.isEmpty(orderNos) && orderNos.length != 0) { + Double anfme = locDto.getAnfme(); + for (String orderNo : orderNos) { + OrderDetl orderDetl = orderDetlService.selectItem(orderNo, locDto.getMatnr(), locDto.getBatch()); + if (orderDetl == null) { + orderDetl = orderDetlService.selectItem(orderNo, locDto.getMatnr(), null); + } + if (orderDetl.getAnfme() <= anfme) { + if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getAnfme())) { + throw new CoolException("淇敼璁㈠崟鏄庣粏鏁伴噺澶辫触"); + } + anfme = anfme - orderDetl.getAnfme(); + } else { + if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), anfme)) { + throw new CoolException("淇敼璁㈠崟鏄庣粏鏁伴噺澶辫触"); + } + } + orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); + } + } else { + OrderDetl orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch()); + if (orderDetl == null) { + orderDetl = orderDetlService.selectItem(locDto.getOrderNo(), locDto.getMatnr(), null); + } + if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), locDto.getAnfme())) { + throw new CoolException("淇敼璁㈠崟鏄庣粏鏁伴噺澶辫触"); + } + orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); + } + } else { + // 璁㈠崟鍚堝苟鍑哄簱 + List<OrderDto> orderDtoList = JSON.parseArray(locDto.getOrderNo(), OrderDto.class); + + for (OrderDto orderDto : orderDtoList) { + OrderDetl orderDetl = orderDetlService.selectItem(orderDto.getOrderNo(), locDto.getMatnr(), locDto.getBatch()); + if (orderDetl == null) { + orderDetl = orderDetlService.selectItem(orderDto.getOrderNo(), locDto.getMatnr(), null); + } + if (!orderDetlService.increase(orderDetl.getOrderId(), orderDetl.getMatnr(), orderDetl.getBatch(), orderDto.getAnfme())) { + throw new CoolException("淇敼璁㈠崟鏄庣粏鏁伴噺澶辫触"); + } + orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); + } + } + } else {//鑷姩缁勬墭 + WaitPakin waitPakin = new WaitPakin(); + waitPakin.sync(mat); + waitPakin.setBatch(wrkDetl.getBatch()); + waitPakin.setZpallet(wrkDetl.getZpallet()); // 鎵樼洏鐮� + waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵�� + waitPakin.setAnfme(wrkDetl.getAnfme()); // 鏁伴噺 + waitPakin.setStatus("Y"); // 鐘舵�� + waitPakin.setAppeUser(userId); + waitPakin.setAppeTime(now); + waitPakin.setModiUser(userId); + waitPakin.setModiTime(now); + waitPakin.setMemo(wrkDetl.getMemo()); + waitPakin.setFrozen(wrkDetl.getFrozen()); // 鏄惁鍐荤粨 + waitPakin.setManu(wrkDetl.getManu()); + waitPakin.setMatType(mat.getMatType());//鐗╂枡绫诲瀷 + if (!waitPakinService.insert(waitPakin)) { + throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�"); + } } - orderService.updateSettle(orderDetl.getOrderId(), 2L, userId); } // 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓� locMast = locMastService.selectById(taskDto.getLocNo()); if (locMast.getLocSts().equals("F")) { - locMast.setLocSts(ioType==101?"R":"P"); + locMast.setLocSts(ioType == 101 ? "R" : "P"); locMast.setModiUser(userId); locMast.setModiTime(now); if (!locMastService.updateById(locMast)) { - throw new CoolException("棰勭害搴撲綅鐘舵�佸け璐ワ紝搴撲綅鍙凤細"+taskDto.getLocNo()); + throw new CoolException("棰勭害搴撲綅鐘舵�佸け璐ワ紝搴撲綅鍙凤細" + taskDto.getLocNo()); } } else { throw new CoolException(taskDto.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��"); } + } + + private String[] GetOrderNo(String orderNo) { + String[] s3 = orderNo.split("\""); + String[] s = new String[(s3.length - 1) / 6]; + if (!Cools.isEmpty(s3)) { + int i = 0; + int j = 0; + for (String ss : s3) { + if (ss.equals("orderNo")) { + s[i] = s3[j + 2]; + i++; + } + j++; + } + } else { + s = null; + } + return s; + } + + private String[] GetAnfme(String orderNo) { + String[] s3 = orderNo.split("\""); + String[] s = new String[(s3.length - 1) / 6]; + int i = 0; + int j = 0; + for (String ss : s3) { + if (ss.equals("anfme")) { + String[] s4 = s3[j + 1].split(":"); + String[] s5 = s4[1].split("\\."); + s[i] = s5[0]; + i++; + } + j++; + } + return s; } @Override @@ -380,8 +1342,9 @@ wrkMast.setIoTime(new Date()); wrkMast.setWrkSts(1L); // 宸ヤ綔鐘舵�侊細鐢熸垚鍏ュ簱ID wrkMast.setIoType(10); // 鍏ュ嚭搴撶姸鎬侊細10.绌烘澘鍏ュ簱 - wrkMast.setIoPri(10D); // 浼樺厛绾э細10 - wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo(), true)?1:0);; + Double ioPri = wrkMastService.getIoPri(10, dto.getLocNo()); + wrkMast.setIoPri(ioPri); // 浼樺厛绾э細10 + wrkMast.setOutMost(locMastService.isOutMost(dto.getLocNo(), true) ? 1 : 0); wrkMast.setCrnNo(dto.getCrnNo()); wrkMast.setSourceStaNo(dto.getSourceStaNo()); wrkMast.setStaNo(dto.getStaNo()); @@ -405,20 +1368,20 @@ sourceStaNo.setWrkNo(workNo); sourceStaNo.setModiUser(userId); sourceStaNo.setModiTime(new Date()); - if (!basDevpService.updateById(sourceStaNo)){ + if (!basDevpService.updateById(sourceStaNo)) { throw new CoolException("鏇存柊婧愮珯澶辫触"); } // 鏇存柊鐩爣搴撲綅鐘舵�� LocMast locMast = locMastService.selectById(dto.getLocNo()); - if (locMast.getLocSts().equals("O")){ + if (locMast.getLocSts().equals("O")) { locMast.setLocSts("S"); // S.鍏ュ簱棰勭害 locMast.setModiUser(userId); locMast.setModiTime(new Date()); - if (!locMastService.updateById(locMast)){ + if (!locMastService.updateById(locMast)) { throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�"); } } else { - throw new CoolException(dto.getLocNo()+"鐩爣搴撲綅宸茶鍗犵敤"); + throw new CoolException(dto.getLocNo() + "鐩爣搴撲綅宸茶鍗犵敤"); } return dto.getLocNo(); } @@ -442,7 +1405,10 @@ // 鑾峰彇搴撲綅 LocMast locMast = locMastService.selectById(locNo); if (Cools.isEmpty(locMast)) { - throw new CoolException(locNo+"搴撲綅涓嶅瓨鍦�"); + throw new CoolException(locNo + "搴撲綅涓嶅瓨鍦�"); + } + if (!locMast.getLocSts().equals("D")) { + throw new CoolException("鎵�閫夊簱浣嶅瓨鍦ㄧ姸鎬佷笉涓篋鐨勫簱浣嶏紝搴撲綅鍙凤細" + locMast.getLocNo() + " 銆佸綋鍓嶇姸鎬侊細" + locMast.getLocSts() + "-" + locMast.getLocSts$()); } // 鑾峰彇婧愮珯 Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() @@ -450,6 +1416,9 @@ .eq("stn_no", param.getOutSite()) .eq("crn_no", locMast.getCrnNo()); StaDesc staDesc = staDescService.selectOne(wrapper); + if (Cools.isEmpty(staDesc)) { + throw new CoolException("闈炴硶璺緞锛�"); + } Integer sourceStaNo = staDesc.getCrnStn(); if (Cools.isEmpty(sourceStaNo)) { throw new CoolException("妫�绱㈡簮绔欏け璐�"); @@ -460,10 +1429,11 @@ wrkMast.setIoTime(new Date()); wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID wrkMast.setIoType(110); // 鍏ュ嚭搴撶姸鎬侊細 110.绌烘澘鍑哄簱 - wrkMast.setIoPri(10D); + Double ioPri = wrkMastService.getIoPri(110, locNo); + wrkMast.setIoPri(ioPri); wrkMast.setSourceStaNo(sourceStaNo); // 婧愮珯 wrkMast.setStaNo(param.getOutSite()); // 鐩爣绔� - wrkMast.setOutMost(locMastService.isOutMost(locNo, false)?1:0);; + wrkMast.setOutMost(locMastService.isOutMost(locNo, false) ? 1 : 0); wrkMast.setCrnNo(locMast.getCrnNo()); wrkMast.setSourceLocNo(locNo); // 婧愬簱浣� wrkMast.setFullPlt("N"); // 婊℃澘锛歒 @@ -480,7 +1450,7 @@ throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); } // 鏇存柊搴撲綅鐘舵�� D.绌烘澘 -> R.鍑哄簱棰勭害 - if (locMast.getLocSts().equals("D")){ + if (locMast.getLocSts().equals("D")) { locMast.setLocSts("R"); locMast.setModiUser(userId); locMast.setModiTime(new Date()); @@ -494,6 +1464,9 @@ @Override @Transactional public void locCheckOut(StockOutParam param, Long userId) { +// if (wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 107)) > 0) { +// throw new CoolException("鍙兘瀛樺湪涓�绗旂洏鐐逛换鍔�"); +// } // 鐩爣绔欑偣鐘舵�佹娴� BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite()); // 鑾峰彇搴撲綅鏄庣粏 @@ -505,8 +1478,14 @@ } } if (!locDetlDtos.isEmpty()) { - // 鍚姩鍑哄簱寮�濮� 107.鐩樼偣鍑哄簱 - stockOut(staNo, locDetlDtos, IoWorkType.CHECK_OUT, userId); + LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetlDtos.get(0).getLocDetl().getLocNo())); + if (locMast.getLocSts().equals("F")) { + // 鍚姩鍑哄簱寮�濮� 107.鐩樼偣鍑哄簱 + stockOut(staNo, locDetlDtos, IoWorkType.CHECK_OUT, userId); + } else { + throw new CoolException("鎵�閫夊簱浣嶅瓨鍦ㄧ姸鎬佷笉涓篎鐨勫簱浣嶏紝搴撲綅鍙凤細" + locMast.getLocNo() + " 銆佸綋鍓嶇姸鎬侊細" + locMast.getLocSts() + "-" + locMast.getLocSts$()); + } + } else { throw new CoolException("搴撲綅鐗╂枡涓嶅瓨鍦�"); } @@ -517,39 +1496,43 @@ public void locMove(String sourceLocNo, String locNo, Long userId) { LocMast sourceLoc = locMastService.selectById(sourceLocNo); List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo)); - if (Cools.isEmpty(sourceLoc)){ + if (Cools.isEmpty(sourceLoc)) { throw new CoolException("鏈壘鍒板簱浣�"); } LocMast loc = locMastService.selectById(locNo); - if (Cools.isEmpty(loc)){ + if (Cools.isEmpty(loc)) { throw new CoolException("鏈壘鍒板簱浣�"); } - if (!sourceLoc.getCrnNo().equals(loc.getCrnNo())) { - throw new CoolException("绉昏浆搴撲綅灞炰簬涓嶅悓鍫嗗灈鏈�"); + if (!loc.getLocSts().equals("O") || (!sourceLoc.getLocSts().equals("F") && !sourceLoc.getLocSts().equals("D"))) { + throw new CoolException("搴撲綅鐘舵�佸凡鏀瑰彉"); } + if (!sourceLoc.getCrnNo().equals(loc.getCrnNo())) { +// throw new CoolException("绉昏浆搴撲綅灞炰簬涓嶅悓鍫嗗灈鏈�"); todo:luxiaotao + } + Date now = new Date(); // 鑾峰彇宸ヤ綔鍙� int workNo = commonService.getWorkNo(WorkNoType.PICK.type); // 淇濆瓨宸ヤ綔妗� WrkMast wrkMast = new WrkMast(); wrkMast.setWrkNo(workNo); - wrkMast.setIoTime(new Date()); + wrkMast.setIoTime(now); wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID wrkMast.setIoType(11); // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇 wrkMast.setIoPri(10D); - wrkMast.setOutMost(locMastService.isOutMost(locNo, false)?1:0);; + wrkMast.setOutMost(locMastService.isOutMost(locNo, false) ? 1 : 0); wrkMast.setCrnNo(sourceLoc.getCrnNo()); wrkMast.setSourceLocNo(sourceLocNo); // 婧愬簱浣� wrkMast.setLocNo(locNo); // 鐩爣搴撲綅 - wrkMast.setFullPlt(Cools.isEmpty(locDetls)?"N":"Y"); // 婊℃澘锛歒 + wrkMast.setFullPlt(Cools.isEmpty(locDetls) ? "N" : "Y"); // 婊℃澘锛歒 wrkMast.setPicking("N"); // 鎷f枡 wrkMast.setExitMk("N"); // 閫�鍑� - wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D")?"Y":"N"); // 绌烘澘 + wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D") ? "Y" : "N"); // 绌烘澘 wrkMast.setBarcode(sourceLoc.getBarcode()); // 鎵樼洏鐮� wrkMast.setLinkMis("N"); wrkMast.setAppeUser(userId); - wrkMast.setAppeTime(new Date()); + wrkMast.setAppeTime(now); wrkMast.setModiUser(userId); - wrkMast.setModiTime(new Date()); + wrkMast.setModiTime(now); boolean res = wrkMastService.insert(wrkMast); if (!res) { throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); @@ -559,12 +1542,13 @@ WrkDetl wrkDetl = new WrkDetl(); wrkDetl.sync(locDetl); wrkDetl.setWrkNo(workNo); - wrkDetl.setIoTime(new Date()); + wrkDetl.setIoTime(now); wrkDetl.setAnfme(locDetl.getAnfme()); - wrkDetl.setAppeTime(new Date()); + wrkDetl.setAppeTime(now); wrkDetl.setAppeUser(userId); - wrkDetl.setModiTime(new Date()); + wrkDetl.setModiTime(now); wrkDetl.setModiUser(userId); + wrkDetl.setMatType(locDetl.getMatType()); if (!wrkDetlService.insert(wrkDetl)) { throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); } @@ -573,23 +1557,23 @@ if (sourceLoc.getLocSts().equals("D") || sourceLoc.getLocSts().equals("F")) { sourceLoc.setLocSts("R"); // R.鍑哄簱棰勭害 sourceLoc.setModiUser(userId); - sourceLoc.setModiTime(new Date()); - if (!locMastService.updateById(sourceLoc)){ + sourceLoc.setModiTime(now); + if (!locMastService.updateById(sourceLoc)) { throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�"); } } else { - throw new CoolException("婧愬簱浣嶅嚭搴撳け璐ワ紝鐘舵�侊細"+sourceLoc.getLocSts$()); + throw new CoolException(sourceLoc.getLocNo() + "婧愬簱浣嶅嚭搴撳け璐ワ紝鐘舵�侊細" + sourceLoc.getLocSts$()); } // 淇敼鐩爣搴撲綅鐘舵�� if (loc.getLocSts().equals("O")) { loc.setLocSts("S"); // S.鍏ュ簱棰勭害 - loc.setModiTime(new Date()); + loc.setModiTime(now); loc.setModiUser(userId); if (!locMastService.updateById(loc)) { throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�"); } } else { - throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細"+loc.getLocSts$()); + throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + loc.getLocSts$()); } } @@ -597,17 +1581,18 @@ @Transactional public void completeWrkMast(String workNo, Long userId) { WrkMast wrkMast = wrkMastService.selectById(workNo); - if (Cools.isEmpty(wrkMast)){ - throw new CoolException(workNo+"宸ヤ綔妗d笉瀛樺湪"); + if (Cools.isEmpty(wrkMast)) { + throw new CoolException(workNo + "宸ヤ綔妗d笉瀛樺湪"); } if (wrkMast.getWrkSts() == 9 || wrkMast.getWrkSts() == 17) { throw new CoolException("褰撳墠宸ヤ綔妗e凡瀹屾垚"); } // 鍏ュ簱 + 搴撲綅杞Щ - if (wrkMast.getWrkSts() < 9 || (wrkMast.getWrkSts() > 10 && wrkMast.getIoType()==11)) { + if (wrkMast.getWrkSts() < 9 || (wrkMast.getWrkSts() > 10 && wrkMast.getIoType() == 11)) { wrkMast.setWrkSts(9L); // 鍑哄簱 } else if (wrkMast.getWrkSts() > 10) { + wrkMast.setSteNo(0); wrkMast.setWrkSts(17L); } Date now = new Date(); @@ -647,27 +1632,31 @@ Iterator<LocDetlAdjustParam.LocDetlAdjust> iterator1 = list.iterator(); while (iterator1.hasNext()) { LocDetlAdjustParam.LocDetlAdjust adjust = iterator1.next(); - if (adjust.getCount() == 0) { continue; } + if (adjust.getCount() == 0) { + continue; + } if (locDetl.getMatnr().equals(adjust.getMatnr()) && Cools.eq(locDetl.getBatch(), adjust.getBatch())) { - if (!locDetl.getAnfme().equals(adjust.getCount())) { - // todo 鐩樼偣璁板綍 - // 淇敼搴撳瓨 - if (!locDetlService.updateAnfme(adjust.getCount(), locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch())) { - throw new CoolException(locDetl.getLocNo() + "搴撲綅锛�" + locDetl.getMatnr() + "鍟嗗搧锛�" + locDetl.getBatch() + "搴忓垪鐮佷慨鏀规暟閲忓け璐�"); - } - // 淇濆瓨璋冩暣璁板綍 - AdjDetl adjDetl = new AdjDetl(); - adjDetl.setLocNo(locDetl.getLocNo()); - adjDetl.setMatnr(locDetl.getMatnr()); - adjDetl.setBatch(locDetl.getBatch()); - adjDetl.setOriQty(locDetl.getAnfme()); - adjDetl.setAdjQty(adjust.getCount()); - adjDetl.setModiTime(now); - adjDetl.setModiUser(userId); - adjDetl.setAppeTime(now); - adjDetl.setAppeUser(userId); - adjDetlService.save(adjDetl, userId); + // todo 鐩樼偣璁板綍 + // 淇敼搴撳瓨 + if (!locDetlService.updateAnfme(adjust.getCount(), locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), adjust.getManu(), adjust.getMemo())) { + throw new CoolException(locDetl.getLocNo() + "搴撲綅锛�" + locDetl.getMatnr() + "鍟嗗搧锛�" + locDetl.getBatch() + "搴忓垪鐮佷慨鏀规暟閲忓け璐�"); } + // 淇濆瓨璋冩暣璁板綍 + AdjDetl adjDetl = new AdjDetl(); + adjDetl.setLocNo(locDetl.getLocNo()); + adjDetl.setMatnr(locDetl.getMatnr()); + adjDetl.setSpecs(locDetl.getSpecs()); + adjDetl.setBatch(locDetl.getBatch()); + adjDetl.setOriQty(locDetl.getAnfme()); + adjDetl.setAdjQty(adjust.getCount()); + adjDetl.setMemo(adjust.getMemo()); + adjDetl.setManu(adjust.getManu()); + adjDetl.setModiTime(now); + adjDetl.setModiUser(userId); + adjDetl.setAppeTime(now); + adjDetl.setAppeUser(userId); + adjDetlService.save(adjDetl, userId); + iterator.remove(); iterator1.remove(); } @@ -696,13 +1685,17 @@ // 娣诲姞搴撳瓨 for (LocDetlAdjustParam.LocDetlAdjust adjust : list) { - if (adjust.getCount() == 0.0D) { continue; } + if (adjust.getCount() == 0.0D) { + continue; + } Mat mat = matService.selectByMatnr(adjust.getMatnr()); LocDetl locDetl = new LocDetl(); locDetl.sync(mat); locDetl.setBatch(adjust.getBatch()); locDetl.setLocNo(locMast.getLocNo()); locDetl.setAnfme(adjust.getCount()); // 鏁伴噺 + locDetl.setMemo(adjust.getMemo()); + locDetl.setManu(adjust.getManu()); locDetl.setModiUser(userId); // 鎿嶄綔浜哄憳淇℃伅 locDetl.setModiTime(now); locDetl.setAppeUser(userId); @@ -715,6 +1708,8 @@ adjDetl.setLocNo(locMast.getLocNo()); adjDetl.setMatnr(adjust.getMatnr()); adjDetl.setBatch(adjust.getBatch()); + adjDetl.setMemo(adjust.getMemo()); + adjDetl.setManu(adjust.getManu()); adjDetl.setOriQty(0.0D); adjDetl.setAdjQty(adjust.getCount()); adjDetl.setModiTime(now); @@ -747,44 +1742,47 @@ @Transactional public void cancelWrkMast(String workNo, Long userId) { WrkMast wrkMast = wrkMastService.selectById(workNo); - if (Cools.isEmpty(wrkMast)){ - throw new CoolException(workNo+"宸ヤ綔妗d笉瀛樺湪"); + if (Cools.isEmpty(wrkMast)) { + throw new CoolException(workNo + "宸ヤ綔妗d笉瀛樺湪"); } String locNo = ""; // 寰呬慨鏀圭洰鏍囧簱浣� String locSts = ""; // 寰呬慨鏀圭洰鏍囧簱浣嶇姸鎬� // 鍏ュ簱鍙栨秷锛堜慨鏀圭洰鏍囧簱浣嶏級 - if (wrkMast.getWrkSts() < 4) { + if (wrkMast.getWrkSts() < 9) { locNo = wrkMast.getLocNo(); locSts = "O"; // 搴撲綅杞Щ - if (wrkMast.getIoType() == 11) { + if (wrkMast.getIoType() == 11 || wrkMast.getIoType() == 111) { // 搴撲綅杞Щ锛氭簮搴撲綅 LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo()); if (Cools.isEmpty(locMast)) { - throw new CoolException("鍙栨秷搴撲綅杞Щ澶辫触锛屾簮搴撲綅涓嶅瓨鍦�:"+ wrkMast.getSourceLocNo()); + throw new CoolException("鍙栨秷搴撲綅杞Щ澶辫触锛屾簮搴撲綅涓嶅瓨鍦�:" + wrkMast.getSourceLocNo()); } locMast.setLocSts("F"); locMast.setModiTime(new Date()); locMast.setModiUser(userId); locMastService.updateById(locMast); } - // 鍑哄簱鍙栨秷锛堜慨鏀规簮搴撲綅锛� - } else if (wrkMast.getWrkSts() > 10 && wrkMast.getWrkSts() != 14) { + // 鍑哄簱鍙栨秷锛堜慨鏀规簮搴撲綅锛� + } else if (wrkMast.getWrkSts() > 10 && wrkMast.getWrkSts() != 19) { locNo = wrkMast.getSourceLocNo(); // 鍑哄簱 ===>> F.鍦ㄥ簱 if (wrkMast.getIoType() > 100 && wrkMast.getIoType() != 110) { locSts = "F"; - // 绌烘澘鍑哄簱 ===>> D.绌烘《/绌烘爤鏉� + // 绌烘澘鍑哄簱 ===>> D.绌烘《/绌烘爤鏉� } else if (wrkMast.getIoType() == 110) { locSts = "D"; - // 搴撲綅杞Щ ===>> D.绌烘《/绌烘爤鏉� - } else if (wrkMast.getIoType() == 11) { - locSts = wrkMast.getFullPlt().equalsIgnoreCase("N")?"D":"F"; + // 搴撲綅杞Щ ===>> D.绌烘《/绌烘爤鏉� + } else if (wrkMast.getIoType() == 11 || wrkMast.getIoType() == 111) { + if (wrkMast.getWrkSts() > 11) { + throw new CoolException("绉诲簱浠诲姟宸插湪鎵ц涓紝涓嶈兘鍙栨秷"); + } + locSts = wrkMast.getFullPlt().equalsIgnoreCase("N") ? "D" : "F"; // 搴撲綅杞Щ锛氱洰鏍囧簱浣� LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); if (Cools.isEmpty(locMast)) { - throw new CoolException("鍙栨秷搴撲綅杞Щ澶辫触锛岀洰鏍囧簱浣嶄笉瀛樺湪:"+ wrkMast.getSourceLocNo()); + throw new CoolException("鍙栨秷搴撲綅杞Щ澶辫触锛岀洰鏍囧簱浣嶄笉瀛樺湪:" + wrkMast.getSourceLocNo()); } locMast.setLocSts("O"); locMast.setModiTime(new Date()); @@ -798,11 +1796,44 @@ List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); for (WrkDetl wrkDetl : wrkDetls) { if (!Cools.isEmpty(wrkDetl.getOrderNo())) { - if (!orderDetlService.decrease(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) { - throw new CoolException("璁㈠崟鏁版嵁鍥炴粴澶辫触"); + String[] orderNos = GetOrderNo(wrkDetl.getOrderNo()); + if (!Cools.isEmpty(orderNos) && orderNos.length != 0) { + String[] anfmes = GetAnfme(wrkDetl.getOrderNo()); + int i = 0; + for (String orderNo : orderNos) { + if (!Cools.isEmpty(orderNo)) { + Double anfme = Integer.parseInt(anfmes[i]) + 0.0; + i++; + if (!BaseController.isJSON(wrkDetl.getOrderNo())) { + if (!orderDetlService.decrease(orderNo, wrkDetl.getMatnr(), wrkDetl.getBatch(), anfme)) { + throw new CoolException("璁㈠崟鏁版嵁鍥炴粴澶辫触"); + } + } else { + // 璁㈠崟鍚堝苟鍑哄簱 + List<OrderDto> orderDtoList = JSON.parseArray(wrkDetl.getOrderNo(), OrderDto.class); + for (OrderDto orderDto : orderDtoList) { + if (!orderDetlService.decrease(orderDto.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), orderDto.getAnfme())) { + throw new CoolException("璁㈠崟鏁版嵁鍥炴粴澶辫触"); + } + } + } + } + } + } else { + if (!BaseController.isJSON(wrkDetl.getOrderNo())) { + if (!orderDetlService.decrease(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) { + throw new CoolException("璁㈠崟鏁版嵁鍥炴粴澶辫触"); + } + } else { + // 璁㈠崟鍚堝苟鍑哄簱 + List<OrderDto> orderDtoList = JSON.parseArray(wrkDetl.getOrderNo(), OrderDto.class); + for (OrderDto orderDto : orderDtoList) { + if (!orderDetlService.decrease(orderDto.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), orderDto.getAnfme())) { + throw new CoolException("璁㈠崟鏁版嵁鍥炴粴澶辫触"); + } + } + } } - // 鐢熸垚鏂扮殑鍑哄簱浣滀笟 -// stockOutRe(wrkMast, wrkDetls); } } // 鍙栨秷鎿嶄綔浜哄憳璁板綍 @@ -831,7 +1862,7 @@ // 淇敼搴撲綅鐘舵�� LocMast locMast = locMastService.selectById(locNo); if (Cools.isEmpty(locMast)) { - throw new CoolException("鍙栨秷宸ヤ綔妗eけ璐ワ紝搴撲綅涓嶅瓨鍦�:"+ locNo); + throw new CoolException("鍙栨秷宸ヤ綔妗eけ璐ワ紝搴撲綅涓嶅瓨鍦�:" + locNo); } locMast.setLocSts(locSts); locMast.setModiTime(new Date()); @@ -840,14 +1871,15 @@ if (!wrkMastRes || !locMastRes) { throw new CoolException("淇濆瓨鏁版嵁澶辫触"); } + waitPakinService.delete(new EntityWrapper<WaitPakin>().eq("zpallet", wrkMast.getBarcode())); } @Override @Transactional public void pickWrkMast(String workNo, Long userId) { WrkMast wrkMast = wrkMastService.selectById(workNo); - if (Cools.isEmpty(wrkMast)){ - throw new CoolException(workNo+"宸ヤ綔妗d笉瀛樺湪"); + if (Cools.isEmpty(wrkMast)) { + throw new CoolException(workNo + "宸ヤ綔妗d笉瀛樺湪"); } // 鍏ュ嚭搴撶被鍨嬪垽鏂� if (wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107) { @@ -918,10 +1950,14 @@ } @Override + @Transactional public void shuttleTransfer(List<String> locNos) { if (Cools.isEmpty(locNos)) { return; } +// if (true && !Cools.isEmpty(locNos)) { +// throw new CoolException("鏆備笉鏀寔绉诲簱浠诲姟"); // todo:luxiaotao 绉诲簱寮�鍏� +// } LocMast one = locMastService.selectById(locNos.get(0)); List<Integer> rows = Utils.getGroupLoc(Integer.parseInt(locNos.get(0).substring(0, 2))); List<LocMast> locMasts = locMastService.queryFreeLocMast(rows, rows.size(), one.getLocType1()); @@ -943,10 +1979,99 @@ Collections.reverse(locMasts); break; default: - throw new IllegalStateException("Unexpected value: " + locMasts.get(0).getRow1()); + break; } + if (locNos.size() > locMasts.size()) { + throw new CoolException("鏈嶅姟鍣ㄩ敊璇�"); + } + Date now = new Date(); // 鐢熸垚绉诲簱宸ヤ綔妗� + Iterator<LocMast> iterator = locMasts.iterator(); + for (String sourceLocNo : locNos) { + while (iterator.hasNext()) { + LocMast sourceLoc = locMastService.selectById(sourceLocNo); + List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo)); + if (Cools.isEmpty(sourceLoc)) { + throw new CoolException("鏈壘鍒板簱浣�"); + } + LocMast loc = iterator.next(); + if (Cools.isEmpty(loc)) { + throw new CoolException("鏈壘鍒板簱浣�"); + } + if (!sourceLoc.getCrnNo().equals(loc.getCrnNo())) { +// throw new CoolException("绉昏浆搴撲綅灞炰簬涓嶅悓鍫嗗灈鏈�"); todo:luxiaotao + } + // 鑾峰彇宸ヤ綔鍙� + int workNo = commonService.getWorkNo(WorkNoType.PICK.type); + // 淇濆瓨宸ヤ綔妗� + WrkMast wrkMast = new WrkMast(); + wrkMast.setWrkNo(workNo); + wrkMast.setIoTime(now); + wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID + wrkMast.setIoType(11); // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇 + wrkMast.setIoPri(15D); + wrkMast.setOutMost(locMastService.isOutMost(loc.getLocNo(), false) ? 1 : 0); + wrkMast.setCrnNo(sourceLoc.getCrnNo()); + wrkMast.setSourceLocNo(sourceLocNo); // 婧愬簱浣� + wrkMast.setLocNo(loc.getLocNo()); // 鐩爣搴撲綅 + wrkMast.setFullPlt(Cools.isEmpty(locDetls) ? "N" : "Y"); // 婊℃澘锛歒 + wrkMast.setPicking("N"); // 鎷f枡 + wrkMast.setExitMk("N"); // 閫�鍑� + wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D") ? "Y" : "N"); // 绌烘澘 + wrkMast.setBarcode(sourceLoc.getBarcode()); // 鎵樼洏鐮� + wrkMast.setLinkMis("N"); + wrkMast.setAppeUser(9527L); + wrkMast.setAppeTime(now); + wrkMast.setModiUser(9527L); + wrkMast.setModiTime(now); + boolean res = wrkMastService.insert(wrkMast); + if (!res) { + throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); + } + // 宸ヤ綔妗f槑缁嗕繚瀛� + for (LocDetl locDetl : locDetls) { + WrkDetl wrkDetl = new WrkDetl(); + wrkDetl.sync(locDetl); + wrkDetl.setWrkNo(workNo); + wrkDetl.setIoTime(now); + wrkDetl.setAnfme(locDetl.getAnfme()); + wrkDetl.setAppeTime(now); + wrkDetl.setAppeUser(9527L); + wrkDetl.setModiTime(now); + wrkDetl.setModiUser(9527L); + wrkDetl.setMatType(locDetl.getMatType()); + if (!wrkDetlService.insert(wrkDetl)) { + throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); + } + } + // 淇敼婧愬簱浣嶇姸鎬� + if (sourceLoc.getLocSts().equals("D") || sourceLoc.getLocSts().equals("F")) { + sourceLoc.setLocSts("R"); // R.鍑哄簱棰勭害 + sourceLoc.setModiUser(9527L); + sourceLoc.setModiTime(now); + if (!locMastService.updateById(sourceLoc)) { + throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�"); + } + } else { + throw new CoolException(sourceLoc.getLocNo() + "婧愬簱浣嶅嚭搴撳け璐ワ紝鐘舵�侊細" + sourceLoc.getLocSts$()); + } + // 淇敼鐩爣搴撲綅鐘舵�� + if (loc.getLocSts().equals("O")) { + loc.setLocSts("S"); // S.鍏ュ簱棰勭害 + loc.setModiTime(now); + loc.setModiUser(9527L); + if (!locMastService.updateById(loc)) { + throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�"); + } + } else { + throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + loc.getLocSts$()); + } + + iterator.remove(); + break; + } + } } } -- Gitblit v1.9.1