huanghongfa
2021-05-19 c355cd9ca0e9c1cee4687867fa87e6fe65bd3a77
实有人口优化
1个文件已删除
12个文件已修改
17个文件已添加
2001 ■■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/PopulHouseControlStatusEnum.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/PopulHousePurposeEnum.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/PopulHouseStatusEnum.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/PopulIsOksEnum.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/PopulOutOrLocalEnum.java 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationConfirmServeExcelListen.java 177 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java 144 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/area/AreaAddressVO.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationCarVO.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationServeExcelVO.java 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVO.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/ComHouseMemberVo.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/ComMngHouseVo.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/StringUtils.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommonDataApi.java 311 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/PopulationApi.java 377 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommonDataApi.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngCarDAO.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationDAO.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationHouseDAO.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationHouseUserDAO.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComMngPopulationDO.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComMngPopulationHouseDO.java 126 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComMngPopulationHouseUserDO.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationHouseService.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationHouseUserService.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationHouseServiceImpl.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationHouseUserServiceImpl.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java 227 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/PopulHouseControlStatusEnum.java
New file
@@ -0,0 +1,44 @@
package com.panzhihua.common.enums;
import lombok.Getter;
/**
 * 房屋管控状态
 *
 * @author LYQ
 */
