From 177249c76aeea0b4bf8d8816d4994e3b445b45ce Mon Sep 17 00:00:00 2001 From: huanghongfa <huanghongfa123456> Date: 星期四, 02 九月 2021 10:39:34 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/zzj' into zzj --- springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComCvtServeExcelListen.java | 25 +++++++++++-------------- 1 files changed, 11 insertions(+), 14 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComCvtServeExcelListen.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComCvtServeExcelListen.java index 53ab598..2b71ee3 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComCvtServeExcelListen.java +++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComCvtServeExcelListen.java @@ -1,5 +1,8 @@ package com.panzhihua.common.listen; +import java.util.ArrayList; +import java.util.List; + import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; import com.alibaba.excel.exception.ExcelDataConvertException; @@ -8,10 +11,8 @@ import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.ComCvtServeExcelVO; import com.panzhihua.common.service.community.CommunityService; -import lombok.extern.slf4j.Slf4j; -import java.util.ArrayList; -import java.util.List; +import lombok.extern.slf4j.Slf4j; /** * @description: 便民服务导入监听 @@ -21,18 +22,14 @@ @Slf4j public class ComCvtServeExcelListen extends AnalysisEventListener<ComCvtServeExcelVO> { + private static final int BATCH_COUNT = 5000; private CommunityService communityService; - private Long communityId; - + private List<ComCvtServeExcelVO> list = new ArrayList<>(); public ComCvtServeExcelListen(CommunityService communityService, Long communityId) { this.communityService = communityService; this.communityId = communityId; } - - - private static final int BATCH_COUNT = 5000; - private List<ComCvtServeExcelVO> list = new ArrayList<>(); @Override public void invoke(ComCvtServeExcelVO comCvtServeExcelVO, AnalysisContext analysisContext) { @@ -44,7 +41,7 @@ if (!R.isOk(r)) { throw new ServiceException(r.getMsg()); } - //清空list + // 清空list list.clear(); } @@ -53,15 +50,15 @@ @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()); } } - /** * 在转换异常 + * * @param exception * @param context * @throws Exception @@ -72,8 +69,8 @@ if (exception instanceof ExcelDataConvertException) { ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException)exception; log.error("第{}行,第{}列解析异常,数据为:{}", excelDataConvertException.getRowIndex(), - excelDataConvertException.getColumnIndex(), excelDataConvertException.getCellData()); - }else{ + excelDataConvertException.getColumnIndex(), excelDataConvertException.getCellData()); + } else { throw new ServiceException(exception.getMessage()); } } -- Gitblit v1.7.1