Explorar o código

V1.1.3 自动投放 批量创建应用 完成

yumeng %!s(int64=4) %!d(string=hai) anos
pai
achega
7c3f1479df

+ 2 - 2
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/MD5Util.java

@@ -28,10 +28,10 @@ public class MD5Util {
 		}
 		return String.valueOf(str);
 	}
-	public static String getMd5(String msg) {
+	public static String getMd5(String url) {
 		MessageDigest md5 = MD5.get();
 		md5.reset();
-		return toHexStr(md5.digest(msg.getBytes()));
+		return toHexStr(md5.digest(url.getBytes()));
 	}
 
 	public static String byteArrayToHexString(byte b[]) {

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -187,6 +187,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/batch/kuaiShouGroupTemplate/*", "anon");
         filterChainDefinitionMap.put("/kuaishouBatch/**", "anon");
         filterChainDefinitionMap.put("/kuaishou/creative/*", "anon");
+        filterChainDefinitionMap.put("/ai/aiKuaiShouAppInfo/*", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

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

@@ -17,7 +17,6 @@ import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceEffectVideoInfoService;
-import cn.com.ctop.toutiao.modules.report.entity.BytedanceAccountReportTaskRecord;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
 import cn.com.ctop.toutiao.modules.report.service.*;
 import com.alibaba.fastjson.JSONArray;
@@ -36,8 +35,6 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.InputStream;
 import java.math.BigDecimal;
@@ -112,9 +109,36 @@ public class TestController {
     private IBindAccountAuthService bindAccountAuthService;
     @Autowired
     private UserAllocationMapper allocationMapper;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
+
+    @GetMapping("/loadMatData")
+    public Map<String, Object> getData(String startDate, String endDate, Long accountId) {
+        Map<String, Object> result = new HashMap<>();
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        Date start = DateUtils.parseDate(startDate, "yyyy-MM-dd");
+        int days = DateUtils.getdaysOfTwoDate(startDate, endDate) + 1;
+        for (int i = 0; i < days; i++) {
+            String getDate = DateUtils.formatDate(DateUtils.addDay(start, i));
+            // bytedanceReportService.bytedanceMaterialReport(token, getDate, getDate);
+
+            suzhaoService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    bytedanceReportService.bytedanceMaterialReport(token, getDate, getDate);
+
+                }
+            });
+
+        }
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
+    }
+
 
     @GetMapping("/testKuaishou")
-    public String kuaishouCallback( @RequestParam("auth_code") String authCode, @RequestParam("state") String state) {
+    public String kuaishouCallback(@RequestParam("auth_code") String authCode, @RequestParam("state") String state) {
         try {
             JSONObject json = JSONObject.parseObject(state);
             if (Check.isNull(json)) {
@@ -224,14 +248,14 @@ public class TestController {
 
 
     @GetMapping("/getBytedanceMatReport")
-    public Map<String,Object>getData(){
+    public Map<String, Object> getData() {
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         executorService = Executors.newFixedThreadPool(10);
         CountDownLatch countDownLatch = new CountDownLatch(tokens.size());
         tokens.forEach(record -> executorService.submit(() -> {
             try {
-                reportService.getAdvertiserReport(record, DateUtils.parseDate("2021-01-01","yyyy-MM-dd"), DateUtils.parseDate("2021-01-31","yyyy-MM-dd"),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-                log.info("账户数据获取完成:account:{},时间:{}-{}",record.getAccountId(),"2021-01-01","2020-01-31");
+                reportService.getAdvertiserReport(record, DateUtils.parseDate("2021-01-01", "yyyy-MM-dd"), DateUtils.parseDate("2021-01-31", "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+                log.info("账户数据获取完成:account:{},时间:{}-{}", record.getAccountId(), "2021-01-01", "2020-01-31");
             } catch (Exception e) {
 
             } finally {
@@ -249,8 +273,8 @@ public class TestController {
 //        bytedanceReportMaterialDailyMapper.updateImageReportProjectName();
 //        bytedanceReportMaterialDailyMapper.updateImageReportPlaneId();
 //        bytedanceReportMaterialDailyMapper.updateImageReportPlaneName();
-        Map<String,Object> result =  new HashMap<>();
-        ResultMapUtils.setResultMap(new HashMap<>(),StatusCode.COMMON_SUCCESS);
+        Map<String, Object> result = new HashMap<>();
+        ResultMapUtils.setResultMap(new HashMap<>(), StatusCode.COMMON_SUCCESS);
         return result;
     }
 

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

@@ -6,12 +6,10 @@ import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
-import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAccountTargetTemplateService;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouNewCreateCampaign;
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
@@ -25,13 +23,10 @@ import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataServ
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceAccountReportTaskRecord;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
 import cn.com.ctop.toutiao.modules.report.service.*;
-import com.alibaba.fastjson.JSONArray;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.catalina.User;
 import org.jeecg.common.util.DateUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.openqa.selenium.By;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
@@ -43,7 +38,6 @@ import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -71,11 +65,16 @@ public class SampleTest {
     private IBindAccountLoginService bindAccountLoginService;
     @Autowired
     private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
-
+ /*   @Autowired
+    private IByteDanceAdvertiserDataService advertiserDataService;
+*/
 
     @Test
     public void loadBytedanceCreativeData() throws ParseException {
-
+        //    1662234704806924
+        CtopOauthToken tokenByAccountId = tokenService.getTokenByAccountId(1662234704806924L);
+        advertiserDataService.getMaterialList(tokenByAccountId);
+       /* getVideoByPage(token, "", 1);
         List<KuaiShouVideoGet> KuaiShouVideoGets = videoGetService.selectPhotoIdsByAccountId(9743746L);
         if (!Check.isNull(KuaiShouVideoGets)) {
             JSONArray dateList = new JSONArray();
@@ -97,7 +96,7 @@ public class SampleTest {
             }
             dateList.add(photoIds);
             kuaishouVideoRelateCreativesService.videoRelateCreatives(9743746L, dateList, statdateMap);
-        }
+        }*/
     }
 
     @Test
@@ -588,7 +587,7 @@ public class SampleTest {
         //countDownLatch = new CountDownLatch(31);
         for (int i = 3; i <= 31; i++) {
             String statDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -i));
-                    ietlReportBytedanceVideoService.cleanETL(statDate);
+            ietlReportBytedanceVideoService.cleanETL(statDate);
         }
     }
 }

