Browse Source

素材同步状态修改

yumeng 3 years ago
parent
commit
a6b79d0876

+ 15 - 16
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -116,7 +116,7 @@ public class TestController {
     private String jobUrl;
 
 
-    @GetMapping(value = "/updateMaterial")
+ /*   @GetMapping(value = "/updateMaterial")
     public void updateMaterial() {
 
         List<String> codeList = materialInfoService.getCodeList();
@@ -125,27 +125,26 @@ public class TestController {
             if (Check.isNull(s)) {
                 continue;
             }
-            Integer num = materialInfoService.getCountByCode(s);
-            if (num > 0) {
-                videoService.submit(new Runnable() {
-                    @Override
-                    public void run() {
-                        try {
-                            System.err.println(s);
+
+            videoService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        Integer num = materialInfoService.getCountByCode(s);
+                        System.err.println(s);
+                        if (num > 0) {
                             materialInfoService.updateByCode(s);
-                        } catch (Exception e) {
-                            e.printStackTrace();
                         }
+                    } catch (Exception e) {
+                        e.printStackTrace();
                     }
-                });
-            }
+                }
+            });
+
         }
     }
 
 
-
-
-
     @GetMapping(value = "/updateByteDanceMaterial")
     public void updateByteDanceMaterial() {
 
@@ -170,7 +169,7 @@ public class TestController {
                 });
             }
         }
-    }
+    }*/
 
 
   /*  @GetMapping(value = "/getProgramCreative")

+ 8 - 1
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -14,6 +14,7 @@ import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouOperationRecordMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouReportDailyMaterialService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService2;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouProgramCreativeService;
 import cn.com.ctop.kuaishou.modules.dimension.service.IKuaiShouDimensionStrategyService;
 import cn.com.ctop.kuaishou.modules.dimension.service.IKuaiShouDimensionVariableService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
@@ -101,6 +102,8 @@ public class SampleTest {
     IRuleKuaiShouPlanService ruleKuaiShouPlanService;
     @Autowired
     private ISendMessageService sendMessageService;
+    @Autowired
+    private IKuaishouProgramCreativeService kuaishouProgramCreativeService;
 
 
     @Test
@@ -108,7 +111,11 @@ public class SampleTest {
       /*  CtopOauthToken oauthToken = tokenService.getTokenByAccountId(10571378L);
         ruleKuaiShouPlanService.cleanRuleDataTarget(10571378L, oauthToken.getAccessToken(), 1);*/
 
-        sendMessageService.sendMessage("eb003a809ff44ee6bd1d9be5384ef4b8","测试发送消息");
+     //   sendMessageService.sendMessage("eb003a809ff44ee6bd1d9be5384ef4b8","测试发送消息");
+        CtopOauthToken oauthToken = tokenService.getTokenByAccountId(10838846L);
+        kuaishouProgramCreativeService.getProgramCreative(oauthToken.getAccountId(),  536025521L, oauthToken.getAccessToken(), null, null, 1);
+
+        //   iKuaishouInterfaceService.getVideoList(oauthToken,null,null);
     }
 
 

+ 2 - 2
module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialInfoMapper.java

