| | |
| | | package com.panzhihua.common.listen; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.alibaba.fastjson.JSONArray; |
| | |
| | | log.info("开始导入邪教人员数据"); |
| | | log.info("表格总数据:" + list.size()); |
| | | if (list.size() == 0) { |
| | | throw new ServiceException("500", "导入数据为空!"); |
| | | throw new ServiceException("000", "导入数据为空!"); |
| | | } |
| | | ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); |
| | | String key = Constants.CULT_POPULATION_ERROR_LIST + communityId; |
| | | String key = Constants.CULT_POPULATION_ERROR_LIST; |
| | | |
| | | Map<String,String> dictMap = dictionaryR.getData().stream().collect(Collectors.toMap(BcDictionaryVO::getDictName,BcDictionaryVO::getDictValue)); |
| | | // Map<String,Integer> dictMap = new HashMap<>(); |
| | |
| | | |
| | | int index = 2; |
| | | try { |
| | | String[] parsePatterns = new String[]{"yyyy-MM-dd", "yyyy-M-dd", "yyyy-MM-d", "yyyy-M-d", "yyyy/MM/dd", "yyyy/M/dd", "yyyy/MM/d", "yyyy/M/d"}; |
| | | ArrayList<ComMngPopulationCultExcelVO> voList = Lists.newArrayList(); |
| | | // List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); |
| | | ArrayList<ComMngPopulationCultMistakeExcelVO> mistakes = Lists.newArrayList(); |
| | |
| | | vo.setSerialNumber(oneData.get(0)); |
| | | } |
| | | //姓名和身份证都为空,为空户,无需操作,否则就解析年龄,性别,出生年月日 |
| | | if(StringUtils.isNotEmpty(oneData.get(1)) || StringUtils.isNotEmpty(oneData.get(2))){ |
| | | if(StringUtils.isEmpty(oneData.get(1))){ |
| | | ComMngPopulationCultMistakeExcelVO mistake = new ComMngPopulationCultMistakeExcelVO(); |
| | | index++; |
| | |
| | | }else{ |
| | | vo.setSex(PopulSexEnum.nv.getCode()); |
| | | } |
| | | } |
| | | |
| | | if(StringUtils.isNotEmpty(oneData.get(3))){ |
| | | vo.setNation(oneData.get(3)); |
| | | } |
| | |
| | | continue; |
| | | } |
| | | vo.setDoorNo(oneData.get(9).trim()); |
| | | if(StringUtils.isEmpty(oneData.get(10))){ |
| | | index++; |
| | | ComMngPopulationCultMistakeExcelVO mistake = new ComMngPopulationCultMistakeExcelVO(); |
| | | setMistake(oneData, mistake); |
| | | mistake.setMistake("楼排号不可为空"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | // if(StringUtils.isEmpty(oneData.get(10))){ |
| | | // index++; |
| | | // ComMngPopulationCultMistakeExcelVO mistake = new ComMngPopulationCultMistakeExcelVO(); |
| | | // setMistake(oneData, mistake); |
| | | // mistake.setMistake("楼排号不可为空"); |
| | | // mistakes.add(mistake); |
| | | // continue; |
| | | // } |
| | | if(StringUtils.isNotEmpty(oneData.get(10))) { |
| | | vo.setFloor(oneData.get(10).trim()); |
| | | } |
| | | vo.setFloor(oneData.get(10).trim()); |
| | | if(StringUtils.isEmpty(oneData.get(11))){ |
| | | index++; |
| | | ComMngPopulationCultMistakeExcelVO mistake = new ComMngPopulationCultMistakeExcelVO(); |
| | | setMistake(oneData, mistake); |
| | | mistake.setMistake("单元号不可为空"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | // if(StringUtils.isEmpty(oneData.get(11))){ |
| | | // index++; |
| | | // ComMngPopulationCultMistakeExcelVO mistake = new ComMngPopulationCultMistakeExcelVO(); |
| | | // setMistake(oneData, mistake); |
| | | // mistake.setMistake("单元号不可为空"); |
| | | // mistakes.add(mistake); |
| | | // continue; |
| | | // } |
| | | if(StringUtils.isNotEmpty(oneData.get(11))) { |
| | | vo.setUnitNo(oneData.get(11).trim()); |
| | | } |
| | | vo.setUnitNo(oneData.get(11).trim()); |
| | | if(StringUtils.isEmpty(oneData.get(12))){ |
| | | index++; |
| | | ComMngPopulationCultMistakeExcelVO mistake = new ComMngPopulationCultMistakeExcelVO(); |
| | | setMistake(oneData, mistake); |
| | | mistake.setMistake("户室不可为空"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | // if(StringUtils.isEmpty(oneData.get(12))){ |
| | | // index++; |
| | | // ComMngPopulationCultMistakeExcelVO mistake = new ComMngPopulationCultMistakeExcelVO(); |
| | | // setMistake(oneData, mistake); |
| | | // mistake.setMistake("户室不可为空"); |
| | | // mistakes.add(mistake); |
| | | // continue; |
| | | // } |
| | | if(StringUtils.isNotEmpty(oneData.get(12))) { |
| | | vo.setHouseNo(oneData.get(12).trim()); |
| | | } |
| | | vo.setHouseNo(oneData.get(12).trim()); |
| | | if(StringUtils.isNotEmpty(oneData.get(13))){ |
| | | Integer isOk = PopulHouseUseEnum.getCodeByName(oneData.get(13)); |
| | | if(isOk.equals(-1)){ |
| | |
| | | vo.setBasicSituation(oneData.get(20).trim()); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(21))){ |
| | | vo.setRemark(oneData.get(21).trim()); |
| | | vo.setJoinCultDate(DateUtil.parse(oneData.get(21).trim(), parsePatterns)); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(22))){ |
| | | Integer isOk = PopulHouseUseEnum.getCodeByName(oneData.get(22)); |
| | | if(isOk.equals(-1)){ |
| | | ComMngPopulationCultMistakeExcelVO mistake = new ComMngPopulationCultMistakeExcelVO(); |
| | | index++; |
| | | setMistake(oneData, mistake); |
| | | mistake.setMistake("您填写的是否对外宣传有误"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | } |
| | | vo.setIsExternalPublicity(isOk); |
| | | }else { |
| | | vo.setIsExternalPublicity(PopulHouseUseEnum.getCodeByName("否")); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(23))){ |
| | | vo.setRemark(oneData.get(23).trim()); |
| | | } |
| | | vo.getUserTagStr().add("邪教人员"); |
| | | for (int i = 22; i < headSize; i++) { |
| | | for (int i = 24; i < headSize; i++) { |
| | | if (oneData.get(i) != null && oneData.get(i).equals("是")) { |
| | | vo.getUserTagStr().add(headData.get(i).substring(0,headData.get(i).indexOf("("))); |
| | | } |
| | |
| | | vo.setCensusRegister(map.get(18)); |
| | | vo.setCultName(map.get(19)); |
| | | vo.setBasicSituation(map.get(20)); |
| | | vo.setRemark(map.get(21)); |
| | | vo.setJoinCultDate(map.get(21)); |
| | | vo.setIsExternalPublicity(map.get(22)); |
| | | vo.setRemark(map.get(23)); |
| | | } |
| | | |
| | | private String convertMarriage(String ma) { |