Commit 9612b0982619fc8cf224d141e89ca54190e15a34
1 parent
3fc19e59
调整查询语句
Showing
1 changed file
with
62 additions
and
48 deletions
fw-valhalla-dao/src/main/resources/mapper/ClueTaskMapper.xml
... | ... | @@ -9,26 +9,26 @@ |
9 | 9 | SELECT t1.id, |
10 | 10 | if(t1.type=3 , t4.plate_no, t3.plate_no) plate_no, |
11 | 11 | if(t1.type=3 , t4.frame_no, t3.frame_no) frame_no, |
12 | - if(t1.type=3 , t4.mobile, t5.mobile) mobile, | |
13 | - t3.cus_level cus_level, | |
14 | - t2.expires loan_expires, | |
15 | - t1.type type, | |
16 | - t1.follow_user user_id, | |
17 | - t1.follow_user_name follow_user_name, | |
18 | - t1.follow_shop shop_id, | |
19 | - t1.finish_shop finish_shop, | |
20 | - t1.finish_user_name finish_user_name, | |
21 | - t1.create_time start_time, | |
22 | - t3.buy_date buy_date, | |
23 | - t3.insurance_expires insurance_expires, | |
24 | - t3.arrival_time arrival_time, | |
25 | - IFNULL(t1.times, 0) times, | |
26 | - TIMESTAMPDIFF(HOUR, now(), t1.deadline) remaining, | |
27 | - t1.redistribution redistribution, | |
28 | - t1.state state, | |
29 | - t1.close_time close_time, | |
30 | - t1.reason initiative, | |
31 | - t1.group_id group_id | |
12 | + if(t1.type=3 , t4.mobile, t5.mobile) mobile, | |
13 | + t3.cus_level cus_level, | |
14 | + t2.expires loan_expires, | |
15 | + t1.type type, | |
16 | + t1.follow_user user_id, | |
17 | + t1.follow_user_name follow_user_name, | |
18 | + t1.follow_shop shop_id, | |
19 | + t1.finish_shop finish_shop, | |
20 | + t1.finish_user_name finish_user_name, | |
21 | + t1.create_time start_time, | |
22 | + t3.buy_date buy_date, | |
23 | + t3.insurance_expires insurance_expires, | |
24 | + t3.arrival_time arrival_time, | |
25 | + IFNULL(t1.times, 0) times, | |
26 | + TIMESTAMPDIFF(HOUR, now(), t1.deadline) remaining, | |
27 | + t1.redistribution redistribution, | |
28 | + t1.state state, | |
29 | + t1.close_time close_time, | |
30 | + t1.reason initiative, | |
31 | + t1.group_id group_id | |
32 | 32 | FROM clue_task t1 |
33 | 33 | left join follow_clue t6 on t1.clue_id=t6.id |
34 | 34 | left join customer t3 on t6.vin = t3.frame_no and t6.group_id = t3.group_id and t3.yn=1 |
... | ... | @@ -36,7 +36,7 @@ |
36 | 36 | left join accident_pool t4 on t6.biz_id = t4.id |
37 | 37 | left join customer_loan_info t2 on t6.vin = t2.frame_no and t6.group_id = t2.group_id |
38 | 38 | <where> |
39 | - t1.group_id = #{condition.groupId} | |
39 | + t1.group_id = #{condition.groupId} | |
40 | 40 | <if test="condition.userId !=null"> |
41 | 41 | and t1.follow_user = #{condition.userId} |
42 | 42 | </if> |
... | ... | @@ -44,7 +44,8 @@ |
44 | 44 | and t1.follow_user_name like concat('%',#{condition.userName},'%') |
45 | 45 | </if> |
46 | 46 | <if test="condition.plateNo != null and condition.plateNo !='' "> |
47 | - and (t3.plate_no like concat('%', #{condition.plateNo}, '%') or t4.plate_no like concat('%', #{condition.plateNo}, '%')) | |
47 | + and (t3.plate_no like concat('%', #{condition.plateNo}, '%') or t4.plate_no like concat('%', | |
48 | + #{condition.plateNo}, '%')) | |
48 | 49 | </if> |
49 | 50 | <if test="condition.frameNo != null and condition.frameNo !='' "> |
50 | 51 | and t6.vin like concat('%', #{condition.frameNo}, '%') |
... | ... | @@ -54,13 +55,13 @@ |
54 | 55 | </if> |
55 | 56 | |
56 | 57 | <if test="condition.shopIds !=null"> |
57 | - and t1.follow_shop in | |
58 | + and t1.follow_shop in | |
58 | 59 | <foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=","> |
59 | 60 | #{id} |
60 | 61 | </foreach> |
61 | 62 | </if> |
62 | 63 | <if test="condition.state != null"> |
63 | - and t1.state in | |
64 | + and t1.state in | |
64 | 65 | <foreach collection="condition.state" item="id" index="index" open="(" close=")" separator=","> |
65 | 66 | #{id} |
66 | 67 | </foreach> |
... | ... | @@ -75,13 +76,19 @@ |
75 | 76 | and t1.create_time >= #{condition.startTime1} |
76 | 77 | </if> |
77 | 78 | <if test="condition.startTime2 !=null"> |
78 | - and t1.create_time <= #{condition.startTime2} | |
79 | - </if> | |
80 | - <if test="condition.closeTime1 !=null"> | |
81 | - and t1.close_time >= #{condition.closeTime1} | |
82 | - </if> | |
83 | - <if test="condition.closeTime2 !=null"> | |
84 | - and t1.close_time <= #{condition.closeTime2} | |
79 | + and t1.create_time <= #{condition.startTime2} | |
80 | + </if> | |
81 | + <if test="condition.closeTime1 !=null or condition.closeTime2 !=null"> | |
82 | + and ( t1.close_time is null or ( | |
83 | + <trim prefixOverrides="and"> | |
84 | + <if test="condition.closeTime1 !=null"> | |
85 | + and t1.close_time >= #{condition.closeTime1} | |
86 | + </if> | |
87 | + <if test="condition.closeTime2 !=null"> | |
88 | + and t1.close_time <= #{condition.closeTime2} | |
89 | + </if> | |
90 | + </trim> | |
91 | + )) | |
85 | 92 | </if> |
86 | 93 | <if test="condition.redistribution !=null"> |
87 | 94 | and t1.redistribution = #{condition.redistribution} |
... | ... | @@ -112,7 +119,7 @@ |
112 | 119 | left join accident_pool t4 on t6.biz_id = t4.id |
113 | 120 | left join customer_loan_info t2 on t6.vin = t2.frame_no and t6.group_id = t2.group_id |
114 | 121 | <where> |
115 | - t1.group_id = #{condition.groupId} | |
122 | + t1.group_id = #{condition.groupId} | |
116 | 123 | <if test="condition.userId !=null"> |
117 | 124 | and t1.follow_user = #{condition.userId} |
118 | 125 | </if> |
... | ... | @@ -120,7 +127,8 @@ |
120 | 127 | and t1.follow_user_name like concat('%',#{condition.userName},'%') |
121 | 128 | </if> |
122 | 129 | <if test="condition.plateNo != null and condition.plateNo !='' "> |
123 | - and (t3.plate_no like concat('%', #{condition.plateNo}, '%') or t4.plate_no like concat('%', #{condition.plateNo}, '%')) | |
130 | + and (t3.plate_no like concat('%', #{condition.plateNo}, '%') or t4.plate_no like concat('%', | |
131 | + #{condition.plateNo}, '%')) | |
124 | 132 | </if> |
125 | 133 | <if test="condition.frameNo != null and condition.frameNo !='' "> |
126 | 134 | and t6.vin like concat('%', #{condition.frameNo}, '%') |
... | ... | @@ -130,13 +138,13 @@ |
130 | 138 | </if> |
131 | 139 | |
132 | 140 | <if test="condition.shopIds !=null"> |
133 | - and t1.follow_shop in | |
141 | + and t1.follow_shop in | |
134 | 142 | <foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=","> |
135 | 143 | #{id} |
136 | 144 | </foreach> |
137 | 145 | </if> |
138 | 146 | <if test="condition.state != null"> |
139 | - and t1.state in | |
147 | + and t1.state in | |
140 | 148 | <foreach collection="condition.state" item="id" index="index" open="(" close=")" separator=","> |
141 | 149 | #{id} |
142 | 150 | </foreach> |
... | ... | @@ -151,13 +159,19 @@ |
151 | 159 | and t1.create_time >= #{condition.startTime1} |
152 | 160 | </if> |
153 | 161 | <if test="condition.startTime2 !=null"> |
154 | - and t1.create_time <= #{condition.startTime2} | |
155 | - </if> | |
156 | - <if test="condition.closeTime1 !=null"> | |
157 | - and t1.close_time >= #{condition.closeTime1} | |
158 | - </if> | |
159 | - <if test="condition.closeTime2 !=null"> | |
160 | - and t1.close_time <= #{condition.closeTime2} | |
162 | + and t1.create_time <= #{condition.startTime2} | |
163 | + </if> | |
164 | + <if test="condition.closeTime1 !=null or condition.closeTime2 !=null"> | |
165 | + and ( t1.close_time is null or ( | |
166 | + <trim prefixOverrides="and"> | |
167 | + <if test="condition.closeTime1 !=null"> | |
168 | + and t1.close_time >= #{condition.closeTime1} | |
169 | + </if> | |
170 | + <if test="condition.closeTime2 !=null"> | |
171 | + and t1.close_time <= #{condition.closeTime2} | |
172 | + </if> | |
173 | + </trim> | |
174 | + )) | |
161 | 175 | </if> |
162 | 176 | <if test="condition.redistribution !=null"> |
163 | 177 | and t1.redistribution = #{condition.redistribution} |
... | ... | @@ -172,17 +186,16 @@ |
172 | 186 | </select> |
173 | 187 | |
174 | 188 | |
175 | - | |
176 | 189 | <select |
177 | 190 | id="queryBeCompleted" |
178 | 191 | resultType="cn.fw.valhalla.domain.dto.ShouldBeCompletedDTO" |
179 | 192 | parameterType="cn.fw.valhalla.domain.query.BeCompletedQuery" |
180 | 193 | > |
181 | 194 | SELECT |
182 | - t2.vin, | |
183 | - t1.follow_user user_id, | |
184 | - t1.follow_user_name user_name, | |
185 | - t1.follow_shop shop_id | |
195 | + t2.vin, | |
196 | + t1.follow_user user_id, | |
197 | + t1.follow_user_name user_name, | |
198 | + t1.follow_shop shop_id | |
186 | 199 | from clue_task t1 |
187 | 200 | inner join follow_clue t2 on t1.clue_id = t2.id |
188 | 201 | <where> |
... | ... | @@ -196,7 +209,8 @@ |
196 | 209 | <if test="condition.userId !=null"> |
197 | 210 | and t1.follow_user = #{condition.userId} |
198 | 211 | </if> |
199 | - and DATE(t1.close_time) BETWEEN DATE(from_unixtime(#{condition.startTime})) AND DATE(from_unixtime(#{condition.endTime})) | |
212 | + and DATE(t1.close_time) BETWEEN DATE(from_unixtime(#{condition.startTime})) AND | |
213 | + DATE(from_unixtime(#{condition.endTime})) | |
200 | 214 | </where> |
201 | 215 | </select> |
202 | 216 | </mapper> | ... | ... |