|
@@ -35,7 +35,9 @@ import javax.servlet.http.HttpServletResponse;
|
35
|
35
|
import java.util.ArrayList;
|
36
|
36
|
import java.util.Comparator;
|
37
|
37
|
import java.util.List;
|
|
38
|
+import java.util.Map;
|
38
|
39
|
import java.util.concurrent.CompletableFuture;
|
|
40
|
+import java.util.stream.Collectors;
|
39
|
41
|
|
40
|
42
|
/**
|
41
|
43
|
* 剧场管理
|
|
@@ -262,11 +264,18 @@ public class AdTheatreController extends BaseController{
|
262
|
264
|
}
|
263
|
265
|
// 入库
|
264
|
266
|
List<AdTheatre> adTheatres = adTheatreService.batchAdd(list, tvList);
|
265
|
|
-
|
|
267
|
+ //电视剧分组
|
|
268
|
+ Map<String,List<AdTheatre>> map = list.stream().collect(Collectors.groupingBy(b -> b.getName()));
|
|
269
|
+ for (Map.Entry<String, List<AdTheatre>> entry : map.entrySet()) {
|
|
270
|
+ if(CollectionUtils.isNotEmpty(entry.getValue())){
|
|
271
|
+ CompletableFuture[] completableFutures = entry.getValue().stream().map(x -> CompletableFuture.runAsync(() -> {
|
|
272
|
+ adTheatreTvStatService.saveStatByTheatreTv(x);
|
|
273
|
+ }, taskExecutor)).toArray(CompletableFuture[]::new);
|
|
274
|
+ CompletableFuture.allOf(completableFutures).join();
|
|
275
|
+ }
|
|
276
|
+ }
|
266
|
277
|
// 判断执行结果
|
267
|
278
|
if (adTheatres != null) {
|
268
|
|
- //异步统计数据
|
269
|
|
- asyncBatchSaveStatByTheatreTv(adTheatres);
|
270
|
279
|
request.setAttribute("repeat", 0);
|
271
|
280
|
request.setAttribute("code", Constants.CODE_SUCCESS);
|
272
|
281
|
request.setAttribute("msg", msg);
|
|
@@ -283,13 +292,4 @@ public class AdTheatreController extends BaseController{
|
283
|
292
|
request.setAttribute("msg", msg);
|
284
|
293
|
return returnHtml;
|
285
|
294
|
}
|
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
|
|
- }
|
295
|
295
|
}
|