Browse Source

居民信息采集-Excel导入

feature/syp_points
songyunpeng 5 years ago
parent
commit
d1cd635545
  1. 29
      esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysPopulationSimpleDictDTO.java
  2. 26
      esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/SysPopulationSimpleDictFormDTO.java
  3. 8
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDictController.java
  4. 10
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDictService.java
  5. 43
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDictServiceImpl.java
  6. 24
      esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/ExcelUtils.java
  7. 57
      esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/constant/PopulationDictConstant.java
  8. 30
      esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcPopulationErrorResultDTO.java
  9. 15
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/HousingInformationController.java
  10. 31
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/excel/BasePopulationInformationExcel.java
  11. 2
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/excel/BaseResidentInformationExcel.java
  12. 2
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/excel/HouseBusinessInfoExcel.java
  13. 13
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/feign/AdminFeignClient.java
  14. 7
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/feign/fallback/AdminFeignClientFallback.java
  15. 9
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/HousingInformationService.java
  16. 842
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/HousingInformationServiceImpl.java

29
esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysPopulationSimpleDictDTO.java

@ -0,0 +1,29 @@
package com.elink.esua.epdc.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 数据字典简要信息
*
* @author songyunpeng
* @date 2020/8/31 09:29
*/
@Data
public class SysPopulationSimpleDictDTO implements Serializable {
private static final long serialVersionUID = -4827806651372425347L;
/**
*
*/
private String dicType;
/**
* 字典列表
*/
private List<SysSimpleDictDTO> sysSimpleDicts;
}

26
esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/SysPopulationSimpleDictFormDTO.java

@ -0,0 +1,26 @@
package com.elink.esua.epdc.dto.epdc.form;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 数据字典简要信息
*
* @author songyunpeng
* @date 2020/8/31 09:29
*/
@Data
public class SysPopulationSimpleDictFormDTO implements Serializable {
private static final long serialVersionUID = -4827806651372425347L;
/**
* type列表
*/
private List<String> dicTypes;
}

8
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDictController.java

@ -17,7 +17,9 @@ import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
import com.elink.esua.epdc.dto.SysDictDTO;
import com.elink.esua.epdc.dto.SysPopulationSimpleDictDTO;
import com.elink.esua.epdc.dto.SysSimpleDictDTO;
import com.elink.esua.epdc.dto.epdc.form.SysPopulationSimpleDictFormDTO;
import com.elink.esua.epdc.service.SysDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@ -143,6 +145,12 @@ public class SysDictController {
return sysDictService.listSimpleDictInfo(dictType);
}
@PostMapping("listPopulationSimple")
public Result<List<SysPopulationSimpleDictDTO>> listPopulationSimple(@RequestBody SysPopulationSimpleDictFormDTO sysPopulationSimpleDictFormDTO) {
//字典分类数据
return sysDictService.listPopulationSimple(sysPopulationSimpleDictFormDTO);
}
@DeleteMapping("{id}")
@ApiOperation("删除")
@LogOperation("Delete Dict")

10
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDictService.java

@ -12,7 +12,9 @@ import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.SysDictDTO;
import com.elink.esua.epdc.dto.SysPopulationSimpleDictDTO;
import com.elink.esua.epdc.dto.SysSimpleDictDTO;
import com.elink.esua.epdc.dto.epdc.form.SysPopulationSimpleDictFormDTO;
import com.elink.esua.epdc.entity.SysDictEntity;
import java.util.List;
@ -59,4 +61,12 @@ public interface SysDictService extends BaseService<SysDictEntity> {
* @date 2019/7/15 10:14
*/
void delete(Long id);
/**
* @Description 根据数据字典类型获取简版数据字典列表用于居民信息采集数据校验
* @Author songyunpeng
* @Date 2020/8/31
* @Param [dictType]
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.SysSimpleDictDTO>>
**/
Result<List<SysPopulationSimpleDictDTO>> listPopulationSimple(SysPopulationSimpleDictFormDTO sysPopulationSimpleDictFormDTO);
}

43
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDictServiceImpl.java

