Browse Source

居民信息采集-bug修改

feature/syp_points
songyunpeng 5 years ago
parent
commit
57c3e3357c
  1. 7
      esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/PopulationInformationDTO.java
  2. 149
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/HousingInformationController.java
  3. 44
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/PopulationInformationController.java
  4. 20
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/excel/BasePopulationInformationExportExcel.java
  5. 2
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/excel/BaseResidentInformationExportExcel.java
  6. 2
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/excel/populationMotorVehicleExcel.java
  7. 1
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/HouseResidentServiceImpl.java
  8. 112
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/HousingInformationServiceImpl.java
  9. 8
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/PopulationInformationServiceImpl.java
  10. 6
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/PopulationInformationDao.xml

7
esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/PopulationInformationDTO.java

@ -268,5 +268,12 @@ public class PopulationInformationDTO implements Serializable {
/**
* 机动车类型 - 辅助前台显示
*/
private List<String> motorVehicleCategoryList;
}

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

@ -37,11 +37,16 @@ import com.elink.esua.epdc.excel.BaseResidentInformationExcel;
import com.elink.esua.epdc.excel.BaseResidentInformationExportExcel;
import com.elink.esua.epdc.feign.AdminFeignClient;
import com.elink.esua.epdc.service.HousingInformationService;
import org.apache.commons.lang3.StringUtils;
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.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@ -110,6 +115,60 @@ public class HousingInformationController {
if(basePopulationInformationExcelList == null || basePopulationInformationExcelList.size()==0){
ExcelUtils.exportExcelToTargetWithSheets(response, "居民信息导出",sheetNames,classes,new ArrayList<>(), new ArrayList<>(),new ArrayList<>());
}
//根据字典赋值
//获取字典信息
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();
for (BasePopulationInformationExportDto basePopulationInformationExportDto : basePopulationInformationExcelList) {
String educationLevel = basePopulationInformationExportDto.getEducationLevel();
String politicsStatus = basePopulationInformationExportDto.getPoliticsStatus();
String bodyStatus = basePopulationInformationExportDto.getBodyStatus();
String maritalStatus = basePopulationInformationExportDto.getMaritalStatus();
String accountType = basePopulationInformationExportDto.getAccountType();
String employmentStatus = basePopulationInformationExportDto.getEmploymentStatus();
String unemploymentReason = basePopulationInformationExportDto.getUnemploymentReason();
String familyCategory = basePopulationInformationExportDto.getFamilyCategory();
String helpStatus = basePopulationInformationExportDto.getHelpStatus();
String motorVehicleCategory = basePopulationInformationExportDto.getMotorVehicleCategory();
setDicNameByValue(sysPopulationSimpleDictDTOS,basePopulationInformationExportDto,"educationLevel",educationLevel,PopulationDictConstant.EDUCATION_LEVEL);
setDicNameByValue(sysPopulationSimpleDictDTOS,basePopulationInformationExportDto,"politicsStatus",politicsStatus,PopulationDictConstant.POLITICS_STATUS);
setDicNameByValue(sysPopulationSimpleDictDTOS,basePopulationInformationExportDto,"bodyStatus",bodyStatus,PopulationDictConstant.BODY_STATUS);
setDicNameByValue(sysPopulationSimpleDictDTOS,basePopulationInformationExportDto,"maritalStatus",maritalStatus,PopulationDictConstant.MARITAL_STATUS);
setDicNameByValue(sysPopulationSimpleDictDTOS,basePopulationInformationExportDto,"accountType",accountType,PopulationDictConstant.ACCOUNT_TYPE);
setDicNameByValue(sysPopulationSimpleDictDTOS,basePopulationInformationExportDto,"employmentStatus",employmentStatus,PopulationDictConstant.EMPLOYMENT_STATUS);
setDicNameByValue(sysPopulationSimpleDictDTOS,basePopulationInformationExportDto,"unemploymentReason",unemploymentReason,PopulationDictConstant.UNEMPLOYMENT_REASON);
setDicNameByValue(sysPopulationSimpleDictDTOS,basePopulationInformationExportDto,"familyCategory",familyCategory,PopulationDictConstant.FAMILY_CATEGORY);
setDicNameByValue(sysPopulationSimpleDictDTOS,basePopulationInformationExportDto,"helpStatus",helpStatus,PopulationDictConstant.HELP_STATUS);
//处理多选类型
if(StringUtils.isNotBlank(motorVehicleCategory)){
String[] motorVehicleCategoryStrings = motorVehicleCategory.split(",");
String motorVehicleCategoryEnd = "";
for(String motorVehicleCategoryStr : Arrays.asList(motorVehicleCategoryStrings)){
for (SysPopulationSimpleDictDTO sysPopulationSimpleDictDTO : sysPopulationSimpleDictDTOS) {
if (PopulationDictConstant.MOTOR_VEHICLE_CATEGORY.equals(sysPopulationSimpleDictDTO.getDicType())) {
List<SysSimpleDictDTO> sysSimpleDicts = sysPopulationSimpleDictDTO.getSysSimpleDicts();
for (SysSimpleDictDTO sysSimpleDict : sysSimpleDicts) {
if (motorVehicleCategoryStr.equals(sysSimpleDict.getDictValue())) {
motorVehicleCategoryEnd += sysSimpleDict.getDictName()+",";
}
}
}
}
}
basePopulationInformationExportDto.setMotorVehicleCategory(motorVehicleCategoryEnd.substring(0,motorVehicleCategoryEnd.lastIndexOf(",")));
}
}
//根据获取的户主ID查询居住人信息
Map<String,List<BasePopulationInformationExportDto>> baseMap = basePopulationInformationExcelList.stream().collect(Collectors.groupingBy(BasePopulationInformationExportDto::getId));
//获取所有的户主ID
@ -117,7 +176,32 @@ public class HousingInformationController {
List<BaseResidentInformationExportDto> baseResidentInformationExportDtoList = housingInformationService.selectBaseResidentInformationExcelList(houseHeadIds);
ExcelUtils.exportExcelToTargetWithSheets(response, "居民信息导出",sheetNames,classes,new ArrayList<>(), ConvertUtils.sourceToTarget(basePopulationInformationExcelList, BasePopulationInformationExportExcel.class),ConvertUtils.sourceToTarget(baseResidentInformationExportDtoList,BaseResidentInformationExportExcel.class));
}
/**
* @Description 根据字典值匹配键
* @Author songyunpeng
* @Date 2020/9/8
* @param column 实体类的属性名
* @param columnValue 实体类的属性值
* @param dicType 字典的类型
* @Param [sysPopulationSimpleDictDTOS, basePopulationInformationExportDto, column]
* @return java.lang.String
**/
private void setDicNameByValue(List<SysPopulationSimpleDictDTO> sysPopulationSimpleDictDTOS,BasePopulationInformationExportDto basePopulationInformationExportDto,String column,String columnValue,String dicType) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
a:for (SysPopulationSimpleDictDTO sysPopulationSimpleDictDTO : sysPopulationSimpleDictDTOS) {
if (dicType.equals(sysPopulationSimpleDictDTO.getDicType())) {
List<SysSimpleDictDTO> sysSimpleDicts = sysPopulationSimpleDictDTO.getSysSimpleDicts();
for (SysSimpleDictDTO sysSimpleDict : sysSimpleDicts) {
if (columnValue.equals(sysSimpleDict.getDictValue())) {
Class basePopulationInformationExportDtoClass = basePopulationInformationExportDto.getClass();
PropertyDescriptor pd = new PropertyDescriptor(column, basePopulationInformationExportDtoClass);
Method wM = pd.getWriteMethod();//获得写方法
wM.invoke(basePopulationInformationExportDto, sysSimpleDict.getDictName());
break a;
}
}
}
}
}
/**
* @Description 批量导入
* @Author songyunpeng
@ -218,70 +302,65 @@ public class HousingInformationController {
houseUse.setFirstCol(7);
houseUse.setLastCol(7);
houseUse.setExcelSelections(new String[]{"自住","租赁","经营"});
ExcelSelectionDto houseHead = new ExcelSelectionDto();
houseHead.setSheetIndex(0);
houseHead.setFirstCol(16);
houseHead.setLastCol(16);
houseHead.setExcelSelections(new String[]{"男","女"});
ExcelSelectionDto educationLevel = new ExcelSelectionDto();
educationLevel.setSheetIndex(0);
educationLevel.setFirstCol(19);
educationLevel.setLastCol(19);
educationLevel.setFirstCol(17);
educationLevel.setLastCol(17);
ExcelSelectionDto politicsStatus = new ExcelSelectionDto();
politicsStatus.setSheetIndex(0);
politicsStatus.setFirstCol(20);
politicsStatus.setLastCol(20);
politicsStatus.setFirstCol(18);
politicsStatus.setLastCol(18);
ExcelSelectionDto bodyStatus = new ExcelSelectionDto();
bodyStatus.setSheetIndex(0);
bodyStatus.setFirstCol(25);
bodyStatus.setLastCol(25);
bodyStatus.setFirstCol(23);
bodyStatus.setLastCol(23);
ExcelSelectionDto maritalStatus = new ExcelSelectionDto();
maritalStatus.setSheetIndex(0);
maritalStatus.setFirstCol(26);
maritalStatus.setLastCol(26);
maritalStatus.setFirstCol(24);
maritalStatus.setLastCol(24);
ExcelSelectionDto accountType = new ExcelSelectionDto();
accountType.setSheetIndex(0);
accountType.setFirstCol(27);
accountType.setLastCol(27);
accountType.setFirstCol(25);
accountType.setLastCol(25);
ExcelSelectionDto militaryService = new ExcelSelectionDto();
militaryService.setSheetIndex(0);
militaryService.setFirstCol(28);
militaryService.setLastCol(28);
militaryService.setFirstCol(26);
militaryService.setLastCol(26);
militaryService.setExcelSelections(new String[]{"是","否"});
ExcelSelectionDto employedStatus = new ExcelSelectionDto();
employedStatus.setSheetIndex(0);
employedStatus.setFirstCol(30);
employedStatus.setLastCol(30);
employedStatus.setFirstCol(28);
employedStatus.setLastCol(28);
ExcelSelectionDto unEmployedReason = new ExcelSelectionDto();
unEmployedReason.setSheetIndex(0);
unEmployedReason.setFirstCol(33);
unEmployedReason.setLastCol(33);
unEmployedReason.setFirstCol(31);
unEmployedReason.setLastCol(31);
ExcelSelectionDto reEmployedPermit = new ExcelSelectionDto();
reEmployedPermit.setSheetIndex(0);
reEmployedPermit.setFirstCol(34);
reEmployedPermit.setLastCol(34);
reEmployedPermit.setFirstCol(32);
reEmployedPermit.setLastCol(32);
reEmployedPermit.setExcelSelections(new String[]{"有","无"});
ExcelSelectionDto unEmployedRegister = new ExcelSelectionDto();
unEmployedRegister.setSheetIndex(0);
unEmployedRegister.setFirstCol(35);
unEmployedRegister.setLastCol(35);
unEmployedRegister.setFirstCol(33);
unEmployedRegister.setLastCol(33);
unEmployedRegister.setExcelSelections(new String[]{"是","否"});
ExcelSelectionDto familyCategory = new ExcelSelectionDto();
familyCategory.setSheetIndex(0);
familyCategory.setFirstCol(37);
familyCategory.setLastCol(37);
familyCategory.setFirstCol(35);
familyCategory.setLastCol(35);
ExcelSelectionDto helpStatus = new ExcelSelectionDto();
helpStatus.setSheetIndex(0);
helpStatus.setFirstCol(38);
helpStatus.setLastCol(38);
helpStatus.setFirstCol(36);
helpStatus.setLastCol(36);
ExcelSelectionDto motorVehicleCategory = new ExcelSelectionDto();
motorVehicleCategory.setSheetIndex(0);
motorVehicleCategory.setFirstCol(40);
motorVehicleCategory.setLastCol(40);
motorVehicleCategory.setFirstCol(38);
motorVehicleCategory.setLastCol(38);
ExcelSelectionDto dogStatus = new ExcelSelectionDto();
dogStatus.setSheetIndex(0);
dogStatus.setFirstCol(41);
dogStatus.setLastCol(41);
dogStatus.setFirstCol(39);
dogStatus.setLastCol(39);
dogStatus.setExcelSelections(new String[]{"有","无"});
ExcelSelectionDto houseHeadRelation = new ExcelSelectionDto();
houseHeadRelation.setSheetIndex(1);
@ -385,7 +464,7 @@ public class HousingInformationController {
continue;
}
}
Collections.addAll(excelSelectionDtos,houseUse,houseHead,educationLevel,politicsStatus,bodyStatus,maritalStatus,accountType,employedStatus,unEmployedReason,familyCategory,helpStatus,motorVehicleCategory,dogStatus,unEmployedRegister,reEmployedPermit,militaryService,houseHeadRelation,residentSex);
Collections.addAll(excelSelectionDtos,houseUse,educationLevel,politicsStatus,bodyStatus,maritalStatus,accountType,employedStatus,unEmployedReason,familyCategory,helpStatus,motorVehicleCategory,dogStatus,unEmployedRegister,reEmployedPermit,militaryService,houseHeadRelation,residentSex);
ExcelUtils.exportExcelToTargetWithSheets(response, "居民信息录入模板",sheetNames,classes,excelSelectionDtos,basePopulationInformationExcels,baseResidentInformationExcels);
}

44
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/controller/PopulationInformationController.java

@ -17,6 +17,7 @@
package com.elink.esua.epdc.controller;
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.ExcelUtils;
import com.elink.esua.epdc.commons.tools.utils.IdentityNoUtils;
@ -26,18 +27,22 @@ import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
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.constant.PopulationDictConstant;
import com.elink.esua.epdc.dto.PopulationInfoOverviewDTO;
import com.elink.esua.epdc.dto.PopulationInformationDTO;
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.excel.FamilyInformationExcel;
import com.elink.esua.epdc.excel.PopulationInformationExcel;
import com.elink.esua.epdc.excel.populationMotorVehicleExcel;
import com.elink.esua.epdc.feign.AdminFeignClient;
import com.elink.esua.epdc.service.PopulationInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
@ -53,6 +58,10 @@ public class PopulationInformationController {
@Autowired
private PopulationInformationService populationInformationService;
@Autowired
private AdminFeignClient adminFeignClient;
@GetMapping("page")
public Result<PageData<PopulationInformationDTO>> page(@RequestParam Map<String, Object> params){
PageData<PopulationInformationDTO> page = populationInformationService.listPage(params);
@ -134,6 +143,37 @@ public class PopulationInformationController {
@GetMapping("motorVehicle/export")
public void motorVehicleExport(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<PopulationInformationDTO> list = populationInformationService.motorVehicleList(params);
//处理机动车类型
//获取字典信息
SysPopulationSimpleDictFormDTO sysPopulationSimpleDictFormDTO = new SysPopulationSimpleDictFormDTO();
List<String> dicTypes = new ArrayList<>();
Collections.addAll(dicTypes, PopulationDictConstant.MOTOR_VEHICLE_CATEGORY);
sysPopulationSimpleDictFormDTO.setDicTypes(dicTypes);
Result<List<SysPopulationSimpleDictDTO>> listResult = adminFeignClient.listPopulationSimple(sysPopulationSimpleDictFormDTO);
if (listResult == null || !listResult.success()) {
throw new RenException("获取字典失败!");
}
List<SysPopulationSimpleDictDTO> sysPopulationSimpleDictDTOS = listResult.getData();
for (PopulationInformationDTO populationInformationDTO : list) {
String[] motorVehicleCategoryStrings = populationInformationDTO.getMotorVehicleCategory().split(",");
String motorVehicleCategoryEnd = "";
a:for(String motorVehicleCategoryStr : Arrays.asList(motorVehicleCategoryStrings)){
for (SysPopulationSimpleDictDTO sysPopulationSimpleDictDTO : sysPopulationSimpleDictDTOS) {
if (PopulationDictConstant.MOTOR_VEHICLE_CATEGORY.equals(sysPopulationSimpleDictDTO.getDicType())) {
List<SysSimpleDictDTO> sysSimpleDicts = sysPopulationSimpleDictDTO.getSysSimpleDicts();
for (SysSimpleDictDTO sysSimpleDict : sysSimpleDicts) {
if (motorVehicleCategoryStr.equals(sysSimpleDict.getDictValue())) {
motorVehicleCategoryEnd += sysSimpleDict.getDictName()+",";
continue a;
}
}
}
}
}
populationInformationDTO.setMotorVehicleCategory(motorVehicleCategoryEnd.substring(0,motorVehicleCategoryEnd.lastIndexOf(",")));
}
ExcelUtils.exportExcelToTarget(response, "机动车信息", list, populationMotorVehicleExcel.class);
}
/**

20
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/excel/BasePopulationInformationExportExcel.java

@ -91,10 +91,10 @@ public class BasePopulationInformationExportExcel {
@Excel(name = "民族")
private String residentsNation;
@Excel(name = "文化程度",replace = {"博士_0","硕士_1","本科_2","大专_3","中专和中技_4","技工学校_5","高中_6","初中_7","小学_8","文盲与半文盲_9"})
@Excel(name = "文化程度")
private String educationLevel;
@Excel(name = "政治面貌",replace = {"群众_0","党员_1"})
@Excel(name = "政治面貌")
private String politicsStatus;
@Excel(name = "入党时间")
@ -109,13 +109,13 @@ public class BasePopulationInformationExportExcel {
@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"})
@ -124,7 +124,7 @@ public class BasePopulationInformationExportExcel {
@Excel(name = "户籍地")
private String householdRegistrationPlace;
@Excel(name = "就业情况",replace = {"在岗_0","失业_1"})
@Excel(name = "就业情况")
private String employmentStatus;
@Excel(name = "现工作单位")
@ -133,7 +133,7 @@ public class BasePopulationInformationExportExcel {
@Excel(name = "现单位地址")
private String currentEmployerAddress;
@Excel(name = "失业原因",replace = {"原单位破产_0","解除合同_1","效益不好_2","减员_3","其他_4"})
@Excel(name = "失业原因")
private String unemploymentReason;
@Excel(name = "再就业优惠证",replace = {"无_0","有_1"})
@ -145,16 +145,16 @@ public class BasePopulationInformationExportExcel {
@Excel(name = "失业登记时间")
private String unemploymentRegisterTime;
@Excel(name = "家庭类别",replace = {"普通家庭_0","军烈家庭_1","优抚家庭_2","困难家庭_3"})
@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/BaseResidentInformationExportExcel.java

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

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

@ -36,7 +36,7 @@ public class populationMotorVehicleExcel {
@Excel(name = "联系电话")
private String residentsPhone;
@Excel(name = "机动车类型",replace = {"轿车_0", "摩托_1","其他_2"})
@Excel(name = "机动车类型")
private String motorVehicleCategory;

1
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/HouseResidentServiceImpl.java

@ -372,6 +372,7 @@ public class HouseResidentServiceImpl extends BaseServiceImpl<HouseResidentDao,
populationInformationService.updateById(populationInformationEntity);
HouseResidentEntity houseResidentEntity = new HouseResidentEntity();
houseResidentEntity.setHouseHeadRelation(dto.getHouseHeadRelation());
houseResidentEntity.setId(dto.getId());
this.updateById(houseResidentEntity);
return new Result();
}

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

@ -261,14 +261,15 @@ public class HousingInformationServiceImpl extends BaseServiceImpl<HousingInform
//1.根据房屋信息查询所有与房屋关联的人
Map<String, Object> params = new HashMap<>();
params.put("HOUSE_ID", ids[0]);
//其实此时查看与房子有关系的人,只会查出一个就是户主,居住人的关联关系只与户主有关
List<HouseResidentEntity> houseResidentEntities = houseResidentDao.selectByMap(params);
List<String> populationIds = new ArrayList<>();
if (houseResidentEntities != null && houseResidentEntities.size() > 0) {
for (HouseResidentEntity houseResidentEntity : houseResidentEntities) {
//删除条件:与此房屋有关联的人有户主和居住人两个身份
//删除条件:与此房屋有关联的人有户主
//判断是否还有其他房子的关联关系,如果有只删除与此房子的关联关系,没有则删除人口信息+关联关系
Map<String, Object> residentParams = new HashMap<>();
params.put("RESIDENT_ID", houseResidentEntity.getResidentId());
residentParams.put("RESIDENT_ID", houseResidentEntity.getResidentId());
List<HouseResidentEntity> allHouseResidentEntities = houseResidentDao.selectByMap(residentParams);
if (allHouseResidentEntities != null && allHouseResidentEntities.size() == 1) {
//此人只与此房屋关联
@ -278,6 +279,11 @@ public class HousingInformationServiceImpl extends BaseServiceImpl<HousingInform
//删除人口信息 -- 只删与且仅与此房屋有关系的人口
if (populationIds.size() > 0) {
populationInformationService.deleteBatchIds(populationIds);
//且删除此户主对应的居民信息
//根据此户主ID删除
Map<String, Object> residentParams = new HashMap<>();
residentParams.put("HOUSE_HEAD_ID", populationIds.get(0));
houseResidentDao.deleteByMap(residentParams);
}
//删除关联关系 -- 全删
houseResidentDao.deleteByMap(params);
@ -297,11 +303,11 @@ public class HousingInformationServiceImpl extends BaseServiceImpl<HousingInform
@Transactional(rollbackFor = Exception.class)
public Result importPopulationInfo(MultipartFile file, String gridId) {
if (StringUtils.isBlank(gridId)) {
throw new RenException("归属部门不能为空");
return new Result().error("归属部门不能为空");
}
Result<ParentAndAllDeptDTO> parentAndAllDept = adminFeignClient.getParentAndAllDept(gridId);
if (!parentAndAllDept.success() || parentAndAllDept.getData() == null) {
throw new RenException("获取归属部门信息失败");
return new Result().error("获取归属部门信息失败");
}
ParentAndAllDeptDTO parentAndAllDeptDTO = parentAndAllDept.getData();
//获取字典信息
@ -313,7 +319,7 @@ public class HousingInformationServiceImpl extends BaseServiceImpl<HousingInform
sysPopulationSimpleDictFormDTO.setDicTypes(dicTypes);
Result<List<SysPopulationSimpleDictDTO>> listResult = adminFeignClient.listPopulationSimple(sysPopulationSimpleDictFormDTO);
if (listResult == null || !listResult.success()) {
throw new RenException("获取字典信息失败");
return new Result().error("获取字典信息失败");
}
List<SysPopulationSimpleDictDTO> sysPopulationSimpleDictDTOS = listResult.getData();
@ -323,34 +329,41 @@ public class HousingInformationServiceImpl extends BaseServiceImpl<HousingInform
try {
//获取多个sheet页
Workbook workBook = ExcelUtils.getWorkBook(file);
//
Map<String, String> populationIdNoAndIdMap = new HashMap<>();
List<BasePopulationInformationExcel> basePopulationInformationExcels = null;
List<EpdcPopulationErrorResultDTO> epdcHouseAndHouseHeadErrorResultDTOS = null;
List<BaseResidentInformationExcel> baseResidentInformationExcels = null;
List<EpdcPopulationErrorResultDTO> epdcResidentErrorResultDTOS = null;
for (int numSheet = 0; numSheet < workBook.getNumberOfSheets(); numSheet++) {
//第几个sheet
importParams.setStartSheetIndex(numSheet);
if (numSheet == 0) {//校验和新增房屋和户主信息
List<BasePopulationInformationExcel> basePopulationInformationExcels = ExcelImportUtil.importExcel(f, BasePopulationInformationExcel.class, importParams);
basePopulationInformationExcels = ExcelImportUtil.importExcel(f, BasePopulationInformationExcel.class, importParams);
// 校验数据
List<EpdcPopulationErrorResultDTO> epdcPartyErrorResultDTOS = this.checkPopulationExcel(basePopulationInformationExcels, sysPopulationSimpleDictDTOS);
if (epdcPartyErrorResultDTOS.size() > 0) {
return new Result().ok(epdcPartyErrorResultDTOS);
}
if(basePopulationInformationExcels.size()>0){
savePopulationList(basePopulationInformationExcels, parentAndAllDeptDTO);
}
epdcHouseAndHouseHeadErrorResultDTOS = this.checkPopulationExcel(basePopulationInformationExcels, sysPopulationSimpleDictDTOS);
} else if (numSheet == 1) {//检验和新增居住人信息
List<BaseResidentInformationExcel> baseResidentInformationExcels = ExcelImportUtil.importExcel(f, BaseResidentInformationExcel.class, importParams);
baseResidentInformationExcels = ExcelImportUtil.importExcel(f, BaseResidentInformationExcel.class, importParams);
// 校验数据
List<EpdcPopulationErrorResultDTO> epdcPartyErrorResultDTOS = this.checkResidentsExcel(baseResidentInformationExcels, sysPopulationSimpleDictDTOS);
if (epdcPartyErrorResultDTOS.size() > 0) {
return new Result().ok(epdcPartyErrorResultDTOS);
}
if(baseResidentInformationExcels.size()>0){
saveResidentList(baseResidentInformationExcels);
}
epdcResidentErrorResultDTOS = this.checkResidentsExcel(baseResidentInformationExcels, sysPopulationSimpleDictDTOS);
}
}
if (epdcHouseAndHouseHeadErrorResultDTOS!=null && epdcHouseAndHouseHeadErrorResultDTOS.size() > 0) {
return new Result().ok(epdcHouseAndHouseHeadErrorResultDTOS);
}
if (epdcResidentErrorResultDTOS!=null && epdcResidentErrorResultDTOS.size() > 0) {
return new Result().ok(epdcResidentErrorResultDTOS);
}
if(basePopulationInformationExcels!=null && basePopulationInformationExcels.size()>0){
populationIdNoAndIdMap = savePopulationList(basePopulationInformationExcels, parentAndAllDeptDTO);
}
if(baseResidentInformationExcels!=null && baseResidentInformationExcels.size()>0){
saveResidentList(baseResidentInformationExcels,populationIdNoAndIdMap);
}
} catch (Exception e1) {
throw new RenException("导入失败:{}" + e1.getMessage());
throw new RenException("导入失败:请检查导入模板或导入数据");
}
return new Result();
}
@ -372,14 +385,8 @@ public class HousingInformationServiceImpl extends BaseServiceImpl<HousingInform
* @Date 2020/8/31
* @Param [baseResidentInformationExcels]
**/
private void saveResidentList(List<BaseResidentInformationExcel> baseResidentInformationExcels) {
private void saveResidentList(List<BaseResidentInformationExcel> baseResidentInformationExcels, Map<String, String> populationIdNoAndIdMap) {
for (BaseResidentInformationExcel baseResidentInformationExcel : baseResidentInformationExcels) {
//查找户主ID
PopulationInformationEntity infoByIdentityNo = populationInformationService.getInfoByIdentityNo(baseResidentInformationExcel.getResidentsIdentityNo());
if (infoByIdentityNo == null) {
//查找不到户主则跳过此人
continue;
}
//插入居民信息
PopulationInformationEntity populationInformationEntity = ConvertUtils.sourceToTarget(baseResidentInformationExcel, PopulationInformationEntity.class);
populationInformationEntity.setResidentsIdentityNo(null);
@ -387,7 +394,17 @@ public class HousingInformationServiceImpl extends BaseServiceImpl<HousingInform
//插入房屋人员关联关系表
HouseResidentEntity houseResidentEntity = ConvertUtils.sourceToTarget(baseResidentInformationExcel, HouseResidentEntity.class);
houseResidentEntity.setResidentId(populationInformationEntity.getId());
houseResidentEntity.setHouseHeadId(infoByIdentityNo.getId());
//根据身份证获取户主ID
//查找户主ID
String houseHeadId;
PopulationInformationEntity infoByIdentityNo = populationInformationService.getInfoByIdentityNo(baseResidentInformationExcel.getResidentsIdentityNo());
if (infoByIdentityNo == null) {
//查找不到户主则从Map中取
houseHeadId = populationIdNoAndIdMap.get(baseResidentInformationExcel.getResidentsIdentityNo());
} else {
houseHeadId = infoByIdentityNo.getId();
}
houseResidentEntity.setHouseHeadId(houseHeadId);
houseResidentEntity.setIsHouseHead("0");
houseResidentEntity.setHouseHeadRelation(baseResidentInformationExcel.getHouseHeadRelation());
houseResidentDao.insert(houseResidentEntity);
@ -403,7 +420,7 @@ public class HousingInformationServiceImpl extends BaseServiceImpl<HousingInform
* @Date 2020/8/31
* @Param [basePopulationInformationExcels]
**/
private void savePopulationList(List<BasePopulationInformationExcel> basePopulationInformationExcels, ParentAndAllDeptDTO parentAndAllDeptDTO) {
private Map<String,String> savePopulationList(List<BasePopulationInformationExcel> basePopulationInformationExcels, ParentAndAllDeptDTO parentAndAllDeptDTO) {
//插入房屋信息
List<HousingInformationEntity> housingInformationEntityList = new ArrayList<>();
@ -522,6 +539,13 @@ public class HousingInformationServiceImpl extends BaseServiceImpl<HousingInform
if (houseResidentEntityList.size() > 0) {
houseResidentService.insertBatch(houseResidentEntityList);
}
//组装人口身份证和ID信息 辅助添加居民信息
insertPopulationInfo.addAll(updatePopulationInfo);
Map<String,String> populationIdNoAndIdMap = new HashMap<>();
insertPopulationInfo.forEach(i -> {
populationIdNoAndIdMap.put(i.getResidentsIdentityNo(),i.getId());
});
return populationIdNoAndIdMap;
}
/**
@ -1368,32 +1392,38 @@ public class HousingInformationServiceImpl extends BaseServiceImpl<HousingInform
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
if (motorVehicleNum.intValue() > 0 && StringUtils.isBlank(motorVehicleCategory)) {
if (motorVehicleNum != null && 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());
//处理多选类型
String[] motorVehicleCategoryStrings = motorVehicleCategory.split(",");
Integer matchNum = 0;
String motorVehicleCategoryEnd = "";
for(String motorVehicleCategoryStr : Arrays.asList(motorVehicleCategoryStrings)){
for (SysPopulationSimpleDictDTO sysPopulationSimpleDictDTO : sysPopulationSimpleDictDTOS) {
if (PopulationDictConstant.MOTOR_VEHICLE_CATEGORY.equals(sysPopulationSimpleDictDTO.getDicType())) {
List<SysSimpleDictDTO> sysSimpleDicts = sysPopulationSimpleDictDTO.getSysSimpleDicts();
for (SysSimpleDictDTO sysSimpleDict : sysSimpleDicts) {
if (motorVehicleCategoryStr.equals(sysSimpleDict.getDictName())) {
matchNum ++;
motorVehicleCategoryEnd += sysSimpleDict.getDictValue()+",";
}
}
}
}
}
if (!isMatch) {
if (matchNum != motorVehicleCategoryStrings.length) {
errorLineInfoDto = new EpdcPopulationErrorResultDTO();
errorLineInfoDto.setErrorLine((i + 2) + "");
errorLineInfoDto.setErrorInfo("机动车类型数据不匹配");
errorLineInfoDto.setSheetName("房屋信息和户主信息");
errorLineInfoList.add(errorLineInfoDto);
}
basePopulationInformationExcel.setMotorVehicleCategory(motorVehicleCategoryEnd.substring(0,motorVehicleCategoryEnd.lastIndexOf(",")));
}
if (StringUtils.isBlank(dogStatus)) {
errorLineInfoDto = new EpdcPopulationErrorResultDTO();

8
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/PopulationInformationServiceImpl.java

@ -237,7 +237,13 @@ public class PopulationInformationServiceImpl extends BaseServiceImpl<Population
@Override
public PopulationInformationDTO getHouseHeadInfo(String houseId) {
return baseDao.getHouseHeadInfo(houseId);
PopulationInformationDTO houseHeadInfo = baseDao.getHouseHeadInfo(houseId);
//处理机动车类型
if(StringUtils.isNotBlank(houseHeadInfo.getMotorVehicleCategory())){
String[] motorVehicleCategoryStrings = houseHeadInfo.getMotorVehicleCategory().split(",");
houseHeadInfo.setMotorVehicleCategoryList(Arrays.asList(motorVehicleCategoryStrings));
}
return houseHeadInfo;
}
@Override

6
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/resources/mapper/PopulationInformationDao.xml

@ -82,10 +82,6 @@
t.MOTOR_VEHICLE_NUM,
t.MOTOR_VEHICLE_CATEGORY,
t.DOG_STATUS,
t.FAMILY_MEMBER_NUM,
t.FAMILY_MEMBER_OUT_NUM,
t.FAMILY_MEMBER_OUT_REASON,
t.FAMILY_MEMBER_OUT_MONTH,
t.CURRENT_ADDRESS,
t1.HOUSE_ID as houseId
from epdc_population_information t
@ -150,7 +146,7 @@
select MOTOR_VEHICLE_NUM,MOTOR_VEHICLE_CATEGORY,RESIDENTS_NAME,RESIDENTS_PHONE
from epdc_population_information
where DEL_FLAG ='0' and MOTOR_VEHICLE_NUM is not null and MOTOR_VEHICLE_NUM > 0
<if test="motorVehicleCategory != '' and motorVehicleCategory != null">and MOTOR_VEHICLE_CATEGORY = #{motorVehicleCategory} </if>
<if test="motorVehicleCategory != '' and motorVehicleCategory != null">and find_in_set(#{motorVehicleCategory},MOTOR_VEHICLE_CATEGORY) </if>
<if test="residentsName != '' and residentsName != null">and RESIDENTS_NAME like concat('%',#{residentsName},'%') </if>
order by CREATED_TIME
</select>

Loading…
Cancel
Save