From 773f400add07622510e7b73657a03abd9f151d66 Mon Sep 17 00:00:00 2001 From: jiangpeng Date: Wed, 22 Apr 2026 17:00:59 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BA=A7=E5=93=81=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=AF=BC=E5=87=BA=E5=8A=9F=E8=83=BD=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/sip/domain/ProductInfo.java | 53 ++++++++------- .../service/impl/ProductInfoServiceImpl.java | 64 ++++++++++++++++++- 2 files changed, 88 insertions(+), 29 deletions(-) diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/ProductInfo.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/ProductInfo.java index d4381b1e..fe485a1f 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/ProductInfo.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/domain/ProductInfo.java @@ -27,35 +27,43 @@ public class ProductInfo extends BaseEntity /** ID */ private Long id; - /** 产品编码 */ @Excel(name = "产品编码") private String productCode; private List productCodeList; @Excel(name = "华智编码") private String hzCode; - private String type; - private String value; - //目录单价 - private String cataloguePrice; - //指导折扣 - private String guidanceDiscount; - - /** 产品名称 */ @Excel(name = "产品名称") private String productName; - - /** 产品代码 */ @Excel(name = "产品代码") private String model; - - /** 产品描述 */ - @Excel(name = "产品描述") - private String description; - - /** 创建时间 */ + private String type; + @Excel(name = "产品类型") + private String typeName; + private String level2Type; + @Excel(name = "二级类型") + private String level2TypeName; + private String value; + @Excel(name = "目录单价") + private String cataloguePrice; + @Excel(name = "指导折扣") + private String guidanceDiscount; + @Excel(name = "制造商") + private String vendorCode; @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") private Date createdAt; + @Excel(name = "备注") + private String remark; + @Excel(name = "产品描述") + private String description; + @Excel(name = "终端类型") + private String terminalType; + @Excel(name = "国产化") + private String localization; + @Excel(name = "CPU品牌") + private String cpuBrand; + @Excel(name = "CPU架构") + private String cpuArchitecture; /** 更新时间 */ private Date updatedAt; @@ -63,7 +71,6 @@ public class ProductInfo extends BaseEntity /** 删除时间 */ private Date deletedAt; private String serialNumber; - private String vendorCode; private List vendorCodeList; private String vendorName; //实时库存 @@ -73,16 +80,6 @@ public class ProductInfo extends BaseEntity private Long inventoryCount; private Long warehouseId; private String warehouseName; - // 二级类型 - private String level2Type; - // 终端类型 - private String terminalType; - // 国产化 - private String localization; - // CPU品牌 - private String cpuBrand; - // CPU架构 - private String cpuArchitecture; @Getter public enum ProductTypeEnum { /** diff --git a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProductInfoServiceImpl.java b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProductInfoServiceImpl.java index f380d992..354092c5 100644 --- a/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProductInfoServiceImpl.java +++ b/ruoyi-sip/src/main/java/com/ruoyi/sip/service/impl/ProductInfoServiceImpl.java @@ -1,8 +1,11 @@ package com.ruoyi.sip.service.impl; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; import cn.hutool.core.collection.CollUtil; @@ -30,6 +33,15 @@ import com.ruoyi.common.core.text.Convert; @Service public class ProductInfoServiceImpl implements IProductInfoService { + private static final Map PRODUCT_TYPE_DESC_MAP = Arrays.stream(ProductInfo.ProductTypeEnum.values()) + .collect(Collectors.toMap(ProductInfo.ProductTypeEnum::getType, ProductInfo.ProductTypeEnum::getDesc)); + private static final Map SOFTWARE_LEVEL2_DESC_MAP = Arrays.stream(ProductInfo.ProductTypeLevel2SoftwareEnum.values()) + .collect(Collectors.toMap(ProductInfo.ProductTypeLevel2SoftwareEnum::getType, ProductInfo.ProductTypeLevel2SoftwareEnum::getDesc)); + private static final Map HARDWARE_LEVEL2_DESC_MAP = Arrays.stream(ProductInfo.ProductTypeLevel2HardwareEnum.values()) + .collect(Collectors.toMap(ProductInfo.ProductTypeLevel2HardwareEnum::getType, ProductInfo.ProductTypeLevel2HardwareEnum::getDesc)); + private static final Map SERVICE_LEVEL2_DESC_MAP = Arrays.stream(ProductInfo.ProductTypeLevel2ServiceEnum.values()) + .collect(Collectors.toMap(ProductInfo.ProductTypeLevel2ServiceEnum::getType, ProductInfo.ProductTypeLevel2ServiceEnum::getDesc)); + @Autowired private ProductInfoMapper productInfoMapper; @Autowired @@ -57,7 +69,57 @@ public class ProductInfoServiceImpl implements IProductInfoService @Override public List selectProductInfoList(ProductInfo productInfo) { - return productInfoMapper.selectProductInfoList(productInfo); + List productInfoList = productInfoMapper.selectProductInfoList(productInfo); + if (CollUtil.isEmpty(productInfoList)) { + return productInfoList; + } + productInfoList.forEach(this::fillTypeDesc); + return productInfoList; + } + + private void fillTypeDesc(ProductInfo productInfo) { + if (productInfo == null) { + return; + } + String typeName = PRODUCT_TYPE_DESC_MAP.get(productInfo.getType()); + if (StringUtils.isNotEmpty(typeName)) { + productInfo.setTypeName(typeName); + } + String level2TypeName = resolveLevel2TypeName(productInfo.getType(), productInfo.getLevel2Type()); + if (StringUtils.isNotEmpty(level2TypeName)) { + productInfo.setLevel2TypeName(level2TypeName); + } + } + + private String resolveLevel2TypeName(String type, String level2Type) { + if (StringUtils.isEmpty(type) || StringUtils.isEmpty(level2Type)) { + return null; + } + if (isSoftwareType(type)) { + return SOFTWARE_LEVEL2_DESC_MAP.get(level2Type); + } + if (isHardwareType(type)) { + return HARDWARE_LEVEL2_DESC_MAP.get(level2Type); + } + if (isServiceType(type)) { + return SERVICE_LEVEL2_DESC_MAP.get(level2Type); + } + return null; + } + + private boolean isSoftwareType(String type) { + return Objects.equals(type, ProductInfo.ProductTypeEnum.SOFTWARE.getType()) + || Objects.equals(type, ProductInfo.ProductTypeEnum.SOFTWARE_MAINTENANCE.getType()); + } + + private boolean isHardwareType(String type) { + return Objects.equals(type, ProductInfo.ProductTypeEnum.HARDWARE.getType()) + || Objects.equals(type, ProductInfo.ProductTypeEnum.HARDWARE_MAINTENANCE.getType()); + } + + private boolean isServiceType(String type) { + return Objects.equals(type, ProductInfo.ProductTypeEnum.SERVICE.getType()) + || Objects.equals(type, ProductInfo.ProductTypeEnum.PROVINCE_SERVICE.getType()); } /**