Browse Source

sku报价表字段新增

fgd 1 year ago
parent
commit
d37522a6bb

+ 11 - 2
sd-business/src/main/java/com/sd/business/entity/board/dto/SkuSpecQuotationDto.java

@@ -24,8 +24,17 @@ public class SkuSpecQuotationDto {
     private String skuSpecCode;
 
     /**
-     * sku品名
+     * bom品号
      */
-    private String skuSpecName;
+    private String bomSpecCode;
 
+    /**
+     * 颜色
+     */
+    private String colour;
+
+    /**
+     * 色层 字典:bom_chromatophore
+     */
+    private String chromatophore;
 }

+ 47 - 11
sd-business/src/main/java/com/sd/business/entity/board/vo/SkuSpecQuotationVo.java

@@ -24,6 +24,21 @@ import java.math.BigDecimal;
 public class SkuSpecQuotationVo {
 
     /**
+     * id
+     */
+    private Long id;
+
+    /**
+     * sku id
+     */
+    private Long skuId;
+
+    /**
+     * bom id
+     */
+    private Long bomSpecId;
+
+    /**
      * 品牌
      */
     @ColumnWidth(15)
@@ -45,79 +60,100 @@ public class SkuSpecQuotationVo {
     private String skuSpecName;
 
     /**
+     * bom品号
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "bom品号", index = 3)
+    private String bomSpecCode;
+
+    /**
+     * 颜色
+     */
+    @ColumnWidth(12)
+    @ExcelProperty(value = "颜色", index = 4)
+    private String colour;
+
+    /**
+     * 色层 字典:bom_chromatophore
+     */
+    @ColumnWidth(12)
+    @ExcelProperty(value = "色层", index = 5)
+    private String chromatophore;
+
+    /**
      * sku 裸垫单价
      */
     @ColumnWidth(12)
-    @ExcelProperty(value = {"SKU单价(含税)", "裸垫"}, index = 3)
+    @ExcelProperty(value = {"SKU单价(含税)", "裸垫"}, index = 6)
     private BigDecimal skuSpecUnitPrice;
 
     /**
      * sku 激光logo单价
      */
     @ColumnWidth(12)
-    @ExcelProperty(value = {"SKU单价(含税)", "激光logo"}, index = 4)
+    @ExcelProperty(value = {"SKU单价(含税)", "激光logo"}, index = 7)
     private BigDecimal skuSpecUnitPriceLogo;
 
     /**
      * sku 激光体位线单价
      */
     @ColumnWidth(15)
-    @ExcelProperty(value = {"SKU单价(含税)", "激光体位线"}, index = 5)
+    @ExcelProperty(value = {"SKU单价(含税)", "激光体位线"}, index = 8)
     private BigDecimal skuSpecUnitPriceLine;
 
     /**
      * bom 主材单价
      */
     @ColumnWidth(12)
-    @ExcelProperty(value = {"价格组成", "主材"}, index = 6)
+    @ExcelProperty(value = {"价格组成", "主材"}, index = 9)
     private BigDecimal bomSpecUnitPrice;
 
     /**
      * 包材费
      */
     @ColumnWidth(12)
-    @ExcelProperty(value = {"价格组成", "包材配件"}, index = 7)
+    @ExcelProperty(value = {"价格组成", "包材配件"}, index = 10)
     private BigDecimal packagingMaterialCost;
 
     /**
      * 激光logo价格
      */
     @ColumnWidth(12)
-    @ExcelProperty(value = {"价格组成", "激光logo"}, index = 8)
+    @ExcelProperty(value = {"价格组成", "激光logo"}, index = 11)
     private BigDecimal logoProcessingFee;
 
     /**
      * 激光体位线价格
      */
     @ColumnWidth(15)
-    @ExcelProperty(value = {"价格组成", "激光体位线"}, index = 9)
+    @ExcelProperty(value = {"价格组成", "激光体位线"}, index = 12)
     private BigDecimal lineProcessingFee;
 
     /**
      * 代发费
      */
     @ColumnWidth(12)
-    @ExcelProperty(value = {"价格组成", "代发"}, index = 10)
+    @ExcelProperty(value = {"价格组成", "代发"}, index = 13)
     private BigDecimal issueFee;
 
     /**
      * 快递包材费
      */
     @ColumnWidth(12)
-    @ExcelProperty(value = {"价格组成", "快递包材"}, index = 11)
+    @ExcelProperty(value = {"价格组成", "快递包材"}, index = 14)
     private BigDecimal deliveryMaterialsFee;
 
     /**
      * 包装人工费
      */
     @ColumnWidth(12)
-    @ExcelProperty(value = {"价格组成", "包装人工"}, index = 12)
+    @ExcelProperty(value = {"价格组成", "包装人工"}, index = 15)
     private BigDecimal packingLabor;
 
     /**
      * 管理费
      */
     @ColumnWidth(12)
-    @ExcelProperty(value = {"价格组成", "管理"}, index = 13)
+    @ExcelProperty(value = {"价格组成", "管理"}, index = 16)
     private BigDecimal managementFee;
 }

+ 2 - 2
sd-business/src/main/java/com/sd/business/entity/board/vo/TurnoverRateStatisticsVo.java

@@ -33,13 +33,13 @@ public class TurnoverRateStatisticsVo {
     /**
      * 宽
      */
-    @ExcelProperty(value = "宽", index = 2)
+    @ExcelProperty(value = "宽", index = 2)
     private BigDecimal width;
 
     /**
      * 高
      */
-    @ExcelProperty(value = "", index = 3)
+    @ExcelProperty(value = "厚度", index = 3)
     private BigDecimal height;
 
     /**

+ 8 - 0
sd-business/src/main/java/com/sd/business/mapper/sku/SkuSpecMapper.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.utils.wrapper.IWrapper;
+import com.sd.business.entity.board.vo.SkuSpecQuotationVo;
 import com.sd.business.entity.bom.bo.BomSpecBo;
 import com.sd.business.entity.sku.bo.SkuSpecBo;
 import com.sd.business.entity.sku.po.SkuSpec;
@@ -37,4 +38,11 @@ public interface SkuSpecMapper extends BaseMapper<SkuSpec> {
      * 根据sku规格id获取sku详情信息
      */
     List<SkuSpecBo> getSkuSpecBoList(@Param("ew") QueryWrapper<Object> in);
+
+    /**
+     * 查询sku报价板列表
+     * @param wrapper
+     * @return
+     */
+    List<SkuSpecQuotationVo> getSkuSpecQuotationList(@Param("ew") IWrapper<SkuSpec> wrapper);
 }

+ 51 - 28
sd-business/src/main/java/com/sd/business/service/sku/impl/SkuSpecServiceImpl.java

@@ -6,12 +6,16 @@ import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.tenant.entity.dict.po.DictCommonData;
+import com.fjhx.tenant.service.dict.DictCommonDataService;
 import com.ruoyi.common.core.domain.BaseIdPo;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.sd.business.entity.board.dto.SkuSpecQuotationDto;
 import com.sd.business.entity.board.vo.SkuSpecQuotationVo;
 import com.sd.business.entity.bom.bo.BomSpecBo;
+import com.sd.business.entity.bom.po.Bom;
+import com.sd.business.entity.bom.po.BomSpec;
 import com.sd.business.entity.department.po.Department;
 import com.sd.business.entity.inventory.po.Inventory;
 import com.sd.business.entity.price.po.PriceBillingStandard;
@@ -71,6 +75,9 @@ public class SkuSpecServiceImpl extends ServiceImpl<SkuSpecMapper, SkuSpec> impl
     @Autowired
     private PriceBillingStandardDetailService priceBillingStandardDetailService;
 
+    @Autowired
+    private DictCommonDataService dictCommonDataService;
+
     @Override
     public Page<SkuSpecVo> getPage(SkuSpecSelectDto dto) {
         IWrapper<SkuSpec> wrapper = getWrapper();
@@ -186,12 +193,15 @@ public class SkuSpecServiceImpl extends ServiceImpl<SkuSpecMapper, SkuSpec> impl
             return Collections.emptyList();
         }
 
-        Map<Long, Sku> skuMap = skuService.mapKEntity(BaseIdPo::getId, q -> q.in(Sku::getBrand, brandList));
-        List<SkuSpec> skuSpecList = this.list(q -> q
-                .in(SkuSpec::getSkuId, skuMap.keySet())
-                .isNotNull(SkuSpec::getBomSpecId)
-                .like(StrUtil.isNotBlank(dto.getSkuSpecCode()), SkuSpec::getCode, dto.getSkuSpecCode())
-                .like(StrUtil.isNotBlank(dto.getSkuSpecName()), SkuSpec::getName, dto.getSkuSpecName()));
+        IWrapper<SkuSpec> wrapper = getWrapper();
+        wrapper.orderByDesc("ss", SkuSpec::getId);
+        wrapper.in("s", Sku::getBrand, brandList);
+        wrapper.like("ss", SkuSpec::getCode, dto.getSkuSpecCode());
+        wrapper.like("bs", BomSpec::getCode, dto.getBomSpecCode());
+        wrapper.like("bs", BomSpec::getColour, dto.getColour());
+        wrapper.eq("b", Bom::getChromatophore, dto.getChromatophore());
+        wrapper.isNotNull("ss.bom_spec_id");
+        List<SkuSpecQuotationVo> skuSpecList = this.baseMapper.getSkuSpecQuotationList(wrapper);
 
         if (skuSpecList.isEmpty()) {
             return Collections.emptyList();
@@ -207,24 +217,25 @@ public class SkuSpecServiceImpl extends ServiceImpl<SkuSpecMapper, SkuSpec> impl
                 q -> q.in(PriceBillingStandardDetail::getPriceBillingStandardId, priceBillingStandardIds));
 
         // 获取sku关联的所有bom数据
-        List<Long> skuSpecIds = skuSpecList.stream().map(BaseIdPo::getId).collect(Collectors.toList());
-        Map<Long, List<SkuSpecLink>> linkMap = skuSpecLinkService.mapKGroup(SkuSpecLink::getSkuSpecId,
-                q -> q.in(SkuSpecLink::getSkuSpecId, skuSpecIds).eq(SkuSpecLink::getType, 1));
-        Set<Long> bomSpecIds = skuSpecList.stream().map(SkuSpec::getBomSpecId).collect(Collectors.toSet());
-        bomSpecIds.addAll(linkMap.values().stream().flatMap(item -> item.stream().map(SkuSpecLink::getBomSpecId)).collect(Collectors.toList()));
+        List<Long> skuSpecIds = skuSpecList.stream().map(SkuSpecQuotationVo::getId).collect(Collectors.toList());
+
+        List<SkuSpecLink> skuSpecLinkList = skuSpecLinkService.list(q -> q.in(SkuSpecLink::getSkuSpecId, skuSpecIds));
+        Map<Long, Map<Integer, List<SkuSpecLink>>> skuSpecLinkBomSpecMap = skuSpecLinkList.stream().collect(
+                Collectors.groupingBy(SkuSpecLink::getSkuSpecId, Collectors.groupingBy(SkuSpecLink::getType)));
+
+        Set<Long> bomSpecIds = skuSpecList.stream().map(SkuSpecQuotationVo::getBomSpecId).collect(Collectors.toSet());
+        bomSpecIds.addAll(skuSpecLinkList.stream().map(SkuSpecLink::getBomSpecId).collect(Collectors.toList()));
         Map<Long, BomSpecBo> bomSpecBoMap = this.getBomSpecBoByIdList(bomSpecIds);
 
-        List<SkuSpecQuotationVo> list = new ArrayList<>();
+        Map<String, String> bomChromatophoreMap = dictCommonDataService.list(q -> q.eq(DictCommonData::getDictCode, "bom_chromatophore"))
+                .stream().collect(Collectors.toMap(DictCommonData::getDictKey, DictCommonData::getDictValue));
+
 
-        for (SkuSpec skuSpec : skuSpecList) {
-            Sku sku = skuMap.get(skuSpec.getSkuId());
-            BomSpecBo bomSpecBo = bomSpecBoMap.get(skuSpec.getBomSpecId());
+        for (SkuSpecQuotationVo vo : skuSpecList) {
+            BomSpecBo bomSpecBo = bomSpecBoMap.get(vo.getBomSpecId());
 
             // 赋值
-            SkuSpecQuotationVo vo = new SkuSpecQuotationVo();
-            vo.setBrand(sku.getBrand());
-            vo.setSkuSpecCode(skuSpec.getCode());
-            vo.setSkuSpecName(skuSpec.getName());
+            vo.setChromatophore(bomChromatophoreMap.get(vo.getChromatophore()));
             vo.setBomSpecUnitPrice(bomSpecBo.getInternalSellingPrice());
             vo.setPackagingMaterialCost(BigDecimal.ZERO);
             vo.setLineProcessingFee(BigDecimal.ZERO);
@@ -235,9 +246,10 @@ public class SkuSpecServiceImpl extends ServiceImpl<SkuSpecMapper, SkuSpec> impl
             vo.setManagementFee(BigDecimal.ZERO);
 
             // 获取包材费
-            List<SkuSpecLink> skuSpecLinkList = linkMap.get(skuSpec.getId());
-            if (ObjectUtil.isNotEmpty(skuSpecLinkList)) {
-                BigDecimal packagingMaterialCost = skuSpecLinkList.stream().map(item -> {
+            Map<Integer, List<SkuSpecLink>> linkMap = skuSpecLinkBomSpecMap.getOrDefault(vo.getId(), Collections.emptyMap());
+            List<SkuSpecLink> packagingLinkList = linkMap.getOrDefault(1, Collections.emptyList());
+            if (ObjectUtil.isNotEmpty(packagingLinkList)) {
+                BigDecimal packagingMaterialCost = packagingLinkList.stream().map(item -> {
                     BomSpecBo skuSpecLinkBomSpec = bomSpecBoMap.get(item.getBomSpecId());
                     if (skuSpecLinkBomSpec == null) {
                         return BigDecimal.ZERO;
@@ -272,14 +284,27 @@ public class SkuSpecServiceImpl extends ServiceImpl<SkuSpecMapper, SkuSpec> impl
                     case "50":
                         vo.setIssueFee(chargePrice);
                         break;
-                    case "60":
-                        vo.setDeliveryMaterialsFee(chargePrice);
-                        break;
                     case "70":
                         vo.setManagementFee(chargePrice);
                         break;
                 }
             }
+            // 计算快递包材费
+            List<SkuSpecLink> deliveryLinkList = linkMap.getOrDefault(2, Collections.emptyList());
+            if (deliveryLinkList.isEmpty()) {
+                vo.setDeliveryMaterialsFee(BigDecimal.ZERO);
+            } else {
+                BigDecimal deliveryMaterialsFee = deliveryLinkList.stream()
+                        .map(item -> {
+                            BomSpecBo bomSpec = bomSpecBoMap.get(item.getBomSpecId());
+                            if (bomSpec == null) {
+                                return BigDecimal.ZERO;
+                            }
+                            return item.getQuantity().multiply(bomSpec.getInternalSellingPrice());
+                        })
+                        .reduce(BigDecimal.ZERO, BigDecimal::add);
+                vo.setDeliveryMaterialsFee(deliveryMaterialsFee);
+            }
 
             // 计算Sku单价
             vo.setSkuSpecUnitPrice(
@@ -291,11 +316,9 @@ public class SkuSpecServiceImpl extends ServiceImpl<SkuSpecMapper, SkuSpec> impl
                             .add(vo.getManagementFee()));
             vo.setSkuSpecUnitPriceLogo(vo.getSkuSpecUnitPrice().add(vo.getLogoProcessingFee()));
             vo.setSkuSpecUnitPriceLine(vo.getSkuSpecUnitPrice().add(vo.getLineProcessingFee()));
-
-            list.add(vo);
         }
 
-        return list;
+        return skuSpecList;
     }
 
 }

+ 17 - 0
sd-business/src/main/resources/mapper/sku/SkuSpecMapper.xml

@@ -62,4 +62,21 @@
             ${ew.customSqlSegment}
     </select>
 
+    <select id="getSkuSpecQuotationList" resultType="com.sd.business.entity.board.vo.SkuSpecQuotationVo">
+        select ss.id,
+               ss.sku_id,
+               ss.code skuSpecCode,
+               ss.name skuSpecName,
+               ss.bom_spec_id,
+               s.brand,
+               bs.code bomSpecCode,
+               bs.colour,
+               b.chromatophore
+        from sku_spec ss
+             left join sku s on ss.sku_id = s.id
+             left join bom_spec bs on ss.bom_spec_id = bs.id
+             left join bom b on bs.bom_id = b.id
+            ${ew.customSqlSegment}
+    </select>
+
 </mapper>