Browse Source

Merge remote-tracking branch 'origin/master'

songyh 4 years ago
parent
commit
8f9049746b

+ 5 - 10
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -1594,21 +1594,16 @@ public class DateUtils extends PropertyEditorSupport {
      */
      */
     public static String getdateFromWeek(int number) {
     public static String getdateFromWeek(int number) {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-        Calendar c = Calendar.getInstance();
-        // 今天是一周中的第几天
-        int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
+        Calendar calendar = Calendar.getInstance();
 
 
-        if (c.getFirstDayOfWeek() == Calendar.SUNDAY) {
-            c.add(Calendar.DAY_OF_MONTH, 1);
+        while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) {
+            calendar.add(Calendar.DAY_OF_WEEK, -1);
         }
         }
-        // 计算一周开始的日期
-        c.add(Calendar.DAY_OF_MONTH, -dayOfWeek);
-
         for (int i = 1; i <= 7; i++) {
         for (int i = 1; i <= 7; i++) {
-            c.add(Calendar.DAY_OF_MONTH, 1);
             if (number == i) {
             if (number == i) {
-                return sdf.format(c.getTime());
+                return sdf.format(calendar.getTime());
             }
             }
+            calendar.add(Calendar.DAY_OF_MONTH, 1);
         }
         }
         return null;
         return null;
     }
     }

+ 1 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouCreateUnitJob.java

@@ -27,7 +27,7 @@ public class KuaishouCreateUnitJob {
             XxlJobHelper.log("批量2.0暂时没有未创建的组");
             XxlJobHelper.log("批量2.0暂时没有未创建的组");
             return;
             return;
         }
         }
