|
@ -37,11 +37,16 @@ import com.elink.esua.epdc.excel.BaseResidentInformationExcel; |
|
|
import com.elink.esua.epdc.excel.BaseResidentInformationExportExcel; |
|
|
import com.elink.esua.epdc.excel.BaseResidentInformationExportExcel; |
|
|
import com.elink.esua.epdc.feign.AdminFeignClient; |
|
|
import com.elink.esua.epdc.feign.AdminFeignClient; |
|
|
import com.elink.esua.epdc.service.HousingInformationService; |
|
|
import com.elink.esua.epdc.service.HousingInformationService; |
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
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.math.BigDecimal; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
@ -110,6 +115,60 @@ public class HousingInformationController { |
|
|
if(basePopulationInformationExcelList == null || basePopulationInformationExcelList.size()==0){ |
|
|
if(basePopulationInformationExcelList == null || basePopulationInformationExcelList.size()==0){ |
|
|
ExcelUtils.exportExcelToTargetWithSheets(response, "居民信息导出",sheetNames,classes,new ArrayList<>(), new ArrayList<>(),new ArrayList<>()); |
|
|
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查询居住人信息
|
|
|
//根据获取的户主ID查询居住人信息
|
|
|
Map<String,List<BasePopulationInformationExportDto>> baseMap = basePopulationInformationExcelList.stream().collect(Collectors.groupingBy(BasePopulationInformationExportDto::getId)); |
|
|
Map<String,List<BasePopulationInformationExportDto>> baseMap = basePopulationInformationExcelList.stream().collect(Collectors.groupingBy(BasePopulationInformationExportDto::getId)); |
|
|
//获取所有的户主ID
|
|
|
//获取所有的户主ID
|
|
@ -117,7 +176,32 @@ public class HousingInformationController { |
|
|
List<BaseResidentInformationExportDto> baseResidentInformationExportDtoList = housingInformationService.selectBaseResidentInformationExcelList(houseHeadIds); |
|
|
List<BaseResidentInformationExportDto> baseResidentInformationExportDtoList = housingInformationService.selectBaseResidentInformationExcelList(houseHeadIds); |
|
|
ExcelUtils.exportExcelToTargetWithSheets(response, "居民信息导出",sheetNames,classes,new ArrayList<>(), ConvertUtils.sourceToTarget(basePopulationInformationExcelList, BasePopulationInformationExportExcel.class),ConvertUtils.sourceToTarget(baseResidentInformationExportDtoList,BaseResidentInformationExportExcel.class)); |
|
|
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 批量导入 |
|
|
* @Description 批量导入 |
|
|
* @Author songyunpeng |
|
|
* @Author songyunpeng |
|
@ -218,70 +302,65 @@ public class HousingInformationController { |
|
|
houseUse.setFirstCol(7); |
|
|
houseUse.setFirstCol(7); |
|
|
houseUse.setLastCol(7); |
|
|
houseUse.setLastCol(7); |
|
|
houseUse.setExcelSelections(new String[]{"自住","租赁","经营"}); |
|
|
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(); |
|
|
ExcelSelectionDto educationLevel = new ExcelSelectionDto(); |
|
|
educationLevel.setSheetIndex(0); |
|
|
educationLevel.setSheetIndex(0); |
|
|
educationLevel.setFirstCol(19); |
|
|
educationLevel.setFirstCol(17); |
|
|
educationLevel.setLastCol(19); |
|
|
educationLevel.setLastCol(17); |
|
|
ExcelSelectionDto politicsStatus = new ExcelSelectionDto(); |
|
|
ExcelSelectionDto politicsStatus = new ExcelSelectionDto(); |
|
|
politicsStatus.setSheetIndex(0); |
|
|
politicsStatus.setSheetIndex(0); |
|
|
politicsStatus.setFirstCol(20); |
|
|
politicsStatus.setFirstCol(18); |
|
|
politicsStatus.setLastCol(20); |
|
|
politicsStatus.setLastCol(18); |
|
|
ExcelSelectionDto bodyStatus = new ExcelSelectionDto(); |
|
|
ExcelSelectionDto bodyStatus = new ExcelSelectionDto(); |
|
|
bodyStatus.setSheetIndex(0); |
|
|
bodyStatus.setSheetIndex(0); |
|
|
bodyStatus.setFirstCol(25); |
|
|
bodyStatus.setFirstCol(23); |
|
|
bodyStatus.setLastCol(25); |
|
|
bodyStatus.setLastCol(23); |
|
|
ExcelSelectionDto maritalStatus = new ExcelSelectionDto(); |
|
|
ExcelSelectionDto maritalStatus = new ExcelSelectionDto(); |
|
|
maritalStatus.setSheetIndex(0); |
|
|
maritalStatus.setSheetIndex(0); |
|
|
maritalStatus.setFirstCol(26); |
|
|
maritalStatus.setFirstCol(24); |
|
|
maritalStatus.setLastCol(26); |
|
|
maritalStatus.setLastCol(24); |
|
|
ExcelSelectionDto accountType = new ExcelSelectionDto(); |
|
|
ExcelSelectionDto accountType = new ExcelSelectionDto(); |
|
|
accountType.setSheetIndex(0); |
|
|
accountType.setSheetIndex(0); |
|
|
accountType.setFirstCol(27); |
|
|
accountType.setFirstCol(25); |
|
|
accountType.setLastCol(27); |
|
|
accountType.setLastCol(25); |
|
|
ExcelSelectionDto militaryService = new ExcelSelectionDto(); |
|
|
ExcelSelectionDto militaryService = new ExcelSelectionDto(); |
|
|
militaryService.setSheetIndex(0); |
|
|
militaryService.setSheetIndex(0); |
|
|
militaryService.setFirstCol(28); |
|
|
militaryService.setFirstCol(26); |
|
|
militaryService.setLastCol(28); |
|
|
militaryService.setLastCol(26); |
|
|
militaryService.setExcelSelections(new String[]{"是","否"}); |
|
|
militaryService.setExcelSelections(new String[]{"是","否"}); |
|
|
ExcelSelectionDto employedStatus = new ExcelSelectionDto(); |
|
|
ExcelSelectionDto employedStatus = new ExcelSelectionDto(); |
|
|
employedStatus.setSheetIndex(0); |
|
|
employedStatus.setSheetIndex(0); |
|
|
employedStatus.setFirstCol(30); |
|
|
employedStatus.setFirstCol(28); |
|
|
employedStatus.setLastCol(30); |
|
|
employedStatus.setLastCol(28); |
|
|
ExcelSelectionDto unEmployedReason = new ExcelSelectionDto(); |
|
|
ExcelSelectionDto unEmployedReason = new ExcelSelectionDto(); |
|
|
unEmployedReason.setSheetIndex(0); |
|
|
unEmployedReason.setSheetIndex(0); |
|
|
unEmployedReason.setFirstCol(33); |
|
|
unEmployedReason.setFirstCol(31); |
|
|
unEmployedReason.setLastCol(33); |
|
|
unEmployedReason.setLastCol(31); |
|
|
ExcelSelectionDto reEmployedPermit = new ExcelSelectionDto(); |
|
|
ExcelSelectionDto reEmployedPermit = new ExcelSelectionDto(); |
|
|
reEmployedPermit.setSheetIndex(0); |
|
|
reEmployedPermit.setSheetIndex(0); |
|
|
reEmployedPermit.setFirstCol(34); |
|
|
reEmployedPermit.setFirstCol(32); |
|
|
reEmployedPermit.setLastCol(34); |
|
|
reEmployedPermit.setLastCol(32); |
|
|
reEmployedPermit.setExcelSelections(new String[]{"有","无"}); |
|
|
reEmployedPermit.setExcelSelections(new String[]{"有","无"}); |
|
|
ExcelSelectionDto unEmployedRegister = new ExcelSelectionDto(); |
|
|
ExcelSelectionDto unEmployedRegister = new ExcelSelectionDto(); |
|
|
unEmployedRegister.setSheetIndex(0); |
|
|
unEmployedRegister.setSheetIndex(0); |
|
|
unEmployedRegister.setFirstCol(35); |
|
|
unEmployedRegister.setFirstCol(33); |
|
|
unEmployedRegister.setLastCol(35); |
|
|
unEmployedRegister.setLastCol(33); |
|
|
unEmployedRegister.setExcelSelections(new String[]{"是","否"}); |
|
|
unEmployedRegister.setExcelSelections(new String[]{"是","否"}); |
|
|
ExcelSelectionDto familyCategory = new ExcelSelectionDto(); |
|
|
ExcelSelectionDto familyCategory = new ExcelSelectionDto(); |
|
|
familyCategory.setSheetIndex(0); |
|
|
familyCategory.setSheetIndex(0); |
|
|
familyCategory.setFirstCol(37); |
|
|
familyCategory.setFirstCol(35); |
|
|
familyCategory.setLastCol(37); |
|
|
familyCategory.setLastCol(35); |
|
|
ExcelSelectionDto helpStatus = new ExcelSelectionDto(); |
|
|
ExcelSelectionDto helpStatus = new ExcelSelectionDto(); |
|
|
helpStatus.setSheetIndex(0); |
|
|
helpStatus.setSheetIndex(0); |
|
|
helpStatus.setFirstCol(38); |
|
|
helpStatus.setFirstCol(36); |
|
|
helpStatus.setLastCol(38); |
|
|
helpStatus.setLastCol(36); |
|
|
ExcelSelectionDto motorVehicleCategory = new ExcelSelectionDto(); |
|
|
ExcelSelectionDto motorVehicleCategory = new ExcelSelectionDto(); |
|
|
motorVehicleCategory.setSheetIndex(0); |
|
|
motorVehicleCategory.setSheetIndex(0); |
|
|
motorVehicleCategory.setFirstCol(40); |
|
|
motorVehicleCategory.setFirstCol(38); |
|
|
motorVehicleCategory.setLastCol(40); |
|
|
motorVehicleCategory.setLastCol(38); |
|
|
ExcelSelectionDto dogStatus = new ExcelSelectionDto(); |
|
|
ExcelSelectionDto dogStatus = new ExcelSelectionDto(); |
|
|
dogStatus.setSheetIndex(0); |
|
|
dogStatus.setSheetIndex(0); |
|
|
dogStatus.setFirstCol(41); |
|
|
dogStatus.setFirstCol(39); |
|
|
dogStatus.setLastCol(41); |
|
|
dogStatus.setLastCol(39); |
|
|
dogStatus.setExcelSelections(new String[]{"有","无"}); |
|
|
dogStatus.setExcelSelections(new String[]{"有","无"}); |
|
|
ExcelSelectionDto houseHeadRelation = new ExcelSelectionDto(); |
|
|
ExcelSelectionDto houseHeadRelation = new ExcelSelectionDto(); |
|
|
houseHeadRelation.setSheetIndex(1); |
|
|
houseHeadRelation.setSheetIndex(1); |
|
@ -385,7 +464,7 @@ public class HousingInformationController { |
|
|
continue; |
|
|
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); |
|
|
ExcelUtils.exportExcelToTargetWithSheets(response, "居民信息录入模板",sheetNames,classes,excelSelectionDtos,basePopulationInformationExcels,baseResidentInformationExcels); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|