| | |
| | | */ |
| | | private void saveData() { |
| | | R<List<BcDictionaryVO>> dictionaryR = communityService.listDictionaryByKey(BcDictionaryConstants.FAMILY); |
| | | log.info("开始导入人口数据"); |
| | | ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); |
| | | String key = Constants.POPULATION_ERROR_LIST + communityId; |
| | | |
| | |
| | | // } |
| | | //根据list中的IdCard城市来去重 |
| | | List<ComMngPopulationServeExcelVO> newVoList = voList.stream().filter(ListUtils.distinctByKey(ComMngPopulationServeExcelVO::getDistinctPass)).collect(Collectors.toList()); |
| | | log.info("开始进入业务层处理逻辑"); |
| | | R r = communityService.listSavePopulationServeExcelVO(newVoList, communityId); |
| | | log.info("业务层处理逻辑完成"); |
| | | if (!R.isOk(r)) { |
| | | log.info("业务层处理成功"); |
| | | List<ComMngPopulationMistakeExcelVO> list = JSONArray.parseArray(JSONArray.toJSONString(r.getData()), ComMngPopulationMistakeExcelVO.class); |
| | | // String errMsg = r.getMsg(); |
| | | // List<ComMngPopulationImportErrorVO> errorList = JSON.parseArray(errMsg,ComMngPopulationImportErrorVO.class); |
| | |
| | | // populationImportErrorVOList.addAll(errorList); |
| | | // } |
| | | mistakes.addAll(list); |
| | | log.info("将错误数据存入redis中"); |
| | | valueOperations.set(key,JSONArray.toJSONString(mistakes),1, TimeUnit.HOURS); |
| | | log.info("将错误数据存入redis中成功"); |
| | | throw new ServiceException("500", key); |
| | | }else{ |
| | | log.info("业务层处理逻辑失败"); |
| | | if(!mistakes.isEmpty()){ |
| | | log.info("业务层处理逻辑失败,将错误数据缓存到redis中"); |
| | | valueOperations.set(key,JSONArray.toJSONString(mistakes),1, TimeUnit.HOURS); |
| | | log.info("业务层处理逻辑失败,将错误数据缓存到redis中成功"); |
| | | throw new ServiceException("500", key); |
| | | } |
| | | } |
| | | } catch (NumberFormatException e) { |
| | | log.info("处理数据时失败"); |
| | | e.printStackTrace(); |
| | | // List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); |
| | | // ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); |
| | |
| | | // importErrorVO.setErrorMsg("数据格式有误,请检查文档内数据"); |
| | | // populationImportErrorVOList.add(importErrorVO); |
| | | log.error("数据格式有误,第" + index + "行"); |
| | | throw new ServiceException("500", "导入失败"); |
| | | throw new ServiceException("500", "导入失败111"); |
| | | } catch (ParseException e1) { |
| | | log.info("处理数据时失败2"); |
| | | e1.printStackTrace(); |
| | | // List<ComMngPopulationImportErrorVO> populationImportErrorVOList = new ArrayList<>(); |
| | | // ComMngPopulationImportErrorVO importErrorVO = new ComMngPopulationImportErrorVO(); |
| | |
| | | // importErrorVO.setErrorMsg("数据格式有误,请检查文档内数据"); |
| | | // populationImportErrorVOList.add(importErrorVO); |
| | | log.error("数据格式有误,第" + index + "行"); |
| | | throw new ServiceException("500", "导入失败"); |
| | | throw new ServiceException("500", "导入失败222"); |
| | | } |
| | | } |
| | | |