|
@@ -1,9 +1,11 @@
|
|
package com.winhc.bigdata.udf.justice;
|
|
package com.winhc.bigdata.udf.justice;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.aliyun.odps.udf.ExecutionContext;
|
|
import com.aliyun.odps.udf.ExecutionContext;
|
|
import com.aliyun.odps.udf.UDF;
|
|
import com.aliyun.odps.udf.UDF;
|
|
import com.aliyun.odps.udf.UDFException;
|
|
import com.aliyun.odps.udf.UDFException;
|
|
import com.winhc.bigdata.bean.case_no.CaseNoRegionInfoEntity;
|
|
import com.winhc.bigdata.bean.case_no.CaseNoRegionInfoEntity;
|
|
|
|
+import com.winhc.bigdata.utils.BaseUtils;
|
|
import com.winhc.bigdata.utils.CaseNoRegionUtils;
|
|
import com.winhc.bigdata.utils.CaseNoRegionUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
@@ -14,7 +16,7 @@ import java.util.stream.Collectors;
|
|
/**
|
|
/**
|
|
* @Author: XuJiakai
|
|
* @Author: XuJiakai
|
|
* 2023/11/6 9:54
|
|
* 2023/11/6 9:54
|
|
- *
|
|
|
|
|
|
+ * <p>
|
|
* function name: case_no_area_code
|
|
* function name: case_no_area_code
|
|
*/
|
|
*/
|
|
public class CaseNoRegionInfoUDF extends UDF {
|
|
public class CaseNoRegionInfoUDF extends UDF {
|
|
@@ -31,31 +33,39 @@ public class CaseNoRegionInfoUDF extends UDF {
|
|
case_no_keyword_map = caseNoRegionInfo;
|
|
case_no_keyword_map = caseNoRegionInfo;
|
|
|
|
|
|
|
|
|
|
- Map<String, CaseNoRegionInfoEntity> collect = caseNoRegionInfo.values().stream().collect(Collectors.toMap(CaseNoRegionInfoEntity::getCourt_name, e -> e,(e1,e2)->{
|
|
|
|
|
|
+ Map<String, CaseNoRegionInfoEntity> collect = caseNoRegionInfo.values().stream().collect(Collectors.toMap(CaseNoRegionInfoEntity::getCourt_name, e -> e, (e1, e2) -> {
|
|
return e1;
|
|
return e1;
|
|
}));
|
|
}));
|
|
court_name_map = collect;
|
|
court_name_map = collect;
|
|
}
|
|
}
|
|
|
|
|
|
- public List<String> evaluate(String case_no, String court_name) {
|
|
|
|
- List<String> list = new ArrayList<String>(3);
|
|
|
|
- String caseNoKeyword = getCaseNoKeyword(case_no);
|
|
|
|
- if (caseNoKeyword != null && case_no_keyword_map.containsKey(caseNoKeyword)) {
|
|
|
|
- CaseNoRegionInfoEntity caseNoRegionInfoEntity = case_no_keyword_map.get(caseNoKeyword);
|
|
|
|
- list.set(0, caseNoRegionInfoEntity.getProvince_code());
|
|
|
|
- list.set(1, caseNoRegionInfoEntity.getCity_code());
|
|
|
|
- list.set(2, caseNoRegionInfoEntity.getDistrict_code());
|
|
|
|
- return list;
|
|
|
|
|
|
+ public String evaluate(String case_no, String court_name) {
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ CaseNoRegionInfoEntity caseNoRegionInfoEntity = null;
|
|
|
|
+ if (StringUtils.isNotEmpty(court_name) && court_name_map.containsKey(court_name)) {
|
|
|
|
+ caseNoRegionInfoEntity = court_name_map.get(court_name);
|
|
}
|
|
}
|
|
|
|
|
|
- if (StringUtils.isNotEmpty(court_name) && court_name_map.containsKey(court_name)) {
|
|
|
|
- CaseNoRegionInfoEntity caseNoRegionInfoEntity = court_name_map.get(court_name);
|
|
|
|
- list.set(0, caseNoRegionInfoEntity.getProvince_code());
|
|
|
|
- list.set(1, caseNoRegionInfoEntity.getCity_code());
|
|
|
|
- list.set(2, caseNoRegionInfoEntity.getDistrict_code());
|
|
|
|
- return list;
|
|
|
|
|
|
+ String caseNoKeyword = getCaseNoKeyword(case_no);
|
|
|
|
+ if (caseNoRegionInfoEntity == null && caseNoKeyword != null && case_no_keyword_map.containsKey(caseNoKeyword)) {
|
|
|
|
+ caseNoRegionInfoEntity = case_no_keyword_map.get(caseNoKeyword);
|
|
}
|
|
}
|
|
- return list;
|
|
|
|
|
|
+ if (caseNoRegionInfoEntity == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ jsonObject.put("province_code", caseNoRegionInfoEntity.getProvince_code());
|
|
|
|
+ jsonObject.put("city_code", caseNoRegionInfoEntity.getCity_code());
|
|
|
|
+ jsonObject.put("district_code", caseNoRegionInfoEntity.getDistrict_code());
|
|
|
|
+ jsonObject.put("province", caseNoRegionInfoEntity.getProvince());
|
|
|
|
+ jsonObject.put("city", caseNoRegionInfoEntity.getCity());
|
|
|
|
+ jsonObject.put("district", caseNoRegionInfoEntity.getDistrict());
|
|
|
|
+ jsonObject.put("court_level", caseNoRegionInfoEntity.getCourt_level());
|
|
|
|
+ jsonObject.put("court_code", caseNoRegionInfoEntity.getCourt_code());
|
|
|
|
+ jsonObject.put("superior_court_code", caseNoRegionInfoEntity.getSuperior_court_code());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return BaseUtils.toString(jsonObject);
|
|
}
|
|
}
|
|
|
|
|
|
private String getCaseNoKeyword(String case_no) {
|
|
private String getCaseNoKeyword(String case_no) {
|
|
@@ -73,6 +83,7 @@ public class CaseNoRegionInfoUDF extends UDF {
|
|
public static void main(String[] args) throws UDFException, IOException {
|
|
public static void main(String[] args) throws UDFException, IOException {
|
|
CaseNoRegionInfoUDF caseNoRegionInfoUDF = new CaseNoRegionInfoUDF();
|
|
CaseNoRegionInfoUDF caseNoRegionInfoUDF = new CaseNoRegionInfoUDF();
|
|
caseNoRegionInfoUDF.setup(null);
|
|
caseNoRegionInfoUDF.setup(null);
|
|
|
|
+ System.out.println(caseNoRegionInfoUDF.evaluate("XXX沪XXX", ""));
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|