Browse Source

优化未检测人员列表数据

fllmoyu 5 năm trước cách đây
mục cha
commit
11c4d7be9b

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

@@ -68,4 +68,6 @@ public interface PersonDeviceFilterLogDAO {
     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);
 }

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

@@ -82,4 +82,7 @@ public interface PersonDeviceFilterLogService {
     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);
 }

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

@@ -299,4 +299,13 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
     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;
+    }
 }

+ 27 - 0
common/src/main/resources/mapper/base/PersonDeviceFilterLog.xml

@@ -448,5 +448,32 @@
         group by person_id ) m
 
 
+    </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>
+
+
+
+
+
     </select>
 </mapper>

+ 16 - 3
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonDeviceLogApiController.java

@@ -721,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));