From bee0055f9d33ec0e8cd307c7b087e64f96f7a750 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 26 十二月 2024 18:43:36 +0800
Subject: [PATCH] 1、一个springboot模块只能有一个listener,所以删除OrgListener.java 2、IC卡充值和消费日、月、年自动化统计,农户充值和消费日、月、年自动化统计中数据库查询一般返回list的bug修改

---
 pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StatisticsListener.java |   46 +++++++++++++++++++++++++++++++---------------
 1 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StatisticsListener.java b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StatisticsListener.java
index af3fb64..db5df2c 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StatisticsListener.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StatisticsListener.java
@@ -1,31 +1,35 @@
 package com.dy.pipIrrStatistics.statistics;
+import com.dy.common.schedulerTask.SchedulerTaskSupport;
+import com.dy.pipIrrGlobal.util.Org;
+import com.dy.pipIrrGlobal.util.OrgListenerSupport;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.lang.NonNull;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.List;
 
 /**
  * @Author: liurunyu
  * @Date: 2024/7/22 14:39
  * @Description
- */
-
-import com.dy.common.schedulerTask.SchedulerTaskSupport;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.context.event.ApplicationReadyEvent;
-import org.springframework.context.ApplicationListener;
-import org.springframework.lang.NonNull;
-import org.springframework.stereotype.Component;
-
-/**
  * 鐩戝惉鍣紝瀹炵幇鍔熻兘锛氬湪绯荤粺鍚姩鏃跺垵濮嬪寲锛屽悜鏁版嵁搴撲腑鎻掑叆鏁版嵁
  * 鏈洃鍚櫒涓嶈兘閲囩敤ServletContextListener鏂瑰紡锛屽洜涓篠ervlet涓婁笅鏂嘋ontext鍒涘缓鍚�
  * Spring瀹瑰櫒骞舵病鏈夊垱寤哄畬锛岃�屾湰绫讳腑鐢ㄤ簡Spring瀹瑰櫒涓殑Bean锛屽嵆*Dao 銆�
  * 鎵�浠ラ噰鐢ㄤ簡Spring浜嬩欢鐩戝惉鍣ㄦ潵瀹炵幇
  */
 @Component
-public class StatisticsListener implements ApplicationListener<ApplicationReadyEvent> {
+public class StatisticsListener extends OrgListenerSupport  implements ApplicationListener<ApplicationReadyEvent> {
 
     private static Logger log = LogManager.getLogger(StatisticsListener.class.getName()) ;
 
+    protected static final String orgKey = "tag" ;
     private static final String JobName = "statisticsJob" ;
     private static final String JobGroupName = "statisticsGroup" ;
     private static final Integer ThreadPoolMaxCount = 1 ;//绾跨▼姹犵嚎绋嬫渶澶т釜鏁�
@@ -40,6 +44,10 @@
     @Value("${auto-statistics.startMinute: 5}")
     protected Integer startMinute;//缁熻寮�濮嬪垎閽�
 
+
+    @Autowired
+    protected ResourceLoader resourceLoader ;
+
     /**
      * SpringBoot瀹瑰櫒宸茬粡鍑嗗濂戒簡锛屾墽琛屼笅闈㈡柟娉�
      * @param event 浜嬩欢
@@ -53,6 +61,7 @@
             e.printStackTrace();
         }finally {
             try{
+                super.init(resourceLoader);
                 this.start(event);
             }catch (Exception e){
                 log.error("娉ㄥ唽缁熻瀹氭椂浠诲姟鍑洪敊", e);
@@ -67,7 +76,14 @@
         if(startHour < 0 || startHour > 5){
             startHour = 0 ;
         }
-        SchedulerTaskSupport.setThreadPoolPro(ThreadPoolMaxCount, ThreadPoolPriority);
-        SchedulerTaskSupport.addDailyJob(JobName, JobGroupName, StatisticsJob.class, null, startHour, startMinute ) ;
+        List<Org.OrgVo> orgList = Org.OrgList ;
+        if(orgList != null && orgList.size() >0){
+            SchedulerTaskSupport.setThreadPoolPro(ThreadPoolMaxCount * orgList.size(), ThreadPoolPriority);
+            for(Org.OrgVo vo : orgList){
+                HashMap<String , Object> jobDataMap	= new HashMap<String , Object>() ;
+                jobDataMap.put(orgKey, vo.tag) ;
+                SchedulerTaskSupport.addDailyJob(JobName + vo.tag, JobGroupName, StatisticsJob.class, jobDataMap, startHour, startMinute ) ;
+            }
+        }
     }
 }

--
Gitblit v1.8.0