瀏覽代碼

Merge remote-tracking branch 'origin/test' into test2

xuzuoyun 5 年之前
父節點
當前提交
6a7331e447

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

@@ -175,6 +175,15 @@ public class ByteDanceAdvertiserPostController {
     }
     }
 
 
     /**
     /**
+     * 14:获取流量包数据
+     */
+    @RequestMapping("/advertiser/custom/package/get")
+    public Map<String, Object> flowPackageGet(String accountId) {
+        return advertiserDataService.flowPackageGet(accountId);
+    }
+
+
+    /**
      * 15:上传视频信息
      * 15:上传视频信息
      *
      *
      * @param accountId 本平台广告主id
      * @param accountId 本平台广告主id

+ 62 - 51
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CreateInternalServiceImpl.java

@@ -116,6 +116,8 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
         chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
         chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
         chromeOptions.setAcceptInsecureCerts(true);
         chromeOptions.setAcceptInsecureCerts(true);
         WebDriver webDriver = new ChromeDriver(chromeOptions);
         WebDriver webDriver = new ChromeDriver(chromeOptions);
+        //清除所有的缓存
+        webDriver.manage().deleteAllCookies();
         try {
         try {
             webDriver.get(url);  //获取登录页面
             webDriver.get(url);  //获取登录页面
             for (Cookie cookie : webDriver.manage().getCookies()) {
             for (Cookie cookie : webDriver.manage().getCookies()) {
@@ -172,14 +174,13 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
             }
             }
             if (errorCode == 0) {
             if (errorCode == 0) {
                 //表示登录成功
                 //表示登录成功
-                String csrftoken = "";
                 List<org.apache.http.cookie.Cookie> cookies = HttpUtils2.cookieStore.getCookies();
                 List<org.apache.http.cookie.Cookie> cookies = HttpUtils2.cookieStore.getCookies();
                 for (org.apache.http.cookie.Cookie ck : cookies) {
                 for (org.apache.http.cookie.Cookie ck : cookies) {
                     Cookie cookie = new Cookie(ck.getName(), ck.getValue(), "." + ck.getDomain(), ck.getPath(), ck.getExpiryDate());
                     Cookie cookie = new Cookie(ck.getName(), ck.getValue(), "." + ck.getDomain(), ck.getPath(), ck.getExpiryDate());
                     webDriver.manage().addCookie(cookie);
                     webDriver.manage().addCookie(cookie);
                 }
                 }
-
-                webDriver.get("https://ad.oceanengine.com/pages/promotion.html#/ad");//登录成功 进入推广页面
+                //登录成功 进入推广页面
+                webDriver.get("https://ad.oceanengine.com/pages/promotion.html#/ad");
                 Thread.sleep(3000);
                 Thread.sleep(3000);
                 WebElement element = webDriver.findElement(By.xpath("//div[contains(@class,'-user-account-id')] "));
                 WebElement element = webDriver.findElement(By.xpath("//div[contains(@class,'-user-account-id')] "));
                 if (null != element) {
                 if (null != element) {
@@ -237,6 +238,7 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
         chromeOptions.setAcceptInsecureCerts(true);
         chromeOptions.setAcceptInsecureCerts(true);
         WebDriver webDriver = new ChromeDriver(chromeOptions);
         WebDriver webDriver = new ChromeDriver(chromeOptions);
         try {
         try {
+            webDriver.manage().deleteAllCookies();
             //获取登录页面
             //获取登录页面
             webDriver.get(url);
             webDriver.get(url);
             for (Cookie cookie : webDriver.manage().getCookies()) {
             for (Cookie cookie : webDriver.manage().getCookies()) {
@@ -305,42 +307,43 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 Thread.sleep(3000);
                 Thread.sleep(3000);
                 String templateName = requestJson.getString("templateName");
                 String templateName = requestJson.getString("templateName");
                 String uuid = UUID.randomUUID().toString();
                 String uuid = UUID.randomUUID().toString();
-                if (null == campaignId || campaignId.equals("")) {
-                    //创建广告组页面
-                    webDriver.get("https://ad.oceanengine.com/pages/campaign/create.html");
-                    Map<String, Object> campaignParam = new HashMap<>();
-                    campaignParam.put("campaign_id", "");
-                    campaignParam.put("campaign_name", templateName + "-广告组-" + uuid.substring(1, 7));
-                    campaignParam.put("landing_type", 3);
-                    campaignParam.put("campaign_type", 1);
-                    Map<String, Object> budgetMap = new HashMap<>();
-                    budgetMap.put("budget", 0);
-                    budgetMap.put("budget_mode", -1);
-                    campaignParam.put("budget", budgetMap);
-                    for (Cookie cookie : webDriver.manage().getCookies()) {
-                        if ("csrftoken".equals(cookie.getName())) {
-                            csrftoken = cookie.getValue();
-                        }
-                        BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
-                        ck.setDomain("ad.oceanengine.com");
-                        ck.setExpiryDate(cookie.getExpiry());
-                        ck.setPath(cookie.getPath());
-                        HttpUtils2.cookieStore.addCookie(ck);
+
+                //创建广告组页面
+                webDriver.get("https://ad.oceanengine.com/pages/campaign/create.html");
+                Map<String, Object> campaignParam = new HashMap<>();
+                campaignParam.put("campaign_id", "");
+                campaignParam.put("campaign_name", templateName + "-广告组-" + uuid.substring(1, 7));
+                campaignParam.put("landing_type", 3);
+                campaignParam.put("campaign_type", 1);
+                Map<String, Object> budgetMap = new HashMap<>();
+                budgetMap.put("budget", 0);
+                budgetMap.put("budget_mode", -1);
+                campaignParam.put("budget", budgetMap);
+                for (Cookie cookie : webDriver.manage().getCookies()) {
+                    if ("csrftoken".equals(cookie.getName())) {
+                        csrftoken = cookie.getValue();
                     }
                     }
+                    BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
+                    ck.setDomain("ad.oceanengine.com");
+                    ck.setExpiryDate(cookie.getExpiry());
+                    ck.setPath(cookie.getPath());
+                    HttpUtils2.cookieStore.addCookie(ck);
+                }
 
 
-                    header.put("Accept", "application/json, text/javascript, */*; q=0.01");
-                    header.put("Connection", "keep-alive");
-                    header.put("Host", "ad.oceanengine.com");
-                    header.put("Content-Type", "application/json");
-                    header.put("Origin", "https://ad.oceanengine.com");
-                    header.put("X-CSRFToken", csrftoken);
-                    header.put("X-Requested-With", "XMLHttpRequest");
-                    header.put("Referer", "https://ad.oceanengine.com/pages/campaign/create.html");
+                header.put("Accept", "application/json, text/javascript, */*; q=0.01");
+                header.put("Connection", "keep-alive");
+                header.put("Host", "ad.oceanengine.com");
+                header.put("Content-Type", "application/json");
+                header.put("Origin", "https://ad.oceanengine.com");
+                header.put("X-CSRFToken", csrftoken);
+                header.put("X-Requested-With", "XMLHttpRequest");
+                header.put("Referer", "https://ad.oceanengine.com/pages/promotion.html");
                     // 创建广告组返回信息
                     // 创建广告组返回信息
+                if (null == campaignId || "".equals(campaignId.trim())) {
                     res = HttpUtils2.httpPostRequest("https://ad.oceanengine.com/overture/campaign/create/", campaignParam, header);
                     res = HttpUtils2.httpPostRequest("https://ad.oceanengine.com/overture/campaign/create/", campaignParam, header);
                     JsonNode node = mapper.readTree(res);
                     JsonNode node = mapper.readTree(res);
                     campaignId = node.get("data").get("campaign_id").asText();
                     campaignId = node.get("data").get("campaign_id").asText();
-                    System.out.println(res);
+                    System.out.println("创建广告组返回信息" + res);
                 }
                 }
 
 
                 Integer itratorNum = requestJson.getInteger("itratorNum");
                 Integer itratorNum = requestJson.getInteger("itratorNum");
