From f8f5ea74a82b471f99f0b500e13429b02b0c4b18 Mon Sep 17 00:00:00 2001 From: wans <747101512@qq.com> Date: Wed, 26 Jan 2022 16:26:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=85=A8=E9=87=8F=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IBasePopulationInfoService.java | 2 + .../impl/BasePopulationInfoServiceImpl.java | 64 +++++++++++++++++++ .../utils/IdCardVerifyUtil.java | 18 +++++- 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/src/main/java/cn/com/tenlion/commonpopulation/service/basepopulationinfo/IBasePopulationInfoService.java b/src/main/java/cn/com/tenlion/commonpopulation/service/basepopulationinfo/IBasePopulationInfoService.java index f862f88..b0080cd 100644 --- a/src/main/java/cn/com/tenlion/commonpopulation/service/basepopulationinfo/IBasePopulationInfoService.java +++ b/src/main/java/cn/com/tenlion/commonpopulation/service/basepopulationinfo/IBasePopulationInfoService.java @@ -182,4 +182,6 @@ public interface IBasePopulationInfoService { List> getDefaultPageEducation(Map params); List> getDefaultPageNation(Map params); + + void kafkaFullPullSync(String tableNumber); } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/commonpopulation/service/basepopulationinfo/impl/BasePopulationInfoServiceImpl.java b/src/main/java/cn/com/tenlion/commonpopulation/service/basepopulationinfo/impl/BasePopulationInfoServiceImpl.java index 5650a09..415d91b 100644 --- a/src/main/java/cn/com/tenlion/commonpopulation/service/basepopulationinfo/impl/BasePopulationInfoServiceImpl.java +++ b/src/main/java/cn/com/tenlion/commonpopulation/service/basepopulationinfo/impl/BasePopulationInfoServiceImpl.java @@ -585,4 +585,68 @@ public class BasePopulationInfoServiceImpl extends DefaultBaseService implements kafkaTemplate.send("tableSync", jObj.toJSONString()); } + @Override + public void kafkaFullPullSync(String tableNumber) { + JSONObject jObj = new JSONObject(); + jObj.put("tableNumber", tableNumber); + jObj.put("action", "save"); + List fullList = basePopulationInfoDao.listBasePopulationInfo(null); + for(BasePopulationInfoDTO item : fullList){ + jObj.put("uid", item.getBasePopulationInfoId()); + PopulationInfo info = new PopulationInfo(); + info.setfull_name(item.getFullName()); + info.setname_used_before(item.getNameUsedBefore()); + String gender = IdCardVerifyUtil.getIdCardGender(item.getIdCardNumber()); + info.setgender("1".equals(gender) ? "男" : "女"); + info.setage(IdCardVerifyUtil.getAgeFromIdCardNumber(item.getIdCardNumber())); + if(item.getNation() != null && !"".equals(item.getNation())){ + DataDTO dataDTO = mongoDataService.get(item.getNation()); + info.setnation(dataDTO == null ? "" : dataDTO.getDataName()); + } + if(item.getReligion() != null && !"".equals(item.getReligion())){ + DataDTO dataDTO = mongoDataService.get(item.getReligion()); + info.setreligion(dataDTO == null ? "" : dataDTO.getDataName()); + } + if(item.getEducation() != null && !"".equals(item.getEducation())){ + DataDTO dataDTO = mongoDataService.get(item.getEducation()); + info.seteducation(dataDTO == null ? "" : dataDTO.getDataName()); + } + if(item.getPoliticalStatus() != null && !"".equals(item.getPoliticalStatus())){ + DataDTO dataDTO = mongoDataService.get(item.getPoliticalStatus()); + info.setpolitical_status(dataDTO == null ? "" : dataDTO.getDataName()); + } + if(item.getMaritalStatus() != null && !"".equals(item.getMaritalStatus())){ + DataDTO dataDTO = mongoDataService.get(item.getMaritalStatus()); + info.setmarital_status(dataDTO == null ? "" : dataDTO.getDataName()); + } + if(item.getOccupationCategory() != null && !"".equals(item.getOccupationCategory())){ + DataDTO dataDTO = mongoDataService.get(item.getOccupationCategory()); + info.setoccupation_category(dataDTO == null ? "" : dataDTO.getDataName()); + } + info.setoccupation(item.getOccupation() == null ? "" : item.getOccupation()); + info.setlocation_all(item.getAreaNames() == null ? "" : item.getAreaNames()); + info.setlocation_code(item.getAreaCode() == null ? "" : item.getAreaCode()); + if(item.getAreaCode() != null && !"".equals(item.getAreaCode())){ + AreaDTO areaDTO = mongoAreaService.getByCode(item.getAreaCode()); + info.setlocation_area(areaDTO == null ? "" : areaDTO.getAreaName()); + } + info.setis_key_teenager("否"); + info.setkey_teenager_time(""); + info.setis_addicts("否"); + info.setaddicts_time(""); + info.setis_aids("否"); + info.setaids_time(""); + info.setis_community_correction("否"); + info.setcommunity_correction_time(""); + info.setis_mental_disorders("否"); + info.setmental_disorders_time(""); + info.setis_release_after_sentence("否"); + info.setrelease_after_sentence_time(""); + info.setgrid_code(item.getGridId() == null ? "" : item.getGridId()); + info.setgrid_name(item.getGridName() == null ? "" : item.getGridName()); + jObj.put("data", info.saveCheckToJson()); + kafkaTemplate.send("tableSync", jObj.toJSONString()); + } + } + } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/commonpopulation/utils/IdCardVerifyUtil.java b/src/main/java/cn/com/tenlion/commonpopulation/utils/IdCardVerifyUtil.java index 86145ae..81960aa 100644 --- a/src/main/java/cn/com/tenlion/commonpopulation/utils/IdCardVerifyUtil.java +++ b/src/main/java/cn/com/tenlion/commonpopulation/utils/IdCardVerifyUtil.java @@ -233,10 +233,26 @@ public class IdCardVerifyUtil { return split; } + public static String sensitiveDataReplace(String str){ + if(str == null || str.length() == 0){ + return "******"; + } + Integer strLen = str.length(); + if(strLen > 6){ + String newStr = str.substring(0,str.length() - 6); + return newStr + "******"; + } + if(strLen > 3){ + String newStr = str.substring(0,str.length() - 3); + return newStr + "***"; + } + return "***"; + } + public static void main(String[] args) { //boolean isTrue = isIDCard("330622810725323"); - System.out.println(getAgeFromIdCardNumber("152822199310146919")); + System.out.println(sensitiveDataReplace("152822199310146919")); } }