Browse Source

1.账号查询问题修复
2.进出记录以人脸时间为准
3.大屏密接人群问题修复

wxg 3 years ago
parent
commit
98bc17f3fc

+ 3 - 0
src/main/java/com/yx/face/dao/FaceLogDao.java

@@ -25,5 +25,8 @@ public interface FaceLogDao extends TKMapper<FaceLog> {
     Date getRecent(@Param("userId") Long userId, @Param("sn") String sn);
     Date getRecent(@Param("userId") Long userId, @Param("sn") String sn);
 
 
     List<FaceLogVoExcel> getFaceLogsExcel(@Param("query") QueryUserVo query);
     List<FaceLogVoExcel> getFaceLogsExcel(@Param("query") QueryUserVo query);
+
+    List<FaceLogVO> getYellow(@Param("adminId")Integer adminId,@Param("faceTime")String faceTime,@Param("jkm")String jkm);
+
 }
 }
 
 

+ 88 - 36
src/main/java/com/yx/face/service/impl/AdminDataShowServiceImpl.java

@@ -197,7 +197,6 @@ public class AdminDataShowServiceImpl implements AdminDataShowService {
         }
         }
         map.put("query", data);
         map.put("query", data);
         faceLogs = faceLogDao.getFaceLogs(map);
         faceLogs = faceLogDao.getFaceLogs(map);
