|
|
@@ -10,6 +10,9 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
@@ -23,9 +26,9 @@ import java.util.regex.Pattern;
|
|
|
@Component
|
|
|
public class ZijinDuplicateInsuranceComponents {
|
|
|
|
|
|
- public static final String JQ_REGEX = "交强险:.+?起保日期 (.+?);终保日期 (.+?);";
|
|
|
+ public static final String JQ_REGEX = "交强险.+?终保日期 (.+?);";
|
|
|
|
|
|
- public static final String SY_REGEX = "商业险:.+?起保日期 (.+?);终保日期 (.+?);";
|
|
|
+ public static final String SY_REGEX = "商业险.+?终保日期:(.+?);";
|
|
|
|
|
|
private final ZijinRequestApiComponents zijinRequestApiComponents;
|
|
|
|
|
|
@@ -42,10 +45,21 @@ public class ZijinDuplicateInsuranceComponents {
|
|
|
*/
|
|
|
public static String getTheExpiryDate(String message, String regex) {
|
|
|
Pattern pattern = Pattern.compile(regex);
|
|
|
- Matcher m = pattern.matcher(message);
|
|
|
+ Matcher m = pattern.matcher(message.replace("\n", ";"));
|
|
|
boolean b = m.find();
|
|
|
if (b) {
|
|
|
- return m.group(2) + ":00";
|
|
|
+ String group = m.group(1);
|
|
|
+ if (group.contains("-")) {
|
|
|
+ return m.group(1) + ":00";
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmm");
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ return simpleDateFormat.format(dateFormat.parse(m.group(1)));
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new SystemException("时间转换格式失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
throw new SystemException(message);
|
|
|
}
|
|
|
@@ -84,7 +98,7 @@ public class ZijinDuplicateInsuranceComponents {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (jq && sy){
|
|
|
+ if (jq && sy) {
|
|
|
throw new SystemException(rtnMsg);
|
|
|
}
|
|
|
|