RemarkUtils.java
3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package cn.com.glsx.entmicro.util;
import cn.com.glsx.entmicro.constants.RegexConstants;
import cn.com.glsx.entmicro.dto.CustomerKafkaDTO;
import cn.com.glsx.entmicro.model.request.CustomerInfoRequest;
import com.glsx.plat.common.utils.StringUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @ClassName RemarkUtils
* @Description
* @Author lichongyuan
* @Date 2022/4/18
*/
public class RemarkUtils {
/**
* 识别备注内容 (只读取第一次匹配到的内容)
*
* @param description 识别字段
* @return
*/
public static CustomerKafkaDTO distinguishMethod(String description) {
// tring palte = "LBV3M210XFME93683,15778727124,车牌号:桂N0005警";
CustomerKafkaDTO customerKafkaDTO = new CustomerKafkaDTO();
//去特殊符号
if (com.glsx.plat.common.utils.StringUtils.isNotBlank(description)) {
String[] split = description.split(RegexConstants.REGEX_SPLIT);
//手机正则
Pattern phoneReg = Pattern.compile(RegexConstants.REGEX_PHONENUM);
//车架号正则
Pattern carVin = Pattern.compile(RegexConstants.REGEX_CARVIN);
//车牌号正则
Pattern newCar = Pattern.compile(RegexConstants.NEW_ENERGY_PLATE_REGEX);
Pattern police = Pattern.compile(RegexConstants.POLICE_PLATE_REGEX);
Pattern wj = Pattern.compile(RegexConstants.WJ_PLATE_REGEX);
Pattern ORDINARY = Pattern.compile(RegexConstants.ORDINARY_LICENSE_PLATE_REGEX);
Pattern pla = Pattern.compile(RegexConstants.PLA__PLATE_REGEX);
//按行匹配
for (String s : split) {
Matcher carVin_m = carVin.matcher(s);
Matcher phoneReg_m = phoneReg.matcher(s);
Matcher newCar_n = newCar.matcher(s);
Matcher police_m = police.matcher(s);
Matcher wj_m = wj.matcher(s);
Matcher ORDINARY_m = ORDINARY.matcher(s);
Matcher pla_m = pla.matcher(s);
//手机号
if (phoneReg_m.find()) {
customerKafkaDTO.setCustomerPhone(phoneReg_m.group());
continue;
}
//车架号
if (carVin_m.find()) {
customerKafkaDTO.setCarVin(carVin_m.group());
continue;
}
//车牌
//新能源牌
if (newCar_n.find()) {
customerKafkaDTO.setCarNumber(newCar_n.group());
continue;
}
//警车车牌
if (police_m.find()) {
customerKafkaDTO.setCarNumber(police_m.group());
continue;
}
//武警车牌
if (wj_m.find()) {
customerKafkaDTO.setCarNumber(wj_m.group());
continue;
}
//普通车牌
if (ORDINARY_m.find()) {
customerKafkaDTO.setCarNumber(ORDINARY_m.group());
continue;
}
//军牌
if (pla_m.find()) {
customerKafkaDTO.setCarNumber(pla_m.group());
continue;
}
}
}
return customerKafkaDTO;
}
}