diff --git a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/bo/product/info/GetProductBo.java b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/bo/product/info/GetProductBo.java index 740abdc..c97daf3 100644 --- a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/bo/product/info/GetProductBo.java +++ b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/bo/product/info/GetProductBo.java @@ -2,20 +2,16 @@ package com.lframework.xingyun.basedata.bo.product.info; import com.lframework.starter.common.constants.StringPool; import com.lframework.starter.common.utils.CollectionUtil; +import com.lframework.starter.common.utils.ObjectUtil; import com.lframework.starter.web.annotations.convert.EnumConvert; import com.lframework.starter.web.bo.BaseBo; import com.lframework.starter.web.common.utils.ApplicationUtil; import com.lframework.xingyun.basedata.dto.product.ProductPropertyRelationDto; -import com.lframework.xingyun.basedata.entity.Product; -import com.lframework.xingyun.basedata.entity.ProductBrand; -import com.lframework.xingyun.basedata.entity.ProductBundle; -import com.lframework.xingyun.basedata.entity.ProductCategory; -import com.lframework.xingyun.basedata.entity.ProductPurchase; -import com.lframework.xingyun.basedata.entity.ProductRetail; -import com.lframework.xingyun.basedata.entity.ProductSale; +import com.lframework.xingyun.basedata.entity.*; import com.lframework.xingyun.basedata.enums.ColumnType; import com.lframework.xingyun.basedata.enums.ProductType; import com.lframework.xingyun.basedata.service.product.*; +import com.lframework.xingyun.basedata.service.supplier.SupplierService; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; import java.util.ArrayList; @@ -171,6 +167,18 @@ public class GetProductBo extends BaseBo { @ApiModelProperty("库存") private BigDecimal stock; + /** + * 供应商ID + */ + @ApiModelProperty("供应商ID") + private String supplierId; + + /** + * 供应商名称 + */ + @ApiModelProperty("供应商名称") + private String supplierName; + public GetProductBo() { } @@ -244,6 +252,9 @@ public class GetProductBo extends BaseBo { } ProductService productService = ApplicationUtil.getBean(ProductService.class); this.stock = productService.getStock(dto.getId()); + SupplierService supplierService = ApplicationUtil.getBean(SupplierService.class); + Supplier supplier = supplierService.findById(dto.getSupplierId()); + this.supplierName = ObjectUtil.isNotNull(supplier) ? supplier.getName() : ""; } @Data diff --git a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/bo/product/info/QueryProductBo.java b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/bo/product/info/QueryProductBo.java index fb57e46..dbd24d3 100644 --- a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/bo/product/info/QueryProductBo.java +++ b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/bo/product/info/QueryProductBo.java @@ -1,19 +1,17 @@ package com.lframework.xingyun.basedata.bo.product.info; -import cn.hutool.core.util.ObjectUtil; import com.fasterxml.jackson.annotation.JsonFormat; import com.lframework.starter.common.constants.StringPool; +import com.lframework.starter.common.utils.ObjectUtil; import com.lframework.starter.web.annotations.convert.EnumConvert; 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.ProductSale; +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.ProductSaleService; import com.lframework.xingyun.basedata.service.product.ProductService; +import com.lframework.xingyun.basedata.service.supplier.SupplierService; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; @@ -105,6 +103,18 @@ public class QueryProductBo extends BaseBo { @ApiModelProperty("库存") private BigDecimal stock; + /** + * 供应商ID + */ + @ApiModelProperty("供应商ID") + private String supplierId; + + /** + * 供应商名称 + */ + @ApiModelProperty("供应商名称") + private String supplierName; + public QueryProductBo() { } @@ -131,5 +141,9 @@ public class QueryProductBo extends BaseBo { ProductService productService = ApplicationUtil.getBean(ProductService.class); this.stock = productService.getStock(dto.getId()); + + SupplierService supplierService = ApplicationUtil.getBean(SupplierService.class); + Supplier supplier = supplierService.findById(dto.getSupplierId()); + this.supplierName = ObjectUtil.isNotNull(supplier) ? supplier.getName() : ""; } } diff --git a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/entity/Product.java b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/entity/Product.java index 8c3ed0c..9d37a35 100644 --- a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/entity/Product.java +++ b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/entity/Product.java @@ -8,6 +8,8 @@ import com.lframework.starter.web.dto.BaseDto; import com.lframework.xingyun.basedata.enums.ProductType; import java.math.BigDecimal; import java.time.LocalDateTime; + +import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** @@ -141,4 +143,9 @@ public class Product extends BaseEntity implements BaseDto { */ @TableField(fill = FieldFill.INSERT_UPDATE) private LocalDateTime updateTime; + + /** + * 供应商ID + */ + private String supplierId; } diff --git a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/excel/product/ProductImportListener.java b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/excel/product/ProductImportListener.java index f209fdf..467e853 100644 --- a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/excel/product/ProductImportListener.java +++ b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/excel/product/ProductImportListener.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.lframework.starter.common.constants.PatternPool; import com.lframework.starter.common.exceptions.impl.DefaultClientException; import com.lframework.starter.common.utils.NumberUtil; +import com.lframework.starter.common.utils.ObjectUtil; import com.lframework.starter.common.utils.RegUtil; import com.lframework.starter.common.utils.StringUtil; import com.lframework.starter.web.common.utils.ApplicationUtil; @@ -15,6 +16,7 @@ import com.lframework.starter.web.utils.IdUtil; 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.Supplier; import com.lframework.xingyun.basedata.enums.ProductType; import com.lframework.xingyun.basedata.service.product.ProductBrandService; import com.lframework.xingyun.basedata.service.product.ProductCategoryService; @@ -22,6 +24,7 @@ import com.lframework.xingyun.basedata.service.product.ProductPurchaseService; import com.lframework.xingyun.basedata.service.product.ProductRetailService; import com.lframework.xingyun.basedata.service.product.ProductSaleService; import com.lframework.xingyun.basedata.service.product.ProductService; +import com.lframework.xingyun.basedata.service.supplier.SupplierService; import com.lframework.xingyun.basedata.vo.product.purchase.CreateProductPurchaseVo; import com.lframework.xingyun.basedata.vo.product.retail.CreateProductRetailVo; import com.lframework.xingyun.basedata.vo.product.sale.CreateProductSaleVo; @@ -190,12 +193,16 @@ public class ProductImportListener extends ExcelImportListener datas = this.getDatas(); for (int i = 0; i < datas.size(); i++) { @@ -206,11 +213,17 @@ public class ProductImportListener extends ExcelImportListener 0) { throw new DefaultClientException("第" + (i + 1) + "行“商品SKU编号”重复,请重新输入"); } + Wrapper checkSupplierWrapper = Wrappers.lambdaQuery(Supplier.class) + .eq(Supplier::getCode, data.getSupplierCode()); + Supplier checkSupplier = supplierService.getOne(checkSupplierWrapper); + if(ObjectUtil.isNull(checkSupplier)){ + throw new DefaultClientException("第" + (i + 1) + "行“供应商编号”不存在,请检查"); + } Product record = new Product(); record.setId(IdUtil.getId()); - + record.setSupplierId(checkSupplier.getId()); record.setCode(data.getCode()); record.setName(data.getName()); if (StringUtil.isNotBlank(data.getShortName())) { diff --git a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/excel/product/ProductImportModel.java b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/excel/product/ProductImportModel.java index bb0c6de..d2317e2 100644 --- a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/excel/product/ProductImportModel.java +++ b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/excel/product/ProductImportModel.java @@ -5,6 +5,8 @@ import com.alibaba.excel.annotation.ExcelProperty; import com.lframework.starter.web.annotations.excel.ExcelRequired; import com.lframework.starter.web.components.excel.ExcelModel; import java.math.BigDecimal; + +import io.swagger.annotations.ApiModelProperty; import lombok.Data; @Data @@ -36,6 +38,13 @@ public class ProductImportModel implements ExcelModel { @ExcelProperty("简称") private String shortName; + /** + * 供应商编号 + */ + @ExcelRequired + @ExcelProperty("供应商编号") + private String supplierCode; + /** * SKU编号 */ diff --git a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/impl/product/ProductServiceImpl.java b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/impl/product/ProductServiceImpl.java index 51754d6..b872bf4 100644 --- a/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/impl/product/ProductServiceImpl.java +++ b/xingyun-basedata/src/main/java/com/lframework/xingyun/basedata/impl/product/ProductServiceImpl.java @@ -18,10 +18,7 @@ import com.lframework.starter.web.utils.IdUtil; import com.lframework.starter.web.utils.JsonUtil; import com.lframework.starter.web.utils.PageHelperUtil; import com.lframework.starter.web.utils.PageResultUtil; -import com.lframework.xingyun.basedata.entity.Product; -import com.lframework.xingyun.basedata.entity.ProductBundle; -import com.lframework.xingyun.basedata.entity.ProductProperty; -import com.lframework.xingyun.basedata.entity.ProductPropertyItem; +import com.lframework.xingyun.basedata.entity.*; import com.lframework.xingyun.basedata.enums.ColumnType; import com.lframework.xingyun.basedata.enums.ProductCategoryNodeType; import com.lframework.xingyun.basedata.enums.ProductType; @@ -34,6 +31,7 @@ import com.lframework.xingyun.basedata.service.product.ProductPurchaseService; import com.lframework.xingyun.basedata.service.product.ProductRetailService; import com.lframework.xingyun.basedata.service.product.ProductSaleService; import com.lframework.xingyun.basedata.service.product.ProductService; +import com.lframework.xingyun.basedata.service.supplier.SupplierService; import com.lframework.xingyun.basedata.vo.product.info.CreateProductVo; import com.lframework.xingyun.basedata.vo.product.info.ProductPropertyRelationVo; import com.lframework.xingyun.basedata.vo.product.info.QueryProductSelectorVo; @@ -90,6 +88,9 @@ public class ProductServiceImpl extends BaseMpServiceImpl query(Integer pageIndex, Integer pageSize, QueryProductVo vo) { @@ -214,16 +215,33 @@ public class ProductServiceImpl extends BaseMpServiceImpl + + AND g.supplier_id = #{vo.supplierId} + ORDER BY g.code