Przeglądaj źródła

Merge #8 into master from pingkang

常读剧集同步

* pingkang: (1 commits)
  常读剧集同步

Signed-off-by: 1129979389@qq.com <accounts_6361eaad7b63b44dd7833e63@mail.teambition.com>
Merged-by: 1129979389@qq.com <accounts_6361eaad7b63b44dd7833e63@mail.teambition.com>

CR-link: https://codeup.aliyun.com/60c06368dbbed34fe0f0c263/job/hr_job-bytedance/change/8
huangpingkang 1 rok temu
rodzic
commit
2e48c797c7

+ 8 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/controller/ChangDuController.java

@@ -73,4 +73,12 @@ public class ChangDuController {
         channelService.getDistributorConfig();
     }
 
+    @GetMapping("/syncMovieId")
+    public void syncMovieId(@RequestParam(required = false) String startDate,
+                            @RequestParam(required = false) String endDate) {
+        startDate = startDate == null ? DateUtils.getNowAddDate("yyyy-MM-dd", -1) : startDate;
+        endDate = endDate == null ? DateUtils.getNowDate("yyyy-MM-dd") : endDate;
+        channelService.syncMovieId(startDate, endDate);
+    }
+
 }

+ 16 - 2
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/ChannelMapper.java

@@ -11,20 +11,34 @@ import java.util.Map;
 import java.util.Set;
 
 public interface ChannelMapper {
+    List<String> getSyncMovieList(@Param("startDate") String startDate, @Param("endDate") String endDate);
+
     List<JSONObject> getChannelInfoList();
+
     void repalceChannels(@Param("adds") List<ChannelChangdunovelInfo> adds);
+
     Integer getAppType(@Param("appId") String appId);
-    List<String> getOrderIds(@Param("startDate")Integer startDate,
-                             @Param("startPayTime")String startPayTime,
+
+    List<String> getOrderIds(@Param("startDate") Integer startDate,
+                             @Param("startPayTime") String startPayTime,
                              @Param("endDate") Integer endDate,
                              @Param("endPayTime") String endPayTime);
+
     Map<String, Object> getUserInfo(@Param("distributorId") String distributorId, @Param("eventTime") String eventTime, @Param("uid") String uid);
+
     Map<String, Object> getLinkInfo(@Param("linkId") String linkId);
+
     String getMovieName(@Param("movieId") String movieId);
+
     void insertOrder(List<ChangDuOrder> changDuOrders);
+
     List<JSONObject> getChangDuRetryJob();
+
     List<JSONObject> getDistributorKey();
+
     void insertChangduDistributorApp(Set<ChangDuAppDistributor> adds);
+
     void insertChangduDistributorConfig(Set<ChangDuAppDistributor> adds);
+
     void insertChannelAccountInfo(Set<ChangDuAppDistributor> adds);
 }

+ 14 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/xml/ChannelMapper.xml

@@ -1,6 +1,20 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="cn.com.ctop.job.bytedance.data.mapper.ChannelMapper">
+    <select id="getSyncMovieList" resultType="java.lang.String">
+        select distinct i.movie_id
+        from deepthink.channel_changdunovel_info i
+        left join deepthink.changdu_movie_config c
+        on i.movie_id = c.movie_id
+        where c.movie_id is null
+        <if test="startDate != null">
+            and i.create_time >= "${startDate} 00:00:00"
+        </if>
+        <if test="endDate != null">
+            and i.create_time &lt;= "${endDate} 23:59:59"
+        </if>
+    </select>
+
     <select id="getChangDuRetryJob" resultType="com.alibaba.fastjson.JSONObject">
         SELECT t1.is_send AS 'isSend', t1.id AS 'id', t1.start_date AS 'startDate', t1.end_date AS 'endDate', t1.data_dimension AS 'dataDimension', t1.data_type AS 'dataType',
                 t2.channel_account_id as 'channelAccountId',t2.secret_key as 'secretKey',

+ 2 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IChannelService.java

@@ -14,4 +14,6 @@ public interface IChannelService {
     void getDistributorConfig();
 
     List<JSONObject> getChannelInfoList();
+
+    void syncMovieId(String startDate,String endDate);
 }

+ 25 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/impl/ChannelServiceImpl.java

@@ -347,6 +347,31 @@ public class ChannelServiceImpl implements IChannelService {
         return channelMapper.getChannelInfoList();
     }
 
+    @Override
+    public void syncMovieId(String startDate, String endDate) {
+        String url = "https://api.deepthink.artlinkworld.cn/changdu/movieConfig/taskAdd";
+        try {
+            List<String> syncMovieIds = channelMapper.getSyncMovieList(startDate, endDate);
+            log.info("录入常读剧列表size:{}", syncMovieIds.size());
+            for (String movieId : syncMovieIds) {
+                HashMap<String, Object> postParam = new HashMap<>();
+                postParam.put("movieId", movieId);
+                postParam.put("movieSource", 2);
+                String s = HttpUtils.httpPostRequest(url, postParam, null);
+                JSONObject jsonObject = JSONObject.parseObject(s);
+                if (!Check.isNull(jsonObject) && jsonObject.getInteger("code") == 0) {
+                    log.info("movieId: {} 录入成功", movieId);
+                } else {
+                    log.error("movieId: {} 录入失败,返回:{}", movieId, s);
+                }
+                Thread.sleep(500);
+            }
+        } catch (Exception e) {
+            log.error("录入常读剧列表失败", e);
+            e.printStackTrace();
+        }
+    }
+
     private static String getSign(String distributorId, String secretKey, String ts) {
         return SecureUtil.md5(distributorId + secretKey + ts).toLowerCase();
     }

+ 7 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/ChangDuJob.java

@@ -55,4 +55,11 @@ public class ChangDuJob {
         channelService.getDistributorConfig();
     }
 
+    @XxlJob("syncMovieId")
+    public void syncMovieId() {
+        String startDate = DateUtils.getNowAddDate("yyyy-MM-dd", -1);
+        String endDate = DateUtils.getNowDate("yyyy-MM-dd");
+        channelService.syncMovieId(startDate, endDate);
+    }
+
 }