@@ -353,12 +356,16 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                         webDriver.get(url2);
                         webDriver.get(url2);
                         header.put("Referer", url2);
                         header.put("Referer", url2);
                         for (Cookie cookie : webDriver.manage().getCookies()) {
                         for (Cookie cookie : webDriver.manage().getCookies()) {
+                            if ("csrftoken".equals(cookie.getName())) {
+                                csrftoken = cookie.getValue();
+                            }
                             BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
                             BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
                             ck.setDomain("ad.oceanengine.com");
                             ck.setDomain("ad.oceanengine.com");
                             ck.setExpiryDate(cookie.getExpiry());
                             ck.setExpiryDate(cookie.getExpiry());
                             ck.setPath(cookie.getPath());
                             ck.setPath(cookie.getPath());
                             HttpUtils2.cookieStore.addCookie(ck);
                             HttpUtils2.cookieStore.addCookie(ck);
                         }
                         }
+                        header.put("X-CSRFToken", csrftoken);
                         Map<String, Object> audienceParam = new HashMap<>();
                         Map<String, Object> audienceParam = new HashMap<>();
                         audienceParam.put("location_type", 4);
                         audienceParam.put("location_type", 4);
                         audienceParam.put("aweme_account_fans", 0);
                         audienceParam.put("aweme_account_fans", 0);
@@ -388,8 +395,6 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                             // 落地页链接
                             // 落地页链接
                             planParam.put("external_url", urlInfo.getUrl());
                             planParam.put("external_url", urlInfo.getUrl());
                         }
                         }
-                        // 投放范围
-                        planParam.put("delivery_range", 1);
                         //广告类别  5 内广
                         //广告类别  5 内广
                         planParam.put("classify", 5);
                         planParam.put("classify", 5);
                         planParam.put("projectid", "");
                         planParam.put("projectid", "");
@@ -475,7 +480,7 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                         System.out.println(planParam);
                         System.out.println(planParam);
                         String createResult = HttpUtils2.httpPostRequest("https://ad.oceanengine.com/overture/ad/create/", planParam, header);
                         String createResult = HttpUtils2.httpPostRequest("https://ad.oceanengine.com/overture/ad/create/", planParam, header);
                         JSONObject result = JSONObject.parseObject(createResult);
                         JSONObject result = JSONObject.parseObject(createResult);
