|
@@ -0,0 +1,225 @@
|
|
|
+package com.winhc.bigdata.udf;
|
|
|
+
|
|
|
+import com.aliyun.odps.udf.UDF;
|
|
|
+import com.aliyun.odps.utils.StringUtils;
|
|
|
+import com.winhc.bigdata.utils.BigDecimalUtil;
|
|
|
+
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.temporal.TemporalAccessor;
|
|
|
+import java.util.regex.Pattern;
|
|
|
+
|
|
|
+import static com.winhc.bigdata.utils.BigDecimalUtil.mul;
|
|
|
+import static com.winhc.bigdata.utils.BigDecimalUtil.subtract;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author: XuJiakai
|
|
|
+ * 2022/8/9 11:25
|
|
|
+ * <p>
|
|
|
+ * judgment_document_score
|
|
|
+ */
|
|
|
+public class JudgmentDocumentScore extends UDF {
|
|
|
+
|
|
|
+
|
|
|
+ public Double evaluate(Long court_level
|
|
|
+ , String new_case_stage
|
|
|
+ , String judge_name
|
|
|
+ , String doc_type
|
|
|
+ , String judge_date
|
|
|
+ , Double der
|
|
|
+ ) {
|
|
|
+
|
|
|
+ String courtLevels = null;
|
|
|
+ if (court_level != null) {
|
|
|
+ if (court_level == 0) {
|
|
|
+ courtLevels = "最高";
|
|
|
+ } else if (court_level == 1) {
|
|
|
+ courtLevels = "高级";
|
|
|
+ } else if (court_level == 2) {
|
|
|
+ courtLevels = "中级";
|
|
|
+ } else if (court_level == 3) {
|
|
|
+ courtLevels = "基层";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String judicialProcedure = null;
|
|
|
+ if (StringUtils.isNotBlank(new_case_stage)) {
|
|
|
+ if (new_case_stage.contains("一审")) {
|
|
|
+ judicialProcedure = "一审";
|
|
|
+ } else if (new_case_stage.contains("二审")) {
|
|
|
+ judicialProcedure = "二审";
|
|
|
+ } else if (new_case_stage.contains("再审审查")) {
|
|
|
+ judicialProcedure = "再审审查";
|
|
|
+ } else if (new_case_stage.contains("再审")) {
|
|
|
+ judicialProcedure = "再审";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return getJudgmentDocumentScore(courtLevels, judicialProcedure, judge_name, doc_type, judge_date, der);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param courtLevels 法院层级:高院、中院……
|
|
|
+ * @param judicialProcedure 审级:一审、二审……
|
|
|
+ * @param judicialOrganization 审判决组织:独任制、三人合议庭、五人合议庭、七人合议庭
|
|
|
+ * @param documentType 文书类型:判决书、裁定书、决定、通知书、令
|
|
|
+ * @param judgmentDate 审判时间
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static Double getJudgmentDocumentScore(String courtLevels
|
|
|
+ , String judicialProcedure
|
|
|
+ , String judicialOrganization
|
|
|
+ , String documentType
|
|
|
+ , String judgmentDate
|
|
|
+ , Double der
|
|
|
+ ) {
|
|
|
+ double score = 0d;
|
|
|
+ if (StringUtils.isNotBlank(courtLevels)) {
|
|
|
+ switch (courtLevels) {
|
|
|
+ case "基层":
|
|
|
+ score += 1;
|
|
|
+ break;
|
|
|
+ case "中级":
|
|
|
+ score += 2;
|
|
|
+ break;
|
|
|
+ case "高级":
|
|
|
+ score += 3;
|
|
|
+ break;
|
|
|
+ case "最高":
|
|
|
+ score += 4;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(judicialProcedure)) {
|
|
|
+ switch (judicialProcedure) {
|
|
|
+ case "再审审查":
|
|
|
+ score += 2.0;
|
|
|
+ break;
|
|
|
+ case "一审":
|
|
|
+ score += 1;
|
|
|
+ break;
|
|
|
+ case "二审":
|
|
|
+ score += 2.5;
|
|
|
+ break;
|
|
|
+ case "再审":
|
|
|
+ score += 2.1;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(judicialOrganization)) {
|
|
|
+ if (!judicialOrganizationPattern.matcher(judicialOrganization).matches()) {
|
|
|
+ try {
|
|
|
+ String[] split = judicialOrganization.split("\n");
|
|
|
+ if (split.length == 1) {
|
|
|
+ judicialOrganization = "独任制";
|
|
|
+ } else if (split.length == 3) {
|
|
|
+ judicialOrganization = "三人合议庭";
|
|
|
+ } else if (split.length == 5) {
|
|
|
+ judicialOrganization = "五人合议庭";
|
|
|
+ } else if (split.length == 7) {
|
|
|
+ judicialOrganization = "七人合议庭";
|
|
|
+ } else {
|
|
|
+ judicialOrganization = "独任制";
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ judicialOrganization = "独任制";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (judicialOrganization) {
|
|
|
+ case "独任制":
|
|
|
+ score += 1;
|
|
|
+ break;
|
|
|
+ case "三人合议庭":
|
|
|
+ score += 2;
|
|
|
+ break;
|
|
|
+ case "五人合议庭":
|
|
|
+ score += 2.1;
|
|
|
+ break;
|
|
|
+ case "七人合议庭":
|
|
|
+ score += 2.2;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(documentType)) {
|
|
|
+ switch (documentType) {
|
|
|
+ case "决定书":
|
|
|
+ case "令":
|
|
|
+ case "通知书":
|
|
|
+ score += 1;
|
|
|
+ break;
|
|
|
+ case "调解书":
|
|
|
+ score += 2;
|
|
|
+ break;
|
|
|
+ case "裁定书":
|
|
|
+ score += 3;
|
|
|
+ break;
|
|
|
+ case "判决书":
|
|
|
+ score += 4;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ score = mul(score, subtract(1d, der)) + mul(getJudgmentDateScore(judgmentDate), der);
|
|
|
+ return score;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static final Pattern judicialOrganizationPattern = Pattern.compile("^(独任制)|([三五七]人合议庭)$");
|
|
|
+
|
|
|
+ private static final DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+
|
|
|
+ private static final Double i = (double) (LocalDate.now().getYear() - 30);
|
|
|
+
|
|
|
+ private static double getJudgmentDateScore(String judgmentDate) {
|
|
|
+ if (StringUtils.isEmpty(judgmentDate)) {
|
|
|
+ return 0d;
|
|
|
+ }
|
|
|
+ if (judgmentDate.contains(" ")) {
|
|
|
+ judgmentDate = judgmentDate.split(" ")[0];
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ TemporalAccessor parse = dtf.parse(judgmentDate);
|
|
|
+ LocalDate from = LocalDate.from(parse);
|
|
|
+ int year = from.getYear();
|
|
|
+ int dayOfYear = from.getDayOfYear();
|
|
|
+ int year_days = from.isLeapYear() ? 366 : 365;
|
|
|
+ double ys = BigDecimalUtil.add(year, BigDecimalUtil.div(dayOfYear, year_days, 8));
|
|
|
+
|
|
|
+ if (ys < i - 1.5) {
|
|
|
+ ys = 1 / (i - ys);
|
|
|
+ } else if (ys >= i + 0.75) {
|
|
|
+ ys = ys - i;
|
|
|
+ } else {
|
|
|
+ ys = 0.75;
|
|
|
+ }
|
|
|
+
|
|
|
+ return Math.log(ys + 1.1d) * 4;
|
|
|
+ } catch (Exception e) {
|
|
|
+ return 0d;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+
|
|
|
+ Double ys = 1992.85;
|
|
|
+
|
|
|
+ if (ys < i - 1.5) {
|
|
|
+ ys = 1 / (i - ys);
|
|
|
+ } else if (ys >= i + 0.75) {
|
|
|
+ ys = ys - i;
|
|
|
+ } else {
|
|
|
+ ys = 0.75;
|
|
|
+ }
|
|
|
+ Double d = Math.log(ys + 1.1d) * 4;
|
|
|
+ System.out.println(d);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|