| New file | 
 |  |  | 
 |  |  | package com.dy.pipIrrStatistics.statistics; | 
 |  |  |  | 
 |  |  | import com.dy.common.multiDataSource.DataSourceContext; | 
 |  |  | import com.dy.common.schedulerTask.TaskJob; | 
 |  |  | import com.dy.common.springUtil.SpringContextUtil; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.quartz.JobDataMap; | 
 |  |  | import org.quartz.JobExecutionContext; | 
 |  |  | import org.quartz.JobExecutionException; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * @Author: liurunyu | 
 |  |  |  * @Date: 2024/12/27 8:43 | 
 |  |  |  * @Description 测试不同线程是否得到专属的orgTag | 
 |  |  |  */ | 
 |  |  | @Slf4j | 
 |  |  | public class TestJob extends TaskJob { | 
 |  |  |  | 
 |  |  |     private String orgTag ; | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public void execute(JobExecutionContext ctx) throws JobExecutionException { | 
 |  |  |         JobDataMap jobDataMap = ctx.getJobDetail().getJobDataMap() ; | 
 |  |  |         if(jobDataMap != null){ | 
 |  |  |             orgTag = (String)jobDataMap.get(StatisticsListener.orgKey) ; | 
 |  |  |         } | 
 |  |  |         if(orgTag == null){ | 
 |  |  |             return ; | 
 |  |  |         } | 
 |  |  |         DataSourceContext.set(orgTag);//设置数据源 | 
 |  |  |         log.info("设置数据源:" + orgTag); | 
 |  |  |         TestWorker worker = SpringContextUtil.getBean(TestWorker.class); | 
 |  |  |         worker.doJob(); | 
 |  |  |     } | 
 |  |  | } |