|
@@ -34,6 +34,7 @@ import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author supeng
|
|
* @author supeng
|
|
@@ -291,17 +292,34 @@ public class ExecutionTaskServiceImpl implements ExecutionTaskService {
|
|
|
//获取昨日Top10视频
|
|
//获取昨日Top10视频
|
|
|
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
|
|
LocalDateTime yesterday = LocalDateTime.now().minusDays(1);
|
|
|
String dt = DateUtil.formatLocalDateTime(yesterday, "yyyyMMdd");
|
|
String dt = DateUtil.formatLocalDateTime(yesterday, "yyyyMMdd");
|
|
|
- String sql = "select * from " + yesterdayReturnVideoTable + " where dt='" + dt + "' ORDER BY 回流人数 DESC LIMIT " + TOP_N + ";";
|
|
|
|
|
|
|
+ int topN = TOP_N * 5;
|
|
|
|
|
+ String sql = "select * from " + yesterdayReturnVideoTable + " where dt='" + dt + "' ORDER BY 回流人数 DESC LIMIT " + topN + ";";
|
|
|
List<Record> records = odpsManager.query(sql);
|
|
List<Record> records = odpsManager.query(sql);
|
|
|
if (Objects.isNull(records) || records.isEmpty()) {
|
|
if (Objects.isNull(records) || records.isEmpty()) {
|
|
|
log.info("yesterdayTopReturnVideoExecutionTaskCreateHandler records is empty");
|
|
log.info("yesterdayTopReturnVideoExecutionTaskCreateHandler records is empty");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ List<Record> findRecords = new ArrayList<>();
|
|
|
|
|
+ for (Record record : records) {
|
|
|
|
|
+ if (Objects.isNull(record)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ //TODO 待优化,只针对本策略去重
|
|
|
|
|
+ String videoId = record.getString("videoid");
|
|
|
|
|
+ int count = sdExecutionTaskContentMapper.countByContentId(ContentTypeEnum.VIDEO.getValue(), videoId);
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ findRecords.add(record);
|
|
|
|
|
+ if (findRecords.size() >= topN) {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
long topCostMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
|
|
long topCostMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
|
|
|
log.info("yesterdayTopReturnVideoExecutionTaskCreateHandler get top video cost={}ms", topCostMs);
|
|
log.info("yesterdayTopReturnVideoExecutionTaskCreateHandler get top video cost={}ms", topCostMs);
|
|
|
//创建解构任务
|
|
//创建解构任务
|
|
|
int count = 0;
|
|
int count = 0;
|
|
|
- for (Record record : records) {
|
|
|
|
|
|
|
+ for (Record record : findRecords) {
|
|
|
try {
|
|
try {
|
|
|
String videoId = record.getString("videoid");
|
|
String videoId = record.getString("videoid");
|
|
|
SdExecutionTask sdExecutionTask = new SdExecutionTask();
|
|
SdExecutionTask sdExecutionTask = new SdExecutionTask();
|