| | |
| | | public void startupFullTakeStore(StockOutParam param, Long userId) { |
| | | List<StockOutParam.LocDetl> locDetls = new ArrayList<>(); |
| | | List<String> locs = new ArrayList<>(); |
| | | List<SameMatCount> sameMatCounts = new ArrayList<>(); |
| | | for (StockOutParam.LocDetl one : param.getLocDetls()) { |
| | | 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 : 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("所选库位存在状态不为F、D的库位,库位号:"+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; |
| | | Map<String, Double> isOuts = new HashMap<>(); |
| | | Double isOut = 0.0; |
| | | List<String> locNoWeighting = new ArrayList<>(); |
| | | log.info("canshu:{}", stockOutParamLocDetlSort); |
| | | for (StockOutParam.LocDetl locDetl : stockOutParamLocDetlSort) { |
| | | if (isOuts.get(locDetl.getMatnr()) == null) { |
| | | isOuts.put(locDetl.getMatnr(), locDetl.getCount()); |
| | | } else { |
| | | isOuts.put(locDetl.getMatnr(), isOuts.get(locDetl.getMatnr()) + locDetl.getCount()); |
| | | } |
| | | } |
| | | log.info("canshu:{}", JSON.toJSONString(isOuts)); |
| | | |
| | | for (StockOutParam.LocDetl locDetl : stockOutParamLocDetlSort) { |
| | | |
| | | // SameMatCount smc = new SameMatCount(); |
| | | // if (Cools.isEmpty(sameMatCounts)) { |
| | | // smc.setMatnr(locDetl.getMatnr()); |
| | | // smc.setNeedOutCount(locDetl.getCount()); |
| | | // sameMatCounts.add(smc); |
| | | // } else { |
| | | // for (SameMatCount sameMatCount : sameMatCounts) { |
| | | // if (sameMatCount.getMatnr().equals(locDetl.getMatnr())) { |
| | | // sameMatCount.setNeedOutCount(locDetl.getCount() + sameMatCount.getNeedOutCount()); |
| | | // //smc.setMatnr(sameMatCount.getMatnr()); |
| | | // smc.setNeedOutCount(sameMatCount.getNeedOutCount()); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | |
| | | if (Cools.isEmpty(locNoWeighting)) { |
| | | if (Cools.isEmpty(locNoWeighting)){ |
| | | locNoWeighting.add(locDetl.getLocNo()); |
| | | } else { |
| | | if (!Utils.getLocNoWeighting(locNoWeighting, locDetl.getLocNo())) { |
| | | }else { |
| | | if (!Utils.getLocNoWeighting(locNoWeighting,locDetl.getLocNo())){ |
| | | locNoWeighting.add(locDetl.getLocNo()); |
| | | sign = true; |
| | | } |
| | | } |
| | | |
| | | if (sign) { |
| | | 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)) { |
| | | if (locMast.getLocType2().equals((short)3)){ |
| | | groupOuterSingleLoc = Utils.getGroupOuterSingleLocLowFrequency(locDetl.getLocNo()); |
| | | sign = false; |
| | | } |
| | | for (String locNo : groupOuterSingleLoc) { |
| | | //每个库位的库位明细 |
| | | if (locs.contains(locNo)) continue; |
| | | 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")) { |
| | | 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) { |
| | | if (!sign){ |
| | | locDetls.add(new StockOutParam.LocDetl(detl.getLocNo(), detl.getMatnr(), detl.getBatch(), detl.getAnfme())); |
| | | System.out.println("1"); |
| | | } |
| | | continue; |
| | | } |
| | | if (!param.getOutSite().equals(214) && !param.getOutSite().equals(114)) { |
| | | if (detl.getAnfme() >= isOuts.get(detl.getMatnr())) { |
| | | // if (detl.getAnfme() >= locDetl.getCount()) { |
| | | locDetls.add(new StockOutParam.LocDetl(detl.getLocNo(), detl.getMatnr(), detl.getBatch(), isOuts.get(detl.getMatnr()))); |
| | | System.out.println("2"); |
| | | //isOut = locDetl.getCount(); |
| | | 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())); |
| | | isOuts.put(detl.getMatnr(), isOuts.get(detl.getMatnr()) - detl.getAnfme()); |
| | | System.out.println(isOuts.get(locDetl.getMatnr())); |
| | | isOut = detl.getAnfme(); |
| | | } |
| | | } else { |
| | | //强制不是相同物料 |
| | | locDetls.add(new StockOutParam.LocDetl(detl.getLocNo(), detl.getMatnr(), detl.getBatch(), detl.getAnfme())); |
| | | // System.out.println("4"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (!isfull && isOuts.get(locDetl.getMatnr()) != null && isOuts.get(locDetl.getMatnr()) > 0) { |
| | | if (locDetl.getCount() >= isOuts.get(locDetl.getMatnr())) { |
| | | locDetls.add(new StockOutParam.LocDetl(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), isOuts.get(locDetl.getMatnr()))); |
| | | isOuts.put(locDetl.getMatnr(), isOuts.get(locDetl.getMatnr()) - locDetl.getCount()); |
| | | // System.out.println(23); |
| | | } else { |
| | | locDetls.add(new StockOutParam.LocDetl(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), locDetl.getCount())); |
| | | isOuts.put(locDetl.getMatnr(), isOuts.get(locDetl.getMatnr()) - locDetl.getCount()); |
| | | // System.out.println("1222"); |
| | | } |
| | | if (!isfull) { |
| | | |
| | | |
| | | //locDetls.add(new StockOutParam.LocDetl(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), locDetl.getCount() - isOut)); |
| | | locDetls.add(new StockOutParam.LocDetl(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getBatch(), locDetl.getCount() - isOut)); |
| | | // locDetls.add(locDetl); |
| | | } |
| | | } |
| | |
| | | // List<StockOutParam.LocDetl> locDetls = param.getLocDetls(); |
| | | |
| | | |
| | | |
| | | // ArrayList<String> locNos = new ArrayList<>(); |
| | | // List<StockOutParam.LocDetl> locDetls = new ArrayList<>(); |
| | | // ArrayList<String> matnrs = new ArrayList<>();//目的做数据去重 |
| | |
| | | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); |
| | | } |
| | | } |
| | | for (LocDetlDto locDetlDto : locDetlDtos) { |
| | | if (locs.contains(locDetlDto.getLocDetl().getLocNo())) { |
| | | 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")) { |
| | | if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D") ){ |
| | | // 启动出库开始 101.出库 |
| | | stockOut2(staNo, locDetlDtos, null, userId); |
| | | } else { |
| | | throw new CoolException("所选库位存在状态不为F、D的库位,库位号:" + locMast.getLocNo() + " 、当前状态:" + locMast.getLocSts() + "-" + locMast.getLocSts$()); |
| | | }else { |
| | | throw new CoolException("所选库位存在状态不为F、D的库位,库位号:"+locMast.getLocNo()+" 、当前状态:"+locMast.getLocSts()+"-"+locMast.getLocSts$()); |
| | | } |
| | | } else { |
| | | throw new CoolException("库存不存在"); |