Browse Source

推送回调更新

liu 2 years atrás
parent
commit
416653c3a6

+ 7 - 50
.idea/workspace.xml

@@ -5,20 +5,18 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="995b8ac7-46be-4ba7-be5a-eaf424ddd316" name="Default Changelist" comment="">
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/template/api/SmartFaceDiscernTestControllerAPI.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/template/common/utils/BASE64DecodedMultipartFile.java" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/main/java/com/template/common/utils/MultipartFileUtils.java" afterDir="false" />
       <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/AutoCode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/AutoCode.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/main/java/com/template/api/SmartFaceDiscernControllerAPI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/api/SmartFaceDiscernControllerAPI.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/api/SmartFaceDiscernTestControllerAPI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/api/SmartFaceDiscernTestControllerAPI.java" 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/services/SmartDeviceService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/services/SmartDeviceService.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/services/impl/SmartDeviceServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/services/impl/SmartDeviceServiceImpl.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/model/pojo/SmartFaceDiscern.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/model/pojo/SmartFaceDiscern.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/model/pojo/SmartFaceDiscernTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/model/pojo/SmartFaceDiscernTest.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/services/SmartUserService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/services/SmartUserService.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$/src/main/java/com/template/services/impl/SmartUserServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/services/impl/SmartUserServiceImpl.java" afterDir="false" />
     </list>
-    <list id="09eff92e-84e6-4825-81c9-523c173595c5" name="Changes" comment="">
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-    </list>
+    <list id="09eff92e-84e6-4825-81c9-523c173595c5" name="Changes" comment="" />
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
     <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -93,37 +91,6 @@
       </list>
     </option>
   </component>
-  <component name="LineStatusTrackerManager">
-    <file path="$PROJECT_DIR$/.idea/workspace.xml">
-      <ranges>
-        <range start1="6" end1="7" start2="6" end2="6" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="8" end1="17" start2="7" end2="10" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="18" end1="19" start2="11" end2="13" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="20" end1="60" start2="14" end2="20" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="69" end1="119" start2="29" end2="29" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="122" end1="122" start2="32" end2="33" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="125" end1="126" start2="36" end2="36" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="185" end1="185" start2="95" end2="126" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="294" end1="307" start2="235" end2="235" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="310" end1="311" start2="238" end2="238" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="312" end1="327" start2="239" end2="254" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="328" end1="329" start2="255" end2="256" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="332" end1="333" start2="259" end2="259" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="334" end1="334" start2="260" end2="263" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="338" end1="353" start2="267" end2="294" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="360" end1="360" start2="301" end2="307" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="375" end1="376" start2="322" end2="322" changelist="09eff92e-84e6-4825-81c9-523c173595c5" />
-        <range start1="383" end1="384" start2="329" end2="329" changelist="09eff92e-84e6-4825-81c9-523c173595c5" />
-        <range start1="386" end1="387" start2="331" end2="331" changelist="09eff92e-84e6-4825-81c9-523c173595c5" />
-        <range start1="515" end1="516" start2="459" end2="459" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="521" end1="522" start2="464" end2="464" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="527" end1="528" start2="469" end2="469" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="533" end1="534" start2="474" end2="474" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="539" end1="540" start2="479" end2="479" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-        <range start1="545" end1="546" start2="484" end2="484" changelist="995b8ac7-46be-4ba7-be5a-eaf424ddd316" />
-      </ranges>
-    </file>
-  </component>
   <component name="MarkdownSettingsMigration">
     <option name="stateVersion" value="1" />
   </component>
@@ -484,16 +451,6 @@
           <line>371</line>
           <option name="timeStamp" value="21" />
         </line-breakpoint>
-        <line-breakpoint enabled="true" type="java-line">
-          <url>file://$PROJECT_DIR$/src/main/java/com/template/controller/SmartFaceDiscernTestController.java</url>
-          <line>65</line>
-          <option name="timeStamp" value="23" />
-        </line-breakpoint>
-        <line-breakpoint enabled="true" type="java-line">
-          <url>file://$PROJECT_DIR$/src/main/java/com/template/controller/SmartFaceDiscernTestController.java</url>
-          <line>56</line>
-          <option name="timeStamp" value="24" />
-        </line-breakpoint>
       </breakpoints>
     </breakpoint-manager>
   </component>

+ 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);
+
+
 }

+ 131 - 0
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)
@@ -169,6 +177,129 @@ public class SmartFaceDiscernController implements SmartFaceDiscernControllerAPI
         return CommonResult.ok(vos);
     }
 
