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/ComEldersAuthElderlyExcelListen.java |   46 +++++++++++++++++++++-------------------------
 1 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComEldersAuthElderlyExcelListen.java b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComEldersAuthElderlyExcelListen.java
index 6e82587..1d191e5 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComEldersAuthElderlyExcelListen.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/common/src/main/java/com/panzhihua/common/listen/ComEldersAuthElderlyExcelListen.java
@@ -1,10 +1,10 @@
 package com.panzhihua.common.listen;
 
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.util.IdcardUtil;
+import java.util.*;
+import java.util.stream.Collectors;
+
 import com.alibaba.excel.context.AnalysisContext;
 import com.alibaba.excel.event.AnalysisEventListener;
-import com.alibaba.fastjson.JSONObject;
 import com.panzhihua.common.enums.EldersAuthLevelEnum;
 import com.panzhihua.common.exceptions.ServiceException;
 import com.panzhihua.common.model.vos.R;
@@ -13,10 +13,9 @@
 import com.panzhihua.common.utlis.DateUtils;
 import com.panzhihua.common.utlis.ListUtils;
 import com.panzhihua.common.utlis.StringUtils;
-import lombok.extern.slf4j.Slf4j;
 
-import java.util.*;
-import java.util.stream.Collectors;
+import cn.hutool.core.util.IdcardUtil;
+import lombok.extern.slf4j.Slf4j;
 
 /**
  * @description: 高龄老人导入监听
@@ -26,21 +25,17 @@
 @Slf4j
 public class ComEldersAuthElderlyExcelListen extends AnalysisEventListener<EldersAuthElderlyExcelVO> {
 
+    private static final int BATCH_COUNT = 3000;
     private CommunityService communityService;
-
     private Long communityId;
-
     private Long createBy;
+    private List<EldersAuthElderlyExcelVO> list = new ArrayList<>();
 
-    public ComEldersAuthElderlyExcelListen(CommunityService communityService, Long communityId, Long createBy){
+    public ComEldersAuthElderlyExcelListen(CommunityService communityService, Long communityId, Long createBy) {
         this.communityService = communityService;
         this.communityId = communityId;
         this.createBy = createBy;
     }
-
-
-    private static final int BATCH_COUNT = 3000;
-    private List<EldersAuthElderlyExcelVO> list = new ArrayList<>();
 
     /**
      * @author cedoo
@@ -56,7 +51,7 @@
         List<T> repeatEles = new ArrayList<T>();
         for (T t : datas) {
             if (set.contains(t)) {
-                if(!repeatEles.contains(t)) {
+                if (!repeatEles.contains(t)) {
                     repeatEles.add(t);
                 }
             } else {
@@ -68,21 +63,21 @@
 
     @Override
     public void invoke(EldersAuthElderlyExcelVO eldersAuthElderlyExcelVO, AnalysisContext analysisContext) {
-        if(StringUtils.isEmpty(eldersAuthElderlyExcelVO.getName())){
+        if (StringUtils.isEmpty(eldersAuthElderlyExcelVO.getName())) {
             throw new ServiceException("姓名不可为空");
         }
-        if(StringUtils.isEmpty(eldersAuthElderlyExcelVO.getIsExist())){
+        if (StringUtils.isEmpty(eldersAuthElderlyExcelVO.getIsExist())) {
             eldersAuthElderlyExcelVO.setIsExist("是");
         }
-        if(StringUtils.isEmpty(eldersAuthElderlyExcelVO.getIsBigAge())){
+        if (StringUtils.isEmpty(eldersAuthElderlyExcelVO.getIsBigAge())) {
             eldersAuthElderlyExcelVO.setIsBigAge("是");
         }
-        if(StringUtils.isEmpty(eldersAuthElderlyExcelVO.getIdCard())){
+        if (StringUtils.isEmpty(eldersAuthElderlyExcelVO.getIdCard())) {
             throw new ServiceException("身份证号错误");
         }
 
         String idCard = eldersAuthElderlyExcelVO.getIdCard();
-        if(idCard!=null && idCard.contains("x")){
+        if (idCard != null && idCard.contains("x")) {
             idCard = idCard.replaceAll("x", "X");
         }
         eldersAuthElderlyExcelVO.setIdCard(idCard);
@@ -92,7 +87,7 @@
 
         list.add(eldersAuthElderlyExcelVO);
         // 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
-        if(list.size() >= BATCH_COUNT){
+        if (list.size() >= BATCH_COUNT) {
             doAfterAllAnalysed(analysisContext);
             list.clear();
         }
@@ -101,18 +96,19 @@
 
     @Override
     public void doAfterAllAnalysed(AnalysisContext analysisContext) {
-        //去重
-        List<String>  idcardList = new ArrayList<>();
+        // 去重
+        List<String> idcardList = new ArrayList<>();
         list.forEach(voInList -> {
             idcardList.add(voInList.getIdCard());
         });
         List<String> repeatList = findRepeat(idcardList);
-        if(repeatList!=null && repeatList.size()>0){
+        if (repeatList != null && repeatList.size() > 0) {
             String repeatedId = StringUtils.join(repeatList, ",");
             throw new ServiceException(repeatedId + " 身份证号码存在多条");
         }
-        List<EldersAuthElderlyExcelVO> newVoList = list.stream().filter(ListUtils.distinctByKey(EldersAuthElderlyExcelVO::getIdCard)).collect(Collectors.toList());
-        R r = this.communityService.listSaveEldersAuthElderlyExcelVO(newVoList,this.communityId,this.createBy);
+        List<EldersAuthElderlyExcelVO> newVoList = list.stream()
+            .filter(ListUtils.distinctByKey(EldersAuthElderlyExcelVO::getIdCard)).collect(Collectors.toList());
+        R r = this.communityService.listSaveEldersAuthElderlyExcelVO(newVoList, this.communityId, this.createBy);
         if (!R.isOk(r)) {
             throw new ServiceException(r.getMsg());
         }

--
Gitblit v1.7.1