ソースを参照

Merge remote-tracking branch 'origin/master'

syh 5 年 前
コミット
a90b6f0046

+ 19 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java

@@ -173,6 +173,12 @@ public class ProjectController {
                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                 HttpServletRequest req) {
         Result<IPage<Project>> result = new Result<>();
+        String advertiserName = project.getAdvertiserName();
+        project.setAdvertiserName(null);
+        String projectName = project.getProjectName();
+        project.setProjectName(null);
+
+
         String industryId = project.getIndustryId();
         project.setIndustryId(null);
         QueryWrapper<Project> queryWrapper = QueryGenerator.initQueryWrapper(project, req.getParameterMap());
@@ -183,12 +189,19 @@ public class ProjectController {
             queryWrapper.eq("user_id", sysUser.getId());
             queryWrapper.orderByDesc("create_time");
         }
-        if(null!=industryId&&!"".equals(industryId.trim())){
+        if (null != industryId && !"".equals(industryId.trim())) {
             SysCategory category = sysCategoryService.getById(industryId);
-            if(null!=category){
-                queryWrapper.likeRight("industry_code",category.getCode());
+            if (null != category) {
+                queryWrapper.likeRight("industry_code", category.getCode());
             }
         }
+        if (!Check.isNull(advertiserName)) {
+            queryWrapper.like("advertiser_name", advertiserName);
+
+        }
+        if (!Check.isNull(projectName)) {
+            queryWrapper.like("project_name", projectName);
+        }
         IPage<Project> pageList = projectService.page(page, queryWrapper);
         result.setSuccess(true);
         result.setResult(pageList);
@@ -217,7 +230,7 @@ public class ProjectController {
                 project.setCompanyId(advertiser.getCompanyId());
             }
             SysCategory category = sysCategoryService.getById(project.getIndustryId());
-            if(null!=category){
+            if (null != category) {
                 project.setIndustryCode(category.getCode());
                 project.setIndustryId(category.getId());
             }
@@ -283,7 +296,7 @@ public class ProjectController {
         }
 
         SysCategory category = sysCategoryService.getById(project.getIndustryId());
-        if(null!=category){
+        if (null != category) {
             project.setIndustryCode(category.getCode());
             project.setIndustryId(category.getId());
         }
@@ -308,7 +321,7 @@ public class ProjectController {
             userAllocationQueryWrapper.eq("project_id", project.getId());
             UserAllocation updateUserAllocation = new UserAllocation();
             updateUserAllocation.setProjectName(project.getProjectName());
-           // updateUserAllocation.setMediaId(project.getMediaId());
+            // updateUserAllocation.setMediaId(project.getMediaId());
             userAllocationService.update(updateUserAllocation, userAllocationQueryWrapper);
 
             if (ok) {

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

@@ -105,7 +105,7 @@ public class TestController {
 
             //1:查询当日数据
             QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("media_id",2);
+            queryWrapper.eq("media_id", 2);
             queryWrapper.orderByDesc("create_time");
             List<CtopOauthToken> tokens = tokenService.list(queryWrapper);
             if (null == tokens || tokens.size() <= 0) {
@@ -220,7 +220,7 @@ public class TestController {
     }
 
 
-   /* @GetMapping(value = "/getVideoByAccountId")
+    @GetMapping(value = "/getVideoByAccountId")
     public String getVideoByAccountId(Long accountId) throws IOException {
 
         try {
@@ -233,7 +233,7 @@ public class TestController {
                     tokenQueryWrapper.eq("account_id", accountId);
                     CtopOauthToken one = tokenService.getOne(tokenQueryWrapper);
                     try {
-                        kuaishouInterfaceService.getSuZaoList(one.getAccessToken(), one.getAccountId(), 1);
+                        kuaishouInterfaceService.getSuZaoList(one.getAccessToken(), one.getAccountId(), 1, null, null);
                         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
                         String videoEndDate = DateUtils.addDay(nowDate, -180);
                         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
@@ -260,7 +260,7 @@ public class TestController {
             e.printStackTrace();
         }
         return "Success";
-    }*/
+    }
 
 
     @GetMapping(value = "/createCutTask")
@@ -439,6 +439,28 @@ public class TestController {
     }
 
 
+    @GetMapping(value = "/getHistoryDataByAccountId")
+    public String getHistoryDataByAccountId(Long accountId) {
+        Result<String> result = new Result<>();
+        try {
+            String endDateStr = DateUtils.getDate("yyyy-MM-dd");
+            String startDate = DateUtils.addMonth(endDateStr, -6);
+            QueryWrapper<CtopOauthToken> tokenQueryWrapper = new QueryWrapper<>();
+            tokenQueryWrapper.eq("media_id", 2);
+            tokenQueryWrapper.eq("account_id", accountId);
+            CtopOauthToken ctopOauthTokens = oauthTokenMapper.selectOne(tokenQueryWrapper);
+            if (!Check.isNull(ctopOauthTokens)) {
+                historyReportTaskService.createTask(ctopOauthTokens.getAccountId(), ctopOauthTokens.getAccessToken(), startDate, endDateStr, CtopAdConstant.KUAISHOU_LOAD_JOB_TYPE_HISTORY);
+
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return "success";
+    }
+
+
     @GetMapping(value = "/getTaskList")
     public String getTaskList() {
         Result<String> result = new Result<>();

+ 3 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouSuZaoLoadJob.java

@@ -2,9 +2,7 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import com.xxl.job.core.util.DateUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.quartz.Job;
@@ -37,8 +35,9 @@ public class KuaishouSuZaoLoadJob implements Job {
                         @Override
                         public void run() {
                             try {
-                                String endDate = DateUtils.getNowDate("yyyy-MM-dd");
-                                String startDate = DateUtils.getAnotherDay("yyyy-mm-dd", endDate, -1);
+                                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                                String endDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, 1);
+                                String startDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, -1);
                                 kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startDate, endDate);
                             } catch (Exception e) {
                                 e.printStackTrace();

+ 5 - 2
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouSuZaoLoadJob.java

@@ -26,10 +26,13 @@ public class KuaishouSuZaoLoadJob {
     public ReturnT<String> execute(String param) throws Exception {
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
         executorService = Executors.newFixedThreadPool(8);
-        String endDate = DateUtils.getDate("yyyy-MM-dd");
-        String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", endDate, -1);
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String endDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, 1);
+        String startDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, -1);
         tokens.forEach(token -> executorService.submit(() -> kuaishouInterfaceService.getSuZaoList(token.getAccessToken(), token.getAccountId(), 1, startDate, endDate)));
         XxlJobLogger.log("快手素造数据同步完成");
         return ReturnT.SUCCESS;
     }
+
+
 }

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

@@ -166,8 +166,9 @@ public class BatchController {
             Thread thread3 = new Thread() {
                 @Override
                 public void run() {
-                    String endDate = DateUtils.getNowDate("yyyy-MM-dd");
-                    String startDate = DateUtils.getAnotherDay("yyyy-mm-dd", endDate, -1);
+                    String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                    String endDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, 1);
+                    String startDate = DateUtils.getAnotherDay("yyyy-mm-dd", nowDate, -1);
                     iKuaishouInterfaceService.getSuZaoList(oauthToken.getAccessToken(), oauthToken.getAccountId(), 1, startDate, endDate);
                 }
             };

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

@@ -285,17 +285,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 detailJson.put("photo_comment", detailJson.getString("comment"));
                 detailJson.put("photo_like", detailJson.getString("like"));
                 detailJson.put("photo_show", detailJson.getString("show"));
-                detailJson.remove("share");
-                detailJson.remove("comment");
-                detailJson.remove("like");
-                detailJson.remove("show");
-                detailJson.remove("adScene");
-                detailJson.remove("stat_hour");
-                detailJson.remove("event_valid_clues");
-                detailJson.remove("event_valid_clues_cost");
-                KuaishouReportDailyAccount kuaishouReportDailyAccount = JsonUtil.jsonToObj(detailJson, KuaishouReportDailyAccount.class);
-                kuaishouReportDailyAccount.setAccountId(token.getAccountId());
-                dailyAccountMapper.insertSelective(kuaishouReportDailyAccount);
+                var KuaishouReportDailyAccount = JSONObject.toJavaObject(detailJson, KuaishouReportDailyAccount.class);
+                KuaishouReportDailyAccount.setAccountId(token.getAccountId());
+                dailyAccountMapper.insertSelective(KuaishouReportDailyAccount);
             }
         }
         getAccountDailyReportByPage(token, startDate, endDate, page + 1);
@@ -2869,12 +2861,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         param.put("advertiser_id", accountId);
         param.put("page", page);
         param.put("page_size", 200);
-        if (!Check.isNull(startDate) && !Check.isNull(startDate)) {
+        if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
             param.put("start_date", startDate);
             param.put("end_date", endDate);
         }
+        System.err.println("入参:" + param);
+        System.err.println("headers:" + headers);
         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) {