|  |  |  | 
|---|
|  |  |  | 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(BaseRes.PARAM); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 订单明细 | 
|---|
|  |  |  | List<OrderDetl> orderDetls = orderDetlService.selectBatchIds(ids); | 
|---|
|  |  |  | if (orderDetls.isEmpty()) { | 
|---|
|  |  |  | return R.parse("请选择数据"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取订单主表 | 
|---|
|  |  |  | Order order = orderService.selectOne(new EntityWrapper<Order>().eq("order_no", orderDetls.get(0).getOrderNo())); | 
|---|
|  |  |  | Order order = orderService.selectOne( | 
|---|
|  |  |  | new EntityWrapper<Order>().eq("order_no", orderDetls.get(0).getOrderNo()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if (order == null) { | 
|---|
|  |  |  | return R.parse("订单数据为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Set<String> exist = new HashSet<>(); | 
|---|
|  |  |  | // 每个包装组查一次库存 | 
|---|
|  |  |  | 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) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (OrderDetl orderDetl : orderDetls) { | 
|---|
|  |  |  | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getWorkQty()).orElse(0.0D); | 
|---|
|  |  |  | if (issued <= 0.0D) { continue; } | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("brand",orderDetl.getBrand())); | 
|---|
|  |  |  | if (issued > 0 && !locDetls.isEmpty()) { | 
|---|
|  |  |  | // 根据单据类型返回出库口列表 21出库口,22盘点口,23反修品出库口 | 
|---|
|  |  |  | List<Integer> staNos  = new ArrayList<>(); | 
|---|
|  |  |  | if (order.getDocType() == 21) { | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | LocDto locDto = new LocDto(); | 
|---|
|  |  |  | locDto.setLocNo(locDetls.get(0).getLocNo()); | 
|---|
|  |  |  | //                    wrkDetl.setMatnr(roll.getSpecs()); // 规格 | 
|---|
|  |  |  | //                    wrkDetl.setMaktx(roll.getSpecs()); //规格 | 
|---|
|  |  |  | //                    locDto.setBatch(locDetl.getBatch()); // 箱号 | 
|---|
|  |  |  | //                    locDto.setModel(locDetl.getModel()); // 卷号 | 
|---|
|  |  |  | locDto.setBrand(orderDetl.getBrand()); // 包装组号 | 
|---|
|  |  |  | //                    locDto.setOrigin(locDetl.getOrigin()); // 木箱在托盘位置 | 
|---|
|  |  |  | //                    locDto.setWeight(locDetl.getWeight()); // 净重 | 
|---|
|  |  |  | //                    locDto.setVolume(locDetl.getVolume()); // 毛重 | 
|---|
|  |  |  | //                    locDto.setPrice(locDetl.getPrice()); | 
|---|
|  |  |  | //                    locDto.setSpecs(locDetl.getSpecs()); | 
|---|
|  |  |  | //                    locDto.setZpallet(locDetl.getZpallet()); | 
|---|
|  |  |  | locDto.setOrderNo(orderDetl.getOrderNo()); | 
|---|
|  |  |  | locDto.setStaNos(staNos); | 
|---|
|  |  |  | locDto.setOrderDetlId(orderDetl.getId()); | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | if (locDetls.isEmpty()) continue; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取出库口 | 
|---|
|  |  |  | List<Integer> staNos = new ArrayList<>(); | 
|---|
|  |  |  | if (order.getDocType() == 21) { | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 去重 key,避免相同 loc+unit+model 重复显示 | 
|---|
|  |  |  | Set<String> seen = new HashSet<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (LocDetl locDetl : locDetls) { | 
|---|
|  |  |  | String key = locDetl.getLocNo() + "|" + locDetl.getUnit() + "|" + locDetl.getModel(); | 
|---|
|  |  |  | if (seen.contains(key)) continue; | 
|---|
|  |  |  | seen.add(key); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 对应多个明细时,分配到第一个明细(或你可以拆分多个) | 
|---|
|  |  |  | OrderDetl firstDetl = brandOrderDetls.get(0); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LocDto locDto = new LocDto(); | 
|---|
|  |  |  | locDto.setLocNo(locDetl.getLocNo()); | 
|---|
|  |  |  | locDto.setUnit(locDetl.getUnit()); | 
|---|
|  |  |  | locDto.setModel(locDetl.getModel()); | 
|---|
|  |  |  | locDto.setThreeCode(locDetl.getThreeCode()); | 
|---|
|  |  |  | locDto.setBrand(locDetl.getBrand()); | 
|---|
|  |  |  | locDto.setOrderNo(firstDetl.getOrderNo()); | 
|---|
|  |  |  | locDto.setStaNos(staNos); | 
|---|
|  |  |  | locDto.setOrderDetlId(firstDetl.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | locDtos.add(locDto); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok().add(locDtos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 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 { | 
|---|
|  |  |  | //        StockOutParam param = new StockOutParam(); | 
|---|
|  |  |  | //        ArrayList<StockOutParam.LocDetl> locDetls = new ArrayList<>(); | 
|---|
|  |  |  | //        for (LocDto locDto:locDtos){ | 
|---|
|  |  |  | //            StockOutParam.LocDetl locDetl = new StockOutParam.LocDetl(); | 
|---|
|  |  |  | //            locDetl.setBrand(locDto.getBrand()); | 
|---|
|  |  |  | //            locDetl.setLocNo(locDto.getLocNo()); | 
|---|
|  |  |  | //            locDetl.setAnfme(locDto.getAnfme()); | 
|---|
|  |  |  | //            locDetl.setMatnr(locDto.getMatnr()); | 
|---|
|  |  |  | //            locDetl.setBatch(locDto.getBatch()); | 
|---|
|  |  |  | //            locDetl.setModel(locDto.getModel()); | 
|---|
|  |  |  | //            locDetl.setSpecs(locDto.getSpecs()); | 
|---|
|  |  |  | //            locDetl.setZpallet(locDto.getZpallet()); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //            param.setOrderNo(locDto.getOrderNo()); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //            locDetls.add(locDetl); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        param.setLocDetls(locDetls); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        List<StockOutParam> stockOutParams = OutboundAllocationUtil.OutboundClassification(param); | 
|---|
|  |  |  | //        for (StockOutParam stockOutParam : stockOutParams){ | 
|---|
|  |  |  | //            workService.startupFullTakeStore(stockOutParam, getUserId()); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        for (LocDto locDto:locDtos){ | 
|---|
|  |  |  | //            OrderDetl orderDetl = orderDetlService.selectById(locDto.getOrderDetlId()); | 
|---|
|  |  |  | //            orderDetl.setWorkQty(locDto.getAnfme()); | 
|---|
|  |  |  | //            orderDetlService.updateById(orderDetl); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        Order order = orderService.selectByNo(param.getOrderNo()); | 
|---|
|  |  |  | //        order.setSettle(2L); | 
|---|
|  |  |  | //        orderService.updateById(order); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | boolean lack = true; | 
|---|
|  |  |  | for (LocDto locDto : locDtos) { | 
|---|
|  |  |  | if (!locDto.isLack()) { | 
|---|
|  |  |  | 
|---|
|  |  |  | Thread.sleep(1000L); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<StockOutParam> stockOutParams = new ArrayList<>(); | 
|---|
|  |  |  | Map<Integer, StockOutParam> staNoMap = new HashMap<>(); | 
|---|
|  |  |  | Set<String> processedKeys = new HashSet<>(); // 防止重复添加 brand+staNo | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (LocDto locDto : locDtos) { | 
|---|
|  |  |  | boolean flag1 = true; | 
|---|
|  |  |  | for(StockOutParam stockOutParam: stockOutParams) { | 
|---|
|  |  |  | if(stockOutParam.getOutSite().equals(locDto.getStaNo())) { // 有一样的出库口 | 
|---|
|  |  |  | List<StockOutParam.LocDetl> locDetls = new ArrayList<>(); | 
|---|
|  |  |  | List<LocDetl> locDetls1 = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("brand", locDto.getBrand())); | 
|---|
|  |  |  | for(LocDetl locDetl:locDetls1) { | 
|---|
|  |  |  | StockOutParam.LocDetl  locDetl1 = new StockOutParam.LocDetl(); | 
|---|
|  |  |  | locDetl1.setLocNo(locDetl.getLocNo()); | 
|---|
|  |  |  | locDetl1.setBrand(locDetl.getBrand()); | 
|---|
|  |  |  | locDetl1.setModel(locDetl.getModel()); | 
|---|
|  |  |  | locDetl1.setCount(locDetl.getAnfme()); | 
|---|
|  |  |  | locDetls.add(locDetl1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | stockOutParam.getLocDetls().addAll(locDetls); | 
|---|
|  |  |  | flag1 = false; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(flag1) { // 没有一样的出库口 | 
|---|
|  |  |  | StockOutParam stockOutParam = new StockOutParam(); | 
|---|
|  |  |  | stockOutParam.setOutSite(locDto.getStaNo()); | 
|---|
|  |  |  | Integer staNo = locDto.getStaNo(); | 
|---|
|  |  |  | String brand = locDto.getBrand(); | 
|---|
|  |  |  | String key = staNo + "_" + brand; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取或创建 StockOutParam(按出库口合并) | 
|---|
|  |  |  | StockOutParam stockOutParam = staNoMap.get(staNo); | 
|---|
|  |  |  | if (stockOutParam == null) { | 
|---|
|  |  |  | stockOutParam = new StockOutParam(); | 
|---|
|  |  |  | stockOutParam.setOutSite(staNo); | 
|---|
|  |  |  | stockOutParam.setOrderNo(locDto.getOrderNo()); | 
|---|
|  |  |  | List<StockOutParam.LocDetl> locDetls = new ArrayList<>(); | 
|---|
|  |  |  | List<LocDetl> locDetls1 = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("brand", locDto.getBrand())); | 
|---|
|  |  |  | for(LocDetl locDetl:locDetls1) { | 
|---|
|  |  |  | StockOutParam.LocDetl  locDetl1 = new StockOutParam.LocDetl(); | 
|---|
|  |  |  | locDetl1.setLocNo(locDetl.getLocNo()); | 
|---|
|  |  |  | locDetl1.setBrand(locDetl.getBrand()); | 
|---|
|  |  |  | locDetl1.setModel(locDetl.getModel()); | 
|---|
|  |  |  | locDetl1.setCount(locDetl.getAnfme()); | 
|---|
|  |  |  | locDetls.add(locDetl1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | stockOutParam.setLocDetls(locDetls); | 
|---|
|  |  |  | stockOutParam.setLocDetls(new ArrayList<>()); | 
|---|
|  |  |  | stockOutParams.add(stockOutParam); | 
|---|
|  |  |  | staNoMap.put(staNo, stockOutParam); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 避免重复添加相同brand的数据 | 
|---|
|  |  |  | if (processedKeys.contains(key)) continue; | 
|---|
|  |  |  | processedKeys.add(key); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<LocDetl> locDetls1 = locDetlService.selectList( | 
|---|
|  |  |  | new EntityWrapper<LocDetl>().eq("brand", brand)); | 
|---|
|  |  |  | for (LocDetl locDetl : locDetls1) { | 
|---|
|  |  |  | StockOutParam.LocDetl detl = new StockOutParam.LocDetl(); | 
|---|
|  |  |  | detl.setLocNo(locDetl.getLocNo()); | 
|---|
|  |  |  | detl.setBrand(locDetl.getBrand()); | 
|---|
|  |  |  | detl.setModel(locDetl.getModel()); | 
|---|
|  |  |  | detl.setCount(locDetl.getAnfme()); | 
|---|
|  |  |  | stockOutParam.getLocDetls().add(detl); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for(StockOutParam stockOutParam :stockOutParams) { | 
|---|
|  |  |  | // 执行出库逻辑 | 
|---|
|  |  |  | for (StockOutParam stockOutParam : stockOutParams) { | 
|---|
|  |  |  | BasDevp staNo = basDevpService.checkSiteStatus(stockOutParam.getOutSite()); | 
|---|
|  |  |  | // 获取库位明细 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<LocDetlDto> locDetlDtos = new ArrayList<>(); | 
|---|
|  |  |  | for (StockOutParam.LocDetl paramLocDetl : stockOutParam.getLocDetls()) { | 
|---|
|  |  |  | LocDetl one = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_no",paramLocDetl.getLocNo()) | 
|---|
|  |  |  | .eq("brand",paramLocDetl.getBrand()).eq("model",paramLocDetl.getModel())); | 
|---|
|  |  |  | if (null != one) { | 
|---|
|  |  |  | if(!"合格".equals(one.getThreeCode())) { | 
|---|
|  |  |  | throw new CoolException(one.getModel() + "卷不合格:" + one.getThreeCode() ); | 
|---|
|  |  |  | LocDetl one = locDetlService.selectOne(new EntityWrapper<LocDetl>() | 
|---|
|  |  |  | .eq("loc_no", paramLocDetl.getLocNo()) | 
|---|
|  |  |  | .eq("brand", paramLocDetl.getBrand()) | 
|---|
|  |  |  | .eq("model", paramLocDetl.getModel())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (one != null) { | 
|---|
|  |  |  | // 判断是否为盘点单(docType == 23),如果不是则校验合格性 | 
|---|
|  |  |  | Order order = orderService.selectByNo(stockOutParam.getOrderNo()); | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount(), stockOutParam.getOrderNo())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!locDetlDtos.isEmpty()) { | 
|---|
|  |  |  | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", locDetlDtos.get(0).getLocDetl().getLocNo())); | 
|---|
|  |  |  | if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D") ){ | 
|---|
|  |  |  | // 根据订单类型判断出库类型 | 
|---|
|  |  |  | Order order = orderService.selectByNo(stockOutParam.getOrderNo()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 启动出库开始 | 
|---|
|  |  |  | workService.stockOut(staNo, locDetlDtos, order.getDocType() ==  23 ? IoWorkType.CHECK_OUT : null, getUserId()); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | throw new CoolException("所选库位存在状态不为F、D的库位,库位号:"+locMast.getLocNo()+" 、当前状态:"+locMast.getLocSts()+"-"+locMast.getLocSts$()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!locDetlDtos.isEmpty()) { | 
|---|
|  |  |  | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("loc_no", locDetlDtos.get(0).getLocDetl().getLocNo())); | 
|---|
|  |  |  | if ("F".equals(locMast.getLocSts()) || "D".equals(locMast.getLocSts())) { | 
|---|
|  |  |  | Order order = orderService.selectByNo(stockOutParam.getOrderNo()); | 
|---|
|  |  |  | 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() + ",当前状态:" + | 
|---|
|  |  |  | locMast.getLocSts() + "-" + locMast.getLocSts$()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | throw new CoolException("库存不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //        List<TaskDto> taskDtos = new ArrayList<>(); | 
|---|
|  |  |  | //        // 根据 (库位 & 出库站) 分组; 理想状态:一组为一次出库任务 | 
|---|
|  |  |  | //        for (LocDto locDto : locDtos) { | 
|---|
|  |  |  | //            if (locDto.isLack()) { continue; } | 
|---|
|  |  |  | //            TaskDto taskDto = new TaskDto(locDto.getLocNo(), locDto.getStaNo(), locDto); | 
|---|
|  |  |  | //            if (TaskDto.has(taskDtos, taskDto)) { | 
|---|
|  |  |  | //                TaskDto dto = TaskDto.find(taskDtos, taskDto); | 
|---|
|  |  |  | //                assert dto != null; | 
|---|
|  |  |  | //                dto.getLocDtos().addAll(taskDto.getLocDtos()); | 
|---|
|  |  |  | //            } else { | 
|---|
|  |  |  | //                taskDtos.add(taskDto); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | // ----------------------------------------------------------------------------------------------- | 
|---|
|  |  |  | //        for (TaskDto taskDto : taskDtos) { | 
|---|
|  |  |  | //            BasDevp staNo = basDevpService.checkSiteStatus(taskDto.getStaNo()); | 
|---|
|  |  |  | //            workService.stockOut(staNo, taskDto, getUserId()); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        stockOut(staNo, locDetlDtos, IoWorkType.CHECK_OUT, userId); | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|