From 99c25cee34ac89c4582b9772795b2c8555cb5f80 Mon Sep 17 00:00:00 2001 From: x_z Date: Tue, 20 Sep 2022 23:32:55 +0800 Subject: [PATCH] =?UTF-8?q?1.=E9=87=8D=E5=86=99=E6=B6=89=E5=8F=8Amongodb?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=93=8D=E4=BD=9C=E7=9A=84=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../udi/admin/controller/TestController.java | 8 +- .../inout/InvProductsController.java | 23 +- .../controller/inout/OrderController.java | 67 +++--- .../inout/StockQRCodeTextController.java | 8 +- .../inout/UdiRelevanceController.java | 6 +- .../controller/inout/UdiTraceController.java | 39 ++-- .../controller/inout/WareHouseController.java | 54 +++-- .../glxp/udi/admin/dao/inout/CodesDao.java | 35 +++ .../udi/admin/dao/inout/CodesTempDao.java | 25 +++ .../service/InvProductDetailMdService.java | 175 --------------- .../service/InvProductDetailService.java | 114 ++++++++++ .../mongo/service/InvProductService.java | 207 ++++-------------- .../udi/admin/mongo/service/OrderService.java | 19 +- ...seMdService.java => WarehouseService.java} | 180 +++++---------- .../mongo/service/WarehouseTempMdService.java | 102 --------- .../mongo/service/WarehouseTempService.java | 74 +++++++ .../admin/thread/InvProductsTrService.java | 12 +- .../admin/thread/SubmitOrderToSpmsTask.java | 17 +- .../udi/admin/thread/TransInoutService.java | 21 +- .../glxp/udi/admin/thread/TransInoutTask.java | 10 +- .../glxp/udi/admin/util/inout/InoutUtils.java | 7 +- .../mybatis/mapper/inout/CodesDao.xml | 25 +++ .../mybatis/mapper/inout/CodesTempDao.xml | 17 ++ 23 files changed, 523 insertions(+), 722 deletions(-) delete mode 100644 src/main/java/com/glxp/udi/admin/mongo/service/InvProductDetailMdService.java create mode 100644 src/main/java/com/glxp/udi/admin/mongo/service/InvProductDetailService.java rename src/main/java/com/glxp/udi/admin/mongo/service/{WarehouseMdService.java => WarehouseService.java} (50%) delete mode 100644 src/main/java/com/glxp/udi/admin/mongo/service/WarehouseTempMdService.java create mode 100644 src/main/java/com/glxp/udi/admin/mongo/service/WarehouseTempService.java create mode 100644 src/main/resources/mybatis/mapper/inout/CodesDao.xml create mode 100644 src/main/resources/mybatis/mapper/inout/CodesTempDao.xml diff --git a/src/main/java/com/glxp/udi/admin/controller/TestController.java b/src/main/java/com/glxp/udi/admin/controller/TestController.java index 67b2f05..3115a9a 100644 --- a/src/main/java/com/glxp/udi/admin/controller/TestController.java +++ b/src/main/java/com/glxp/udi/admin/controller/TestController.java @@ -9,7 +9,7 @@ import com.glxp.udi.admin.entity.inout.*; import com.glxp.udi.admin.entity.inout.WarehousetempEntity; import com.glxp.udi.admin.entity.mongo.*; import com.glxp.udi.admin.mongo.dao.*; -import com.glxp.udi.admin.mongo.service.InvProductDetailMdService; +import com.glxp.udi.admin.mongo.service.InvProductDetailService; import com.glxp.udi.admin.mongo.service.InvProductService; import com.glxp.udi.admin.mongo.service.OrderDetailService; import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest; @@ -31,7 +31,7 @@ public class TestController { @Resource private InvProductService invProductService; @Resource - private InvProductDetailMdService invProductDetailMdService; + private InvProductDetailService invProductDetailService; @Resource private UdiInfoDao udiInfoDao; @@ -102,7 +102,7 @@ public class TestController { }); //刷新库存详情表数据 - List invProductDetailEntities = invProductDetailMdService.filterAllInvProduct(new FilterInvProductDetailRequest()); + List invProductDetailEntities = invProductDetailService.filterAllInvProduct(new FilterInvProductDetailRequest()); invProductDetailEntities.forEach(invProductDetailEntity -> { UdiInfoEntity udiInfoEntity = udiInfoDao.selectOne(new QueryWrapper().eq(StrUtil.isNotBlank(invProductDetailEntity.getProductIdFk()), "uuid", invProductDetailEntity.getProductIdFk()) .eq(StrUtil.isNotBlank(invProductDetailEntity.getCustomerId()), "customerId", invProductDetailEntity.getCustomerId()) @@ -110,7 +110,7 @@ public class TestController { if (null != udiInfoEntity) { invProductDetailEntity.setProductIdFk(String.valueOf(udiInfoEntity.getId())); log.info("刷新库存详情"); - invProductDetailMdService.updateInvProduct(invProductDetailEntity); + invProductDetailService.updateInvProduct(invProductDetailEntity); } }); return "success"; diff --git a/src/main/java/com/glxp/udi/admin/controller/inout/InvProductsController.java b/src/main/java/com/glxp/udi/admin/controller/inout/InvProductsController.java index 2a74ace..bbece76 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inout/InvProductsController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inout/InvProductsController.java @@ -10,9 +10,8 @@ import com.glxp.udi.admin.entity.auth.AuthAdmin; import com.glxp.udi.admin.entity.inout.InvProductDetailEntity; import com.glxp.udi.admin.entity.inout.InvProductEntity; import com.glxp.udi.admin.entity.inout.UdiInfoEntity; -import com.glxp.udi.admin.mongo.service.InvProductDetailMdService; +import com.glxp.udi.admin.mongo.service.InvProductDetailService; import com.glxp.udi.admin.mongo.service.InvProductService; -import com.glxp.udi.admin.mongo.utils.PageResult; import com.glxp.udi.admin.req.inout.DeleteRequest; import com.glxp.udi.admin.req.inout.FilterInvProductDetailRequest; import com.glxp.udi.admin.req.inout.FilterUdiInfoRequest; @@ -44,7 +43,7 @@ public class InvProductsController { @Resource private InvProductService invProductService; @Resource - private InvProductDetailMdService invProductDetailService; + private InvProductDetailService invProductDetailService; @Resource private UdiInfoService udiInfoService; @Resource @@ -80,8 +79,8 @@ public class InvProductsController { codes.addAll(warehouseUserService.selectCodeByUserId(user.getId())); } filterInvProductRequest.setInvCodes(codes); - PageResult invProductEntityPageResult = invProductService.filterInvProduct(filterInvProductRequest); - List invProductEntities = invProductEntityPageResult.getList(); + IPage page = invProductService.filterInvProduct(filterInvProductRequest); + List invProductEntities = page.getRecords(); List result = new ArrayList<>(); for (InvProductEntity invProductEntity : invProductEntities) { InvProductResponse invProductResponse = new InvProductResponse(); @@ -92,7 +91,7 @@ public class InvProductsController { } PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(invProductEntityPageResult.getTotal()); + pageSimpleResponse.setTotal(page.getTotal()); pageSimpleResponse.setList(result); return ResultVOUtils.success(pageSimpleResponse); } @@ -122,9 +121,9 @@ public class InvProductsController { if (CollUtil.isNotEmpty(invCodes)) { filterInvProductRequest.setInvCodes(invCodes); } - PageResult invProductEntityPageResult = invProductService.filterInvProduct(filterInvProductRequest); + IPage page = invProductService.filterInvProduct(filterInvProductRequest); - List invProductEntities = invProductEntityPageResult.getList(); + List invProductEntities = page.getRecords(); List invProductResponses = new ArrayList<>(); for (InvProductEntity invProductEntity : invProductEntities) { UdiInfoEntity udiInfoEntity = udiInfoService.findByUuid(invProductEntity.getRelIdFk(), invProductEntity.getCustomerId()); @@ -141,7 +140,7 @@ public class InvProductsController { } PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(invProductEntityPageResult.getTotal()); + pageSimpleResponse.setTotal(page.getTotal()); pageSimpleResponse.setList(invProductResponses); return ResultVOUtils.success(pageSimpleResponse); } @@ -159,8 +158,8 @@ public class InvProductsController { } } filterInvProductRequest.setInvCodes(codes); - PageResult pageResult = invProductDetailService.filterInvProduct(filterInvProductRequest); - List invProductDetailEntities = pageResult.getList(); + IPage page = invProductDetailService.filterInvProduct(filterInvProductRequest); + List invProductDetailEntities = page.getRecords(); List invProductDetailResponses = new ArrayList<>(invProductDetailEntities.size()); if (CollUtil.isNotEmpty(invProductDetailEntities)) { @@ -179,7 +178,7 @@ public class InvProductsController { } PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(pageResult.getTotal()); + pageSimpleResponse.setTotal(page.getTotal()); pageSimpleResponse.setList(invProductDetailResponses); return ResultVOUtils.success(pageSimpleResponse); } diff --git a/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java b/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java index d090e86..3b18c0d 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inout/OrderController.java @@ -3,6 +3,7 @@ package com.glxp.udi.admin.controller.inout; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DatePattern; +import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONObject; @@ -16,13 +17,10 @@ import com.glxp.udi.admin.entity.auth.AuthAdmin; import com.glxp.udi.admin.entity.basic.BussinessTypeEntity; import com.glxp.udi.admin.entity.info.PlatformEntity; import com.glxp.udi.admin.entity.inout.*; -import com.glxp.udi.admin.entity.mongo.OrderMdEntity; -import com.glxp.udi.admin.entity.mongo.WarehouseMdEntity; import com.glxp.udi.admin.mongo.service.OrderDetailService; import com.glxp.udi.admin.mongo.service.OrderService; -import com.glxp.udi.admin.mongo.service.WarehouseMdService; -import com.glxp.udi.admin.mongo.service.WarehouseTempMdService; -import com.glxp.udi.admin.mongo.utils.PageResult; +import com.glxp.udi.admin.mongo.service.WarehouseService; +import com.glxp.udi.admin.mongo.service.WarehouseTempService; import com.glxp.udi.admin.req.inout.*; import com.glxp.udi.admin.res.PageSimpleResponse; import com.glxp.udi.admin.res.inout.OrderMdResponse; @@ -66,7 +64,7 @@ public class OrderController { @Resource private OrderService orderService; @Resource - private WarehouseMdService warehouseMdService; + private WarehouseService warehouseService; @Resource private UnitMaintainService unitMaintainService; @Resource @@ -86,7 +84,7 @@ public class OrderController { @Resource private GennerOrderUtils gennerOrderUtils; @Resource - private WarehouseTempMdService warehouseTempMdService; + private WarehouseTempService warehouseTempService; @AuthRuleAnnotation("") @GetMapping("/warehouse/inout/order/filter") @@ -178,10 +176,10 @@ public class OrderController { orderFilterRequest.setInvCodes(codes); orderFilterRequest.setCustomerId(authAdmin.getCustomerId()); orderFilterRequest.setStatus(orderFilterRequest.getStatus()); - PageResult pageResult = orderService.filterList(orderFilterRequest); - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(pageResult.getTotal()); - pageSimpleResponse.setList(pageResult.getList()); + IPage page = orderService.filterList(orderFilterRequest); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(page.getTotal()); + pageSimpleResponse.setList(page.getRecords()); return ResultVOUtils.success(pageSimpleResponse); } @@ -205,10 +203,10 @@ public class OrderController { } orderFilterRequest.setInvCodes(invCodes); - PageResult pageResult = orderService.filterList(orderFilterRequest); - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(pageResult.getTotal()); - pageSimpleResponse.setList(pageResult.getList()); + IPage page = orderService.filterList(orderFilterRequest); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(page.getTotal()); + pageSimpleResponse.setList(page.getRecords()); return ResultVOUtils.success(pageSimpleResponse); } @@ -231,10 +229,10 @@ public class OrderController { orderFilterRequest.setInvCodes(codes); orderFilterRequest.setCustomerId(authAdmin.getCustomerId()); orderFilterRequest.setStatus(ConstantStatus.ORDER_STATUS_ADDITIONAL); - PageResult pageResult = orderService.filterList(orderFilterRequest); + IPage page = orderService.filterList(orderFilterRequest); List responses = new ArrayList<>(); - if (CollUtil.isNotEmpty(pageResult.getList())) { - pageResult.getList().forEach(order -> { + if (CollUtil.isNotEmpty(page.getRecords())) { + page.getRecords().forEach(order -> { OrderMdResponse response = new OrderMdResponse(); BeanUtil.copyProperties(order, response); String name = invWarehouseDao.selectNameByCode(order.getLocStorageCode()); @@ -245,7 +243,7 @@ public class OrderController { }); } PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(pageResult.getTotal()); + pageSimpleResponse.setTotal(page.getTotal()); pageSimpleResponse.setList(responses); return ResultVOUtils.success(pageSimpleResponse); } @@ -267,28 +265,28 @@ public class OrderController { } String mainOrder = orderList.get(0); for (int i = 1; i < orderList.size(); i++) { - warehouseMdService.updateOrderId(orderList.get(i), mainOrder); + warehouseService.updateOrderId(orderList.get(i), mainOrder); DeleteRequest deleteRequest = new DeleteRequest(); deleteRequest.setOrderId(orderList.get(i)); orderService.deleteOrder(deleteRequest); } - new Thread(() -> { + ThreadUtil.execute(() -> { WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest(); warehouseQueryRequest.setOrderId(mainOrder); - List transData = warehouseMdService.filterWarehouse(warehouseQueryRequest); + List transData = warehouseService.filterWarehouse(warehouseQueryRequest); inoutUtils.generateConstrastDetail(udiInfoService, udiRelevanceService, orderDetailService, transData); - }).start(); + }); } return ResultVOUtils.success("合并成功,后台正在数据转换,请稍后刷新重试!"); } @PostMapping("/warehouse/inout/order/unit") - public BaseResponse updateUnit(@RequestBody @Valid OrderMdEntity orderEntity, BindingResult bindingResult) { + public BaseResponse updateUnit(@RequestBody @Valid OrderEntity orderEntity, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); } orderService.updateOrder(orderEntity); - warehouseMdService.updateUnit(orderEntity.getOrderId(), orderEntity.getFromCorpId(), orderEntity.getFromCorp()); + warehouseService.updateUnit(orderEntity.getOrderId(), orderEntity.getFromCorpId(), orderEntity.getFromCorp()); return ResultVOUtils.success("添加成功"); } @@ -317,7 +315,7 @@ public class OrderController { orderBean.setAction(unitMaintainEntity.getTargetAction()); WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest(); warehouseQueryRequest.setOrderId(orderEntity.getOrderId()); - List warehouseEntities = warehouseMdService.filterWarehouse(warehouseQueryRequest); + List warehouseEntities = warehouseService.filterWarehouse(warehouseQueryRequest); List codeBeans = new ArrayList<>(); UnitMaintainEntity finalUnitMaintainEntity = unitMaintainEntity; warehouseEntities.forEach(data -> { @@ -480,7 +478,7 @@ public class OrderController { String oldOrderId = originOrder.getOrderId(); String replicateNo = originOrder.getReplicateNo(); //复制单号 //查询条码 - List originCodes = warehouseMdService.findByOrderId(originOrder.getOrderId()); + List originCodes = warehouseService.findByOrderId(originOrder.getOrderId()); originOrder.setActDate(cn.hutool.core.date.DateUtil.date().toString(DatePattern.NORM_DATETIME_PATTERN)); originOrder.setFromCorp(addOrderChangeRequest.getFromCorp()); originOrder.setFromCorpId(addOrderChangeRequest.getFromCorpId()); @@ -529,7 +527,7 @@ public class OrderController { originOrder.setUpdateTime(new Date()); originOrder.setOrderId(null); orderService.insertOrder(originOrder); - warehouseTempMdService.insertTempWarehouses(supplementCodes); + warehouseTempService.insertTempWarehouses(supplementCodes); orderService.updateReplicateNo(oldOrderId, replicateNo); return ResultVOUtils.success(); } @@ -592,12 +590,13 @@ public class OrderController { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); } AuthAdmin authAdmin = customerService.getUserBean(); - OrderMdEntity orderMdEntity = orderService.findByOne(updateExportStatusRequest.getOrderId()); - orderMdEntity.setReceiveStatus(ConstantStatus.RECEIVE_ED); //验收状态修改为已验收 - orderMdEntity.setReviewUser(authAdmin.getId().intValue()); - orderMdEntity.setUpdateTime(new Date()); - orderService.updateOrder(orderMdEntity); - invProductsTrService.genInvProducts(orderMdEntity.getOrderId()); + OrderEntity orderEntity = orderService.findByOne(updateExportStatusRequest.getOrderId()); + //验收状态修改为已验收 + orderEntity.setReceiveStatus(ConstantStatus.RECEIVE_ED); + orderEntity.setReviewUser(authAdmin.getId().intValue()); + orderEntity.setUpdateTime(new Date()); + orderService.updateOrder(orderEntity); + invProductsTrService.genInvProducts(orderEntity.getOrderId()); return ResultVOUtils.success("更新成功"); } diff --git a/src/main/java/com/glxp/udi/admin/controller/inout/StockQRCodeTextController.java b/src/main/java/com/glxp/udi/admin/controller/inout/StockQRCodeTextController.java index 8728279..91a100f 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inout/StockQRCodeTextController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inout/StockQRCodeTextController.java @@ -8,10 +8,10 @@ import com.glxp.udi.admin.common.res.BaseResponse; import com.glxp.udi.admin.constant.Constant; import com.glxp.udi.admin.entity.basic.StockPrintEntity; import com.glxp.udi.admin.entity.info.CompanyEntity; +import com.glxp.udi.admin.entity.inout.OrderEntity; import com.glxp.udi.admin.entity.inout.StockOrderPrintEntity; import com.glxp.udi.admin.entity.inout.StockQRCodeTextEntity; import com.glxp.udi.admin.entity.inventory.StockPrintTempEntity; -import com.glxp.udi.admin.entity.mongo.OrderMdEntity; import com.glxp.udi.admin.entity.param.SystemPDFModuleEntity; import com.glxp.udi.admin.entity.param.SystemPDFTemplateEntity; import com.glxp.udi.admin.mongo.service.OrderService; @@ -300,12 +300,12 @@ public class StockQRCodeTextController { @PostMapping("/udiwms/pdf/template/inspection/stock/order/file") public BaseResponse inspectionStockOrderPDFFromTemplateFile( @RequestBody InspectionPDFTemplateRequest inspectionPDFTemplateRequest) { - OrderMdEntity orderMdEntity = orderService.findByOne(inspectionPDFTemplateRequest.getOrderId()); - if (orderMdEntity == null) { + OrderEntity orderEntity = orderService.findByOne(inspectionPDFTemplateRequest.getOrderId()); + if (orderEntity == null) { return ResultVOUtils.error(ResultEnum.DATA_NOT, "未找到该订单"); } SystemPDFTemplateRelevanceRequest systemPDFTemplateRelevanceRequest = new SystemPDFTemplateRelevanceRequest(); - systemPDFTemplateRelevanceRequest.setLocalAction(orderMdEntity.getAction()); + systemPDFTemplateRelevanceRequest.setLocalAction(orderEntity.getAction()); systemPDFTemplateRelevanceRequest.setModuleId(inspectionPDFTemplateRequest.getModuleId()); IPage page = systemPDFTemplateRelevanceService.filterList(systemPDFTemplateRelevanceRequest); if (page.getTotal() == 0) { diff --git a/src/main/java/com/glxp/udi/admin/controller/inout/UdiRelevanceController.java b/src/main/java/com/glxp/udi/admin/controller/inout/UdiRelevanceController.java index 9a22a08..fb4d208 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inout/UdiRelevanceController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inout/UdiRelevanceController.java @@ -8,7 +8,7 @@ import com.glxp.udi.admin.common.res.BaseResponse; import com.glxp.udi.admin.entity.inout.UdiInfoEntity; import com.glxp.udi.admin.entity.inout.WarehouseEntity; import com.glxp.udi.admin.mongo.service.InvProductService; -import com.glxp.udi.admin.mongo.service.WarehouseMdService; +import com.glxp.udi.admin.mongo.service.WarehouseService; import com.glxp.udi.admin.req.inout.DeleteRequest; import com.glxp.udi.admin.req.inout.FilterUdiInfoRequest; import com.glxp.udi.admin.req.inout.FilterWarehouseRequest; @@ -49,7 +49,7 @@ public class UdiRelevanceController { @Resource private InvProductService invProductService; @Resource - private WarehouseMdService warehouseMdService; + private WarehouseService warehouseService; //客户端器械信息下载 @GetMapping("/udi/udirel/download") @@ -101,7 +101,7 @@ public class UdiRelevanceController { FilterWarehouseRequest filterWarehouseRequest = new FilterWarehouseRequest(); filterWarehouseRequest.setCode(udiInfoEntity.getNameCode()); filterWarehouseRequest.setCustomerId(Long.valueOf(customerId)); - List warehouseEntities = warehouseMdService.findByCode(filterWarehouseRequest); + List warehouseEntities = warehouseService.findByCode(filterWarehouseRequest); if (CollUtil.isNotEmpty(warehouseEntities)) { return ResultVOUtils.error(500, "改产品已被" + warehouseEntities.get(0).getOrderId() + "订单关联不能删除"); } 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 5e0b139..18059c2 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 @@ -9,11 +9,10 @@ import com.glxp.udi.admin.entity.inout.InvProductDetailEntity; import com.glxp.udi.admin.entity.inout.OrderEntity; import com.glxp.udi.admin.entity.inout.UdiInfoEntity; import com.glxp.udi.admin.entity.inout.WarehouseEntity; -import com.glxp.udi.admin.entity.mongo.OrderMdEntity; import com.glxp.udi.admin.entity.udid.UdiEntity; -import com.glxp.udi.admin.mongo.service.InvProductDetailMdService; +import com.glxp.udi.admin.mongo.service.InvProductDetailService; import com.glxp.udi.admin.mongo.service.OrderService; -import com.glxp.udi.admin.mongo.service.WarehouseMdService; +import com.glxp.udi.admin.mongo.service.WarehouseService; import com.glxp.udi.admin.req.inout.FilterInvProductDetailRequest; import com.glxp.udi.admin.req.inout.OrderFilterRequest; import com.glxp.udi.admin.req.inout.WarehouseQueryRequest; @@ -37,7 +36,7 @@ import java.util.stream.Collectors; public class UdiTraceController { @Resource - private WarehouseMdService warehouseMdService; + private WarehouseService warehouseService; @Resource private UdiInfoService udiInfoService; @Resource @@ -45,7 +44,7 @@ public class UdiTraceController { @Resource private OrderService orderService; @Resource - private InvProductDetailMdService invProductDetailMdService; + private InvProductDetailService invProductDetailService; @GetMapping("/udiwarehouse/trace/filter") public BaseResponse list(WarehouseQueryRequest warehouseQueryRequest) { @@ -71,19 +70,19 @@ public class UdiTraceController { for (UdiInfoEntity udiInfoEntity : udiInfoEntityList) { warehouseQueryRequest.setBatchNo(udiEntity.getBatchNo()); warehouseQueryRequest.setUdi(udiInfoEntity.getNameCode()); - List temps = filterUdiTrace(warehouseQueryRequest); + List temps = filterUdiTrace(warehouseQueryRequest); if (CollUtil.isEmpty(temps)) { break; } - for (OrderMdEntity temp : temps) { + for (OrderEntity temp : temps) { UdiTraceResponse udiTraceResponse = new UdiTraceResponse(); BeanUtil.copyProperties(temp, udiTraceResponse); udiTraceResponse.setActDate(temp.getActDate()); udiTraceResponse.setYlqxzcrbarmc(udiInfoEntity.getYlqxzcrbarmc()); udiTraceResponse.setCpmctymc(udiInfoEntity.getCpmctymc()); udiTraceResponse.setGgxh(udiInfoEntity.getGgxh()); - List orderList = warehouseMdService.findByOrderId(temp.getOrderId()); + List orderList = warehouseService.findByOrderId(temp.getOrderId()); if (CollUtil.isNotEmpty(orderList)) { udiTraceResponse.setCount(orderList.get(0).getCount()); } else { @@ -117,7 +116,7 @@ public class UdiTraceController { if (StrUtil.isBlank(warehouseQueryRequest.getCode())) { return ResultVOUtils.success(Collections.emptyList()); } - List orderMdEntities = new ArrayList<>(); + List orderEntities = new ArrayList<>(); String customerId = authAdminService.getCurrentUserCustomerId(); if (!Long.valueOf(customerId).equals(110)) { warehouseQueryRequest.setCustomerId(customerId); @@ -132,27 +131,27 @@ public class UdiTraceController { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "此产品信息在耗材字典中不存在"); } List udiInfoEntities = udiInfoService.findByUuids(udiInfoEntity.getUuid(), customerId); - Set set = new HashSet<>(); + Set set = new HashSet<>(); if (udiInfoEntities != null && udiInfoEntities.size() > 0) { for (UdiInfoEntity temp : udiInfoEntities) { warehouseQueryRequest.setBatchNo(udiEntity.getBatchNo()); warehouseQueryRequest.setUdi(temp.getNameCode()); - List temps = filterUdiTrace(warehouseQueryRequest); + List temps = filterUdiTrace(warehouseQueryRequest); if (CollUtil.isNotEmpty(temps)) { set.addAll(temps); } } } - orderMdEntities.addAll(set); - if (CollUtil.isNotEmpty(orderMdEntities)) { + orderEntities.addAll(set); + if (CollUtil.isNotEmpty(orderEntities)) { //根据时间排序 - orderMdEntities = orderMdEntities.stream().sorted(Comparator.comparing(OrderMdEntity::getActDate)).collect(Collectors.toList()); + orderEntities = orderEntities.stream().sorted(Comparator.comparing(OrderEntity::getActDate)).collect(Collectors.toList()); } - Page pageResult = new Page<>(warehouseQueryRequest.getPage(), warehouseQueryRequest.getLimit()); - pageResult.setRecords(orderMdEntities); - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + Page pageResult = new Page<>(warehouseQueryRequest.getPage(), warehouseQueryRequest.getLimit()); + pageResult.setRecords(orderEntities); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); pageSimpleResponse.setTotal(pageResult.getTotal()); pageSimpleResponse.setList(pageResult.getRecords()); return ResultVOUtils.success(pageSimpleResponse); @@ -176,14 +175,14 @@ public class UdiTraceController { if (warehouseQueryRequest.getCustomerId() != null) { filterInvProductDetailRequest.setCustomerId(warehouseQueryRequest.getCustomerId() + ""); } - invProductDetailEntities = invProductDetailMdService.filterAllInvProduct(filterInvProductDetailRequest); + invProductDetailEntities = invProductDetailService.filterAllInvProduct(filterInvProductDetailRequest); } else if (udiInfoEntities.size() == 1) { //单级包装,且唯一查询条码 FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest(); filterInvProductDetailRequest.setCode(warehouseQueryRequest.getCode()); if (warehouseQueryRequest.getCustomerId() != null) { filterInvProductDetailRequest.setCustomerId(warehouseQueryRequest.getCustomerId() + ""); } - invProductDetailEntities = invProductDetailMdService.filterAllInvProduct(filterInvProductDetailRequest); + invProductDetailEntities = invProductDetailService.filterAllInvProduct(filterInvProductDetailRequest); } else { return null; } @@ -202,7 +201,7 @@ public class UdiTraceController { if (warehouseQueryRequest.getCustomerId() != null) { filterInvProductDetailRequest.setCustomerId(warehouseQueryRequest.getCustomerId() + ""); } - invProductDetailEntities = invProductDetailMdService.filterAllInvProduct(filterInvProductDetailRequest); + invProductDetailEntities = invProductDetailService.filterAllInvProduct(filterInvProductDetailRequest); } if (invProductDetailEntities != null && invProductDetailEntities.size() > 0) { List orderEntities = new ArrayList<>(); diff --git a/src/main/java/com/glxp/udi/admin/controller/inout/WareHouseController.java b/src/main/java/com/glxp/udi/admin/controller/inout/WareHouseController.java index 21d0417..6d0b2bb 100644 --- a/src/main/java/com/glxp/udi/admin/controller/inout/WareHouseController.java +++ b/src/main/java/com/glxp/udi/admin/controller/inout/WareHouseController.java @@ -2,20 +2,17 @@ package com.glxp.udi.admin.controller.inout; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.glxp.udi.admin.annotation.AuthRuleAnnotation; import com.glxp.udi.admin.common.res.BaseResponse; import com.glxp.udi.admin.constant.ConstantStatus; import com.glxp.udi.admin.entity.auth.AuthAdmin; import com.glxp.udi.admin.entity.inout.*; -import com.glxp.udi.admin.entity.mongo.OrderMdEntity; -import com.glxp.udi.admin.entity.mongo.WarehouseMdEntity; -import com.glxp.udi.admin.entity.mongo.WarehousetempMdEntity; import com.glxp.udi.admin.entity.udid.UdiEntity; import com.glxp.udi.admin.mongo.service.OrderService; -import com.glxp.udi.admin.mongo.service.WarehouseMdService; -import com.glxp.udi.admin.mongo.service.WarehouseTempMdService; -import com.glxp.udi.admin.mongo.utils.PageResult; +import com.glxp.udi.admin.mongo.service.WarehouseService; +import com.glxp.udi.admin.mongo.service.WarehouseTempService; import com.glxp.udi.admin.req.inout.*; import com.glxp.udi.admin.req.inventory.FilterInvLinkDataRequest; import com.glxp.udi.admin.res.PageSimpleResponse; @@ -52,63 +49,62 @@ public class WareHouseController { @Resource private TransInoutService transInoutService; @Resource - private WarehouseMdService warehouseMdService; + private WarehouseService warehouseService; @Resource - private WarehouseTempMdService warehouseTempMdService; + private WarehouseTempService warehouseTempService; @Resource private OrderService orderService; @Resource private UdiInfoService udiInfoService; - @AuthRuleAnnotation("") @PostMapping("warehouse/inout/postOrders") public BaseResponse postOrders(@RequestBody PostOrderRequest postOrderRequest, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); } - transInoutService.createOrder(postOrderRequest, Long.valueOf(authAdminService.getCurrentUserCustomerId())); + transInoutService.createOrder(postOrderRequest, Long.parseLong(authAdminService.getCurrentUserCustomerId())); return ResultVOUtils.success("导入成功"); } @GetMapping("admin/warehouse/inout/findByOrderId") public BaseResponse findByOrderId(WarehouseQueryRequest warehouseQueryRequest) { - PageResult pageResult = warehouseMdService.filterWarehouseByPage(warehouseQueryRequest); - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(pageResult.getTotal()); - pageSimpleResponse.setList(pageResult.getList()); + IPage page = warehouseService.filterWarehouseByPage(warehouseQueryRequest); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(page.getTotal()); + pageSimpleResponse.setList(page.getRecords()); return ResultVOUtils.success(pageSimpleResponse); } @GetMapping("admin/warehouse/inout/findErrorByOrderId") public BaseResponse findErrorByOrderId(WarehouseQueryRequest warehouseQueryRequest) { - PageResult pageResult = warehouseTempMdService.filterWarehouseByPage(warehouseQueryRequest); - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(pageResult.getTotal()); - pageSimpleResponse.setList(pageResult.getList()); + IPage page = warehouseTempService.filterWarehouseByPage(warehouseQueryRequest); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(page.getTotal()); + pageSimpleResponse.setList(page.getRecords()); return ResultVOUtils.success(pageSimpleResponse); } @AuthRuleAnnotation("") @GetMapping("warehouse/inout/deleteCodesTempById") public BaseResponse deleteCodesTempById(String id) { - WarehousetempMdEntity warehousetemp = warehouseTempMdService.findTempById(id); + WarehousetempEntity warehousetemp = warehouseTempService.findTempById(id); if (null == warehousetemp) { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); } if (warehousetemp.getCount() != null && warehousetemp.getCount() > 1) { warehousetemp.setCount(warehousetemp.getCount() - 1); - warehouseTempMdService.updateById(warehousetemp); + warehouseTempService.updateById(warehousetemp); } else { - warehouseTempMdService.deleteTempWarehouses(Collections.singletonList(warehousetemp.getId())); + warehouseTempService.deleteTempWarehouses(Collections.singletonList(warehousetemp.getId())); } - List tempByOrderId = warehouseTempMdService.findTempByOrderId(warehousetemp.getOrderId()); + List tempByOrderId = warehouseTempService.findTempByOrderId(warehousetemp.getOrderId()); if (tempByOrderId.size() == 0) { DeleteRequest deleteRequest = new DeleteRequest(); deleteRequest.setOrderId(warehousetemp.getOrderId()); - warehouseTempMdService.deleteCode(deleteRequest); + warehouseTempService.deleteCode(deleteRequest); } return ResultVOUtils.success(); } @@ -218,7 +214,7 @@ public class WareHouseController { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); } - OrderMdEntity orderEntity = orderService.findByOne(commitRequest.getOrderId()); + OrderEntity orderEntity = orderService.findByOne(commitRequest.getOrderId()); orderEntity.setStatus(ConstantStatus.ORDER_STATUS_WAIT); orderService.updateOrder(orderEntity); return ResultVOUtils.success("提交成功"); @@ -233,10 +229,10 @@ public class WareHouseController { @AuthRuleAnnotation("") @GetMapping("spms/inout/dlcode/findByOrderId") public BaseResponse downloadCodesByOrderId(WarehouseQueryRequest warehouseQueryRequest) { - PageResult pageResult = warehouseMdService.findOrdersById(warehouseQueryRequest); - PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); - pageSimpleResponse.setTotal(pageResult.getTotal()); - pageSimpleResponse.setList(pageResult.getList()); + IPage page = warehouseService.filterWarehouseByPage(warehouseQueryRequest); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(page.getTotal()); + pageSimpleResponse.setList(page.getRecords()); return ResultVOUtils.success(pageSimpleResponse); } @@ -261,7 +257,7 @@ public class WareHouseController { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "产品未维护"); } codesReplaceRequest.setUdiEntity(udiInfoEntity); - warehouseMdService.replaceCodes(codesReplaceRequest); + warehouseService.replaceCodes(codesReplaceRequest); return ResultVOUtils.success(); } diff --git a/src/main/java/com/glxp/udi/admin/dao/inout/CodesDao.java b/src/main/java/com/glxp/udi/admin/dao/inout/CodesDao.java index b5f9d30..a25e57b 100644 --- a/src/main/java/com/glxp/udi/admin/dao/inout/CodesDao.java +++ b/src/main/java/com/glxp/udi/admin/dao/inout/CodesDao.java @@ -3,10 +3,45 @@ package com.glxp.udi.admin.dao.inout; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.glxp.udi.admin.entity.inout.WarehouseEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 码表数据接口 */ @Mapper public interface CodesDao extends BaseMapper { + + /** + * 更新单位信息 + * + * @param orderId + * @param fromCorp + * @param fromCorpId + */ + void updateUnit(@Param("orderId") String orderId, @Param("fromCorp") String fromCorp, @Param("fromCorpId") String fromCorpId); + + /** + * 更新单号 + * + * @param orderId + * @param newOrderId + */ + void updateOrderId(@Param("orderId") String orderId, @Param("newOrderId") String newOrderId); + + /** + * 根据单据号查询码表 + * + * @param orderId + * @return + */ + List selectByOrderId(@Param("orderId") String orderId); + + /** + * 更新总数 + * @param count + * @param id + */ + void updateCount(@Param("count") Integer count, @Param("id") String id); } diff --git a/src/main/java/com/glxp/udi/admin/dao/inout/CodesTempDao.java b/src/main/java/com/glxp/udi/admin/dao/inout/CodesTempDao.java index 6c4168c..fb25d07 100644 --- a/src/main/java/com/glxp/udi/admin/dao/inout/CodesTempDao.java +++ b/src/main/java/com/glxp/udi/admin/dao/inout/CodesTempDao.java @@ -3,10 +3,35 @@ package com.glxp.udi.admin.dao.inout; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.glxp.udi.admin.entity.inout.WarehousetempEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 临时码表数据接口 */ @Mapper public interface CodesTempDao extends BaseMapper { + + /** + * 根据单据号查询临时码表 + * + * @param orderId + * @return + */ + List selectByOrderId(@Param("orderId") String orderId); + + /** + * 删除 + * @param id + * @param orderId + */ + void delete(@Param("id") String id, @Param("orderId") String orderId); + + /** + * + * @param id + * @param count + */ + void updateCount(@Param("id") String id, @Param("count") Integer count); } diff --git a/src/main/java/com/glxp/udi/admin/mongo/service/InvProductDetailMdService.java b/src/main/java/com/glxp/udi/admin/mongo/service/InvProductDetailMdService.java deleted file mode 100644 index 62ee745..0000000 --- a/src/main/java/com/glxp/udi/admin/mongo/service/InvProductDetailMdService.java +++ /dev/null @@ -1,175 +0,0 @@ -package com.glxp.udi.admin.mongo.service; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import com.glxp.udi.admin.entity.inout.InvProductDetailEntity; -import com.glxp.udi.admin.entity.udid.UdiEntity; -import com.glxp.udi.admin.mongo.MongoDBName; -import com.glxp.udi.admin.mongo.utils.MongoPageHelper; -import com.glxp.udi.admin.mongo.utils.PageResult; -import com.glxp.udi.admin.req.inout.FilterInvProductDetailRequest; -import com.glxp.udi.admin.util.FilterUdiUtils; -import org.springframework.data.mongodb.core.MongoTemplate; -import org.springframework.data.mongodb.core.query.Criteria; -import org.springframework.data.mongodb.core.query.Query; -import org.springframework.data.mongodb.core.query.Update; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.List; - -@Service -public class InvProductDetailMdService { - - @Resource - private MongoTemplate mongoTemplate; - @Resource - private MongoPageHelper mongoPageHelper; - - public PageResult filterInvProduct(FilterInvProductDetailRequest filterInvProductDetailRequest) { - Query query = new Query(); - if (filterInvProductDetailRequest.getCode() != null && !filterInvProductDetailRequest.getCode().isEmpty()) { - query.addCriteria(Criteria.where("code").is(filterInvProductDetailRequest.getCode())); - } - if (filterInvProductDetailRequest.getProductIdFk() != null && !filterInvProductDetailRequest.getProductIdFk().isEmpty()) { - query.addCriteria(Criteria.where("productIdFk").is(filterInvProductDetailRequest.getProductIdFk())); - } - if (filterInvProductDetailRequest.getMainAction() != null && !filterInvProductDetailRequest.getMainAction().isEmpty()) { - query.addCriteria(Criteria.where("mainAction").is(filterInvProductDetailRequest.getMainAction())); - } - if (filterInvProductDetailRequest.getCustomerId() != null && !filterInvProductDetailRequest.getCustomerId().isEmpty()) { - query.addCriteria(Criteria.where("customerId").is(filterInvProductDetailRequest.getCustomerId())); - } - if (filterInvProductDetailRequest.getBatchNo() != null && !filterInvProductDetailRequest.getBatchNo().isEmpty()) { - query.addCriteria(Criteria.where("batchNo").is(filterInvProductDetailRequest.getBatchNo())); - } - if (CollUtil.isNotEmpty(filterInvProductDetailRequest.getInvCodes())) { - query.addCriteria(Criteria.where("locStorageCode").in(filterInvProductDetailRequest.getInvCodes())); - } - return mongoPageHelper.pageQuery(query, InvProductDetailEntity.class, - filterInvProductDetailRequest.getLimit(), filterInvProductDetailRequest.getPage(), - filterInvProductDetailRequest.getLastId(), MongoDBName.NAME_INV_PRODUCT_DETAIL); - - } - - public List filterAllInvProduct(FilterInvProductDetailRequest filterInvProductDetailRequest) { - Query query = new Query(); - if (filterInvProductDetailRequest.getCode() != null && !filterInvProductDetailRequest.getCode().isEmpty()) { - query.addCriteria(Criteria.where("code").is(filterInvProductDetailRequest.getCode())); - } - if (filterInvProductDetailRequest.getProductIdFk() != null && !filterInvProductDetailRequest.getProductIdFk().isEmpty()) { - query.addCriteria(Criteria.where("productIdFk").is(filterInvProductDetailRequest.getProductIdFk())); - } - if (filterInvProductDetailRequest.getMainAction() != null && !filterInvProductDetailRequest.getMainAction().isEmpty()) { - query.addCriteria(Criteria.where("mainAction").is(filterInvProductDetailRequest.getMainAction())); - } - if (filterInvProductDetailRequest.getCustomerId() != null && !filterInvProductDetailRequest.getCustomerId().isEmpty()) { - query.addCriteria(Criteria.where("customerId").is(filterInvProductDetailRequest.getCustomerId())); - } - if (filterInvProductDetailRequest.getBatchNo() != null && !filterInvProductDetailRequest.getBatchNo().isEmpty()) { - query.addCriteria(Criteria.where("batchNo").is(filterInvProductDetailRequest.getBatchNo())); - } - if (StrUtil.isNotBlank(filterInvProductDetailRequest.getOrderIdFk())) { - query.addCriteria(Criteria.where("orderIdFk").is(filterInvProductDetailRequest.getOrderIdFk())); - } - if (CollUtil.isNotEmpty(filterInvProductDetailRequest.getInvCodes())) { - query.addCriteria(Criteria.where("locStorageCode").in(filterInvProductDetailRequest.getInvCodes())); - } - return mongoTemplate.find(query, InvProductDetailEntity.class, MongoDBName.NAME_INV_PRODUCT_DETAIL); - } - - public void insertInvProduct(InvProductDetailEntity invProductDetailEntity) { - mongoTemplate.insert(invProductDetailEntity, MongoDBName.NAME_INV_PRODUCT_DETAIL); - } - - public void updateInvProduct(InvProductDetailEntity invProductDetailEntity) { - Query query = new Query(); - query.addCriteria(new Criteria().and("_id").is(invProductDetailEntity.getId())); - Update update = new Update(); - - if (invProductDetailEntity.getCount() != null) { - update.set("count", invProductDetailEntity.getCount()); - } - if (invProductDetailEntity.getCode() != null) { - update.set("code", invProductDetailEntity.getCode()); - } - if (invProductDetailEntity.getProductIdFk() != null) { - update.set("productIdFk", invProductDetailEntity.getProductIdFk()); - } - if (invProductDetailEntity.getOrderIdFk() != null) { - update.set("orderIdFk", invProductDetailEntity.getOrderIdFk()); - } - if (invProductDetailEntity.getCustomerId() != null) { - update.set("customerId", invProductDetailEntity.getCustomerId()); - } - if (invProductDetailEntity.getMainAction() != null) { - update.set("mainAction", invProductDetailEntity.getMainAction()); - } - if (invProductDetailEntity.getAction() != null) { - update.set("action", invProductDetailEntity.getAction()); - } - mongoTemplate.updateMulti(query, update, MongoDBName.NAME_INV_PRODUCT_DETAIL); - } - - public void deleteById(String id) { - Query query = new Query(); - if (id != null) { - query.addCriteria(Criteria.where("id").is(id)); - } - mongoTemplate.remove(query, InvProductDetailEntity.class, MongoDBName.NAME_INV_PRODUCT_DETAIL); - } - - public void deleteByProductId(String productIdFk) { - Query query = new Query(); - if (productIdFk != null) { - query.addCriteria(Criteria.where("invProductIdFk").is(productIdFk)); - } - mongoTemplate.remove(query, InvProductDetailEntity.class, MongoDBName.NAME_INV_PRODUCT_DETAIL); - } - - /** - * 统计库存数量 - * - * @param detailParams - * @return - */ - public long statCount(FilterInvProductDetailRequest detailParams) { - Query query = new Query(); - if (StrUtil.isNotEmpty(detailParams.getBatchNo())) { - query.addCriteria(Criteria.where("batchNo").is(detailParams.getBatchNo())); - } - if (StrUtil.isNotBlank(detailParams.getProductIdFk())) { - query.addCriteria(Criteria.where("productIdFk").is(detailParams.getProductIdFk())); - } - if (CollUtil.isNotEmpty(detailParams.getInvCodes())) { - query.addCriteria(Criteria.where("locStorageCode").in(detailParams.getInvCodes())); - } - return mongoTemplate.count(query, MongoDBName.NAME_INV_PRODUCT_DETAIL); - } - - - public InvProductDetailEntity statInvPreInDetail(String code) { - FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest(); - filterInvProductDetailRequest.setCode(code); - - List datas = filterAllInvProduct(filterInvProductDetailRequest); - if (CollUtil.isEmpty(datas)) { - FilterInvProductDetailRequest tempQuery = new FilterInvProductDetailRequest(); - UdiEntity udiEntity = FilterUdiUtils.getUdi(code); - if (StrUtil.isNotEmpty(udiEntity.getBatchNo())) { - tempQuery.setBatchNo(udiEntity.getBatchNo()); - } else { - tempQuery.setBatchNo("empty"); - } - - datas = filterAllInvProduct(filterInvProductDetailRequest); - } - - - if (CollUtil.isNotEmpty(datas)) { - InvProductDetailEntity invProductDetailEntity = datas.get(0); - return invProductDetailEntity; - } - return null; - } -} diff --git a/src/main/java/com/glxp/udi/admin/mongo/service/InvProductDetailService.java b/src/main/java/com/glxp/udi/admin/mongo/service/InvProductDetailService.java new file mode 100644 index 0000000..8f7781e --- /dev/null +++ b/src/main/java/com/glxp/udi/admin/mongo/service/InvProductDetailService.java @@ -0,0 +1,114 @@ +package com.glxp.udi.admin.mongo.service; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.glxp.udi.admin.dao.inout.InvProductDetailDao; +import com.glxp.udi.admin.entity.inout.InvProductDetailEntity; +import com.glxp.udi.admin.entity.udid.UdiEntity; +import com.glxp.udi.admin.req.inout.FilterInvProductDetailRequest; +import com.glxp.udi.admin.util.FilterUdiUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +@Service +public class InvProductDetailService { + + @Resource + private InvProductDetailDao invProductDetailDao; + + public IPage filterInvProduct(FilterInvProductDetailRequest filterInvProductDetailRequest) { + QueryWrapper wrapper = buildInvDetailQueryWrapper(filterInvProductDetailRequest); + IPage page = new Page<>(filterInvProductDetailRequest.getPage(), filterInvProductDetailRequest.getLimit()); + return invProductDetailDao.selectPage(page, wrapper); + } + + /** + * 构造查询条件 + * + * @param filterInvProductDetailRequest + * @return + */ + private QueryWrapper buildInvDetailQueryWrapper(FilterInvProductDetailRequest filterInvProductDetailRequest) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StrUtil.isNotBlank(filterInvProductDetailRequest.getCode()), "code", filterInvProductDetailRequest.getCode()) + .eq(StrUtil.isNotBlank(filterInvProductDetailRequest.getProductIdFk()), "productIdFk", filterInvProductDetailRequest.getProductIdFk()) + .eq(StrUtil.isNotBlank(filterInvProductDetailRequest.getMainAction()), "mainAction", filterInvProductDetailRequest.getMainAction()) + .eq(null != filterInvProductDetailRequest.getCustomerId(), "customerId", filterInvProductDetailRequest.getCustomerId()) + .eq(StrUtil.isNotBlank(filterInvProductDetailRequest.getBatchNo()), "batchNo", filterInvProductDetailRequest.getBatchNo()) + .eq(StrUtil.isNotBlank(filterInvProductDetailRequest.getOrderIdFk()), "orderIdFk", filterInvProductDetailRequest.getOrderIdFk()) + .in(CollUtil.isNotEmpty(filterInvProductDetailRequest.getInvCodes()), "locStorageCode", filterInvProductDetailRequest.getInvCodes()); + return wrapper; + } + + public List filterAllInvProduct(FilterInvProductDetailRequest filterInvProductDetailRequest) { + QueryWrapper wrapper = buildInvDetailQueryWrapper(filterInvProductDetailRequest); + return invProductDetailDao.selectList(wrapper); + } + + public void insertInvProduct(InvProductDetailEntity invProductDetailEntity) { + invProductDetailDao.insert(invProductDetailEntity); + } + + public void updateInvProduct(InvProductDetailEntity invProductDetailEntity) { + invProductDetailDao.updateById(invProductDetailEntity); + } + + public void deleteById(String id) { + invProductDetailDao.deleteById(id); + } + + /** + * 根据产品ID删除库存详情 + * + * @param productIdFk + */ + public void deleteByProductId(String productIdFk) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("productIdFk", productIdFk); + invProductDetailDao.delete(wrapper); + } + + /** + * 统计库存数量 + * + * @param detailParams + * @return + */ + public long statCount(FilterInvProductDetailRequest detailParams) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StrUtil.isNotBlank(detailParams.getBatchNo()), "batchNo", detailParams.getBatchNo()) + .eq(StrUtil.isNotBlank(detailParams.getProductIdFk()), "productIdFk", detailParams.getProductIdFk()) + .eq(CollUtil.isNotEmpty(detailParams.getInvCodes()), "locStorageCode", detailParams.getInvCodes()); + return invProductDetailDao.selectCount(wrapper); + } + + public InvProductDetailEntity statInvPreInDetail(String code) { + FilterInvProductDetailRequest filterInvProductDetailRequest = new FilterInvProductDetailRequest(); + filterInvProductDetailRequest.setCode(code); + + List datas = filterAllInvProduct(filterInvProductDetailRequest); + if (CollUtil.isEmpty(datas)) { + FilterInvProductDetailRequest tempQuery = new FilterInvProductDetailRequest(); + UdiEntity udiEntity = FilterUdiUtils.getUdi(code); + if (StrUtil.isNotEmpty(udiEntity.getBatchNo())) { + tempQuery.setBatchNo(udiEntity.getBatchNo()); + } else { + tempQuery.setBatchNo("empty"); + } + + datas = filterAllInvProduct(filterInvProductDetailRequest); + } + + if (CollUtil.isNotEmpty(datas)) { + InvProductDetailEntity invProductDetailEntity = datas.get(0); + return invProductDetailEntity; + } + return null; + } + +} diff --git a/src/main/java/com/glxp/udi/admin/mongo/service/InvProductService.java b/src/main/java/com/glxp/udi/admin/mongo/service/InvProductService.java index d8855a9..dd32f97 100644 --- a/src/main/java/com/glxp/udi/admin/mongo/service/InvProductService.java +++ b/src/main/java/com/glxp/udi/admin/mongo/service/InvProductService.java @@ -2,193 +2,72 @@ package com.glxp.udi.admin.mongo.service; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.glxp.udi.admin.dao.inout.InvProductDao; import com.glxp.udi.admin.entity.inout.InvProductEntity; -import com.glxp.udi.admin.mongo.MongoDBName; -import com.glxp.udi.admin.mongo.utils.MongoPageHelper; -import com.glxp.udi.admin.mongo.utils.PageResult; import com.glxp.udi.admin.req.inventory.FilterInvProductRequest; -import org.springframework.data.mongodb.core.MongoTemplate; -import org.springframework.data.mongodb.core.query.Criteria; -import org.springframework.data.mongodb.core.query.Query; -import org.springframework.data.mongodb.core.query.Update; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; -import java.util.regex.Pattern; @Service public class InvProductService { @Resource - private MongoTemplate mongoTemplate; - @Resource - private MongoPageHelper mongoPageHelper; + private InvProductDao invProductDao; - public PageResult filterInvProduct(FilterInvProductRequest filterInvProductRequest) { - Query query = new Query(); - if (filterInvProductRequest.getUuids() != null && filterInvProductRequest.getUuids().size() > 0) { - query.addCriteria(Criteria.where("relIdFk").in(filterInvProductRequest.getUuids())); - } - if (filterInvProductRequest.getBatchNo() != null && !filterInvProductRequest.getBatchNo().isEmpty()) { - query.addCriteria(Criteria.where("batchNo").is(filterInvProductRequest.getBatchNo())); - } - if (filterInvProductRequest.getCustomerId() != null && !filterInvProductRequest.getCustomerId().isEmpty()) { - query.addCriteria(Criteria.where("customerId").is(filterInvProductRequest.getCustomerId())); - } - if (CollUtil.isNotEmpty(filterInvProductRequest.getInvCodes())) { - query.addCriteria(Criteria.where("locStorageCode").in(filterInvProductRequest.getInvCodes())); - } - if (StrUtil.isNotBlank(filterInvProductRequest.getNameCode())) { - query.addCriteria(Criteria.where("nameCode").is(filterInvProductRequest.getNameCode())); - } - if (StrUtil.isNotBlank(filterInvProductRequest.getCpmctymc())) { - Pattern pattern = Pattern.compile("^.*" + filterInvProductRequest.getCpmctymc() + ".*$"); - query.addCriteria(Criteria.where("productsName").regex(pattern)); - } - if (StrUtil.isNotBlank(filterInvProductRequest.getZczbhhzbapzbh())) { - Pattern pattern = Pattern.compile("^.*" + filterInvProductRequest.getZczbhhzbapzbh() + ".*$"); - query.addCriteria(Criteria.where("zczbhhzbapzbh").regex(pattern)); - } - if (StrUtil.isNotBlank(filterInvProductRequest.getManufactory())) { - Pattern pattern = Pattern.compile("^.*" + filterInvProductRequest.getManufactory() + ".*$"); - query.addCriteria(Criteria.where("manufactory").regex(pattern)); - } - if (StrUtil.isNotBlank(filterInvProductRequest.getGgxh())) { - Pattern pattern = Pattern.compile("^.*" + filterInvProductRequest.getGgxh() + ".*$"); - query.addCriteria(Criteria.where("ggxh").regex(pattern)); - } - return mongoPageHelper.pageQuery(query, InvProductEntity.class, - filterInvProductRequest.getLimit(), filterInvProductRequest.getPage(), filterInvProductRequest.getLastId(), MongoDBName.NAME_INV_PRODUCT); + public IPage filterInvProduct(FilterInvProductRequest filterInvProductRequest) { + QueryWrapper wrapper = buildInvQueryWrapper(filterInvProductRequest); + + IPage page = new Page<>(filterInvProductRequest.getPage(), filterInvProductRequest.getLimit()); + return invProductDao.selectPage(page, wrapper); + } + + private QueryWrapper buildInvQueryWrapper(FilterInvProductRequest filterInvProductRequest) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StrUtil.isNotBlank(filterInvProductRequest.getRelIdFk()), "relIdFk", filterInvProductRequest.getRelIdFk()) + .eq(StrUtil.isNotBlank(filterInvProductRequest.getBatchNo()), "batchNo", filterInvProductRequest.getBatchNo()) + .eq(StrUtil.isNotBlank(filterInvProductRequest.getCustomerId()), "customerId", filterInvProductRequest.getCustomerId()) + .in(CollUtil.isNotEmpty(filterInvProductRequest.getInvCodes()), "locStorageCode", filterInvProductRequest.getInvCodes()) + .eq(StrUtil.isNotBlank(filterInvProductRequest.getNameCode()), "nameCode", filterInvProductRequest.getNameCode()) + .like(StrUtil.isNotBlank(filterInvProductRequest.getProductsName()), "productName", filterInvProductRequest.getProductsName()) + .like(StrUtil.isNotBlank(filterInvProductRequest.getZczbhhzbapzbh()), "zczbhhzbapzbh", filterInvProductRequest.getZczbhhzbapzbh()) + .like(StrUtil.isNotBlank(filterInvProductRequest.getManufactory()), "manufactory", filterInvProductRequest.getManufactory()) + .like(StrUtil.isNotBlank(filterInvProductRequest.getGgxh()), "ggxh", filterInvProductRequest.getGgxh()); + return wrapper; } public List filterInvProductList(FilterInvProductRequest filterInvProductRequest) { - Query query = new Query(); - if (filterInvProductRequest.getUuids() != null && filterInvProductRequest.getUuids().size() > 0) { - query.addCriteria(Criteria.where("relIdFk").in(filterInvProductRequest.getUuids())); - } - if (filterInvProductRequest.getBatchNo() != null && !filterInvProductRequest.getBatchNo().isEmpty()) { - query.addCriteria(Criteria.where("batchNo").is(filterInvProductRequest.getBatchNo())); - } - if (filterInvProductRequest.getCustomerId() != null && !filterInvProductRequest.getCustomerId().isEmpty()) { - query.addCriteria(Criteria.where("customerId").is(filterInvProductRequest.getCustomerId())); - } - if (CollUtil.isNotEmpty(filterInvProductRequest.getInvCodes())) { - query.addCriteria(Criteria.where("locStorageCode").in(filterInvProductRequest.getInvCodes())); - } - if (StrUtil.isNotBlank(filterInvProductRequest.getNameCode())) { - query.addCriteria(Criteria.where("nameCode").is(filterInvProductRequest.getNameCode())); - } - if (StrUtil.isNotBlank(filterInvProductRequest.getCpmctymc())) { - Pattern pattern = Pattern.compile("^.*" + filterInvProductRequest.getCpmctymc() + ".*$"); - query.addCriteria(Criteria.where("productsName").regex(pattern)); - } - if (StrUtil.isNotBlank(filterInvProductRequest.getZczbhhzbapzbh())) { - Pattern pattern = Pattern.compile("^.*" + filterInvProductRequest.getZczbhhzbapzbh() + ".*$"); - query.addCriteria(Criteria.where("zczbhhzbapzbh").regex(pattern)); - } - if (StrUtil.isNotBlank(filterInvProductRequest.getManufactory())) { - Pattern pattern = Pattern.compile("^.*" + filterInvProductRequest.getManufactory() + ".*$"); - query.addCriteria(Criteria.where("manufactory").regex(pattern)); - } - if (StrUtil.isNotBlank(filterInvProductRequest.getGgxh())) { - Pattern pattern = Pattern.compile("^.*" + filterInvProductRequest.getGgxh() + ".*$"); - query.addCriteria(Criteria.where("ggxh").regex(pattern)); - } - return mongoTemplate.find(query, InvProductEntity.class, MongoDBName.NAME_INV_PRODUCT); + QueryWrapper wrapper = buildInvQueryWrapper(filterInvProductRequest); + return invProductDao.selectList(wrapper); } public InvProductEntity selectByUuid(String relIdFk, String batchNo, String customerId, String locStorageCode) { - Query query = new Query(); - if (relIdFk != null && !relIdFk.isEmpty()) { - query.addCriteria(Criteria.where("relIdFk").is(relIdFk)); - } - if (batchNo != null && !batchNo.isEmpty()) { - query.addCriteria(Criteria.where("batchNo").is(batchNo)); - } - if (customerId != null && !customerId.isEmpty()) { - query.addCriteria(Criteria.where("customerId").is(customerId)); - } - if (StrUtil.isNotBlank(locStorageCode)) { - query.addCriteria(Criteria.where("locStorageCode").is(locStorageCode)); - } - List invProductEntities = mongoTemplate.find(query, InvProductEntity.class, MongoDBName.NAME_INV_PRODUCT); - if (invProductEntities != null && invProductEntities.size() > 0) { - return invProductEntities.get(0); - } - return null; + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StrUtil.isNotBlank(relIdFk), "relIdFk", relIdFk) + .eq(StrUtil.isNotBlank(batchNo), "batchNo", batchNo) + .eq(StrUtil.isNotBlank(customerId), "customerId", customerId) + .eq(StrUtil.isNotBlank(locStorageCode), "locStorageCode", locStorageCode); + return invProductDao.selectOne(wrapper); } public InvProductEntity selectById(String id) { - Query query = new Query(); - if (id != null && !id.isEmpty()) { - query.addCriteria(Criteria.where("id").is(id)); - } - List invProductEntities = mongoTemplate.find(query, InvProductEntity.class, MongoDBName.NAME_INV_PRODUCT); - if (CollUtil.isNotEmpty(invProductEntities)) { - return invProductEntities.get(0); - } - return null; + return invProductDao.selectById(id); } public void insertInvProduct(InvProductEntity invProductEntity) { - mongoTemplate.insert(invProductEntity, MongoDBName.NAME_INV_PRODUCT); + invProductDao.insert(invProductEntity); } public void updateInvProduct(InvProductEntity invProductEntity) { - Query query = new Query(); - query.addCriteria(new Criteria().and("_id").is(invProductEntity.getId())); - Update update = new Update(); - - if (invProductEntity.getInCount() != null) { - update.set("inCount", invProductEntity.getInCount()); - } - if (invProductEntity.getOutCount() != null) { - update.set("outCount", invProductEntity.getOutCount()); - } - if (invProductEntity.getProductsName() != null) { - update.set("productsName", invProductEntity.getProductsName()); - } - if (invProductEntity.getNameCode() != null) { - update.set("nameCode", invProductEntity.getNameCode()); - } - if (invProductEntity.getRelIdFk() != null) { - update.set("relIdFk", invProductEntity.getRelIdFk()); - } - if (invProductEntity.getGgxh() != null) { - update.set("ggxh", invProductEntity.getGgxh()); - } - if (invProductEntity.getBatchNo() != null) { - update.set("batchNo", invProductEntity.getBatchNo()); - } - if (invProductEntity.getProductDate() != null) { - update.set("productionDate", invProductEntity.getProductDate()); - } - if (invProductEntity.getExpireDate() != null) { - update.set("expireDate", invProductEntity.getExpireDate()); - } - if (invProductEntity.getYlqxzcrbarmc() != null) { - update.set("ylqxzcrbarmc", invProductEntity.getYlqxzcrbarmc()); - } - if (invProductEntity.getZczbhhzbapzbh() != null) { - update.set("zczbhhzbapzbh", invProductEntity.getZczbhhzbapzbh()); - } - if (invProductEntity.getReCount() != null) { - update.set("reCount", invProductEntity.getReCount()); - } - if (invProductEntity.getCustomerId() != null) { - update.set("customerId", invProductEntity.getCustomerId()); - } - mongoTemplate.updateMulti(query, update, MongoDBName.NAME_INV_PRODUCT); + invProductDao.updateById(invProductEntity); } - public void deleteById(String id) { - Query query = new Query(); - if (id != null) { - query.addCriteria(Criteria.where("id").is(id)); - } - mongoTemplate.remove(query, InvProductEntity.class, MongoDBName.NAME_INV_PRODUCT); + invProductDao.deleteById(id); } /** @@ -198,9 +77,9 @@ public class InvProductService { * @return */ public boolean isExist(String code) { - Query query = new Query(); - query.addCriteria(Criteria.where("locStorageCode").is(code)); - long count = mongoTemplate.count(query, InvProductEntity.class, MongoDBName.NAME_INV_PRODUCT); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("locStorageCode", code); + Long count = invProductDao.selectCount(wrapper); if (count > 0) { return true; } @@ -215,10 +94,10 @@ public class InvProductService { * @return */ public Long countByNamecode(String nameCode, String customerId) { - Query query = new Query(); - query.addCriteria(Criteria.where("nameCode").is(nameCode)); - query.addCriteria(Criteria.where("customerId").is(customerId)); - return mongoTemplate.count(query, InvProductEntity.class, MongoDBName.NAME_INV_PRODUCT); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("nameCode", nameCode).eq("customerId", customerId); + Long count = invProductDao.selectCount(wrapper); + return count; } } diff --git a/src/main/java/com/glxp/udi/admin/mongo/service/OrderService.java b/src/main/java/com/glxp/udi/admin/mongo/service/OrderService.java index 16425b7..adf2f51 100644 --- a/src/main/java/com/glxp/udi/admin/mongo/service/OrderService.java +++ b/src/main/java/com/glxp/udi/admin/mongo/service/OrderService.java @@ -21,11 +21,8 @@ import com.glxp.udi.admin.entity.auth.CustomerInfoEntity; import com.glxp.udi.admin.entity.basic.BussinessTypeEntity; import com.glxp.udi.admin.entity.inout.*; import com.glxp.udi.admin.entity.mongo.OrderMdEntity; -import com.glxp.udi.admin.entity.mongo.WarehouseMdEntity; -import com.glxp.udi.admin.entity.mongo.WarehousetempMdEntity; import com.glxp.udi.admin.entity.param.SystemParamConfigEntity; import com.glxp.udi.admin.mongo.MongoDBName; -import com.glxp.udi.admin.mongo.dao.OrderMdDao; import com.glxp.udi.admin.req.inout.DeleteRequest; import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest; import com.glxp.udi.admin.req.inout.OrderFilterRequest; @@ -56,10 +53,10 @@ public class OrderService { private SystemParamConfigService systemParamConfigService; @Lazy @Resource - private WarehouseMdService warehouseMdService; + private WarehouseService warehouseService; @Lazy @Resource - private WarehouseTempMdService warehouseTempMdService; + private WarehouseTempService warehouseTempService; @Lazy @Resource private OrderDetailService orderDetailService; @@ -77,8 +74,6 @@ public class OrderService { @Resource private BussinessTypeDao bussinessTypeDao; @Resource - private OrderMdDao orderMdDao; - @Resource private OrderDao orderDao; public IPage filterList(OrderFilterRequest orderFilterRequest) { @@ -202,10 +197,10 @@ public class OrderService { supplementOrder.setAction(supplementType.getAction()); //复制码表 - List codes = warehouseMdService.findByOrderId(orderEntity.getOrderId()); - List supplementCodes = new ArrayList<>(codes.size()); + List codes = warehouseService.findByOrderId(orderEntity.getOrderId()); + List supplementCodes = new ArrayList<>(codes.size()); codes.forEach(code -> { - WarehousetempMdEntity supplementCode = new WarehousetempEntity(); + WarehousetempEntity supplementCode = new WarehousetempEntity(); BeanUtil.copyProperties(code, supplementCode); supplementCode.setFromCorpId(supplementOrder.getFromCorpId()); supplementCode.setFromCorp(supplementOrder.getFromCorp()); @@ -219,12 +214,12 @@ public class OrderService { //更新数据 try { - supplementOrder.setId(null); + supplementOrder.setOrderId(null); insertOrder(supplementOrder); //更新配货单表对应的单据补单号 orderEntity.setSupplementNo(supplementOrderNo); updateOrder(orderEntity); - warehouseTempMdService.insertTempWarehouses(supplementCodes); + warehouseTempService.insertTempWarehouses(supplementCodes); } catch (Exception e) { log.error("补单数据插入失败", e); } diff --git a/src/main/java/com/glxp/udi/admin/mongo/service/WarehouseMdService.java b/src/main/java/com/glxp/udi/admin/mongo/service/WarehouseService.java similarity index 50% rename from src/main/java/com/glxp/udi/admin/mongo/service/WarehouseMdService.java rename to src/main/java/com/glxp/udi/admin/mongo/service/WarehouseService.java index d2efb3d..5a00d21 100644 --- a/src/main/java/com/glxp/udi/admin/mongo/service/WarehouseMdService.java +++ b/src/main/java/com/glxp/udi/admin/mongo/service/WarehouseService.java @@ -2,38 +2,25 @@ package com.glxp.udi.admin.mongo.service; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.glxp.udi.admin.constant.ConstantStatus; import com.glxp.udi.admin.constant.ConstantType; -import com.glxp.udi.admin.entity.inout.InvProductDetailEntity; -import com.glxp.udi.admin.entity.inout.InvProductEntity; -import com.glxp.udi.admin.entity.inout.OrderDetailEntity; -import com.glxp.udi.admin.entity.inout.OrderEntity; -import com.glxp.udi.admin.entity.mongo.WarehouseMdEntity; -import com.glxp.udi.admin.mongo.MongoDBName; -import com.glxp.udi.admin.mongo.utils.MongoPageHelper; -import com.glxp.udi.admin.mongo.utils.PageResult; +import com.glxp.udi.admin.dao.inout.CodesDao; +import com.glxp.udi.admin.entity.inout.*; import com.glxp.udi.admin.req.inout.*; import com.glxp.udi.admin.req.inventory.FilterInvProductRequest; import org.springframework.context.annotation.Lazy; -import org.springframework.data.mongodb.core.MongoTemplate; -import org.springframework.data.mongodb.core.query.Criteria; -import org.springframework.data.mongodb.core.query.Query; -import org.springframework.data.mongodb.core.query.Update; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.List; @Service -public class WarehouseMdService { +public class WarehouseService { - @Resource - private MongoTemplate mongoTemplate; - @Resource - private MongoPageHelper mongoPageHelper; @Lazy @Resource private OrderService orderService; @@ -42,101 +29,65 @@ public class WarehouseMdService { private InvProductService invProductService; @Lazy @Resource - private InvProductDetailMdService invProductDetailMdService; + private InvProductDetailService invProductDetailService; @Lazy @Resource private OrderDetailService orderDetailService; + @Resource + private CodesDao codesDao; - public PageResult filterWarehouseByPage(WarehouseQueryRequest warehouseQueryRequest) { - Query query = new Query(); - if (warehouseQueryRequest.getCode() != null && !warehouseQueryRequest.getCode().isEmpty()) { - query.addCriteria(Criteria.where("code").is(warehouseQueryRequest.getCode())); - } - if (warehouseQueryRequest.getCorpOrderId() != null && !warehouseQueryRequest.getCorpOrderId().isEmpty()) { - query.addCriteria(Criteria.where("corpOrderId").is(warehouseQueryRequest.getCorpOrderId())); - } - if (warehouseQueryRequest.getOrderId() != null && !warehouseQueryRequest.getOrderId().isEmpty()) { - query.addCriteria(Criteria.where("orderId").is(warehouseQueryRequest.getOrderId())); - } - return mongoPageHelper.pageQuery(query, WarehouseMdEntity.class, - warehouseQueryRequest.getLimit(), warehouseQueryRequest.getPage(), warehouseQueryRequest.getLastId(), MongoDBName.NAME_CODE); + public IPage filterWarehouseByPage(WarehouseQueryRequest warehouseQueryRequest) { + IPage page = new Page<>(warehouseQueryRequest.getPage(), warehouseQueryRequest.getLimit()); + QueryWrapper wrapper = buildCodesQueryWrapper(warehouseQueryRequest); + return codesDao.selectPage(page, wrapper); } - public List filterWarehouse(WarehouseQueryRequest warehouseQueryRequest) { - Query query = new Query(); - if (warehouseQueryRequest.getCode() != null && !warehouseQueryRequest.getCode().isEmpty()) { - query.addCriteria(Criteria.where("code").is(warehouseQueryRequest.getCode())); - } - if (warehouseQueryRequest.getCorpOrderId() != null && !warehouseQueryRequest.getCorpOrderId().isEmpty()) { - query.addCriteria(Criteria.where("corpOrderId").is(warehouseQueryRequest.getCorpOrderId())); - } - if (warehouseQueryRequest.getOrderId() != null && !warehouseQueryRequest.getOrderId().isEmpty()) { - query.addCriteria(Criteria.where("orderId").is(warehouseQueryRequest.getOrderId())); - } - if (StrUtil.isNotBlank(warehouseQueryRequest.getCustomerId())) { - query.addCriteria(Criteria.where("customerId").is(warehouseQueryRequest.getCustomerId())); - } - if (warehouseQueryRequest.getBatchNo() != null) { - query.addCriteria(Criteria.where("batchNo").is(warehouseQueryRequest.getBatchNo())); - } - if (warehouseQueryRequest.getUdi() != null) { - query.addCriteria(Criteria.where("udi").is(warehouseQueryRequest.getUdi())); - } - return mongoTemplate.find(query, WarehouseMdEntity.class, MongoDBName.NAME_CODE); + public List filterWarehouse(WarehouseQueryRequest warehouseQueryRequest) { + QueryWrapper wrapper = buildCodesQueryWrapper(warehouseQueryRequest); + return codesDao.selectList(wrapper); } - public void insertWarehouses(List warehouseEntities) { - if (warehouseEntities != null) { - Collection warehouseMdEntityCollection = new ArrayList<>(); - warehouseMdEntityCollection.addAll(warehouseEntities); - mongoTemplate.insert(warehouseMdEntityCollection, MongoDBName.NAME_CODE); + private QueryWrapper buildCodesQueryWrapper(WarehouseQueryRequest warehouseQueryRequest) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StrUtil.isNotBlank(warehouseQueryRequest.getCode()), "code", warehouseQueryRequest.getCode()) + .eq(null != warehouseQueryRequest.getCorpOrderId(), "corpOrderId", warehouseQueryRequest.getCorpOrderId()) + .eq(StrUtil.isNotBlank(warehouseQueryRequest.getOrderId()), "orderId", warehouseQueryRequest.getOrderId()) + .eq(StrUtil.isNotBlank(warehouseQueryRequest.getCustomerId()), "customerId", warehouseQueryRequest.getCustomerId()) + .eq(StrUtil.isNotBlank(warehouseQueryRequest.getBatchNo()), "batchNo", warehouseQueryRequest.getBatchNo()) + .eq(StrUtil.isNotBlank(warehouseQueryRequest.getUdi()), "nameCode", warehouseQueryRequest.getUdi()) + .eq(StrUtil.isNotBlank(warehouseQueryRequest.getCode()), "code", warehouseQueryRequest.getCode()); + return wrapper; + } + + public void insertWarehouses(List warehouseEntities) { + if (CollUtil.isNotEmpty(warehouseEntities)) { + for (WarehouseEntity warehouseEntity : warehouseEntities) { + codesDao.insert(warehouseEntity); + } } } - public List findByCode(FilterWarehouseRequest filterWarehouseRequest) { - Query query = new Query(); - query.addCriteria( - Criteria.where("customerId").is(filterWarehouseRequest.getCustomerId()) - .and("code").is(filterWarehouseRequest.getCode()) - ); - return mongoTemplate.find(query, WarehouseMdEntity.class, MongoDBName.NAME_CODE); + public List findByCode(FilterWarehouseRequest filterWarehouseRequest) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(null != filterWarehouseRequest.getCustomerId(), "customerId", filterWarehouseRequest.getCustomerId()) + .eq(StrUtil.isNotBlank(filterWarehouseRequest.getCode()), "code", filterWarehouseRequest.getCode()); + return codesDao.selectList(wrapper); } public void updateUnit(String orderId, String fromCorpId, String fromCorp) { - Query query = new Query(); - query.addCriteria(new Criteria().and("orderId").is(orderId)); - Update update = new Update(); - update.set("fromCorp", fromCorp); - update.set("fromCorpId", fromCorpId); - mongoTemplate.updateMulti(query, update, MongoDBName.NAME_CODE); + codesDao.updateUnit(orderId, fromCorp, fromCorpId); } public void updateOrderId(String orderId, String newOrderId) { - Query query = new Query(); - query.addCriteria(new Criteria().and("orderId").is(orderId)); - Update update = new Update(); - update.set("orderId", newOrderId); - mongoTemplate.updateMulti(query, update, MongoDBName.NAME_CODE); + codesDao.updateOrderId(orderId, newOrderId); } - public List findByOrderId(String orderId) { - if (StrUtil.isBlank(orderId)) { + public List findByOrderId(String orderId) { + if (StrUtil.isNotBlank(orderId)) { return Collections.emptyList(); } - Query query = new Query(); - query.addCriteria(Criteria.where("orderId").is(orderId)); - return mongoTemplate.find(query, WarehouseMdEntity.class, MongoDBName.NAME_CODE); - } - - public PageResult findOrdersById(WarehouseQueryRequest warehouseQueryRequest) { - if (null != warehouseQueryRequest && StrUtil.isBlank(warehouseQueryRequest.getOrderId())) { - return new PageResult<>(); - } - Query query = new Query(); - query.addCriteria(Criteria.where("orderId").is(warehouseQueryRequest.getOrderId())); - PageResult pageResult = mongoPageHelper.pageQuery(query, WarehouseMdEntity.class, warehouseQueryRequest.getPage(), warehouseQueryRequest.getLimit(), MongoDBName.NAME_CODE); - return pageResult; + return codesDao.selectByOrderId(orderId); } public void replaceCodes(CodesReplaceRequest codesReplaceRequest) { @@ -149,9 +100,9 @@ public class WarehouseMdService { WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest(); warehouseQueryRequest.setCode(codesReplaceRequest.getCode()); warehouseQueryRequest.setOrderId(order.getOrderId()); - List warehouseEntities = findByOrderId(warehouseQueryRequest); + List warehouseEntities = filterWarehouse(warehouseQueryRequest); if (CollUtil.isNotEmpty(warehouseEntities)) { - WarehouseMdEntity warehouseMdEntity = warehouseEntities.get(0); + WarehouseEntity warehouseMdEntity = warehouseEntities.get(0); if (warehouseMdEntity.getCount() > 1) { //删除一个条码 warehouseMdEntity.setCount(warehouseMdEntity.getCount() - 1); @@ -170,16 +121,16 @@ public class WarehouseMdService { if (StrUtil.isNotBlank(warehouseMdEntity.getBatchNo())) { filterInvProductDetailRequest.setBatchNo(warehouseMdEntity.getBatchNo()); } - List invProductDetailEntities = invProductDetailMdService.filterAllInvProduct(filterInvProductDetailRequest); + List invProductDetailEntities = invProductDetailService.filterAllInvProduct(filterInvProductDetailRequest); if (CollUtil.isNotEmpty(invProductDetailEntities)) { //库存详情不为空,单据已验收,扣减库存 InvProductDetailEntity invProductDetailEntity = invProductDetailEntities.get(0); if (invProductDetailEntity.getCount() > 1) { invProductDetailEntity.setCount(invProductDetailEntity.getCount() - 1); - invProductDetailMdService.updateInvProduct(invProductDetailEntity); + invProductDetailService.updateInvProduct(invProductDetailEntity); } else { //扣减库存后等于0,删除库存详情 - invProductDetailMdService.deleteById(invProductDetailEntity.getId()); + invProductDetailService.deleteById(invProductDetailEntity.getId()); } //查询原库存详情和新的库存详情 @@ -204,7 +155,7 @@ public class WarehouseMdService { detailParams.setBatchNo(invProductEntity.getBatchNo()); detailParams.setInvCodes(Collections.singletonList(invProductEntity.getLocStorageCode())); detailParams.setProductIdFk(invProductEntity.getRelIdFk()); - long count = invProductDetailMdService.statCount(detailParams); + long count = invProductDetailService.statCount(detailParams); if (count == 0) { //删除库存 invProductService.deleteById(invProductEntity.getId()); @@ -245,39 +196,12 @@ public class WarehouseMdService { } } - /** - * 使用订单ID和码查询此单据所有的条码 - * - * @param warehouseQueryRequest - * @return - */ - public List findByOrderId(WarehouseQueryRequest warehouseQueryRequest) { - Query query = new Query(); - if (StrUtil.isNotBlank(warehouseQueryRequest.getOrderId())) { - query.addCriteria(Criteria.where("orderId").is(warehouseQueryRequest.getOrderId())); - } - if (StrUtil.isNotBlank(warehouseQueryRequest.getCode())) { - query.addCriteria(Criteria.where("code").is(warehouseQueryRequest.getCode())); - } - return mongoTemplate.find(query, WarehouseMdEntity.class, MongoDBName.NAME_CODE); - } - - public void updateCode(WarehouseMdEntity warehouseMdEntity) { - Query query = new Query(); - query.addCriteria(Criteria.where("id").is(warehouseMdEntity.getId())); - - Update update = new Update(); - if (null != warehouseMdEntity.getCount()) { - update.set("count", warehouseMdEntity.getCount()); - } - mongoTemplate.updateMulti(query, update, MongoDBName.NAME_CODE); + public void updateCode(WarehouseEntity warehouseEntity) { + codesDao.updateCount(warehouseEntity.getCount(), warehouseEntity.getId()); } public void deleteById(String id) { - Query query = new Query(); - query.addCriteria(Criteria.where("id").is(id)); - - mongoTemplate.remove(query, WarehouseMdEntity.class, MongoDBName.NAME_CODE); + codesDao.deleteById(id); } } diff --git a/src/main/java/com/glxp/udi/admin/mongo/service/WarehouseTempMdService.java b/src/main/java/com/glxp/udi/admin/mongo/service/WarehouseTempMdService.java deleted file mode 100644 index 3a82599..0000000 --- a/src/main/java/com/glxp/udi/admin/mongo/service/WarehouseTempMdService.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.glxp.udi.admin.mongo.service; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import com.glxp.udi.admin.entity.mongo.WarehousetempMdEntity; -import com.glxp.udi.admin.mongo.MongoDBName; -import com.glxp.udi.admin.mongo.utils.MongoPageHelper; -import com.glxp.udi.admin.mongo.utils.PageResult; -import com.glxp.udi.admin.req.inout.DeleteRequest; -import com.glxp.udi.admin.req.inout.WarehouseQueryRequest; -import org.springframework.data.mongodb.core.MongoTemplate; -import org.springframework.data.mongodb.core.query.Criteria; -import org.springframework.data.mongodb.core.query.Query; -import org.springframework.data.mongodb.core.query.Update; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -@Service -public class WarehouseTempMdService { - - @Resource - private MongoTemplate mongoTemplate; - @Resource - private MongoPageHelper mongoPageHelper; - - public PageResult filterWarehouseByPage(WarehouseQueryRequest warehouseQueryRequest) { - Query query = new Query(); - if (warehouseQueryRequest.getCode() != null && !warehouseQueryRequest.getCode().isEmpty()) { - query.addCriteria(Criteria.where("code").is(warehouseQueryRequest.getCode())); - } - if (warehouseQueryRequest.getCorpOrderId() != null && !warehouseQueryRequest.getCorpOrderId().isEmpty()) { - query.addCriteria(Criteria.where("corpOrderId").is(warehouseQueryRequest.getCorpOrderId())); - } - if (warehouseQueryRequest.getOrderId() != null && !warehouseQueryRequest.getOrderId().isEmpty()) { - query.addCriteria(Criteria.where("orderId").is(warehouseQueryRequest.getOrderId())); - } - if (warehouseQueryRequest.getCustomerId() != null) { - query.addCriteria(Criteria.where("customerId").is(warehouseQueryRequest.getCustomerId())); - } - return mongoPageHelper.pageQuery(query, WarehousetempMdEntity.class, - warehouseQueryRequest.getLimit(), warehouseQueryRequest.getPage(), warehouseQueryRequest.getLastId(), MongoDBName.NAME_CODE_TEMP); - } - - public List findTempByOrderId(String orderId) { - Query query = new Query(Criteria.where("orderId").is(orderId)); - List result = mongoTemplate.find(query, WarehousetempMdEntity.class, MongoDBName.NAME_CODE_TEMP); - return result; - } - - public void insertTempWarehouses(List warehouseEntities) { - if (warehouseEntities != null) { - Collection warehousetempEntityCollection = new ArrayList<>(warehouseEntities); - mongoTemplate.insert(warehousetempEntityCollection, MongoDBName.NAME_CODE_TEMP); - } - } - - public void deleteTempWarehouses(List ids) { - if (ids != null) { - for (String id : ids) { - Query query = new Query(); - query.addCriteria(Criteria.where("_id").is(id)); - mongoTemplate.remove(query, MongoDBName.NAME_CODE_TEMP); - } - } - } - - public void deleteCode(DeleteRequest deleteRequest) { - Query query = new Query(); - if (deleteRequest.getId() != null) { - query.addCriteria(Criteria.where("id").is(deleteRequest.getId())); - } - if (deleteRequest.getOrderId() != null) { - query.addCriteria(Criteria.where("orderId").is(deleteRequest.getOrderId())); - } - mongoTemplate.remove(query, WarehousetempMdEntity.class, MongoDBName.NAME_CODE_TEMP); - } - - public WarehousetempMdEntity findTempById(String id) { - Query query = new Query(); - if (StrUtil.isNotBlank(id)) { - query.addCriteria(Criteria.where("id").is(id)); - List warehousetempEntities = mongoTemplate.find(query, WarehousetempMdEntity.class, MongoDBName.NAME_CODE_TEMP); - if (CollUtil.isNotEmpty(warehousetempEntities)) { - return warehousetempEntities.get(0); - } - } - return null; - } - - public void updateById(WarehousetempMdEntity warehousetemp) { - Query query = new Query(); - query.addCriteria(Criteria.where("id").is(warehousetemp.getId())); - Update update = new Update(); - update.set("count", warehousetemp.getCount()); - mongoTemplate.updateMulti(query, update, WarehousetempMdEntity.class, MongoDBName.NAME_CODE_TEMP); - } - -} diff --git a/src/main/java/com/glxp/udi/admin/mongo/service/WarehouseTempService.java b/src/main/java/com/glxp/udi/admin/mongo/service/WarehouseTempService.java new file mode 100644 index 0000000..7bc1c79 --- /dev/null +++ b/src/main/java/com/glxp/udi/admin/mongo/service/WarehouseTempService.java @@ -0,0 +1,74 @@ +package com.glxp.udi.admin.mongo.service; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.glxp.udi.admin.dao.inout.CodesTempDao; +import com.glxp.udi.admin.entity.inout.WarehousetempEntity; +import com.glxp.udi.admin.req.inout.DeleteRequest; +import com.glxp.udi.admin.req.inout.WarehouseQueryRequest; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +@Service +public class WarehouseTempService { + + @Resource + private CodesTempDao codesTempDao; + + public IPage filterWarehouseByPage(WarehouseQueryRequest warehouseQueryRequest) { + QueryWrapper wrapper = buildCodesTempQueryWrapper(warehouseQueryRequest); + + IPage page = new Page<>(warehouseQueryRequest.getPage(), warehouseQueryRequest.getLimit()); + return codesTempDao.selectPage(page, wrapper); + } + + /** + * 构造查询条件 + * @param warehouseQueryRequest + * @return + */ + private QueryWrapper buildCodesTempQueryWrapper(WarehouseQueryRequest warehouseQueryRequest) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StrUtil.isNotBlank(warehouseQueryRequest.getCode()), "code", warehouseQueryRequest.getCode()) + .eq(StrUtil.isNotBlank(warehouseQueryRequest.getOrderId()),"orderId",warehouseQueryRequest.getOrderId()) + .eq(StrUtil.isNotBlank(warehouseQueryRequest.getCorpOrderId()), "corpOrderId", warehouseQueryRequest.getCorpOrderId()) + .eq(null != warehouseQueryRequest.getCustomerId(), "customerId", warehouseQueryRequest.getCustomerId()); + return wrapper; + } + + public List findTempByOrderId(String orderId) { + return codesTempDao.selectByOrderId(orderId); + } + + public void insertTempWarehouses(List warehouseEntities) { + if (CollUtil.isNotEmpty(warehouseEntities)) { + warehouseEntities.forEach(warehousetemp -> codesTempDao.insert(warehousetemp)); + } + } + + public void deleteTempWarehouses(List ids) { + if (CollUtil.isNotEmpty(ids)) { + for (String id : ids) { + codesTempDao.deleteById(id); + } + } + } + + public void deleteCode(DeleteRequest deleteRequest) { + codesTempDao.delete(deleteRequest.getId(), deleteRequest.getOrderId()); + } + + public WarehousetempEntity findTempById(String id) { + return codesTempDao.selectById(id); + } + + public void updateById(WarehousetempEntity warehousetemp) { + codesTempDao.updateCount(warehousetemp.getId(), warehousetemp.getCount()); + } + +} 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 c95a07d..eedce89 100644 --- a/src/main/java/com/glxp/udi/admin/thread/InvProductsTrService.java +++ b/src/main/java/com/glxp/udi/admin/thread/InvProductsTrService.java @@ -5,8 +5,6 @@ import cn.hutool.core.util.StrUtil; import com.glxp.udi.admin.constant.ConstantStatus; import com.glxp.udi.admin.constant.TypeConstant; import com.glxp.udi.admin.entity.inout.*; -import com.glxp.udi.admin.entity.mongo.OrderMdEntity; -import com.glxp.udi.admin.entity.mongo.WarehouseMdEntity; import com.glxp.udi.admin.mongo.service.*; import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest; import com.glxp.udi.admin.req.inout.OrderFilterRequest; @@ -36,7 +34,7 @@ public class InvProductsTrService { private OrderDetailService myErpOrderService; @Lazy @Resource - private WarehouseMdService codesService; + private WarehouseService codesService; @Lazy @Resource private UdiInfoService udiInfoService; @@ -45,7 +43,7 @@ public class InvProductsTrService { private InvProductService invProductService; @Lazy @Resource - private InvProductDetailMdService invProductDetailService; + private InvProductDetailService invProductDetailService; @Resource private InoutUtils inoutUtils; @@ -53,8 +51,8 @@ public class InvProductsTrService { public void genInvProducts(String orderId) { OrderFilterRequest orderFilterRequest = new OrderFilterRequest(); orderFilterRequest.setId(orderId); - List orderMdEntities = orderService.findAll(orderFilterRequest); - OrderMdEntity orderEntity = orderMdEntities.get(0); + List orderEntities = orderService.findAll(orderFilterRequest); + OrderEntity orderEntity = orderEntities.get(0); String customerId = orderEntity.getCustomerId() + ""; if (orderEntity.getStatus().equals(ConstantStatus.ORDER_STATUS_SUCCESS)) { FilterOrderDetailRequest filterOrderDetailRequest = new FilterOrderDetailRequest(); @@ -104,7 +102,7 @@ public class InvProductsTrService { if (StrUtil.isNotBlank(invProductEntity.getBatchNo())) { warehouseQueryRequest.setBatchNo(invProductEntity.getBatchNo()); } - List warehouseEntities = codesService.filterWarehouse(warehouseQueryRequest); + List warehouseEntities = codesService.filterWarehouse(warehouseQueryRequest); if (CollUtil.isNotEmpty(warehouseEntities)) { for (WarehouseEntity warehouseEntity : warehouseEntities) { UdiInfoEntity tempUdi = udiInfoService.findByNameCode(warehouseEntity.getNameCode(), customerId); diff --git a/src/main/java/com/glxp/udi/admin/thread/SubmitOrderToSpmsTask.java b/src/main/java/com/glxp/udi/admin/thread/SubmitOrderToSpmsTask.java index bf383a2..d747a83 100644 --- a/src/main/java/com/glxp/udi/admin/thread/SubmitOrderToSpmsTask.java +++ b/src/main/java/com/glxp/udi/admin/thread/SubmitOrderToSpmsTask.java @@ -14,12 +14,11 @@ import com.glxp.udi.admin.entity.info.ScheduledEntity; import com.glxp.udi.admin.entity.inout.OrderDetailEntity; import com.glxp.udi.admin.entity.inout.OrderEntity; import com.glxp.udi.admin.entity.inout.UnitMaintainEntity; -import com.glxp.udi.admin.entity.mongo.OrderMdEntity; -import com.glxp.udi.admin.entity.mongo.WarehouseMdEntity; +import com.glxp.udi.admin.entity.inout.WarehouseEntity; import com.glxp.udi.admin.entity.param.SystemParamConfigEntity; import com.glxp.udi.admin.mongo.service.OrderDetailService; import com.glxp.udi.admin.mongo.service.OrderService; -import com.glxp.udi.admin.mongo.service.WarehouseMdService; +import com.glxp.udi.admin.mongo.service.WarehouseService; import com.glxp.udi.admin.req.inout.FilterOrderDetailRequest; import com.glxp.udi.admin.req.inout.PostUdimsOrderDetailRequest; import com.glxp.udi.admin.req.inout.PostUdimsOrderRequest; @@ -62,7 +61,7 @@ public class SubmitOrderToSpmsTask implements SchedulingConfigurer { @Resource private SystemParamCustomerConfigService systemParamCustomerConfigService; @Resource - private WarehouseMdService warehouseMdService; + private WarehouseService warehouseService; @Resource private OrderDetailService orderDetailService; @Resource @@ -106,7 +105,7 @@ public class SubmitOrderToSpmsTask implements SchedulingConfigurer { orderBean.setAction(unitMaintainEntity.getTargetAction()); WarehouseQueryRequest warehouseQueryRequest = new WarehouseQueryRequest(); warehouseQueryRequest.setOrderId(orderEntity.getOrderId()); - List warehouseEntities = warehouseMdService.filterWarehouse(warehouseQueryRequest); + List warehouseEntities = warehouseService.filterWarehouse(warehouseQueryRequest); List codeBeans = new ArrayList<>(); warehouseEntities.forEach(data -> { PostUdimsOrderRequest.OrderBean.CodeBean codeBean = new PostUdimsOrderRequest.OrderBean.CodeBean(); @@ -150,10 +149,10 @@ public class SubmitOrderToSpmsTask implements SchedulingConfigurer { }); if (baseResponse.getCode() == 20000) { log.info("自动上传单据成功," + unitMaintainEntity.getName() + "上传单据数量为 " + orderEntities.size()); - for (OrderMdEntity orderMdEntity : orderEntities) { - log.info("修改单号为:{} 的上传状态", orderMdEntity.getOrderId()); - orderMdEntity.setUploadStatus("1"); - orderService.updateOrder(orderMdEntity); + for (OrderEntity orderEntity : orderEntities) { + log.info("修改单号为:{} 的上传状态", orderEntity.getOrderId()); + orderEntity.setUploadStatus("1"); + orderService.updateOrder(orderEntity); } } else { log.error("自动上传单据到自助平台异常,响应结果:{}", response); 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 47bb967..869eb7a 100644 --- a/src/main/java/com/glxp/udi/admin/thread/TransInoutService.java +++ b/src/main/java/com/glxp/udi/admin/thread/TransInoutService.java @@ -7,8 +7,8 @@ import com.glxp.udi.admin.entity.basic.BussinessTypeEntity; import com.glxp.udi.admin.entity.inout.*; import com.glxp.udi.admin.mongo.service.OrderDetailService; import com.glxp.udi.admin.mongo.service.OrderService; -import com.glxp.udi.admin.mongo.service.WarehouseMdService; -import com.glxp.udi.admin.mongo.service.WarehouseTempMdService; +import com.glxp.udi.admin.mongo.service.WarehouseService; +import com.glxp.udi.admin.mongo.service.WarehouseTempService; import com.glxp.udi.admin.req.inout.OrderFilterRequest; import com.glxp.udi.admin.req.inout.PostOrderRequest; import com.glxp.udi.admin.service.basic.BussinessTypeService; @@ -34,7 +34,6 @@ import java.util.List; @Transactional(rollbackFor = Exception.class) public class TransInoutService { - @Resource private UdiRelevanceService udiRelevanceService; @Resource @@ -44,9 +43,9 @@ public class TransInoutService { @Resource private OrderService orderService; @Resource - private WarehouseTempMdService warehouseTempMdService; + private WarehouseTempService warehouseTempService; @Resource - private WarehouseMdService warehouseMdService; + private WarehouseService warehouseService; @Resource private OrderDetailService orderDetailService; @Resource @@ -117,7 +116,7 @@ public class TransInoutService { } } - List filterList = warehouseTempMdService.findTempByOrderId(orderEntity.getOrderId()); + List filterList = warehouseTempService.findTempByOrderId(orderEntity.getOrderId()); List insertList = new ArrayList<>(); if (StrUtil.isBlank(orderEntity.getLocStorageCode())) { if (!StrUtil.isEmpty(bussinessTypeEntity.getStorageCode())) { @@ -133,7 +132,7 @@ public class TransInoutService { for (WarehousetempEntity warehousetemp : filterList) { warehousetemp.setLocStorageCode(orderEntity.getLocStorageCode()); - String result = inoutUtils.filterCode(warehouseMdService, warehousetemp, setupService); + String result = inoutUtils.filterCode(warehouseService, warehousetemp, setupService); if (result == null) { WarehouseEntity warehouseEntity = new WarehouseEntity(); BeanUtil.copyProperties(warehousetemp, warehouseEntity, "id"); @@ -166,13 +165,13 @@ public class TransInoutService { } if (insertList.size() > 0) { - warehouseMdService.insertWarehouses(insertList); - List temps = warehouseTempMdService.findTempByOrderId(orderEntity.getOrderId()); + warehouseService.insertWarehouses(insertList); + List temps = warehouseTempService.findTempByOrderId(orderEntity.getOrderId()); List ids = new ArrayList<>(); for (WarehousetempEntity temp : temps) { ids.add(temp.getId()); } - warehouseTempMdService.deleteTempWarehouses(ids); + warehouseTempService.deleteTempWarehouses(ids); tempEntity.setStatus(ConstantStatus.ORDER_STATUS_SUCCESS); orderService.updateOrder(tempEntity); inoutUtils.generateConstrastDetail(udiInfoService, udiRelevanceService, orderDetailService, insertList); @@ -229,7 +228,7 @@ public class TransInoutService { warehousetempList.get(index).setOrderId(orderId); warehousetempList.get(index).setCustomerId(customerId); } - warehouseTempMdService.insertTempWarehouses(warehousetempList); + warehouseTempService.insertTempWarehouses(warehousetempList); } } } diff --git a/src/main/java/com/glxp/udi/admin/thread/TransInoutTask.java b/src/main/java/com/glxp/udi/admin/thread/TransInoutTask.java index d2b2bff..3d6a987 100644 --- a/src/main/java/com/glxp/udi/admin/thread/TransInoutTask.java +++ b/src/main/java/com/glxp/udi/admin/thread/TransInoutTask.java @@ -5,7 +5,7 @@ import com.glxp.udi.admin.constant.ConstantStatus; import com.glxp.udi.admin.constant.SystemParamConstant; import com.glxp.udi.admin.dao.info.ScheduledDao; import com.glxp.udi.admin.entity.info.ScheduledEntity; -import com.glxp.udi.admin.entity.mongo.OrderMdEntity; +import com.glxp.udi.admin.entity.inout.OrderEntity; import com.glxp.udi.admin.entity.param.SystemParamConfigEntity; import com.glxp.udi.admin.mongo.service.OrderService; import com.glxp.udi.admin.req.inout.OrderFilterRequest; @@ -60,13 +60,13 @@ public class TransInoutTask implements SchedulingConfigurer { //查询待处理单据,判断此单据的用户是否开启了自动处理单据,如果已开启则自动处理,未开启跳过 OrderFilterRequest orderFilterRequest = new OrderFilterRequest(); orderFilterRequest.setStatus(ConstantStatus.ORDER_STATUS_WAIT); - List list = orderService.findAll(orderFilterRequest); + List list = orderService.findAll(orderFilterRequest); if (CollUtil.isNotEmpty(list)) { - for (OrderMdEntity orderMdEntity : list) { - SystemParamConfigEntity io_transInout_auto = systemParamCustomerConfigService.getParamByKey(SystemParamConstant.IO_TRANSINOUT_AUTO, orderMdEntity.getCustomerId()); + for (OrderEntity orderEntity : list) { + SystemParamConfigEntity io_transInout_auto = systemParamCustomerConfigService.getParamByKey(SystemParamConstant.IO_TRANSINOUT_AUTO, orderEntity.getCustomerId()); if (null != io_transInout_auto && io_transInout_auto.getParamValue().equals("1")) { //此单可以自动提交 - transInoutService.transInout(orderMdEntity); + transInoutService.transInout(orderEntity); } } } diff --git a/src/main/java/com/glxp/udi/admin/util/inout/InoutUtils.java b/src/main/java/com/glxp/udi/admin/util/inout/InoutUtils.java index 9864a45..a2cc07f 100644 --- a/src/main/java/com/glxp/udi/admin/util/inout/InoutUtils.java +++ b/src/main/java/com/glxp/udi/admin/util/inout/InoutUtils.java @@ -11,7 +11,7 @@ import com.glxp.udi.admin.entity.inout.WarehouseEntity; import com.glxp.udi.admin.entity.inout.WarehousetempEntity; import com.glxp.udi.admin.entity.udid.UdiEntity; import com.glxp.udi.admin.mongo.service.OrderDetailService; -import com.glxp.udi.admin.mongo.service.WarehouseMdService; +import com.glxp.udi.admin.mongo.service.WarehouseService; import com.glxp.udi.admin.req.inout.FilterWarehouseRequest; import com.glxp.udi.admin.service.info.SetupService; import com.glxp.udi.admin.service.inout.UdiInfoService; @@ -35,7 +35,7 @@ public class InoutUtils { @Resource private UdiInfoService udiInfoService; - public String filterCode(WarehouseMdService warehouseService, WarehousetempEntity warehousetemp, SetupService setupService) { + public String filterCode(WarehouseService warehouseService, WarehousetempEntity warehousetemp, SetupService setupService) { SetupEntity setupEntity = setupService.selectSetup(String.valueOf(warehousetemp.getCustomerId())); FilterWarehouseRequest filterWarehouseRequest = new FilterWarehouseRequest(); filterWarehouseRequest.setCode(warehousetemp.getCode()); @@ -44,7 +44,8 @@ public class InoutUtils { WarehouseEntity warehouseData = new WarehouseEntity(); BeanUtils.copyProperties(warehousetemp, warehouseData); - if (warehouseEntityList == null || warehouseEntityList.size() == 0) { //数据库为null,可以添加 + //数据库为null,可以添加 + if (warehouseEntityList == null || warehouseEntityList.size() == 0) { return nullVail(warehousetemp, setupEntity); } List inList = new ArrayList<>(); diff --git a/src/main/resources/mybatis/mapper/inout/CodesDao.xml b/src/main/resources/mybatis/mapper/inout/CodesDao.xml new file mode 100644 index 0000000..b53a357 --- /dev/null +++ b/src/main/resources/mybatis/mapper/inout/CodesDao.xml @@ -0,0 +1,25 @@ + + + + + + + + update io_codes + set fromCorp = #{fromCorp} and fromCorpId = #{fromCorpId} + where orderId = #{orderId} + + + + update io_codes set orderId = #{newOrderId} where orderId = #{orderId} + + + + update io_codes set count = #{count} where id = #{id} + + + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/inout/CodesTempDao.xml b/src/main/resources/mybatis/mapper/inout/CodesTempDao.xml new file mode 100644 index 0000000..f8501cc --- /dev/null +++ b/src/main/resources/mybatis/mapper/inout/CodesTempDao.xml @@ -0,0 +1,17 @@ + + + + + + update io_codes_temp set count = #{count} where id = #{id} + + + + delete from io_codes_temp where id = #{id} and orderId = #{orderId} + + + + + \ No newline at end of file