夏文涛 пре 2 година
родитељ
комит
61fc7854a4

+ 31 - 6
.idea/workspace.xml

@@ -4,11 +4,22 @@
     <option name="autoReloadType" value="SELECTIVE" />
   </component>
   <component name="ChangeListManager">
+<<<<<<< HEAD
     <list default="true" id="995b8ac7-46be-4ba7-be5a-eaf424ddd316" name="Default Changelist" comment="" />
     <list id="09eff92e-84e6-4825-81c9-523c173595c5" name="Changes" comment="" />
     <ignored path="$PROJECT_DIR$/classes/" />
     <ignored path="$PROJECT_DIR$/target/" />
     <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
+=======
+    <list default="true" id="995b8ac7-46be-4ba7-be5a-eaf424ddd316" name="Default Changelist" comment="">
+      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/controller/SmartFaceDiscernController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/controller/SmartFaceDiscernController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/controller/SmartFaceDiscernTestController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/controller/SmartFaceDiscernTestController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/services/impl/SmartFaceDiscernServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/services/impl/SmartFaceDiscernServiceImpl.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/target/mybatis_plus-0.0.1-SNAPSHOT.jar.original" beforeDir="false" afterPath="$PROJECT_DIR$/target/mybatis_plus-0.0.1-SNAPSHOT.jar.original" afterDir="false" />
+    </list>
+    <list id="09eff92e-84e6-4825-81c9-523c173595c5" name="Changes" comment="" />
+>>>>>>> bfc19b94eef7e36cdd12d67e8fec72ad3c89e747
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
     <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -257,6 +268,7 @@
       <recent name="com.template.api" />
     </key>
   </component>
+<<<<<<< HEAD
   <component name="RunDashboard">
     <option name="ruleStates">
       <list>
@@ -296,19 +308,17 @@
         <option name="Make" enabled="true" />
       </method>
     </configuration>
+=======
+  <component name="RunManager">
+>>>>>>> bfc19b94eef7e36cdd12d67e8fec72ad3c89e747
     <configuration name="MybatisPlusApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
+      <option name="ACTIVE_PROFILES" />
       <module name="mybatis_plus" />
       <option name="SPRING_BOOT_MAIN_CLASS" value="com.template.MybatisPlusApplication" />
       <method v="2">
         <option name="Make" enabled="true" />
       </method>
     </configuration>
-    <recent_temporary>
-      <list>
-        <item itemvalue="Application.SmartFaceDiscernTestController" />
-        <item itemvalue="Application.AutoCode" />
-      </list>
-    </recent_temporary>
   </component>
   <component name="SpellCheckerSettings" BundledDictionaries="0" Folders="0" CustomDictionaries="0" Dictionaries="0" CorrectionsLimit="5" DefaultDictionary="application-level" UseSingleDictionary="true" />
   <component name="SshConsoleOptionsProvider">
@@ -483,6 +493,7 @@
         </line-breakpoint>
         <line-breakpoint enabled="true" type="java-line">
           <url>file://$PROJECT_DIR$/src/main/java/com/template/controller/SmartFaceDiscernTestController.java</url>
+<<<<<<< HEAD
           <line>65</line>
           <properties />
           <option name="timeStamp" value="23" />
@@ -492,6 +503,20 @@
           <line>56</line>
           <properties />
           <option name="timeStamp" value="24" />
+=======
+          <line>67</line>
+          <option name="timeStamp" value="35" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" type="java-line">
+          <url>file://$PROJECT_DIR$/src/main/java/com/template/controller/SmartFaceDiscernTestController.java</url>
+          <line>84</line>
+          <option name="timeStamp" value="37" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" type="java-line">
+          <url>file://$PROJECT_DIR$/src/main/java/com/template/services/impl/SmartUploadServiceImpl.java</url>
+          <line>95</line>
+          <option name="timeStamp" value="40" />
+>>>>>>> bfc19b94eef7e36cdd12d67e8fec72ad3c89e747
         </line-breakpoint>
       </breakpoints>
     </breakpoint-manager>