@ -17,7 +17,9 @@ import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dao.SysDictDao;
import com.elink.esua.epdc.dto.SysDictDTO;
import com.elink.esua.epdc.dto.SysPopulationSimpleDictDTO;
import com.elink.esua.epdc.dto.SysSimpleDictDTO;
import com.elink.esua.epdc.dto.epdc.form.SysPopulationSimpleDictFormDTO;
import com.elink.esua.epdc.entity.SysDictEntity;
import com.elink.esua.epdc.redis.SysDictRedis;
import com.elink.esua.epdc.service.SysDictService;
@ -28,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -121,6 +124,46 @@ public class SysDictServiceImpl extends BaseServiceImpl<SysDictDao, SysDictEntit
baseDao.deleteById(id);
}
@Override
public Result<List<SysPopulationSimpleDictDTO>> listPopulationSimple(SysPopulationSimpleDictFormDTO sysPopulationSimpleDictFormDTO) {
List<SysPopulationSimpleDictDTO> sysPopulationSimpleDictDTOS = new ArrayList<>();
try {
for(String dictType : sysPopulationSimpleDictFormDTO.getDicTypes()){
SysPopulationSimpleDictDTO sysPopulationSimpleDictDTO = new SysPopulationSimpleDictDTO();
List<SysSimpleDictDTO> simpleDictList = Lists.newArrayList();
if (StringUtils.isNotBlank(dictType)) {
List<SysSimpleDictDTO> dictList = dictRedis.getSimpleDictList(dictType);
if (null != dictList) {
sysPopulationSimpleDictDTO.setSysSimpleDicts(dictList);
sysPopulationSimpleDictDTO.setDicType(dictType);
sysPopulationSimpleDictDTOS.add(sysPopulationSimpleDictDTO);
continue;
}
QueryWrapper<SysDictEntity> sdWrapper = new QueryWrapper<>();
sdWrapper.select("dict_value", "dict_name");
sdWrapper.eq("dict_type", dictType);
sdWrapper.ne("dict_value", "");
sdWrapper.isNotNull("dict_value");
sdWrapper.orderByAsc("SORT", Constant.CREATE_DATE);
List<SysDictEntity> entityList = baseDao.selectList(sdWrapper);
if (!entityList.isEmpty()) {
simpleDictList = ConvertUtils.sourceToTarget(entityList, SysSimpleDictDTO.class);
sysPopulationSimpleDictDTO.setSysSimpleDicts(simpleDictList);
sysPopulationSimpleDictDTO.setDicType(dictType);
sysPopulationSimpleDictDTOS.add(sysPopulationSimpleDictDTO);
dictRedis.setSimpleDictList(dictType, simpleDictList);
}
}
}
} catch (Exception e) {
log.error("获取数据字典列表失败,错误信息{}", e.getMessage());
}
return new Result<List<SysPopulationSimpleDictDTO>>().ok(sysPopulationSimpleDictDTOS);
}
@Override
public Result<List<SysSimpleDictDTO>> listSimpleDictInfo(String dictType) {
List<SysSimpleDictDTO> simpleDictList = Lists.newArrayList();

24
esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/utils/ExcelUtils.java

@ -13,13 +13,17 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.elink.esua.epdc.commons.tools.exception.RenException;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.*;
@ -141,4 +145,24 @@ public class ExcelUtils {
out.flush();
out.close();
}
/**
* 得到Workbook对象
* @param file
* @return
* @throws IOException
*/
public static Workbook getWorkBook(MultipartFile file) throws IOException{
//这样写 excel 能兼容03和07
InputStream is = file.getInputStream();
Workbook hssfWorkbook = null;
try {
hssfWorkbook = new HSSFWorkbook(is);
} catch (Exception ex) {
is =file.getInputStream();
hssfWorkbook = new XSSFWorkbook(is);
}
return hssfWorkbook;
}
}

57
esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/constant/PopulationDictConstant.java

@ -0,0 +1,57 @@
package com.elink.esua.epdc.constant;
/**
* @author: songyunpeng
* @Date: 2020/08/19 14:12
* @Description: 房屋用处
*/
public interface PopulationDictConstant {
/**
* 政治面貌
*/
String POLITICS_STATUS = "politics_status";
/**
* 文化程度
*/
String EDUCATION_LEVEL = "education_level";
/**
* 身体状况
*/
String BODY_STATUS = "body_status";
/**
* 婚姻状况
*/
String MARITAL_STATUS = "marital_status";
/**
* 户口类型
*/
String ACCOUNT_TYPE = "account_type";
/**
* 就业情况
*/
String EMPLOYMENT_STATUS = "employment_status";
/**
* 失业原因
*/
String UNEMPLOYMENT_REASON = "unemployment_reason";
/**
* 家庭类别
*/
String FAMILY_CATEGORY = "family_category";
/**
* 救助情况
*/
String HELP_STATUS = "help_status";
/**
* 机动车类型
*/
String MOTOR_VEHICLE_CATEGORY = "motor_vehicle_category";
/**
* 性别
*/
String GENDER = "gender";
}

30
esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/EpdcPopulationErrorResultDTO.java

@ -0,0 +1,30 @@
package com.elink.esua.epdc.dto.epdc.result;
import lombok.Data;
import java.io.Serializable;
/**
* @author: songyunpeng
* @Date: 2020/8/31 17:06
* @Description: 批量导入居民信息错误反馈
*/
@Data
public class EpdcPopulationErrorResultDTO implements Serializable {
private static final long serialVersionUID = 5643743407138967806L;
/**
* 错误数据sheet名
*/
private String sheetName;
/**
* 错误数据行数
*/
private String errorLine;
/**
* 错误数据信息
*/
private String errorInfo;
}

15
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/HousingInformationController.java

