瀏覽代碼

Merge remote-tracking branch 'origin/master'

zhaoxian 8 月之前
父節點
當前提交
ecb2ce2e3a

+ 69 - 70
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -956,6 +956,10 @@ public class DateUtils extends PropertyEditorSupport {
 
 
     }
     }
 
 
+    public static Long dateToLong(String startDate) {
+        return Long.valueOf(startDate.replace("-", ""));
+    }
+
 
 
     /**
     /**
      * String类型 转换为Date, 如果参数长度为10 转换格式”yyyy-MM-dd“ 如果参数长度为19 转换格式”yyyy-MM-dd
      * String类型 转换为Date, 如果参数长度为10 转换格式”yyyy-MM-dd“ 如果参数长度为19 转换格式”yyyy-MM-dd
@@ -1262,7 +1266,7 @@ public class DateUtils extends PropertyEditorSupport {
         Date parse = null;
         Date parse = null;
         try {
         try {
             parse = df.parse(date);
             parse = df.parse(date);
-        }catch (ParseException e) {
+        } catch (ParseException e) {
             e.printStackTrace();
             e.printStackTrace();
         }
         }
         return String.format("%tY", parse);
         return String.format("%tY", parse);
@@ -1295,12 +1299,12 @@ public class DateUtils extends PropertyEditorSupport {
      * @return
      * @return
      * @throws ParseException
      * @throws ParseException
      */
      */
