浏览代码

优化查询已测温人数。

tomatozq 5 年之前
父节点
当前提交
4d1eb7512a
共有 1 个文件被更改,包括 14 次插入23 次删除
  1. 14 23
      common/src/main/resources/mapper/base/PersonDeviceFilterLog.xml

+ 14 - 23
common/src/main/resources/mapper/base/PersonDeviceFilterLog.xml

@@ -417,37 +417,28 @@
 
     <select id="getDayCheckedPersonByCompanyList" resultMap="PersonDeviceFilterLogMap">
         <![CDATA[
-
-                 select * from base_person_device_filter_log a left join base_person_info b
-                on a.person_id = b.id_
-                where  a.record_time>=#{startDate}
-                and a.record_time<#{endDate}
-                and a.del_flag=0
-                and b.company_id = #{companyInfo.id}
-
-                ]]>
-
-                group by a.person_id order by a.record_time desc
-</select>
-
+            select * from base_person_device_filter_log a left join base_person_info b
+            on a.person_id = b.id_
+            where  a.record_time>=#{startDate}
+            and a.record_time<#{endDate}
+            and a.del_flag=0
+            and b.company_id = #{companyInfo.id}
+        ]]>
+        group by a.person_id order by a.record_time desc
+    </select>
     <select id="countDetectedByCompanyIds" resultType="long">
         <![CDATA[
-        select  count(*) from (
-            SELECT count(*) from base_person_device_filter_log a ,base_person_info b
+            SELECT count(distinct(b.id_)) from base_person_device_filter_log a ,base_person_info b
             where a.person_id = b.id_
             and a.del_flag = 0
             and b.del_flag = 0
             and a.record_time>=#{startTime}
             and a.record_time<=#{endTime}
         ]]>
-
-            <foreach collection="companyIds" index="index" item="item" open="and b.company_id in(" separator=","
-                     close=")">
-                #{item}
-            </foreach>
-        group by person_id ) m
-
-
+        <foreach collection="companyIds" index="index" item="item" open="and b.company_id in(" separator=","
+                 close=")">
+            #{item}
+        </foreach>
     </select>
 
     <select id="findUndetectedPersonListByCompanyIds" resultMap="com.jpsoft.smart.modules.base.dao.PersonInfoDAO.PersonInfoMap">