huanghongfa
2021-08-01 8e77e28389acc0b1f428004b5505717957a28ead
打印日志
1个文件已修改
15 ■■■■ 已修改文件
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngPopulationServeExcelListen.java
@@ -114,6 +114,7 @@
         */
        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;
@@ -567,8 +568,11 @@
//            }
                //根据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);
@@ -576,15 +580,21 @@
//                        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();
@@ -592,8 +602,9 @@
//                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();
@@ -601,7 +612,7 @@
//                importErrorVO.setErrorMsg("数据格式有误,请检查文档内数据");
//                populationImportErrorVOList.add(importErrorVO);
                log.error("数据格式有误,第" + index + "行");
                throw new ServiceException("500", "导入失败");
                throw new ServiceException("500", "导入失败222");
            }
        }