From bbd50cf91c9a8c7cfe48b3c00dde205b7049ae3b Mon Sep 17 00:00:00 2001
From: leutu <leutu@qq.com>
Date: 星期二, 20 八月 2024 14:50:32 +0800
Subject: [PATCH] 时间戳/1000 成为秒,围栏采用楼层判断

---
 src/main/java/com/skyline/electricity/timer/Consumer.java |   36 ++++++++++++++++--------------------
 1 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/src/main/java/com/skyline/electricity/timer/Consumer.java b/src/main/java/com/skyline/electricity/timer/Consumer.java
index d6e13ba..46c6146 100644
--- a/src/main/java/com/skyline/electricity/timer/Consumer.java
+++ b/src/main/java/com/skyline/electricity/timer/Consumer.java
@@ -19,7 +19,6 @@
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
-import java.text.SimpleDateFormat;
 import java.util.*;
 
 @Slf4j
@@ -41,7 +40,7 @@
     InformationService informationService ;
     @Override
     public void onMessage(String message) {
-        //System.out.println("recv msg:  "+message);
+        System.out.println("recv msg:  "+message);
         sendAllMessage(message);
     }
 
@@ -64,22 +63,17 @@
      */
 
     public void sendAllMessage(String message) {
-        //System.out.println("銆恮ebsocket娑堟伅銆戝箍鎾秷鎭�:"+message);
+        System.out.println("銆恮ebsocket娑堟伅銆戝箍鎾秷鎭�:"+message);
 
         JSONObject jsonObject = JSONObject.parseObject(message);
         String personNo = jsonObject.getString("personNo");
 
         SysUser sysUser = infoSynchService.selectUserInfoById(personNo) ;
-        //System.out.println("銆恥ser]:"+JSONObject.toJSONString(sysUser));
+        System.out.println("銆恥ser]:"+JSONObject.toJSONString(sysUser));
         List<RetInfo> list = new ArrayList<>();
         //鏌ヨ鐢ㄦ埛鎵�澶勫洿鏍�
-        List<FencePosition> fencePositionList = null ;
-        try{
-            fencePositionList = (List<FencePosition>)this.detectService.checkInFence(jsonObject.get("w84lat").toString(),jsonObject.get("w84lon").toString());
-        }catch (Exception e){
-            System.out.println(e.getMessage());
-        }
-        //System.out.println("銆怓encePosition]:"+JSONObject.toJSONString(fencePositionList));
+        List<FencePosition> fencePositionList = (List<FencePosition>)this.detectService.checkInFence(jsonObject.get("w84lat").toString(),jsonObject.get("w84lon").toString());
+        System.out.println("銆怓encePosition]:"+JSONObject.toJSONString(fencePositionList));
         RetInfo alertinfo = new RetInfo();
         initAlertInfos(jsonObject, personNo, sysUser, alertinfo);
         if( fencePositionList != null && fencePositionList.size() > 0){
@@ -88,7 +82,7 @@
                 Fence_User fence_user = detectService.checkInAlert(f.getWorkId(),sysUser.getId());
                 alertinfo.setFence_name(f.getFname());
                 alertinfo.setWtId(f.getWorkId());
-                if( fence_user == null && checkHight(alertinfo.getBaseFloor(),f.getStartaltitude())){
+                if( fence_user == null && checkHight(alertinfo.getBaseFloor(),f)){
                     alertinfo.setStatus("alert");
 
                 }else{
@@ -101,7 +95,7 @@
             list.add(alertinfo) ;
         }
         insertInformation(list);
-       // System.out.println( "list:"+jsonObject.toJSONString(list));
+        System.out.println( "list:"+jsonObject.toJSONString(list));
 //        if( list != null && list.size() > 0)
 //            System.out.println( "websocket status ..["+webSocketController.sendAllMessage(JSONObject.toJSONString(list))+"["+JSONObject.toJSONString(list)+"]" );
     }
@@ -120,14 +114,14 @@
         alertinfo.setMobile(sysUser.getMobile());
 
         alertinfo.setBaseFloor(jsonObject.get("baseFloor").toString());
-        String time = Long.toString(new Date().getTime());
-
-        alertinfo.setStartTime(time.substring(0,time.length()-3));
-        alertinfo.setHb(jsonObject.getIntValue("hb"));
+        alertinfo.setStartTime(jsonObject.get("timestamp").toString());
+        alertinfo.setHb(jsonObject.getInteger("hb").intValue());
     }
 
-    private boolean checkHight(String basefloor,double start){
-        return  (Integer.parseInt(basefloor)-2)*6.3 >=start ;
+    private boolean checkHight(String basefloor,FencePosition f){
+        int fl = (int)(f.getEndaltitude()/7)+1 ;
+        System.out.println("鎺ユ敹锛�"+basefloor+" 鍥存爮妤煎眰:"+f.getFname()+":"+fl);
+        return  (Integer.parseInt(basefloor)-1) ==fl ;
     }
 
 
@@ -137,7 +131,9 @@
            Information information = new Information();
            information.setFence_type(r.getType());
            information.setName(r.getFence_name());
-           information.setStartTime(r.getStartTime());
+           //information.setStartTime(r.getStartTime());
+           //閬垮厤鏃堕棿鍚屾闂
+           information.setStartTime((new Date()).getTime()/1000+"");
            information.setStatus(r.getStatus());
            information.setUserId(r.getUserId());
            information.setWtId(r.getWtId());

--
Gitblit v1.9.3