@ -32,6 +32,7 @@ import com.elink.esua.epdc.excel.HousingInformationExcel;
import com.elink.esua.epdc.service.HousingInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
@ -93,6 +94,20 @@ public class HousingInformationController {
ExcelUtils.exportExcelToTarget(response, null, list, HousingInformationExcel.class);
}
/**
* @Description 批量导入
* @Author songyunpeng
* @Date 2020/8/31
* @Param [file]
* @return com.elink.esua.epdc.commons.tools.utils.Result
**/
@PostMapping("importExcel")
public Result importExcel(@RequestParam("file") MultipartFile file,String gridId) {
return housingInformationService.importPopulationInfo(file,gridId);
}
/**
* @Description 导出模板
* @Author songyunpeng

31
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/excel/BasePopulationInformationExcel.java

@ -21,6 +21,7 @@ import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 人口信息表
@ -46,9 +47,12 @@ public class BasePopulationInformationExcel {
@Excel(name = "产权人身份证号")
private String propertyOwnerIdentityNo;
@Excel(name = "联系电话")
@Excel(name = "产权人联系电话")
private String propertyOwnerMobile;
@Excel(name = "产权证")
private String propertyOwnerCard;
@Excel(name = "房屋用途",replace = {"自住_0","租赁_1","经营_2"})
private String houseUse;
@ -76,16 +80,19 @@ public class BasePopulationInformationExcel {
@Excel(name = "户主姓名")
private String residentsName;
@Excel(name = "性别",replace = {"女_0","男_1"})
@Excel(name = "性别")
private String residentsSex;
@Excel(name = "出生年月")
private Date residentsBirthday;
@Excel(name = "民族")
private String residentsNation;
@Excel(name = "文化程度")
private String educationLevel;
@Excel(name = "政治面貌",replace = {"群众_0","党员_1"})
@Excel(name = "政治面貌")
private String politicsStatus;
@Excel(name = "入党时间")
@ -97,16 +104,16 @@ public class BasePopulationInformationExcel {
@Excel(name = "身份证号码")
private String residentsIdentityNo;
@Excel(name = "联系电话")
@Excel(name = "户主联系电话")
private String residentsPhone;
@Excel(name = "身体状况",replace = {"病残_0","健康_1"})
@Excel(name = "身体状况")
private String bodyStatus;
@Excel(name = "婚姻状况",replace = {"未婚_0","已婚_1"})
@Excel(name = "婚姻状况")
private String maritalStatus;
@Excel(name = "户口类型",replace = {"城镇_0","农业_1"})
@Excel(name = "户口类型")
private String accountType;
@Excel(name = "服兵役",replace = {"否_0","是_1"})
@ -115,7 +122,7 @@ public class BasePopulationInformationExcel {
@Excel(name = "户籍地")
private String householdRegistrationPlace;
@Excel(name = "就业情况",replace = {"在岗_0","就业_1"})
@Excel(name = "就业情况")
private String employmentStatus;
@Excel(name = "现工作单位")
@ -124,7 +131,7 @@ public class BasePopulationInformationExcel {
@Excel(name = "现单位地址")
private String currentEmployerAddress;
@Excel(name = "失业原因",replace = {"原单位破产_0","解除合同_1","效益不好_2","减员_3","其他_4"})
@Excel(name = "失业原因")
private String unemploymentReason;
@Excel(name = "再就业优惠证",replace = {"无_0","有_1"})
@ -136,16 +143,16 @@ public class BasePopulationInformationExcel {
@Excel(name = "失业登记时间")
private String unemploymentRegisterTime;
@Excel(name = "家庭类别",replace = {"普通家庭_0","军烈_2","优抚_3","困难家庭_6"})
@Excel(name = "家庭类别")
private String familyCategory;
@Excel(name = "救助情况",replace = {"低保_0","大病_1","廉租_2","教育_3","临时_4","其他_5"})
@Excel(name = "救助情况")
private String helpStatus;
@Excel(name = "机动车数量")
private Integer motorVehicleNum;
@Excel(name = "机动车类型",replace = {"轿车_0","摩托_1","其他_2"})
@Excel(name = "机动车类型")
private String motorVehicleCategory;
@Excel(name = "宠物犬状况",replace = {"无_0","有_1"})

2
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/excel/BaseResidentInformationExcel.java

@ -35,7 +35,7 @@ public class BaseResidentInformationExcel {
@Excel(name = "与户主关系",replace = {"子女_0","夫妻_1","其他_2","父母_3"})
private String houseHeadRelation;
@Excel(name = "户主姓名")
@Excel(name = "居住人姓名")
private String residentsName;
@Excel(name = "性别",replace = {"女_0","男_1"})

2
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/excel/HouseBusinessInfoExcel.java

@ -42,7 +42,7 @@ public class HouseBusinessInfoExcel {
@Excel(name = "企业名称")
private String enterpriseName;
@Excel(name = "企业注册号")
@Excel(name = "社会统一代码")
private String socialUniformCode;

13
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/feign/AdminFeignClient.java

@ -4,10 +4,14 @@ import com.elink.esua.epdc.commons.tools.constant.ServiceConstant;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.CompleteDeptDTO;
import com.elink.esua.epdc.dto.ParentAndAllDeptDTO;
import com.elink.esua.epdc.dto.SysPopulationSimpleDictDTO;
import com.elink.esua.epdc.dto.epdc.form.SysPopulationSimpleDictFormDTO;
import com.elink.esua.epdc.feign.fallback.AdminFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@ -51,4 +55,13 @@ public interface AdminFeignClient {
*/
@GetMapping("sys/dept/getCompleteDept/{gridId}")
Result<CompleteDeptDTO> getCompleteDept(@PathVariable("gridId") Long gridId);
/**
* @Description 获取多个字典值列表
* @Author songyunpeng
* @Date 2020/8/31
* @Param [sysPopulationSimpleDictFormDTO]
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.SysPopulationSimpleDictDTO>>
**/
@PostMapping("sys/dict/listPopulationSimple")
Result<List<SysPopulationSimpleDictDTO>> listPopulationSimple(@RequestBody SysPopulationSimpleDictFormDTO sysPopulationSimpleDictFormDTO);
}

7
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/feign/fallback/AdminFeignClientFallback.java

@ -5,6 +5,8 @@ import com.elink.esua.epdc.commons.tools.utils.ModuleUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.CompleteDeptDTO;
import com.elink.esua.epdc.dto.ParentAndAllDeptDTO;
import com.elink.esua.epdc.dto.SysPopulationSimpleDictDTO;
import com.elink.esua.epdc.dto.epdc.form.SysPopulationSimpleDictFormDTO;
import com.elink.esua.epdc.feign.AdminFeignClient;
import org.springframework.stereotype.Component;
@ -32,4 +34,9 @@ public class AdminFeignClientFallback implements AdminFeignClient {
public Result<CompleteDeptDTO> getCompleteDept(Long gridId) {
return ModuleUtils.feignConError(ServiceConstant.EPDC_ADMIN_SERVER, "getCompleteDept", gridId);
}
@Override
public Result<List<SysPopulationSimpleDictDTO>> listPopulationSimple(SysPopulationSimpleDictFormDTO sysPopulationSimpleDictFormDTO){
return ModuleUtils.feignConError(ServiceConstant.EPDC_ADMIN_SERVER, "listPopulationSimple", sysPopulationSimpleDictFormDTO);
}
}

9
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/HousingInformationService.java

@ -22,6 +22,7 @@ import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.HousingInformationDTO;
import com.elink.esua.epdc.entity.HousingInformationEntity;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map;
@ -101,4 +102,12 @@ public interface HousingInformationService extends BaseService<HousingInformatio
* @return com.elink.esua.epdc.commons.tools.page.PageData<com.elink.esua.epdc.dto.HousingInformationDTO>
**/
PageData<HousingInformationDTO> listOfPage(Map<String, Object> params);
/**
* @Description 批量导入居民信息
* @Author songyunpeng
* @Date 2020/8/31
* @Param [file]
* @return com.elink.esua.epdc.commons.tools.utils.Result
**/
Result importPopulationInfo(MultipartFile file,String gridId);
}

