Procházet zdrojové kódy

假离线bug修复

terry před 2 měsíci
rodič
revize
c9328fa7d5
3 změnil soubory, kde provedl 92 přidání a 89 odebrání
  1. 7 3
      initialize/myData.go
  2. 1 2
      modbus/operate.go
  3. 84 84
      static/data.json

+ 7 - 3
initialize/myData.go

@@ -176,7 +176,6 @@ func parseData(data *model.QueueData) {
 		return
 	}
 	toString := hex.EncodeToString(data.Value)
-	logger.Get().Println("Modbus Data: " + toString)
 	switch toString[0:2] {
 	case "fe":
 		switch toString[4:8] { // 开关灯
@@ -200,9 +199,15 @@ func parseData(data *model.QueueData) {
 					reg.Devices[i].State = 1
 					reg.Devices[i].OnlineTime = time.Now()
 				}
+				for i2, _ := range device.DeviceLoops {
+					if toString[6:8] == "ff" || toString[6:8] == "0f" {
+						device.DeviceLoops[i2].State = 1
+					} else if toString[6:8] == "00" {
+						device.DeviceLoops[i2].State = 0
+					}
+				}
 			}
 			regions, err := utils.SaveRegionOnData(reg)
-			logger.Get().Println(data.Id + "-----" + toString)
 			err = service.SaveData(regions)
 			if err != nil {
 				logger.Get().Errorln(err)
@@ -210,7 +215,6 @@ func parseData(data *model.QueueData) {
 			}
 		}
 	case "11":
-		logger.Get().Println("太阳能---" + toString)
 		switch toString[2:6] {
 		case "0336":
 			logger.Get().Println(data.Id + "太阳能" + toString)

+ 1 - 2
modbus/operate.go

@@ -13,7 +13,6 @@ func GetSunPowerInfo() error {
 		_, dev, err := utils.GetDataByDeviceId(id)
 		if dev.IsSun && dev.State == 1 { //打开  并且在线
 			err = utils.WriteDevice(SolarEnergyData(), conn)
-			logger.Get().Info(dev.Sn + "SunPowerInfo 发送")
 			if err != nil {
 				return err
 			}
@@ -39,7 +38,7 @@ func DealWithOffline() {
 	}
 	for i, region := range regions {
 		for i2, device := range region.Devices {
-			if time.Now().After(device.OnlineTime.Add(4*time.Minute)) && regions[i].Devices[i2].State != 0 {
+			if time.Now().After(device.OnlineTime.Add(8*time.Minute)) && regions[i].Devices[i2].State != 0 {
 				regions[i].Devices[i2].State = 0
 			}
 		}

+ 84 - 84
static/data.json

@@ -10,18 +10,18 @@
         "regionId": 1,
         "name": "维修车间",
         "genre": "八回路控制",
-        "state": 1,
+        "state": 0,
         "isSun": true,
         "loopNumber": 8,
-        "onlineTime": "2025-01-19T09:43:59.91502361+08:00",
+        "onlineTime": "2025-01-19T17:19:59.057003056+08:00",
         "deviceLoops": [
           {
             "id": 1,
             "deviceId": "JM36xWRZq6PiwmKV",
             "name": "回路12",
             "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -30,8 +30,8 @@
             "deviceId": "JM36xWRZq6PiwmKV",
             "name": "回路2",
             "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -40,8 +40,8 @@
             "deviceId": "JM36xWRZq6PiwmKV",
             "name": "回路3",
             "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -50,8 +50,8 @@
             "deviceId": "JM36xWRZq6PiwmKV",
             "name": "回路4",
             "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -60,8 +60,8 @@
             "deviceId": "JM36xWRZq6PiwmKV",
             "name": "回路5",
             "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -70,8 +70,8 @@
             "deviceId": "JM36xWRZq6PiwmKV",
             "name": "回路6",
             "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -80,8 +80,8 @@
             "deviceId": "JM36xWRZq6PiwmKV",
             "name": "回路7",
             "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -90,8 +90,8 @@
             "deviceId": "JM36xWRZq6PiwmKV",
             "name": "回路8",
             "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           }
@@ -109,18 +109,18 @@
         "regionId": 1,
         "name": "洗车房",
         "genre": "四回路控制",
-        "state": 1,
+        "state": 0,
         "isSun": false,
         "loopNumber": 4,
-        "onlineTime": "2025-01-19T09:46:00.028035846+08:00",
+        "onlineTime": "2025-01-19T18:22:00.035072721+08:00",
         "deviceLoops": [
           {
             "id": 1,
             "deviceId": "JM453Sa4a8pdYdgV",
             "name": "回路1",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -128,9 +128,9 @@
             "id": 2,
             "deviceId": "JM453Sa4a8pdYdgV",
             "name": "回路2",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -138,9 +138,9 @@
             "id": 3,
             "deviceId": "JM453Sa4a8pdYdgV",
             "name": "回路3",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -148,9 +148,9 @@
             "id": 4,
             "deviceId": "JM453Sa4a8pdYdgV",
             "name": "回路4",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           }
@@ -171,15 +171,15 @@
         "state": 1,
         "isSun": false,
         "loopNumber": 4,
-        "onlineTime": "2025-01-19T09:46:00.027293637+08:00",
+        "onlineTime": "2025-01-19T18:34:00.037774419+08:00",
         "deviceLoops": [
           {
             "id": 1,
             "deviceId": "JM45U0zGDCMhgrxc",
             "name": "回路1",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -187,9 +187,9 @@
             "id": 2,
             "deviceId": "JM45U0zGDCMhgrxc",
             "name": "回路2",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -197,9 +197,9 @@
             "id": 3,
             "deviceId": "JM45U0zGDCMhgrxc",
             "name": "回路3",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -207,9 +207,9 @@
             "id": 4,
             "deviceId": "JM45U0zGDCMhgrxc",
             "name": "回路4",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           }
@@ -230,15 +230,15 @@
         "state": 1,
         "isSun": false,
         "loopNumber": 4,
-        "onlineTime": "2025-01-19T09:44:00.051568026+08:00",
+        "onlineTime": "2025-01-19T18:34:00.05470463+08:00",
         "deviceLoops": [
           {
             "id": 1,
             "deviceId": "JM45S67eqnSKueAK",
             "name": "回路1",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -246,9 +246,9 @@
             "id": 2,
             "deviceId": "JM45S67eqnSKueAK",
             "name": "回路2",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -256,9 +256,9 @@
             "id": 3,
             "deviceId": "JM45S67eqnSKueAK",
             "name": "回路3",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -266,9 +266,9 @@
             "id": 4,
             "deviceId": "JM45S67eqnSKueAK",
             "name": "回路4",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           }
@@ -287,17 +287,17 @@
         "name": "入厂道路",
         "genre": "八回路控制",
         "state": 1,
-        "isSun": false,
+        "isSun": true,
         "loopNumber": 8,
-        "onlineTime": "2025-01-19T09:46:00.039018537+08:00",
+        "onlineTime": "2025-01-19T18:33:59.320571748+08:00",
         "deviceLoops": [
           {
             "id": 1,
             "deviceId": "JM36g0RM0ivegAGK",
             "name": "回路1",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -305,9 +305,9 @@
             "id": 2,
             "deviceId": "JM36g0RM0ivegAGK",
             "name": "回路2",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -315,9 +315,9 @@
             "id": 3,
             "deviceId": "JM36g0RM0ivegAGK",
             "name": "回路3",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -325,9 +325,9 @@
             "id": 4,
             "deviceId": "JM36g0RM0ivegAGK",
             "name": "回路4",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -335,9 +335,9 @@
             "id": 5,
             "deviceId": "JM36g0RM0ivegAGK",
             "name": "回路5",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -345,9 +345,9 @@
             "id": 6,
             "deviceId": "JM36g0RM0ivegAGK",
             "name": "回路6",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -355,9 +355,9 @@
             "id": 7,
             "deviceId": "JM36g0RM0ivegAGK",
             "name": "回路7",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           },
@@ -365,9 +365,9 @@
             "id": 8,
             "deviceId": "JM36g0RM0ivegAGK",
             "name": "回路8",
-            "state": 0,
-            "timeCondition1OnTime": "关闭",
-            "timeCondition1OffTime": "关闭",
+            "state": 1,
+            "timeCondition1OnTime": "17:30",
+            "timeCondition1OffTime": "07:00",
             "timeCondition2OnTime": "关闭",
             "timeCondition2OffTime": "关闭"
           }