diff --git a/bms-back/ruoyi-system/src/main/java/com/ruoyi/customer/customerinfo/domain/BmsCustomer.java b/bms-back/ruoyi-system/src/main/java/com/ruoyi/customer/customerinfo/domain/BmsCustomer.java index 18842af5..5c06e336 100644 --- a/bms-back/ruoyi-system/src/main/java/com/ruoyi/customer/customerinfo/domain/BmsCustomer.java +++ b/bms-back/ruoyi-system/src/main/java/com/ruoyi/customer/customerinfo/domain/BmsCustomer.java @@ -107,9 +107,9 @@ public class BmsCustomer extends BaseEntity @Excel(name = "信用额度", readConverterExp = "元=") private BigDecimal creditEd; - /** 绑定产品ID(多个产品ID用逗号分隔,支持批量操作) */ - @Excel(name = "绑定产品ID", readConverterExp = "多=个产品ID用逗号分隔,支持批量操作") - private String productIds; + /** 绑定产品代码(多个产品代码用逗号分隔;旧库导入产品ID不稳定,统一用代码对接) */ + @Excel(name = "绑定产品代码") + private String productCodes; /** 附件列表(子表 bms_customer_attachment) */ private List attachmentList; diff --git a/bms-back/ruoyi-system/src/main/resources/mapper/customer/BmsCustomerMapper.xml b/bms-back/ruoyi-system/src/main/resources/mapper/customer/BmsCustomerMapper.xml index b116013b..034cd76c 100644 --- a/bms-back/ruoyi-system/src/main/resources/mapper/customer/BmsCustomerMapper.xml +++ b/bms-back/ruoyi-system/src/main/resources/mapper/customer/BmsCustomerMapper.xml @@ -27,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + @@ -51,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" (select coalesce(sum(ca.total_credit+ca.extra_credit-ca.used_credit), 0) from customer_account ca where ca.customer_id = c.customer_id and ca.del_flag = '0') as credit_ed, - c.product_ids, c.remark, + c.product_codes, c.remark, c.create_by, c.create_time, c.update_by, c.update_time, c.del_flag from bms_customer c ${params.dataScope} @@ -253,7 +253,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" weight_threshold, throw_ratio, credit_ed, - product_ids, + product_codes, remark, create_by, create_time, @@ -283,7 +283,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{weightThreshold}, #{throwRatio}, #{creditEd}, - #{productIds}, + #{productCodes}, #{remark}, #{createBy}, #{createTime}, @@ -315,7 +315,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" foreign_currency_balance = #{foreignCurrencyBalance}, weight_threshold = #{weightThreshold}, throw_ratio = #{throwRatio}, - product_ids = #{productIds}, + product_codes = #{productCodes}, remark = #{remark}, create_by = #{createBy}, create_time = #{createTime}, diff --git a/bms-back/sql/customer+supplier/customer.sql b/bms-back/sql/customer+supplier/customer.sql index 07bc1819..eec22df1 100644 --- a/bms-back/sql/customer+supplier/customer.sql +++ b/bms-back/sql/customer+supplier/customer.sql @@ -29,7 +29,7 @@ CREATE TABLE `bms_customer` ( `weight_threshold` decimal(15,2) DEFAULT 0.00 COMMENT '重量阈值(kg)', `throw_ratio` decimal(15,2) DEFAULT 0.00 COMMENT '抛比(%)', `credit_ed` decimal(15,2) DEFAULT 0.00 COMMENT '信用额度(元)', - `product_ids` varchar(1000) DEFAULT NULL COMMENT '绑定产品ID(多个产品ID用逗号分隔,支持批量操作)', + `product_codes` varchar(1000) DEFAULT NULL COMMENT '绑定产品代码(多个产品代码用逗号分隔,对接旧库产品编码)', -- ========== 附件字段(新增) ========== `logo_oss_id` bigint(20) DEFAULT NULL COMMENT '客户Logo(图片,关联sys_oss.oss_id)', diff --git a/bms-back/sql/customer+supplier/customer_product_codes.sql b/bms-back/sql/customer+supplier/customer_product_codes.sql new file mode 100644 index 00000000..15fb3536 --- /dev/null +++ b/bms-back/sql/customer+supplier/customer_product_codes.sql @@ -0,0 +1,23 @@ +-- ===================================================================== +-- 客户绑定产品:存储口径由「产品ID逗号串」改为「产品代码逗号串」 +-- 背景:后续产品数据从旧数据库迁移导入,新旧库产品ID不一致, +-- 产品代码(product_code)在两库间稳定,故客户绑定关系改用代码。 +-- 日期:2026-09-22 +-- ===================================================================== + +-- 1. 列改名(保留原数据,CHANGE 仅改列名/注释) +ALTER TABLE bms_customer + CHANGE COLUMN product_ids product_codes varchar(1000) DEFAULT NULL + COMMENT '绑定产品代码(多个产品代码用逗号分隔,对接旧库产品编码)'; + +-- 2. 旧值(产品ID逗号串)按 bms_product 映射为产品代码逗号串 +-- FIND_IN_SET 逐个匹配逗号串中的ID,GROUP_CONCAT 重新拼为代码串; +-- 匹配不到产品的ID会被置为NULL(脏数据,可在客户编辑页重新绑定) +UPDATE bms_customer c +SET c.product_codes = ( + SELECT GROUP_CONCAT(p.product_code) + FROM bms_product p + WHERE FIND_IN_SET(p.product_id, c.product_codes) + ) +WHERE c.product_codes IS NOT NULL + AND c.product_codes <> ''; diff --git a/bms-front/src/components/ProductSelect/index.vue b/bms-front/src/components/ProductSelect/index.vue index fcfaf979..a92d257a 100644 --- a/bms-front/src/components/ProductSelect/index.vue +++ b/bms-front/src/components/ProductSelect/index.vue @@ -1,11 +1,11 @@