Kaynağa Gözat

添加门禁通行记录

liu 2 yıl önce
ebeveyn
işleme
a2c15aecfe

+ 5 - 3
src/main/java/com/template/api/SmartAccessControllerAPI.java

@@ -4,10 +4,12 @@ import com.template.model.result.CommonResult;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 
 @RequestMapping("/api/smartAccess")
 public interface SmartAccessControllerAPI {
-//    @GetMapping("/getPage")
-//    @ApiOperation(value = "门禁通行记录", notes = "门禁通行记录", httpMethod = "GET")
-//    CommonResult getPage();
+
+    @GetMapping("/getPage")
+    @ApiOperation(value = "门禁通行记录", notes = "门禁通行记录", httpMethod = "GET")
+    CommonResult getPage(@RequestParam Integer currentPage, @RequestParam Integer pageCount,String keyWord,Integer gradeId,Integer classId,Integer departmentId,Integer openType,Integer resultStatus,String startTime,String endTime);
 }

+ 14 - 1
src/main/java/com/template/controller/SmartAccessController.java

@@ -3,6 +3,12 @@ package com.template.controller;
 
 import com.template.annotation.DESRespondSecret;
 import com.template.api.SmartAccessControllerAPI;
+import com.template.model.pojo.SmartAccess;
+import com.template.model.result.CommonResult;
+import com.template.model.result.PageUtils;
+import com.template.model.vo.SmartAccessVo;
+import com.template.services.SmartAccessService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.web.bind.annotation.RestController;
@@ -19,7 +25,14 @@ import org.springframework.web.bind.annotation.RestController;
 @DESRespondSecret
 public class SmartAccessController implements SmartAccessControllerAPI {
 
+    @Autowired
+    SmartAccessService smartAccessService;
 
-
+    @Override
+    @DESRespondSecret(validated = false)
+    public CommonResult getPage(Integer currentPage, Integer pageCount, String keyWord,Integer gradeId, Integer classId, Integer departmentId, Integer openType, Integer resultStatus,String startTime,String endTime) {
+        PageUtils<SmartAccessVo> pageUtils=smartAccessService.getPage(currentPage,pageCount,keyWord,gradeId,classId,departmentId,openType,resultStatus,startTime,endTime);
+        return CommonResult.ok(pageUtils);
+    }
 }
 

+ 9 - 5
src/main/java/com/template/controller/SmartFaceDiscernController.java

@@ -283,12 +283,16 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
 //            百胜门禁编号
             String idNum = jsonObject.getString("idNum");
             logger.info("idNum = " + idNum);
-            SmartUser smartUser = smartUserService.getBsStudentNo(idNum);
+
             Integer userId = 0;