-    public static String getDay(String format, String date){
+    public static String getDay(String format, String date) {
         SimpleDateFormat df = new SimpleDateFormat(format);
         SimpleDateFormat df = new SimpleDateFormat(format);
         Date parse = null;
         Date parse = null;
         try {
         try {
             parse = df.parse(date);
             parse = df.parse(date);
-        }catch (ParseException e) {
+        } catch (ParseException e) {
             e.printStackTrace();
             e.printStackTrace();
         }
         }
         return String.format("%td", parse);
         return String.format("%td", parse);
@@ -1863,7 +1867,7 @@ public class DateUtils extends PropertyEditorSupport {
         return null;
         return null;
     }
     }
 
 
-/**
+    /**
      * int 日期转 string
      * int 日期转 string
      * 20220118 ====>>>> 2022-01-18
      * 20220118 ====>>>> 2022-01-18
      *
      *
@@ -1878,7 +1882,7 @@ public class DateUtils extends PropertyEditorSupport {
         String dateTarget = "";
         String dateTarget = "";
         try {
         try {
             dateTarget = sdfTarget.format(sdfSource.parse(dateSource));
             dateTarget = sdfTarget.format(sdfSource.parse(dateSource));
-        }catch (Exception e) {
+        } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
         }
         }
         return dateTarget;
         return dateTarget;
@@ -1886,8 +1890,6 @@ public class DateUtils extends PropertyEditorSupport {
     }
     }
 
 
 
 
-
-
     /**
     /**
      * 获取当前月份第一天
      * 获取当前月份第一天
      *
      *
@@ -2262,15 +2264,13 @@ public class DateUtils extends PropertyEditorSupport {
 
 
 
 
         System.out.println(subMonthMiddleDay("2022-12-01"));
         System.out.println(subMonthMiddleDay("2022-12-01"));
-        if (subMonthMiddleDay("2022-12-01") == 20221215){
+        if (subMonthMiddleDay("2022-12-01") == 20221215) {
             System.out.println("111");
             System.out.println("111");
-        }else {
+        } else {
             System.out.println("222");
             System.out.println("222");
         }
         }
 
 
 
 
-
-
     }
     }
 
 
     /****
     /****
@@ -2285,7 +2285,7 @@ public class DateUtils extends PropertyEditorSupport {
         Date dt = null;
         Date dt = null;
         try {
         try {
             dt = sdf.parse(date);
             dt = sdf.parse(date);
-        }catch (Exception e) {
+        } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
         }
         }
 
 
@@ -2298,21 +2298,20 @@ public class DateUtils extends PropertyEditorSupport {
     }
     }
 
 
 
 
-
-
     /**
     /**
      * 获取季度所在的3个月份的 开始和结束时间
      * 获取季度所在的3个月份的 开始和结束时间
+     *
      * @param quarterTime
      * @param quarterTime
      * @return
      * @return
      */
      */
-    public static List<Map<String,Integer>> getQuarStartAndEndTime(int quarterTime){
-        List<Map<String,Integer>> list = new ArrayList();
-        Map<String,Object> timeMap = DateUtils.getCurrentQuarterMonths(quarterTime);
-        String[] quarterStr = (String[])timeMap.get("quarter");
-        for (String month : quarterStr ){
-            Map<String,Integer> map = new HashMap<>();
-            map.put("startTime",getFirstDayOfMonth(Integer.valueOf(month)));
-            map.put("endTime",getLastDayOfMonth(Integer.valueOf(month)));
+    public static List<Map<String, Integer>> getQuarStartAndEndTime(int quarterTime) {
+        List<Map<String, Integer>> list = new ArrayList();
+        Map<String, Object> timeMap = DateUtils.getCurrentQuarterMonths(quarterTime);
+        String[] quarterStr = (String[]) timeMap.get("quarter");
+        for (String month : quarterStr) {
+            Map<String, Integer> map = new HashMap<>();
+            map.put("startTime", getFirstDayOfMonth(Integer.valueOf(month)));
+            map.put("endTime", getLastDayOfMonth(Integer.valueOf(month)));
             list.add(map);
             list.add(map);
         }
         }
         return list;
         return list;
@@ -2321,33 +2320,35 @@ public class DateUtils extends PropertyEditorSupport {
 
 
     /**
     /**
      * 获取当前时间的季度的月份
      * 获取当前时间的季度的月份
+     *
      * @return
      * @return
      */
      */
-    public static Map<String,Object> getCurrentQuarterMonths(int quarterTime){
+    public static Map<String, Object> getCurrentQuarterMonths(int quarterTime) {
 
 
-        Map<String,Object> map = new HashMap<>();
+        Map<String, Object> map = new HashMap<>();
         String quarter[] = new String[]{};
         String quarter[] = new String[]{};
 
 
-        if (quarterTime == 1){
-             quarter = new String[]{"01","02","03"};
+        if (quarterTime == 1) {
+            quarter = new String[]{"01", "02", "03"};
         }
         }
-        if (quarterTime == 2){
-             quarter = new String[]{"04","05","06"};
+        if (quarterTime == 2) {
+            quarter = new String[]{"04", "05", "06"};
         }
         }
-        if (quarterTime == 3){
-             quarter = new String[]{"07","08","09"};
+        if (quarterTime == 3) {
+            quarter = new String[]{"07", "08", "09"};
         }
         }
-        if (quarterTime == 4){
-             quarter = new String[]{"10","11","12"};
+        if (quarterTime == 4) {
+            quarter = new String[]{"10", "11", "12"};
         }
         }
-        map.put("quarterTime",quarterTime);
-        map.put("quarter",quarter);
+        map.put("quarterTime", quarterTime);
+        map.put("quarter", quarter);
         return map;
         return map;
     }
     }
 
 
 
 
     /**
     /**
      * 获得季度开始时间
      * 获得季度开始时间
+     *
      * @return
      * @return
      */
      */
     public static Date getCurrentQuarterStartTime() {
     public static Date getCurrentQuarterStartTime() {
@@ -2375,6 +2376,7 @@ public class DateUtils extends PropertyEditorSupport {
 
 
     /**
     /**
      * 当前季度的结束时间
      * 当前季度的结束时间
+     *
      * @return
      * @return
      */
      */
     public static Date getCurrentQuarterEndTime() {
     public static Date getCurrentQuarterEndTime() {
@@ -2395,6 +2397,7 @@ public class DateUtils extends PropertyEditorSupport {
 
 
     /**
     /**
      * 离职时间所在季度的最后一天
      * 离职时间所在季度的最后一天
+     *
      * @param time
      * @param time
      * @return
      * @return
      */
      */
@@ -2417,9 +2420,9 @@ public class DateUtils extends PropertyEditorSupport {
     }
     }
 
 
 
 
-
     /**
     /**
      * 获取当前月第一天
      * 获取当前月第一天
+     *
      * @param month
      * @param month
      * @return
      * @return
      */
      */
@@ -2439,6 +2442,7 @@ public class DateUtils extends PropertyEditorSupport {
 
 
     /**
     /**
      * 获取当前月最后一天
      * 获取当前月最后一天
+     *
      * @param month
      * @param month
      * @return
      * @return
      */
      */
@@ -2447,12 +2451,12 @@ public class DateUtils extends PropertyEditorSupport {
         // 设置月份
         // 设置月份
         calendar.set(Calendar.MONTH, month - 1);
         calendar.set(Calendar.MONTH, month - 1);
         // 获取某月最大天数
         // 获取某月最大天数
-        int lastDay=0;
+        int lastDay = 0;
         //2月的平年瑞年天数
         //2月的平年瑞年天数
-        if(month==2) {
+        if (month == 2) {
             // 这个api在计算2020年2月的过程中有问题
             // 这个api在计算2020年2月的过程中有问题
             lastDay = calendar.getLeastMaximum(Calendar.DAY_OF_MONTH);
             lastDay = calendar.getLeastMaximum(Calendar.DAY_OF_MONTH);
-        }else {
+        } else {
             lastDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
             lastDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
         }
         }
         // 设置日历中月份的最大天数
         // 设置日历中月份的最大天数
@@ -2464,12 +2468,7 @@ public class DateUtils extends PropertyEditorSupport {
     }
     }
 
 
 
 
-
-
-
-
-
-    public static Double getMaterialCost(String frozenTime, String createTime,int monthTime){
+    public static Double getMaterialCost(String frozenTime, String createTime, int monthTime) {
 
 
         //String frozenTime = "";
         //String frozenTime = "";
         //String createTime = "2022-11-02 12:23:23";
         //String createTime = "2022-11-02 12:23:23";
@@ -2481,72 +2480,72 @@ public class DateUtils extends PropertyEditorSupport {
         /**
         /**
          * 人员离职
          * 人员离职
          */
          */
-        if (frozenTime != null){
+        if (frozenTime != null) {
 
 
-            Date  date = DateUtils.str2Date(frozenTime,new SimpleDateFormat("yyyy-MM-dd"));
+            Date date = DateUtils.str2Date(frozenTime, new SimpleDateFormat("yyyy-MM-dd"));
             // 判断时间所在的季度
             // 判断时间所在的季度
             int quarterTime = DateUtils.getQuarter(date);
             int quarterTime = DateUtils.getQuarter(date);
 
 
             //季度查询时间 超过 离职时间 则比例为0 绩效 无
             //季度查询时间 超过 离职时间 则比例为0 绩效 无
-            if (quarterTime < monthTime){
+            if (quarterTime < monthTime) {
                 i = 0;
                 i = 0;
-                log.info("离职-----离职时间是:{},查询季度{} 绩效按照0计算。当前时间是:{},",frozenTime,monthTime,new Date());
+                log.info("离职-----离职时间是:{},查询季度{} 绩效按照0计算。当前时间是:{},", frozenTime, monthTime, new Date());
 
 
             }
             }
 
 
-            if (quarterTime > monthTime){
-                log.info("离职-----离职时间是:{},查询季度{},绩效按照240计算。当前时间是:{},",frozenTime,monthTime,new Date());
+            if (quarterTime > monthTime) {
+                log.info("离职-----离职时间是:{},查询季度{},绩效按照240计算。当前时间是:{},", frozenTime, monthTime, new Date());
 
 
             }
             }
 
 
             //离职时间 是否是当前季度
             //离职时间 是否是当前季度
-            if (quarterTime == monthTime){
-                Map<String,Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
+            if (quarterTime == monthTime) {
+                Map<String, Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
                 //离职时间所在 月份
                 //离职时间所在 月份
-                String month = DateUtils.getMonth("yyyy-MM-dd",frozenTime);
+                String month = DateUtils.getMonth("yyyy-MM-dd", frozenTime);
                 //离职时间所在的季度 的全部 月份
                 //离职时间所在的季度 的全部 月份
-                String[]  quarter =(String[]) map.get("quarter");
+                String[] quarter = (String[]) map.get("quarter");
                 //判断当前离职所在的月份 与当前季度中的月份集合 并获取下标  下标+1 则是 在职月份i
                 //判断当前离职所在的月份 与当前季度中的月份集合 并获取下标  下标+1 则是 在职月份i
-                int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(month));
+                int j = Collections.indexOfSubList(Arrays.asList(quarter), Arrays.asList(month));
                 i = j + 1;
                 i = j + 1;
-                log.info("离职-----离职时间是:{}在查询季度{}范围内!系数为{}个月的绩效数据--->{}",frozenTime,monthTime,i,i*cost);
+                log.info("离职-----离职时间是:{}在查询季度{}范围内!系数为{}个月的绩效数据--->{}", frozenTime, monthTime, i, i * cost);
 
 
             }
             }
             //return i * cost;
             //return i * cost;
 
 
-        }else {
-            Date  date = DateUtils.str2Date(createTime,new SimpleDateFormat("yyyy-MM-dd"));
+        } else {
+            Date date = DateUtils.str2Date(createTime, new SimpleDateFormat("yyyy-MM-dd"));
             // 判断时间所在的季度
             // 判断时间所在的季度
             int quarterTime = DateUtils.getQuarter(date);
             int quarterTime = DateUtils.getQuarter(date);
             //查询入职前的 比例
             //查询入职前的 比例
             //季度查询时间 超过 入职时间  绩效0
             //季度查询时间 超过 入职时间  绩效0
-            if (quarterTime < monthTime){
-                log.info("在职-----入职时间是:{},查询季度{} 绩效按照240计算。当前时间是:{},",createTime,monthTime,new Date());
+            if (quarterTime < monthTime) {
+                log.info("在职-----入职时间是:{},查询季度{} 绩效按照240计算。当前时间是:{},", createTime, monthTime, new Date());
             }
             }
             //查询入职后的 比例
             //查询入职后的 比例
-            if (quarterTime > monthTime){
+            if (quarterTime > monthTime) {
                 i = 0;
                 i = 0;
-                log.info("在职-----入职时间是:{},查询季度{},绩效按照0计算。当前时间是:{},",createTime,monthTime,new Date());
+                log.info("在职-----入职时间是:{},查询季度{},绩效按照0计算。当前时间是:{},", createTime, monthTime, new Date());
             }
             }
 
 
             //入职时间 在当前季度
             //入职时间 在当前季度
-            if (quarterTime == monthTime){
-                Map<String,Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
+            if (quarterTime == monthTime) {
+                Map<String, Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
                 //月份
                 //月份
                 //入职时间所在 月份
                 //入职时间所在 月份
-                String month = DateUtils.getMonth("yyyy-MM-dd",createTime);
+                String month = DateUtils.getMonth("yyyy-MM-dd", createTime);
                 //季度
                 //季度
-                String[]  quarter =(String[]) map.get("quarter");
+                String[] quarter = (String[]) map.get("quarter");
                 //判断当前离职所在的月份 与当前季度中的月份集合 并获取下标  下标+1 则是 在职月份i
                 //判断当前离职所在的月份 与当前季度中的月份集合 并获取下标  下标+1 则是 在职月份i
-                int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(month));
+                int j = Collections.indexOfSubList(Arrays.asList(quarter), Arrays.asList(month));
                 i = j + 1;
                 i = j + 1;
-                log.info("在职-----入职时间是:{}在查询季度{}内!系数为{}个月的绩效数据--->{}",createTime,monthTime,i,i*cost);
+                log.info("在职-----入职时间是:{}在查询季度{}内!系数为{}个月的绩效数据--->{}", createTime, monthTime, i, i * cost);
                 return i * cost;
                 return i * cost;
-            };
+            }
+            ;
         }
         }
         return i * cost;
         return i * cost;
     }
     }
 
 
 
 
-
 }
 }

+ 1 - 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -263,6 +263,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ctop/byteDanceVideoInfo/*", "anon");
         filterChainDefinitionMap.put("/ctop/byteDanceVideoInfo/*", "anon");
         filterChainDefinitionMap.put("/first/delivery/*", "anon");
         filterChainDefinitionMap.put("/first/delivery/*", "anon");
         filterChainDefinitionMap.put("/budget/**", "anon");
         filterChainDefinitionMap.put("/budget/**", "anon");
+        filterChainDefinitionMap.put("/duanju/report/**", "anon");
 
 
         // 添加自己的过滤器并且取名为jwt
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 193 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/DuanJUReportController.java

@@ -0,0 +1,193 @@
+package cn.com.ctop.kuaishou.modules.report.controller;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.report.service.IDuanJUReportService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@RestController
+@RequestMapping("/duanju/report")
+public class DuanJUReportController {
+    @Autowired
+    private IDuanJUReportService duanJUReportService;
+
+    @GetMapping("/getTotalCharge")
+    public Result<Object> getTotalCharge(String startDate, String endDate) {
+        try {
+            Long start = DateUtils.dateToLong(startDate);
+            Long end = DateUtils.dateToLong(endDate);
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            JSONObject data = duanJUReportService.getTotalCharge(requestMap);
+            return Result.OK(data);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+
+    @GetMapping("/getAccountList")
+    public Result<Object> getAccountList(String startDate, String endDate) {
+        try {
+            Long start = DateUtils.dateToLong(startDate);
+            Long end = DateUtils.dateToLong(endDate);
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            List<JSONObject> data = duanJUReportService.getAccountList(requestMap);
+            return Result.OK(data);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    @GetMapping("/getDuanJuList")
+    public Result<Object> getDuanJuList(String startDate, String endDate) {
+        try {
+            Long start = DateUtils.dateToLong(startDate);
+            Long end = DateUtils.dateToLong(endDate);
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            List<JSONObject> data = duanJUReportService.getDuanJuList(requestMap);
+            return Result.OK(data);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    @GetMapping("/stopList")
+    public Result<Object> stopList(Long accountId) {
+        try {
+
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("accountId", accountId);
+
+            List<JSONObject> data = duanJUReportService.stopList(requestMap);
+            return Result.OK(data);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    @GetMapping("/getViodeoList")
+    public Result<Object> getViodeoList(String startDate, String endDate) {
+        try {
+            Long start = DateUtils.dateToLong(startDate);
+            Long end = DateUtils.dateToLong(endDate);
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("start", start);
+            requestMap.put("end", end);
+            List<JSONObject> data = duanJUReportService.getViodeoList(requestMap);
+            return Result.OK(data);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+
+    @GetMapping("/stopPlan")
+    public Result<Object> stopPlan(Long accountId) {
+        try {
+
+            if (Check.isNull(accountId)) {
+                throw new Exception("请传入账户ID");
+            }
+            String token = duanJUReportService.getAgentToken(165893351L);
+            getPlan(accountId, token, 1);
+            return Result.OK();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.error("查询失败");
+    }
+
+    /*   @GetMapping("/getPlan")*/
+    public void getPlan(Long accountId, String token, Integer page) {
+        String url = "https://ad.e.kuaishou.com/rest/openapi/gw/dsp/campaign/list";
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", token);
+        headers.put("Content-Type", " application/json");
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", accountId);
+        param.put("page", page);
+        param.put("page_size", 500);
+        param.put("status", 4);
+
+        String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (Check.isNull(resultJson)) {
+            log.error("获取广告计划信息返回结果异常,advertiserId:{}", accountId);
+            return;
+        }
+        Integer code = resultJson.getInteger("code");
+        if (null == code || code != 0) {
+            log.error("获取广告计划信息返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
+            return;
+        }
+        JSONObject dataJson = resultJson.getJSONObject("data");
+        JSONArray details = dataJson.getJSONArray("details");
+        List<JSONObject> adds = new ArrayList<>();
+        if (!Check.isNull(details)) {
+            for (int i = 0; i < details.size(); i++) {
+                JSONObject addJson = new JSONObject();
+                JSONObject planInfo = details.getJSONObject(i);
+                String campaignName = planInfo.getString("campaign_name");
+                Long campaignId = planInfo.getLong("campaign_id");
+                addJson.put("accountId", accountId);
+                addJson.put("campaignId", campaignId);
+                addJson.put("campaignName", campaignName);
+                String updateUrl = "https://ad.e.kuaishou.com/rest/openapi/v1/campaign/update/status";
+                JSONObject updateParam = new JSONObject();
+                updateParam.put("advertiser_id", accountId);
+                updateParam.put("put_status", 2);
+                updateParam.put("campaign_id", campaignId);
+                String updateResult = HttpUtils.kuaiShouhttpPostRequest(updateUrl, updateParam.toJSONString(), headers);
+                JSONObject updateJson = JSONObject.parseObject(updateResult);
+                if (!Check.isNull(updateJson)) {
+                    addJson.put("updateMessage", "暂停失败,返回为空");
+                }
+                Integer code1 = updateJson.getInteger("code");
+                if (code1 == 0) {
+                    addJson.put("updateMessage", "暂停成功");
+                } else {
+                    addJson.put("updateMessage", "暂停失败," + updateJson.getString("message"));
+                }
+                adds.add(addJson);
+            }
+        }
+
+        if (!Check.isNull(adds)) {
+            duanJUReportService.replaceDatas(adds);
+        }
+
+        if (details.size() >= 500) {
+            getPlan(accountId, token, page + 1);
+        }
+
+    }
+
+}

+ 23 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/DuanJUReportMapper.java

@@ -0,0 +1,23 @@
+package cn.com.ctop.kuaishou.modules.report.mapper;
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+public interface DuanJUReportMapper {
+    JSONObject getTotalCharge(Map<String, Object> requestMap);
+
+    List<JSONObject> getAccountList(Map<String, Object> requestMap);
+
+    List<JSONObject> getDuanJuList(Map<String, Object> requestMap);
+
+    List<JSONObject> getViodeoList(Map<String, Object> requestMap);
+
+    String getAgentToken(@Param("appId") Long appId);
+
+    void replaceDatas(@Param("adds") List<JSONObject> adds);
+
+    List<JSONObject> stopList(Map<String, Object> requestMap);
+}

+ 114 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/DuanJUReportMapper.xml

@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.DuanJUReportMapper">
+    <insert id="replaceDatas" >
+        replace into kuaishou_duanju_stop_plan(
+        account_id,
+        campaign_id,
+        campaign_name,
+        update_message
+        )
+        values
+        <foreach collection="adds" item="add" separator=",">
+            (
+            #{add.accountId},
+            #{add.campaignId},
+            #{add.campaignName},
+            #{add.updateMessage}
+            )
+        </foreach>
+
+    </insert>
+
+
+    <select id="getTotalCharge" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT SUM(charge) AS 'charge', COUNT(DISTINCT advertiser_id) AS 'accountNum', round(
+                ifnull(SUM(event_pay_purchase_amount) / SUM(charge) * 100, 0), 2) AS roi,
+               COUNT(DISTINCT substring_index(substring_index(campaign_name, '-', 2), '-', -1)) AS playCount
+        FROM media_api.compass_bind_kuaishou_campaign_report_daily
+        WHERE stat_date &gt;= #{start}
+          AND stat_date &lt;= #{end}
+    </select>
+    <select id="getAccountList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT *
+        FROM (SELECT t1.advertiser_id                                                              AS accountId,
+                     t2.advertiser_name AS 'accountName', SUM(t1.charge) AS charge,
+                     round(ifnull(SUM(t1.event_pay_purchase_amount) / SUM(t1.charge) * 100, 0), 2) AS roi,
+                     SUM(t1.event_pay_purchase_amount)                                             AS event_pay_purchase_amount,
+                     SUM(t1.aclick)                                                                AS aclick,
+                     SUM(t1.bclick)                                                                AS bclick,
+                     concat(round(ifnull(SUM(t1.bclick) / SUM(t1.aclick) * 100, 0), 2), '%')       AS ctr,
+                     round(SUM(t1.charge) / SUM(t1.bclick), 2)                                     AS cpc,
+                     round(SUM(t1.charge) / SUM(t1.aclick) * 1000, 2)                              AS cpm,
+                     SUM(t1.activation)                                                            AS activation,
+                     round(SUM(t1.charge) / SUM(t1.activation), 2)                                 AS active_cost,
+                     SUM(t1.event_pay)                                                             AS event_pay,
+                     round(SUM(t1.charge) / SUM(t1.event_pay), 2)                                  AS pay_cost,
+                     SUM(round(t1.event_new_user_pay))                                             AS event_new_user_pay,
+                     round(SUM(t1.charge) / SUM(t1.event_new_user_pay), 2)                         AS new_pay_cost
+              FROM media_api.compass_bind_kuaishou_campaign_report_daily t1
+                       LEFT JOIN media_api.compass_bind_advertisers t2 ON t1.advertiser_id = t2.advertiser_id
+              WHERE t1.stat_date &gt;= #{start}
+                AND t1.stat_date &lt;= #{end}
+              GROUP BY t1.advertiser_id) t
+        ORDER BY t.charge DESC
+    </select>
+    <select id="getDuanJuList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT *
+        FROM (SELECT substring_index(campaign_name, '-', 1)                                               AS agent,
+                     substring_index(substring_index(campaign_name, '-', 2), '-', -1)                     AS play_name,
+                     SUM(charge)                                                                          AS charge,
+                     SUM(event_pay_purchase_amount)                                                       AS event_pay_purchase_amount,
+                     concat(round(ifnull(SUM(event_pay_purchase_amount) / SUM(charge) * 100, 0), 2), '%') AS roi,
+                     SUM(aclick)                                                                          AS aclick,
+                     SUM(bclick)                                                                          AS bclick,
+                     concat(round(ifnull(SUM(bclick) / SUM(aclick) * 100, 0), 2), '%')                    AS ctr,
+                     round(SUM(charge) / SUM(bclick), 2)                                                  AS cpc,
+                     round(SUM(charge) / SUM(aclick) * 1000, 2)                                           AS cpm,
+                     SUM(activation)                                                                      AS activation,
+                     round(SUM(charge) / SUM(activation), 2)                                              AS active_cost,
+                     SUM(event_pay)                                                                       AS event_pay,
+                     round(SUM(charge) / SUM(event_pay), 2)                                               AS pay_cost,
+                     SUM(round(event_new_user_pay))                                                       AS event_new_user_pay,
+                     round(SUM(charge) / SUM(event_new_user_pay), 2)                                      AS new_pay_cost
+              FROM media_api.compass_bind_kuaishou_campaign_report_daily
+              WHERE stat_date &gt;= #{start}
+                AND stat_date &lt;= #{end}
+              GROUP BY agent, play_name) t
+        ORDER BY t.charge DESC
+    </select>
+    <select id="getViodeoList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT *
+        FROM (SELECT CAST(photo_id AS char)                                                  AS photo_id,
+                     cover_url AS 'cover_url', photo_url AS 'photo_url', SUM(charge) AS charge,
+                     SUM(event_pay_purchase_amount)                                          AS event_pay_purchase_amount,
+                     round(ifnull(SUM(event_pay_purchase_amount) / SUM(charge) * 100, 0), 2) AS roi,
+                     SUM(aclick)                                                             AS aclick,
+                     SUM(bclick)                                                             AS bclick,
+                     concat(round(ifnull(SUM(bclick) / SUM(aclick) * 100, 0), 2), '%')       AS ctr,
+                     round(SUM(charge) / SUM(bclick), 2)                                     AS cpc,
+                     round(SUM(charge) / SUM(aclick) * 1000, 2)                              AS cpm,
+                     SUM(activation)                                                         AS activation,
+                     round(SUM(charge) / SUM(activation), 2)                                 AS active_cost,
+                     SUM(event_pay)                                                          AS event_pay,
+                     round(SUM(charge) / SUM(event_pay), 2)                                  AS pay_cost,
+                     SUM(round(event_new_user_pay))                                          AS event_new_user_pay,
+                     round(SUM(charge) / SUM(event_new_user_pay), 2)                         AS new_pay_cost
+              FROM media_api.compass_bind_kuaishou_material_video_report_daily
+              WHERE stat_date &gt;= #{start}
+                AND stat_date &lt;= #{end}
+              GROUP BY photo_id) t
+        ORDER BY t.charge DESC
+    </select>
+    <select id="getAgentToken" resultType="java.lang.String" parameterType="java.lang.Long">
+        SELECT access_token
+        FROM ctop_oauth_agent_token
+        WHERE app_id = #{appId}
+    </select>
+    <select id="stopList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT account_id AS 'accountId', campaign_id AS 'campaignId', campaign_name AS 'campaignName', update_message AS 'updateMessage', CAST(create_time AS char) AS 'createTime'
+        FROM kuaishou_duanju_stop_plan
+        WHERE account_id = #{accountId}
+        ORDER BY create_time DESC
+    </select>
+</mapper>

+ 22 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IDuanJUReportService.java

@@ -0,0 +1,22 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+import java.util.Map;
+
+public interface IDuanJUReportService {
+    JSONObject getTotalCharge(Map<String, Object> requestMap);
+
+    List<JSONObject> getAccountList(Map<String, Object> requestMap);
+
+    List<JSONObject> getDuanJuList(Map<String, Object> requestMap);
+
+    List<JSONObject> getViodeoList(Map<String, Object> requestMap);
+
+    String getAgentToken(Long appId);
+
+    void replaceDatas(List<JSONObject> adds);
+
+    List<JSONObject> stopList(Map<String, Object> requestMap);
+}

+ 51 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/DuanJUReportServiceImpl.java

@@ -0,0 +1,51 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.mapper.DuanJUReportMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IDuanJUReportService;
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class DuanJUReportServiceImpl implements IDuanJUReportService {
+    @Autowired
+    private DuanJUReportMapper duanJUReportMapper;
+
+    @Override
+    public JSONObject getTotalCharge(Map<String, Object> requestMap) {
+        return duanJUReportMapper.getTotalCharge(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getAccountList(Map<String, Object> requestMap) {
+        return duanJUReportMapper.getAccountList(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getDuanJuList(Map<String, Object> requestMap) {
+        return duanJUReportMapper.getDuanJuList(requestMap);
+    }
+
+    @Override
+    public List<JSONObject> getViodeoList(Map<String, Object> requestMap) {
+        return duanJUReportMapper.getViodeoList(requestMap);
+    }
+
+    @Override
+    public String getAgentToken(Long appId) {
+        return duanJUReportMapper.getAgentToken(appId);
+    }
+
+    @Override
+    public void replaceDatas(List<JSONObject> adds) {
+        duanJUReportMapper.replaceDatas(adds);
+    }
+
+    @Override
+    public List<JSONObject> stopList(Map<String, Object> requestMap) {
+        return duanJUReportMapper.stopList(requestMap);
+    }
+}