From a2c792ee79e69224d71dc6204c6cc01f92b9384e Mon Sep 17 00:00:00 2001
From: manailin <261030956@qq.com>
Date: 星期一, 23 八月 2021 16:14:46 +0800
Subject: [PATCH] [新增]整理代码规范

---
 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngVillageServeExcelListen.java |   32 ++++++++++++++------------------
 1 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngVillageServeExcelListen.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngVillageServeExcelListen.java
index 3e68b17..7d155b9 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngVillageServeExcelListen.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngVillageServeExcelListen.java
@@ -1,20 +1,20 @@
 package com.panzhihua.common.listen;
 
+import java.util.ArrayList;
+import java.util.Date;
+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.LoginUserInfoVO;
 import com.panzhihua.common.model.vos.R;
-import com.panzhihua.common.model.vos.community.ComCvtServeExcelVO;
 import com.panzhihua.common.model.vos.community.ComMngVillageServeExcelVO;
 import com.panzhihua.common.service.community.CommunityService;
 import com.panzhihua.common.utlis.Snowflake;
-import lombok.extern.slf4j.Slf4j;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import lombok.extern.slf4j.Slf4j;
 
 /**
  * @description: 实有房屋导入监听
@@ -23,19 +23,14 @@
 @Slf4j
 public class ComMngVillageServeExcelListen extends AnalysisEventListener<ComMngVillageServeExcelVO> {
 
+    private static final int BATCH_COUNT = 100;
     private CommunityService communityService;
-
-    private  LoginUserInfoVO loginUserInfo ;
-
+    private LoginUserInfoVO loginUserInfo;
+    private List<ComMngVillageServeExcelVO> list = new ArrayList<>();
     public ComMngVillageServeExcelListen(CommunityService communityService, LoginUserInfoVO loginUserInfo) {
         this.communityService = communityService;
         this.loginUserInfo = loginUserInfo;
     }
-
-
-    private static final int BATCH_COUNT = 100;
-    private List<ComMngVillageServeExcelVO> list = new ArrayList<>();
-
 
     @Override
     public void invoke(ComMngVillageServeExcelVO comMngVillageServeExcelVO, AnalysisContext analysisContext) {
@@ -43,7 +38,7 @@
         // 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
         if (list.size() >= BATCH_COUNT) {
             log.info("excel导入数据【{}】", JSONObject.toJSONString(list));
-            list.forEach(villageServe->{
+            list.forEach(villageServe -> {
                 villageServe.setVillageId(Snowflake.getId());
                 villageServe.setCreateAt(new Date());
             });
@@ -51,15 +46,16 @@
             if (!R.isOk(r)) {
                 throw new ServiceException(r.getMsg());
             }
-            //清空list
+            // 清空list
             list.clear();
         }
     }
 
     @Override
-    public void doAfterAllAnalysed(AnalysisContext analysisContext) { log.info("excel导入数据【{}】", JSONObject.toJSONString(list));
-        //确保最后遗留的数据保存在数据库中
-        list.forEach(villageServe->{
+    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+        log.info("excel导入数据【{}】", JSONObject.toJSONString(list));
+        // 确保最后遗留的数据保存在数据库中
+        list.forEach(villageServe -> {
             villageServe.setVillageId(Snowflake.getId());
             villageServe.setCreateAt(new Date());
         });

--
Gitblit v1.7.1