+ 5 - 0
src/main/java/com/template/api/SmartFaceDiscernControllerAPI.java

@@ -3,6 +3,7 @@ package com.template.api;
 import com.template.model.result.CommonResult;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 
@@ -26,6 +27,10 @@ public interface SmartFaceDiscernControllerAPI {
     CommonResult lastSevenDaysTrack(@RequestParam int userId);
 
 
+    @PostMapping("/callBack")
+    @ApiOperation(value = "百胜门禁记录回调",notes = "百胜门禁记录回调",httpMethod = "POST")
+    String callBack(HttpServletRequest request, HttpServletResponse response);
+
 
 
 }

+ 8 - 2
src/main/java/com/template/api/SmartFaceDiscernTestControllerAPI.java

@@ -2,6 +2,7 @@ package com.template.api;
 
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import javax.servlet.http.HttpServletRequest;
@@ -10,8 +11,13 @@ import javax.servlet.http.HttpServletResponse;
 @RequestMapping("/api/smartFaceDiscernTest")
 public interface SmartFaceDiscernTestControllerAPI {
 
-    @GetMapping("/callBack")
-    @ApiOperation(value = "回调",notes = "回调",httpMethod = "GET")
+    @PostMapping("/callBack")
+    @ApiOperation(value = "百胜门禁记录回调",notes = "百胜门禁记录回调",httpMethod = "POST")
     String callBack(HttpServletRequest request, HttpServletResponse response);
 
+    @PostMapping("/heartBeatAlive")
+    @ApiOperation(value = "心跳回调",notes = "心跳回调",httpMethod = "POST")
+    String heartBeatAlive(HttpServletRequest request, HttpServletResponse response);
+
+
 }

+ 190 - 6
src/main/java/com/template/controller/SmartFaceDiscernController.java

@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
@@ -71,7 +72,14 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
     @Autowired
     SmartClassService smartClassService;
 
+    @Autowired
+    SmartUploadService smartUploadService;
+
+    @Autowired
+    SmartNotificationService smartNotificationService;
 
+    @Autowired
+    SmartDeviceService smartDeviceService;
 
     @Override
     @DESRespondSecret(validated = true)
@@ -144,12 +152,12 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
             vos.add(lastSevenDaysTrackVo);
         }
 
-        List<SmartAttendance> attendances=smartAttendanceService.track(startTime,endTime,userId);
+        List<SmartAttendance> attendances = smartAttendanceService.track(startTime, endTime, userId);
 //        获取班级名称
         SmartUser smartUser = smartUserService.getSmartById(userId);
         SmartClass smartClass = smartClassService.getSmartClassById(smartUser.getSchoolClass());
         String className = smartClass.getName();
-        SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" );
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         for (SmartAttendance attendance : attendances) {
             LastSevenDaysTrackVo lastSevenDaysTrackVo = new LastSevenDaysTrackVo();
             lastSevenDaysTrackVo.setName(attendance.getXwUserName());
@@ -169,6 +177,176 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
         return CommonResult.ok(vos);
     }
 
