Null
2021-03-18 d132ccb2e8e8d92088b9c452a00087b1a8518417
居民管理
8个文件已修改
3个文件已添加
803 ■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/user/InputUserTagsDTO.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/user/PageInputUserDTO.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/InputUserInfoVO.java 125 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/user/UserService.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommonDataApi.java 167 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/api/UserApi.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/SysUserInputDAO.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/UserDao.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/model/dos/SysUserInputDO.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/SysUserInputService.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/SysUserInputServiceImpl.java 180 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/user/InputUserTagsDTO.java
New file
@@ -0,0 +1,26 @@
package com.panzhihua.common.model.dtos.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
 * @description: 居民标签设置参数
 * @author: Null
 * @date: 2021/3/11 10:36
 */
@Data
@ApiModel(value = "居民标签设置参数")
public class InputUserTagsDTO implements Serializable {
    @ApiModelProperty("用户编号")
    private Long id;
    @ApiModelProperty("设置用户标签多个用,分割")
    private String tags;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/dtos/user/PageInputUserDTO.java
New file
@@ -0,0 +1,35 @@
package com.panzhihua.common.model.dtos.user;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
 * @description: 居民信息excel导入
 * @author: huang.hongfa weixin hhf9596 qq 959656820
 * @create: 2021-02-04 16:06
 **/
@Data
@ApiModel("居民管理分页列表请求参数")
public class PageInputUserDTO {
    @ApiModelProperty("姓名")
    private String name;
    @ApiModelProperty("联系方式")
    private String phone;
    @ApiModelProperty(value = "社区id",hidden = true)
    private Long communityId;
    @ApiModelProperty("小区Id")
    private String areaId;
    @ApiModelProperty(value = "分页-当前页数",example = "1")
    private Long pageNum;
    @ApiModelProperty(value = "分页-每页记录数",example = "10")
    private Long pageSize;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/user/InputUserInfoVO.java
New file
@@ -0,0 +1,125 @@
package com.panzhihua.common.model.vos.user;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.panzhihua.common.model.vos.community.ComMngStructHouseVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
 * @description: 居民数据信息
 * @author: Null
 * @date: 2021/3/11 10:36
 */
@Data
@ApiModel(value = "居民数据信息")
public class InputUserInfoVO implements Serializable {
    @ApiModelProperty("用户编号")
    private Long id;
    @ApiModelProperty("生日")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date birthday;
    @ApiModelProperty("门牌号")
    private String doorNumber;
    @ApiModelProperty("是否租住 0 不是 1 是")
    private Integer isRent;
    @ApiModelProperty("姓名")
    private String name;
    @ApiModelProperty("民族")
    private String nation;
    @ApiModelProperty("政治面貌:1 - 党员;2 - 团员;3 - 群众")
    private Integer politicalOutlook;
    @ApiModelProperty("0 未婚 1 已婚")
    private Integer maritalStatus;
    @ApiModelProperty("联系方式")
    private String phone;
    @ApiModelProperty("文化程度")
    private String education;
    @ApiModelProperty("身份证")
    private String idCard;
    @ApiModelProperty("工作单位(学校)")
    private String company;
    @ApiModelProperty("户口所在地")
    private String residence;
    @ApiModelProperty("目前是否在攀枝花 0 否 1 是")
    private Integer isPanzhihua;
    @ApiModelProperty("近一个月离(返)攀情况")
    private String situation;
    @ApiModelProperty("是否有与疑似或确诊病例密切接触史 0 否 1 是")
    private Integer isContact;
    @ApiModelProperty("是否特殊情况(重大过往病史或者孕妇) 0 否 1是")
    private Integer major;
    @ApiModelProperty("是否退伍军人 0 否 1是")
    private Integer soldier;
    @ApiModelProperty("是否低保户 0 否 1是")
    private Integer lowincomeHouseholds;
    @ApiModelProperty("是否低收入人员 0否 1是")
    private Integer lowincomePeople;
    @ApiModelProperty("是否高龄老人 0否 1是")
    private Integer oldPeople;
    @ApiModelProperty("是否特服家庭 0 否 1是")
    private Integer specialServiceFamily;
    @ApiModelProperty("是否重点人员 0 否 1是")
    private Integer keyPersonnel;
    @ApiModelProperty("社区id")
    private Long communityId;
    @ApiModelProperty("小区id")
    private Long areaId;
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date createAt;
    @ApiModelProperty("修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date updateAt;
    @ApiModelProperty("是否残疾人 0 否 1是")
    private Integer disability;
    @ApiModelProperty("专享政策")
    private String tags;
    @ApiModelProperty("年龄")
    private Integer age;
    @ApiModelProperty("性别")
    private Integer sex;
    @ApiModelProperty("家庭成员")
    private List<ComMngFamilyInfoVO> comMngFamilyInfoVOS;
    @ApiModelProperty("房屋信息")
    private List<ComMngStructHouseVO> comMngStructHouseVOS;
}
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/service/user/UserService.java
@@ -3,10 +3,7 @@
import com.panzhihua.common.model.dtos.PageDTO;
import com.panzhihua.common.model.dtos.community.ExportUserDTO;
import com.panzhihua.common.model.dtos.community.NoticeReadDTO;
import com.panzhihua.common.model.dtos.user.EexcelUserDTO;
import com.panzhihua.common.model.dtos.user.PageFeedBackDTO;
import com.panzhihua.common.model.dtos.user.PageUserAppletsBackstageDTO;
import com.panzhihua.common.model.dtos.user.SysUserFeedbackDTO;
import com.panzhihua.common.model.dtos.user.*;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.MenuVO;
import com.panzhihua.common.model.vos.R;
@@ -545,5 +542,47 @@
     */
    @GetMapping("getUserByPhone")
    R getSysUserVOByPhone(@RequestParam(value = "phone") String phone);
    /**
     * 基础数据》居民管理》居民列表
     * @param pageInputUserDTO 查询参数
     * @return 分页数据
     */
    @PostMapping("common/data/user/page")
    R pageInputUser(@RequestBody PageInputUserDTO pageInputUserDTO);
    /**
     * 基础数据》居民管理》设置用户标签
     * @param inputUserTagsDTO 标签信息
     * @return 设置结果
     */
    @PostMapping("common/data/user/tags")
    R setInputUserTag(@RequestBody InputUserTagsDTO inputUserTagsDTO);
    /**
     * 基础数据》居民管理》批量导入居民用户
     * @param list 居民用户集合
     * @param areaName 小区名字
     * @return 导入结果
     */
    @PostMapping("common/data/user/import")
    R batchSaveInputUser(@RequestBody List<EexcelUserDTO> list,@RequestParam("areaName")StringBuffer areaName);
    /**
     * 基础数据》居民管理》 居民详情
     * @param id 人员id
     * @return CommunityUserInfoVO
     */
    @PostMapping("/common/data/user/detail")
    R inputUserDetail(@RequestParam("id")Long id);
    /**
     *  基础数据》居民管理》 导出居民信息
     * @param exportUserDTO 用户搜索内容
     * @return List<EexcelUserDTO> excel内容
     */
    @PostMapping("/common/data/user/export")
    R inputUserExport(@RequestBody ExportUserDTO exportUserDTO);
    
}
springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/CommonDataApi.java
@@ -1,23 +1,37 @@
package com.panzhihua.community_backstage.api;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.enums.CellExtraTypeEnum;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson.JSONObject;
import com.jcraft.jsch.SftpException;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.listen.ComCvtServeExcelListen;
import com.panzhihua.common.listen.ComMngCarExcelListen;
import com.panzhihua.common.model.dtos.community.ComMngCarSaveDTO;
import com.panzhihua.common.model.dtos.community.PageComMngCarDTO;
import com.panzhihua.common.model.dtos.user.EexcelUserDTO;
import com.panzhihua.common.model.dtos.user.InputUserTagsDTO;
import com.panzhihua.common.model.dtos.user.PageInputUserDTO;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComCvtServeExcelVO;
import com.panzhihua.common.model.vos.community.ComMngCarExcelVO;
import com.panzhihua.common.model.vos.community.ComMngCarVO;
import com.panzhihua.common.model.vos.community.*;
import com.panzhihua.common.model.vos.user.CommunityUserInfoVO;
import com.panzhihua.common.model.vos.user.InputUserInfoVO;
import com.panzhihua.common.service.community.CommunityService;
import com.panzhihua.common.service.user.UserService;
import com.panzhihua.common.utlis.SFTPUtil;
import com.panzhihua.common.validated.AddGroup;
import com.panzhihua.community_backstage.easyexcel.UploadEexcelUserDTOListener;
import com.panzhihua.community_backstage.excel.CustomSheetWriteHandler;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -25,8 +39,13 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
 * @description: 社区管理基础数据库管理接口
@@ -41,7 +60,10 @@
    @Resource
    private CommunityService communityService;
    @Resource
    private UserService userService;
    @Value("${excel.userurl}")
    private String excelUrl;
    @Value("${excel.carUrl}")
    private String carUrl="http://panzhihua.nhys.cdnhxx.com/web/%e8%bd%a6%e8%be%86%e5%af%bc%e5%85%a5%e6%a8%a1%e6%9d%bf.xlsx";
    // FTP 登录用户名
@@ -102,4 +124,141 @@
        }
        return R.ok();
    }
    @ApiOperation(value = "下载居民导入模板")
    @GetMapping("/user/template")
    @ApiImplicitParam(name ="id",value = "小区id",required = true)
    public R exportUser(@RequestParam("id") Long id ){
//        检查小区是否已经批量设置过房屋并且返回小区房屋门号规则
        R r=communityService.checkAreaHouse(id);
        if (R.isOk(r)) {
//            生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址
            ComMngStructAreaVO comMngStructAreaVO= JSONObject.parseObject(JSONObject.toJSONString(r.getData()),ComMngStructAreaVO.class);
            String areaName = comMngStructAreaVO.getAreaName();
            String roleFloor = comMngStructAreaVO.getRoleFloor();
            String roleConnector = comMngStructAreaVO.getRoleConnector();
            String roleDoor = comMngStructAreaVO.getRoleDoor();
            String doorNumber="1-1-1-"+roleFloor+roleConnector+roleDoor;
//            String url="http://www.psciio.com/web/excel/";
            String ftpUrl="/mnt/data/web/excel/";
            String name=areaName + ".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 {
                        excelWriter = EasyExcel.write(fileName, EexcelUserDTO.class).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerWriteHandler(new CustomSheetWriteHandler()).build();
                        WriteSheet writeSheet = EasyExcel.writerSheet(areaName+"居民导入模板").build();
                        List<EexcelUserDTO> eexcelUserDTOS=new ArrayList<>();
                        EexcelUserDTO eexcelUserDTO=new EexcelUserDTO();
                        eexcelUserDTO.setOrder("例子(可不用删除)");
                        eexcelUserDTO.setDoorNumber(doorNumber);
                        eexcelUserDTO.setIsRent("是");
                        eexcelUserDTO.setName("张三");
                        eexcelUserDTO.setNation("汉");
                        eexcelUserDTO.setPoliticalOutlook("群众");
                        eexcelUserDTO.setMaritalStatus("已婚");
                        eexcelUserDTO.setPhone("13545789626");
                        eexcelUserDTO.setEducation("高中");
                        eexcelUserDTO.setIdCard("342589457896122557");
                        eexcelUserDTO.setCompany("恰恰食品厂");
                        eexcelUserDTO.setResidence("攀枝花");
                        eexcelUserDTO.setIsPanZhiHua("是");
                        eexcelUserDTO.setSituation("1月27日返攀");
                        eexcelUserDTO.setIsContact("否");
                        eexcelUserDTO.setMajor("否");
                        eexcelUserDTO.setSoldier("否");
                        eexcelUserDTO.setDisability("否");
                        eexcelUserDTO.setLowIncomePeople("否");
                        eexcelUserDTO.setLowIncomeHouseholds("否");
                        eexcelUserDTO.setOldPeople("否");
                        eexcelUserDTO.setSpecialServiceFamily("否");
                        eexcelUserDTO.setKeyPersonnel("否");
                        eexcelUserDTOS.add(eexcelUserDTO);
                        excelWriter.write(eexcelUserDTOS, 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+areaName+".xlsx");
            } catch (Exception e) {
                e.printStackTrace();
                log.error("文件传输失败【{}】", e.getMessage());
                return R.fail();
            }
        }else{
            return r;
        }
    }
    @ApiOperation(value = "居民管理导入居民")
    @PostMapping("/user/import")
    public R importUser(@RequestParam MultipartFile file)throws IOException {
        String name = file.getOriginalFilename();
        Float size = Float.parseFloat(String.valueOf(file.getSize())) / 1024;
        BigDecimal b = new BigDecimal(size);
        size = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
        log.info("导入文件名字【{}】,文件大小【{}】KB",name,size);
        String fileType=name.substring(name.indexOf("."),name.length());
        boolean isXls = !fileType.contains("xls") && !fileType.contains("xlsx");
        if (isXls) {
            return R.fail("请上传xls或者xlsx格式的文件");
        }
        EasyExcel.read(file.getInputStream(), EexcelUserDTO.class, new UploadEexcelUserDTOListener(userService,name)) .extraRead(CellExtraTypeEnum.MERGE).headRowNumber(1).sheet().doRead();
        return R.ok();
    }
    @ApiOperation(value = "居民管理选择导入的小区",response =ComMngStructAreaVO.class )
    @GetMapping("/user/areas")
    public R listAreas() {
        Long communityId = this.getCommunityId();
        return communityService.listAreas(null,communityId);
    }
    @ApiOperation(value = "居民管理 分页查询居民列表",response =InputUserInfoVO.class )
    @PostMapping("/user/page")
    public R userPage(@RequestBody PageInputUserDTO pageInputUserDTO) {
        Long communityId = this.getCommunityId();
        pageInputUserDTO.setCommunityId(communityId);
        return userService.pageInputUser(pageInputUserDTO);
    }
    @ApiOperation(value = "居民管理 居民详情",response = InputUserInfoVO.class)
    @GetMapping("/user/detail")
    @ApiImplicitParam(name ="id",value = "用户ID",required = true)
    public R detailUser(@RequestParam("id")Long id){
        return userService.inputUserDetail(id);
    }
    /**
     * 设置居民标签
     * @param inputUserTagsDTO 标签信息
     * @return 设置结果
     */
    @ApiOperation(value = "居民管理 设置居民标签",response = InputUserInfoVO.class)
    @PostMapping("/user/tags")
    public R putUserTag(@RequestBody InputUserTagsDTO inputUserTagsDTO){
        return userService.setInputUserTag(inputUserTagsDTO);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/api/UserApi.java
@@ -3,10 +3,7 @@
import com.panzhihua.common.model.dtos.PageDTO;
import com.panzhihua.common.model.dtos.community.ExportUserDTO;
import com.panzhihua.common.model.dtos.community.NoticeReadDTO;
import com.panzhihua.common.model.dtos.user.EexcelUserDTO;
import com.panzhihua.common.model.dtos.user.PageFeedBackDTO;
import com.panzhihua.common.model.dtos.user.PageUserAppletsBackstageDTO;
import com.panzhihua.common.model.dtos.user.SysUserFeedbackDTO;
import com.panzhihua.common.model.dtos.user.*;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.SystemmanagementConfigVO;
@@ -602,4 +599,71 @@
    public R getSysUserVOByPhone(@RequestParam(value = "phone") String phone){
        return userService.getSysUserVOByPhone(phone);
    }
    /**
     *分页查询人口管理
     * @param pageInputUserDTO 查询参数
     * @return 分页数据
     */
    @PostMapping("/common/data/user/page")
    public R pageInputUser(@RequestBody PageInputUserDTO pageInputUserDTO){
        return sysUserInputService.pageInputUser(pageInputUserDTO);
    }
    /**
     * 设置用户标签
     * @param inputUserTagsDTO 标签信息
     * @return 设置结果
     */
    @PostMapping("/common/data/user/tags")
    public R setInputUserTag(@RequestBody InputUserTagsDTO inputUserTagsDTO){
        return sysUserInputService.putUserTag(inputUserTagsDTO);
    }
    /**
     * 批量导入居民用户
     * @param list 居民用户集合
     * @param areaName 小区名字
     * @return 导入结果
     */
    @PostMapping("/common/data/user/import")
    public R batchSaveInputUser(@RequestBody List<EexcelUserDTO> list,@RequestParam("areaName")StringBuffer areaName){
        R r = null;
        try {
            r = sysUserInputService.batchSaveUser(list, areaName);
        } catch (Exception e) {
            String message = e.getMessage();
            log.error(message);
            if (message.contains("unique_id_card")) {
                int i = message.indexOf("'");
                String idcard = message.substring(i + 1, message.indexOf("'", i + 1));
//                System.out.println(idcard);
                return R.fail("身份证存在重复"+idcard);
            }else {
                return R.fail(e.getMessage());
            }
        }
        return r;
    }
    /**
     *  居民管理》居民详情
     * @param id 人员id
     * @return CommunityUserInfoVO
     */
    @PostMapping("/common/data/user/detail")
    public R inputUserDetail(@RequestParam("id")Long id){
        InputUserInfoVO inputUserInfoVO=sysUserInputService.inputUserDetail(id);
        return R.ok(inputUserInfoVO);
    }
    /**
     *  用户搜索了就下载搜索的用户否则下载所有用户
     * @param exportUserDTO 用户搜索内容
     * @return List<EexcelUserDTO> excel内容
     */
    @PostMapping("/common/data/user/export")
    public R inputUserExport(@RequestBody ExportUserDTO exportUserDTO){
        return sysUserInputService.export(exportUserDTO);
    }
}
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/SysUserInputDAO.java
@@ -1,9 +1,13 @@
package com.panzhihua.service_user.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.dtos.user.PageInputUserDTO;
import com.panzhihua.common.model.vos.community.ComMngStructAreaVO;
import com.panzhihua.common.model.vos.community.ComMngStructHouseVO;
import com.panzhihua.common.model.vos.user.ComMngFamilyInfoVO;
import com.panzhihua.common.model.vos.user.InputUserInfoVO;
import com.panzhihua.service_user.model.dos.SysUserInputDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -54,4 +58,74 @@
            "\tp.door_number = #{doorNumber} \n" +
            "\tAND p.id !=#{userId}")
    List<ComMngFamilyInfoVO> selectListFamily(@Param("doorNumber") String doorNumber, @Param("userId")Long userId);
    @Select("<script> " +
            "SELECT " +
            " t.`name`, " +
            "CASE " +
            " IF " +
            "  ( " +
            "   length( t.id_card ) = 18, " +
            "   cast( substring( t.id_card, 17, 1 ) AS UNSIGNED ) % 2, " +
            "  IF " +
            "   ( " +
            "    length( t.id_card ) = 15, " +
            "    cast( substring( t.id_card, 15, 1 ) AS UNSIGNED ) % 2, " +
            "    3  " +
            "   )  " +
            "  )  " +
            "  WHEN 1 THEN " +
            "  1  " +
            "  WHEN 0 THEN " +
            "  2 ELSE 0  " +
            " END AS sex, " +
            " t.phone, " +
            " YEAR ( now( ) ) - YEAR ( substring( t.id_card, 7, 8 ) ) age, " +
            " t1.area_name, " +
            " t.political_outlook politicalOutlook, " +
            " CONCAT( " +
            " IF " +
            "  ( t.soldier = 1, '军人,', '' ), " +
            " IF " +
            "  ( t.lowIncome_households = 1, '低保户,', '' ), " +
            " IF " +
            "  ( t.lowIncome_people = 1, '低收入,', '' ), " +
            " IF " +
            "  ( t.old_people = 1, '特服家庭,', '' ), " +
            " IF " +
            "  ( t.key_personnel = 1, '重点人员,', '' )  " +
            " ) tags  " +
            "FROM " +
            " sys_user_input t " +
            " LEFT JOIN com_mng_struct_area t1 ON t.area_id = t1.id  " +
            "WHERE " +
            " t.community_id = #{pageInputUserDTO.communityId}"+
            "<if test='pageInputUserDTO.name != null and pageInputUserDTO.name.trim() != &quot;&quot;'>" +
            " and t.`name` like concat(#{pageInputUserDTO.name},'%')  " +
            " </if> " +
            "<if test='pageInputUserDTO.phone != null and pageInputUserDTO.phone.trim() != &quot;&quot;'>" +
            " and t.phone like concat(#{pageInputUserDTO.phone},'%')  " +
            " </if> " +
            "<if test='pageInputUserDTO.areaId != null and pageInputUserDTO.areaId.trim() != &quot;&quot;'>" +
            " and t.area_id = #{pageInputUserDTO.areaId}  " +
            " </if> " +
            " group by t.id_card "+
            "</script>")
    IPage<InputUserInfoVO> pageInputUser(Page page, @Param("pageInputUserDTO") PageInputUserDTO pageInputUserDTO);
    @Select("select a.id,a.community_id,a.area_name,address_detail from com_mng_struct_area a where a.community_id=#{communityId}")
    List<ComMngStructAreaVO> selectComMngStructArea(@Param("communityId") Long communityId);
    @Select("" +
            "SELECT " +
            " t1.house_code houseCode, " +
            " t1.house_name houseName, " +
            " t1.square, " +
            " t1.state " +
            "FROM " +
            " sys_user_input t  " +
            " LEFT JOIN com_mng_struct_house t1 ON t.house_code = t1.house_code " +
            " WHERE" +
            " t.id_card = #{idCard}")
    List<ComMngStructHouseVO> selectUserHouseList(@Param("idCard") String idCard);
}
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/dao/UserDao.java
@@ -107,45 +107,6 @@
            "<if test='loginUserInfoVO.phone != null and loginUserInfoVO.phone.trim() != &quot;&quot;'>" +
            "AND u.phone like concat(#{loginUserInfoVO.phone},'%') " +
            " </if> " +
            "union all "+
            "SELECT \n" +
            "u.id+100000000 user_id,\n" +
            "u.`name`,\n" +
            "case if(length(u.id_card)=18, cast(substring(u.id_card,17,1) as UNSIGNED)%2, if(length(u.id_card)=15,cast(substring(u.id_card,15,1) as UNSIGNED)%2,3)) \n" +
            "when 1 then 1\n" +
            "when 0 then 2\n" +
            "else 0\n" +
            "end as sex,\n" +
            "'' nick_name,\n" +
            "u.phone,\n" +
            "YEAR (now()) - YEAR (substring(u.id_card, 7, 8)) age,\n" +
            "if(su.user_id is null ,0,1)isRegister,\n" +
            "u.political_outlook,\n" +
            "u.id_card,\n" +
            "'' job,\n" +
            "c.area_name communityName,\n" +
            "CONCAT(if(u.soldier=1,'军人,',''),if(u.lowIncome_households=1,'低保户,',''),if(u.lowIncome_people=1,'低收入,',''),if(u.old_people=1,'特服家庭,',''),if(u.key_personnel=1,'重点人员,',''))tags,\n" +
            "u.create_at\n" +
            "FROM\n" +
            "\tsys_user_input u\n" +
            "\tLEFT JOIN sys_user su on su.id_card=u.id_card"+
            "<if test='loginUserInfoVO.communityName != null and loginUserInfoVO.communityName.trim() != &quot;&quot;'>" +
            " JOIN com_mng_struct_area c ON u.area_id = c.id \n" +
            " </if> " +
            "<if test='loginUserInfoVO.communityName == null or loginUserInfoVO.communityName.trim() == &quot;&quot;'>" +
            "LEFT JOIN com_mng_struct_area c ON u.area_id = c.id \n" +
            " </if> " +
            "<if test='loginUserInfoVO.communityName != null and loginUserInfoVO.communityName.trim() != &quot;&quot;'>" +
            "AND c.`area_name` like concat(#{loginUserInfoVO.communityName},'%')  \n" +
            " </if> " +
            " where u.community_id=#{loginUserInfoVO.communityId} " +
            "<if test='loginUserInfoVO.phone != null and loginUserInfoVO.phone.trim() != &quot;&quot;'>" +
            "AND u.phone like concat(#{loginUserInfoVO.phone},'%') " +
            " </if> " +
            "<if test='loginUserInfoVO.name != null and loginUserInfoVO.name.trim() != &quot;&quot;'>" +
            " and u.`name` like concat(#{loginUserInfoVO.name},'%')  \n" +
            " </if> " +
            "</script>")
    IPage<LoginUserInfoVO> pageUser(Page page, @Param("loginUserInfoVO") LoginUserInfoVO loginUserInfoVO);
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/model/dos/SysUserInputDO.java
@@ -159,4 +159,9 @@
     * 残疾人
     */
    private Integer disability;
    /**
     * 标签
     */
    private String tags;
}
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/SysUserInputService.java
@@ -1,9 +1,14 @@
package com.panzhihua.service_user.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.panzhihua.common.model.dtos.community.ExportUserDTO;
import com.panzhihua.common.model.dtos.user.EexcelUserDTO;
import com.panzhihua.common.model.dtos.user.InputUserTagsDTO;
import com.panzhihua.common.model.dtos.user.PageInputUserDTO;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.user.CommunityUserInfoVO;
import com.panzhihua.common.model.vos.user.InputUserInfoVO;
import com.panzhihua.service_user.model.dos.SysUserInputDO;
import java.util.List;
@@ -28,4 +33,32 @@
     * @return CommunityUserInfoVO
     */
    CommunityUserInfoVO detailUserComunity(Long userId);
    /**
     * 分页查询居民数据
     * @param pageInputUserDTO
     * @return
     */
    R pageInputUser(PageInputUserDTO pageInputUserDTO);
    /**
     * 设置标签
     * @param inputUserTagsDTO
     * @return
     */
    R putUserTag(InputUserTagsDTO inputUserTagsDTO);
    /**
     * 导出居民信息
     * @param exportUserDTO
     * @return
     */
    R export(ExportUserDTO exportUserDTO);
    /**
     * 居民详情
     * @param id
     * @return
     */
    InputUserInfoVO inputUserDetail(Long id);
}
springcloud_k8s_panzhihuazhihuishequ/service_user/src/main/java/com/panzhihua/service_user/service/impl/SysUserInputServiceImpl.java
@@ -2,16 +2,24 @@
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.exceptions.ServiceException;
import com.panzhihua.common.model.dtos.community.ExportUserDTO;
import com.panzhihua.common.model.dtos.user.EexcelUserDTO;
import com.panzhihua.common.model.dtos.user.InputUserTagsDTO;
import com.panzhihua.common.model.dtos.user.PageInputUserDTO;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.ComMngStructAreaVO;
import com.panzhihua.common.model.vos.community.ComMngStructHouseVO;
import com.panzhihua.common.model.vos.community.ComMngVolunteerMngVO;
import com.panzhihua.common.model.vos.user.ComMngFamilyInfoVO;
import com.panzhihua.common.model.vos.user.CommunityUserInfoVO;
import com.panzhihua.common.model.vos.user.InputUserInfoVO;
import com.panzhihua.common.utlis.IdCard;
import com.panzhihua.common.utlis.SensitiveUtil;
import com.panzhihua.service_user.dao.SysUserInputDAO;
import com.panzhihua.service_user.model.dos.ComMngFamilyInfoDO;
import com.panzhihua.service_user.model.dos.SysUserDO;
@@ -66,41 +74,52 @@
            }
            List<ComMngStructHouseVO> comMngStructHouseVOS1=comMngStructHouseVOS;
            list.forEach(eexcelUserDTO -> {
                SysUserInputDO sysUserInputDO=new SysUserInputDO();
                String doorNumber = eexcelUserDTO.getDoorNumber();
                List<ComMngStructHouseVO> collect = comMngStructHouseVOS1.stream().filter(comMngStructHouseVO -> comMngStructHouseVO.getHouseName().equals(doorNumber)).collect(Collectors.toList());
                if (ObjectUtils.isEmpty(collect)) {
                    throw new ServiceException("门牌号后台不存在或格式错误,错误门牌号为"+doorNumber);
                }else{
                    sysUserInputDO.setHouseCode(collect.get(0).getHouseCode());
                }
                sysUserInputDO.setAreaId(comMngStructAreaVO.getId());
                sysUserInputDO.setCommunityId(comMngStructAreaVO.getCommunityId());
                sysUserInputDO.setCompany(eexcelUserDTO.getCompany());
                sysUserInputDO.setDoorNumber(doorNumber);
                sysUserInputDO.setEducation(eexcelUserDTO.getEducation());
                sysUserInputDO.setIdCard(eexcelUserDTO.getIdCard());
                sysUserInputDO.setIsContact(eexcelUserDTO.getIsContact().equals("是")?1:0);
                sysUserInputDO.setIsPanzhihua(eexcelUserDTO.getIsPanZhiHua().equals("是")?1:0);
                sysUserInputDO.setIsRent(eexcelUserDTO.getIsRent().equals("是")?1:0);
                sysUserInputDO.setKeyPersonnel(eexcelUserDTO.getKeyPersonnel().equals("是")?1:0);
                sysUserInputDO.setLowincomeHouseholds(eexcelUserDTO.getLowIncomeHouseholds().equals("是")?1:0);
                sysUserInputDO.setLowincomePeople(eexcelUserDTO.getLowIncomePeople().equals("是")?1:0);
                sysUserInputDO.setMajor(eexcelUserDTO.getMajor().equals("是")?1:0);
                sysUserInputDO.setMaritalStatus(eexcelUserDTO.getMaritalStatus().equals("是")?1:0);
                sysUserInputDO.setName(eexcelUserDTO.getName());
                sysUserInputDO.setNation(eexcelUserDTO.getNation());
                sysUserInputDO.setOldPeople(eexcelUserDTO.getOldPeople().equals("是")?1:0);
                sysUserInputDO.setDisability(eexcelUserDTO.getDisability().equals("是")?1:0);
                sysUserInputDO.setPhone(eexcelUserDTO.getPhone());
                String politicalOutlook = eexcelUserDTO.getPoliticalOutlook();
                sysUserInputDO.setPoliticalOutlook(politicalOutlook.equals("党员")?1:politicalOutlook.equals("团员")?2:3);
                sysUserInputDO.setResidence(eexcelUserDTO.getResidence());
                sysUserInputDO.setSituation(eexcelUserDTO.getSituation());
                sysUserInputDO.setSoldier(eexcelUserDTO.getSoldier().equals("是")?1:0);
                sysUserInputDO.setSpecialServiceFamily(eexcelUserDTO.getSpecialServiceFamily().equals("是")?1:0);
                //判断身份证和门牌号是否重复
                int count = sysUserInputDAO.selectCount(new QueryWrapper<SysUserInputDO>().lambda()
                        .eq(SysUserInputDO::getIdCard,eexcelUserDTO.getIdCard())
                        .and(wrapper->wrapper.eq(SysUserInputDO::getDoorNumber,eexcelUserDTO.getDoorNumber()))
                );
                if(count==0){
                    SysUserInputDO sysUserInputDO=new SysUserInputDO();
                    String doorNumber = eexcelUserDTO.getDoorNumber();
                    List<ComMngStructHouseVO> collect = comMngStructHouseVOS1.stream().filter(comMngStructHouseVO -> comMngStructHouseVO.getHouseName().equals(doorNumber)).collect(Collectors.toList());
                    if (ObjectUtils.isEmpty(collect)) {
                        throw new ServiceException("门牌号后台不存在或格式错误,错误门牌号为"+doorNumber);
                    }else{
                        sysUserInputDO.setHouseCode(collect.get(0).getHouseCode());
                    }
                    sysUserInputDO.setAreaId(comMngStructAreaVO.getId());
                    sysUserInputDO.setCommunityId(comMngStructAreaVO.getCommunityId());
                    sysUserInputDO.setCompany(eexcelUserDTO.getCompany());
                    sysUserInputDO.setDoorNumber(doorNumber);
                    sysUserInputDO.setEducation(eexcelUserDTO.getEducation());
                    sysUserInputDO.setIdCard(eexcelUserDTO.getIdCard());
                    sysUserInputDO.setIsContact(eexcelUserDTO.getIsContact().equals("是")?1:0);
                    sysUserInputDO.setIsPanzhihua(eexcelUserDTO.getIsPanZhiHua().equals("是")?1:0);
                    sysUserInputDO.setIsRent(eexcelUserDTO.getIsRent().equals("是")?1:0);
                    sysUserInputDO.setKeyPersonnel(eexcelUserDTO.getKeyPersonnel().equals("是")?1:0);
                    sysUserInputDO.setLowincomeHouseholds(eexcelUserDTO.getLowIncomeHouseholds().equals("是")?1:0);
                    sysUserInputDO.setLowincomePeople(eexcelUserDTO.getLowIncomePeople().equals("是")?1:0);
                    sysUserInputDO.setMajor(eexcelUserDTO.getMajor().equals("是")?1:0);
                    sysUserInputDO.setMaritalStatus(eexcelUserDTO.getMaritalStatus().equals("是")?1:0);
                    sysUserInputDO.setName(eexcelUserDTO.getName());
                    sysUserInputDO.setNation(eexcelUserDTO.getNation());
                    sysUserInputDO.setOldPeople(eexcelUserDTO.getOldPeople().equals("是")?1:0);
                    sysUserInputDO.setDisability(eexcelUserDTO.getDisability().equals("是")?1:0);
                    sysUserInputDO.setPhone(eexcelUserDTO.getPhone());
                    String politicalOutlook = eexcelUserDTO.getPoliticalOutlook();
                    if(!ObjectUtils.isEmpty(politicalOutlook)){
                        sysUserInputDO.setPoliticalOutlook(politicalOutlook.equals("党员")?1:politicalOutlook.equals("团员")?2:3);
                    }else{
                        sysUserInputDO.setPoliticalOutlook(3);
                    }
                    sysUserInputDO.setResidence(eexcelUserDTO.getResidence());
                    sysUserInputDO.setSituation(eexcelUserDTO.getSituation());
                    sysUserInputDO.setSoldier(eexcelUserDTO.getSoldier().equals("是")?1:0);
                    sysUserInputDO.setSpecialServiceFamily(eexcelUserDTO.getSpecialServiceFamily().equals("是")?1:0);
                sysUserInputDOS.add(sysUserInputDO);
                    sysUserInputDOS.add(sysUserInputDO);
                }
            });
            this.saveBatch(sysUserInputDOS);
        }
