feat(stock): 添加产品供应商信息- 在多个 BO 和 DTO 中添加供应商 ID、编号和名称字段- 修改查询映射文件,增加供应商信息的查询

- 优化代码结构,提高可维护性和可读性
This commit is contained in:
lijiaqi 2024-11-26 09:15:17 +08:00
parent 78c509f50f
commit 15dd0d8e18
11 changed files with 237 additions and 14 deletions

View File

@ -1,13 +1,16 @@
package com.lframework.xingyun.sc.bo.stock.take.plan; package com.lframework.xingyun.sc.bo.stock.take.plan;
import com.lframework.starter.common.utils.ObjectUtil;
import com.lframework.starter.web.bo.BaseBo; import com.lframework.starter.web.bo.BaseBo;
import com.lframework.starter.web.common.utils.ApplicationUtil; import com.lframework.starter.web.common.utils.ApplicationUtil;
import com.lframework.xingyun.basedata.entity.Product; import com.lframework.xingyun.basedata.entity.Product;
import com.lframework.xingyun.basedata.entity.ProductBrand; import com.lframework.xingyun.basedata.entity.ProductBrand;
import com.lframework.xingyun.basedata.entity.ProductCategory; import com.lframework.xingyun.basedata.entity.ProductCategory;
import com.lframework.xingyun.basedata.entity.Supplier;
import com.lframework.xingyun.basedata.service.product.ProductBrandService; import com.lframework.xingyun.basedata.service.product.ProductBrandService;
import com.lframework.xingyun.basedata.service.product.ProductCategoryService; import com.lframework.xingyun.basedata.service.product.ProductCategoryService;
import com.lframework.xingyun.basedata.service.product.ProductService; import com.lframework.xingyun.basedata.service.product.ProductService;
import com.lframework.xingyun.basedata.service.supplier.SupplierService;
import com.lframework.xingyun.sc.dto.stock.take.plan.QueryTakeStockPlanProductDto; import com.lframework.xingyun.sc.dto.stock.take.plan.QueryTakeStockPlanProductDto;
import com.lframework.xingyun.sc.entity.TakeStockConfig; import com.lframework.xingyun.sc.entity.TakeStockConfig;
import com.lframework.xingyun.sc.service.stock.take.TakeStockConfigService; import com.lframework.xingyun.sc.service.stock.take.TakeStockConfigService;
@ -77,6 +80,24 @@ public class QueryTakeStockPlanProductBo extends BaseBo<QueryTakeStockPlanProduc
@ApiModelProperty("初始库存") @ApiModelProperty("初始库存")
private Integer stockNum; private Integer stockNum;
/**
* 供应商id
*/
@ApiModelProperty("供应商id")
private String supplierId;
/**
* 供应商编号
*/
@ApiModelProperty("供应商编号")
private String supplierCode;
/**
* 供应商名称
*/
@ApiModelProperty("供应商名称")
private String supplierName;
public QueryTakeStockPlanProductBo(QueryTakeStockPlanProductDto dto) { public QueryTakeStockPlanProductBo(QueryTakeStockPlanProductDto dto) {
super(dto); super(dto);
@ -110,5 +131,14 @@ public class QueryTakeStockPlanProductBo extends BaseBo<QueryTakeStockPlanProduc
if (!config.getShowStock()) { if (!config.getShowStock()) {
this.stockNum = null; this.stockNum = null;
} }
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();
}
} }
} }

View File

@ -4,16 +4,15 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.lframework.starter.common.constants.StringPool; import com.lframework.starter.common.constants.StringPool;
import com.lframework.starter.common.utils.CollectionUtil; import com.lframework.starter.common.utils.CollectionUtil;
import com.lframework.starter.common.utils.ObjectUtil;
import com.lframework.starter.web.bo.BaseBo; import com.lframework.starter.web.bo.BaseBo;
import com.lframework.starter.web.common.utils.ApplicationUtil; import com.lframework.starter.web.common.utils.ApplicationUtil;
import com.lframework.xingyun.basedata.entity.Product; import com.lframework.xingyun.basedata.entity.*;
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.service.product.ProductBrandService; import com.lframework.xingyun.basedata.service.product.ProductBrandService;
import com.lframework.xingyun.basedata.service.product.ProductCategoryService; import com.lframework.xingyun.basedata.service.product.ProductCategoryService;
import com.lframework.xingyun.basedata.service.product.ProductService; import com.lframework.xingyun.basedata.service.product.ProductService;
import com.lframework.xingyun.basedata.service.storecenter.StoreCenterService; import com.lframework.xingyun.basedata.service.storecenter.StoreCenterService;
import com.lframework.xingyun.basedata.service.supplier.SupplierService;
import com.lframework.xingyun.sc.dto.stock.take.plan.TakeStockPlanFullDto; import com.lframework.xingyun.sc.dto.stock.take.plan.TakeStockPlanFullDto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -231,6 +230,25 @@ public class TakeStockPlanFullBo extends BaseBo<TakeStockPlanFullDto> {
@JsonIgnore @JsonIgnore
private String planId; private String planId;
/**
* 供应商id
*/
@ApiModelProperty("供应商id")
private String supplierId;
/**
* 供应商编号
*/
@ApiModelProperty("供应商编号")
private String supplierCode;
/**
* 供应商名称
*/
@ApiModelProperty("供应商名称")
private String supplierName;
public DetailBo(TakeStockPlanFullDto.DetailDto dto, String planId) { public DetailBo(TakeStockPlanFullDto.DetailDto dto, String planId) {
this.planId = planId; this.planId = planId;
@ -274,6 +292,15 @@ public class TakeStockPlanFullBo extends BaseBo<TakeStockPlanFullDto> {
this.diffNum = this.oriTakeNum - this.stockNum; this.diffNum = this.oriTakeNum - this.stockNum;
} }
} }
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();
}
} }
} }
} }

