ChargerIncomeDiffSMapper.xml 8.95 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.ChargerIncomeDiffSMapper">
    <resultMap id="BaseResultMap" type="com.zteits.park.domain.ChargerIncomeDiff">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="static_date" jdbcType="DATE" property="staticDate"/>
        <result column="org_id" jdbcType="BIGINT" property="orgId"/>
        <result column="pl_no" jdbcType="VARCHAR" property="plNo"/>
        <result column="pl_name" jdbcType="VARCHAR" property="plName"/>
        <result column="berth_range_no" jdbcType="VARCHAR" property="berthRangeNo"/>
        <result column="berth_range_name" jdbcType="VARCHAR" property="berthRangeName"/>
        <result column="berth_range_eqp_num" jdbcType="INTEGER" property="berthRangeEqpNum"/>
        <result column="berth_range_berth_num" jdbcType="INTEGER" property="berthRangeBerthNum"/>
        <result column="charger_code" jdbcType="VARCHAR" property="chargerCode"/>
        <result column="charger_name" jdbcType="VARCHAR" property="chargerName"/>
        <result column="group_start_time" jdbcType="TIMESTAMP" property="groupStartTime"/>
        <result column="group_start_time_str" jdbcType="VARCHAR" property="groupStartTimeStr"/>
        <result column="group_end_time" jdbcType="TIMESTAMP" property="groupEndTime"/>
        <result column="group_end_time_str" jdbcType="VARCHAR" property="groupEndTimeStr"/>
        <result column="pda_eqp_park_num" jdbcType="INTEGER" property="pdaEqpParkNum"/>
        <result column="pda_eqp_park_fee" jdbcType="INTEGER" property="pdaEqpParkFee"/>
        <result column="eqp_park_num" jdbcType="INTEGER" property="eqpParkNum"/>
        <result column="eqp_total_fee" jdbcType="INTEGER" property="eqpTotalFee"/>
        <result column="park_and_eqp_diff_fee" jdbcType="INTEGER" property="parkAndEqpDiffFee"/>
        <result column="park_and_eqp_diff_rate" jdbcType="VARCHAR" property="parkAndEqpDiffRate"/>
        <result column="order_total_fee" jdbcType="BIGINT" property="orderTotalFee"/>
        <result column="order_act_fee" jdbcType="BIGINT" property="orderActFee"/>
        <result column="order_diff_fee" jdbcType="BIGINT" property="orderDiffFee"/>
        <result column="order_diff_rate" jdbcType="VARCHAR" property="orderDiffRate"/>
        <result column="data_status" jdbcType="INTEGER" property="dataStatus"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="create_op" jdbcType="VARCHAR" property="createOp"/>
        <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
        <result column="modify_op" jdbcType="VARCHAR" property="modifyOp"/>
    </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,
        static_date,
        org_id,
        pl_no,
        pl_name,
        berth_range_no,
        berth_range_name,
        berth_range_eqp_num,
        berth_range_berth_num,
        charger_code,
        charger_name,
        group_start_time,
        group_start_time_str,
        group_end_time,
        group_end_time_str,
        pda_eqp_park_num,
        pda_eqp_park_fee,
        eqp_park_num,
        eqp_total_fee,
        park_and_eqp_diff_fee,
        park_and_eqp_diff_rate,
        order_total_fee,
        order_act_fee,
        order_diff_fee,
        order_diff_rate,
        data_status,
        remark,
        create_time,
        create_op,
        modify_time,
        modify_op
    </sql>

    <select id="queryChargerIncomeDiffForSummary"
            resultType="com.zteits.clouds.api.dto.park.dto.ChargerIncomeDiffSummaryDTO">
        SELECT
        sum(result.parkNum) parkNum,
        sum(result.chargerCodeNum) chargerCodeNum,
        sum(result.orderTotalFee) orderTotalFee,
        sum(result.eqpTotalFee) eqpTotalFee,
        sum(result.eqpNum) eqpNum,
        sum(result.berthNum) berthNum
        FROM (

        SELECT
        count(DISTINCT pl_no) parkNum,
        count(DISTINCT charger_code) chargerCodeNum,
        sum(pda_eqp_park_fee) orderTotalFee,
        sum(eqp_total_fee) eqpTotalFee,
        0 eqpNum,
        0 berthNum
        FROM charger_income_diff
        WHERE data_status = 1
        AND pl_no IN
        <foreach collection="plNos" item="plNo" separator="," open="(" close=")" index="index">
            #{plNo}
        </foreach>
        <if test="chargerCode != null">
            AND charger_code = #{chargerCode}
        </if>
        <if test="berthRangeNos != null and berthRangeNos.size() >0">
            AND berth_range_no In
            <foreach collection="berthRangeNos" item="berthRangeNo" separator="," open="(" close=")" index="index">
                #{berthRangeNo}
            </foreach>

        </if>

        AND static_date BETWEEN #{startDate} AND #{endDate}

        UNION ALL

        SELECT
        0 parkNum,
        0 chargerCodeNum,
        0 orderTotalFee,
        0 eqpTotalFee,
        sum(temp.eqpNum) eqpNum,
        sum(temp.berthNum) berthNum
        FROM (
        SELECT

        max(berth_range_eqp_num) eqpNum,
        max(berth_range_berth_num) berthNum

        FROM charger_income_diff
        WHERE data_status = 1
        AND pl_no IN
        <foreach collection="plNos" item="plNo" separator="," open="(" close=")" index="index">
            #{plNo}
        </foreach>
        <if test="chargerCode != null">
            AND charger_code = #{chargerCode}
        </if>
        <if test="berthRangeNos != null and berthRangeNos.size() >0">
            AND berth_range_no In
            <foreach collection="berthRangeNos" item="berthRangeNo" separator="," open="(" close=")" index="index">
                #{berthRangeNo}
            </foreach>

        </if>
        AND static_date BETWEEN #{startDate} AND #{endDate}

        GROUP BY berth_range_no) temp) result


    </select>

</mapper>