StatisticsMapper.xml
6.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bjivt.entity.showtime.Statistics">
<!-- 统计注册人数 总数变化情况-->
<select id="getRegistUserTotal" parameterType="java.util.Map" resultType="com.bjivt.entity.vo.StatisticsResult">
<if test="types==0 or types==1" >
select date_format(u.date,'%Y-%m-%d') time,(
select sum(new_user_count) counts from db_showtime_stat.tbl_daily_statistics ds
where <![CDATA[ date_format(ds.date,'%Y-%m-%d') <= date_format(u.date,'%Y-%m-%d') ]]> ) as counts
from db_showtime_stat.tbl_daily_statistics u
where u.date is not null
<if test="startTime !=null and startTime!=''">
<![CDATA[ and date_format(u.date,'%Y-%m-%d') >= str_to_date(#{startTime},'%Y-%m-%d') ]]>
</if>
<if test="endTime !=null and endTime!=''">
<![CDATA[ and date_format(u.date,'%Y-%m-%d') <= str_to_date(#{endTime},'%Y-%m-%d') ]]>
</if>
order by time
</if>
<if test="types==2">
select distinct date_format(u.date,'%Y年第%u周') time,(
select sum(new_user_count) counts from db_showtime_stat.tbl_daily_statistics ds
where <![CDATA[ date_format(ds.date,'%Y年第%u周') <= date_format(u.date,'%Y年第%u周') ]]> ) as counts
from db_showtime_stat.tbl_daily_statistics u
where u.date is not null
<if test="startTime !=null and startTime!=''">
<![CDATA[ and date_format(u.date,'%Y-%m-%d') >= str_to_date(#{startTime},'%Y-%m-%d') ]]>
</if>
<if test="endTime !=null and endTime!=''">
<![CDATA[ and date_format(u.date,'%Y-%m-%d') <= str_to_date(#{endTime},'%Y-%m-%d') ]]>
</if>
order by time
</if>
<if test="types==3">
select distinct date_format(u.date,'%Y年%m月') time,(
select sum(new_user_count) counts from db_showtime_stat.tbl_daily_statistics ds
where <![CDATA[ date_format(ds.date,'%Y年%m月') <= date_format(u.date,'%Y年%m月') ]]> ) as counts
from db_showtime_stat.tbl_daily_statistics u
where u.date is not null
<if test="startTime !=null and startTime!=''">
<![CDATA[ and date_format(u.date,'%Y-%m-%d') >= str_to_date(#{startTime},'%Y-%m-%d') ]]>
</if>
<if test="endTime !=null and endTime!=''">
<![CDATA[ and date_format(u.date,'%Y-%m-%d') <= str_to_date(#{endTime},'%Y-%m-%d') ]]>
</if>
order by time
</if>
<if test="types==4">
select distinct date_format(u.date,'%Y') time,(
select sum(new_user_count) counts from db_showtime_stat.tbl_daily_statistics ds
where <![CDATA[ date_format(ds.date,'%Y') <= date_format(u.date,'%Y') ]]> ) as counts
from db_showtime_stat.tbl_daily_statistics u
where u.date is not null
<if test="startTime !=null and startTime!=''">
<![CDATA[ and date_format(u.date,'%Y-%m-%d') >= str_to_date(#{startTime},'%Y-%m-%d') ]]>
</if>
<if test="endTime !=null and endTime!=''">
<![CDATA[ and date_format(u.date,'%Y-%m-%d') <= str_to_date(#{endTime},'%Y-%m-%d') ]]>
</if>
order by time
</if>
</select>
<!-- 统计注册人数 统计按某个时间段统计的注册人数-->
<select id="getRegistUserEveryDay" parameterType="java.util.Map" resultType="com.bjivt.entity.vo.StatisticsResult">
<if test="types==0 or types==1" >
select date_format(u.date,'%Y-%m-%d') time,new_user_count counts
from db_showtime_stat.tbl_daily_statistics u
where date_format(u.date,'%Y%m%d') is not null
<if test="startTime !=null and startTime!=''">
<![CDATA[ and date_format(u.date,'%Y-%m-%d') >= str_to_date(#{startTime},'%Y-%m-%d') ]]>
</if>
<if test="endTime !=null and endTime!=''">
<![CDATA[ and date_format(u.date,'%Y-%m-%d') <= str_to_date(#{endTime},'%Y-%m-%d') ]]>
</if>
group by time, new_user_count order by time
</if>
<if test="types==2">
select date_format(u.date,'%Y年第%u周') time,
sum(new_user_count) counts from db_showtime_stat.tbl_daily_statistics u
where date_format(u.date,'%Y%u') is not null
and date_format(u.date,'%Y%m%d') between date_format(#{startTime},'%Y%m%d') and date_format(#{endTime},'%Y%m%d')
group by date_format(u.date,'%Y年第%u周') order by time
</if>
<if test="types==3">
select date_format(u.date,'%Y年%m月') time,sum(new_user_count) counts from db_showtime_stat.tbl_daily_statistics u
where date_format(u.date,'%Y%m') is not null
and date_format(u.date,'%Y%m%d') between date_format(#{startTime},'%Y%m%d') and date_format(#{endTime},'%Y%m%d')
group by date_format(u.date,'%Y年%m月') order by time
</if>
<if test="types==4">
select date_format(u.date,'%Y') time,sum(new_user_count) counts from db_showtime_stat.tbl_daily_statistics u
where date_format(u.date,'%Y') is not null
and date_format(u.date,'%Y') between date_format(#{startTime},'%Y') and date_format(#{endTime},'%Y')
group by date_format(u.date,'%Y') order by time
</if>
</select>
<select id="getRegistUserBeforeDayCount" parameterType="java.util.Map" resultType="java.lang.Integer">
select user_total_count counts from db_showtime_stat.tbl_daily_statistics tu
where tu.date is not null
<if test="endTime !=null and endTime != ''">
<![CDATA[ and date_format(tu.date,'%Y-%m-%d') = str_to_date(#{endTime},'%Y-%m-%d') ]]>
</if>
</select>
<!-- 统计各个手机的型号和机型统计 -->
<select id="statisticMobileByMap" parameterType="java.util.Map" resultType="com.bjivt.entity.vo.StatisticMobile">
select model, brand,count(*) as counts from db_showtime_log.tbl_mobile_info group by model, brand
<if test="page != null and page !=''">
<if test="page.orderBy != null and page.orderBy != ''">
order by ${page.orderBy}
</if>
<if test="page.from != null and page.size != null">
limit #{page.from},#{page.size}
</if>
</if>
</select>
<select id="statisticMobileCount" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(*) FROM (select model, brand,count(*) as counts from db_showtime_log.tbl_mobile_info group by model, brand ) as t
</select>
<select id="findUserListByMap" resultType="com.bjivt.entity.showtime.User" parameterType="java.util.Map">
SELECT * FROM tbl_user_list
</select>
</mapper>