Просмотр исходного кода

Merge remote-tracking branch 'origin/dev_jzg_lipf_v20260622'

jiakai 1 месяц назад
Родитель
Сommit
534b86fcd5

+ 41 - 29
commons/src/main/java/com/jzg/commons/util/OrderComponents.java

@@ -9,65 +9,57 @@ public class OrderComponents {
     public static Map<String, String> fillKeyNameMap(){
 
         Map<String,String> nameMap = new HashMap<>();
-        nameMap.put("costRatio.jqExportRatio","交强出口比例");
-        nameMap.put("costRatio.jqFollowRatio","交强跟单比例");
-        nameMap.put("costRatio.jqInletRatio","交强入口比例");
-        nameMap.put("costRatio.jqKeepPointRatio","交强留点比例");
-
 
         nameMap.put("insFeeOrders.jqExportRatio","交强出口比例");
         nameMap.put("insFeeOrders.syExportRatio","商业出口比例");
         nameMap.put("insFeeOrders.jyExportRatio","驾意出口比例");
-
-        nameMap.put("costRatio.syExportRatio","商业出口比例");
-        nameMap.put("costRatio.syFollowRatio","商业跟单比例");
-        nameMap.put("costRatio.syInletRatio","商业入口比例");
-        nameMap.put("costRatio.syKeepPointRatio","商业留点比例");
-
-        nameMap.put("costRatio.jyExportRatio","驾意出口比例");
-        nameMap.put("costRatio.jyFollowRatio","驾意跟单比例");
-        nameMap.put("costRatio.jyInletRatio","驾意入口比例");
-        nameMap.put("costRatio.jyKeepPointRatio","驾意留点比例");
-
         nameMap.put("insFeeOrders.jqExportPremium","交强出口费用");
         nameMap.put("insFeeOrders.jqReceivablePremium","交强应收费用");
         nameMap.put("insFeeOrders.jqKeepPointPremium","交强留点费用");
         nameMap.put("insFeeOrders.jqFollowPremium","交强跟单费用");
         nameMap.put("insFeeOrders.jqPayablePremium","交强应付费用");
-
         nameMap.put("insFeeOrders.syExportPremium","商业出口费用");
         nameMap.put("insFeeOrders.syReceivablePremium","商业应收费用");
         nameMap.put("insFeeOrders.syKeepPointPremium","商业留点费用");
         nameMap.put("insFeeOrders.syFollowPremium","商业跟单费用");
         nameMap.put("insFeeOrders.syPayablePremium","商业应付费用");
-
         nameMap.put("insFeeOrders.jyExportPremium","驾意出口费用");
         nameMap.put("insFeeOrders.jyReceivablePremium","驾意应收费用");
         nameMap.put("insFeeOrders.jyKeepPointPremium","驾意留点费用");
         nameMap.put("insFeeOrders.jyFollowPremium","驾意跟单费用");
         nameMap.put("insFeeOrders.jyPayablePremium","驾意应付费用");
-
         nameMap.put("insFeeOrders.totalReceivablePremium","总应收费用");
         nameMap.put("insFeeOrders.totalPayablePremium","总应付费用");
         nameMap.put("insFeeOrders.totalExportPremium","总出口费用");
-
-        nameMap.put("costRatio.jqCommissionRatio","交强险手续费比例");
-        nameMap.put("costRatio.syCommissionRatio","商业险手续费比例");
-        nameMap.put("costRatio.jyCommissionRatio","驾意险手续费比例");
+        nameMap.put("insFeeOrders.syAdditionalPremium","商业险加投费费费用");
+        nameMap.put("insFeeOrders.jyAdditionalPremium","驾意险加投费费费用");
+        nameMap.put("insFeeOrders.jqAdditionalPremium","交强险加投费费费用");
+        nameMap.put("insFeeOrders.signTime","签单时间");
         nameMap.put("insFeeOrders.jqCommissionPremium","交强险手续费费用");
         nameMap.put("insFeeOrders.syCommissionPremium","商业险手续费费用");
         nameMap.put("insFeeOrders.jyCommissionPremium","驾意险手续费费用");
+        nameMap.put("insFeeOrders.agreementId","协议id");
+
 
+        nameMap.put("costRatio.jqCommissionRatio","交强险手续费比例");
+        nameMap.put("costRatio.syCommissionRatio","商业险手续费比例");
+        nameMap.put("costRatio.jyCommissionRatio","驾意险手续费比例");
         nameMap.put("costRatio.jyAdditionalRatio","驾意险加投比例");
         nameMap.put("costRatio.syAdditionalRatio","商业险加投比例");
         nameMap.put("costRatio.jqAdditionalRatio","交强险加投比例");
-        nameMap.put("insFeeOrders.syAdditionalPremium","商业险加投费费费用");
-        nameMap.put("insFeeOrders.jyAdditionalPremium","驾意险加投费费费用");
-        nameMap.put("insFeeOrders.jqAdditionalPremium","交强险加投费费费用");
+        nameMap.put("costRatio.syExportRatio","商业出口比例");
+        nameMap.put("costRatio.syFollowRatio","商业跟单比例");
+        nameMap.put("costRatio.syInletRatio","商业入口比例");
+        nameMap.put("costRatio.syKeepPointRatio","商业留点比例");
+        nameMap.put("costRatio.jyExportRatio","驾意出口比例");
+        nameMap.put("costRatio.jyFollowRatio","驾意跟单比例");
+        nameMap.put("costRatio.jyInletRatio","驾意入口比例");
+        nameMap.put("costRatio.jyKeepPointRatio","驾意留点比例");
+        nameMap.put("costRatio.jqExportRatio","交强出口比例");
+        nameMap.put("costRatio.jqFollowRatio","交强跟单比例");
+        nameMap.put("costRatio.jqInletRatio","交强入口比例");
+        nameMap.put("costRatio.jqKeepPointRatio","交强留点比例");
 
-        nameMap.put("insFeeOrders.signTime","签单时间");
-        nameMap.put("order.dockingPerson","对接人姓名");
-        nameMap.put("order.dockingPersonPhone","对接人手机号");
 
         nameMap.put("insCompanyVo[0].companyCode","保司编码");
         nameMap.put("insCompanyVo[0].nameSimple","保司简称");
@@ -76,11 +68,31 @@ public class OrderComponents {
         nameMap.put("insCompanyVo[0].name","保司全称");
         nameMap.put("insCompanyVo[0].logo","保司logo");
         nameMap.put("insCompanyVo[0].id","保司ID");
+
+        nameMap.put("order.dockingPerson","对接人姓名");
+        nameMap.put("order.dockingPersonPhone","对接人手机号");
         nameMap.put("order.companyName","保司名称");
         nameMap.put("order.insuranceCompanyCode","保司ID");
+        nameMap.put("order.agreementType","协议类型");
+        nameMap.put("order.agreementName","协议名称");
+        nameMap.put("order.agreementId","协议id");
+
+
         nameMap.put("isProblem","是否是疑问订单");
         nameMap.put("problemReason","疑问订单原因");
         nameMap.put("problemTime","设为疑问订单的时间");
+        nameMap.put("id","订单id");
+
+        nameMap.put("systemCode","租户代码");
+        nameMap.put("parentId","父订单id");
+        nameMap.put("quoteNo","报价订单号");
+        nameMap.put("agreementId","协议ID");
+        nameMap.put("schemeId","方案ID");
+        nameMap.put("apiType","请求类型");
+        nameMap.put("orderStatus","订单状态");
+        nameMap.put("companyOrderNo","保司订单单号");
+        nameMap.put("companyId","保司ID");
+
         return nameMap;
     }
 

+ 118 - 0
commons/src/main/java/com/jzg/commons/util/SchemaDescriptionParser.java

@@ -0,0 +1,118 @@
+package com.jzg.commons.util;
+
+import cn.hutool.core.annotation.Alias;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.json.JSONUtil;
+import com.jzg.commons.entity.quote.vo.aggregated.QuoteEchoVo;
+import io.swagger.v3.oas.annotations.media.Schema;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Field;
+import java.util.*;
+
+public class SchemaDescriptionParser {
+
+    private static final Logger log = LoggerFactory.getLogger(SchemaDescriptionParser.class);
+    /**
+     * 用于存储解析结果的缓存 Map
+     * key: 完全模拟 Hutool JSONUtil.toJsonStr() 序列化后的 Key
+     * value: @Schema 的 description 值;如果没有注解,则 value 等于 key
+     */
+    private static final Map<String, String> SCHEMA_CACHE = new HashMap<>();
+
+    static {
+        try {
+            parseClassHierarchy(QuoteEchoVo.class, null);
+
+            log.info("初始化的SCHEMA_CACHE的大小是[{}]", CollUtil.size(SCHEMA_CACHE));
+            log.info("SCHEMA_CACHE.before=[{}]", JSONUtil.toJsonStr(SCHEMA_CACHE));
+            Map<String, String> otherMap = OrderComponents.fillKeyNameMap();
+            SCHEMA_CACHE.putAll(otherMap);
+            log.info("初始化的SCHEMA_CACHE的大小是[{}]. otherMap.size=[{}]", CollUtil.size(SCHEMA_CACHE), CollUtil.size(otherMap));
+            log.info("SCHEMA_CACHE.after=[{}]", JSONUtil.toJsonStr(SCHEMA_CACHE));
+            log.info("==============");
+            List<String> sortedKeys = new ArrayList<>(SCHEMA_CACHE.keySet()).stream().sorted().toList();
+            for (String sortedKey : sortedKeys) {
+                System.out.println(sortedKey);
+            }
+            log.info("==============");
+
+            log.info(">>>>>>>>>>>>>>>>>>>>>");
+            for (String s : otherMap.keySet().stream().toList().stream().sorted().toList()) {
+                System.out.println(s);
+            }
+            log.info(">>>>>>>>>>>>>>>>>>>>>");
+            log.info("sortedKeys=[{}]", JSONUtil.toJsonStr(sortedKeys));
+
+        } catch (Exception e) {
+            log.error("初始化 Schema 描述映射失败: ",e);
+        }
+    }
+
+    /**
+     * 递归解析类及其内部类
+     */
+    private static void parseClassHierarchy(Class<?> clazz, String parentPrefix) {
+        if (clazz == null || clazz.isPrimitive() || clazz.getName().startsWith("java.")) {
+            return;
+        }
+
+        Field[] fields = clazz.getDeclaredFields();
+
+        for (Field field : fields) {
+            Class<?> fieldType = field.getType();
+
+            // 1. 处理内部类(嵌套对象)
+            if (fieldType.isMemberClass()) {
+                String jsonFieldName = resolveJsonFieldName(field);
+                String newPrefix = (parentPrefix == null ? "" : parentPrefix + ".") + jsonFieldName;
+                parseClassHierarchy(fieldType, newPrefix);
+                continue;
+            }
+
+            // 2. 处理普通字段(无论有没有 @Schema 注解都会收录)
+            String jsonFieldName = resolveJsonFieldName(field);
+            String key = (parentPrefix == null ? "" : parentPrefix + ".") + jsonFieldName;
+
+            // 获取 @Schema 注解的 description
+            Schema schema = field.getAnnotation(Schema.class);
+            String value;
+            if (schema != null && !schema.description().isEmpty()) {
+                value = schema.description();
+            } else {
+                // 没有注解或 description 为空时,value 等于 key
+                value = key;
+            }
+
+            SCHEMA_CACHE.put(key, value);
+        }
+    }
+
+    /**
+     * 解析字段的 JSON Key 名称
+     * 模拟 Hutool JSONUtil.toJsonStr() 的行为:
+     * 1. 优先读取 @Alias 注解的值
+     * 2. 没有 @Alias 注解时,直接使用字段名
+     */
+    private static String resolveJsonFieldName(Field field) {
+        Alias alias = field.getAnnotation(Alias.class);
+        if (alias != null && !alias.value().isEmpty()) {
+            return alias.value();
+        }
+        return field.getName();
+    }
+
+    /**
+     * 获取解析后的 Map (只读)
+     */
+    public static Map<String, String> getSchemaMap() {
+        return Collections.unmodifiableMap(SCHEMA_CACHE);
+    }
+
+    // --- 测试主函数 ---
+    public static void main(String[] args) {
+        Map<String, String> result = SchemaDescriptionParser.getSchemaMap();
+        //result.forEach((k, v) -> System.out.println(k + " = " + v));
+    }
+}

+ 3 - 2
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/aop/OrderOperationLogAspect.java

@@ -18,7 +18,7 @@ import com.jzg.commons.entity.vo.AdjustAllRefundVo;
 import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
 import com.jzg.commons.entity.vo.QuestionOrder;
 import com.jzg.commons.util.JsonDiffUtil;
-import com.jzg.commons.util.OrderComponents;
+import com.jzg.commons.util.SchemaDescriptionParser;
 import com.jzg.quotation.commons.constant.SpElMapping;
 import com.jzg.quotation.commons.utils.SpElFieldExtractor;
 import com.jzg.quotation.summary.aop.aspect.OrderOperationLog;
@@ -293,7 +293,8 @@ public class OrderOperationLogAspect {
         if(CollUtil.isNotEmpty(diffMap)){
             List<String> oldItems = new ArrayList<>();
             List<String> newItems = new ArrayList<>();
-            Map<String,String> keyMap = OrderComponents.fillKeyNameMap();
+            // Map<String,String> keyMap = OrderComponents.fillKeyNameMap();
+            Map<String,String> keyMap = SchemaDescriptionParser.getSchemaMap();
             diffMap.forEach((path, values) ->{
                         System.out.println("路径: " + path + " -> 值1: " + values.get(0) + " | 值2: " + values.get(1));
                         oldItems.add(keyMap.getOrDefault(path,path)  + ": " + values.get(0));

+ 3 - 2
tenant/organization/src/main/java/com/jzg/organization/aop/OrderOperationLogAspect.java

@@ -11,7 +11,7 @@ import com.jzg.commons.entity.orders.po.InsOrdersTrack;
 import com.jzg.commons.entity.quote.vo.aggregated.QuoteEchoVo;
 import com.jzg.commons.entity.vo.QuestionOrder;
 import com.jzg.commons.util.JsonDiffUtil;
-import com.jzg.commons.util.OrderComponents;
+import com.jzg.commons.util.SchemaDescriptionParser;
 import com.jzg.organization.client.InsOrdersClient;
 import com.jzg.quotation.summary.aop.aspect.OrderOperationLog;
 import org.aspectj.lang.ProceedingJoinPoint;
@@ -160,7 +160,8 @@ public class OrderOperationLogAspect {
             if(CollUtil.isNotEmpty(diffMap)){
                 List<String> oldItems = new ArrayList<>();
                 List<String> newItems = new ArrayList<>();
-                Map<String,String> keyMap = OrderComponents.fillKeyNameMap();
+                //Map<String,String> keyMap = OrderComponents.fillKeyNameMap();
+                Map<String,String> keyMap = SchemaDescriptionParser.getSchemaMap();
                 diffMap.forEach((path, values) ->{
                             System.out.println("路径: " + path + " -> 值1: " + values.get(0) + " | 值2: " + values.get(1));
                             oldItems.add(keyMap.getOrDefault(path,path)  + ": " + values.get(0));

+ 18 - 6
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -3841,12 +3841,24 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             // updateAgreementId不为空时,从ins_ply_income(income)查询比例覆盖batchModifyVo,用于后续calRatio和calPremium计算
             // ins_ply_income中的比例是字符串形式的小数值(如"0.20000"),转为BigDecimal后与batchModifyVo.divide100()后的格式一致
             if (StrUtil.isNotBlank(updateAgreementId)) {
-                batchModifyVo.setJqSuperviseCostsProportion(StrUtil.isNotBlank(income.getJqSuperviseCostsProportion()) ? new BigDecimal(income.getJqSuperviseCostsProportion()) : BigDecimal.ZERO);
-                batchModifyVo.setJqOtherCostsProportion(StrUtil.isNotBlank(income.getJqOtherCostsProportion()) ? new BigDecimal(income.getJqOtherCostsProportion()) : BigDecimal.ZERO);
-                batchModifyVo.setSySuperviseCostsProportion(StrUtil.isNotBlank(income.getSySuperviseCostsProportion()) ? new BigDecimal(income.getSySuperviseCostsProportion()) : BigDecimal.ZERO);
-                batchModifyVo.setSyOtherCostsProportion(StrUtil.isNotBlank(income.getSyOtherCostsProportion()) ? new BigDecimal(income.getSyOtherCostsProportion()) : BigDecimal.ZERO);
-                batchModifyVo.setJySuperviseCostsProportion(StrUtil.isNotBlank(income.getJySuperviseCostsProportion()) ? new BigDecimal(income.getJySuperviseCostsProportion()) : BigDecimal.ZERO);
-                batchModifyVo.setJyOtherCostsProportion(StrUtil.isNotBlank(income.getJyOtherCostsProportion()) ? new BigDecimal(income.getJyOtherCostsProportion()) : BigDecimal.ZERO);
+                if (null == batchModifyVo.getJqSuperviseCostsProportion() || BigDecimal.ZERO.compareTo(batchModifyVo.getJqSuperviseCostsProportion()) == 0){
+                    batchModifyVo.setJqSuperviseCostsProportion(StrUtil.isNotBlank(income.getJqSuperviseCostsProportion()) ? new BigDecimal(income.getJqSuperviseCostsProportion()) : BigDecimal.ZERO);
+                }
+                if (null == batchModifyVo.getJqOtherCostsProportion() || BigDecimal.ZERO.compareTo(batchModifyVo.getJqOtherCostsProportion()) == 0) {
+                    batchModifyVo.setJqOtherCostsProportion(StrUtil.isNotBlank(income.getJqOtherCostsProportion()) ? new BigDecimal(income.getJqOtherCostsProportion()) : BigDecimal.ZERO);
+                }
+                if (null == batchModifyVo.getSySuperviseCostsProportion() || BigDecimal.ZERO.compareTo(batchModifyVo.getSySuperviseCostsProportion()) == 0) {
+                    batchModifyVo.setSySuperviseCostsProportion(StrUtil.isNotBlank(income.getSySuperviseCostsProportion()) ? new BigDecimal(income.getSySuperviseCostsProportion()) : BigDecimal.ZERO);
+                }
+                if (null == batchModifyVo.getSyOtherCostsProportion() || BigDecimal.ZERO.compareTo(batchModifyVo.getSyOtherCostsProportion()) == 0) {
+                    batchModifyVo.setSyOtherCostsProportion(StrUtil.isNotBlank(income.getSyOtherCostsProportion()) ? new BigDecimal(income.getSyOtherCostsProportion()) : BigDecimal.ZERO);
+                }
+                if (null == batchModifyVo.getJySuperviseCostsProportion() || BigDecimal.ZERO.compareTo(batchModifyVo.getJySuperviseCostsProportion()) == 0) {
+                    batchModifyVo.setJySuperviseCostsProportion(StrUtil.isNotBlank(income.getJySuperviseCostsProportion()) ? new BigDecimal(income.getJySuperviseCostsProportion()) : BigDecimal.ZERO);
+                }
+                if (null == batchModifyVo.getJyOtherCostsProportion() || BigDecimal.ZERO.compareTo(batchModifyVo.getJyOtherCostsProportion()) == 0) {
+                    batchModifyVo.setJyOtherCostsProportion(StrUtil.isNotBlank(income.getJyOtherCostsProportion()) ? new BigDecimal(income.getJyOtherCostsProportion()) : BigDecimal.ZERO);
+                }
                 log.info("切换协议后,从ins_ply_income查询比例覆盖batchModifyVo。orderNo=[{}], batchModifyVo=[{}]", income.getOrderNo(), JSONUtil.toJsonStr(batchModifyVo));
             }