From f1620c37a5e215bcd4e4e82f75a56deb4a5b3b9f Mon Sep 17 00:00:00 2001 From: gaoben Date: Tue, 9 Nov 2021 17:13:41 +0800 Subject: [PATCH] =?UTF-8?q?v3.0.6=201.=E4=BF=AE=E6=94=B9=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=E8=AF=8115=E4=BD=8D=E8=BD=AC18=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../net/shapelight/common/utils/Convert.java | 26 ++++++++++++++++ .../app/controller/AppApiController.java | 31 +++++++++++++++++++ .../ten/controller/TenPersonController.java | 13 ++++++++ 3 files changed, 70 insertions(+) diff --git a/shapelight-admin/src/main/java/net/shapelight/common/utils/Convert.java b/shapelight-admin/src/main/java/net/shapelight/common/utils/Convert.java index 6fb88eb..b67ad42 100644 --- a/shapelight-admin/src/main/java/net/shapelight/common/utils/Convert.java +++ b/shapelight-admin/src/main/java/net/shapelight/common/utils/Convert.java @@ -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; + } } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppApiController.java b/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppApiController.java index 2274214..dad3aec 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppApiController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppApiController.java @@ -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()); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java index fa2d109..ffa9bfb 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenPersonController.java @@ -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())){