+    @Override
+    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());
+//            System.out.println("jsonObject = " + jsonObject);
+//            比对结果
+            Integer resultStatus = jsonObject.getInteger("resultStatus");
+            if (1 == resultStatus) {
+
+//          抓拍的照片 base64字符串
+                String scenePhoto = jsonObject.getString("scenePhoto");
+                scenePhoto = "data:image/jpeg;base64," + scenePhoto;
+                System.out.println("scenePhoto = " + scenePhoto.substring(0, 100));
+//            base64转文件
+                MultipartFile multipartFile = MultipartFileUtils.base64ToMultipartFile(scenePhoto);
+//            上传到cos桶,并生成图片地址
+                String image = smartUploadService.upload(new MultipartFile[]{multipartFile});
+
+                //          设备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;
+                }
+                DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                String dateTime = dateTimeFormatter1.format(LocalDateTime.now());
+
+                SmartFaceDiscern smartFaceDiscern = new SmartFaceDiscern();
+                smartFaceDiscern.setImage(image);
+                smartFaceDiscern.setName(s);
+                smartFaceDiscern.setLocation(address);
+                smartFaceDiscern.setType(type);
+                smartFaceDiscern.setUserId(userId);
+                smartFaceDiscern.setDateTime(dateTime);
+                smartFaceDiscern.setIdNum(idNum);
+                smartFaceDiscern.setSn(sn);
+                smartFaceDiscernService.save(smartFaceDiscern);
+
+                if (userId != 0) {
+
+//                        通过学生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 = "离开大门";
+                                }
+
+                                //                        时间格式是 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(dateTime);
+                                smartNotification.setType(2);
+
+                                smartNotificationService.save(smartNotification);
+
+                            }
+
+                        }
+
+                    }
+                }
+
+            }
+
+        } 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) {

+ 131 - 48
src/main/java/com/template/controller/SmartFaceDiscernTestController.java

@@ -6,14 +6,13 @@ 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.SmartNotification;
 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.services.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 
@@ -24,11 +23,14 @@ 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 +51,9 @@ public class SmartFaceDiscernTestController implements SmartFaceDiscernTestContr
     @Autowired
     SmartUploadService smartUploadService;
 
+    @Autowired
+    SmartNotificationService smartNotificationService;
+
     @Override
     @PassToken
     @DESRespondSecret(validated = false)
@@ -61,62 +66,140 @@ public class SmartFaceDiscernTestController implements SmartFaceDiscernTestContr
                 responseStrBuilder.append(inputStr);
             }
             JSONObject jsonObject = JSONObject.parseObject(responseStrBuilder.toString());
-
+//            System.out.println("jsonObject = " + jsonObject);
 //            比对结果
             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) {
+
 //          抓拍的照片 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;
+                System.out.println("scenePhoto = " + scenePhoto.substring(0, 100));
 //            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();
+                String image = smartUploadService.upload(new MultipartFile[]{multipartFile});
+
+                //          设备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();
-            }
+                    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;
+                }
+                DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+                String dateTime = dateTimeFormatter1.format(LocalDateTime.now());
+
+                SmartFaceDiscernTest smartFaceDiscernTest = new SmartFaceDiscernTest();
+                smartFaceDiscernTest.setImage(image);
+                smartFaceDiscernTest.setName(s);
+                smartFaceDiscernTest.setLocation(address);
+                smartFaceDiscernTest.setType(type);
+                smartFaceDiscernTest.setUserId(userId);
+                smartFaceDiscernTest.setDateTime(dateTime);
+                smartFaceDiscernTest.setIdNum(idNum);
+                smartFaceDiscernTest.setSn(sn);
+                smartFaceDiscernTestService.save(smartFaceDiscernTest);
+
+                if (userId != 0) {
+
+//                        通过学生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 = "离开大门";
+                                }
+
+                                //                        时间格式是 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(dateTime);
+                                smartNotification.setType(2);
+
+                                smartNotificationService.save(smartNotification);
+
+                            }
+
+                        }
+
+                    }
+                }
 
-//            名字
-            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();
+        }
+
+        JSONObject r = new JSONObject();
+        r.put("message", "Success");
+        r.put("result", 0);
+        return r.toJSONString();
+    }
 
-        }catch (Exception e){
+    @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);
 }

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

@@ -63,7 +63,7 @@ public class SmartFaceDiscernServiceImpl extends ServiceImpl<SmartFaceDiscernMap
 
 //    @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;
+    }
+
 
 }