GarOrderMapper.xml
16 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<?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.trash.garbage.mapper.GarOrderMapper">
<resultMap id="BaseResultMap" type="com.trash.garbage.pojo.domain.GarOrder">
<id property="garOrderId" column="gar_order_id" jdbcType="VARCHAR"/>
<result property="garOrderUserId" column="gar_order_user_id" jdbcType="VARCHAR"/>
<result property="garOrderAddress" column="gar_order_address" jdbcType="VARCHAR"/>
<result property="garTimeOutFlag" column="gar_time_out_flag" jdbcType="TINYINT"/>
<result property="garOrderAddressDetails" column="gar_order_address_details" jdbcType="VARCHAR"/>
<result property="garOrderContactName" column="gar_order_contact_name" jdbcType="VARCHAR"/>
<result property="garOrderTrashType" column="gar_order_trash_type" jdbcType="VARCHAR"/>
<result property="garOrderContactTel" column="gar_order_contact_tel" jdbcType="VARCHAR"/>
<result property="garOrderCompanyId" column="gar_order_company_id" jdbcType="VARCHAR"/>
<result property="garOrderCompanyUserId" column="gar_order_company_user_id" jdbcType="VARCHAR"/>
<result property="garOrderCompanyName" column="gar_order_company_name" jdbcType="VARCHAR"/>
<result property="garOrderCompanyTel" column="gar_order_company_tel" jdbcType="VARCHAR"/>
<result property="garOrderHandlerStatus" column="gar_order_handler_status" jdbcType="INTEGER"/>
<result property="garOrderAgreementTime" column="gar_order_agreement_time" jdbcType="VARCHAR"/>
<result property="garCreateTime" column="gar_create_time" jdbcType="TIMESTAMP"/>
<result property="garUpdateTime" column="gar_update_time" jdbcType="TIMESTAMP"/>
<result property="garCreateBy" column="gar_create_by" jdbcType="VARCHAR"/>
<result property="garUpdateBy" column="gar_update_by" jdbcType="VARCHAR"/>
<result property="garRemark" column="gar_remark" jdbcType="VARCHAR"/>
<result property="garReason" column="gar_reason" jdbcType="VARCHAR"/>
<result property="garCancelFlag" column="gar_cancel_flag" jdbcType="TINYINT"/>
<result property="garEvaluateFlag" column="gar_evaluate_flag" jdbcType="TINYINT"/>
<result property="garHandlerEvaluateFlag" column="gar_handler_evaluate_flag" jdbcType="TINYINT"/>
<result property="garOrderScanHandlerFlag" column="gar_order_scan_handler_flag" jdbcType="TINYINT"/>
<result property="garLatitude" column="gar_latitude" jdbcType="DOUBLE"/>
<result property="garLongitude" column="gar_longitude" jdbcType="DOUBLE"/>
<result property="garCoordinate" column="gar_coordinate" jdbcType="DOUBLE"/>
<result property="garRealCarCount" column="gar_real_car_count" jdbcType="INTEGER"/>
</resultMap>
<resultMap id="TransportDetailVo" type="com.trash.garbage.pojo.vo.OrderDetailTransportVo">
<id property="garOrderId" column="gar_order_id" jdbcType="VARCHAR"/>
<result property="garOrderAddress" column="gar_order_address" jdbcType="VARCHAR"/>
<result property="garOrderAddressDetails" column="gar_order_address_details" jdbcType="VARCHAR"/>
<result property="garOrderTrashType" column="gar_order_trash_type" jdbcType="VARCHAR"/>
<result property="garOrderContactTel" column="gar_order_contact_tel" jdbcType="VARCHAR"/>
<result property="garOrderCompanyId" column="gar_order_company_id" jdbcType="VARCHAR"/>
<result property="garOrderCompanyName" column="gar_order_company_name" jdbcType="VARCHAR"/>
<result property="garOrderDisposalStatus" column="gar_order_disposal_status" jdbcType="INTEGER"/>
<result property="garOrderCompanyTel" column="gar_order_company_tel" jdbcType="VARCHAR"/>
<result property="garRemark" column="gar_remark" jdbcType="VARCHAR"/>
<result property="garLatitude" column="gar_latitude" jdbcType="DOUBLE"/>
<result property="garLongitude" column="gar_longitude" jdbcType="DOUBLE"/>
<result property="garCoordinate" column="gar_coordinate" jdbcType="DOUBLE"/>
<result property="garRealCarCount" column="gar_real_car_count" jdbcType="INTEGER"/>
<collection property="transportDetails"
ofType="com.trash.garbage.pojo.vo.OrderDetailTransportVo$TransportDetail">
<result property="garHandlerCarCode" column="gar_handler_car_code"/>
<result property="garOrderContainerVolume" column="gar_order_container_volume"/>
<result property="fillImage" column="fill_image"/>
<result property="garCarryingWeight" column="gar_carrying_weight" jdbcType="DOUBLE"/>
<result property="garAskId" column="gar_ask_id"/>
</collection>
</resultMap>
<sql id="Base_Column_List">
gar_order_id
,gar_order_user_id,
gar_order_address,gar_order_address_details,gar_order_contact_name,
gar_order_trash_type,gar_order_contact_tel,gar_order_company_id,
gar_order_company_name,gar_order_company_tel,gar_order_handler_status,
gar_order_agreement_time,gar_create_time,gar_update_time,gar_time_out_flag,
gar_create_by,gar_update_by,gar_remark,gar_reason,gar_cancel_flag,
gar_evaluate_flag,gar_handler_evaluate_flag,gar_order_scan_handler_flag,gar_coordinate,gar_longitude,gar_latitude,gar_real_car_count
</sql>
<update id="updateTimeOutOrderStatus">
update gar_order set gar_order_handler_status = #{status},gar_time_out_flag = #{timeOutFlag}
where gar_order_id in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item.garOrderId}
</foreach>
</update>
<select id="queryCleanNumberByEnterpriseIds" resultType="com.trash.garbage.pojo.domain.GarOrder">
select gar_order_company_id, count(gar_order_company_id) as count
from gar_order
where gar_order_handler_status = #{status}
<if test="list == null or list.size() == 0">
and 1 = 0
</if>
<if test="list != null and list.size() > 0">
and gar_order_company_id in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
group by gar_order_company_id
</select>
<select id="queryDriverOrderListByTelWithType" resultType="com.trash.garbage.pojo.vo.GarOrderDriverVo">
SELECT
`order`.gar_order_id ,`order`.gar_order_user_id,`order`.gar_coordinate,
`order`.gar_order_address,`order`.gar_order_address_details,`order`.gar_order_contact_name,`order`.gar_longitude,
`order`.gar_order_trash_type,`order`.gar_order_contact_tel,`order`.gar_order_company_id,`order`.gar_latitude,
`order`.gar_order_company_name,`order`.gar_order_company_tel,`order`.gar_order_scan_handler_flag,
`order`.gar_order_agreement_time,`order`.gar_remark,`order`.gar_handler_evaluate_flag,
-- `order`.gar_order_handler_status gar_order_status,
`handler`.gar_order_handler_status,`handler`.gar_cancel_flag,`handler`.gar_reason,`order`.gar_real_car_count
FROM gar_order `order`
INNER JOIN gar_order_match_handler `handler` ON `order`.gar_order_id = `handler`.gar_order_id
<where>
`handler`.gar_order_handler_tel = #{garUserTel}
<if test="type != null">
AND `handler`.gar_order_handler_status = #{type}
</if>
<if test="cancelFlag != null">
AND `handler`.gar_cancel_flag = #{cancelFlag}
</if>
</where>
order by `order`.gar_order_agreement_time desc
</select>
<select id="queryOrderByTelWithType" resultType="com.trash.garbage.pojo.vo.GarOrderDriverVo">
SELECT
`order`.gar_order_id ,`order`.gar_order_user_id,`order`.gar_latitude,
`order`.gar_order_address,`order`.gar_order_address_details,`order`.gar_order_contact_name,`order`.gar_longitude,
`order`.gar_order_trash_type,`order`.gar_order_contact_tel,`order`.gar_order_company_id,`order`.gar_coordinate,
`order`.gar_order_company_name,`order`.gar_order_company_tel,`order`.gar_order_scan_handler_flag,`order`.gar_real_car_count,`order`.need_follow_car,
`order`.gar_order_agreement_time,`order`.gar_remark,`order`.gar_handler_evaluate_flag,
`handler`.gar_order_handler_status,`handler`.gar_cancel_flag,`handler`.gar_reason,`handler`.gar_handler_car_code
FROM gar_order `order`
INNER JOIN gar_order_match_handler `handler` ON `order`.gar_order_id = `handler`.gar_order_id AND
`order`.gar_order_id = #{orderId}
<where>
`handler`.gar_order_handler_tel = #{garUserTel}
<if test="cancelFlag != null">
AND `handler`.gar_cancel_flag = #{cancelFlag}
</if>
</where>
</select>
<select id="queryDisposalOrderListByTelWithType" resultType="com.trash.garbage.pojo.vo.GarOrderDisposalVo">
SELECT
`order`.gar_order_id,
`order`.gar_order_user_id,
`order`.gar_coordinate,
`order`.gar_order_address,
`order`.gar_order_address_details,
`order`.gar_order_contact_name,
`order`.gar_longitude,
`order`.gar_order_trash_type,
`order`.gar_order_contact_tel,
`order`.gar_order_company_id,
`order`.gar_order_company_user_id,
`order`.gar_latitude,
`order`.gar_order_company_name,
`order`.gar_order_company_tel,
`order`.gar_order_agreement_time,
`disposal`.gar_create_time,
`disposal`.gar_order_disposal_status,
`order`.gar_real_car_count,
(
CASE
`order`.gar_order_id
WHEN `order`.gar_order_id THEN
( SELECT count(*) FROM gar_order_match_ask ask INNER JOIN gar_order ON `gar_order`.gar_order_id =
`ask`.gar_order_id WHERE `order`.gar_order_id = `gar_order`.gar_order_id and ask.gar_order_handler_id is not null)
END
) AS gar_now_car_count
FROM
gar_order `order`
INNER JOIN gar_order_match_disposal `disposal` ON `order`.gar_order_id = `disposal`.gar_order_id
<where>
`disposal`.gar_order_disposal_tel = #{garUserTel}
<if test="type != null">
AND `disposal`.gar_order_disposal_status = #{type}
</if>
</where>
order by `disposal`.gar_create_time desc
</select>
<select id="queryDriverDetailByTelWithOrderId" resultType="com.trash.garbage.pojo.vo.ScanDriverDetailVo">
SELECT
`order`.gar_order_id ,`order`.gar_order_user_id,`order`.gar_latitude,`order`.gar_order_company_user_id,
`order`.gar_order_address,`order`.gar_order_address_details,`order`.gar_order_contact_name,`order`.gar_longitude,
`order`.gar_order_trash_type,`order`.gar_order_contact_tel,`order`.gar_order_company_id,`order`.gar_coordinate,
`order`.gar_order_company_name,`order`.gar_order_company_tel,`handler`.gar_create_time,
`order`.gar_order_handler_status
gar_order_status,`handler`.gar_handler_car_code,`handler`.gar_order_handler_name,
`handler`.gar_handler_car_code,
`handler`.gar_order_handler_tel,
`handler`.gar_order_handler_id,
`handler`.gar_order_container_volume
FROM gar_order `order`
INNER JOIN gar_order_match_handler `handler` ON `order`.gar_order_id = `handler`.gar_order_id AND
`order`.gar_order_id = #{orderId}
<where>
`handler`.gar_order_handler_id = #{userId}
</where>
</select>
<select id="queryOrderTransportDetail" resultMap="TransportDetailVo">
SELECT `order`.gar_order_id,
`order`.gar_order_user_id,
`order`.gar_coordinate,
`order`.gar_order_address,
`order`.gar_order_address_details,
`order`.gar_order_contact_name,
`order`.gar_longitude,
`order`.gar_order_trash_type,
`order`.gar_order_contact_tel,
`order`.gar_order_company_id,
`order`.gar_order_company_user_id,
`order`.gar_latitude,
`order`.gar_order_company_name,
`order`.gar_order_company_tel,
`order`.gar_order_agreement_time,
`disposal`.gar_create_time,
`disposal`.gar_order_disposal_status,
`order`.gar_real_car_count,
`ask`.gar_id gar_ask_id,
`ask`.gar_carrying_weight,
`ask`.gar_handler_car_code,
`ask`.gar_order_handler_id
FROM gar_order `order`
LEFT JOIN gar_order_match_disposal `disposal` ON `order`.gar_order_id = `disposal`.gar_order_id
LEFT JOIN gar_order_match_ask `ask` ON `ask`.gar_order_id = `order`.gar_order_id
WHERE `order`.gar_order_id = #{orderId}
</select>
<select id="queryUnprocessedOrder" resultType="com.trash.garbage.pojo.domain.GarOrder">
select *
from gar_order
where gar_order.gar_order_handler_status = #{orderType}
and gar_order.gar_time_out_flag = #{timeOutFlag}
and gar_order.gar_cancel_flag = #{cancelFlag}
</select>
<select id="queryDriverOrderListByTelWithTypeCount" resultType="java.lang.Integer">
SELECT
count(*)
FROM gar_order `order`
INNER JOIN gar_order_match_handler `handler` ON `order`.gar_order_id = `handler`.gar_order_id
<where>
`handler`.gar_order_handler_tel = #{garUserTel}
<if test="type != null">
AND `handler`.gar_order_handler_status = #{type}
</if>
<if test="cancelFlag != null">
AND `handler`.gar_cancel_flag = #{cancelFlag}
</if>
</where>
order by `order`.gar_order_agreement_time desc
</select>
<select id="queryDisposalOrderListByTelWithTypeCount" resultType="java.lang.Integer">
SELECT
count(*)
FROM
gar_order `order`
INNER JOIN gar_order_match_disposal `disposal` ON `order`.gar_order_id = `disposal`.gar_order_id
<where>
`disposal`.gar_order_disposal_tel = #{garUserTel}
<if test="type != null">
AND `disposal`.gar_order_disposal_status = #{type}
</if>
</where>
order by `disposal`.gar_create_time desc
</select>
<select id="queryCompanyIdByPhone" parameterType="java.lang.String" resultType="java.lang.String">
select company_id from driver d where phoneNo=#{phone}
</select>
<select id="queryReportByCarCode" resultType="com.trash.garbage.pojo.domain.DockingQRCodeEntity">
select go2.gar_order_address garOrderAddress ,go2.gar_order_address_details garOrderAddressDetails ,go2.gar_order_agreement_time garOrderAgreementTime,
gu.gar_user_name garUserName,gu.gar_user_tel garUserTel,goc.container_volume containerVolume
,gomd.gar_order_disposal_company_id garOrderDisposalCompanyId
from gar_order go2
left join gar_user gu on gu.gar_user_id =go2.gar_order_user_id
left join gar_order_car goc on goc.gar_order_id =go2.gar_order_id
left join gar_order_match_disposal gomd on gomd.gar_order_id=go2.gar_order_id
left join gar_order_match_handler gomh on gomh.gar_order_id =go2.gar_order_id
where gomh.gar_handler_car_code=#{carCode}
AND gomh.gar_cancel_flag = 0
and (go2.gar_create_time <![CDATA[ >= ]]>#{dateStr} or go2.gar_order_handler_status in(0,1))
order by go2.gar_create_time desc
</select>
<select id="queryGarRealCarCountByGarOrderId" resultType="java.lang.Integer">
select gar_real_car_count from gar_order where gar_order_id=#{garOrderId}
</select>
<update id="updateGarRealCarCount">
update gar_order
set gar_real_car_count = gar_real_car_count + #{garRealCarCount}
where gar_order_id = #{garOrderId}
</update>
<select id="queryGarNowCarCount">
SELECT count(*) FROM gar_order_match_ask where gar_order_id = #{garOrderId} and transport_distance is not null
</select>
</mapper>