View File

@ -2,16 +2,15 @@ package com.lframework.xingyun.sc.bo.stock.take.pre;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.lframework.starter.common.constants.StringPool; import com.lframework.starter.common.constants.StringPool;
import com.lframework.starter.common.utils.ObjectUtil;
import com.lframework.starter.web.bo.BaseBo; import com.lframework.starter.web.bo.BaseBo;
import com.lframework.starter.web.common.utils.ApplicationUtil; import com.lframework.starter.web.common.utils.ApplicationUtil;
import com.lframework.xingyun.basedata.entity.Product; import com.lframework.xingyun.basedata.entity.*;
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.service.product.ProductBrandService; import com.lframework.xingyun.basedata.service.product.ProductBrandService;
import com.lframework.xingyun.basedata.service.product.ProductCategoryService; import com.lframework.xingyun.basedata.service.product.ProductCategoryService;
import com.lframework.xingyun.basedata.service.product.ProductService; import com.lframework.xingyun.basedata.service.product.ProductService;
import com.lframework.xingyun.basedata.service.storecenter.StoreCenterService; import com.lframework.xingyun.basedata.service.storecenter.StoreCenterService;
import com.lframework.xingyun.basedata.service.supplier.SupplierService;
import com.lframework.xingyun.sc.dto.stock.take.pre.PreTakeStockSheetFullDto; import com.lframework.xingyun.sc.dto.stock.take.pre.PreTakeStockSheetFullDto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -165,6 +164,24 @@ public class GetPreTakeStockSheetBo extends BaseBo<PreTakeStockSheetFullDto> {
@ApiModelProperty("抽盘数量") @ApiModelProperty("抽盘数量")
private Integer randNum; private Integer randNum;
/**
* 供应商id
*/
@ApiModelProperty("供应商id")
private String supplierId;
/**
* 供应商编号
*/
@ApiModelProperty("供应商编号")
private String supplierCode;
/**
* 供应商名称
*/
@ApiModelProperty("供应商名称")
private String supplierName;
public SheetDetailBo(PreTakeStockSheetFullDto.SheetDetailDto dto) { public SheetDetailBo(PreTakeStockSheetFullDto.SheetDetailDto dto) {
super(dto); super(dto);
@ -192,6 +209,14 @@ public class GetPreTakeStockSheetBo extends BaseBo<PreTakeStockSheetFullDto> {
this.externalCode = product.getExternalCode(); this.externalCode = product.getExternalCode();
this.spec = product.getSpec(); this.spec = product.getSpec();
this.unit = product.getUnit(); this.unit = product.getUnit();
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();
}
} }
} }

View File

