xufei 11 months ago
parent
commit
de86fdfe47

File diff suppressed because it is too large
+ 71 - 0
src/main/java/com/winhc/bigdata/udf/case_title.java


+ 135 - 0
src/main/java/com/winhc/bigdata/utils/TitleUtil.java

@@ -0,0 +1,135 @@
+package com.winhc.bigdata.utils;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.*;
+
+/**
+ * @Description: TitleUtil
+ * @Author: xda
+ * @Date: 2020/11/2  09:21
+ */
+public class TitleUtil {
+
+    /**
+     *  案件类型 map
+     */
+    private static final Map<String, String> CASE_TYPE_MAP = new HashMap<>();
+    static {
+        CASE_TYPE_MAP.put("辖", "管辖案件");
+        CASE_TYPE_MAP.put("民", "民事案件");
+        CASE_TYPE_MAP.put("执", "执行案件");
+        CASE_TYPE_MAP.put("行", "行政案件");
+        CASE_TYPE_MAP.put("刑", "刑事案件");
+        CASE_TYPE_MAP.put("赔", "赔偿案件");
+    }
+
+    /**
+     *  label list
+     */
+    private static final List<String> LABEL_LIST = new ArrayList<>(Arrays.asList("裁判文书", "开庭公告", "法院公告", "送达公告", "立案信息"));
+
+    /**
+     *  特殊四个标签
+     */
+    private static final List<String> SPECIAL_LABEL_LIST = new ArrayList<>(Arrays.asList("失信人", "被执行人", "限制高消费", "终本案件"));
+
+    public static String convertTitle(List<String> ygNameList, List<String> bgNameList, List<String> labelList, String caseReason, List<String> caseNoList) {
+        StringBuilder stringBuilder = new StringBuilder();
+        // format yg,bg
+        String ygName = convertNameList(ygNameList);
+        String bgName = convertNameList(bgNameList);
+        if (StringUtils.isBlank(caseReason)) {
+            caseReason = convertCaseType(caseNoList);
+        }
+        // 原告+'与'+ 被告 + 案由
+        // a:原告被告最多取三个,超过的用‘等’
+        // b: 如果只有失信、被执行人,限高,终本 没有原告,显示‘xx被申请执行案件’
+        // c: 如果非失信、被执行人、限高、终本,有原告被告 && 没有案由显示xx、xx 民事案件(根据案号判断是什么类型的案件)
+        // d:如果只有案由,没有原被告,显示案由
+        if (CollectionUtils.isEmpty(ygNameList) && CollectionUtils.isEmpty(bgNameList)) {
+            // 直接返回案由
+            return caseReason;
+        }
+
+        // b
+        // 移除特殊案件标签和普通标签
+        List<String> localList = new ArrayList<>(labelList);
+        CASE_TYPE_MAP.forEach((key, value) -> localList.remove(value));
+        LABEL_LIST.forEach(localList :: remove);
+        if (StringUtils.isBlank(ygName)) {
+            boolean contain = true;
+            // 无原告, 由特殊标签
+            for (String label : localList) {
+                if (!SPECIAL_LABEL_LIST.contains(label)) {
+                    contain = false;
+                    break;
+                }
+            }
+            if (contain) {
+                return stringBuilder.append(bgName).append("被申请执行案件").toString();
+            }
+        }
+        // c
+        if (StringUtils.isNotBlank(ygName) && StringUtils.isNotBlank(bgName) && StringUtils.isBlank(caseReason)) {
+            boolean contain = true;
+            // 有原告被告  无特殊标签
+            for (String label : localList) {
+                if (SPECIAL_LABEL_LIST.contains(label)) {
+                    contain = false;
+                    break;
+                }
+            }
+            if (contain) {
+                return stringBuilder.append(ygName).append("、").append(bgName).append(convertCaseType(caseNoList)).toString();
+            }
+        }
+
+        // 默认展示 原告+'与'+被告+案由
+        stringBuilder.append(ygName);
+        if (StringUtils.isNotBlank(ygName) && StringUtils.isNotBlank(bgName)) {
+            stringBuilder.append("与");
+        }
+        return stringBuilder.append(bgName).append(caseReason).toString();
+    }
+
+    /**
+     * 格式化原被告name
+     * @param list 1
+     * @return java.util.List<java.lang.String>
+     * @Author: xda
+     * @Date: 2020/10/27 11:08
+     */
+    private static String convertNameList(List<String> list) {
+        if (CollectionUtils.isEmpty(list)) {
+            return "";
+        }
+        if (list.size() > 3) {
+            return String.format("%s等", String.join("、", list.subList(0,3)));
+        }
+        return String.join("、", list);
+    }
+
+    /**
+     * 根据案号获取案件类型
+     * @param caseNoList 1
+     * @return java.lang.String
+     * @Author: xda
+     * @Date: 2020/10/27 14:44
+     */
+    private static String convertCaseType(List<String> caseNoList) {
+        caseNoList.remove("");
+        caseNoList.remove(null);
+        if (CollectionUtils.isEmpty(caseNoList)) {
+            return "其它案件";
+        }
+        String caseNo = caseNoList.get(0);
+        for (Map.Entry<String, String> entry : CASE_TYPE_MAP.entrySet()) {
+            if (caseNo.contains(entry.getKey())) {
+                return entry.getValue();
+            }
+        }
+        return "其它案件";
+    }
+}