From da79ec6e4f79247c0e4dd3e62edb66874ca8e10c Mon Sep 17 00:00:00 2001 From: anthonywj Date: Mon, 22 Nov 2021 09:25:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E5=8D=95=E6=8D=AE=E4=B8=8E?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=8D=95=E6=8D=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/inout/WareHouseController.java | 1 + .../inout/utils/ContrastErpUtil.java | 5 + .../controller/inout/utils/InoutUtils.java | 3 +- .../inventory/InvProductsController.java | 77 ++++++++++ .../admin/dao/inventory/InvProductDao.java | 27 ++++ .../dao/inventory/InvProductDetailDao.java | 25 +++ .../admin/entity/inout/ErpOrderEntity.java | 1 + .../inventory/InvProductDetailEntity.java | 18 +++ .../entity/inventory/InvProductEntity.java | 33 ++++ .../FilterInvProductDetailRequest.java | 16 ++ .../inventory/FilterInvProductRequest.java | 23 +++ .../res/inventory/InvProductResponse.java | 33 ++++ .../admin/service/inout/CodesService.java | 1 + .../inventory/InvProductDetailService.java | 24 +++ .../service/inventory/InvProductService.java | 26 ++++ .../impl/InvProductDetailServiceImpl.java | 58 +++++++ .../inventory/impl/InvProductServiceImpl.java | 78 ++++++++++ .../admin/thread/InvProductsTrService.java | 144 ++++++++++++++++++ .../admin/thread/IoTransInoutService.java | 17 ++- .../mybatis/mapper/inout/CodesTempDao.xml | 9 +- .../mybatis/mapper/inout/OrderDetail.xml | 15 +- .../mapper/inventory/InvProductDao.xml | 140 +++++++++++++++++ .../mapper/inventory/InvProductDetailDao.xml | 83 ++++++++++ 23 files changed, 842 insertions(+), 15 deletions(-) create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/controller/inventory/InvProductsController.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvProductDao.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvProductDetailDao.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/entity/inventory/InvProductDetailEntity.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/entity/inventory/InvProductEntity.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/req/inventory/FilterInvProductDetailRequest.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/req/inventory/FilterInvProductRequest.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/res/inventory/InvProductResponse.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvProductDetailService.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvProductService.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvProductDetailServiceImpl.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvProductServiceImpl.java create mode 100644 api-admin/src/main/java/com/glxp/sale/admin/thread/InvProductsTrService.java create mode 100644 api-admin/src/main/resources/mybatis/mapper/inventory/InvProductDao.xml create mode 100644 api-admin/src/main/resources/mybatis/mapper/inventory/InvProductDetailDao.xml diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/inout/WareHouseController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/inout/WareHouseController.java index a99d25a..7f4cf72 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/controller/inout/WareHouseController.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/inout/WareHouseController.java @@ -257,6 +257,7 @@ public class WareHouseController { warehouseEntity.setFromCorp(addOrderRequest.getFromCorp()); warehouseEntity.setBatchNo(udiEntity.getBatchNo()); warehouseEntity.setProduceDate(udiEntity.getProduceDate()); + warehouseEntity.setNameCode(udiEntity.getUdi()); warehouseEntity.setExpireDate(udiEntity.getExpireDate()); warehouseEntity.setSerialNo(udiEntity.getSerialNo()); warehouseEntity.setCount(1); diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/inout/utils/ContrastErpUtil.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/inout/utils/ContrastErpUtil.java index ab68112..2da10fe 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/controller/inout/utils/ContrastErpUtil.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/inout/utils/ContrastErpUtil.java @@ -19,6 +19,7 @@ import com.glxp.sale.admin.service.basic.UdiRelevanceService; import com.glxp.sale.admin.service.param.SystemParamConfigService; import com.glxp.sale.admin.service.inout.OrderDetailService; import com.glxp.sale.admin.service.inout.OrderService; +import com.glxp.sale.admin.thread.InvProductsTrService; import com.glxp.sale.admin.thread.IoTransInoutService; import org.springframework.stereotype.Service; @@ -37,6 +38,8 @@ public class ContrastErpUtil { @Resource IoTransInoutService ioTransInoutService; + @Resource + InvProductsTrService InvProductsTrService; public ContrastErpUtil() { @@ -117,6 +120,8 @@ public class ContrastErpUtil { orderEntity.setContrastStatus(ConstantStatus.ORDER_CHECK_SUCCESS); orderService.updateOrder(orderEntity); ioTransInoutService.printOrder(orderEntity.getId()); + InvProductsTrService.genInvProducts(orderEntity.getId()); + } if (errorData.size() > 0) { new InoutUtils(udiUrl).generateConstrastDetail(udiInfoService, udiRelevanceService, orderDetailService, errorData); diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/inout/utils/InoutUtils.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/inout/utils/InoutUtils.java index 5e88e75..f8639f6 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/controller/inout/utils/InoutUtils.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/inout/utils/InoutUtils.java @@ -191,7 +191,7 @@ public class InoutUtils { List returnOrderDetail = new ArrayList<>(); Map sortMaps = new HashMap<>(); for (UdiInfoEntity detailCodeEntity : udiInfoEntities) { - String key = detailCodeEntity.getNameCode(); + String key = detailCodeEntity.getUuid() + detailCodeEntity.getBatchNo();//todo 20211118 从nameCode修改为UUID未测试 UdiInfoEntity temp = sortMaps.get(key); if (temp != null) { detailCodeEntity.setCount(temp.getCount() + detailCodeEntity.getCount()); @@ -218,6 +218,7 @@ public class InoutUtils { erpOrderEntity.setProductCompany(erpDetailCodeEntity.getYlqxzcrbarmc()); erpOrderEntity.setAuthCode(erpDetailCodeEntity.getZczbhhzbapzbh()); erpOrderEntity.setPackSpec(erpDetailCodeEntity.getGgxh()); + erpOrderEntity.setUuidFk(erpDetailCodeEntity.getUuid()); erpOrderEntities.add(erpOrderEntity); } if (!erpOrderEntities.isEmpty()) diff --git a/api-admin/src/main/java/com/glxp/sale/admin/controller/inventory/InvProductsController.java b/api-admin/src/main/java/com/glxp/sale/admin/controller/inventory/InvProductsController.java new file mode 100644 index 0000000..0ae9292 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/controller/inventory/InvProductsController.java @@ -0,0 +1,77 @@ +package com.glxp.sale.admin.controller.inventory; + +import com.github.pagehelper.PageInfo; +import com.glxp.sale.admin.entity.inout.OrderEntity; +import com.glxp.sale.admin.entity.inventory.InvProductDetailEntity; +import com.glxp.sale.admin.entity.inventory.InvProductEntity; +import com.glxp.sale.admin.req.inout.DeleteRequest; +import com.glxp.sale.admin.req.inout.OrderQueryRequest; +import com.glxp.sale.admin.req.inventory.FilterInvProductDetailRequest; +import com.glxp.sale.admin.req.inventory.FilterInvProductRequest; +import com.glxp.sale.admin.res.PageSimpleResponse; +import com.glxp.sale.admin.res.inventory.InvProductResponse; +import com.glxp.sale.admin.service.inventory.InvProductDetailService; +import com.glxp.sale.admin.service.inventory.InvProductService; +import com.glxp.sale.common.enums.ResultEnum; +import com.glxp.sale.common.res.BaseResponse; +import com.glxp.sale.common.util.ResultVOUtils; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +public class InvProductsController { + + @Resource + InvProductService invProductService; + @Resource + InvProductDetailService invProductDetailService; + + @GetMapping("spms/inv/products/filter") + public BaseResponse filterInvProduct(FilterInvProductRequest filterInvProductRequest) { + List invProductResponses = invProductService.filterJoinInvProduct(filterInvProductRequest); + PageInfo pageInfo; + pageInfo = new PageInfo<>(invProductResponses); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setList(invProductResponses); + return ResultVOUtils.success(pageSimpleResponse); + } + + + @GetMapping("spms/inv/products/filterDetail") + public BaseResponse filterInvProductDetail(FilterInvProductDetailRequest filterInvProductRequest) { + List invProductDetailEntities = invProductDetailService.filterInvProduct(filterInvProductRequest); + PageInfo pageInfo; + pageInfo = new PageInfo<>(invProductDetailEntities); + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse<>(); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + pageSimpleResponse.setList(invProductDetailEntities); + return ResultVOUtils.success(pageSimpleResponse); + } + + + @PostMapping("spms/inv/products/delete") + public BaseResponse deleteInvProduct(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) { + + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + String id = deleteRequest.getId(); + InvProductEntity invProductEntity = invProductService.selectById(id); + if (invProductEntity != null) { + invProductService.deleteById(id); + invProductDetailService.deleteByProductId(invProductEntity.getId() + ""); + return ResultVOUtils.success("删除成功"); + } else { + return ResultVOUtils.error(500, "删除失败!"); + } + + + } +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvProductDao.java b/api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvProductDao.java new file mode 100644 index 0000000..2d2da8d --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvProductDao.java @@ -0,0 +1,27 @@ +package com.glxp.sale.admin.dao.inventory; + +import com.glxp.sale.admin.entity.inventory.InvProductEntity; +import com.glxp.sale.admin.req.inventory.FilterInvProductRequest; +import com.glxp.sale.admin.res.inventory.InvProductResponse; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface InvProductDao { + + + List filterInvProduct(FilterInvProductRequest filterInvProductRequest); + + List filterJoinInvProduct(FilterInvProductRequest filterInvProductRequest); + + boolean insertInvProduct(InvProductEntity invProductEntity); + + boolean updateInvProduct(InvProductEntity invProductEntity); + + InvProductEntity selectById(@Param("id") String id); + + boolean deleteById(@Param("id") String id); + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvProductDetailDao.java b/api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvProductDetailDao.java new file mode 100644 index 0000000..52150da --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/dao/inventory/InvProductDetailDao.java @@ -0,0 +1,25 @@ +package com.glxp.sale.admin.dao.inventory; + +import com.glxp.sale.admin.entity.inventory.InvProductDetailEntity; +import com.glxp.sale.admin.req.inventory.FilterInvProductDetailRequest; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface InvProductDetailDao { + + List filterInvProductDetail(FilterInvProductDetailRequest filterInvProductDetailRequest); + + boolean insertInvProductDetail(InvProductDetailEntity invProductDetailEntity); + + boolean insertInvProductDetails(List invProductDetailEntitys); + + boolean updateInvProductDetail(InvProductDetailEntity invProductDetailEntity); + + boolean deleteById(@Param("id") String id); + + boolean deleteByProductId(@Param("productIdFk") String productIdFk); + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/inout/ErpOrderEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/inout/ErpOrderEntity.java index d0017c2..6193ecf 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/entity/inout/ErpOrderEntity.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/inout/ErpOrderEntity.java @@ -38,6 +38,7 @@ public class ErpOrderEntity { private String expireDate; private Integer erpCount; private Integer reCount; + private String uuidFk; private String nameCode; diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/inventory/InvProductDetailEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/inventory/InvProductDetailEntity.java new file mode 100644 index 0000000..ac1b1c3 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/inventory/InvProductDetailEntity.java @@ -0,0 +1,18 @@ +package com.glxp.sale.admin.entity.inventory; + +import lombok.Data; + +import java.util.Date; + +@Data +public class InvProductDetailEntity { + private Integer id; + private String code; + private String productIdFk; + private String orderIdFk; + private String customerId; + private String mainAction; + private String action; + private Integer count; + private Date updateTime; +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/entity/inventory/InvProductEntity.java b/api-admin/src/main/java/com/glxp/sale/admin/entity/inventory/InvProductEntity.java new file mode 100644 index 0000000..e9ef366 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/entity/inventory/InvProductEntity.java @@ -0,0 +1,33 @@ +package com.glxp.sale.admin.entity.inventory; + +import lombok.Data; + +@Data +public class InvProductEntity { + private Integer id; + private String productsName; + private String nameCode; + private String relIdFk; + private String ggxh; + private String batchNo; + private String productionDate; + private String expireDate; + private String ylqxzcrbarmc; + private String zczbhhzbapzbh; + private Integer inCount; + private Integer outCount; + private Integer reCount; + private String customerId; + + public Integer getInCount() { + if (inCount == null) + return 0; + return inCount; + } + + public Integer getOutCount() { + if (outCount == null) + return 0; + return outCount; + } +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/req/inventory/FilterInvProductDetailRequest.java b/api-admin/src/main/java/com/glxp/sale/admin/req/inventory/FilterInvProductDetailRequest.java new file mode 100644 index 0000000..bfdf2ef --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/req/inventory/FilterInvProductDetailRequest.java @@ -0,0 +1,16 @@ +package com.glxp.sale.admin.req.inventory; + +import com.glxp.sale.admin.req.ListPageRequest; +import lombok.Data; + +@Data +public class FilterInvProductDetailRequest extends ListPageRequest { + + private String id; + private String code; + private String productIdFk; + private String customerId; + private String mainAction; + private String action; + private Integer count; +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/req/inventory/FilterInvProductRequest.java b/api-admin/src/main/java/com/glxp/sale/admin/req/inventory/FilterInvProductRequest.java new file mode 100644 index 0000000..66153dc --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/req/inventory/FilterInvProductRequest.java @@ -0,0 +1,23 @@ +package com.glxp.sale.admin.req.inventory; + +import com.glxp.sale.admin.req.ListPageRequest; +import lombok.Data; + +@Data +public class FilterInvProductRequest extends ListPageRequest { + + private String id; + private String cpmctymc; + private String nameCode; + private String relIdFk; + private String ggxh; + private String batchNo; + private String productionDate; + private String expireDate; + private String ylqxzcrbarmc; + private String zczbhhzbapzbh; + private String customerId; + private String productsName; + + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/res/inventory/InvProductResponse.java b/api-admin/src/main/java/com/glxp/sale/admin/res/inventory/InvProductResponse.java new file mode 100644 index 0000000..1bc1217 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/res/inventory/InvProductResponse.java @@ -0,0 +1,33 @@ +package com.glxp.sale.admin.res.inventory; + +import lombok.Data; + +@Data +public class InvProductResponse { + private Integer id; + private String cpmctymc; + private String nameCode; + private String relIdFk; + private String ggxh; + private String batchNo; + private String productionDate; + private String expireDate; + private String ylqxzcrbarmc; + private String zczbhhzbapzbh; + private Integer inCount; + private Integer outCount; + private Integer reCount; + private String customerId; + + public Integer getInCount() { + if (inCount == null) + return 0; + return inCount; + } + + public Integer getOutCount() { + if (outCount == null) + return 0; + return outCount; + } +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/inout/CodesService.java b/api-admin/src/main/java/com/glxp/sale/admin/service/inout/CodesService.java index 62239e0..62bf5ec 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/service/inout/CodesService.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/inout/CodesService.java @@ -6,6 +6,7 @@ import com.glxp.sale.admin.req.inout.WarehouseQueryRequest; import java.util.List; public interface CodesService { + List listWarehouse(WarehouseQueryRequest warehouseQueryRequest); boolean insertWarehouse(WarehouseEntity warehouseEntity); diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvProductDetailService.java b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvProductDetailService.java new file mode 100644 index 0000000..8b79750 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvProductDetailService.java @@ -0,0 +1,24 @@ +package com.glxp.sale.admin.service.inventory; + +import com.glxp.sale.admin.entity.inventory.InvProductDetailEntity; +import com.glxp.sale.admin.req.inventory.FilterInvProductDetailRequest; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Service; + +import java.util.List; + +public interface InvProductDetailService { + + + List filterInvProduct(FilterInvProductDetailRequest filterInvProductDetailRequest); + + boolean insertInvProduct(InvProductDetailEntity invProductDetailEntity); + + boolean insertInvProducts(List invProductDetailEntitys); + + boolean updateInvProduct(InvProductDetailEntity invProductDetailEntity); + + boolean deleteById(String id); + + boolean deleteByProductId(String productIdFk); +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvProductService.java b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvProductService.java new file mode 100644 index 0000000..3bf50ce --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/InvProductService.java @@ -0,0 +1,26 @@ +package com.glxp.sale.admin.service.inventory; + +import com.glxp.sale.admin.entity.inventory.InvProductEntity; +import com.glxp.sale.admin.req.inventory.FilterInvProductRequest; +import com.glxp.sale.admin.res.inventory.InvProductResponse; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface InvProductService { + + List filterInvProduct(FilterInvProductRequest filterInvProductRequest); + + List filterJoinInvProduct(FilterInvProductRequest filterInvProductRequest); + + InvProductEntity selectByUuid(String uuid, String batchNo); + + InvProductEntity selectById(String id); + + boolean insertInvProduct(InvProductEntity invProductEntity); + + boolean updateInvProduct(InvProductEntity invProductEntity); + + boolean deleteById(String id); + +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvProductDetailServiceImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvProductDetailServiceImpl.java new file mode 100644 index 0000000..1f5e736 --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvProductDetailServiceImpl.java @@ -0,0 +1,58 @@ +package com.glxp.sale.admin.service.inventory.impl; + +import com.github.pagehelper.PageHelper; +import com.glxp.sale.admin.dao.inventory.InvProductDetailDao; +import com.glxp.sale.admin.entity.inventory.InvProductDetailEntity; +import com.glxp.sale.admin.req.inventory.FilterInvProductDetailRequest; +import com.glxp.sale.admin.service.inventory.InvProductDetailService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; + + +@Service +public class InvProductDetailServiceImpl implements InvProductDetailService { + + @Resource + InvProductDetailDao invProductDetailDao; + + @Override + public List filterInvProduct(FilterInvProductDetailRequest filterInvProductDetailRequest) { + if (filterInvProductDetailRequest == null) { + return Collections.emptyList(); + } + if (filterInvProductDetailRequest.getPage() != null) { + int offset = (filterInvProductDetailRequest.getPage() - 1) * filterInvProductDetailRequest.getLimit(); + PageHelper.offsetPage(offset, filterInvProductDetailRequest.getLimit()); + } + List data = invProductDetailDao.filterInvProductDetail(filterInvProductDetailRequest); + return data; + } + + @Override + public boolean insertInvProduct(InvProductDetailEntity invProductDetailEntity) { + return invProductDetailDao.insertInvProductDetail(invProductDetailEntity); + } + + @Override + public boolean insertInvProducts(List invProductDetailEntitys) { + return invProductDetailDao.insertInvProductDetails(invProductDetailEntitys); + } + + @Override + public boolean updateInvProduct(InvProductDetailEntity invProductDetailEntity) { + return invProductDetailDao.updateInvProductDetail(invProductDetailEntity); + } + + @Override + public boolean deleteById(String id) { + return invProductDetailDao.deleteById(id); + } + + @Override + public boolean deleteByProductId(String productIdFk) { + return false; + } +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvProductServiceImpl.java b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvProductServiceImpl.java new file mode 100644 index 0000000..4c955ed --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/service/inventory/impl/InvProductServiceImpl.java @@ -0,0 +1,78 @@ +package com.glxp.sale.admin.service.inventory.impl; + +import com.github.pagehelper.PageHelper; +import com.glxp.sale.admin.dao.inventory.InvProductDao; +import com.glxp.sale.admin.entity.inventory.InvProductEntity; +import com.glxp.sale.admin.req.inventory.FilterInvProductRequest; +import com.glxp.sale.admin.res.inventory.InvProductResponse; +import com.glxp.sale.admin.service.inventory.InvProductService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; + +@Service +public class InvProductServiceImpl implements InvProductService { + + @Resource + InvProductDao invProductDao; + + @Override + public List filterInvProduct(FilterInvProductRequest filterInvProductRequest) { + if (filterInvProductRequest == null) { + return Collections.emptyList(); + } + if (filterInvProductRequest.getPage() != null) { + int offset = (filterInvProductRequest.getPage() - 1) * filterInvProductRequest.getLimit(); + PageHelper.offsetPage(offset, filterInvProductRequest.getLimit()); + } + List data = invProductDao.filterInvProduct(filterInvProductRequest); + return data; + } + + @Override + public List filterJoinInvProduct(FilterInvProductRequest filterInvProductRequest) { + if (filterInvProductRequest == null) { + return Collections.emptyList(); + } + if (filterInvProductRequest.getPage() != null) { + int offset = (filterInvProductRequest.getPage() - 1) * filterInvProductRequest.getLimit(); + PageHelper.offsetPage(offset, filterInvProductRequest.getLimit()); + } + List data = invProductDao.filterJoinInvProduct(filterInvProductRequest); + return data; + } + + @Override + public InvProductEntity selectByUuid(String uuid, String batchNo) { + FilterInvProductRequest filterInvProductRequest = new FilterInvProductRequest(); + filterInvProductRequest.setRelIdFk(uuid); + filterInvProductRequest.setBatchNo(batchNo); + List data = filterInvProduct(filterInvProductRequest); + if (data != null && data.size() > 0) { + return data.get(0); + } + return null; + } + + @Override + public InvProductEntity selectById(String id) { + return invProductDao.selectById(id); + } + + @Override + public boolean insertInvProduct(InvProductEntity invProductEntity) { + return invProductDao.insertInvProduct(invProductEntity); + } + + @Override + public boolean updateInvProduct(InvProductEntity invProductEntity) { + return invProductDao.updateInvProduct(invProductEntity); + } + + @Override + public boolean deleteById(String id) { + return invProductDao.deleteById(id); + } +} diff --git a/api-admin/src/main/java/com/glxp/sale/admin/thread/InvProductsTrService.java b/api-admin/src/main/java/com/glxp/sale/admin/thread/InvProductsTrService.java new file mode 100644 index 0000000..10101cf --- /dev/null +++ b/api-admin/src/main/java/com/glxp/sale/admin/thread/InvProductsTrService.java @@ -0,0 +1,144 @@ +package com.glxp.sale.admin.thread; + +import com.glxp.sale.admin.constant.ConstantStatus; +import com.glxp.sale.admin.constant.ConstantType; +import com.glxp.sale.admin.entity.basic.BussinessTypeEntity; +import com.glxp.sale.admin.entity.basic.UdiInfoEntity; +import com.glxp.sale.admin.entity.inout.ErpOrderEntity; +import com.glxp.sale.admin.entity.inout.FilterErpOrderRequest; +import com.glxp.sale.admin.entity.inout.OrderEntity; +import com.glxp.sale.admin.entity.inout.WarehouseEntity; +import com.glxp.sale.admin.entity.inventory.InvProductDetailEntity; +import com.glxp.sale.admin.entity.inventory.InvProductEntity; +import com.glxp.sale.admin.req.basic.FilterUdiInfoRequest; +import com.glxp.sale.admin.res.basic.UdiRelevanceResponse; +import com.glxp.sale.admin.service.basic.BussinessTypeService; +import com.glxp.sale.admin.service.basic.UdiInfoService; +import com.glxp.sale.admin.service.basic.UdiRelevanceService; +import com.glxp.sale.admin.service.inout.CodesService; +import com.glxp.sale.admin.service.inout.OrderDetailService; +import com.glxp.sale.admin.service.inout.OrderService; +import com.glxp.sale.admin.service.inventory.InvProductDetailService; +import com.glxp.sale.admin.service.inventory.InvProductService; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.*; + +@Service +public class InvProductsTrService { + + + @Resource + private OrderService orderService; + @Resource + private OrderDetailService myErpOrderService; + @Resource + private CodesService codesService; + @Resource + private UdiRelevanceService udiRelevanceService; + @Resource + private UdiInfoService udiInfoService; + @Resource + private BussinessTypeService bussinessTypeService; + + @Resource + private InvProductService invProductService; + @Resource + private InvProductDetailService invProductDetailService; + + + @Async + public void genInvProducts(String orderId) { + OrderEntity orderEntity = orderService.findById(orderId); + if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_SUCCESS && + (orderEntity.getContrastStatus() == ConstantStatus.ORDER_CHECK_SUCCESS || + orderEntity.getContrastStatus() == ConstantStatus.ORDER_CHECK_UN)) { + FilterErpOrderRequest filterErpOrderRequest = new FilterErpOrderRequest(); + filterErpOrderRequest.setOrderId(orderId); + List erpOrderEntities = myErpOrderService.filterAllMyErpOrder(filterErpOrderRequest); + BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(orderEntity.getAction()); + if (erpOrderEntities != null && erpOrderEntities.size() > 0) { + for (ErpOrderEntity erpOrderEntity : erpOrderEntities) { + + String nameCode = erpOrderEntity.getNameCode(); + String erpId = erpOrderEntity.getGoodsid(); + FilterUdiInfoRequest filterUdiInfoRequest = new FilterUdiInfoRequest(); + filterUdiInfoRequest.setNameCode(nameCode); + + if (bussinessTypeEntity.getThirdSysFk().equals("thirdId")) { + filterUdiInfoRequest.setThirdId(erpId); + } else if (bussinessTypeEntity.getThirdSysFk().equals("thirdId1")) { + filterUdiInfoRequest.setThirdId1(erpId); + } else if (bussinessTypeEntity.getThirdSysFk().equals("thirdId2")) { + filterUdiInfoRequest.setThirdId2(erpId); + } else if (bussinessTypeEntity.getThirdSysFk().equals("thirdId3")) { + filterUdiInfoRequest.setThirdId3(erpId); + } else if (bussinessTypeEntity.getThirdSysFk().equals("thirdId4")) { + filterUdiInfoRequest.setThirdId4(erpId); + } + + List udiRelevanceResponses = udiRelevanceService.filterUdiRelevance(filterUdiInfoRequest); + String relId = null; + if (udiRelevanceResponses != null && udiRelevanceResponses.size() > 0) { + relId = udiRelevanceResponses.get(0).getId() + ""; + } + if (relId != null) { + InvProductEntity invProductEntity = invProductService.selectByUuid(relId, erpOrderEntity.getBatchNo()); + if (invProductEntity == null) { + invProductEntity = new InvProductEntity(); + invProductEntity.setRelIdFk(relId); + invProductEntity.setBatchNo(erpOrderEntity.getBatchNo()); + invProductEntity.setCustomerId(orderEntity.getCustomerId()); + invProductEntity.setExpireDate(erpOrderEntity.getExpireDate()); + invProductEntity.setProductionDate(erpOrderEntity.getProductDate()); + invProductEntity.setGgxh(erpOrderEntity.getPackSpec()); + invProductEntity.setNameCode(erpOrderEntity.getNameCode()); + invProductEntity.setProductsName(erpOrderEntity.getCoName()); + invProductEntity.setYlqxzcrbarmc(erpOrderEntity.getProductCompany()); + invProductEntity.setZczbhhzbapzbh(erpOrderEntity.getAuthCode()); + if (orderEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { + invProductEntity.setOutCount(erpOrderEntity.getCount()); + } else if (orderEntity.getMainAction().equals(ConstantType.TYPE_PUT)) { + invProductEntity.setInCount(erpOrderEntity.getCount()); + } + invProductService.insertInvProduct(invProductEntity); + invProductEntity = invProductService.selectByUuid(relId, erpOrderEntity.getBatchNo()); + } else { + if (orderEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { + invProductEntity.setOutCount(invProductEntity.getOutCount() + erpOrderEntity.getCount()); + } else if (orderEntity.getMainAction().equals(ConstantType.TYPE_PUT)) { + invProductEntity.setInCount(invProductEntity.getInCount() + erpOrderEntity.getCount()); + } + invProductService.updateInvProduct(invProductEntity); + } + List warehouseEntities = codesService.findByReceiptId(orderId); + if (warehouseEntities != null && warehouseEntities.size() > 0) { + for (WarehouseEntity warehouseEntity : warehouseEntities) { + UdiInfoEntity udiInfoEntity = udiInfoService.findByNameCode(warehouseEntity.getNameCode()); + if (udiInfoEntity.getUuid().equals(erpOrderEntity.getUuidFk())) { + if ((warehouseEntity.getBatchNo() == null && erpOrderEntity.getBatchNo() == null) || + warehouseEntity.getBatchNo().equals(erpOrderEntity.getBatchNo())) { + InvProductDetailEntity invProductDetailEntity = new InvProductDetailEntity(); + invProductDetailEntity.setProductIdFk(invProductEntity.getId() + ""); + invProductDetailEntity.setCode(warehouseEntity.getCode()); + invProductDetailEntity.setAction(warehouseEntity.getAction()); + invProductDetailEntity.setMainAction(warehouseEntity.getMainAction()); + invProductDetailEntity.setOrderIdFk(warehouseEntity.getOrderId()); + invProductDetailEntity.setCount(warehouseEntity.getCount()); + invProductDetailEntity.setUpdateTime(new Date()); + invProductDetailEntity.setCustomerId(orderEntity.getCustomerId()); + invProductDetailService.insertInvProduct(invProductDetailEntity); + } + } + } + + } + } + } + } + } + + } +} \ No newline at end of file diff --git a/api-admin/src/main/java/com/glxp/sale/admin/thread/IoTransInoutService.java b/api-admin/src/main/java/com/glxp/sale/admin/thread/IoTransInoutService.java index d92da5d..86a21c8 100644 --- a/api-admin/src/main/java/com/glxp/sale/admin/thread/IoTransInoutService.java +++ b/api-admin/src/main/java/com/glxp/sale/admin/thread/IoTransInoutService.java @@ -61,13 +61,13 @@ public class IoTransInoutService { @Resource private BussinessTypeService bussinessTypeService; @Resource - private ThrOrderService thrOrderService; - @Resource ThrDataService thrDataService; @Resource StockOrderService stockOrderService; @Resource StockOrderDetailService stockOrderDetailService; + @Resource + InvProductsTrService invProductsTrService; //web端新增订单, @@ -228,6 +228,7 @@ public class IoTransInoutService { //因为只需用到条码,所以不需要重新读取 new InoutUtils(udiUrl).generateConstrastDetail(udiInfoService, udiRelevanceService, myErpOrderService, insertList); orderService.updateOrderStatus(orderEntity.getId(), ConstantStatus.ORDER_STATUS_SUCCESS); + invProductsTrService.genInvProducts(orderEntity.getId()); printOrder(orderEntity.getId()); } @@ -256,7 +257,8 @@ public class IoTransInoutService { @Async public void repeatPrint(OrderEntity orderEntity) { - printOrder(orderEntity.getId()); + syncprintOrder(orderEntity.getId()); + invProductsTrService.genInvProducts(orderEntity.getId()); } public void checkOrder(OrderEntity orderEntity) { @@ -276,6 +278,7 @@ public class IoTransInoutService { myErpOrderService.deleteByOrderId(orderEntity.getId()); new InoutUtils(udiUrl).generateConstrastDetail(udiInfoService, udiRelevanceService, myErpOrderService, transData); printOrder(orderEntity.getId()); + invProductsTrService.genInvProducts(orderEntity.getId()); } } @@ -297,6 +300,7 @@ public class IoTransInoutService { BussinessTypeEntity bussinessTypeEntity = bussinessTypeService.findBTByAction(orderEntity.getAction()); new ContrastErpUtil(udiUrl).contrastErp(udiInfoService, udiRelevanceService, myErpOrderService, orderService, transData, systemParamConfigService, bussinessTypeEntity); + } else { orderEntity.setContrastStatus(ConstantStatus.ORDER_CHECK_FAIL); orderEntity.setStatus(ConstantStatus.ORDER_STATUS_SUCCESS); @@ -328,6 +332,11 @@ public class IoTransInoutService { //校验ERP单后,订单详情转入等待打印 @Async public void printOrder(String orderId) { + syncprintOrder(orderId); + } + + + public void syncprintOrder(String orderId) { OrderEntity orderEntity = orderService.findById(orderId); if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_SUCCESS && orderEntity.getErpFk() == null ) { @@ -346,7 +355,6 @@ public class IoTransInoutService { boolean isError = false; for (ErpOrderEntity erpOrderEntity : erpOrderEntities) { StockOrderDetailEntity stockOrderDetailEntity = new StockOrderDetailEntity(); -// stockOrderDetailEntity.setOrderIdFk(stockOrderEntity.getId()); stockOrderDetailEntity.setProductId(erpOrderEntity.getGoodsid()); stockOrderDetailEntity.setProductName(erpOrderEntity.getGoodsname()); @@ -424,6 +432,7 @@ public class IoTransInoutService { } } + public StockOrderEntity genStockOrder(OrderEntity orderEntity, BussinessTypeEntity bussinessTypeEntity) { //生成业务单据记录 StockOrderEntity stockOrderEntity = new StockOrderEntity(); diff --git a/api-admin/src/main/resources/mybatis/mapper/inout/CodesTempDao.xml b/api-admin/src/main/resources/mybatis/mapper/inout/CodesTempDao.xml index 7c2fbdb..77e5308 100644 --- a/api-admin/src/main/resources/mybatis/mapper/inout/CodesTempDao.xml +++ b/api-admin/src/main/resources/mybatis/mapper/inout/CodesTempDao.xml @@ -7,7 +7,7 @@ INSERT INTO io_codes_temp (action, mainAction,code, corpOrderId, actor,actDate, - fromCorpId, fromCorp, orderId,batchNo,produceDate,expireDate,serialNo,count) + fromCorpId, fromCorp, orderId,batchNo,produceDate,expireDate,serialNo,count,nameCode) VALUES @@ -25,7 +25,7 @@ ,#{item.produceDate} ,#{item.expireDate} ,#{item.serialNo} - ,#{item.count} + ,#{item.count},#{item.nameCode} ) @@ -33,7 +33,8 @@ INSERT INTO io_codes_temp(action, mainAction, code, corpOrderId, actor, actDate, - fromCorpId, fromCorp, orderId, batchNo, produceDate, expireDate, serialNo, count) + fromCorpId, fromCorp, orderId, batchNo, produceDate, expireDate, serialNo, + count,nameCode) values( #{action}, #{mainAction}, @@ -48,7 +49,7 @@ #{produceDate}, #{expireDate}, #{serialNo}, - #{count} + #{count},#{nameCode} ) diff --git a/api-admin/src/main/resources/mybatis/mapper/inout/OrderDetail.xml b/api-admin/src/main/resources/mybatis/mapper/inout/OrderDetail.xml index 85a105d..e8b9db5 100644 --- a/api-admin/src/main/resources/mybatis/mapper/inout/OrderDetail.xml +++ b/api-admin/src/main/resources/mybatis/mapper/inout/OrderDetail.xml @@ -111,7 +111,7 @@ batchNoId,goodsname,companyname, batchNo,erpCount,credate,nameCode,productCompany, coName,authCode,packSpec,packRatio,bhzxxsbzsl, - zxxsbzbhsydysl,orderIdFk,count,reCount,productDate,expireDate,bindStatus,bindRlFk) + zxxsbzbhsydysl,orderIdFk,count,reCount,productDate,expireDate,bindStatus,bindRlFk,uuidFk) values( #{id}, #{companyid}, @@ -128,7 +128,7 @@ #{credate}, #{nameCode},#{productCompany},#{coName},#{authCode},#{packSpec},#{packRatio}, #{bhzxxsbzsl},#{zxxsbzbhsydysl},#{orderIdFk},#{count},#{reCount},#{productDate},#{expireDate} - ,#{bindStatus},#{bindRlFk} + ,#{bindStatus},#{bindRlFk},#{uuidFk} ) @@ -137,7 +137,7 @@ companyid,erpOrderId,iodtlId,inoutId,goodsunit,goodsid,batchNoId,goodsname,companyname, batchNo,erpCount,credate,nameCode,productCompany, coName,authCode,packSpec,packRatio,bhzxxsbzsl,zxxsbzbhsydysl,orderIdFk,count,reCount,productDate,expireDate - ,bindStatus,bindRlFk) + ,bindStatus,bindRlFk,uuidFk) values @@ -159,20 +159,23 @@ #{item.packRatio}, #{item.bhzxxsbzsl}, #{item.zxxsbzbhsydysl}, #{item.orderIdFk}, #{item.count},#{item.reCount},#{item.productDate},#{item.expireDate}, - #{item.bindStatus}, #{item.bindRlFk}) + #{item.bindStatus}, #{item.bindRlFk},#{item.uuidFk} + ) UPDATE io_order_detail - + goodsid=#{goodsid}, goodsname=#{goodsname}, bindStatus=#{bindStatus}, bindRlFk=#{bindRlFk}, count=#{count}, reCount=#{reCount}, - + uuidFk=#{uuidFk}, + + WHERE id = #{id} diff --git a/api-admin/src/main/resources/mybatis/mapper/inventory/InvProductDao.xml b/api-admin/src/main/resources/mybatis/mapper/inventory/InvProductDao.xml new file mode 100644 index 0000000..33abb60 --- /dev/null +++ b/api-admin/src/main/resources/mybatis/mapper/inventory/InvProductDao.xml @@ -0,0 +1,140 @@ + + + + + + + + + + + + + insert INTO inv_product + (productsName,nameCode,relIdFk,ggxh,batchNo, + productionDate,expireDate,ylqxzcrbarmc,zczbhhzbapzbh, + inCount,outCount,reCount,customerId) + values + ( + #{productsName},#{nameCode}, + #{relIdFk},#{ggxh},#{batchNo}, + #{productionDate},#{expireDate}, + #{ylqxzcrbarmc},#{zczbhhzbapzbh}, + #{inCount},#{outCount},#{reCount},#{customerId} + ) + + + + + DELETE FROM inv_product WHERE id = #{id} + + + + UPDATE inv_product + + productsName=#{productsName}, + nameCode=#{nameCode}, + relIdFk=#{relIdFk}, + ggxh=#{ggxh}, + batchNo=#{batchNo}, + productionDate=#{productionDate}, + expireDate=#{expireDate}, + ylqxzcrbarmc=#{ylqxzcrbarmc}, + zczbhhzbapzbh=#{zczbhhzbapzbh}, + inCount=#{inCount}, + outCount=#{outCount}, + reCount=#{reCount}, + customerId=#{customerId}, + + WHERE id = #{id} + + + \ No newline at end of file diff --git a/api-admin/src/main/resources/mybatis/mapper/inventory/InvProductDetailDao.xml b/api-admin/src/main/resources/mybatis/mapper/inventory/InvProductDetailDao.xml new file mode 100644 index 0000000..48b3d7b --- /dev/null +++ b/api-admin/src/main/resources/mybatis/mapper/inventory/InvProductDetailDao.xml @@ -0,0 +1,83 @@ + + + + + + + + + insert INTO inv_product_detail + (code,productIdFk,orderIdFk,customerId,mainAction,action,count,updateTime) + values + + ( + #{code}, + #{productIdFk},#{orderIdFk}, + #{customerId},#{mainAction},#{action},#{count},#{updateTime} + ) + + + + + insert INTO inv_product_detail + (code,productIdFk,customerId,mainAction,action,count,updateTime) + values + + + ( + #{item.code}, + #{item.productIdFk},#{item.orderIdFk}, + #{item.customerId},#{item.mainAction},#{item.action},#{item.count},#{item.updateTime} + ) + + + + + + + DELETE FROM inv_product_detail WHERE id = #{id} + + + + DELETE FROM inv_product_detail WHERE productIdFk = #{productIdFk} + + + + UPDATE inv_product_detail + + code=#{code}, + productIdFk=#{productIdFk}, + customerId=#{customerId}, + mainAction=#{mainAction}, + action=#{action}, + count=#{count}, + + WHERE id = #{id} + + + \ No newline at end of file