瀏覽代碼

ehsd产品库修改

yzc 2 年之前
父節點
當前提交
25e8763f5b

+ 17 - 0
code/src/test/java/ehsdDataSource.java

@@ -0,0 +1,17 @@
+import fly.generator.GeneratorApplication;
+
+public class ehsdDataSource {
+
+    public static void main(String[] args) {
+        GeneratorApplication.builder()
+                .url("jdbc:mysql://36.134.91.96:17330/bytesailing_ehsd?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true")
+                .username("fjhx2012mysql")
+                .password("3PN-Mzn#vnP&q6d")
+                .port(9989)
+                .module("hx-ehsd")
+                .parent("com.fjhx.ehsd")
+                .superServiceClass("com.ruoyi.common.core.service.BaseService")
+                .build();
+    }
+
+}

+ 0 - 13
hx-item/src/main/java/com/fjhx/item/entity/product/dto/ProductInfoDto.java

@@ -53,17 +53,4 @@ public class ProductInfoDto extends ProductInfo {
      * 10 正序  20 倒序
      */
     private  Integer orderBy;
-
-
-
-
-    /**
-     * 主图片列表
-     */
-    private List<ObsFile> imgList;
-    /**
-     * 副图片列表
-     */
-    private List<ObsFile> minorImgList;
-
 }

+ 0 - 17
hx-item/src/main/java/com/fjhx/item/entity/product/dto/ProductInfoSelectDto.java

@@ -64,21 +64,4 @@ public class ProductInfoSelectDto extends BaseSelectDto {
      * 10 正序  20 倒序
      */
     private Integer orderBy;
-
-
-    /**
-     * 产品编号 ehsd
-     */
-    private String code;
-    /**
-     * 产品名称 ehsd
-     */
-    private String name;
-
-    /**
-     * 客户名称
-     */
-    private String customerName;
-
-
 }

+ 85 - 87
hx-item/src/main/java/com/fjhx/item/entity/product/po/ProductInfoEhsdJson.java

@@ -1,11 +1,9 @@
 package com.fjhx.item.entity.product.po;
 
-import com.fjhx.file.entity.ObsFile;
 import lombok.Getter;
 import lombok.Setter;
 
 import java.math.BigDecimal;
-import java.util.List;
 
 @Getter
 @Setter
