manailin
2021-06-14 b1eb51c980efb4db207223ce86ddc459916dff7c
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/KeyPersonInfoServiceImpl.java
@@ -5,16 +5,25 @@
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 javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.List;
/**
@@ -30,6 +39,8 @@
    @Resource
    private ComMngPopulationService comMngPopulationService;
    @Value("${domain.aesKey:}")
    private String aesKey;
    /**
     * description 批量保存重点人群人员信息
     * 处理逻辑:同一个人的信息可以被多个社区重复录入
@@ -54,10 +65,22 @@
                comMngPopulationTagCardNoDTO.setCardNo(dbKeyPerson.getCardNo());
                comMngPopulationTagCardNoDTO.setLabel(calculateLabel(dbKeyPerson));
                comMngPopulationService.editTagPopulationByCardNo(comMngPopulationTagCardNoDTO);
                ComMngPopulationDO population=comMngPopulationService.getPopulationByCardNo(keyPersonInfoDO.getCardNo());
                if(population !=null){
                    keyPersonInfoDO.setUserId(population.getId());
                }
                keyPersonInfoDO.setVisiterType(Integer.parseInt(keyPersonInfoDTO.getVisiterType()));
                keyPersonInfoDO.setInvalid(false);
                updateById(keyPersonInfoDO);
            } else {
                KeyPersonInfoDO keyPersonInfoDO = new KeyPersonInfoDO();
                BeanUtils.copyProperties(keyPersonInfoDTO, keyPersonInfoDO);
                ComMngPopulationDO population=comMngPopulationService.getPopulationByCardNo(keyPersonInfoDO.getCardNo());
                if(population !=null){
                    keyPersonInfoDO.setUserId(population.getId());
                }
                keyPersonInfoDO.setVisiterType(Integer.parseInt(keyPersonInfoDTO.getVisiterType()));
                keyPersonInfoDO.setInvalid(false);
                save(keyPersonInfoDO);
            }
        });
@@ -82,11 +105,17 @@
    }
    private KeyPersonInfoDO checkExistFromDb(KeyPersonInfoDTO keyPersonInfoDTO) {
        try {
            String aesCardNo = AESUtil.encrypt128(keyPersonInfoDTO.getCardNo(), aesKey);
        return baseMapper.selectOne(
                new QueryWrapper<KeyPersonInfoDO>()
                        .eq("act_id", keyPersonInfoDTO.getActId())
                        .eq("card_no", keyPersonInfoDTO.getCardNo())
                            .eq("card_no",aesCardNo)
                        .eq("visiter_type", keyPersonInfoDTO.getVisiterType())
        );
        } catch (Exception e) {
            log.error("根据身份证查询特殊人群业务-加密证件信息出错");
        }
        return null;
    }
}