-        String url = "http://jiaoyangapi.shyouteng.com.cn/jeecg-boot/batch/kuaiShouGroupTemplate/createUnit";
+        String url = "http://api.tjyourong.com.cn/jeecg-boot/batch/kuaiShouGroupTemplate/createUnit";
         for (int i = 0; i < idList.size(); i++) {
         for (int i = 0; i < idList.size(); i++) {
             Long id = idList.get(i);
             Long id = idList.get(i);
             Map<String, Object> requestMap = new HashMap<>();
             Map<String, Object> requestMap = new HashMap<>();

+ 4 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAccountReportLoadEtlJob.java

@@ -3,6 +3,7 @@ package cn.com.ctop.job.kuaishou.handler;
 import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaishouAccountMaterialReportDailyMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.EtlKuaishouAccountMaterialReportDailyMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouAccountMaterialReportDailyService;
 import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouAccountMaterialReportDailyService;
 import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouReportAccountDailyService;
 import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouReportAccountDailyService;
+import cn.com.ctop.kuaishou.modules.report.service.IEtlKuaishouReportAccountHourlyService;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.DateUtils;
@@ -26,11 +27,13 @@ public class KuaishouDailyAccountReportLoadEtlJob {
     private IEtlKuaishouAccountMaterialReportDailyService etlKuaishouAccountMaterialReportDailyService;
     private IEtlKuaishouAccountMaterialReportDailyService etlKuaishouAccountMaterialReportDailyService;
     @Resource
     @Resource
     private EtlKuaishouAccountMaterialReportDailyMapper etlKuaishouAccountMaterialReportDailyMapper;
     private EtlKuaishouAccountMaterialReportDailyMapper etlKuaishouAccountMaterialReportDailyMapper;
-
+    @Autowired
+    private IEtlKuaishouReportAccountHourlyService hourlyService;
     @XxlJob("kuaishouDailyAccountReportLoadEtl")
     @XxlJob("kuaishouDailyAccountReportLoadEtl")
     public void execute() throws Exception {
     public void execute() throws Exception {
         try {
         try {
             iEtlKuaishouReportAccountDailyService.queryEveryDayDataForAccount();
             iEtlKuaishouReportAccountDailyService.queryEveryDayDataForAccount();
+            hourlyService.updateYesterdayEtlHourlyData();
             XxlJobHelper.log("queryEveryDayDataForAccount success");
             XxlJobHelper.log("queryEveryDayDataForAccount success");
         } catch (Exception e) {
         } catch (Exception e) {
             XxlJobHelper.log(e.getMessage());
             XxlJobHelper.log(e.getMessage());

+ 6 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/EtlKuaishouReportAccountDailyMapper.java

@@ -45,4 +45,10 @@ public interface EtlKuaishouReportAccountDailyMapper extends BaseMapper<EtlKuais
     List<JSONObject> leaderAccountPageList(JSONObject request);
     List<JSONObject> leaderAccountPageList(JSONObject request);
 
 
     int leaderAccountPageListTotal(JSONObject request);
     int leaderAccountPageListTotal(JSONObject request);
+
+    List<EtlKuaishouReportAccountHourly> selectList(@Param("startDate") String startDate,@Param("endDate") String endDate);
+
+    int operatingStaffDataListTotal(JSONObject request);
+
+    List<JSONObject> operatingStaffDataList(JSONObject request);
 }
 }

+ 6 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouAccountMaterialReportDailyMapper.xml

@@ -32,7 +32,8 @@
             event_jin_jian_landing_page,
             event_jin_jian_landing_page,
             event_credit_grant_landing_page,
             event_credit_grant_landing_page,
             event_next_day_stay,
             event_next_day_stay,
-            form_count)
+            form_count,
+            play_3s_count)
      select
      select
      c.company_id,
      c.company_id,
      c.company_name,
      c.company_name,
@@ -62,8 +63,8 @@
      sum(m.event_jin_jian_landing_page) as event_jin_jian_landing_page,
      sum(m.event_jin_jian_landing_page) as event_jin_jian_landing_page,
      sum(m.event_credit_grant_landing_page) as event_credit_grant_landing_page,
      sum(m.event_credit_grant_landing_page) as event_credit_grant_landing_page,
      sum(m.event_next_day_stay) as event_next_day_stay,
      sum(m.event_next_day_stay) as event_next_day_stay,
-     sum(m.form_count)as form_count
-
+     sum(m.form_count)as form_count,
+     round(sum(m.play_3s_ratio * m.photo_show),0) as play_3s_count
      from ctop_kuaishou_report_daily_material m left join ctop_user_allocation u on u.account_id = m.account_id
      from ctop_kuaishou_report_daily_material m left join ctop_user_allocation u on u.account_id = m.account_id
      left join ctop_project p on p.id = u.project_id
      left join ctop_project p on p.id = u.project_id
      left join user_company c on c.user_id = u.account_id
      left join user_company c on c.user_id = u.account_id
@@ -71,6 +72,8 @@
      and m.stat_date = #{date}
      and m.stat_date = #{date}
      group by m.account_id,m.signature
      group by m.account_id,m.signature
     </insert>
     </insert>
+
+
     <insert id="replaceBatch">
     <insert id="replaceBatch">
         replace into ctop_etl_kuaishou_account_material_report_daily(
         replace into ctop_etl_kuaishou_account_material_report_daily(
         company_id ,
         company_id ,

+ 164 - 27
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouReportAccountDailyMapper.xml

@@ -397,7 +397,6 @@
         ) t6 ON t6.account_id = t2.account_id
         ) t6 ON t6.account_id = t2.account_id
         where stat_date &gt;= #{startTime}
         where stat_date &gt;= #{startTime}
         AND stat_date &lt;= #{endTime}
         AND stat_date &lt;= #{endTime}
-        and t2.account_status = 0
         <if test="userIds != null">
         <if test="userIds != null">
             AND t2.user_id IN
             AND t2.user_id IN
             <foreach item="id" index="index" collection="userIds"
             <foreach item="id" index="index" collection="userIds"
@@ -423,7 +422,6 @@
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         where stat_date &gt;= #{startTime}
         where stat_date &gt;= #{startTime}
         AND stat_date &lt;= #{endTime}
         AND stat_date &lt;= #{endTime}
-        and t2.account_status = 0
         <if test="userIds != null">
         <if test="userIds != null">
             AND t2.user_id IN
             AND t2.user_id IN
             <foreach item="id" index="index" collection="userIds"
             <foreach item="id" index="index" collection="userIds"
@@ -473,7 +471,6 @@
         ORDER BY stat_date
         ORDER BY stat_date
     </select>
     </select>
 
 
-
     <select id="projectPageList" resultType="com.alibaba.fastjson.JSONObject">
     <select id="projectPageList" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
         SELECT
         ${filed},
         ${filed},
@@ -487,13 +484,12 @@
         IFNULL(t4.userCount,0) as 'userCount'
         IFNULL(t4.userCount,0) as 'userCount'
         FROM ctop_etl_kuaishou_report_account_daily t1
         FROM ctop_etl_kuaishou_report_account_daily t1
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-        LEFT JOIN ctop_project t3 ON t2.project_id = t3.id
+        INNER JOIN ctop_project t3 ON t2.project_id = t3.id
         LEFT JOIN (
         LEFT JOIN (
         SELECT project_id,COUNT(1) 'userCount'
         SELECT project_id,COUNT(1) 'userCount'
         FROM (
         FROM (
         SELECT DISTINCT project_id,user_id
         SELECT DISTINCT project_id,user_id
         FROM ctop_user_allocation
         FROM ctop_user_allocation
-        where account_status = 0
         ) t
         ) t
         GROUP BY project_id
         GROUP BY project_id
         ) t4 ON t4.project_id = t3.id
         ) t4 ON t4.project_id = t3.id
@@ -502,55 +498,196 @@
         LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
         LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
         where i1.stat_date &gt;= DATE_SUB(#{startTime},INTERVAL 7 DAY)
         where i1.stat_date &gt;= DATE_SUB(#{startTime},INTERVAL 7 DAY)
         AND i1.stat_date &lt;= DATE_SUB(#{endTime},INTERVAL 7 DAY)
         AND i1.stat_date &lt;= DATE_SUB(#{endTime},INTERVAL 7 DAY)
-        AND i2.user_id IN
-        <foreach item="id" index="index" collection="userIds"
-                 open="(" separator="," close=")">
-            #{id}
-        </foreach>
         GROUP BY i1.account_id
         GROUP BY i1.account_id
         ) t6 ON t2.account_id = t6.account_id
         ) t6 ON t2.account_id = t6.account_id
         LEFT JOIN (
         LEFT JOIN (
         SELECT project_id ,count(1) as 'accountCount' FROM (
         SELECT project_id ,count(1) as 'accountCount' FROM (
         SELECT i2.project_id,i2.account_id FROM ctop_etl_kuaishou_report_account_daily i1
         SELECT i2.project_id,i2.account_id FROM ctop_etl_kuaishou_report_account_daily i1
         LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
         LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
-        where account_status = 0
-        AND i1.stat_date &gt;= #{startTime}
+        where i1.stat_date &gt;= #{startTime}
         AND i1.stat_date &lt;= #{endTime}
         AND i1.stat_date &lt;= #{endTime}
         GROUP BY project_id,i1.account_id ) t GROUP BY t.project_id
         GROUP BY project_id,i1.account_id ) t GROUP BY t.project_id
         ) t7 on t2.project_id = t7.project_id
         ) t7 on t2.project_id = t7.project_id
         where t1.stat_date &gt;= #{startTime}
         where t1.stat_date &gt;= #{startTime}
         AND t1.stat_date &lt;= #{endTime}
         AND t1.stat_date &lt;= #{endTime}
-        AND t2.user_id in
-        <foreach item="id" index="index" collection="userIds"
-                 open="(" separator="," close=")">
-            #{id}
-        </foreach>
         GROUP BY t3.id
         GROUP BY t3.id
+        HAVING SUM(charge)>0
         <if test="sortCode != '' and sortCode != null ">
         <if test="sortCode != '' and sortCode != null ">
             ORDER BY ${sortCode}
             ORDER BY ${sortCode}
+            ${sortType}
         </if>
         </if>
-        ${sortType}
-    </select>
 
 
+    </select>
 
 
     <select id="projectPageListTotal" resultType="java.lang.Integer">
     <select id="projectPageListTotal" resultType="java.lang.Integer">
         SELECT IFNULL(SUM(1),0) from
         SELECT IFNULL(SUM(1),0) from
-        (
-        SELECT
-        t3.id
+            (
+                SELECT
+                    t3.id
+                FROM ctop_etl_kuaishou_report_account_daily t1
+                         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+                         INNER JOIN ctop_project t3 ON t2.project_id = t3.id
+                where t1.stat_date &gt;= #{startTime}
+                  AND t1.stat_date &lt;= #{endTime}
+                GROUP BY t3.id
+                HAVING SUM(charge)>0
+            ) t
+    </select>
+
+    <select id="selectList" resultType="cn.com.ctop.kuaishou.modules.report.entity.EtlKuaishouReportAccountHourly">
+        SELECT * from ctop_etl_kuaishou_report_account_daily
+        WHERE stat_date &gt;= #{startDate}
+          and stat_date &lt;= #{endDate}
+    </select>
+
+    <select id="operatingStaffDataListTotal" resultType="java.lang.Integer">
+        SELECT IFNULL(SUM(1),0)
+        FROM (
+        SELECT 1
         FROM ctop_etl_kuaishou_report_account_daily t1
         FROM ctop_etl_kuaishou_report_account_daily t1
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-        LEFT JOIN ctop_project t3 ON t2.project_id = t3.id
-        where t1.stat_date &gt;= #{startTime}
-        AND t1.stat_date &lt;= #{endTime}
-        AND t2.user_id in
+        WHERE stat_date &gt;= #{startTime}
+        and stat_date &lt;= #{endTime}
+        AND t2.user_id IN
         <foreach item="id" index="index" collection="userIds"
         <foreach item="id" index="index" collection="userIds"
                  open="(" separator="," close=")">
                  open="(" separator="," close=")">
             #{id}
             #{id}
         </foreach>
         </foreach>
-        GROUP BY t3.id
+        GROUP BY t2.user_id
         ) t
         ) t
     </select>
     </select>
 
 
+    <select id="operatingStaffDataList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        IFNULL(t2.user_id,'') 'userId',
+        IFNULL(t9.realname,'') 'realName',
+        IFNULL(t3.accountCount,0) 'accountCount',
+        IFNULL(SUM(t1.charge),0) 'charge',
+        IFNULL(t4.weekCharge,0) 'weekCharge',
+        concat(CAST(IFNULL(ROUND((t4.weekCharge-t5.lweekCharge)/t5.lweekCharge*100,2), 0)as char),'%')as 'grew',
+        IFNULL(t6.effectiveCount,0) 'effectiveCount',
+        IFNULL(t7.campaignCount,0) 'campaignCount',
+        IFNULL(t8.unitCount,0) 'unitCount'
+        FROM
+        ctop_etl_kuaishou_report_account_daily t1
+        LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        LEFT JOIN(
+        SELECT user_id,COUNT(1) 'accountCount' FROM ctop_user_allocation i1
+        INNER JOIN ctop_etl_kuaishou_report_account_daily  i2 ON i1.account_id = i2.account_id
+        AND i2.stat_date &gt;= #{startTime}
+        and i2.stat_date &lt;= #{endTime}
+        WHERE user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY user_id
+        ) t3 ON t2.user_id = t3.user_id
+        LEFT JOIN (
+        SELECT
+        SUM(charge) 'weekCharge',
+        tt2.user_id
+        FROM
+        ctop_etl_kuaishou_report_account_daily tt1
+        LEFT JOIN ctop_user_allocation tt2 ON tt1.account_id = tt2.account_id
+        WHERE tt1.stat_date &lt;=#{today}
+        and tt1.stat_date &gt;=#{weekStartTime}
+        AND tt2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY tt2.user_id
+        ) t4 ON t2.user_id = t4.user_id
+        LEFT JOIN (
+        SELECT
+        SUM(charge) 'lweekCharge',
+        tt2.user_id
+        FROM
+        ctop_etl_kuaishou_report_account_daily tt1
+        LEFT JOIN ctop_user_allocation tt2 ON tt1.account_id = tt2.account_id
+        WHERE tt1.stat_date &lt;=#{lweekEndTime}
+        and tt1.stat_date &gt;=#{lweekStartTime}
+        AND tt2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY tt2.user_id
+        ) t5 ON t2.user_id = t5.user_id
+        LEFT JOIN (
+        SELECT
+        SUM(effective_count) 'effectiveCount',
+        tt2.user_id
+        FROM
+        ctop_etl_kuaishou_account_material_overview tt1
+        LEFT JOIN ctop_user_allocation tt2 ON tt1.account_id = tt2.account_id
+        WHERE tt1.state_date &gt;= #{startTime}
+        and tt1.state_date &lt;= #{endTime}
+        AND tt2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY tt2.user_id
+        ) t6 ON t2.user_id = t6.user_id
+        LEFT JOIN (
+        SELECT
+        SUM(new_count) 'campaignCount',
+        tt2.user_id
+        FROM
+        ctop_etl_kuaishou_newly tt1
+        LEFT JOIN ctop_user_allocation tt2 ON tt1.account_id = tt2.account_id
+        WHERE tt1.stat_date &gt;= #{startTime}
+        and tt1.stat_date &lt;= #{endTime}
+        AND tt1.new_type = 'campaign'
+        AND tt2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY tt2.user_id
+        ) t7 ON t2.user_id = t7.user_id
+        LEFT JOIN (
+        SELECT
+        SUM(new_count) 'unitCount',
+        tt2.user_id
+        FROM
+        ctop_etl_kuaishou_newly tt1
+        LEFT JOIN ctop_user_allocation tt2 ON tt1.account_id = tt2.account_id
+        WHERE tt1.stat_date &gt;= #{startTime}
+        and tt1.stat_date &lt;= #{endTime}
+        AND tt1.new_type = 'unit'
+        AND tt2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY tt2.user_id
+        ) t8 ON t2.user_id = t8.user_id
+        LEFT JOIN (
+        SELECT
+        id,realname
+        FROM
+        sys_user
+        WHERE id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        ) t9 ON t2.user_id = t9.id
+        WHERE t1.stat_date &gt;= #{startTime}
+        and t1.stat_date &lt;= #{endTime}
+        AND t2.user_id IN
+        <foreach item="id" index="index" collection="userIds"
+                 open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        GROUP BY t2.user_id
+        <if test="sortCode != '' and sortCode != null ">
+            ORDER BY ${sortCode}
+        </if>
+        ${sortType}
+    </select>
 
 
 </mapper>
 </mapper>

+ 11 - 36
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/EtlKuaishouReportAccountHourlyMapper.xml

@@ -289,7 +289,6 @@
         FROM ctop_etl_kuaishou_report_account_hourly t1
         FROM ctop_etl_kuaishou_report_account_hourly t1
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         where stat_date = #{startTime}
         where stat_date = #{startTime}
-        and t2.account_status = 0
         <if test="userIds != null">
         <if test="userIds != null">
             AND t2.user_id IN
             AND t2.user_id IN
             <foreach item="id" index="index" collection="userIds"
             <foreach item="id" index="index" collection="userIds"
@@ -371,7 +370,6 @@
         where state =1
         where state =1
         ) t6 ON t6.account_id = t2.account_id
         ) t6 ON t6.account_id = t2.account_id
         where stat_date = #{startTime}
         where stat_date = #{startTime}
-        and t2.account_status = 0
         <if test="userIds != null">
         <if test="userIds != null">
             AND t2.user_id IN
             AND t2.user_id IN
             <foreach item="id" index="index" collection="userIds"
             <foreach item="id" index="index" collection="userIds"
@@ -411,8 +409,7 @@
         SELECT 1
         SELECT 1
         FROM ctop_etl_kuaishou_report_account_hourly t1
         FROM ctop_etl_kuaishou_report_account_hourly t1
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-        WHERE stat_date = #{today}
-        AND t2.account_status = 0
+        WHERE stat_date = #{startTime}
         AND t2.user_id IN
         AND t2.user_id IN
         <foreach item="id" index="index" collection="userIds"
         <foreach item="id" index="index" collection="userIds"
                  open="(" separator="," close=")">
                  open="(" separator="," close=")">
@@ -439,9 +436,8 @@
         LEFT JOIN(
         LEFT JOIN(
         SELECT user_id,COUNT(1) 'accountCount' FROM ctop_user_allocation i1
         SELECT user_id,COUNT(1) 'accountCount' FROM ctop_user_allocation i1
         INNER JOIN ctop_etl_kuaishou_report_account_hourly  i2 ON i1.account_id = i2.account_id
         INNER JOIN ctop_etl_kuaishou_report_account_hourly  i2 ON i1.account_id = i2.account_id
-        AND i2.stat_date = #{today}
-        WHERE
-        account_status = 0 AND user_id IN
+        AND i2.stat_date = #{startTime}
+        WHERE user_id IN
         <foreach item="id" index="index" collection="userIds"
         <foreach item="id" index="index" collection="userIds"
                  open="(" separator="," close=")">
                  open="(" separator="," close=")">
             #{id}
             #{id}
@@ -538,8 +534,7 @@
             #{id}
             #{id}
         </foreach>
         </foreach>
         ) t9 ON t2.user_id = t9.id
         ) t9 ON t2.user_id = t9.id
-        WHERE t1.stat_date = #{today}
-        AND t2.account_status = 0
+        WHERE t1.stat_date = #{startTime}
         AND t2.user_id IN
         AND t2.user_id IN
         <foreach item="id" index="index" collection="userIds"
         <foreach item="id" index="index" collection="userIds"
                  open="(" separator="," close=")">
                  open="(" separator="," close=")">
@@ -564,18 +559,17 @@
         (
         (
         SELECT count(1) FROM ctop_etl_kuaishou_report_account_hourly i1
         SELECT count(1) FROM ctop_etl_kuaishou_report_account_hourly i1
         LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
         LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
-        where project_id = t3.id and account_status = 0
+        where project_id = t3.id
         AND i1.stat_date = #{startTime}) as 'accountCount',
         AND i1.stat_date = #{startTime}) as 'accountCount',
         IFNULL(t4.userCount,0) as 'userCount'
         IFNULL(t4.userCount,0) as 'userCount'
         FROM ctop_etl_kuaishou_report_account_hourly t1
         FROM ctop_etl_kuaishou_report_account_hourly t1
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-        LEFT JOIN ctop_project t3 ON t2.project_id = t3.id
+        INNER JOIN ctop_project t3 ON t2.project_id = t3.id
         LEFT JOIN (
         LEFT JOIN (
         SELECT project_id,COUNT(1) 'userCount'
         SELECT project_id,COUNT(1) 'userCount'
         FROM (
         FROM (
         SELECT DISTINCT project_id,user_id
         SELECT DISTINCT project_id,user_id
         FROM ctop_user_allocation
         FROM ctop_user_allocation
-        where account_status = 0
         ) t
         ) t
         GROUP BY project_id
         GROUP BY project_id
         ) t4 ON t4.project_id = t3.id
         ) t4 ON t4.project_id = t3.id
@@ -584,11 +578,6 @@
         LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
         LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
         where stat_date = DATE_SUB(#{startTime},INTERVAL 1 DAY)
         where stat_date = DATE_SUB(#{startTime},INTERVAL 1 DAY)
         AND stat_hour &lt;= #{hours}
         AND stat_hour &lt;= #{hours}
-        AND i2.user_id IN
-        <foreach item="id" index="index" collection="userIds"
-                 open="(" separator="," close=")">
-            #{id}
-        </foreach>
         GROUP BY i1.account_id
         GROUP BY i1.account_id
         ) t5 ON t2.account_id = t5.account_id
         ) t5 ON t2.account_id = t5.account_id
         LEFT JOIN(
         LEFT JOIN(
@@ -596,25 +585,16 @@
         LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
         LEFT JOIN ctop_user_allocation i2 ON i1.account_id = i2.account_id
         where stat_date = DATE_SUB(#{startTime},INTERVAL 7 DAY)
         where stat_date = DATE_SUB(#{startTime},INTERVAL 7 DAY)
         AND stat_hour &lt;= #{hours}
         AND stat_hour &lt;= #{hours}
-        AND i2.user_id IN
-        <foreach item="id" index="index" collection="userIds"
-                 open="(" separator="," close=")">
-            #{id}
-        </foreach>
         GROUP BY i1.account_id
         GROUP BY i1.account_id
         ) t6 ON t2.account_id = t6.account_id
         ) t6 ON t2.account_id = t6.account_id
         where stat_date = #{startTime}
         where stat_date = #{startTime}
-        and t2.account_status = 0
-        AND t2.user_id IN
-        <foreach item="id" index="index" collection="userIds"
-                 open="(" separator="," close=")">
-            #{id}
-        </foreach>
         GROUP BY t3.id
         GROUP BY t3.id
+        HAVING SUM(charge)>0
         <if test="sortCode != '' and sortCode != null ">
         <if test="sortCode != '' and sortCode != null ">
             ORDER BY ${sortCode}
             ORDER BY ${sortCode}
+            ${sortType}
         </if>
         </if>
-        ${sortType}
+
     </select>
     </select>
 
 
     <select id="projectPageListTotal" resultType="java.lang.Integer">
     <select id="projectPageListTotal" resultType="java.lang.Integer">
@@ -624,15 +604,10 @@
         t3.id
         t3.id
         FROM ctop_etl_kuaishou_report_account_hourly t1
         FROM ctop_etl_kuaishou_report_account_hourly t1
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
         LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
-        LEFT JOIN ctop_project t3 ON t2.project_id = t3.id
+        INNER JOIN ctop_project t3 ON t2.project_id = t3.id
         where stat_date = #{startTime}
         where stat_date = #{startTime}
-        and t2.account_status = 0
-        AND t2.user_id in
-        <foreach item="id" index="index" collection="userIds"
-                 open="(" separator="," close=")">
-            #{id}
-        </foreach>
         GROUP BY t3.id
         GROUP BY t3.id
+        HAVING SUM(charge)>0
         )t
         )t
     </select>
     </select>
 
 

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IEtlKuaishouReportAccountHourlyService.java

@@ -39,4 +39,6 @@ public interface IEtlKuaishouReportAccountHourlyService extends IService<EtlKuai
     Result<Object> projectList(JSONObject request) throws Exception;
     Result<Object> projectList(JSONObject request) throws Exception;
 
 
     Result<Object> leaderAccountPageList(JSONObject request) throws Exception;
     Result<Object> leaderAccountPageList(JSONObject request) throws Exception;
+
+    void updateYesterdayEtlHourlyData();
 }
 }

+ 33 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaishouReportAccountHourlyServiceImpl.java

@@ -86,6 +86,19 @@ public class EtlKuaishouReportAccountHourlyServiceImpl extends ServiceImpl<EtlKu
     }
     }
 
 
     @Override
     @Override
+    public void updateYesterdayEtlHourlyData() {
+        //昨天日期
+        String lastStartDate = DateUtils.getLastDay(DateUtils.formatDate(new Date()), 1);
+        List<EtlKuaishouReportAccountHourly> list = etlDailyAccountMapper.selectList(lastStartDate, lastStartDate);
+        if (!Check.isNull(list)) {
+            for (EtlKuaishouReportAccountHourly accountHourly : list) {
+                accountHourly.setStatHour(23l);
+            }
+            etlHourlyAccountMapper.replaceBatch(list);
+        }
+    }
+
+    @Override
     public Result<Object> getAggregateByHour(JSONObject request) throws ParseException {
     public Result<Object> getAggregateByHour(JSONObject request) throws ParseException {
         Long accountId = request.getLong("accountId");
         Long accountId = request.getLong("accountId");
         String startTime = request.getString("startTime");
         String startTime = request.getString("startTime");
@@ -490,7 +503,9 @@ public class EtlKuaishouReportAccountHourlyServiceImpl extends ServiceImpl<EtlKu
     @Override
     @Override
     public Result<Object> operatingStaffDataList(JSONObject request) {
     public Result<Object> operatingStaffDataList(JSONObject request) {
         String userId = request.getString("userId");
         String userId = request.getString("userId");
-        if (Check.isNull(userId)) {
+        String startTime = request.getString("startTime");
+        String endTime = request.getString("endTime");
+        if (Check.isNull(userId)||Check.isNull(startTime)||Check.isNull(endTime)) {
             return Result.error("缺少账户入参");
             return Result.error("缺少账户入参");
         }
         }
         String sortCode = request.getString("sortCode");
         String sortCode = request.getString("sortCode");
@@ -529,11 +544,24 @@ public class EtlKuaishouReportAccountHourlyServiceImpl extends ServiceImpl<EtlKu
         request.put("yesterday", yesterday);
         request.put("yesterday", yesterday);
         //获取人群集
         //获取人群集
         request.put("userIds", getUserIdList(userId));
         request.put("userIds", getUserIdList(userId));
-        int totle = etlHourlyAccountMapper.operatingStaffDataListTotal(request);
-        PageHelper.startPage(pageNo, pageSize, false);
-        PageInfo pageInfo = new PageInfo(etlHourlyAccountMapper.operatingStaffDataList(request));
+        List<JSONObject> list = null;
+        int total = 0;
+        //单日数据
+        if (endTime.equals(startTime)) {
+            if(!today.equals(startTime)){
+                request.put("yesterday", startTime);
+            }
+            total = etlHourlyAccountMapper.operatingStaffDataListTotal(request);
+            PageHelper.startPage(pageNo, pageSize, false);
+            list = etlHourlyAccountMapper.operatingStaffDataList(request);
+        }else {
+            total = etlDailyAccountMapper.operatingStaffDataListTotal(request);
+            PageHelper.startPage(pageNo, pageSize, false);
+            list = etlDailyAccountMapper.operatingStaffDataList(request);
+        }
+        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
         if (!Check.isNull(pageInfo)) {
         if (!Check.isNull(pageInfo)) {
-            pageInfo.setTotal(totle);
+            pageInfo.setTotal(total);
         }
         }
         return Result.ok(pageInfo);
         return Result.ok(pageInfo);
     }
     }

+ 17 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/utils/LinkUtils.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.math.RoundingMode;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
@@ -18,6 +19,11 @@ public class LinkUtils {
         List<JSONObject> result = new ArrayList<>();
         List<JSONObject> result = new ArrayList<>();
         beforeData.forEach(before -> {
         beforeData.forEach(before -> {
             String yesStat = String.valueOf(before.get(standard));
             String yesStat = String.valueOf(before.get(standard));
+            //修改点记率 乱码
+            byte[] click   = before.getBytes("clickRate");
+            String clickRate = new String(click, Charset.forName("UTF-8"));
+            before.put("clickRate",clickRate);
+
             AfterData.forEach(after -> {
             AfterData.forEach(after -> {
                 if ((String.valueOf(after.get(standard))).equals(yesStat)) {
                 if ((String.valueOf(after.get(standard))).equals(yesStat)) {
                     //消耗较昨日环比
                     //消耗较昨日环比
@@ -29,6 +35,11 @@ public class LinkUtils {
                     if(after.getLong("convertNum")!=null){
                     if(after.getLong("convertNum")!=null){
                         after.put("convertNumProportion", countLink(BigDecimal.valueOf(after.getLong("convertNum")), BigDecimal.valueOf(before.getLong("convertNum"))));
                         after.put("convertNumProportion", countLink(BigDecimal.valueOf(after.getLong("convertNum")), BigDecimal.valueOf(before.getLong("convertNum"))));
                     }
                     }
+                    //修改点记率 乱码
+                    byte[] aftClick   = after.getBytes("clickRate");
+                    String afterCli = new String(aftClick, Charset.forName("UTF-8"));
+                    after.put("clickRate",afterCli);
+
                     before.put("afterData", after);
                     before.put("afterData", after);
                 }
                 }
             });
             });
@@ -46,4 +57,10 @@ public class LinkUtils {
         return link;
         return link;
     }
     }
 
 
+    public static void main(String[] args) {
+        BigDecimal a = BigDecimal.valueOf(5.2);
+        BigDecimal b = BigDecimal.valueOf(4.2);
+        System.out.println(countLink(a,b));
+    }
+
 }
 }