Browse Source

1.修改进出记录的

wxg 3 năm trước cách đây
mục cha
commit
103736eb89

+ 4 - 0
src/main/java/com/yx/face/dao/AdminDao.java

@@ -31,5 +31,9 @@ public interface AdminDao extends TKMapper<Admin> {
     List<AdminVO> getAdminlist(AdminVO info);
 
     List<AdminVO> getAdminLsit(@Param("type") Integer type);
+
+    List<Long> getAdminListSearch(Map<String, Object> map);
+
+    List<AdminVO> getByAdminlist(List<Long> list);
 }
 

+ 2 - 0
src/main/java/com/yx/face/dao/FaceDeviceDao.java

@@ -52,5 +52,7 @@ public interface FaceDeviceDao extends TKMapper<FaceDevice> {
     List<FaceDevice> selectTypeFaceDev(@Param("type") int type);
 
     Integer updateStatus(@Param("sn") String sn, @Param("type") int type, @Param("adminId") Integer adminId);
+
+    List<FaceDeviceVO> getBySnList(List<String> snList);
 }
 

+ 2 - 1
src/main/java/com/yx/face/dao/FaceLogDao.java

@@ -33,6 +33,7 @@ public interface FaceLogDao extends TKMapper<FaceLog> {
     FaceLogVO getDetails(@Param("id") Integer id);
 
     List<FaceLogVO> getYellow(@Param("adminId")Integer adminId,@Param("faceTime")String faceTime,@Param("jkm")String jkm);
-
+    /*2022-02-27对face_log查询就行优化 单表查询*/
+    List<FaceLogVO> getFaceLogsNew(Map<String, Object> map);
 }
 

+ 6 - 0
src/main/java/com/yx/face/model/vo/FaceLogVO.java

@@ -104,5 +104,11 @@ public class FaceLogVO {
     @ApiModelProperty(value = "创建时间")
 //    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
     private Date createTime;
+
+    @ApiModelProperty(value = "adminId")
+    private Long adminId;
+
+    @ApiModelProperty(value = "账号名称")
+    private String username;
 }
 

+ 5 - 1
src/main/java/com/yx/face/service/AdminService.java

@@ -10,6 +10,7 @@ import com.yx.face.model.update.AdminUpdate;
 import com.yx.face.model.vo.AdminVO;
 
 import java.util.List;
+import java.util.Map;
 
 
 /**
@@ -108,6 +109,9 @@ public interface AdminService {
      * 大屏获取少量的账号信息
      * */
     AdminVO showDataGetInfo();
-
+    /*查询*/
+    List<Long> getAdminListSearch(Map<String, Object> map);
+    /*根据adminIdList查询到所有的adminVO*/
+    List<AdminVO> getByAdminlist(List<Long> list);
 }
 

+ 10 - 0
src/main/java/com/yx/face/service/impl/AdminServiceImpl.java

@@ -479,5 +479,15 @@ public class AdminServiceImpl implements AdminService {
         return showDataGetInfo(Integer.parseInt(token));
     }
 
+    @Override
+    public List<Long> getAdminListSearch(Map<String, Object> map) {
+        return adminDao.getAdminListSearch(map);
+    }
+
+    @Override
+    public List<AdminVO> getByAdminlist(List<Long> list) {
+        return adminDao.getByAdminlist(list);
+    }
+
 }
 

+ 38 - 1
src/main/java/com/yx/face/service/impl/FaceServiceImpl.java

@@ -10,6 +10,7 @@ import com.yx.face.boot.restful.ServiceException;
 import com.yx.face.boot.uitls.*;
 import com.yx.face.dao.*;
 import com.yx.face.model.dto.FaceDeviceDTO;
+import com.yx.face.model.entity.Admin;
 import com.yx.face.model.entity.FaceDevice;
 import com.yx.face.model.entity.FaceDeviceLogo;
 import com.yx.face.model.entity.FaceRequestLog;
