springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/constants/Constants.java
@@ -167,6 +167,8 @@ public static final String SENTENCE_POPULATION_ERROR_LIST = "SENTENCE_POPULATION_ERROR_LIST_"; public static final String VETERANS_POPULATION_ERROR_LIST = "VETERANS_POPULATION_ERROR_LIST_"; /** * 高德地图获取天气url */ springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationVeteransExcelListen.java
New file @@ -0,0 +1,128 @@ package com.panzhihua.common.listen; import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.fastjson.JSONArray; import com.google.common.collect.Lists; import com.panzhihua.common.constants.BcDictionaryConstants; import com.panzhihua.common.constants.Constants; import com.panzhihua.common.enums.*; import com.panzhihua.common.exceptions.ServiceException; import com.panzhihua.common.model.vos.BcDictionaryVO; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.ComMngPopulationVeteransExcelVO; import com.panzhihua.common.model.vos.community.ComMngPopulationVeteransMistakeExcelVO; import com.panzhihua.common.service.community.CommunityService; import com.panzhihua.common.utlis.ListUtils; import com.panzhihua.common.utlis.PayUtil; import com.panzhihua.common.utlis.StringUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.ValueOperations; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** * @description: 退役军人导入监听 * @author: txb */ @Slf4j public class ComMngPopulationVeteransExcelListen extends AnalysisEventListener<Map<Integer, String>> { private CommunityService communityService; private Long communityId; private static int headSize = 0; private Map<Integer, String> headData; private String userName; // FTP 登录密码 private String password; // FTP 服务器地址IP地址 private String host; // FTP 端口 private int port; private String excelUrl; private StringRedisTemplate stringRedisTemplate; public static String loadUrl; public ComMngPopulationVeteransExcelListen(CommunityService communityService, Long communityId, String userName, String password, String host, int port, String excelUrl, StringRedisTemplate stringRedisTemplate) { this.communityService = communityService; this.communityId = communityId; this.userName = userName; this.password = password; this.host = host; this.port = port; this.excelUrl = excelUrl; this.stringRedisTemplate = stringRedisTemplate; } /** * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 */ private static final int BATCH_COUNT = 5000; List<Map<Integer, String>> list = new ArrayList<Map<Integer, String>>(); @Override public void invoke(Map<Integer, String> data, AnalysisContext context) { list.add(data); if (list.size() >= BATCH_COUNT) { saveData(); list.clear(); } } /** * 这里会一行行的返回头 * * @param headMap * @param context */ @Override public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) { headSize = headMap.size(); headData = headMap; } @Override public void doAfterAllAnalysed(AnalysisContext context) { saveData(); log.info("所有数据解析完成!"); } /** * 不是固定的列只能手动处理 */ private void saveData() { R<List<BcDictionaryVO>> dictionaryR = communityService.listDictionaryByKey(BcDictionaryConstants.FAMILY); log.info("开始导入退役军人数据"); log.info("表格总数据:" + list.size()); if (list.size() == 0) { throw new ServiceException("500", "导入数据为空!"); } ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); String Veterans = Constants.VETERANS_POPULATION_ERROR_LIST + communityId; Map<String,String> dictMap = dictionaryR.getData().stream().collect(Collectors.toMap(BcDictionaryVO::getDictName,BcDictionaryVO::getDictValue)); // Map<String,Integer> dictMap = new HashMap<>(); // for(BcDictionaryVO vo : dictionaryR.getData()){ // dictMap.put(vo.getDictName(),Integer.valueOf(vo.getDictValue())); // } int index = 2; } } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVeteransExcelVO.java
New file @@ -0,0 +1,242 @@ package com.panzhihua.common.model.vos.community; import com.alibaba.excel.annotation.ExcelProperty; import com.google.common.collect.Lists; import com.panzhihua.common.model.helper.encrypt.EncryptDecryptClass; import com.panzhihua.common.model.helper.encrypt.EncryptDecryptField; import com.panzhihua.common.validated.AddGroup; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotBlank; import java.io.Serializable; import java.util.Date; import java.util.List; /** * @description: 批量导入退役军人 * @author: txb */ @Data @EncryptDecryptClass public class ComMngPopulationVeteransExcelVO implements Serializable { @ExcelProperty(value = "序号", index = 0) private String serialNumber; @ExcelProperty(value = "人员状态:正常、失联、出国(取字典表)", index = 1) private String personStatus; @ExcelProperty(value = "机构", index = 2) private String organization; @ExcelProperty(value = "姓名", index = 3) private String name; @ExcelProperty(value = "身份证号码", index = 4) @EncryptDecryptField private String cardNo; @ExcelProperty(value = "联系电话", index = 5) private String phone; @ExcelProperty(value = "照片", index = 6) private String photo; @ExcelProperty(value = "户籍性质(1.城镇户口 2.农村户口)", index = 7) private Integer regiterNature; @ExcelProperty(value = "户口所在地", index = 8) private String censusRegister; @ExcelProperty(value = "外地/本地(1.本地 2.外地)", index = 9) private Integer outOrLocal; @ExcelProperty(value = "街/路/巷", index = 10) private String road; @ExcelProperty(value = "小区号", index = 11) private String doorNo; @ExcelProperty(value = "楼排号", index = 12) private String floor; @ExcelProperty(value = "单元号", index = 13) private String unitNo; @ExcelProperty(value = "户室(房间号)", index = 14) private String houseNo; @ExcelProperty(value = "是否租住", index = 15) private Integer isRent; @ExcelProperty(value = "房屋状态(1.自住 2.租住 3.其他)", index = 16) private Integer houseStatus; @ExcelProperty(value = "房屋用途(1.住宅 2.公寓 3.宿舍 4.仓库 5.其他)", index = 17) private Integer housePurpose; @ExcelProperty(value = "管控状态(1.常规 2.关注 3.管控)", index = 18) private Integer controlStatus; @ExcelProperty(value = "入伍时间", index = 19) private Date enlistDate; @ExcelProperty(value = "退伍时间", index = 20) private Date retireDate; @ExcelProperty(value = "人员类别", index = 21) private String personCategory; @ExcelProperty(value = "民族", index = 22) private String nation; @ExcelProperty(value = "健康状况", index = 23) private String healthy; @ExcelProperty(value = "政治面貌", index = 24) private Integer politicalOutlook; @ExcelProperty(value = "婚姻状况", index = 25) private Integer marriage; @ExcelProperty(value = "住房状况", index = 26) private String houseSituation; @ExcelProperty(value = "住房状况其他", index = 27) private String houseSituationOther; @ExcelProperty(value = "建筑面积", index = 28) private String buildArea; @ExcelProperty(value = "现就业情况", index = 29) private String employmentSituation; @ExcelProperty(value = "在职情况类型", index = 30) private String incumbencyType; @ExcelProperty(value = "现就业情况其他", index = 31) private String employmentSituationOther; @ExcelProperty(value = "养老保险", index = 32) private String endowmentInsurance; @ExcelProperty(value = "医疗保险", index = 33) private String medicalInsurance; @ExcelProperty(value = "现个人年收入(单位:元)", index = 34) private String annualIncome; @ExcelProperty(value = "父亲健康状况", index = 35) private String fatherHealthy; @ExcelProperty(value = "母亲健康状况", index = 36) private String motherHealthy; @ExcelProperty(value = "配偶健康状况", index = 37) private String spouseHealthy; @ExcelProperty(value = "儿子健康状况", index = 38) private String sonHealthy; @ExcelProperty(value = "女儿健康状况", index = 39) private String daughterHealthy; @ExcelProperty(value = "主要困难", index = 40) private String mainDifficulty; @ExcelProperty(value = "其他困难", index = 41) private String otherDifficulty; @ExcelProperty(value = "主要诉求", index = 42) private String mainDemand; @ExcelProperty(value = "主要诉求其他事项问题(手填)", index = 43) private String mainDemandOther; @ExcelProperty(value = "需参加的学历培训", index = 44) private String academicTraining; @ExcelProperty(value = "是否已参加退役军人培训(政府性质)", index = 45) private Integer isVeteransTraining; @ExcelProperty(value = "入伍前学历", index = 46) private String educationBeforeEnlistment; @ExcelProperty(value = "再教育学历", index = 47) private String reEducation; @ExcelProperty(value = "所学专业", index = 48) private String major; @ExcelProperty(value = "所学专业其他", index = 49) private String majorOther; @ExcelProperty(value = "曾从事行业(含现从事行业)", index = 50) private String onceEngagedIndustry; @ExcelProperty(value = "曾从事行业(含现从事行业)其他(手填)", index = 51) private String onceEngagedIndustryOther; @ExcelProperty(value = "意向就业地点", index = 52) private String intendedPlaceOfEmployment; @ExcelProperty(value = "意向就业地点其他地区(手填)", index = 53) private String intendedPlaceOfEmploymentOther; @ExcelProperty(value = "待业期间的求职意向", index = 54) private String unemploymedEngagedIndustry; @ExcelProperty(value = "待业期间的求职意向其他(手填)", index = 55) private String unemploymedEngagedIndustryOther; @ExcelProperty(value = "是否有创业意愿", index = 56) private Integer isBusiness; @ExcelProperty(value = "创业意愿", index = 57) private String businessDesire; @ExcelProperty(value = "备注", index = 58) private String remark; @ExcelProperty(value = "填表单位", index = 59) private String fillUnit; @ExcelProperty(value = "填表人", index = 60) private String fillPerson; @ExcelProperty(value = "填表人联系电话", index = 61) private String fillPersonPhone; /** * 去重字段,使用(姓名+身份证号+街路巷+小区号+楼牌号+单元号+户室)组合字段进行MD5加密实现去重 */ private String distinctPass; /** * 年龄 */ private Integer age; /** * 性别(1.男 2.女) */ private Integer sex; /** * 出生年月日 */ private String birthday; /** * 扩展字段用逗号隔开 */ private List<String> userTagStr = Lists.newArrayList(); private Long houseId; /** * 地址 */ private String address; } springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/model/vos/community/ComMngPopulationVeteransMistakeExcelVO.java
New file @@ -0,0 +1,209 @@ package com.panzhihua.common.model.vos.community; import com.alibaba.excel.annotation.ExcelProperty; import com.google.common.collect.Lists; import com.panzhihua.common.model.helper.encrypt.EncryptDecryptClass; import com.panzhihua.common.model.helper.encrypt.EncryptDecryptField; import lombok.Data; import java.io.Serializable; import java.util.List; /** * @description: 批量导入退役军人 * @author: txb */ @Data @EncryptDecryptClass public class ComMngPopulationVeteransMistakeExcelVO implements Serializable { @ExcelProperty(value = "序号", index = 0) private String serialNumber; @ExcelProperty(value = "人员状态:正常、失联、出国(取字典表)", index = 1) private String personStatus; @ExcelProperty(value = "机构", index = 2) private String organization; @ExcelProperty(value = "姓名", index = 3) private String name; @ExcelProperty(value = "身份证号码", index = 4) @EncryptDecryptField private String cardNo; @ExcelProperty(value = "联系电话", index = 5) private String phone; @ExcelProperty(value = "照片", index = 6) private String photo; @ExcelProperty(value = "户籍性质(1.城镇户口 2.农村户口)", index = 7) private String regiterNature; @ExcelProperty(value = "户口所在地", index = 8) private String censusRegister; @ExcelProperty(value = "外地/本地(1.本地 2.外地)", index = 9) private String outOrLocal; @ExcelProperty(value = "街/路/巷", index = 10) private String road; @ExcelProperty(value = "小区号", index = 11) private String doorNo; @ExcelProperty(value = "楼排号", index = 12) private String floor; @ExcelProperty(value = "单元号", index = 13) private String unitNo; @ExcelProperty(value = "户室(房间号)", index = 14) private String houseNo; @ExcelProperty(value = "是否租住", index = 15) private String isRent; @ExcelProperty(value = "房屋状态(1.自住 2.租住 3.其他)", index = 16) private String houseStatus; @ExcelProperty(value = "房屋用途(1.住宅 2.公寓 3.宿舍 4.仓库 5.其他)", index = 17) private String housePurpose; @ExcelProperty(value = "管控状态(1.常规 2.关注 3.管控)", index = 18) private String controlStatus; @ExcelProperty(value = "入伍时间", index = 19) private String enlistString; @ExcelProperty(value = "入伍时间", index = 20) private String retireString; @ExcelProperty(value = "人员类别", index = 21) private String personCategory; @ExcelProperty(value = "民族", index = 22) private String nation; @ExcelProperty(value = "健康状况", index = 23) private String healthy; @ExcelProperty(value = "政治面貌", index = 24) private String politicalOutlook; @ExcelProperty(value = "婚姻状况", index = 25) private String marriage; @ExcelProperty(value = "住房状况", index = 26) private String houseSituation; @ExcelProperty(value = "住房状况其他", index = 27) private String houseSituationOther; @ExcelProperty(value = "建筑面积", index = 28) private String buildArea; @ExcelProperty(value = "现就业情况", index = 29) private String employmentSituation; @ExcelProperty(value = "在职情况类型", index = 30) private String incumbencyType; @ExcelProperty(value = "现就业情况其他", index = 31) private String employmentSituationOther; @ExcelProperty(value = "养老保险", index = 32) private String endowmentInsurance; @ExcelProperty(value = "医疗保险", index = 33) private String medicalInsurance; @ExcelProperty(value = "现个人年收入(单位:元)", index = 34) private String annualIncome; @ExcelProperty(value = "父亲健康状况", index = 35) private String fatherHealthy; @ExcelProperty(value = "母亲健康状况", index = 36) private String motherHealthy; @ExcelProperty(value = "配偶健康状况", index = 37) private String spouseHealthy; @ExcelProperty(value = "儿子健康状况", index = 38) private String sonHealthy; @ExcelProperty(value = "女儿健康状况", index = 39) private String daughterHealthy; @ExcelProperty(value = "主要困难", index = 40) private String mainDifficulty; @ExcelProperty(value = "其他困难", index = 41) private String otherDifficulty; @ExcelProperty(value = "主要诉求", index = 42) private String mainDemand; @ExcelProperty(value = "主要诉求其他事项问题(手填)", index = 43) private String mainDemandOther; @ExcelProperty(value = "需参加的学历培训", index = 44) private String academicTraining; @ExcelProperty(value = "是否已参加退役军人培训(政府性质)", index = 45) private String isVeteransTraining; @ExcelProperty(value = "入伍前学历", index = 46) private String educationBeforeEnlistment; @ExcelProperty(value = "再教育学历", index = 47) private String reEducation; @ExcelProperty(value = "所学专业", index = 48) private String major; @ExcelProperty(value = "所学专业其他", index = 49) private String majorOther; @ExcelProperty(value = "曾从事行业(含现从事行业)", index = 50) private String onceEngagedIndustry; @ExcelProperty(value = "曾从事行业(含现从事行业)其他(手填)", index = 51) private String onceEngagedIndustryOther; @ExcelProperty(value = "意向就业地点", index = 52) private String intendedPlaceOfEmployment; @ExcelProperty(value = "意向就业地点其他地区(手填)", index = 53) private String intendedPlaceOfEmploymentOther; @ExcelProperty(value = "待业期间的求职意向", index = 54) private String unemploymedEngagedIndustry; @ExcelProperty(value = "待业期间的求职意向其他(手填)", index = 55) private String unemploymedEngagedIndustryOther; @ExcelProperty(value = "是否有创业意愿", index = 56) private String isBusiness; @ExcelProperty(value = "创业意愿", index = 57) private String businessDesire; @ExcelProperty(value = "备注", index = 58) private String remark; @ExcelProperty(value = "填表单位", index = 59) private String fillUnit; @ExcelProperty(value = "填表人", index = 60) private String fillPerson; @ExcelProperty(value = "填表人联系电话", index = 61) private String fillPersonPhone; @ExcelProperty(value = "错误信息", index = 62) private String mistake; } springcloud_k8s_panzhihuazhihuishequ/community_backstage/src/main/java/com/panzhihua/community_backstage/api/PopulationApi.java
@@ -230,6 +230,24 @@ return R.ok(); } @ApiOperation(value = "excel导入退役军人") @PostMapping(value = "/serve/importVeterans", consumes = "multipart/*", headers = "content-type=multipart/form-date") public R importVeterans(@RequestParam MultipartFile file, HttpServletRequest request) { //获取文件名 String fileName = file.getOriginalFilename(); log.info("传入文件名字【{}】", fileName); InputStream inputStream = null; try { inputStream = file.getInputStream(); ComMngPopulationVeteransExcelListen comMngPopulationVeteransExcelListen = new ComMngPopulationVeteransExcelListen(communityService, this.getCommunityId(),userName,password,host,port,excelUrl,stringRedisTemplate); EasyExcel.read(inputStream, null, comMngPopulationVeteransExcelListen).sheet().doRead(); } catch (IOException e) { log.error("导入模板失败【{}】", e.getMessage()); e.printStackTrace(); } return R.ok(); } /** * 确认导入实有人口(有则更新,无则新建) *