From ea5adbd1ab134c61dd281b8ae9965f4a780ddf84 Mon Sep 17 00:00:00 2001 From: huanghongfa <huanghongfa123456> Date: 星期四, 15 四月 2021 17:50:22 +0800 Subject: [PATCH] 实有人口模块bug修复 --- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java | 96 ++++++++++++++++++++++++++++++++++------------- 1 files changed, 69 insertions(+), 27 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java index 7e874ab..b6fbc7f 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java @@ -12,6 +12,8 @@ import com.panzhihua.common.model.vos.community.ComMngPopulationServeExcelVO; import com.panzhihua.common.model.vos.community.ComMngVillageServeExcelVO; import com.panzhihua.common.service.community.CommunityService; +import com.panzhihua.common.utlis.AgeUtils; +import com.panzhihua.common.utlis.IdCardUtil; import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -82,40 +84,80 @@ ArrayList<ComMngPopulationServeExcelVO> voList = Lists.newArrayList(); for (Map<Integer, String> oneData : list) { ComMngPopulationServeExcelVO vo = new ComMngPopulationServeExcelVO(); + if(oneData.get(0) == null){ + throw new ServiceException("500", "名字不可为空:第" + index + "行,第1列"); + } vo.setName(oneData.get(0)); - vo.setSex(PopulSexEnum.getCodeByName(oneData.get(1))); - if(oneData.get(2) == null){ - throw new ServiceException("500", "年龄不可为空:第" + index + "行,第3列"); + if(oneData.get(1) == null){ + throw new ServiceException("500", "身份证号不可为空:第" + index + "行,第2列"); } - vo.setAge(Integer.valueOf(oneData.get(2))); - if(oneData.get(3) == null){ - throw new ServiceException("500", "是否租住不可为空:第" + index + "行,第4列"); + vo.setCardNo(oneData.get(1)); + //根据身份证号码解析年龄以及性别 + if(IdCardUtil.strongVerifyIdNumber(vo.getCardNo())){ + //获取用户生日 + String birthday = vo.getCardNo().substring(6, 14); + //设置用户年龄 + vo.setAge(AgeUtils.getAgeFromBirthTime(birthday)); + //获取用户性别 + int sex = Integer.parseInt(vo.getCardNo().substring(16, 17)); + if(sex%2 == 1){ + vo.setSex(PopulSexEnum.nan.getCode()); + }else{ + vo.setSex(PopulSexEnum.nv.getCode()); + } + }else{ + throw new ServiceException("500", "身份证号码有误:第" + index + "行,第3列"); } - vo.setIsRent(PopulIsOkEnum.getCodeByName(oneData.get(3))); - vo.setRoad(oneData.get(4)); - if(oneData.get(5) == null){ - throw new ServiceException("500", "门牌号不可为空:第" + index + "行,第6列"); + + if(oneData.get(2) != null){ + vo.setNation(oneData.get(2)); } - vo.setDoorNo(Integer.valueOf(oneData.get(5))); - vo.setFloor(oneData.get(6)); - if(oneData.get(7) == null){ - throw new ServiceException("500", "单元号不可为空:第" + index + "行,第8列"); + if(oneData.get(3) != null){ + vo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCodeByName(oneData.get(3))); } - vo.setUnitNo(Integer.valueOf(oneData.get(7))); - if(oneData.get(8) == null){ - throw new ServiceException("500", "户室不可为空:第" + index + "行,第9列"); + if(oneData.get(4) != null){ + vo.setIsRent(PopulIsOkEnum.getCodeByName(oneData.get(4))); } - vo.setHouseNo(Integer.valueOf(oneData.get(8))); - vo.setNation(oneData.get(9)); - if(oneData.get(10) == null){ - throw new ServiceException("500", "政治面貌不可为空:第" + index + "行,第11列"); + if(oneData.get(5) != null){ + vo.setRelation(oneData.get(5)); } - vo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCodeByName(oneData.get(10))); - vo.setCardNo(oneData.get(11)); - vo.setPhone(oneData.get(12)); - vo.setNativePlace(oneData.get(13)); - vo.setWorkCompany(oneData.get(14)); - for (int i = 15; i < headSize; i++) { + if(oneData.get(6) != null){ + vo.setRoad(oneData.get(6)); + } + if(oneData.get(7) != null){ + vo.setDoorNo(Integer.valueOf(oneData.get(7))); + } + if(oneData.get(8) != null){ + vo.setFloor(oneData.get(8)); + } + if(oneData.get(9) != null){ + vo.setUnitNo(Integer.valueOf(oneData.get(9))); + } + if(oneData.get(10) != null){ + vo.setHouseNo(Integer.valueOf(oneData.get(10))); + } + if(oneData.get(11) != null){ + vo.setPhone(oneData.get(11)); + } + if(oneData.get(12) != null){ + vo.setNativePlace(oneData.get(12)); + } + if(oneData.get(13) != null){ + vo.setCultureLevel(oneData.get(13)); + } + if(oneData.get(14) != null){ + vo.setMarriage(oneData.get(14)); + } + if(oneData.get(15) != null){ + vo.setHealthy(oneData.get(15)); + } + if(oneData.get(16) != null){ + vo.setWorkCompany(oneData.get(16)); + } + if(oneData.get(17) != null){ + vo.setRemark(oneData.get(17)); + } + for (int i = 18; i < headSize; i++) { if (oneData.get(i) != null && oneData.get(i).equals("是")) { vo.getUserTagStr().add(headData.get(i)); } -- Gitblit v1.7.1