From cc1098fc00a50cb1591d182f04bc37066ff0a9e2 Mon Sep 17 00:00:00 2001
From: 罗元桥 <2376770955@qq.com>
Date: 星期四, 05 八月 2021 15:12:39 +0800
Subject: [PATCH] Merge branch 'test' into 'master'

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/KeyPersonInfoServiceImpl.java |   47 ++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/KeyPersonInfoServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/KeyPersonInfoServiceImpl.java
index ffcaf32..b497207 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/KeyPersonInfoServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/KeyPersonInfoServiceImpl.java
@@ -5,16 +5,20 @@
 import com.panzhihua.common.enums.KeyPersonLabelEnum;
 import com.panzhihua.common.model.dtos.community.ComMngPopulationTagCardNoDTO;
 import com.panzhihua.common.model.dtos.community.KeyPersonInfoDTO;
+import com.panzhihua.common.model.helper.AESUtil;
 import com.panzhihua.common.model.vos.R;
 import com.panzhihua.service_community.dao.KeyPersonInfoDAO;
+import com.panzhihua.service_community.model.dos.ComMngPopulationDO;
 import com.panzhihua.service_community.model.dos.KeyPersonInfoDO;
 import com.panzhihua.service_community.service.ComMngPopulationService;
 import com.panzhihua.service_community.service.KeyPersonInfoService;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -29,6 +33,9 @@
 
     @Resource
     private ComMngPopulationService comMngPopulationService;
+
+    @Value("${domain.aesKey:}")
+    private String aesKey;
 
     /**
      * description 批量保存重点人群人员信息
@@ -45,6 +52,10 @@
     public R saveBatchKeyPerson(List<KeyPersonInfoDTO> list) {
         list.forEach(keyPersonInfoDTO -> {
             KeyPersonInfoDO dbKeyPerson = checkExistFromDb(keyPersonInfoDTO);
+            ComMngPopulationDO population = comMngPopulationService.getPopulationByCardNo(keyPersonInfoDTO.getCardNo());
+            if (population != null) {
+                keyPersonInfoDTO.setUserId(population.getId());
+            }
             if (dbKeyPerson != null) {
                 //已经存在数据,进行数据更新操作
                 KeyPersonInfoDO keyPersonInfoDO = new KeyPersonInfoDO();
@@ -54,10 +65,26 @@
                 comMngPopulationTagCardNoDTO.setCardNo(dbKeyPerson.getCardNo());
                 comMngPopulationTagCardNoDTO.setLabel(calculateLabel(dbKeyPerson));
                 comMngPopulationService.editTagPopulationByCardNo(comMngPopulationTagCardNoDTO);
-                updateById(keyPersonInfoDO);
+                try {
+                    String aesCardNo = AESUtil.encrypt128(keyPersonInfoDTO.getCardNo(), aesKey);
+                    String phone = AESUtil.encrypt128(keyPersonInfoDTO.getPhone(), aesKey);
+                    String guardianPhone = AESUtil.encrypt128(keyPersonInfoDTO.getGuardianPhone(), aesKey);
+                    keyPersonInfoDO.setCardNo(aesCardNo);
+                    keyPersonInfoDO.setPhone(phone);
+                    keyPersonInfoDO.setGuardianPhone(guardianPhone);
+                    keyPersonInfoDO.setVisiterType(Integer.parseInt(keyPersonInfoDTO.getVisiterType()));
+                    keyPersonInfoDO.setInvalid(false);
+                    keyPersonInfoDO.setSubmitDate(new Date());
+                    updateById(keyPersonInfoDO);
+                } catch (Exception e) {
+                    log.error("根据身份证查询残疾人群业务-加密证件信息出错");
+                }
             } else {
                 KeyPersonInfoDO keyPersonInfoDO = new KeyPersonInfoDO();
                 BeanUtils.copyProperties(keyPersonInfoDTO, keyPersonInfoDO);
+                keyPersonInfoDO.setVisiterType(Integer.parseInt(keyPersonInfoDTO.getVisiterType()));
+                keyPersonInfoDO.setInvalid(false);
+                keyPersonInfoDO.setSubmitDate(new Date());
                 save(keyPersonInfoDO);
             }
         });
@@ -82,11 +109,17 @@
     }
 
     private KeyPersonInfoDO checkExistFromDb(KeyPersonInfoDTO keyPersonInfoDTO) {
-        return baseMapper.selectOne(
-                new QueryWrapper<KeyPersonInfoDO>()
-                        .eq("act_id", keyPersonInfoDTO.getActId())
-                        .eq("card_no", keyPersonInfoDTO.getCardNo())
-                        .eq("visiter_type", keyPersonInfoDTO.getVisiterType())
-        );
+        try {
+            String aesCardNo = AESUtil.encrypt128(keyPersonInfoDTO.getCardNo(), aesKey);
+            return baseMapper.selectOne(
+                    new QueryWrapper<KeyPersonInfoDO>()
+                            .eq("act_id", keyPersonInfoDTO.getActId())
+                            .eq("card_no", aesCardNo)
+                            .eq("visiter_type", keyPersonInfoDTO.getVisiterType())
+            );
+        } catch (Exception e) {
+            log.error("根据身份证查询特殊人群业务-加密证件信息出错");
+        }
+        return null;
     }
 }

--
Gitblit v1.7.1