DataAnalysisSMapper.xml 9.66 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.zteits.park.mapper.smapper.DataAnalysisSMapper">
	<select id="getOccupationRatioRankingData" parameterType="com.zteits.clouds.api.dto.govclouds.param.OccupationRatioRankingRequest"
	    resultType="com.zteits.park.domain.OccupationRatioRankingDO">
		select 
		    @rownum:=@rownum+1 as rownum, 
		    a.* 
		from (
		        (select @rownum:=0) o, 
		        (select distinct 
		            lt1.pl_name plName, 
		            (1-lt1.free_ratio) occupancyRatio,  
		            case when lt1.free_ratio &lt; lt2.free_ratio then 1
		                 when lt1.free_ratio > lt2.free_ratio then -1
		                 when lt1.free_ratio = lt2.free_ratio then 0
		            end  comparingResults
		        from parking_lot_use_statistic lt1 
		                    inner join parking_lot_use_statistic lt2 
		                            on lt2.statistic_end_time = DATE_ADD(lt1.statistic_end_time, INTERVAL -20 MINUTE) 
		                                and lt2.pl_no=lt1.pl_no and lt2.statistic_type=1
		        where lt1.statistic_end_time=(select statistic_end_time from parking_lot_use_statistic 
		                                    order by statistic_end_time desc limit 1) 
		            and lt1.statistic_type=1
		            order by 1-lt1.free_ratio desc) a
		)
	</select>
	
	<select id="getOccupationRationDetailsData" parameterType="com.zteits.clouds.api.dto.govclouds.param.OccupationRatioDetailsRequest"
        resultType="com.zteits.park.domain.OccupationRatioDetailsDO">
        select 
		    @rownum:=@rownum+1 as rownum, 
		    a.* 
		from (
		        (select @rownum:=0) o, 
		        (select distinct  
		            lt1.pl_name plName, 
		            (1-lt1.free_ratio) occupancyRatio,  
		            case when lt1.free_ratio &lt; lt2.free_ratio then 1
		                 when lt1.free_ratio > lt2.free_ratio then -1
		                 when lt1.free_ratio = lt2.free_ratio then 0
		            end  monthComparingResults,
		            case when lt1.free_ratio &lt; lt3.free_ratio then 1
		                 when lt1.free_ratio > lt3.free_ratio then -1
		                 when lt1.free_ratio = lt3.free_ratio then 0
		            end  dayComparingResults
		        from parking_lot_use_statistic lt1 
		                    inner join parking_lot_use_statistic lt2 
		                            on lt2.statistic_end_time = DATE_ADD(lt1.statistic_end_time, INTERVAL -1 MONTH)
		                                and lt2.pl_no=lt1.pl_no and lt2.statistic_type=1
		                    inner join parking_lot_use_statistic lt3 
		                            on lt3.statistic_end_time = DATE_ADD(lt1.statistic_end_time, INTERVAL -1 DAY) 
		                                and lt3.pl_no=lt1.pl_no and lt3.statistic_type=1
		            
		        where lt1.statistic_end_time=(select statistic_end_time from parking_lot_use_statistic 
		                                    order by statistic_end_time desc limit 1) 
		            and lt1.statistic_type=1
		            order by 1-lt1.free_ratio desc) a
		    )
    </select>
    
    <select id="getTurnOverRatioRankingData" parameterType="com.zteits.clouds.api.dto.govclouds.param.TurnOverRatioRankingRequest"
        resultType="com.zteits.park.domain.TurnOverRatioRankingDO">
        select 
            @rownum:=@rownum+1 as rownum, 
            a.* 
        from (
                (select @rownum:=0) o, 
                (select distinct 
                    lt1.pl_name plName, 
                    lt1.turnover_ratio turnOverRatio,  
                    case when lt1.turnover_ratio > lt2.turnover_ratio then 1
                         when lt1.turnover_ratio &lt; lt2.turnover_ratio then -1
                         when lt1.turnover_ratio = lt2.turnover_ratio then 0
                    end  comparingResults
                from parking_lot_use_statistic lt1 
                            inner join parking_lot_use_statistic lt2 
                                    on lt2.statistic_end_time = DATE_ADD(lt1.statistic_end_time, INTERVAL -20 MINUTE) 
                                        and lt2.pl_no=lt1.pl_no and lt2.statistic_type=1
                where lt1.statistic_end_time=(select statistic_end_time from parking_lot_use_statistic 
                                            order by statistic_end_time desc limit 1) 
                    and lt1.statistic_type=1
                    order by lt1.turnover_ratio desc) a
        )
    </select>
    <!-- 周转率详情 -->
    <select id="getTurnOverRatioDetailsData" parameterType="com.zteits.clouds.api.dto.govclouds.param.TurnOverRatioDetailsRequest"
        resultType="com.zteits.park.domain.TurnOverRatioDetailsDO">
        select 
            @rownum:=@rownum+1 as rownum, 
            a.* 
        from (
                (select @rownum:=0) o, 
                (select distinct  
                    lt1.pl_name plName, 
                    lt1.turnover_ratio turnOverRatio,  
                    case when lt1.turnover_ratio > lt2.turnover_ratio then 1
                         when lt1.turnover_ratio &lt; lt2.turnover_ratio then -1
                         when lt1.turnover_ratio = lt2.turnover_ratio then 0
                    end  monthComparingResults,
                    case when lt1.turnover_ratio > lt3.turnover_ratio then 1
                         when lt1.turnover_ratio &lt; lt3.turnover_ratio then -1
                         when lt1.turnover_ratio = lt3.turnover_ratio then 0
                    end  dayComparingResults
                from parking_lot_use_statistic lt1 
                            inner join parking_lot_use_statistic lt2 
                                    on lt2.statistic_end_time = DATE_ADD(lt1.statistic_end_time, INTERVAL -1 MONTH)
                                        and lt2.pl_no=lt1.pl_no and lt2.statistic_type=1
                            inner join parking_lot_use_statistic lt3 
                                    on lt3.statistic_end_time = DATE_ADD(lt1.statistic_end_time, INTERVAL -1 DAY) 
                                        and lt3.pl_no=lt1.pl_no and lt3.statistic_type=1
                    
                where lt1.statistic_end_time=(select statistic_end_time from parking_lot_use_statistic 
                                            order by statistic_end_time desc limit 1) 
                    and lt1.statistic_type=1
                    order by lt1.turnover_ratio desc) a
            )
    </select>
    
    <!-- 空置率排行榜 -->
    <select id="getFreeRatioRankingData" parameterType="com.zteits.clouds.api.dto.govclouds.param.FreeRatioRankingRequest"
        resultType="com.zteits.park.domain.FreeRatioRankingDO">
        select 
            @rownum:=@rownum+1 as rownum, 
            a.* 
        from (
                (select @rownum:=0) o, 
                (select distinct 
                    lt1.pl_name plName, 
                    lt1.free_ratio freeRatio,  
                    case when lt1.free_ratio > lt2.free_ratio then 1
                         when lt1.free_ratio &lt; lt2.free_ratio then -1
                         when lt1.free_ratio = lt2.free_ratio then 0
                    end  comparingResults
                from parking_lot_use_statistic lt1 
                            inner join parking_lot_use_statistic lt2 
                                    on lt2.statistic_end_time = DATE_ADD(lt1.statistic_end_time, INTERVAL -20 MINUTE) 
                                        and lt2.pl_no=lt1.pl_no and lt2.statistic_type=1
                where lt1.statistic_end_time=(select statistic_end_time from parking_lot_use_statistic 
                                            order by statistic_end_time desc limit 1) 
                    and lt1.statistic_type=1
                    order by lt1.free_ratio desc) a
        )
    </select>
    <!-- 空置率详情 -->
    <select id="getFreeRatioDetailsData" parameterType="com.zteits.clouds.api.dto.govclouds.param.FreeRatioDetailsRequest"
        resultType="com.zteits.park.domain.FreeRatioDetailsDO">
        select 
            @rownum:=@rownum+1 as rownum, 
            a.* 
        from (
                (select @rownum:=0) o, 
                (select distinct  
                    lt1.pl_name plName, 
                    lt1.free_ratio freeRatio,  
                    case when lt1.free_ratio > lt2.free_ratio then 1
                         when lt1.free_ratio &lt; lt2.free_ratio then -1
                         when lt1.free_ratio = lt2.free_ratio then 0
                    end  monthComparingResults,
                    case when lt1.free_ratio > lt3.free_ratio then 1
                         when lt1.free_ratio &lt; lt3.free_ratio then -1
                         when lt1.free_ratio = lt3.free_ratio then 0
                    end  dayComparingResults
                from parking_lot_use_statistic lt1 
                            inner join parking_lot_use_statistic lt2 
                                    on lt2.statistic_end_time = DATE_ADD(lt1.statistic_end_time, INTERVAL -1 MONTH)
                                        and lt2.pl_no=lt1.pl_no and lt2.statistic_type=1
                            inner join parking_lot_use_statistic lt3 
                                    on lt3.statistic_end_time = DATE_ADD(lt1.statistic_end_time, INTERVAL -1 DAY) 
                                        and lt3.pl_no=lt1.pl_no and lt3.statistic_type=1
                    
                where lt1.statistic_end_time=(select statistic_end_time from parking_lot_use_statistic 
                                            order by statistic_end_time desc limit 1) 
                    and lt1.statistic_type=1
                    order by lt1.free_ratio desc) a
            )
    </select>
</mapper>