+ 49 - 9
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/controller/AiKuaiShouAppInfoController.java

@@ -1,6 +1,9 @@
 package cn.com.ctop.kuaishou.modules.ai.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouAppInfoService;
 import com.alibaba.fastjson.JSON;
@@ -49,21 +52,27 @@ import java.util.Map;
 public class AiKuaiShouAppInfoController {
     @Autowired
     private IAiKuaiShouAppInfoService aiKuaiShouAppInfoService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
 
 
     @PostMapping(value = "/importAppExcel")
-    public Result<?> importExcel(@RequestParam("file") MultipartFile file,
-                                 @RequestParam("accountId") Long accountId,
-                                 @RequestParam("imageToken") String imageToken) {
-
-
+    public JSONObject importExcel(@RequestParam("file") MultipartFile file,
+                                  @RequestParam("accountId") Long accountId,
+                                  @RequestParam("platform") Integer platform,
+                                  @RequestParam("imageToken") String imageToken) {
         FileInputStream fis = null;
+        JSONObject returnJson = new JSONObject();
         try {
-
-            JSONObject json = aiKuaiShouAppInfoService.importExcel(file, accountId, imageToken);
-            //          System.out.println("导入是否成功:" + flag);
+            CtopOauthToken oauthToken = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            returnJson = aiKuaiShouAppInfoService.importExcel(file, accountId, imageToken, platform, oauthToken.getAccessToken());
         } catch (Exception e) {
             e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
         } finally {
             if (fis != null) {
                 try {
@@ -73,8 +82,39 @@ public class AiKuaiShouAppInfoController {
                 }
             }
         }
+        return returnJson;
+    }
+
+    /**
+     * 上传应用头像
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/uploadAppIconImage")
+    public JSONObject uploadAppIconImage(@RequestBody JSONObject requestJson) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            Long accountId = requestJson.getLong("accountId");
+            CtopOauthToken oauthToken = tokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            String url = requestJson.getString("url");
+            if (Check.isNull(url)) {
+                throw new Exception("请传入素材url");
+            }
+            returnJson = aiKuaiShouAppInfoService.uploadAppIconImage(url, accountId, oauthToken.getAccessToken());
+        } catch (Exception e) {
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
 
-        return Result.ok("文件导入成功!");
+    @GetMapping(value = "/appCreate")
+    public void appCreate(Long accountId, String accessToken) {
+        aiKuaiShouAppInfoService.appCreative(accountId, accessToken);
     }
 
 

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/entity/AiKuaiShouAppInfo.java

@@ -89,12 +89,14 @@ public class AiKuaiShouAppInfo {
     @Excel(name = "app文件MD5", width = 15)
     @ApiModelProperty(value = "app文件MD5")
     private String appMd5;
+    private String imageToken;
     /**
      * 状态
      */
     @Excel(name = "状态", width = 15)
     @ApiModelProperty(value = "状态")
     private Integer status;
+    private String remark;
     /**
      * app_id
      */

+ 6 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaiShouAppInfoService.java

@@ -13,5 +13,10 @@ import org.springframework.web.multipart.MultipartFile;
  */
 public interface IAiKuaiShouAppInfoService extends IService<AiKuaiShouAppInfo> {
 
-    JSONObject importExcel(MultipartFile file, Long accountId, String imageToken);
+    JSONObject importExcel(MultipartFile file, Long accountId, String imageToken, Integer platform, String accessToken);
+
+    JSONObject uploadAppIconImage(String url, Long accountId, String accessToken);
+
+    void appCreative(Long accountId, String accessToken);
+
 }

+ 161 - 28
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaiShouAppInfoServiceImpl.java

@@ -1,11 +1,16 @@
 package cn.com.ctop.kuaishou.modules.ai.service.impl;
 
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
 import cn.com.ctop.kuaishou.modules.ai.mapper.AiKuaiShouAppInfoMapper;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouAppInfoService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFDateUtil;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@@ -14,12 +19,16 @@ import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.jeecg.common.util.MD5Util;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
-import java.util.Date;
+import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 /**
  * ai批量上传应用
@@ -29,7 +38,13 @@ import java.util.Date;
  * @date 2021-02-02
  */
 @Service
+@Slf4j
 public class AiKuaiShouAppInfoServiceImpl extends ServiceImpl<AiKuaiShouAppInfoMapper, AiKuaiShouAppInfo> implements IAiKuaiShouAppInfoService {
+    @Autowired
+    private IKuaiShouMaterialUploadService materialUploadService;
+    @Autowired
+    private AiKuaiShouAppInfoMapper aiKuaiShouAppInfoMapper;
+    static ExecutorService executorService = Executors.newFixedThreadPool(10);
 
     /**
      * 文件导入
@@ -40,42 +55,40 @@ public class AiKuaiShouAppInfoServiceImpl extends ServiceImpl<AiKuaiShouAppInfoM
      * @return
      */
     @Override
-    public JSONObject importExcel(MultipartFile myFile, Long accountId, String imageToken) {
+    public JSONObject importExcel(MultipartFile myFile, Long accountId, String imageToken, Integer platform, String accessToken) {
+        JSONObject returnJson = new JSONObject();
         try {
             Workbook workbook = null;
             String fileName = myFile.getOriginalFilename();
-            if (fileName.endsWith("XLS")) {
-                //2003
+            String substring = fileName.substring(fileName.lastIndexOf(".") + 1).toUpperCase();
+            if (substring.equals("XLS")) {
                 workbook = new HSSFWorkbook(myFile.getInputStream());
-            } else if (fileName.endsWith("XLSX")) {
-                //2007
+            } else if (substring.equals("XLSX")) {
                 workbook = new XSSFWorkbook(myFile.getInputStream());
             } else {
-                //   throw new Exception("文件不是Excel文件");
+                throw new Exception("文件不是Excel文件");
             }
-
             Sheet sheet = workbook.getSheet("Sheet1");
             int rows = sheet.getLastRowNum();// 指的行数,一共有多少行+
             if (rows == 0) {
-                // throw new Exception("请填写数据");
+                throw new Exception("请填写数据");
             }
+            List<AiKuaiShouAppInfo> appList = new ArrayList<>();
             for (int i = 1; i <= rows + 1; i++) {
-                // 读取左上端单元格
                 Row row = sheet.getRow(i);
-                // 行不为空
                 if (row != null) {
-                    // **读取cell**
                     AiKuaiShouAppInfo appInfo = new AiKuaiShouAppInfo();
-
+                    appInfo.setStatus(0);
+                    appInfo.setRemark("应用待创建");
+                    appInfo.setAccountId(accountId);
+                    appInfo.setPlatform(platform);
+                    appInfo.setImageToken(imageToken);
                     String appName = getCellValue(row.getCell(0));
                     appInfo.setAppName(appName);
-
                     String packageName = getCellValue(row.getCell(1));
                     appInfo.setPackageName(packageName);
-
                     String appVersion = getCellValue(row.getCell(2));
                     appInfo.setAppVersion(appVersion);
-
                     String useSdk = getCellValue(row.getCell(3));
                     if (!Check.isNull(useSdk)) {
                         appInfo.setUseSdk(Integer.valueOf(useSdk));
@@ -84,27 +97,101 @@ public class AiKuaiShouAppInfoServiceImpl extends ServiceImpl<AiKuaiShouAppInfoM
                     if (!Check.isNull(appPrivacyUrl)) {
                         appInfo.setAppPrivacyUrl(appPrivacyUrl);
                     }
-
-                    String trackUrl = getCellValue(row.getCell(5));
+                    String url = getCellValue(row.getCell(5));
+                    if (!Check.isNull(url)) {
+                        appInfo.setUrl(url);
+                    }
+                    String trackUrl = getCellValue(row.getCell(6));
                     if (!Check.isNull(trackUrl)) {
                         appInfo.setTrackUrl(trackUrl);
                     }
-                    //考试时间
-                  /*  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//小写的mm表示的是分钟
-                    String dateString = getCellValue(row.getCell(3));
-                    if (!StringUtils.isEmpty(dateString)) {
-                        Date date = sdf.parse(dateString);
-                        student.setTime(date);
-                    }
-                    studentMapper.insert(student);*/
+                    appList.add(appInfo);
                 }
             }
-
+            this.saveBatch(appList);
+            appCreative(accountId, accessToken);
+            returnJson.put("code", 0);
+            returnJson.put("message", "文件导入成功,异步创建中,请稍后...");
         } catch (Exception e) {
             e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
 
+    @Override
+    public void appCreative(Long accountId, String accessToken) {
+        List<AiKuaiShouAppInfo> appListByStatus = getAppListByStatus(accountId, 0);
+        for (AiKuaiShouAppInfo appInfo : appListByStatus) {
+            AiKuaiShouAppInfo updateAppInfo = new AiKuaiShouAppInfo();
+            updateAppInfo.setId(appInfo.getId());
+            String md5 = MD5Util.getMd5(appInfo.getUrl());
+            if (Check.isNull(md5)) {
+                updateAppInfo.setStatus(3);
+                updateAppInfo.setRemark("获取应用MD5失败");
+                this.updateById(updateAppInfo);
+                continue;
+            }
+            updateAppInfo.setAppMd5(md5);
+            updateAppInfo.setStatus(1);
+            updateAppInfo.setRemark("应用创建中");
+            this.updateById(updateAppInfo);
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        JSONObject requestJson = new JSONObject();
+                        requestJson.put("advertiser_id", appInfo.getAccountId());
+                        requestJson.put("app_version", appInfo.getAppVersion());
+                        requestJson.put("app_name", appInfo.getAppName());
+                        requestJson.put("image_token", appInfo.getImageToken());
+                        requestJson.put("package_name", appInfo.getPackageName());
+                        requestJson.put("platform", appInfo.getPlatform());
+                        requestJson.put("url", appInfo.getUrl());
+                        requestJson.put("use_sdk", appInfo.getUseSdk());
+                        requestJson.put("app_privacy_url", appInfo.getAppPrivacyUrl());
+                        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.APP_CREATE;
+                        Map<String, String> headerMap = new HashMap<>();
+                        headerMap.put("Content-Type", "multipart/form-data");
+                        headerMap.put("Access-Token", accessToken);
+                        String s = materialUploadService.exceptInfoForRestTemplate(url, requestJson, headerMap);
+                        JSONObject resultJson = JSONObject.parseObject(s);
+                        log.info("上传应用返回信息:{}", resultJson);
+                        if (!Check.isNull(resultJson)) {
+                            Integer code = resultJson.getInteger("code");
+                            if (code == 0) {
+                                JSONObject data = resultJson.getJSONObject("data");
+                                Long app_id = data.getLong("app_id");
+                                updateAppInfo.setStatus(2);
+                                updateAppInfo.setRemark("创建应用成功");
+                                updateAppInfo.setAppId(app_id);
+                            } else {
+                                updateAppInfo.setStatus(3);
+                                updateAppInfo.setRemark(resultJson.getString("message"));
+                            }
+                        } else {
+                            updateAppInfo.setStatus(3);
+                            updateAppInfo.setRemark("上传应用返回结果为空");
+                        }
+
+                    } catch (Exception e) {
+                        updateAppInfo.setStatus(3);
+                        updateAppInfo.setRemark("系统异常");
+
+                    }
+                    aiKuaiShouAppInfoMapper.updateById(updateAppInfo);
+                }
+            });
         }
-        return null;
+    }
+
+
+    private List<AiKuaiShouAppInfo> getAppListByStatus(Long accountId, Integer status) {
+        QueryWrapper<AiKuaiShouAppInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("status", status);
+        return this.list(queryWrapper);
     }
 
 
@@ -148,4 +235,50 @@ public class AiKuaiShouAppInfoServiceImpl extends ServiceImpl<AiKuaiShouAppInfoM
         }
         return value.trim();
     }
+
+
+    @Override
+    public JSONObject uploadAppIconImage(String url, Long accountId, String accessToken) {
+
+        JSONObject returnJson = new JSONObject();
+        try {
+            Map<String, String> headerMap = new HashMap<>();
+            JSONObject requestJson = new JSONObject();
+            requestJson.put("advertiser_id", accountId);
+            headerMap.put("Access-Token", accessToken);
+            headerMap.put("Content-Type", "multipart/form-data");
+            requestJson.put("url", url);
+            requestJson.put("type", 1);
+            requestJson.put("upload_type", "2");
+            String requestUrl = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_UPLOAD;
+            String result = materialUploadService.exceptInfoForRestTemplate(requestUrl, requestJson, headerMap);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                if (resultJson.getInteger("code") == 0) {
+                    JSONObject dataJson = resultJson.getJSONObject("data");
+                    if (!Check.isNull(dataJson)) {
+                        String signature = dataJson.getString("signature");
+                        String image_token = dataJson.getString("image_token");
+                        returnJson.put("code", 0);
+                        returnJson.put("imageToken", image_token);
+                        returnJson.put("signature", signature);
+
+                    } else {
+                        log.error("快手同步封面素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
+                        returnJson.put("code", -1);
+                        returnJson.put("message", "图片上传失败");
+                    }
+                } else {
+                    log.error("快手同步封面素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
+                    returnJson.put("code", -1);
+                    returnJson.put("message", resultJson.getString("message"));
+                }
+            }
+        } catch (Exception e) {
+            returnJson.put("code", -1);
+            returnJson.put("message", "系统错误,请重新上传");
+        }
+
+        return returnJson;
+    }
 }

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouMaterialUploadService.java

@@ -2,8 +2,13 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 
 import com.alibaba.fastjson.JSONObject;
 
+import java.util.Map;
+
 public interface IKuaiShouMaterialUploadService {
     JSONObject video(String url, Integer type, Long accountId, String accessToken, String signature);
 
     String kuauiShouImageUpload(String url, String signature, Long accountId, String token);
+
+
+    String exceptInfoForRestTemplate(String url, Map<String, Object> paramMap, Map<String, String> headerMap);
 }

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

@@ -186,7 +186,8 @@ public class KuaiShouMaterialUploadServiceImpl implements IKuaiShouMaterialUploa
     @Autowired
     private RestTemplate rest;
 
-    private String exceptInfoForRestTemplate(String url, Map<String, Object> paramMap, Map<String, String> headerMap) {
+    @Override
+    public String exceptInfoForRestTemplate(String url, Map<String, Object> paramMap, Map<String, String> headerMap) {
         try {
             MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
             if (!Check.isNullMap(paramMap)) {