TpPPdaSMapper.xml 8.71 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.TpPPdaSMapper">
    <resultMap id="BaseResultMap" type="com.zteits.park.domain.TpPPda">
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="pl_no" jdbcType="VARCHAR" property="plNo" />
        <result column="pda_no" jdbcType="VARCHAR" property="pdaNo" />
        <result column="pda_name" jdbcType="VARCHAR" property="pdaName" />
        <result column="charger_code" jdbcType="VARCHAR" property="chargerCode" />
        <result column="charger_name" jdbcType="VARCHAR" property="chargerName" />
        <result column="pda_type" jdbcType="CHAR" property="pdaType" />
        <result column="sim_no" jdbcType="VARCHAR" property="simNo" />
        <result column="pda_status" jdbcType="CHAR" property="pdaStatus" />
        <result column="online_flg" jdbcType="CHAR" property="onlineFlg" />
        <result column="remark" jdbcType="VARCHAR" property="remark" />
        <result column="system_type" jdbcType="CHAR" property="systemType" />
        <result column="lat_id" jdbcType="DOUBLE" property="latId" />
        <result column="lon_id" jdbcType="DOUBLE" property="lonId" />
        <result column="software_version" jdbcType="VARCHAR" property="softwareVersion" />
        <result column="carno_registerno" jdbcType="VARCHAR" property="carnoRegisterno" />
        <result column="register_state" jdbcType="INTEGER" property="registerState" />
        <result column="data_state" jdbcType="INTEGER" property="dataState" />
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
        <result column="create_op" jdbcType="BIGINT" property="createOp" />
        <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
        <result column="enable_time" jdbcType="TIMESTAMP" property="enableTime" />
        <result column="disable_time" jdbcType="TIMESTAMP" property="disableTime" />
        <result column="registerno_distribute_time" jdbcType="TIMESTAMP" property="registernoDistributeTime" />
        <result column="registerno_state_time" jdbcType="TIMESTAMP" property="registernoStateTime" />
        <result column="modify_op" jdbcType="BIGINT" property="modifyOp" />
        <result column="latest_used_time" jdbcType="TIMESTAMP" property="latestUsedTime" />
        <result column="org_id" jdbcType="BIGINT" property="orgId" />
        <result column="berth_range_no" jdbcType="VARCHAR" property="berthRangeNo" />
        <result column="berth_range_name" jdbcType="VARCHAR" property="berthRangeName" />
    </resultMap>
    <sql id="Base_Column_List">
        id, pl_no, pda_no, pda_name, charger_code, charger_name,pda_type, sim_no, pda_status, online_flg,
        remark, system_type, lat_id, lon_id, software_version, carno_registerno, register_state,
        data_state, create_time, create_op, modify_time, enable_time, disable_time, registerno_distribute_time,
        registerno_state_time, modify_op, latest_used_time, org_id,berth_range_no, berth_range_name
    </sql>
    <!-- 分页查询 -->
    <select id="queryPdaInfo" parameterType="com.zteits.clouds.api.dto.park.param.TpPPdaPageQueryRequest"
            resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from tp_p_pda
        where data_state = 1
        <if test="plNos != null and plNos.size >0">
            AND pl_no in
            <foreach collection="plNos" index="index" item="plNo" open="(" separator="," close=")">
                #{plNo}
            </foreach>
        </if>
        <if test="pdaNo != null and pdaNo != ''">
            and pda_no = #{pdaNo,jdbcType=VARCHAR}
        </if>
        <if test="pdaType != null and pdaType != ''">
            and pda_type = #{pdaType,jdbcType=CHAR}
        </if>
        <if test="pdaTypes != null and pdaTypes.size >0">
            AND pda_type in
            <foreach collection="pdaTypes" index="index" item="type" open="(" separator="," close=")">
                #{type}
            </foreach>
        </if>
        <if test="pdaStatus != null and pdaStatus != ''">
            and pda_status = #{pdaStatus,jdbcType=CHAR}
        </if>
        <if test="onlineFlg != null and onlineFlg != ''">
            and online_flg = #{onlineFlg,jdbcType=CHAR}
        </if>
        <if test="registerState != null and registerState != ''">
            and register_state = #{registerState}
        </if>
        <if test="orgId != null and orgId != ''">
            and org_id = #{orgId}
        </if>
        ORDER BY create_time DESC
    </select>

    <insert id="insertBatchPda" useGeneratedKeys="true" parameterType="java.util.List">
        <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
            SELECT LAST_INSERT_ID()
        </selectKey>
        insert into tp_p_pda (pl_no, pda_no, pda_name,
        pda_type, sim_no, pda_status,
        remark, data_state, create_time,
        create_op, modify_time, modify_op,
        online_flg)
        values (#{plNo,jdbcType=VARCHAR}, #{pdaNo,jdbcType=VARCHAR}, #{pdaName,jdbcType=VARCHAR},
        #{pdaType,jdbcType=CHAR}, #{simNo,jdbcType=VARCHAR}, #{pdaStatus,jdbcType=CHAR},
        #{remark,jdbcType=VARCHAR}, #{dataState,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
        #{createOp,jdbcType=BIGINT}, #{modifyTime,jdbcType=TIMESTAMP}, #{modifyOp,jdbcType=BIGINT},
        #{onlineFlg,jdbcType=CHAR})
    </insert>

    <sql id="statisticEqpCountWhere">
        WHERE
        eqp.data_state = 1
        <if test="plNos != null and plNos.size >0">
            AND eqp.pl_no in
            <foreach collection="plNos" index="index" item="plNo" open="(" separator="," close=")">
                #{plNo}
            </foreach>
        </if>
        <if test="pdaNo != null and pdaNo != ''">
            and eqp.pda_no = #{pdaNo,jdbcType=VARCHAR}
        </if>
        <if test="pdaType != null and pdaType != ''">
            and eqp.pda_type = #{pdaType,jdbcType=CHAR}
        </if>
        <if test="pdaStatus != null and pdaStatus != ''">
            and eqp.pda_status = #{pdaStatus,jdbcType=CHAR}
        </if>
        <if test="onlineFlg != null and onlineFlg != ''">
            and eqp.online_flg = #{onlineFlg,jdbcType=CHAR}
        </if>
        <if test="registerState != null and registerState != ''">
            and eqp.register_state = #{registerState}
        </if>
        <if test="orgId != null and orgId != ''">
            and eqp.org_id = #{orgId}
        </if>
    </sql>

    <!-- 统计设备数量-根据设备类型分组 -->
    <select id="statisticEqpCountGroupByEqpType" parameterType="com.zteits.clouds.api.dto.park.param.QueryEqpRequest"
            resultType="com.zteits.clouds.api.dto.park.dto.StatisticEqpCountByEqpTypeDTO">
        SELECT
        eqp.pda_type AS eqpType,
        count(1) as allEqpNum,
        sum( CASE WHEN (pda_status='1' and online_flg='0') THEN 1 ELSE 0 END ) AS onlineEqpNum,
        sum( CASE WHEN (pda_status='1' and online_flg='1') THEN 1 ELSE 0 END ) AS offLineEqpNum,
        sum( CASE WHEN (pda_status='0') THEN 1 ELSE 0 END ) AS faultEqpNum
        FROM
        tp_p_pda eqp
        <include refid="statisticEqpCountWhere" />
        GROUP BY eqp.pda_type;
    </select>
    <!-- 统计设备数量-根据停车场编号分组 -->
    <select id="statisticEqpCountGroupByPlNo" parameterType="com.zteits.clouds.api.dto.park.param.QueryEqpRequest"
            resultType="com.zteits.clouds.api.dto.park.dto.StatisticEqpCountByPlNoDTO">
        SELECT
        lot.pl_no as plNo,
        lot.pl_name as plName,
        eqp.pda_type AS eqpType,
        count(1) as allEqpNum,
        sum( CASE WHEN (pda_status='1' and online_flg='0') THEN 1 ELSE 0 END ) AS onlineEqpNum,
        sum( CASE WHEN (pda_status='1' and online_flg='1') THEN 1 ELSE 0 END ) AS offLineEqpNum,
        sum( CASE WHEN (pda_status='0') THEN 1 ELSE 0 END ) AS faultEqpNum
        FROM
        tp_p_pda eqp
        JOIN parking_lot lot ON eqp.pl_no = lot.pl_no and lot.data_status = 1
        <include refid="statisticEqpCountWhere" />
        GROUP BY lot.pl_no,lot.pl_name,eqp.pda_type;
    </select>


    <!-- 根据泊位区间编号和停车场编号查询PDA信息 -->
    <select id="queryPdaInfoByPlNoAndOther" resultMap="BaseResultMap"
            parameterType="com.zteits.clouds.api.dto.pda.param.QueryEqpByPlNoAndOrtherRequest">
        SELECT
        <include refid="Base_Column_List" />
        from tp_p_pda
        where data_state = 1
        <if test="plNo != null and plNo != '' ">
            and pl_no = #{plNo}
        </if>
        <if test="parkAreaCode != null and parkAreaCode != '' ">
            and berth_range_no = #{parkAreaCode}
        </if>
        order by pl_no,berth_range_no
    </select>

</mapper>