@@ -29,6 +30,7 @@ import net.coobird.thumbnailator.Thumbnails;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -39,6 +41,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @description: FaceServiceImpl <br>
@@ -257,9 +260,43 @@ public class FaceServiceImpl implements FaceService {
         map.put("adminVo", info);
         map.put("query", data);
 
+        /*1.获取所有满足条件的adminId*/
+        List<Long> adminIds = adminService.getAdminListSearch(map);
+        map.put("adminIds",adminIds);
+        /*2.获取所有满足条件的设备编号
+        * 注:因为没有设备的相关查询条件所以不需要查询 所有满足条件的设备编号
+        * */
+
+        /*3.通过查询回来的id值 插入map中重新查询face_log表 进行单表查询*/
         PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
-        List<FaceLogVO> list = faceLogDao.getFaceLogs(map);
+        List<FaceLogVO> list = faceLogDao.getFaceLogsNew(map);
+        /*4.查询完成之后应当对其中的数据包括进行填入
+        *   1.对admin中的数据字段进行填入
+        *   2.对face_device中的数据字段进行填入
+        * */
+
+        /*4.1 获取所有adminId并把获取相关的admin*/
+        List<Long> adminList = list.stream().collect(Collectors.groupingBy(FaceLogVO::getAdminId)).keySet().stream().map(key -> key).collect(Collectors.toList());
+        List<AdminVO> adminVOList = adminService.getByAdminlist(adminList);
+        Map<Integer, AdminVO> adminVOMap = adminVOList.stream().collect(Collectors.toMap(AdminVO::getAdminId,AdminVO->AdminVO));
+
+
+        List<String> snList = list.stream().collect(Collectors.groupingBy(FaceLogVO::getDeviceSn)).keySet().stream().map(key -> key).collect(Collectors.toList());
+        List<FaceDeviceVO> faceDeviceVOList = faceDeviceDao.getBySnList(snList);
+        Map<String, FaceDeviceVO> faceDeviceVOMap = faceDeviceVOList.stream().collect(Collectors.toMap(FaceDeviceVO::getSn,FaceDeviceVO->FaceDeviceVO));
+//        PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
+//        List<FaceLogVO> list = faceLogDao.getFaceLogs(map);
         for (FaceLogVO faceLog : list) {
+            AdminVO adminVO = adminVOMap.get(faceLog.getAdminId());
+            if(Objects.nonNull(adminVO)){
+                faceLog.setUsername(adminVO.getUsername());
+            }
+            FaceDeviceVO faceDeviceVO = faceDeviceVOMap.get(faceLog.getDeviceSn());
+            if(Objects.nonNull(faceDeviceVO)){
+                faceLog.setDeviceName(faceDeviceVO.getName());
+                faceLog.setOutType(faceDeviceVO.getPass());
+            }
+
             if(!faceLog.getJkmStatus().equals("01") && !faceLog.getJkmStatus().equals("10")){
                 if (faceLog.getPhone() != null)
                     faceLog.setPhone(SMSOrIdCardUtils.hidePhone(faceLog.getPhone()));

+ 4 - 1
src/main/java/com/yx/face/service/impl/FaceTBServiceImpl.java

@@ -617,8 +617,11 @@ public class FaceTBServiceImpl implements FaceTBService {
             if (StringUtils.hasText(photo)) {
                 photo = buildImage(photo, sn + pin);
             }
+            faceLog = new FaceLog();
             if (verifytype == 0) {
                 userId = Long.valueOf(pin);
+                UserInfo userInfo = userInfoDao.selectByPrimaryKey(userId);
+                if(userInfo != null && userInfo.getPhone() !=null) faceLog.setPhone(userInfo.getPhone());
             } else {
                 userId = 0L;
             }
@@ -633,7 +636,7 @@ public class FaceTBServiceImpl implements FaceTBService {
                     }
                 }
             }
-            faceLog = new FaceLog();
+
             faceLog.setRecordid(Long.valueOf(recordid));
             faceLog.setAction(action);
             faceLog.setDeviceSn(sn);

+ 54 - 0
src/main/resources/mapper/AdminDao.xml

@@ -123,6 +123,60 @@
         FROM admin a
         where a.type = #{type}
     </select>
+    <select id="getAdminListSearch" resultType="java.lang.Long">
+        SELECT
+            id
+        from admin a
+        <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>
+        </where>
+    </select>
+    <select id="getByAdminlist" resultType="com.yx.face.model.vo.AdminVO">
+        select
+        id as adminId,
+        username
+        from admin
+        <where>
+            <if test="list !=null and list.size()>0">
+            and id in
+                <foreach collection="list" index="index" item="adminId" open="(" close=")" separator=",">
+                    #{adminId}
+                </foreach>
+            </if>
+        </where>
+    </select>
 
 </mapper>
 

+ 16 - 0
src/main/resources/mapper/FaceDeviceDao.xml

@@ -215,5 +215,21 @@
         WHERE enable = 1 and  online = 1 and  auth = 1
           AND type = #{type}
     </select>
+    <select id="getBySnList" resultType="com.yx.face.model.vo.FaceDeviceVO">
+        select
+        id as deviceId,
+        sn,
+        name,
+        pass
+        from face_device
+        <where>
+            <if test="list !=null and list.size()>0">
+                and sn in
+                <foreach collection="list" index="index" item="sn" open="(" close=")" separator=",">
+                    #{sn}
+                </foreach>
+            </if>
+        </where>
+    </select>
 </mapper>
 

+ 106 - 3
src/main/resources/mapper/FaceLogDao.xml

@@ -11,7 +11,7 @@
         fd.name AS deviceName,
         log.user_id AS userId,
         replace(log.`name`,' ','') AS name,
-        ui.phone AS phone,
+        log.phone AS phone,
         log.photo AS photo,
         log.cardid AS cardid,
         log.cardidex AS cardidex,
@@ -27,7 +27,6 @@
         log.face_time AS faceTime,
         log.create_time AS createTime
         FROM face_log AS log
-        LEFT JOIN user_info ui on log.user_id = ui.id
         LEFT JOIN face_device fd on log.device_sn = fd.sn
         left join admin a on a.id =log.admin_id
         <where>
@@ -65,6 +64,7 @@
                 and a.area_id =#{query.areaId}
             </if>
 
+
             <!-- 体温 -->
             <if test="query.twStatus != null and query.twStatus !=''">
                 <if test="query.twStatus == '1'.toString()">
@@ -115,7 +115,7 @@
                 AND replace(log.`name`,' ','') LIKE CONCAT('%',#{query.name},'%')
             </if>
             <if test="query.phone != null and query.phone != ''">
-                AND ui.phone = #{query.phone}
+                AND log.phone = #{query.phone}
             </if>
             <if test="query.idNumber != null and query.idNumber != ''">
                 AND log.cardid = #{query.idNumber}
@@ -327,5 +327,108 @@
             left join admin a on a.id =log.admin_id
         where log.id = #{id}
     </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,
+        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,
+        log.face_time AS faceTime,
+        log.create_time AS createTime,
+        log.admin_id AS adminId
+        FROM 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 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 != ''">
+                AND log.device_sn = #{query.deviceSn}
+            </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>