@Getter
public enum PopulHouseControlStatusEnum
{
    CG(1, "常规"),
    GZ(2, "关注"),
    GK(3, "管控");
    private final Integer code;
    private final String name;
    PopulHouseControlStatusEnum(Integer code, String name)
    {
        this.code = code;
        this.name = name;
    }
    public static int getCodeByName(String name) {
        for (PopulHouseControlStatusEnum item : PopulHouseControlStatusEnum.values()) {
            if (item.name.equals(name)) {
                return item.getCode();
            }
        }
        return 0;
    }
    public static String getCnDescByName(Integer code) {
        for (PopulHouseControlStatusEnum item : PopulHouseControlStatusEnum.values()) {
            if (item.code.equals(code)) {
                return item.getName();
            }
        }
        return "";
    }
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/PopulHousePurposeEnum.java
New file
@@ -0,0 +1,46 @@
package com.panzhihua.common.enums;
import lombok.Getter;
/**
 * 房屋用途
 *
 * @author LYQ
 */
@Getter
public enum PopulHousePurposeEnum
{
    ZZ(1, "住宅"),
    GY(2, "公寓"),
    SS(3, "宿舍"),
    CK(4, "仓库"),
    QT(5, "其他");
    private final Integer code;
    private final String name;
    PopulHousePurposeEnum(Integer code, String name)
    {
        this.code = code;
        this.name = name;
    }
    public static int getCodeByName(String name) {
        for (PopulHousePurposeEnum item : PopulHousePurposeEnum.values()) {
            if (item.name.equals(name)) {
                return item.getCode();
            }
        }
        return 5;
    }
    public static String getCnDescByName(Integer code) {
        for (PopulHousePurposeEnum item : PopulHousePurposeEnum.values()) {
            if (item.code.equals(code)) {
                return item.getName();
            }
        }
        return "其他";
    }
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/PopulHouseStatusEnum.java
New file
@@ -0,0 +1,44 @@
package com.panzhihua.common.enums;
import lombok.Getter;
/**
 * 房屋状态
 *
 * @author LYQ
 */
@Getter
public enum PopulHouseStatusEnum
{
    ZI_ZHU(1, "自住"),
    ZU_ZHU(2, "租住"),
    QI_TA(3, "其他");
    private final Integer code;
    private final String name;
    PopulHouseStatusEnum(Integer code, String name)
    {
        this.code = code;
        this.name = name;
    }
    public static int getCodeByName(String name) {
        for (PopulHouseStatusEnum item : PopulHouseStatusEnum.values()) {
            if (item.name.equals(name)) {
                return item.getCode();
            }
        }
        return 3;
    }
    public static String getCnDescByName(Integer code) {
        for (PopulHouseStatusEnum item : PopulHouseStatusEnum.values()) {
            if (item.code.equals(code)) {
                return item.getName();
            }
        }
        return "其他";
    }
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/PopulIsOksEnum.java
New file
@@ -0,0 +1,42 @@
package com.panzhihua.common.enums;
import lombok.Getter;
/**
 * 是否状态(1.是 2.否)
 *
 * @author huanghongfa
 */
@Getter
public enum PopulIsOksEnum
{
    YES(1, "是"), NO(2, "否");
    private final Integer code;
    private final String name;
    PopulIsOksEnum(Integer code, String name)
    {
        this.code = code;
        this.name = name;
    }
    public static int getCodeByName(String name) {
        for (PopulIsOksEnum item : PopulIsOksEnum.values()) {
            if (item.name.equals(name)) {
                return item.getCode();
            }
        }
        return 2;
    }
    public static String getCnDescByName(Integer code) {
        for (PopulIsOksEnum item : PopulIsOksEnum.values()) {
            if (item.code.equals(code)) {
                return item.getName();
            }
        }
        return "否";
    }
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/enums/PopulOutOrLocalEnum.java
New file
@@ -0,0 +1,43 @@
package com.panzhihua.common.enums;
import lombok.Getter;
/**
 * 本地外地
 *
 * @author LYQ
 */
@Getter
public enum PopulOutOrLocalEnum
{
    BD(1, "本地"),
    WD(2, "外地");
    private final Integer code;
    private final String name;
    PopulOutOrLocalEnum(Integer code, String name)
    {
        this.code = code;
        this.name = name;
    }
    public static int getCodeByName(String name) {
        for (PopulOutOrLocalEnum item : PopulOutOrLocalEnum.values()) {
            if (item.name.equals(name)) {
                return item.getCode();
            }
        }
        return 0;
    }
    public static String getCnDescByName(Integer code) {
        for (PopulOutOrLocalEnum item : PopulOutOrLocalEnum.values()) {
            if (item.code.equals(code)) {
                return item.getName();
            }
        }
        return "";
    }
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationConfirmServeExcelListen.java
File was deleted
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java
@@ -12,10 +12,7 @@
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 com.panzhihua.common.utlis.ListUtils;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.common.utlis.*;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -88,7 +85,9 @@
            List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>();
            for (Map<Integer, String> oneData : list) {
                ComMngPopulationServeExcelVO vo = new ComMngPopulationServeExcelVO();
                if(oneData.get(0) == null){
                //姓名和身份证都为空,为空户,无需操作,否则就解析年龄,性别,出生年月日
                if(StringUtils.isNotEmpty(oneData.get(0)) || StringUtils.isNotEmpty(oneData.get(1))){
                    if(StringUtils.isEmpty(oneData.get(0))){
                    ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO();
                    importErrorVO.setErrorPosition("第" + index + "行,第1列");
                    importErrorVO.setErrorMsg("名字不可为空,请填写姓名");
@@ -105,9 +104,7 @@
                    index++;
                    continue;
                }
//                if(!IdCardUtil.identityValidator(oneData.get(1))){
//                    throw new ServiceException("500", "身份证号格式错误:第" + index + "行,第2列");
//                }
                //判断身份证号码位数
                if(oneData.get(1).length() != 18){
                    ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO();
@@ -121,6 +118,12 @@
                //根据身份证号码解析年龄以及性别
                //获取用户生日
                String birthday = vo.getCardNo().substring(6, 14);
                    if(StringUtils.isNotEmpty(birthday)){
                        String year = birthday.substring(0,4);
                        String month = birthday.substring(4,6);
                        String day = birthday.substring(6,8);
                        vo.setBirthday(year + "-" + month + "-" + day);
                    }
                //设置用户年龄
                vo.setAge(AgeUtils.getAgeFromBirthTime(birthday));
                //获取用户性别
@@ -130,72 +133,120 @@
                }else{
                    vo.setSex(PopulSexEnum.nv.getCode());
                }
                if(oneData.get(2) != null){
                }
                if(StringUtils.isNotEmpty(oneData.get(2))){
                    vo.setNation(oneData.get(2));
                }
                if(oneData.get(3) != null){
                if(StringUtils.isNotEmpty(oneData.get(3))){
                    vo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCodeByName(oneData.get(3)));
                }
                if(oneData.get(4) != null){
                if(StringUtils.isNotEmpty(oneData.get(4))){
                    vo.setIsRent(PopulIsOkEnum.getCodeByName(oneData.get(4)));
                }
                if(oneData.get(5) != null){
                if(StringUtils.isNotEmpty(oneData.get(5))){
                    vo.setRelation(PopulRelationEnum.getCodeByName(oneData.get(5)));
                }
                if(oneData.get(6) != null){
                if(StringUtils.isEmpty(oneData.get(6))){
                    ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO();
                    importErrorVO.setErrorPosition("第" + index + "行,第7列");
                    importErrorVO.setErrorMsg("街路巷不可为空");
                    populationImportErrorVOList.add(importErrorVO);
                    index++;
                    continue;
                }
                    vo.setRoad(oneData.get(6));
                if(StringUtils.isEmpty(oneData.get(7))){
                    ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO();
                    importErrorVO.setErrorPosition("第" + index + "行,第8列");
                    importErrorVO.setErrorMsg("小区号不可为空");
                    populationImportErrorVOList.add(importErrorVO);
                    index++;
                    continue;
                }
                if(oneData.get(7) != null){
                    vo.setDoorNo(Integer.valueOf(oneData.get(7)));
                vo.setDoorNo(oneData.get(7).trim());
                if(StringUtils.isEmpty(oneData.get(8))){
                    ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO();
                    importErrorVO.setErrorPosition("第" + index + "行,第9列");
                    importErrorVO.setErrorMsg("楼排号不可为空");
                    populationImportErrorVOList.add(importErrorVO);
                    index++;
                    continue;
                }
                if(oneData.get(8) != null){
                    vo.setFloor(oneData.get(8));
                vo.setFloor(oneData.get(8).trim());
                if(StringUtils.isEmpty(oneData.get(9))){
                    ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO();
                    importErrorVO.setErrorPosition("第" + index + "行,第10列");
                    importErrorVO.setErrorMsg("单元号不可为空");
                    populationImportErrorVOList.add(importErrorVO);
                    index++;
                    continue;
                }
                if(oneData.get(9) != null){
                    vo.setUnitNo(Integer.valueOf(oneData.get(9)));
                vo.setUnitNo(oneData.get(9).trim());
                if(StringUtils.isEmpty(oneData.get(10))){
                    ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO();
                    importErrorVO.setErrorPosition("第" + index + "行,第11列");
                    importErrorVO.setErrorMsg("户室不可为空");
                    populationImportErrorVOList.add(importErrorVO);
                    index++;
                    continue;
                }
                if(oneData.get(10) != null){
                    vo.setHouseNo(Integer.valueOf(oneData.get(10).trim()));
                vo.setHouseNo(oneData.get(10).trim());
                if(StringUtils.isNotEmpty(oneData.get(11))){
                    vo.setPhone(oneData.get(11).trim());
                }
                if(oneData.get(11) != null){
                    vo.setPhone(oneData.get(11));
                if(StringUtils.isNotEmpty(oneData.get(12))){
                    vo.setNativePlace(oneData.get(12).trim());
                }
                if(oneData.get(12) != null){
                    vo.setNativePlace(oneData.get(12));
                if(StringUtils.isNotEmpty(oneData.get(13))){
                    vo.setCultureLevel(PopulCultureLevelEnum.getCodeByName(oneData.get(13).trim()));
                }
                if(oneData.get(13) != null){
                    vo.setCultureLevel(PopulCultureLevelEnum.getCodeByName(oneData.get(13)));
                if(StringUtils.isNotEmpty(oneData.get(14))){
                    vo.setMarriage(PopulMarriageEnum.getCodeByName(oneData.get(14).trim()));
                }
                if(oneData.get(14) != null){
                    vo.setMarriage(PopulMarriageEnum.getCodeByName(oneData.get(14)));
                if(StringUtils.isNotEmpty(oneData.get(15))){
                    vo.setHealthy(oneData.get(15).trim());
                }
                if(oneData.get(15) != null){
                    vo.setHealthy(oneData.get(15));
                if(StringUtils.isNotEmpty(oneData.get(16))){
                    vo.setWorkCompany(oneData.get(16).trim());
                }
                if(oneData.get(16) != null){
                    vo.setWorkCompany(oneData.get(16));
                if(StringUtils.isNotEmpty(oneData.get(17))){
                    vo.setRemark(oneData.get(17).trim());
                }
                if(oneData.get(17) != null && StringUtils.isNotEmpty(oneData.get(17))){
                    String outOrLocal = oneData.get(17);
                    if(outOrLocal.equals(ComMngPopulationServeExcelVO.outOrLocal.bd)){
                        vo.setOutOrLocal(1);
                    }else if(outOrLocal.equals(ComMngPopulationServeExcelVO.outOrLocal.wd)){
                        vo.setOutOrLocal(2);
                if(StringUtils.isNotEmpty(oneData.get(18))){
                    vo.setCensusRegister(oneData.get(18).trim());
                    }
                if(StringUtils.isNotEmpty(oneData.get(19))){
                    vo.setOutOrLocal(PopulOutOrLocalEnum.getCodeByName(oneData.get(19).trim()));
                }
                if(oneData.get(18) != null){
                    vo.setCensusRegister(oneData.get(18));
                if(StringUtils.isNotEmpty(oneData.get(20))){
                    vo.setHouseStatus(PopulHouseStatusEnum.getCodeByName(oneData.get(20).trim()));
                }
                if(oneData.get(19) != null){
                    vo.setRemark(oneData.get(19));
                if(StringUtils.isNotEmpty(oneData.get(21))){
                    vo.setHousePurpose(PopulHousePurposeEnum.getCodeByName(oneData.get(21).trim()));
                }
                for (int i = 20; i < headSize; i++) {
                if(StringUtils.isNotEmpty(oneData.get(22))){
                    vo.setControlStatus(PopulHouseControlStatusEnum.getCodeByName(oneData.get(22).trim()));
                }
                if(StringUtils.isNotEmpty(oneData.get(23))){
                    vo.setIsResidence(PopulIsOksEnum.getCodeByName(oneData.get(23).trim()));
                }
                for (int i = 24; i < headSize; i++) {
                    if (oneData.get(i) != null && oneData.get(i).equals("是")) {
                        vo.getUserTagStr().add(headData.get(i).substring(0,headData.get(i).indexOf("(")));
                    }
                }
                //将重复的数据进行MD5加密实现去重
                String distinct = vo.getName() + vo.getCardNo() + vo.getRoad() + vo.getDoorNo() + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo();
                try {
                    String distinctPass = PayUtil.MD5(distinct);
                    if(StringUtils.isNotEmpty(distinctPass)){
                        vo.setDistinctPass(distinctPass);
                    }
                }catch (Exception e){
                    log.error("组装MD5加密字段失败,数据表格行数:" + index);
                    continue;
                }
                voList.add(vo);
                index++;
            }
@@ -209,7 +260,7 @@
//                throw new ServiceException("500", JSON.toJSONString(populationImportErrorVOList));
//            }
            //根据list中的IdCard城市来去重
            List<ComMngPopulationServeExcelVO> newVoList = voList.stream().filter(ListUtils.distinctByKey(ComMngPopulationServeExcelVO::getCardNo)).collect(Collectors.toList());
            List<ComMngPopulationServeExcelVO> newVoList = voList.stream().filter(ListUtils.distinctByKey(ComMngPopulationServeExcelVO::getDistinctPass)).collect(Collectors.toList());
            R r = communityService.listSavePopulationServeExcelVO(newVoList, communityId);
            if (!R.isOk(r)) {
                String errMsg = r.getMsg();
@@ -229,7 +280,6 @@
            importErrorVO.setErrorPosition("第" + index + "行");
            importErrorVO.setErrorMsg("数据格式有误,请检查文档内数据");
            populationImportErrorVOList.add(importErrorVO);
            index++;
            throw new ServiceException("500", JSON.toJSONString(populationImportErrorVOList));
        }
    }
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/area/AreaAddressVO.java
New file
@@ -0,0 +1,25 @@
package com.panzhihua.common.model.vos.area;
import io.swagger.annotations.ApiModel;
import lombok.Data;
@Data
@ApiModel(value = "查询社区地址信息")
public class AreaAddressVO {
    /**
     * 省份名称
     */
    private String province;
    /**
     * 城市名称
     */
    private String city;
    /**
     * 区域名称
     */
    private String district;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationCarVO.java
New file
@@ -0,0 +1,32 @@
package com.panzhihua.common.model.vos.community;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * @description: 实有人口详情车辆信息
 * @author: lyq
 * @date: 2021/5/19 12:28
 */
@Data
@ApiModel("实有人口详情车辆信息")
public class ComMngPopulationCarVO implements Serializable {
    @ApiModelProperty("主键")
    private Long id;
    @ApiModelProperty("车牌号")
    private String plateNum;
    @ApiModelProperty("车辆品牌型号")
    private String brand;
    @ApiModelProperty("车身颜色")
    private String color;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationServeExcelVO.java
@@ -36,16 +36,16 @@
    private String road;
    @ExcelProperty(value = "门牌号", index = 7)
    private Integer doorNo;
    private String doorNo;
    @ExcelProperty(value = "楼排号", index = 8)
    private String floor;
    @ExcelProperty(value = "单元号", index = 9)
    private Integer unitNo;
    private String unitNo;
    @ExcelProperty(value = "户室(房间号)", index = 10)
    private Integer houseNo;
    private String houseNo;
    @ExcelProperty(value = "联系方式", index = 11)
    private String phone;
@@ -65,29 +65,56 @@
    @ExcelProperty(value = "工作单位", index = 16)
    private String workCompany;
    @ExcelProperty(value = "外地or本地(1.本地  2.外地)", index = 17)
    private Integer outOrLocal;
    @ExcelProperty(value = "备注", index = 17)
    private String remark;
    @ExcelProperty(value = "户口所在地", index = 18)
    private String censusRegister;
    @ExcelProperty(value = "备注", index = 19)
    private String remark;
    @ExcelProperty(value = "外地or本地(1.本地  2.外地)", index = 19)
    private Integer outOrLocal;
    @ExcelProperty(value = "房屋状态(1.自住 2.租住 3.其他)", index = 20)
    private Integer houseStatus;
    @ExcelProperty(value = "房屋用途(1.住宅 2.公寓 3.宿舍 4.仓库 5.其他)", index = 21)
    private Integer housePurpose;
    @ExcelProperty(value = "管控状态(1.常规 2.关注 3.管控)", index = 22)
    private Integer controlStatus;
    @ExcelProperty(value = "是否是居住地(1.是 2.否)", index = 23)
    private Integer isResidence;
    /**
     * 去重字段,使用(姓名+身份证号+街路巷+小区号+楼牌号+单元号+户室)组合字段进行MD5加密实现去重
     */
    private String distinctPass;
    /**
     * 年龄
     */
    private Integer age;
    /**
     * 性别(1.男  2.女)
     */
    private Integer sex;
    /**
     * 出生年月日
     */
    private String birthday;
    /**
     * 房屋地址
     */
    private String address;
    /**
     * 扩展字段用逗号隔开
     */
    private List<String> userTagStr = Lists.newArrayList();
    /**
     * 外地or本地(1.本地  2.外地)
     */
    public interface outOrLocal{
        String bd = "本地";
        String wd = "外地";
    }
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVO.java
@@ -6,6 +6,7 @@
import com.panzhihua.common.model.helper.sensitive.SensitiveStrategy;
import com.panzhihua.common.model.vos.user.ComHouseMemberVo;
import com.panzhihua.common.model.vos.user.ComMngFamilyInfoVO;
import com.panzhihua.common.model.vos.user.ComMngHouseVo;
import com.panzhihua.common.model.vos.user.UserElectronicFileVO;
import com.panzhihua.common.validated.AddGroup;
import io.swagger.annotations.ApiModel;
@@ -155,6 +156,12 @@
    @ApiModelProperty("与户主关系(1.户主 2.配偶 3.子女 4.孙女 5.父母 6.其他)")
    private Integer relation;
    @ApiModelProperty("房屋列表")
    private List<ComMngHouseVo> houseList;
    @ApiModelProperty("车辆列表")
    private List<ComMngPopulationCarVO> carList;
    public interface sex{
        int nan = 1;
        int nv = 2;
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/ComHouseMemberVo.java
@@ -9,22 +9,35 @@
import lombok.Data;
@Data
@ApiModel("房屋成员信息")
@ApiModel("户主关系对象")
@EncryptDecryptClass
public class ComHouseMemberVo {
    @ApiModelProperty("房屋成员用户id")
    private Long id;
    private Long populId;
    @ApiModelProperty("姓名")
    private String name;
    @ApiModelProperty("手机号")
    @EncryptDecryptField
    @Sensitive(strategy = SensitiveStrategy.PHONE)
//    @Sensitive(strategy = SensitiveStrategy.PHONE)
    private String phone;
    @ApiModelProperty("与户主关系")
    @ApiModelProperty("与户主关系(1.户主 2.配偶 3.子女 4.孙女 5.父母 6.其他)")
    private String relation;
    @ApiModelProperty("年龄")
    private Integer age;
    @ApiModelProperty("健康状况")
    private String healthy;
    @ApiModelProperty("身份证号")
    @EncryptDecryptField
    private String cardNo;
    @ApiModelProperty("工作单位")
    private String workCompany;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/ComMngHouseVo.java
New file
@@ -0,0 +1,23 @@
package com.panzhihua.common.model.vos.user;
import com.panzhihua.common.model.helper.encrypt.EncryptDecryptClass;
import com.panzhihua.common.model.helper.encrypt.EncryptDecryptField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("实有人口详情房屋信息")
@EncryptDecryptClass
public class ComMngHouseVo {
    @ApiModelProperty("房屋id")
    private Long houseId;
    @ApiModelProperty("房屋地址")
    private String address;
    @ApiModelProperty("房屋状态")
    private Integer status;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/utlis/StringUtils.java
@@ -2,6 +2,7 @@
import java.util.*;
import java.util.regex.Pattern;
/**
 * 字符串工具类
@@ -451,4 +452,15 @@
    {
        return (T) obj;
    }
    /**
     * 判断是否为数字格式不限制位数
     * @param o
     *     待校验参数
     * @return
     *     如果全为数字,返回true;否则,返回false
     */
    public static boolean isNumber(Object o){
        return  (Pattern.compile("[0-9]*")).matcher(String.valueOf(o)).matches();
    }
}
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommonDataApi.java
@@ -757,316 +757,5 @@
        return communityService.getDistrictByCityCode(cityAdcode);
    }
    @ApiOperation(value = "分页查询实有人口列表", response = ComMngPopulationVO.class)
    @PostMapping("/population/pagePopulation")
    public R pageQueryComMngRealAssets(@RequestBody ComMngPopulationDTO comMngPopulationVO) {
        //获取登陆用户绑定社区id
        Long communityId = this.getLoginUserInfo().getCommunityId();
        comMngPopulationVO.setActId(communityId);
        return communityService.pagePopulation(comMngPopulationVO);
    }
    @ApiOperation(value = "excel导入实有人口")
    @PostMapping(value = "/serve/population/import", consumes = "multipart/*", headers = "content-type=multipart/form-date")
    public R downloadPopulationTemplate(@RequestParam MultipartFile file, HttpServletRequest request) {
        //获取文件名
        String fileName = file.getOriginalFilename();
        log.info("传入文件名字【{}】", fileName);
        InputStream inputStream = null;
        try {
            inputStream = file.getInputStream();
            LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
            ComMngPopulationServeExcelListen comMngPopulationServeExcelListen = new ComMngPopulationServeExcelListen(communityService, loginUserInfo.getCommunityId());
            EasyExcel.read(inputStream, null, comMngPopulationServeExcelListen).sheet().doRead();
        } catch (IOException e) {
            log.error("导入模板失败【{}】", e.getMessage());
            e.printStackTrace();
        }
        return R.ok();
    }
    @ApiOperation(value = "编辑实有人口")
    @PostMapping(value = "/population/edit")
    public R editPopulationInfo(@RequestBody EditComMngPopulationVO editComMngPopulationVO){
        LoginUserInfoVO loginUserInfo = getLoginUserInfo();
        return communityService.editPopulation(editComMngPopulationVO,loginUserInfo.getCommunityId());
    }
    @ApiOperation(value = "excel确认导入实有人口")
    @PostMapping(value = "/serve/population/import/confirm", consumes = "multipart/*", headers = "content-type=multipart/form-date")
    public R listSavePopulationConfirm(@RequestParam MultipartFile file, HttpServletRequest request) {
        //获取文件名
        String fileName = file.getOriginalFilename();
        log.info("传入文件名字【{}】", fileName);
        InputStream inputStream = null;
        try {
            inputStream = file.getInputStream();
            LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
            ComMngPopulationConfirmServeExcelListen comMngPopulationServeExcelListen = new ComMngPopulationConfirmServeExcelListen(communityService, loginUserInfo.getCommunityId());
            EasyExcel.read(inputStream, null, comMngPopulationServeExcelListen).sheet().doRead();
        } catch (IOException e) {
            log.error("导入模板失败【{}】", e.getMessage());
            e.printStackTrace();
        }
        return R.ok();
    }
    @ApiOperation(value = "实有人口详情", response = ComMngPopulationVO.class)
    @PostMapping("/population/detail")
    public R detailPopulation(@RequestParam(value = "populationId") Long populationId) {
        return communityService.detailPopulation(populationId);
    }
    @ApiOperation(value = "查询实有人口电子档案", response = UserElectronicFileVO.class)
    @PostMapping("/population/electronicArchives")
    public R electronicArchivesPopulation(@RequestParam(value = "populationId") Long populationId) {
        return communityService.electronicArchivesPopulation(populationId);
    }
    @ApiOperation(value = "实有人口标签修改", response = ComMngPopulationVO.class)
    @PostMapping("/population/editTag")
    public R editTagPopulation(@RequestBody ComMngPopulationTagDTO populationTagDTO) {
        return communityService.editTagPopulation(populationTagDTO);
    }
    @ApiOperation(value = "实有人口-下载模板")
    @GetMapping("/population/export")
    public R exportPopulation() {
        //获取登陆用户
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        //获取登陆用户绑定社区id
        Long communityId = loginUserInfo.getCommunityId();
        //生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址
        String ftpUrl = "/mnt/data/web/excel/";
        String name = "实有人口导入模板.xlsx";
        try {
            SFTPUtil sftp = new SFTPUtil(userName, password, host, port);
            sftp.login();
            boolean existDir = sftp.isExistDir(ftpUrl + name);
            if (!existDir) {
                String property = System.getProperty("user.dir");
                String fileName = property + File.separator + name;
                // 这里 需要指定写用哪个class去写
                InputStream inputStream = null;
                try {
                    List<List<String>> list = new ArrayList<>();
                    list = headDataFilling();
                    List<List<Object>> dataList = new ArrayList<>();
                    List<Object> data = new ArrayList<>();
                    data = formDataFilling();
                    //查询当前社区标签列表
                    R tagsResult = userService.listTags(communityId);
                    if(Constants.SUCCESS.equals(tagsResult.getCode())){
                        List<String> TagsList = (List<String>)tagsResult.getData();
                        //动态加载标签列表到表头
                        for (int i = 0; i < TagsList.size(); i++) {
                            List<String> head = new ArrayList<>();
                            head.add(TagsList.get(i) + "(是/否)");
                            list.add(head);
                            data.add("否");
                        }
                    }
                    dataList.add(data);
                    EasyExcel.write(fileName).head(list).sheet("实有人口导入模板").doWrite(dataList);
                    File file = new File(fileName);
                    inputStream = new FileInputStream(file);
                    sftp.uploadMore(ftpUrl, name, inputStream);
                    sftp.logout();
                    inputStream.close();
                    String absolutePath = file.getAbsolutePath();
                    boolean delete = file.delete();
                    log.info("删除excel【{}】结果【{}】", absolutePath, delete);
                } finally {
                    // 千万别忘记finish 会帮忙关闭流
                    if (inputStream != null) {
                        inputStream.close();
                    }
                }
            }
            return R.ok(excelUrl + "实有人口导入模板.xlsx");
        } catch (Exception e) {
            e.printStackTrace();
            log.error("文件传输失败【{}】", e.getMessage());
            return R.fail();
        }
    }
    @ApiOperation(value = "批量删除实有人口")
    @PostMapping("/population/delete")
    public R deletePopulations(@RequestBody List<Long> Ids){
        return communityService.deletePopulations(Ids);
    }
    private List<List<String>> headDataFilling(){
        List<List<String>> list = new ArrayList<List<String>>();
        List<String> head0 = new ArrayList<String>();
        head0.add("姓名");
        List<String> head1 = new ArrayList<String>();
        head1.add("身份证(性别和年龄自动根据身份证号识别)");
        List<String> head2 = new ArrayList<String>();
        head2.add("民族");
        List<String> head3 = new ArrayList<String>();
        head3.add("政治面貌(群众/中共党员/共青团员)");
        List<String> head4 = new ArrayList<String>();
        head4.add("是否租住");
        List<String> head5 = new ArrayList<String>();
        head5.add("与户主关系");
        List<String> head6 = new ArrayList<String>();
        head6.add("街/路/巷");
        List<String> head7 = new ArrayList<String>();
        head7.add("小区号(政府对于每个小区都有特定编号)");
        List<String> head8 = new ArrayList<String>();
        head8.add("楼排号");
        List<String> head10 = new ArrayList<String>();
        head10.add("单元号");
        List<String> head11 = new ArrayList<String>();
        head11.add("户室(四位数表示。前两位楼层,后两位户号)");
        List<String> head12 = new ArrayList<String>();
        head12.add("联系方式");
        List<String> head13 = new ArrayList<String>();
        head13.add("籍贯");
        List<String> head14 = new ArrayList<String>();
        head14.add("文化程度");
        List<String> head15 = new ArrayList<String>();
        head15.add("婚姻状况");
        List<String> head16 = new ArrayList<String>();
        head16.add("健康状况");
        List<String> head17 = new ArrayList<String>();
        head17.add("工作单位");
        List<String> head18 = new ArrayList<String>();
        head18.add("本地/外地");
        List<String> head19 = new ArrayList<String>();
        head19.add("户口所在地");
        List<String> head20 = new ArrayList<String>();
        head20.add("备注");
        list.add(head0);
        list.add(head1);
        list.add(head2);
        list.add(head3);
        list.add(head4);
        list.add(head5);
        list.add(head6);
        list.add(head7);
        list.add(head8);
        list.add(head10);
        list.add(head11);
        list.add(head12);
        list.add(head13);
        list.add(head14);
        list.add(head15);
        list.add(head16);
        list.add(head17);
        list.add(head18);
        list.add(head19);
        list.add(head20);
        return list;
    }
    private List<Object> formDataFilling(){
        List<Object> data = new ArrayList<>();
        data.add("张三");
        data.add("513421199508187219");
        data.add("汉族");
        data.add("群众");
        data.add("是");
        data.add("");
        data.add("樱花街");
        data.add(115);
        data.add("15栋");
        data.add(10);
        data.add(1001);
        data.add("13768548521");
        data.add("中国");
        data.add("");
        data.add("");
        data.add("");
        data.add("阿里巴巴");
        data.add("本地");
        data.add("四川成都");
        data.add("");
        return data;
    }
    @ApiOperation(value = "实有人口-数据导出")
    @PostMapping("/population/data/export")
    public R dataExportPopulation(@RequestBody List<Long> Ids) {
        //获取登陆用户
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        //获取登陆用户绑定社区id
        Long communityId = loginUserInfo.getCommunityId();
        //生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址
        String ftpUrl = "/mnt/data/web/excel/";
        String name = "实有人口数据.xlsx";
        try {
            SFTPUtil sftp = new SFTPUtil(userName, password, host, port);
            sftp.login();
            boolean existDir = sftp.isExistDir(ftpUrl + name);
            if (!existDir) {
                String property = System.getProperty("user.dir");
                String fileName = property + File.separator + name;
                // 这里 需要指定写用哪个class去写
                ExcelWriter excelWriter = null;
                InputStream inputStream = null;
                try {
                    List<ComMngPopulationVO> populList = null;
                    if(Ids.size() > 0){//导出部分
                        populList = JSON.parseArray(JSON.toJSONString(communityService.getPopulationLists(Ids).getData()),ComMngPopulationVO.class);
                    }else{//导出全部
                        populList = JSON.parseArray(JSON.toJSONString(communityService.getPopulationListByCommunityId(communityId).getData()),ComMngPopulationVO.class);
                    }
                    List<ComMngPopulationExcelVo> populationExcelVoList = new ArrayList<>();
                    if(populList != null && populList.size() > 0){
                        for (ComMngPopulationVO popul:populList){
                            ComMngPopulationExcelVo populationExcelVo = new ComMngPopulationExcelVo();
                            BeanUtils.copyProperties(popul,populationExcelVo);
                            //设置性别
                            populationExcelVo.setSex(PopulSexEnum.getCnDescByName(popul.getSex()));
                            //设置政治面貌
                            populationExcelVo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCnDescByName(popul.getPoliticalOutlook()));
                            //设置是否租住
                            populationExcelVo.setIsRent(PopulIsOkEnum.getCnDescByName(popul.getIsRent()));
                            populationExcelVoList.add(populationExcelVo);
                        }
                    }
                    excelWriter = EasyExcel.write(fileName, ComMngPopulationExcelVo.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build();
                    WriteSheet writeSheet = EasyExcel.writerSheet("实有人口导出数据").build();
                    excelWriter.write(populationExcelVoList, writeSheet);
                    excelWriter.finish();
                    File file = new File(fileName);
                    inputStream = new FileInputStream(file);
                    sftp.uploadMore(ftpUrl, name, inputStream);
                    sftp.logout();
                    inputStream.close();
                    String absolutePath = file.getAbsolutePath();
                    boolean delete = file.delete();
                    log.info("删除excel【{}】结果【{}】", absolutePath, delete);
                } finally {
                    // 千万别忘记finish 会帮忙关闭流
                    if (inputStream != null) {
                        inputStream.close();
                    }
                    if (excelWriter != null) {
                        excelWriter.finish();
                    }
                }
            }
            return R.ok(excelUrl + name);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("文件传输失败【{}】", e.getMessage());
            return R.fail();
        }
    }
    @ApiOperation(value = "编辑实有人口_电子档案")
    @PostMapping("/population/edit/electronicArchives")
    R editPopulation(@RequestBody UserElectronicFileVO userElectronicFileVO){
        return communityService.editUserElectronicFile(userElectronicFileVO);
    }
}
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/PopulationApi.java
New file
@@ -0,0 +1,377 @@
package com.panzhihua.community_backstage.api;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson.JSON;
import com.panzhihua.common.constants.Constants;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.enums.PopulIsOkEnum;
import com.panzhihua.common.enums.PopulPoliticalOutlookEnum;
import com.panzhihua.common.enums.PopulSexEnum;
import com.panzhihua.common.listen.ComMngPopulationServeExcelListen;
import com.panzhihua.common.model.dtos.community.ComMngPopulationDTO;
import com.panzhihua.common.model.dtos.community.ComMngPopulationTagDTO;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComMngPopulationExcelVo;
import com.panzhihua.common.model.vos.community.ComMngPopulationVO;
import com.panzhihua.common.model.vos.community.EditComMngPopulationVO;
import com.panzhihua.common.model.vos.user.UserElectronicFileVO;
import com.panzhihua.common.service.community.CommunityService;
import com.panzhihua.common.service.user.UserService;
import com.panzhihua.common.utlis.SFTPUtil;
import com.panzhihua.community_backstage.excel.CustomSheetWriteHandler;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Api(tags = {"社区管理/基础数据库/实有人口"})
@RestController
@RequestMapping("/common/data/population/")
public class PopulationApi extends BaseController {
    @Resource
    private CommunityService communityService;
    @Resource
    private UserService userService;
    // FTP 登录用户名
    @Value("${ftp.username}")
    private String userName;
    // FTP 登录密码
    @Value("${ftp.password}")
    private String password;
    // FTP 服务器地址IP地址
    @Value("${ftp.host}")
    private String host;
    // FTP 端口
    @Value("${ftp.port}")
    private int port;
    @Value("${excel.userurl}")
    private String excelUrl;
    @ApiOperation(value = "分页查询实有人口列表", response = ComMngPopulationVO.class)
    @PostMapping("/pagePopulation")
    public R pageQueryComMngRealAssets(@RequestBody ComMngPopulationDTO comMngPopulationVO) {
        //获取登陆用户绑定社区id
        Long communityId = this.getLoginUserInfo().getCommunityId();
        comMngPopulationVO.setActId(communityId);
        return communityService.pagePopulation(comMngPopulationVO);
    }
    @ApiOperation(value = "excel导入实有人口")
    @PostMapping(value = "/serve/import", consumes = "multipart/*", headers = "content-type=multipart/form-date")
    public R downloadPopulationTemplate(@RequestParam MultipartFile file, HttpServletRequest request) {
        //获取文件名
        String fileName = file.getOriginalFilename();
        log.info("传入文件名字【{}】", fileName);
        InputStream inputStream = null;
        try {
            inputStream = file.getInputStream();
            LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
            ComMngPopulationServeExcelListen comMngPopulationServeExcelListen = new ComMngPopulationServeExcelListen(communityService, loginUserInfo.getCommunityId());
            EasyExcel.read(inputStream, null, comMngPopulationServeExcelListen).sheet().doRead();
        } catch (IOException e) {
            log.error("导入模板失败【{}】", e.getMessage());
            e.printStackTrace();
        }
        return R.ok();
    }
    @ApiOperation(value = "编辑实有人口")
    @PostMapping(value = "/edit")
    public R editPopulationInfo(@RequestBody EditComMngPopulationVO editComMngPopulationVO){
        LoginUserInfoVO loginUserInfo = getLoginUserInfo();
        return communityService.editPopulation(editComMngPopulationVO,loginUserInfo.getCommunityId());
    }
    @ApiOperation(value = "实有人口详情", response = ComMngPopulationVO.class)
    @PostMapping("/detail")
    public R detailPopulation(@RequestParam(value = "populationId") Long populationId) {
        return communityService.detailPopulation(populationId);
    }
    @ApiOperation(value = "查询实有人口电子档案", response = UserElectronicFileVO.class)
    @PostMapping("/electronicArchives")
    public R electronicArchivesPopulation(@RequestParam(value = "populationId") Long populationId) {
        return communityService.electronicArchivesPopulation(populationId);
    }
    @ApiOperation(value = "实有人口标签修改", response = ComMngPopulationVO.class)
    @PostMapping("/editTag")
    public R editTagPopulation(@RequestBody ComMngPopulationTagDTO populationTagDTO) {
        return communityService.editTagPopulation(populationTagDTO);
    }
    @ApiOperation(value = "实有人口-下载模板")
    @GetMapping("/export")
    public R exportPopulation() {
        //获取登陆用户
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        //获取登陆用户绑定社区id
        Long communityId = loginUserInfo.getCommunityId();
        //生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址
        String ftpUrl = "/mnt/data/web/excel/";
        String name = "实有人口导入模板.xlsx";
        try {
            SFTPUtil sftp = new SFTPUtil(userName, password, host, port);
            sftp.login();
            boolean existDir = sftp.isExistDir(ftpUrl + name);
            if (!existDir) {
                String property = System.getProperty("user.dir");
                String fileName = property + File.separator + name;
                // 这里 需要指定写用哪个class去写
                InputStream inputStream = null;
                try {
                    List<List<String>> list = new ArrayList<>();
                    list = headDataFilling();
                    List<List<Object>> dataList = new ArrayList<>();
                    List<Object> data = new ArrayList<>();
                    data = formDataFilling();
                    //查询当前社区标签列表
                    R tagsResult = userService.listTags(communityId);
                    if(Constants.SUCCESS.equals(tagsResult.getCode())){
                        List<String> TagsList = (List<String>)tagsResult.getData();
                        //动态加载标签列表到表头
                        for (int i = 0; i < TagsList.size(); i++) {
                            List<String> head = new ArrayList<>();
                            head.add(TagsList.get(i) + "(是/否)");
                            list.add(head);
                            data.add("否");
                        }
                    }
                    dataList.add(data);
                    EasyExcel.write(fileName).head(list).sheet("实有人口导入模板").doWrite(dataList);
                    File file = new File(fileName);
                    inputStream = new FileInputStream(file);
                    sftp.uploadMore(ftpUrl, name, inputStream);
                    sftp.logout();
                    inputStream.close();
                    String absolutePath = file.getAbsolutePath();
                    boolean delete = file.delete();
                    log.info("删除excel【{}】结果【{}】", absolutePath, delete);
                } finally {
                    // 千万别忘记finish 会帮忙关闭流
                    if (inputStream != null) {
                        inputStream.close();
                    }
                }
            }
            return R.ok(excelUrl + "实有人口导入模板.xlsx");
        } catch (Exception e) {
            e.printStackTrace();
            log.error("文件传输失败【{}】", e.getMessage());
            return R.fail();
        }
    }
    @ApiOperation(value = "批量删除实有人口")
    @PostMapping("/delete")
    public R deletePopulations(@RequestBody List<Long> Ids){
        return communityService.deletePopulations(Ids);
    }
    private List<List<String>> headDataFilling(){
        List<List<String>> list = new ArrayList<List<String>>();
        List<String> head0 = new ArrayList<String>();
        head0.add("姓名");
        List<String> head1 = new ArrayList<String>();
        head1.add("身份证(性别和年龄自动根据身份证号识别)");
        List<String> head2 = new ArrayList<String>();
        head2.add("民族");
        List<String> head3 = new ArrayList<String>();
        head3.add("政治面貌(群众/中共党员/共青团员)");
        List<String> head4 = new ArrayList<String>();
        head4.add("是否租住(是/否)");
        List<String> head5 = new ArrayList<String>();
        head5.add("与户主关系(户主/配偶/子女/孙女/父母/其他)");
        List<String> head6 = new ArrayList<String>();
        head6.add("*街/路/巷(必填)");
        List<String> head7 = new ArrayList<String>();
        head7.add("*小区号(必填,政府对于每个小区都有特定编号)");
        List<String> head8 = new ArrayList<String>();
        head8.add("*楼排号(必填)");
        List<String> head10 = new ArrayList<String>();
        head10.add("*单元号(必填)");
        List<String> head11 = new ArrayList<String>();
        head11.add("*户室(必填,四位数表示。前两位楼层,后两位户号)");
        List<String> head12 = new ArrayList<String>();
        head12.add("联系方式");
        List<String> head13 = new ArrayList<String>();
        head13.add("籍贯");
        List<String> head14 = new ArrayList<String>();
        head14.add("文化程度(小学/初中/高中/中专/大专/本科/硕士/博士/其他)");
        List<String> head15 = new ArrayList<String>();
        head15.add("婚姻状况(未婚/已婚/离异/丧偶/分居/其他)");
        List<String> head16 = new ArrayList<String>();
        head16.add("健康状况");
        List<String> head17 = new ArrayList<String>();
        head17.add("工作单位");
        List<String> head18 = new ArrayList<String>();
        head18.add("备注");
        List<String> head19 = new ArrayList<String>();
        head19.add("户口所在地");
        List<String> head20 = new ArrayList<String>();
        head20.add("本地外地(本地/外地)");
        List<String> head21 = new ArrayList<String>();
        head21.add("房屋状态(自住/租住/其他)");
        List<String> head22 = new ArrayList<String>();
        head22.add("房屋用途(住宅/公寓/宿舍/仓库/其他)");
        List<String> head23 = new ArrayList<String>();
        head23.add("管控状态(常规/关注/管控)");
        List<String> head24 = new ArrayList<String>();
        head24.add("是否为居住地(是/否)");
        list.add(head0);
        list.add(head1);
        list.add(head2);
        list.add(head3);
        list.add(head4);
        list.add(head5);
        list.add(head6);
        list.add(head7);
        list.add(head8);
        list.add(head10);
        list.add(head11);
        list.add(head12);
        list.add(head13);
        list.add(head14);
        list.add(head15);
        list.add(head16);
        list.add(head17);
        list.add(head18);
        list.add(head19);
        list.add(head20);
        list.add(head21);
        list.add(head22);
        list.add(head23);
        list.add(head24);
        return list;
    }
    private List<Object> formDataFilling(){
        List<Object> data = new ArrayList<>();
        data.add("张三");
        data.add("513421199508187219");
        data.add("汉族");
        data.add("群众");
        data.add("是");
        data.add("户主");
        data.add("樱花街");
        data.add("115");
        data.add("15栋");
        data.add("1单元");
        data.add("1001");
        data.add("13768548521");
        data.add("中国");
        data.add("硕士");
        data.add("未婚");
        data.add("");
        data.add("阿里巴巴");
        data.add("");
        data.add("四川成都");
        data.add("本地");
        data.add("自住");
        data.add("公寓");
        data.add("常规");
        data.add("否");
        return data;
    }
    @ApiOperation(value = "实有人口-数据导出")
    @PostMapping("/data/export")
    public R dataExportPopulation(@RequestBody List<Long> Ids) {
        //获取登陆用户
        LoginUserInfoVO loginUserInfo = this.getLoginUserInfo();
        //获取登陆用户绑定社区id
        Long communityId = loginUserInfo.getCommunityId();
        //生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址
        String ftpUrl = "/mnt/data/web/excel/";
        String name = "实有人口数据.xlsx";
        try {
            SFTPUtil sftp = new SFTPUtil(userName, password, host, port);
            sftp.login();
            boolean existDir = sftp.isExistDir(ftpUrl + name);
            if (!existDir) {
                String property = System.getProperty("user.dir");
                String fileName = property + File.separator + name;
                // 这里 需要指定写用哪个class去写
                ExcelWriter excelWriter = null;
                InputStream inputStream = null;
                try {
                    List<ComMngPopulationVO> populList = null;
                    if(Ids.size() > 0){//导出部分
                        populList = JSON.parseArray(JSON.toJSONString(communityService.getPopulationLists(Ids).getData()),ComMngPopulationVO.class);
                    }else{//导出全部
                        populList = JSON.parseArray(JSON.toJSONString(communityService.getPopulationListByCommunityId(communityId).getData()),ComMngPopulationVO.class);
                    }
                    List<ComMngPopulationExcelVo> populationExcelVoList = new ArrayList<>();
                    if(populList != null && populList.size() > 0){
                        for (ComMngPopulationVO popul:populList){
                            ComMngPopulationExcelVo populationExcelVo = new ComMngPopulationExcelVo();
                            BeanUtils.copyProperties(popul,populationExcelVo);
                            //设置性别
                            populationExcelVo.setSex(PopulSexEnum.getCnDescByName(popul.getSex()));
                            //设置政治面貌
                            populationExcelVo.setPoliticalOutlook(PopulPoliticalOutlookEnum.getCnDescByName(popul.getPoliticalOutlook()));
                            //设置是否租住
                            populationExcelVo.setIsRent(PopulIsOkEnum.getCnDescByName(popul.getIsRent()));
                            populationExcelVoList.add(populationExcelVo);
                        }
                    }
                    excelWriter = EasyExcel.write(fileName, ComMngPopulationExcelVo.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build();
                    WriteSheet writeSheet = EasyExcel.writerSheet("实有人口导出数据").build();
                    excelWriter.write(populationExcelVoList, writeSheet);
                    excelWriter.finish();
                    File file = new File(fileName);
                    inputStream = new FileInputStream(file);
                    sftp.uploadMore(ftpUrl, name, inputStream);
                    sftp.logout();
                    inputStream.close();
                    String absolutePath = file.getAbsolutePath();
                    boolean delete = file.delete();
                    log.info("删除excel【{}】结果【{}】", absolutePath, delete);
                } finally {
                    // 千万别忘记finish 会帮忙关闭流
                    if (inputStream != null) {
                        inputStream.close();
                    }
                    if (excelWriter != null) {
                        excelWriter.finish();
                    }
                }
            }
            return R.ok(excelUrl + name);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("文件传输失败【{}】", e.getMessage());
            return R.fail();
        }
    }
    @ApiOperation(value = "编辑实有人口_电子档案")
    @PostMapping("/edit/electronicArchives")
    public R editPopulation(@RequestBody UserElectronicFileVO userElectronicFileVO){
        return communityService.editUserElectronicFile(userElectronicFileVO);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/api/CommonDataApi.java
@@ -275,7 +275,7 @@
     */
    @PostMapping("/population/import")
    @Transactional(rollbackFor = Exception.class)
    public R listSavePopulationExcelVO(@RequestBody List<ComMngPopulationServeExcelVO> list, @RequestParam(value = "communityId") Long communityId){
    public R listSavePopulationExcelVO(@RequestBody List<ComMngPopulationServeExcelVO> list, @RequestParam(value = "communityId") Long communityId)  throws Exception{
        return comMngPopulationService.listSavePopulation(list,communityId);
    }
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngCarDAO.java
@@ -5,10 +5,13 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.dtos.community.PageComMngCarDTO;
import com.panzhihua.common.model.vos.community.ComMngCarVO;
import com.panzhihua.common.model.vos.community.ComMngPopulationCarVO;
import com.panzhihua.service_community.model.dos.ComMngCarDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
 * @description: 车辆管理
@@ -52,4 +55,11 @@
            " order by t.create_at desc" +
            "</script>")
    IPage<ComMngCarVO> pageQueryComMngCar(Page page, @Param(value = "pageComMngCarDTO") PageComMngCarDTO pageComMngCarDTO);
    @Select("select cmc.id,cmc.plate_num,cmc.color,cmc.brand from com_mng_car as cmc " +
            " left join sys_user as su on su.user_id = cmc.user_id " +
            " where su.id_card = #{idCard}")
    List<ComMngPopulationCarVO> getPopulationCarListByIdCard(@Param(value = "idCard") String idCard);
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationDAO.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.dtos.community.ComMngPopulationDTO;
import com.panzhihua.common.model.dtos.user.PageInputUserDTO;
import com.panzhihua.common.model.vos.area.AreaAddressVO;
import com.panzhihua.common.model.vos.community.ComActMessageVO;
import com.panzhihua.common.model.vos.community.ComMngPopulationVO;
import com.panzhihua.common.model.vos.community.PageComActMessageVO;
@@ -97,8 +98,10 @@
    @Select("select id,user_id,relationship,`name`,id_card,phone,age,health,job,create_at,update_at,card_photo_front,card_photo_back,family_book from com_mng_family_info where user_id=#{userId}")
    List<ComMngFamilyInfoVO> listFamilyByUserId(Long userId);
    @Select("select id,`name`,phone,relation from com_mng_population where road = #{comMngPopulationDO.road} and door_no = #{comMngPopulationDO.doorNo} and floor = #{comMngPopulationDO.floor} and unit_no = #{comMngPopulationDO.unitNo} and house_no = #{comMngPopulationDO.houseNo} and id != #{comMngPopulationDO.id}")
    List<ComHouseMemberVo> listHouseMermberByUserId(@Param("comMngPopulationDO") ComMngPopulationDO comMngPopulationDO);
    @Select("select cmphu.popul_id,cmp.name,cmp.relation,cmp.age,cmp.phone,cmp.healthy,cmp.card_no,cmp.work_company from com_mng_population_house_user cmphu " +
            " left join com_mng_population cmp on cmp.id = cmphu.popul_id " +
            " where cmphu.house_id = #{houseId} and cmphu.popul_id != #{populId}")
    List<ComHouseMemberVo> listHouseMermberByUserId(@Param("houseId") Long houseId, @Param("populId") Long populId);
    @Select("<script> " +
            "SELECT\n" +
@@ -130,6 +133,7 @@
            "cmp.out_or_local, \n" +
            "cmp.census_register, \n" +
            "cmp.healthy, \n" +
            "cmp.birthday, \n" +
            "cmp.is_rent \n" +
            "FROM \n" +
            "com_mng_population AS cmp " +
@@ -142,10 +146,19 @@
            " and cmp.act_id = #{comMngPopulationVO.actId} " +
            " </if> " +
            "<if test='comMngPopulationVO.road != null and comMngPopulationVO.road != &quot;&quot;'>" +
            "AND cmp.road LIKE concat(#{comMngPopulationVO.road},'%') " +
            "AND cmp.road = #{comMngPopulationVO.road} " +
            " </if> " +
            "<if test='comMngPopulationVO.doorNo != null and comMngPopulationVO.doorNo != &quot;&quot;'>" +
            "AND cmp.door_no = #{comMngPopulationVO.doorNo} " +
            " </if> " +
            "<if test='comMngPopulationVO.floor != null and comMngPopulationVO.floor != &quot;&quot;'>" +
            "AND cmp.floor = #{comMngPopulationVO.floor} " +
            " </if> " +
            "<if test='comMngPopulationVO.unitNo != null and comMngPopulationVO.unitNo != &quot;&quot;'>" +
            "AND cmp.unit_no = #{comMngPopulationVO.unitNo} " +
            " </if> " +
            "<if test='comMngPopulationVO.houseNo != null and comMngPopulationVO.houseNo != &quot;&quot;'>" +
            "AND cmp.house_no = #{comMngPopulationVO.houseNo} " +
            " </if> " +
            "<if test='comMngPopulationVO.alley != null and comMngPopulationVO.alley != &quot;&quot;'>" +
            "AND cmv.alley LIKE concat(#{comMngPopulationVO.alley},'%') " +
@@ -175,6 +188,7 @@
            "AND cmp.remark = #{comMngPopulationVO.remark} " +
            " </if> " +
            " </where>" +
            " order by cmp.create_at desc" +
            "</script>")
    IPage<ComMngPopulationVO> pagePopulation(Page page, @Param("comMngPopulationVO") ComMngPopulationDTO comMngPopulationVO);
@@ -202,4 +216,11 @@
    @Select("update sys_user set card_photo_front=#{vo.cardPhotoFront},card_photo_back=#{vo.cardPhotoBack},family_book=#{vo.familyBook} where user_id=#{vo.userId}")
    void updateSysUserElectronicFile(@Param("vo") UserElectronicFileVO vo);
    @Select("<script> " +
            "select (select province_name from com_mng_struct_area_province where province_adcode = #{provinceCode}) as province," +
            "(select city_name from com_mng_struct_area_city where city_adcode = #{cityCode}) as city," +
            "(select district_name from com_mng_struct_area_district where district_adcode = #{districtCode}) as district" +
            "</script>")
    AreaAddressVO getAreaAddress(@Param("provinceCode") String provinceCode,@Param("cityCode") String cityCode,@Param("districtCode") String districtCode);
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationHouseDAO.java
New file
@@ -0,0 +1,25 @@
package com.panzhihua.service_community.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.panzhihua.common.model.vos.user.ComMngHouseVo;
import com.panzhihua.service_community.model.dos.ComMngPopulationHouseDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
 * @auther lyq
 * @create 2021-05-18 09:26:31
 * @describe 社区管理》小区管理》实有房屋mapper类
 */
@Mapper
public interface ComMngPopulationHouseDAO extends BaseMapper<ComMngPopulationHouseDO> {
    @Select("select cmphu.house_id,cmph.address,cmph.status from com_mng_population_house_user cmphu " +
            " left join com_mng_population_house as cmph on cmph.id = cmphu.house_id " +
            " where cmphu.popul_id = #{populId}")
    List<ComMngHouseVo> getPopulHouseListByPopulId(@Param("populId")Long populId);
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/dao/ComMngPopulationHouseUserDAO.java
New file
@@ -0,0 +1,15 @@
package com.panzhihua.service_community.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.panzhihua.service_community.model.dos.ComMngPopulationHouseUserDO;
import org.apache.ibatis.annotations.Mapper;
/**
 * @auther lyq
 * @create 2021-05-18 09:26:53
 * @describe 房屋居住信息关联表mapper类
 */
@Mapper
public interface ComMngPopulationHouseUserDAO extends BaseMapper<ComMngPopulationHouseUserDO> {
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComMngPopulationDO.java
@@ -55,7 +55,7 @@
    /**
     * 门牌号
     */
    private Integer doorNo;
    private String doorNo;
    /**
     * 楼排号
     */
@@ -63,11 +63,11 @@
    /**
     * 单元号
     */
    private Integer unitNo;
    private String unitNo;
    /**
     * 户室(房间号)
     */
    private Integer houseNo;
    private String houseNo;
    /**
     * 政治面貌(1.中共党员2.中共预备党员3.共青团员4.民革党员5.民盟盟员6.民建会员7.8.农工党党员9.致公党党员10.九三学社社员11.台盟盟员12.无党派人士13.群众)
     */
@@ -150,6 +150,41 @@
    private String healthy;
    /**
     * 房屋地址
     */
    private String houseAddress;
    /**
     * 出生年月日
     */
    private String birthday;
    /**
     * 房屋状态(1.自住 2.租住 3.其他)
     */
    private Integer houseStatus;
    /**
     * 房屋用途(1.住宅 2.公寓 3.宿舍 4.仓库 5.其他)
     */
    private Integer housePurpose;
    /**
     * 管控状态(1.常规 2.关注 3.管控)
     */
    private Integer controlStatus;
    /**
     * 是否是居住地(1.是 2.否)
     */
    private Integer isResidence;
    /**
     * 居住地房屋id
     */
    private Long houseId;
    /**
     * 性别(1.男 2.女 3.未知)
     */
    public interface sex{
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComMngPopulationHouseDO.java
New file
@@ -0,0 +1,126 @@
package com.panzhihua.service_community.model.dos;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * @auther lyq
 * @create 2021-05-18 09:26:31
 * @describe 社区管理》小区管理》实有房屋实体类
 */
@Data
@TableName("com_mng_population_house")
public class ComMngPopulationHouseDO implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 主键id
     */
    @TableId(type = IdType.AUTO)
    private Long id;
    /**
     * 房屋地址
     */
    private String address;
    /**
     * 房屋编号
     */
    private String code;
    /**
     * 社区id
     */
    private Long communityId;
    /**
     * 街路巷id
     */
    private String alley;
    /**
     * 门牌号
     */
    private String houseNum;
    /**
     * 楼排号
     */
    private String floor;
    /**
     * 单元号
     */
    private String unitNo;
    /**
     * 户室(房间号)
     */
    private String houseNo;
    /**
     * 房屋状态(1.自住 2.租住 3.其他)
     */
    private Integer status;
    /**
     * 房屋用途(1.住宅 2.公寓 3.宿舍 4.仓库 5.其他)
     */
    private Integer purpose;
    /**
     * 管控状态(1.常规 2.关注 3.管控)
     */
    private Integer controlStatus;
    /**
     * 空户(1.是 2.否)
     */
    private Integer isEmpty;
    /**
     * 建筑用途
     */
    private String constructPurpose;
    /**
     * 建筑面积
     */
    private Integer constructArea;
    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createAt;
    /**
     * 修改时间
     */
    @TableField(fill = FieldFill.UPDATE)
    private Date updateAt;
    @Override
    public String toString() {
        return "ComMngPopulationHouseDO{" +
                "id=" + id +
                ", address=" + address +
                ", code=" + code +
                ", alley=" + alley +
                ", houseNum=" + houseNum +
                ", status=" + status +
                ", purpose=" + purpose +
                ", controlStatus=" + controlStatus +
                ", isEmpty=" + isEmpty +
                ", constructPurpose=" + constructPurpose +
                ", constructArea=" + constructArea +
                ", createAt=" + createAt +
                ", updateAt=" + updateAt +
                "}";
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/model/dos/ComMngPopulationHouseUserDO.java
New file
@@ -0,0 +1,59 @@
package com.panzhihua.service_community.model.dos;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
 * @auther lyq
 * @create 2021-05-18 09:26:53
 * @describe 房屋居住信息关联表实体类
 */
@Data
@TableName("com_mng_population_house_user")
public class ComMngPopulationHouseUserDO implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * 主键id
     */
    @TableId(type = IdType.AUTO)
    private Long id;
    /**
     * 实有人口id
     */
    private Long populId;
    /**
     * 实有房屋id
     */
    private Long houseId;
    /**
     * 与户主关系(1.户主 2.配偶 3.子女 4.孙女 5.父母 6.其他)
     */
    private Integer relation;
    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    private Date createAt;
    @Override
    public String toString() {
        return "ComMngPopulationHouseUserDO{" +
                "id=" + id +
                ", populId=" + populId +
                ", houseId=" + houseId +
                ", createAt=" + createAt +
                "}";
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationHouseService.java
New file
@@ -0,0 +1,13 @@
package com.panzhihua.service_community.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.panzhihua.service_community.model.dos.ComMngPopulationHouseDO;
/**
 * @auther lyq
 * @create 2021-05-18 09:26:31
 * @describe 社区管理》小区管理》实有房屋服务类
 */
public interface ComMngPopulationHouseService extends IService<ComMngPopulationHouseDO> {
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationHouseUserService.java
New file
@@ -0,0 +1,13 @@
package com.panzhihua.service_community.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.panzhihua.service_community.model.dos.ComMngPopulationHouseUserDO;
/**
 * @auther lyq
 * @create 2021-05-18 09:26:53
 * @describe 房屋居住信息关联表服务类
 */
public interface ComMngPopulationHouseUserService extends IService<ComMngPopulationHouseUserDO> {
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/ComMngPopulationService.java
@@ -63,7 +63,7 @@
     * @param communityId
     * @return
     */
    R listSavePopulation(List<ComMngPopulationServeExcelVO> list, Long communityId);
    R listSavePopulation(List<ComMngPopulationServeExcelVO> list, Long communityId) throws Exception;
    /**
     * 确认导入实有人口(有则更新,无则新建)
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationHouseServiceImpl.java
New file
@@ -0,0 +1,19 @@
package com.panzhihua.service_community.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.service_community.dao.ComMngPopulationHouseDAO;
import com.panzhihua.service_community.model.dos.ComMngPopulationHouseDO;
import com.panzhihua.service_community.service.ComMngPopulationHouseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
 * @auther lyq
 * @create 2021-05-18 09:26:31
 * @describe 社区管理》小区管理》实有房屋服务实现类
 */
@Slf4j
@Service
public class ComMngPopulationHouseServiceImpl extends ServiceImpl<ComMngPopulationHouseDAO, ComMngPopulationHouseDO> implements ComMngPopulationHouseService {
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationHouseUserServiceImpl.java
New file
@@ -0,0 +1,19 @@
package com.panzhihua.service_community.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.service_community.dao.ComMngPopulationHouseUserDAO;
import com.panzhihua.service_community.model.dos.ComMngPopulationHouseUserDO;
import com.panzhihua.service_community.service.ComMngPopulationHouseUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
 * @auther lyq
 * @create 2021-05-18 09:26:53
 * @describe 房屋居住信息关联表服务实现类
 */
@Slf4j
@Service
public class ComMngPopulationHouseUserServiceImpl extends ServiceImpl<ComMngPopulationHouseUserDAO, ComMngPopulationHouseUserDO> implements ComMngPopulationHouseUserService {
}
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComMngPopulationServiceImpl.java
@@ -7,6 +7,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.panzhihua.common.enums.PopulIsOksEnum;
import com.panzhihua.common.exceptions.ServiceException;
import com.panzhihua.common.model.dtos.community.ComMngPopulationDTO;
import com.panzhihua.common.model.dtos.community.ComMngPopulationTagDTO;
@@ -15,26 +16,22 @@
import com.panzhihua.common.model.dtos.community.PageComActDTO;
import com.panzhihua.common.model.helper.AESUtil;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.area.AreaAddressVO;
import com.panzhihua.common.model.vos.community.*;
import com.panzhihua.common.model.vos.user.ComHouseMemberVo;
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.model.vos.user.*;
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;
import com.panzhihua.service_community.model.dos.ComActDO;
import com.panzhihua.service_community.model.dos.ComMngPopulationDO;
import com.panzhihua.service_community.model.dos.ComMngVillageDO;
import com.panzhihua.common.utlis.PayUtil;
import com.panzhihua.service_community.dao.*;
import com.panzhihua.service_community.model.dos.*;
import com.panzhihua.service_community.service.ComMngPopulationService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import com.panzhihua.common.utlis.StringUtils;
import javax.annotation.Resource;
import javax.crypto.BadPaddingException;
@@ -59,6 +56,14 @@
    private ComActDAO comActDAO;
    @Resource
    private ComActVillageDAO comActVillageDAO;
    @Resource
    private ComMngPopulationHouseDAO comMngPopulationHouseDAO;
    @Resource
    private ComStreetDAO comStreetDAO;
    @Resource
    private ComMngCarDAO comMngCarDAO;
    @Resource
    private ComMngPopulationHouseUserDAO comMngPopulationHouseUserDAO;
    @Value("${domain.aesKey:}")
    private String aesKey;
@@ -135,7 +140,7 @@
        BeanUtils.copyProperties(comMngPopulationDO, comMngPopulationVO);
        //查询户主关系信息
        List<ComHouseMemberVo> comMngFamilyInfoVOS = populationDAO.listHouseMermberByUserId(comMngPopulationDO);
        List<ComHouseMemberVo> comMngFamilyInfoVOS = populationDAO.listHouseMermberByUserId(comMngPopulationDO.getHouseId(),comMngPopulationDO.getId());
        if (!comMngFamilyInfoVOS.isEmpty()) {
            comMngPopulationVO.setComMngFamilyInfoVOS(comMngFamilyInfoVOS);
        }
@@ -151,6 +156,18 @@
                    comMngPopulationVO.setFamilyInfoVOList(familyInfoVOList);
                }
            }
        }
        //查询当前用户房屋信息
        List<ComMngHouseVo> houseList = comMngPopulationHouseDAO.getPopulHouseListByPopulId(populationId);
        if(!houseList.isEmpty()){
            comMngPopulationVO.setHouseList(houseList);
        }
        //查询当前实有人口车辆信息
        List<ComMngPopulationCarVO> carList = comMngCarDAO.getPopulationCarListByIdCard(comMngPopulationDO.getCardNo());
        if(!carList.isEmpty()){
            comMngPopulationVO.setCarList(carList);
        }
        return R.ok(comMngPopulationVO);
    }
@@ -175,16 +192,6 @@
        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);
    }
@@ -223,48 +230,165 @@
    }
    @Override
    public R listSavePopulation(List<ComMngPopulationServeExcelVO> list, Long communityId) {
    @Transactional(rollbackFor = Exception.class)
    public R listSavePopulation(List<ComMngPopulationServeExcelVO> list, Long communityId) throws Exception{
        List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>();
        List<ComMngPopulationDO> comMngPopulationDOS = populationDAO.selectList(new QueryWrapper<ComMngPopulationDO>().lambda().eq(ComMngPopulationDO::getActId, communityId));
        //查询该社区所有(实有房屋)小区
//        List<ComMngVillageDO> villageDOList = comActVillageDAO.selectList(new QueryWrapper<ComMngVillageDO>().lambda().eq(ComMngVillageDO::getCommunityId, communityId));
        //查询该社区
        ComActDO comActDO = comActDAO.selectById(communityId);
        ArrayList<ComMngPopulationDO> populationDOList = Lists.newArrayList();
        int index = 2;
        for (ComMngPopulationServeExcelVO vo : list) {
            //判断DB和exel数据重复判断
            boolean result = comMngPopulationDOS.stream().anyMatch(population -> population.getCardNo().equals(vo.getCardNo()));
            if (result) {
                ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO();
                importErrorVO.setErrorMsg("导入实有人口已存在(" + vo.getCardNo() + ")");
                importErrorVO.setErrorPosition("第" + index + "行,第2列");
                populationImportErrorVOList.add(importErrorVO);
                index++;
                continue;
//                return R.fail(501,"导入实有人口已存在(" + vo.getCardNo() + ")");
        //查询该社区的省市区地址
        AreaAddressVO areaAddressVO = populationDAO.getAreaAddress(comActDO.getProvinceCode(),comActDO.getCityCode(),comActDO.getAreaCode());
        //查询社区上街道信息
        String street = "";
        if(comActDO.getStreetId() != null){
            ComStreetDO streetDO = comStreetDAO.selectById(comActDO.getStreetId());
            if(streetDO != null){
                street = streetDO.getName();
            }
            ComMngPopulationDO comMngPopulationDO = new ComMngPopulationDO();
        }
        int index = 2;
        //处理实有人口信息
        List<ComMngPopulationDO> savePopulList = new ArrayList<>();
        for (ComMngPopulationServeExcelVO vo : list) {
            String address = "";
            //查询街路巷是否存在
            ComMngVillageDO comMngVillageDO = comActVillageDAO.selectOne(new QueryWrapper<ComMngVillageDO>().eq("alley",vo.getRoad()).eq("house_num",vo.getDoorNo()).eq("community_id",communityId));
//            ComMngVillageDO comMngVillageDO = villageDOList.stream().filter(village -> village.getAlley().equals(vo.getRoad()) && village.getHouseNum().equals(Integer.valueOf(vo.getDoorNo()))).findFirst().orElse(null);
            BeanUtils.copyProperties(vo, comMngPopulationDO);
            if (comMngVillageDO == null) {
                ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO();
                importErrorVO.setErrorMsg("查无:" + vo.getRoad() + "小区/房租地址,请先新建地址");
                importErrorVO.setErrorMsg("查无:" + vo.getRoad() + vo.getDoorNo() + "小区/房租地址,请先新建地址");
                importErrorVO.setErrorPosition("第" + index + "行,第7、8列");
                populationImportErrorVOList.add(importErrorVO);
                index++;
                continue;
            }
            address = areaAddressVO.getProvince() + areaAddressVO.getCity()
                    + areaAddressVO.getDistrict() + street + comMngVillageDO.getAlley() + comMngVillageDO.getHouseNum() + "号"
                    + vo.getFloor() + vo.getUnitNo() + vo.getHouseNo();
            vo.setAddress(address);
            //先判断房屋是否存在
            ComMngPopulationHouseDO populationHouseDO = comMngPopulationHouseDAO.selectOne(new QueryWrapper<ComMngPopulationHouseDO>().lambda()
                    .eq(ComMngPopulationHouseDO::getCommunityId,communityId).eq(ComMngPopulationHouseDO::getAlley,vo.getRoad()).eq(ComMngPopulationHouseDO::getHouseNum,vo.getDoorNo())
                    .eq(ComMngPopulationHouseDO::getFloor,vo.getFloor()).eq(ComMngPopulationHouseDO::getUnitNo,vo.getUnitNo())
                    .eq(ComMngPopulationHouseDO::getHouseNo,vo.getHouseNo()));
            if(populationHouseDO == null){
                //查询该房屋未建立,执行建立房屋信息
                populationHouseDO = new ComMngPopulationHouseDO();
                populationHouseDO.setAlley(vo.getRoad());
                populationHouseDO.setHouseNum(vo.getDoorNo());
                populationHouseDO.setCommunityId(communityId);
                populationHouseDO.setFloor(vo.getFloor());
                populationHouseDO.setUnitNo(vo.getUnitNo());
                populationHouseDO.setHouseNo(vo.getHouseNo());
                populationHouseDO.setAddress(address);
                if(StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())){
                    populationHouseDO.setIsEmpty(PopulIsOksEnum.YES.getCode());
                }
                if(vo.getHouseStatus() != null){
                    populationHouseDO.setStatus(vo.getHouseStatus());
                }
                if(vo.getHousePurpose() != null){
                    populationHouseDO.setPurpose(vo.getHousePurpose());
                }
                if(vo.getControlStatus() != null){
                    populationHouseDO.setControlStatus(vo.getControlStatus());
                }
                comMngPopulationHouseDAO.insert(populationHouseDO);
            }
            if(StringUtils.isEmpty(vo.getName()) && StringUtils.isEmpty(vo.getCardNo())){
                //空户处理完房屋信息,直接返回
                continue;
            }
            //判断实有人口是否已存在
            ComMngPopulationDO populationDO = this.baseMapper.selectOne(new QueryWrapper<ComMngPopulationDO>().lambda()
                    .eq(ComMngPopulationDO::getCardNo,AESUtil.encrypt128(vo.getCardNo(), aesKey)).eq(ComMngPopulationDO::getName,vo.getName()));
            if(populationDO == null){
                if(savePopulList.size() > 0){
                    String name = vo.getName();
                    String cardNo = AESUtil.encrypt128(vo.getCardNo(), aesKey);
                    if(savePopulList.stream().anyMatch(populDo -> name.equals(populDo.getName()) && cardNo.equals(populDo.getCardNo()))){
                        //实有人口已存在,判断录入的这个房屋信息是否是用户的居住地
                        for (ComMngPopulationDO savePopul:savePopulList) {
                            if(savePopul.getName().equals(name) && savePopul.getCardNo().equals(cardNo)){
                                if(vo.getIsResidence() != null && vo.getIsResidence().equals(PopulIsOksEnum.YES.getCode())) {
                                    savePopul.setRoad(vo.getRoad());
                                    savePopul.setDoorNo(vo.getDoorNo());
                                    savePopul.setFloor(vo.getFloor());
                                    savePopul.setUnitNo(vo.getUnitNo());
                                    savePopul.setHouseNo(vo.getHouseNo());
                                    savePopul.setHouseAddress(vo.getAddress());
                                    savePopul.setHouseId(populationHouseDO.getId());
                                    savePopul.setCardNo(cardNo);
                                    savePopul.setPhone(AESUtil.encrypt128(savePopul.getPhone(), aesKey));
                                    this.baseMapper.updateById(savePopul);
                                }
                                populationDO = savePopul;
                                break;
                            }
                        }
                    }else{
                        //不存在实有人口则新增
                        populationDO = new ComMngPopulationDO();
                        BeanUtils.copyProperties(vo,populationDO);
            List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
            comMngPopulationDO.setVillageId(comMngVillageDO.getVillageId());
            comMngPopulationDO.setActId(comActDO.getCommunityId());
            comMngPopulationDO.setStreetId(comActDO.getStreetId());
            comMngPopulationDO.setLabel(Joiner.on(",").join(userTag));
            comMngPopulationDO.setVillageName(comMngVillageDO.getGroupAt());
            populationDOList.add(comMngPopulationDO);
                        populationDO.setVillageId(comMngVillageDO.getVillageId());
                        populationDO.setActId(comActDO.getCommunityId());
                        populationDO.setStreetId(comActDO.getStreetId());
                        populationDO.setLabel(Joiner.on(",").join(userTag));
                        populationDO.setVillageName(comMngVillageDO.getGroupAt());
                        populationDO.setHouseAddress(address);
                        populationDO.setHouseId(populationHouseDO.getId());
                        this.baseMapper.insert(populationDO);
                        savePopulList.add(populationDO);
            index++;
                    }
                }else {
                    //不存在实有人口则新增
                    populationDO = new ComMngPopulationDO();
                    BeanUtils.copyProperties(vo,populationDO);
                    List<String> userTag = vo.getUserTagStr().stream().map(userTagStr -> userTagStr.split("\\(")[0]).collect(Collectors.toList());
                    populationDO.setVillageId(comMngVillageDO.getVillageId());
                    populationDO.setActId(comActDO.getCommunityId());
                    populationDO.setStreetId(comActDO.getStreetId());
                    populationDO.setLabel(Joiner.on(",").join(userTag));
                    populationDO.setVillageName(comMngVillageDO.getGroupAt());
                    populationDO.setHouseAddress(address);
                    populationDO.setHouseId(populationHouseDO.getId());
                    this.baseMapper.insert(populationDO);
                    savePopulList.add(populationDO);
                    index++;
                }
            }else {
                //实有人口已存在,判断录入的这个房屋信息是否是用户的居住地
                if(vo.getIsResidence() != null && vo.getIsResidence().equals(PopulIsOksEnum.YES.getCode())){
                    populationDO.setRoad(vo.getRoad());
                    populationDO.setDoorNo(vo.getDoorNo());
                    populationDO.setFloor(vo.getFloor());
                    populationDO.setUnitNo(vo.getUnitNo());
                    populationDO.setHouseNo(vo.getHouseNo());
                    populationDO.setHouseAddress(address);
                    populationDO.setCardNo(AESUtil.encrypt128(populationDO.getCardNo(), aesKey));
                    populationDO.setPhone(AESUtil.encrypt128(populationDO.getPhone(), aesKey));
                    populationDO.setHouseId(populationHouseDO.getId());
                    this.baseMapper.updateById(populationDO);
                }
            }
            //处理实有房屋居住信息
            if(populationDO != null){
                ComMngPopulationHouseUserDO populationHouseUserDO = comMngPopulationHouseUserDAO.selectOne(new QueryWrapper<ComMngPopulationHouseUserDO>()
                        .lambda().eq(ComMngPopulationHouseUserDO::getHouseId,populationHouseDO.getId())
                        .eq(ComMngPopulationHouseUserDO::getPopulId,populationDO.getId()));
                if(populationHouseUserDO == null){
                    populationHouseUserDO = new ComMngPopulationHouseUserDO();
                    populationHouseUserDO.setHouseId(populationHouseDO.getId());
                    populationHouseUserDO.setPopulId(populationDO.getId());
                    populationHouseUserDO.setRelation(populationDO.getRelation());
                    comMngPopulationHouseUserDAO.insert(populationHouseUserDO);
                }
            }
        }
        //如果有错误,返回错误
        //暂时注释,等客户完成任务需要恢复
@@ -273,11 +397,10 @@
        }
        this.saveBatch(populationDOList);*/
        this.saveBatch(populationDOList);
        if(!populationImportErrorVOList.isEmpty()){
            return R.fail(JSON.toJSONString(populationImportErrorVOList));
        }
        return R.ok("共计导入实有人口数量:" + populationDOList.size());
        return R.ok();
    }
    /**