wangxianzhang 3 years ago
parent
commit
7cb2021e4e
  1. 27
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/IdCardTypeEnum.java
  2. 30
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/processor/MaskProcessor.java
  3. 133
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/IdCardRegexUtils.java
  4. 2
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiVolunteerAuthenticateFormDTO.java
  5. 8
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java
  6. 2
      epmet-module/gov-grid/gov-grid-client/src/main/java/com/epmet/dto/form/SaveOrUpdateParyMemberFormDTO.java
  7. 10
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/mine/controller/PersonalCenterController.java
  8. 9
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java
  9. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcFollowUpRecordDTO.java
  10. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddIcVaccineFormDTO.java
  11. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditInfoFormDTO.java
  12. 4
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcMoveInAddEditFormDTO.java
  13. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcNoticeFormDTO.java
  14. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcTripReportFormDTO.java
  15. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/InfoSubmitFromDTO.java
  16. 4
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PageFollowUpFormDTO.java
  17. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/CollectListMemberExcelResultDTO.java
  18. 16
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiCollectController.java
  19. 9
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiCollectVisitorController.java
  20. 18
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  21. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcTripReportRecordController.java
  22. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiUserEntity.java
  23. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ChangeDeathExcel.java
  24. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ChangeRelocationExcel.java
  25. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ChangeWelfareExcel.java
  26. 12
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcBirthRecordServiceImpl.java
  27. 12
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcMoveInRecordServiceImpl.java
  28. 94
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java
  29. 25
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
  30. 13
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java
  31. BIN
      epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_import_template.xls

27
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/IdCardTypeEnum.java

@ -0,0 +1,27 @@
package com.epmet.commons.tools.enums;
/**
* 唯一整件类型
*/
public enum IdCardTypeEnum {
OTHERS("0", "其他"),
SFZH("1", "身份证号"),
PASSPORT("2", "护照");
private String type;
private String name;
IdCardTypeEnum(String type, String name) {
this.type = type;
this.name = name;
}
public String getType() {
return type;
}
public String getName() {
return name;
}
}

30
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/processor/MaskProcessor.java

