From 62c8ce18992be21e88d29a4357a14555150c0b48 Mon Sep 17 00:00:00 2001
From: huanghongfa <huanghongfa123456>
Date: 星期三, 16 六月 2021 19:08:34 +0800
Subject: [PATCH] 合并一标三实代码

---
 springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComMngVillageServeExcelListen.java |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 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 eed46f2..3e68b17 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
@@ -4,13 +4,16 @@
 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;
 
 /**
@@ -22,11 +25,11 @@
 
     private CommunityService communityService;
 
-    private Long communityId;
+    private  LoginUserInfoVO loginUserInfo ;
 
-    public ComMngVillageServeExcelListen(CommunityService communityService, Long communityId) {
+    public ComMngVillageServeExcelListen(CommunityService communityService, LoginUserInfoVO loginUserInfo) {
         this.communityService = communityService;
-        this.communityId = communityId;
+        this.loginUserInfo = loginUserInfo;
     }
 
 
@@ -40,7 +43,11 @@
         // 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
         if (list.size() >= BATCH_COUNT) {
             log.info("excel导入数据【{}】", JSONObject.toJSONString(list));
-            R r = communityService.listSaveVillageServeExcelVO(list, this.communityId);
+            list.forEach(villageServe->{
+                villageServe.setVillageId(Snowflake.getId());
+                villageServe.setCreateAt(new Date());
+            });
+            R r = communityService.listSaveVillageServeExcelVO(list, loginUserInfo.getCommunityId());
             if (!R.isOk(r)) {
                 throw new ServiceException(r.getMsg());
             }
@@ -52,7 +59,11 @@
     @Override
     public void doAfterAllAnalysed(AnalysisContext analysisContext) { log.info("excel导入数据【{}】", JSONObject.toJSONString(list));
         //确保最后遗留的数据保存在数据库中
-        R r = this.communityService.listSaveVillageServeExcelVO(list, this.communityId);
+        list.forEach(villageServe->{
+            villageServe.setVillageId(Snowflake.getId());
+            villageServe.setCreateAt(new Date());
+        });
+        R r = this.communityService.listSaveVillageServeExcelVO(list, loginUserInfo.getCommunityId());
         if (!R.isOk(r)) {
             throw new ServiceException(r.getMsg());
         }

--
Gitblit v1.7.1