-        log.info("【facelogs长度】:{}", faceLogs.size());
 
 
         totalNum+=faceLogs.size();
         totalNum+=faceLogs.size();
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -205,43 +204,49 @@ public class AdminDataShowServiceImpl implements AdminDataShowService {
         Date date = new Date();
         Date date = new Date();
         long parse = 0;
         long parse = 0;
         try {
         try {
-             parse = sdfToday.parse(sdfToday.format(date)).getTime();
+            parse = sdfToday.parse(sdfToday.format(date)).getTime();
         } catch (ParseException e) {
         } catch (ParseException e) {
             e.printStackTrace();
             e.printStackTrace();
         }
         }
 
 
-        LinkedHashSet<Long> red = new LinkedHashSet<>();
+//        LinkedHashSet<Long> red = new LinkedHashSet<>();
-        LinkedHashSet<Long> yellow = new LinkedHashSet<>();
+//        LinkedHashSet<Long> yellow = new LinkedHashSet<>();
 
 
         for (FaceLogVO faceLog : faceLogs) {
         for (FaceLogVO faceLog : faceLogs) {
             if(faceLog.getLogId().intValue() > biggerNum){
             if(faceLog.getLogId().intValue() > biggerNum){
                 biggerNum = faceLog.getLogId().intValue();
                 biggerNum = faceLog.getLogId().intValue();
             }
             }
-            if(faceLog.getCreateTime().getTime()>parse){
+            Long parse1 = null;
+            try {
+                parse1 = sdf.parse(faceLog.getFaceTime()).getTime();
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+            if(parse1>parse){
                 todayNum++;
                 todayNum++;
                 //红马及其接触人数
                 //红马及其接触人数
                 if (faceLog.getJkmStatus().equals("10")) {
                 if (faceLog.getJkmStatus().equals("10")) {
                     redNum++;
                     redNum++;
-                    //获取前后5分钟内的密切接触红马人员
+//                    //获取前后5分钟内的密切接触红马人员
-                    long createTime = faceLog.getCreateTime().getTime();
+//                    long createTime = parse1;
-                    String startTime = sdf.format(new Date(createTime - (5 * 60 * 1000)-(8*60*60*1000)));
+//                    String startTime = sdf.format(new Date(createTime - (5 * 60 * 1000)-(8*60*60*1000)));
-                    String endTime = sdf.format(new Date(createTime + (5 * 60 * 1000)-(8*60*60*1000)));
+//                    String endTime = sdf.format(new Date(createTime + (5 * 60 * 1000)-(8*60*60*1000)));
-                    List<Long> cbs = adminDataShowDao.getCountByTimeAndSn(startTime, endTime, faceLog.getDeviceSn(),faceLog.getLogId());
+//                    List<Long> cbs = adminDataShowDao.getCountByTimeAndSn(startTime, endTime, faceLog.getDeviceSn(),faceLog.getLogId());
-                    for (Long cb : cbs) {
+//                    for (Long cb : cbs) {
-                        red.add(cb);
+//                        red.add(cb);
-                    }
+//                    }
                 }
                 }
                 //黄马及其接触人数
                 //黄马及其接触人数
                 else if (faceLog.getJkmStatus().equals("01")){
                 else if (faceLog.getJkmStatus().equals("01")){
                     yellowNum++;
                     yellowNum++;
-                    //获取前后5分钟内的密切接触黄马人员
+//                    //获取前后5分钟内的密切接触黄马人员
-                    long createTime = faceLog.getCreateTime().getTime();
+//                    long createTime = parse1;
-                    String startTime = sdf.format(new Date(createTime - (5 * 60 * 1000)-(8*60*60*1000)));
+//                    String startTime = sdf.format(new Date(createTime - (5 * 60 * 1000)-(8*60*60*1000)));
-                    String endTime = sdf.format(new Date(createTime + (5 * 60 * 1000)-(8*60*60*1000)));
+//                    String endTime = sdf.format(new Date(createTime + (5 * 60 * 1000)-(8*60*60*1000)));
-                    List<Long> cbs = adminDataShowDao.getCountByTimeAndSn(startTime, endTime, faceLog.getDeviceSn(),faceLog.getLogId());
+//                    List<Long> cbs = adminDataShowDao.getCountByTimeAndSn(startTime, endTime, faceLog.getDeviceSn(),faceLog.getLogId());
-                    for (Long cb : cbs) {
+//                    for (Long cb : cbs) {
-                        yellow.add(cb);
+//                        yellow.add(cb);
-                    }
+//                    }
                 }
                 }
                 else if (faceLog.getJkmStatus().equals("00"))greenNum++;
                 else if (faceLog.getJkmStatus().equals("00"))greenNum++;
                 else {
                 else {
@@ -272,8 +277,10 @@ public class AdminDataShowServiceImpl implements AdminDataShowService {
         adminData.setNotKnowNum(notKnowNum);
         adminData.setNotKnowNum(notKnowNum);
         adminData.setTwExceptionNum(twExceptionNum);
         adminData.setTwExceptionNum(twExceptionNum);
         adminData.setTwNormal(twNormal);
         adminData.setTwNormal(twNormal);
-        adminData.setContactRedNum(contactRedNum+red.size());
+        adminData.setContactRedNum(contactRedNum);
-        adminData.setContactYellowNum(contactYellowNum+yellow.size());
+        adminData.setContactYellowNum(contactYellowNum);
+//        adminData.setContactRedNum(contactRedNum+red.size());
+//        adminData.setContactYellowNum(contactYellowNum+yellow.size());
         adminData.setExceptionNum(exceptionNum);
         adminData.setExceptionNum(exceptionNum);
         adminData.setInoculationNum(inoculationNum);
         adminData.setInoculationNum(inoculationNum);
         adminData.setNoInoculationNum(noInoculationNum);
         adminData.setNoInoculationNum(noInoculationNum);
@@ -281,10 +288,67 @@ public class AdminDataShowServiceImpl implements AdminDataShowService {
         adminData.setEffectiveTime(new Date(date.getTime() + (60 * 1000)));
         adminData.setEffectiveTime(new Date(date.getTime() + (60 * 1000)));
         adminData.setTime(date);
         adminData.setTime(date);
         adminData.setBiggerNum(biggerNum);
         adminData.setBiggerNum(biggerNum);
+
+        /*
+         * 如果红码和黄码人数不为0则需要重新统计密切接触人数
+         * */
+        if(yellowNum != 0){
+            LinkedHashSet<Long> yellowredContact = new LinkedHashSet<>();
+            /*获取黄码*/
+            String zero = getZero();//获取当天的0点;
+            List<FaceLogVO> faceLogVOList = faceLogDao.getYellow(adminId, zero, "01");
+            for (FaceLogVO faceLogVO : faceLogVOList) {
+                Long faceTime=null;
+                try {
+                    faceTime = sdf.parse(faceLogVO.getFaceTime()).getTime();
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
+                String startTime = sdf.format(new Date(faceTime - (5 * 60 * 1000)));
+                String endTime = sdf.format(new Date(faceTime + (5 * 60 * 1000)));
+                List<Long> cbs = adminDataShowDao.getCountByTimeAndSn(startTime, endTime, faceLogVO.getDeviceSn(),faceLogVO.getLogId());
+                for (Long cb : cbs) {
+                    yellowredContact.add(cb);
+                }
+            }
+            adminData.setContactYellowNum(yellowredContact.size());
+        }
+        if(redNum != 0){
+            LinkedHashSet<Long> redContact = new LinkedHashSet<>();
+            /*获取黄码*/
+            String zero = getZero();//获取当天的0点;
+            List<FaceLogVO> faceLogVOList = faceLogDao.getYellow(adminId, zero, "01");
+            for (FaceLogVO faceLogVO : faceLogVOList) {
+                Long faceTime=null;
+                try {
+                    faceTime = sdf.parse(faceLogVO.getFaceTime()).getTime();
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
+                String startTime = sdf.format(new Date(faceTime - (5 * 60 * 1000)));
+                String endTime = sdf.format(new Date(faceTime + (5 * 60 * 1000)));
+                List<Long> cbs = adminDataShowDao.getCountByTimeAndSn(startTime, endTime, faceLogVO.getDeviceSn(),faceLogVO.getLogId());
+                for (Long cb : cbs) {
+                    redContact.add(cb);
+                }
+            }
+            adminData.setContactRedNum(redContact.size());
+        }
+
         //将数据存入redis
         //将数据存入redis
         redisUtil.set(RName + adminId,adminData);
         redisUtil.set(RName + adminId,adminData);
         return adminData;
         return adminData;
     }
     }
+    private String getZero(){
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(new Date());
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        Date zero = calendar.getTime();
+        return sdf.format(zero);
+    }
 
 
     private FaceServerLogSearch getFaceServerLogSearch() {
     private FaceServerLogSearch getFaceServerLogSearch() {
         FaceServerLogSearch data = new FaceServerLogSearch();
         FaceServerLogSearch data = new FaceServerLogSearch();
@@ -301,19 +365,7 @@ public class AdminDataShowServiceImpl implements AdminDataShowService {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         data.setStartTime(sdf.format(zero));
         data.setStartTime(sdf.format(zero));
         data.setEndTime(sdf.format(one));
         data.setEndTime(sdf.format(one));
-//        //时间减去8小时
+
-//        if (StringUtils.isNotBlank(data.getEndTime()) && StringUtils.isNotBlank(data.getStartTime())) {
-//            String startTime = DateUtils.getReduceEightTime(data.getStartTime());
-//            String endTime = DateUtils.getReduceEightTime(data.getEndTime());
-//            data.setStartTime(startTime);
-//            data.setEndTime(endTime);
-//        }
-//        if (StringUtils.isNotBlank(data.getStartTime()) && StringUtils.isBlank(data.getEndTime())) {
-//            String startTime = DateUtils.getReduceEightTime(data.getStartTime());
-//            String endTime = DateUtils.getReduceEightTime(data.getEndTime());
-//            data.setStartTime(startTime);
-//            data.setEndTime(endTime);
-//        }
         return data;
         return data;
     }
     }
 }
 }

+ 4 - 4
src/main/resources/mapper/AdminDao.xml

@@ -38,12 +38,12 @@
                 and a.type in (3 ,4 ,5)
                 and a.type in (3 ,4 ,5)
             </if>
             </if>
             <if test="type == 3">
             <if test="type == 3">
-                and a.city_id = #{adminVo.cityId}
+                and a.province_id = #{adminVo.provinceId}
                 and a.type in (4 ,5)
                 and a.type in (4 ,5)
                 and a.tag_id = #{adminVo.tagId}
                 and a.tag_id = #{adminVo.tagId}
             </if>
             </if>
             <if test="type == 4">
             <if test="type == 4">
-                and a.street_id = #{adminVo.streetId}
+                and a.city_id = #{adminVo.cityId}
                 and a.type = 5
                 and a.type = 5
                 and a.tag_id = #{adminVo.tagId}
                 and a.tag_id = #{adminVo.tagId}
             </if>
             </if>
@@ -101,12 +101,12 @@
                 and a.type in (3 ,4 ,5)
                 and a.type in (3 ,4 ,5)
             </if>
             </if>
             <if test="type == 3">
             <if test="type == 3">
-                and a.city_id = #{cityId}
+                and a.province_id = #{provinceId}
                 and a.type in (4 ,5)
                 and a.type in (4 ,5)
                 and a.tag_id = #{tagId}
                 and a.tag_id = #{tagId}
             </if>
             </if>
             <if test="type == 4">
             <if test="type == 4">
-                and a.street_id = #{streetId}
+                and a.city_id = #{cityId}
                 and a.type = 5
                 and a.type = 5
                 and a.tag_id = #{tagId}
                 and a.tag_id = #{tagId}
             </if>
             </if>

+ 1 - 1
src/main/resources/mapper/AdminDataShowDao.xml

@@ -79,7 +79,7 @@
         select
         select
             id
             id
         from face_log
         from face_log
-        where create_time BETWEEN #{stratTime} and #{endTime} and device_sn = #{sn} and id != #{id}
+        where face_time BETWEEN #{stratTime} and #{endTime} and device_sn = #{sn} and id != #{id}
     </select>
     </select>
 </mapper>
 </mapper>
 
 

+ 11 - 0
src/main/resources/mapper/FaceLogDao.xml

@@ -211,5 +211,16 @@
         </where>
         </where>
         ORDER BY log.id DESC
         ORDER BY log.id DESC
     </select>
     </select>
+    <select id="getYellow" resultType="com.yx.face.model.vo.FaceLogVO">
+        select
+            id as logId,
+            device_sn AS deviceSn,
+            face_time AS faceTime
+        from face_log
+        where
+            face_time > #{faceTime}
+          and jkm_status=#{jkm}
+          and admin_id = #{adminId}
+    </select>
 </mapper>
 </mapper>