@ -2,8 +2,10 @@ package com.epmet.commons.tools.processor;
import cn.hutool.core.util.StrUtil;
import com.epmet.commons.tools.annotation.MaskResponse;
import com.epmet.commons.tools.enums.IdCardTypeEnum;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.IdCardRegexUtils;
import com.epmet.commons.tools.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@ -13,6 +15,7 @@ import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
/**
* desc:脱敏处理器
@ -136,21 +139,34 @@ public class MaskProcessor {
}
/**
* 唯一整件号打码可能是身份证号或者是护照号
* 将明文字符串打码变为掩码保留前6后面打码
* @param originString
* @return
*/
private String maskIdCard(String originString) {
int clearTextLength = 12;
// 仅将6位之后的全都打码
int length = originString.length();
if (length <= clearTextLength) {
IdCardRegexUtils regexUtil = IdCardRegexUtils.parse(originString);
if (regexUtil == null) {
// 不匹配任何类型,不码
return originString;
}
String maskStr = StrUtil.repeatByLength("*", length - clearTextLength);
return originString.replaceAll("^(\\d{10})\\d+([a-zA-Z0-9]{2})$", new StringBuilder("$1").append(maskStr).append("$2").toString());
if (regexUtil.getTypeEnum() == IdCardTypeEnum.SFZH) {
// 身份证号
// 仅将6位之后的全都打码
int maskedTextLength = 12;
int length = originString.length();
String maskStr = StrUtil.repeatByLength("*", length - maskedTextLength);
return originString.replaceAll("^(\\d{10})\\d+([a-zA-Z0-9]{2})$", new StringBuilder("$1").append(maskStr).append("$2").toString());
} else if (regexUtil.getTypeEnum() == IdCardTypeEnum.PASSPORT) {
// 护照,前两位,后两位为明文,其他*
String maskStr = StrUtil.repeatByLength("*", originString.length() - 4);
return originString.replaceAll("^([a-zA-Z0-9]{2})\\d+(\\d{2})$", new StringBuilder("$1").append(maskStr).append("$2").toString());
} else {
// 其他情况,不码
return originString;
}
}
/**

133
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/IdCardRegexUtils.java

@ -0,0 +1,133 @@
package com.epmet.commons.tools.utils;
import com.epmet.commons.tools.enums.IdCardTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 唯一整件正则工具
*/
public class IdCardRegexUtils {
/**
* 15位身份证号的正则表达式
*/
private static 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 static 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]$");
/**
* 9位护照
*/
private static final Pattern PATTERN_9_PASSPORT = Pattern.compile("^[a-zA-Z]{2}\\d{7}$|^[a-zA-Z]{1}\\d{8}$");
private String inputText;
private Matcher matcher;
private IdCardTypeEnum idCardType;
private IdCardRegexUtils(IdCardTypeEnum idCardType, Matcher matcher, String inputText) {
this.idCardType = idCardType;
this.matcher = matcher;
this.inputText = inputText;
}
/**
* 正则解析结果
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class ParsedContent {
private String birthdayYear;
private String birthdayMonth;
private String birthdayDay;
private String sex;
}
/**
* desc:校验输入的证件号是否合法
* @param input
* @return
*/
public static boolean validateIdCard(String input){
IdCardRegexUtils parse = IdCardRegexUtils.parse(input);
return parse != null;
}
/**
* 解析正则
* @param input
* @return
*/
public static IdCardRegexUtils parse(String input) {
if (input == null || input.trim().length() == 0) {
return null;
}
if (input.length() == 15) {
Matcher matcher = PATTERN_15_ID.matcher(input);
if (matcher.matches()) {
return new IdCardRegexUtils(IdCardTypeEnum.SFZH, matcher, input);
}
}
if (input.length() == 18) {
Matcher matcher = PATTERN_18_ID.matcher(input);
if (matcher.matches()) {
return new IdCardRegexUtils(IdCardTypeEnum.SFZH, matcher, input);
}
}
if (input.length() == 9) {
Matcher matcher = PATTERN_9_PASSPORT.matcher(input);
if (matcher.matches()) {
return new IdCardRegexUtils(IdCardTypeEnum.PASSPORT, matcher, input);
}
}
return null;
}
/**
* 获取解析结果
* @return
*/
public ParsedContent getParsedResult() {
if (matcher == null || idCardType == null) {
return null;
}
if (IdCardTypeEnum.SFZH == idCardType) {
//是身份证号,可以解析
String year;
if (inputText.length() == 15) {
// 15位身份证号,years前需要拼上19
year = "19".concat(matcher.group("year"));
} else {
year = matcher.group("year");
}
String month = matcher.group("month");
String day = matcher.group("day");
String sex = matcher.group("sex");
return new ParsedContent(year, month, day, sex);
}
// 其他类型暂时不可解析
return null;
}
/**
* 获取类型枚举
* @return
*/
public IdCardTypeEnum getTypeEnum() {
return idCardType;
}
}

2
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiVolunteerAuthenticateFormDTO.java

