Просмотр исходного кода

Merge remote-tracking branch 'origin/V1' into V1

xiao547607 5 лет назад
Родитель
Сommit
b66906f369

+ 4 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceFilterLogDAO.java

@@ -66,4 +66,8 @@ public interface PersonDeviceFilterLogDAO {
     int deleteExpiredVisitorRecord(@Param("limit") int limit);
 
     List<PersonDeviceFilterLog> getDayCheckedPersonByCompanyList(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("companyInfo") CompanyInfo companyInfo);
+
+    long countDetectedByCompanyIds(List<String> companyIds, Date startTime, Date endTime);
+
+    List<PersonInfo> findUndetectedPersonListByCompanyIds(Map<String, Object> searchParams);
 }

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

@@ -35,4 +35,6 @@ public interface PersonInfoDAO {
 	PersonInfo findById(long id);
 
     long countByCompanyId(String companyId);
+
+    long countByCompanyIds(List<String> companyIds);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceFilterLogService.java

@@ -80,4 +80,9 @@ public interface PersonDeviceFilterLogService {
     int deleteExpiredVisitorRecord(int limit);
 
     List<PersonDeviceFilterLog> getDayCheckedPersonByCompanyList(Date beginTime, Date endTime,CompanyInfo companyInfo);
+
+    long countDetectedByCompanyIds(List<String> companyIds, Date startTime, Date endTime);
+
+
+    Page<PersonInfo> findUndetectedPersonListByCompanyIds(Map<String, Object> searchParams, int pageIndex, int pageSize, boolean b);
 }

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonInfoService.java

@@ -34,4 +34,6 @@ public interface PersonInfoService {
 	PersonInfo findById(long longValue);
 
     long countByCompanyId(String companyId);
+
+    long countByCompanyIds(List<String> companyIds);
 }

+ 14 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceFilterLogServiceImpl.java

@@ -294,4 +294,18 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
     public List<PersonDeviceFilterLog> getDayCheckedPersonByCompanyList(Date beginTime, Date endTime, CompanyInfo companyInfo) {
         return personDeviceFilterLogDAO.getDayCheckedPersonByCompanyList(beginTime,endTime,companyInfo);
     }
+
+    @Override
+    public long countDetectedByCompanyIds(List<String> companyIds, Date startTime, Date endTime) {
+        return personDeviceFilterLogDAO.countDetectedByCompanyIds(companyIds,  startTime, endTime);
+    }
+
+    @Override
+    public Page<PersonInfo> findUndetectedPersonListByCompanyIds(Map<String, Object> searchParams, int pageIndex, int pageSize, boolean count) {
+        Page<PersonInfo> page = PageHelper.startPage(pageIndex,pageSize,count).doSelectPage(()->{
+            personDeviceFilterLogDAO.findUndetectedPersonListByCompanyIds(searchParams);
+        });
+
+        return page;
+    }
 }

+ 5 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonInfoServiceImpl.java

@@ -125,4 +125,9 @@ public class PersonInfoServiceImpl implements PersonInfoService {
 	public long countByCompanyId(String companyId) {
 		return personInfoDAO.countByCompanyId(companyId);
 	}
+
+	@Override
+	public long countByCompanyIds(List<String> companyIds) {
+		return personInfoDAO.countByCompanyIds(companyIds);
+	}
 }

+ 137 - 84
common/src/main/resources/mapper/base/PersonDeviceFilterLog.xml

@@ -20,28 +20,30 @@
     </sql>
     <delete id="deleteExpiredVisitorRecord">
         <![CDATA[
-            delete from base_person_device_filter_log
-            where datediff(now(),record_time)>1
-            and person_id=0
-            order by record_time asc limit ${limit}
+
+                    delete from base_person_device_filter_log
+                    where datediff(now(),record_time)>1
+                    and person_id=0
+                    order by record_time asc limit ${limit}
+
         ]]>
     </delete>
     <resultMap id="PersonDeviceFilterLogMap" type="com.jpsoft.smart.modules.base.entity.PersonDeviceFilterLog">
