魏超 5 年 前
コミット
3a928313f3
共有1 個のファイルを変更した90 個の追加82 個の削除を含む
  1. 90
    82
      src/main/resources/mapper/statistic/TaActivityStaticMapper.xml

+ 90
- 82
src/main/resources/mapper/statistic/TaActivityStaticMapper.xml ファイルの表示

985
         ) as activity
985
         ) as activity
986
 
986
 
987
         left join (
987
         left join (
988
-        select * from (
989
-        select count(*) as shareNum, a.be_share, a.tagert_type From ta_share_count a where a.tagert_type in (
990
-        'activity', 'group','h5','help','liveApp','livePost')
991
-        and a.org_id = #{orgId}
992
-        <if test="targetType != null and targetType != ''">
993
-            and a.tagert_type = #{targetType}
994
-        </if>
995
-        <if test="startDate != null ">
996
-            and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
997
-        </if>
998
-        <if test="endDate != null ">
999
-            and a.create_date &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
1000
-        </if>
1001
-        <if test="startDate == null or endDate == null ">
1002
-            AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1003
-        </if>
1004
-        group by a.be_share, tagert_type
1005
-        ) as a
988
+            SELECT count(1) as shareNum, a.be_share, case when a.tagert_type = 'liveApp' then 'live' when a.tagert_type = 'livePost' then 'live' else a.tagert_type end as tagert_type
989
+            FROM ta_share_count a where a.tagert_type in (
990
+            'activity', 'group','h5','help','liveApp','livePost')
991
+            and a.org_id = #{orgId}
992
+            <if test="targetType != null and targetType != ''">
993
+                and a.tagert_type = #{targetType}
994
+            </if>
995
+            <if test="startDate != null ">
996
+                and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
997
+            </if>
998
+            <if test="endDate != null ">
999
+                and a.create_date &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
1000
+            </if>
1001
+            <if test="startDate == null or endDate == null ">
1002
+                AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1003
+            </if>
1004
+            group by a.be_share
1006
         ) as shareNum on shareNum.be_share = activity.activityId and shareNum.tagert_type = activity.activityType
1005
         ) as shareNum on shareNum.be_share = activity.activityId and shareNum.tagert_type = activity.activityType
1007
 
1006
 