-                        System.out.println(result.toJSONString());
+                        System.out.println("创建广告计划返回信息:" + result.toJSONString());
                         String status = result.getString("status");
                         String status = result.getString("status");
                         String msg = result.getString("msg");
                         String msg = result.getString("msg");
                         if (null != status && !"success".equals(status)) {
                         if (null != status && !"success".equals(status)) {
@@ -503,31 +508,40 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                             BytedanceCreativeLaunchTemplate launchTemplate = launchTemplateMapper.selectById(creativeTemplateId);
                             BytedanceCreativeLaunchTemplate launchTemplate = launchTemplateMapper.selectById(creativeTemplateId);
                             data.put("ad_id", adId);
                             data.put("ad_id", adId);
                             String advertiseLoaction = launchTemplate.getAdvertiseLocation();
                             String advertiseLoaction = launchTemplate.getAdvertiseLocation();
+                            if (deliveryRange == 2) {
+                                //按媒体指定位置
+                                JSONArray inventoryType = new JSONArray();
+                                inventoryType.add("INVENTORY_UNION_SLOT");
+                                data.put("inventory_type", inventoryType);
+                            } else {
+                                //穿山甲
+                                //按媒体指定位置
+                                if (null != advertiseLoaction && "media".equals(advertiseLoaction)) {
+                                    String inventoryTypeStr = launchTemplate.getInventoryType();
+                                    JSONArray inventoryType = JSONArray.parseArray(inventoryTypeStr);
+                                    data.put("inventory_type", inventoryType);
+                                }
+                                //按场景指定位置
+                                if (null != advertiseLoaction && "sence".equals(advertiseLoaction)) {
+                                    data.put("scene_inventory", launchTemplate.getSceneInventory());
+                                }
+                            }
+                            //创意展现方式
+                            data.put("creative_display_mode", launchTemplate.getCreativeDisplayMode());
                             //优选广告位
                             //优选广告位
                             if (null != advertiseLoaction && advertiseLoaction.equals("great") && null != launchTemplate.getSmartInventory() && !"".equals(launchTemplate.getSmartInventory())) {
                             if (null != advertiseLoaction && advertiseLoaction.equals("great") && null != launchTemplate.getSmartInventory() && !"".equals(launchTemplate.getSmartInventory())) {
                                 data.put("smart_inventory", launchTemplate.getSmartInventory());
                                 data.put("smart_inventory", launchTemplate.getSmartInventory());
                             }
                             }
-                            //按媒体指定位置
-                            if (null != advertiseLoaction && "media".equals(advertiseLoaction)) {
-                                String inventoryTypeStr = launchTemplate.getInventoryType();
-                                JSONArray inventoryType = JSONArray.parseArray(inventoryTypeStr);
-                                data.put("inventory_type", inventoryType);
-                            }
-                            //按场景指定位置
-                            if (null != advertiseLoaction && "sence".equals(advertiseLoaction)) {
-                                data.put("scene_inventory", launchTemplate.getSceneInventory());
-                            }
 
 
                             //广告评论
                             //广告评论
                             data.put("is_comment_disable", launchTemplate.getCommentDisable());
                             data.put("is_comment_disable", launchTemplate.getCommentDisable());
-                            //创意展现方式
-                            data.put("creative_display_mode", launchTemplate.getCreativeDisplayMode());
                             //创意分类
                             //创意分类
                             JSONArray categorys = JSONArray.parseArray(launchTemplate.getThirdIndustryId());
                             JSONArray categorys = JSONArray.parseArray(launchTemplate.getThirdIndustryId());
                             String thirdIndustryId = categorys.getString(2);
                             String thirdIndustryId = categorys.getString(2);
                             data.put("third_industry_id", thirdIndustryId);
                             data.put("third_industry_id", thirdIndustryId);
                             //创意标签
                             //创意标签
                             data.put("ad_keywords", JSONArray.parseArray(launchTemplate.getAdKeywords()));
                             data.put("ad_keywords", JSONArray.parseArray(launchTemplate.getAdKeywords()));
+
                             //创意标题
                             //创意标题
                             data.put("title", name + "_" + System.currentTimeMillis() + "_" + "汇创广告创意");
                             data.put("title", name + "_" + System.currentTimeMillis() + "_" + "汇创广告创意");
 
 
@@ -582,7 +596,6 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                                     JSONArray titleList = new JSONArray();
                                     JSONArray titleList = new JSONArray();
                                     titleArray.forEach(v -> {
                                     titleArray.forEach(v -> {
                                         JSONObject getTitleObject = JSONObject.parseObject(JSONObject.toJSONString(v));
                                         JSONObject getTitleObject = JSONObject.parseObject(JSONObject.toJSONString(v));
-                                        ;
                                         JSONObject titleObject = new JSONObject();
                                         JSONObject titleObject = new JSONObject();
                                         String getTitle = getTitleObject.getString("text");
                                         String getTitle = getTitleObject.getString("text");
                                         titleObject.put("title", getTitle);
                                         titleObject.put("title", getTitle);
@@ -643,8 +656,6 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
         } finally {
         } finally {
-            //获得cookie
-            Set<Cookie> coo = webDriver.manage().getCookies();
             //清除所有的缓存
             //清除所有的缓存
             webDriver.manage().deleteAllCookies();
             webDriver.manage().deleteAllCookies();
             webDriver.quit();
             webDriver.quit();

+ 7 - 6
jeecg-boot-module-system/src/main/resources/application-test.yml

@@ -136,10 +136,11 @@ mybatis-plus:
 jeecg:
 jeecg:
   path:
   path:
     #文件上传根目录 设置
     #文件上传根目录 设置
-    upload: D://upFiles
+    #文件上传根目录 设置
+    upload: /data/upload
     #webapp文件路径
     #webapp文件路径
-    webapp: D://webapp
-    video-upload: D://upFiles//video//
-    image-upload: D://upFiles//image//
-    chrome-driver: D://chromedriver.exe
-    csv-upload: D://upFiles//csv//
+    webapp: /data/webapp
+    video-upload: /data/upload/video/
+    image-upload: /data/upload/image/
+    chrome-driver: /usr/bin/chromedriver
+    csv-upload: /data/upload/csv/

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

@@ -47,7 +47,7 @@ import java.lang.reflect.Type;
 import java.util.*;
 import java.util.*;
 
 
 /**
 /**
- * @author 于萌萌
+ * @author
  */
  */
 @Slf4j
 @Slf4j
 @Service
 @Service

+ 10 - 0
module-report/src/main/java/cn/com/ctop/bytedance/controller/BytedanceReportController.java

@@ -55,4 +55,14 @@ public class BytedanceReportController {
     }
     }
 
 
 
 
+    @PostMapping("/kuaiShou/getReportList")
+    public List<JSONObject> getReportList(@RequestBody JSONObject requestJson) {
+        System.err.println(requestJson);
+
+        List<JSONObject> kuaiShouAccounDetailtReport = bytedanceReportService.getReportList(requestJson);
+        return kuaiShouAccounDetailtReport;
+
+    }
+
+
 }
 }

+ 17 - 1
module-report/src/main/java/cn/com/ctop/bytedance/mapper/BytedanceReportMapper.java

@@ -49,7 +49,7 @@ public interface BytedanceReportMapper {
      * @param statHour
      * @param statHour
      * @return
      * @return
      */
      */
-    JSONObject selectYesterdayByHourAndDate(@Param("date") String date, @Param("statHour") String statHour);
+    JSONObject selectDayHourlyByHourAndDate(@Param("date") String date, @Param("statHour") String statHour);
 
 
     /**
     /**
      * 查询 七天汇总数据
      * 查询 七天汇总数据
@@ -101,4 +101,20 @@ public interface BytedanceReportMapper {
      * @return
      * @return
      */
      */
     JSONObject selectDayDailyByDate(@Param("statDate") String statDate);
     JSONObject selectDayDailyByDate(@Param("statDate") String statDate);
+
+
+    /**
+     * 按天汇总数据
+     *
+     * @param date
+     * @return
+     */
+    JSONObject selectDayReportByDate(@Param("date") String date);
+
+    /**
+     * 根据日期获取 分时详情数据
+     * @param date
+     * @return
+     */
+    List<JSONObject> selectHourlyDetailsByDate(@Param("date") String date);
 }
 }

+ 34 - 3
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/BytedanceReportMapper.xml

@@ -15,7 +15,6 @@
       </select>
       </select>
 
 
 
 
-
     <select id="selectByDate" resultType="com.alibaba.fastjson.JSONObject">
     <select id="selectByDate" resultType="com.alibaba.fastjson.JSONObject">
       select
       select
        sum(charge) cost,
        sum(charge) cost,
@@ -45,7 +44,8 @@
        sum(photo_show) photoShow,
        sum(photo_show) photoShow,
        sum(photo_click) photoClick,
        sum(photo_click) photoClick,
        sum(aclick) aclick,
        sum(aclick) aclick,
-       stat_hour statHour
+       stat_hour statHour,
+       stat_date statDate
      from
      from
       ctop_kuaishou_report_hourly_account
       ctop_kuaishou_report_hourly_account
       where stat_date = #{date}
       where stat_date = #{date}
@@ -54,7 +54,7 @@
     </select>
     </select>
 
 
 
 
-    <select id="selectYesterdayByHourAndDate" resultType="com.alibaba.fastjson.JSONObject">
+    <select id="selectDayHourlyByHourAndDate" resultType="com.alibaba.fastjson.JSONObject">
       select
       select
        sum(charge) cost,
        sum(charge) cost,
        sum(photo_show) photoShow,
        sum(photo_show) photoShow,
@@ -152,4 +152,35 @@
       group by stat_date
       group by stat_date
     </select>
     </select>
 
 
+
+    <select id="selectDayReportByDate" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       sum(charge) cost,
+       sum(photo_show) photoShow,
+       sum(photo_click) photoClick,
+       sum(aclick) aclick,
+       stat_date statDate
+     from
+      ctop_kuaishou_report_daily_account
+      where stat_date = #{date}
+      group by stat_date
+    </select>
+
+
+    <select id="selectHourlyDetailsByDate" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       sum(charge) cost,
+       sum(photo_show) photoShow,
+       sum(photo_click) photoClick,
+       sum(aclick) aclick,
+       stat_hour statHour,
+       stat_date statDate
+     from
+      ctop_kuaishou_report_hourly_account
+      where stat_date = #{date}
+      group by stat_hour
+      order by stat_hour desc
+    </select>
+
+
 </mapper>
 </mapper>

+ 9 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/IBytedanceReportService.java

@@ -23,4 +23,13 @@ public interface IBytedanceReportService {
      * @return
      * @return
      */
      */
     List<JSONObject> getKuaiShouAccounDetailtReport(JSONObject requestJson);
     List<JSONObject> getKuaiShouAccounDetailtReport(JSONObject requestJson);
+
+
+    /**
+     * 明细列表
+     *
+     * @param requestJson
+     * @return
+     */
+    List<JSONObject> getReportList(JSONObject requestJson);
 }
 }

+ 275 - 137
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceReportServiceImpl.java

@@ -2,7 +2,6 @@ package cn.com.ctop.bytedance.service.impl;
 
 
 import cn.com.ctop.bytedance.entity.BytedanceAdvertiserDailyReport;
 import cn.com.ctop.bytedance.entity.BytedanceAdvertiserDailyReport;
 import cn.com.ctop.bytedance.mapper.BytedanceAdvertiserDailyReportMapper;
 import cn.com.ctop.bytedance.mapper.BytedanceAdvertiserDailyReportMapper;
-import cn.com.ctop.bytedance.mapper.BytedanceCampaignDailyReportMapper;
 import cn.com.ctop.bytedance.mapper.BytedanceReportMapper;
 import cn.com.ctop.bytedance.mapper.BytedanceReportMapper;
 import cn.com.ctop.bytedance.service.IBytedanceReportService;
 import cn.com.ctop.bytedance.service.IBytedanceReportService;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.entity.UserAllocation;
@@ -19,6 +18,7 @@ import org.springframework.stereotype.Service;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
@@ -195,59 +195,54 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
      * @param requestJson
      * @param requestJson
      * @return
      * @return
      */
      */
-    @Autowired
-    private BytedanceCampaignDailyReportMapper campaignDailyReportMapper;
-
     @Override
     @Override
     public JSONObject getKuaiShouAccountReport(JSONObject requestJson) {
     public JSONObject getKuaiShouAccountReport(JSONObject requestJson) {
         Integer type = requestJson.getInteger("type");
         Integer type = requestJson.getInteger("type");
         JSONObject accountJson = new JSONObject();
         JSONObject accountJson = new JSONObject();
-
         try {
         try {
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd"); // 当前日期
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd"); // 当前日期
             String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1); // 当前日期-1
             String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1); // 当前日期-1
             if (type == 1) { // 今日总消耗
             if (type == 1) { // 今日总消耗
                 accountJson = reportMapper.selectDayReport(nowDate);
                 accountJson = reportMapper.selectDayReport(nowDate);
                 if (!Check.isNull(accountJson)) {
                 if (!Check.isNull(accountJson)) {
-                    JSONObject yesterJson = reportMapper.selectDayReport(anotherDay);
-                    if (!Check.isNull(yesterJson)) {
+                    JSONObject yesterdayJson = reportMapper.selectDayReport(anotherDay);
+                    if (!Check.isNull(yesterdayJson)) {
                         BigDecimal cost = accountJson.getBigDecimal("cost"); // 今日消耗
                         BigDecimal cost = accountJson.getBigDecimal("cost"); // 今日消耗
-                        BigDecimal yesterCost = yesterJson.getBigDecimal("cost");// 昨日消耗
+                        BigDecimal yesterdayCost = yesterdayJson.getBigDecimal("cost");// 昨日消耗
                         BigDecimal compareBigDecima = new BigDecimal(0);
                         BigDecimal compareBigDecima = new BigDecimal(0);
-                        if (yesterCost.compareTo(compareBigDecima) != 0) {
-                            BigDecimal costProportion = (cost.subtract(yesterCost)).divide(yesterCost, BigDecimal.ROUND_HALF_UP);
+                        if (yesterdayCost.compareTo(compareBigDecima) != 0) {
+                            BigDecimal costProportion = (cost.subtract(yesterdayCost)).divide(yesterdayCost, BigDecimal.ROUND_HALF_UP);
                             accountJson.put("costProportion", costProportion); // 较昨日增加比例
                             accountJson.put("costProportion", costProportion); // 较昨日增加比例
                         } else {
                         } else {
                             accountJson.put("costProportion", 0); // 较昨日增加比例
                             accountJson.put("costProportion", 0); // 较昨日增加比例
                         }
                         }
 
 
                         Long photoShow = accountJson.getLong("photoShow");// 今日封面展示
                         Long photoShow = accountJson.getLong("photoShow");// 今日封面展示
-                        Long yesterPhotoShow = yesterJson.getLong("photoShow");// 昨日封面展示
-                        if (yesterPhotoShow != 0L) {
-                            double showProportion = (photoShow.doubleValue() - yesterPhotoShow.doubleValue()) / yesterPhotoShow.doubleValue();
+                        Long yesterdayPhotoShow = yesterdayJson.getLong("photoShow");// 昨日封面展示
+                        if (yesterdayPhotoShow != 0L) {
+                            double showProportion = (photoShow.doubleValue() - yesterdayPhotoShow.doubleValue()) / yesterdayPhotoShow.doubleValue();
                             accountJson.put("showProportion", showProportion); // 较昨日增加比例
                             accountJson.put("showProportion", showProportion); // 较昨日增加比例
                         } else {
                         } else {
                             accountJson.put("showProportion", 0); // 较昨日增加比例
                             accountJson.put("showProportion", 0); // 较昨日增加比例
                         }
                         }
 
 
                         Long photoClick = accountJson.getLong("photoClick");// 今日封面展示
                         Long photoClick = accountJson.getLong("photoClick");// 今日封面展示
-                        Long yesterphotoClick = yesterJson.getLong("photoShow");// 昨日封面展示
-                        if (yesterPhotoShow != 0L) {
-                            double photoClickProportion = (photoClick.doubleValue() - yesterphotoClick.doubleValue()) / yesterphotoClick.doubleValue();
+                        Long yesterdayPhotoClick = yesterdayJson.getLong("photoShow");// 昨日封面展示
+                        if (yesterdayPhotoClick != 0L) {
+                            double photoClickProportion = (photoClick.doubleValue() - yesterdayPhotoClick.doubleValue()) / yesterdayPhotoClick.doubleValue();
                             accountJson.put("photoClickProportion", photoClickProportion); // 较昨日增加比例
                             accountJson.put("photoClickProportion", photoClickProportion); // 较昨日增加比例
                         } else {
                         } else {
                             accountJson.put("photoClickProportion", 0); // 较昨日增加比例
                             accountJson.put("photoClickProportion", 0); // 较昨日增加比例
                         }
                         }
 
 
-                        Long aclick = accountJson.getLong("aclick");// 今日封面展示
-                        Long yesterAclick = yesterJson.getLong("photoShow");// 昨日封面展示
-                        if (yesterPhotoShow != 0L) {
-                            double aClickProportion = (aclick.doubleValue() - yesterAclick.doubleValue()) / yesterAclick.doubleValue();
+                        Long aClick = accountJson.getLong("aclick");// 今日封面展示
+                        Long yesterdayAClick = yesterdayJson.getLong("photoShow");// 昨日封面展示
+                        if (yesterdayAClick != 0L) {
+                            double aClickProportion = (aClick.doubleValue() - yesterdayAClick.doubleValue()) / yesterdayAClick.doubleValue();
                             accountJson.put("aClickProportion", aClickProportion); // 较昨日增加比例
                             accountJson.put("aClickProportion", aClickProportion); // 较昨日增加比例
                         } else {
                         } else {
                             accountJson.put("aClickProportion", 0); // 较昨日增加比例
                             accountJson.put("aClickProportion", 0); // 较昨日增加比例
                         }
                         }
-
                     }
                     }
                 }
                 }
             } else if (type == 2) { // 昨日总消耗
             } else if (type == 2) { // 昨日总消耗
@@ -284,13 +279,23 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                 String sign = requestJson.getString("sign");
                 String sign = requestJson.getString("sign");
                 String bigDate = requestJson.getString("bigDate");
                 String bigDate = requestJson.getString("bigDate");
                 String smallDate = requestJson.getString("smallDate");
                 String smallDate = requestJson.getString("smallDate");
+
+                JSONObject beComparedJson = new JSONObject();
+                JSONObject comparedJson = new JSONObject();
+
                 if ("month".equals(sign)) {
                 if ("month".equals(sign)) {
                     Map<String, Object> dateMap = DateUtils.compare_date("yyyy-MM", bigDate, smallDate);
                     Map<String, Object> dateMap = DateUtils.compare_date("yyyy-MM", bigDate, smallDate);
-                    JSONObject beComparedJson = reportMapper.selectMonthReportByDate((String) dateMap.get("smallDate"));   // 被除数数据
-                    JSONObject comparedJson = reportMapper.selectMonthReportByDate((String) dateMap.get("bigDate"));   // 除数数据
+                    beComparedJson = reportMapper.selectMonthReportByDate((String) dateMap.get("smallDate"));   // 被除数数据
+                    comparedJson = reportMapper.selectMonthReportByDate((String) dateMap.get("bigDate"));   // 除数数据
+                } else if ("day".equals(sign)) {
+                    Map<String, Object> dateMap = DateUtils.compare_date("yyyy-MM-dd", bigDate, smallDate);
+                    beComparedJson = reportMapper.selectDayReportByDate((String) dateMap.get("smallDate"));   // 被除数数据
+                    comparedJson = reportMapper.selectDayReportByDate((String) dateMap.get("bigDate"));   // 除数数据
+                }
+
+                if (!Check.isNull(comparedJson)) {
                     BigDecimal cost = comparedJson.getBigDecimal("cost");
                     BigDecimal cost = comparedJson.getBigDecimal("cost");
                     BigDecimal comparedCost = beComparedJson.getBigDecimal("cost");
                     BigDecimal comparedCost = beComparedJson.getBigDecimal("cost");
-
                     if (comparedCost.compareTo(new BigDecimal(0)) != 0) {
                     if (comparedCost.compareTo(new BigDecimal(0)) != 0) {
                         BigDecimal costProportion = (cost.subtract(comparedCost)).divide(comparedCost, BigDecimal.ROUND_HALF_UP);
                         BigDecimal costProportion = (cost.subtract(comparedCost)).divide(comparedCost, BigDecimal.ROUND_HALF_UP);
                         comparedJson.put("costProportion", costProportion);
                         comparedJson.put("costProportion", costProportion);
@@ -306,26 +311,28 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
                     } else {
                     } else {
                         comparedJson.put("photoClickProportion", 0);
                         comparedJson.put("photoClickProportion", 0);
                     }
                     }
-                    Long comparedPhotoShow = beComparedJson.getLong("photoShow");
-                    Long photoShow = comparedJson.getLong("photoShow");
-                    if (comparedPhotoShow != 0L) {
-                        double showProportion = (photoShow.doubleValue() - comparedPhotoShow.doubleValue()) / comparedPhotoShow.doubleValue();
-                        comparedJson.put("showProportion", showProportion);
-                    } else {
-                        comparedJson.put("showProportion", 0);
-                    }
+
                     Long aClick = comparedJson.getLong("aclick");
                     Long aClick = comparedJson.getLong("aclick");
-                    Long comparedAclick = beComparedJson.getLong("photoShow");
-                    if (comparedAclick != 0L) {
-                        double aClickProportion = (aClick.doubleValue() - comparedAclick.doubleValue()) / comparedAclick.doubleValue();
+                    Long comparedAClick = beComparedJson.getLong("photoShow");
+                    if (comparedAClick != 0L) {
+                        double aClickProportion = (aClick.doubleValue() - comparedAClick.doubleValue()) / comparedAClick.doubleValue();
                         comparedJson.put("comparedAclick", aClickProportion);
                         comparedJson.put("comparedAclick", aClickProportion);
                     } else {
                     } else {
                         comparedJson.put("comparedAclick", 0);
                         comparedJson.put("comparedAclick", 0);
                     }
                     }
-                    accountJson.put("beCompared", beComparedJson);
-                    accountJson.put("compared", comparedJson);
                 }
                 }
 
 
+                Long comparedPhotoShow = beComparedJson.getLong("photoShow");
+                Long photoShow = comparedJson.getLong("photoShow");
+                if (comparedPhotoShow != 0L) {
+                    double showProportion = (photoShow.doubleValue() - comparedPhotoShow.doubleValue()) / comparedPhotoShow.doubleValue();
+                    comparedJson.put("showProportion", showProportion);
+                } else {
+                    comparedJson.put("showProportion", 0);
+                }
+                accountJson.put("beCompared", beComparedJson);
+                accountJson.put("compared", comparedJson);
+
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
@@ -343,53 +350,64 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
             String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
             String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
             if (type == 1) { //  今日明细
             if (type == 1) { //  今日明细
+
+                List<JSONObject> yesterdayDetail = reportMapper.selectReportDetail(anotherDay);
                 List<JSONObject> dayDetail = reportMapper.selectReportDetail(nowDate);
                 List<JSONObject> dayDetail = reportMapper.selectReportDetail(nowDate);
-                for (int i = 0; i < dayDetail.size(); i++) {
-                    JSONObject detailJson = dayDetail.get(i);
-                    String statHour = detailJson.getString("statHour");
-                    JSONObject yesterDayJson = reportMapper.selectYesterdayByHourAndDate(anotherDay, statHour);
-                    if (!Check.isNull(yesterDayJson)) {
-                        BigDecimal cost = detailJson.getBigDecimal("cost"); // 今日消耗
-                        BigDecimal yesterCost = yesterDayJson.getBigDecimal("cost");// 昨日消耗
-                        BigDecimal compareBigDecima = new BigDecimal(0);
-                        if (yesterCost.compareTo(compareBigDecima) != 0) {
-                            BigDecimal costProportion = (cost.subtract(yesterCost)).divide(yesterCost, BigDecimal.ROUND_HALF_UP);
-                            detailJson.put("proportion", costProportion); // 较昨日增加比例
-                        } else {
-                            detailJson.put("proportion", 0); // 较昨日增加比例
-                        }
-                        Long photoShow = detailJson.getLong("photoShow");// 今日封面展示
-                        Long yesterPhotoShow = yesterDayJson.getLong("photoShow");// 昨日封面展示
-                        if (yesterPhotoShow != 0L) {
-                            double showProportion = (photoShow.doubleValue() - yesterPhotoShow.doubleValue()) / yesterPhotoShow.doubleValue();
-                            detailJson.put("proportion", showProportion); // 较昨日增加比例
-                        } else {
-                            detailJson.put("proportion", 0); // 较昨日增加比例
-                        }
+                for (int i = 0; i < yesterdayDetail.size(); i++) {
+                    JSONObject yesterdayJson = yesterdayDetail.get(i);
+                    if (!Check.isNull(yesterdayJson)) {
+                        String yesterdayStatHour = yesterdayJson.getString("statHour");
+
+                        for (int j = 0; j < dayDetail.size(); j++) {
+                            JSONObject nowJson = dayDetail.get(j);
+                            String statHour = nowJson.getString("statHour");
+                            if (yesterdayStatHour.equals(statHour)) {
+                                BigDecimal cost = nowJson.getBigDecimal("cost"); // 今日消耗
+                                BigDecimal yesterdayCost = yesterdayJson.getBigDecimal("cost");// 昨日消耗
+                                BigDecimal compareBigDecimal = new BigDecimal(0);
+                                if (yesterdayCost.compareTo(compareBigDecimal) != 0) {
+                                    BigDecimal costProportion = (cost.subtract(yesterdayCost)).divide(yesterdayCost, BigDecimal.ROUND_HALF_UP);
+                                    nowJson.put("proportion", costProportion); // 较昨日增加比例
+                                } else {
+                                    nowJson.put("proportion", 0); // 较昨日增加比例
+                                }
 
 
-                        Long photoClick = detailJson.getLong("photoClick");// 今日封面展示
-                        Long yesterphotoClick = yesterDayJson.getLong("photoShow");// 昨日封面展示
-                        if (yesterPhotoShow != 0L) {
-                            double photoClickroportion = (photoClick.doubleValue() - yesterphotoClick.doubleValue()) / yesterphotoClick.doubleValue();
-                            detailJson.put("proportion", photoClickroportion); // 较昨日增加比例
-                        } else {
-                            detailJson.put("proportion", 0); // 较昨日增加比例
-                        }
-                        Long aclick = detailJson.getLong("aclick");// 今日封面展示
-                        Long yesterAclick = yesterDayJson.getLong("photoShow");// 昨日封面展示
-                        if (yesterPhotoShow != 0L) {
-                            double aClickProportion = (aclick.doubleValue() - yesterAclick.doubleValue()) / yesterAclick.doubleValue();
-                            detailJson.put("proportion", aClickProportion); // 较昨日增加比例
-                        } else {
-                            detailJson.put("proportion", 0); // 较昨日增加比例
-                        }
+                                Long photoShow = nowJson.getLong("photoShow");// 今日封面展示
+                                Long yesterdayPhotoShow = yesterdayJson.getLong("photoShow");// 昨日封面展示
+                                if (yesterdayPhotoShow != 0L) {
+                                    double showProportion = (photoShow.doubleValue() - yesterdayPhotoShow.doubleValue()) / yesterdayPhotoShow.doubleValue();
+                                    nowJson.put("proportion", showProportion); // 较昨日增加比例
+                                } else {
+                                    nowJson.put("proportion", 0); // 较昨日增加比例
+                                }
 
 
-                    }
-                    detail.add(detailJson);
+                                Long photoClick = nowJson.getLong("photoClick");// 今日封面展示
+                                Long yesterdayPhotoClick = yesterdayJson.getLong("photoShow");// 昨日封面展示
+                                if (yesterdayPhotoClick != 0L) {
+                                    double photoClickProportion = (photoClick.doubleValue() - yesterdayPhotoClick.doubleValue()) / yesterdayPhotoClick.doubleValue();
+                                    nowJson.put("proportion", photoClickProportion); // 较昨日增加比例
+                                } else {
+                                    nowJson.put("proportion", 0); // 较昨日增加比例
+                                }
 
 
+                                Long aClick = nowJson.getLong("aclick");// 今日封面展示
+                                Long yesterdayAClick = yesterdayJson.getLong("photoShow");// 昨日封面展示
+                                if (yesterdayAClick != 0L) {
+                                    double aClickProportion = (aClick.doubleValue() - yesterdayAClick.doubleValue()) / yesterdayAClick.doubleValue();
+                                    nowJson.put("proportion", aClickProportion); // 较昨日增加比例
+                                } else {
+                                    nowJson.put("proportion", 0); // 较昨日增加比例
+                                }
+                                yesterdayJson.put("now", nowJson);
+                            }
+
+                        }
+                    }
+                    detail.add(yesterdayJson);
                 }
                 }
             } else if (type == 2) { // 昨日明细
             } else if (type == 2) { // 昨日明细
                 detail = reportMapper.selectReportDetail(anotherDay);
                 detail = reportMapper.selectReportDetail(anotherDay);
+
             } else if (type == 3) { // 近七天明细
             } else if (type == 3) { // 近七天明细
                 String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
                 String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
                 detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
                 detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
@@ -397,96 +415,122 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             } else if (type == 4) { // 近十五天明细
             } else if (type == 4) { // 近十五天明细
                 String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
                 String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
                 detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
                 detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
+
             } else if (type == 5) { // 近1个月明细
             } else if (type == 5) { // 近1个月明细
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
                 detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
                 detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
+
             } else if (type == 6) { // 近三个月明细
             } else if (type == 6) { // 近三个月明细
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -3);
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -3);
                 detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
                 detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
+
             } else if (type == 7) { // 近半年明细
             } else if (type == 7) { // 近半年明细
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -6);
                 String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -6);
                 detail = reportMapper.selectDayDetailByMonth(anotherDay, endDate);
                 detail = reportMapper.selectDayDetailByMonth(anotherDay, endDate);
-            } else if (type == 8) {
+
+            } else if (type == 8) {// 所有数据按月明细
                 detail = reportMapper.selectAllDayDetailByMonth();
                 detail = reportMapper.selectAllDayDetailByMonth();
-            } else if (type == 9) {
+
+            } else if (type == 9) { // 自定义查询区间
                 String startDate = requestJson.getString("startDate");
                 String startDate = requestJson.getString("startDate");
                 String endDate = requestJson.getString("endDate");
                 String endDate = requestJson.getString("endDate");
                 detail = reportMapper.selectDayDetailByDate(startDate, endDate);
                 detail = reportMapper.selectDayDetailByDate(startDate, endDate);
-            } else if (type == 10) {
+
+            } else if (type == 10) { // 数据对比
                 String sign = requestJson.getString("sign");
                 String sign = requestJson.getString("sign");
                 String bigDate = requestJson.getString("bigDate");
                 String bigDate = requestJson.getString("bigDate");
                 String smallDate = requestJson.getString("smallDate");
                 String smallDate = requestJson.getString("smallDate");
+
+                List<JSONObject> comparedArr = new ArrayList<>();
+                String comparedDate = "";
                 if ("month".equals(sign)) {
                 if ("month".equals(sign)) {
                     Map<String, Object> dateMap = DateUtils.compare_date("yyyy-MM", bigDate, smallDate);
                     Map<String, Object> dateMap = DateUtils.compare_date("yyyy-MM", bigDate, smallDate);
-                    List<JSONObject> comparedArr = reportMapper.selectDayDetailsByMonth((String) dateMap.get("bigDate"));   // 除数数据
-                    String comparedDate = (String) dateMap.get("smallDate");
-                    for (int i = 0; i < comparedArr.size(); i++) {
-                        JSONObject comparedJson = comparedArr.get(i);
-                        if (!Check.isNull(comparedJson)) {
-                            String statDate = comparedJson.getString("statDate");
+                    comparedDate = (String) dateMap.get("smallDate");
+                    comparedArr = reportMapper.selectDayDetailsByMonth((String) dateMap.get("bigDate"));   // 除数数据
+                } else if ("day".equals(sign)) {
+                    Map<String, Object> dateMap = DateUtils.compare_date("yyyy-MM-dd", bigDate, smallDate);
+                    comparedDate = (String) dateMap.get("smallDate");
+                    comparedArr = reportMapper.selectHourlyDetailsByDate((String) dateMap.get("bigDate"));   // 除数数据
+                }
+
+                for (int i = 0; i < comparedArr.size(); i++) {
+                    JSONObject comparedJson = comparedArr.get(i);
+                    if (!Check.isNull(comparedJson)) {
+
+                        JSONObject beComparedJson = new JSONObject();
+                        String statDate = comparedJson.getString("statDate");
+                        String beComparedDate = "";
+                        String statHour = "";
+                        if ("month".equals(sign)) {
                             String day = DateUtils.getDay("yyyy-MM-dd", statDate);
                             String day = DateUtils.getDay("yyyy-MM-dd", statDate);
-                            String beComparedDate = comparedDate + "-" + day;
-                            JSONObject beComparedJson = reportMapper.selectDayDailyByDate(beComparedDate);
-                            if (!Check.isNull(beComparedJson)) {
-                                JSONObject json = new JSONObject();
-                                BigDecimal cost = comparedJson.getBigDecimal("cost");
-                                Long photoShow = comparedJson.getLong("photoShow");
-                                Long photoClick = comparedJson.getLong("photoClick");
-                                Long aClick = comparedJson.getLong("aclick");
-                                json.put("cost", cost);
-                                json.put("photoShow", photoShow);
-                                json.put("photoClick", photoClick);
-                                json.put("aClick", aClick);
-                                json.put("statDate", statDate);
-
-                                BigDecimal comparedCost = beComparedJson.getBigDecimal("cost");
-                                Long comparedPhotoShow = beComparedJson.getLong("photoShow");
-                                Long comparedPhotoClick = beComparedJson.getLong("photoClick");
-                                Long comparedAClick = beComparedJson.getLong("aclick");
-                                json.put("beComparedCost", comparedCost);
-                                json.put("beComparedPhotoShow", comparedPhotoShow);
-                                json.put("beComparedPhotoClick", comparedPhotoClick);
-                                json.put("beComparedAClick", comparedAClick);
-                                json.put("beComparedDate", beComparedDate);
-                                if (comparedCost.compareTo(new BigDecimal(0)) != 0) {
-                                    BigDecimal costProportion = (cost.subtract(comparedCost)).divide(comparedCost, BigDecimal.ROUND_HALF_UP);
-                                    json.put("costProportion", costProportion);
-                                } else {
-                                    json.put("costProportion", 0);
-                                }
+                            beComparedDate = comparedDate + "-" + day;
+                            beComparedJson = reportMapper.selectDayDailyByDate(beComparedDate);
 
 
-                                if (comparedPhotoClick != 0L) {
-                                    double photoClickProportion = (photoClick.doubleValue() - comparedPhotoClick.doubleValue()) / comparedPhotoClick.doubleValue();
-                                    json.put("photoClickProportion", photoClickProportion);
-                                } else {
-                                    json.put("photoClickProportion", 0);
-                                }
+                        } else if ("day".equals(sign)) {
+                            statHour = comparedJson.getString("statHour");
+                            beComparedJson = reportMapper.selectDayHourlyByHourAndDate(comparedDate, statHour);
+                            beComparedDate = comparedDate;
+                        }
 
 
-                                if (comparedPhotoShow != 0L) {
-                                    double showProportion = (photoShow.doubleValue() - comparedPhotoShow.doubleValue()) / comparedPhotoShow.doubleValue();
-                                    json.put("showProportion", showProportion);
-                                } else {
-                                    json.put("showProportion", 0);
-                                }
+                        if (!Check.isNull(beComparedJson)) {
+                            JSONObject json = new JSONObject();
+                            BigDecimal cost = comparedJson.getBigDecimal("cost");
+                            Long photoShow = comparedJson.getLong("photoShow");
+                            Long photoClick = comparedJson.getLong("photoClick");
+                            Long aClick = comparedJson.getLong("aclick");
+                            json.put("cost", cost);
+                            json.put("photoShow", photoShow);
+                            json.put("photoClick", photoClick);
+                            json.put("aClick", aClick);
+                            json.put("statDate", statDate);
+                            if ("day".equals(sign)) {
+                                json.put("statHour", statHour);
+                            }
 
 
-                                if (comparedAClick != 0L) {
-                                    double aClickProportion = (aClick.doubleValue() - comparedAClick.doubleValue()) / comparedAClick.doubleValue();
-                                    json.put("comparedAclick", aClickProportion);
-                                } else {
-                                    json.put("comparedAclick", 0);
-                                }
+                            BigDecimal comparedCost = beComparedJson.getBigDecimal("cost");
+                            Long comparedPhotoShow = beComparedJson.getLong("photoShow");
+                            Long comparedPhotoClick = beComparedJson.getLong("photoClick");
+                            Long comparedAClick = beComparedJson.getLong("aclick");
+                            json.put("beComparedCost", comparedCost);
+                            json.put("beComparedPhotoShow", comparedPhotoShow);
+                            json.put("beComparedPhotoClick", comparedPhotoClick);
+                            json.put("beComparedAClick", comparedAClick);
+                            json.put("beComparedDate", beComparedDate);
+
+                            if (comparedCost.compareTo(new BigDecimal(0)) != 0) {
+                                BigDecimal costProportion = (cost.subtract(comparedCost)).divide(comparedCost, BigDecimal.ROUND_HALF_UP);
+                                json.put("costProportion", costProportion);
+                            } else {
+                                json.put("costProportion", 0);
+                            }
+
+                            if (comparedPhotoClick != 0L) {
+                                double photoClickProportion = (photoClick.doubleValue() - comparedPhotoClick.doubleValue()) / comparedPhotoClick.doubleValue();
+                                json.put("photoClickProportion", photoClickProportion);
+                            } else {
+                                json.put("photoClickProportion", 0);
+                            }
 
 
-                                detail.add(json);
+                            if (comparedPhotoShow != 0L) {
+                                double showProportion = (photoShow.doubleValue() - comparedPhotoShow.doubleValue()) / comparedPhotoShow.doubleValue();
+                                json.put("showProportion", showProportion);
+                            } else {
+                                json.put("showProportion", 0);
+                            }
 
 
+                            if (comparedAClick != 0L) {
+                                double aClickProportion = (aClick.doubleValue() - comparedAClick.doubleValue()) / comparedAClick.doubleValue();
+                                json.put("comparedAclick", aClickProportion);
+                            } else {
+                                json.put("comparedAclick", 0);
                             }
                             }
 
 
+                            detail.add(json);
                         }
                         }
 
 
                     }
                     }
 
 
-
                 }
                 }
-
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
             e.printStackTrace();
             e.printStackTrace();
@@ -494,7 +538,101 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
         }
         }
 
 
         System.err.println(detail);
         System.err.println(detail);
-
         return detail;
         return detail;
     }
     }
