yumeng 4 years ago
parent
commit
492928865b

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

@@ -90,7 +90,8 @@ public class TestController {
 
     @GetMapping(value = "/getMd5")
     public void getMd5() {
-        kuaiShouHistoryReportTaskService.getMd5();
+        kuaiShouHistoryReportTaskService.getTaskList();
+
     }
 
     @GetMapping(value = "/getGroupReport")

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

@@ -97,10 +97,10 @@ public class SampleTest {
         QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("media_id", 2);
         List<CtopOauthToken> list = oauthTokenService.list(queryWrapper);
-        // for (CtopOauthToken token : list) {
-        kuaiShouHistoryReportTaskService.createTask(1872430L, "9cd4d43ea697ad9f2aa91fc0f4b921e5", "2020-03-15", "2020-09-15", "history");
+         for (CtopOauthToken token : list) {
+        kuaiShouHistoryReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), "2020-09-17", "2020-09-19", "history");
 
-        // }
+         }
 
     }
 

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml

@@ -117,6 +117,8 @@
         <if test="statDate != null and statDate != '' ">
             and stat_date = #{statDate}
         </if>
+        and  stat_date &gt;= '2020-09-17'
+        and stat_date &lt;= '2020-09-19'
         group by photo_id
     </select>
 

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

@@ -15,5 +15,5 @@ public interface IKuaiShouHistoryReportTaskService extends IService<KuaiShouHist
 
     void getTaskList();
 
-    void getMd5();
+    void getMd5(String statDate, Long accountId);
 }

+ 16 - 19
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouDailyReportTaskServiceImpl.java

@@ -5,9 +5,7 @@ import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouDailyReportTask;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouDailyReportTaskMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouReportDailyMaterialMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyReportTaskService;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterialVo;
-import cn.com.ctop.kuaishou.modules.report.entity.VideoGetvo;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCampaignMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCreativeMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyGroupMapper;
@@ -50,6 +48,8 @@ public class KuaiShouDailyReportTaskServiceImpl extends ServiceImpl<KuaiShouDail
     private KuaishouReportDailyCreativeMapper reportDailyCreativeMapper;
     @Autowired
     private KuaiShouReportDailyMaterialMapper kuaishouReportDailyMaterialMapper;
