Sfoglia il codice sorgente

移动端增加对人员关联多个单位查询条件过滤。

zhengqiang 5 anni fa
parent
commit
fb81737541

+ 1 - 1
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonInfoDAO.java

@@ -18,5 +18,5 @@ public interface PersonInfoDAO {
     PersonInfo findByNameAndPhone(String name, String phone);
 	PersonInfo findByOpenId(String openId);
     List<PersonInfo> findByCompanyId(String companyId);
-    long countByCompanyCode(String code,Long companyId);
+    long countByCompanyCode(String code,Long personId);
 }

+ 14 - 9
common/src/main/resources/mapper/base/CompanyInfo.xml

@@ -123,13 +123,15 @@
         select a.*,b.name_ as parent_name
         from base_company_info a
         left join base_company_info b on a.parent_id = b.id_
-        where a.code_ like #{code}
-        and a.del_flag=0
-        <if test="personId!=null">
-        and a.id_ in (
-            select c.id_ from base_person_company c where c.person_id = #{personId}
+        where a.del_flag=0
+        and (
+            a.code_ like #{code}
+            <if test="personId!=null">
+            or a.id_ in (
+                select c.id_ from base_person_company c where c.person_id = #{personId}
+            )
+            </if>
         )
-        </if>
         order by a.id_ asc
     </select>
     <select id="countByParentId" resultType="long">
@@ -147,11 +149,14 @@
     <select id="countByCompanyCode" resultType="long">
         select count(*)
         from base_company_info
-        where code_ like #{code} and del_flag=0
+        where del_flag=0
+        and (
+            code_ like #{code}
         <if test="personId!=null">
-            and a.id_ in (
-                select c.id_ from base_person_company c where c.person_id = #{personId}
+            or id_ in (
+            select c.id_ from base_person_company c where c.person_id = #{personId}
             )
         </if>
+        )
     </select>
 </mapper>

+ 13 - 7
common/src/main/resources/mapper/base/PersonDeviceFilterLog.xml

@@ -221,16 +221,18 @@
         LEFT JOIN base_person_info b on a.person_id=b.id_
         LEFT JOIN base_company_info c on b.company_id=c.id_
             where a.del_flag=false
-            and c.code_ like #{companyCode}
             and a.temperature_ >= #{temperature}
             and a.record_time >= #{startDate}
             and a.record_time < #{endDate}
         ]]>
+        and (
+            c.code_ like #{companyCode}
         <if test="personId!=null">
-            and c.id_ in (
+            or c.id_ in (
                 select d.id_ from base_person_company d where d.person_id = #{personId}
             )
         </if>
+        )
         GROUP BY c.id_,date_format(a.record_time,'%Y-%m-%d')
     </select>
     <select id="lastPersonLog"   resultMap="PersonDeviceFilterLogMap">
@@ -252,15 +254,17 @@
             LEFT JOIN base_person_info b on a.person_id=b.id_
             LEFT JOIN base_company_info c on b.company_id=c.id_
             where a.del_flag=false
-            and c.code_ like #{companyCode}
             and record_time >= #{startDate}
             and record_time <= #{endDate}
         ]]>
+        and (
+        c.code_ like #{companyCode}
         <if test="personId!=null">
-            and c.id_ in (
+            or c.id_ in (
                 select d.id_ from base_person_company d where d.person_id = #{personId}
             )
         </if>
+        )
         <if test="status==-1">
         <![CDATA[
             and a.temperature_>=37
@@ -287,8 +291,7 @@
     <select id="countUndetectedByCompanyCode" resultType="long">
         <![CDATA[
             select count(*) from base_person_info a,base_company_info b
-            where b.code_ like #{companyCode}
-            and a.company_id = b.id_
+            where a.company_id = b.id_
             and b.del_flag=0
             and a.del_flag=0
             and a.id_ not in (
@@ -297,10 +300,13 @@
                 and record_time <= #{endTime}
             )
         ]]>
+        and (
+            b.code_ like #{companyCode}
         <if test="personId!=null">
-            and b.id_ in (
+            or b.id_ in (
                 select d.id_ from base_person_company d where d.person_id = #{personId}
             )
         </if>
+        )
     </select>
 </mapper>

+ 2 - 2
common/src/main/resources/mapper/base/PersonInfo.xml

@@ -256,9 +256,9 @@
         from base_person_info a
         left join base_company_info b on a.company_id = b.id_
         where a.del_flag = 0
-        and b.code_ like #{0}
+        and b.code_ like #{code}
         <if test="personId!=null">
-            and b.id_ in (
+            or b.id_ in (
                 select c.id_ from base_person_company c where c.person_id = #{personId}
             )
         </if>