From 1ac50c2c5f4f9a0671bbcf49ceeb47732fa992a7 Mon Sep 17 00:00:00 2001 From: x_z Date: Wed, 28 Sep 2022 20:58:00 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E7=94=9F=E6=88=90=E5=BA=93?= =?UTF-8?q?=E5=AD=98=E6=95=B0=E6=8D=AE=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/inout/UdiTraceController.java | 2 +- .../req/inout/WarehouseQueryRequest.java | 33 ++++ .../service/inout/InvProductService.java | 2 +- .../admin/service/inout/WarehouseService.java | 1 + .../admin/thread/InvProductsTrService.java | 152 +++++++++++------- .../udi/admin/thread/TransInoutService.java | 9 +- 6 files changed, 133 insertions(+), 66 deletions(-) diff --git a/src/main/java/com/glxp/udi/admin/controller/inout/UdiTraceController.java b/src/main/java/com/glxp/udi/admin/controller/inout/UdiTraceController.java index abc527a..02715a3 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inout/UdiTraceController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inout/UdiTraceController.java @@ -170,7 +170,7 @@ public class UdiTraceController { if (udiInfoEntities != null) { if (udiInfoEntities.size() > 1) {//多级包装,查所有 FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest(); - filterInvProductDetailRequest.setProductIdFk(udiInfoEntity.getUuid()); + filterInvProductDetailRequest.setProductIdFk(String.valueOf(udiInfoEntity.getId())); filterInvProductDetailRequest.setBatchNo(udiEntity.getBatchNo()); if (warehouseQueryRequest.getCustomerId() != null) { filterInvProductDetailRequest.setCustomerId(warehouseQueryRequest.getCustomerId() + ""); diff --git a/src/main/java/com/glxp/udi/admin/req/inout/WarehouseQueryRequest.java b/src/main/java/com/glxp/udi/admin/req/inout/WarehouseQueryRequest.java index 3d28a5c..4cbcdc3 100644 --- a/src/main/java/com/glxp/udi/admin/req/inout/WarehouseQueryRequest.java +++ b/src/main/java/com/glxp/udi/admin/req/inout/WarehouseQueryRequest.java @@ -6,14 +6,47 @@ import lombok.Data; @Data public class WarehouseQueryRequest extends ListPageRequest { + /** + * 单据流水号 + */ private String corpOrderId; + + /** + * 码 + */ private String code; + + /** + * DI标识 + */ private String udi; + + /** + * 批次号 + */ private String batchNo; + + /** + * 单据号 + */ private String orderId; + + /** + * DI标识 + */ private String nameCode; private String lastId; + + /** + * 客户ID + */ private String customerId; + private Integer filterType; + + /** + * 产品ID + */ + private String relId; } diff --git a/src/main/java/com/glxp/udi/admin/service/inout/InvProductService.java b/src/main/java/com/glxp/udi/admin/service/inout/InvProductService.java index 87cdc0c..8d3e555 100644 --- a/src/main/java/com/glxp/udi/admin/service/inout/InvProductService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/InvProductService.java @@ -45,7 +45,7 @@ public class InvProductService { return invProductDao.selectList(wrapper); } - public InvProductEntity selectByUuid(String relIdFk, String batchNo, String customerId, String locStorageCode) { + public InvProductEntity selectByRelIdFk(String relIdFk, String batchNo, String customerId, String locStorageCode) { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StrUtil.isNotBlank(relIdFk), "relIdFk", relIdFk) .eq(StrUtil.isNotBlank(batchNo), "batchNo", batchNo) diff --git a/src/main/java/com/glxp/udi/admin/service/inout/WarehouseService.java b/src/main/java/com/glxp/udi/admin/service/inout/WarehouseService.java index d7f1986..8fea0d7 100644 --- a/src/main/java/com/glxp/udi/admin/service/inout/WarehouseService.java +++ b/src/main/java/com/glxp/udi/admin/service/inout/WarehouseService.java @@ -57,6 +57,7 @@ public class WarehouseService { private QueryWrapper buildCodesQueryWrapper(WarehouseQueryRequest warehouseQueryRequest) { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StrUtil.isNotBlank(warehouseQueryRequest.getCode()), "code", warehouseQueryRequest.getCode()) + .eq(StrUtil.isNotBlank(warehouseQueryRequest.getRelId()), "relId", warehouseQueryRequest.getRelId()) .eq(null != warehouseQueryRequest.getCorpOrderId(), "corpOrderId", warehouseQueryRequest.getCorpOrderId()) .eq(StrUtil.isNotBlank(warehouseQueryRequest.getOrderId()), "orderId", warehouseQueryRequest.getOrderId()) .eq(StrUtil.isNotBlank(warehouseQueryRequest.getCustomerId()), "customerId", warehouseQueryRequest.getCustomerId()) diff --git a/src/main/java/com/glxp/udi/admin/thread/InvProductsTrService.java b/src/main/java/com/glxp/udi/admin/thread/InvProductsTrService.java index ff936df..e66e4d7 100644 --- a/src/main/java/com/glxp/udi/admin/thread/InvProductsTrService.java +++ b/src/main/java/com/glxp/udi/admin/thread/InvProductsTrService.java @@ -51,77 +51,107 @@ public class InvProductsTrService { orderFilterRequest.setId(orderId); List orderEntities = orderService.findAll(orderFilterRequest); OrderEntity orderEntity = orderEntities.get(0); - String customerId = orderEntity.getCustomerId() + ""; + String customerId = String.valueOf(orderEntity.getCustomerId()); if (orderEntity.getStatus().equals(ConstantStatus.ORDER_STATUS_SUCCESS)) { FilterOrderDetailRequest filterOrderDetailRequest = new FilterOrderDetailRequest(); filterOrderDetailRequest.setOrderId(orderId); List erpOrderEntities = myErpOrderService.filterOrderDetails(filterOrderDetailRequest); if (erpOrderEntities != null && erpOrderEntities.size() > 0) { for (OrderDetailEntity orderDetailEntity : erpOrderEntities) { - String nameCode = orderDetailEntity.getNameCode(); - UdiInfoEntity udiInfoEntity = udiInfoService.findByNameCode(nameCode, customerId); - InvProductEntity invProductEntity = invProductService.selectByUuid(udiInfoEntity.getUuid(), orderDetailEntity.getBatchNo(), orderEntity.getCustomerId() + "", orderEntity.getLocStorageCode()); - if (invProductEntity == null) { - invProductEntity = new InvProductEntity(); - invProductEntity.setRelIdFk(String.valueOf(udiInfoEntity.getId())); - invProductEntity.setBatchNo(orderDetailEntity.getBatchNo()); - invProductEntity.setCustomerId(orderEntity.getCustomerId() + ""); - invProductEntity.setExpireDate(orderDetailEntity.getExpireDate()); - invProductEntity.setProductDate(orderDetailEntity.getProduceDate()); - invProductEntity.setGgxh(orderDetailEntity.getGgxh()); - invProductEntity.setNameCode(orderDetailEntity.getNameCode()); - invProductEntity.setProductsName(orderDetailEntity.getProductName()); - invProductEntity.setYlqxzcrbarmc(orderDetailEntity.getProductCompany()); - invProductEntity.setZczbhhzbapzbh(orderDetailEntity.getZczbhhzbapzbh()); - invProductEntity.setLocStorageCode(orderEntity.getLocStorageCode()); - invProductEntity.setManufactory(udiInfoEntity.getManufactory()); - if (orderEntity.getMainAction().equals(TypeConstant.TYPE_OUT)) { - invProductEntity.setOutCount(orderDetailEntity.getCount()); - invProductEntity.setInCount(0); - } else if (orderEntity.getMainAction().equals(TypeConstant.TYPE_PUT)) { - invProductEntity.setInCount(orderDetailEntity.getCount()); - invProductEntity.setOutCount(0); - } - invProductService.insertInvProduct(invProductEntity); - invProductEntity = invProductService.selectByUuid(invProductEntity.getRelIdFk(), invProductEntity.getBatchNo(), orderEntity.getCustomerId() + "", orderEntity.getLocStorageCode()); - } else { - if (orderEntity.getMainAction().equals(TypeConstant.TYPE_OUT)) { - invProductEntity.setOutCount(invProductEntity.getOutCount() + orderDetailEntity.getCount()); - } else if (orderEntity.getMainAction().equals(TypeConstant.TYPE_PUT)) { - invProductEntity.setInCount(invProductEntity.getInCount() + orderDetailEntity.getCount()); - } - invProductService.updateInvProduct(invProductEntity); - } - - //查询码详情数据,用于生成库存 - WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest(); - warehouseQueryRequest.setOrderId(orderId); - List warehouseEntities = codesService.filterWarehouse(warehouseQueryRequest); - if (CollUtil.isNotEmpty(warehouseEntities)) { - for (WarehouseEntity warehouseEntity : warehouseEntities) { - UdiInfoEntity tempUdi = udiInfoService.findByNameCode(warehouseEntity.getNameCode(), customerId); - InvProductDetailEntity invProductDetailEntity = new InvProductDetailEntity(); - invProductDetailEntity.setProductIdFk(invProductEntity.getRelIdFk() + ""); - invProductDetailEntity.setInvProductIdFk(String.valueOf(invProductEntity.getId())); - invProductDetailEntity.setCode(warehouseEntity.getCode()); - invProductDetailEntity.setOrderIdFk(warehouseEntity.getOrderId()); - int actCount = inoutUtils.getActCount(tempUdi); - invProductDetailEntity.setCount(actCount * warehouseEntity.getCount()); - invProductDetailEntity.setAction(warehouseEntity.getAction()); - invProductDetailEntity.setBatchNo(warehouseEntity.getBatchNo()); - invProductDetailEntity.setMainAction(warehouseEntity.getMainAction()); - invProductDetailEntity.setProductDate(warehouseEntity.getProduceDate()); - invProductDetailEntity.setExpireDate(warehouseEntity.getExpireDate()); - invProductDetailEntity.setUpdateTime(new Date()); - invProductDetailEntity.setCustomerId(orderEntity.getCustomerId() + ""); - invProductDetailEntity.setLocStorageCode(warehouseEntity.getLocStorageCode()); - invProductDetailService.insertInvProduct(invProductDetailEntity); - } - } + //生成或更新库存数据 + InvProductEntity invProductEntity = getInvProductEntity(orderEntity, customerId, orderDetailEntity); + //生成库存详情数据 + genInvProductDetail(orderId, invProductEntity, customerId); } } } } + /** + * 添加 / 更新库存数据 + * + * @param orderEntity 单据数据 + * @param customerId 客户ID + * @param orderDetailEntity 单据详情数据 + * @return + */ + private InvProductEntity getInvProductEntity(OrderEntity orderEntity, String customerId, OrderDetailEntity orderDetailEntity) { + String nameCode = orderDetailEntity.getNameCode(); + UdiInfoEntity udiInfoEntity = udiInfoService.findByNameCode(nameCode, customerId); + InvProductEntity invProductEntity = invProductService.selectByRelIdFk(String.valueOf(udiInfoEntity.getId()), orderDetailEntity.getBatchNo(), orderEntity.getCustomerId() + "", orderEntity.getLocStorageCode()); + if (invProductEntity == null) { + invProductEntity = new InvProductEntity(); + invProductEntity.setRelIdFk(String.valueOf(udiInfoEntity.getId())); + invProductEntity.setBatchNo(orderDetailEntity.getBatchNo()); + invProductEntity.setCustomerId(orderEntity.getCustomerId() + ""); + invProductEntity.setExpireDate(orderDetailEntity.getExpireDate()); + invProductEntity.setProductDate(orderDetailEntity.getProduceDate()); + invProductEntity.setGgxh(orderDetailEntity.getGgxh()); + invProductEntity.setNameCode(orderDetailEntity.getNameCode()); + invProductEntity.setProductsName(orderDetailEntity.getProductName()); + invProductEntity.setYlqxzcrbarmc(orderDetailEntity.getProductCompany()); + invProductEntity.setZczbhhzbapzbh(orderDetailEntity.getZczbhhzbapzbh()); + invProductEntity.setLocStorageCode(orderEntity.getLocStorageCode()); + invProductEntity.setManufactory(udiInfoEntity.getManufactory()); + if (orderEntity.getMainAction().equals(TypeConstant.TYPE_OUT)) { + invProductEntity.setOutCount(orderDetailEntity.getCount()); + invProductEntity.setInCount(0); + } else if (orderEntity.getMainAction().equals(TypeConstant.TYPE_PUT)) { + invProductEntity.setInCount(orderDetailEntity.getCount()); + invProductEntity.setOutCount(0); + } + //生成库存数据 + invProductService.insertInvProduct(invProductEntity); + invProductEntity = invProductService.selectByRelIdFk(invProductEntity.getRelIdFk(), invProductEntity.getBatchNo(), orderEntity.getCustomerId() + "", orderEntity.getLocStorageCode()); + } else { + if (orderEntity.getMainAction().equals(TypeConstant.TYPE_OUT)) { + invProductEntity.setOutCount(invProductEntity.getOutCount() + orderDetailEntity.getCount()); + } else if (orderEntity.getMainAction().equals(TypeConstant.TYPE_PUT)) { + invProductEntity.setInCount(invProductEntity.getInCount() + orderDetailEntity.getCount()); + } + //库存存在,更新库存数据 + invProductService.updateInvProduct(invProductEntity); + } + return invProductEntity; + } + + /** + * 生成库存详情 + * + * @param orderId 单据号 + * @param invProductEntity 库存信息 + * @param customerId 客户ID + */ + private void genInvProductDetail(String orderId, InvProductEntity invProductEntity, String customerId) { + //查询码详情数据,用于生成库存 + WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest(); + warehouseQueryRequest.setOrderId(orderId); + warehouseQueryRequest.setNameCode(invProductEntity.getNameCode()); + warehouseQueryRequest.setRelId(invProductEntity.getRelIdFk()); + warehouseQueryRequest.setBatchNo(invProductEntity.getBatchNo()); + List warehouseEntities = codesService.filterWarehouse(warehouseQueryRequest); + if (CollUtil.isNotEmpty(warehouseEntities)) { + for (WarehouseEntity warehouseEntity : warehouseEntities) { + UdiInfoEntity tempUdi = udiInfoService.findByNameCode(warehouseEntity.getNameCode(), customerId); + InvProductDetailEntity invProductDetailEntity = new InvProductDetailEntity(); + invProductDetailEntity.setProductIdFk(String.valueOf(invProductEntity.getRelIdFk())); + invProductDetailEntity.setInvProductIdFk(String.valueOf(invProductEntity.getId())); + invProductDetailEntity.setCode(warehouseEntity.getCode()); + invProductDetailEntity.setOrderIdFk(warehouseEntity.getOrderId()); + int actCount = inoutUtils.getActCount(tempUdi); + invProductDetailEntity.setCount(actCount * warehouseEntity.getCount()); + invProductDetailEntity.setAction(warehouseEntity.getAction()); + invProductDetailEntity.setBatchNo(warehouseEntity.getBatchNo()); + invProductDetailEntity.setMainAction(warehouseEntity.getMainAction()); + invProductDetailEntity.setProductDate(warehouseEntity.getProduceDate()); + invProductDetailEntity.setExpireDate(warehouseEntity.getExpireDate()); + invProductDetailEntity.setUpdateTime(new Date()); + invProductDetailEntity.setCustomerId(customerId); + invProductDetailEntity.setLocStorageCode(warehouseEntity.getLocStorageCode()); + invProductDetailService.insertInvProduct(invProductDetailEntity); + } + } + } + } \ No newline at end of file diff --git a/src/main/java/com/glxp/udi/admin/thread/TransInoutService.java b/src/main/java/com/glxp/udi/admin/thread/TransInoutService.java index f8ea956..dabd48c 100644 --- a/src/main/java/com/glxp/udi/admin/thread/TransInoutService.java +++ b/src/main/java/com/glxp/udi/admin/thread/TransInoutService.java @@ -63,7 +63,8 @@ public class TransInoutService { public void transInout(OrderEntity orderEntity) { OrderFilterRequest orderFilterRequest = new OrderFilterRequest(); orderFilterRequest.setCorpOrderId(orderEntity.getCorpOrderId()); - orderFilterRequest.setStatus(ConstantStatus.ORDER_STATUS_SUCCESS); //查询已完成单据 + //查询已完成单据 + orderFilterRequest.setStatus(ConstantStatus.ORDER_STATUS_SUCCESS); List orderEntities = orderService.findAll(orderFilterRequest); OrderEntity tempEntity = new OrderEntity(); tempEntity.setOrderId(orderEntity.getOrderId()); @@ -178,11 +179,13 @@ public class TransInoutService { insertList.clear(); //单据处理完成后判断单据类型是否开启二次验收校验,设置验收状态 if (bussinessTypeEntity.isSecCheckEnable()) { - tempEntity.setReceiveStatus(ConstantStatus.RECEIVE_UN); //验收状态设置为待验收 + //验收状态设置为待验收 + tempEntity.setReceiveStatus(ConstantStatus.RECEIVE_UN); tempEntity.setRemark("待验收"); orderService.updateOrder(tempEntity); } else { - tempEntity.setReceiveStatus(ConstantStatus.RECEIVE_NOT); //此单据类型不需要验收 + //此单据类型不需要验收 + tempEntity.setReceiveStatus(ConstantStatus.RECEIVE_NOT); tempEntity.setRemark("已完成"); orderService.updateOrder(tempEntity); invProductsTrService.genInvProducts(orderEntity.getOrderId());