From a0a9fc7a58a39626a395d2760194641726e1cd35 Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期五, 25 四月 2025 10:48:15 +0800 Subject: [PATCH] 1、微信小程序后端轮灌迟延时长改为可配置的; 2、微信小程序查询取水口接口实现修改,改为后端模糊查询; --- pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StatisticsListener.java | 88 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 88 insertions(+), 0 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 new file mode 100644 index 0000000..b313e63 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-statistics/src/main/java/com/dy/pipIrrStatistics/statistics/StatisticsListener.java @@ -0,0 +1,88 @@ +package com.dy.pipIrrStatistics.statistics; +import com.dy.common.schedulerTask.SchedulerTaskSupport; +import com.dy.pipIrrGlobal.util.Org; +import com.dy.pipIrrGlobal.util.OrgListenerSupport; +import lombok.extern.slf4j.Slf4j; +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 + * 鐩戝惉鍣紝瀹炵幇鍔熻兘锛氬惎鍔ㄦ棩缁熻瀹氭椂浠诲姟 + * 鏈洃鍚櫒涓嶈兘閲囩敤ServletContextListener鏂瑰紡锛屽洜涓篠ervlet涓婁笅鏂嘋ontext鍒涘缓鍚� + * Spring瀹瑰櫒骞舵病鏈夊垱寤哄畬锛岃�屾湰绫讳腑鐢ㄤ簡Spring瀹瑰櫒涓殑Bean锛屽嵆*Dao 銆� + * 鎵�浠ラ噰鐢ㄤ簡Spring浜嬩欢鐩戝惉鍣ㄦ潵瀹炵幇 + */ +@Slf4j +@Component +public class StatisticsListener extends OrgListenerSupport implements ApplicationListener<ApplicationReadyEvent> { + + protected static final String orgKey = "tag" ; + private static final String JobName = "statisticsJob" ; + private static final String JobGroupName = "statisticsGroup" ; + private static final Integer ThreadPoolMaxCount = 1 ;//绾跨▼姹犵嚎绋嬫渶澶т釜鏁� + private static final Integer ThreadPoolPriority = 5 ;//绾跨▼浼樺厛绾� + + /** + * 缁熻寮�濮嬪皬鏃讹紝蹇呴』0鐐规垨涔嬪悗锛岃StatisticsJob涓粺璁★紝鏃ョ粺璁℃槸缁熻鏄ㄥぉ鐨� + */ + @Value("${auto-statistics.startHour: 0}") + protected Integer startHour;//缁熻寮�濮嬪皬鏃� + + @Value("${auto-statistics.startMinute: 5}") + protected Integer startMinute;//缁熻寮�濮嬪垎閽� + + + @Autowired + protected ResourceLoader resourceLoader ; + + /** + * SpringBoot瀹瑰櫒宸茬粡鍑嗗濂戒簡锛屾墽琛屼笅闈㈡柟娉� + * @param event 浜嬩欢 + */ + @Override + public void onApplicationEvent(@NonNull ApplicationReadyEvent event) { + try { + //绛�1绉掞紝绛夊緟com.alibaba.druid.pool.DruidDataSource瀹炲鍖栧畬鎴� + Thread.sleep(1000L); + } catch (InterruptedException e) { + e.printStackTrace(); + }finally { + try{ + super.init(resourceLoader); + this.start(event); + }catch (Exception e){ + log.error("娉ㄥ唽缁熻瀹氭椂浠诲姟鍑洪敊", e); + } + + } + } + /** + * 鍒濆鍖� + */ + private void start(ApplicationReadyEvent event) throws Exception{ + if(startHour < 0 || startHour > 5){ + startHour = 0 ; + } + 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 ) ; + //SchedulerTaskSupport.addSecondlyJob(JobName + vo.tag, JobGroupName, TestJob.class, jobDataMap, 10, 10000, 0 ) ; + } + } + } +} -- Gitblit v1.8.0