devices.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package task
  2. import (
  3. "server/dao/devices"
  4. "server/service/tcp"
  5. "time"
  6. )
  7. // 网关巡检
  8. func GatewayRoutingInspection() {
  9. g := devices.GateWay{}
  10. gatewayList, _ := g.PublicGateway()
  11. for _, gateway := range gatewayList {
  12. currentTime := time.Now()
  13. status := 1
  14. if (gateway.RecentOnline == time.Time{} || currentTime.Sub(gateway.RecentOnline).Minutes() > 15) { //如果上次在线时间与当前时间对比超过十五分钟则离线
  15. //离线 && 修改网关下所有设备的状态为离线
  16. status = 0
  17. //_ = devices.UpdateCameraStatusByGatewayId(gateway.ID, status)
  18. //_ = devices.UpdateScreensStatusByGatewayId(gateway.ID, status)
  19. //_ = devices.UpdateRadarStatusByGatewayId(gateway.ID, status)
  20. }
  21. _ = devices.UpdateGatewayStatus(gateway.GatewayCode, status)
  22. }
  23. }
  24. //8:00调节LED屏幕亮度
  25. func SetBrightnessAtDay() {
  26. screens := devices.Screens{}
  27. screensList, _ := screens.QueryOnlineScreens()
  28. for _, s := range screensList {
  29. _ = tcp.SetBrightness(s.Sn, s.DayBright)
  30. }
  31. }
  32. //18:00调节LED屏幕亮度
  33. func SetBrightnessAtNight() {
  34. screens := devices.Screens{}
  35. screensList, _ := screens.QueryOnlineScreens()
  36. for _, s := range screensList {
  37. _ = tcp.SetBrightness(s.Sn, s.NightBright)
  38. }
  39. }