package task import ( "server/dao/devices" "server/service/tcp" "time" ) // 网关巡检 func GatewayRoutingInspection() { g := devices.GateWay{} gatewayList, _ := g.PublicGateway() for _, gateway := range gatewayList { currentTime := time.Now() status := 1 if (gateway.RecentOnline == time.Time{} || currentTime.Sub(gateway.RecentOnline).Minutes() > 15) { //如果上次在线时间与当前时间对比超过十五分钟则离线 //离线 && 修改网关下所有设备的状态为离线 status = 0 //_ = devices.UpdateCameraStatusByGatewayId(gateway.ID, status) //_ = devices.UpdateScreensStatusByGatewayId(gateway.ID, status) //_ = devices.UpdateRadarStatusByGatewayId(gateway.ID, status) } _ = devices.UpdateGatewayStatus(gateway.GatewayCode, status) } } //8:00调节LED屏幕亮度 func SetBrightnessAtDay() { screens := devices.Screens{} screensList, _ := screens.QueryOnlineScreens() for _, s := range screensList { _ = tcp.SetBrightness(s.Sn, s.DayBright) } } //18:00调节LED屏幕亮度 func SetBrightnessAtNight() { screens := devices.Screens{} screensList, _ := screens.QueryOnlineScreens() for _, s := range screensList { _ = tcp.SetBrightness(s.Sn, s.NightBright) } }