@@ -38,13 +38,13 @@ public interface MaterialInfoMapper extends BaseMapper<MaterialInfo> {
 
     JSONArray getIdListByProject(Long projectId);
 
-    List<String> getCodeList();
+    List<String> getCodeList(@Param("date") String date);
 
     Integer getCountByCode(@Param("code") String code);
 
     void updateByCode(@Param("signature") String signature);
 
-    List<String> getBytedanceCodeList();
+    List<String> getBytedanceCodeList(@Param("date") String date);
 
     Integer getBytedanceCountByCode(@Param("code") String code);
 

+ 6 - 2
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialInfoMapper.xml

@@ -189,7 +189,9 @@
 
     </select>
     <select id="getCodeList" resultType="java.lang.String">
-         SELECT `code`  from  ctop_material_info WHERE sync_kuaishou = 1
+         SELECT `code`  from  ctop_material_info
+         WHERE sync_kuaishou = 1
+         and  create_time &gt;= #{date}
          GROUP BY `code`
     </select>
     <select id="getCountByCode" resultType="java.lang.Integer">
@@ -197,7 +199,9 @@
 
     </select>
     <select id="getBytedanceCodeList" resultType="java.lang.String">
-         SELECT `code`  from  ctop_material_info WHERE sync_bytedance = 1
+         SELECT `code`  from  ctop_material_info
+         WHERE sync_bytedance = 1
+         and create_time &gt;= #{date}
          GROUP BY `code`
 
     </select>

+ 2 - 2
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialInfoService.java

@@ -83,13 +83,13 @@ public interface IMaterialInfoService extends IService<MaterialInfo> {
 
     Map<String, Object> getListByParams(String tagCode, String type, Integer status, String materialName, List<Long> projectIds, String code, String startDate, String endDate, String userId, String clipId, String shotId, String planId, Integer offlineFlag, Integer pageNo, Integer pageSize);
 
-    List<String> getCodeList();
+    List<String> getCodeList(String date);
 
     Integer getCountByCode(String s);
 
     void updateByCode(String s);
 
-    List<String> getBytedanceCodeList();
+    List<String> getBytedanceCodeList(String date);
 
     Integer getBytedanceCountByCode(String s);
 

+ 4 - 4
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -861,8 +861,8 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
     }
 
     @Override
-    public List<String> getCodeList() {
-        return materialInfoMapper.getCodeList();
+    public List<String> getCodeList(String date) {
+        return materialInfoMapper.getCodeList(date);
     }
 
     @Override
@@ -876,8 +876,8 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
     }
 
     @Override
-    public List<String> getBytedanceCodeList() {
-        return materialInfoMapper.getBytedanceCodeList();
+    public List<String> getBytedanceCodeList(String date) {
+        return materialInfoMapper.getBytedanceCodeList(date);
     }
 
     @Override

+ 77 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/SyncMaterialUploadJob.java

@@ -1,27 +1,37 @@
 package cn.com.ctop.job.kuaishou.handler;
 
+import cn.com.ctop.common.module.service.IMaterialInfoService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils2;
 import cn.com.ctop.kuaishou.modules.batch.service.IMaterialUploadTaskService;
 import com.alibaba.fastjson.JSONObject;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.GetMapping;
 
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 @Slf4j
 @Component
 public class SyncMaterialUploadJob {
     @Autowired
     private IMaterialUploadTaskService taskService;
+    @Autowired
+    private IMaterialInfoService materialInfoService;
     private static String uploadUrl = "http://upload.tjyourong.com.cn/material/materialUploadTask/uploadMaterial";
+    static ExecutorService kuaishouShouService = Executors.newFixedThreadPool(10);
+    static ExecutorService bytedanceervice = Executors.newFixedThreadPool(10);
+
 
     /**
-     * 快手自动创建组
+     * 素材同步
      */
     @XxlJob("syncMaterialUpload")
     public void execute() {
@@ -51,4 +61,70 @@ public class SyncMaterialUploadJob {
             }
         }
     }
+
+    /**
+     * 更新快手同步状态
+     */
+    @XxlJob("updateKuaiShouMaterialStatus")
+    public void updateKuaiShouMaterialStatus() {
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -30);
+        anotherDay += " 00:00:01";
+        log.info("查询快手未同步素材列表,开始时间:{}", anotherDay);
+        List<String> codeList = materialInfoService.getCodeList(anotherDay);
+        for (int i = 0; i < codeList.size(); i++) {
+            String code = codeList.get(i);
+            if (Check.isNull(code)) {
+                continue;
+            }
+            kuaishouShouService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        Integer num = materialInfoService.getCountByCode(code);
+                        if (num > 0) {
+                            materialInfoService.updateByCode(code);
+                        }
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            });
+
+        }
+    }
+
+
+    /**
+     * 更新头条同步状态
+     */
+    @GetMapping(value = "/updateByteDanceMaterial")
+    public void updateByteDanceMaterial() {
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -30);
+        anotherDay += " 00:00:01";
+        log.info("查询头条未同步素材列表,开始时间:{}", anotherDay);
+        List<String> codeList = materialInfoService.getBytedanceCodeList(anotherDay);
+        for (int i = 0; i < codeList.size(); i++) {
+            String code = codeList.get(i);
+            if (Check.isNull(code)) {
+                continue;
+            }
+            bytedanceervice.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        Integer num = materialInfoService.getBytedanceCountByCode(code);
+                        if (num > 0) {
+                            materialInfoService.updateByteDanceByCode(code);
+                        }
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+            });
+
+        }
+    }
+
 }

+ 1 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouProgramCreativeServiceImpl.java

@@ -78,6 +78,7 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
 
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
+        System.err.println(resultJson);
         Integer code = resultJson.getInteger("code");
         String message = resultJson.getString("message");
         if (null == code || code != 0) {