Browse Source

产品库功能修改

yzc 1 năm trước cách đây
mục cha
commit
66613058f5

+ 20 - 0
hx-item/src/main/java/com/fjhx/item/controller/product/ProductCustomInfoController.java

@@ -0,0 +1,20 @@
+package com.fjhx.item.controller.product;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+/**
+ * <p>
+ * item_产品定制信息 前端控制器
+ * </p>
+ *
+ * @author
+ * @since 2024-02-18
+ */
+@RestController
+@RequestMapping("/productCustomInfo")
+public class ProductCustomInfoController {
+
+
+}

+ 22 - 0
hx-item/src/main/java/com/fjhx/item/entity/product/dto/ProductCustomInfoDto.java

@@ -0,0 +1,22 @@
+package com.fjhx.item.entity.product.dto;
+
+import com.fjhx.file.entity.ObsFile;
+import com.fjhx.item.entity.product.po.ProductCustomInfo;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * item_产品定制信息新增编辑入参实体
+ *
+ * @author
+ * @since 2024-02-18
+ */
+@Getter
+@Setter
+public class ProductCustomInfoDto extends ProductCustomInfo {
+
+    private List<ObsFile> fileList;
+
+}

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

@@ -0,0 +1,17 @@
+package com.fjhx.item.entity.product.dto;
+
+import com.ruoyi.common.core.domain.BaseSelectDto;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * item_产品定制信息列表查询入参实体
+ *
+ * @author
+ * @since 2024-02-18
+ */
+@Getter
+@Setter
+public class ProductCustomInfoSelectDto extends BaseSelectDto {
+
+}

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

@@ -1,6 +1,7 @@
 package com.fjhx.item.entity.product.dto;
 
 import com.fjhx.file.entity.ObsFile;
+import com.fjhx.item.entity.product.po.ProductBomDetail;
 import com.fjhx.item.entity.product.po.ProductInfo;
 import lombok.Getter;
 import lombok.Setter;
@@ -68,4 +69,14 @@ public class ProductInfoDto extends ProductInfo {
      * 生产文件列表
      */
     private List<ObsFile> prodFileList;
+
+    /**
+     * 产品BOM列表
+     */
+    private List<ProductBomDetail> productBomDetailList;
+
+    /**
+     * 产品定制信息列表
+     */
+    private List<ProductCustomInfoDto> productCustomInfoList;
 }

+ 41 - 0
hx-item/src/main/java/com/fjhx/item/entity/product/po/ProductCustomInfo.java

@@ -0,0 +1,41 @@
+package com.fjhx.item.entity.product.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.domain.BasePo;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * item_产品定制信息
+ * </p>
+ *
+ * @author
+ * @since 2024-02-18
+ */
+@Getter
+@Setter
+@TableName("product_custom_info")
+public class ProductCustomInfo extends BasePo {
+
+    /**
+     * 产品id
+     */
+    private Long productId;
+
+    /**
+     * 类型 1定制刀模 2定制纹路 3定制模具
+     */
+    private Integer type;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 是否选择
+     */
+    private Integer isCheck;
+
+}

+ 37 - 0
hx-item/src/main/java/com/fjhx/item/entity/product/po/ProductInfo.java

@@ -175,4 +175,41 @@ public class ProductInfo extends BasePo {
      */
     private Long companyId;
 
+    //----------------------------------------
+    /**
+     * LOGO长
+     */
+    private BigDecimal logoLength;
+    /**
+     * LOGO宽
+     */
+    private BigDecimal logoWidth;
+    /**
+     * LOGO高
+     */
+    private BigDecimal logoHeight;
+    /**
+     * 几色印刷
+     */
+    private Integer colorCount;
+    /**
+     * 是否折叠
+     */
+    private Integer isFold;
+    /**
+     * 折叠数 字典(fold_way)
+     */
+    private String foldWay;
+    /**
+     * 包装要求 字典(pack_ask)
+     */
+    private String packAsk;
+    /**
+     * 是否定制
+     */
+    private Integer isCustomized;
+    /**
+     * 色卡号
+     */
+    private String colorCardCode;
 }

