StatisticsMapper.xml 6.28 KB
<?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>