zhaotx 1 год назад
Родитель
Сommit
ed4242d985

+ 5 - 1
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/controller/FeishuController.java

@@ -38,6 +38,8 @@ public class FeishuController {
     OssUtil ossUtil;
     @Autowired
     CsjResoureJob csjResoureJob;
+    @Autowired
+    IDianzhongConfigService dianzhongConfigService;
 
     @Autowired
     IUserLoginRecordService userLoginRecordService;
@@ -53,7 +55,9 @@ public class FeishuController {
 //        cutGroupRankPushService.send();
 //        reportsByBusinessPushService.test();
 
-        csjResoureJob.csjResourceOssJob();
+//        csjResoureJob.csjResourceOssJob();
+//    dianzhongConfigService.pullMovieInfo("2025-08-08", 78012L);
+        dianzhongConfigService.pullChannelInfo();
     }
 
 

+ 20 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/DianzhongDistributorConfig.java

@@ -0,0 +1,20 @@
+package cn.com.ctop.job.bytedance.data.entity;
+
+import lombok.Data;
+
+@Data
+public class DianzhongDistributorConfig {
+    private String distributorId;//渠道账号ID
+    private String distributorName;//渠道账号名称
+    private String nickName;//渠道昵称
+    private String dianzhongAccountId;
+    private String channelCreateTime;//渠道端创建时间
+    private String jumpType;//1:单端 2:双端
+    private String ofAppid;//公众号(小程序)appid
+    private String ofName;//公众号名称
+    private String remark;//备注
+    private String createBy;//创建者
+    private String createTime;//创建时间
+    private String updateBy;//更新者
+    private String updateTime;//修改时间
+}

+ 24 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/entity/DianzhongMovieConfig.java

@@ -0,0 +1,24 @@
+package cn.com.ctop.job.bytedance.data.entity;
+
+import lombok.Data;
+
+@Data
+public class DianzhongMovieConfig {
+
+    private String movieId; //剧目ID
+    private String movieName; //剧目名称
+    private String introduction; //简介
+    private Integer wordCount; //字数
+    private String coverImgUrl; //封面图链接
+    private String type1; //男频/女频
+    private String type2; //二级分类
+    private String type3; //三级分类
+    private String firstShelfTime; //上架时间
+    private String showTitle; //显示标题
+    private String remark; //备注
+    private String createBy; //创建者
+    private String createTime; //创建时间
+    private String updateBy; //更新者
+    private String updateTime; //修改时间
+
+}

+ 13 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/mapper/DianzhongConfigMapper.java

@@ -0,0 +1,13 @@
+package cn.com.ctop.job.bytedance.data.mapper;
+
+import cn.com.ctop.job.bytedance.data.entity.DianzhongDistributorConfig;
+import cn.com.ctop.job.bytedance.data.entity.DianzhongMovieConfig;
+
+public interface DianzhongConfigMapper {
+
+    int insertConfigSelective(DianzhongMovieConfig config);
+
+    int insertDistributorConfigSelective(DianzhongDistributorConfig config);
+
+
+}

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

@@ -0,0 +1,89 @@
+<?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.DianzhongConfigMapper">
+    <!--create table dianzhong_movie_config(
+    movie_id varchar(64) not null comment '剧目ID'
+    primary key,
+    movie_name varchar(64) not null comment '剧目名称',
+    introduction text null comment '简介',
+    word_count int null comment '字数',
+    cover_img_url varchar(256) null comment '封面图链接',
+    type_1 varchar(64) null comment '男频/女频',
+    type_2 varchar(64) null comment '二级分类',
+    type_3 varchar(64) null comment '三级分类',
+    first_shelf_time datetime null comment '上架时间',
+    show_title varchar(64) null comment '显示标题',
+    remark varchar(64) null comment '备注',
+    create_by          varchar(64) default ''                null comment '创建者',
+    create_time        datetime    default CURRENT_TIMESTAMP null comment '创建时间',
+    update_by          varchar(64) default ''                null comment '更新者',
+    update_time        datetime    default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '修改时间'
+    ) comment '点众-短剧配置表';-->
+
+
+    <insert id="insertConfigSelective">
+        REPLACE INTO deepthink.dianzhong_movie_config
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="movieId != null">movie_id,</if>
+            <if test="movieName != null">movie_name,</if>
+            <if test="introduction != null">introduction,</if>
+            <if test="wordCount != null">word_count,</if>
+            <if test="coverImgUrl != null">cover_img_url,</if>
+            <if test="type1 != null">type_1,</if>
+            <if test="type2 != null">type_2,</if>
+            <if test="type3 != null">type_3,</if>
+            <if test="firstShelfTime != null">first_shelf_time,</if>
+            <if test="showTitle != null">show_title,</if>
+            <if test="remark != null">remark,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="updateBy != null">update_by,</if>
+        </trim>
+        VALUES
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="movieId != null">#{movieId},</if>
+            <if test="movieName != null">#{movieName},</if>
+            <if test="introduction != null">#{introduction},</if>
+            <if test="wordCount != null">#{wordCount},</if>
+            <if test="coverImgUrl != null">#{coverImgUrl},</if>
+            <if test="type1 != null">#{type1},</if>
+            <if test="type2 != null">#{type2},</if>
+            <if test="type3 != null">#{type3},</if>
+            <if test="firstShelfTime != null">#{firstShelfTime},</if>
+            <if test="showTitle != null">#{showTitle},</if>
+            <if test="remark != null">#{remark},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+        </trim>
+    </insert>
+
+    <insert id="insertDistributorConfigSelective">
+        REPLACE INTO deepthink.dianzhong_distributor_config
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="distributorId != null">distributor_id,</if>
+            <if test="distributorName != null">distributor_name,</if>
+            <if test="nickName != null">nick_name,</if>
+            <if test="dianzhongAccountId != null">dianzhong_account_id,</if>
+            <if test="channelCreateTime != null">channel_create_time,</if>
+            <if test="jumpType != null">jump_type,</if>
+            <if test="ofAppid != null">of_appid,</if>
+            <if test="ofName != null">of_name,</if>
+            <if test="remark != null">remark,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="updateBy != null">update_by,</if>
+        </trim>
+        VALUES
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="distributorId != null">#{distributorId},</if>
+            <if test="distributorName != null">#{distributorName},</if>
+            <if test="nickName != null">#{nickName},</if>
+            <if test="dianzhongAccountId != null">#{dianzhongAccountId},</if>
+            <if test="channelCreateTime != null">#{channelCreateTime},</if>
+            <if test="jumpType != null">#{jumpType},</if>
+            <if test="ofAppid != null">#{ofAppid},</if>
+            <if test="ofName != null">#{ofName},</if>
+            <if test="remark != null">#{remark},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+        </trim>
+    </insert>
+</mapper>

+ 11 - 0
job-bytedance/src/main/java/cn/com/ctop/job/bytedance/data/service/IDianzhongConfigService.java

@@ -0,0 +1,11 @@
+package cn.com.ctop.job.bytedance.data.service;
+
+public interface IDianzhongConfigService {
+    /**
+     * 同步剧目信息
+     * @param date 上架时间
+     */
+    void pullMovieInfo(String date, Long channelId);
+
+    void pullChannelInfo();
+}

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

@@ -0,0 +1,156 @@
+package cn.com.ctop.job.bytedance.data.service.impl;
+
+import cn.com.ctop.job.bytedance.config.DianZhongConfig;
+import cn.com.ctop.job.bytedance.data.entity.DianzhongDistributorConfig;
+import cn.com.ctop.job.bytedance.data.entity.DianzhongMovieConfig;
+import cn.com.ctop.job.bytedance.data.mapper.DianzhongConfigMapper;
+import cn.com.ctop.job.bytedance.data.service.IDianzhongConfigService;
+import cn.com.ctop.job.bytedance.data.utils.HttpUtils;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+@Service
+@Slf4j
+public class DianzhongConfigServiceImpl implements IDianzhongConfigService {
+    @Autowired
+    DianZhongConfig dianZhongConfig;
+    @Resource
+    DianzhongConfigMapper dianzhongConfigMapper;
+
+
+
+    @Override
+    public void pullChannelInfo() {
+        for (DianZhongConfig.DZConfig dzAuth : dianZhongConfig.getDzConfig()){
+            String url = "https://routine.wqxsw.com/flames/channel/query/channelInfoList";
+            JSONObject requestJson = initRequestJson2(dzAuth);
+            System.out.println("请求点众渠道用户列表接口,参数:" + requestJson.toJSONString());
+            String res = HttpUtils.httpPostRequest(url, requestJson, null);
+            System.out.println("点众回调渠道用户列表接口返回结果:" + res);
+            if (StringUtils.isEmpty(res)){
+                log.error("点众渠道用户列表接口返回结果为空");
+                return;
+            }
+            JSONObject resObj = JSONObject.parseObject(res);
+            int code = resObj.getIntValue("retCode");
+            if (code != 0){
+                log.error("点众渠道用户列表接口返回错误,code: {}, msg: {}", code, resObj.getString("retMsg"));
+                return;
+            }
+            JSONObject data = resObj.getJSONObject("data");
+            JSONArray channelInfoList = data.getJSONArray("channelInfoList");
+            if (channelInfoList == null || channelInfoList.isEmpty()) {
+                log.info("点众渠道用户列表接口没有返回数据");
+                return;
+            }
+            for (int i = 0; i < channelInfoList.size(); i++) {
+                JSONObject obj = channelInfoList.getJSONObject(i);
+                DianzhongDistributorConfig config = new DianzhongDistributorConfig();
+                config.setDistributorId(obj.getString("channelId"));
+                config.setDistributorName(obj.getString("userName"));
+                config.setNickName(obj.getString("nickName"));
+                config.setDianzhongAccountId(dzAuth.getClientId());
+                config.setChannelCreateTime( obj.getString("createTime"));
+                config.setJumpType( obj.getString("jumpType"));
+                config.setOfAppid( obj.getString("ofAppid"));
+                config.setCreateBy("system");
+                config.setUpdateBy("system");
+
+                dianzhongConfigMapper.insertDistributorConfigSelective(config);
+            }
+
+        }
+    }
+
+
+
+
+    //获取调用点众接口的必要参数
+    private JSONObject initRequestJson(DianZhongConfig.DZConfig authConfig){
+        JSONObject object = new JSONObject();
+        String clientId = authConfig.getClientId();
+        String token = authConfig.getToken();
+        object.put("clientId", clientId);
+        long timestamp = System.currentTimeMillis() / 1000;
+        object.put("timestamp", String.valueOf(timestamp));
+        System.out.println(clientId + token + timestamp);
+        String signKey = DigestUtils.md5Hex(
+                clientId + token + timestamp
+        ).toLowerCase();
+        object.put("signKey", signKey);
+        return object;
+    }
+
+    private JSONObject initRequestJson2(DianZhongConfig.DZConfig authConfig){
+        JSONObject object = new JSONObject();
+        String clientId = authConfig.getClientId();
+        String token = authConfig.getToken();
+        object.put("clientId", clientId);
+        long timestamp = System.currentTimeMillis();
+        object.put("timestamp", String.valueOf(timestamp));
+        System.out.println(clientId + token + timestamp);
+        String signKey = DigestUtils.md5Hex(
+                clientId + token + timestamp
+        ).toLowerCase();
+        object.put("signKey", signKey);
+        return object;
+    }
+
+//    private DianZhongConfig.DZConfig getAuthConfig(){
+//        return dianZhongConfig.getDzConfig().get(0);
+//    }
+    //废弃
+@Override
+public void pullMovieInfo(String date, Long channelId) {
+    String url = "https://video.wqxsw.com/api/channelapi/books";
+    JSONObject requestJson = initRequestJson(dianZhongConfig.getDzConfig().get(0));
+    requestJson.put("date", date);
+    if (channelId != null){
+        requestJson.put("channelId", channelId);
+    }
+    System.out.println("请求点众书籍列表接口,参数:" + requestJson.toJSONString());
+    String res = HttpUtils.httpPostRequest(url, requestJson, null);
+    if (StringUtils.isEmpty(res)){
+        log.error("点众书籍列表接口返回结果为空");
+        return;
+    }
+    JSONObject resObj = JSONObject.parseObject(res);
+    int code = resObj.getIntValue("code");
+    if (code >1){
+        log.error("点众书籍列表接口返回错误,code: {}, msg: {}", code, resObj.getString("msg"));
+        return;
+    }
+    JSONArray data = resObj.getJSONArray("data");
+    if (data == null || data.isEmpty()) {
+        System.out.println(res);
+        log.info("点众书籍列表接口没有返回数据");
+        return;
+    }
+    for (int i = 0; i < data.size(); i++) {
+        JSONObject m = data.getJSONObject(i);
+        DianzhongMovieConfig config = new DianzhongMovieConfig();
+        config.setMovieId(m.getString("bookId"));
+        config.setMovieName(m.getString("bookName"));
+        config.setIntroduction(m.getString("introduction"));
+        config.setWordCount(m.getInteger("totalWordSize"));
+        config.setCoverImgUrl(m.getString("coverWap"));
+        config.setType1(m.getString("bookTypeOneText"));
+        config.setType2(m.getString("bookTypeTwoText"));
+        config.setType3(m.getString("bookTypeThreeText"));
+        config.setFirstShelfTime(m.getString("firstShelfTime"));
+        config.setShowTitle(m.getString("showTitle"));
+        config.setUpdateBy("system");
+        config.setCreateBy("system");
+
+        System.out.println(JSONObject.toJSONString(config));
+        dianzhongConfigMapper.insertConfigSelective(config);
+    }
+}
+}