1008
         left join (
1007
         left join (
1009
-        select count(*) as sharePersonNum ,sharePersonNum.be_share, sharePersonNum.tagert_type,
1010
-        sharePersonNum.create_date from (
1011
-        select a.* From ta_share_count a where a.tagert_type in ( 'activity', 'group','h5','help','liveApp','livePost')
1008
+        SELECT count(*) as sharePersonNum ,sharePersonNum.be_share, sharePersonNum.tagert_type, sharePersonNum.create_date from (
1009
+        SELECT a.be_share, a.create_date ,case when a.tagert_type = 'liveApp' then 'live' when a.tagert_type = 'livePost' then 'live' else a.tagert_type end   as tagert_type
1010
+        From ta_share_count a where a.tagert_type in ( 'activity', 'group','h5','help','liveApp','livePost')
1012
         and a.org_id = #{orgId}
1011
         and a.org_id = #{orgId}
1013
         <if test="targetType != null and targetType != ''">
1012
         <if test="targetType != null and targetType != ''">
1014
             and a.tagert_type = #{targetType}
1013
             and a.tagert_type = #{targetType}
1028
         activity.activityType
1027
         activity.activityType
1029
 
1028
 
1030
         left join (
1029
         left join (
1031
-        select * from (
1032
-        select count(*) as visitNum, a.target_id, a.event_type From ta_person_visit_record a where a.event_type in
1033
-        ('activity','group','h5','help') and a.`event` = 'detail' and a.org_id = #{orgId}
1034
-        <if test="targetType != null and targetType != ''">
1035
-            and (case when #{targetType} = 'activity' then a.target_type = 'dynamic' else a.target_type = #{targetType}
1036
-            end)
1037
-        </if>
1038
-        <if test="startDate != null">
1039
-            and a.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1040
-        </if>
1041
-        <if test="endDate != null">
1042
-            and a.visit_time &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
1043
-        </if>
1044
-        <if test="startDate == null or endDate == null ">
1045
-            AND a.visit_time BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1046
-        </if>
1047
-        group by a.target_id, a.event_type
1048
-        ) as a
1049
-        ) as visitNum on visitNum.target_id = activity.activityId and visitNum.event_type = activity.activityType
1030
+            select count(*) as visitNum, a.target_id, case when a.target_type = 'dynamic' then 'activity' else a.target_type end as target_type
1031
+            From ta_person_visit_record a where a.event_type in
1032
+            ('activity','group','h5','help') and a.`event` = 'detail' and a.org_id = #{orgId}
1033
+            <if test="targetType != null and targetType != ''">
1034
+                and (case when #{targetType} = 'activity' then a.target_type = 'dynamic' else a.target_type = #{targetType}
1035
+                end)
1036
+            </if>
1037
+            <if test="startDate != null">
1038
+                and a.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1039
+            </if>
1040
+            <if test="endDate != null">
1041
+                and a.visit_time &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
1042
+            </if>
1043
+            <if test="startDate == null or endDate == null ">
1044
+                AND a.visit_time BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1045
+            </if>
1046
+            group by a.target_id, a.event_type
1047
+        ) as visitNum on visitNum.target_id = activity.activityId and visitNum.target_type = activity.activityType
1050
 
1048
 
1051
         left join (
1049
         left join (
1052
-        select count(*) as visitPersonNum ,visitPersonNum.target_id, visitPersonNum.event_type from (
1053
-        select a.* From ta_person_visit_record a where a.event_type in ('activity','group','h5','help') and a.`event` =
1054
-        'detail' and a.org_id = #{orgId}
1055
-        <if test="targetType != null and targetType != ''">
1056
-            and (case when #{targetType} = 'activity' then a.target_type = 'dynamic' else a.target_type = #{targetType}
1057
-            end)
1058
-        </if>
1059
-        <if test="startDate != null">
1060
-            and a.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1061
-        </if>
1062
-        <if test="endDate != null">
1063
-            and a.visit_time &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
1064
-        </if>
1065
-        <if test="startDate == null or endDate == null ">
1066
-            AND a.visit_time BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1067
-        </if>
1068
-        group by a.person_id, a.target_id, a.event_type
1069
-        ) as visitPersonNum group by visitPersonNum.target_id, visitPersonNum.event_type
1050
+            SELECT count(DISTINCT(a.person_id)) as visitPersonNum , a.target_id, case when a.target_type = 'dynamic' then 'activity' else a.target_type end as event_type
1051
+            From ta_person_visit_record a where a.event_type in ('activity','group','h5','help') and a.`event` =
1052
+            'detail' and a.org_id = #{orgId}
1053
+            <if test="targetType != null and targetType != ''">
1054
+                and (case when #{targetType} = 'activity' then a.target_type = 'dynamic' else a.target_type = #{targetType}
1055
+                end)
1056
+            </if>
1057
+            <if test="startDate != null">
1058
+                and a.visit_time &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%S' )
1059
+            </if>
1060
+            <if test="endDate != null">
1061
+                and a.visit_time &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%S' )
1062
+            </if>
1063
+            <if test="startDate == null or endDate == null ">
1064
+                AND a.visit_time BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1065
+            </if>
1066
+            group by a.target_id, a.event_type
1070
         ) as visitPersonNum on visitPersonNum.target_id = activity.activityId and visitPersonNum.event_type =
1067
         ) as visitPersonNum on visitPersonNum.target_id = activity.activityId and visitPersonNum.event_type =
1071
         activity.activityType
1068
         activity.activityType
1072
 
1069
 
1200
         ) as activity
1197
         ) as activity
1201
 
1198
 
1202
         left join (
1199
         left join (
1203
-        select * from (
1204
-        select count(*) as shareNum, a.be_share, a.tagert_type From ta_share_count a where a.tagert_type in (
1200
+        SELECT count(1) as shareNum, a.be_share, case when a.tagert_type = 'liveApp' then 'live' when a.tagert_type = 'livePost' then 'live' else a.tagert_type end as tagert_type
1201
+        FROM ta_share_count a where a.tagert_type in (
1205
         'activity', 'group','h5','help','liveApp','livePost')
1202
         'activity', 'group','h5','help','liveApp','livePost')
1206
         and a.org_id = #{orgId}
1203
         and a.org_id = #{orgId}
1207
         <if test="startDate != null ">
1204
         <if test="startDate != null ">
1213
         <if test="startDate == null or endDate == null ">
1210
         <if test="startDate == null or endDate == null ">
1214
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1211
             AND a.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
1215
         </if>
1212
         </if>
1216
-        group by a.be_share, tagert_type
1217
-        ) as a
1213
+        group by a.be_share
1218
         ) as shareNum on shareNum.be_share = activity.activityId and shareNum.tagert_type = activity.activityType
1214
         ) as shareNum on shareNum.be_share = activity.activityId and shareNum.tagert_type = activity.activityType
1219
 
1215
 
1220
         left join (
1216
         left join (
1221
         select count(*) as sharePersonNum ,sharePersonNum.be_share, sharePersonNum.tagert_type,
1217
         select count(*) as sharePersonNum ,sharePersonNum.be_share, sharePersonNum.tagert_type,
1222
         sharePersonNum.create_date from (
1218
         sharePersonNum.create_date from (
1223
-        select a.* From ta_share_count a where a.tagert_type in ( 'activity', 'group','h5','help','liveApp','livePost')
1219
+        SELECT a.be_share, a.create_date ,case when a.tagert_type = 'liveApp' then 'live' when a.tagert_type = 'livePost' then 'live' else a.tagert_type end   as tagert_type From ta_share_count a where a.tagert_type in ( 'activity', 'group','h5','help','liveApp','livePost')
1224
         and a.org_id = #{orgId}
1220
         and a.org_id = #{orgId}
1225
         <if test="startDate != null ">
1221
         <if test="startDate != null ">
1226
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d' )
1222
             and a.create_date &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d' )
1372
         ) as person
1368
         ) as person
1373
 
1369
 
1374
         left join (
1370
         left join (
1375
-        select * from (
1376
-        SELECT count(*) as shareNum, t.person_id
1377
-        FROM ta_share_count t
1378
-        LEFT JOIN ta_help_activity a ON t.be_share = a.help_activity_id
1379
-        LEFT JOIN ta_share_activity b ON t.be_share = b.share_id
1380
-        LEFT JOIN ta_live_activity c ON t.be_share = c.live_activity_id
1381
-        LEFT JOIN ta_drainage d ON t.be_share = d.drainage_id
1382
-        LEFT JOIN ta_building_dynamic e ON t.be_share = e.dynamic_id
1383
-        LEFT JOIN ta_person f
1384
-        ON t.person_id = f.person_id
1385
-        WHERE t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
1386
-        and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date &lt;=
1387
-        DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' )
1388
-        group by person_id
1389
-        ) as temp
1371
+            select * from (
1372
+                SELECT count(*) as shareNum, t.person_id
1373
+                FROM ta_share_count t
1374
+                LEFT JOIN ta_help_activity a ON t.be_share = a.help_activity_id
1375
+                LEFT JOIN ta_share_activity b ON t.be_share = b.share_id
1376
+                LEFT JOIN ta_live_activity c ON t.be_share = c.live_activity_id
1377
+                LEFT JOIN ta_drainage d ON t.be_share = d.drainage_id
1378
+                LEFT JOIN ta_building_dynamic e ON t.be_share = e.dynamic_id
1379
+                LEFT JOIN ta_person f
1380
+                ON t.person_id = f.person_id
1381
+                WHERE t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
1382
+                and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date &lt;=
1383
+                DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' )
1384
+                <if test="activityId != null and activityId != ''">
1385
+                    and t.be_share = #{activityId}
1386
+                </if>
1387
+                <if test="activityType != null and activityType != ''">
1388
+                    and t.tagert_type = #{activityType}
1389
+                </if>
1390
+                group by person_id
1391
+            ) as temp
1390
         ) as shareNum on person.person_id = shareNum.person_id
1392
         ) as shareNum on person.person_id = shareNum.person_id
1391
 
1393
 
1392
         left join (
1394
         left join (
1517
         WHERE t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
1519
         WHERE t.tagert_type in ('activity','group','h5','help','liveApp','livePost') and t.org_id = #{orgId}
1518
         and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date &lt;=
1520
         and t.create_date >= DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%I:%S' ) and t.create_date &lt;=
1519
         DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' )
1521
         DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%I:%S' )
1522
+        <if test="activityId != null and activityId != ''">
1523
+            and t.be_share = #{activityId}
1524
+        </if>
1525
+        <if test="activityType != null and activityType != ''">
1526
+            and t.tagert_type = #{activityType}
1527
+        </if>
1520
         group by person_id
1528
         group by person_id
1521
         ) as temp
1529
         ) as temp
1522
         ) as shareNum on person.person_id = shareNum.person_id
1530
         ) as shareNum on person.person_id = shareNum.person_id
1848
             and t.target_id = #{activityId}
1856
             and t.target_id = #{activityId}
1849
         </if>
1857
         </if>
1850
         <if test="activityType != null and activityType != ''">
1858
         <if test="activityType != null and activityType != ''">
1851
-            and t.event_type = #{activityType}
1859
+            and t.target_type = #{activityType}
1852
         </if>
1860
         </if>
1853
         <if test="buildingId != null and buildingId != ''">
1861
         <if test="buildingId != null and buildingId != ''">
1854
             and t.building_id = #{buildingId}
1862
             and t.building_id = #{buildingId}
1905
             and t.target_id = #{activityId}
1913
             and t.target_id = #{activityId}
1906
         </if>
1914
         </if>
1907
         <if test="activityType != null and activityType != ''">
1915
         <if test="activityType != null and activityType != ''">
1908
-            and t.event_type = #{activityType}
1916
+            and t.target_type = #{activityType}
1909
         </if>
1917
         </if>
1910
         <if test="buildingId != null and buildingId != ''">
1918
         <if test="buildingId != null and buildingId != ''">
1911
             and t.building_id = #{buildingId}
1919
             and t.building_id = #{buildingId}
1970
             and t.target_id = #{activityId}
1978
             and t.target_id = #{activityId}
1971
         </if>
1979
         </if>
1972
         <if test="activityType != null and activityType != ''">
1980
         <if test="activityType != null and activityType != ''">
1973
-            and t.event_type = #{activityType}
1981
+            and t.target_type = #{activityType}
1974
         </if>
1982
         </if>
1975
         <if test="buildingId != null and buildingId != ''">
1983
         <if test="buildingId != null and buildingId != ''">
1976
             and t.building_id = #{buildingId}
1984
             and t.building_id = #{buildingId}
2036
             and t.target_id = #{activityId}
2044
             and t.target_id = #{activityId}
2037
         </if>
2045
         </if>
2038
         <if test="activityType != null and activityType != ''">
2046
         <if test="activityType != null and activityType != ''">
2039
-            and t.event_type = #{activityType}
2047
+            and t.target_type = #{activityType}
2040
         </if>
2048
         </if>
2041
         <if test="buildingId != null and buildingId != ''">
2049
         <if test="buildingId != null and buildingId != ''">
2042
             and t.building_id = #{buildingId}
2050
             and t.building_id = #{buildingId}