@ -62,6 +62,25 @@ public class PreTakeStockProductBo extends BaseBo<PreTakeStockProductDto> {
@ApiModelProperty("单位") @ApiModelProperty("单位")
private String unit; private String unit;
/**
* 供应商id
*/
@ApiModelProperty("供应商id")
private String supplierId;
/**
* 供应商编号
*/
@ApiModelProperty("供应商编号")
private String supplierCode;
/**
* 供应商名称
*/
@ApiModelProperty("供应商名称")
private String supplierName;
public PreTakeStockProductBo() { public PreTakeStockProductBo() {
} }

View File

@ -1,14 +1,17 @@
package com.lframework.xingyun.sc.bo.stock.take.pre; package com.lframework.xingyun.sc.bo.stock.take.pre;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.lframework.starter.common.utils.ObjectUtil;
import com.lframework.starter.web.bo.BaseBo; import com.lframework.starter.web.bo.BaseBo;
import com.lframework.starter.web.common.utils.ApplicationUtil; import com.lframework.starter.web.common.utils.ApplicationUtil;
import com.lframework.xingyun.basedata.entity.Product; import com.lframework.xingyun.basedata.entity.Product;
import com.lframework.xingyun.basedata.entity.ProductBrand; import com.lframework.xingyun.basedata.entity.ProductBrand;
import com.lframework.xingyun.basedata.entity.ProductCategory; import com.lframework.xingyun.basedata.entity.ProductCategory;
import com.lframework.xingyun.basedata.entity.Supplier;
import com.lframework.xingyun.basedata.service.product.ProductBrandService; import com.lframework.xingyun.basedata.service.product.ProductBrandService;
import com.lframework.xingyun.basedata.service.product.ProductCategoryService; import com.lframework.xingyun.basedata.service.product.ProductCategoryService;
import com.lframework.xingyun.basedata.service.product.ProductService; import com.lframework.xingyun.basedata.service.product.ProductService;
import com.lframework.xingyun.basedata.service.supplier.SupplierService;
import com.lframework.xingyun.sc.dto.stock.take.pre.QueryPreTakeStockSheetProductDto; import com.lframework.xingyun.sc.dto.stock.take.pre.QueryPreTakeStockSheetProductDto;
import com.lframework.xingyun.sc.entity.ProductStock; import com.lframework.xingyun.sc.entity.ProductStock;
import com.lframework.xingyun.sc.entity.TakeStockConfig; import com.lframework.xingyun.sc.entity.TakeStockConfig;
@ -94,6 +97,24 @@ public class QueryPreTakeStockSheetProductBo extends BaseBo<QueryPreTakeStockShe
@ApiModelProperty("盘点数量") @ApiModelProperty("盘点数量")
private Integer takeNum; private Integer takeNum;
/**
* 供应商id
*/
@ApiModelProperty("供应商id")
private String supplierId;
/**
* 供应商编号
*/
@ApiModelProperty("供应商编号")
private String supplierCode;
/**
* 供应商名称
*/
@ApiModelProperty("供应商名称")
private String supplierName;
public QueryPreTakeStockSheetProductBo(QueryPreTakeStockSheetProductDto dto, String scId) { public QueryPreTakeStockSheetProductBo(QueryPreTakeStockSheetProductDto dto, String scId) {
this.scId = scId; this.scId = scId;
@ -139,5 +160,14 @@ public class QueryPreTakeStockSheetProductBo extends BaseBo<QueryPreTakeStockShe
ProductStock productStock = productStockService.getByProductIdAndScId(this.productId, this.scId); ProductStock productStock = productStockService.getByProductIdAndScId(this.productId, this.scId);
this.stockNum = productStock == null ? 0 : productStock.getStockNum(); this.stockNum = 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();
}
} }
} }

View File

@ -2,17 +2,16 @@ package com.lframework.xingyun.sc.bo.stock.take.sheet;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.lframework.starter.common.constants.StringPool; 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.common.utils.StringUtil;
import com.lframework.starter.web.bo.BaseBo; import com.lframework.starter.web.bo.BaseBo;
import com.lframework.starter.web.common.utils.ApplicationUtil; import com.lframework.starter.web.common.utils.ApplicationUtil;
import com.lframework.xingyun.basedata.entity.Product; import com.lframework.xingyun.basedata.entity.*;
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.service.product.ProductBrandService; import com.lframework.xingyun.basedata.service.product.ProductBrandService;
import com.lframework.xingyun.basedata.service.product.ProductCategoryService; import com.lframework.xingyun.basedata.service.product.ProductCategoryService;
import com.lframework.xingyun.basedata.service.product.ProductService; import com.lframework.xingyun.basedata.service.product.ProductService;
import com.lframework.xingyun.basedata.service.storecenter.StoreCenterService; import com.lframework.xingyun.basedata.service.storecenter.StoreCenterService;
import com.lframework.xingyun.basedata.service.supplier.SupplierService;
import com.lframework.xingyun.sc.dto.stock.take.plan.GetTakeStockPlanDetailProductDto; import com.lframework.xingyun.sc.dto.stock.take.plan.GetTakeStockPlanDetailProductDto;
import com.lframework.xingyun.sc.dto.stock.take.sheet.TakeStockSheetFullDto; import com.lframework.xingyun.sc.dto.stock.take.sheet.TakeStockSheetFullDto;
import com.lframework.xingyun.sc.entity.PreTakeStockSheet; import com.lframework.xingyun.sc.entity.PreTakeStockSheet;
@ -305,6 +304,24 @@ public class TakeStockSheetFullBo extends BaseBo<TakeStockSheetFullDto> {
@ApiModelProperty("盘点任务ID") @ApiModelProperty("盘点任务ID")
private String planId; private String planId;
/**
* 供应商id
*/
@ApiModelProperty("供应商id")
private String supplierId;
/**
* 供应商编号
*/
@ApiModelProperty("供应商编号")
private String supplierCode;
/**
* 供应商名称
*/
@ApiModelProperty("供应商名称")
private String supplierName;
public SheetDetailBo(TakeStockSheetFullDto.SheetDetailDto dto, String planId) { public SheetDetailBo(TakeStockSheetFullDto.SheetDetailDto dto, String planId) {
this.planId = planId; this.planId = planId;
@ -346,6 +363,14 @@ public class TakeStockSheetFullBo extends BaseBo<TakeStockSheetFullDto> {
this.planId, this.productId); this.planId, this.productId);
this.stockNum = planDetail.getStockNum(); this.stockNum = planDetail.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();
}
} }
} }
} }

