소스 검색

调整素造接口

yumeng 4 년 전
부모
커밋
30ba35e4a5

+ 3 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -148,7 +148,8 @@ public class BatchController {
             Thread thread2 = new Thread() {
                 @Override
                 public void run() {
-                    syncPullMaterialService.getSyncVideoList(accountId, nowDate, nowDate);
+                    // syncPullMaterialService.getSyncVideoList(accountId, nowDate, nowDate);
+                    iKuaishouInterfaceService.getVideoList(oauthToken, nowDate, nowDate);
 
                 }
             };
@@ -157,7 +158,7 @@ public class BatchController {
             Thread thread3 = new Thread() {
                 @Override
                 public void run() {
-                    syncPullMaterialService.getSyncSuZaoList(accountId, nowDate, endDate);
+                    iKuaishouInterfaceService.getSuZaoList(oauthToken.getAccessToken(), accountId, 1, nowDate, endDate);
                 }
             };
             thread3.start();

+ 50 - 41
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -206,6 +206,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             }
             String result = HttpUtils.httpPostRequest(url, param, headers);
             JSONObject resultJson = JSONObject.parseObject(result);
+            if (Check.isNull(resultJson)) {
+                return;
+
+            }
             Integer code = resultJson.getInteger("code");
             String message = resultJson.getString("message");
             if (null == code || code != 0) {
@@ -1604,7 +1608,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         KuaishouResultToken kuaiShouResult = null;
         try {
             String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
-            log.info("返回token信息:{}",JSONObject.parseObject(result));
+            log.info("返回token信息:{}", JSONObject.parseObject(result));
             ObjectMapper mapper = new ObjectMapper();
             mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
             kuaiShouResult = mapper.readValue(result, new TypeReference<KuaishouResultToken>() {
@@ -2913,6 +2917,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         }
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
+        if (Check.isNull(resultJson)) {
+            return;
+        }
         Integer code = resultJson.getInteger("code");
         String message = resultJson.getString("message");
         if (null == code || code != 0) {
@@ -2920,51 +2927,53 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             return;
         }
         JSONObject dataJson = resultJson.getJSONObject("data");
-        if (!Check.isNull(dataJson)) {
-            JSONArray details = dataJson.getJSONArray("details");
-            if (Check.isNull(details)) {
-                return;
-            }
-            KuaiShouAdvertiserBaseInfo baseInfo = KuaiShouAdvertiserBaseInfoService.getBaseInfo(accountId);
-            Long userId = null;
-            if (!Check.isNull(baseInfo)) {
-                userId = Long.valueOf(baseInfo.getUserId());
-            }
-            for (int i = 0; i < details.size(); i++) {
-                JSONObject jsonObject = details.getJSONObject(i);
-                if (!Check.isNull(jsonObject)) {
-                    KuaiShouVideoGet kuaiShouVideoGet = new KuaiShouVideoGet();
-                    Long photo_id = jsonObject.getLong("photo_id");
-                    kuaiShouVideoGet.setId(String.valueOf(accountId) + String.valueOf(photo_id));
-                    kuaiShouVideoGet.setPhotoId(String.valueOf(photo_id));
-                    kuaiShouVideoGet.setUrl(jsonObject.getString("watermark_url"));
-                    kuaiShouVideoGet.setWidth(jsonObject.getInteger("width"));
-                    kuaiShouVideoGet.setHeight(jsonObject.getInteger("height"));
-                    kuaiShouVideoGet.setCoverUrl(jsonObject.getString("cover_url"));
-                    kuaiShouVideoGet.setAccountId(accountId);
-                    String md5 = jsonObject.getString("md5");
-                    kuaiShouVideoGet.setSignature(md5);
-                    kuaiShouVideoGet.setStatDate(jsonObject.getDate("sync_date"));
-                    kuaiShouVideoGet.setChannelType(1);
-                    kuaiShouVideoGet.setUserId(userId);
-                    kuaiShouVideoGet.setMaterialId(jsonObject.getString("material_id"));
-                    Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
-                    if (!Check.isNull(type)) {
-                        kuaiShouVideoGet.setMaterialType(type);
-                    }
-                    kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
-                    Thread thread = new Thread() {
-                        @Override
-                        public void run() {
-                            videoGetService.getKeyFrame(token, accountId, md5, String.valueOf(photo_id));
-                        }
-                    };
-                    thread.start();
+        if (Check.isNull(dataJson)) {
+            return;
+        }
 
 
+        JSONArray details = dataJson.getJSONArray("details");
+        if (Check.isNull(details)) {
+            return;
+        }
+        KuaiShouAdvertiserBaseInfo baseInfo = KuaiShouAdvertiserBaseInfoService.getBaseInfo(accountId);
+        Long userId = null;
+        if (!Check.isNull(baseInfo)) {
+            userId = Long.valueOf(baseInfo.getUserId());
+        }
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject jsonObject = details.getJSONObject(i);
+            if (!Check.isNull(jsonObject)) {
+                KuaiShouVideoGet kuaiShouVideoGet = new KuaiShouVideoGet();
+                Long photo_id = jsonObject.getLong("photo_id");
+                kuaiShouVideoGet.setId(String.valueOf(accountId) + String.valueOf(photo_id));
+                kuaiShouVideoGet.setPhotoId(String.valueOf(photo_id));
+                kuaiShouVideoGet.setUrl(jsonObject.getString("watermark_url"));
+                kuaiShouVideoGet.setWidth(jsonObject.getInteger("width"));
+                kuaiShouVideoGet.setHeight(jsonObject.getInteger("height"));
+                kuaiShouVideoGet.setCoverUrl(jsonObject.getString("cover_url"));
+                kuaiShouVideoGet.setAccountId(accountId);
+                String md5 = jsonObject.getString("md5");
+                kuaiShouVideoGet.setSignature(md5);
+                kuaiShouVideoGet.setStatDate(jsonObject.getDate("sync_date"));
+                kuaiShouVideoGet.setChannelType(1);
+                kuaiShouVideoGet.setUserId(userId);
+                kuaiShouVideoGet.setMaterialId(jsonObject.getString("material_id"));
+                Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
+                if (!Check.isNull(type)) {
+                    kuaiShouVideoGet.setMaterialType(type);
                 }
+                kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
+                Thread thread = new Thread() {
+                    @Override
+                    public void run() {
+                        videoGetService.getKeyFrame(token, accountId, md5, String.valueOf(photo_id));
+                    }
+                };
+                thread.start();
             }
         }
+
         getSuZaoList(token, accountId, page + 1, startDate, endDate);
 
     }