+    @Override
+    @PassToken
+    @DESRespondSecret(validated = false)
+    public String callBack(HttpServletRequest request, HttpServletResponse response) {
+        try {
+            BufferedReader streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
+            StringBuilder responseStrBuilder = new StringBuilder();
+            String inputStr;
+            while ((inputStr = streamReader.readLine()) != null) {
+                responseStrBuilder.append(inputStr);
+            }
+            JSONObject jsonObject = JSONObject.parseObject(responseStrBuilder.toString());
+
+            DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+            //                比对时间
+            String time = jsonObject.getString("time");
+            logger.info("time = " + time);
+            LocalDateTime localDateTime = LocalDateTime.now().withHour(0).withSecond(0).withMinute(0);
+            LocalDateTime localDateTime2 = LocalDateTime.parse(time, dateTimeFormatter1);
+//            只获取当天的
+            if (localDateTime.isBefore(localDateTime2)) {
+//            比对结果
+                Integer resultStatus = jsonObject.getInteger("resultStatus");
+                if (1 == resultStatus) {
+
+                    //          设备sn
+                    String sn = jsonObject.getString("sn");
+                    SmartDevice smartDevice = smartDeviceService.getNum(sn);
+                    String address = "";
+                    String type = "";
+                    if (ObjectUtils.isNotEmpty(smartDevice)) {
+                        //            地点
+                        address = smartDevice.getAddress();
+//            类型
+                        type = smartDevice.getName();
+                    }
+
+//            名字,学生会加班级[]
+                    String name = jsonObject.getString("name");
+                    System.out.println("name = " + name);
+                    String[] split = name.split("\\[");
+                    String s = split[0];
+                    logger.info("name = " + s);
+//            百胜门禁编号
+                    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;
+                    }
+
+
+                    SmartFaceDiscern smartFaceDiscern = new SmartFaceDiscern();
+
+                    smartFaceDiscern.setName(s);
+                    smartFaceDiscern.setLocation(address);
+                    smartFaceDiscern.setType(type);
+                    smartFaceDiscern.setUserId(userId);
+                    smartFaceDiscern.setDateTime(time);
+                    smartFaceDiscern.setIdNum(idNum);
+                    smartFaceDiscern.setSn(sn);
+                    if (userId != 0) {
+                        //                    判断是否已经添加
+                        LambdaQueryWrapper<SmartFaceDiscern> wrapperFD = new LambdaQueryWrapper<>();
+                        wrapperFD.eq(SmartFaceDiscern::getDateTime, smartFaceDiscern.getDateTime())
+                                .eq(SmartFaceDiscern::getUserId, userId);
+                        List<SmartFaceDiscern> list = smartFaceDiscernService.list(wrapperFD);
+                        if (ObjectUtils.isEmpty(list) && list.size() == 0) {
+                            //          抓拍的照片 base64字符串
+                            String scenePhoto = jsonObject.getString("scenePhoto");
+                            scenePhoto = "data:image/jpeg;base64," + scenePhoto;
+                            logger.info("scenePhoto =" + scenePhoto.substring(0, 50));
+//            base64转文件
+                            MultipartFile multipartFile = MultipartFileUtils.base64ToMultipartFile(scenePhoto);
+                            String image="";
+                            try {
+                                //            上传到cos桶,并生成图片地址
+                                 image = smartUploadService.upload(new MultipartFile[]{multipartFile});
+                            }catch (Exception e){
+                                e.printStackTrace();
+                                logger.error("上传cos桶失败");
+                            }
+
+                            smartFaceDiscern.setImage(image);
+                            smartFaceDiscernService.save(smartFaceDiscern);
+
+//                        通过学生id找到关联的家长affiliate,并找到公众号,如果openid为空则不传
+                            List<SmartUser> userList = smartUserService.getAffiliateList(userId);
+                            if (ObjectUtils.isNotEmpty(userList) && userList.size() > 0) {
+
+                                for (SmartUser user : userList) {
+                                    String gzhOpenId = user.getGzhOpenId();
+                                    if (ObjectUtils.isNotEmpty(gzhOpenId)) {
+                                        String pushType = "";
+                                        if (type.contains("进校")) {
+                                            pushType = "进入大门";
+                                        } else if (type.contains("出校")) {
+                                            pushType = "离开大门";
+                                        }
+                                        LocalDateTime date = LocalDateTime.now();
+                                        String format = date.format(dateTimeFormatter1);
+                                        //                    公众号信息推送
+                                        Message2.send(gzhOpenId, pushType, address, format);
+
+                                        SmartNotification smartNotification = new SmartNotification();
+                                        smartNotification.setUserId(smartUser.getId());
+                                        smartNotification.setUserName(smartUser.getName());
+                                        smartNotification.setTypeName(pushType);
+                                        smartNotification.setLocation(address);
+                                        smartNotification.setImage(image);
+                                        smartNotification.setDateTime(time);
+                                        smartNotification.setType(2);
+
+                                        smartNotificationService.save(smartNotification);
+
+                                    }
+
+                                }
+                            }
+                        }
+                    } else {
+
+                        smartFaceDiscern.setUserId(0);
+//                    判断是否已经添加
+                        LambdaQueryWrapper<SmartFaceDiscern> wrapperFD = new LambdaQueryWrapper<>();
+                        wrapperFD.eq(SmartFaceDiscern::getDateTime, time)
+                                .eq(SmartFaceDiscern::getName, s)
+                                .eq(SmartFaceDiscern::getType, type);
+                        List<SmartFaceDiscern> list = smartFaceDiscernService.list(wrapperFD);
+
+                        if (ObjectUtils.isEmpty(list) && list.size() == 0) {
+                            //          抓拍的照片 base64字符串
+                            String scenePhoto = jsonObject.getString("scenePhoto");
+                            scenePhoto = "data:image/jpeg;base64," + scenePhoto;
+                            logger.info("scenePhoto =" + scenePhoto.substring(0, 50));
+//            base64转文件
+                            MultipartFile multipartFile = MultipartFileUtils.base64ToMultipartFile(scenePhoto);
+                            String image="";
+                            try {
+                                //            上传到cos桶,并生成图片地址
+                                image = smartUploadService.upload(new MultipartFile[]{multipartFile});
+                            }catch (Exception e){
+                                e.printStackTrace();
+                                logger.error("上传cos桶失败");
+                            }
+                            smartFaceDiscern.setImage(image);
+                            smartFaceDiscernService.save(smartFaceDiscern);
+                        }
+
+                    }
+                }
+            }
+
+        } catch (
+                Exception e) {
+            e.printStackTrace();
+            JSONObject r = new JSONObject();
+            r.put("message", "Success");
+            r.put("result", 0);
+            return r.toJSONString();
+        }
+
+        JSONObject r = new JSONObject();
+        r.put("message", "Success");
+        r.put("result", 0);
+        return r.toJSONString();
+    }
 
 
     public static JSONObject getDate(Integer date) {
@@ -188,10 +366,16 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
     }
 
     public static void main(String[] args) {
-        LocalDateTime end = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).plusDays(1);
-        System.out.println("end = " + end);
-        LocalDateTime satrt = end.minusDays(7);
-        System.out.println("satrt = " + satrt);
+        LocalDateTime dateTime1 = LocalDateTime.of(2022, 8, 29, 12, 0, 0);
+        LocalDateTime dateTime2 = LocalDateTime.of(2022, 8, 30, 12, 0, 0);
+        LocalDateTime dateTime3 = LocalDateTime.of(2022, 8, 28, 12, 0, 0);
+
+        boolean isBefore = dateTime1.isBefore(dateTime2);
+        boolean isBefore2 = dateTime1.isBefore(dateTime3);
+
+        System.out.println("dateTime1 is before dateTime2: " + isBefore);
+        System.out.println("dateTime1 is before dateTime2: " + isBefore2);
+
     }
 
 }

