Browse Source

电视剧导入,异步统计数据

chenjz 3 years ago
parent
commit
cdc434109a
1 changed files with 11 additions and 7 deletions
  1. 11 7
      src/main/java/com/ylcm/sys/controller/AdTheatreController.java

+ 11 - 7
src/main/java/com/ylcm/sys/controller/AdTheatreController.java

@@ -62,7 +62,7 @@ public class AdTheatreController extends BaseController{
62 62
 	@Resource
63 63
 	private AdTheatreTvStatService adTheatreTvStatService;
64 64
 	@Resource
65
-	private TaskExecutor batchExecutor;
65
+	private TaskExecutor taskExecutor;
66 66
 
67 67
 	/**
68 68
 	 * to 列表页面
@@ -263,14 +263,10 @@ public class AdTheatreController extends BaseController{
263 263
 			// 入库
264 264
 			List<AdTheatre> adTheatres = adTheatreService.batchAdd(list, tvList);
265 265
 
266
-
267
-            //同步统计数据
268
-			for (AdTheatre adTheatre:adTheatres) {
269
-				adTheatreTvStatService.saveStatByTheatreTv(adTheatre);
270
-			}
271
-
272 266
 			// 判断执行结果
273 267
 			if (adTheatres != null) {
268
+				//异步统计数据
269
+				asyncBatchSaveStatByTheatreTv(adTheatres);
274 270
 				request.setAttribute("repeat", 0);
275 271
 				request.setAttribute("code", Constants.CODE_SUCCESS);
276 272
 				request.setAttribute("msg", msg);
@@ -288,4 +284,12 @@ public class AdTheatreController extends BaseController{
288 284
 		return returnHtml;
289 285
 	}
290 286
 
287
+	// 异步统计数据
288
+	private void asyncBatchSaveStatByTheatreTv(List<AdTheatre> adTheatres) {
289
+		CompletableFuture.runAsync(() -> {
290
+			for (AdTheatre adTheatre:adTheatres) {
291
+				adTheatreTvStatService.saveStatByTheatreTv(adTheatre);
292
+			}
293
+		}, taskExecutor);
294
+	}
291 295
 }