Commit 11e920400213bbd19833a9b0dbf168e8ee137a8b
Committed by
xp.Huang
1 parent
f7129f32
fix:小程序首页统计信息 客户查询数量不正确
(cherry picked from commit f90cd70fa63b2d96195d57459fad281435d5500c)
Showing
1 changed file
with
11 additions
and
7 deletions
@@ -103,20 +103,24 @@ | @@ -103,20 +103,24 @@ | ||
103 | </select> | 103 | </select> |
104 | 104 | ||
105 | <select id="countAlarms" resultMap="aggregationMap"> | 105 | <select id="countAlarms" resultMap="aggregationMap"> |
106 | - SELECT status ,COUNT(id) AS value FROM alarm | 106 | + SELECT status , COUNT(m.id) AS value FROM alarm m |
107 | + <if test="queryMap.customerId !=null"> | ||
108 | + LEFT JOIN tk_device d ON m.originator_id = d.tb_device_id::uuid | ||
109 | + LEFT JOIN device bd ON bd.id = d.tb_device_id::uuid | ||
110 | + </if> | ||
107 | <where> | 111 | <where> |
108 | 1=1 | 112 | 1=1 |
109 | <if test="queryMap.tenantId !=null"> | 113 | <if test="queryMap.tenantId !=null"> |
110 | - AND tenant_id= #{queryMap.tenantId}::uuid | 114 | + AND m.tenant_id= #{queryMap.tenantId}::uuid |
111 | </if> | 115 | </if> |
112 | <if test="queryMap.customerId !=null"> | 116 | <if test="queryMap.customerId !=null"> |
113 | - AND customer_id= #{queryMap.customerId}::uuid | 117 | + AND bd.customer_id= #{queryMap.customerId}::uuid |
114 | </if> | 118 | </if> |
115 | - <if test="queryMap.startTime !=null"> | ||
116 | - AND created_time >= #{queryMap.startTime} | 119 | + <if test="queryMap.startTime !=null and queryMap.customerId ==null"> |
120 | + AND m.created_time >= #{queryMap.startTime} | ||
117 | </if> | 121 | </if> |
118 | - <if test="queryMap.endTime !=null"> | ||
119 | - AND created_time < #{queryMap.endTime} | 122 | + <if test="queryMap.endTime !=null and queryMap.customerId ==null"> |
123 | + AND m.created_time < #{queryMap.endTime} | ||
120 | </if> | 124 | </if> |
121 | </where> | 125 | </where> |
122 | GROUP BY status; | 126 | GROUP BY status; |