|
|
@ -85,10 +85,24 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
public static final List<String> controlGroup1 = Arrays.asList("input", "textarea", "datepicker", "daterange"); |
|
|
|
public static final List<String> controlGroup2 = Arrays.asList("select", "radio"); |
|
|
|
|
|
|
|
// 身份证号的正则表达式
|
|
|
|
/** |
|
|
|
* 15位身份证号的正则表达式 |
|
|
|
*/ |
|
|
|
private final Pattern PATTERN_15_ID = Pattern.compile("^\\d{6}(?<year>\\d{2})(?<month>0[1-9]|1[0-2])(?<day>[0-2][0-9]|3[0-1])\\d{2}(?<sex>\\d)$"); |
|
|
|
/** |
|
|
|
* 18位身份证号的正则表达式 |
|
|
|
*/ |
|
|
|
private final Pattern PATTERN_18_ID = Pattern.compile("^\\d{6}(?<year>\\d{4})(?<month>0[1-9]|1[0-2])(?<day>[0-2][0-9]|3[0-1])\\d{2}(?<sex>\\d)[0-9a-xA-X]$"); |
|
|
|
|
|
|
|
/** |
|
|
|
* 日期解析,不含时间 |
|
|
|
*/ |
|
|
|
private final Pattern PATTERN_DATE_PICKER = Pattern.compile("^(\\d{4})[-/](0?[1-9]|1[0-2])[-/](3[0-1]|[0-2]?\\d).*$"); |
|
|
|
/** |
|
|
|
* daterange的解析:1992-01-20,1992-01-30 |
|
|
|
*/ |
|
|
|
private final Pattern PATTERN_DATE_RANGE = Pattern.compile("^(\\d{4})[-/](0?[1-9]|1[0-2])[-/](3[0-1]|[0-2]?\\d).*,(\\d{4})[-/](0?[1-9]|1[0-2])[-/](3[0-1]|[0-2]?\\d).*$"); |
|
|
|
|
|
|
|
/** |
|
|
|
* 身份证号列序号 |
|
|
|
*/ |
|
|
@ -149,7 +163,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
private OssFeignClient ossFeignClient; |
|
|
|
|
|
|
|
/** |
|
|
|
* 字表中不需要的列 |
|
|
|
* 子表中不需要的列。因为主表中需要身份证号,网格等信息,但子表中不需要这些列必填,只要有身份证号即可,因此字表判断的时候需要排除这些列 |
|
|
|
*/ |
|
|
|
private List<String> subTableNeedlessColumns = Arrays.asList("GRID_ID", "VILLAGE_ID", "BUILD_ID", "UNIT_ID", "HOME_ID", |
|
|
|
"IS_BDHJ", "NAME", "MOBILE", "GENDER", "ID_CARD", |
|
|
@ -621,7 +635,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
columnAndValues.put("BIRTHDAY", String.join("-", Arrays.asList(year, month,day))); |
|
|
|
columnAndValues.put("GENDER", isMale ? "1" : "2"); |
|
|
|
columnAndValues.put("IS_OLD_PEOPLE", age >= 60 ? "1" : "0"); |
|
|
|
System.out.println(6); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -695,7 +708,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
String errorMsg; |
|
|
|
if (e instanceof RenException) { |
|
|
|
if (e instanceof RenException || e instanceof EpmetException) { |
|
|
|
errorMsg = e.getMessage(); |
|
|
|
} else { |
|
|
|
errorMsg = "未知系统错误"; |
|
|
@ -792,6 +805,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
|
|
|
|
String notFoundColumnName = null; |
|
|
|
List<String> emptyColumnNames = new ArrayList<>(); |
|
|
|
List<String> patternErrorColumnNames = new ArrayList<>(); |
|
|
|
|
|
|
|
// 这两列要提前放进去,因为有的列未填写的话,会抛异常出去,需要用这两列来做描述
|
|
|
|
target2Insert.put("ID_CARD", row.get(ID_CARD_COLUMN_NO)); |
|
|
@ -823,6 +837,13 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
// 日期控件的数据校验和清晰
|
|
|
|
boolean dateError = dateTypeCheckAndWash(columnWrapper, patternErrorColumnNames); |
|
|
|
if (dateError) { |
|
|
|
hasError = dateError; |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
// "select", "radio"
|
|
|
|
} else if (controlGroup2.contains(columnWrapper.getItemType())){ |
|
|
|
|
|
|
@ -916,10 +937,63 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
sb.append(notFoundColumnName).append("填写的值在系统中未找到"); |
|
|
|
} |
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(patternErrorColumnNames)) { |
|
|
|
sb.append(String.join(",", patternErrorColumnNames)).append("的值格式错误"); |
|
|
|
} |
|
|
|
|
|
|
|
throw new EpmetException(sb.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 处理一下日期类型的数据 |
|
|
|
* @param columnWrapper |
|
|
|
* @param patternErrorColumnNames |
|
|
|
* @return true:有错误,false,没错误 |
|
|
|
*/ |
|
|
|
private boolean dateTypeCheckAndWash(ColumnWrapper columnWrapper, List<String> patternErrorColumnNames) { |
|
|
|
// 日期格式不对的检查
|
|
|
|
String cellContent = columnWrapper.getCellContent(); |
|
|
|
if (StringUtils.isBlank(cellContent)) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if ("datepicker".equals(columnWrapper.getItemType())) { |
|
|
|
Matcher matcher = PATTERN_DATE_PICKER.matcher(cellContent); |
|
|
|
if (matcher.matches()) { |
|
|
|
String year = matcher.group(1); |
|
|
|
String month = matcher.group(2); |
|
|
|
String day = matcher.group(3); |
|
|
|
|
|
|
|
cellContent = String.format("%s-%02d-%02d", year, Integer.parseInt(month), Integer.parseInt(day)); |
|
|
|
columnWrapper.setCellContent(cellContent); |
|
|
|
columnWrapper.setColValue(cellContent); |
|
|
|
} else { |
|
|
|
patternErrorColumnNames.add(columnWrapper.getCombinedLabel()); |
|
|
|
return true; |
|
|
|
} |
|
|
|
} else if ("daterange".equals(columnWrapper.getItemType())) { |
|
|
|
Matcher matcher = PATTERN_DATE_RANGE.matcher(cellContent); |
|
|
|
if (matcher.matches()) { |
|
|
|
String year = matcher.group(1); |
|
|
|
String month = matcher.group(2); |
|
|
|
String day = matcher.group(3); |
|
|
|
String yearEnd = matcher.group(4); |
|
|
|
String monthEnd = matcher.group(5); |
|
|
|
String dayEnd = matcher.group(6); |
|
|
|
|
|
|
|
cellContent = String.format("%s-%02d-%02d,%s-%02d-%02d", year, Integer.parseInt(month), Integer.parseInt(day), yearEnd, Integer.parseInt(monthEnd), Integer.parseInt(dayEnd)); |
|
|
|
columnWrapper.setCellContent(cellContent); |
|
|
|
columnWrapper.setColValue(cellContent); |
|
|
|
} else { |
|
|
|
patternErrorColumnNames.add(columnWrapper.getCombinedLabel()); |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 必填,但是用户没填的,放到list中 |
|
|
|
* @param isPrimaryTable 是否是主表。true:是主表,false:从表 |
|
|
|