✨ 同步客户区域字段并统一字典标识

This commit is contained in:
caojia
2026-11-04 18:29:47 +08:00
parent 846a41c6df
commit 942d5932ae
11 changed files with 211 additions and 44 deletions
@@ -47,9 +47,9 @@ 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;
/** 客户区域(字典 customer_area) */
@Excel(name = "客户区域", dictType = "customer_area")
private String customerArea;
/** 启用状态(0正常 1停用) */
@Excel(name = "启用状态", readConverterExp = "0=正常,1=停用")
@@ -45,10 +45,10 @@ public class BmsCustomerLogServiceImpl implements IBmsCustomerLogService
private static final ThreadLocal<SimpleDateFormat> DATE_FMT =
ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd"));
/** 区域类型走字典 data_area_type;缓存未命中时保留原编码。 */
private static String areaTypeLabel(String value)
/** 客户区域走字典 customer_area;缓存未命中时保留原编码。 */
private static String customerAreaLabel(String value)
{
String label = DictUtils.getDictLabel("data_area_type", value);
String label = DictUtils.getDictLabel("customer_area", value);
return StringUtils.isEmpty(label) ? value : label;
}
@@ -77,7 +77,7 @@ public class BmsCustomerLogServiceImpl implements IBmsCustomerLogService
/**
* 需要记录日志的主表字段(顺序即展示顺序)。
* requireNonBlank 为 true 的字段对应 update SQL 的 &lt;if test="x!=null and x!=''"&gt;,
* 其余动态字段仅在新值非 null 时落库;业务员/结算员/客服、区域类型为无条件写入。
* 其余动态字段仅在新值非 null 时落库;业务员/结算员/客服、客户区域为无条件写入。
*/
private static final List<FieldDef> FIELD_DEFS = List.of(
new FieldDef("customerCode", "客户编码", BmsCustomer::getCustomerCode, true, Function.identity()),
@@ -85,7 +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("customerArea", "客户区域", BmsCustomer::getCustomerArea, false, BmsCustomerLogServiceImpl::customerAreaLabel),
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),
@@ -208,8 +208,8 @@ public class BmsCustomerLogServiceImpl implements IBmsCustomerLogService
{
// 与 update SQL 的动态条件保持一致:未提交(null/空串)的字段本次不落库,不参与比对
Object raw = def.rawGetter.apply(newCustomer);
// 合同起止、区域类型允许清空;其余动态字段未提交时不落库,也不记日志
if (raw == null && !isContractDateField(def.field) && !"areaType".equals(def.field))
// 合同起止、客户区域允许清空;其余动态字段未提交时不落库,也不记日志
if (raw == null && !isContractDateField(def.field) && !"customerArea".equals(def.field))
{
continue;
}
@@ -60,6 +60,7 @@ public class CustomerSyncService
private static final int LEN_CODE = 50;
private static final int LEN_NAME = 100;
private static final int LEN_CODE_DW = 50;
private static final int LEN_CUSTOMER_AREA = 32;
private static final int LEN_USER = 50;
private static final int LEN_REMARK = 500;
/** 告警明细最多打印条数 */
@@ -178,6 +179,7 @@ public class CustomerSyncService
c.setDelFlag("0");
c.setCustomerCodeDw(truncate(getStr(row, "CUSTOMER_OUTER_CODE"), LEN_CODE_DW, code, "customer_code_dw", warnings));
c.setCustomerArea(truncate(getStr(row, "CUSTOMER_AREA"), LEN_CUSTOMER_AREA, code, "customer_area", warnings));
String sourceSalesCode = clean(getStr(row, "BELONG_SALER"));
c.setSourceSalesCode(sourceSalesCode);
c.setSalesUserId(resolveSalesUserId(sourceSalesCode, userIdsByLogin,
@@ -11,7 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="customerCodeDw" column="customer_code_dw" />
<result property="creditCode" column="credit_code" />
<result property="customerType" column="customer_type" />
<result property="areaType" column="area_type" />
<result property="customerArea" column="customer_area" />
<result property="isEnable" column="is_enable" />
<result property="salesUserId" column="sales_user_id" />
<result property="salesUser" column="sales_user" />
@@ -45,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 账户余额/外币余额统一取 ctr_customer_account 余额表(CNY 为本币,其余为外币),不取 ctr_customer 冗余列 -->
<!-- 信用额度=总额度+额外额度-已用额度-->
<sql id="selectBmsCustomerVo">
select c.customer_id, c.customer_code, c.customer_name, c.customer_code_dw, c.credit_code, c.customer_type, c.area_type,
select c.customer_id, c.customer_code, c.customer_name, c.customer_code_dw, c.credit_code, c.customer_type, c.customer_area,
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,
@@ -92,7 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
<if test="creditCode != null and creditCode != ''"> and c.credit_code = #{creditCode}</if>
<if test="customerType != null and customerType != ''"> and c.customer_type = #{customerType}</if>
<if test="areaType != null and areaType != ''"> and c.area_type = #{areaType}</if>
<if test="customerArea != null and customerArea != ''"> and c.customer_area = #{customerArea}</if>
<if test="isEnable != null and isEnable != ''"> and c.is_enable = #{isEnable}</if>
<if test="salesUserId != null and salesUserId != ''"> and c.sales_user_id = #{salesUserId}</if>
<if test="salesUser != null and salesUser != ''"> and su.nick_name = #{salesUser}</if>
@@ -317,7 +317,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="customerCodeDw != null">customer_code_dw,</if>
<if test="creditCode != null">credit_code,</if>
<if test="customerType != null">customer_type,</if>
<if test="areaType != null">area_type,</if>
<if test="customerArea != null">customer_area,</if>
<if test="isEnable != null">is_enable,</if>
<if test="salesUserId != null">sales_user_id,</if>
<if test="salesUser != null">sales_user,</if>
@@ -350,7 +350,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="customerCodeDw != null">#{customerCodeDw},</if>
<if test="creditCode != null">#{creditCode},</if>
<if test="customerType != null">#{customerType},</if>
<if test="areaType != null">#{areaType},</if>
<if test="customerArea != null">#{customerArea},</if>
<if test="isEnable != null">#{isEnable},</if>
<if test="salesUserId != null">#{salesUserId},</if>
<if test="salesUser != null">#{salesUser},</if>
@@ -387,7 +387,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="customerCodeDw != null">customer_code_dw = #{customerCodeDw},</if>
<if test="creditCode != null">credit_code = #{creditCode},</if>
<if test="customerType != null">customer_type = #{customerType},</if>
area_type = #{areaType},
customer_area = #{customerArea},
<if test="isEnable != null">is_enable = #{isEnable},</if>
sales_user_id = #{salesUserId},
sales_user = #{salesUser},
@@ -30,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
del_flag, create_by, sales_user_id, source_sales_code
<if test="customerCodeDw != null">, customer_code_dw</if>
<if test="customerType != null">, customer_type</if>
<if test="customerArea != null">, customer_area</if>
<if test="salesUser != null">, sales_user</if>
<if test="settlementUser != null">, settlement_user</if>
<if test="serviceUser != null">, service_user</if>
@@ -46,6 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
'0', #{createBy}, #{salesUserId}, #{sourceSalesCode}
<if test="customerCodeDw != null">, #{customerCodeDw}</if>
<if test="customerType != null">, #{customerType}</if>
<if test="customerArea != null">, #{customerArea}</if>
<if test="salesUser != null">, #{salesUser}</if>
<if test="settlementUser != null">, #{settlementUser}</if>
<if test="serviceUser != null">, #{serviceUser}</if>
@@ -66,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="customerName != null">, customer_name = #{customerName}</if>
<if test="customerCodeDw != null">, customer_code_dw = #{customerCodeDw}</if>
<if test="customerType != null">, customer_type = #{customerType}</if>
<if test="customerArea != null">, customer_area = #{customerArea}</if>
, sales_user_id = #{salesUserId}
, source_sales_code = #{sourceSalesCode}
<if test="salesUser != null">, sales_user = #{salesUser}</if>
@@ -10,7 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
BELONG_SALER, BELONG_SALER_NAME, SETTLEMENT_MAN, SERVICE_MAN,
REMARK, WEIGHT_LIMIT, CREDIT_LIMIT, TEMP_AMOUNT,
ACCOUNT_AMOUNT, EUR_AMOUNT,
CUSTOMER_TYPE, CUSTOMER_BALANCE_MODE, BL_OPEN,
CUSTOMER_TYPE, CUSTOMER_AREA, CUSTOMER_BALANCE_MODE, BL_OPEN,
CREATE_DATE, GMT_CREATE
FROM WEISHI_USER.TAB_CUSTOMER
</select>