CeDo
2021-05-19 575e94e9db7e507ecec2441d24a13e9415fd9f03
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
@@ -20,6 +20,7 @@
import com.panzhihua.common.model.vos.user.ComMngFamilyInfoVO;
import com.panzhihua.common.model.vos.user.InputUserInfoVO;
import com.panzhihua.common.model.vos.user.UserElectronicFileVO;
import com.panzhihua.common.utlis.AgeUtils;
import com.panzhihua.service_community.dao.ComActDAO;
import com.panzhihua.service_community.dao.ComActVillageDAO;
import com.panzhihua.service_community.dao.ComMngPopulationDAO;
@@ -43,6 +44,7 @@
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@@ -173,6 +175,16 @@
        page.setSize(pageSize);
        page.setCurrent(pageNum);
        IPage<ComMngPopulationVO> iPage = populationDAO.pagePopulation(page, comMngPopulationVO);
        iPage.getRecords().forEach(vo->{
            //获取用户生日
            String date = vo.getCardNo().substring(6, 14);
            String year = date.substring(0,4);
            String month = date.substring(4,6);
            String day = date.substring(6,8);
            String birthday = year + "-" + month + "-" + day;
            //设置用户年龄
            vo.setBirthday(birthday);
        });
        return R.ok(iPage);
    }
@@ -416,10 +428,11 @@
        if(populationDO==null){
            return R.fail();
        }
        String cardNo = populationDO.getCardNo();
        BeanUtils.copyProperties(vo,populationDO);
        try {
            //TODO 修改拦截器时候需要维护加密操作
            if(!populationDO.getCardNo().equals(vo.getCardNo())){//判断是否修改身份证号码
            if(!cardNo.equals(vo.getCardNo())){//判断是否修改身份证号码
                //判断要修改的身份证号码是否已存在
                ComMngPopulationDO cardNoDO = populationDAO.selectOne(new QueryWrapper<ComMngPopulationDO>()
                        .lambda().eq(ComMngPopulationDO::getCardNo,vo.getCardNo()));
@@ -427,8 +440,10 @@
                    return R.fail("您输入的身份证已存在,请重新输入");
                }
                populationDO.setCardNo(AESUtil.encrypt128(vo.getCardNo(), aesKey));
                populationDO.setPhone(AESUtil.encrypt128(vo.getPhone(), aesKey));
            }else{
                populationDO.setCardNo(AESUtil.encrypt128(cardNo, aesKey));
            }
            populationDO.setPhone(AESUtil.encrypt128(vo.getPhone(), aesKey));
        } catch (Exception e) {
            e.printStackTrace();
            return R.fail();
@@ -445,6 +460,7 @@
        if(!StringUtils.isEmpty(comMngVillageDO.getGroupAt())){
            populationDO.setVillageName(comMngVillageDO.getGroupAt());
        }
        populationDO.setUpdateAt(new Date());
//        this.updateById(populationDO);
        if(populationDAO.updateById(populationDO) > 0){
            return R.ok();
@@ -500,4 +516,14 @@
        }
        return R.ok();
    }
    @Override
    public R editUserElectronicFile(UserElectronicFileVO userElectronicFileVO) {
        UserElectronicFileVO electronicFileVO = populationDAO.getSysUserById(userElectronicFileVO.getUserId());
        if(electronicFileVO==null){
            return R.fail("id有误!");
        }
         populationDAO.updateSysUserElectronicFile(userElectronicFileVO);
        return R.ok();
    }
}