Browse Source

给所有的定时器,添加线程池配置

hyx 2 years ago
parent
commit
1d206e9ebc

+ 2 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/GetData/GetAllData.java

@@ -13,6 +13,7 @@ import com.example.nngkxxdp.util.Blank;
 import com.example.nngkxxdp.util.ConstStr;
 import com.example.nngkxxdp.util.SendUtil;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -127,6 +128,7 @@ public class GetAllData {
     @RequestMapping("/article2")
     //自动获取前14天0 42 16 * * ?
 //    @Scheduled(cron = "0 0 1 * * ?")//定时每天凌晨1点钟执行
+//    @Async("threadPoolTaskExecutor")//多个定时器需要用到的线程池
     public String article2() throws Exception {
 //        getarticletotal   抓取所有的公众号的前面的数据,放在数据库中, 用字符按连接起来
         String appid = GetIdAndSecret.getId();

+ 1 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/task/HlwTask.java

@@ -88,6 +88,7 @@ public class HlwTask {
     }
 
     //    @Scheduled(cron = "0 10 0 * * ?")
+//    @Async("threadPoolTaskExecutor")//多个定时器需要用到的线程池
 //    @GetMapping("/getTodayData")
     public void saveAndUpdateColumnRelationData() throws Exception {
         JSONArray articleList = HlwHttpUtil.getArticleList("-1");

+ 2 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/util/DeptTaskUtil.java

@@ -8,6 +8,7 @@ import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 
@@ -34,6 +35,7 @@ public class DeptTaskUtil {
 	private TjDao tjDao;
 
 //	@Scheduled(cron = "0 30 0 1 * ?")
+//@Async("threadPoolTaskExecutor")//多个定时器需要用到的线程池
 	private void task() {
 		String[] columns = new String[] {"重大建设项目","公共资源交易","义务教育","户籍管理","社会救助","养老服务","公共法律服务","财政预决算",
 				"促进就业","社会保险","国土空间规划","征地补偿","生态环保","国有土地上房屋征收","保障性住房","农村危房改造","城市综合执法","市政服务",

+ 2 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/util/NewDeptTaskUtil.java

@@ -8,6 +8,7 @@ import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 
@@ -55,6 +56,7 @@ public class NewDeptTaskUtil {
 	public static int[] partitionThreeMonth = new int[] {37};
 	
 //	@Scheduled(cron = "0 30 0 1 * ?")
+//@Async("threadPoolTaskExecutor")//多个定时器需要用到的线程池
 	private void task() {
 		// 初始化部门分值
 		List<Map<String, Object>> deptList = initDeptScore();

+ 2 - 0
nngkxxdp/src/main/java/com/example/nngkxxdp/util/WebsiteSmsUtil.java

@@ -11,6 +11,7 @@ import com.example.nngkxxdp.service.WebsiteSmsService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 
@@ -52,6 +53,7 @@ public class WebsiteSmsUtil {
 	* @throws
 	 */
 //	@Scheduled(cron = "0 0 08 10 * ?")
+//	@Async("threadPoolTaskExecutor")//多个定时器需要用到的线程池
 	public void task() {
 		StaticLog.info("==============================================================");
 		StaticLog.info("开始执行每月网站考评短信发送任务");