+ 15 - 0
hx-item/src/main/java/com/fjhx/item/entity/product/vo/ProductBomDetailVo.java

@@ -30,4 +30,19 @@ public class ProductBomDetailVo extends ProductBomDetail {
     private BigDecimal materialHeight;
     private BigDecimal materialPrice;
 
+    /**
+     * 净重
+     */
+    private BigDecimal materialNetWeight;
+
+    /**
+     * 颜色
+     */
+    private String materialColor;
+
+    /**
+     * 色卡号
+     */
+    private String materialColorCardCode;
+
 }

+ 22 - 0
hx-item/src/main/java/com/fjhx/item/entity/product/vo/ProductCustomInfoVo.java

@@ -0,0 +1,22 @@
+package com.fjhx.item.entity.product.vo;
+
+import com.fjhx.file.entity.FileInfoVo;
+import com.fjhx.item.entity.product.po.ProductCustomInfo;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * item_产品定制信息列表查询返回值实体
+ *
+ * @author
+ * @since 2024-02-18
+ */
+@Getter
+@Setter
+public class ProductCustomInfoVo extends ProductCustomInfo {
+
+    List<FileInfoVo> fileList;
+
+}

+ 10 - 0
hx-item/src/main/java/com/fjhx/item/entity/product/vo/ProductInfoVo.java

@@ -69,4 +69,14 @@ public class ProductInfoVo extends ProductInfo {
      * 归属公司名称
      */
     private String companyName;
+
+    /**
+     * 物料列表
+     */
+    List<ProductBomDetailVo> productBomDetailList;
+
+    /**
+     * 产品定制信息列表
+     */
+    List<ProductCustomInfoVo> productCustomInfoList;
 }

+ 17 - 0
hx-item/src/main/java/com/fjhx/item/mapper/product/ProductCustomInfoMapper.java

@@ -0,0 +1,17 @@
+package com.fjhx.item.mapper.product;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fjhx.item.entity.product.po.ProductCustomInfo;
+
+
+/**
+ * <p>
+ * item_产品定制信息 Mapper 接口
+ * </p>
+ *
+ * @author
+ * @since 2024-02-18
+ */
+public interface ProductCustomInfoMapper extends BaseMapper<ProductCustomInfo> {
+
+}

+ 17 - 0
hx-item/src/main/java/com/fjhx/item/service/product/ProductCustomInfoService.java

@@ -0,0 +1,17 @@
+package com.fjhx.item.service.product;
+
+import com.fjhx.item.entity.product.po.ProductCustomInfo;
+import com.ruoyi.common.core.service.BaseService;
+
+
+/**
+ * <p>
+ * item_产品定制信息 服务类
+ * </p>
+ *
+ * @author
+ * @since 2024-02-18
+ */
+public interface ProductCustomInfoService extends BaseService<ProductCustomInfo> {
+
+}

+ 21 - 0
hx-item/src/main/java/com/fjhx/item/service/product/impl/ProductCustomInfoServiceImpl.java

@@ -0,0 +1,21 @@
+package com.fjhx.item.service.product.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.item.entity.product.po.ProductCustomInfo;
+import com.fjhx.item.mapper.product.ProductCustomInfoMapper;
+import com.fjhx.item.service.product.ProductCustomInfoService;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * <p>
+ * item_产品定制信息 服务实现类
+ * </p>
+ *
+ * @author
+ * @since 2024-02-18
+ */
+@Service
+public class ProductCustomInfoServiceImpl extends ServiceImpl<ProductCustomInfoMapper, ProductCustomInfo> implements ProductCustomInfoService {
+
+}

+ 112 - 63
hx-item/src/main/java/com/fjhx/item/service/product/impl/ProductInfoServiceImpl.java

@@ -8,6 +8,7 @@ import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -16,25 +17,21 @@ import com.fjhx.common.constant.SourceConstant;
 import com.fjhx.common.entity.AvailableStockBo;
 import com.fjhx.common.service.file.FtpFileService;
 import com.fjhx.common.service.file.impl.FtpFileServiceImpl;
