Blame view

parking-module-park/src/main/resources/mybatis/smapper/InparkLogSMapper.xml 4.9 KB
9af4a544   王彪总   新项目
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
  <?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>