From 3ff9f82a49b81fc6d6463e2bd2f91e1c1842d128 Mon Sep 17 00:00:00 2001 From: lijiaqi Date: Mon, 25 Nov 2024 13:12:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(stock):=20=E6=B7=BB=E5=8A=A0=E4=BE=9B?= =?UTF-8?q?=E5=BA=94=E5=95=86=E4=BF=A1=E6=81=AF=E5=B9=B6=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在多个 BO 和 DTO 中添加供应商 ID、编号和名称字段 - 更新查询接口和 Excel 导出模型,支持供应商信息展示 - 在查询 SQL 中添加供应商 ID 条件,支持按供应商筛选 --- .../bo/stock/product/QueryProductStockBo.java | 36 ++++++++++++++++--- .../product/log/QueryProductStockLogBo.java | 34 +++++++++++++++--- .../stock/transfer/ScTransferOrderFullBo.java | 34 +++++++++++++++--- .../stock/transfer/ScTransferProductBo.java | 22 ++++++++++++ .../stock/transfer/ScTransferProductDto.java | 18 ++++++++++ .../excel/stock/ProductStockExportModel.java | 30 +++++++++++++--- .../stock/ProductStockLogExportModel.java | 29 ++++++++++++--- .../sc/vo/stock/QueryProductStockVo.java | 6 ++++ .../vo/stock/log/QueryProductStockLogVo.java | 6 ++++ .../mappers/stock/ProductStockLogMapper.xml | 3 ++ .../mappers/stock/ProductStockMapper.xml | 3 ++ .../stock/transfer/ScTransferOrderMapper.xml | 9 ++++- 12 files changed, 208 insertions(+), 22 deletions(-) diff --git a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/product/QueryProductStockBo.java b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/product/QueryProductStockBo.java index 69ca937..4493736 100644 --- a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/product/QueryProductStockBo.java +++ b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/product/QueryProductStockBo.java @@ -1,21 +1,21 @@ package com.lframework.xingyun.sc.bo.stock.product; import com.lframework.starter.common.utils.NumberUtil; +import com.lframework.starter.common.utils.ObjectUtil; import com.lframework.starter.web.bo.BaseBo; import com.lframework.starter.web.common.utils.ApplicationUtil; -import com.lframework.xingyun.basedata.entity.Product; -import com.lframework.xingyun.basedata.entity.ProductBrand; -import com.lframework.xingyun.basedata.entity.ProductCategory; -import com.lframework.xingyun.basedata.entity.StoreCenter; +import com.lframework.xingyun.basedata.entity.*; import com.lframework.xingyun.basedata.service.product.ProductBrandService; import com.lframework.xingyun.basedata.service.product.ProductCategoryService; import com.lframework.xingyun.basedata.service.product.ProductService; import com.lframework.xingyun.basedata.service.storecenter.StoreCenterService; +import com.lframework.xingyun.basedata.service.supplier.SupplierService; import com.lframework.xingyun.sc.entity.ProductStock; import io.swagger.annotations.ApiModelProperty; -import java.math.BigDecimal; import lombok.Data; +import java.math.BigDecimal; + @Data public class QueryProductStockBo extends BaseBo { @@ -91,6 +91,24 @@ public class QueryProductStockBo extends BaseBo { @ApiModelProperty("含税金额") private BigDecimal taxAmount; + /** + * 供应商id + */ + @ApiModelProperty("供应商id") + private String supplierId; + + /** + * 供应商编号 + */ + @ApiModelProperty("供应商编号") + private String supplierCode; + + /** + * 供应商名称 + */ + @ApiModelProperty("供应商名称") + private String supplierName; + public QueryProductStockBo() { } @@ -118,6 +136,9 @@ public class QueryProductStockBo extends BaseBo { ProductBrandService productBrandService = ApplicationUtil.getBean(ProductBrandService.class); ProductBrand productBrand = productBrandService.findById(product.getBrandId()); + SupplierService supplierService = ApplicationUtil.getBean(SupplierService.class); + Supplier supplier = supplierService.findById(product.getSupplierId()); + this.productCode = product.getCode(); this.productName = product.getName(); this.categoryName = productCategory.getName(); @@ -125,5 +146,10 @@ public class QueryProductStockBo extends BaseBo { this.taxPrice = NumberUtil.getNumber(dto.getTaxPrice(), 2); this.taxAmount = NumberUtil.getNumber(dto.getTaxAmount(), 2); + if (ObjectUtil.isNotNull(supplier)) { + this.supplierCode = supplier.getCode(); + this.supplierName = supplier.getName(); + this.supplierId = supplier.getId(); + } } } diff --git a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/product/log/QueryProductStockLogBo.java b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/product/log/QueryProductStockLogBo.java index ef43b65..3a1d4b1 100644 --- a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/product/log/QueryProductStockLogBo.java +++ b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/product/log/QueryProductStockLogBo.java @@ -3,16 +3,15 @@ package com.lframework.xingyun.sc.bo.stock.product.log; import com.fasterxml.jackson.annotation.JsonFormat; import com.lframework.starter.common.constants.StringPool; import com.lframework.starter.common.utils.NumberUtil; +import com.lframework.starter.common.utils.ObjectUtil; import com.lframework.starter.web.bo.BaseBo; import com.lframework.starter.web.common.utils.ApplicationUtil; -import com.lframework.xingyun.basedata.entity.Product; -import com.lframework.xingyun.basedata.entity.ProductBrand; -import com.lframework.xingyun.basedata.entity.ProductCategory; -import com.lframework.xingyun.basedata.entity.StoreCenter; +import com.lframework.xingyun.basedata.entity.*; import com.lframework.xingyun.basedata.service.product.ProductBrandService; import com.lframework.xingyun.basedata.service.product.ProductCategoryService; import com.lframework.xingyun.basedata.service.product.ProductService; import com.lframework.xingyun.basedata.service.storecenter.StoreCenterService; +import com.lframework.xingyun.basedata.service.supplier.SupplierService; import com.lframework.xingyun.sc.entity.ProductStockLog; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; @@ -143,6 +142,24 @@ public class QueryProductStockLogBo extends BaseBo { @ApiModelProperty("业务类型") private Integer bizType; + /** + * 供应商id + */ + @ApiModelProperty("供应商id") + private String supplierId; + + /** + * 供应商编号 + */ + @ApiModelProperty("供应商编号") + private String supplierCode; + + /** + * 供应商名称 + */ + @ApiModelProperty("供应商名称") + private String supplierName; + public QueryProductStockLogBo() { } @@ -176,6 +193,9 @@ public class QueryProductStockLogBo extends BaseBo { ProductBrandService productBrandService = ApplicationUtil.getBean(ProductBrandService.class); ProductBrand productBrand = productBrandService.findById(product.getBrandId()); + SupplierService supplierService = ApplicationUtil.getBean(SupplierService.class); + Supplier supplier = supplierService.findById(product.getSupplierId()); + this.productCode = product.getCode(); this.productName = product.getName(); this.categoryName = productCategory.getName(); @@ -186,5 +206,11 @@ public class QueryProductStockLogBo extends BaseBo { this.taxAmount = NumberUtil.getNumber(dto.getTaxAmount(), 2); this.bizType = dto.getBizType().getCode(); + + if (ObjectUtil.isNotNull(supplier)) { + this.supplierCode = supplier.getCode(); + this.supplierName = supplier.getName(); + this.supplierId = supplier.getId(); + } } } diff --git a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/transfer/ScTransferOrderFullBo.java b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/transfer/ScTransferOrderFullBo.java index c3d8094..e2c1891 100644 --- a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/transfer/ScTransferOrderFullBo.java +++ b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/transfer/ScTransferOrderFullBo.java @@ -3,18 +3,17 @@ package com.lframework.xingyun.sc.bo.stock.transfer; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import com.lframework.starter.common.constants.StringPool; +import com.lframework.starter.common.utils.ObjectUtil; import com.lframework.starter.common.utils.StringUtil; import com.lframework.starter.web.bo.BaseBo; import com.lframework.starter.web.common.utils.ApplicationUtil; import com.lframework.starter.web.utils.EnumUtil; -import com.lframework.xingyun.basedata.entity.Product; -import com.lframework.xingyun.basedata.entity.ProductBrand; -import com.lframework.xingyun.basedata.entity.ProductCategory; -import com.lframework.xingyun.basedata.entity.StoreCenter; +import com.lframework.xingyun.basedata.entity.*; import com.lframework.xingyun.basedata.service.product.ProductBrandService; import com.lframework.xingyun.basedata.service.product.ProductCategoryService; import com.lframework.xingyun.basedata.service.product.ProductService; import com.lframework.xingyun.basedata.service.storecenter.StoreCenterService; +import com.lframework.xingyun.basedata.service.supplier.SupplierService; import com.lframework.xingyun.sc.dto.stock.transfer.ScTransferOrderFullDto; import com.lframework.xingyun.sc.entity.ProductStock; import com.lframework.xingyun.sc.enums.ScTransferOrderStatus; @@ -268,6 +267,24 @@ public class ScTransferOrderFullBo extends BaseBo { @ApiModelProperty(hidden = true) private Integer status; + /** + * 供应商id + */ + @ApiModelProperty("供应商id") + private String supplierId; + + /** + * 供应商编号 + */ + @ApiModelProperty("供应商编号") + private String supplierCode; + + /** + * 供应商名称 + */ + @ApiModelProperty("供应商名称") + private String supplierName; + public DetailBo(ScTransferOrderFullDto.DetailDto dto, String scId, Integer status) { this.scId = scId; @@ -314,6 +331,15 @@ public class ScTransferOrderFullBo extends BaseBo { this.scId); this.curStockNum = productStock == null ? 0 : productStock.getStockNum(); } + + SupplierService supplierService = ApplicationUtil.getBean(SupplierService.class); + Supplier supplier = supplierService.findById(product.getSupplierId()); + + if (ObjectUtil.isNotNull(supplier)) { + this.supplierCode = supplier.getCode(); + this.supplierName = supplier.getName(); + this.supplierId = supplier.getId(); + } } } } diff --git a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/transfer/ScTransferProductBo.java b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/transfer/ScTransferProductBo.java index 84dcbae..c0ff208 100644 --- a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/transfer/ScTransferProductBo.java +++ b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/bo/stock/transfer/ScTransferProductBo.java @@ -79,6 +79,25 @@ public class ScTransferProductBo extends BaseBo { @ApiModelProperty(hidden = true) private String scId; + + /** + * 供应商id + */ + @ApiModelProperty("供应商id") + private String supplierId; + + /** + * 供应商编号 + */ + @ApiModelProperty("供应商编号") + private String supplierCode; + + /** + * 供应商名称 + */ + @ApiModelProperty("供应商名称") + private String supplierName; + public ScTransferProductBo() { } @@ -101,5 +120,8 @@ public class ScTransferProductBo extends BaseBo { ProductStock productStock = productStockService.getByProductIdAndScId(dto.getId(), this.scId); this.curStockNum = productStock == null ? 0 : productStock.getStockNum(); + this.supplierId = dto.getSupplierId(); + this.supplierCode = dto.getSupplierCode(); + this.supplierName = dto.getSupplierName(); } } diff --git a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/dto/stock/transfer/ScTransferProductDto.java b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/dto/stock/transfer/ScTransferProductDto.java index f9d36ec..3675c2a 100644 --- a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/dto/stock/transfer/ScTransferProductDto.java +++ b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/dto/stock/transfer/ScTransferProductDto.java @@ -2,6 +2,8 @@ package com.lframework.xingyun.sc.dto.stock.transfer; import com.lframework.starter.web.dto.BaseDto; import java.io.Serializable; + +import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @@ -68,4 +70,20 @@ public class ScTransferProductDto implements BaseDto, Serializable { * 当前库存数量 */ private Integer curStockNum; + + + /** + * 供应商id + */ + private String supplierId; + + /** + * 供应商编号 + */ + private String supplierCode; + + /** + * 供应商名称 + */ + private String supplierName; } diff --git a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/stock/ProductStockExportModel.java b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/stock/ProductStockExportModel.java index 08dd55c..a3b7637 100644 --- a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/stock/ProductStockExportModel.java +++ b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/stock/ProductStockExportModel.java @@ -2,19 +2,20 @@ package com.lframework.xingyun.sc.excel.stock; import com.alibaba.excel.annotation.ExcelProperty; import com.lframework.starter.common.utils.NumberUtil; +import com.lframework.starter.common.utils.ObjectUtil; import com.lframework.starter.web.bo.BaseBo; import com.lframework.starter.web.common.utils.ApplicationUtil; import com.lframework.starter.web.components.excel.ExcelModel; -import com.lframework.xingyun.basedata.entity.Product; -import com.lframework.xingyun.basedata.entity.ProductBrand; -import com.lframework.xingyun.basedata.entity.ProductCategory; -import com.lframework.xingyun.basedata.entity.StoreCenter; +import com.lframework.xingyun.basedata.entity.*; import com.lframework.xingyun.basedata.service.product.ProductBrandService; import com.lframework.xingyun.basedata.service.product.ProductCategoryService; import com.lframework.xingyun.basedata.service.product.ProductService; import com.lframework.xingyun.basedata.service.storecenter.StoreCenterService; +import com.lframework.xingyun.basedata.service.supplier.SupplierService; import com.lframework.xingyun.sc.entity.ProductStock; import java.math.BigDecimal; + +import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @@ -74,6 +75,19 @@ public class ProductStockExportModel extends BaseBo implements Exc @ExcelProperty("含税金额") private BigDecimal taxAmount; + + /** + * 供应商编号 + */ + @ExcelProperty("供应商编号") + private String supplierCode; + + /** + * 供应商名称 + */ + @ExcelProperty("供应商名称") + private String supplierName; + public ProductStockExportModel() { } @@ -108,6 +122,9 @@ public class ProductStockExportModel extends BaseBo implements Exc ProductBrandService productBrandService = ApplicationUtil.getBean(ProductBrandService.class); ProductBrand productBrand = productBrandService.findById(product.getBrandId()); + SupplierService supplierService = ApplicationUtil.getBean(SupplierService.class); + Supplier supplier = supplierService.findById(product.getSupplierId()); + this.productCode = product.getCode(); this.productName = product.getName(); this.categoryName = productCategory.getName(); @@ -116,5 +133,10 @@ public class ProductStockExportModel extends BaseBo implements Exc this.setStockNum(dto.getStockNum()); this.setTaxPrice(NumberUtil.getNumber(dto.getTaxPrice(), 2)); this.setTaxAmount(NumberUtil.getNumber(dto.getTaxAmount(), 2)); + + if (ObjectUtil.isNotNull(supplier)) { + this.supplierCode = supplier.getCode(); + this.supplierName = supplier.getName(); + } } } diff --git a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/stock/ProductStockLogExportModel.java b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/stock/ProductStockLogExportModel.java index d1843c8..a3974ba 100644 --- a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/stock/ProductStockLogExportModel.java +++ b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/excel/stock/ProductStockLogExportModel.java @@ -5,17 +5,16 @@ import com.alibaba.excel.annotation.format.DateTimeFormat; import com.lframework.starter.common.constants.StringPool; import com.lframework.starter.common.utils.DateUtil; import com.lframework.starter.common.utils.NumberUtil; +import com.lframework.starter.common.utils.ObjectUtil; import com.lframework.starter.web.bo.BaseBo; import com.lframework.starter.web.common.utils.ApplicationUtil; import com.lframework.starter.web.components.excel.ExcelModel; -import com.lframework.xingyun.basedata.entity.Product; -import com.lframework.xingyun.basedata.entity.ProductBrand; -import com.lframework.xingyun.basedata.entity.ProductCategory; -import com.lframework.xingyun.basedata.entity.StoreCenter; +import com.lframework.xingyun.basedata.entity.*; import com.lframework.xingyun.basedata.service.product.ProductBrandService; import com.lframework.xingyun.basedata.service.product.ProductCategoryService; import com.lframework.xingyun.basedata.service.product.ProductService; import com.lframework.xingyun.basedata.service.storecenter.StoreCenterService; +import com.lframework.xingyun.basedata.service.supplier.SupplierService; import com.lframework.xingyun.sc.entity.ProductStockLog; import java.math.BigDecimal; import java.util.Date; @@ -121,6 +120,19 @@ public class ProductStockLogExportModel extends BaseBo implemen @ExcelProperty("业务类型") private String bizType; + + /** + * 供应商编号 + */ + @ExcelProperty("供应商编号") + private String supplierCode; + + /** + * 供应商名称 + */ + @ExcelProperty("供应商名称") + private String supplierName; + public ProductStockLogExportModel() { } @@ -153,6 +165,9 @@ public class ProductStockLogExportModel extends BaseBo implemen ProductBrandService productBrandService = ApplicationUtil.getBean(ProductBrandService.class); ProductBrand productBrand = productBrandService.findById(product.getBrandId()); + SupplierService supplierService = ApplicationUtil.getBean(SupplierService.class); + Supplier supplier = supplierService.findById(product.getSupplierId()); + this.productCode = product.getCode(); this.productName = product.getName(); this.categoryName = productCategory.getName(); @@ -168,5 +183,11 @@ public class ProductStockLogExportModel extends BaseBo implemen this.setCreateTime(DateUtil.toDate(dto.getCreateTime())); this.setBizCode(dto.getBizCode()); this.setBizType(dto.getBizType().getDesc()); + + + if (ObjectUtil.isNotNull(supplier)) { + this.supplierCode = supplier.getCode(); + this.supplierName = supplier.getName(); + } } } diff --git a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/vo/stock/QueryProductStockVo.java b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/vo/stock/QueryProductStockVo.java index eb198b9..7fb8583 100644 --- a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/vo/stock/QueryProductStockVo.java +++ b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/vo/stock/QueryProductStockVo.java @@ -36,4 +36,10 @@ public class QueryProductStockVo extends SortPageVo { */ @ApiModelProperty("商品品牌ID") private String brandId; + + /** + * 供应商id + */ + @ApiModelProperty("供应商id") + private String supplierId; } diff --git a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/vo/stock/log/QueryProductStockLogVo.java b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/vo/stock/log/QueryProductStockLogVo.java index cbe25fc..325f997 100644 --- a/xingyun-sc/src/main/java/com/lframework/xingyun/sc/vo/stock/log/QueryProductStockLogVo.java +++ b/xingyun-sc/src/main/java/com/lframework/xingyun/sc/vo/stock/log/QueryProductStockLogVo.java @@ -60,4 +60,10 @@ public class QueryProductStockLogVo extends SortPageVo { @ApiModelProperty("业务类型") @IsEnum(message = "业务类型不存在!", enumClass = ProductStockBizType.class) private Integer bizType; + + /** + * 供应商ID + */ + @ApiModelProperty("供应商ID") + private String supplierId; } diff --git a/xingyun-sc/src/main/resources/mappers/stock/ProductStockLogMapper.xml b/xingyun-sc/src/main/resources/mappers/stock/ProductStockLogMapper.xml index fec1db1..519050c 100644 --- a/xingyun-sc/src/main/resources/mappers/stock/ProductStockLogMapper.xml +++ b/xingyun-sc/src/main/resources/mappers/stock/ProductStockLogMapper.xml @@ -62,6 +62,9 @@ AND (g.category_id = #{vo.categoryId} OR FIND_IN_SET(#{vo.categoryId}, rm.path)) + + AND g.supplier_id = #{vo.supplierId} + AND gsl.create_time >= #{vo.createStartTime} diff --git a/xingyun-sc/src/main/resources/mappers/stock/ProductStockMapper.xml b/xingyun-sc/src/main/resources/mappers/stock/ProductStockMapper.xml index ce64730..2e8e972 100644 --- a/xingyun-sc/src/main/resources/mappers/stock/ProductStockMapper.xml +++ b/xingyun-sc/src/main/resources/mappers/stock/ProductStockMapper.xml @@ -75,6 +75,9 @@ AND (g.category_id = #{vo.categoryId} OR FIND_IN_SET(#{vo.categoryId}, rm.path)) + + AND g.supplier_id = #{vo.supplierId} + ORDER BY sc.code, g.code diff --git a/xingyun-sc/src/main/resources/mappers/stock/transfer/ScTransferOrderMapper.xml b/xingyun-sc/src/main/resources/mappers/stock/transfer/ScTransferOrderMapper.xml index 5b141f7..e7149cd 100644 --- a/xingyun-sc/src/main/resources/mappers/stock/transfer/ScTransferOrderMapper.xml +++ b/xingyun-sc/src/main/resources/mappers/stock/transfer/ScTransferOrderMapper.xml @@ -37,6 +37,9 @@ + + + @@ -83,12 +86,16 @@ g.sku_code, g.external_code, g.spec, - g.unit + g.unit, + g.supplier_id, + s.name AS supplier_name, + s.code AS supplier_code FROM tbl_product_stock AS ps INNER JOIN base_data_product AS g ON g.id = ps.product_id AND g.product_type = 1 LEFT JOIN base_data_product_category AS c ON c.id = g.category_id LEFT JOIN base_data_product_brand AS b ON b.id = g.brand_id LEFT JOIN recursion_mapping AS rm ON rm.node_id = c.id and rm.node_type = 2 + LEFT JOIN base_data_supplier AS s ON s.id = g.supplier_id