-import com.fjhx.common.utils.Assert;
 import com.fjhx.file.entity.FileInfoVo;
 import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.item.entity.product.ProcessesBo;
 import com.fjhx.item.entity.product.bo.ProductAnalysisBo;
 import com.fjhx.item.entity.product.bo.ProductExcelExportBo;
+import com.fjhx.item.entity.product.dto.ProductCustomInfoDto;
 import com.fjhx.item.entity.product.dto.ProductInfoDto;
 import com.fjhx.item.entity.product.dto.ProductInfoSelectDto;
-import com.fjhx.item.entity.product.po.ProductBomDetail;
-import com.fjhx.item.entity.product.po.ProductClassify;
-import com.fjhx.item.entity.product.po.ProductInfo;
-import com.fjhx.item.entity.product.po.ProductStockInfo;
+import com.fjhx.item.entity.product.po.*;
+import com.fjhx.item.entity.product.vo.ProductBomDetailVo;
+import com.fjhx.item.entity.product.vo.ProductCustomInfoVo;
 import com.fjhx.item.entity.product.vo.ProductInfoVo;
 import com.fjhx.item.enums.ProductAvailableRecordType;
 import com.fjhx.item.mapper.product.ProductInfoMapper;
-import com.fjhx.item.service.product.ProductBomDetailService;
-import com.fjhx.item.service.product.ProductClassifyService;
-import com.fjhx.item.service.product.ProductInfoService;
-import com.fjhx.item.service.product.ProductStockInfoService;
+import com.fjhx.item.service.product.*;
 import com.fjhx.item.util.CodeEnum;
 import com.fjhx.item.util.excel.ExcelImgUtils;
 import com.fjhx.item.util.excel.util.ExcelUtil;
@@ -91,6 +88,8 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
     private ProductStockInfoService productStockInfoService;
     @Autowired
     private ProductBomDetailService productBomDetailService;
+    @Autowired
+    private ProductCustomInfoService productCustomInfoService;
 
 
     @Override
@@ -231,6 +230,34 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         if (ObjectUtil.isNotEmpty(productClassify)) {
             result.setClassifyName(productClassify.getName());
         }
+
+        //赋值物料信息
+        List<ProductBomDetail> productBomDetailList = productBomDetailService.list(q -> q.eq(ProductBomDetail::getProductId, id));
+        List<ProductBomDetailVo> productBomDetailVos = BeanUtil.copyToList(productBomDetailList, ProductBomDetailVo.class);
+        this.attributeAssign(productBomDetailVos, ProductBomDetail::getMaterialId, (item, material) -> {
+            item.setMaterialName(material.getName());
+            item.setMaterialCode(material.getCustomCode());
+            item.setMaterialLength(material.getLength());
+            item.setMaterialWidth(material.getWidth());
+            item.setMaterialHeight(material.getHeight());
+            item.setMaterialPrice(material.getPrice());
+            item.setMaterialNetWeight(material.getNetWeight());
+            item.setMaterialColor(material.getColor());
+            item.setMaterialColorCardCode(material.getColorCardCode());
+        });
+        result.setProductBomDetailList(productBomDetailVos);
+
+        //赋值产品定制信息
+        List<ProductCustomInfo> productCustomInfoList = productCustomInfoService.list(q -> q.eq(ProductCustomInfo::getProductId, id));
+        List<Long> pIds = productCustomInfoList.stream().map(ProductCustomInfo::getId).collect(Collectors.toList());
+        Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(pIds, 0);
+        List<ProductCustomInfoVo> productCustomInfoVos = BeanUtil.copyToList(productCustomInfoList, ProductCustomInfoVo.class);
+        for (ProductCustomInfoVo productCustomInfoVo : productCustomInfoVos) {
+            List<FileInfoVo> fileInfoVoList = fileMap.get(productCustomInfoVo.getId());
+            productCustomInfoVo.setFileList(fileInfoVoList);
+        }
+        result.setProductCustomInfoList(productCustomInfoVos);
+
         return result;
     }
 
@@ -274,12 +301,20 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         //操作ftp文件
         editFtpFile(productInfoDto);
 
