package model import ( "encoding/json" "net" "server/dao" "sync" ) var ( InductanceTCP net.Listener Mutex sync.Mutex ConnectionMap1 = &sync.Map{} ) type QueueData struct { Ip string `json:"ip"` Value []byte `json:"value"` } type RegionRequest struct { RegionId int `json:"regionId"` State int `json:"state"` } type DevicesRequest struct { IDs []int `json:"ids"` State int `json:"state"` } // 蓝牙 ---------------------------------------------------------------------------------- type MsgRoot struct { ID string `json:"id"` Method string `json:"method"` // 对应 /thing/event/xxx/post Params MsgParams `json:"params"` Version string `json:"version"` } // MsgParams 外层 params 节点 type MsgParams struct { Time int64 `json:"time"` // 毫秒时间戳 Value json.RawMessage `json:"value"` // 动态内容,RawMessage 延迟解析 } // HeartbeatValue 心跳上报 value type HeartbeatValue struct { DeviceName string `json:"device_name"` // 网关名称 Area string `json:"area"` // 区号 Number string `json:"number"` // 灯号 Cluster string `json:"cluster"` // 组号(已偏移) UUID string `json:"uuid"` // 设备唯一ID(业务主键) UpdatedTime string `json:"updated_time"` // 上报时间戳 } type BeaconValue struct { Area string `json:"area"` Number string `json:"number"` Cluster string `json:"cluster"` UUID string `json:"uuid"` Version string `json:"version"` DeviceName string `json:"device_name"` Type string `json:"type"` } // TriggerValue 人体/传感器触发上报 type TriggerValue struct { DeviceName string `json:"device_name"` Area string `json:"area"` Number string `json:"number"` UUID string `json:"uuid"` TrigTime int64 `json:"trig_time"` // 触发时间(毫秒) } // AlsValue 照度上报 type AlsValue struct { DeviceName string `json:"device_name"` Area string `json:"area"` Number string `json:"number"` UUID string `json:"uuid"` Lux int `json:"lux"` // 照度值(lux) UpdatedTime string `json:"updated_time"` } // ConsumptionValue 能耗上报 type ConsumptionValue struct { DeviceName string `json:"device_name"` Area string `json:"area"` Number string `json:"number"` UUID string `json:"uuid"` AcquisitionTime int64 `json:"acquisition_time"` TimeDur int64 `json:"time_dur"` // 通电时长(秒) SensorDur int64 `json:"sensor_dur"` // 感应时长 EnergyDur int64 `json:"energy_dur"` // 等效能耗时长 Power float64 `json:"power"` // 单灯功率 } // CurrentValue 实时亮度、色温 type CurrentValue struct { DeviceName string `json:"device_name"` Area string `json:"area"` Number string `json:"number"` UUID string `json:"uuid"` CurrentBright int `json:"current_bright"` // 当前亮度 CurrentCct int `json:"current_cct"` // 当前色温 UpdatedTime string `json:"updated_time"` } // SceneValue 情景模式上报 type SceneValue struct { DeviceName string `json:"device_name"` Area string `json:"area"` Number string `json:"number"` UUID string `json:"uuid"` SceneNo int `json:"scene_no"` // 情景号 1~31 HighBright string `json:"high_bright"` // 有人亮度 StandbyBright string `json:"standby_bright"` // 无人亮度 CctBright string `json:"cct_bright"` // 色温 DelayTime string `json:"delay_time"` // 一段延时 DelayTime2 string `json:"delay_time2"` // 二段延时 LightMode string `json:"light_mode"` // 亮灯模式 DelayMode string `json:"delay_mode"` // 感应模式 AlsControlMode string `json:"alscontrol_mode"` // 恒照度模式 SceneValidity string `json:"scene_validity"` // 情景是否有效 } // TempHumValue 温湿度传感器上报 type TempHumValue struct { DeviceName string `json:"device_name"` Area string `json:"area"` Number string `json:"number"` UUID string `json:"uuid"` Temperature int `json:"temperature"` // 单位 0.1℃ Humidity int `json:"humidity"` // 单位 0.1%RH UpdatedTime string `json:"updated_time"` } // AcStatusValue 空调状态上报 type AcStatusValue struct { DeviceName string `json:"device_name"` Area string `json:"area"` Number string `json:"number"` UUID string `json:"uuid"` AcStatus string `json:"ac_status"` // On/Off AcMode string `json:"ac_mode"` // Cold/Warm/... AcSleep string `json:"ac_sleep"` // 睡眠模式 AcTemperature string `json:"ac_temperature"` AcWindSpeed string `json:"ac_wind_speed"` AcChildLock string `json:"ac_child_lock"` } // MeterCurrentValue 电表电流 type MeterCurrentValue struct { DeviceName string `json:"device_name"` Area string `json:"area"` Cluster string `json:"cluster"` Number string `json:"number"` UUID string `json:"uuid"` Addr int `json:"Addr"` // 电表地址 Ia float64 `json:"Ia"` Ib float64 `json:"Ic"` Ic float64 `json:"Ib"` } // MeterVoltageValue 电表电压 type MeterVoltageValue struct { DeviceName string `json:"device_name"` Area string `json:"area"` Cluster string `json:"cluster"` Number string `json:"number"` UUID string `json:"uuid"` Addr int `json:"Addr"` Ua float64 `json:"Ua"` Ub float64 `json:"Ub"` Uc float64 `json:"Uc"` } // MeterPowerValue 电表功率 type MeterPowerValue struct { DeviceName string `json:"device_name"` Area string `json:"area"` Cluster string `json:"cluster"` Number string `json:"number"` UUID string `json:"uuid"` Addr int `json:"addr"` Pt float64 `json:"Pt"` // 有功功率 Qt float64 `json:"Qt"` // 无功功率 PFt float64 `json:"PFt"` // 功率因数 Freq int `json:"Freq"` // 频率 } type DashboardRequest struct { GatewayID uint `json:"gatewayId" form:"gatewayId"` Year int `json:"year" form:"year"` Week int `json:"week" form:"week"` } // 趋势图数据结构 type TrendData struct { Date string `json:"date"` Actual float64 `json:"actual"` Theory float64 `json:"theory"` } type AvailableWeek struct { Year int `json:"year"` Week int `json:"week"` Label string `json:"label"` } type DashboardResponse struct { Gateways []dao.Gateway `json:"gateways"` AvailableWeeks []AvailableWeek `json:"available_weeks"` CurrentGatewayID uint `json:"currentGatewayId"` TotalLuminaires int `json:"total_luminaires"` ElectricityConsumption float64 `json:"total_electricity_consumption_this_week"` CarbonReduction float64 `json:"carbon_emission_reduction"` CarbonReductionRatio float64 `json:"carbon_emission_reduction_ratio"` WarningCount int `json:"warning_count"` LoopDeviceCount int `json:"loop_device_count"` Devices []dao.Device `json:"devices"` GatewayCount int `json:"gateway_count"` Trends []TrendData `json:"trends"` YearOnYearTrends []TrendData `json:"year_on_year_trends"` }