| | |
| | | import com.panzhihua.common.exceptions.ServiceException; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComMngCarExcelVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngPopulationServeExcelVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngRealCompanyExcelVO; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.utlis.ListUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @description: 实有单位导入监听 |
| | |
| | | // 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM |
| | | if(list.size() >= BATCH_COUNT){ |
| | | log.info("excel导入数据【{}】", JSONObject.toJSONString(list)); |
| | | R r = this.communityService.listSaveMngRealCompanyExcelVO(list,this.communityId); |
| | | // 根据list中的creditCode来去重 |
| | | List<ComMngRealCompanyExcelVO> newVoList = list.stream().filter(ListUtils.distinctByKey(ComMngRealCompanyExcelVO::getCreditCode)).collect(Collectors.toList()); |
| | | R r = this.communityService.listSaveMngRealCompanyExcelVO(newVoList,this.communityId); |
| | | if (!R.isOk(r)) { |
| | | throw new ServiceException(r.getMsg()); |
| | | } |
| | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
| | | log.info("excel导入数据【{}】", JSONObject.toJSONString(list)); |
| | | R r = this.communityService.listSaveMngRealCompanyExcelVO(list,this.communityId);//确保最后遗留的数据保存在数据库中 |
| | | // 根据list中的creditCode来去重 |
| | | List<ComMngRealCompanyExcelVO> newVoList = list.stream().filter(ListUtils.distinctByKey(ComMngRealCompanyExcelVO::getCreditCode)).collect(Collectors.toList()); |
| | | R r = this.communityService.listSaveMngRealCompanyExcelVO(newVoList,this.communityId);//确保最后遗留的数据保存在数据库中 |
| | | if (!R.isOk(r)) { |
| | | throw new ServiceException(r.getMsg()); |
| | | } |