| | |
| | | |
| | | Set<String> exist = new HashSet<>(); |
| | | |
| | | //标记库位 |
| | | HashMap<String,Integer> hm = new HashMap<>(); |
| | | |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getWorkQty()).orElse(0.0D); |
| | | if (issued <= 0.0D) { |
| | | continue; |
| | | } |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), hostId); |
| | | for (LocDetl locDetl : locDetls) { |
| | | List<LocDetl> locMats = locDetlService.list(new LambdaQueryWrapper<LocDetl>() |
| | | .eq(LocDetl::getLocNo, locDetl.getLocNo()) |
| | | .eq(LocDetl::getHostId, hostId)); |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | | issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued); |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), ((issued >= locDetl.getAnfme()) && (locMats.size() == 1)) ? 101 : 103, hostId); |
| | | locDto.setStaNos(staNos); |
| | | locDtos.add(locDto); |
| | | exist.add(locDetl.getLocNo()); |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |
| | | } else { |
| | | break; |
| | | if(!Cools.isEmpty(hm)){ |
| | | for(HashMap.Entry<String,Integer> entry:hm.entrySet()){ |
| | | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>() |
| | | .eq(LocDetl::getHostId, hostId) |
| | | .eq(LocDetl::getLocNo, entry.getKey()) |
| | | .eq(LocDetl::getMatnr, orderDetl.getMatnr())); |
| | | for (LocDetl locDetl : locDetls) { |
| | | List<LocDetl> locMats = locDetlService.list(new LambdaQueryWrapper<LocDetl>() |
| | | .eq(LocDetl::getLocNo, locDetl.getLocNo()) |
| | | .eq(LocDetl::getHostId, hostId)); |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | | issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued); |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), ((issued >= locDetl.getAnfme()) && (locMats.size() == 1)) ? 101 : 103, hostId); |
| | | locDto.setStaNos(staNos); |
| | | locDtos.add(locDto); |
| | | exist.add(locDetl.getLocNo()); |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |
| | | hm.put(locDetl.getLocNo(), 1); |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (issued >0){ |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), hostId); |
| | | for (LocDetl locDetl : locDetls) { |
| | | for (HashMap.Entry<String,Integer> entry:hm.entrySet()){ |
| | | if(locDetl.getLocNo().equals(entry.getKey())){ |
| | | continue; |
| | | } |
| | | } |
| | | List<LocDetl> locMats = locDetlService.list(new LambdaQueryWrapper<LocDetl>() |
| | | .eq(LocDetl::getLocNo, locDetl.getLocNo()) |
| | | .eq(LocDetl::getHostId, hostId)); |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | | issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued); |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), ((issued >= locDetl.getAnfme()) && (locMats.size() == 1)) ? 101 : 103, hostId); |
| | | locDto.setStaNos(staNos); |
| | | locDtos.add(locDto); |
| | | exist.add(locDetl.getLocNo()); |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |
| | | hm.put(locDetl.getLocNo(), 1); |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), hostId); |
| | | for (LocDetl locDetl : locDetls) { |
| | | List<LocDetl> locMats = locDetlService.list(new LambdaQueryWrapper<LocDetl>() |
| | | .eq(LocDetl::getLocNo, locDetl.getLocNo()) |
| | | .eq(LocDetl::getHostId, hostId)); |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | | issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued); |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), ((issued >= locDetl.getAnfme()) && (locMats.size() == 1)) ? 101 : 103, hostId); |
| | | locDto.setStaNos(staNos); |
| | | locDtos.add(locDto); |
| | | exist.add(locDetl.getLocNo()); |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |
| | | hm.put(locDetl.getLocNo(), 1); |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (issued > 0) { |
| | | List<LocDetl> locDetls1 = locDetlService.list(new LambdaQueryWrapper<LocDetl>() |
| | | .eq(LocDetl::getMatnr, orderDetl.getMatnr()).eq(LocDetl::getHostId, hostId)); |
| | |
| | | return R.error(orderDto.getOrderNo() + "订单已失效,请及时刷新页面"); |
| | | } |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), orderDto.getMatnr(), null, getHostId()); |
| | | if(Cools.isEmpty(orderDetl)){ |
| | | return R.error("没有找到订单明细"); |
| | | } |
| | | int oerderDetlCount = orderDetlService.count(new LambdaQueryWrapper<OrderDetl>() |
| | | .eq(OrderDetl::getOrderId,order.getId()).eq(OrderDetl::getMatnr,orderDto.getMatnr()).eq(OrderDetl::getHostId,getHostId())); |
| | | if(oerderDetlCount>1){ |
| | | return R.error("同一订单不允许有相同物料"); |
| | | } |
| | | if (orderDetl.getAnfme() - orderDetl.getQty() < orderDto.getAnfme()) { |
| | | return R.ok(orderDto.getOrderNo() + "订单已作业,请及时刷新页面"); |
| | | } |