+ 150 - 52
src/main/java/com/template/controller/SmartFaceDiscernTestController.java

@@ -2,18 +2,15 @@ package com.template.controller;
 
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.template.annotation.DESRespondSecret;
 import com.template.annotation.PassToken;
 import com.template.api.SmartFaceDiscernTestControllerAPI;
+import com.template.common.utils.Message2;
 import com.template.common.utils.MultipartFileUtils;
-import com.template.model.pojo.SmartDevice;
-import com.template.model.pojo.SmartFaceDiscernTest;
-import com.template.model.pojo.SmartUser;
-import com.template.services.SmartDeviceService;
-import com.template.services.SmartFaceDiscernTestService;
-import com.template.services.SmartUploadService;
-import com.template.services.SmartUserService;
+import com.template.model.pojo.*;
+import com.template.services.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 
@@ -24,11 +21,13 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.Date;
-
+import java.util.List;
 /**
  * <p>
- *  前端控制器
+ * 前端控制器
  * </p>
  *
  * @author ceshi
@@ -49,6 +48,9 @@ public class SmartFaceDiscernTestController implements SmartFaceDiscernTestContr
     @Autowired
     SmartUploadService smartUploadService;
 
+    @Autowired
+    SmartNotificationService smartNotificationService;
+
     @Override
     @PassToken
     @DESRespondSecret(validated = false)
@@ -64,59 +66,155 @@ public class SmartFaceDiscernTestController implements SmartFaceDiscernTestContr
 
 //            比对结果
             Integer resultStatus = jsonObject.getInteger("resultStatus");
-            if (0!=resultStatus) {
-                JSONObject r = new JSONObject();
-                r.put("message","Success");
-                r.put("result",0);
-                return r.toJSONString();
-            }
+            if (1 == resultStatus) {
+                //                比对时间
+                String time = jsonObject.getString("time");
+                //          设备sn
+                String sn = jsonObject.getString("sn");
+                SmartDevice smartDevice = smartDeviceService.getNum(sn);
+                String address = "";
+                String type = "";
+                if (ObjectUtils.isNotEmpty(smartDevice)) {
+                    //            地点
+                    address = smartDevice.getAddress();
+//            类型
+                    type = smartDevice.getName();
+                }
+
+//            名字,学生会加班级[]
+                String name = jsonObject.getString("name");
+                System.out.println("name = " + name);
+                String[] split = name.split("\\[");
+                String s = split[0];
+                System.out.println("s = " + s);
+//            百胜门禁编号
+                String idNum = jsonObject.getString("idNum");
+                System.out.println("idNum = " + idNum);
+                SmartUser smartUser = smartUserService.getBsStudentNo(idNum);
+                Integer userId = 0;
+                if (ObjectUtils.isNotEmpty(smartUser)) {
+                    userId = smartUser.getId();
+                } else {
+                    userId = 0;
+                }
+
 //          抓拍的照片 base64字符串
-            String scenePhoto = jsonObject.getString("scenePhoto");
-            System.out.println("scenePhoto = " + scenePhoto.substring(0,100));
+                String scenePhoto = jsonObject.getString("scenePhoto");
+                scenePhoto = "data:image/jpeg;base64," + scenePhoto;
 //            base64转文件
-            MultipartFile multipartFile = MultipartFileUtils.base64ToMultipartFile(scenePhoto);
+                MultipartFile multipartFile = MultipartFileUtils.base64ToMultipartFile(scenePhoto);
 //            上传到cos桶,并生成图片地址
-            String image = smartUploadService.upload(new MultipartFile[]{multipartFile});
-
- //          设备mac
-            String mac = jsonObject.getString("mac");
-            SmartDevice smartDevice = smartDeviceService.getNum(mac);
-            String address="";
-            String type="";
-            if (ObjectUtils.isNotEmpty(smartDevice)) {
-                //            地点
-                address = smartDevice.getAddress();
-//            类型
-                type = smartDevice.getName();
-            }
+                String image = smartUploadService.upload(new MultipartFile[]{multipartFile});
+
+
+                SmartFaceDiscernTest smartFaceDiscernTest = new SmartFaceDiscernTest();
+                smartFaceDiscernTest.setImage(image);
+                smartFaceDiscernTest.setName(s);
+                smartFaceDiscernTest.setLocation(address);
+                smartFaceDiscernTest.setType(type);
+                smartFaceDiscernTest.setUserId(userId);
+                smartFaceDiscernTest.setDateTime(time);
+                smartFaceDiscernTest.setIdNum(idNum);
+                smartFaceDiscernTest.setSn(sn);
+
+
+                if (userId != 0) {
+                    //                    判断是否已经添加
+                    LambdaQueryWrapper<SmartFaceDiscernTest> wrapperFD = new LambdaQueryWrapper<>();
+                    wrapperFD.eq(SmartFaceDiscernTest::getDateTime, time)
+                            .eq(SmartFaceDiscernTest::getUserId, userId);
+                    List<SmartFaceDiscernTest> list = smartFaceDiscernTestService.list(wrapperFD);
+                    if (ObjectUtils.isEmpty(list) && list.size() == 0) {
+                        smartFaceDiscernTestService.save(smartFaceDiscernTest);
+
+//                        通过学生id找到关联的家长affiliate,并找到公众号,如果openid为空则不传
+                        List<SmartUser> userList = smartUserService.getAffiliateList(userId);
+                        if (ObjectUtils.isNotEmpty(userList) && userList.size() > 0) {
+
+                            for (SmartUser user : userList) {
+                                String gzhOpenId = user.getGzhOpenId();
+                                if (ObjectUtils.isNotEmpty(gzhOpenId)) {
+                                    String pushType = "";
+                                    if (type.contains("进校")) {
+                                        pushType = "进入大门";
+                                    } else if (type.contains("出校")) {
+                                        pushType = "离开大门";
+                                    }
+                                    DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                                    LocalDateTime date = LocalDateTime.now();
+                                    String format = date.format(dateTimeFormatter1);
+                                    //                    公众号信息推送
+                                    Message2.send(gzhOpenId, pushType, address,format);
+
+                                    SmartNotification smartNotification = new SmartNotification();
+                                    smartNotification.setUserId(smartUser.getId());
+                                    smartNotification.setUserName(smartUser.getName());
+                                    smartNotification.setTypeName(pushType);
+                                    smartNotification.setLocation(address);
+                                    smartNotification.setImage(image);
+                                    smartNotification.setDateTime(time);
+                                    smartNotification.setType(2);
+
+                                    smartNotificationService.save(smartNotification);
+
+                                }
+
+                            }
+                        }
+                    }
+                }else {
+
+                    smartFaceDiscernTest.setUserId(0);
+
+//                    判断是否已经添加
+                    LambdaQueryWrapper<SmartFaceDiscernTest> wrapperFD = new LambdaQueryWrapper<>();
+                    wrapperFD.eq(SmartFaceDiscernTest::getDateTime, time)
+                            .eq(SmartFaceDiscernTest::getName, s)
+                            .eq(SmartFaceDiscernTest::getType, type);
+                    List<SmartFaceDiscernTest> list = smartFaceDiscernTestService.list(wrapperFD);
+
+                    if (ObjectUtils.isEmpty(list) && list.size() == 0) {
+                        smartFaceDiscernTestService.save(smartFaceDiscernTest);
+                    }
+
+                }
 
-//            名字
-            String name = jsonObject.getString("name");
-//            身份证号
-            String idNum = jsonObject.getString("idNum");
-            SmartUser user = smartUserService.getCard(idNum);
-            Integer userId=0;
-            if (ObjectUtils.isNotEmpty(user)) {
-                userId = user.getId();
-            }else {
-                userId=0;
             }
 
-            SmartFaceDiscernTest smartFaceDiscernTest = new SmartFaceDiscernTest();
-            smartFaceDiscernTest.setImage(image);
-            smartFaceDiscernTest.setName(name);
-            smartFaceDiscernTest.setLocation(address);
-            smartFaceDiscernTest.setType(type);
-            smartFaceDiscernTest.setUserId(userId);
-            smartFaceDiscernTest.setDateTime(new Date());
-            smartFaceDiscernTestService.save(smartFaceDiscernTest);
+        } catch (
+                Exception e) {
+            e.printStackTrace();
+            JSONObject r = new JSONObject();
+            r.put("message", "Success");
+            r.put("result", 0);
+            return r.toJSONString();
+        }
 
-        }catch (Exception e){
+        JSONObject r = new JSONObject();
+        r.put("message", "Success");
+        r.put("result", 0);
+        return r.toJSONString();
+    }
+
+    @Override
+    @PassToken
+    @DESRespondSecret(validated = false)
+    public String heartBeatAlive(HttpServletRequest request, HttpServletResponse response) {
+        try {
+            BufferedReader streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
+            StringBuilder responseStrBuilder = new StringBuilder();
+            String inputStr;
+            while ((inputStr = streamReader.readLine()) != null) {
+                responseStrBuilder.append(inputStr);
+            }
+            JSONObject jsonObject = JSONObject.parseObject(responseStrBuilder.toString());
+            System.out.println("jsonObject = " + jsonObject);
+        } catch (Exception e) {
             e.printStackTrace();
         }
         JSONObject r = new JSONObject();
-        r.put("message","Success");
-        r.put("result",0);
+        r.put("message", "Success");
+        r.put("result", 0);
         return r.toJSONString();
     }
 

+ 6 - 0
src/main/java/com/template/model/pojo/SmartFaceDiscern.java

@@ -50,6 +50,12 @@ public class SmartFaceDiscern implements Serializable {
     @ApiModelProperty(value = "图片")
     private String image;
 
+    @ApiModelProperty(value = "百胜门禁编号")
+    private String idNum;
+
+    @ApiModelProperty(value = "设备sn号")
+    private String sn;
+
     @ApiModelProperty(value = "备注")
     private String remark;
 

+ 7 - 1
src/main/java/com/template/model/pojo/SmartFaceDiscernTest.java

@@ -45,6 +45,12 @@ public class SmartFaceDiscernTest implements Serializable {
     @ApiModelProperty(value = "地点")
     private String location;
 
+    @ApiModelProperty(value = "百胜门禁编号")
+    private String idNum;
+
+    @ApiModelProperty(value = "设备sn号")
+    private String sn;
+
     @ApiModelProperty(value = "图片")
     private String image;
 
@@ -52,7 +58,7 @@ public class SmartFaceDiscernTest implements Serializable {
     private String remark;
 
     @ApiModelProperty(value = "发生时间")
-    private Date dateTime;
+    private String dateTime;
 
     @ApiModelProperty(value = "创建时间")
     @TableField(fill = FieldFill.INSERT)

+ 6 - 0
src/main/java/com/template/services/SmartUserService.java

@@ -121,4 +121,10 @@ public interface SmartUserService extends IService<SmartUser> {
      */
     SmartUser getCard(String certificateNumber);
 
