浏览代码

报表统计,新上监控 数据源换表

zhaoxian 10 月之前
父节点
当前提交
6981d42a0a

+ 21 - 19
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewGroupReportCtrl.java

@@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.ibatis.annotations.Param;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -54,8 +55,8 @@ public class KsNewGroupReportCtrl {
         Map<String, Object> result = new HashMap<>();
         JSONArray accountIds = requestBody.getJSONArray("accountIds");
         String userId = requestBody.getString("userId");
-        //TODO 没有维护快手事业部负责人角色,增加判断
-        if ("4afe739502ae4258a18c36a000d7ff20".equals(userId) || "228c45f913924639bf20c79ce5dadb16".equals(userId)) {
+        //f6a6843879c949618e4a859140c8a127 李超  丁总 b161b7d9793942f980dbfe8c931cd1b0
+        if ("f6a6843879c949618e4a859140c8a127".equals(userId) || "b161b7d9793942f980dbfe8c931cd1b0".equals(userId)) {
             accountIds = newPlanReportService.getAccountIdsByMedia();
         } else {
             if (!userId.isEmpty()) {
@@ -65,20 +66,20 @@ public class KsNewGroupReportCtrl {
                 return resultBody;
             }
         }
-
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
-        startDate=startDate+" 00:00:00";
-        endDate=endDate+" 59:59:59";
+
+        Integer startDateInteger = DateUtils.getDateInteger(startDate);
+        Integer endDateInteger = DateUtils.getDateInteger(endDate);
+
         String target = requestBody.getString("target");
-        String order = requestBody.getString("order");
         try {
             /*JSONObject sumData = newGroupReportService.getSumNewGroupBy(accountIds, startDate, endDate);
             List<JSONObject> chartData = newGroupReportService.getKsNewGroupGroupByStatDate(accountIds, startDate, endDate);
             List<JSONObject> listData = newGroupReportService.getKsNewGroupGroupByAccount(accountIds, startDate, endDate, target, order);*/
             List<JSONObject> chartData = newMonitorService.getKuaiShouGroupMessageGroup(accountIds, startDate, endDate);
-            JSONObject sumData = newMonitorService.getKuaiShouGroupSum(accountIds, startDate, endDate);
-            List<JSONObject> listData = newMonitorService.getKuaiShouGroupMessage(accountIds, startDate, endDate, target);
+            JSONObject sumData = newMonitorService.getKuaiShouGroupSum(accountIds, startDateInteger, endDateInteger);
+            List<JSONObject> listData = newMonitorService.getKuaiShouGroupMessage(accountIds, startDateInteger, endDateInteger);
             result.put("sumData", sumData);
             result.put("chartData", chartData);
             result.put("listData", listData);
@@ -121,8 +122,8 @@ public class KsNewGroupReportCtrl {
 
         JSONArray accountIds = requestBody.getJSONArray("accountIds");
         String userId = requestBody.getString("userId");
-        //TODO 没有维护快手事业部负责人角色,增加判断
-        if ("6b4c821adc414dc8b7718ab63ccbfcaf".equals(userId)) {
+        //f6a6843879c949618e4a859140c8a127 李超  丁总 b161b7d9793942f980dbfe8c931cd1b0
+        if ("f6a6843879c949618e4a859140c8a127".equals(userId) || "b161b7d9793942f980dbfe8c931cd1b0".equals(userId)) {
             accountIds = newPlanReportService.getAccountIdsByMedia();
         } else {
             if (!userId.isEmpty()) {
@@ -135,10 +136,11 @@ public class KsNewGroupReportCtrl {
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
         String target = requestBody.getString("target");
-        startDate=startDate+" 00:00:00";
-        endDate=endDate+" 59:59:59";
-        String order = requestBody.getString("order");
-        List<JSONObject> listData = newMonitorService.getKuaiShouGroupMessage(accountIds, startDate, endDate, target);
+
+        Integer startDateInteger = DateUtils.getDateInteger(startDate);
+        Integer endDateInteger = DateUtils.getDateInteger(endDate);
+
+        List<JSONObject> listData = newMonitorService.getKuaiShouGroupMessage(accountIds, startDateInteger, endDateInteger);
 
         List<List<Object>> excelList = new ArrayList<>();
         listData.forEach(data -> {
@@ -152,7 +154,7 @@ public class KsNewGroupReportCtrl {
             excelList.add(temp);
         });
         try {
-            String[] headers = {"账户名称","账户ID","账户所属人","新上推广组","有效推广组","最近上新时间"};
+            String[] headers = {"账户名称", "账户ID", "账户所属人", "新上推广组", "有效推广组", "最近上新时间"};
             OutputStream os = response.getOutputStream();
             ExportExcelUtils eeu = new ExportExcelUtils();
             XSSFWorkbook workbook = new XSSFWorkbook();
@@ -170,15 +172,15 @@ public class KsNewGroupReportCtrl {
      * 查询所有的快手运营
      */
     @GetMapping("/report/AllOperator")
-    public Result<List<JSONObject>> getAllOperator(@Param("userId")String userId,@Param("userName")String userName) {
+    public Result<List<JSONObject>> getAllOperator(@Param("userId") String userId, @Param("userName") String userName) {
         Result<List<JSONObject>> result = new Result<>();
-        List<JSONObject> listData=new ArrayList<>();
+        List<JSONObject> listData = new ArrayList<>();
         try {
             String roleCode = sysRoleService.getRoleCodeByUserId(userId);
             if (roleCode != null && roleCode.equals("admin") || roleCode.equals("saleDirector")) {
                 listData = newPlanReportService.getAllOperator();
-            }else {
-                listData=newMonitorService.getOperator(userId,userName);
+            } else {
+                listData = newMonitorService.getOperator(userId, userName);
             }
 
             result.setResult(listData);

+ 17 - 13
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KsNewPlanReportCtrl.java

@@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -47,8 +48,8 @@ public class KsNewPlanReportCtrl {
         Map<String, Object> result = new HashMap<>();
         JSONArray accountIds = requestBody.getJSONArray("accountIds");
         String userId = requestBody.getString("userId");
-        //TODO 没有维护快手事业部负责人角色,增加判断
-        if ("6b4c821adc414dc8b7718ab63ccbfcaf".equals(userId)) {
+        //f6a6843879c949618e4a859140c8a127 李超  丁总 b161b7d9793942f980dbfe8c931cd1b0
+        if ("f6a6843879c949618e4a859140c8a127".equals(userId) || "b161b7d9793942f980dbfe8c931cd1b0".equals(userId)) {
             accountIds = newPlanReportService.getAccountIdsByMedia();
         } else {
             if (!userId.isEmpty()) {
@@ -60,17 +61,18 @@ public class KsNewPlanReportCtrl {
         }
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
-        startDate=startDate+" 00:00:00";
-        endDate=endDate+" 59:59:59";
+
+        Integer startDateInteger = DateUtils.getDateInteger(startDate);
+        Integer endDateInteger = DateUtils.getDateInteger(endDate);
+
         String target = requestBody.getString("target");
-        String order = requestBody.getString("order");
         try {
             /*JSONObject sumData = newPlanReportService.getSumNewPlanBy(accountIds, startDate, endDate);
             List<JSONObject> chartData = newPlanReportService.getKsNewPlanGroupByStatDate(accountIds, startDate, endDate);
             List<JSONObject> listData = newPlanReportService.getKsNewPlanGroupByAccount(accountIds, startDate, endDate, target, order);*/
-           List<JSONObject> listData = newMonitorService.getPlanMessage(accountIds, startDate, endDate, target, "1");
-            List<JSONObject> chartData = newMonitorService.getPlanMessageGroup(accountIds, startDate, endDate, "1");
-            JSONObject sumData = newMonitorService.getPlanSum(accountIds, startDate, endDate, "1");
+            List<JSONObject> listData = newMonitorService.getPlanMessage(accountIds, startDateInteger, endDateInteger);
+            List<JSONObject> chartData = newMonitorService.getPlanMessageGroup(accountIds, startDate, endDate);
+            JSONObject sumData = newMonitorService.getPlanSum(accountIds, startDateInteger, endDateInteger);
             result.put("sumData", sumData);
             result.put("chartData", chartData);
             result.put("listData", listData);
@@ -116,8 +118,8 @@ public class KsNewPlanReportCtrl {
 
         JSONArray accountIds = requestBody.getJSONArray("accountIds");
         String userId = requestBody.getString("userId");
-        //TODO 没有维护快手事业部负责人角色,增加判断
-        if ("6b4c821adc414dc8b7718ab63ccbfcaf".equals(userId)) {
+        //f6a6843879c949618e4a859140c8a127 李超  丁总 b161b7d9793942f980dbfe8c931cd1b0
+        if ("f6a6843879c949618e4a859140c8a127".equals(userId) || "b161b7d9793942f980dbfe8c931cd1b0".equals(userId)) {
             accountIds = newPlanReportService.getAccountIdsByMedia();
         } else {
             if (!userId.isEmpty()) {
@@ -129,11 +131,13 @@ public class KsNewPlanReportCtrl {
         }
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
-        startDate=startDate+" 00:00:00";
-        endDate=endDate+" 59:59:59";
+        Integer startDateInteger = DateUtils.getDateInteger(startDate);
+        Integer endDateInteger = DateUtils.getDateInteger(endDate);
+        startDate = startDate + " 00:00:00";
+        endDate = endDate + " 59:59:59";
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
-        List<JSONObject> listData = newMonitorService.getPlanMessage(accountIds, startDate, endDate, target, "1");
+        List<JSONObject> listData = newMonitorService.getPlanMessage(accountIds, startDateInteger, endDateInteger);
 
         List<List<Object>> excelList = new ArrayList<>();
         listData.forEach(data -> {

+ 9 - 9
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/NewMonitorMapper.java

@@ -45,24 +45,24 @@ public interface NewMonitorMapper {
 
     void updateMonitorPlanByCampaignId(@Param("campaignId") String campaignId, @Param("effective") String effective);
 
-    List<JSONObject> getKuaiShouGroupMessage(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate);
+    List<JSONObject> getKuaiShouGroupMessage(@Param("array") JSONArray array, @Param("startDate") Integer startDate, @Param("endDate") Integer endDate);
 
-    JSONObject getKuaiShouGroupSum(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate);
+    JSONObject getKuaiShouGroupSum(@Param("array") JSONArray array, @Param("startDate") Integer startDate, @Param("endDate") Integer endDate);
 
-    List<JSONObject> getKuaiShouGroupMessageGroup(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("group") String group);
+    List<JSONObject> getKuaiShouGroupMessageGroup(@Param("array") JSONArray array, @Param("startDate") Integer startDate, @Param("endDate") Integer endDate, @Param("group") String group);
 
-    List<JSONObject> getPlanMessage(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("project") String project);
+    List<JSONObject> getPlanMessage(@Param("array") JSONArray array, @Param("startDate") Integer startDate, @Param("endDate") Integer endDate);
 
-    JSONObject getPlanSum(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("project") String project);
+    JSONObject getPlanSum(@Param("array") JSONArray array, @Param("startDate") Integer startDate, @Param("endDate") Integer endDate);
 
-    List<JSONObject> getPlanMessageGroup(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("group") String group, @Param("project") String project);
+    List<JSONObject> getPlanMessageGroup(@Param("array") JSONArray array, @Param("startDate") Integer startDate, @Param("endDate") Integer endDate, @Param("group") String group);
 
     List<NewMonitorInfo> getOperator(@Param("userId") String userId);
 
-    JSONObject getPlanSumBytedance(@Param("userId") String userId, @Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("project") String project);
+    JSONObject getPlanSumBytedance(@Param("array") JSONArray array, @Param("startDate") Integer startDate, @Param("endDate") Integer endDate);
 
-    List<JSONObject> getPlanMessageGroupBytedance(@Param("userId") String userId,@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("group") String group, @Param("project") String project);
+    List<JSONObject> getPlanMessageGroupBytedance(@Param("array") JSONArray array, @Param("startDate") Integer startDate, @Param("endDate") Integer endDate, @Param("group") String group);
 
-    List<JSONObject> getPlanMessageBytedance(@Param("userId") String userId, @Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("project") String project);
+    List<JSONObject> getPlanMessageBytedance(@Param("array") JSONArray array, @Param("startDate") Integer startDate, @Param("endDate") Integer endDate);
 
 }

+ 136 - 172
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/NewMonitorMapper.xml

@@ -171,231 +171,195 @@
     </update>
 
     <select id="getKuaiShouGroupMessage" resultType="com.alibaba.fastjson.JSONObject">
-        select account_id as 'accountId',account_name as 'authName',MAX(create_time) as
-        'maxCreateTime',COUNT(IF(effective ='1', TRUE, NULL)) as 'valid',count(effective) as 'new',operating_name as
-        'userName','' as 'projectName'
-        from ctop_new_monitor_group where ( create_time between #{startDate} and #{endDate})
-        and account_id in
-        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
-            #{item}
-        </foreach>
+        SELECT
+        account_id AS 'accountId',
+        account_name AS 'authName',
+        MAX(stat_date) AS 'maxCreateTime',
+        '0' AS 'valid',
+        IFNULL(SUM(new_unit_num),0) AS 'new',
+        user_name AS 'userName'
+        FROM
+        application.app_kuaishou_account_base_info_d
+        WHERE stat_date >= #{startDate}
+        AND stat_date &lt;= #{endDate}
+        <if test="array != null and array.size() > 0">
+            and account_id in
+            <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+                #{item}
+            </foreach>
+        </if>
         GROUP BY account_id
-        order by account_id desc
+        order by `new` desc
     </select>
 
 
     <select id="getPlanMessage" resultType="com.alibaba.fastjson.JSONObject">
-        select account_id as 'accountId',account_name as 'authName',MAX(create_time) as
-        'maxCreateTime',COUNT(IF(effective ='1', TRUE, NULL)) as 'valid',count(effective) as 'new',operating_name as
-        'userName','' as 'projectName'
-        from ctop_new_monitor_campaign where ( create_time between #{startDate} and #{endDate}) and
-        project_type=#{project}
-        and account_id in
-        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
-            #{item}
-        </foreach>
+        SELECT
+        account_id AS 'accountId',
+        account_name AS 'authName',
+        MAX(stat_date) AS 'maxCreateTime',
+        '0' AS 'valid',
+        IFNULL(SUM(new_campaign_num),0) AS 'new',
+        user_name AS 'userName'
+        FROM
+        application.app_kuaishou_account_base_info_d
+        WHERE stat_date >= #{startDate}
+        AND stat_date &lt;= #{endDate}
+        <if test="array != null and array.size() > 0">
+            and account_id in
+            <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+                #{item}
+            </foreach>
+        </if>
         GROUP BY account_id
-        order by account_id desc
+        order by `new` desc
     </select>
 
     <select id="getKuaiShouGroupSum" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid',COUNT(t.effective) as 'new' from
-        ctop_new_monitor_group t
-        where create_time between #{startDate} and #{endDate}
-        and t.account_id in
-        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
-            #{item}
-        </foreach>
+        SELECT
+        IFNULL(SUM(new_unit_num),0) AS 'new',
+        '-' AS 'valid'
+        FROM
+        application.app_kuaishou_account_base_info_d
+        where stat_date >= #{startDate}
+        AND stat_date &lt;= #{endDate}
+        <if test="array != null and array.size() > 0">
+            and account_id in
+            <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+                #{item}
+            </foreach>
+        </if>
     </select>
 
     <select id="getPlanSum" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid',COUNT(t.effective) as 'new' from
-        ctop_new_monitor_campaign t
-        where (create_time between #{startDate} and #{endDate}) and project_type=#{project}
-        and t.account_id in
-        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
-            #{item}
-        </foreach>
+        SELECT IFNULL(SUM(new_campaign_num),0) AS 'new',
+        '-' AS 'valid'
+        FROM
+        application.app_kuaishou_account_base_info_d
+        where stat_date >= #{startDate}
+        AND stat_date &lt;= #{endDate}
+        <if test="array != null and array.size() > 0">
+            and account_id in
+            <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+                #{item}
+            </foreach>
+        </if>
     </select>
 
     <select id="getKuaiShouGroupMessageGroup" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
         <choose>
             <when test='group=="1"'>
-                DATE_FORMAT(t.create_time,'%Y-%m') as 'statDate',
-            </when>
-            <otherwise>
-                DATE_FORMAT(t.create_time,'%Y-%m-%d') as 'statDate',
-            </otherwise>
-        </choose>
-        COUNT(t.effective) as 'new',COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid' from ctop_new_monitor_group t
-        where (create_time between #{startDate} and #{endDate}) and t.account_id in
-        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
-            #{item}
-        </foreach>
-        <choose>
-            <when test='group=="1"'>
-                GROUP BY DATE_FORMAT(t.create_time,'%Y-%m')
+                DATE_FORMAT(stat_date, '%Y-%m' ) AS 'statDate',
             </when>
             <otherwise>
-                GROUP BY DATE_FORMAT(t.create_time,'%Y-%m-%d')
+                DATE_FORMAT(stat_date, '%Y-%m-%d' ) AS 'statDate',
             </otherwise>
         </choose>
-        order by t.create_time asc
+        IFNULL(SUM(new_unit_num),0) AS 'new',
+        '0' AS 'valid'
+        FROM application.app_kuaishou_account_base_info_d
+        where stat_date >= #{startDate}
+        AND stat_date &lt;= #{endDate}
+        <if test="array != null and array.size() > 0">
+            and account_id in
+            <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY
+        statDate
+        order by statDate asc
     </select>
 
     <select id="getPlanMessageGroup" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
         <choose>
             <when test='group=="1"'>
-                DATE_FORMAT(t.create_time,'%Y-%m') as 'statDate',
-            </when>
-            <otherwise>
-                DATE_FORMAT(t.create_time,'%Y-%m-%d') as 'statDate',
-            </otherwise>
-        </choose>
-        COUNT(t.effective) as 'new',COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid' from ctop_new_monitor_campaign t
-        where project_type=#{project} and (create_time between #{startDate} and #{endDate}) and t.account_id in
-        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
-            #{item}
-        </foreach>
-        <choose>
-            <when test='group=="1"'>
-                GROUP BY DATE_FORMAT(t.create_time,'%Y-%m')
+                DATE_FORMAT(stat_date, '%Y-%m') AS 'statDate',
             </when>
             <otherwise>
-                GROUP BY DATE_FORMAT(t.create_time,'%Y-%m-%d')
+                DATE_FORMAT(stat_date, '%Y-%m-%d') AS 'statDate',
             </otherwise>
         </choose>
-        order by t.create_time asc
+        IFNULL(SUM(new_campaign_num),0) AS 'new',
+        '0' AS 'valid'
+        FROM application.app_kuaishou_account_base_info_d
+        where stat_date >= #{startDate}
+        AND stat_date &lt;= #{endDate}
+        <if test="array != null and array.size() > 0">
+            and account_id in
+            <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY
+        statDate
+        order by statDate asc
     </select>
 
     <select id="getPlanSumBytedance" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid',COUNT(t.effective)+
-        (
-        SELECT
-        IFNULL(SUM(promotion_num),0)
-        FROM application.app_bytedance_account_base_info_d
-        WHERE stat_date >= DATE_FORMAT(#{startDate},'%Y%m%d')
-        AND stat_date &lt;=DATE_FORMAT(#{endDate},'%Y%m%d')
-        AND user_id = #{userId}
-        ) as 'new'
-        from ctop_new_monitor_campaign t
-        where (create_time between #{startDate} and #{endDate}) and project_type=#{project}
-        and t.account_id in
-        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
-            #{item}
-        </foreach>
+        SELECT IFNULL(SUM(promotion_num),0) AS 'new',
+        '-' AS 'valid'
+        FROM
+        application.app_bytedance_account_base_info_d
+        where stat_date >= #{startDate}
+        AND stat_date &lt;= #{endDate}
+        <if test="array != null and array.size() > 0">
+            and account_id in
+            <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+                #{item}
+            </foreach>
+        </if>
     </select>
 
 
     <select id="getPlanMessageGroupBytedance" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT t1.statDate,
-        t1.promotionNum +IFNULL(t2.new,0) as 'new',
-        IFNULL(t2.valid,0) as 'valid'
-        FROM
-        (
         SELECT
         <choose>
             <when test='group=="1"'>
-                DATE_FORMAT(stat_date,'%Y-%m') as 'statDate',
+                DATE_FORMAT(stat_date, '%Y-%m') AS 'statDate',
             </when>
             <otherwise>
-                DATE_FORMAT(stat_date,'%Y-%m-%d') as 'statDate',
+                DATE_FORMAT(stat_date, '%Y-%m-%d') AS 'statDate',
             </otherwise>
         </choose>
-        IFNULL(SUM(promotion_num),0) as 'promotionNum'
+        IFNULL(SUM(promotion_num),0) AS 'new',
+        '0' AS 'valid'
         FROM application.app_bytedance_account_base_info_d
-        WHERE stat_date >= DATE_FORMAT(#{startDate},'%Y%m%d')
-        AND stat_date &lt;=DATE_FORMAT(#{endDate},'%Y%m%d')
-        AND user_id = #{userId}
-        <choose>
-            <when test='group=="1"'>
-                GROUP BY DATE_FORMAT(stat_date,'%Y-%m')
-            </when>
-            <otherwise>
-                GROUP BY stat_date
-            </otherwise>
-        </choose>
-        ) t1
-        LEFT JOIN (
-        SELECT
-        <choose>
-            <when test='group=="1"'>
-                DATE_FORMAT(t.create_time,'%Y-%m') as 'statDate',
-            </when>
-            <otherwise>
-                DATE_FORMAT(t.create_time,'%Y-%m-%d') as 'statDate',
-            </otherwise>
-        </choose>
-        COUNT(t.effective) as 'new',COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid' from ctop_new_monitor_campaign t
-        where project_type=#{project} and (create_time between #{startDate} and #{endDate}) and t.account_id in
-        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
-            #{item}
-        </foreach>
-        <choose>
-            <when test='group=="1"'>
-                GROUP BY DATE_FORMAT(t.create_time,'%Y-%m')
-            </when>
-            <otherwise>
-                GROUP BY DATE_FORMAT(t.create_time,'%Y-%m-%d')
-            </otherwise>
-        </choose>
-        ) t2 ON t1.statDate = t2.statDate
-        WHERE t1.promotionNum +IFNULL(t2.new,0) >0
-        ORDER BY `statDate`
+        where stat_date >= #{startDate}
+        AND stat_date &lt;= #{endDate}
+        <if test="array != null and array.size() > 0">
+            and account_id in
+            <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY
+        statDate
+        order by statDate asc
     </select>
 
 
     <select id="getPlanMessageBytedance" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT * FROM (
-        SELECT
-        IFNULL(t2.account_id,t1.account_id) as 'accountId',
-        IFNULL(t2.authName,t1.account_name) as 'authName',
-        IFNULL(t2.maxCreateTime,statDate) as 'maxCreateTime',
-        t1.promotionNum+IFNULL(t2.new,0) as 'new',
-        IFNULL(t2.userName,t1.user_name) as 'userName',
-        IFNULL(t2.valid ,0) as 'valid'
-        FROM
-        (
-        SELECT
-        account_id,
-        account_name,
-        user_name,
-        DATE_FORMAT(stat_date,'%Y-%m-%d') as 'statDate',
-        IFNULL(SUM(promotion_num),0) as 'promotionNum'
-        FROM application.app_bytedance_account_base_info_d
-        WHERE stat_date >= DATE_FORMAT(#{startDate},'%Y%m%d')
-        AND stat_date &lt;=DATE_FORMAT(#{endDate},'%Y%m%d')
-        AND user_id = #{userId}
-        GROUP BY account_id
-        ) t1
-        LEFT JOIN (
         SELECT
-        account_id,
+        account_id AS 'accountId',
         account_name AS 'authName',
-        MAX( create_time ) AS 'maxCreateTime',
-        COUNT(
-        IF
-        ( effective = '1', TRUE, NULL )) AS 'valid',
-        count( effective ) AS 'new',
-        operating_name AS 'userName',
-        '' AS 'projectName'
+        MAX(stat_date) AS 'maxCreateTime',
+        '0' AS 'valid',
+        IFNULL(SUM(promotion_num),0) AS 'new',
+        user_name AS 'userName'
         FROM
-        ctop_new_monitor_campaign
-        WHERE
-        (create_time between #{startDate} and #{endDate})
-        and project_type=#{project}
-        AND account_id IN
-        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
-            #{item}
-        </foreach>
-        GROUP BY
-        account_id
-        ) t2 ON t1.account_id = t2.account_id
-        ) t
-        WHERE new >0
-        ORDER BY maxCreateTime desc
+        application.app_bytedance_account_base_info_d
+        WHERE stat_date >= #{startDate}
+        AND stat_date &lt;= #{endDate}
+        <if test="array != null and array.size() > 0">
+            and account_id in
+            <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY account_id
+        order by `new` desc
     </select>
-
 </mapper>

+ 8 - 8
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/NewMonitorService.java

@@ -11,23 +11,23 @@ public interface NewMonitorService {
 
     public Result synchronousTouTiaoMonitor(String type, Long accId);
 
-    List<JSONObject> getKuaiShouGroupMessage(JSONArray array, String startDate, String endDate, String target);
+    List<JSONObject> getKuaiShouGroupMessage(JSONArray array, Integer startDate, Integer endDate );
 
-    JSONObject getKuaiShouGroupSum(JSONArray array, String startDate, String endDate);
+    JSONObject getKuaiShouGroupSum(JSONArray array, Integer startDate, Integer endDate);
 
     List<JSONObject> getKuaiShouGroupMessageGroup(JSONArray array, String startDate, String endDate);
 
-    List<JSONObject> getPlanMessage(JSONArray array, String startDate, String endDate, String target, String project);
+    List<JSONObject> getPlanMessage(JSONArray array, Integer startDate, Integer endDate);
 
-    JSONObject getPlanSum(JSONArray array, String startDate, String endDate, String project);
+    JSONObject getPlanSum(JSONArray array, Integer startDate, Integer endDate);
 
-    List<JSONObject> getPlanMessageGroup(JSONArray array, String startDate, String endDate, String project);
+    List<JSONObject> getPlanMessageGroup(JSONArray array, String startDate, String endDate);
 
     List<JSONObject> getOperator(String userId, String userName);
 
-    JSONObject getPlanSumBytedance(String userId, JSONArray accountIds, String startDate, String endDate, String s);
+    JSONObject getPlanSumBytedance(JSONArray accountIds, Integer startDate, Integer endDate);
 
-    List<JSONObject> getPlanMessageGroupBytedance(String userId, JSONArray accountIds, String startDate, String endDate, String s);
+    List<JSONObject> getPlanMessageGroupBytedance(JSONArray accountIds, String startDate, String endDate);
 
-    List<JSONObject> getPlanMessageBytedance(String userId, JSONArray accountIds, String startDate, String endDate, String target, String s);
+    List<JSONObject> getPlanMessageBytedance(JSONArray accountIds, Integer startDate, Integer endDate);
 }

+ 15 - 16
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/NewMonitorServiceImpl.java

@@ -210,7 +210,7 @@ public class NewMonitorServiceImpl implements NewMonitorService {
      * @return
      */
     @Override
-    public List<JSONObject> getKuaiShouGroupMessage(JSONArray array, String startDate, String endDate, String target) {
+    public List<JSONObject> getKuaiShouGroupMessage(JSONArray array, Integer startDate, Integer endDate) {
         return newMonitorMapper.getKuaiShouGroupMessage(array, startDate, endDate);
     }
 
@@ -221,7 +221,7 @@ public class NewMonitorServiceImpl implements NewMonitorService {
      * @return
      */
     @Override
-    public JSONObject getKuaiShouGroupSum(JSONArray array, String startDate, String endDate) {
+    public JSONObject getKuaiShouGroupSum(JSONArray array, Integer startDate, Integer endDate) {
         return newMonitorMapper.getKuaiShouGroupSum(array, startDate, endDate);
     }
 
@@ -239,7 +239,7 @@ public class NewMonitorServiceImpl implements NewMonitorService {
             if (DateUtils.isMoreSixMonth(startDate, endDate)) {
                 group = "1";
             }
-            kuaiShouGroupMessageGroup = newMonitorMapper.getKuaiShouGroupMessageGroup(array, startDate, endDate, group);
+            kuaiShouGroupMessageGroup = newMonitorMapper.getKuaiShouGroupMessageGroup(array, DateUtils.getDateInteger(startDate), DateUtils.getDateInteger(endDate), group);
         } catch (Exception e) {
             log.info("查询数据错误:{}", e.toString());
         }
@@ -248,8 +248,8 @@ public class NewMonitorServiceImpl implements NewMonitorService {
     }
 
     @Override
-    public List<JSONObject> getPlanMessage(JSONArray array, String startDate, String endDate, String target, String project) {
-        return newMonitorMapper.getPlanMessage(array, startDate, endDate, project);
+    public List<JSONObject> getPlanMessage(JSONArray array, Integer startDate, Integer endDate) {
+        return newMonitorMapper.getPlanMessage(array, startDate, endDate);
     }
 
     /**
@@ -259,23 +259,22 @@ public class NewMonitorServiceImpl implements NewMonitorService {
      * @return
      */
     @Override
-    public JSONObject getPlanSum(JSONArray array, String startDate, String endDate, String project) {
-        return newMonitorMapper.getPlanSum(array, startDate, endDate, project);
+    public JSONObject getPlanSum(JSONArray array, Integer startDate, Integer endDate) {
+        return newMonitorMapper.getPlanSum(array, startDate, endDate);
     }
 
     @Override
-    public List<JSONObject> getPlanMessageGroup(JSONArray array, String startDate, String endDate, String project) {
+    public List<JSONObject> getPlanMessageGroup(JSONArray array, String startDate, String endDate) {
         String group = "0";
         List<JSONObject> planGroupMessageGroup = new ArrayList<>();
         try {
             if (DateUtils.isMoreSixMonth(startDate, endDate)) {
                 group = "1";
             }
-            planGroupMessageGroup = newMonitorMapper.getPlanMessageGroup(array, startDate, endDate, group, project);
+            planGroupMessageGroup = newMonitorMapper.getPlanMessageGroup(array, DateUtils.getDateInteger(startDate), DateUtils.getDateInteger(endDate),group);
         } catch (Exception e) {
             log.info("查询数据错误:{}", e.toString());
         }
-
         return planGroupMessageGroup;
     }
 
@@ -298,19 +297,19 @@ public class NewMonitorServiceImpl implements NewMonitorService {
     }
 
     @Override
-    public JSONObject getPlanSumBytedance(String userId, JSONArray accountIds, String startDate, String endDate, String project) {
-        return newMonitorMapper.getPlanSumBytedance(userId,accountIds, startDate, endDate, project);
+    public JSONObject getPlanSumBytedance(JSONArray accountIds, Integer startDate, Integer endDate) {
+        return newMonitorMapper.getPlanSumBytedance(accountIds, startDate, endDate);
     }
 
     @Override
-    public List<JSONObject> getPlanMessageGroupBytedance(String userId, JSONArray array, String startDate, String endDate, String project) {
+    public List<JSONObject> getPlanMessageGroupBytedance(JSONArray array, String startDate, String endDate) {
         String group = "0";
         List<JSONObject> planGroupMessageGroup = new ArrayList<>();
         try {
             if (DateUtils.isMoreSixMonth(startDate, endDate)) {
                 group = "1";
             }
-            planGroupMessageGroup = newMonitorMapper.getPlanMessageGroupBytedance(userId,array, startDate, endDate, group, project);
+            planGroupMessageGroup = newMonitorMapper.getPlanMessageGroupBytedance(array, DateUtils.getDateInteger(startDate), DateUtils.getDateInteger(endDate),group);
         } catch (Exception e) {
             log.info("查询数据错误:{}", e.toString());
         }
@@ -318,8 +317,8 @@ public class NewMonitorServiceImpl implements NewMonitorService {
     }
 
     @Override
-    public List<JSONObject> getPlanMessageBytedance(String userId, JSONArray array, String startDate, String endDate, String target, String project) {
-        return newMonitorMapper.getPlanMessageBytedance(userId,array, startDate, endDate, project);
+    public List<JSONObject> getPlanMessageBytedance(JSONArray array, Integer startDate, Integer endDate) {
+        return newMonitorMapper.getPlanMessageBytedance(array, startDate, endDate);
     }
 
     List<JSONObject> getAllNode(List<NewMonitorInfo> operator) {

+ 17 - 12
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceNewPlanReportCtrl.java

@@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -46,9 +47,9 @@ public class BytedanceNewPlanReportCtrl {
         Result<Map<String, Object>> resultBody = new Result<>();
         Map<String, Object> result = new HashMap<>();
         JSONArray accountIds = requestBody.getJSONArray("accountIds");
-        //TODO 没有维护头条事业部负责人角色,增加判断
+        // 陈思宇 4afe739502ae4258a18c36a000d7ff20
         String userId = requestBody.getString("userId");
-        if ("0c2113fb63b94941be024efce2d83369".equals(userId)) {
+        if ("4afe739502ae4258a18c36a000d7ff20".equals(userId)) {
             accountIds = newPlanReportService.getAccountIdsByMedia();
         } else {
             if (!userId.isEmpty()) {
@@ -60,8 +61,10 @@ public class BytedanceNewPlanReportCtrl {
         }
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
-        startDate=startDate+" 00:00:00";
-        endDate=endDate+" 23:59:59";
+
+        Integer startDateInteger = DateUtils.getDateInteger(startDate);
+        Integer endDateInteger = DateUtils.getDateInteger(endDate);
+
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
         try {
@@ -69,9 +72,9 @@ public class BytedanceNewPlanReportCtrl {
             List<JSONObject> chartData = newPlanReportService.getBytedanceNewPlanGroupByStatDate(accountIds, startDate, endDate);
             List<JSONObject> listData = newPlanReportService.getBytedanceNewPlanGroupByAccount(accountIds, startDate, endDate, target, order);
 */
-            JSONObject sumData = newMonitorService.getPlanSumBytedance(userId,accountIds, startDate, endDate, "0");
-            List<JSONObject> chartData = newMonitorService.getPlanMessageGroupBytedance(userId,accountIds, startDate, endDate, "0");
-            List<JSONObject> listData = newMonitorService.getPlanMessageBytedance(userId,accountIds, startDate, endDate, target, "0");
+            JSONObject sumData = newMonitorService.getPlanSumBytedance(accountIds, startDateInteger, endDateInteger);
+            List<JSONObject> chartData = newMonitorService.getPlanMessageGroupBytedance(accountIds, startDate, endDate);
+            List<JSONObject> listData = newMonitorService.getPlanMessageBytedance(accountIds, startDateInteger, endDateInteger);
             result.put("sumData", sumData);
             result.put("chartData", chartData);
             result.put("listData", listData);
@@ -91,8 +94,8 @@ public class BytedanceNewPlanReportCtrl {
 
         JSONArray accountIds = requestBody.getJSONArray("accountIds");
         String userId = requestBody.getString("userId");
-        //TODO 没有维护快手事业部负责人角色,增加判断
-        if ("6b4c821adc414dc8b7718ab63ccbfcaf".equals(userId)) {
+        // 陈思宇 4afe739502ae4258a18c36a000d7ff20
+        if ("4afe739502ae4258a18c36a000d7ff20".equals(userId)) {
             accountIds = newPlanReportService.getAccountIdsByMedia();
         } else {
             if (!userId.isEmpty()) {
@@ -104,11 +107,13 @@ public class BytedanceNewPlanReportCtrl {
         }
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
-        startDate=startDate+" 00:00:00";
-        endDate=endDate+" 59:59:59";
+
+        Integer startDateInteger = DateUtils.getDateInteger(startDate);
+        Integer endDateInteger = DateUtils.getDateInteger(endDate);
+
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
-        List<JSONObject> listData = newMonitorService.getPlanMessageBytedance(userId,accountIds, startDate, endDate, target, "0");
+        List<JSONObject> listData = newMonitorService.getPlanMessageBytedance(accountIds, startDateInteger, endDateInteger);
 
         List<List<Object>> excelList = new ArrayList<>();
         listData.forEach(data -> {