TpPPdaSMapper.xml
8.71 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?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>