| | |
| | | |
| | | private Long communityId; |
| | | |
| | | public ComCvtServeExcelListen(CommunityService communityService,Long communityId){ |
| | | public ComCvtServeExcelListen(CommunityService communityService, Long communityId) { |
| | | this.communityService = communityService; |
| | | this.communityId = communityId; |
| | | } |
| | |
| | | |
| | | private static final int BATCH_COUNT = 100; |
| | | private List<ComCvtServeExcelVO> list = new ArrayList<>(); |
| | | |
| | | @Override |
| | | public void invoke(ComCvtServeExcelVO comCvtServeExcelVO, AnalysisContext analysisContext) { |
| | | list.add(comCvtServeExcelVO); |
| | | // 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM |
| | | if(list.size() >= BATCH_COUNT){ |
| | | if (list.size() >= BATCH_COUNT) { |
| | | log.info("excel导入数据【{}】", JSONObject.toJSONString(list)); |
| | | R r = this.communityService.listSaveConvenientServeExcelVO(list,this.communityId); |
| | | R r = this.communityService.listSaveConvenientServeExcelVO(list, this.communityId); |
| | | if (!R.isOk(r)) { |
| | | throw new ServiceException(r.getMsg()); |
| | | } |
| | | list.clear(); //清空list |
| | | //清空list |
| | | list.clear(); |
| | | } |
| | | |
| | | } |
| | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
| | | log.info("excel导入数据【{}】", JSONObject.toJSONString(list)); |
| | | R r = this.communityService.listSaveConvenientServeExcelVO(list,this.communityId);//确保最后遗留的数据保存在数据库中 |
| | | R r = this.communityService.listSaveConvenientServeExcelVO(list, this.communityId);//确保最后遗留的数据保存在数据库中 |
| | | if (!R.isOk(r)) { |
| | | throw new ServiceException(r.getMsg()); |
| | | } |