|  |  |  | 
|---|
|  |  |  | import com.core.common.*; | 
|---|
|  |  |  | import com.core.exception.CoolException; | 
|---|
|  |  |  | import com.zy.asrs.entity.*; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.PakoutRequest; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.StockOutParam; | 
|---|
|  |  |  | import com.zy.asrs.service.*; | 
|---|
|  |  |  | import com.zy.common.model.LocDetlDto; | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok().add(orderDetlService.selectByOrderId(orderId).stream().map(OrderDetl::getId).distinct().collect(Collectors.toList())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/getMesOrder/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R getMesOrder() { | 
|---|
|  |  |  | List<String> orderNoList = orderService.getOrderNosByDocType(25L); | 
|---|
|  |  |  | return R.ok().add(orderNoList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/out/pakout/preview/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R pakoutPreview(@RequestBody List<Long> ids) { | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.parse("订单数据为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 按包装组号分组处理 | 
|---|
|  |  |  | Map<String, List<OrderDetl>> brandGroup = orderDetls.stream() | 
|---|
|  |  |  | .collect(Collectors.groupingBy(o -> { | 
|---|
|  |  |  | String brand = o.getBrand(); | 
|---|
|  |  |  | return brand != null ? brand : "跨巷道"; | 
|---|
|  |  |  | })); | 
|---|
|  |  |  | Map<String, List<OrderDetl>> brandGroup; | 
|---|
|  |  |  | if (order.getDocType() == 27) { | 
|---|
|  |  |  | // 按包装组号分组处理 | 
|---|
|  |  |  | brandGroup = orderDetls.stream() | 
|---|
|  |  |  | .collect(Collectors.groupingBy(o -> { | 
|---|
|  |  |  | String brand = o.getModel(); | 
|---|
|  |  |  | return brand != null ? brand : "跨巷道"; | 
|---|
|  |  |  | })); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | // 按包装组号分组处理 | 
|---|
|  |  |  | brandGroup = orderDetls.stream() | 
|---|
|  |  |  | .collect(Collectors.groupingBy(o -> { | 
|---|
|  |  |  | String brand = o.getBrand(); | 
|---|
|  |  |  | return brand != null ? brand : "跨巷道"; | 
|---|
|  |  |  | })); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<LocDto> locDtos = new ArrayList<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  | for (Map.Entry<String, List<OrderDetl>> entry : brandGroup.entrySet()) { | 
|---|
|  |  |  | String brand = entry.getKey(); | 
|---|
|  |  |  | List<OrderDetl> brandOrderDetls = entry.getValue(); | 
|---|
|  |  |  | List<LocDetl> locDetls; | 
|---|
|  |  |  | if (order.getDocType() == 27) { | 
|---|
|  |  |  | locDetls = locDetlService.selectList( | 
|---|
|  |  |  | new EntityWrapper<LocDetl>().eq("model", brand) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | // 查这个包装组对应的所有库存 | 
|---|
|  |  |  | locDetls = locDetlService.selectList( | 
|---|
|  |  |  | new EntityWrapper<LocDetl>().eq("brand", brand) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 查这个包装组对应的所有库存 | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.selectList( | 
|---|
|  |  |  | new EntityWrapper<LocDetl>().eq("brand", brand) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if (locDetls.isEmpty()) continue; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取出库口 | 
|---|
|  |  |  | List<Integer> staNos = new ArrayList<>(); | 
|---|
|  |  |  | if (order.getDocType() == 21) { | 
|---|
|  |  |  | staNos.add(3077); staNos.add(3106); | 
|---|
|  |  |  | staNos.add(3077); | 
|---|
|  |  |  | staNos.add(3106); | 
|---|
|  |  |  | } else if (order.getDocType() == 22) { | 
|---|
|  |  |  | staNos.add(2041); | 
|---|
|  |  |  | } else if (order.getDocType() == 23) { | 
|---|
|  |  |  | staNos.add(3092); staNos.add(3102); staNos.add(3095); | 
|---|
|  |  |  | staNos.add(3092); | 
|---|
|  |  |  | staNos.add(3102); | 
|---|
|  |  |  | staNos.add(3095); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 去重 key,避免相同 loc+unit+model 重复显示 | 
|---|
|  |  |  | 
|---|
|  |  |  | locDto.setUnit(locDetl.getUnit()); | 
|---|
|  |  |  | locDto.setModel(locDetl.getModel()); | 
|---|
|  |  |  | locDto.setThreeCode(locDetl.getThreeCode()); | 
|---|
|  |  |  | locDto.setBrand(brand); | 
|---|
|  |  |  | locDto.setBrand(locDetl.getBrand()); | 
|---|
|  |  |  | locDto.setOrderNo(firstDetl.getOrderNo()); | 
|---|
|  |  |  | locDto.setStaNos(staNos); | 
|---|
|  |  |  | locDto.setOrderDetlId(firstDetl.getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.parse(BaseRes.PARAM); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<LocDto> locDtos = new ArrayList<>(); | 
|---|
|  |  |  | for (Long id : ids){ | 
|---|
|  |  |  | for (Long id : ids) { | 
|---|
|  |  |  | Order order = orderService.selectById(id); | 
|---|
|  |  |  | List<OrderDetl> orderDetls = orderDetlService.selectByOrderId(order.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (OrderDetl orderDetl : orderDetls) { | 
|---|
|  |  |  | LocDto locDto = new LocDto(orderDetl.getManu(), orderDetl.getMatnr(), orderDetl.getMaktx(),orderDetl.getModel(),orderDetl.getSpecs(), | 
|---|
|  |  |  | orderDetl.getBatch(),orderDetl.getBrand(),orderDetl.getBarcode(), orderDetl.getOrderNo(),orderDetl.getAnfme()); | 
|---|
|  |  |  | LocDto locDto = new LocDto(orderDetl.getManu(), orderDetl.getMatnr(), orderDetl.getMaktx(), orderDetl.getModel(), orderDetl.getSpecs(), | 
|---|
|  |  |  | orderDetl.getBatch(), orderDetl.getBrand(), orderDetl.getBarcode(), orderDetl.getOrderNo(), orderDetl.getAnfme()); | 
|---|
|  |  |  | locDto.setOrderDetlId(orderDetl.getId()); | 
|---|
|  |  |  | locDto.setTkType(orderDetl.getTkType()); | 
|---|
|  |  |  | locDtos.add(locDto); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/out/pakout/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "订单出库") | 
|---|
|  |  |  | public synchronized R pakout(@RequestBody List<LocDto> locDtos) throws InterruptedException { | 
|---|
|  |  |  | public synchronized R pakout(@RequestBody PakoutRequest request) throws InterruptedException { | 
|---|
|  |  |  | List<LocDto> locDtos = request.getTableCache(); | 
|---|
|  |  |  | String optionValue = request.getOptionValue(); | 
|---|
|  |  |  | if (Cools.isEmpty(locDtos)) { | 
|---|
|  |  |  | return R.parse(BaseRes.PARAM); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if (one != null) { | 
|---|
|  |  |  | // 判断是否为盘点单(docType == 23),如果不是则校验合格性 | 
|---|
|  |  |  | Order order = orderService.selectByNo(stockOutParam.getOrderNo()); | 
|---|
|  |  |  | if ( order.getDocType() != 23) { | 
|---|
|  |  |  | if (!"合格".equals(one.getThreeCode())) { | 
|---|
|  |  |  | throw new CoolException(one.getModel() + "卷不合格: " + one.getThreeCode()); | 
|---|
|  |  |  | if (order.getDocType() != 23) { | 
|---|
|  |  |  | if (order.getDocType() == 26 || order.getDocType() == 27) { | 
|---|
|  |  |  | if ("合格".equals(one.getThreeCode())) { | 
|---|
|  |  |  | throw new CoolException(one.getModel() + "卷是合格: " + one.getThreeCode()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | // 3077 3106 只有合格能出 | 
|---|
|  |  |  | if((stockOutParam.getOutSite() == 3077 || stockOutParam.getOutSite() == 3106) && !"合格".equals(one.getThreeCode())) { | 
|---|
|  |  |  | throw new CoolException(one.getModel() + "卷不合格:" + one.getThreeCode()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 2041 只有待判能出 | 
|---|
|  |  |  | if(stockOutParam.getOutSite() == 2041 && null != one.getThreeCode()) { | 
|---|
|  |  |  | throw new CoolException(one.getModel() + "卷不为待判:" + one.getThreeCode()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq("loc_no", locDetlDtos.get(0).getLocDetl().getLocNo())); | 
|---|
|  |  |  | if ("F".equals(locMast.getLocSts()) || "D".equals(locMast.getLocSts())) { | 
|---|
|  |  |  | Order order = orderService.selectByNo(stockOutParam.getOrderNo()); | 
|---|
|  |  |  | workService.stockOut(staNo, locDetlDtos, | 
|---|
|  |  |  | order.getDocType() != null && order.getDocType() == 23 | 
|---|
|  |  |  | ? IoWorkType.CHECK_OUT : null, | 
|---|
|  |  |  | getUserId()); | 
|---|
|  |  |  | IoWorkType ioWorkType = (order.getDocType() != null && order.getDocType() == 23) | 
|---|
|  |  |  | ? IoWorkType.CHECK_OUT : null; | 
|---|
|  |  |  | if (order.getDocType() != null) { | 
|---|
|  |  |  | if (order.getDocType() == 26 || order.getDocType() == 27) { | 
|---|
|  |  |  | ioWorkType = IoWorkType.ALL_OUT; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (order.getDocType() == 27) { | 
|---|
|  |  |  | workService.stockOut2(staNo, locDetlDtos, | 
|---|
|  |  |  | ioWorkType, | 
|---|
|  |  |  | getUserId(), optionValue); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | workService.stockOut(staNo, locDetlDtos, | 
|---|
|  |  |  | ioWorkType, | 
|---|
|  |  |  | getUserId(), optionValue); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | throw new CoolException("所选库位状态不为F/D,库位号:" + | 
|---|
|  |  |  | locMast.getLocNo() + ",当前状态:" + | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/out/refund/loc/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "订单出库") | 
|---|
|  |  |  | public synchronized R refundLoc(@RequestBody List<LocDto> locDtos) throws InterruptedException { | 
|---|
|  |  |  | 
|---|
|  |  |  | long nowOrderNo = System.currentTimeMillis(); | 
|---|
|  |  |  | Order order = new Order( | 
|---|
|  |  |  | String.valueOf(snowflakeIdWorker.nextId()),    // 编号[非空] | 
|---|
|  |  |  | "TK"+nowOrderNo,    // 订单编号 | 
|---|
|  |  |  | "TK" + nowOrderNo,    // 订单编号 | 
|---|
|  |  |  | DateUtils.convert(now),    // 单据日期 | 
|---|
|  |  |  | docType.getDocId(),    // 单据类型 | 
|---|
|  |  |  | null,    // 项目编号 | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new CoolException("保存订单主档失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 单据明细档 | 
|---|
|  |  |  | int i=0; | 
|---|
|  |  |  | int i = 0; | 
|---|
|  |  |  | List<LocDto> locDtosList = new ArrayList<>(); | 
|---|
|  |  |  | List<String> batchList = new ArrayList<>(); | 
|---|
|  |  |  | for (LocDto locDto : locDtos) { | 
|---|
|  |  |  | if (!batchList.contains(locDto.getBatch())){ | 
|---|
|  |  |  | if (!batchList.contains(locDto.getBatch())) { | 
|---|
|  |  |  | batchList.add(locDto.getBatch()); | 
|---|
|  |  |  | locDtosList.add(locDto); | 
|---|
|  |  |  | } | 
|---|