@ -59,7 +59,7 @@ public class ResiVolunteerAuthenticateFormDTO implements Serializable {
/**
* 身份证号码
*/
@NotBlank(message = "身份证号码不能为空", groups = {AddUserShowGroup.class })
@NotBlank(message = "证号能为空", groups = {AddUserShowGroup.class })
private String idNum;
/**

8
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java

@ -22,6 +22,7 @@ import com.epmet.commons.tools.dto.form.mq.MqBaseFormDTO;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.IdCardRegexUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constant.SystemMessageType;
@ -38,6 +39,7 @@ import com.epmet.dto.result.resi.ResiVolunteerInfoResultDTO;
import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.send.SendMqMsgUtil;
import com.epmet.service.VolunteerInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -72,6 +74,12 @@ public class ResiVolunteerController {
formDTO.setUserId(tokenDto.getUserId());
formDTO.setCustomerId(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(formDTO, ResiVolunteerAuthenticateFormDTO.AddUserShowGroup.class, ResiVolunteerAuthenticateFormDTO.AddUserInternalGroup.class);
if (StringUtils.isNotBlank(formDTO.getIdNum())){
boolean b = IdCardRegexUtils.validateIdCard(formDTO.getIdNum());
if (!b){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"请输入正确的证件号","请输入正确的证件号");
}
}
volunteerInfoService.authenticate(formDTO);
//发送志愿者人员消息变动

2
epmet-module/gov-grid/gov-grid-client/src/main/java/com/epmet/dto/form/SaveOrUpdateParyMemberFormDTO.java

@ -31,7 +31,7 @@ public class SaveOrUpdateParyMemberFormDTO implements Serializable {
@NotBlank(message = "姓名不能为空", groups = {AddUserShowGroup.class})
private String name;
@NotBlank(message = "身份证不能为空", groups = {AddUserShowGroup.class})
@NotBlank(message = "证件号不能为空", groups = {AddUserShowGroup.class})
private String idCard;
@NotBlank(message = "手机号不能为空", groups = {AddUserShowGroup.class})

10
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/mine/controller/PersonalCenterController.java

@ -1,7 +1,10 @@
package com.epmet.modules.mine.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.IdCardRegexUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.EditInfoFormDTO;
@ -10,6 +13,7 @@ import com.epmet.dto.form.SendCodeFormDTO;
import com.epmet.modules.mine.service.PersonalCenterService;
import com.epmet.resi.mine.dto.result.InitInfoResultDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -55,6 +59,12 @@ public class PersonalCenterController {
formDTO.setUserId(tokenDto.getUserId());
formDTO.setCustomerId(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(formDTO,EditInfoFormDTO.AddUserShowGroup.class,EditInfoFormDTO.AddUserInternalGroup.class);
if (StringUtils.isNotBlank(formDTO.getIdNum())){
boolean b = IdCardRegexUtils.validateIdCard(formDTO.getIdNum());
if (!b){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"请输入正确的证件号","请输入正确的证件号");
}
}
personalCenterService.editInfo(tokenDto, formDTO);
return new Result();
}

9
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java

@ -10,6 +10,7 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.bean.GridInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.IdCardRegexUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.*;
import com.epmet.dto.*;
@ -167,6 +168,14 @@ public class PartyMemberConfirmServiceImpl implements PartyMemberConfirmService
@Transactional(rollbackFor = Exception.class)
public Result submit(PartymemberInfoDTO partyMemberInfoDTO) {
log.info("submit param:{}",JSON.toJSONString(partyMemberInfoDTO));
// 证件类型判断----start----
IdCardRegexUtils regex = IdCardRegexUtils.parse(partyMemberInfoDTO.getIdCard());
if (regex == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "证件号解析错误", "证件号解析错误");
}
// 证件类型判断----end----
Result result = new Result();
//校验手机验证码是否正常

2
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcFollowUpRecordDTO.java

@ -67,7 +67,7 @@ public class IcFollowUpRecordDTO implements Serializable {
*/
@ColumnWidth(25)
@ExcelProperty("身份证号")
@NotBlank(message = "身份证号不能为空", groups = {AddUserRequired.class})
@NotBlank(message = "证号不能为空", groups = {AddUserRequired.class})
private String idCard;
/**

2
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddIcVaccineFormDTO.java

@ -56,7 +56,7 @@ public class AddIcVaccineFormDTO implements Serializable {
/**
* 身份证号
*/
@NotBlank(message = "身份证号不能为空", groups = Vaccine.class)
@NotBlank(message = "证号不能为空", groups = Vaccine.class)
private String idCard;
/**
* 接种时间

2
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditInfoFormDTO.java

@ -47,7 +47,7 @@ public class EditInfoFormDTO implements Serializable {
private String name;
//@NotBlank(message = "身份证号不能为空")
@Length(max=18,message = "身份证号不能超过18位",groups = AddUserShowGroup.class)
@Length(max=18,message = "证号不能超过18位",groups = AddUserShowGroup.class)
//别的小程序不统一升级,没办法限制必填。
private String idNum;

4
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcMoveInAddEditFormDTO.java

@ -71,8 +71,8 @@ public class IcMoveInAddEditFormDTO implements Serializable {
/**
* 身份证号
*/
@NotBlank(message = "身份证号不能为空", groups = {AddGroup.class})
@Length(min = 15, max = 18, message = "身份证号位数不正确", groups = AddGroup.class)
@NotBlank(message = "证号不能为空", groups = {AddGroup.class})
@Length(min = 9, max = 18, message = "证号位数不正确", groups = AddGroup.class)
private String idCard;
/**
* 性别1男2女0未知

2
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcNoticeFormDTO.java

@ -17,6 +17,6 @@ public class IcNoticeFormDTO extends PageFormDTO implements Serializable {
private static final long serialVersionUID = 7392894573654015338L;
private String customerId;
private String noticeId;
@NotBlank(message = "身份证号不能为空", groups = DefaultGroup.class)
@NotBlank(message = "证号不能为空", groups = DefaultGroup.class)
private String idCard;
}

2
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcTripReportFormDTO.java

@ -57,7 +57,7 @@ public class IcTripReportFormDTO implements Serializable {
/**
* 身份证号
*/
@NotBlank(message = "身份证号能为空", groups = {ResiUserRequired.class,PcAddRequired.class,PcUpdateRequired.class})
@NotBlank(message = "证号能为空", groups = {ResiUserRequired.class,PcAddRequired.class,PcUpdateRequired.class})
private String idCard;
/**

2
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/InfoSubmitFromDTO.java

@ -57,7 +57,7 @@ public class InfoSubmitFromDTO implements Serializable {
private String name;
//@NotBlank(message = "身份证号不能为空")
@Length(max=18,message = "身份证号不能超过18位")
@Length(max=18,message = "证号不能超过18位")
//别的小程序不统一升级,没办法限制必填。
private String idNum;

4
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PageFollowUpFormDTO.java

@ -12,10 +12,10 @@ public class PageFollowUpFormDTO extends PageFormDTO {
/**
* 身份证号
*/
@NotBlank(message = "身份证号不能为空", groups = {AddUserShowGroup.class})
@NotBlank(message = "证号不能为空", groups = {AddUserShowGroup.class})
private String idCard;
@NotBlank(message = "身份证号不能为空", groups = {AddUserShowGroup.class})
@NotBlank(message = "证号不能为空", groups = {AddUserShowGroup.class})
private String name;
/**

2
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/CollectListMemberExcelResultDTO.java

@ -24,7 +24,7 @@ public class CollectListMemberExcelResultDTO implements Serializable {
/**
* 成员身份证
*/
@Excel(name = "成员身份证号", width = 30)
@Excel(name = "成员证号", width = 30)
private String memberIdNum;
/**

16
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiCollectController.java

@ -4,15 +4,19 @@ import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.annotation.MaskResponse;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.IdCardRegexUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.service.IcResiCollectService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -180,6 +184,18 @@ public class IcResiCollectController {
//效验数据
ValidatorUtils.validateEntity(formDTO);
formDTO.setOrigin("internal");//固定为内部
// 证件类型判断----start----
for (IcResiCollectMemFormDTO member : formDTO.getMemberList()) {
if (StringUtils.isNotBlank(member.getIdNum())) {
IdCardRegexUtils regex = IdCardRegexUtils.parse(member.getIdNum());
if (regex == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "证件号解析错误", "证件号解析错误");
}
}
}
// 证件类型判断----end----
return icResiCollectService.saveCollectInfo(formDTO);
}

9
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiCollectVisitorController.java

@ -2,9 +2,12 @@ package com.epmet.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.IdCardRegexUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
@ -115,6 +118,12 @@ public class IcResiCollectVisitorController {
public Result saveInfo(@RequestBody SaveCollectVisitorFormDTO dto) {
//效验数据
ValidatorUtils.validateEntity(dto);
// 证件类型判断----start----
IdCardRegexUtils regex = IdCardRegexUtils.parse(dto.getIdCard());
if (regex == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "证件号解析错误", "证件号解析错误");
}
// 证件类型判断----end----
return icResiCollectVisitorService.saveInfo(dto);
}

18
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

@ -307,12 +307,30 @@ public class IcResiUserController implements ResultDataResolver {
*/
@PostMapping("rent/updateimage")
public Result updateImage(@LoginUser TokenDto tokenDto, @RequestBody RentTenantFormDTO formDTO) {
// 身份证号验证
if (StringUtils.isNotBlank(formDTO.getUser().getIdCard())) {
checkIdCard(formDTO.getUser().getIdCard());
}
if (StringUtils.isNotBlank(formDTO.getIdCard())) {
checkIdCard(formDTO.getIdCard());
}
String resiUserId = icResiUserService.updateImage(tokenDto, formDTO);
//推送MQ事件
editResiMq(formDTO.getCustomerId(), resiUserId);
return new Result();
}
private void checkIdCard(String idCard) {
// 证件类型判断----start----
IdCardRegexUtils regex = IdCardRegexUtils.parse(idCard);
if (regex == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "证件号解析错误", "证件号解析错误");
}
}
private void editResiMq(String customerId, String userId) {
//推送MQ事件
IcResiUserAddMQMsg mqMsg = new IcResiUserAddMQMsg();

7
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcTripReportRecordController.java

@ -33,6 +33,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
@ -159,6 +160,12 @@ public class IcTripReportRecordController implements ResultDataResolver {
formDTO.setUserId(tokenDto.getUserId());
formDTO.setUserType(IcResiUserConstant.USER_TYPE_RESI);
ValidatorUtils.validateEntity(formDTO,IcTripReportFormDTO.ResiUserRequired.class,IcTripReportFormDTO.ResiUserInternalGroup.class);
if (StringUtils.isNotBlank(formDTO.getIdCard())){
boolean b = IdCardRegexUtils.validateIdCard(formDTO.getIdCard());
if (!b){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"请输入正确的证件号","请输入正确的证件号");
}
}
return new Result().ok(icTripReportRecordService.resiSave(formDTO));
}

