1.修改身份证15位转18位
This commit is contained in:
gaoben 2021-11-09 17:13:41 +08:00
parent bc8cb2a220
commit f1620c37a5
3 changed files with 70 additions and 0 deletions

View File

@ -996,4 +996,30 @@ public class Convert
}
return head + s.replaceAll("(零.)*零元", "").replaceFirst("(零.)+", "").replaceAll("(零.)+", "").replaceAll("^整$", "零元整");
}
/**
* 将15位转换为18位
* @param idCode 15位身份证号
* @return String 18位身份证号
*/
public static String toEighteen(String idCode) {
idCode = idCode.substring(0, 6) + "19" + idCode.substring(6);//加入年份变成17位
//计算校验位 begin
char[] Ai = idCode.toCharArray();
int[] Wi = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
char[] verifyCode = {'1','0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
int S = 0;
int Y;
for(int i = 0; i < Wi.length; i++){
S += (Ai[i] - '0') * Wi[i];
}
Y = S % 11;
//校验位计算结果verifyCode[Y] end
idCode += verifyCode[Y];
return idCode;
}
}

View File

@ -133,6 +133,13 @@ public class AppApiController {
tenPerson.setAppFlag(Constant.APP_LOGIN_YES);
tenPerson.setStatus(Constant.PESON_SUATUS_WAITREVIEW);
if(tenPerson.getIdCard()!=null){
if(tenPerson.getIdCard().length() == 15){
String id18 = Convert.toEighteen(tenPerson.getIdCard());
tenPerson.setIdCard(id18);
}
}
TenPersonEntity tenPersonEntity = tenPersonService.findByName(tenPerson.getName(),
tenPerson.getRoomId(),tenPerson.getCellId());
@ -163,6 +170,12 @@ public class AppApiController {
if(user == null){
return R.error("用户不存在");
}
if(tenPerson.getIdCard()!=null){
if(tenPerson.getIdCard().length() == 15){
String id18 = Convert.toEighteen(tenPerson.getIdCard());
tenPerson.setIdCard(id18);
}
}
TenCellEntity cell = tenCellService.getById(tenPerson.getCellId());
long id = new SnowflakeIdWorker().nextId();
tenPerson.setPersonId(id);
@ -263,6 +276,12 @@ public class AppApiController {
// if(tenPersonEntity!=null){
// return R.error("姓名在此房间已存在");
// }
if(tenPerson.getIdCard()!=null){
if(tenPerson.getIdCard().length() == 15){
String id18 = Convert.toEighteen(tenPerson.getIdCard());
tenPerson.setIdCard(id18);
}
}
TenCellEntity cell= tenCellService.getById(tenPerson.getCellId());
long id = new SnowflakeIdWorker().nextId();
@ -471,6 +490,12 @@ public class AppApiController {
}else{
tenPerson.setAppFlag(Constant.APP_LOGIN_NO);
}
if(tenPerson.getIdCard()!=null){
if(tenPerson.getIdCard().length() == 15){
String id18 = Convert.toEighteen(tenPerson.getIdCard());
tenPerson.setIdCard(id18);
}
}
//验证app人员是否注册
if (tenPerson.getAppFlag()==Constant.APP_LOGIN_YES) {
//1.验证用户名
@ -540,6 +565,12 @@ public class AppApiController {
// TenPersonEntity loginPerson = tenPersonService.getById(tenPerson.getAppLoginPersonId(),tenPerson.getCellId());
if(tenPerson.getIdCard()!=null){
if(tenPerson.getIdCard().length() == 15){
String id18 = Convert.toEighteen(tenPerson.getIdCard());
tenPerson.setIdCard(id18);
}
}
tenPerson.setCellId(loginPerson.getCellId());
tenPerson.setBuildId(loginPerson.getBuildId());
tenPerson.setBuildUnit(loginPerson.getBuildUnit());

View File

@ -316,6 +316,12 @@ public class TenPersonController extends AbstractController {
// if(room!=null){
// return R.error("此户室已经存在");
// }
if(tenPerson.getIdCard()!=null){
if(tenPerson.getIdCard().length() == 15){
String id18 = Convert.toEighteen(tenPerson.getIdCard());
tenPerson.setIdCard(id18);
}
}
//验证app人员是否注册
if (tenPerson.getAppFlag() == Constant.APP_LOGIN_YES) {
//1.验证用户名
@ -385,6 +391,13 @@ public class TenPersonController extends AbstractController {
tenPerson.setLastUpdateTime(new Date());
tenPerson.setFaceFailure(Constant.FACE_FAILURE_OK);
if(tenPerson.getIdCard()!=null){
if(tenPerson.getIdCard().length() == 15){
String id18 = Convert.toEighteen(tenPerson.getIdCard());
tenPerson.setIdCard(id18);
}
}
if(tenPerson.getName()!=null){
TenPersonEntity oldPerson = tenPersonService.getById(tenPerson.getPersonId(),tenPerson.getCellId());
if(!tenPerson.getName().equals(oldPerson.getName())){