| | |
| | | throw new CoolException("参数:出库数量 batchNum为空"); |
| | | } |
| | | |
| | | Mat mat = matService.selectByMatnr(param.getMatnr()); |
| | | if (Cools.isEmpty(mat)){ |
| | | throw new CoolException("品号 matnr,请先下发基础档案!!!"); |
| | | } |
| | | if (Cools.isEmpty(mat.getUnits())){ |
| | | throw new CoolException("品号 matnr,重量范围偏移值为空!!!,请先下发基础档案!!!"); |
| | | } |
| | | |
| | | |
| | | ArrayList<LocDetl> locDetlArrayList = new ArrayList<>(); |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("matnr", param.getMatnr()).eq("weight", param.getWeight())); |
| | | Wrapper<LocDetl> wrapper = new EntityWrapper<LocDetl>().eq("matnr", param.getMatnr()).eq("weight", param.getWeight()); |
| | | if (param.getDevNo() == 536) { |
| | | wrapper.eq("model", param.getModel()) |
| | | .eq("specs", param.getOrderNo()); |
| | | } |
| | | |
| | | List<LocDetl> locDetls = locDetlService.selectList(wrapper); |
| | | if (locDetls.isEmpty()){ |
| | | locDetls = new ArrayList<LocDetl>(); |
| | | } |
| | | for (LocDetl locDetl:locDetls){ |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo())); |
| | | if (locMast.getLocSts().equals("F")){ |
| | | locDetlArrayList.add(locDetl); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (param.getDevNo() == 536){ |
| | | locDetlArrayList = new ArrayList<>(); |
| | | locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("matnr", param.getMatnr()) |
| | | .eq("weight", param.getWeight()) |
| | | .eq("specs", param.getOrderNo()) |
| | | .eq("model", param.getTaskNo())); |
| | | if (locDetls.isEmpty()){ |
| | | locDetls = new ArrayList<LocDetl>(); |
| | | } |
| | | for (LocDetl locDetl:locDetls){ |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo())); |
| | | if (locMast.getLocSts().equals("F")){ |
| | | if (locDetlArrayList.size()<param.getBatchNum()) {//下 |
| | | locDetlArrayList.add(locDetl); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (locDetlArrayList.isEmpty()){ |
| | | throw new CoolException("未找到符合条件的物料明细:品号==》matnr:"+param.getMatnr()+";重量==》wright:"+param.getWeight()); |
| | | } |
| | | |
| | | Integer batchNum = param.getBatchNum(); |
| | | if (locDetlArrayList.size()<batchNum){//上5 |
| | | locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("matnr", param.getMatnr()) |
| | | .eq("specs", param.getOrderNo()) |
| | | .eq("model", param.getTaskNo()) |
| | | .lt("weight", param.getWeight()+5) |
| | | if (locDetlArrayList.size()<batchNum){//上 |
| | | Wrapper<LocDetl> locDetlWrapper = new EntityWrapper<LocDetl>().eq("matnr", param.getMatnr()) |
| | | .lt("weight", param.getWeight() + mat.getUnits()) |
| | | .and() |
| | | .gt("weight", param.getWeight()) |
| | | .orderBy("weight",true)); |
| | | .orderBy("weight", true); |
| | | if (param.getDevNo() == 536){ |
| | | locDetlWrapper.eq("model", param.getModel()) |
| | | .eq("specs", param.getOrderNo()); |
| | | } |
| | | locDetls = locDetlService.selectList(locDetlWrapper); |
| | | if (locDetls.isEmpty()){ |
| | | locDetls = new ArrayList<LocDetl>(); |
| | | } |
| | | for (LocDetl locDetl:locDetls){ |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo())); |
| | | if (locMast.getLocSts().equals("F")){ |
| | | locDetlArrayList.add(locDetl); |
| | | break; |
| | | if (locDetlArrayList.size()<batchNum) {//下 |
| | | locDetlArrayList.add(locDetl); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (locDetlArrayList.size()<batchNum){//下5 |
| | | locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("matnr", param.getMatnr()) |
| | | |
| | | .eq("specs", param.getOrderNo()) |
| | | .eq("model", param.getTaskNo()) |
| | | .gt("weight", param.getWeight()-5) |
| | | if (locDetlArrayList.size()<batchNum){//下 |
| | | Wrapper<LocDetl> locDetlWrapper = new EntityWrapper<LocDetl>().eq("matnr", param.getMatnr()) |
| | | .gt("weight", param.getWeight() - mat.getUnits()) |
| | | .and() |
| | | .lt("weight", param.getWeight()) |
| | | .orderBy("weight",false)); |
| | | .orderBy("weight", false); |
| | | if (param.getDevNo() == 536){ |
| | | locDetlWrapper.eq("model", param.getModel()) |
| | | .eq("specs", param.getOrderNo()); |
| | | } |
| | | locDetls = locDetlService.selectList(locDetlWrapper); |
| | | |
| | | if (locDetls.isEmpty()){ |
| | | locDetls = new ArrayList<LocDetl>(); |
| | |
| | | for (LocDetl locDetl:locDetls){ |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo())); |
| | | if (locMast.getLocSts().equals("F")){ |
| | | locDetlArrayList.add(locDetl); |
| | | break; |
| | | if (locDetlArrayList.size()<batchNum) {//下 |
| | | locDetlArrayList.add(locDetl); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作明细失败==》小料箱直供产线任务明细生成"); |
| | | } |
| | | |
| | | } |
| | | |
| | | public Integer getStaEnd(Integer staNo){ |