-        <id property="id" column="id_" />
-        <result property="createBy" column="create_by" />
-        <result property="createTime" column="create_time" />
-        <result property="updateBy" column="update_by" />
-        <result property="updateTime" column="update_time" />
-        <result property="delFlag" column="del_flag" />
-        <result property="deviceNo" column="device_no" />
-        <result property="personId" column="person_id" />
-        <result property="temperature" column="temperature_" />
-        <result property="matchStatus" column="match_status" />
-        <result property="matchMsg" column="match_msg" />
-        <result property="matchFaceId" column="match_face_id" />
-        <result property="faceImage" column="face_image" />
-        <result property="recordTime" column="record_time" />
-        <result property="timeZones" column="time_zones" />
+        <id property="id" column="id_"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="deviceNo" column="device_no"/>
+        <result property="personId" column="person_id"/>
+        <result property="temperature" column="temperature_"/>
+        <result property="matchStatus" column="match_status"/>
+        <result property="matchMsg" column="match_msg"/>
+        <result property="matchFaceId" column="match_face_id"/>
+        <result property="faceImage" column="face_image"/>
+        <result property="recordTime" column="record_time"/>
+        <result property="timeZones" column="time_zones"/>
     </resultMap>
 
     <select id="get" parameterType="long" resultMap="PersonDeviceFilterLogMap">
@@ -184,38 +186,42 @@
                 ]]>
             </if>
         </where>
-        <foreach item="sort" collection="sortList"  open="order by" separator=",">
+        <foreach item="sort" collection="sortList" open="order by" separator=",">
             ${sort.name} ${sort.order}
         </foreach>
     </select>
-    <select id="temperatureNormalStatistics"   resultMap="PersonDeviceFilterLogMap">
+    <select id="temperatureNormalStatistics" resultMap="PersonDeviceFilterLogMap">
         <![CDATA[
-            select count(*) from base_person_device_filter_log a
-            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}
+
+                    select count(*) from base_person_device_filter_log a
+                    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}
+
         ]]>
     </select>
-    <select id="temperatureUnusualStatistics"   resultMap="PersonDeviceFilterLogMap">
+    <select id="temperatureUnusualStatistics" resultMap="PersonDeviceFilterLogMap">
         <![CDATA[
-            select count(*) from base_person_device_filter_log a
-            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}
+
+                    select count(*) from base_person_device_filter_log a
+                    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}
+
         ]]>
     </select>
     <select id="list" resultMap="PersonDeviceFilterLogMap">
         select * from base_person_device_filter_log where del_flag=false
     </select>