+    /**
+     * 通过百胜门禁编号查询对应的人
+     * @param idNum
+     * @return
+     */
+    SmartUser getBsStudentNo(String idNum);
 }

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

@@ -61,9 +61,9 @@ public class SmartFaceDiscernServiceImpl extends ServiceImpl<SmartFaceDiscernMap
     private Integer page = 1;
     private Integer size = 50;
 
-//    @Scheduled(cron = "0 0/50 * * * ? ")
+
     @Async
-    @Scheduled(cron = "0 0 0/1 * * ? ")
+//    @Scheduled(cron = "0 0 0/1 * * ? ")
     public void baiS() {
         if(scheduleConfig.getIsOpen().equals("1")){
             try {

+ 10 - 0
src/main/java/com/template/services/impl/SmartUserServiceImpl.java

@@ -327,5 +327,15 @@ public class SmartUserServiceImpl extends ServiceImpl<SmartUserMapper, SmartUser
         return one;
     }
 
+    @Override
+    public SmartUser getBsStudentNo(String idNum) {
+        LambdaQueryWrapper<SmartUser> wrapper=new LambdaQueryWrapper<>();
+        wrapper.eq(SmartUser::getBsStudentNo,idNum)
+                .or()
+                .eq(SmartUser::getBsStaffCode,idNum);
+        SmartUser one = this.getOne(wrapper);
+        return one;
+    }
+
 
 }

BIN
target/mybatis_plus-0.0.1-SNAPSHOT.jar.original