Browse Source

Merge branch 'master' into master_rule_engine

# Conflicts:
#	jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
jiequan.bi 4 năm trước cách đây
mục cha
commit
6d33978a34

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

@@ -7,9 +7,12 @@ import cn.com.ctop.common.module.message.handle.impl.EmailSendMsgHandle;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAgentAccountMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceFundDailyService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceFundDailyService;
@@ -37,6 +40,8 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Executors;
 
 
+import static org.jeecg.common.util.DateUtils.getAnotherDay;
+
 @RunWith(SpringRunner.class)
 @RunWith(SpringRunner.class)
 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 @ActiveProfiles("wps")
 @ActiveProfiles("wps")
@@ -53,15 +58,40 @@ public class SampleTest {
 
 
     @Autowired
     @Autowired
     private ICtopOauthTokenService tokenService;
     private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IByteDanceAdvertiserDataService byteDanceAdvertiserDataService;
+
+    @Autowired
+    private IKuaishouTemplateService kuaishouTemplateService;
+
 
 
     @Test
     @Test
     public void loadBytedanceCreativeData() {
     public void loadBytedanceCreativeData() {
-        QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("media_id", 2);
-        List<CtopOauthToken> list = oauthTokenService.list(queryWrapper);
-        for (CtopOauthToken token : list) {
-            kuaiShouHistoryReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), "2020-09-20", "2020-09-20", "daily");
+
+        List<CtopOauthToken> ctopOauthTokens = tokenService.selectKuaiShouToken();
+        for (CtopOauthToken token : ctopOauthTokens) {
+            kuaishouTemplateService.getTemplateByAccountId(token.getAccountId(), token.getAccessToken(), 1);
         }
         }
+
+
+
+
+       /* Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", "d7048013910d63c434debabb058b9fe4d60e3b6b");
+
+        JSONObject params=new JSONObject();
+        params.put("advertiser_id","1660666858777607");
+        params.put("convert_id","1678604543575044");
+
+
+        JSONObject jsonObject = JSONObject.parseObject(HttpUtils.httpGet("https://ad.oceanengine.com/open_api/2/tools/ad_convert/read/", params, headers));
+        System.err.println(jsonObject);
+
+
+       // JSONObject jsonObject = JSONObject.parseObject(HttpUtils.httpGet(QueryToolUrlConstant.AD_CONVERT_QUERY, params, headers));
+
+        byteDanceAdvertiserDataService.getBytedancePlanList("1660666858777607","d7048013910d63c434debabb058b9fe4d60e3b6b",1,null,"2020-11-12");*/
     }
     }
 
 
     @Autowired
     @Autowired
