DurationStatisticParkMonthSMapper.xml 4.77 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.order.mapper.smapper.DurationStatisticParkMonthSMapper">
  <resultMap id="BaseResultMap" type="com.zteits.order.domain.DurationStatisticParkMonth">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="static_date" jdbcType="DATE" property="staticDate" />
    <result column="static_date_str" jdbcType="VARCHAR" property="staticDateStr" />
    <result column="org_id" jdbcType="INTEGER" property="orgId" />
    <result column="area_id" jdbcType="VARCHAR" property="areaId" />
    <result column="area_name" jdbcType="VARCHAR" property="areaName" />
    <result column="pl_no" jdbcType="VARCHAR" property="plNo" />
    <result column="pl_name" jdbcType="VARCHAR" property="plName" />
    <result column="berth_num" jdbcType="INTEGER" property="berthNum" />
    <result column="total_duration" jdbcType="BIGINT" property="totalDuration" />
    <result column="total_parking_times" jdbcType="INTEGER" property="totalParkingTimes" />
    <result column="avg_berth_duration" jdbcType="BIGINT" property="avgBerthDuration" />
    <result column="avg_times_duration" jdbcType="BIGINT" property="avgTimesDuration" />
    <result column="min_15" jdbcType="INTEGER" property="min15" />
    <result column="min_30" jdbcType="INTEGER" property="min30" />
    <result column="hour_1" jdbcType="INTEGER" property="hour1" />
    <result column="hour_6" jdbcType="INTEGER" property="hour6" />
    <result column="hour_12" jdbcType="INTEGER" property="hour12" />
    <result column="hour_24" jdbcType="INTEGER" property="hour24" />
    <result column="day_1" jdbcType="INTEGER" property="day1" />
    <result column="data_state" jdbcType="INTEGER" property="dataState" />
    <result column="create_emp_id" jdbcType="VARCHAR" property="createEmpId" />
    <result column="create_emp_name" jdbcType="VARCHAR" property="createEmpName" />
    <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
    <result column="modfiy_emp_id" jdbcType="VARCHAR" property="modfiyEmpId" />
    <result column="modfiy_emp_name" jdbcType="VARCHAR" property="modfiyEmpName" />
    <result column="modfiy_date" jdbcType="TIMESTAMP" property="modfiyDate" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="pl_type" jdbcType="INTEGER" property="plType" />
  </resultMap>
  
    <!-- 停车时长汇总(按月) -->
    <select id="queryDurationStatisticParkMonthTotal" resultType="com.zteits.clouds.api.dto.order.duration.dto.DurationParkTotalDTO" 
        parameterType="com.zteits.clouds.api.dto.order.duration.param.DurationParkReq">
       SELECT b.*,
	       IFNULL(b.totalDuration/b.berthNum,0) avgBerthDuration,
	       IFNULL(b.totalDuration/b.totalParkingTimes,0) avgTimesDuration
	       from(
	            SELECT
	            count(DISTINCT(a.pl_no)) as parkNum,
	            a.pl_type as plType,
	            MAX(a.static_date_str) as staticDateStr,
	            sum((IFNULL(a.berth_num,0))) as berthNum,
	            sum(IFNULL(a.total_duration,0)) as totalDuration,
	            sum(IFNULL(a.total_parking_times,0)) as totalParkingTimes
	        FROM
	            duration_statistic_park_month a
	        where 1=1
	          and a.data_state=1
	          and a.static_date between #{beginTime} and #{endTime}
	          and a.pl_no in
	            <foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
	                #{plNo}
	            </foreach>
	         group by a.pl_type)b
    </select>
    
    <!-- 停车时长分布(按月) -->
    <select id="queryParkDurationMonthDistribute" resultType="com.zteits.clouds.api.dto.order.duration.dto.DurationParkDistDTO" 
        parameterType="com.zteits.clouds.api.dto.order.duration.param.DurationParkReq">
           SELECT
                a.pl_type as plType,
                MAX(a.static_date_str) as staticDateStr,
                sum((IFNULL(a.min_15,0))) as min15,
                sum(IFNULL(a.min_30,0)) as min30,
                sum(IFNULL(a.hour_1,0)) as hour1,
                sum(IFNULL(a.hour_6,0)) as hour6,
                sum(IFNULL(a.hour_12,0)) as hour12,
                sum(IFNULL(a.hour_24,0)) as hour24,
                sum(IFNULL(a.day_1,0)) as day1,
                sum(IFNULL(a.total_parking_times,0)) as totalParkingTimes
            FROM
                duration_statistic_park_month a
            where 1=1
              and a.data_state=1
              and a.static_date between #{beginTime} and #{endTime}
              and a.pl_no in
                <foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
                    #{plNo}
                </foreach>
             group by a.pl_type
    </select>
    
</mapper>