+        //保存原材料信息
+        saveOrEditRawMaterial(productInfoDto);
+
         this.save(productInfoDto);
         ObsFileUtil.saveFile(productInfoDto.getFileList(), productInfoDto.getId());
         ObsFileUtil.saveFile(productInfoDto.getProdFileList(), productInfoDto.getId(), 2);
 
-        //保存原材料信息
-        saveOrEditRawMaterial(productInfoDto);
+        //保存物料信息
+        List<ProductBomDetail> productBomDetailList = productInfoDto.getProductBomDetailList();
+        productBomDetailList.forEach(item -> item.setProductId(productInfoDto.getId()));
+        productBomDetailService.saveBatch(productBomDetailList);
+
+        //保存产品定制信息
+        saveOrEditCustomInfo(productInfoDto);
     }
 
 //    /**
@@ -333,37 +368,37 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
     @Override
     public void edit(ProductInfoDto productInfoDto) {
 
-        //修改物料时 更新关联产品价格
-        if (ObjectUtil.equals(productInfoDto.getDefinition(), 2)) {
-            List<ProductBomDetail> productBomDetailList = productBomDetailService.list(q -> q
-                    .eq(ProductBomDetail::getMaterialId, productInfoDto.getId())
-            );
-
-            //获取物料信息
-            ProductInfo materialInfo = this.getById(productInfoDto.getId());
-            BigDecimal oldPrice = materialInfo.getPrice();
-            BigDecimal newPrice = productInfoDto.getPrice();
-
-            for (ProductBomDetail productBomDetail : productBomDetailList) {
-                ProductInfo productInfo = this.getById(productBomDetail.getProductId());
-
-                if (ObjectUtil.equals(productBomDetail.getType(), 1)) {
-                    oldPrice = productInfo.getLength().multiply(productInfo.getWidth()).multiply(oldPrice);
-                    newPrice = productInfo.getLength().multiply(productInfo.getWidth()).multiply(newPrice);
-                } else {
-                    oldPrice = oldPrice.multiply(productBomDetail.getQuantity());
-                    newPrice = newPrice.multiply(productBomDetail.getQuantity());
-                }
-
-                BigDecimal subtract = newPrice.subtract(oldPrice);
-                this.update(q -> q
-                        .in(ProductInfo::getId, productInfo.getId())
-                        .setSql("price = price + " + subtract)
-                        .set(BasePo::getUpdateTime, new Date())
-                        .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
-                );
-            }
-        }
+//        //修改物料时 更新关联产品价格
+//        if (ObjectUtil.equals(productInfoDto.getDefinition(), 2)) {
+//            List<ProductBomDetail> productBomDetailList = productBomDetailService.list(q -> q
+//                    .eq(ProductBomDetail::getMaterialId, productInfoDto.getId())
+//            );
+//
+//            //获取物料信息
+//            ProductInfo materialInfo = this.getById(productInfoDto.getId());
+//            BigDecimal oldPrice = materialInfo.getPrice();
+//            BigDecimal newPrice = productInfoDto.getPrice();
+//
+//            for (ProductBomDetail productBomDetail : productBomDetailList) {
+//                ProductInfo productInfo = this.getById(productBomDetail.getProductId());
+//
+//                if (ObjectUtil.equals(productBomDetail.getType(), 1)) {
+//                    oldPrice = productInfo.getLength().multiply(productInfo.getWidth()).multiply(oldPrice);
+//                    newPrice = productInfo.getLength().multiply(productInfo.getWidth()).multiply(newPrice);
+//                } else {
+//                    oldPrice = oldPrice.multiply(productBomDetail.getQuantity());
+//                    newPrice = newPrice.multiply(productBomDetail.getQuantity());
+//                }
+//
+//                BigDecimal subtract = newPrice.subtract(oldPrice);
+//                this.update(q -> q
+//                        .in(ProductInfo::getId, productInfo.getId())
+//                        .setSql("price = price + " + subtract)
+//                        .set(BasePo::getUpdateTime, new Date())
+//                        .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
+//                );
+//            }
+//        }
 
 
         // 禁止产品编号修改
@@ -395,39 +430,53 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
             productInfoDto.setCompanyId(SecurityUtils.getCompanyId());
         }
 