@@ -22,18 +20,18 @@ public class ProductInfoEhsdJson {
      * 产品成本价
      */
     private BigDecimal costPrice;
-    /**
-     * 材质英文
-     */
-    private String material;
-    /**
-     * 材质中文
-     */
-    private String materialChinese;
-    /**
-     * 产品型号 英文
-     */
-    private String productModelEn;
+//    /**
+//     * 材质英文
+//     */
+//    private String material;
+//    /**
+//     * 材质中文
+//     */
+//    private String materialChinese;
+//    /**
+//     * 产品型号 英文
+//     */
+//    private String productModelEn;
     /**
      * 产品尺寸 长
      */
@@ -46,18 +44,18 @@ public class ProductInfoEhsdJson {
      * 产品尺寸 高
      */
     private String productHigh;
-    /**
-     * 装箱尺寸 长
-     */
-    private String packagLong;
-    /**
-     * 装箱尺寸 宽
-     */
-    private String packagWide;
-    /**
-     * 装箱尺寸 高
-     */
-    private String packagHigh;
+//    /**
+//     * 装箱尺寸 长
+//     */
+//    private String packagLong;
+//    /**
+//     * 装箱尺寸 宽
+//     */
+//    private String packagWide;
+//    /**
+//     * 装箱尺寸 高
+//     */
+//    private String packagHigh;
     /**
      * 内包装方式
      */
@@ -71,63 +69,63 @@ public class ProductInfoEhsdJson {
      */
     private Double netWeight;
 
-    /**
-     * 毛重(单位g)
-     */
-    private Double grossWeight;
+//    /**
+//     * 毛重(单位g)
+//     */
+//    private Double grossWeight;
 
     /**
      * 海关编码
      */
-    private String customsCode;
-    /**
-     * MOQ(最低订购量)
-     */
-    private Integer moq;
-    /**
-     * 销售单位
-     */
-    private String salesUnit;
-    /**
-     * 出入库单位
-     */
-    private String issueReceiptUnit;
-    /**
-     * 换算比例
-     */
-    private Double conversionScale;
-    /**
-     * 安全库存
-     */
-    private BigDecimal safetyStock;
-    /**
-     * 采购周期(单位:天)
-     */
-    private Integer procurementCycle;
-    /**
-     * 质检合格率
-     */
-    private BigDecimal qualityQualifiedRate;
-    /**
-     * (云仓)出入库规则:0、不启用;1、一物一码;2、一物一码&先入先出
-     */
-    private Integer firstInFirstOut;
-    /**
-     * 状态
-     */
-    private Integer status;
-    /**
-     * 评估状态
-     */
-    private Integer assessStatus;
-    /**
-     * 产品分类英文名
-     */
-    private String categoryEnName;
-    /**
-     * 分类中文名
-     */
-    private String categoryCnName;
+    private String hsCode;
+//    /**
+//     * MOQ(最低订购量)
+//     */
+//    private Integer moq;
+//    /**
+//     * 销售单位
+//     */
+//    private String salesUnit;
+//    /**
+//     * 出入库单位
+//     */
+//    private String issueReceiptUnit;
+//    /**
+//     * 换算比例
+//     */
+//    private Double conversionScale;
+//    /**
+//     * 安全库存
+//     */
+//    private BigDecimal safetyStock;
+//    /**
+//     * 采购周期(单位:天)
+//     */
+//    private Integer procurementCycle;
+//    /**
+//     * 质检合格率
+//     */
+//    private BigDecimal qualityQualifiedRate;
+//    /**
+//     * (云仓)出入库规则:0、不启用;1、一物一码;2、一物一码&先入先出
+//     */
+//    private Integer firstInFirstOut;
+//    /**
+//     * 状态
+//     */
+//    private Integer status;
+//    /**
+//     * 评估状态
+//     */
+//    private Integer assessStatus;
+//    /**
+//     * 产品分类英文名
+//     */
+//    private String categoryEnName;
+//    /**
+//     * 分类中文名
+//     */
+//    private String categoryCnName;
     /**
      * 客户id
      */
@@ -136,14 +134,14 @@ public class ProductInfoEhsdJson {
      * 客户名称
      */
     private String customerName;
-    /**
-     * 图片列表
-     */
-    private List<ObsFile> imgList;
-    /**
-     * 附件列表
-     */
-    private List<ObsFile> attachmentList;
+//    /**
+//     * 图片列表
+//     */
+//    private List<ObsFile> imgList;
+//    /**
+//     * 附件列表
+//     */
+//    private List<ObsFile> attachmentList;
 
     /**
      * 产品类型 1公司产品 2客户产品

+ 30 - 58
hx-item/src/main/java/com/fjhx/item/service/product/impl/ProductInfoServiceImpl.java

@@ -174,55 +174,27 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
     @Override
     public Page<ProductInfoVo> getCustomerProductList(ProductInfoSelectDto dto) {
         IWrapper<ProductInfo> wrapper = getWrapper();
-        wrapper.eq("json_unquote(pi.ehsd_json -> '$.status')", 0);//状态 启用
-        wrapper.eq("json_unquote(pi.ehsd_json -> '$.assessStatus')", 3);//评估状态 具备
-//        wrapper.ne("json_unquote(pi.ehsd_json -> '$.customerId')", 0);//客户id不等于0
         wrapper.eq("json_unquote(pi.ehsd_json -> '$.type')", 2);//客户产品
-        //根据产品名称/产品编号过滤
-        wrapper.like("pi", ProductInfo::getCode, dto.getCode());
-        if (ObjectUtil.isNotEmpty(dto.getName())) {
-            wrapper.and(q -> q.like("pi", ProductInfo::getName, dto.getName()))
-                    .or().like("json_unquote(pi.ehsd_json -> '$.englishName')", dto.getName());
-        }
-        //根据产品分类id过滤
-        wrapper.eq("pi", ProductInfo::getProductClassifyId, dto.getProductClassifyId());
-        //客户名称过滤
-        wrapper.like("c.name", dto.getCustomerName());
-
-        Page<ProductInfoVo> page = baseMapper.getCustomerProductList(dto.getPage(), wrapper);
-        List<ProductInfoVo> records = page.getRecords();
-        //赋值客户名称
-        List<Long> customerIds = new ArrayList<>();
-        for (ProductInfoVo record : records) {
-            ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(record.getEhsdJson(), ProductInfoEhsdJson.class);
-            customerIds.add(productInfoEhsdJson.getCustomerId());
-        }
-        if (ObjectUtil.isNotEmpty(customerIds)) {
-            Map<Long, String> customerMap = customerService.mapKV(Customer::getId, Customer::getName, q -> q.in(Customer::getId, customerIds));
-            for (ProductInfoVo record : records) {
-                ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(record.getEhsdJson(), ProductInfoEhsdJson.class);
-                String customerName = customerMap.get(productInfoEhsdJson.getCustomerId());
-                productInfoEhsdJson.setCustomerName(customerName);
-                record.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson));
-            }
-        }
-        //赋值创建人名称
-        UserUtil.assignmentNickName(page.getRecords(), ProductInfo::getCreateUser, ProductInfoVo::setCreateUserName);
-        return page;
+        return getPageByEhsd(dto, wrapper);
     }
 
     @Override
     public Page<ProductInfoVo> getConditionProductList(ProductInfoSelectDto dto) {
         IWrapper<ProductInfo> wrapper = getWrapper();
-        wrapper.eq("json_unquote(pi.ehsd_json -> '$.status')", 0);//状态 启用
-        wrapper.eq("json_unquote(pi.ehsd_json -> '$.assessStatus')", 3);//评估状态 具备
-//        wrapper.eq("json_unquote(pi.ehsd_json -> '$.customerId')", 0);//客户id等于0
         wrapper.eq("json_unquote(pi.ehsd_json -> '$.type')", 1);//公司产品
+        return getPageByEhsd(dto, wrapper);
+    }
+
+    /**
+     * 尔泓产品库分页公共代码
+     */
+    public Page<ProductInfoVo> getPageByEhsd(ProductInfoSelectDto dto, IWrapper<ProductInfo> wrapper) {
         //根据产品名称/产品编号过滤
-        wrapper.like("pi", ProductInfo::getCode, dto.getCode());
-        if (ObjectUtil.isNotEmpty(dto.getName())) {
-            wrapper.and(q -> q.like("pi", ProductInfo::getName, dto.getName()))
-                    .or().like("json_unquote(pi.ehsd_json -> '$.englishName')", dto.getName());
+        if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
+            wrapper.and(q -> q.like("pi", ProductInfo::getName, dto.getKeyword()))
+                    .or().like("json_unquote(pi.ehsd_json -> '$.nameEnglish')", dto.getKeyword())
+                    .or().like("pi", ProductInfo::getCode, dto.getKeyword())//产品编号
+                    .or().like("c.name", dto.getKeyword());//客户名称
         }
         //根据产品分类id过滤
         wrapper.eq("pi", ProductInfo::getProductClassifyId, dto.getProductClassifyId());
@@ -272,8 +244,6 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
     public void addByEhsd(ProductInfoDto productInfoDto) {
         //赋值初始状态
         ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(productInfoDto.getEhsdJson(), ProductInfoEhsdJson.class);
-        productInfoEhsdJson.setStatus(0);
-        productInfoEhsdJson.setAssessStatus(3);
         if (ObjectUtil.isEmpty(productInfoEhsdJson.getCustomerId())) {
             //如果客户id为空就赋值为0 公司产品
             productInfoEhsdJson.setCustomerId(0l);
@@ -286,26 +256,28 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         // 排除名称重复
         this.nameDuplication(ProductInfo::getName, productInfoDto.getName(), "产品名称重复");
         this.save(productInfoDto);
-        //图片列表
-        ObsFileUtil.saveFile(productInfoDto.getImgList(), productInfoDto.getId(), 1);
-        //附件列表
-        ObsFileUtil.saveFile(productInfoDto.getMinorImgList(), productInfoDto.getId(), 2);
         //附件列表
-        ObsFileUtil.saveFile(productInfoDto.getFileList(), productInfoDto.getId(), 3);
+        ObsFileUtil.saveFile(productInfoDto.getFileList(), productInfoDto.getId());
     }
 
     @DSTransactional
     @Override
     public void editByEhsd(ProductInfoDto productInfoDto) {
-        // 禁止产品编号修改
-        productInfoDto.setCode(null);
-        // 排除名称重复
-        this.nameDuplication(ProductInfo::getName, productInfoDto.getName(), productInfoDto.getId(), "产品名称重复");
-        this.updateById(productInfoDto);
-        ObsFileUtil.editFile(productInfoDto.getImgList(), productInfoDto.getId(), 1);
-        ObsFileUtil.editFile(productInfoDto.getMinorImgList(), productInfoDto.getId(), 2);
-        ObsFileUtil.editFile(productInfoDto.getFileList(), productInfoDto.getId(), 3);
-
+        ProductInfoEhsdJson newProductInfoEhsdJson = JSONObject.parseObject(productInfoDto.getEhsdJson(), ProductInfoEhsdJson.class);
+        //只允许修改以下字段 销售指导价、成本价、净重、图片、备注
+        ProductInfo productInfo = getById(productInfoDto.getId());
+        if (ObjectUtil.isEmpty(productInfo)) {
+            throw new ServiceException("无法查询到改产品的产品信息,产品id" + productInfoDto.getId());
+        }
+        ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(productInfo.getEhsdJson(), ProductInfoEhsdJson.class);
+        productInfoEhsdJson.setPrice(newProductInfoEhsdJson.getPrice());//销售指导价
+        productInfoEhsdJson.setCostPrice(newProductInfoEhsdJson.getCostPrice());//成本价
+        productInfoEhsdJson.setNetWeight(newProductInfoEhsdJson.getNetWeight());//净重
+        productInfo.setRemark(productInfoDto.getRemark());//备注
+        productInfo.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson));
+        this.updateById(productInfo);
+        //修改图片
+        ObsFileUtil.editFile(productInfoDto.getFileList(), productInfoDto.getId());
     }
 
     @Override
@@ -318,7 +290,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         if (ObjectUtil.isNotEmpty(productInfoEhsdJson) && ObjectUtil.isNotEmpty(productInfoEhsdJson.getCustomerId())) {
             //赋值客户名称
             Customer customer = customerService.getById(productInfoEhsdJson.getCustomerId());
-            if(ObjectUtil.isNotEmpty(customer)) {
+            if (ObjectUtil.isNotEmpty(customer)) {
                 productInfoEhsdJson.setCustomerName(customer.getName());
                 result.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson));
             }