@@ -163,20 +193,20 @@ public class SampleTest {
 
 
     @Test
     @Test
     public void testLoadBytedanceData() {
     public void testLoadBytedanceData() {
-        List<UserAllocation>allocations = allocationService.getByParams(273L,null,0);
-        if(null!=allocations&&!allocations.isEmpty()){
-            for(UserAllocation allocation:allocations){
+        List<UserAllocation> allocations = allocationService.getByParams(273L, null, 0);
+        if (null != allocations && !allocations.isEmpty()) {
+            for (UserAllocation allocation : allocations) {
                 CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
                 CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
                 String startDate = "2020-11-05";
                 String startDate = "2020-11-05";
                 String endDate = "2020-11-09";
                 String endDate = "2020-11-09";
-                reportService.getAdvertiserPlanReport(token, DateUtils.parseDate(startDate,"yyyy-MM-dd"), DateUtils.parseDate(endDate,"yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+                reportService.getAdvertiserPlanReport(token, DateUtils.parseDate(startDate, "yyyy-MM-dd"), DateUtils.parseDate(endDate, "yyyy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
             }
             }
         }
         }
         System.out.println("任务结束");
         System.out.println("任务结束");
     }
     }
 
 
     @Test
     @Test
-    public void loadBytedancePlanData(){
+    public void loadBytedancePlanData() {
         CtopOauthToken token = tokenService.getTokenByAccountId(100198696723L);
         CtopOauthToken token = tokenService.getTokenByAccountId(100198696723L);
 //        advertiserDataService.getAdvertiserPlan(token, "", null, null);
 //        advertiserDataService.getAdvertiserPlan(token, "", null, null);
         Date getDate = DateUtils.addDay(new Date(), 0);
         Date getDate = DateUtils.addDay(new Date(), 0);
@@ -185,15 +215,16 @@ public class SampleTest {
 
 
     @Autowired
     @Autowired
     private IBytedanceFundDailyService bytedanceFundDailyService;
     private IBytedanceFundDailyService bytedanceFundDailyService;
+
     @Test
     @Test
     public void loadFoudData() {
     public void loadFoudData() {
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         for (CtopOauthToken token : tokens) {
         for (CtopOauthToken token : tokens) {
-            System.out.println(token.getAccountId()+"############################");
-            for(int i=20;i<130;i++){
-                Date date = DateUtils.addDay(new Date(),-i);
-                bytedanceFundDailyService.loadFundDataByPage(token, DateUtils.formatDate(date), DateUtils.formatDate(date),1);
-                System.out.println(i+"############################");
+            System.out.println(token.getAccountId() + "############################");
+            for (int i = 20; i < 130; i++) {
+                Date date = DateUtils.addDay(new Date(), -i);
+                bytedanceFundDailyService.loadFundDataByPage(token, DateUtils.formatDate(date), DateUtils.formatDate(date), 1);
+                System.out.println(i + "############################");
             }
             }
         }
         }
     }
     }
@@ -205,25 +236,42 @@ public class SampleTest {
      * 测试获取快手图片消耗数据任务
      * 测试获取快手图片消耗数据任务
      */
      */
     @Test
     @Test
-    public void loadKuaishouImageTask(){
+    public void loadKuaishouImageTask() {
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
-        for(int i=1;i<130;i++) {
+        for (int i = 1; i < 130; i++) {
             Date getDate = DateUtils.addDay(new Date(), -i);
             Date getDate = DateUtils.addDay(new Date(), -i);
             String getDateStr = DateUtils.formatDate(getDate);
             String getDateStr = DateUtils.formatDate(getDate);
             tokens.forEach(token -> reportTaskService.createTask(token.getAccountId(), token.getAccessToken(), getDateStr, getDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_DAILY));
             tokens.forEach(token -> reportTaskService.createTask(token.getAccountId(), token.getAccessToken(), getDateStr, getDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_DAILY));
         }
         }
     }
     }
 
 
+    @Autowired
+    private IKuaiShouDailyReportTaskService dailyReportTaskService;
+
+    /**
+     * 测试获取快手图片消耗数据入库
+     */
+    @Test
+    public void loadKuaishouImageTaskFile() {
+        String nowDate = DateUtils.getDate("yyyy-MM-dd");
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        for (int i = 1; i < 15; i++) {
+            String statDate = getAnotherDay("yyyy-MM-dd", nowDate, -i);
+            tokens.forEach(token -> dailyReportTaskService.getTaskList(token.getAccountId(), token.getAccessToken(), statDate));
+        }
+        //  查询快手token
+    }
+
     @Test
     @Test
-    public void testLoadBytedanceImageData(){
-        List<CtopOauthToken>tokens = tokenService.selectToutiaoToken();
+    public void testLoadBytedanceImageData() {
+        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         countDownLatch = new CountDownLatch(tokens.size());
         countDownLatch = new CountDownLatch(tokens.size());
         executorService = Executors.newFixedThreadPool(8);
         executorService = Executors.newFixedThreadPool(8);
-        tokens.forEach(token->executorService.submit(()->{
+        tokens.forEach(token -> executorService.submit(() -> {
             try {
             try {
                 advertiserDataService.getMaterialList(token);
                 advertiserDataService.getMaterialList(token);
-            }catch (Exception e){
-            }finally {
+            } catch (Exception e) {
+            } finally {
                 countDownLatch.countDown();
                 countDownLatch.countDown();
             }
             }
         }));
         }));
@@ -237,7 +285,11 @@ public class SampleTest {
     }
     }
 
 
     @Autowired
     @Autowired
+    private KuaishouAgentAccountMapper kuaishouAgentAccountMapper;
+
+    @Autowired
     private IKuaishouReportDailyAgentService kuaishouReportDailyAgentService;
     private IKuaishouReportDailyAgentService kuaishouReportDailyAgentService;
+
     @Test
     @Test
     public void loadKuaishouAgentData() throws JsonProcessingException {
     public void loadKuaishouAgentData() throws JsonProcessingException {
         kuaishouReportDailyAgentService.loginAgent();
         kuaishouReportDailyAgentService.loginAgent();
@@ -254,13 +306,14 @@ public class SampleTest {
             e.printStackTrace();
             e.printStackTrace();
         }
         }
     }
     }
+
     @Autowired
     @Autowired
     private IKuaishouInterfaceService kuaishouInterfaceService;
     private IKuaishouInterfaceService kuaishouInterfaceService;
 
 
     @Test
     @Test
     public void loadKuaishouGroupData() throws ParseException {
     public void loadKuaishouGroupData() throws ParseException {
         Date endDate = new Date();
         Date endDate = new Date();
-        String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(endDate), -1);
+        String anotherDay = getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(endDate), -1);
         SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
         SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
         Date startDate = sim.parse(anotherDay);
         Date startDate = sim.parse(anotherDay);
         CtopOauthToken token = tokenService.getTokenByAccountId(7087890L);
         CtopOauthToken token = tokenService.getTokenByAccountId(7087890L);
@@ -268,6 +321,18 @@ public class SampleTest {
     }
     }
 
 
 
 
+    @Test
+    public void loadAccountData() {
+//        List<UserAllocation> allocations = allocationService.getByParams(776L,null,0);
+//        for (UserAllocation allocation:allocations) {
+        CtopOauthToken token = tokenService.getTokenByAccountId(93238965516L);
+        for (int i = 92; i < 100; i++) {
+            Date getDate = DateUtils.addDay(new Date(), -i);
+            reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        }
+//        }
+    }
+
     @Autowired
     @Autowired
     IUReportExportService uReportExportService;
     IUReportExportService uReportExportService;
     @Autowired
     @Autowired
@@ -275,11 +340,23 @@ public class SampleTest {
     @Autowired
     @Autowired
     IUReportService uReportService;
     IUReportService uReportService;
 
 
+    @Test
+    public void loadBytedanceData() {
+        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+        for (int i = 0; i < tokens.size(); i++) {
+            for (int j = 0; j < 4; j++) {
+                String getDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -j));
+                bytedanceReportService.bytedanceVideoMaterialReport(tokens.get(i), getDate, getDate);
+            }
+        }
+    }
+
     @Autowired
     @Autowired
     private IBytedanceReportService bytedanceReportService;
     private IBytedanceReportService bytedanceReportService;
+
     @Test
     @Test
-    public void loadMatData(){
-        List<UserAllocation> allocations = allocationService.getByParams(289L,null,0);
+    public void loadMatData() {
+        List<UserAllocation> allocations = allocationService.getByParams(289L, null, 0);
         countDownLatch = new CountDownLatch(allocations.size());
         countDownLatch = new CountDownLatch(allocations.size());
         executorService = Executors.newFixedThreadPool(2);
         executorService = Executors.newFixedThreadPool(2);
         allocations.forEach(allocation -> {
         allocations.forEach(allocation -> {

+ 5 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MessageTemplateImpl.java

@@ -5,6 +5,9 @@ import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.util.Arrays;
+import java.util.List;
+
 @Service
 @Service
 public class MessageTemplateImpl implements IMessageTemplate {
 public class MessageTemplateImpl implements IMessageTemplate {
 
 
@@ -187,8 +190,9 @@ public class MessageTemplateImpl implements IMessageTemplate {
                 .append("下的账户:").append(advertiserId + ",").append("<br/>")
                 .append("下的账户:").append(advertiserId + ",").append("<br/>")
                 .append("广告组id为:").append(unitId).append("<br/>")
                 .append("广告组id为:").append(unitId).append("<br/>")
                 .append("广告组名称为:").append(unit_name).append("<br/>")
                 .append("广告组名称为:").append(unit_name).append("<br/>")
-                .append("出价设置过高。").append("<br/>")
+                .append("出价设置过高。").append("<br/>")
                 .append("系统已执行暂停此组操作,请您及时查看!");
                 .append("系统已执行暂停此组操作,请您及时查看!");
         return text.toString();
         return text.toString();
     }
     }
+
 }
 }

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

@@ -48,11 +48,11 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
             Integer code = resultJson.getInteger("code");
             Integer code = resultJson.getInteger("code");
             if (code == 0) {
             if (code == 0) {
                 JSONObject dataJson = resultJson.getJSONObject("data");
                 JSONObject dataJson = resultJson.getJSONObject("data");
-                if (!Check.isNull(dataJson)) {
+                if (Check.isNull(dataJson)) {
                     return;
                     return;
                 }
                 }
                 JSONArray details = dataJson.getJSONArray("details");
                 JSONArray details = dataJson.getJSONArray("details");
-                if (!Check.isNull(details)) {
+                if (Check.isNull(details)) {
                     return;
                     return;
                 }
                 }
                 for (int i = 0; i < details.size(); i++) {
                 for (int i = 0; i < details.size(); i++) {

+ 4 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceAdvertiserDataService.java

@@ -41,4 +41,8 @@ public interface IByteDanceAdvertiserDataService {
     void getImageByPage(CtopOauthToken token, String imageIds, int page);
     void getImageByPage(CtopOauthToken token, String imageIds, int page);
 
 
     JSONArray advertiserList(String token);
     JSONArray advertiserList(String token);
+
+
+    void getBytedancePlanList(String accountId, String accessToken, int pageNum, String createDate, String updateDate);
+
 }
 }

+ 43 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -749,4 +749,47 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         params.put("page_size", 100);
         params.put("page_size", 100);
         return HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, params);
         return HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, params);
     }
     }
+
+
+    public void getBytedancePlanList(String accountId, String accessToken, int pageNum, String createDate, String updateDate) {
+
+        // 请求地址
+        String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_get");
+        // 请求参数
+        Map<String, Object> filtering = new HashMap<>();
+        if (null != createDate && !"".equals(createDate)) {
+            filtering.put("ad_create_time", createDate);
+        }
+        if (null != updateDate && !"".equals(updateDate)) {
+            filtering.put("ad_modify_time", updateDate);
+        }
+
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", accountId);
+        param.put("page", pageNum);
+        param.put("page_size", 1000);
+        param.put("filtering", filtering);
+        JSONObject resultObject = HttpUtils.bytedanceGetRequest(accessToken, url, param);
+        Integer code = resultObject.getInteger("code");
+        if (null == code || !code.equals(0)) {
+            log.error("获取广告计划信息接口异常==》accountId:{},message:{}", accountId, resultObject.getString("message"));
+            return;
+        }
+        JSONArray data = resultObject.getJSONObject("data").getJSONArray("list");
+        if (null == data || data.isEmpty()) {
+            return;
+        }
+        for (int i = 0; i < data.size(); i++) {
+            JSONObject dataObject = data.getJSONObject(i);
+            ByteDanceAdvertisePlan advertisePlan = new ByteDanceAdvertisePlan(dataObject, accountId);
+            BigDecimal deepCpabid = dataObject.getBigDecimal("deep_cpabid");
+            if (null != deepCpabid) {
+                advertisePlan.setDeepCpaBid(deepCpabid);
+            }
+            //   advertisePlanService.saveOrUpdate(advertisePlan);
+        }
+        getBytedancePlanList(accountId, accessToken, pageNum + 1, createDate, updateDate);
+    }
+
+
 }
 }