+
+
+    /**
+     * 明细列表
+     *
+     * @param requestJson
+     * @return
+     */
+    @Override
+    public List<JSONObject> getReportList(JSONObject requestJson) {
+        List<JSONObject> reportList = new ArrayList<>();
+        try {
+            Integer type = requestJson.getInteger("type");
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+            if (type == 1) {//今日分时列表
+                List<JSONObject> nowReportList = reportMapper.selectReportDetail(nowDate);
+                List<JSONObject> yesterdayReportList = reportMapper.selectReportDetail(anotherDay);
+                JSONObject json = new JSONObject();
+                json.put("now", nowReportList);
+                json.put("yesterday", yesterdayReportList);
+                reportList.add(json);
+
+            } else if (type == 2) { //昨日分时列表
+                reportList = reportMapper.selectReportDetail(anotherDay);
+
+            } else if (type == 3) {// 近七天分天列表
+
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
+                reportList = reportMapper.selectDayDetailByDate(anotherDay, endDate);
+
+            } else if (type == 4) { // 近十五天明细
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
+                reportList = reportMapper.selectDayDetailByDate(anotherDay, endDate);
+
+            } else if (type == 5) { // 近1个月明细
+                String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
+                reportList = reportMapper.selectDayDetailByDate(anotherDay, endDate);
+
+            } else if (type == 6) { // 近三个月明细
+                String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -3);
+                reportList = reportMapper.selectDayDetailByDate(anotherDay, endDate);
+
+            } else if (type == 7) { // 近半年明细
+                String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -6);
+                reportList = reportMapper.selectDayDetailByMonth(anotherDay, endDate);
+
+            } else if (type == 8) {// 所有数据按月明细
+                reportList = reportMapper.selectAllDayDetailByMonth();
+
+            } else if (type == 9) { // 自定义查询区间
+                String startDate = requestJson.getString("startDate");
+                String endDate = requestJson.getString("endDate");
+                reportList = reportMapper.selectDayDetailByDate(startDate, endDate);
+
+            } else if (type == 10) {
+                String sign = requestJson.getString("sign");
+                String bigDate = requestJson.getString("bigDate");
+                String smallDate = requestJson.getString("smallDate");
+                Map<String, Object> dateMap = new HashMap<>();
+                if ("month".equals(sign)) {
+                    dateMap = DateUtils.compare_date("yyyy-MM", bigDate, smallDate);
+                } else if ("day".equals(sign)) {
+                    dateMap = DateUtils.compare_date("yyyy-MM-dd", bigDate, smallDate);
+                }
+                String comparedDate = (String) dateMap.get("bigDate");
+                String beComparedDate = (String) dateMap.get("smallDate");
+                JSONObject detailJson = new JSONObject();
+                if ("month".equals(sign)) {
+                    List<JSONObject> comparedArr = reportMapper.selectDayDetailsByMonth(beComparedDate);   // 被除数数据
+                    detailJson.put("beStatDate", beComparedDate);
+                    detailJson.put("beComparedDetail", comparedArr);
+                    List<JSONObject> beComparedArr = reportMapper.selectDayDetailsByMonth(comparedDate);   // 除数数据
+                    detailJson.put("statDate", comparedDate);
+                    detailJson.put("comparedDetail", beComparedArr);
+
+                } else if ("day".equals(sign)) {
+                    List<JSONObject> comparedArr = reportMapper.selectHourlyDetailsByDate(comparedDate);// 除数数据
+                    detailJson.put("beStatDate", beComparedDate);
+                    detailJson.put("beComparedDetail", comparedArr);
+                    List<JSONObject> beComparedArr = reportMapper.selectHourlyDetailsByDate(beComparedDate);// 被除数数据
+                    detailJson.put("statDate", comparedDate);
+                    detailJson.put("comparedDetail", beComparedArr);
+
+                }
+                reportList.add(detailJson);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+
+        System.err.println(reportList);
+        return reportList;
+    }
 }
 }

