From 6dbde9bff0d2dd0e0779019fba7234c8206b5265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E8=96=AA=E5=90=8D?= <942005050@qq.com> Date: Mon, 27 Nov 2023 09:08:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E6=AC=A1=E7=AD=96=E7=95=A5=E4=B8=8B?= =?UTF-8?q?=E6=9E=B6=E7=AD=96=E7=95=A5=E8=BF=94=E5=9B=9E=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E4=BD=99=E9=A2=9D=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IssueRequestMainServiceImpl.java | 132 +-------------- .../com/win/module/wms/util/JobUtils.java | 150 ++++++++++++++++++ 2 files changed, 153 insertions(+), 129 deletions(-) diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/issueRequest/IssueRequestMainServiceImpl.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/issueRequest/IssueRequestMainServiceImpl.java index ea458d02..173b3934 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/issueRequest/IssueRequestMainServiceImpl.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/issueRequest/IssueRequestMainServiceImpl.java @@ -666,137 +666,11 @@ public class IssueRequestMainServiceImpl implements IssueRequestMainService { List issueJobDetailDOList = new ArrayList<>(); List expectinCreateReqVOList = new ArrayList<>(); List expectoutCreateReqVOList = new ArrayList<>(); + JobUtils jobUtils = new JobUtils(); // 根据发料申请子表数据进行分析 detailDO.forEach(item -> { - // 批次策略 - RuleRespVO ruleRespVOBatch = ruleService.batch(null, null,null,null,null,item.getProjectCode(),item.getItemCode()); - JSONObject jsonObjectBatch = JSONUtil.parseObj(ruleRespVOBatch.getConfiguration()); - // 下架策略 - RuleRespVO ruleRespVOOffShelf = ruleService.offShelf(null,null,null,null,null,item.getProjectCode(),item.getItemCode(),null,null,null); - JSONObject jsonObjectOffShelf = JSONUtil.parseObj(ruleRespVOOffShelf.getConfiguration()); - // 查询库存余额 - QueryWrapper queryWrapper = new QueryWrapper(); - queryWrapper.select("item_code", "batch", "SUM(qty) as qty", "packing_number", "container_number", "warehouse_code", "area_code", "location_group_code", "location_code", "produce_date", "arrive_date"); - queryWrapper.eq("item_code", item.getItemCode()); - queryWrapper.eq("inventory_status", item.getInventoryStatus()); - // 根据下架策略 作为查询库存余额条件 - // 仓库 - if (jsonObjectOffShelf.get("WarehouseCode") != null && !jsonObjectOffShelf.get("WarehouseCode").equals("")) { - queryWrapper.eq("warehouse_code", jsonObjectOffShelf.get("WarehouseCode")); - } - // 库区 - if (jsonObjectOffShelf.get("AreaCode") != null && !jsonObjectOffShelf.get("AreaCode").equals("")) { - queryWrapper.eq("area_code", jsonObjectOffShelf.get("AreaCode")); - } - // 库位组 - if (jsonObjectOffShelf.get("LocationGroupCode") != null && !jsonObjectOffShelf.get("LocationGroupCode").equals("")) { - queryWrapper.eq("location_group_code", jsonObjectOffShelf.get("LocationGroupCode")); - } - // 库位 - if (jsonObjectOffShelf.get("LocationCode") != null && !jsonObjectOffShelf.get("LocationCode").equals("")) { - queryWrapper.eq("location_code", jsonObjectOffShelf.get("LocationCode")); - } - // 根据下架策略 作为查询库存余额分组 - // 发料包装类型——按 包装 - if (jsonObjectOffShelf.get("IssueStorageType") != null && jsonObjectOffShelf.get("IssueStorageType").equals("1")) { - queryWrapper.groupBy("packing_number"); - } - // 发料包装类型——按 容器 - if (jsonObjectOffShelf.get("IssueStorageType") != null && jsonObjectOffShelf.get("IssueStorageType").equals("2")) { - queryWrapper.groupBy("container_number"); - } - // 发料包装类型——按 单件 - if (jsonObjectOffShelf.get("IssueStorageType") != null && jsonObjectOffShelf.get("IssueStorageType").equals("3")) { - queryWrapper.groupBy("item_code", "batch", "qty", "packing_number", "container_number", "warehouse_code", "area_code", "location_group_code", "location_code", "expire_date", "produce_date", "arrive_date"); - } - // 根据批次策略 作为查询库存余额排序 - // 批次类型——按 生产时间 - if (jsonObjectBatch.get("BatchType") != null && jsonObjectBatch.get("BatchType").equals("0")) { - // ASC = 0,正向 - if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("0")) { - queryWrapper.orderByAsc("produce_date"); - } - // DESC = 1,逆向 - if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("1")) { - queryWrapper.orderByDesc("produce_date"); - } - } - // 批次类型——按 到货时间 - if (jsonObjectBatch.get("BatchType") != null && jsonObjectBatch.get("BatchType").equals("1")) { - // ASC = 0,正向 - if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("0")) { - queryWrapper.orderByAsc("arrive_date"); - } - // DESC = 1,逆向 - if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("1")) { - queryWrapper.orderByDesc("arrive_date"); - } - } - // 批次类型——按 失效时间 - if (jsonObjectBatch.get("BatchType") != null && jsonObjectBatch.get("BatchType").equals("2")) { - // ASC = 0,正向 - if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("0")) { - queryWrapper.orderByAsc("expire_date"); - } - // DESC = 1,逆向 - if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("1")) { - queryWrapper.orderByDesc("expire_date"); - } - } - // 批次类型——按 供应商批次 - if (jsonObjectBatch.get("BatchType") != null && jsonObjectBatch.get("BatchType").equals("3")) { -// TODO: 供应商批次 ??? 不知道怎么搞了 - } - // 批次类型——按 供应商优先级 - if (jsonObjectBatch.get("BatchType") != null && jsonObjectBatch.get("BatchType").equals("4")) { -// TODO: 供应商优先级 ??? 不知道怎么搞了 - } - // 批次类型——按 其它批次 - if (jsonObjectBatch.get("BatchType") != null && jsonObjectBatch.get("BatchType").equals("5")) { - // ASC = 0,正向 - if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("0")) { - queryWrapper.orderByAsc("batch"); - } - // DESC = 1,逆向 - if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("1")) { - queryWrapper.orderByDesc("batch"); - } - } - // 数量排序方向 正向 - if (jsonObjectOffShelf.get("QtyOrderDirection") != null && jsonObjectOffShelf.get("QtyOrderDirection").equals("ASC")) { - queryWrapper.orderByAsc("qty"); - } - // 数量排序方向 逆向 - if (jsonObjectOffShelf.get("QtyOrderDirection") != null && jsonObjectOffShelf.get("QtyOrderDirection").equals("DESC")) { - queryWrapper.orderByDesc("qty"); - } - - // 任务子表数据 - List balanceDOListJob = new ArrayList<>(); - List balanceDOList = balanceMapper.selectList(queryWrapper); - BigDecimal countQty = new BigDecimal(0.000000); - for (BalanceDO balanceDO: balanceDOList) { - // 查询 预计出 求和 数量 -// TODO: 后续完善 根据 管理精度查询 - QueryWrapper queryWrapperExpectout = new QueryWrapper(); - queryWrapperExpectout.select("SUM(qty) as qty"); - queryWrapperExpectout.eq("item_code", balanceDO.getItemCode()); - if (balanceDO.getPackingNumber() != null && !balanceDO.getPackingNumber().equals("")) queryWrapperExpectout.eq("packing_number", balanceDO.getPackingNumber()); - if (balanceDO.getBatch() != null && !balanceDO.getBatch().equals("")) queryWrapperExpectout.eq("batch", balanceDO.getBatch()); - queryWrapperExpectout.groupBy("item_code","packing_number", "batch"); - ExpectoutDO expectoutDO = expectoutMapper.selectOne(queryWrapperExpectout); - BigDecimal countQtyExpectout = new BigDecimal(0.000000); - if (expectoutDO != null) { - countQtyExpectout = expectoutDO.getQty(); - } - // balanceDO.getQty().subtract(countQtyExpectout) 扣减预计出数量 - countQty = countQty.add(balanceDO.getQty().subtract(countQtyExpectout)); - balanceDOListJob.add(balanceDO); - // 数据列表循环累加 直到总和大于等于当前物品的qty {countQty >= balanceDO.getQty()} - if (countQty.compareTo(item.getQty()) != -1) { - break; - } - } + // 根据批次策略/下架策略 返回 库存余额DO + List balanceDOListJob = jobUtils.getBalanceByBatchOffShelf(item.getItemCode(),item.getInventoryStatus(),item.getProjectCode(),item.getQty()); // 根据 查询出所需数据 解析成 任务子表数据 balanceDOListJob.forEach(balanceDOItem -> { IssueJobDetailDO issueJobDetailDO = new IssueJobDetailDO(); diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/util/JobUtils.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/util/JobUtils.java index a00dca76..fb83764b 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/util/JobUtils.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/util/JobUtils.java @@ -2,6 +2,7 @@ package com.win.module.wms.util; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.win.module.wms.controller.rule.vo.RuleRespVO; import com.win.module.wms.dal.dataobject.balance.BalanceDO; import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; @@ -725,4 +726,153 @@ public class JobUtils { return true; } + /** + * 根据批次策略/下架策略 返回 库存余额DO + * @param itemCode + * @param inventoryStatus + * @param projectCode + * @param qty + * @return + */ + public List getBalanceByBatchOffShelf(String itemCode, String inventoryStatus, String projectCode, BigDecimal qty) { + // 批次策略 + RuleRespVO ruleRespVOBatch = ruleService.batch(null, null,null,null,null,projectCode,itemCode); + JSONObject jsonObjectBatch = JSONUtil.parseObj(ruleRespVOBatch.getConfiguration()); + // 下架策略 + RuleRespVO ruleRespVOOffShelf = ruleService.offShelf(null,null,null,null,null,projectCode,itemCode,inventoryStatus,null,null); + JSONObject jsonObjectOffShelf = JSONUtil.parseObj(ruleRespVOOffShelf.getConfiguration()); + // 查询库存余额 + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.select("item_code", "batch", "SUM(qty) as qty", "packing_number", "container_number", "warehouse_code", "area_code", "location_group_code", "location_code", "produce_date", "arrive_date"); + if (itemCode != null && !itemCode.equals("")) { + queryWrapper.eq("item_code", itemCode); + } else { + return null; + } + if (inventoryStatus != null && !inventoryStatus.equals("")) { + queryWrapper.eq("inventory_status", inventoryStatus); + } else { + return null; + } + // 根据下架策略 作为查询库存余额条件 + // 仓库 + if (jsonObjectOffShelf.get("WarehouseCode") != null && !jsonObjectOffShelf.get("WarehouseCode").equals("")) { + queryWrapper.eq("warehouse_code", jsonObjectOffShelf.get("WarehouseCode")); + } + // 库区 + if (jsonObjectOffShelf.get("AreaCode") != null && !jsonObjectOffShelf.get("AreaCode").equals("")) { + queryWrapper.eq("area_code", jsonObjectOffShelf.get("AreaCode")); + } + // 库位组 + if (jsonObjectOffShelf.get("LocationGroupCode") != null && !jsonObjectOffShelf.get("LocationGroupCode").equals("")) { + queryWrapper.eq("location_group_code", jsonObjectOffShelf.get("LocationGroupCode")); + } + // 库位 + if (jsonObjectOffShelf.get("LocationCode") != null && !jsonObjectOffShelf.get("LocationCode").equals("")) { + queryWrapper.eq("location_code", jsonObjectOffShelf.get("LocationCode")); + } + // 根据下架策略 作为查询库存余额分组 + // 发料包装类型——按 包装 + if (jsonObjectOffShelf.get("IssueStorageType") != null && jsonObjectOffShelf.get("IssueStorageType").equals("1")) { + queryWrapper.groupBy("packing_number"); + } + // 发料包装类型——按 容器 + if (jsonObjectOffShelf.get("IssueStorageType") != null && jsonObjectOffShelf.get("IssueStorageType").equals("2")) { + queryWrapper.groupBy("container_number"); + } + // 发料包装类型——按 单件 + if (jsonObjectOffShelf.get("IssueStorageType") != null && jsonObjectOffShelf.get("IssueStorageType").equals("3")) { + queryWrapper.groupBy("item_code", "batch", "qty", "packing_number", "container_number", "warehouse_code", "area_code", "location_group_code", "location_code", "expire_date", "produce_date", "arrive_date"); + } + // 根据批次策略 作为查询库存余额排序 + // 批次类型——按 生产时间 + if (jsonObjectBatch.get("BatchType") != null && jsonObjectBatch.get("BatchType").equals("0")) { + // ASC = 0,正向 + if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("0")) { + queryWrapper.orderByAsc("produce_date"); + } + // DESC = 1,逆向 + if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("1")) { + queryWrapper.orderByDesc("produce_date"); + } + } + // 批次类型——按 到货时间 + if (jsonObjectBatch.get("BatchType") != null && jsonObjectBatch.get("BatchType").equals("1")) { + // ASC = 0,正向 + if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("0")) { + queryWrapper.orderByAsc("arrive_date"); + } + // DESC = 1,逆向 + if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("1")) { + queryWrapper.orderByDesc("arrive_date"); + } + } + // 批次类型——按 失效时间 + if (jsonObjectBatch.get("BatchType") != null && jsonObjectBatch.get("BatchType").equals("2")) { + // ASC = 0,正向 + if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("0")) { + queryWrapper.orderByAsc("expire_date"); + } + // DESC = 1,逆向 + if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("1")) { + queryWrapper.orderByDesc("expire_date"); + } + } + // 批次类型——按 供应商批次 + if (jsonObjectBatch.get("BatchType") != null && jsonObjectBatch.get("BatchType").equals("3")) { +// TODO: 供应商批次 ??? 不知道怎么搞了 + } + // 批次类型——按 供应商优先级 + if (jsonObjectBatch.get("BatchType") != null && jsonObjectBatch.get("BatchType").equals("4")) { +// TODO: 供应商优先级 ??? 不知道怎么搞了 + } + // 批次类型——按 其它批次 + if (jsonObjectBatch.get("BatchType") != null && jsonObjectBatch.get("BatchType").equals("5")) { + // ASC = 0,正向 + if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("0")) { + queryWrapper.orderByAsc("batch"); + } + // DESC = 1,逆向 + if (jsonObjectBatch.get("BatchDirection") != null && jsonObjectBatch.get("BatchDirection").equals("1")) { + queryWrapper.orderByDesc("batch"); + } + } + // 数量排序方向 正向 + if (jsonObjectOffShelf.get("QtyOrderDirection") != null && jsonObjectOffShelf.get("QtyOrderDirection").equals("ASC")) { + queryWrapper.orderByAsc("qty"); + } + // 数量排序方向 逆向 + if (jsonObjectOffShelf.get("QtyOrderDirection") != null && jsonObjectOffShelf.get("QtyOrderDirection").equals("DESC")) { + queryWrapper.orderByDesc("qty"); + } + + // 任务子表数据 + List balanceDOListJob = new ArrayList<>(); + List balanceDOList = balanceMapper.selectList(queryWrapper); + BigDecimal countQty = new BigDecimal(0.000000); + for (BalanceDO balanceDO: balanceDOList) { + // 查询 预计出 求和 数量 +// TODO: 后续完善 根据 管理精度查询 + QueryWrapper queryWrapperExpectout = new QueryWrapper(); + queryWrapperExpectout.select("SUM(qty) as qty"); + queryWrapperExpectout.eq("item_code", balanceDO.getItemCode()); + if (balanceDO.getPackingNumber() != null && !balanceDO.getPackingNumber().equals("")) queryWrapperExpectout.eq("packing_number", balanceDO.getPackingNumber()); + if (balanceDO.getBatch() != null && !balanceDO.getBatch().equals("")) queryWrapperExpectout.eq("batch", balanceDO.getBatch()); + queryWrapperExpectout.groupBy("item_code","packing_number", "batch"); + ExpectoutDO expectoutDO = expectoutMapper.selectOne(queryWrapperExpectout); + BigDecimal countQtyExpectout = new BigDecimal(0.000000); + if (expectoutDO != null) { + countQtyExpectout = expectoutDO.getQty(); + } + // balanceDO.getQty().subtract(countQtyExpectout) 扣减预计出数量 + countQty = countQty.add(balanceDO.getQty().subtract(countQtyExpectout)); + balanceDOListJob.add(balanceDO); + // 数据列表循环累加 直到总和大于等于当前物品的qty {countQty >= balanceDO.getQty()} + if (countQty.compareTo(qty) != -1) { + break; + } + } + return balanceDOListJob; + } + }