842
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/HousingInformationServiceImpl.java

@ -17,6 +17,9 @@
package com.elink.esua.epdc.service.impl;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
@ -24,17 +27,23 @@ import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.exception.RenException;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils;
import com.elink.esua.epdc.commons.tools.utils.IdentityNoUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.config.StreamUtils;
import com.elink.esua.epdc.constant.HouseUseConstant;
import com.elink.esua.epdc.constant.PopulationDictConstant;
import com.elink.esua.epdc.dao.HouseResidentDao;
import com.elink.esua.epdc.dao.HousingInformationDao;
import com.elink.esua.epdc.dto.HousingInformationDTO;
import com.elink.esua.epdc.dto.ParentAndAllDeptDTO;
import com.elink.esua.epdc.entity.HouseBusinessInfoEntity;
import com.elink.esua.epdc.entity.HouseRentInfoEntity;
import com.elink.esua.epdc.entity.HouseResidentEntity;
import com.elink.esua.epdc.entity.HousingInformationEntity;
import com.elink.esua.epdc.dto.SysPopulationSimpleDictDTO;
import com.elink.esua.epdc.dto.SysSimpleDictDTO;
import com.elink.esua.epdc.dto.epdc.form.SysPopulationSimpleDictFormDTO;
import com.elink.esua.epdc.dto.epdc.result.EpdcPopulationErrorResultDTO;
import com.elink.esua.epdc.entity.*;
import com.elink.esua.epdc.excel.BasePopulationInformationExcel;
import com.elink.esua.epdc.excel.BaseResidentInformationExcel;
import com.elink.esua.epdc.feign.AdminFeignClient;
import com.elink.esua.epdc.redis.HousingInformationRedis;
import com.elink.esua.epdc.service.HouseBusinessInfoService;
@ -42,10 +51,14 @@ import com.elink.esua.epdc.service.HouseRentInfoService;
import com.elink.esua.epdc.service.HousingInformationService;
import com.elink.esua.epdc.service.PopulationInformationService;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.math.BigDecimal;
import java.util.*;
/**
@ -248,4 +261,825 @@ public class HousingInformationServiceImpl extends BaseServiceImpl<HousingInform
return new PageData<>(list, page.getTotal());
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result importPopulationInfo(MultipartFile file,String gridId) {
if (StringUtils.isBlank(gridId)) {
throw new RenException("归属部门不能为空");
}
Result<ParentAndAllDeptDTO> parentAndAllDept = adminFeignClient.getParentAndAllDept(gridId);
if (!parentAndAllDept.success() || parentAndAllDept.getData() == null) {
throw new RenException("获取归属部门信息失败");
}
ParentAndAllDeptDTO parentAndAllDeptDTO = parentAndAllDept.getData();
//获取字典信息
SysPopulationSimpleDictFormDTO sysPopulationSimpleDictFormDTO = new SysPopulationSimpleDictFormDTO();
List<String> dicTypes = new ArrayList<>();
Collections.addAll(dicTypes, PopulationDictConstant.ACCOUNT_TYPE,PopulationDictConstant.BODY_STATUS,PopulationDictConstant.EDUCATION_LEVEL
,PopulationDictConstant.EMPLOYMENT_STATUS,PopulationDictConstant.FAMILY_CATEGORY,PopulationDictConstant.GENDER,PopulationDictConstant.HELP_STATUS,PopulationDictConstant.MARITAL_STATUS
,PopulationDictConstant.MOTOR_VEHICLE_CATEGORY,PopulationDictConstant.POLITICS_STATUS,PopulationDictConstant.UNEMPLOYMENT_REASON);
sysPopulationSimpleDictFormDTO.setDicTypes(dicTypes);
Result<List<SysPopulationSimpleDictDTO>> listResult = adminFeignClient.listPopulationSimple(sysPopulationSimpleDictFormDTO);
if(listResult==null || !listResult.success()){
throw new RenException("获取字典信息失败");
}
List<SysPopulationSimpleDictDTO> sysPopulationSimpleDictDTOS = listResult.getData();
File f = StreamUtils.conversionFile(file);
ImportParams importParams = new ImportParams();
try {
//获取多个sheet页
Workbook workBook = ExcelUtils.getWorkBook(file);
for(int numSheet = 0; numSheet < workBook.getNumberOfSheets(); numSheet++){
//第几个sheet
importParams.setStartSheetIndex(numSheet);
if(numSheet==0){//校验和新增房屋和户主信息
List<BasePopulationInformationExcel> basePopulationInformationExcels = ExcelImportUtil.importExcel(f, BasePopulationInformationExcel.class, importParams);
// 校验数据
List<EpdcPopulationErrorResultDTO> epdcPartyErrorResultDTOS = this.checkPopulationExcel(basePopulationInformationExcels,sysPopulationSimpleDictDTOS);
if(epdcPartyErrorResultDTOS.size()>0){
return new Result().ok(epdcPartyErrorResultDTOS);
}
savePopulationList(basePopulationInformationExcels,parentAndAllDeptDTO);
} else if (numSheet == 1){//检验和新增居住人信息
List<BaseResidentInformationExcel> baseResidentInformationExcels = ExcelImportUtil.importExcel(f, BaseResidentInformationExcel.class, importParams);
// 校验数据
List<EpdcPopulationErrorResultDTO> epdcPartyErrorResultDTOS = this.checkResidentsExcel(baseResidentInformationExcels,sysPopulationSimpleDictDTOS);
if(epdcPartyErrorResultDTOS.size()>0){
return new Result().ok(epdcPartyErrorResultDTOS);
}
saveResidentList(baseResidentInformationExcels);
}
}
} catch (Exception e1) {
throw new RenException("导入失败:{}" + e1.getMessage());
}
return new Result();
}
/**
* @Description 校验完成后插入居民信息
* @Author songyunpeng
* @Date 2020/8/31
* @Param [baseResidentInformationExcels]
* @return void
**/
private void saveResidentList(List<BaseResidentInformationExcel> baseResidentInformationExcels) {
for (BaseResidentInformationExcel baseResidentInformationExcel : baseResidentInformationExcels) {
//插入居民信息
PopulationInformationEntity populationInformationEntity = ConvertUtils.sourceToTarget(baseResidentInformationExcel,PopulationInformationEntity.class);
populationInformationEntity.setResidentsIdentityNo(null);
populationInformationService.insert(populationInformationEntity);
//插入房屋人员关联关系表
HouseResidentEntity houseResidentEntity = ConvertUtils.sourceToTarget(baseResidentInformationExcel,HouseResidentEntity.class);
houseResidentEntity.setResidentId(populationInformationEntity.getId());
//查找户主ID
PopulationInformationEntity infoByIdentityNo = populationInformationService.getInfoByIdentityNo(baseResidentInformationExcel.getResidentsIdentityNo());
houseResidentEntity.setHouseHeadId(infoByIdentityNo.getId());
houseResidentEntity.setIsHouseHead("0");
houseResidentDao.insert(houseResidentEntity);
}
}
/**
* @Description 校验完成后新增人口信息
* @Author songyunpeng
* @Date 2020/8/31
* @Param [basePopulationInformationExcels]
* @return void
**/
private void savePopulationList(List<BasePopulationInformationExcel> basePopulationInformationExcels,ParentAndAllDeptDTO parentAndAllDeptDTO) {
for (BasePopulationInformationExcel basePopulationInformationExcel : basePopulationInformationExcels) {
//插入房屋信息
HousingInformationEntity housingInformationEntity = ConvertUtils.sourceToTarget(basePopulationInformationExcel,HousingInformationEntity.class);
housingInformationEntity.setBuyingTime(DateUtil.parse(basePopulationInformationExcel.getBuyingTime()));
housingInformationEntity.setGridId(parentAndAllDeptDTO.getGridId());
housingInformationEntity.setAllDeptNames(parentAndAllDeptDTO.getAllDeptNames());
housingInformationEntity.setAllDeptIds(parentAndAllDeptDTO.getAllDeptIds());
housingInformationEntity.setParentDeptNames(parentAndAllDeptDTO.getParentDeptNames());
housingInformationEntity.setParentDeptIds(parentAndAllDeptDTO.getParentDeptIds());
baseDao.insert(housingInformationEntity);
if(HouseUseConstant.RENT.equals(housingInformationEntity.getHouseUse())){
//房屋租赁信息
HouseRentInfoEntity houseRentInfoEntity = ConvertUtils.sourceToTarget(basePopulationInformationExcel,HouseRentInfoEntity.class);
houseRentInfoEntity.setHouseId(housingInformationEntity.getId());
houseRentInfoService.insert(houseRentInfoEntity);
}else if(HouseUseConstant.BUSINESS.equals(housingInformationEntity.getHouseUse())){
//房屋经营信息
HouseBusinessInfoEntity houseBusinessInfoEntity = ConvertUtils.sourceToTarget(basePopulationInformationExcel,HouseBusinessInfoEntity.class);
houseBusinessInfoEntity.setHouseId(housingInformationEntity.getId());
houseBusinessInfoService.insert(houseBusinessInfoEntity);
}
//插入户主信息
PopulationInformationEntity populationInformationEntity = ConvertUtils.sourceToTarget(basePopulationInformationExcel,PopulationInformationEntity.class);
PopulationInformationEntity oldPopulationInformationEntity= populationInformationService.getInfoByIdentityNo(populationInformationEntity.getResidentsIdentityNo());
if(oldPopulationInformationEntity!=null){
//身份证在列表已存在,则更新户主信息
populationInformationEntity.setId(oldPopulationInformationEntity.getId());
populationInformationService.updateById(populationInformationEntity);
}else {
populationInformationService.insert(populationInformationEntity);
}
//插入房屋人员关联关系表
HouseResidentEntity houseResidentEntity = new HouseResidentEntity();
houseResidentEntity.setHouseId(housingInformationEntity.getId());
houseResidentEntity.setResidentId(populationInformationEntity.getId());
houseResidentEntity.setIsHouseHead("1");
houseResidentDao.insert(houseResidentEntity);
}
}
/**
* @Description 校验居住人数据
* @Author songyunpeng
* @Date 2020/8/31
* @Param [basePopulationInformationExcels, basePopulationInformationExcels1]
* @return java.util.List<com.elink.esua.epdc.dto.epdc.result.EpdcPopulationErrorResultDTO>
**/
private List<EpdcPopulationErrorResultDTO> checkResidentsExcel(List<BaseResidentInformationExcel> basePopulationInformationExcels,List<SysPopulationSimpleDictDTO> sysPopulationSimpleDictDTOS) {
// 不匹配信息
List<EpdcPopulationErrorResultDTO> errorLineInfoList = new ArrayList<>();
EpdcPopulationErrorResultDTO errorLineInfoDto;
for (int i = 0; i < basePopulationInformationExcels.size(); i++) {
BaseResidentInformationExcel baseResidentInformationExcel = basePopulationInformationExcels.get(i);
String residentsIdentityNo = baseResidentInformationExcel.getResidentsIdentityNo();
String houseHeadRelation = baseResidentInformationExcel.getHouseHeadRelation();
String residentsName = baseResidentInformationExcel.getResidentsName();
String residentsSex = baseResidentInformationExcel.getResidentsSex();
String residentsNation = baseResidentInformationExcel.getResidentsNation();
String currentEmployer = baseResidentInformationExcel.getCurrentEmployer();
String currentAddress = baseResidentInformationExcel.getCurrentAddress();
if (StringUtils.isBlank(residentsIdentityNo)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主身份证号为空");
errorLineInfoDto.setSheetName("居住人信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(houseHeadRelation)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("与户主关系为空");
errorLineInfoDto.setSheetName("居住人信息");
errorLineInfoList.add(errorLineInfoDto);
}
if(StringUtils.isNotBlank(houseHeadRelation) && !"0".equals(houseHeadRelation) && !"1".equals(houseHeadRelation) && !"2".equals(houseHeadRelation)&& !"3".equals(houseHeadRelation)){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("与户主关系数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(residentsName)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("姓名为空");
errorLineInfoDto.setSheetName("居住人信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(residentsSex)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("性别为空");
errorLineInfoDto.setSheetName("居住人信息");
errorLineInfoList.add(errorLineInfoDto);
}
if(StringUtils.isNotBlank(residentsSex) && !"0".equals(residentsSex) && !"1".equals(residentsSex)){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("性别不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(residentsNation)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("民族为空");
errorLineInfoDto.setSheetName("居住人信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(currentEmployer)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("工作单位或学校地址为空");
errorLineInfoDto.setSheetName("居住人信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(currentAddress)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("现居住地址为空");
errorLineInfoDto.setSheetName("居住人信息");
errorLineInfoList.add(errorLineInfoDto);
}
}
return errorLineInfoList;
}
/**
* @Description 校验户主和房屋数据
* @Author songyunpeng
* @Date 2020/8/31
* @Param [basePopulationInformationExcels, populationInformationDTOS]
* @return java.util.List<com.elink.esua.epdc.dto.epdc.result.EpdcPartyErroyResultDTO>
**/
private List<EpdcPopulationErrorResultDTO> checkPopulationExcel(List<BasePopulationInformationExcel> basePopulationInformationExcels,List<SysPopulationSimpleDictDTO> sysPopulationSimpleDictDTOS) {
// 不匹配信息
List<EpdcPopulationErrorResultDTO> errorLineInfoList = new ArrayList<>();
EpdcPopulationErrorResultDTO errorLineInfoDto;
for (int i = 0; i < basePopulationInformationExcels.size(); i++) {
BasePopulationInformationExcel basePopulationInformationExcel = basePopulationInformationExcels.get(i);
String houseAddress = basePopulationInformationExcel.getHouseAddress();
String buyingTime = basePopulationInformationExcel.getBuyingTime();
BigDecimal houseArea = basePopulationInformationExcel.getHouseArea();
String propertyOwner = basePopulationInformationExcel.getPropertyOwner();
String propertyOwnerIdentityNo = basePopulationInformationExcel.getPropertyOwnerIdentityNo();
String propertyOwnerMobile = basePopulationInformationExcel.getPropertyOwnerMobile();
String propertyOwnerCard = basePopulationInformationExcel.getPropertyOwnerCard();
String houseUse = basePopulationInformationExcel.getHouseUse();
String tenantName = basePopulationInformationExcel.getTenantName();
String tenantIdentityNo = basePopulationInformationExcel.getTenantIdentityNo();
String tenantPhone = basePopulationInformationExcel.getTenantPhone();
String enterpriseName = basePopulationInformationExcel.getEnterpriseName();
String legalRepresentative = basePopulationInformationExcel.getLegalRepresentative();
String enterprisePhone = basePopulationInformationExcel.getEnterprisePhone();
String socialUniformCode = basePopulationInformationExcel.getSocialUniformCode();
String residentsName = basePopulationInformationExcel.getResidentsName();
String residentsNation = basePopulationInformationExcel.getResidentsNation();
String educationLevel = basePopulationInformationExcel.getEducationLevel();
String politicsStatus = basePopulationInformationExcel.getPoliticsStatus();
String joinTime = basePopulationInformationExcel.getJoinTime();
String organizationalRelationshipLocation = basePopulationInformationExcel.getOrganizationalRelationshipLocation();
String residentsIdentityNo = basePopulationInformationExcel.getResidentsIdentityNo();
String residentsPhone = basePopulationInformationExcel.getResidentsPhone();
String bodyStatus = basePopulationInformationExcel.getBodyStatus();
String maritalStatus = basePopulationInformationExcel.getMaritalStatus();
String accountType = basePopulationInformationExcel.getAccountType();
String militaryService = basePopulationInformationExcel.getMilitaryService();
String householdRegistrationPlace = basePopulationInformationExcel.getHouseholdRegistrationPlace();
String employmentStatus = basePopulationInformationExcel.getEmploymentStatus();
String currentEmployer = basePopulationInformationExcel.getCurrentEmployer();
String currentEmployerAddress = basePopulationInformationExcel.getCurrentEmployerAddress();
String unemploymentReason = basePopulationInformationExcel.getUnemploymentReason();
String reemploymentPermit = basePopulationInformationExcel.getReemploymentPermit();
String unemploymentRegister = basePopulationInformationExcel.getUnemploymentRegister();
String unemploymentRegisterTime = basePopulationInformationExcel.getUnemploymentRegisterTime();
String familyCategory = basePopulationInformationExcel.getFamilyCategory();
String helpStatus = basePopulationInformationExcel.getHelpStatus();
Integer motorVehicleNum = basePopulationInformationExcel.getMotorVehicleNum();
String motorVehicleCategory = basePopulationInformationExcel.getMotorVehicleCategory();
String dogStatus = basePopulationInformationExcel.getDogStatus();
if (StringUtils.isBlank(houseAddress)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("房屋地址为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(buyingTime)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("购房时间为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (houseArea==null) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("房屋面积为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(propertyOwner)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("产权人为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(propertyOwnerIdentityNo)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("产权人身份证号为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(propertyOwnerMobile)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("产权人电话为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(propertyOwnerCard)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("产权证为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(houseUse)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("房屋用途为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if(StringUtils.isNotBlank(houseUse) && !"0".equals(houseUse) && !"1".equals(houseUse) && !"2".equals(houseUse)){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("房屋用途数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if(HouseUseConstant.RENT.equals(houseUse)){
if (StringUtils.isBlank(tenantName)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("承租人为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(tenantPhone)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("承租人电话为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(tenantIdentityNo)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("承租人身份证号为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
} else if(HouseUseConstant.BUSINESS.equals(houseUse)){
if (StringUtils.isBlank(enterpriseName)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("企业名称为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(legalRepresentative)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("法人为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(enterprisePhone)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("企业联系电话为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(socialUniformCode)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("社会统一代码为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
}
if (StringUtils.isBlank(residentsName)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主姓名为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(residentsNation)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("民族为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(educationLevel)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("文化程度为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if(StringUtils.isNotBlank(educationLevel)){
boolean isMatch = false;
for (SysPopulationSimpleDictDTO sysPopulationSimpleDictDTO : sysPopulationSimpleDictDTOS) {
if(PopulationDictConstant.EDUCATION_LEVEL.equals(sysPopulationSimpleDictDTO.getDicType())){
List<SysSimpleDictDTO> sysSimpleDicts = sysPopulationSimpleDictDTO.getSysSimpleDicts();
for (SysSimpleDictDTO sysSimpleDict : sysSimpleDicts) {
if(educationLevel.equals(sysSimpleDict.getDictName())) {
isMatch = true;
basePopulationInformationExcel.setEducationLevel(sysSimpleDict.getDictValue());
}
}
}
}
if(!isMatch){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("文化程度数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
}
if (StringUtils.isBlank(politicsStatus)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("政治面貌为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if(StringUtils.isNotBlank(politicsStatus)){
boolean isMatch = false;
for (SysPopulationSimpleDictDTO sysPopulationSimpleDictDTO : sysPopulationSimpleDictDTOS) {
if(PopulationDictConstant.POLITICS_STATUS.equals(sysPopulationSimpleDictDTO.getDicType())){
List<SysSimpleDictDTO> sysSimpleDicts = sysPopulationSimpleDictDTO.getSysSimpleDicts();
for (SysSimpleDictDTO sysSimpleDict : sysSimpleDicts) {
if(politicsStatus.equals(sysSimpleDict.getDictName())) {
isMatch = true;
basePopulationInformationExcel.setPoliticsStatus(sysSimpleDict.getDictValue());
}
}
}
}
if(!isMatch){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("政治面貌数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
}
if("党员".equals(politicsStatus)){
if (StringUtils.isBlank(joinTime)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("入党时间为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(organizationalRelationshipLocation)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("组织关系所在地为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
}
if (StringUtils.isBlank(residentsIdentityNo)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主身份证号码为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if(StringUtils.isNotBlank(residentsIdentityNo)){
String result = IdentityNoUtils.IdentityNoVerification(residentsIdentityNo);
if(result!=null){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主身份证号码有误");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
basePopulationInformationExcel.setResidentsSex(IdentityNoUtils.getSex(residentsIdentityNo));
basePopulationInformationExcel.setResidentsBirthday(DateUtil.parse(IdentityNoUtils.getBirthday(residentsIdentityNo)));
}
if (StringUtils.isBlank(residentsPhone)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主联系电话为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(bodyStatus)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主身体状况为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if(StringUtils.isNotBlank(bodyStatus)){
boolean isMatch = false;
for (SysPopulationSimpleDictDTO sysPopulationSimpleDictDTO : sysPopulationSimpleDictDTOS) {
if(PopulationDictConstant.BODY_STATUS.equals(sysPopulationSimpleDictDTO.getDicType())){
List<SysSimpleDictDTO> sysSimpleDicts = sysPopulationSimpleDictDTO.getSysSimpleDicts();
for (SysSimpleDictDTO sysSimpleDict : sysSimpleDicts) {
if(bodyStatus.equals(sysSimpleDict.getDictName())) {
isMatch = true;
basePopulationInformationExcel.setBodyStatus(sysSimpleDict.getDictValue());
}
}
}
}
if(!isMatch){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("身体状况数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
}
if (StringUtils.isBlank(maritalStatus)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主婚姻状况为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if(StringUtils.isNotBlank(maritalStatus)){
boolean isMatch = false;
for (SysPopulationSimpleDictDTO sysPopulationSimpleDictDTO : sysPopulationSimpleDictDTOS) {
if(PopulationDictConstant.MARITAL_STATUS.equals(sysPopulationSimpleDictDTO.getDicType())){
List<SysSimpleDictDTO> sysSimpleDicts = sysPopulationSimpleDictDTO.getSysSimpleDicts();
for (SysSimpleDictDTO sysSimpleDict : sysSimpleDicts) {
if(maritalStatus.equals(sysSimpleDict.getDictName())) {
isMatch = true;
basePopulationInformationExcel.setMaritalStatus(sysSimpleDict.getDictValue());
}
}
}
}
if(!isMatch){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("婚姻状况数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
}
if (StringUtils.isBlank(accountType)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主户口类型为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}else if(StringUtils.isNotBlank(accountType)){
boolean isMatch = false;
for (SysPopulationSimpleDictDTO sysPopulationSimpleDictDTO : sysPopulationSimpleDictDTOS) {
if(PopulationDictConstant.ACCOUNT_TYPE.equals(sysPopulationSimpleDictDTO.getDicType())){
List<SysSimpleDictDTO> sysSimpleDicts = sysPopulationSimpleDictDTO.getSysSimpleDicts();
for (SysSimpleDictDTO sysSimpleDict : sysSimpleDicts) {
if(accountType.equals(sysSimpleDict.getDictName())) {
isMatch = true;
basePopulationInformationExcel.setAccountType(sysSimpleDict.getDictValue());
}
}
}
}
if(!isMatch){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户口类型数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
}
if (StringUtils.isBlank(militaryService)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主是否服兵役为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if(StringUtils.isNotBlank(militaryService) && !"0".equals(militaryService) && !"1".equals(militaryService)){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主是否服兵役数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(householdRegistrationPlace)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主户籍地为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(employmentStatus)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主是否就业为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}else if(StringUtils.isNotBlank(employmentStatus)){
boolean isMatch = false;
for (SysPopulationSimpleDictDTO sysPopulationSimpleDictDTO : sysPopulationSimpleDictDTOS) {
if(PopulationDictConstant.EMPLOYMENT_STATUS.equals(sysPopulationSimpleDictDTO.getDicType())){
List<SysSimpleDictDTO> sysSimpleDicts = sysPopulationSimpleDictDTO.getSysSimpleDicts();
for (SysSimpleDictDTO sysSimpleDict : sysSimpleDicts) {
if(employmentStatus.equals(sysSimpleDict.getDictName())) {
isMatch = true;
basePopulationInformationExcel.setEmploymentStatus(sysSimpleDict.getDictValue());
}
}
}
}
if(!isMatch){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主是否就业数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
}
if("在岗".equals(employmentStatus)){
if (StringUtils.isBlank(currentEmployer)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主现工作单位为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(currentEmployerAddress)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主现单位地址为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
}else if("失业".equals(employmentStatus)){
if (StringUtils.isBlank(unemploymentReason)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主失业原因为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}else if(StringUtils.isNotBlank(unemploymentReason)){
boolean isMatch = false;
for (SysPopulationSimpleDictDTO sysPopulationSimpleDictDTO : sysPopulationSimpleDictDTOS) {
if(PopulationDictConstant.UNEMPLOYMENT_REASON.equals(sysPopulationSimpleDictDTO.getDicType())){
List<SysSimpleDictDTO> sysSimpleDicts = sysPopulationSimpleDictDTO.getSysSimpleDicts();
for (SysSimpleDictDTO sysSimpleDict : sysSimpleDicts) {
if(unemploymentReason.equals(sysSimpleDict.getDictName())) {
isMatch = true;
basePopulationInformationExcel.setUnemploymentReason(sysSimpleDict.getDictValue());
}
}
}
}
if(!isMatch){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主失业原因数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
}
if (StringUtils.isBlank(reemploymentPermit)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主是否有再就业优惠证为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if(StringUtils.isNotBlank(reemploymentPermit) && !"0".equals(reemploymentPermit) && !"1".equals(reemploymentPermit)){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主是否有再就业优惠证数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(unemploymentRegister)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主是否失业登记为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if(StringUtils.isNotBlank(unemploymentRegister) && !"0".equals(unemploymentRegister) && !"1".equals(unemploymentRegister)){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主是否失业登记数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (StringUtils.isBlank(unemploymentRegisterTime)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主失业登记时间为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
}
if (StringUtils.isBlank(familyCategory)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主家庭类别为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}else if(StringUtils.isNotBlank(familyCategory)){
boolean isMatch = false;
for (SysPopulationSimpleDictDTO sysPopulationSimpleDictDTO : sysPopulationSimpleDictDTOS) {
if(PopulationDictConstant.FAMILY_CATEGORY.equals(sysPopulationSimpleDictDTO.getDicType())){
List<SysSimpleDictDTO> sysSimpleDicts = sysPopulationSimpleDictDTO.getSysSimpleDicts();
for (SysSimpleDictDTO sysSimpleDict : sysSimpleDicts) {
if(familyCategory.equals(sysSimpleDict.getDictName())) {
isMatch = true;
basePopulationInformationExcel.setFamilyCategory(sysSimpleDict.getDictValue());
}
}
}
}
if(!isMatch){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主家庭类别数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
}
if (StringUtils.isBlank(helpStatus)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主家庭救助情况为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}else if(StringUtils.isNotBlank(helpStatus)){
boolean isMatch = false;
for (SysPopulationSimpleDictDTO sysPopulationSimpleDictDTO : sysPopulationSimpleDictDTOS) {
if(PopulationDictConstant.HELP_STATUS.equals(sysPopulationSimpleDictDTO.getDicType())){
List<SysSimpleDictDTO> sysSimpleDicts = sysPopulationSimpleDictDTO.getSysSimpleDicts();
for (SysSimpleDictDTO sysSimpleDict : sysSimpleDicts) {
if(helpStatus.equals(sysSimpleDict.getDictName())) {
isMatch = true;
basePopulationInformationExcel.setHelpStatus(sysSimpleDict.getDictValue());
}
}
}
}
if(!isMatch){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("户主家庭救助情况数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
}
if (motorVehicleNum==null) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("机动车台数为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (motorVehicleNum.intValue()>0 && StringUtils.isBlank(motorVehicleCategory)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("机动车类型为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}else if(StringUtils.isNotBlank(motorVehicleCategory)){
boolean isMatch = false;
for (SysPopulationSimpleDictDTO sysPopulationSimpleDictDTO : sysPopulationSimpleDictDTOS) {
if(PopulationDictConstant.MOTOR_VEHICLE_CATEGORY.equals(sysPopulationSimpleDictDTO.getDicType())){
List<SysSimpleDictDTO> sysSimpleDicts = sysPopulationSimpleDictDTO.getSysSimpleDicts();
for (SysSimpleDictDTO sysSimpleDict : sysSimpleDicts) {
if(motorVehicleCategory.equals(sysSimpleDict.getDictName())) {
isMatch = true;
basePopulationInformationExcel.setMotorVehicleCategory(sysSimpleDict.getDictValue());
}
}
}
}
if(!isMatch){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("机动车类型数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
}
if (StringUtils.isBlank(dogStatus)) {
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("宠物犬情况为空");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if(StringUtils.isNotBlank(dogStatus) && !"0".equals(dogStatus) && !"1".equals(dogStatus)){
errorLineInfoDto=new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i+2)+"");
errorLineInfoDto.setErrorInfo("宠物犬情况数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
}
return errorLineInfoList;
}
}
Loading…
Cancel
Save