| | |
| | | package com.panzhihua.common.listen; |
| | | |
| | | import cn.hutool.core.date.DateException; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStream; |
| | | import java.text.ParseException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | 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.REHABILITATION_POPULATION_ERROR_LIST + communityId; |
| | | String key = Constants.REHABILITATION_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<ComMngPopulationRehabilitationExcelVO> voList = Lists.newArrayList(); |
| | | // List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); |
| | | ArrayList<ComMngPopulationRehabilitationMistakeExcelVO> mistakes = Lists.newArrayList(); |
| | |
| | | vo.setSerialNumber(oneData.get(0)); |
| | | } |
| | | //姓名和身份证都为空,为空户,无需操作,否则就解析年龄,性别,出生年月日 |
| | | if(StringUtils.isNotEmpty(oneData.get(1)) || StringUtils.isNotEmpty(oneData.get(3))){ |
| | | if(StringUtils.isEmpty(oneData.get(1))){ |
| | | ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | index++; |
| | | setRehabilitationMistake(oneData, mistake); |
| | | mistake.setMistake("名字不可为空,请填写姓名"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | } |
| | | vo.setName(oneData.get(1)); |
| | | if(StringUtils.isEmpty(oneData.get(3))){ |
| | | ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | index++; |
| | | setRehabilitationMistake(oneData, mistake); |
| | | mistake.setMistake("身份证号不可为空,请填写身份证"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | } |
| | | if(StringUtils.isEmpty(oneData.get(1))){ |
| | | ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | index++; |
| | | setRehabilitationMistake(oneData, mistake); |
| | | mistake.setMistake("名字不可为空,请填写姓名"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | } |
| | | vo.setName(oneData.get(1)); |
| | | if(StringUtils.isEmpty(oneData.get(3))){ |
| | | ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | index++; |
| | | setRehabilitationMistake(oneData, mistake); |
| | | mistake.setMistake("身份证号不可为空,请填写身份证"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | } |
| | | |
| | | //判断身份证号码位数 |
| | | if(oneData.get(3).length() != 18){ |
| | | ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | index++; |
| | | setRehabilitationMistake(oneData, mistake); |
| | | mistake.setMistake("身份证号位数有误,请检查身份证号码是否正确"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | } |
| | | vo.setCardNo(oneData.get(3).toUpperCase()); |
| | | //根据身份证号码解析年龄以及性别 |
| | | //获取用户生日 |
| | | String birthday = vo.getCardNo().substring(6, 14); |
| | | if(StringUtils.isNotEmpty(birthday)){ |
| | | String year = birthday.substring(0,4); |
| | | String month = birthday.substring(4,6); |
| | | String day = birthday.substring(6,8); |
| | | vo.setBirthday(year + "-" + month + "-" + day); |
| | | } |
| | | //判断身份证号码位数 |
| | | if(oneData.get(3).length() != 18){ |
| | | ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | index++; |
| | | setRehabilitationMistake(oneData, mistake); |
| | | mistake.setMistake("身份证号位数有误,请检查身份证号码是否正确"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | } |
| | | vo.setCardNo(oneData.get(3).toUpperCase()); |
| | | //根据身份证号码解析年龄以及性别 |
| | | //获取用户生日 |
| | | String birthday = vo.getCardNo().substring(6, 14); |
| | | if(StringUtils.isNotEmpty(birthday)){ |
| | | String year = birthday.substring(0,4); |
| | | String month = birthday.substring(4,6); |
| | | String day = birthday.substring(6,8); |
| | | vo.setBirthday(year + "-" + month + "-" + day); |
| | | } |
| | | // //设置用户年龄 |
| | | // vo.setAge(AgeUtils.getAgeFromBirthTime(birthday)); |
| | | //获取用户性别 |
| | | int sex = Integer.parseInt(vo.getCardNo().substring(16, 17)); |
| | | if(sex%2 == 1){ |
| | | vo.setSex(PopulSexEnum.nan.getCode()); |
| | | }else{ |
| | | vo.setSex(PopulSexEnum.nv.getCode()); |
| | | } |
| | | //获取用户性别 |
| | | int sex = Integer.parseInt(vo.getCardNo().substring(16, 17)); |
| | | if(sex%2 == 1){ |
| | | vo.setSex(PopulSexEnum.nan.getCode()); |
| | | }else{ |
| | | vo.setSex(PopulSexEnum.nv.getCode()); |
| | | } |
| | | |
| | | if(StringUtils.isNotEmpty(oneData.get(2))){ |
| | | vo.setNation(oneData.get(2)); |
| | | } |
| | |
| | | continue; |
| | | } |
| | | vo.setDoorNo(oneData.get(7).trim()); |
| | | if(StringUtils.isEmpty(oneData.get(8))){ |
| | | index++; |
| | | ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | setRehabilitationMistake(oneData, mistake); |
| | | mistake.setMistake("楼排号不可为空"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | // if(StringUtils.isEmpty(oneData.get(8))){ |
| | | // index++; |
| | | // ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | // setRehabilitationMistake(oneData, mistake); |
| | | // mistake.setMistake("楼排号不可为空"); |
| | | // mistakes.add(mistake); |
| | | // continue; |
| | | // } |
| | | if(StringUtils.isNotEmpty(oneData.get(8))) { |
| | | vo.setFloor(oneData.get(8).trim()); |
| | | } |
| | | vo.setFloor(oneData.get(8).trim()); |
| | | if(StringUtils.isEmpty(oneData.get(9))){ |
| | | index++; |
| | | ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | setRehabilitationMistake(oneData, mistake); |
| | | mistake.setMistake("单元号不可为空"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | // if(StringUtils.isEmpty(oneData.get(9))){ |
| | | // index++; |
| | | // ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | // setRehabilitationMistake(oneData, mistake); |
| | | // mistake.setMistake("单元号不可为空"); |
| | | // mistakes.add(mistake); |
| | | // continue; |
| | | // } |
| | | if(StringUtils.isNotEmpty(oneData.get(9))) { |
| | | vo.setUnitNo(oneData.get(9).trim()); |
| | | } |
| | | vo.setUnitNo(oneData.get(9).trim()); |
| | | if(StringUtils.isEmpty(oneData.get(10))){ |
| | | index++; |
| | | ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | setRehabilitationMistake(oneData, mistake); |
| | | mistake.setMistake("户室不可为空"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | // if(StringUtils.isEmpty(oneData.get(10))){ |
| | | // index++; |
| | | // ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | // setRehabilitationMistake(oneData, mistake); |
| | | // mistake.setMistake("户室不可为空"); |
| | | // mistakes.add(mistake); |
| | | // continue; |
| | | // } |
| | | if(StringUtils.isNotEmpty(oneData.get(10))) { |
| | | vo.setHouseNo(oneData.get(10).trim()); |
| | | } |
| | | vo.setHouseNo(oneData.get(10).trim()); |
| | | if(StringUtils.isNotEmpty(oneData.get(11))){ |
| | | Integer isOk = PopulHouseUseEnum.getCodeByName(oneData.get(11)); |
| | | if(isOk.equals(-1)){ |
| | |
| | | vo.setIsRehab(PopulHouseUseEnum.getCodeByName("否")); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(21))){ |
| | | vo.setRemark(oneData.get(21).trim()); |
| | | Integer isOk = PopulHouseUseEnum.getCodeByName(oneData.get(21)); |
| | | if(isOk.equals(-1)){ |
| | | ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | index++; |
| | | setRehabilitationMistake(oneData, mistake); |
| | | mistake.setMistake("您填写的是否累惯犯有误"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | } |
| | | vo.setIsRecidivist(isOk); |
| | | }else { |
| | | vo.setIsRecidivist(PopulHouseUseEnum.getCodeByName("否")); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(22))){ |
| | | vo.setOriginalTerm(oneData.get(22).trim()); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(23))){ |
| | | vo.setSentenceBegin(DateUtil.parse(oneData.get(23).trim())); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(24))){ |
| | | vo.setOriginalCharge(oneData.get(24).trim()); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(25))){ |
| | | vo.setSentenceEnd(DateUtil.parse(oneData.get(25).trim())); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(26))){ |
| | | vo.setSentencePlace(oneData.get(26).trim()); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(27))){ |
| | | vo.setRiskAssessment(oneData.get(27).trim()); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(28))){ |
| | | vo.setJoinDate(DateUtil.parse(oneData.get(28).trim())); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(29))){ |
| | | vo.setJoinSituation(oneData.get(29).trim()); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(30))){ |
| | | Integer isOk = PopulHouseUseEnum.getCodeByName(oneData.get(30)); |
| | | if(isOk.equals(-1)){ |
| | | ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | index++; |
| | | setRehabilitationMistake(oneData, mistake); |
| | | mistake.setMistake("您填写的是否重新犯罪有误"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | } |
| | | vo.setIsAgainCrime(isOk); |
| | | }else { |
| | | vo.setIsAgainCrime(PopulHouseUseEnum.getCodeByName("否")); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(31))){ |
| | | vo.setAgainCrimeName(oneData.get(31).trim()); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(32))){ |
| | | vo.setPlaceSituation(oneData.get(32).trim()); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(33))){ |
| | | vo.setPlaceDate(DateUtil.parse(oneData.get(33).trim())); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(34))){ |
| | | vo.setNotPlaceReason(oneData.get(34).trim()); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(35))){ |
| | | try { |
| | | vo.setHelpBegin(DateUtil.parse(oneData.get(35).trim())); |
| | | } catch (DateException e) { |
| | | log.info("处理数据时失败"); |
| | | e.printStackTrace(); |
| | | ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | index++; |
| | | setRehabilitationMistake(oneData, mistake); |
| | | mistake.setMistake("您填写的帮教开始日期有误"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | } |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(36))){ |
| | | try { |
| | | vo.setHelpEnd(DateUtil.parse(oneData.get(36).trim())); |
| | | } catch (DateException e) { |
| | | log.info("处理数据时失败"); |
| | | e.printStackTrace(); |
| | | ComMngPopulationRehabilitationMistakeExcelVO mistake = new ComMngPopulationRehabilitationMistakeExcelVO(); |
| | | index++; |
| | | setRehabilitationMistake(oneData, mistake); |
| | | mistake.setMistake("您填写的帮教结束日期有误"); |
| | | mistakes.add(mistake); |
| | | continue; |
| | | } |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(37))){ |
| | | vo.setHelpSituation(oneData.get(37).trim()); |
| | | } |
| | | if(StringUtils.isNotEmpty(oneData.get(38))){ |
| | | vo.setRemark(oneData.get(38).trim()); |
| | | } |
| | | vo.getUserTagStr().add("刑满释放"); |
| | | for (int i = 22; i < headSize; i++) { |
| | | for (int i = 39; 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.setPatientRelation(map.get(18)); |
| | | vo.setRehabReasonAndType(map.get(19)); |
| | | vo.setIsRehab(map.get(20)); |
| | | vo.setRemark(map.get(21)); |
| | | vo.setIsRecidivist(map.get(21)); |
| | | vo.setOriginalTerm(map.get(22)); |
| | | vo.setSentenceBegin(map.get(23)); |
| | | vo.setOriginalCharge(map.get(24)); |
| | | vo.setSentenceEnd(map.get(25)); |
| | | vo.setSentencePlace(map.get(26)); |
| | | vo.setRiskAssessment(map.get(27)); |
| | | vo.setJoinDate(map.get(28)); |
| | | vo.setJoinSituation(map.get(29)); |
| | | vo.setIsAgainCrime(map.get(30)); |
| | | vo.setAgainCrimeName(map.get(31)); |
| | | vo.setPlaceSituation(map.get(32)); |
| | | vo.setPlaceDate(map.get(33)); |
| | | vo.setNotPlaceReason(map.get(34)); |
| | | vo.setHelpBegin(map.get(35)); |
| | | vo.setHelpEnd(map.get(36)); |
| | | vo.setHelpSituation(map.get(37)); |
| | | vo.setRemark(map.get(38)); |
| | | } |
| | | |
| | | private R mistakeExportPopulation(List<ComMngPopulationMistakeExcelVO> vo) { |