@@ -168,4 +187,97 @@
        }
        return communityUserInfoVO;
    }
    @Override
    public R pageInputUser(PageInputUserDTO pageInputUserDTO) {
        Page page = new Page<>();
        Long pageNum = pageInputUserDTO.getPageNum();
        Long pageSize = pageInputUserDTO.getPageSize();
        if (null==pageNum||0==pageNum) {
            pageNum = 1l;
        }
        if (null==pageSize||0==pageSize) {
            pageSize = 10l;
        }
        page.setSize(pageSize);
        page.setCurrent(pageNum);
        IPage<InputUserInfoVO> iPage = sysUserInputDAO.pageInputUser(page, pageInputUserDTO);
        iPage.getRecords().forEach(record->{
            record.setPhone(SensitiveUtil.desensitizedPhoneNumber(record.getPhone()));
            record.setIdCard(SensitiveUtil.desensitizedIdNumber(record.getIdCard()));
        });
        return R.ok(iPage);
    }
    @Override
    public R putUserTag(InputUserTagsDTO inputUserTagsDTO) {
        SysUserInputDO userInputDO=new SysUserInputDO();
        userInputDO.setId(inputUserTagsDTO.getId());
        userInputDO.setTags(inputUserTagsDTO.getTags());
        List<SysUserInputDO> all = sysUserInputDAO.selectList(new QueryWrapper<SysUserInputDO>().lambda().eq(SysUserInputDO::getIdCard,userInputDO.getIdCard()));
        all.forEach(d->{
            d.setTags(inputUserTagsDTO.getTags());
            sysUserInputDAO.updateById(userInputDO);
        });
        return R.ok();
    }
    @Override
    public R export(ExportUserDTO exportUserDTO) {
        return null;
    }
    @Override
    public InputUserInfoVO inputUserDetail(Long id) {
        InputUserInfoVO inputUserInfoVO = new InputUserInfoVO();
        SysUserInputDO sysUserInputDO = sysUserInputDAO.selectById(id);
        if (!org.springframework.util.ObjectUtils.isEmpty(sysUserInputDO)) {
            BeanUtils.copyProperties(sysUserInputDO,inputUserInfoVO);
            String idCard = sysUserInputDO.getIdCard();
            if (!org.springframework.util.ObjectUtils.isEmpty(idCard)) {
                inputUserInfoVO.setAge(IdCard.IdNOToAge(idCard));
                inputUserInfoVO.setBirthday(IdCard.birthDay(idCard));
                inputUserInfoVO.setIdCard(idCard);
                inputUserInfoVO.setSex(IdCard.sex(idCard));
            }
            Integer keyPersonnel = sysUserInputDO.getKeyPersonnel();
            Integer specialServiceFamily = sysUserInputDO.getSpecialServiceFamily();
            Integer soldier = sysUserInputDO.getSoldier();
            Integer lowincomeHouseholds = sysUserInputDO.getLowincomeHouseholds();
            Integer lowincomePeople = sysUserInputDO.getLowincomePeople();
            Integer oldPeople = sysUserInputDO.getOldPeople();
            Integer disability = sysUserInputDO.getDisability();
            StringBuilder stringBuilder=new StringBuilder("");
            if (keyPersonnel.intValue()==1) {
                stringBuilder.append("重点人员,");
            }
            if (specialServiceFamily.intValue()==1) {
                stringBuilder.append("特服家庭,");
            }
            if (soldier.intValue()==1) {
                stringBuilder.append("军人,");
            }
            if (lowincomeHouseholds.intValue()==1) {
                stringBuilder.append("低保户,");
            }
            if (lowincomePeople.intValue()==1) {
                stringBuilder.append("低收入人员,");
            }
            if (oldPeople.intValue()==1) {
                stringBuilder.append("高龄老人,");
            }
            if (disability.intValue()==1) {
                stringBuilder.append("残疾人,");
            }
            inputUserInfoVO.setTags(stringBuilder.toString());
            String doorNumber = sysUserInputDO.getDoorNumber();
            List<ComMngFamilyInfoVO> comMngFamilyInfoVOS = sysUserInputDAO.selectListFamily(doorNumber,id);
            inputUserInfoVO.setComMngFamilyInfoVOS(comMngFamilyInfoVOS);
            List<ComMngStructHouseVO> comMngStructHouseVOS = sysUserInputDAO.selectUserHouseList(inputUserInfoVO.getIdCard());
            inputUserInfoVO.setComMngStructHouseVOS(comMngStructHouseVOS);
        }
        return inputUserInfoVO;
    }
}