Browse Source

adq对接

yumeng 1 week ago
parent
commit
fbe0b56238
22 changed files with 2490 additions and 239 deletions
  1. 24 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/config/DashboardAsyncConfig.java
  2. 121 32
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/controller/ReportController.java
  3. 15 1
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/vo/KuaiShouOperateGroupVo.java
  4. 67 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/AdqAdvertiserReportMapper.java
  5. 14 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/BytedanceAccountReportDailyDwMapper.java
  6. 14 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/KuaishouAccountReportDailyDwMapper.java
  7. 8 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/MaterialStareMapper.java
  8. 748 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/AdqAdvertiserReportMapper.xml
  9. 264 35
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/BytedanceAccountReportDailyDwMapper.xml
  10. 259 35
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/KuaishouAccountReportDailyDwMapper.xml
  11. 115 19
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/MaterialStareMapper.xml
  12. 19 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/IAdqAdvertiserReportService.java
  13. 416 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/AdqAdvertiserReportServiceImpl.java
  14. 91 24
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/BytedanceAccountReportDailyDwServiceImpl.java
  15. 88 24
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/KuaishouAccountReportDailyDwServiceImpl.java
  16. 49 61
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/SafeTiFlashInterceptor.java
  17. 49 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/support/DashboardLocalCacheService.java
  18. 94 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/support/DashboardQuerySupport.java
  19. 28 0
      jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/support/DashboardStartupWarmup.java
  20. 2 5
      jeecg-boot-material-view/src/main/resources/application-dev.yml
  21. 2 2
      jeecg-boot-material-view/src/main/resources/application-prod.yml
  22. 3 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java

+ 24 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/config/DashboardAsyncConfig.java

@@ -0,0 +1,24 @@
+package org.jeecg.ctop.material.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+
+@Configuration
+public class DashboardAsyncConfig {
+
+    @Bean("dashboardSummaryExecutor")
+    public Executor dashboardSummaryExecutor() {
+        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+        executor.setCorePoolSize(3);
+        executor.setMaxPoolSize(3);
+        executor.setQueueCapacity(16);
+        executor.setThreadNamePrefix("dashboard-summary-");
+        executor.setWaitForTasksToCompleteOnShutdown(true);
+        executor.setAwaitTerminationSeconds(10);
+        executor.initialize();
+        return executor;
+    }
+}

+ 121 - 32
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/controller/ReportController.java

@@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.ctop.material.service.IAdqAdvertiserReportService;
 import org.jeecg.ctop.material.service.IBytedanceAccountReportDailyDwService;
 import org.jeecg.ctop.material.service.IBytedanceAccountReportDailyDwService;
 import org.jeecg.ctop.material.service.IKuaishouAccountReportDailyDwService;
 import org.jeecg.ctop.material.service.IKuaishouAccountReportDailyDwService;
+import org.jeecg.ctop.material.service.support.DashboardLocalCacheService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -14,8 +16,12 @@ import org.springframework.web.bind.annotation.RestController;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.util.Date;
 import java.util.Date;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executor;
+import java.util.function.Supplier;
 
 
 /**
 /**
  * 汇总数据
  * 汇总数据
@@ -25,25 +31,46 @@ import java.util.Map;
 @Slf4j
 @Slf4j
 public class ReportController {
 public class ReportController {
 
 
+    private static final long REALTIME_CACHE_TTL = 30 * 1000L;
+    private static final long HISTORY_CACHE_TTL = 5 * 60 * 1000L;
+
     @Autowired
     @Autowired
     private IKuaishouAccountReportDailyDwService kuaishouReportService;
     private IKuaishouAccountReportDailyDwService kuaishouReportService;
 
 
     @Resource
     @Resource
     private IBytedanceAccountReportDailyDwService bytedanceReportService;
     private IBytedanceAccountReportDailyDwService bytedanceReportService;
 
 
+    @Resource
+    private IAdqAdvertiserReportService adqAdvertiserReportService;
+
+    @Resource
+    private DashboardLocalCacheService dashboardLocalCacheService;
+
+    @Resource(name = "dashboardSummaryExecutor")
+    private Executor dashboardSummaryExecutor;
+
 
 
     /**
     /**
      * 获取快手&&头条当日消耗、自然周同比、日环比
      * 获取快手&&头条当日消耗、自然周同比、日环比
      */
      */
     @GetMapping("/getTotalCharge")
     @GetMapping("/getTotalCharge")
     public Result<Object> getTotalCharge() {
     public Result<Object> getTotalCharge() {
-        log.info("----------------开始请求-----------------");
         try {
         try {
+            String today = DateUtils.formatDate(new Date());
             Integer nowHour = DateUtils.getNowHour();
             Integer nowHour = DateUtils.getNowHour();
+            String cacheKey = "dashboard:summary:getTotalCharge:" + today + ":" + nowHour;
+            return getCachedResult(cacheKey, REALTIME_CACHE_TTL, () -> loadTotalCharge(today, nowHour));
+        } catch (Exception e) {
+            log.error("getTotalCharge error", e);
+        }
+        return Result.error("查询失败");
+    }
+
+    private Result<Object> loadTotalCharge(String today, Integer nowHour) {
+        log.info("----------------开始请求-----------------");
+        try {
             //本周一
             //本周一
             String monday = DateUtils.getdateFromWeek(1);
             String monday = DateUtils.getdateFromWeek(1);
-            //当天日期
-            String today = DateUtils.formatDate(new Date());
             //昨天日期
             //昨天日期
             String yesterday = DateUtils.getLastDay(today, 1);
             String yesterday = DateUtils.getLastDay(today, 1);
             //上周一日期
             //上周一日期
@@ -57,18 +84,43 @@ public class ReportController {
             paramsMap.put("today", DateUtils.getDateInteger(today));
             paramsMap.put("today", DateUtils.getDateInteger(today));
             paramsMap.put("yesterday", DateUtils.getDateInteger(yesterday));
             paramsMap.put("yesterday", DateUtils.getDateInteger(yesterday));
             paramsMap.put("hour", nowHour);
             paramsMap.put("hour", nowHour);
-            JSONObject kuaishou = kuaishouReportService.getTotalCharge(paramsMap);
-            JSONObject bytedance = bytedanceReportService.getTotalCharge(paramsMap);
+
+            CompletableFuture<JSONObject> kuaishouFuture = querySummaryAsync(
+                    "kuaishou",
+                    () -> kuaishouReportService.getTotalCharge(Collections.unmodifiableMap(new HashMap<>(paramsMap)))
+            );
+            CompletableFuture<JSONObject> bytedanceFuture = querySummaryAsync(
+                    "bytedance",
+                    () -> bytedanceReportService.getTotalCharge(Collections.unmodifiableMap(new HashMap<>(paramsMap)))
+            );
+            CompletableFuture<JSONObject> tencentFuture = querySummaryAsync(
+                    "tencent",
+                    () -> adqAdvertiserReportService.getTotalCharge(Collections.unmodifiableMap(new HashMap<>(paramsMap)))
+            );
+            CompletableFuture.allOf(kuaishouFuture, bytedanceFuture, tencentFuture).join();
+            JSONObject kuaishou = kuaishouFuture.join();
+            JSONObject bytedance = bytedanceFuture.join();
+            JSONObject tencent = tencentFuture.join();
             JSONObject data = new JSONObject();
             JSONObject data = new JSONObject();
             data.put("kuaishou", kuaishou);
             data.put("kuaishou", kuaishou);
             data.put("bytedance", bytedance);
             data.put("bytedance", bytedance);
+            data.put("tencent", tencent);
             log.info("----------------请求结束-----------------");
             log.info("----------------请求结束-----------------");
-
             return Result.OK(data);
             return Result.OK(data);
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new RuntimeException(e);
         }
         }
-        return Result.error("查询失败");
+    }
+
+    private CompletableFuture<JSONObject> querySummaryAsync(String media, Supplier<JSONObject> supplier) {
+        return CompletableFuture.supplyAsync(() -> {
+            long start = System.currentTimeMillis();
+            try {
+                return supplier.get();
+            } finally {
+                log.info("getTotalCharge {} finished in {} ms", media, System.currentTimeMillis() - start);
+            }
+        }, dashboardSummaryExecutor);
     }
     }
 
 
 
 
@@ -82,15 +134,20 @@ public class ReportController {
     @GetMapping("/getTrendCharge")
     @GetMapping("/getTrendCharge")
     public Result<Object> getTrendCharge(String type, String mediaId, Long projectId, String startTime, String endTime) {
     public Result<Object> getTrendCharge(String type, String mediaId, Long projectId, String startTime, String endTime) {
         try {
         try {
-            JSONObject data = null;
-            if ("1".equals(mediaId)) {
-                data = bytedanceReportService.getTrendCharge(type, projectId, startTime, endTime);
-            } else {
-                data = kuaishouReportService.getTrendCharge(type, projectId, startTime, endTime);
-            }
-            return Result.OK(data);
+            String cacheKey = "dashboard:summary:getTrendCharge:" + safe(mediaId) + ":" + safe(type) + ":" + safe(projectId) + ":" + safe(startTime) + ":" + safe(endTime);
+            return getCachedResult(cacheKey, resolveCacheTtl(startTime, endTime), () -> {
+                JSONObject data;
+                if ("1".equals(mediaId)) {
+                    data = bytedanceReportService.getTrendCharge(type, projectId, startTime, endTime);
+                } else if ("16".equals(mediaId)) {
+                    data = adqAdvertiserReportService.getTrendCharge(type, projectId, startTime, endTime);
+                } else {
+                    data = kuaishouReportService.getTrendCharge(type, projectId, startTime, endTime);
+                }
+                return Result.OK(data);
+            });
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error("getTrendCharge error", e);
         }
         }
         return Result.error("查询失败");
         return Result.error("查询失败");
     }
     }
@@ -105,13 +162,21 @@ public class ReportController {
     @GetMapping("/getProjectReport")
     @GetMapping("/getProjectReport")
     public Result<Object> getProjectReport(String mediaId, String category, String sortCode, String order, Long projectId, String startTime, String endTime, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
     public Result<Object> getProjectReport(String mediaId, String category, String sortCode, String order, Long projectId, String startTime, String endTime, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
         try {
         try {
-            if ("1".equals(mediaId)) {
-                return bytedanceReportService.getProjectReport(category, projectId, startTime, endTime, sortCode, order, pageSize, pageNo);
-            } else {
-                return kuaishouReportService.getProjectReport(category, projectId, startTime, endTime, sortCode, order, pageSize, pageNo);
-            }
+            String cacheKey = "dashboard:summary:getProjectReport:" + safe(mediaId) + ":" + safe(category) + ":" + safe(sortCode) + ":" + safe(order) + ":" + safe(projectId) + ":" + safe(startTime) + ":" + safe(endTime) + ":" + safe(pageNo) + ":" + safe(pageSize);
+            return getCachedResult(cacheKey, resolveCacheTtl(startTime, endTime), () -> {
+                try {
+                    if ("1".equals(mediaId)) {
+                        return bytedanceReportService.getProjectReport(category, projectId, startTime, endTime, sortCode, order, pageSize, pageNo);
+                    } else if ("16".equals(mediaId)) {
+                        return adqAdvertiserReportService.getProjectReport(category, projectId, startTime, endTime, sortCode, order, pageSize, pageNo);
+                    }
+                    return kuaishouReportService.getProjectReport(category, projectId, startTime, endTime, sortCode, order, pageSize, pageNo);
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            });
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error("getProjectReport error", e);
         }
         }
         return Result.error("查询失败");
         return Result.error("查询失败");
     }
     }
@@ -126,13 +191,17 @@ public class ReportController {
     @GetMapping("/getOperateInfo")
     @GetMapping("/getOperateInfo")
     public Result<Object> getOperateInfo(String mediaId, String category, String sortCode, String order, String startTime, String endTime, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
     public Result<Object> getOperateInfo(String mediaId, String category, String sortCode, String order, String startTime, String endTime, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
         try {
         try {
-            if ("1".equals(mediaId)) {
-                return bytedanceReportService.getOperateInfo(startTime, endTime);
-            } else {
+            String cacheKey = "dashboard:summary:getOperateInfo:" + safe(mediaId) + ":" + safe(startTime) + ":" + safe(endTime);
+            return getCachedResult(cacheKey, resolveCacheTtl(startTime, endTime), () -> {
+                if ("1".equals(mediaId)) {
+                    return bytedanceReportService.getOperateInfo(startTime, endTime);
+                } else if ("16".equals(mediaId)) {
+                    return adqAdvertiserReportService.getOperateInfo(startTime, endTime);
+                }
                 return kuaishouReportService.getOperateInfo(startTime, endTime);
                 return kuaishouReportService.getOperateInfo(startTime, endTime);
-            }
+            });
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error("getOperateInfo error", e);
         }
         }
         return Result.error("查询失败");
         return Result.error("查询失败");
     }
     }
@@ -148,15 +217,35 @@ public class ReportController {
     @GetMapping("/getOperateGroupInfo")
     @GetMapping("/getOperateGroupInfo")
     public Result<Object> getOperateGroupInfo(String mediaId, String startTime, String endTime) {
     public Result<Object> getOperateGroupInfo(String mediaId, String startTime, String endTime) {
         try {
         try {
-            if ("1".equals(mediaId)) {
-                return bytedanceReportService.getOperateGroupInfo(startTime, endTime);
-            } else {
+            String cacheKey = "dashboard:summary:getOperateGroupInfo:" + safe(mediaId) + ":" + safe(startTime) + ":" + safe(endTime);
+            return getCachedResult(cacheKey, resolveCacheTtl(startTime, endTime), () -> {
+                if ("1".equals(mediaId)) {
+                    return bytedanceReportService.getOperateGroupInfo(startTime, endTime);
+                } else if ("16".equals(mediaId)) {
+                    return adqAdvertiserReportService.getOperateGroupInfo(startTime, endTime);
+                }
                 return kuaishouReportService.getOperateGroupInfo(startTime, endTime);
                 return kuaishouReportService.getOperateGroupInfo(startTime, endTime);
-            }
+            });
         } catch (Exception e) {
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error("getOperateGroupInfo error", e);
         }
         }
         return Result.error("查询失败");
         return Result.error("查询失败");
     }
     }
 
 
+    private Result<Object> getCachedResult(String cacheKey, long ttlMillis, Supplier<Result<Object>> loader) {
+        return dashboardLocalCacheService.getIfCacheable(cacheKey, ttlMillis, loader, result -> result != null && result.isSuccess());
+    }
+
+    private long resolveCacheTtl(String startTime, String endTime) {
+        String today = DateUtils.formatDate(new Date());
+        if (today.equals(startTime) && today.equals(endTime)) {
+            return REALTIME_CACHE_TTL;
+        }
+        return HISTORY_CACHE_TTL;
+    }
+
+    private String safe(Object value) {
+        return value == null ? "null" : String.valueOf(value);
+    }
+
 }
 }

+ 15 - 1
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/vo/KuaiShouOperateGroupVo.java

@@ -68,7 +68,21 @@ public class KuaiShouOperateGroupVo implements Serializable {
         this.realname = realname;
         this.realname = realname;
     }
     }
 
 
+    public String getRealname() {
+        return realname;
+    }
+
+    public void setRealname(String realname) {
+        this.realname = realname;
+    }
 
 
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
 
 
 
 
-}
+}

+ 67 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/AdqAdvertiserReportMapper.java

@@ -0,0 +1,67 @@
+package org.jeecg.ctop.material.mapper;
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public interface AdqAdvertiserReportMapper {
+
+    JSONObject getTotalCharge(Map<String, Object> paramsMap);
+
+    JSONObject getTotalChargeHourly(Map<String, Object> paramsMap);
+
+    JSONObject getTotalChargeDaily(Map<String, Object> paramsMap);
+
+    Long getYesterdayUploadNewMaterialCount(Map<String, Object> paramsMap);
+
+    List<JSONObject> getHourCost(@Param("projectId") Long projectId, @Param("startTime") Integer startTime);
+
+    List<JSONObject> getDataCost(@Param("projectId") Long projectId, @Param("startTime") Integer startTime, @Param("endTime") Integer endTime);
+
+    List<JSONObject> getProjectTodayBase(@Param("projectId") Long projectId, @Param("startTime") Integer startTime);
+
+    List<JSONObject> getProjectMetaByIds(@Param("projectIds") List<Long> projectIds);
+
+    List<JSONObject> getProjectMaterialCountByDayAndIds(@Param("statDate") Integer statDate, @Param("projectIds") List<Long> projectIds);
+
+    List<JSONObject> getProjectPrevHourlyCostByDayAndIds(@Param("statDate") Integer statDate, @Param("hour") Integer hour, @Param("projectIds") List<Long> projectIds);
+
+    List<JSONObject> getProjectAccountOperatorCountByCurrentHourlyAndIds(@Param("statDate") Integer statDate, @Param("hour") Integer hour, @Param("projectIds") List<Long> projectIds);
+
+    List<JSONObject> getProjectAccountOperatorCountByDayAndIds(@Param("statDate") Integer statDate, @Param("projectIds") List<Long> projectIds);
+
+    List<JSONObject> getProjectToDayReport(@Param("category") String category, @Param("projectId") Long projectId, @Param("startTime") Integer startTime, @Param("hour") Integer hour, @Param("sortCode") String sortCode, @Param("order") String order);
+
+    List<JSONObject> getProjectMoreDaysReport(@Param("projectId") Long projectId, @Param("startTime") Integer startTime, @Param("endTime") Integer endTime, @Param("lastStart") Integer lastStart, @Param("lastEnd") Integer lastEnd, @Param("sortCode") String sortCode, @Param("order") String order);
+
+    List<JSONObject> getProjectNoByDays(@Param("startTime") Integer startTime, @Param("endTime") Integer endTime);
+
+    List<JSONObject> getAdvertiserNoByDays(@Param("startTime") Integer startTime, @Param("endTime") Integer endTime);
+
+    List<JSONObject> getUnitNoByHours(@Param("startTime") Integer startTime);
+
+    List<JSONObject> getUnitNoByDays(@Param("startTime") Integer startTime, @Param("endTime") Integer endTime);
+
+    List<JSONObject> getAdqOperateInfoHourly(@Param("hour") Integer hour, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart, @Param("list") List<String> operatorUserIds);
+
+    List<JSONObject> getAdqOperateInfo(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart, @Param("list") List<String> operatorUserIds);
+
+    JSONObject getAdqOperateGroupInfoHourly(@Param("hour") Integer hour, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart, @Param("list") Set<String> operatorUserIds);
+
+    JSONObject getAdqOperateGroupInfo(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart, @Param("list") Set<String> operatorUserIds);
+
+    List<JSONObject> getOperateGroupCurrentHourlyByUsers(@Param("hour") Integer hour, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("userIds") List<String> userIds);
+
+    List<JSONObject> getOperateGroupCurrentByUsers(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("userIds") List<String> userIds);
+
+    List<JSONObject> getOperateGroupPreviousHourlyByUsers(@Param("hour") Integer hour, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("userIds") List<String> userIds);
+
+    List<JSONObject> getOperateGroupPreviousByUsers(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("userIds") List<String> userIds);
+
+    List<JSONObject> getAdqOperateGroupInfoHourlyBatch(@Param("managerIds") List<String> managerIds, @Param("hour") Integer hour, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart);
+
+    List<JSONObject> getAdqOperateGroupInfoBatch(@Param("managerIds") List<String> managerIds, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart);
+}

+ 14 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/BytedanceAccountReportDailyDwMapper.java

@@ -46,4 +46,18 @@ public interface BytedanceAccountReportDailyDwMapper {
 
 
     JSONObject getToutiaoOperateGroupInfo(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart, @Param("list") Set<String> operatorUserIds);
     JSONObject getToutiaoOperateGroupInfo(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart, @Param("list") Set<String> operatorUserIds);
 
 
+    List<JSONObject> getOperateGroupCurrentHourlyByUsers(@Param("hour") Integer hour, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("userIds") List<String> userIds);
+
+    List<JSONObject> getOperateGroupCurrentByUsers(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("userIds") List<String> userIds);
+
+    List<JSONObject> getOperateGroupPreviousHourlyByUsers(@Param("hour") Integer hour, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("userIds") List<String> userIds);
+
+    List<JSONObject> getOperateGroupPreviousByUsers(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("userIds") List<String> userIds);
+
+    List<JSONObject> getOperateGroupBaseByUsers(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("userIds") List<String> userIds);
+
+    List<JSONObject> getToutiaoOperateGroupInfoHourlyBatch(@Param("managerIds") List<String> managerIds, @Param("hour") Integer hour, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart);
+
+    List<JSONObject> getToutiaoOperateGroupInfoBatch(@Param("managerIds") List<String> managerIds, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart);
+
 }
 }

