diff --git a/bms-back/bms-system/src/main/java/com/bms/customer/customerinfo/domain/BmsCustomer.java b/bms-back/bms-system/src/main/java/com/bms/customer/customerinfo/domain/BmsCustomer.java index 1d351d7e..e78df049 100644 --- a/bms-back/bms-system/src/main/java/com/bms/customer/customerinfo/domain/BmsCustomer.java +++ b/bms-back/bms-system/src/main/java/com/bms/customer/customerinfo/domain/BmsCustomer.java @@ -47,6 +47,10 @@ public class BmsCustomer extends BaseEntity @Excel(name = "业务类型", readConverterExp = "0=直客,1=同行,2=集运") private String customerType; + /** 区域类型(字典 data_area_type) */ + @Excel(name = "区域类型", dictType = "data_area_type") + private String areaType; + /** 启用状态(0正常 1停用) */ @Excel(name = "启用状态", readConverterExp = "0=正常,1=停用") private String isEnable; diff --git a/bms-back/bms-system/src/main/java/com/bms/customer/customerinfo/service/impl/BmsCustomerLogServiceImpl.java b/bms-back/bms-system/src/main/java/com/bms/customer/customerinfo/service/impl/BmsCustomerLogServiceImpl.java index 128c1f9a..43bd4133 100644 --- a/bms-back/bms-system/src/main/java/com/bms/customer/customerinfo/service/impl/BmsCustomerLogServiceImpl.java +++ b/bms-back/bms-system/src/main/java/com/bms/customer/customerinfo/service/impl/BmsCustomerLogServiceImpl.java @@ -13,7 +13,9 @@ import java.util.function.Function; import com.alibaba.fastjson2.JSON; import com.bms.common.core.domain.entity.SysUser; import com.bms.common.utils.DateUtils; +import com.bms.common.utils.DictUtils; import com.bms.common.utils.SecurityUtils; +import com.bms.common.utils.StringUtils; import com.bms.customer.customerinfo.domain.BmsCustomer; import com.bms.customer.customerinfo.domain.BmsCustomerAttachment; import com.bms.customer.customerinfo.domain.BmsCustomerCompany; @@ -43,6 +45,13 @@ public class BmsCustomerLogServiceImpl implements IBmsCustomerLogService private static final ThreadLocal DATE_FMT = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd")); + /** 区域类型走字典 data_area_type;缓存未命中时保留原编码。 */ + private static String areaTypeLabel(String value) + { + String label = DictUtils.getDictLabel("data_area_type", value); + return StringUtils.isEmpty(label) ? value : label; + } + /** 业务类型字典 */ private static final Map CUSTOMER_TYPE_MAP = Map.of( "0", "直客", "1", "同行", "2", "集运"); @@ -68,7 +77,7 @@ public class BmsCustomerLogServiceImpl implements IBmsCustomerLogService /** * 需要记录日志的主表字段(顺序即展示顺序)。 * requireNonBlank 为 true 的字段对应 update SQL 的 <if test="x!=null and x!=''">, - * 其余动态字段仅在新值非 null 时落库;业务员/结算员/客服为无条件写入。 + * 其余动态字段仅在新值非 null 时落库;业务员/结算员/客服、区域类型为无条件写入。 */ private static final List FIELD_DEFS = List.of( new FieldDef("customerCode", "客户编码", BmsCustomer::getCustomerCode, true, Function.identity()), @@ -76,6 +85,7 @@ public class BmsCustomerLogServiceImpl implements IBmsCustomerLogService new FieldDef("customerCodeDw", "对外代码", BmsCustomer::getCustomerCodeDw, false, Function.identity()), new FieldDef("creditCode", "统一社会信用代码", BmsCustomer::getCreditCode, false, Function.identity()), new FieldDef("customerType", "业务类型", BmsCustomer::getCustomerType, false, CUSTOMER_TYPE_MAP::get), + new FieldDef("areaType", "区域类型", BmsCustomer::getAreaType, false, BmsCustomerLogServiceImpl::areaTypeLabel), new FieldDef("isEnable", "启用状态", BmsCustomer::getIsEnable, false, ENABLE_MAP::get), new FieldDef("salesUserId", "业务员", c -> userDisplay(c.getSalesUserId(), c.getSalesUser()), false, Function.identity()), new FieldDef("ed", "资金额度(元)", BmsCustomer::getEd, false, BmsCustomerLogServiceImpl::numText), @@ -198,8 +208,8 @@ public class BmsCustomerLogServiceImpl implements IBmsCustomerLogService { // 与 update SQL 的动态条件保持一致:未提交(null/空串)的字段本次不落库,不参与比对 Object raw = def.rawGetter.apply(newCustomer); - // 合同起止允许清空;其余动态字段未提交时不落库,也不记日志 - if (raw == null && !isContractDateField(def.field)) + // 合同起止、区域类型允许清空;其余动态字段未提交时不落库,也不记日志 + if (raw == null && !isContractDateField(def.field) && !"areaType".equals(def.field)) { continue; } diff --git a/bms-back/bms-system/src/main/resources/mapper/customer/BmsCustomerMapper.xml b/bms-back/bms-system/src/main/resources/mapper/customer/BmsCustomerMapper.xml index 8ac9eef2..fbbf8b95 100644 --- a/bms-back/bms-system/src/main/resources/mapper/customer/BmsCustomerMapper.xml +++ b/bms-back/bms-system/src/main/resources/mapper/customer/BmsCustomerMapper.xml @@ -11,6 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -44,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select c.customer_id, c.customer_code, c.customer_name, c.customer_code_dw, c.credit_code, c.customer_type, + select c.customer_id, c.customer_code, c.customer_name, c.customer_code_dw, c.credit_code, c.customer_type, c.area_type, c.is_enable, case when su.user_id is not null then cast(su.user_id as char) else null end as sales_user_id, su.nick_name as sales_user, c.ed, c.zq, c.settlement_user_id, c.settlement_user, @@ -91,6 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and c.credit_code = #{creditCode} and c.customer_type = #{customerType} + and c.area_type = #{areaType} and c.is_enable = #{isEnable} and c.sales_user_id = #{salesUserId} and su.nick_name = #{salesUser} @@ -315,6 +317,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" customer_code_dw, credit_code, customer_type, + area_type, is_enable, sales_user_id, sales_user, @@ -347,6 +350,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{customerCodeDw}, #{creditCode}, #{customerType}, + #{areaType}, #{isEnable}, #{salesUserId}, #{salesUser}, @@ -383,6 +387,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" customer_code_dw = #{customerCodeDw}, credit_code = #{creditCode}, customer_type = #{customerType}, + area_type = #{areaType}, is_enable = #{isEnable}, sales_user_id = #{salesUserId}, sales_user = #{salesUser}, diff --git a/bms-back/sql/bms_init.sql b/bms-back/sql/bms_init.sql index 581cfe62..443bf205 100644 --- a/bms-back/sql/bms_init.sql +++ b/bms-back/sql/bms_init.sql @@ -355,6 +355,7 @@ CREATE TABLE `ctr_customer` ( `customer_code_dw` varchar(50) DEFAULT '' COMMENT '对外代码', `credit_code` varchar(18) DEFAULT '' COMMENT '统一社会信用代码', `customer_type` char(1) DEFAULT '0' COMMENT '业务类型(0直客 1同行 2集运)', + `area_type` varchar(32) DEFAULT NULL COMMENT '区域类型(字典 data_area_type)', `is_enable` char(1) DEFAULT '0' COMMENT '启用状态(0正常 1停用)', `sales_user_id` varchar(64) DEFAULT NULL COMMENT '业务员系统用户ID(sys_user.user_id)', `source_sales_code` varchar(255) DEFAULT NULL COMMENT '客户同步源业务员工号(内部字段)', diff --git a/bms-back/sql/customer+supplier/20261030_customer_area_type.sql b/bms-back/sql/customer+supplier/20261030_customer_area_type.sql new file mode 100644 index 00000000..725747d8 --- /dev/null +++ b/bms-back/sql/customer+supplier/20261030_customer_area_type.sql @@ -0,0 +1,11 @@ +-- ctr_customer.area_type:客户区域类型,取值来自字典 data_area_type(可重复执行) +SET @col_exists := ( + SELECT COUNT(1) FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'ctr_customer' AND COLUMN_NAME = 'area_type' +); +SET @sql := IF(@col_exists = 0, + 'ALTER TABLE `ctr_customer` ADD COLUMN `area_type` varchar(32) DEFAULT NULL COMMENT ''区域类型(字典 data_area_type)'' AFTER `customer_type`', + 'SELECT 1'); +PREPARE stmt FROM @sql; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; diff --git a/bms-front/src/views/customersuppliermanagement/customerinfo/customeredit/index.vue b/bms-front/src/views/customersuppliermanagement/customerinfo/customeredit/index.vue index 0a9b1060..dc6a4167 100644 --- a/bms-front/src/views/customersuppliermanagement/customerinfo/customeredit/index.vue +++ b/bms-front/src/views/customersuppliermanagement/customerinfo/customeredit/index.vue @@ -62,6 +62,18 @@ + + + + + + + @@ -727,6 +739,7 @@ const router = useRouter() const { settlement_type } = useDict('settlement_type') const { customer_type } = useDict('customer_type') +const { data_area_type } = useDict('data_area_type') const { ensureProducts, findProduct } = useProducts() @@ -752,6 +765,7 @@ function buildEmptyForm() { customerCodeDw: null, creditCode: null, customerType: null, + areaType: null, isEnable: null, salesUserId: null, salesUser: null, diff --git a/bms-front/src/views/customersuppliermanagement/customerinfo/index.vue b/bms-front/src/views/customersuppliermanagement/customerinfo/index.vue index feba56cc..0461af71 100644 --- a/bms-front/src/views/customersuppliermanagement/customerinfo/index.vue +++ b/bms-front/src/views/customersuppliermanagement/customerinfo/index.vue @@ -30,6 +30,22 @@ /> + + + + + + + +