ParkFreeBerthSMapper.xml 5.99 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.ParkFreeBerthSMapper">
    <resultMap id="BaseResultMap" type="com.zteits.park.domain.ParkFreeBerth">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="pl_id" jdbcType="BIGINT" property="plId"/>
        <result column="pl_name" jdbcType="VARCHAR" property="plName"/>
        <result column="pl_no" jdbcType="VARCHAR" property="plNo"/>
        <result column="free_berth" jdbcType="INTEGER" property="freeBerth"/>
        <result column="data_status" jdbcType="INTEGER" property="dataStatus"/>
        <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
        <result column="type" jdbcType="VARCHAR" property="type"/>
    </resultMap>
    <sql id="Base_Column_List">
    id, pl_id, pl_name, pl_no, free_berth, data_status, modify_time, type
  </sql>

    <!-- 通过区县分组获取空闲车位统计信息 -->
    <select id="StatisticParkFreeBerthsCountByCountry"
            resultType="com.zteits.park.domain.ParkFreeBerthsCountStatisticByCountryDO">
        SELECT
        lot.pl_city_id as plCityId,
        lot.pl_city_name as plCityName,
        lot.pl_country_id as plCountryId,
        lot.pl_country_name as plCountryName,
        sum(free.free_berth) as freeBerthsNum
        FROM
        park_free_berth free
        JOIN parking_lot lot ON free.pl_no= lot.pl_no
        WHERE
        lot.data_status = 1
        and free.data_status =1
        <if test="cityId!=null and cityId!=''">
            AND lot.pl_city_id = #{cityId}
        </if>
        <if test="state!=null">
            AND lot.state = #{state}
        </if>
        group by lot.pl_city_id,lot.pl_city_name,lot.pl_country_id,lot.pl_country_name;
    </select>


    <select id="queryAllFreeBerthNum" resultType="java.lang.Integer">

        SELECT  
        ifnull(sum(case when free_berth is null THEN
		        0
		      else 
		       free_berth
		   end),0) 
		   FROM park_free_berth 
		   where 1=1 
		   and pl_no in
        <foreach collection="plnos" item="plno" index="index" open="(" close=")" separator=",">
            #{plno}
        </foreach>

    </select>

	<select id="getParkingBerthInfo" resultType="com.zteits.park.domain.BerthInfoDO">
		SELECT 
			ifnull(totalBerthNum,0) totalBerthNum,
			ifnull(totalFreeBerthNum,0) totalFreeBerthNum
		FROM
			(select sum(pl_berth_num) totalBerthNum from parking_lot where
				1=1
				<if test="userAreaInfoList != null and userAreaInfoList.size>0">
					or pl_province_id in
			       <foreach collection="userAreaInfoList" item="userAreaInfo" index="index" open="(" close=")" separator=",">
			       		#{userAreaInfo.areaId, jdbcType=VARCHAR}
			       </foreach>
			       or pl_city_id in
			       <foreach collection="userAreaInfoList" item="userAreaInfo" index="index" open="(" close=")" separator=",">
			       		#{userAreaInfo.areaId, jdbcType=VARCHAR}
			       </foreach>
			       or pl_country_id in
			       <foreach collection="userAreaInfoList" item="userAreaInfo" index="index" open="(" close=")" separator=",">
			       		#{userAreaInfo.areaId, jdbcType=VARCHAR}
			       </foreach>
			       or pl_area_block_id in
			       <foreach collection="userAreaInfoList" item="userAreaInfo" index="index" open="(" close=")" separator=",">
			       		#{userAreaInfo.areaId, jdbcType=VARCHAR}
			       </foreach>
			    </if>
		    ) totalBerthNum,
		    (select sum(free_berth) totalFreeBerthNum from park_free_berth 
		    	where pl_id in(select pl_id from parking_lot 
			    		where 
			    		1=1
						<if test="userAreaInfoList != null and userAreaInfoList.size>0">
							or pl_province_id in
					       <foreach collection="userAreaInfoList" item="userAreaInfo" index="index" open="(" close=")" separator=",">
					       		#{userAreaInfo.areaId, jdbcType=VARCHAR}
					       </foreach>
					       or pl_city_id in
					       <foreach collection="userAreaInfoList" item="userAreaInfo" index="index" open="(" close=")" separator=",">
					       		#{userAreaInfo.areaId, jdbcType=VARCHAR}
					       </foreach>
					       or pl_country_id in
					       <foreach collection="userAreaInfoList" item="userAreaInfo" index="index" open="(" close=")" separator=",">
					       		#{userAreaInfo.areaId, jdbcType=VARCHAR}
					       </foreach>
					       or pl_area_block_id in
					       <foreach collection="userAreaInfoList" item="userAreaInfo" index="index" open="(" close=")" separator=",">
					       		#{userAreaInfo.areaId, jdbcType=VARCHAR}
					       </foreach>
					    </if>
			    ))totalFreeBerthNum
	</select>
	
	<select id="getZeroBerthParkinglotList" resultType="com.zteits.park.domain.ZeroBerthParkingLotDO">
		select 
			pl.pl_name parkinglotName,
			g.lon_id longitude,
			g.lat_id latitude
		from parking_lot pl left join parking_lot_geo g on g.pl_id=pl.pl_id and g.geo_type =1 
		where g.pl_no in(select pl_no from park_free_berth where free_berth=0) and g.lon_id is not null and g.lat_id is not null
			<if test="userAreaInfoList != null and userAreaInfoList.size>0">
				and(pl.pl_province_id in
		       <foreach collection="userAreaInfoList" item="userAreaInfo" index="index" open="(" close=")" separator=",">
		       		#{userAreaInfo.areaId, jdbcType=VARCHAR}
		       </foreach>
		       or pl.pl_city_id in
		       <foreach collection="userAreaInfoList" item="userAreaInfo" index="index" open="(" close=")" separator=",">
		       		#{userAreaInfo.areaId, jdbcType=VARCHAR}
		       </foreach>
		       or pl.pl_country_id in
		       <foreach collection="userAreaInfoList" item="userAreaInfo" index="index" open="(" close=")" separator=",">
		       		#{userAreaInfo.areaId, jdbcType=VARCHAR}
		       </foreach>
		       or pl.pl_area_block_id in
		       <foreach collection="userAreaInfoList" item="userAreaInfo" index="index" open="(" close=")" separator=",">
		       		#{userAreaInfo.areaId, jdbcType=VARCHAR}
		       </foreach>
		       )
		    </if>
	
	</select>
</mapper>