From 70406a52ed3bd31fb72793dea750793ca216193a Mon Sep 17 00:00:00 2001
From: 罗元桥 <2376770955@qq.com>
Date: 星期一, 23 八月 2021 19:34:10 +0800
Subject: [PATCH] Merge branch 'test' into 'master'
---
springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComSwRotaExcelListen.java | 24 +++++++++++-------------
1 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComSwRotaExcelListen.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComSwRotaExcelListen.java
index 2bb7e23..eb5527b 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComSwRotaExcelListen.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComSwRotaExcelListen.java
@@ -1,17 +1,17 @@
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.fastjson.JSONObject;
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.ComSwRotaExcelVO;
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 +21,16 @@
@Slf4j
public class ComSwRotaExcelListen extends AnalysisEventListener<ComSwRotaExcelVO> {
+ private static final int BATCH_COUNT = 100;
private CommunityService communityService;
-
private Long communityId;
+ private List<ComSwRotaExcelVO> list = new ArrayList<>();
- public ComSwRotaExcelListen(CommunityService communityService, Long communityId){
+ public ComSwRotaExcelListen(CommunityService communityService, Long communityId) {
this.communityService = communityService;
this.communityId = communityId;
}
-
- private static final int BATCH_COUNT = 100;
- private List<ComSwRotaExcelVO> list = new ArrayList<>();
@Override
public void invoke(ComSwRotaExcelVO comSwRotaExcelVO, AnalysisContext analysisContext) {
list.add(comSwRotaExcelVO);
@@ -40,13 +38,13 @@
throw new ServiceException("500", "导入数据为空!");
}
// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
- if(list.size() >= BATCH_COUNT){
+ if (list.size() >= BATCH_COUNT) {
log.info("excel导入数据【{}】", JSONObject.toJSONString(list));
- R r = this.communityService.listSaveSwRotaExcelVO(list,this.communityId);
+ R r = this.communityService.listSaveSwRotaExcelVO(list, this.communityId);
if (!R.isOk(r)) {
throw new ServiceException(r.getMsg());
}
- list.clear(); //清空list
+ list.clear(); // 清空list
}
}
@@ -57,7 +55,7 @@
if (list.size() == 0) {
throw new ServiceException("500", "导入数据为空!");
}
- R r = this.communityService.listSaveSwRotaExcelVO(list,this.communityId);//确保最后遗留的数据保存在数据库中
+ R r = this.communityService.listSaveSwRotaExcelVO(list, this.communityId);// 确保最后遗留的数据保存在数据库中
if (!R.isOk(r)) {
throw new ServiceException(r.getMsg());
}
--
Gitblit v1.7.1