Răsfoiți Sursa

查看订单详情

lipf 2 luni în urmă
părinte
comite
73d3c75b5f

+ 19 - 2
commons/src/main/java/com/jzg/commons/util/JsonDiffUtil.java

@@ -59,6 +59,10 @@ public class JsonDiffUtil {
             default:
                 // 对于值节点(文本、数字、布尔、null)
                 if (!node1.equals(node2)) {
+                    // 【增强逻辑】:如果前后两个节点都是空(null 或 空字符串),则视为一致,直接过滤掉
+                    if (isEmptyNode(node1) && isEmptyNode(node2)) {
+                        return;
+                    }
                     differences.put(currentPath, Arrays.asList(node1.asText(), node2.asText()));
                 }
                 break;
@@ -68,7 +72,8 @@ public class JsonDiffUtil {
     /**
      * 比较两个JSON对象
      */
-    private static void compareObjects(JsonNode node1, JsonNode node2, String currentPath, Map<String, List<String>> differences, Set<String> ignoreFields) {
+    private static void compareObjects(JsonNode node1, JsonNode node2, String currentPath,
+                                       Map<String, List<String>> differences, Set<String> ignoreFields) {
         Set<String> allFieldNames = new HashSet<>();
         node1.fieldNames().forEachRemaining(allFieldNames::add);
         node2.fieldNames().forEachRemaining(allFieldNames::add);
@@ -98,9 +103,21 @@ public class JsonDiffUtil {
 
         int minSize = Math.min(node1.size(), node2.size());
         for (int i = 0; i < minSize; i++) {
-            // 构建数组元素的路径,例如 "data.imageVoList[0].imageCode"
             String elementPath = currentPath + "[" + i + "]";
             compareNodes(node1.get(i), node2.get(i), elementPath, differences, ignoreFields);
         }
     }
+
+    /**
+     * 【新增辅助方法】判断一个JsonNode是否为空
+     * 满足以下任一条件即视为空:
+     * 1. 节点为 null 或 NullNode
+     * 2. 节点是文本类型且内容为空字符串 ""
+     */
+    private static boolean isEmptyNode(JsonNode node) {
+        if (node == null || node.isNull()) {
+            return true;
+        }
+        return node.isTextual() && node.asText().isEmpty();
+    }
 }

+ 47 - 4
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/aop/OrderOperationLogAspect.java

@@ -278,12 +278,13 @@ public class OrderOperationLogAspect {
         }
         track.setStatus(1);
         if(CollUtil.isNotEmpty(diffMap)){
-            List<String> oldItems = new ArrayList<>(diffMap.keySet());
-            List<String> newItems = new ArrayList<>(diffMap.keySet());
+            List<String> oldItems = new ArrayList<>();
+            List<String> newItems = new ArrayList<>();
+            Map<String,String> keyMap = this.fillKeyNameMap();
             diffMap.forEach((path, values) ->{
                         System.out.println("路径: " + path + " -> 值1: " + values.get(0) + " | 值2: " + values.get(1));
-                        oldItems.add(path + ": " + values.get(0));
-                        newItems.add(path + ": " + values.get(1));
+                        oldItems.add(keyMap.getOrDefault(path,path)  + ": " + values.get(0));
+                        newItems.add(keyMap.getOrDefault(path,path) + ": " + values.get(1));
                     }
             );
             logger.info("oldItem=[{}]", JSONUtil.toJsonStr(oldItems));
@@ -298,6 +299,48 @@ public class OrderOperationLogAspect {
         traceService.save(track);
     }
 
+    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("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","总出口费用");
+        return nameMap;
+    }
+
 
     /**
      * 订单审核(通过/驳回)