View File

@ -91,6 +91,24 @@ public class TakeStockSheetProductBo extends BaseBo<TakeStockSheetProductDto> {
@JsonIgnore @JsonIgnore
private String scId; private String scId;
/**
* 供应商id
*/
@ApiModelProperty("供应商id")
private String supplierId;
/**
* 供应商编号
*/
@ApiModelProperty("供应商编号")
private String supplierCode;
/**
* 供应商名称
*/
@ApiModelProperty("供应商名称")
private String supplierName;
public TakeStockSheetProductBo(TakeStockSheetProductDto dto, String planId, String scId) { public TakeStockSheetProductBo(TakeStockSheetProductDto dto, String planId, String scId) {
this.planId = planId; this.planId = planId;

View File

@ -2,6 +2,8 @@ package com.lframework.xingyun.sc.dto.stock.take.pre;
import com.lframework.starter.web.dto.BaseDto; import com.lframework.starter.web.dto.BaseDto;
import java.io.Serializable; import java.io.Serializable;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@Data @Data
@ -63,4 +65,20 @@ public class PreTakeStockProductDto implements BaseDto, Serializable {
* 单位 * 单位
*/ */
private String unit; private String unit;
/**
* 供应商id
*/
private String supplierId;
/**
* 供应商编号
*/
private String supplierCode;
/**
* 供应商名称
*/
private String supplierName;
} }

View File

@ -2,6 +2,8 @@ package com.lframework.xingyun.sc.dto.stock.take.sheet;
import com.lframework.starter.web.dto.BaseDto; import com.lframework.starter.web.dto.BaseDto;
import java.io.Serializable; import java.io.Serializable;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@Data @Data
@ -63,4 +65,19 @@ public class TakeStockSheetProductDto implements BaseDto, Serializable {
* 单位 * 单位
*/ */
private String unit; private String unit;
/**
* 供应商id
*/
private String supplierId;
/**
* 供应商编号
*/
private String supplierCode;
/**
* 供应商名称
*/
private String supplierName;
} }

View File

@ -51,6 +51,9 @@
<result column="external_code" property="externalCode"/> <result column="external_code" property="externalCode"/>
<result column="spec" property="spec"/> <result column="spec" property="spec"/>
<result column="unit" property="unit"/> <result column="unit" property="unit"/>
<result column="supplier_id" property="supplierId"/>
<result column="supplier_code" property="supplierCode"/>
<result column="supplier_name" property="supplierName"/>
</resultMap> </resultMap>
<sql id="PreTakeStockSheetDto_sql"> <sql id="PreTakeStockSheetDto_sql">
@ -114,11 +117,15 @@
g.sku_code, g.sku_code,
g.external_code, g.external_code,
g.spec, g.spec,
g.unit g.unit,
g.supplier_id,
s.code AS supplier_code,
s.name AS supplier_name
FROM base_data_product AS g FROM base_data_product AS g
LEFT JOIN base_data_product_category AS c ON c.id = g.category_id 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 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 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
</sql> </sql>
<select id="query" resultMap="PreTakeStockSheet"> <select id="query" resultMap="PreTakeStockSheet">

View File

@ -53,6 +53,9 @@
<result column="external_code" property="externalCode"/> <result column="external_code" property="externalCode"/>
<result column="spec" property="spec"/> <result column="spec" property="spec"/>
<result column="unit" property="unit"/> <result column="unit" property="unit"/>
<result column="supplier_id" property="supplierId"/>
<result column="supplier_code" property="supplierCode"/>
<result column="supplier_name" property="supplierName"/>
</resultMap> </resultMap>
<sql id="TakeStockSheetDto_sql"> <sql id="TakeStockSheetDto_sql">
@ -110,11 +113,15 @@
g.sku_code, g.sku_code,
g.external_code, g.external_code,
g.spec, g.spec,
g.unit g.unit,
g.supplier_id,
s.code AS supplier_code,
s.name AS supplier_name
FROM base_data_product AS g FROM base_data_product AS g
LEFT JOIN base_data_product_category AS c ON c.id = g.category_id 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 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 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
</sql> </sql>
<select id="query" resultMap="TakeStockSheet"> <select id="query" resultMap="TakeStockSheet">