-            if (ObjectUtils.isNotEmpty(smartUser)) {
-                userId = smartUser.getId();
-            } else {
-                userId = 0;
+            SmartUser smartUser = null;
+            if (ObjectUtils.isNotEmpty(idNum)) {
+                smartUser = smartUserService.getBsStudentNo(idNum);
+                if (ObjectUtils.isNotEmpty(smartUser)) {
+                    userId = smartUser.getId();
+                } else {
+                    userId = 0;
+                }
             }
 
 //                    出入标识: 1-进, 0-出

+ 6 - 0
src/main/java/com/template/mapper/SmartAccessMapper.java

@@ -1,7 +1,12 @@
 package com.template.mapper;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.template.model.pojo.SmartAccess;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.template.model.vo.SmartAccessVo;
+import com.template.model.vo.VisitorPageVo;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 /**
@@ -15,4 +20,5 @@ import org.springframework.stereotype.Repository;
 @Repository
 public interface SmartAccessMapper extends BaseMapper<SmartAccess> {
 
+    IPage<SmartAccessVo> getPage(Page<SmartAccessVo> page,@Param("keyWord") String keyWord,@Param("gradeId") Integer gradeId, @Param("classId") Integer classId,@Param("departmentId") Integer departmentId,@Param("openType") Integer openType,@Param("resultStatus") Integer resultStatus,@Param("startTime")String startTime,@Param("endTime")String endTime);
 }

+ 44 - 0
src/main/java/com/template/model/vo/SmartAccessVo.java

@@ -0,0 +1,44 @@
+package com.template.model.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class SmartAccessVo {
+    private Integer id;
+
+    @ApiModelProperty(value = "名字")
+    private String name;
+
+    @ApiModelProperty(value = "设备sn号")
+    private String sn;
+
+    @ApiModelProperty(value = "类型")
+    private String type;
+
+    @ApiModelProperty(value = "部门")
+    private String departmentName;
+
+
+    @ApiModelProperty(value = "班级")
+    private String className;
+
+    //    学号
+    private String cardNo;
+
+    @ApiModelProperty(value = "图片")
+    private String image;
+
+    @ApiModelProperty(value = "开门方式:0-白名单比对,1-人证比对,2-IC卡比对")
+    private Integer openType;
+
+    @ApiModelProperty(value = "发生时间")
+    private String dateTime;
+
+    @ApiModelProperty(value = "出入标识: 1-进, 0-出")
+    private Integer access;
+
+    @ApiModelProperty(value = "比对结果:1-成功,0-失败")
+    private Integer resultStatus;
+
+}

+ 4 - 0
src/main/java/com/template/services/SmartAccessService.java

@@ -2,6 +2,8 @@ package com.template.services;
 
 import com.template.model.pojo.SmartAccess;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.template.model.result.PageUtils;
+import com.template.model.vo.SmartAccessVo;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -17,4 +19,6 @@ import java.util.List;
 public interface SmartAccessService extends IService<SmartAccess> {
 
     List<SmartAccess> track(String stateTime, String endTime, Integer id);
+
+    PageUtils<SmartAccessVo> getPage(Integer currentPage, Integer pageCount,String keyWord,Integer gradeId, Integer classId, Integer departmentId, Integer openType, Integer resultStatus,String startTime,String endTime);
 }

+ 18 - 2
src/main/java/com/template/services/impl/SmartAccessServiceImpl.java

@@ -1,11 +1,17 @@
 package com.template.services.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.template.model.pojo.SmartAccess;
 import com.template.mapper.SmartAccessMapper;
 import com.template.model.pojo.SmartFaceDiscern;
+import com.template.model.result.PageUtils;
+import com.template.model.vo.SmartAccessVo;
+import com.template.model.vo.VisitorPageVo;
 import com.template.services.SmartAccessService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -21,15 +27,25 @@ import java.util.List;
 @Service
 public class SmartAccessServiceImpl extends ServiceImpl<SmartAccessMapper, SmartAccess> implements SmartAccessService {
 
+    @Autowired
+    SmartAccessMapper smartAccessMapper;
+
     @Override
     public List<SmartAccess> track(String stateTime, String endTime, Integer id) {
         LambdaQueryWrapper<SmartAccess> wrapper = new LambdaQueryWrapper<>();
         wrapper.between(SmartAccess::getDateTime, stateTime, endTime)
                 .eq(SmartAccess::getUserId, id)
                 .orderByDesc(SmartAccess::getDateTime);
-
         List<SmartAccess> list = this.list(wrapper);
-
         return list;
     }
+
+    @Override
+    public PageUtils<SmartAccessVo> getPage(Integer currentPage, Integer pageCount,String keyWord,Integer gradeId, Integer classId, Integer departmentId, Integer openType, Integer resultStatus,String startTime,String endTime) {
+        Page<SmartAccessVo> page = new Page<>();
+        page.setCurrent(currentPage);
+        page.setSize(pageCount);
+        IPage<SmartAccessVo> datas = smartAccessMapper.getPage(page,keyWord,gradeId,classId,departmentId,openType,resultStatus,startTime,endTime);
+        return new PageUtils(datas);
+    }
 }

+ 45 - 0
src/main/resources/mapper/template/SmartAccessMapper.xml

@@ -2,4 +2,49 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.template.mapper.SmartAccessMapper">
 
+    <select id="getPage" resultType="com.template.model.vo.SmartAccessVo">
+        SELECT
+        sa.id,
+        sa.name,
+        sa.sn,
+        sa.type,
+        sd.`name` as departmentName,
+        sc.`name` as className,
+        su.card_no as cardNo,
+        sa.image,
+        sa.open_type as openType,
+        sa.date_time as dateTime,
+        sa.in_out as access,
+        sa.result_status as resultStatus
+        FROM
+        `smart_access` sa
+        LEFT JOIN smart_user su on sa.user_id=su.id
+        LEFT JOIN smart_department sd on su.department_id=sd.id
+        LEFT JOIN smart_class sc on su.school_class=sc.id
+        LEFT JOIN smart_grade sg on sc.grade_id=sg.id
+        WHERE sa.deleted = 0
+        <if test="keyWord != null and keyWord != ''">
+            and (sa.name like '%' #{keyWord} '%' or su.card_no like '%' #{keyWord} '%')
+        </if>
+        <if test="gradeId != null and gradeId != ''">
+            and sc.grade_id= #{gradeId}
+        </if>
+        <if test="classId != null and classId != ''">
+            and su.school_class= #{classId}
+        </if>
+        <if test="departmentId != null and departmentId != ''">
+            and su.department_id= #{departmentId}
+        </if>
+        <if test="openType != null and openType != ''">
+            and sa.open_type= #{openType}
+        </if>
+        <if test="resultStatus != null and  resultStatus != ''">
+            and sa.result_status= #{resultStatus}
+        </if>
+        <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
+            and sa.date_time &gt;= #{startTime} and sa.date_time &lt;= #{endTime}
+        </if>
+
+        ORDER BY sa.date_time DESC
+    </select>
 </mapper>