EqpVirtualParkRecordSMapper.xml 7.21 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.EqpVirtualParkRecordSMapper">
    <resultMap id="BaseResultMap" type="com.zteits.park.domain.EqpVirtualParkRecord">
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="eqp_type" jdbcType="INTEGER" property="eqpType" />
        <result column="eqp_no" jdbcType="VARCHAR" property="eqpNo" />
        <result column="pl_no" jdbcType="VARCHAR" property="plNo" />
        <result column="berth_no" jdbcType="VARCHAR" property="berthNo" />
        <result column="berth_range_no" jdbcType="VARCHAR" property="berthRangeNo" />
        <result column="pl_name" jdbcType="VARCHAR" property="plName" />
        <result column="pl_type" jdbcType="INTEGER" property="plType" />
        <result column="eqp_in_time" jdbcType="TIMESTAMP" property="eqpInTime" />
        <result column="eqp_out_time" jdbcType="TIMESTAMP" property="eqpOutTime" />
        <result column="park_duration" jdbcType="BIGINT" property="parkDuration" />
        <result column="park_fee" jdbcType="INTEGER" property="parkFee" />
        <result column="remark" jdbcType="VARCHAR" property="remark" />
        <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
    </resultMap>
    <sql id="Example_Where_Clause">
        <where>
            <foreach collection="oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Update_By_Example_Where_Clause">
        <where>
            <foreach collection="example.oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Base_Column_List">
        id, eqp_out_time, eqp_type, eqp_no, berth_no, berth_range_no, pl_no, pl_name, pl_type,
        eqp_in_time, park_duration, park_fee, remark, create_date
    </sql>

    <select id="queryEqpVirtualParkRecordForStatistic"
            resultType="com.zteits.park.domain.EqpVirtualParkRecordStatistic">

        SELECT
            pl_no               plNo,
            eqp_type            eqpType,
            max(pl_name)        plName,
            count(0)            parkNum,
            sum(CASE
                    WHEN park_fee = NULL || park_fee = 0
                        THEN 1
                    ELSE 0 END) freeParknum,
            sum(park_fee)       income


        FROM eqp_virtual_park_record
        WHERE pl_no = #{plNo}
          AND eqp_out_time BETWEEN #{startDate} AND #{endDate}
        GROUP BY pl_no, eqp_type


    </select>



    <select id="queryRecentIncome" parameterType="com.zteits.clouds.api.dto.park.param.EqpVirtualParkRecordRequest"
            resultType="com.zteits.clouds.api.dto.park.dto.EqpVirtualParkRecordRecentStatisticDTO">
        SELECT
        DATE_FORMAT(eqp_out_time,'%Y-%m-%d %H') timeStr,
        sum(park_fee)      parkFee,
        sum(park_duration) parkDuration
        FROM eqp_virtual_park_record
        WHERE
        eqp_type = 1
        AND
        eqp_out_time BETWEEN #{eqpOutTimeStart} AND #{eqpOutTimeEnd}
        AND pl_no IN
        <foreach collection="plNos" index="index" separator="," item="plNo" open="(" close=")">
            #{plNo}
        </foreach>

        GROUP BY timeStr

    </select>

    <select id="queryRecentIncomeforSummary" parameterType="com.zteits.clouds.api.dto.park.param.EqpVirtualParkRecordRequest"
            resultType="com.zteits.clouds.api.dto.park.dto.EqpVirtualParkRecordRecentStatisticDTO">
        SELECT
        sum(park_fee)      parkFee,
        sum(park_duration) parkDuration
        FROM eqp_virtual_park_record
        WHERE
        eqp_type = 1
        AND
        eqp_out_time BETWEEN #{eqpOutTimeStart} AND #{eqpOutTimeEnd}
        AND pl_no IN
        <foreach collection="plNos" index="index" separator="," item="plNo" open="(" close=")">
            #{plNo}
        </foreach>



    </select>
    <select id="queryChargerIncomeDiffInfo" resultType="com.zteits.park.domain.ChargerIncomeDiff">
        SELECT
            berth_range_no berthRangeNo,
            count(0)       eqpParkNum,
            IFNULL(sum(park_fee),0 ) eqpTotalFee
        FROM eqp_virtual_park_record
         where  berth_no IN
          <foreach collection="berthNos" item="berthNo" open="(" close=")" separator="," >
              #{berthNo}
          </foreach>
          AND eqp_out_time BETWEEN #{startDate} AND #{endDate}
          and berth_range_no = #{berthRangeNo}
        GROUP BY berth_range_no



    </select>


</mapper>