1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package Plugins
- import (
- "Cold_mqtt/MqttServer/WarningNotice"
- "Cold_mqtt/lib"
- "Cold_mqtt/logs"
- "Cold_mqtt/models/Device"
- "Cold_mqtt/models/Warning"
- "time"
- )
- // 设备离线报警连续推送 冰箱采集器(wifi版) BX100W
- func ContinuousPushOfOfflineDeviceWarning() {
- ContinuousPushOfOfflineDeviceWarningTOGO:
- DeviceList := Device.Read_获取BX100W离线设备()
- logs.Println("======设备离线报警连续推送========")
- for _, r_Device := range DeviceList {
- DeviceParameter_r, is := Device.Read_DeviceParameter(r_Device.T_sn)
- if !is {
- logs.Println(r_Device.T_sn + " 没有设备参数,跳过")
- continue
- }
- Warningr_new := Warning.Read_T_snT_tp(r_Device.T_sn, 1001)
- if Warningr_new.Id == 0 {
- logs.Println(r_Device.T_sn + " 没有触发过离线,跳过")
- continue
- }
- duration := time.Now().Sub(Warningr_new.T_Ut)
- // 将时间差表示为秒
- seconds := int(duration.Seconds())
- if DeviceParameter_r.T_outA > seconds {
- logs.Println(r_Device.T_sn+" 未满足触发条件,跳过,已经持续", seconds, "秒,配置", DeviceParameter_r.T_outA)
- continue
- }
- Warningr_fUt := Warning.Read_T_snT_tpT_Msid(r_Device.T_sn, 1001, 0)
- if Warningr_fUt.Id == 0 {
- logs.Println(r_Device.T_sn + " 没有触发过初次离线,跳过")
- continue
- }
- Warning_r := Warning.Add_DeviceLogs(1001, r_Device, "设备离线报警,已经持续 "+lib.TimeSinceToString(Warningr_fUt.T_Ut, time.Now()))
- Warning_r.T_fUt = Warningr_fUt.T_Ut
- Warning_r.T_Msid = 1
- Warning.Update_Warning(Warning_r, "T_Msid", "T_fUt")
- WarningNotice.WarningCompanyNotice(&Warning_r, 0, 0)
- }
- time.Sleep(time.Second * 30)
- goto ContinuousPushOfOfflineDeviceWarningTOGO
- }
|