InOutParkSMapper.xml 2.5 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.InOutParkSMapper">
	<!-- 在场数据 -->
  	<sql id="inParkLotData">
  		SELECT
		i.pl_no AS plNo,
		i.pl_name AS parkName,
		i.vpl_number AS carNumber,
		i.in_out_status AS inOutState,
		i.in_time AS inTime,
		i.record_id AS recordId,
		NULL outTime,
		NULL parkingDuration,
		i.is_fixed_car as isFixedCar
	FROM
		inpark_log i
	WHERE
	 i.in_out_status = 1
	 <if test="beginTime != null">
      	<![CDATA[AND i.in_time >=#{beginTime} ]]>
  	</if>
     <if test="plNos != null">
        	and i.pl_no IN 
	      <foreach collection="plNos" open="(" close=")" separator="," item="plNo">
	         #{plNo}
	      </foreach>
     </if>
	 <if test="isFixedCar != null">
      	<![CDATA[AND i.is_fixed_car in (#{isFixedCar},'-1') ]]>
  	</if>
  	</sql>
  	
  	<!-- 出场数据 -->
  	<sql id="outParkLotData">
		SELECT
		o.pl_no AS plNo,
		o.pl_name AS parkName,
		o.vpl_number AS carNumber,
		NULL  inOutState,
		o.in_time  AS inTime,
		o.record_id AS recordId,
		o.out_time AS outTime,
		o.parking_duration as parkingDuration,
		o.is_fixed_car as isFixedCar
	FROM
		outpark_log o
	WHERE
	1=1
	<if test="beginTime != null">
      	<![CDATA[AND o.in_time >=#{beginTime} ]]>
  	</if>
	 <if test="endTime != null">
         <![CDATA[  AND o.out_time <=#{endTime} ]]>
     </if>
     <if test="plNos != null">
        	and o.pl_no IN 
	      <foreach collection="plNos" open="(" close=")" separator="," item="plNo">
	         #{plNo}
	      </foreach>
     </if>
	 <if test="isFixedCar != null">
      	<![CDATA[AND o.is_fixed_car in (#{isFixedCar},'-1') ]]>
  	</if>
  	</sql>
  	
  	
  <!--查询企业云平台->数据统计->进出场统计 -->
  <select id="queryInOutParkForList" resultType="com.zteits.park.domain.InOutParkDO">
      select t.plNo ,t.parkName,t.carNumber,t.inOutState,t.inTime, t.recordId ,t.outTime,t.parkingDuration,t.isFixedCar 
	      from (
      <choose>
		<when test="inOutStatus == null">
	      <include refid="inParkLotData" />
	      union all
	      <include refid="outParkLotData" />
      	</when>
      	<!-- 在场数据 -->
      	<when test="inOutStatus == 1">
      		<include refid="inParkLotData" />
      	</when>
      	<!-- 离场数据 -->
      	<when test="inOutStatus == 2">
      		<include refid="outParkLotData" />
      	</when>
      </choose>
      )t order by t.inTime desc
  </select>
  
  
  
 
  
</mapper>