+ 22 - 8
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceUserOrientationTemplate.java

@@ -245,6 +245,8 @@ public class ByteDanceUserOrientationTemplate {
 
 
     private String adTagStr;
     private String adTagStr;
 
 
+    private String deviceType;
+
     /**
     /**
      * status
      * status
      */
      */
@@ -266,6 +268,10 @@ public class ByteDanceUserOrientationTemplate {
     }
     }
 
 
     public ByteDanceUserOrientationTemplate(String userId, JSONObject template) {
     public ByteDanceUserOrientationTemplate(String userId, JSONObject template) {
+        Long id = template.getLong("id");
+        if (null != id && id != 0) {
+            this.id = id;
+        }
         this.userId = userId;
         this.userId = userId;
         String name = template.getString("name");
         String name = template.getString("name");
         if (null != name && !name.equals("")) {
         if (null != name && !name.equals("")) {
@@ -284,6 +290,14 @@ public class ByteDanceUserOrientationTemplate {
         if (null != ageRange) {
         if (null != ageRange) {
             this.age = ageRange.toJSONString();
             this.age = ageRange.toJSONString();
         }
         }
+        String deviceType = template.getString("deviceType");
+        if (null != deviceType && !deviceType.trim().equals("")) {
+            this.deviceType = deviceType;
+        }
+        String superiorPopularityType = template.getString("superiorPopularityType");
+        if (null != superiorPopularityType && !"".equals(superiorPopularityType.trim())) {
+            this.superiorPopularityType = superiorPopularityType;
+        }
         //兴趣定向类别
         //兴趣定向类别
         String intrestType = template.getString("intrestType");
         String intrestType = template.getString("intrestType");
         if (null != intrestType && !intrestType.equals("")) {
         if (null != intrestType && !intrestType.equals("")) {
@@ -301,8 +315,8 @@ public class ByteDanceUserOrientationTemplate {
                     categoryList.forEach(category -> {
                     categoryList.forEach(category -> {
                         JSONObject categoryObject = JSONObject.parseObject(JSONObject.toJSONString(category));
                         JSONObject categoryObject = JSONObject.parseObject(JSONObject.toJSONString(category));
                         adTagStr.add(categoryObject);
                         adTagStr.add(categoryObject);
-                        Long id = categoryObject.getLong("value");
-                        tags.add(id);
+                        Long tagId = categoryObject.getLong("value");
+                        tags.add(tagId);
                     });
                     });
                 }
                 }
                 this.adTag = tags.toJSONString();
                 this.adTag = tags.toJSONString();
@@ -347,8 +361,8 @@ public class ByteDanceUserOrientationTemplate {
             cityList.forEach(city -> {
             cityList.forEach(city -> {
                 JSONObject cityObject = JSONObject.parseObject(JSONObject.toJSONString(city));
                 JSONObject cityObject = JSONObject.parseObject(JSONObject.toJSONString(city));
                 cityStr.add(cityObject);
                 cityStr.add(cityObject);
-                Long id = cityObject.getLong("value");
-                cityArray.add(id);
+                Long cityId = cityObject.getLong("value");
+                cityArray.add(cityId);
             });
             });
         }
         }
         this.city = cityArray.toJSONString();
         this.city = cityArray.toJSONString();
@@ -361,8 +375,8 @@ public class ByteDanceUserOrientationTemplate {
             areaList.forEach(area -> {
             areaList.forEach(area -> {
                 JSONObject areaObject = JSONObject.parseObject(JSONObject.toJSONString(area));
                 JSONObject areaObject = JSONObject.parseObject(JSONObject.toJSONString(area));
                 areaStr.add(areaObject);
                 areaStr.add(areaObject);
-                Long id = areaObject.getLong("value");
-                areaArray.add(id);
+                Long areaId = areaObject.getLong("value");
+                areaArray.add(areaId);
             });
             });
         }
         }
         this.district = areaArray.toJSONString();
         this.district = areaArray.toJSONString();
@@ -374,8 +388,8 @@ public class ByteDanceUserOrientationTemplate {
         if (null != intrestTagList && intrestTagList.size() > 0) {
         if (null != intrestTagList && intrestTagList.size() > 0) {
             intrestTagList.forEach(intrestCategory -> {
             intrestTagList.forEach(intrestCategory -> {
                 JSONObject intrestCategoryObject = JSONObject.parseObject(JSONObject.toJSONString(intrestCategory));
                 JSONObject intrestCategoryObject = JSONObject.parseObject(JSONObject.toJSONString(intrestCategory));
-                Long id = intrestCategoryObject.getLong("value");
-                intrestTagArray.add(id);
+                Long intrestId = intrestCategoryObject.getLong("value");
+                intrestTagArray.add(intrestId);
             });
             });
         }
         }
         this.interestTags = areaArray.toJSONString();
         this.interestTags = areaArray.toJSONString();

+ 2 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/service/IByteDanceAdvertiserDataService.java

@@ -45,4 +45,6 @@ public interface IByteDanceAdvertiserDataService {
     JSONObject setUserOrentationData(JSONObject data, ByteDanceUserOrientationTemplate template);
     JSONObject setUserOrentationData(JSONObject data, ByteDanceUserOrientationTemplate template);
 
 
     Map<String, Object> getAdvertiserCampaignList(String accountId);
     Map<String, Object> getAdvertiserCampaignList(String accountId);
+
+    Map<String, Object> flowPackageGet(String accountId);
 }
 }

+ 86 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -1,5 +1,7 @@
 package cn.com.ctop.toutiao.service.impl;
 package cn.com.ctop.toutiao.service.impl;
 
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
@@ -11,8 +13,6 @@ import cn.com.ctop.toutiao.service.IByteDanceAdvertiserDataService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
@@ -632,6 +632,42 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         //根据adId获取公告计划信息
         //根据adId获取公告计划信息
         ByteDanceAdvertisePlan advertisePlan = advertisePlanService.getById(adId);
         ByteDanceAdvertisePlan advertisePlan = advertisePlanService.getById(adId);
         data.put("modify_time", advertisePlan.getModifyTime());
         data.put("modify_time", advertisePlan.getModifyTime());
+        Integer deliveryType = requestJson.getInteger("deviceType");
+        if (null != deliveryType && deliveryType == 2) {
+            //穿山甲
+            //精选流量包类型
+            String superiorPopularityType = template.getSuperiorPopularityType();
+            if (null != superiorPopularityType && "ZDY".equals(superiorPopularityType)) {
+                JSONArray flowPackage = requestJson.getJSONArray("flowPackage");
+                if (null != flowPackage && flowPackage.size() > 0) {
+                    JSONArray getFlowPackage = new JSONArray();
+                    for (int i = 0; i < flowPackage.size(); i++) {
+                        String flowPackageString = flowPackage.getString(i);
+                        getFlowPackage.add(Long.parseLong(flowPackageString));
+                    }
+                    data.put("flow_package", getFlowPackage);
+                }
+                JSONArray excludeFlowPackage = requestJson.getJSONArray("excludeFlowPackage");
+                if (null != excludeFlowPackage && excludeFlowPackage.size() > 0) {
+                    JSONArray getExcludeFlowPackage = new JSONArray();
+                    for (int i = 0; i < excludeFlowPackage.size(); i++) {
+                        String excludeFlowPackageString = excludeFlowPackage.getString(i);
+                        getExcludeFlowPackage.add(Long.parseLong(excludeFlowPackageString));
+                    }
+                    data.put("exclude_flow_package", getExcludeFlowPackage);
+                }
+            } else {
+                data.put("superior_popularity_type", superiorPopularityType);
+            }
+            //设备类型
+            String deviceType = template.getDeviceType();
+            if (null != deviceType && !"".equals(deviceType) && !"NONE".equals(deviceType)) {
+                JSONArray typeArray = new JSONArray();
+                typeArray.add(deviceType);
+                data.put("device_type", typeArray);
+            }
+        }
+
         JSONArray retargetingTagsExclude = requestJson.getJSONArray("retargetingTagsExclude");
         JSONArray retargetingTagsExclude = requestJson.getJSONArray("retargetingTagsExclude");
         JSONArray retargetingTagsInclude = requestJson.getJSONArray("retargetingTagsInclude");
         JSONArray retargetingTagsInclude = requestJson.getJSONArray("retargetingTagsInclude");
         if (null != retargetingTagsExclude && retargetingTagsExclude.size() > 0) {
         if (null != retargetingTagsExclude && retargetingTagsExclude.size() > 0) {
@@ -805,6 +841,54 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         return resultMap;
         return resultMap;
     }
     }
 
 
+    /**
+     * 获取流量包数据接口
+     *
+     * @param accountId
+     * @return
+     */
+    @Override
+    public Map<String, Object> flowPackageGet(String accountId) {
+        JSONObject jsonObject = flowPackageGetJSONObject(accountId);
+        JSONObject result = new JSONObject();
+        Integer code = jsonObject.getInteger("code");
+        String message = jsonObject.getString("message");
+        result.put("code", code);
+        result.put("message", message);
+        if (null == code || code != 0) {
+            result.put("success", false);
+            return result;
+        }
+        JSONArray packageList = jsonObject.getJSONObject("data").getJSONArray("list");
+        if (null != packageList && packageList.size() > 0) {
+            JSONArray packageArray = new JSONArray();
+            for (int i = 0; i < packageList.size(); i++) {
+                JSONObject packageObject = packageList.getJSONObject(i);
+                packageObject.remove("rit");
+                String status = packageObject.getString("status");
+                if (null != status && status.equals("FLOW_PACKAGE_ENABLE")) {
+                    packageArray.add(packageObject);
+                }
+            }
+            result.put("data", packageArray);
+        }
+        result.put("success", true);
+        return result;
+    }
+
+    public JSONObject flowPackageGetJSONObject(String accountId) {
+        CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
+        // 请求地址
+        String url = "https://ad.toutiao.com/open_api/2/tools/union/flow_package/get/";
+        // 请求参数
+        JSONObject params = new JSONObject();
+        params.put("advertiser_id", token.getAccountId());
+        params.put("page", 1);
+        params.put("page_size", 100);
+        JSONObject resultObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, params);
+        return resultObject;
+    }
+
 
 
     private void getAdvertiserCreativeByPageNumber(String accountId, Integer pageNumber, String ids) {
     private void getAdvertiserCreativeByPageNumber(String accountId, Integer pageNumber, String ids) {
         CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
         CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);