InparkLogSMapper.xml 4.9 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.InparkLogSMapper">
<resultMap id="BaseResultMap" type="com.zteits.park.domain.InparkLog">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="in_arm_code" jdbcType="VARCHAR" property="inArmCode" />
    <result column="in_time" jdbcType="TIMESTAMP" property="inTime" />
    <result column="vpl_owner" jdbcType="VARCHAR" property="vplOwner" />
    <result column="park_code" jdbcType="VARCHAR" property="parkCode" />
    <result column="vpl_type" jdbcType="INTEGER" property="vplType" />
    <result column="record_id" jdbcType="VARCHAR" property="recordId" />
    <result column="vpl_number" jdbcType="VARCHAR" property="vplNumber" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="cardno" jdbcType="VARCHAR" property="cardno" />
    <result column="vpl_color" jdbcType="INTEGER" property="vplColor" />
    <result column="vpl_color_spare" jdbcType="INTEGER" property="vplColorSpare" />
    <result column="vpl_number_spare" jdbcType="VARCHAR" property="vplNumberSpare" />
    <result column="from_type" jdbcType="INTEGER" property="fromType" />
    <result column="free_berths" jdbcType="INTEGER" property="freeBerths" />
    <result column="pl_no" jdbcType="VARCHAR" property="plNo" />
    <result column="pl_name" jdbcType="VARCHAR" property="plName" />
  </resultMap>
  
  <!-- 通过给定的停车场和时间段查询空闲车位供统计使用 -->
  <select id="queryBerthsForStatistic" resultMap="BaseResultMap">
    select 
    	id,park_code,free_berths,in_time,pl_no,vpl_number,pl_name
    from inpark_log
    <where>
    	in_time between #{beginTime} and #{endTime}
    </where>
  </select>
  
  <!--查询某个时间段停车场进场车辆数 -->
  <select id="queryParklotInCarCount" resultType="com.zteits.park.domain.InparkLogCountDO">

      SELECT
		a.pl_no    as plNo,
		count(1)   as currentParkCount 
		FROM
			inpark_log a
		WHERE 1=1
		   <if test="beginTime != null">
	          <![CDATA[AND DATE_FORMAT(a.in_time, '%Y-%m-%d %H:00:00') >=#{beginTime} ]]>
	      </if>
	      <if test="endTime != null">
	         <![CDATA[  AND DATE_FORMAT(a.in_time, '%Y-%m-%d %H:00:00') <=#{endTime} ]]>
	      </if>
	       and a.pl_no IN 
	      <foreach collection="plNos" open="(" close=")" separator="," item="plNo">
	         #{plNo}
	      </foreach>
		GROUP BY a.pl_no

  </select>
  
   <!--查询某个时间段车辆的进场时间和停车场 -->
  <select id="queryParklotInCarTime" resultType="com.zteits.park.domain.InparkLogVplNumberDO">
      SELECT a.vpl_number as vplNumber,
        a.in_time         as inTime,
        a.pl_no           as plNo
		FROM 
		inpark_log a 
		WHERE  a.vpl_number != ''
		   <if test="beginTime != null">
		          <![CDATA[  AND a.in_time >=#{beginTime} ]]>
		   </if>
	      <if test="endTime != null">
	         <![CDATA[  AND a.in_time <=#{endTime} ]]>
	      </if>
	       <if test="vplNumber != null and vplNumber != ''">
	          and  a.vpl_number like  CONCAT(substring(#{vplNumber},1,1),'%',substring(#{vplNumber},2),'%')
	      </if>
	      
	       and a.pl_no IN 
	      <foreach collection="plNos" open="(" close=")" separator="," item="plNo">
	         #{plNo}
	      </foreach>
  </select>
  
  <!--查询某个时间段车辆的车牌号对应的最大记录 -->
  <select id="queryMaxNum" resultType="java.lang.Integer">
      SELECT 
      MAX(t.num) AS num 
		  FROM
		    (SELECT 
		      a.vpl_number AS vplNumber,
		      COUNT(*) AS num 
		    FROM
		  inpark_log a ,parking_lot b 
		  WHERE a.pl_no=b.pl_no  and a.vpl_number != ""
		     <if test="beginTime != null">
		          <![CDATA[  AND a.in_time >=#{beginTime} ]]>
		       </if>
		       <if test="endTime != null">
		          <![CDATA[  AND a.in_time <=#{endTime} ]]>
		       </if>
		        <if test="vplNumber != null and vplNumber != ''">
		            and  a.vpl_number like  CONCAT(substring(#{vplNumber},1,1),'%',substring(#{vplNumber},2),'%')
		       </if>
		        and a.pl_no IN 
		       <foreach collection="plNos" open="(" close=")" separator="," item="plNo">
		          #{plNo}
		       </foreach>
		  GROUP BY a.vpl_number)t
  </select>
  
  <!--查询某个时间段停车场进场车辆数 -->
  <select id="queryParklotInCar" resultType="com.zteits.park.domain.InparkLogCountDO">

      SELECT
		a.pl_no    as plNo,
		count(1)   as currentParkCount 
		FROM
			inpark_log a
		WHERE 1=1
		   <if test="beginTime != null">
	          <![CDATA[AND a.in_time >=#{beginTime} ]]>
	      </if>
	      <if test="endTime != null">
	         <![CDATA[  AND a.in_time <=#{endTime} ]]>
	      </if>
	       and a.pl_no IN 
	      <foreach collection="plNos" open="(" close=")" separator="," item="plNo">
	         #{plNo}
	      </foreach>
		GROUP BY a.pl_no

  </select>
  
  
  
 
  
</mapper>