Browse Source

add:近期进出记录只保留三个月;remove:切面日志去掉

lileilei 2 years ago
parent
commit
0a4bf11ff9

+ 2 - 2
src/main/java/com/yx/face/boot/component/aop/ServiceLog.java

@@ -14,8 +14,8 @@ import org.springframework.stereotype.Component;
  * </p>
  * @description: 使用 aop 切面记录请求日志信息
  */
-@Aspect
-@Component
+//@Aspect
+//@Component
 @Slf4j
 public class ServiceLog {
     /**

+ 23 - 0
src/main/java/com/yx/face/dao/ShortTermFaceLogDao.java

@@ -0,0 +1,23 @@
+package com.yx.face.dao;
+
+import com.yx.face.boot.component.tk.TKMapper;
+import com.yx.face.model.entity.ShortTermFaceLog;
+import com.yx.face.model.vo.FaceLogVO;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @description: 天波人脸设备进出记录表(FaceLog)表数据库访问层 <br>
+ * @author: PWB <br>
+ * @since: 1.0 <br>
+ * @date: 2021-06-04 14:25:46 <br>
+ */
+
+public interface ShortTermFaceLogDao extends TKMapper<ShortTermFaceLog> {
+    List<FaceLogVO> getFaceLogs(Map<String,Object> map);
+
+    /*2022-02-27对face_log查询就行优化 单表查询*/
+    List<FaceLogVO> getFaceLogsNew(Map<String, Object> map);
+}
+

+ 257 - 0
src/main/java/com/yx/face/model/entity/ShortTermFaceLog.java

@@ -0,0 +1,257 @@
+package com.yx.face.model.entity;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.util.Date;
+
+/**
+ * @description: 天波人脸设备进出记录表(FaceLog)实体类 <br>
+ * @author: PWB <br>
+ * @since: 1.0 <br>
+ * @date: 2021-06-04 14:25:46 <br>
+ */
+@Data
+@Table(name = "short_term_face_log")
+public class ShortTermFaceLog {
+
+    /**
+     * 天波人脸记录id
+     */
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+
+    private Long id;
+
+    /**
+     * 记录唯一序号
+     */
+
+
+    private Long recordid;
+
+    /**
+     * 0:离线(即开门提示逻辑由设备离线处理事后上报)
+     * 1:在线(即开门提示逻辑由平台实时控制
+     */
+
+
+    private Integer action;
+
+    /**
+     * 设备SN
+     */
+
+
+    @Column(name = "device_sn")
+    private String deviceSn;
+
+    /**
+     * 用户id
+     */
+
+
+    @Column(name = "user_id")
+    private Long userId;
+
+    /**
+     * 用户姓名
+     */
+
+
+    private String name;
+
+    /**
+     * 手机号码
+     */
+
+
+    private String phone;
+
+    /**
+     * 照片
+     */
+
+
+    private String photo;
+
+    /**
+     * 10进制(当verifytype=2 时,表示身份证号码)
+     */
+
+
+    private String cardid;
+
+    /**
+     * 物理卡号(卡号2)
+     */
+
+
+    @Column(name = "cardIdEx")
+    private String cardidex;
+
+    /**
+     * 0人脸
+     * 1卡
+     * 2 身份证
+     * 3 二维码
+     * 4 远程
+     * 6 IC卡+人脸
+     */
+
+
+    @Column(name = "verify_type")
+    private Integer verifyType;
+
+    /**
+     * 106 (管理员)
+     * 105(操作员)
+     * 104(普通员工 默认)
+     * 103(访客)
+     * 102(禁止)
+     * 101 (黑名单)
+     */
+
+
+    private Integer rightno;
+
+    /**
+     * 考勤时间格式 yyyy-MM-dd HH:mm:ss
+     */
+
+
+    @Column(name = "face_time")
+    private String faceTime;
+
+    /**
+     * 终端上设置的组织id
+     */
+
+
+    private String orgid;
+
+    /**
+     * 0 通用
+     * 1进门
+     * 2出门
+     */
+
+    @Column(name = "out_type")
+    private Integer outType;
+    // * name 姓名
+    @Column(name = "sfz_name")
+    private String sfzName;
+    //sex 性别
+    @Column(name = "sfz_sex")
+    private String sfzSex;
+    //nation民族
+    @Column(name = "sfz_nation")
+    private String sfzNation;
+    //born出生年月
+    @Column(name = "sfz_born")
+    private String sfzBorn;
+    //address地址
+    @Column(name = "sfz_address")
+    private String sfzAddress;
+    //apartment签发机关
+    @Column(name = "sfz_apartment")
+    private String sfzApartment;
+    //period有效期限
+    @Column(name = "sfz_period")
+    private String sfzPeriod;
+    //no身份证号
+    @Column(name = "sfz_no")
+    private String sfzNo;
+    //country国籍
+    @Column(name = "sfz_country")
+    private String sfzCountry;
+    //cn_name中文名
+    @Column(name = "sfz_cn_name")
+    private String sfzCnName;
+    //Idcard_version证件版本
+    @Column(name = "sfz_idcard_version")
+    private String sfzIdcardVersion;
+    //card_type身份证类型
+    @Column(name = "sfz_card_type")
+    private String sfzCardType;
+    //photo 身份证照片
+    @Column(name = "sfz_photo")
+    private String sfzPhoto;
+    /**
+     * 体温测量度数
+     */
+
+
+    private String extend3;
+
+    /**
+     * String类型
+     * 0:未戴
+     * 1:已戴
+     * 2:未启用口罩检测/开启仅检测体温
+     */
+
+
+    private String extend1;
+
+    /**
+     * 人脸相似度分值
+     */
+
+
+    @Column(name = "verify_score")
+    private String verifyScore;
+
+    /**
+     * 体温是否异常 0 正常 1 异常
+     */
+    @Column(name = "tw_status")
+    private String twStatus;
+    /**
+     * 健康码状态00 绿码 01 黄码 10 红码
+     */
+    @Column(name = "jkm_status")
+    private String jkmStatus;
+    /**
+     * .
+     * 健康码状态 0 健康码 1 国康码
+     */
+    @Column(name = "jkm_type")
+    private String jkmType;
+    /**
+     * 阴性 阳性
+     */
+    @Column(name = "hs_status")
+    private String hsStatus;
+    /**
+     * 疫苗状态 0针 等等依次累加
+     */
+    @Column(name = "ym_status")
+    private String ymStatus;
+    /**
+     * 行程信息
+     */
+    @Column(name = "xc_info")
+    private String xcInfo;
+    /**
+     * admin id
+     */
+    @Column(name = "admin_id")
+    private Integer adminId;
+
+    /**
+     * 健康码组装数据
+     */
+    private String extend5;
+
+    /**
+     * 创建时间
+     */
+
+
+    @Column(name = "create_time")
+    private Date createTime;
+
+}
+

+ 3 - 0
src/main/java/com/yx/face/model/search/FaceServerLogSearch.java

@@ -58,4 +58,7 @@ public class FaceServerLogSearch {
 
     @ApiModelProperty(value = "疫苗状态 0针 等等依次累加")
     private String ymStatus;
+
+    @ApiModelProperty(value = "短期通行进出记录标识")
+    private Boolean shortTermFlag = false;
 }

+ 4 - 2
src/main/java/com/yx/face/service/Aspect/FaceLogDaoAspect.java

@@ -42,10 +42,12 @@ public class FaceLogDaoAspect {
             FaceLog ubl = (FaceLog) args[0];
             boolean photo = ubl.getPhoto() != null && !ubl.getPhoto().equals("") && ubl.getPhoto().indexOf("请求失败") == -1 && ubl.getId() != null;
             boolean sfzPhoto = ubl.getSfzPhoto() != null && !ubl.getSfzPhoto().equals("") && ubl.getSfzPhoto().indexOf("请求失败") == -1 && ubl.getId() != null;
-            if (photo && sfzPhoto) {
+            if (photo) {
                 ublf.setFaceLogId(ubl.getId());
                 ublf.setImgBase(Base64Util.getByteArrayFromUrl(ubl.getPhoto()));
-                ublf.setSfzImgBase(Base64Util.getByteArrayFromUrl(ubl.getSfzPhoto()));
+                if(sfzPhoto) {
+                    ublf.setSfzImgBase(Base64Util.getByteArrayFromUrl(ubl.getSfzPhoto()));
+                }
                 faceLogFromDao.insertSelective(ublf);
             }
         }

+ 17 - 2
src/main/java/com/yx/face/service/impl/FaceServiceImpl.java

@@ -2,6 +2,7 @@ package com.yx.face.service.impl;
 
 import cn.hutool.core.codec.Base64;
 import com.alibaba.fastjson.JSONObject;
+import com.beust.jcommander.internal.Lists;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.google.common.collect.Maps;
@@ -67,6 +68,8 @@ public class FaceServiceImpl implements FaceService {
     @Resource
     private FaceLogDao faceLogDao;
     @Resource
+    private ShortTermFaceLogDao shortTermFaceLogDao;
+    @Resource
     private FaceRequestLogDao faceRequestLogDao;
     @Autowired
     private TBDeviceFaceService tbDeviceFaceService;
@@ -274,7 +277,13 @@ public class FaceServiceImpl implements FaceService {
 
         /*3.通过查询回来的id值 插入map中重新查询face_log表 进行单表查询*/
         PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
-        List<FaceLogVO> list = faceLogDao.getFaceLogsNew(map);
+        List<FaceLogVO> list = null;
+        if(data.getShortTermFlag()){
+            list = shortTermFaceLogDao.getFaceLogsNew(map);
+        }else{
+            list = faceLogDao.getFaceLogsNew(map);
+        }
+
         /*4.查询完成之后应当对其中的数据包括进行填入
          *   1.对admin中的数据字段进行填入
          *   2.对face_device中的数据字段进行填入
@@ -390,7 +399,13 @@ public class FaceServiceImpl implements FaceService {
         Map<String, Object> map = new HashMap<>();
         map.put("adminVo", info);
         map.put("query", data);
-        List<FaceLogVO> list = faceLogDao.getFaceLogs(map);
+        List<FaceLogVO> list = null;
+
+        if(data.getShortTermFlag()){
+            list = shortTermFaceLogDao.getFaceLogs(map);
+        }else{
+            list = faceLogDao.getFaceLogs(map);
+        }
 
         List<FaceLogVoExcel> faceLogs = new ArrayList<>();
 

+ 6 - 0
src/main/java/com/yx/face/service/impl/FaceTBServiceImpl.java

@@ -1,5 +1,6 @@
 package com.yx.face.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
@@ -54,6 +55,8 @@ public class FaceTBServiceImpl implements FaceTBService {
     private UserInfoDao userInfoDao;
     @Resource
     private FaceLogDao faceLogDao;
+    @Resource
+    private ShortTermFaceLogDao shortTermFaceLogDao;
     //    @Resource
 //    private SystemConfigDao systemConfigDao;
     @Resource
@@ -679,7 +682,10 @@ public class FaceTBServiceImpl implements FaceTBService {
             faceLog.setVerifyScore(verify_score);
             faceLog.setCreateTime(now);
             if (verifytype == 0 || verifytype == 2) {
+                //长期通行记录
                 faceLogDao.insertSelective(faceLog);
+                //短期通行记录
+                shortTermFaceLogDao.insertSelective(BeanUtil.copyProperties(faceLog, ShortTermFaceLog.class));
                 //预警数据插入
                 userControlEarlyWarningListService.addWarningInformation(faceLog.getDeviceSn(), faceLog.getCardid(), faceLog.getId());
             }

+ 249 - 0
src/main/resources/mapper/ShortTermFaceLogDao.xml

@@ -0,0 +1,249 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.yx.face.dao.ShortTermFaceLogDao">
+    <select id="getFaceLogs" resultType="com.yx.face.model.vo.FaceLogVO">
+        SELECT log.id AS logId,
+        log.recordid AS recordid,
+        log.action AS action,
+        log.device_sn AS deviceSn,
+        fd.name AS deviceName,
+        log.user_id AS userId,
+        replace(log.`name`,' ','') AS name,
+        log.phone AS phone,
+        log.photo AS photo,
+        log.cardid AS cardid,
+        log.cardidex AS cardidex,
+        log.verify_type AS verifyType,
+        log.rightno AS rightno,
+        log.tw_status AS twStatus,
+        log.jkm_status AS jkmStatus,
+        log.hs_status AS hsStatus,
+        log.ym_status AS ymStatus,
+        log.xc_info AS xcInfo,
+        log.extend3 AS extend3,
+        fd.pass AS outType,
+        log.face_time AS faceTime,
+        log.create_time AS createTime
+        FROM short_term_face_log AS log
+        LEFT JOIN face_device fd on log.device_sn = fd.sn
+        left join admin a on a.id =log.admin_id
+        <where>
+            <if test="adminVo.type == 1">
+
+            </if>
+            <if test="adminVo.type == 2">
+                and a.province_id = #{adminVo.provinceId}
+                and a.type =5
+            </if>
+            <if test="adminVo.type == 3">
+                and a.province_id = #{adminVo.provinceId}
+                and a.type =5
+                and a.tag_id = #{adminVo.tagId}
+            </if>
+            <if test="adminVo.type == 4">
+                and a.city_id = #{adminVo.cityId}
+                and a.type = 5
+                and a.tag_id = #{adminVo.tagId}
+            </if>
+            <if test="adminVo.type == 5">
+                and a.id =#{adminVo.adminId}
+            </if>
+
+            <if test="query.username != null and query.username !=''">
+                and a.username = #{query.username}
+            </if>
+            <if test="query.provinceId != null">
+                and a.province_id =#{query.provinceId}
+            </if>
+            <if test="query.cityId != null">
+                and a.city_id =#{query.cityId}
+            </if>
+            <if test="query.areaId != null">
+                and a.area_id =#{query.areaId}
+            </if>
+
+
+            <!-- 体温 -->
+            <if test="query.twStatus != null and query.twStatus !=''">
+                <if test="query.twStatus == '1'.toString()">
+                    and replace(log.tw_status,' ','') = '0'
+                </if>
+                <if test="query.twStatus == '2'.toString()">
+                    and replace(log.tw_status,' ','') = '1'
+                </if>
+                <if test="query.twStatus == '3'.toString()">
+                    and replace(log.tw_status,' ','') = ''
+                </if>
+            </if>
+            <!-- 健康码状态 -->
+            <if test="query.jkmStatus != null and query.jkmStatus !=''">
+                <if test="query.jkmStatus == 1">
+                    and log.jkm_status = '00'
+                </if>
+                <if test="query.jkmStatus == 2">
+                    and log.jkm_status = '01'
+                </if>
+                <if test="query.jkmStatus == 3">
+                    and log.jkm_status = '10'
+                </if>
+                <if test="query.jkmStatus == 4">
+                    and log.jkm_status = ''
+                </if>
+
+            </if>
+            <!-- 核酸 -->
+            <if test="query.hsStatus != null and query.hsStatus !=''">
+                <if test="query.hsStatus == 1">
+                    and log.hs_status LIKE CONCAT('%','阴性','%')
+                </if>
+                <if test="query.hsStatus == 2">
+                    and log.hs_status LIKE CONCAT('%','阳性','%')
+                </if>
+                <if test="query.hsStatus == 3">
+                    and log.hs_status =''
+                </if>
+            </if>
+            <!-- 疫苗状态 -->
+            <if test="query.ymStatus != null and query.ymStatus !=''">
+                and right(log.ym_status,1) = #{query.ymStatus}
+            </if>
+
+
+            <if test="query.name != null and query.name != ''">
+                AND replace(log.`name`,' ','') LIKE CONCAT('%',#{query.name},'%')
+            </if>
+            <if test="query.phone != null and query.phone != ''">
+                AND log.phone = #{query.phone}
+            </if>
+            <if test="query.idNumber != null and query.idNumber != ''">
+                AND log.cardid = #{query.idNumber}
+            </if>
+            <if test="query.deviceSn != null and query.deviceSn.size() > 0">
+                AND log.device_sn in
+                <foreach collection="query.deviceSn" index="index" item="sn" open="(" close=")" separator=",">
+                    #{sn}
+                </foreach>
+            </if>
+            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != '' ">
+                AND  <![CDATA[ log.face_time >= #{query.startTime}]]>
+                AND  <![CDATA[ log.face_time < #{query.endTime}]]>
+            </if>
+            <if test="query.startTime == '' and query.endTime != null and query.endTime != '' ">
+                AND  <![CDATA[ log.face_time <= #{query.endTime}]]>
+            </if>
+
+            <if test="biggerNum != null ">
+                AND log.id > #{biggerNum}
+            </if>
+        </where>
+        ORDER BY log.id DESC
+    </select>
+
+    <select id="getFaceLogsNew" resultType="com.yx.face.model.vo.FaceLogVO">
+        SELECT log.id AS logId,
+        log.recordid AS recordid,
+        log.action AS action,
+        log.device_sn AS deviceSn,
+        log.user_id AS userId,
+        log.`name` AS name,
+        log.phone AS phone,
+        log.photo AS photo,
+        log.cardid AS cardid,
+        log.cardidex AS cardidex,
+        log.verify_type AS verifyType,
+        log.rightno AS rightno,
+        log.tw_status AS twStatus,
+        log.jkm_status AS jkmStatus,
+        log.hs_status AS hsStatus,
+        log.ym_status AS ymStatus,
+        log.xc_info AS xcInfo,
+        log.extend3 AS extend3,
+        log.face_time AS faceTime,
+        log.create_time AS createTime,
+        log.admin_id AS adminId
+        FROM short_term_face_log AS log
+        <where>
+            <!-- 体温 -->
+            <if test="query.twStatus != null and query.twStatus !=''">
+                <if test="query.twStatus == '1'.toString()">
+                    and replace(log.tw_status,' ','') = '0'
+                </if>
+                <if test="query.twStatus == '2'.toString()">
+                    and replace(log.tw_status,' ','') = '1'
+                </if>
+                <if test="query.twStatus == '3'.toString()">
+                    and replace(log.tw_status,' ','') = ''
+                </if>
+            </if>
+            <!-- 健康码状态 -->
+            <if test="query.jkmStatus != null and query.jkmStatus !=''">
+                <if test="query.jkmStatus == 1">
+                    and log.jkm_status = '00'
+                </if>
+                <if test="query.jkmStatus == 2">
+                    and log.jkm_status = '01'
+                </if>
+                <if test="query.jkmStatus == 3">
+                    and log.jkm_status = '10'
+                </if>
+                <if test="query.jkmStatus == 4">
+                    and log.jkm_status = ''
+                </if>
+
+            </if>
+            <!-- 核酸 -->
+            <if test="query.hsStatus != null and query.hsStatus !=''">
+                <if test="query.hsStatus == 1">
+                    and log.hs_status LIKE CONCAT('%','阴性','%')
+                </if>
+                <if test="query.hsStatus == 2">
+                    and log.hs_status LIKE CONCAT('%','阳性','%')
+                </if>
+                <if test="query.hsStatus == 3">
+                    and log.hs_status =''
+                </if>
+            </if>
+            <!-- 疫苗状态 -->
+            <if test="query.ymStatus != null and query.ymStatus !=''">
+                and right(log.ym_status,1) = #{query.ymStatus}
+            </if>
+
+
+            <if test="query.name != null and query.name != ''">
+                AND log.`name` LIKE CONCAT(#{query.name},'%')
+            </if>
+            <if test="query.phone != null and query.phone != ''">
+                AND log.phone = #{query.phone}
+            </if>
+            <if test="query.idNumber != null and query.idNumber != ''">
+                AND log.cardid = #{query.idNumber}
+            </if>
+            <if test="query.deviceSn != null and query.deviceSn.size() >0">
+                AND log.device_sn in
+                <foreach collection="query.deviceSn" item="sn" open="(" close=")" separator=",">
+                    #{sn}
+                </foreach>
+            </if>
+            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != '' ">
+                AND  <![CDATA[ log.face_time >= #{query.startTime}]]>
+                AND  <![CDATA[ log.face_time < #{query.endTime}]]>
+            </if>
+            <if test="query.startTime == '' and query.endTime != null and query.endTime != '' ">
+                AND  <![CDATA[ log.face_time <= #{query.endTime}]]>
+            </if>
+
+            <if test="biggerNum != null ">
+                AND log.id > #{biggerNum}
+            </if>
+            <if test="adminIds !=null and adminIds.size()> 0">
+                and  log.admin_id in
+                <foreach collection="adminIds" index="index" item="adminId" open="(" close=")" separator=",">
+                    #{adminId}
+                </foreach>
+            </if>
+
+        </where>
+        ORDER BY log.id DESC
+    </select>
+</mapper>
+