| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | |
| | | return R.ok().add(orderDetlService.selectByOrderId(orderId).stream().map(OrderDetl::getId).distinct().collect(Collectors.toList())); |
| | | } |
| | | |
| | | @PostMapping("/out/pakout/previewCustomQuantity/auth") |
| | | @ManagerAuth |
| | | public R pakoutPreviewCustomQuantity(@RequestBody JSONObject jsonObject) { |
| | | List<Long> ids = JSON.parseObject(jsonObject.get("ids").toString(), ArrayList.class); |
| | | Double amount = JSON.parseObject(jsonObject.get("amount").toString(), Double.class); |
| | | 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.getWorkQty()).orElse(0.0D); |
| | | if (!Cools.isEmpty(amount)) { |
| | | if (amount > issued) { |
| | | return R.error("数量高于可出库数量"); |
| | | } |
| | | issued = amount; |
| | | } |
| | | |
| | | if (issued <= 0.0D) { continue; } |
| | | List<LocDetl> locDetls = new ArrayList<>(); |
| | | locDetls = locDetlService.queryStockFour(orderDetl.getMatnr(), orderDetl.getBatch(), null, exist); |
| | | for (LocDetl locDetl : locDetls) { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetl.getLocNo())); |
| | | List<LocMast> locMasts = new ArrayList<>(); |
| | | if (locMast.getBay1() >=1 && locMast.getBay1()<=2){ |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMast.getGro1()) |
| | | .eq("crn_no", 7) |
| | | .eq("loc_type1",locMast.getLocType1()) |
| | | .orderBy("bay1", false)); |
| | | }else if (locMast.getBay1() >=4 && locMast.getBay1()<=12){ |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMast.getGro1()) |
| | | .eq("crn_no", 7) |
| | | .eq("loc_type1",locMast.getLocType1()) |
| | | .orderBy("bay1", true)); |
| | | }else { |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMast.getGro1()) |
| | | .eq("crn_no", 7) |
| | | .eq("loc_type1",locMast.getLocType1()) |
| | | .orderBy("bay1", false)); |
| | | } |
| | | for (LocMast locMast1 : locMasts){ |
| | | if (locMast1.getLocSts().equals("F")){ |
| | | LocDetl locDetl1 = locDetlService.selectOne(new EntityWrapper<LocDetl>() |
| | | .eq("loc_No", locMast1.getLocNo()) |
| | | .eq("matnr", locDetl.getMatnr()).eq("batch", locDetl.getBatch())); |
| | | if (!Cools.isEmpty(locDetl1)) { |
| | | 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() ? 101 : 103); |
| | | List<LocDto.staListDto> maps = new ArrayList<>(); |
| | | for (Integer staNo : staNos) { |
| | | LocDto.staListDto staListDto = new LocDto.staListDto(); |
| | | staListDto.setStaNo(staNo); |
| | | staListDto.setStaName(Utils.getStaName(staNo)); |
| | | maps.add(staListDto); |
| | | } |
| | | locDto.setStaNos(maps); |
| | | locDtos.add(locDto); |
| | | // 剩余待出数量递减 |
| | | 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); |
| | | } |
| | | |
| | | @PostMapping("/out/pakout/preview/auth") |
| | | @ManagerAuth |
| | | public R pakoutPreview(@RequestBody List<Long> ids) { |