-    <select id="unusualStatistics"   resultType="java.util.HashMap">
+    <select id="unusualStatistics" resultType="java.util.HashMap">
         <![CDATA[
         select
         c.id_ as id,
@@ -232,21 +238,21 @@
             and a.record_time < #{endDate}
         ]]>
         and (
-            c.code_ like #{companyCode}
+        c.code_ like #{companyCode}
         <if test="personId!=null">
             or c.id_ in (
-                select d.company_id from base_person_company d where d.person_id = #{personId}
+            select d.company_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">
+    <select id="lastPersonLog" resultMap="PersonDeviceFilterLogMap">
         SELECT * FROM base_person_device_filter_log
         WHERE del_flag = FALSE AND person_id = #{personId}
         ORDER BY record_time desc LIMIT 1
     </select>
-    <select id="getByPersonIdAndDate"   resultMap="PersonDeviceFilterLogMap">
+    <select id="getByPersonIdAndDate" resultMap="PersonDeviceFilterLogMap">
         SELECT * FROM base_person_device_filter_log
         WHERE del_flag=FALSE AND person_id= #{personId}
         <![CDATA[
@@ -267,17 +273,17 @@
         c.code_ like #{companyCode}
         <if test="personId!=null">
             or c.id_ in (
-                select d.company_id from base_person_company d where d.person_id = #{personId}
+            select d.company_id from base_person_company d where d.person_id = #{personId}
             )
         </if>
         )
         <if test="status==1">
-        <![CDATA[
+            <![CDATA[
             and a.temperature_<=#{temperatureMax}
         ]]>
         </if>
         <if test="status==-1">
-        <![CDATA[
+            <![CDATA[
             and a.temperature_>#{temperatureMax}
         ]]>
         </if>
@@ -295,14 +301,15 @@
             )
         ]]>
         and (
-            b.code_ like #{companyCode}
-<!--        <if test="personId!=null">
-            or b.id_ in (
-                select d.company_id from base_person_company d where d.person_id = #{personId}
-            )
-        </if>-->
+        b.code_ like #{companyCode}
+        <!--        <if test="personId!=null">
+                    or b.id_ in (
+                        select d.company_id from base_person_company d where d.person_id = #{personId}
+                    )
+                </if>-->
         <if test="personCompanyList!=null">
-            <foreach collection="personCompanyList" index="index" item="item" open=" or b.id_ in(" separator="," close=")">
+            <foreach collection="personCompanyList" index="index" item="item" open=" or b.id_ in(" separator=","
+                     close=")">
                 #{item.companyId}
             </foreach>
         </if>
@@ -310,10 +317,12 @@
     </select>
     <select id="getDayAbnormalNum" resultType="java.lang.Integer">
         <![CDATA[
-            select count(DISTINCT person_id) from base_person_device_filter_log
-            where record_time >=#{startTime}
-            and record_time <= #{endTime}
-            and temperature_>#{temperatureMax}
+
+                    select count(DISTINCT person_id) from base_person_device_filter_log
+                    where record_time >=#{startTime}
+                    and record_time <= #{endTime}
+                    and temperature_>#{temperatureMax}
+
         ]]>
     </select>
     <select id="getDayAbnormalNumByCompanyList" resultType="Integer">
@@ -323,7 +332,7 @@
         and a.record_time &lt;= #{endTime}
         and a.temperature_>#{temperatureMax}
         and b.company_id in
-        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">   #{item.id}
+        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">#{item.id}
         </foreach>
         and a.del_flag = 0
     </select>
@@ -334,7 +343,7 @@
         where a.record_time >=#{startTime}
         and a.record_time &lt;= #{endTime}
         and b.company_id in
-        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">   #{item.id}
+        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">#{item.id}
         </foreach>
         and a.del_flag = 0
         <if test="popedom!=null">
@@ -353,22 +362,26 @@
     </select>
     <select id="countDayByPersonIdAndDate" resultType="Integer">
         <![CDATA[
-            select count(distinct(DATE_FORMAT(a.record_time,'%y-%m-%d'))) from base_person_device_filter_log a
-            where a.person_id=#{personId}
-            and a.record_time>=#{startDate}
-            and a.record_time<#{endDate}
-            and a.del_flag=0
+
+                    select count(distinct(DATE_FORMAT(a.record_time,'%y-%m-%d'))) from base_person_device_filter_log a
+                    where a.person_id=#{personId}
+                    and a.record_time>=#{startDate}
+                    and a.record_time<#{endDate}
+                    and a.del_flag=0
+
         ]]>
     </select>
     <select id="countDetectedByCompanyId" resultType="int">
         <![CDATA[
-            select count(distinct(a.person_id)) from base_person_device_filter_log a
-            left join base_person_info b on a.person_id = b.id_
-            where b.company_id=#{companyId}
-            and a.record_time>=#{startDate}
-            and a.record_time<#{endDate}
-            and a.del_flag=0
-            and b.del_flag=0
+
+                    select count(distinct(a.person_id)) from base_person_device_filter_log a
+                    left join base_person_info b on a.person_id = b.id_
+                    where b.company_id=#{companyId}
+                    and a.record_time>=#{startDate}
+                    and a.record_time<#{endDate}
+                    and a.del_flag=0
+                    and b.del_flag=0
+
         ]]>
     </select>
     <select id="findUndetectedByCompanyCode"
@@ -387,13 +400,14 @@
         ]]>
         and (
         b.code_ like #{searchParams.companyCode}
-<!--        <if test="personId!=null">
-            or b.id_ in (
-            select d.company_id from base_person_company d where d.person_id = #{personId}
-            )
-        </if>-->
+        <!--        <if test="personId!=null">
+                    or b.id_ in (
+                    select d.company_id from base_person_company d where d.person_id = #{personId}
+                    )
+                </if>-->
         <if test="searchParams.personCompanyList!=null">
-            <foreach collection="searchParams.personCompanyList" index="index" item="item" open=" or b.id_ in(" separator="," close=")">
+            <foreach collection="searchParams.personCompanyList" index="index" item="item" open=" or b.id_ in("
+                     separator="," close=")">
                 #{item.companyId}
             </foreach>
         </if>
@@ -403,15 +417,54 @@
 
     <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}
+            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(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>
+    </select>
 
+    <select id="findUndetectedPersonListByCompanyIds" resultMap="com.jpsoft.smart.modules.base.dao.PersonInfoDAO.PersonInfoMap">
+        <![CDATA[
+        SELECT * from base_person_info where id_ not in (
+            SELECT 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>
+        <![CDATA[
+         GROUP BY a.person_id )
+            and base_person_info.del_flag = 0
         ]]>
+        <foreach collection="companyIds" index="index" item="item" open="and base_person_info.company_id in(" separator="," close=")">
+            #{item}
+        </foreach>
+
+
+
+
 
-        group by a.person_id order by a.record_time desc
     </select>
 </mapper>

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

@@ -350,4 +350,13 @@
     <select id="countByCompanyId" resultType="long">
         select count(*) from base_person_info where company_id=#{0} and del_flag=0
     </select>
+
+    <select id="countByCompanyIds" resultType="long">
+        <![CDATA[
+        select count(*) from base_person_info where  del_flag=0
+        ]]>
+        <foreach collection="list" index="index" item="item" open="and company_id in(" separator="," close=")">
+            #{item}
+        </foreach>
+    </select>
 </mapper>

+ 37 - 4
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonDeviceLogApiController.java

@@ -645,8 +645,28 @@ public class PersonDeviceLogApiController {
             }
 
             List<PersonCompany> personCompanyList = personCompanyService.findByPersonId(personInfo.getId());
+            List<String> companyIds = personCompanyList.stream().map(PersonCompany::getCompanyId).collect(Collectors.toList());
+            List<CompanyInfo> companyInfoList = companyInfoService.findByCompanyCode(companyInfo.getCode(),null);
+            if (companyInfoList.size()>0){
+                for (CompanyInfo companyInfo1:companyInfoList){
+                    if (!companyIds.contains(companyInfo1.getId())){
+                        companyIds.add(companyInfo1.getId());
+                    }
+                }
+            }
+
+
+
+
+            long detectedCount = personDeviceFilterLogService.countDetectedByCompanyIds(companyIds,startTime,endTime);
+            long peronNumCompany = personInfoService.countByCompanyIds(companyIds);
+
+            long undetectedCount = peronNumCompany - detectedCount;
 
-            long undetectedCount = personDeviceFilterLogService.countUndetectedByCompanyCode(companyInfo.getCode() + "%",personCompanyList,startTime,endTime);
+
+
+
+       //     long undetectedCount = personDeviceFilterLogService.countUndetectedByCompanyCode(companyInfo.getCode() + "%",personCompanyList,startTime,endTime);
 
             map.put("companyTotalCount",companyTotalCount);
             map.put("personTotalCount",personTotalCount);
@@ -701,17 +721,30 @@ public class PersonDeviceLogApiController {
             }
 
             Map<String,Object> searchParams = new HashMap<>();
-            searchParams.put("companyCode",companyInfo.getCode() + "%");
+    //        searchParams.put("companyCode",companyInfo.getCode() + "%");
 //            searchParams.put("personId",personInfo.getId());
 
             List<PersonCompany> personCompanyList = personCompanyService.findByPersonId(personInfo.getId());
 
-            searchParams.put("personCompanyList",personCompanyList);
+            List<String> companyIds = personCompanyList.stream().map(PersonCompany::getCompanyId).collect(Collectors.toList());
+            List<CompanyInfo> companyInfoList = companyInfoService.findByCompanyCode(companyInfo.getCode(),null);
+            if (companyInfoList.size()>0){
+                for (CompanyInfo companyInfo1:companyInfoList){
+                    if (!companyIds.contains(companyInfo1.getId())){
+                        companyIds.add(companyInfo1.getId());
+                    }
+                }
+            }
+
+
 
+        //    searchParams.put("personCompanyList",personCompanyList);
             searchParams.put("startTime",startTime);
             searchParams.put("endTime",endTime);
+            searchParams.put("companyIds",companyIds);
 
-            Page<PersonInfo> page = personDeviceFilterLogService.findUndetectedPersonList(searchParams,pageIndex,pageSize,true);
+       //     Page<PersonInfo> page = personDeviceFilterLogService.findUndetectedPersonList(searchParams,pageIndex,pageSize,true);
+            Page<PersonInfo> page = personDeviceFilterLogService.findUndetectedPersonListByCompanyIds(searchParams,pageIndex,pageSize,true);
 
             msgResult.setResult(true);
             msgResult.setData(PojoUtils.pageWrapper(page));