7
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiUserEntity.java

@ -96,10 +96,15 @@ public class IcResiUserEntity extends BaseEpmetEntity {
private String gender;
/**
* 身份证号
*
*/
private String idCard;
/**
* 证件类型1身份证号2护照
*/
private String idCardType;
/**
* 出生日期
*/

2
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ChangeDeathExcel.java

@ -23,7 +23,7 @@ public class ChangeDeathExcel {
@Excel(name = "姓名")
private String name;
@Excel(name = "身份证")
@Excel(name = "证件号")
private String idCard;
@Excel(name = "手机号")

2
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ChangeRelocationExcel.java

@ -32,7 +32,7 @@ public class ChangeRelocationExcel {
@Excel(name = "手机号")
private String mobile;
@Excel(name = "身份证号")
@Excel(name = "证号")
private String idCard;
@Excel(name = "性别")

2
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/ChangeWelfareExcel.java

@ -24,7 +24,7 @@ public class ChangeWelfareExcel {
@Excel(name = "姓名")
private String name;
@Excel(name = "身份证")
@Excel(name = "证件号")
private String idCard;
@Excel(name = "手机号")

12
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcBirthRecordServiceImpl.java

@ -7,12 +7,15 @@ import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.enums.GenderEnum;
import com.epmet.commons.tools.enums.IcResiUserSubStatusEnum;
import com.epmet.commons.tools.enums.IdCardTypeEnum;
import com.epmet.commons.tools.enums.RelationshipEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.IdCardRegexUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcBirthRecordDao;
import com.epmet.dao.IcResiUserDao;
@ -144,6 +147,15 @@ public class IcBirthRecordServiceImpl extends BaseServiceImpl<IcBirthRecordDao,
userEntity.setStatus(NumConstant.ZERO_STR);
userEntity.setSubStatus(IcResiUserSubStatusEnum.BIRTH.getSubStatus());
// 证件类型判断----start----
IdCardRegexUtils regex = IdCardRegexUtils.parse(dto.getIdCard());
if (regex == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "证件号解析错误", "证件号解析错误");
}
IdCardTypeEnum typeEnum = regex.getTypeEnum();
userEntity.setIdCardType(typeEnum.getType());
// 证件类型判断----end----
//判断是否有所属组织,如果有,判断是否属于当前组织,没有的话则直接新增
if (StringUtils.isNotEmpty(sync.getIcResiUserId())) {
userEntity.setId(sync.getIcResiUserId());

12
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcMoveInRecordServiceImpl.java

@ -5,6 +5,7 @@ import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.enums.DictTypeEnum;
import com.epmet.commons.tools.enums.IcResiUserSubStatusEnum;
import com.epmet.commons.tools.enums.IdCardTypeEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
@ -12,6 +13,7 @@ import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.redis.common.bean.GridInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.IdCardRegexUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcMoveInRecordDao;
import com.epmet.dto.ChangeWelfareDTO;
@ -168,6 +170,16 @@ public class IcMoveInRecordServiceImpl extends BaseServiceImpl<IcMoveInRecordDao
IcResiUserEntity entity = ConvertUtils.sourceToTarget(formDTO, IcResiUserEntity.class);
//状态改为0正常
entity.setStatus(NumConstant.ZERO_STR);
// 证件类型判断----start----
IdCardRegexUtils regex = IdCardRegexUtils.parse(formDTO.getIdCard());
if (regex == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "证件号解析错误", "证件号解析错误");
}
IdCardTypeEnum typeEnum = regex.getTypeEnum();
entity.setIdCardType(typeEnum.getType());
// 证件类型判断----end----
//4-1.本社区下正常状态居民且房屋不一样并选择了更新【只更新居民信息,插入调动记录,生成变更记录,不生成变更明细】
if (StringUtils.isNotBlank(resiDTO.getResiAgencyId()) && staffInfo.getAgencyId().equals(resiDTO.getResiAgencyId())
&& "0".equals(resiDTO.getStatus()) && !resiDTO.getResiHomeId().equals(formDTO.getHomeId())

94
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java

@ -18,6 +18,7 @@ import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.dto.result.OptionResultDTO;
import com.epmet.commons.tools.enums.IcResiUserSubStatusEnum;
import com.epmet.commons.tools.enums.IdCardTypeEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils;
@ -89,15 +90,6 @@ 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", "cascader");
/**
* 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]$");
/**
* 日期解析不含时间
*/
@ -233,7 +225,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
private String tableName;
@Excel(name = "身份证号", width = 40)
@Excel(name = "证号", width = 40)
private String idCard;
@Excel(name = "姓名", width = 25)
@ -623,14 +615,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
if (StringUtils.isBlank(idCard)) {
log.debug("【居民信息导入】specifiedCheck身份证号为空的:{},{}", mobile, name);
String errorMsg = "身份证号不能为空";
String errorMsg = "证号不能为空";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg);
}
if (idCard.length() != 18 && idCard.length() != 15) {
errors.add("身份证号长度错误");
}
if (StringUtils.isNotBlank(mobile) && mobile.length() > 15) {
errors.add("手机号长度错误");
}
@ -642,52 +630,48 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
}
// ================== 数据补充 ===================
String year;
String month;
String day;
String sex;
IdCardRegexUtils regexUtilInstance = IdCardRegexUtils.parse(idCard);
if (regexUtilInstance == null) {
String s = "请输入正确的证件号";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), s, s);
}
if (idCard.length() == 15) {
Matcher matcher = PATTERN_15_ID.matcher(idCard);
if (matcher.matches()) {
year = "19".concat(matcher.group("year"));
month = matcher.group("month");
day = matcher.group("day");
sex = matcher.group("sex");
} else {
String s = "身份证号解析错误";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), s, s);
}
} else if (idCard.length() == 18) {
Matcher matcher = PATTERN_18_ID.matcher(idCard);
if (matcher.matches()) {
year = matcher.group("year");
month = matcher.group("month");
day = matcher.group("day");
sex = matcher.group("sex");
} else {
String s = "身份证号解析错误";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), s, s);
}
} else {
String s = "身份证号位数错误";
IdCardTypeEnum idCardType = regexUtilInstance.getTypeEnum();
if (idCardType == null || IdCardTypeEnum.OTHERS == idCardType) {
String s = "证件号解析错误,或不支持的证件类型。(请使用身份证号或者护照号)";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), s, s);
}
// 出生日期 & 年龄
LocalDate birthday = null;
try {
birthday = LocalDate.of(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));
} catch (DateTimeException e) {
throw new EpmetException("身份证号中日期信息错误");
IdCardRegexUtils.ParsedContent parsedResult = regexUtilInstance.getParsedResult();
String year = null, month = null, day = null, sex = null;
if (parsedResult != null) {
year = parsedResult.getBirthdayYear();
month = parsedResult.getBirthdayMonth();
day = parsedResult.getBirthdayDay();
sex = parsedResult.getSex();
}
int age = Period.between(birthday, LocalDate.now()).getYears();
// 性别 & 生日 & 老年人
Boolean isMale = (Integer.parseInt(sex) % 2) == 1;
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");
// 存储证件类型
columnAndValues.put("ID_CARD_TYPE", idCardType.getType());
if (idCardType == IdCardTypeEnum.SFZH) {
//只有证件类型是身份证号才做相关解析
// 出生日期 & 年龄
LocalDate birthday = null;
try {
birthday = LocalDate.of(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));
} catch (DateTimeException e) {
throw new EpmetException("身份证号中日期信息错误");
}
int age = Period.between(birthday, LocalDate.now()).getYears();
// 性别 & 生日 & 老年人
Boolean isMale = (Integer.parseInt(sex) % 2) == 1;
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");
}
}
/**

25
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

@ -258,7 +258,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
if (map.containsKey("ID_CARD")) {
IcResiUserDTO userDTO = baseDao.getResiUserByIdCard(map.get("ID_CARD"), tokenDto.getCustomerId());
if (null != userDTO && null != userDTO.getIdCard()) {
String errorMsg = "新增居民信息失败,身份证号已存在!";
String errorMsg = "新增居民信息失败,证号已存在!";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg);
}
}
@ -294,6 +294,16 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
if (isDyzxh) {
map.put("IS_VOLUNTEER", NumConstant.ONE_STR);
}
// 证件类型判断----start----
IdCardRegexUtils regex = IdCardRegexUtils.parse(map.get("ID_CARD"));
if (regex == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "证件号解析错误", "证件号解析错误");
}
IdCardTypeEnum typeEnum = regex.getTypeEnum();
map.put("ID_CARD_TYPE", typeEnum.getType());
// 证件类型判断----end----
//新增主表数据
baseDao.add(d.getTableName(), map);
@ -505,7 +515,7 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
wrapper.ne(IcResiUserEntity::getId, map.get("ID"));
List<IcResiUserEntity> entityList = baseDao.selectList(wrapper);
if (CollectionUtils.isNotEmpty(entityList)) {
String errorMsg = "修改居民信息失败,身份证号已存在!";
String errorMsg = "修改居民信息失败,证号已存在!";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg, errorMsg);
}
}
@ -620,6 +630,17 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
map.put("IS_VOLUNTEER", NumConstant.ONE_STR);
}
map.put("updated_by", tokenDto.getUserId());
if (StringUtils.isNotBlank(map.get("ID_CARD"))) {
// 证件类型判断----start----
IdCardRegexUtils regex = IdCardRegexUtils.parse(map.get("ID_CARD"));
if (regex == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "证件号解析错误", "证件号解析错误");
}
IdCardTypeEnum typeEnum = regex.getTypeEnum();
map.put("ID_CARD_TYPE", typeEnum.getType());
// 证件类型判断----end----
}
baseDao.upTable("ic_resi_user", resiUserId, map);
}

13
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserResiInfoServiceImpl.java

@ -26,10 +26,13 @@ import com.epmet.commons.tools.constant.EpmetRoleKeyConstant;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.enums.IdCardTypeEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.IdCardRegexUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.SmsTemplateConstant;
import com.epmet.constant.UserConstant;
@ -243,6 +246,16 @@ public class UserResiInfoServiceImpl extends BaseServiceImpl<UserResiInfoDao, Us
*/
@Transactional(rollbackFor = Exception.class)
public void saveUserResiInfo(UserResiInfoDTO userResiInfoDTO) {
if (StringUtils.isNotBlank(userResiInfoDTO.getIdNum())) {
// 证件类型判断----start----
IdCardRegexUtils regex = IdCardRegexUtils.parse(userResiInfoDTO.getIdNum());
if (regex == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "证件号解析错误", "证件号解析错误");
}
// 证件类型判断----end----
}
//1:注册信息表新增数据
baseDao.insert(ConvertUtils.sourceToTarget(userResiInfoDTO, UserResiInfoEntity.class));
//更新该用户在该客户下的注册状态

BIN
epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_import_template.xls

Binary file not shown.
Loading…
Cancel
Save