+ 14 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/KuaishouAccountReportDailyDwMapper.java

@@ -42,4 +42,18 @@ public interface KuaishouAccountReportDailyDwMapper {
     JSONObject getKuaishouOperateGroupInfoHourly(@Param("hour") Integer hour, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart, @Param("list") Set<String> operatorUserIds);
     JSONObject getKuaishouOperateGroupInfoHourly(@Param("hour") Integer hour, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart, @Param("list") Set<String> operatorUserIds);
 
 
     JSONObject getKuaishouOperateGroupInfo(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart, @Param("list") Set<String> operatorUserIds);
     JSONObject getKuaishouOperateGroupInfo(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart, @Param("list") Set<String> operatorUserIds);
+
+    List<JSONObject> getOperateGroupCurrentHourlyByUsers(@Param("hour") Integer hour, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("userIds") List<String> userIds);
+
+    List<JSONObject> getOperateGroupCurrentByUsers(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("userIds") List<String> userIds);
+
+    List<JSONObject> getOperateGroupPreviousHourlyByUsers(@Param("hour") Integer hour, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("userIds") List<String> userIds);
+
+    List<JSONObject> getOperateGroupPreviousByUsers(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("userIds") List<String> userIds);
+
+    List<JSONObject> getOperateGroupBaseByUsers(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("userIds") List<String> userIds);
+
+    List<JSONObject> getKuaishouOperateGroupInfoHourlyBatch(@Param("managerIds") List<String> managerIds, @Param("hour") Integer hour, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart);
+
+    List<JSONObject> getKuaishouOperateGroupInfoBatch(@Param("managerIds") List<String> managerIds, @Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("lastTimeEnd") Long lastTimeEnd, @Param("lastTimeStart") Long lastTimeStart);
 }
 }

+ 8 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/MaterialStareMapper.java