+    @Autowired
+    private IKuaiShouHistoryReportTaskService kuaiShouHistoryReportTaskService;
 
     @Override
     public void formatCreativeDailyReportData(Long accountId, String statDate) {
@@ -132,31 +132,28 @@ public class KuaiShouDailyReportTaskServiceImpl extends ServiceImpl<KuaiShouDail
 
                 } else if (task.getViewType() == 4) {
                     reportDailyCreativeMapper.loadCreativeDailyReport(task.getAccountId(), localPath);
-                    Thread.sleep(1 * 1000);
-                    reportDailyCreativeMapper.formatCreativeDailyReportData(task.getAccountId(), task.getStatDate());
+                  /*  Thread.sleep(1 * 1000);
+                    reportDailyCreativeMapper.formatCreativeDailyReportData(task.getAccountId(), task.getStatDate());*/
                 } else if (task.getViewType() == 10) {
                     XxlJobLogger.log("下载文件,accountId:{}", task.getAccountId());
                     reportDailyCreativeMapper.loadProgramCreativeDailyReport(task.getAccountId(), localPath);
                     XxlJobLogger.log("下载结束,accountId:{}", task.getAccountId());
                 } else if (task.getViewType() == 5) {
                     kuaishouReportDailyMaterialMapper.loadMaterialDailyReport(task.getAccountId(), localPath);
-
-                    List<KuaiShouReportDailyMaterialVo> list = kuaishouReportDailyMaterialMapper.getPhotoList(task.getAccountId(), task.getStatDate());
-                    if (!Check.isNull(list)) {
-                        for (KuaiShouReportDailyMaterialVo materialVo : list) {
-                            Long id = materialVo.getId();
-                            Long photoId = materialVo.getPhotoId();
-                            VideoGetvo videoGetvo = kuaishouReportDailyMaterialMapper.getVideoGetByPhotoId(photoId);
-                            if (!Check.isNull(videoGetvo)) {
-                                KuaiShouReportDailyMaterial material = new KuaiShouReportDailyMaterial();
-                                material.setId(id);
-                                material.setSignature(videoGetvo.getSignature());
-                                material.setChannelType(videoGetvo.getChannelType());
-                                kuaishouReportDailyMaterialMapper.updateById(material);
+                   /* Thread thread = new Thread() {
+                        @Override
+                        public void run() {
+                            try {
+                                Thread.sleep(1 * 1000L);
+                                kuaiShouHistoryReportTaskService.getMd5(task.getStatDate(), task.getAccountId());
+                            } catch (InterruptedException e) {
+                                e.printStackTrace();
                             }
+
                         }
 
-                    }
+                    };
+                    thread.start();*/
 
 
                 }

+ 49 - 21
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouHistoryReportTaskServiceImpl.java

@@ -228,7 +228,7 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
 
                 } else if (task.getViewType() == 4) {
                     reportDailyCreativeMapper.loadCreativeDailyReport(task.getAccountId(), localPath);
-                    reportDailyCreativeMapper.formatCreativeDailyReportData(task.getAccountId(), null);
+                    // reportDailyCreativeMapper.formatCreativeDailyReportData(task.getAccountId(), null);
                 } else if (task.getViewType() == 10) {
                     XxlJobLogger.log("下载文件,accountId:{}", task.getAccountId());
                     reportDailyCreativeMapper.loadProgramCreativeDailyReport(task.getAccountId(), localPath);
@@ -237,22 +237,20 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
                 } else if (task.getViewType() == 5) {
                     kuaishouReportDailyMaterialMapper.loadMaterialDailyReport(task.getAccountId(), localPath);
 
-                    List<KuaiShouReportDailyMaterialVo> list = kuaishouReportDailyMaterialMapper.getPhotoList(task.getAccountId(), null);
-                    if (!Check.isNull(list)) {
-                        for (KuaiShouReportDailyMaterialVo materialVo : list) {
-                            Long id = materialVo.getId();
-                            Long photoId = materialVo.getPhotoId();
-                            VideoGetvo videoGetvo = kuaishouReportDailyMaterialMapper.getVideoGetByPhotoId(photoId);
-                            if (!Check.isNull(videoGetvo)) {
-                                KuaiShouReportDailyMaterial material = new KuaiShouReportDailyMaterial();
-                                material.setId(id);
-                                material.setSignature(videoGetvo.getSignature());
-                                material.setChannelType(videoGetvo.getChannelType());
-                                kuaishouReportDailyMaterialMapper.updateById(material);
+                   /* Thread thread = new Thread() {
+                        @Override
+                        public void run() {
+                            try {
+                                Thread.sleep(1 * 1000L);
+                                getMd5(null, task.getAccountId());
+                            } catch (InterruptedException e) {
+                                e.printStackTrace();
                             }
+
                         }
 
-                    }
+                    };
+                    thread.start();*/
                 }
 
 
@@ -271,33 +269,62 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
     private void getHistoryTypeList() {
 
         historyTypeList = new ArrayList<>();
-
+        historyTypeList.add(5);
         historyTypeList.add(1);
         historyTypeList.add(2);
         historyTypeList.add(3);
-        historyTypeList.add(4);
-        /*  historyTypeList.add(5);*/
         historyTypeList.add(10);
+        historyTypeList.add(4);
+
+
     }
 
     private void getDailyTypeList() {
         dailyTypeList = new ArrayList<>();
+        dailyTypeList.add(5);
+
         dailyTypeList.add(2);
         dailyTypeList.add(3);
         dailyTypeList.add(4);
-        /* dailyTypeList.add(5);*/
+
         dailyTypeList.add(10);
     }
 
 
-    static ExecutorService executorService = Executors.newFixedThreadPool(30);
+    static ExecutorService executorService = Executors.newFixedThreadPool(50);
 
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
 
-
     @Override
-    public void getMd5() {
+    public void getMd5(String statDate, Long accountId) {
+
+       /* executorService.submit(new Runnable() {
+            @Override
+            public void run() {
+                List<KuaiShouReportDailyMaterialVo> photoList = kuaishouReportDailyMaterialMapper.getPhotoList(accountId, statDate);
+                if (!Check.isNull(photoList)) {
+                    for (KuaiShouReportDailyMaterialVo materialVo : photoList) {
+                        Long photoId = materialVo.getPhotoId();
+                        VideoGetvo videoGetvo = kuaishouReportDailyMaterialMapper.getVideoGetByPhotoId(photoId);
+                        if (!Check.isNull(videoGetvo)) {
+                            QueryWrapper<KuaiShouReportDailyMaterial> updateQueryWrapper = new QueryWrapper<>();
+                            updateQueryWrapper.eq("photo_id", photoId);
+                            if (!Check.isNull(statDate)) {
+                                updateQueryWrapper.eq("stat_date", statDate);
+                            }
+
+                            KuaiShouReportDailyMaterial material = new KuaiShouReportDailyMaterial();
+                            material.setSignature(videoGetvo.getSignature());
+                            material.setChannelType(videoGetvo.getChannelType());
+                            kuaishouReportDailyMaterialMapper.update(material, updateQueryWrapper);
+                            log.info("修改成功:photoId:{},accountId:{}", photoId, accountId);
+                        }
+
+                    }
+                }
+            }
+        });*/
 
         QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("media_id", 2);
@@ -315,6 +342,7 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
                             if (!Check.isNull(videoGetvo)) {
                                 QueryWrapper<KuaiShouReportDailyMaterial> updateQueryWrapper = new QueryWrapper<>();
                                 updateQueryWrapper.eq("photo_id", photoId);
+                                updateQueryWrapper.isNull("signature");
                                 KuaiShouReportDailyMaterial material = new KuaiShouReportDailyMaterial();
                                 material.setSignature(videoGetvo.getSignature());
                                 material.setChannelType(videoGetvo.getChannelType());