Commit 11e920400213bbd19833a9b0dbf168e8ee137a8b

Authored by chenjunyu_1481036421
Committed by xp.Huang
1 parent f7129f32

fix:小程序首页统计信息 客户查询数量不正确


(cherry picked from commit f90cd70fa63b2d96195d57459fad281435d5500c)
... ... @@ -103,20 +103,24 @@
103 103 </select>
104 104
105 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 111 <where>
108 112 1=1
109 113 <if test="queryMap.tenantId !=null">
110   - AND tenant_id= #{queryMap.tenantId}::uuid
  114 + AND m.tenant_id= #{queryMap.tenantId}::uuid
111 115 </if>
112 116 <if test="queryMap.customerId !=null">
113   - AND customer_id= #{queryMap.customerId}::uuid
  117 + AND bd.customer_id= #{queryMap.customerId}::uuid
114 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 121 </if>
118   - <if test="queryMap.endTime !=null">
119   - AND created_time &lt; #{queryMap.endTime}
  122 + <if test="queryMap.endTime !=null and queryMap.customerId ==null">
  123 + AND m.created_time &lt; #{queryMap.endTime}
120 124 </if>
121 125 </where>
122 126 GROUP BY status;
... ...