+        //修改产品时 修改原材料
+        saveOrEditRawMaterial(productInfoDto);
+
         this.updateById(productInfoDto);
         ObsFileUtil.editFile(productInfoDto.getFileList(), productInfoDto.getId());
         ObsFileUtil.editFile(productInfoDto.getProdFileList(), productInfoDto.getId(), 2);
 
-        //修改产品时 修改原材料
-        saveOrEditRawMaterial(productInfoDto);
+        //保存物料信息
+        List<ProductBomDetail> productBomDetailList = productInfoDto.getProductBomDetailList();
+        productBomDetailList.forEach(item -> item.setProductId(productInfoDto.getId()));
+        productBomDetailService.editLinked(productBomDetailList, ProductBomDetail::getProductId, productInfoDto.getId());
+
+        //保存产品定制信息
+        saveOrEditCustomInfo(productInfoDto);
     }
 
     /**
-     * 保存修改产品原材料
+     * 保存产品定制信息
      */
-    private void saveOrEditRawMaterial(ProductInfoDto productInfoDto) {
-        Long rawMaterialId = productInfoDto.getRawMaterialId();
+    private void saveOrEditCustomInfo(ProductInfoDto productInfoDto) {
+        //保存产品定制信息
+        List<ProductCustomInfoDto> productCustomInfoList = productInfoDto.getProductCustomInfoList();
 
-        //非产品跳过
-        if (ObjectUtil.notEqual(productInfoDto.getDefinition(), 1)) {
-            return;
+        for (ProductCustomInfoDto productCustomInfoDto : productCustomInfoList) {
+            if (ObjectUtil.isEmpty(productCustomInfoDto.getId())) {
+                productCustomInfoDto.setId(IdWorker.getId());
+            }
+            productCustomInfoDto.setProductId(productInfoDto.getId());
+            ObsFileUtil.saveFile(productCustomInfoDto.getFileList(), productCustomInfoDto.getId());
         }
-        Assert.notEmpty(rawMaterialId, "原材料ID不能为空!");
 
-        //保存原材料信息
-        ProductBomDetail productBomDetail = productBomDetailService.getOne(q -> q
-                .eq(ProductBomDetail::getProductId, productInfoDto.getId())
-                .eq(ProductBomDetail::getType, 1)
-        );
-        if (ObjectUtil.isEmpty(productBomDetail)) {
-            productBomDetail = new ProductBomDetail();
-            productBomDetail.setProductId(productInfoDto.getId());
-            productBomDetail.setType(1);
-            productBomDetail.setQuantity(BigDecimal.ONE);
-            productBomDetail.setMaterialId(rawMaterialId);
+        List<ProductCustomInfo> productCustomInfos = BeanUtil.copyToList(productCustomInfoList, ProductCustomInfo.class);
+        productCustomInfoService.editLinked(productCustomInfos, ProductCustomInfo::getProductId, productInfoDto.getId());
+
+    }
+
+    /**
+     * 保存修改产品原材料
+     */
+    private void saveOrEditRawMaterial(ProductInfoDto productInfoDto) {
+        List<ProductBomDetail> productBomDetailList = productInfoDto.getProductBomDetailList();
+        List<ProductBomDetail> rawMaterialList = productBomDetailList.stream()
+                .filter(item -> ObjectUtil.equals(item.getType(), 1)).collect(Collectors.toList());
+        if (ObjectUtil.isNotEmpty(rawMaterialList)) {
+            ProductBomDetail productBomDetail = rawMaterialList.get(0);
+            productInfoDto.setRawMaterialId(productBomDetail.getMaterialId());
         }
-        productBomDetailService.saveOrUpdate(productBomDetail);
     }
 
     @DSTransactional

+ 4 - 0
hx-item/src/main/resources/mapper/product/ProductCustomInfoMapper.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.item.mapper.product.ProductCustomInfoMapper">
+</mapper>