Jelajahi Sumber

智慧网关-在线状态

sixian 2 tahun lalu
induk
melakukan
962d775972
2 mengubah file dengan 4 tambahan dan 3 penghapusan
  1. 1 1
      config/config.yaml
  2. 3 2
      util/cache/redis.go

+ 1 - 1
config/config.yaml

@@ -7,7 +7,7 @@ server:
 # Logger configurations.
 logger:
   # 1开启  0关闭
-  switch: 1
+  switch: 0
   path:  "./log"
   level: "info"
   name:  "info"

+ 3 - 2
util/cache/redis.go

@@ -48,14 +48,15 @@ func GetDeviceState(id string) (retTime time.Time, retState string) {
 	}()
 	retTime = time.Time{}
 	retState = "2"
-	//redis中 0在线 1离线
+	//redis中 1在线 0离线
 	//todo 需要统一
 	list, err := Redis.HMGet(DeviceStateKey+id, TLast, ONLINE).Result()
+	//fmt.Printf("list = %v id=%v \n", list, id)
 	if err == nil && list[0] != nil || list[1] != nil {
 		t, err1 := common.MlParseTime(list[0].(string))
 		s, err0 := strconv.Atoi(list[1].(string))
 		if err0 == nil && err1 == nil {
-			if s == 0 {
+			if s == 1 {
 				retState = "1"
 			}
 			retTime = t