|
@@ -0,0 +1,74 @@
|
|
|
+package com.tzld.piaoquan.offline.job;
|
|
|
+
|
|
|
+import com.aliyun.odps.data.Record;
|
|
|
+import com.tzld.piaoquan.api.dao.mapper.contentplatform.ContentPlatformVideoMapper;
|
|
|
+import com.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformPlanMapperExt;
|
|
|
+import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo;
|
|
|
+import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideoExample;
|
|
|
+import com.tzld.piaoquan.growth.common.utils.DateUtil;
|
|
|
+import com.tzld.piaoquan.growth.common.utils.OdpsUtil;
|
|
|
+import com.xxl.job.core.biz.model.ReturnT;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+public class ContentPlatformVideoJob {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ContentPlatformPlanMapperExt planMapperExt;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ContentPlatformVideoMapper videoMapper;
|
|
|
+
|
|
|
+ @XxlJob("syncContentPlatformVideoJob")
|
|
|
+ public ReturnT<String> syncContentPlatformVideoJob(String param) {
|
|
|
+ String dt = DateUtil.getBeforeDayDateString();
|
|
|
+ long videoCount = getVideoCount(dt);
|
|
|
+ if (videoCount > 0) {
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+ String sql = String.format("SELECT * FROM loghubods.wecom_cooperation_video_candidate_pool WHERE dt=%s;", dt);
|
|
|
+ List<Record> dataList = OdpsUtil.getOdpsData(sql);
|
|
|
+ Long now = System.currentTimeMillis();
|
|
|
+ if (CollectionUtils.isNotEmpty(dataList)) {
|
|
|
+ List<ContentPlatformVideo> saveList = new ArrayList<>();
|
|
|
+ for (Record record : dataList) {
|
|
|
+ ContentPlatformVideo item = new ContentPlatformVideo();
|
|
|
+ Long videoId = Long.parseLong((String) record.get(0));
|
|
|
+ String category = (String) record.get(1);
|
|
|
+ String title = (String) record.get(2);
|
|
|
+ String videoUrl = (String) record.get(3);
|
|
|
+ Double score = Double.parseDouble((String) record.get(4));
|
|
|
+ item.setDt(dt);
|
|
|
+ item.setVideoId(videoId);
|
|
|
+ item.setCategory(category);
|
|
|
+ item.setTitle(title);
|
|
|
+ item.setVideo(videoUrl);
|
|
|
+ item.setScore(score);
|
|
|
+ item.setCreateTimestamp(now);
|
|
|
+ saveList.add(item);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(saveList)) {
|
|
|
+ planMapperExt.batchInsertContentPlatformVideo(saveList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ReturnT.SUCCESS;
|
|
|
+ }
|
|
|
+
|
|
|
+ private long getVideoCount(String dt) {
|
|
|
+ ContentPlatformVideoExample example = new ContentPlatformVideoExample();
|
|
|
+ example.createCriteria().andDtEqualTo(dt);
|
|
|
+ return videoMapper.countByExample(example);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|