| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * Created by vincent on 2022/3/26 |
| | |
| | | @Autowired |
| | | private BasDevpService basDevpService; |
| | | |
| | | |
| | | @PostMapping("/out/pakout/orderDetlIds/auth") |
| | | @ManagerAuth |
| | | public R pakoutOrderDetlIds(@RequestParam Long orderId) throws InterruptedException { |
| | | Thread.sleep(200); |
| | | return R.ok().add(orderDetlService.selectByOrderId(orderId).stream().map(OrderDetl::getId).distinct().collect(Collectors.toList())); |
| | | } |
| | | |
| | | @PostMapping("/out/pakout/preview/auth") |
| | | @ManagerAuth |
| | | public R pakoutPreview(@RequestBody List<Long> ids) { |
| | |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getQty()).orElse(0.0D); |
| | | if (issued <= 0.0D) { continue; } |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), null); |
| | | |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist); |
| | | |
| | | System.out.println(locDetls); |
| | | for (LocDetl locDetl : locDetls) { |
| | | // if (exist.contains(locDetl.getLocNo())) { continue; } |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(locDetl.getLocNo(), locDetl.getMatnr(), locDetl.getMaktx(), locDetl.getBatch(), orderDetl.getOrderNo(), |
| | | issued >= locDetl.getAnfme() ? locDetl.getAnfme() : issued); |
| | |
| | | // 根据 (库位 & 出库站) 分组; 理想状态:一组为一次出库任务 |
| | | for (LocDto locDto : locDtos) { |
| | | if (locDto.isLack()) { continue; } |
| | | |
| | | //添加部分:增加工作数量 |
| | | // orderDetlService.increaseWorkQtytest(locDto.getOrderNo(),locDto.getMatnr(),locDto.getBatch(),locDto.getAnfme()); |
| | | |
| | | |
| | | TaskDto taskDto = new TaskDto(locDto.getLocNo(), locDto.getStaNo(), locDto); |
| | | if (TaskDto.has(taskDtos, taskDto)) { |
| | | TaskDto dto = TaskDto.find(taskDtos, taskDto); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/out/pakout/preview/authtest") |
| | | @ManagerAuth |
| | | public R pakoutPreviewtest(@RequestBody List<Long> ids) { |
| | | if (Cools.isEmpty(ids)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | List<OrderDetl> orderDetls = orderDetlService.selectBatchIds(ids); |
| | | List<LocDto> locDtos = new ArrayList<>(); |
| | | |
| | | Set<String> exist = new HashSet<>(); |
| | | |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getQty()).orElse(0.0D); |
| | | if (issued <= 0.0D) { continue; } |
| | | |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist); |
| | | //判断出库数量是否大于要出的物品 |
| | | LocDto locDtoo = new LocDto(locDetls.get(0).getLocNo(), locDetls.get(0).getMatnr(), locDetls.get(0).getMaktx(), locDetls.get(0).getBatch(), orderDetl.getOrderNo(), |
| | | issued >= locDetls.get(0).getAnfme() ? locDetls.get(0).getAnfme() : issued); |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locDetls.get(0).getLocNo(), issued >= locDetls.get(0).getAnfme() ? 101 : 103); |
| | | locDtoo.setStaNos(staNos); |
| | | if(issued<locDetls.get(0).getAnfme()){ |
| | | |
| | | locDtos.add(locDtoo); |
| | | exist.add(locDetls.get(0).getLocNo()); |
| | | break; |
| | | }else if(issued==locDetls.get(0).getAnfme()){ |
| | | |
| | | locDtos.add(locDtoo); |
| | | exist.add(locDetls.get(0).getLocNo()); |
| | | break; |
| | | }else { |
| | | |
| | | locDtos.add(locDtoo); |
| | | exist.add(locDetls.get(0).getLocNo()); |
| | | issued=issued-locDetls.get(0).getAnfme(); |
| | | } |
| | | |
| | | List<LocDetl> locDetlList=locDetlService.queryStockOther(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist,locDetls.get(0).getLocNo()); |
| | | for (LocDetl locDetl : locDetlList) { |
| | | 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> staNoss = staDescService.queryOutStaNosByLocNo(locDetl.getLocNo(), issued >= locDetl.getAnfme() ? 101 : 103); |
| | | locDto.setStaNos(staNoss); |
| | | |
| | | locDtos.add(locDto); |
| | | exist.add(locDetl.getLocNo()); |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |
| | | } else { |
| | | break; |
| | | } |
| | | } |
| | | if (issued > 0) { |
| | | LocDto locDto = new LocDto(null, orderDetl.getMatnr(), orderDetl.getMaktx(), orderDetl.getBatch(), orderDetl.getOrderNo(), issued); |
| | | locDto.setLack(Boolean.TRUE); |
| | | locDtos.add(locDto); |
| | | } |
| | | } |
| | | return R.ok().add(locDtos); |
| | | } |
| | | |
| | | } |