@@ -162,6 +162,14 @@ public interface MaterialStareMapper {
 
 
     Set<String> queryToutiaoOperateTeamMember(@Param("userId") String userId,@Param("startDate") Long startDate, @Param("endDate") Long endDate);
     Set<String> queryToutiaoOperateTeamMember(@Param("userId") String userId,@Param("startDate") Long startDate, @Param("endDate") Long endDate);
 
 
+    Set<String> queryAdqOperateTeamMember(@Param("userId") String userId,@Param("startDate") Long startDate, @Param("endDate") Long endDate);
+
+    List<JSONObject> queryKuaishouOperateTeamMemberBatch(@Param("managerIds") List<String> managerIds, @Param("startDate") Long startDate, @Param("endDate") Long endDate);
+
+    List<JSONObject> queryToutiaoOperateTeamMemberBatch(@Param("managerIds") List<String> managerIds, @Param("startDate") Long startDate, @Param("endDate") Long endDate);
+
+    List<JSONObject> queryAdqOperateTeamMemberBatch(@Param("managerIds") List<String> managerIds, @Param("startDate") Long startDate, @Param("endDate") Long endDate);
+
     List<String> getAllOperationByMediaId(@Param("mediaId") String mediaId);
     List<String> getAllOperationByMediaId(@Param("mediaId") String mediaId);
 
 
     List<KuaiShouOperateProjectVo> getBytedanceOperateProjectInfoNew(Map<String, Object> parameterMap);
     List<KuaiShouOperateProjectVo> getBytedanceOperateProjectInfoNew(Map<String, Object> parameterMap);

+ 748 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/AdqAdvertiserReportMapper.xml

@@ -0,0 +1,748 @@
+<?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="org.jeecg.ctop.material.mapper.AdqAdvertiserReportMapper">
+
+    <select id="getTotalCharge" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT hourly.todayCost,
+               hourly.yesterdayCost,
+               daily.thisWeekDailyCost + hourly.thisWeekTodayCost AS 'thisWeekCost',
+               daily.lastWeek1 + hourly.lastWeek2 AS 'lastWeekCost'
+        FROM (
+                 SELECT
+                        IFNULL(SUM(CASE WHEN report.stat_date = #{today} THEN report.cost END), 0.00) AS 'todayCost',
+                        IFNULL(SUM(CASE WHEN report.stat_date = #{yesterday} AND report.stat_hour &lt;= #{hour} THEN report.cost END), 0.00) AS 'yesterdayCost',
+                        IFNULL(SUM(CASE WHEN report.stat_date = #{today} THEN report.cost END), 0.00) AS 'thisWeekTodayCost',
+                        IFNULL(SUM(CASE WHEN report.stat_date = #{lastEndDate} AND report.stat_hour &lt;= #{hour} THEN report.cost END), 0.00) AS 'lastWeek2'
+                 FROM application.adq_advertiser_report_hourly report
+                 WHERE report.stat_date IN (#{today}, #{yesterday}, #{lastEndDate})
+             ) hourly
+                 CROSS JOIN (
+            SELECT IFNULL(SUM(CASE WHEN stat_date >= #{monday} AND stat_date &lt; #{today} THEN cost END), 0.00) AS 'thisWeekDailyCost',
+                   CASE
+                       WHEN #{lastStartDate} - #{lastEndDate} = 0 THEN 0.00
+                       ELSE IFNULL(SUM(CASE
+                                           WHEN stat_date >= #{lastStartDate}
+                                               AND stat_date &lt;= DATE_FORMAT(DATE_SUB(#{lastEndDate}, INTERVAL 1 DAY), '%Y%m%d')
+                                               THEN cost
+                           END), 0.00)
+                       END AS 'lastWeek1'
+            FROM application.adq_advertiser_report_daily
+            WHERE stat_date >= #{lastStartDate}
+              AND stat_date &lt; #{today}
+        ) daily
+    </select>
+
+    <select id="getTotalChargeHourly" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */
+               IFNULL(SUM(CASE WHEN report.stat_date = #{today} THEN report.cost END), 0.00) AS 'todayCost',
+               IFNULL(SUM(CASE WHEN report.stat_date = #{yesterday} AND report.stat_hour &lt;= #{hour} THEN report.cost END), 0.00) AS 'yesterdayCost',
+               IFNULL(SUM(CASE WHEN report.stat_date = #{today} THEN report.cost END), 0.00) AS 'thisWeekTodayCost',
+               IFNULL(SUM(CASE WHEN report.stat_date = #{lastEndDate} AND report.stat_hour &lt;= #{hour} THEN report.cost END), 0.00) AS 'lastWeek2'
+        FROM application.adq_advertiser_report_hourly report
+        WHERE report.stat_date IN (#{today}, #{yesterday}, #{lastEndDate})
+    </select>
+
+    <select id="getTotalChargeDaily" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT IFNULL(SUM(CASE WHEN stat_date >= #{monday} AND stat_date &lt; #{today} THEN cost END), 0.00) AS 'thisWeekDailyCost',
+               CASE
+                   WHEN #{lastStartDate} - #{lastEndDate} = 0 THEN 0.00
+                   ELSE IFNULL(SUM(CASE
+                                       WHEN stat_date >= #{lastStartDate}
+                                           AND stat_date &lt;= DATE_FORMAT(DATE_SUB(#{lastEndDate}, INTERVAL 1 DAY), '%Y%m%d')
+                                           THEN cost
+                       END), 0.00)
+                   END AS 'lastWeek1'
+        FROM application.adq_advertiser_report_daily
+        WHERE stat_date >= #{lastStartDate}
+          AND stat_date &lt; #{today}
+    </select>
+
+    <select id="getYesterdayUploadNewMaterialCount" resultType="Long">
+        SELECT IFNULL(COUNT(DISTINCT material_id), 0)
+        FROM application.adq_material_report_daily_dw
+        WHERE stat_date = #{yesterday}
+          AND project_id IN (
+            SELECT id
+            FROM `jeecg-boot`.ctop_project
+            WHERE media_id = 16
+              AND agent_code IN (1, 2)
+        )
+    </select>
+
+    <select id="getHourCost" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ report.stat_hour AS 'time',
+               IFNULL(SUM(report.cost), 0.00) AS 'cost'
+        FROM application.adq_advertiser_report_hourly report
+        WHERE report.stat_date = #{startTime}
+        <if test="projectId != null and projectId != ''">
+            AND report.project_id = #{projectId}
+        </if>
+        GROUP BY report.stat_hour
+        ORDER BY report.stat_hour
+    </select>
+
+    <select id="getDataCost" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ DATE_FORMAT(report.stat_date, '%Y-%m-%d') AS 'time',
+               IFNULL(SUM(report.cost), 0.00) AS 'cost'
+        FROM application.adq_advertiser_report_hourly report
+        WHERE report.stat_date >= #{startTime}
+          AND report.stat_date &lt;= #{endTime}
+        <if test="projectId != null and projectId != ''">
+            AND report.project_id = #{projectId}
+        </if>
+        GROUP BY report.stat_date
+        ORDER BY report.stat_date
+    </select>
+
+    <select id="getProjectTodayBase" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ report.project_id AS 'projectId',
+               MAX(report.advertiser_name) AS 'companyName',
+               SUM(report.cost) AS 'cost',
+               SUM(report.view_count) AS 'aclick',
+               SUM(report.valid_click_count) AS 'bclick',
+               COUNT(DISTINCT CASE WHEN report.cost > 0 THEN report.account_id END) AS 'accountNum',
+               COUNT(DISTINCT CASE WHEN report.cost > 0 THEN report.user_id END) AS 'operaterNum'
+        FROM application.adq_advertiser_report_hourly report
+        WHERE report.stat_date = #{startTime}
+        <if test="projectId != null and projectId != ''">
+            AND report.project_id = #{projectId}
+        </if>
+        GROUP BY report.project_id
+        HAVING SUM(report.cost) > 0
+    </select>
+
+    <select id="getProjectMetaByIds" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT project.id AS 'projectId',
+               project.project_name AS 'projectName',
+               project.project_name AS 'productName',
+               manager.realname AS 'operater',
+               sale.realname AS 'saler'
+        FROM `jeecg-boot`.ctop_project project
+                 LEFT JOIN `jeecg-boot`.sys_user manager ON project.responsible_id = manager.id
+                 LEFT JOIN `jeecg-boot`.sys_user sale ON project.sale_id = sale.id
+        WHERE project.id IN
+        <foreach collection="projectIds" item="item" separator="," open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="getProjectMaterialCountByDayAndIds" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT material.project_id AS 'projectId',
+               COUNT(DISTINCT material.material_id) AS 'num'
+        FROM application.adq_material_report_daily_dw material
+        WHERE material.stat_date = #{statDate}
+          AND material.project_id IN
+          <foreach collection="projectIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY material.project_id
+    </select>
+
+    <select id="getProjectPrevHourlyCostByDayAndIds" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ report.project_id AS 'projectId',
+               SUM(report.cost) AS 'cost'
+        FROM application.adq_advertiser_report_hourly report
+        WHERE report.stat_date = #{statDate}
+          AND report.stat_hour &lt;= #{hour}
+          AND report.project_id IN
+          <foreach collection="projectIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY report.project_id
+    </select>
+
+    <select id="getProjectAccountOperatorCountByDayAndIds" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT daily.project_id AS 'projectId',
+               COUNT(DISTINCT daily.account_id) AS 'accountNum',
+               COUNT(DISTINCT daily.user_id) AS 'operaterNum'
+        FROM application.adq_advertiser_report_daily daily
+        WHERE daily.stat_date = #{statDate}
+          AND daily.project_id IN
+          <foreach collection="projectIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY daily.project_id
+        HAVING SUM(daily.cost) > 0
+    </select>
+
+    <select id="getProjectAccountOperatorCountByCurrentHourlyAndIds" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ report.project_id AS 'projectId',
+               COUNT(DISTINCT report.account_id) AS 'accountNum',
+               COUNT(DISTINCT report.user_id) AS 'operaterNum'
+        FROM application.adq_advertiser_report_hourly report
+        WHERE report.stat_date = #{statDate}
+          AND report.stat_hour &lt;= #{hour}
+          AND report.cost > 0
+          AND report.project_id IN
+          <foreach collection="projectIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY report.project_id
+    </select>
+
+    <select id="getProjectToDayReport" resultType="com.alibaba.fastjson.JSONObject">
+        WITH active_projects AS (
+            SELECT /*+ READ_FROM_STORAGE(TIKV[t1]) */ t1.project_id AS projectId,
+                   MAX(t1.advertiser_name) AS companyName,
+                   SUM(t1.cost) AS cost,
+                   SUM(t1.view_count) AS aclick,
+                   SUM(t1.valid_click_count) AS bclick
+            FROM application.adq_advertiser_report_hourly t1
+            WHERE t1.stat_date = #{startTime}
+            <if test="projectId != null and projectId != ''">
+                AND t1.project_id = #{projectId}
+            </if>
+            GROUP BY t1.project_id
+            HAVING SUM(t1.cost) > 0
+        )
+        SELECT *
+        FROM (
+                 SELECT ap.projectId AS 'projectId',
+                        t3.project_name AS 'projectName',
+                        t3.project_name AS 'productName',
+                        ap.companyName AS 'companyName',
+                        t5.realname AS 'saler',
+                        t4.realname AS 'operater',
+                        ap.cost AS 'cost',
+                        ap.aclick AS 'aclick',
+                        ap.bclick AS 'bclick',
+                        NULL AS 'num',
+                        CASE
+                            WHEN IFNULL(t7.costs, 0) = 0 THEN '-'
+                            ELSE CONCAT(ROUND((ap.cost - t7.costs) / t7.costs * 100, 2), '%')
+                        END AS 'rio',
+                        CASE
+                            WHEN IFNULL(t7.costs, 0) = 0 THEN NULL
+                            ELSE ROUND((ap.cost - t7.costs) / t7.costs * 100, 2)
+                        END AS 'rioValue',
+                        '-' AS 'ssAd',
+                        '-' AS 'sxhAd',
+                        '-' AS 'lmAd',
+                        '-' AS 'xxlAd',
+                        '-' AS 'jlAd',
+                        '-' AS 'kpAd',
+                        IFNULL(t9.accountNum, 0) AS 'accountNum',
+                        IFNULL(t9.operaterNum, 0) AS 'operaterNum',
+                        NULL AS 'materialUploadMediaNum'
+                 FROM active_projects ap
+                          LEFT JOIN `jeecg-boot`.ctop_project t3 ON ap.projectId = t3.id
+                          LEFT JOIN `jeecg-boot`.sys_user t4 ON t3.responsible_id = t4.id
+                          LEFT JOIN `jeecg-boot`.sys_user t5 ON t3.sale_id = t5.id
+                          LEFT JOIN (
+                     SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ report.project_id,
+                            SUM(report.cost) AS 'costs'
+                     FROM application.adq_advertiser_report_hourly report
+                              INNER JOIN active_projects active ON active.projectId = report.project_id
+                     WHERE report.stat_date = DATE_FORMAT(DATE_SUB(#{startTime}, INTERVAL 1 DAY), '%Y%m%d')
+                       AND report.stat_hour &lt;= #{hour}
+                     GROUP BY report.project_id
+                 ) t7 ON ap.projectId = t7.project_id
+                          LEFT JOIN (
+                     SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ report.project_id,
+                            COUNT(DISTINCT report.account_id) AS 'accountNum',
+                            COUNT(DISTINCT report.user_id) AS 'operaterNum'
+                     FROM application.adq_advertiser_report_hourly report
+                              INNER JOIN active_projects active ON active.projectId = report.project_id
+                     WHERE report.stat_date = #{startTime}
+                       AND report.stat_hour &lt;= #{hour}
+                       AND report.cost > 0
+                     GROUP BY report.project_id
+                 ) t9 ON ap.projectId = t9.project_id
+             ) t
+        <if test="category == 1">
+            WHERE rioValue &lt;= -10
+        </if>
+        ORDER BY ${sortCode} ${order}
+    </select>
+
+    <select id="getProjectMoreDaysReport" resultType="com.alibaba.fastjson.JSONObject">
+        WITH active_projects AS (
+            SELECT t1.project_id AS projectId,
+                   MAX(t1.advertiser_name) AS companyName,
+                   SUM(t1.cost) AS cost,
+                   SUM(t1.view_count) AS aclick,
+                   SUM(t1.valid_click_count) AS bclick
+            FROM application.adq_advertiser_report_daily t1
+            WHERE t1.stat_date >= #{startTime}
+              AND t1.stat_date &lt;= #{endTime}
+            <if test="projectId != null and projectId != ''">
+                AND t1.project_id = #{projectId}
+            </if>
+            GROUP BY t1.project_id
+            HAVING SUM(t1.cost) > 0
+        )
+        SELECT *
+        FROM (
+                 SELECT ap.projectId AS 'projectId',
+                        t3.project_name AS 'projectName',
+                        t3.project_name AS 'productName',
+                        ap.companyName AS 'companyName',
+                        t5.realname AS 'saler',
+                        t4.realname AS 'operater',
+                        ap.cost AS 'cost',
+                        ap.aclick AS 'aclick',
+                        ap.bclick AS 'bclick',
+                        NULL AS 'num',
+                        CASE
+                            WHEN IFNULL(t7.costs, 0) = 0 THEN '-'
+                            ELSE CONCAT(ROUND((ap.cost - t7.costs) / t7.costs * 100, 2), '%')
+                        END AS 'rio',
+                        CASE
+                            WHEN IFNULL(t7.costs, 0) = 0 THEN NULL
+                            ELSE ROUND((ap.cost - t7.costs) / t7.costs * 100, 2)
+                        END AS 'rioValue',
+                        '-' AS 'ssAd',
+                        '-' AS 'sxhAd',
+                        '-' AS 'lmAd',
+                        '-' AS 'xxlAd',
+                        '-' AS 'jlAd',
+                        '-' AS 'kpAd',
+                        IFNULL(t9.accountNum, 0) AS 'accountNum',
+                        IFNULL(t9.operaterNum, 0) AS 'operaterNum',
+                        NULL AS 'materialUploadMediaNum'
+                 FROM active_projects ap
+                          LEFT JOIN `jeecg-boot`.ctop_project t3 ON ap.projectId = t3.id
+                          LEFT JOIN `jeecg-boot`.sys_user t4 ON t3.responsible_id = t4.id
+                          LEFT JOIN `jeecg-boot`.sys_user t5 ON t3.sale_id = t5.id
+                          LEFT JOIN (
+                     SELECT daily.project_id,
+                            SUM(daily.cost) AS 'costs'
+                     FROM application.adq_advertiser_report_daily daily
+                              INNER JOIN active_projects active ON active.projectId = daily.project_id
+                     WHERE daily.stat_date >= #{lastStart}
+                       AND daily.stat_date &lt;= #{lastEnd}
+                     GROUP BY daily.project_id
+                 ) t7 ON ap.projectId = t7.project_id
+                          LEFT JOIN (
+                     SELECT daily.project_id,
+                            COUNT(DISTINCT daily.account_id) AS 'accountNum',
+                            COUNT(DISTINCT daily.user_id) AS 'operaterNum'
+                     FROM application.adq_advertiser_report_daily daily
+                              INNER JOIN active_projects active ON active.projectId = daily.project_id
+                     WHERE daily.stat_date >= #{startTime}
+                       AND daily.stat_date &lt;= #{endTime}
+                     GROUP BY daily.project_id
+                     HAVING SUM(daily.cost) > 0
+                 ) t9 ON ap.projectId = t9.project_id
+             ) t
+        <if test="category == 1">
+            WHERE rioValue &lt;= -10
+        </if>
+        ORDER BY ${sortCode} ${order}
+    </select>
+
+    <select id="getProjectNoByDays" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT stat_date AS 'time', COUNT(1) AS 'count'
+        FROM (
+                 SELECT stat_date, project_id
+                 FROM application.adq_advertiser_report_daily
+                 WHERE stat_date >= #{startTime}
+                   AND stat_date &lt;= #{endTime}
+                 GROUP BY stat_date, project_id
+                 HAVING SUM(cost) >= 10
+             ) t
+        GROUP BY stat_date
+        ORDER BY stat_date
+    </select>
+
+    <select id="getAdvertiserNoByDays" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT stat_date AS 'time', COUNT(1) AS 'count'
+        FROM (
+                 SELECT stat_date, advertiser_name
+                 FROM application.adq_advertiser_report_daily
+                 WHERE stat_date >= #{startTime}
+                   AND stat_date &lt;= #{endTime}
+                 GROUP BY stat_date, advertiser_name
+                 HAVING SUM(cost) >= 10
+             ) t
+        GROUP BY stat_date
+        ORDER BY stat_date
+    </select>
+
+    <select id="getUnitNoByHours" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT HOUR(create_time) AS 'time',
+               COUNT(DISTINCT material_id) AS 'count'
+        FROM application.adq_material_report_daily_dw
+        WHERE stat_date = #{startTime}
+        GROUP BY HOUR(create_time)
+        ORDER BY HOUR(create_time)
+    </select>
+
+    <select id="getUnitNoByDays" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT stat_date AS 'time',
+               COUNT(DISTINCT material_id) AS 'count'
+        FROM application.adq_material_report_daily_dw
+        WHERE stat_date >= #{startTime}
+          AND stat_date &lt;= #{endTime}
+        GROUP BY stat_date
+        ORDER BY stat_date
+    </select>
+
+    <select id="getAdqOperateInfoHourly" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT /*+ READ_FROM_STORAGE(TIKV[t]) */ COUNT(DISTINCT t.account_id) AS 'accountNum',
+               COUNT(DISTINCT t.project_id) AS 'projectNums',
+               SUM(t.cost) AS 'totalCost',
+               t.user_id AS 'userId',
+               t2.realname AS 'userName',
+               CONCAT(CAST(IFNULL(ROUND((SUM(t.cost) - t3.lastCost) / t3.lastCost * 100, 2), 0) AS CHAR), '%') AS 'rate',
+               '-' AS 'newUnitNum',
+               '-' AS 'newCampaignNum',
+               NULL AS 'projectNum'
+        FROM application.adq_advertiser_report_hourly t
+                 LEFT JOIN `jeecg-boot`.sys_user t2 ON t.user_id = t2.id
+                 LEFT JOIN (
+            SELECT /*+ READ_FROM_STORAGE(TIKV[d]) */ SUM(d.cost) AS 'lastCost', d.user_id
+            FROM application.adq_advertiser_report_hourly d
+            WHERE d.cost > 0
+              AND d.stat_hour &lt;= #{hour}
+              AND d.stat_date >= #{lastTimeStart}
+              AND d.stat_date &lt;= #{lastTimeEnd}
+            <if test='list!=null and list.size() > 0'>
+                AND d.user_id IN
+                <foreach collection="list" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            GROUP BY d.user_id
+        ) t3 ON t.user_id = t3.user_id
+        WHERE t.cost > 0
+          AND t.stat_hour &lt;= #{hour}
+          AND t.stat_date >= #{startDate}
+          AND t.stat_date &lt;= #{endDate}
+        <if test='list!=null and list.size() > 0'>
+            AND t.user_id IN
+            <foreach collection="list" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY t.user_id
+        ORDER BY SUM(t.cost) DESC
+    </select>
+
+    <select id="getAdqOperateInfo" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT COUNT(DISTINCT t.account_id) AS 'accountNum',
+               COUNT(DISTINCT t.project_id) AS 'projectNums',
+               SUM(t.cost) AS 'totalCost',
+               t.user_id AS 'userId',
+               t2.realname AS 'userName',
+               CONCAT(CAST(IFNULL(ROUND((SUM(t.cost) - t3.lastCost) / t3.lastCost * 100, 2), 0) AS CHAR), '%') AS 'rate',
+               '-' AS 'newUnitNum',
+               '-' AS 'newCampaignNum',
+               NULL AS 'projectNum'
+        FROM application.adq_advertiser_report_daily t
+                 LEFT JOIN `jeecg-boot`.sys_user t2 ON t.user_id = t2.id
+                 LEFT JOIN (
+            SELECT SUM(d.cost) AS 'lastCost', d.user_id
+            FROM application.adq_advertiser_report_daily d
+            WHERE d.cost > 0
+              AND d.stat_date >= #{lastTimeStart}
+              AND d.stat_date &lt;= #{lastTimeEnd}
+            <if test='list!=null and list.size() > 0'>
+                AND d.user_id IN
+                <foreach collection="list" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            GROUP BY d.user_id
+        ) t3 ON t.user_id = t3.user_id
+        WHERE t.cost > 0
+          AND t.stat_date >= #{startDate}
+          AND t.stat_date &lt;= #{endDate}
+        <if test='list!=null and list.size() > 0'>
+            AND t.user_id IN
+            <foreach collection="list" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY t.user_id
+        ORDER BY SUM(t.cost) DESC
+    </select>
+
+    <select id="getAdqOperateGroupInfoHourly" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT IFNULL(COUNT(t1.user_id), 0) AS 'operationNum',
+               IFNULL(SUM(t1.accountNum), 0) AS 'accountNum',
+               IFNULL(SUM(t1.projectNum), 0) AS 'projectNums',
+               IFNULL(SUM(t1.totalCost), 0) AS 'totalCost',
+               t3.lastCost,
+               CONCAT(CAST(IFNULL(ROUND((SUM(t1.totalCost) - t3.lastCost) / t3.lastCost * 100, 2), 0) AS CHAR), '%') AS 'yearOnYearCost',
+               NULL AS 'unitNum',
+               NULL AS 'projectNum'
+        FROM (
+                 SELECT /*+ READ_FROM_STORAGE(TIKV[d]) */ COUNT(DISTINCT d.account_id) AS 'accountNum',
+                        COUNT(DISTINCT d.project_id) AS 'projectNum',
+                        SUM(d.cost) AS 'totalCost',
+                        d.user_id
+                 FROM application.adq_advertiser_report_hourly d
+                 WHERE d.cost > 0
+                   AND d.stat_hour &lt;= #{hour}
+                   AND d.stat_date >= #{startDate}
+                   AND d.stat_date &lt;= #{endDate}
+                 <if test='list!=null and list.size() > 0'>
+                     AND d.user_id IN
+                     <foreach collection="list" item="item" separator="," open="(" close=")">
+                         #{item}
+                     </foreach>
+                 </if>
+                 GROUP BY d.user_id
+             ) t1
+                 LEFT JOIN (
+            SELECT /*+ READ_FROM_STORAGE(TIKV[d]) */ SUM(d.cost) AS 'lastCost'
+            FROM application.adq_advertiser_report_hourly d
+            WHERE d.cost > 0
+              AND d.stat_hour &lt;= #{hour}
+              AND d.stat_date >= #{lastTimeStart}
+              AND d.stat_date &lt;= #{lastTimeEnd}
+            <if test='list!=null and list.size() > 0'>
+                AND d.user_id IN
+                <foreach collection="list" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+        ) t3 ON 1 = 1
+    </select>
+
+    <select id="getAdqOperateGroupInfo" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT IFNULL(COUNT(t1.user_id), 0) AS 'operationNum',
+               IFNULL(SUM(t1.accountNum), 0) AS 'accountNum',
+               IFNULL(SUM(t1.projectNum), 0) AS 'projectNums',
+               IFNULL(SUM(t1.totalCost), 0) AS 'totalCost',
+               t3.lastCost,
+               CONCAT(CAST(IFNULL(ROUND((SUM(t1.totalCost) - t3.lastCost) / t3.lastCost * 100, 2), 0) AS CHAR), '%') AS 'yearOnYearCost',
+               NULL AS 'unitNum',
+               NULL AS 'projectNum'
+        FROM (
+                 SELECT COUNT(DISTINCT d.account_id) AS 'accountNum',
+                        COUNT(DISTINCT d.project_id) AS 'projectNum',
+                        SUM(d.cost) AS 'totalCost',
+                        d.user_id
+                 FROM application.adq_advertiser_report_daily d
+                 WHERE d.cost > 0
+                   AND d.stat_date >= #{startDate}
+                   AND d.stat_date &lt;= #{endDate}
+                 <if test='list!=null and list.size() > 0'>
+                     AND d.user_id IN
+                     <foreach collection="list" item="item" separator="," open="(" close=")">
+                         #{item}
+                     </foreach>
+                 </if>
+                 GROUP BY d.user_id
+             ) t1
+                 LEFT JOIN (
+            SELECT SUM(d.cost) AS 'lastCost'
+            FROM application.adq_advertiser_report_daily d
+            WHERE d.cost > 0
+              AND d.stat_date >= #{lastTimeStart}
+              AND d.stat_date &lt;= #{lastTimeEnd}
+            <if test='list!=null and list.size() > 0'>
+                AND d.user_id IN
+                <foreach collection="list" item="item" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+        ) t3 ON 1 = 1
+    </select>
+
+    <sql id="adqOperateGroupRelationTable">
+        SELECT t.managerId, t.userId
+        FROM (
+                 SELECT m.manage_id AS managerId, u.id AS userId
+                 FROM `jeecg-boot`.sys_user u
+                          LEFT JOIN `application`.app_user_manage m ON u.id = m.user_id
+                          LEFT JOIN `jeecg-boot`.sys_user_role ur ON u.id = ur.user_id
+                          LEFT JOIN `jeecg-boot`.sys_role r ON ur.role_id = r.id
+                 WHERE m.manage_id IN
+                       <foreach collection="managerIds" item="item" separator="," open="(" close=")">
+                           #{item}
+                       </foreach>
+                   AND r.role_name LIKE '%运营%'
+                   AND u.STATUS = 1
+                   AND u.del_flag = 0
+                   AND EXISTS (
+                         SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ 1
+                         FROM application.adq_advertiser_report_hourly report
+                         WHERE report.user_id = u.id
+                           AND report.stat_date >= #{startDate}
+                           AND report.stat_date &lt;= #{endDate}
+                           AND report.cost > 0
+                         LIMIT 1
+                     )
+                 GROUP BY m.manage_id, u.id
+                 UNION ALL
+                 SELECT /*+ READ_FROM_STORAGE(TIKV[report]) */ report.user_id AS managerId, report.user_id AS userId
+                 FROM application.adq_advertiser_report_hourly report
+                 WHERE report.user_id IN
+                       <foreach collection="managerIds" item="item" separator="," open="(" close=")">
+                           #{item}
+                       </foreach>
+                   AND report.stat_date >= #{startDate}
+                   AND report.stat_date &lt;= #{endDate}
+                   AND report.cost > 0
+                 GROUP BY report.user_id
+             ) t
+        GROUP BY t.managerId, t.userId
+    </sql>
+
+    <sql id="adqOperateGroupUsersTable">
+        SELECT DISTINCT rel.userId
+        FROM (
+                 <include refid="adqOperateGroupRelationTable"/>
+             ) rel
+    </sql>
+
+    <select id="getOperateGroupCurrentHourlyByUsers" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT /*+ READ_FROM_STORAGE(TIKV[d]) */ d.user_id AS 'userId',
+               COUNT(DISTINCT d.account_id) AS 'accountNum',
+               COUNT(DISTINCT d.project_id) AS 'projectNum',
+               SUM(d.cost) AS 'totalCost'
+        FROM application.adq_advertiser_report_hourly d
+        WHERE d.cost > 0
+          AND d.stat_hour &lt;= #{hour}
+          AND d.stat_date >= #{startDate}
+          AND d.stat_date &lt;= #{endDate}
+          AND d.user_id IN
+          <foreach collection="userIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY d.user_id
+    </select>
+
+    <select id="getOperateGroupCurrentByUsers" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT d.user_id AS 'userId',
+               COUNT(DISTINCT d.account_id) AS 'accountNum',
+               COUNT(DISTINCT d.project_id) AS 'projectNum',
+               SUM(d.cost) AS 'totalCost'
+        FROM application.adq_advertiser_report_daily d
+        WHERE d.cost > 0
+          AND d.stat_date >= #{startDate}
+          AND d.stat_date &lt;= #{endDate}
+          AND d.user_id IN
+          <foreach collection="userIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY d.user_id
+    </select>
+
+    <select id="getOperateGroupPreviousHourlyByUsers" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT /*+ READ_FROM_STORAGE(TIKV[d]) */ d.user_id AS 'userId',
+               SUM(d.cost) AS 'lastCost'
+        FROM application.adq_advertiser_report_hourly d
+        WHERE d.cost > 0
+          AND d.stat_hour &lt;= #{hour}
+          AND d.stat_date >= #{startDate}
+          AND d.stat_date &lt;= #{endDate}
+          AND d.user_id IN
+          <foreach collection="userIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY d.user_id
+    </select>
+
+    <select id="getOperateGroupPreviousByUsers" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT d.user_id AS 'userId',
+               SUM(d.cost) AS 'lastCost'
+        FROM application.adq_advertiser_report_daily d
+        WHERE d.cost > 0
+          AND d.stat_date >= #{startDate}
+          AND d.stat_date &lt;= #{endDate}
+          AND d.user_id IN
+          <foreach collection="userIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY d.user_id
+    </select>
+
+    <select id="getAdqOperateGroupInfoHourlyBatch" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT rel.managerId AS 'userId',
+               COUNT(DISTINCT rel.userId) AS 'operationNum',
+               IFNULL(SUM(cur.accountNum), 0) AS 'accountNum',
+               IFNULL(SUM(cur.projectNum), 0) AS 'projectNums',
+               IFNULL(SUM(cur.totalCost), 0) AS 'totalCost',
+               IFNULL(SUM(prev.lastCost), 0) AS 'lastCost',
+               CASE
+                   WHEN IFNULL(SUM(prev.lastCost), 0) = 0 THEN '0%'
+                   ELSE CONCAT(CAST(ROUND((IFNULL(SUM(cur.totalCost), 0) - SUM(prev.lastCost)) / SUM(prev.lastCost) * 100, 2) AS CHAR), '%')
+                   END AS 'yearOnYearCost',
+               NULL AS 'unitNum',
+               NULL AS 'projectNum'
+        FROM (
+                 <include refid="adqOperateGroupRelationTable"/>
+             ) rel
+                 LEFT JOIN (
+            SELECT /*+ READ_FROM_STORAGE(TIKV[d]) */ d.user_id,
+                   COUNT(DISTINCT d.account_id) AS 'accountNum',
+                   COUNT(DISTINCT d.project_id) AS 'projectNum',
+                   SUM(d.cost) AS 'totalCost'
+            FROM application.adq_advertiser_report_hourly d
+                     INNER JOIN (
+                <include refid="adqOperateGroupUsersTable"/>
+            ) users ON users.userId = d.user_id
+            WHERE d.cost > 0
+              AND d.stat_hour &lt;= #{hour}
+              AND d.stat_date >= #{startDate}
+              AND d.stat_date &lt;= #{endDate}
+            GROUP BY d.user_id
+        ) cur ON rel.userId = cur.user_id
+                 LEFT JOIN (
+            SELECT /*+ READ_FROM_STORAGE(TIKV[d]) */ d.user_id,
+                   SUM(d.cost) AS 'lastCost'
+            FROM application.adq_advertiser_report_hourly d
+                     INNER JOIN (
+                <include refid="adqOperateGroupUsersTable"/>
+            ) users ON users.userId = d.user_id
+            WHERE d.cost > 0
+              AND d.stat_hour &lt;= #{hour}
+              AND d.stat_date >= #{lastTimeStart}
+              AND d.stat_date &lt;= #{lastTimeEnd}
+            GROUP BY d.user_id
+        ) prev ON rel.userId = prev.user_id
+        GROUP BY rel.managerId
+        ORDER BY IFNULL(SUM(cur.totalCost), 0) DESC
+    </select>
+
+    <select id="getAdqOperateGroupInfoBatch" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT rel.managerId AS 'userId',
+               COUNT(DISTINCT rel.userId) AS 'operationNum',
+               IFNULL(SUM(cur.accountNum), 0) AS 'accountNum',
+               IFNULL(SUM(cur.projectNum), 0) AS 'projectNums',
+               IFNULL(SUM(cur.totalCost), 0) AS 'totalCost',
+               IFNULL(SUM(prev.lastCost), 0) AS 'lastCost',
+               CASE
+                   WHEN IFNULL(SUM(prev.lastCost), 0) = 0 THEN '0%'
+                   ELSE CONCAT(CAST(ROUND((IFNULL(SUM(cur.totalCost), 0) - SUM(prev.lastCost)) / SUM(prev.lastCost) * 100, 2) AS CHAR), '%')
+                   END AS 'yearOnYearCost',
+               NULL AS 'unitNum',
+               NULL AS 'projectNum'
+        FROM (
+                 <include refid="adqOperateGroupRelationTable"/>
+             ) rel
+                 LEFT JOIN (
+            SELECT d.user_id,
+                   COUNT(DISTINCT d.account_id) AS 'accountNum',
+                   COUNT(DISTINCT d.project_id) AS 'projectNum',
+                   SUM(d.cost) AS 'totalCost'
+            FROM application.adq_advertiser_report_daily d
+                     INNER JOIN (
+                <include refid="adqOperateGroupUsersTable"/>
+            ) users ON users.userId = d.user_id
+            WHERE d.cost > 0
+              AND d.stat_date >= #{startDate}
+              AND d.stat_date &lt;= #{endDate}
+            GROUP BY d.user_id
+        ) cur ON rel.userId = cur.user_id
+                 LEFT JOIN (
+            SELECT d.user_id,
+                   SUM(d.cost) AS 'lastCost'
+            FROM application.adq_advertiser_report_daily d
+                     INNER JOIN (
+                <include refid="adqOperateGroupUsersTable"/>
+            ) users ON users.userId = d.user_id
+            WHERE d.cost > 0
+              AND d.stat_date >= #{lastTimeStart}
+              AND d.stat_date &lt;= #{lastTimeEnd}
+            GROUP BY d.user_id
+        ) prev ON rel.userId = prev.user_id
+        GROUP BY rel.managerId
+        ORDER BY IFNULL(SUM(cur.totalCost), 0) DESC
+    </select>
+
+</mapper>

+ 264 - 35
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/BytedanceAccountReportDailyDwMapper.xml

@@ -12,45 +12,33 @@
 
 
 
 
     <select id="getTotalCharge" resultType="com.alibaba.fastjson.JSONObject">
     <select id="getTotalCharge" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT t1.todaycost, t2.yesterdaycost, t3.thisWeekcost, t4.lastWeek1 + t5.lastWeek2 as 'lastWeekcost'
+        SELECT hourly.todaycost,
+               hourly.yesterdaycost,
+               daily.thisWeekDailyCost + hourly.thisWeekTodayCost AS 'thisWeekcost',
+               daily.lastWeek1 + hourly.lastWeek2 AS 'lastWeekcost'
         FROM (
         FROM (
-                 SELECT IFNULL(sum(cost), 0.00) as 'todaycost'
+                 SELECT IFNULL(SUM(CASE WHEN stat_datetime = #{today} THEN cost END), 0.00) AS 'todaycost',
+                        IFNULL(SUM(CASE WHEN stat_datetime = #{yesterday} AND hour &lt;= #{hour} THEN cost END), 0.00) AS 'yesterdaycost',
+                        IFNULL(SUM(CASE WHEN stat_datetime = #{today} THEN cost END), 0.00) AS 'thisWeekTodayCost',
+                        IFNULL(SUM(CASE WHEN stat_datetime = #{lastEndDate} AND hour &lt;= #{hour} THEN cost END), 0.00) AS 'lastWeek2'
                  FROM application.bytedance_advertiser_report_hourly_dw
                  FROM application.bytedance_advertiser_report_hourly_dw
-                 WHERE stat_datetime = #{today}
-
-             ) t1
-                 LEFT JOIN
-             (
-                 SELECT IFNULL(sum(cost), 0.00) as 'yesterdaycost'
-                 FROM application.bytedance_advertiser_report_hourly_dw
-                 WHERE stat_datetime = #{yesterday}
-                           AND hour &lt;= #{hour}
-
-             ) t2 ON 1 = 1
-                 LEFT JOIN
-             (
-                 SELECT IFNULL(sum(cost), 0.00) as 'thisWeekcost'
-                 FROM application.bytedance_advertiser_report_hourly_dw
-                 WHERE stat_datetime >= #{monday}
-
-                   AND stat_datetime &lt;= #{today}
-             ) t3 ON 1 = 1
-                 LEFT JOIN
+                 WHERE stat_datetime IN (#{today}, #{yesterday}, #{lastEndDate})
+             ) hourly
+                 CROSS JOIN
              (
              (
-                 SELECT IF(#{lastStartDate} - #{lastEndDate} = 0, 0.00, sum(cost)) as 'lastWeek1'
+                 SELECT IFNULL(SUM(CASE WHEN stat_datetime >= #{monday} AND stat_datetime &lt; #{today} THEN cost END), 0.00) AS 'thisWeekDailyCost',
+                        CASE
+                            WHEN #{lastStartDate} - #{lastEndDate} = 0 THEN 0.00
+                            ELSE IFNULL(SUM(CASE
+                                                WHEN stat_datetime >= #{lastStartDate}
+                                                    AND stat_datetime &lt;= DATE_FORMAT(DATE_SUB(#{lastEndDate}, INTERVAL 1 DAY), '%Y%m%d')
+                                                    THEN cost
+                                END), 0.00)
+                            END AS 'lastWeek1'
                  FROM application.bytedance_advertiser_report_daily_dw
                  FROM application.bytedance_advertiser_report_daily_dw
                  WHERE stat_datetime >= #{lastStartDate}
                  WHERE stat_datetime >= #{lastStartDate}
-                   AND stat_datetime &lt;= DATE_FORMAT(DATE_SUB(#{lastEndDate}, INTERVAL 1 DAY ), '%Y%m%d')
-
-             ) t4 ON 1 = 1
-                 LEFT JOIN
-             (
-                 SELECT IFNULL(sum(cost), 0.00) as 'lastWeek2'
-                 FROM application.bytedance_advertiser_report_hourly_dw
-                 WHERE stat_datetime = #{lastEndDate}
-
-                           AND hour &lt;= #{hour}
-             ) t5 ON 1 = 1
+                   AND stat_datetime &lt; #{today}
+             ) daily
     </select>
     </select>
 
 
     <select id="getHourCost" resultType="com.alibaba.fastjson.JSONObject">
     <select id="getHourCost" resultType="com.alibaba.fastjson.JSONObject">
@@ -608,4 +596,245 @@
         ) t4 ON 1=1
         ) t4 ON 1=1
     </select>
     </select>
 
 
-</mapper>
+    <sql id="toutiaoOperateGroupRelationTable">
+        SELECT t.managerId, t.userId
+        FROM (
+                 SELECT m.manage_id AS managerId, u.id AS userId
+                 FROM `jeecg-boot`.sys_user u
+                          LEFT JOIN `application`.app_user_manage m ON u.id = m.user_id
+                          LEFT JOIN `jeecg-boot`.sys_user_role ur ON u.id = ur.user_id
+                          LEFT JOIN `jeecg-boot`.sys_role r ON ur.role_id = r.id
+                 WHERE m.manage_id IN
+                       <foreach collection="managerIds" item="item" separator="," open="(" close=")">
+                           #{item}
+                       </foreach>
+                   AND r.role_name LIKE '%运营%'
+                   AND u.STATUS = 1
+                   AND u.del_flag = 0
+                   AND EXISTS (
+                         SELECT 1
+                         FROM application.bytedance_advertiser_report_hourly_dw report
+                         WHERE report.user_id = u.id
+                           AND report.stat_datetime >= #{startDate}
+                           AND report.stat_datetime &lt;= #{endDate}
+                           AND report.cost > 0
+                         LIMIT 1
+                     )
+                 GROUP BY m.manage_id, u.id
+                 UNION ALL
+                 SELECT report.user_id AS managerId, report.user_id AS userId
+                 FROM application.bytedance_advertiser_report_hourly_dw report
+                 WHERE report.user_id IN
+                       <foreach collection="managerIds" item="item" separator="," open="(" close=")">
+                           #{item}
+                       </foreach>
+                   AND report.stat_datetime >= #{startDate}
+                   AND report.stat_datetime &lt;= #{endDate}
+                   AND report.cost > 0
+                 GROUP BY report.user_id
+             ) t
+        GROUP BY t.managerId, t.userId
+    </sql>
+
+    <sql id="toutiaoOperateGroupUsersTable">
+        SELECT DISTINCT rel.userId
+        FROM (
+                 <include refid="toutiaoOperateGroupRelationTable"/>
+             ) rel
+    </sql>
+
+    <select id="getOperateGroupCurrentHourlyByUsers" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT d.user_id AS 'userId',
+               COUNT(DISTINCT d.account_id) AS 'accountNum',
+               COUNT(DISTINCT d.project_id) AS 'projectNum',
+               SUM(d.cost) AS 'totalCost'
+        FROM application.bytedance_advertiser_report_hourly_dw d
+        WHERE d.cost > 0
+          AND d.hour &lt;= #{hour}
+          AND d.stat_datetime >= #{startDate}
+          AND d.stat_datetime &lt;= #{endDate}
+          AND d.user_id IN
+          <foreach collection="userIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY d.user_id
+    </select>
+
+    <select id="getOperateGroupCurrentByUsers" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT d.user_id AS 'userId',
+               COUNT(DISTINCT d.account_id) AS 'accountNum',
+               COUNT(DISTINCT d.project_id) AS 'projectNum',
+               SUM(d.cost) AS 'totalCost'
+        FROM application.bytedance_advertiser_report_daily_dw d
+        WHERE d.cost > 0
+          AND d.stat_datetime >= #{startDate}
+          AND d.stat_datetime &lt;= #{endDate}
+          AND d.user_id IN
+          <foreach collection="userIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY d.user_id
+    </select>
+
+    <select id="getOperateGroupPreviousHourlyByUsers" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT d.user_id AS 'userId',
+               SUM(d.cost) AS 'lastCost'
+        FROM application.bytedance_advertiser_report_hourly_dw d
+        WHERE d.cost > 0
+          AND d.hour &lt;= #{hour}
+          AND d.stat_datetime >= #{startDate}
+          AND d.stat_datetime &lt;= #{endDate}
+          AND d.user_id IN
+          <foreach collection="userIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY d.user_id
+    </select>
+
+    <select id="getOperateGroupPreviousByUsers" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT d.user_id AS 'userId',
+               SUM(d.cost) AS 'lastCost'
+        FROM application.bytedance_advertiser_report_daily_dw d
+        WHERE d.cost > 0
+          AND d.stat_datetime >= #{startDate}
+          AND d.stat_datetime &lt;= #{endDate}
+          AND d.user_id IN
+          <foreach collection="userIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY d.user_id
+    </select>
+
+    <select id="getOperateGroupBaseByUsers" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT base.user_id AS 'userId',
+               IFNULL(SUM(base.new_ad_num), 0) + IFNULL(SUM(base.promotion_num), 0) AS 'unitNum',
+               IFNULL(SUM(base.new_cpd_project_num), 0) AS 'projectNum'
+        FROM application.app_bytedance_account_base_info_d base
+        WHERE base.stat_date >= #{startDate}
+          AND base.stat_date &lt;= #{endDate}
+          AND base.user_id IN
+          <foreach collection="userIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY base.user_id
+    </select>
+
+    <select id="getToutiaoOperateGroupInfoHourlyBatch" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT rel.managerId AS 'userId',
+               COUNT(DISTINCT rel.userId) AS 'operationNum',
+               IFNULL(SUM(cur.accountNum), 0) AS 'accountNum',
+               IFNULL(SUM(cur.projectNum), 0) AS 'projectNums',
+               IFNULL(SUM(cur.totalCost), 0) AS 'totalCost',
+               IFNULL(SUM(prev.lastCost), 0) AS 'lastCost',
+               CASE
+                   WHEN IFNULL(SUM(prev.lastCost), 0) = 0 THEN '0%'
+                   ELSE CONCAT(CAST(ROUND((IFNULL(SUM(cur.totalCost), 0) - SUM(prev.lastCost)) / SUM(prev.lastCost) * 100, 2) AS CHAR), '%')
+                   END AS 'yearOnYearCost',
+               IFNULL(SUM(base.unitNum), 0) AS 'unitNum',
+               IFNULL(SUM(base.projectNum), 0) AS 'projectNum'
+        FROM (
+                 <include refid="toutiaoOperateGroupRelationTable"/>
+             ) rel
+                 LEFT JOIN (
+            SELECT d.user_id,
+                   COUNT(DISTINCT d.account_id) AS 'accountNum',
+                   COUNT(DISTINCT d.project_id) AS 'projectNum',
+                   SUM(d.cost) AS 'totalCost'
+            FROM `application`.bytedance_advertiser_report_hourly_dw d
+                     INNER JOIN (
+                <include refid="toutiaoOperateGroupUsersTable"/>
+            ) users ON users.userId = d.user_id
+            WHERE d.cost > 0
+              AND d.hour &lt;= #{hour}
+              AND d.stat_datetime >= #{startDate}
+              AND d.stat_datetime &lt;= #{endDate}
+            GROUP BY d.user_id
+        ) cur ON rel.userId = cur.user_id
+                 LEFT JOIN (
+            SELECT d.user_id,
+                   SUM(d.cost) AS 'lastCost'
+            FROM `application`.bytedance_advertiser_report_hourly_dw d
+                     INNER JOIN (
+                <include refid="toutiaoOperateGroupUsersTable"/>
+            ) users ON users.userId = d.user_id
+            WHERE d.cost > 0
+              AND d.hour &lt;= #{hour}
+              AND d.stat_datetime >= #{lastTimeStart}
+              AND d.stat_datetime &lt;= #{lastTimeEnd}
+            GROUP BY d.user_id
+        ) prev ON rel.userId = prev.user_id
+                 LEFT JOIN (
+            SELECT base.user_id,
+                   IFNULL(SUM(base.new_ad_num), 0) + IFNULL(SUM(base.promotion_num), 0) AS 'unitNum',
+                   IFNULL(SUM(base.new_cpd_project_num), 0) AS 'projectNum'
+            FROM application.app_bytedance_account_base_info_d base
+                     INNER JOIN (
+                <include refid="toutiaoOperateGroupUsersTable"/>
+            ) users ON users.userId = base.user_id
+            WHERE base.stat_date >= #{startDate}
+              AND base.stat_date &lt;= #{endDate}
+            GROUP BY base.user_id
+        ) base ON rel.userId = base.user_id
+        GROUP BY rel.managerId
+        ORDER BY IFNULL(SUM(cur.totalCost), 0) DESC
+    </select>
+
+    <select id="getToutiaoOperateGroupInfoBatch" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT rel.managerId AS 'userId',
+               COUNT(DISTINCT rel.userId) AS 'operationNum',
+               IFNULL(SUM(cur.accountNum), 0) AS 'accountNum',
+               IFNULL(SUM(cur.projectNum), 0) AS 'projectNums',
+               IFNULL(SUM(cur.totalCost), 0) AS 'totalCost',
+               IFNULL(SUM(prev.lastCost), 0) AS 'lastCost',
+               CASE
+                   WHEN IFNULL(SUM(prev.lastCost), 0) = 0 THEN '0%'
+                   ELSE CONCAT(CAST(ROUND((IFNULL(SUM(cur.totalCost), 0) - SUM(prev.lastCost)) / SUM(prev.lastCost) * 100, 2) AS CHAR), '%')
+                   END AS 'yearOnYearCost',
+               IFNULL(SUM(base.unitNum), 0) AS 'unitNum',
+               IFNULL(SUM(base.projectNum), 0) AS 'projectNum'
+        FROM (
+                 <include refid="toutiaoOperateGroupRelationTable"/>
+             ) rel
+                 LEFT JOIN (
+            SELECT d.user_id,
+                   COUNT(DISTINCT d.account_id) AS 'accountNum',
+                   COUNT(DISTINCT d.project_id) AS 'projectNum',
+                   SUM(d.cost) AS 'totalCost'
+            FROM `application`.bytedance_advertiser_report_daily_dw d
+                     INNER JOIN (
+                <include refid="toutiaoOperateGroupUsersTable"/>
+            ) users ON users.userId = d.user_id
+            WHERE d.cost > 0
+              AND d.stat_datetime >= #{startDate}
+              AND d.stat_datetime &lt;= #{endDate}
+            GROUP BY d.user_id
+        ) cur ON rel.userId = cur.user_id
+                 LEFT JOIN (
+            SELECT d.user_id,
+                   SUM(d.cost) AS 'lastCost'
+            FROM `application`.bytedance_advertiser_report_daily_dw d
+                     INNER JOIN (
+                <include refid="toutiaoOperateGroupUsersTable"/>
+            ) users ON users.userId = d.user_id
+            WHERE d.cost > 0
+              AND d.stat_datetime >= #{lastTimeStart}
+              AND d.stat_datetime &lt;= #{lastTimeEnd}
+            GROUP BY d.user_id
+        ) prev ON rel.userId = prev.user_id
+                 LEFT JOIN (
+            SELECT base.user_id,
+                   IFNULL(SUM(base.new_ad_num), 0) + IFNULL(SUM(base.promotion_num), 0) AS 'unitNum',
+                   IFNULL(SUM(base.new_cpd_project_num), 0) AS 'projectNum'
+            FROM application.app_bytedance_account_base_info_d base
+                     INNER JOIN (
+                <include refid="toutiaoOperateGroupUsersTable"/>
+            ) users ON users.userId = base.user_id
+            WHERE base.stat_date >= #{startDate}
+              AND base.stat_date &lt;= #{endDate}
+            GROUP BY base.user_id
+        ) base ON rel.userId = base.user_id
+        GROUP BY rel.managerId
+        ORDER BY IFNULL(SUM(cur.totalCost), 0) DESC
+    </select>
+
+</mapper>

+ 259 - 35
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/KuaishouAccountReportDailyDwMapper.xml

@@ -4,45 +4,33 @@
 
 
 
 
     <select id="getTotalCharge" resultType="com.alibaba.fastjson.JSONObject">
     <select id="getTotalCharge" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT t1.todayCharge, t2.yesterdayCharge, t3.thisWeekCharge, t4.lastWeek1 + t5.lastWeek2 as 'lastWeekCharge'
+        SELECT hourly.todayCharge,
+               hourly.yesterdayCharge,
+               daily.thisWeekDailyCharge + hourly.thisWeekTodayCharge AS 'thisWeekCharge',
+               daily.lastWeek1 + hourly.lastWeek2 AS 'lastWeekCharge'
         FROM (
         FROM (
-                 SELECT IFNULL(sum(charge), 0.00) as 'todayCharge'
+                 SELECT IFNULL(SUM(CASE WHEN stat_date = #{today} THEN charge END), 0.00) AS 'todayCharge',
+                        IFNULL(SUM(CASE WHEN stat_date = #{yesterday} AND `hour` &lt;= #{hour} THEN charge END), 0.00) AS 'yesterdayCharge',
+                        IFNULL(SUM(CASE WHEN stat_date = #{today} THEN charge END), 0.00) AS 'thisWeekTodayCharge',
+                        IFNULL(SUM(CASE WHEN stat_date = #{lastEndDate} AND `hour` &lt;= #{hour} THEN charge END), 0.00) AS 'lastWeek2'
                  FROM application.kuaishou_account_report_hourly_dw
                  FROM application.kuaishou_account_report_hourly_dw
-                 WHERE stat_date = #{today}
-             ) t1
-                 LEFT JOIN
+                 WHERE stat_date IN (#{today}, #{yesterday}, #{lastEndDate})
+             ) hourly
+                 CROSS JOIN
              (
              (
-                 SELECT IFNULL(sum(charge), 0.00) as 'yesterdayCharge'
-                 FROM application.kuaishou_account_report_hourly_dw
-                 WHERE stat_date = #{yesterday}
-                   AND `hour` &lt;= #{hour}
-             ) t2
-             ON 1 = 1
-                 LEFT JOIN
-             (
-                 SELECT IFNULL(sum(charge), 0.00) as 'thisWeekCharge'
-                 FROM application.kuaishou_account_report_hourly_dw
-                 WHERE stat_date >= #{monday}
-                   AND stat_date &lt;= #{today}
-             ) t3
-             ON 1 = 1
-                 LEFT JOIN
-             (
-                 SELECT IF(#{lastStartDate} - #{lastEndDate} = 0, 0.00, sum(charge)) as 'lastWeek1'
+                 SELECT IFNULL(SUM(CASE WHEN stat_date >= #{monday} AND stat_date &lt; #{today} THEN charge END), 0.00) AS 'thisWeekDailyCharge',
+                        CASE
+                            WHEN #{lastStartDate} - #{lastEndDate} = 0 THEN 0.00
+                            ELSE IFNULL(SUM(CASE
+                                                WHEN stat_date >= #{lastStartDate}
+                                                    AND stat_date &lt;= DATE_FORMAT(DATE_SUB(#{lastEndDate}, INTERVAL 1 DAY), '%Y%m%d')
+                                                    THEN charge
+                                END), 0.00)
+                            END AS 'lastWeek1'
                  FROM application.kuaishou_account_report_daily_dw
                  FROM application.kuaishou_account_report_daily_dw
                  WHERE stat_date >= #{lastStartDate}
                  WHERE stat_date >= #{lastStartDate}
-                   AND stat_date &lt;= DATE_FORMAT(DATE_SUB(#{lastEndDate}
-                                                       , INTERVAL 1 DAY )
-                     , '%Y%m%d')
-             ) t4
-             ON 1 = 1
-                 LEFT JOIN
-             (
-                 SELECT IFNULL(sum(charge), 0.00) as 'lastWeek2'
-                 FROM application.kuaishou_account_report_hourly_dw
-                 WHERE stat_date = #{lastEndDate}
-                   AND `hour` &lt;= #{hour}
-             ) t5 ON 1 = 1
+                   AND stat_date &lt; #{today}
+             ) daily
     </select>
     </select>
 
 
     <select id="getYesterdayUploadNewMaterialCount" resultType="Long">
     <select id="getYesterdayUploadNewMaterialCount" resultType="Long">
@@ -635,4 +623,240 @@
         ) t4 ON 1=1
         ) t4 ON 1=1
     </select>
     </select>
 
 
-</mapper>
+    <sql id="kuaishouOperateGroupRelationTable">
+        SELECT t.managerId, t.userId
+        FROM (
+                 SELECT m.manage_id AS managerId, u.id AS userId
+                 FROM `jeecg-boot`.sys_user u
+                          LEFT JOIN `application`.app_user_manage m ON u.id = m.user_id
+                          LEFT JOIN `jeecg-boot`.sys_user_role ur ON u.id = ur.user_id
+                          LEFT JOIN `jeecg-boot`.sys_role r ON ur.role_id = r.id
+                 WHERE m.manage_id IN
+                       <foreach collection="managerIds" item="item" separator="," open="(" close=")">
+                           #{item}
+                       </foreach>
+                   AND r.role_name LIKE '%运营%'
+                   AND u.STATUS = 1
+                   AND u.del_flag = 0
+                   AND EXISTS (
+                         SELECT 1
+                         FROM application.kuaishou_account_report_hourly_dw report
+                         WHERE report.user_id = u.id
+                           AND report.stat_date >= #{startDate}
+                           AND report.stat_date &lt;= #{endDate}
+                           AND report.charge > 0
+                         LIMIT 1
+                     )
+                 GROUP BY m.manage_id, u.id
+                 UNION ALL
+                 SELECT report.user_id AS managerId, report.user_id AS userId
+                 FROM application.kuaishou_account_report_hourly_dw report
+                 WHERE report.user_id IN
+                       <foreach collection="managerIds" item="item" separator="," open="(" close=")">
+                           #{item}
+                       </foreach>
+                   AND report.stat_date >= #{startDate}
+                   AND report.stat_date &lt;= #{endDate}
+                   AND report.charge > 0
+                 GROUP BY report.user_id
+             ) t
+        GROUP BY t.managerId, t.userId
+    </sql>
+
+    <sql id="kuaishouOperateGroupUsersTable">
+        SELECT DISTINCT rel.userId
+        FROM (
+                 <include refid="kuaishouOperateGroupRelationTable"/>
+             ) rel
+    </sql>
+
+    <select id="getOperateGroupCurrentHourlyByUsers" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT d.user_id AS 'userId',
+               COUNT(DISTINCT d.account_id) AS 'accountNum',
+               COUNT(DISTINCT d.project_id) AS 'projectNum',
+               SUM(d.charge) AS 'totalCost'
+        FROM application.kuaishou_account_report_hourly_dw d
+        WHERE d.charge > 0
+          AND d.hour &lt;= #{hour}
+          AND d.stat_date >= #{startDate}
+          AND d.stat_date &lt;= #{endDate}
+          AND d.user_id IN
+          <foreach collection="userIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY d.user_id
+    </select>
+
+    <select id="getOperateGroupCurrentByUsers" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT d.user_id AS 'userId',
+               COUNT(DISTINCT d.account_id) AS 'accountNum',
+               COUNT(DISTINCT d.project_id) AS 'projectNum',
+               SUM(d.charge) AS 'totalCost'
+        FROM application.kuaishou_account_report_daily_dw d
+        WHERE d.charge > 0
+          AND d.stat_date >= #{startDate}
+          AND d.stat_date &lt;= #{endDate}
+          AND d.user_id IN
+          <foreach collection="userIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY d.user_id
+    </select>
+
+    <select id="getOperateGroupPreviousHourlyByUsers" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT d.user_id AS 'userId',
+               SUM(d.charge) AS 'lastCost'
+        FROM application.kuaishou_account_report_hourly_dw d
+        WHERE d.charge > 0
+          AND d.hour &lt;= #{hour}
+          AND d.stat_date >= #{startDate}
+          AND d.stat_date &lt;= #{endDate}
+          AND d.user_id IN
+          <foreach collection="userIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY d.user_id
+    </select>
+
+    <select id="getOperateGroupPreviousByUsers" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT d.user_id AS 'userId',
+               SUM(d.charge) AS 'lastCost'
+        FROM application.kuaishou_account_report_daily_dw d
+        WHERE d.charge > 0
+          AND d.stat_date >= #{startDate}
+          AND d.stat_date &lt;= #{endDate}
+          AND d.user_id IN
+          <foreach collection="userIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY d.user_id
+    </select>
+
+    <select id="getOperateGroupBaseByUsers" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT base.user_id AS 'userId',
+               IFNULL(SUM(base.new_all_unit_num), 0) AS 'unitNum'
+        FROM application.app_kuaishou_account_today_base_info_d base
+        WHERE base.stat_date >= #{startDate}
+          AND base.stat_date &lt;= #{endDate}
+          AND base.user_id IN
+          <foreach collection="userIds" item="item" separator="," open="(" close=")">
+              #{item}
+          </foreach>
+        GROUP BY base.user_id
+    </select>
+
+    <select id="getKuaishouOperateGroupInfoHourlyBatch" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT rel.managerId AS 'userId',
+               COUNT(DISTINCT rel.userId) AS 'operationNum',
+               IFNULL(SUM(cur.accountNum), 0) AS 'accountNum',
+               IFNULL(SUM(cur.projectNum), 0) AS 'projectNums',
+               IFNULL(SUM(cur.totalCost), 0) AS 'totalCost',
+               IFNULL(SUM(prev.lastCost), 0) AS 'lastCost',
+               CASE
+                   WHEN IFNULL(SUM(prev.lastCost), 0) = 0 THEN '0%'
+                   ELSE CONCAT(CAST(ROUND((IFNULL(SUM(cur.totalCost), 0) - SUM(prev.lastCost)) / SUM(prev.lastCost) * 100, 2) AS CHAR), '%')
+                   END AS 'yearOnYearCost',
+               IFNULL(SUM(base.unitNum), 0) AS 'unitNum'
+        FROM (
+                 <include refid="kuaishouOperateGroupRelationTable"/>
+             ) rel
+                 LEFT JOIN (
+            SELECT d.user_id,
+                   COUNT(DISTINCT d.account_id) AS 'accountNum',
+                   COUNT(DISTINCT d.project_id) AS 'projectNum',
+                   SUM(d.charge) AS 'totalCost'
+            FROM `application`.kuaishou_account_report_hourly_dw d
+                     INNER JOIN (
+                <include refid="kuaishouOperateGroupUsersTable"/>
+            ) users ON users.userId = d.user_id
+            WHERE d.charge > 0
+              AND d.hour &lt;= #{hour}
+              AND d.stat_date >= #{startDate}
+              AND d.stat_date &lt;= #{endDate}
+            GROUP BY d.user_id
+        ) cur ON rel.userId = cur.user_id
+                 LEFT JOIN (
+            SELECT d.user_id,
+                   SUM(d.charge) AS 'lastCost'
+            FROM `application`.kuaishou_account_report_hourly_dw d
+                     INNER JOIN (
+                <include refid="kuaishouOperateGroupUsersTable"/>
+            ) users ON users.userId = d.user_id
+            WHERE d.charge > 0
+              AND d.hour &lt;= #{hour}
+              AND d.stat_date >= #{lastTimeStart}
+              AND d.stat_date &lt;= #{lastTimeEnd}
+            GROUP BY d.user_id
+        ) prev ON rel.userId = prev.user_id
+                 LEFT JOIN (
+            SELECT base.user_id,
+                   IFNULL(SUM(base.new_all_unit_num), 0) AS 'unitNum'
+            FROM application.app_kuaishou_account_today_base_info_d base
+                     INNER JOIN (
+                <include refid="kuaishouOperateGroupUsersTable"/>
+            ) users ON users.userId = base.user_id
+            WHERE base.stat_date >= #{startDate}
+              AND base.stat_date &lt;= #{endDate}
+            GROUP BY base.user_id
+        ) base ON rel.userId = base.user_id
+        GROUP BY rel.managerId
+        ORDER BY IFNULL(SUM(cur.totalCost), 0) DESC
+    </select>
+
+    <select id="getKuaishouOperateGroupInfoBatch" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT rel.managerId AS 'userId',
+               COUNT(DISTINCT rel.userId) AS 'operationNum',
+               IFNULL(SUM(cur.accountNum), 0) AS 'accountNum',
+               IFNULL(SUM(cur.projectNum), 0) AS 'projectNums',
+               IFNULL(SUM(cur.totalCost), 0) AS 'totalCost',
+               IFNULL(SUM(prev.lastCost), 0) AS 'lastCost',
+               CASE
+                   WHEN IFNULL(SUM(prev.lastCost), 0) = 0 THEN '0%'
+                   ELSE CONCAT(CAST(ROUND((IFNULL(SUM(cur.totalCost), 0) - SUM(prev.lastCost)) / SUM(prev.lastCost) * 100, 2) AS CHAR), '%')
+                   END AS 'yearOnYearCost',
+               IFNULL(SUM(base.unitNum), 0) AS 'unitNum'
+        FROM (
+                 <include refid="kuaishouOperateGroupRelationTable"/>
+             ) rel
+                 LEFT JOIN (
+            SELECT d.user_id,
+                   COUNT(DISTINCT d.account_id) AS 'accountNum',
+                   COUNT(DISTINCT d.project_id) AS 'projectNum',
+                   SUM(d.charge) AS 'totalCost'
+            FROM `application`.kuaishou_account_report_daily_dw d
+                     INNER JOIN (
+                <include refid="kuaishouOperateGroupUsersTable"/>
+            ) users ON users.userId = d.user_id
+            WHERE d.charge > 0
+              AND d.stat_date >= #{startDate}
+              AND d.stat_date &lt;= #{endDate}
+            GROUP BY d.user_id
+        ) cur ON rel.userId = cur.user_id
+                 LEFT JOIN (
+            SELECT d.user_id,
+                   SUM(d.charge) AS 'lastCost'
+            FROM `application`.kuaishou_account_report_daily_dw d
+                     INNER JOIN (
+                <include refid="kuaishouOperateGroupUsersTable"/>
+            ) users ON users.userId = d.user_id
+            WHERE d.charge > 0
+              AND d.stat_date >= #{lastTimeStart}
+              AND d.stat_date &lt;= #{lastTimeEnd}
+            GROUP BY d.user_id
+        ) prev ON rel.userId = prev.user_id
+                 LEFT JOIN (
+            SELECT base.user_id,
+                   IFNULL(SUM(base.new_all_unit_num), 0) AS 'unitNum'
+            FROM application.app_kuaishou_account_today_base_info_d base
+                     INNER JOIN (
+                <include refid="kuaishouOperateGroupUsersTable"/>
+            ) users ON users.userId = base.user_id
+            WHERE base.stat_date >= #{startDate}
+              AND base.stat_date &lt;= #{endDate}
+            GROUP BY base.user_id
+        ) base ON rel.userId = base.user_id
+        GROUP BY rel.managerId
+        ORDER BY IFNULL(SUM(cur.totalCost), 0) DESC
+    </select>
+
+</mapper>

+ 115 - 19
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/MaterialStareMapper.xml

@@ -1885,20 +1885,21 @@
 
 
     <!-- 查询运营经理角色的人员 -->
     <!-- 查询运营经理角色的人员 -->
     <select id="getOperationManagerUser" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateGroupVo">
     <select id="getOperationManagerUser" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateGroupVo">
-        SELECT u.id        as userId,
-               u.username,
-               u.realname  as realname,
-               r.role_name as roleName
-        FROM `jeecg-boot`.sys_user u,
-             `jeecg-boot`.sys_role r,
-             `jeecg-boot`.sys_user_role sur,
-             `jeecg-boot`.user_company c
+        SELECT DISTINCT u.id        as userId,
+                        u.username,
+                        u.realname  as realname,
+                        r.role_name as roleName
+        FROM `jeecg-boot`.sys_user u
+                 INNER JOIN `jeecg-boot`.sys_user_role sur ON u.id = sur.user_id
+                 INNER JOIN `jeecg-boot`.sys_role r ON r.id = sur.role_id
         WHERE r.role_code like concat('%', #{roleCode}, '%')
         WHERE r.role_code like concat('%', #{roleCode}, '%')
-          AND u.id = sur.user_id
-          AND u.id = c.user_id
-          AND r.id = sur.role_id
           AND u.`status` = 1
           AND u.`status` = 1
           AND u.del_flag = 0
           AND u.del_flag = 0
+          AND EXISTS (
+                SELECT 1
+                FROM `jeecg-boot`.user_company c
+                WHERE c.user_id = u.id
+            )
         ORDER BY u.create_time
         ORDER BY u.create_time
     </select>
     </select>
 
 
@@ -1951,15 +1952,110 @@
           AND t.cost > 0
           AND t.cost > 0
     </select>
     </select>
 
 
+    <select id="queryAdqOperateTeamMember" resultType="String">
+        select u.id
+        from `jeecg-boot`.sys_user u
+                 LEFT JOIN `application`.app_user_manage m ON u.id = m.user_id
+                 LEFT JOIN `jeecg-boot`.sys_user_role ur ON u.id = ur.user_id
+                 LEFT JOIN `jeecg-boot`.sys_role r ON ur.role_id = r.id
+                 LEFT JOIN application.adq_advertiser_report_hourly t ON t.user_id = u.id
+        where m.manage_id = #{userId}
+          AND r.role_name LIKE '%运营%'
+          AND u.STATUS = 1
+          AND u.del_flag = 0
+          AND t.stat_date >= #{startDate}
+          AND t.stat_date &lt;= #{endDate}
+          AND t.cost > 0
+        GROUP BY u.id
+        UNION ALL
+        SELECT DISTINCT user_id
+        FROM application.adq_advertiser_report_hourly t
+        WHERE user_id = #{userId}
+          AND t.stat_date >= #{startDate}
+          AND t.stat_date &lt;= #{endDate}
+          AND t.cost > 0
+    </select>
+
+    <select id="queryKuaishouOperateTeamMemberBatch" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t.managerId, t.userId
+        FROM (
+                 SELECT m.manage_id AS managerId, u.id AS userId
+                 FROM `jeecg-boot`.sys_user u
+                          INNER JOIN `application`.app_user_manage m ON u.id = m.user_id
+                          INNER JOIN `jeecg-boot`.sys_user_role ur ON u.id = ur.user_id
+                          INNER JOIN `jeecg-boot`.sys_role r ON ur.role_id = r.id
+                 WHERE m.manage_id IN
+                       <foreach collection="managerIds" item="item" separator="," open="(" close=")">
+                           #{item}
+                       </foreach>
+                   AND r.role_name LIKE '%运营%'
+                   AND u.STATUS = 1
+                   AND u.del_flag = 0
+                 UNION ALL
+                 <foreach collection="managerIds" item="item" separator=" UNION ALL ">
+                     SELECT #{item} AS managerId, #{item} AS userId
+                 </foreach>
+             ) t
+        GROUP BY t.managerId, t.userId
+    </select>
+
+    <select id="queryToutiaoOperateTeamMemberBatch" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t.managerId, t.userId
+        FROM (
+                 SELECT m.manage_id AS managerId, u.id AS userId
+                 FROM `jeecg-boot`.sys_user u
+                          INNER JOIN `application`.app_user_manage m ON u.id = m.user_id
+                          INNER JOIN `jeecg-boot`.sys_user_role ur ON u.id = ur.user_id
+                          INNER JOIN `jeecg-boot`.sys_role r ON ur.role_id = r.id
+                 WHERE m.manage_id IN
+                       <foreach collection="managerIds" item="item" separator="," open="(" close=")">
+                           #{item}
+                       </foreach>
+                   AND r.role_name LIKE '%运营%'
+                   AND u.STATUS = 1
+                   AND u.del_flag = 0
+                 UNION ALL
+                 <foreach collection="managerIds" item="item" separator=" UNION ALL ">
+                     SELECT #{item} AS managerId, #{item} AS userId
+                 </foreach>
+             ) t
+        GROUP BY t.managerId, t.userId
+    </select>
+
+    <select id="queryAdqOperateTeamMemberBatch" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t.managerId, t.userId
+        FROM (
+                 SELECT m.manage_id AS managerId, u.id AS userId
+                 FROM `jeecg-boot`.sys_user u
+                          INNER JOIN `application`.app_user_manage m ON u.id = m.user_id
+                          INNER JOIN `jeecg-boot`.sys_user_role ur ON u.id = ur.user_id
+                          INNER JOIN `jeecg-boot`.sys_role r ON ur.role_id = r.id
+                 WHERE m.manage_id IN
+                       <foreach collection="managerIds" item="item" separator="," open="(" close=")">
+                           #{item}
+                       </foreach>
+                   AND r.role_name LIKE '%运营%'
+                   AND u.STATUS = 1
+                   AND u.del_flag = 0
+                 UNION ALL
+                 <foreach collection="managerIds" item="item" separator=" UNION ALL ">
+                     SELECT #{item} AS managerId, #{item} AS userId
+                 </foreach>
+             ) t
+        GROUP BY t.managerId, t.userId
+    </select>
+
     <select id="getAllOperationByMediaId" resultType="String">
     <select id="getAllOperationByMediaId" resultType="String">
-        select DISTINCT t.user_id
-        FROM `jeecg-boot`.user_company t
-                 LEFT JOIN `jeecg-boot`.sys_user_role t1 ON t.user_id = t1.user_id
-                 LEFT JOIN `jeecg-boot`.sys_role t2 ON t1.role_id = t2.id
-                 LEFT JOIN `jeecg-boot`.sys_user t3 ON t.user_id = t3.id
-                 LEFT JOIN `jeecg-boot`.ctop_user_allocation t4 ON t.user_id = t4.user_id
-        WHERE t2.role_name LIKE '%运营%'
-          AND t4.media_id = #{mediaId}
+        SELECT DISTINCT u.id
+        FROM `jeecg-boot`.sys_user u
+                 INNER JOIN `jeecg-boot`.user_company c ON c.user_id = u.id
+                 INNER JOIN `jeecg-boot`.sys_user_role ur ON u.id = ur.user_id
+                 INNER JOIN `jeecg-boot`.sys_role r ON ur.role_id = r.id
+                 INNER JOIN `jeecg-boot`.ctop_user_allocation ua ON u.id = ua.user_id
+        WHERE r.role_name LIKE '%运营%'
+          AND ua.media_id = #{mediaId}
+          AND u.status = 1
+          AND u.del_flag = 0
     </select>
     </select>
 
 
 
 

+ 19 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/IAdqAdvertiserReportService.java

@@ -0,0 +1,19 @@
+package org.jeecg.ctop.material.service;
+
+import com.alibaba.fastjson.JSONObject;
+import org.jeecg.common.api.vo.Result;
+
+import java.util.Map;
+
+public interface IAdqAdvertiserReportService {
+
+    JSONObject getTotalCharge(Map<String, Object> paramsMap);
+
+    JSONObject getTrendCharge(String type, Long projectId, String startTime, String endTime);
+
+    Result<Object> getProjectReport(String category, Long projectId, String startTime, String endTime, String sortCode, String order, Integer pageSize, Integer pageNo) throws Exception;
+
+    Result<Object> getOperateInfo(String startTime, String endTime);
+
+    Result<Object> getOperateGroupInfo(String startTime, String endTime);
+}

+ 416 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/AdqAdvertiserReportServiceImpl.java

@@ -0,0 +1,416 @@
+package org.jeecg.ctop.material.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.ctop.material.constants.Check;
+import org.jeecg.ctop.material.entity.vo.KuaiShouOperateGroupVo;
+import org.jeecg.ctop.material.mapper.AdqAdvertiserReportMapper;
+import org.jeecg.ctop.material.service.IAdqAdvertiserReportService;
+import org.jeecg.ctop.material.service.support.DashboardQuerySupport;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+
+@Service
+@Slf4j
+public class AdqAdvertiserReportServiceImpl implements IAdqAdvertiserReportService {
+
+    @Resource
+    private AdqAdvertiserReportMapper adqAdvertiserReportMapper;
+
+    @Resource
+    private DashboardQuerySupport dashboardQuerySupport;
+
+    @Override
+    public JSONObject getTotalCharge(Map<String, Object> paramsMap) {
+        CompletableFuture<JSONObject> hourlyFuture = CompletableFuture.supplyAsync(
+                () -> {
+                    long start = System.currentTimeMillis();
+                    try {
+                        return adqAdvertiserReportMapper.getTotalChargeHourly(paramsMap);
+                    } finally {
+                        log.info("adq getTotalChargeHourly finished in {} ms", System.currentTimeMillis() - start);
+                    }
+                }
+        );
+        CompletableFuture<JSONObject> dailyFuture = CompletableFuture.supplyAsync(
+                () -> {
+                    long start = System.currentTimeMillis();
+                    try {
+                        return adqAdvertiserReportMapper.getTotalChargeDaily(paramsMap);
+                    } finally {
+                        log.info("adq getTotalChargeDaily finished in {} ms", System.currentTimeMillis() - start);
+                    }
+                }
+        );
+
+        JSONObject hourly = hourlyFuture.join();
+        JSONObject daily = dailyFuture.join();
+        JSONObject result = new JSONObject();
+        result.put("todayCost", hourly.getBigDecimal("todayCost"));
+        result.put("yesterdayCost", hourly.getBigDecimal("yesterdayCost"));
+        result.put("thisWeekCost", daily.getBigDecimal("thisWeekDailyCost").add(hourly.getBigDecimal("thisWeekTodayCost")));
+        result.put("lastWeekCost", daily.getBigDecimal("lastWeek1").add(hourly.getBigDecimal("lastWeek2")));
+        return result;
+    }
+
+    @Override
+    public JSONObject getTrendCharge(String type, Long projectId, String startTime, String endTime) {
+        Integer startTimeInt = DateUtils.getDateInteger(startTime);
+        Integer endTimeInt = DateUtils.getDateInteger(endTime);
+
+        List<JSONObject> today = null;
+        List<JSONObject> yesterday = null;
+        if ("1".equals(type)) {
+            today = adqAdvertiserReportMapper.getProjectNoByDays(startTimeInt, endTimeInt);
+        } else if ("2".equals(type)) {
+            today = adqAdvertiserReportMapper.getAdvertiserNoByDays(startTimeInt, endTimeInt);
+        } else if ("3".equals(type)) {
+            if (startTime.equals(endTime)) {
+                today = adqAdvertiserReportMapper.getUnitNoByHours(startTimeInt);
+            } else {
+                today = adqAdvertiserReportMapper.getUnitNoByDays(startTimeInt, endTimeInt);
+            }
+        } else {
+            if (startTime.equals(endTime)) {
+                today = adqAdvertiserReportMapper.getHourCost(projectId, startTimeInt);
+                yesterday = adqAdvertiserReportMapper.getHourCost(projectId, DateUtils.getDateInteger(DateUtils.getLastDay(startTime, 1)));
+            } else {
+                today = adqAdvertiserReportMapper.getDataCost(projectId, startTimeInt, endTimeInt);
+                fillingDates(startTime, endTime, today);
+                int days = DateUtils.dateDiff(startTime, endTime);
+                String endTime2 = DateUtils.getLastDay(startTime, 1);
+                String startTime2 = DateUtils.getLastDay(endTime2, days);
+                yesterday = adqAdvertiserReportMapper.getDataCost(projectId, DateUtils.getDateInteger(startTime2), DateUtils.getDateInteger(endTime2));
+                fillingDates(startTime2, endTime2, yesterday);
+            }
+        }
+        JSONObject data = new JSONObject();
+        data.put("today", today);
+        data.put("yesterday", yesterday);
+        return data;
+    }
+
+    private void fillingDates(String startTime, String endTime, List<JSONObject> today) {
+        long dayNum = DateUtils.getDiscrepantDays(startTime, endTime) + 1;
+        int size = today.size();
+        if (dayNum - size != 0) {
+            List<String> days = DateUtils.getDays(startTime, endTime);
+            Set<String> existingDays = today.stream().map(item -> item.getString("time")).collect(Collectors.toSet());
+            for (String day : days) {
+                if (!existingDays.contains(day)) {
+                    JSONObject obj = new JSONObject();
+                    obj.put("time", day);
+                    obj.put("cost", 0.00);
+                    today.add(obj);
+                }
+            }
+        }
+    }
+
+    @Override
+    public Result<Object> getProjectReport(String category, Long projectId, String startTime, String endTime, String sortCode, String order, Integer pageSize, Integer pageNo) throws Exception {
+        if (Check.isNull(order)) {
+            order = "DESC";
+        }
+        if (Check.isNull(sortCode)) {
+            sortCode = "cost";
+        }
+        Integer startTimeInt = DateUtils.getDateInteger(startTime);
+        Integer endTimeInt = DateUtils.getDateInteger(endTime);
+        Integer nowHour = DateUtils.getNowHour();
+        String today = DateUtils.formatDate(new Date());
+
+        List<JSONObject> data;
+        if (startTime.equals(endTime) && today.equals(startTime)) {
+            data = buildTodayProjectReport(category, projectId, startTime, startTimeInt, nowHour, sortCode, order);
+        } else {
+            int days = DateUtils.dateDiff(startTime, endTime) + 1;
+            Integer lastStart = DateUtils.getDateInteger(DateUtils.getLastDay(startTime, days));
+            Integer lastEnd = DateUtils.getDateInteger(DateUtils.getLastDay(endTime, days));
+            data = adqAdvertiserReportMapper.getProjectMoreDaysReport(projectId, startTimeInt, endTimeInt, lastStart, lastEnd, sortCode, order);
+        }
+        PageInfo<JSONObject> page = new PageInfo<>();
+        page.setList(data);
+        return Result.OK(page);
+    }
+
+    @Override
+    public Result<Object> getOperateInfo(String startTime, String endTime) {
+        try {
+            Integer hour = DateUtils.getNowHour();
+            String nowDateStr = DateUtils.formatDate(new Date());
+
+            Long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
+            Long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
+            String lastDay = DateUtils.getLastDay(startTime, 1);
+            int days = DateUtils.dateDiff(startTime, endTime);
+            Long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastDay));
+            Long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(DateUtils.getLastDay(lastDay, days)));
+
+            List<String> userIds = dashboardQuerySupport.getAllOperationUserIds("16");
+            List<JSONObject> list;
+            if (startTime.equals(endTime) && startTime.equals(nowDateStr)) {
+                list = adqAdvertiserReportMapper.getAdqOperateInfoHourly(hour, startDate, entDate, lastTimeEnd, lastTimeStart, userIds);
+            } else {
+                list = adqAdvertiserReportMapper.getAdqOperateInfo(startDate, entDate, lastTimeEnd, lastTimeStart, userIds);
+            }
+            PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
+            return Result.successMsg("查询成功。", pageInfo);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.errorMsg("查询失败了。");
+    }
+
+    private List<JSONObject> buildTodayProjectReport(String category, Long projectId, String startTime, Integer startTimeInt, Integer nowHour, String sortCode, String order) {
+        List<JSONObject> baseRows = adqAdvertiserReportMapper.getProjectTodayBase(projectId, startTimeInt);
+        if (baseRows == null || baseRows.isEmpty()) {
+            return new ArrayList<>();
+        }
+        List<Long> projectIds = baseRows.stream()
+                .map(item -> item.getLong("projectId"))
+                .filter(id -> id != null)
+                .collect(Collectors.toList());
+        if (projectIds.isEmpty()) {
+            return new ArrayList<>();
+        }
+
+        Integer yesterday = DateUtils.getDateInteger(DateUtils.getLastDay(startTime, 1));
+        Map<Long, JSONObject> metaMap = toLongKeyMap(adqAdvertiserReportMapper.getProjectMetaByIds(projectIds));
+        Map<Long, JSONObject> prevCostMap = toLongKeyMap(adqAdvertiserReportMapper.getProjectPrevHourlyCostByDayAndIds(yesterday, nowHour, projectIds));
+
+        List<JSONObject> rows = new ArrayList<>();
+        for (JSONObject baseRow : baseRows) {
+            Long projectIdValue = baseRow.getLong("projectId");
+            if (projectIdValue == null) {
+                continue;
+            }
+            JSONObject row = new JSONObject(new LinkedHashMap<>());
+            JSONObject meta = metaMap.get(projectIdValue);
+            JSONObject prevCost = prevCostMap.get(projectIdValue);
+
+            double cost = getDouble(baseRow, "cost");
+            double lastCost = getDouble(prevCost, "cost");
+            row.put("projectId", projectIdValue);
+            row.put("projectName", getString(meta, "projectName"));
+            row.put("productName", getString(meta, "productName"));
+            row.put("companyName", getString(baseRow, "companyName"));
+            row.put("saler", getString(meta, "saler"));
+            row.put("operater", getString(meta, "operater"));
+            row.put("cost", cost);
+            row.put("aclick", getLong(baseRow, "aclick"));
+            row.put("bclick", getLong(baseRow, "bclick"));
+            row.put("num", null);
+            row.put("ssAd", "-");
+            row.put("sxhAd", "-");
+            row.put("lmAd", "-");
+            row.put("xxlAd", "-");
+            row.put("jlAd", "-");
+            row.put("kpAd", "-");
+            row.put("accountNum", getLong(baseRow, "accountNum"));
+            row.put("operaterNum", getLong(baseRow, "operaterNum"));
+            row.put("materialUploadMediaNum", null);
+            if (lastCost == 0D) {
+                row.put("rio", "-");
+                row.put("rioValue", null);
+            } else {
+                double rioValue = new BigDecimal((cost - lastCost) / lastCost * 100)
+                        .setScale(2, BigDecimal.ROUND_HALF_UP)
+                        .doubleValue();
+                row.put("rioValue", rioValue);
+                row.put("rio", new BigDecimal(rioValue).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "%");
+            }
+            rows.add(row);
+        }
+        if ("1".equals(category)) {
+            rows = rows.stream()
+                    .filter(item -> item.getDouble("rioValue") != null && item.getDouble("rioValue") <= -10D)
+                    .collect(Collectors.toList());
+        }
+        sortProjectRows(rows, sortCode, order);
+        return rows;
+    }
+
+    @Override
+    public Result<Object> getOperateGroupInfo(String startTime, String endTime) {
+        try {
+            Integer hour = DateUtils.getNowHour();
+            String nowDateStr = DateUtils.formatDate(new Date());
+
+            Long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
+            Long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
+            String lastDay = DateUtils.getLastDay(startTime, 1);
+            int days = DateUtils.dateDiff(startTime, endTime);
+            Long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastDay));
+            Long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(DateUtils.getLastDay(lastDay, days)));
+
+            List<JSONObject> list = new ArrayList<>();
+            List<KuaiShouOperateGroupVo> operationManagerList = dashboardQuerySupport.getTencentOperationManagers();
+            List<String> managerIds = operationManagerList.stream().map(KuaiShouOperateGroupVo::getUserId).collect(Collectors.toList());
+            if (managerIds.isEmpty()) {
+                return Result.successMsg("查询成功。", new PageInfo<>(list));
+            }
+            Map<String, Set<String>> teamMembers = dashboardQuerySupport.getOperateTeamMembers("16", managerIds, startDate, entDate);
+            List<String> allUserIds = teamMembers.values().stream().flatMap(Set::stream).distinct().collect(Collectors.toList());
+            if (allUserIds.isEmpty()) {
+                return Result.successMsg("查询成功。", new PageInfo<>(list));
+            }
+            Map<String, JSONObject> currentMap;
+            Map<String, JSONObject> previousMap;
+            if (startTime.equals(endTime) && startTime.equals(nowDateStr)) {
+                currentMap = toMetricMap(adqAdvertiserReportMapper.getOperateGroupCurrentHourlyByUsers(hour, startDate, entDate, allUserIds));
+                previousMap = toMetricMap(adqAdvertiserReportMapper.getOperateGroupPreviousHourlyByUsers(hour, lastTimeStart, lastTimeEnd, allUserIds));
+            } else {
+                currentMap = toMetricMap(adqAdvertiserReportMapper.getOperateGroupCurrentByUsers(startDate, entDate, allUserIds));
+                previousMap = toMetricMap(adqAdvertiserReportMapper.getOperateGroupPreviousByUsers(lastTimeStart, lastTimeEnd, allUserIds));
+            }
+            for (KuaiShouOperateGroupVo groupVo : operationManagerList) {
+                Set<String> memberIds = teamMembers.get(groupVo.getUserId());
+                if (memberIds == null || memberIds.isEmpty()) {
+                    continue;
+                }
+                List<String> activeMemberIds = memberIds.stream().filter(currentMap::containsKey).collect(Collectors.toList());
+                if (activeMemberIds.isEmpty()) {
+                    continue;
+                }
+                JSONObject vo = new JSONObject();
+                vo.put("userId", groupVo.getUserId());
+                vo.put("realname", groupVo.getRealname());
+                vo.put("operationNum", activeMemberIds.size());
+                long accountNum = 0L;
+                long projectNums = 0L;
+                double totalCost = 0D;
+                double lastCost = 0D;
+                for (String memberId : activeMemberIds) {
+                    JSONObject current = currentMap.get(memberId);
+                    if (current != null) {
+                        accountNum += getLong(current, "accountNum");
+                        projectNums += getLong(current, "projectNum");
+                        totalCost += getDouble(current, "totalCost");
+                    }
+                    JSONObject previous = previousMap.get(memberId);
+                    if (previous != null) {
+                        lastCost += getDouble(previous, "lastCost");
+                    }
+                }
+                vo.put("accountNum", accountNum);
+                vo.put("projectNums", projectNums);
+                vo.put("totalCost", totalCost);
+                vo.put("lastCost", lastCost);
+                if (lastCost == 0D) {
+                    vo.put("yearOnYearCost", "0%");
+                } else {
+                    vo.put("yearOnYearCost", new BigDecimal((totalCost - lastCost) / lastCost * 100).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "%");
+                }
+                Integer operationNum = vo.getInteger("operationNum");
+                Double aveDay = totalCost / (days + 1);
+                vo.put("averageDayCost", new BigDecimal(aveDay).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
+                Double avePeople = operationNum == 0 ? 0D : totalCost / operationNum;
+                vo.put("averagePeopleCost", new BigDecimal(avePeople).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
+                Double aveAccount = accountNum == 0 ? 0D : totalCost / accountNum;
+                vo.put("averageAccountCost", new BigDecimal(aveAccount).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
+                list.add(vo);
+            }
+            if (!Check.isNull(list)) {
+                Collections.sort(list, new Comparator<JSONObject>() {
+                    @Override
+                    public int compare(JSONObject o1, JSONObject o2) {
+                        return o2.getDouble("totalCost").compareTo(o1.getDouble("totalCost"));
+                    }
+                });
+            }
+            PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
+            return Result.successMsg("查询成功。", pageInfo);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return Result.errorMsg("查询失败了。");
+    }
+
+    private Map<String, JSONObject> toMetricMap(List<JSONObject> rows) {
+        if (rows == null || rows.isEmpty()) {
+            return Collections.emptyMap();
+        }
+        return rows.stream()
+                .filter(item -> item != null && item.getString("userId") != null)
+                .collect(Collectors.toMap(item -> item.getString("userId"), item -> item, (left, right) -> left));
+    }
+
+    private Map<Long, JSONObject> toLongKeyMap(List<JSONObject> rows) {
+        if (rows == null || rows.isEmpty()) {
+            return Collections.emptyMap();
+        }
+        return rows.stream()
+                .filter(item -> item != null && item.getLong("projectId") != null)
+                .collect(Collectors.toMap(item -> item.getLong("projectId"), item -> item, (left, right) -> left));
+    }
+
+    private void sortProjectRows(List<JSONObject> rows, String sortCode, String order) {
+        if (rows == null || rows.isEmpty()) {
+            return;
+        }
+        String actualSortCode = Check.isNull(sortCode) || "charge".equals(sortCode) ? "cost" : sortCode;
+        Comparator<JSONObject> comparator = (left, right) -> compareSortValue(left.get(actualSortCode), right.get(actualSortCode));
+        if ("ASC".equalsIgnoreCase(order)) {
+            rows.sort(comparator);
+        } else {
+            rows.sort(comparator.reversed());
+        }
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    private int compareSortValue(Object left, Object right) {
+        if (left == right) {
+            return 0;
+        }
+        if (left == null) {
+            return -1;
+        }
+        if (right == null) {
+            return 1;
+        }
+        if (left instanceof Number || right instanceof Number) {
+            return BigDecimal.valueOf(Double.parseDouble(String.valueOf(left)))
+                    .compareTo(BigDecimal.valueOf(Double.parseDouble(String.valueOf(right))));
+        }
+        if (left instanceof Comparable && right instanceof Comparable) {
+            return ((Comparable) left).compareTo(right);
+        }
+        return String.valueOf(left).compareTo(String.valueOf(right));
+    }
+
+    private long getLong(JSONObject row, String key) {
+        if (row == null) {
+            return 0L;
+        }
+        Long value = row.getLong(key);
+        return value == null ? 0L : value;
+    }
+
+    private double getDouble(JSONObject row, String key) {
+        if (row == null) {
+            return 0D;
+        }
+        Double value = row.getDouble(key);
+        return value == null ? 0D : value;
+    }
+
+    private String getString(JSONObject row, String key) {
+        return row == null ? null : row.getString(key);
+    }
+}

+ 91 - 24
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/BytedanceAccountReportDailyDwServiceImpl.java

@@ -7,8 +7,8 @@ import org.jeecg.common.util.DateUtils;
 import org.jeecg.ctop.material.constants.Check;
 import org.jeecg.ctop.material.constants.Check;
 import org.jeecg.ctop.material.entity.vo.KuaiShouOperateGroupVo;
 import org.jeecg.ctop.material.entity.vo.KuaiShouOperateGroupVo;
 import org.jeecg.ctop.material.mapper.BytedanceAccountReportDailyDwMapper;
 import org.jeecg.ctop.material.mapper.BytedanceAccountReportDailyDwMapper;
-import org.jeecg.ctop.material.mapper.MaterialStareMapper;
 import org.jeecg.ctop.material.service.IBytedanceAccountReportDailyDwService;
 import org.jeecg.ctop.material.service.IBytedanceAccountReportDailyDwService;
+import org.jeecg.ctop.material.service.support.DashboardQuerySupport;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
@@ -20,6 +20,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.Set;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 
 @Service
 @Service
 public class BytedanceAccountReportDailyDwServiceImpl implements IBytedanceAccountReportDailyDwService {
 public class BytedanceAccountReportDailyDwServiceImpl implements IBytedanceAccountReportDailyDwService {
@@ -28,7 +29,7 @@ public class BytedanceAccountReportDailyDwServiceImpl implements IBytedanceAccou
     private BytedanceAccountReportDailyDwMapper bytedanceAccountReportDailyDwMapper;
     private BytedanceAccountReportDailyDwMapper bytedanceAccountReportDailyDwMapper;
 
 
     @Resource
     @Resource
-    private MaterialStareMapper materialStareMapper;
+    private DashboardQuerySupport dashboardQuerySupport;
 
 
     @Override
     @Override
     public JSONObject getTotalCharge(Map<String, Object> paramsMap) {
     public JSONObject getTotalCharge(Map<String, Object> paramsMap) {
@@ -83,8 +84,9 @@ public class BytedanceAccountReportDailyDwServiceImpl implements IBytedanceAccou
         int size = today.size();
         int size = today.size();
         if (dayNum - size != 0) {
         if (dayNum - size != 0) {
             List<String> days = DateUtils.getDays(startTime, endTime);
             List<String> days = DateUtils.getDays(startTime, endTime);
+            Set<String> existingDays = today.stream().map(item -> item.getString("time")).collect(Collectors.toSet());
             for (String day : days) {
             for (String day : days) {
-                if (!today.contains(day)) {
+                if (!existingDays.contains(day)) {
                     JSONObject obj = new JSONObject();
                     JSONObject obj = new JSONObject();
                     obj.put("time", day);
                     obj.put("time", day);
                     obj.put("cost", 0.00);
                     obj.put("cost", 0.00);
@@ -150,7 +152,7 @@ public class BytedanceAccountReportDailyDwServiceImpl implements IBytedanceAccou
             Long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastDay));
             Long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastDay));
             Long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(DateUtils.getLastDay(lastDay, days)));
             Long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(DateUtils.getLastDay(lastDay, days)));
 
 
-            List<String> userIds = materialStareMapper.getAllOperationByMediaId("1");
+            List<String> userIds = dashboardQuerySupport.getAllOperationUserIds("1");
             List<JSONObject> list = new ArrayList<>();
             List<JSONObject> list = new ArrayList<>();
             if (startTime.equals(endTime) && startTime.equals(nowDateStr)) {
             if (startTime.equals(endTime) && startTime.equals(nowDateStr)) {
                 list = bytedanceAccountReportDailyDwMapper.getToutiaoOperateInfoHourly(hour, startDate, entDate, lastTimeEnd, lastTimeStart, userIds);
                 list = bytedanceAccountReportDailyDwMapper.getToutiaoOperateInfoHourly(hour, startDate, entDate, lastTimeEnd, lastTimeStart, userIds);
@@ -185,39 +187,85 @@ public class BytedanceAccountReportDailyDwServiceImpl implements IBytedanceAccou
             Long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastDay));
             Long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastDay));
             Long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(DateUtils.getLastDay(lastDay, days)));
             Long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(DateUtils.getLastDay(lastDay, days)));
 
 
-            List<KuaiShouOperateGroupVo> operationManagerList = materialStareMapper.getOperationManagerUser("touTiaoOperationManager");
             List<JSONObject> list = new ArrayList<>();
             List<JSONObject> list = new ArrayList<>();
+            List<KuaiShouOperateGroupVo> operationManagerList = dashboardQuerySupport.getOperationManagers("touTiaoOperationManager");
+            List<String> managerIds = operationManagerList.stream().map(KuaiShouOperateGroupVo::getUserId).collect(Collectors.toList());
+            if (managerIds.isEmpty()) {
+                return Result.successMsg("查询成功。", new PageInfo<>(list));
+            }
+            Map<String, Set<String>> teamMembers = dashboardQuerySupport.getOperateTeamMembers("1", managerIds, startDate, entDate);
+            List<String> allUserIds = teamMembers.values().stream().flatMap(Set::stream).distinct().collect(Collectors.toList());
+            if (allUserIds.isEmpty()) {
+                return Result.successMsg("查询成功。", new PageInfo<>(list));
+            }
+            Map<String, JSONObject> currentMap;
+            Map<String, JSONObject> previousMap;
+            Map<String, JSONObject> baseMap;
+            if (startTime.equals(endTime) && startTime.equals(nowDateStr)) {
+                currentMap = toMetricMap(bytedanceAccountReportDailyDwMapper.getOperateGroupCurrentHourlyByUsers(hour, startDate, entDate, allUserIds));
+                previousMap = toMetricMap(bytedanceAccountReportDailyDwMapper.getOperateGroupPreviousHourlyByUsers(hour, lastTimeStart, lastTimeEnd, allUserIds));
+            } else {
+                currentMap = toMetricMap(bytedanceAccountReportDailyDwMapper.getOperateGroupCurrentByUsers(startDate, entDate, allUserIds));
+                previousMap = toMetricMap(bytedanceAccountReportDailyDwMapper.getOperateGroupPreviousByUsers(lastTimeStart, lastTimeEnd, allUserIds));
+            }
+            baseMap = toMetricMap(bytedanceAccountReportDailyDwMapper.getOperateGroupBaseByUsers(startDate, entDate, allUserIds));
             for (KuaiShouOperateGroupVo groupVo : operationManagerList) {
             for (KuaiShouOperateGroupVo groupVo : operationManagerList) {
-                //有消耗的运营人员
-                Set<String> operatorUserIds = materialStareMapper.queryToutiaoOperateTeamMember(groupVo.getUserId(), startDate, entDate);
-                if (Check.isNull(operatorUserIds)) {
+                Set<String> memberIds = teamMembers.get(groupVo.getUserId());
+                if (memberIds == null || memberIds.isEmpty()) {
                     continue;
                     continue;
                 }
                 }
-                //运营数量
-                int operationNum = operatorUserIds.size();
-                //查询账户数据
-                JSONObject vo = new JSONObject();
-                if (startTime.equals(endTime) && startTime.equals(nowDateStr)) {
-                    //时报
-                    vo = bytedanceAccountReportDailyDwMapper.getToutiaoOperateGroupInfoHourly(hour, startDate, entDate, lastTimeEnd, lastTimeStart, operatorUserIds);
-                } else {
-                    vo = bytedanceAccountReportDailyDwMapper.getToutiaoOperateGroupInfo(startDate, entDate, lastTimeEnd, lastTimeStart, operatorUserIds);
+                List<String> activeMemberIds = memberIds.stream().filter(currentMap::containsKey).collect(Collectors.toList());
+                if (activeMemberIds.isEmpty()) {
+                    continue;
                 }
                 }
+                JSONObject vo = new JSONObject();
                 vo.put("userId", groupVo.getUserId());
                 vo.put("userId", groupVo.getUserId());
                 vo.put("realname", groupVo.getRealname());
                 vo.put("realname", groupVo.getRealname());
-                vo.put("operationNum", operationNum);
-                //总花费
-                Double totalCost = vo.getDouble("totalCost");
+                vo.put("operationNum", activeMemberIds.size());
+                long accountNum = 0L;
+                long projectNums = 0L;
+                double totalCost = 0D;
+                double lastCost = 0D;
+                long unitNum = 0L;
+                long projectNum = 0L;
+                for (String memberId : activeMemberIds) {
+                    JSONObject current = currentMap.get(memberId);
+                    if (current != null) {
+                        accountNum += getLong(current, "accountNum");
+                        projectNums += getLong(current, "projectNum");
+                        totalCost += getDouble(current, "totalCost");
+                    }
+                    JSONObject previous = previousMap.get(memberId);
+                    if (previous != null) {
+                        lastCost += getDouble(previous, "lastCost");
+                    }
+                    JSONObject base = baseMap.get(memberId);
+                    if (base != null) {
+                        unitNum += getLong(base, "unitNum");
+                        projectNum += getLong(base, "projectNum");
+                    }
+                }
+                vo.put("accountNum", accountNum);
+                vo.put("projectNums", projectNums);
+                vo.put("totalCost", totalCost);
+                vo.put("lastCost", lastCost);
+                if (lastCost == 0D) {
+                    vo.put("yearOnYearCost", "0%");
+                } else {
+                    vo.put("yearOnYearCost", new BigDecimal((totalCost - lastCost) / lastCost * 100).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "%");
+                }
+                vo.put("unitNum", unitNum);
+                vo.put("projectNum", projectNum);
+                Integer operationNum = vo.getInteger("operationNum");
                 //日均消耗 总花费/天数
                 //日均消耗 总花费/天数
-                Double aveDay = totalCost / (days + 1);
+                double aveDay = totalCost / (days + 1);
                 vo.put("averageDayCost", new BigDecimal(aveDay).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
                 vo.put("averageDayCost", new BigDecimal(aveDay).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
                 //人均消耗
                 //人均消耗
-                Double avePeople = totalCost / operationNum;
+                double avePeople = operationNum == 0 ? 0D : totalCost / operationNum;
                 vo.put("averagePeopleCost", new BigDecimal(avePeople).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
                 vo.put("averagePeopleCost", new BigDecimal(avePeople).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
                 //账户数量
                 //账户数量
-                Long accountNum = vo.getLong("accountNum");
                 //平均账户消耗 总花费/账户数量
                 //平均账户消耗 总花费/账户数量
-                Double aveAccount = accountNum == 0 ? 0 : totalCost / accountNum;
+                double aveAccount = accountNum == 0 ? 0D : totalCost / accountNum;
                 vo.put("averageAccountCost", new BigDecimal(aveAccount).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
                 vo.put("averageAccountCost", new BigDecimal(aveAccount).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
                 list.add(vo);
                 list.add(vo);
             }
             }
@@ -237,4 +285,23 @@ public class BytedanceAccountReportDailyDwServiceImpl implements IBytedanceAccou
         return Result.errorMsg("查询失败了。");
         return Result.errorMsg("查询失败了。");
     }
     }
 
 
+    private Map<String, JSONObject> toMetricMap(List<JSONObject> rows) {
+        if (rows == null || rows.isEmpty()) {
+            return Collections.emptyMap();
+        }
+        return rows.stream()
+                .filter(item -> item != null && item.getString("userId") != null)
+                .collect(Collectors.toMap(item -> item.getString("userId"), item -> item, (left, right) -> left));
+    }
+
+    private long getLong(JSONObject row, String key) {
+        Long value = row.getLong(key);
+        return value == null ? 0L : value;
+    }
+
+    private double getDouble(JSONObject row, String key) {
+        Double value = row.getDouble(key);
+        return value == null ? 0D : value;
+    }
+
 }
 }

+ 88 - 24
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/KuaishouAccountReportDailyDwServiceImpl.java

@@ -7,8 +7,8 @@ import org.jeecg.common.util.DateUtils;
 import org.jeecg.ctop.material.constants.Check;
 import org.jeecg.ctop.material.constants.Check;
 import org.jeecg.ctop.material.entity.vo.KuaiShouOperateGroupVo;
 import org.jeecg.ctop.material.entity.vo.KuaiShouOperateGroupVo;
 import org.jeecg.ctop.material.mapper.KuaishouAccountReportDailyDwMapper;
 import org.jeecg.ctop.material.mapper.KuaishouAccountReportDailyDwMapper;
-import org.jeecg.ctop.material.mapper.MaterialStareMapper;
 import org.jeecg.ctop.material.service.IKuaishouAccountReportDailyDwService;
 import org.jeecg.ctop.material.service.IKuaishouAccountReportDailyDwService;
+import org.jeecg.ctop.material.service.support.DashboardQuerySupport;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
@@ -20,6 +20,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.Set;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 
 @Service
 @Service
 public class KuaishouAccountReportDailyDwServiceImpl implements IKuaishouAccountReportDailyDwService {
 public class KuaishouAccountReportDailyDwServiceImpl implements IKuaishouAccountReportDailyDwService {
@@ -27,7 +28,7 @@ public class KuaishouAccountReportDailyDwServiceImpl implements IKuaishouAccount
     private KuaishouAccountReportDailyDwMapper kuaishouAccountReportDailyDwMapper;
     private KuaishouAccountReportDailyDwMapper kuaishouAccountReportDailyDwMapper;
 
 
     @Resource
     @Resource
-    private MaterialStareMapper materialStareMapper;
+    private DashboardQuerySupport dashboardQuerySupport;
 
 
     @Override
     @Override
     public JSONObject getTotalCharge(Map<String, Object> paramsMap) {
     public JSONObject getTotalCharge(Map<String, Object> paramsMap) {
@@ -82,8 +83,9 @@ public class KuaishouAccountReportDailyDwServiceImpl implements IKuaishouAccount
         int size = today.size();
         int size = today.size();
         if (dayNum - size != 0) {
         if (dayNum - size != 0) {
             List<String> days = DateUtils.getDays(startTime, endTime);
             List<String> days = DateUtils.getDays(startTime, endTime);
+            Set<String> existingDays = today.stream().map(item -> item.getString("time")).collect(Collectors.toSet());
             for (String day : days) {
             for (String day : days) {
-                if (!today.contains(day)) {
+                if (!existingDays.contains(day)) {
                     JSONObject obj = new JSONObject();
                     JSONObject obj = new JSONObject();
                     obj.put("time", day);
                     obj.put("time", day);
                     obj.put("charge", 0.00);
                     obj.put("charge", 0.00);
@@ -149,7 +151,7 @@ public class KuaishouAccountReportDailyDwServiceImpl implements IKuaishouAccount
             Long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastDay));
             Long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastDay));
             Long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(DateUtils.getLastDay(lastDay, days)));
             Long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(DateUtils.getLastDay(lastDay, days)));
 
 
-            List<String> userIds = materialStareMapper.getAllOperationByMediaId("2");
+            List<String> userIds = dashboardQuerySupport.getAllOperationUserIds("2");
             List<JSONObject> list = new ArrayList<>();
             List<JSONObject> list = new ArrayList<>();
             if (startTime.equals(endTime) && startTime.equals(nowDateStr)) {
             if (startTime.equals(endTime) && startTime.equals(nowDateStr)) {
                 list = kuaishouAccountReportDailyDwMapper.getKuaishouOperateInfoHourly(hour, startDate, entDate, lastTimeEnd, lastTimeStart, userIds);
                 list = kuaishouAccountReportDailyDwMapper.getKuaishouOperateInfoHourly(hour, startDate, entDate, lastTimeEnd, lastTimeStart, userIds);
@@ -184,39 +186,82 @@ public class KuaishouAccountReportDailyDwServiceImpl implements IKuaishouAccount
             Long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastDay));
             Long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastDay));
             Long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(DateUtils.getLastDay(lastDay, days)));
             Long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(DateUtils.getLastDay(lastDay, days)));
 
 
-            List<KuaiShouOperateGroupVo> operationManagerList = materialStareMapper.getOperationManagerUser("kuaishouOperationManager");
             List<JSONObject> list = new ArrayList<>();
             List<JSONObject> list = new ArrayList<>();
+            List<KuaiShouOperateGroupVo> operationManagerList = dashboardQuerySupport.getOperationManagers("kuaishouOperationManager");
+            List<String> managerIds = operationManagerList.stream().map(KuaiShouOperateGroupVo::getUserId).collect(Collectors.toList());
+            if (managerIds.isEmpty()) {
+                return Result.successMsg("查询成功。", new PageInfo<>(list));
+            }
+            Map<String, Set<String>> teamMembers = dashboardQuerySupport.getOperateTeamMembers("2", managerIds, startDate, entDate);
+            List<String> allUserIds = teamMembers.values().stream().flatMap(Set::stream).distinct().collect(Collectors.toList());
+            if (allUserIds.isEmpty()) {
+                return Result.successMsg("查询成功。", new PageInfo<>(list));
+            }
+            Map<String, JSONObject> currentMap;
+            Map<String, JSONObject> previousMap;
+            Map<String, JSONObject> baseMap;
+            if (startTime.equals(endTime) && startTime.equals(nowDateStr)) {
+                currentMap = toMetricMap(kuaishouAccountReportDailyDwMapper.getOperateGroupCurrentHourlyByUsers(hour, startDate, entDate, allUserIds));
+                previousMap = toMetricMap(kuaishouAccountReportDailyDwMapper.getOperateGroupPreviousHourlyByUsers(hour, lastTimeStart, lastTimeEnd, allUserIds));
+            } else {
+                currentMap = toMetricMap(kuaishouAccountReportDailyDwMapper.getOperateGroupCurrentByUsers(startDate, entDate, allUserIds));
+                previousMap = toMetricMap(kuaishouAccountReportDailyDwMapper.getOperateGroupPreviousByUsers(lastTimeStart, lastTimeEnd, allUserIds));
+            }
+            baseMap = toMetricMap(kuaishouAccountReportDailyDwMapper.getOperateGroupBaseByUsers(startDate, entDate, allUserIds));
             for (KuaiShouOperateGroupVo groupVo : operationManagerList) {
             for (KuaiShouOperateGroupVo groupVo : operationManagerList) {
-                //下级员工
-                Set<String> operatorUserIds = materialStareMapper.queryKuaishouOperateTeamMember(groupVo.getUserId(), startDate, entDate);
-                if (Check.isNull(operatorUserIds)) {
+                Set<String> memberIds = teamMembers.get(groupVo.getUserId());
+                if (memberIds == null || memberIds.isEmpty()) {
                     continue;
                     continue;
                 }
                 }
-                //运营数量
-                int operationNum = operatorUserIds.size();
-                //查询账户数据
-                JSONObject vo = new JSONObject();
-                if (startTime.equals(endTime) && startTime.equals(nowDateStr)) {
-                    //时报
-                    vo = kuaishouAccountReportDailyDwMapper.getKuaishouOperateGroupInfoHourly(hour, startDate, entDate, lastTimeEnd, lastTimeStart, operatorUserIds);
-                } else {
-                    vo = kuaishouAccountReportDailyDwMapper.getKuaishouOperateGroupInfo(startDate, entDate, lastTimeEnd, lastTimeStart, operatorUserIds);
+                List<String> activeMemberIds = memberIds.stream().filter(currentMap::containsKey).collect(Collectors.toList());
+                if (activeMemberIds.isEmpty()) {
+                    continue;
                 }
                 }
+                JSONObject vo = new JSONObject();
                 vo.put("userId", groupVo.getUserId());
                 vo.put("userId", groupVo.getUserId());
                 vo.put("realname", groupVo.getRealname());
                 vo.put("realname", groupVo.getRealname());
-                vo.put("operationNum", operationNum);
-                //总花费
-                Double totalCost = vo.getDouble("totalCost");
+                vo.put("operationNum", activeMemberIds.size());
+                long accountNum = 0L;
+                long projectNums = 0L;
+                double totalCost = 0D;
+                double lastCost = 0D;
+                long unitNum = 0L;
+                for (String memberId : activeMemberIds) {
+                    JSONObject current = currentMap.get(memberId);
+                    if (current != null) {
+                        accountNum += getLong(current, "accountNum");
+                        projectNums += getLong(current, "projectNum");
+                        totalCost += getDouble(current, "totalCost");
+                    }
+                    JSONObject previous = previousMap.get(memberId);
+                    if (previous != null) {
+                        lastCost += getDouble(previous, "lastCost");
+                    }
+                    JSONObject base = baseMap.get(memberId);
+                    if (base != null) {
+                        unitNum += getLong(base, "unitNum");
+                    }
+                }
+                vo.put("accountNum", accountNum);
+                vo.put("projectNums", projectNums);
+                vo.put("totalCost", totalCost);
+                vo.put("lastCost", lastCost);
+                if (lastCost == 0D) {
+                    vo.put("yearOnYearCost", "0%");
+                } else {
+                    vo.put("yearOnYearCost", new BigDecimal((totalCost - lastCost) / lastCost * 100).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "%");
+                }
+                vo.put("unitNum", unitNum);
+                Integer operationNum = vo.getInteger("operationNum");
                 //日均消耗 总花费/天数
                 //日均消耗 总花费/天数
-                Double aveDay = totalCost / (days + 1);
+                double aveDay = totalCost / (days + 1);
                 vo.put("averageDayCost", new BigDecimal(aveDay).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
                 vo.put("averageDayCost", new BigDecimal(aveDay).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
                 //人均消耗
                 //人均消耗
-                Double avePeople = totalCost / operationNum;
+                double avePeople = operationNum == 0 ? 0D : totalCost / operationNum;
                 vo.put("averagePeopleCost", new BigDecimal(avePeople).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
                 vo.put("averagePeopleCost", new BigDecimal(avePeople).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
                 //账户数量
                 //账户数量
-                Long accountNum = vo.getLong("accountNum");
                 //平均账户消耗 总花费/账户数量
                 //平均账户消耗 总花费/账户数量
-                Double aveAccount = accountNum == 0 ? 0 : totalCost / accountNum;
+                double aveAccount = accountNum == 0 ? 0D : totalCost / accountNum;
                 vo.put("averageAccountCost", new BigDecimal(aveAccount).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
                 vo.put("averageAccountCost", new BigDecimal(aveAccount).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue());
                 list.add(vo);
                 list.add(vo);
             }
             }
@@ -235,4 +280,23 @@ public class KuaishouAccountReportDailyDwServiceImpl implements IKuaishouAccount
         }
         }
         return Result.errorMsg("查询失败了。");
         return Result.errorMsg("查询失败了。");
     }
     }
+
+    private Map<String, JSONObject> toMetricMap(List<JSONObject> rows) {
+        if (rows == null || rows.isEmpty()) {
+            return Collections.emptyMap();
+        }
+        return rows.stream()
+                .filter(item -> item != null && item.getString("userId") != null)
+                .collect(Collectors.toMap(item -> item.getString("userId"), item -> item, (left, right) -> left));
+    }
+
+    private long getLong(JSONObject row, String key) {
+        Long value = row.getLong(key);
+        return value == null ? 0L : value;
+    }
+
+    private double getDouble(JSONObject row, String key) {
+        Double value = row.getDouble(key);
+        return value == null ? 0D : value;
+    }
 }
 }

+ 49 - 61
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/SafeTiFlashInterceptor.java

@@ -1,91 +1,79 @@
-/*
 package org.jeecg.ctop.material.service.impl;
 package org.jeecg.ctop.material.service.impl;
 
 
-
-import org.apache.ibatis.executor.Executor;
+import org.apache.ibatis.executor.statement.StatementHandler;
 import org.apache.ibatis.mapping.MappedStatement;
 import org.apache.ibatis.mapping.MappedStatement;
-import org.apache.ibatis.plugin.*;
+import org.apache.ibatis.plugin.Interceptor;
+import org.apache.ibatis.plugin.Intercepts;
+import org.apache.ibatis.plugin.Invocation;
+import org.apache.ibatis.plugin.Plugin;
+import org.apache.ibatis.plugin.Signature;
 import org.apache.ibatis.reflection.MetaObject;
 import org.apache.ibatis.reflection.MetaObject;
 import org.apache.ibatis.reflection.SystemMetaObject;
 import org.apache.ibatis.reflection.SystemMetaObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
-import java.lang.reflect.Proxy;
+
 import java.sql.Connection;
 import java.sql.Connection;
 import java.sql.Statement;
 import java.sql.Statement;
 import java.util.Properties;
 import java.util.Properties;
 
 
-*/
 /**
 /**
- * 使用MetaObject安全获取字段的TiFlash拦截器
- *//*
-
+ * 按 mapper 维度切换 TiDB 读引擎。
+ * 腾讯报表只能走 tikv,快手/头条原有报表在 tiflash 下明显更快。
+ */
 @Intercepts({
 @Intercepts({
-        @Signature(type = Executor.class, method = "query",
-                args = {MappedStatement.class, Object.class,
-                        org.apache.ibatis.session.RowBounds.class,
-                        org.apache.ibatis.session.ResultHandler.class})
+        @Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})
 })
 })
 @Component
 @Component
 public class SafeTiFlashInterceptor implements Interceptor {
 public class SafeTiFlashInterceptor implements Interceptor {
 
 
+    private static final Logger log = LoggerFactory.getLogger(SafeTiFlashInterceptor.class);
+
+    private static final String MATERIAL_MAPPER_PREFIX = "org.jeecg.ctop.material.mapper.";
+    private static final String ADQ_MAPPER_PREFIX = MATERIAL_MAPPER_PREFIX + "AdqAdvertiserReportMapper";
+    private static final String TIKV_ENGINE = "tikv";
+    private static final String TIFLASH_ENGINE = "tiflash,tidb";
+
     @Override
     @Override
     public Object intercept(Invocation invocation) throws Throwable {
     public Object intercept(Invocation invocation) throws Throwable {
         try {
         try {
-            // 使用MetaObject安全获取字段
-            Executor executor = (Executor) invocation.getTarget();
-            MetaObject metaObject = SystemMetaObject.forObject(executor);
-
-            // 获取transaction
-            Object transaction = metaObject.getValue("transaction");
-            if (transaction == null) {
-                // 尝试其他可能的字段名
-                transaction = metaObject.getValue("delegate.transaction");
-            }
-
-            if (transaction != null) {
-                // 获取connection
-                MetaObject transactionMeta = SystemMetaObject.forObject(transaction);
-                Connection connection = (Connection) transactionMeta.getValue("connection");
-
-                if (connection != null) {
-                    // 如果是代理连接,获取原始连接
-                    connection = getRealConnection(connection);
-
-                    try (Statement stmt = connection.createStatement()) {
-                        stmt.execute("SET session tidb_isolation_read_engines = 'tiflash,tidb'");
-                        System.out.println("✅ TiFlash引擎设置成功");
-                    }
+            Connection connection = (Connection) invocation.getArgs()[0];
+            if (connection != null) {
+                String statementId = resolveStatementId(invocation.getTarget());
+                String engine = resolveEngine(statementId);
+                if (engine != null) {
+                    applyEngine(connection, engine);
                 }
                 }
             }
             }
         } catch (Exception e) {
         } catch (Exception e) {
-            // 记录错误但不中断流程
-            System.err.println("TiFlash设置失败: " + e.getMessage());
-            // e.printStackTrace(); // 调试时打开
+            log.warn("set tidb engine failed", e);
         }
         }
-
         return invocation.proceed();
         return invocation.proceed();
     }
     }
 
 
-    */
-/**
-     * 获取真实的Connection对象(处理代理)
-     *//*
+    private String resolveStatementId(Object target) {
+        MetaObject metaObject = SystemMetaObject.forObject(target);
+        MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("delegate.mappedStatement");
+        if (mappedStatement == null) {
+            mappedStatement = (MappedStatement) metaObject.getValue("mappedStatement");
+        }
+        return mappedStatement == null ? null : mappedStatement.getId();
+    }
 
 
-    private Connection getRealConnection(Connection connection) {
-        try {
-            if (Proxy.isProxyClass(connection.getClass())) {
-                // 如果是代理对象,尝试获取委托对象
-                java.lang.reflect.InvocationHandler handler = Proxy.getInvocationHandler(connection);
-                if (handler instanceof org.apache.ibatis.executor.loader.javassist.JavassistProxyFactory) {
-                    // MyBatis代理
-                    return (Connection) handler.getClass()
-                            .getMethod("getTarget")
-                            .invoke(handler);
-                }
-            }
-        } catch (Exception e) {
-            // 如果获取失败,返回原始连接
+    private String resolveEngine(String statementId) {
+        if (statementId == null || !statementId.startsWith(MATERIAL_MAPPER_PREFIX)) {
+            return null;
+        }
+        if (statementId.startsWith(ADQ_MAPPER_PREFIX)) {
+            return TIKV_ENGINE;
+        }
+        return TIFLASH_ENGINE;
+    }
+
+    private void applyEngine(Connection connection, String engine) throws Exception {
+        try (Statement statement = connection.createStatement()) {
+            statement.execute("SET SESSION tidb_isolation_read_engines = '" + engine + "'");
         }
         }
-        return connection;
     }
     }
 
 
     @Override
     @Override
@@ -96,4 +84,4 @@ public class SafeTiFlashInterceptor implements Interceptor {
     @Override
     @Override
     public void setProperties(Properties properties) {
     public void setProperties(Properties properties) {
     }
     }
-}*/
+}

+ 49 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/support/DashboardLocalCacheService.java

@@ -0,0 +1,49 @@
+package org.jeecg.ctop.material.service.support;
+
+import org.springframework.stereotype.Service;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+
+@Service
+public class DashboardLocalCacheService {
+
+    private final ConcurrentHashMap<String, CacheValue> cache = new ConcurrentHashMap<>();
+
+    @SuppressWarnings("unchecked")
+    public <T> T get(String key, long ttlMillis, Supplier<T> loader) {
+        long now = System.currentTimeMillis();
+        CacheValue value = cache.compute(key, (cacheKey, oldValue) -> {
+            if (oldValue != null && oldValue.expireAt > now) {
+                return oldValue;
+            }
+            return new CacheValue(loader.get(), now + ttlMillis);
+        });
+        return value == null ? null : (T) value.value;
+    }
+
+    @SuppressWarnings("unchecked")
+    public <T> T getIfCacheable(String key, long ttlMillis, Supplier<T> loader, Predicate<T> cacheablePredicate) {
+        long now = System.currentTimeMillis();
+        CacheValue cachedValue = cache.get(key);
+        if (cachedValue != null && cachedValue.expireAt > now) {
+            return (T) cachedValue.value;
+        }
+        T loadedValue = loader.get();
+        if (cacheablePredicate == null || cacheablePredicate.test(loadedValue)) {
+            cache.put(key, new CacheValue(loadedValue, now + ttlMillis));
+        }
+        return loadedValue;
+    }
+
+    private static class CacheValue {
+        private final Object value;
+        private final long expireAt;
+
+        private CacheValue(Object value, long expireAt) {
+            this.value = value;
+            this.expireAt = expireAt;
+        }
+    }
+}

+ 94 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/support/DashboardQuerySupport.java

@@ -0,0 +1,94 @@
+package org.jeecg.ctop.material.service.support;
+
+import com.alibaba.fastjson.JSONObject;
+import org.jeecg.ctop.material.entity.vo.KuaiShouOperateGroupVo;
+import org.jeecg.ctop.material.mapper.MaterialStareMapper;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+@Service
+public class DashboardQuerySupport {
+
+    private static final long MANAGER_CACHE_TTL = 10 * 60 * 1000L;
+    private static final long OPERATOR_CACHE_TTL = 10 * 60 * 1000L;
+    private static final long TEAM_MEMBER_CACHE_TTL = 10 * 60 * 1000L;
+
+    @Resource
+    private MaterialStareMapper materialStareMapper;
+
+    @Resource
+    private DashboardLocalCacheService dashboardLocalCacheService;
+
+    public List<KuaiShouOperateGroupVo> getOperationManagers(String roleCode) {
+        return dashboardLocalCacheService.get("dashboard:managers:" + roleCode, MANAGER_CACHE_TTL, () -> new ArrayList<>(materialStareMapper.getOperationManagerUser(roleCode)));
+    }
+
+    public List<KuaiShouOperateGroupVo> getTencentOperationManagers() {
+        return dashboardLocalCacheService.get("dashboard:managers:tencent", MANAGER_CACHE_TTL, () -> {
+            List<KuaiShouOperateGroupVo> bytedanceManagers = getOperationManagers("touTiaoOperationManager");
+            List<KuaiShouOperateGroupVo> kuaishouManagers = getOperationManagers("kuaishouOperationManager");
+            Map<String, KuaiShouOperateGroupVo> managerMap = new LinkedHashMap<>();
+            mergeManagers(managerMap, bytedanceManagers);
+            mergeManagers(managerMap, kuaishouManagers);
+            return new ArrayList<>(managerMap.values());
+        });
+    }
+
+    public List<String> getAllOperationUserIds(String mediaId) {
+        return dashboardLocalCacheService.get("dashboard:operators:" + mediaId, OPERATOR_CACHE_TTL, () -> new ArrayList<>(materialStareMapper.getAllOperationByMediaId(mediaId)));
+    }
+
+    public Map<String, Set<String>> getOperateTeamMembers(String mediaId, List<String> managerIds, Long startDate, Long endDate) {
+        if (managerIds == null || managerIds.isEmpty()) {
+            return Collections.emptyMap();
+        }
+        String managerKey = managerIds.stream().sorted().collect(Collectors.joining(","));
+        String cacheKey = "dashboard:team:" + managerKey;
+        List<JSONObject> rows = dashboardLocalCacheService.get(cacheKey, TEAM_MEMBER_CACHE_TTL, () -> loadOperateTeamMembers(mediaId, managerIds, startDate, endDate));
+        Map<String, Set<String>> result = new HashMap<>();
+        if (rows == null) {
+            return result;
+        }
+        for (JSONObject row : rows) {
+            String managerId = row.getString("managerId");
+            String userId = row.getString("userId");
+            if (managerId == null || userId == null) {
+                continue;
+            }
+            result.computeIfAbsent(managerId, key -> new LinkedHashSet<>()).add(userId);
+        }
+        return result;
+    }
+
+    private List<JSONObject> loadOperateTeamMembers(String mediaId, List<String> managerIds, Long startDate, Long endDate) {
+        if ("1".equals(mediaId)) {
+            return materialStareMapper.queryToutiaoOperateTeamMemberBatch(managerIds, startDate, endDate);
+        }
+        if ("16".equals(mediaId)) {
+            return materialStareMapper.queryAdqOperateTeamMemberBatch(managerIds, startDate, endDate);
+        }
+        return materialStareMapper.queryKuaishouOperateTeamMemberBatch(managerIds, startDate, endDate);
+    }
+
+    private void mergeManagers(Map<String, KuaiShouOperateGroupVo> managerMap, List<KuaiShouOperateGroupVo> managers) {
+        if (managers == null || managers.isEmpty()) {
+            return;
+        }
+        for (KuaiShouOperateGroupVo manager : managers) {
+            if (manager == null || manager.getUserId() == null) {
+                continue;
+            }
+            managerMap.putIfAbsent(manager.getUserId(), manager);
+        }
+    }
+}

+ 28 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/support/DashboardStartupWarmup.java

@@ -0,0 +1,28 @@
+package org.jeecg.ctop.material.service.support;
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.ctop.material.controller.ReportController;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
+import org.springframework.context.event.EventListener;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Component
+@Slf4j
+public class DashboardStartupWarmup {
+
+    @Resource
+    private ReportController reportController;
+
+    @EventListener(ApplicationReadyEvent.class)
+    public void warmDashboardSummary() {
+        long start = System.currentTimeMillis();
+        try {
+            reportController.getTotalCharge();
+            log.info("dashboard summary warmup finished in {} ms", System.currentTimeMillis() - start);
+        } catch (Exception e) {
+            log.warn("dashboard summary warmup failed", e);
+        }
+    }
+}

+ 2 - 5
jeecg-boot-material-view/src/main/resources/application-dev.yml

@@ -86,7 +86,7 @@ spring:
         # 初始化大小,最小,最大
         # 初始化大小,最小,最大
         initial-size: 5
         initial-size: 5
         min-idle: 5
         min-idle: 5
-        maxActive: 20
+        maxActive: 50
         # 配置获取连接等待超时的时间
         # 配置获取连接等待超时的时间
         maxWait: 60000
         maxWait: 60000
         # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
         # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
@@ -112,7 +112,7 @@ spring:
           driver-class-name: com.mysql.jdbc.Driver
           driver-class-name: com.mysql.jdbc.Driver
           # 多数据源配置
           # 多数据源配置
           #multi-datasource1:
           #multi-datasource1:
-          url: jdbc:mysql://192.168.0.101:3390/jeecg-boot?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+          url: jdbc:mysql://114.242.47.94:3394/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true&serverTimezone=GMT%2B8&sessionVariables=tidb_isolation_read_engines%3D%27tiflash%2Ctidb%27
           username: hcst
           username: hcst
           password: hcst@2024
           password: hcst@2024
           #driver-class-name: com.mysql.cj.jdbc.Driver
           #driver-class-name: com.mysql.cj.jdbc.Driver
@@ -158,6 +158,3 @@ jeecg :
     cluster-name: jeecg-ES
     cluster-name: jeecg-ES
     cluster-nodes: 127.0.0.1:9200
     cluster-nodes: 127.0.0.1:9200
     check-enabled: false
     check-enabled: false
-
-
-

+ 2 - 2
jeecg-boot-material-view/src/main/resources/application-prod.yml

@@ -87,7 +87,7 @@ spring:
 
 
         initial-size: 5
         initial-size: 5
         min-idle: 5
         min-idle: 5
-        maxActive: 20
+        maxActive: 50
         # 配置获取连接等待超时的时间
         # 配置获取连接等待超时的时间
         maxWait: 60000
         maxWait: 60000
         # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
         # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
@@ -295,4 +295,4 @@ bytedance:
     campaign-report-get: /2/report/campaign/get/
     campaign-report-get: /2/report/campaign/get/
     ad-report-get: /2/report/ad/get/
     ad-report-get: /2/report/ad/get/
     ad-creative-get: /2/report/creative/get/
     ad-creative-get: /2/report/creative/get/
-    advertiser-fund-daily-stat: /2/advertiser/fund/daily_stat/
+    advertiser-fund-daily-stat: /2/advertiser/fund/daily_stat/

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

@@ -121,7 +121,9 @@ public class ProjectController {
         try {
         try {
             QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
             QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
             List<String> mediaIds = new ArrayList<>();
             List<String> mediaIds = new ArrayList<>();
-            if ("1".equals(mediaId)) {
+            if ("16".equals(mediaId)) {
+                mediaIds.add("16");
+            } else if ("1".equals(mediaId)) {
                 mediaIds.add("1");
                 mediaIds.add("1");
                 mediaIds.add("3");
                 mediaIds.add("3");
             } else {
             } else {