package handler import ( "city_chips/internal/service" "city_chips/pkg/helper/resp" "github.com/gin-gonic/gin" "github.com/spf13/viper" ) type HomeHandler struct { *Handler homeService service.HomeService conf *viper.Viper } func NewHomeHandler(handler *Handler, homeService service.HomeService, conf *viper.Viper) *HomeHandler { return &HomeHandler{ Handler: handler, homeService: homeService, conf: conf, } } // GetHome 获取首页数据 func (h *HomeHandler) GetHome(ctx *gin.Context) { m := make(map[string]any) Alarm := make(map[string]any) m["Area"] = 20000 //建筑面积 m["FloorSpace"] = 20000 //占地面积 m["BuildingHeight"] = 30 //建筑高度 m["Storey"] = 30 //建筑层数 m["Device"] = 30 //设备总数 m["Runing"] = 30 //运行总数 m["Fault"] = 30 //设备故障 m["Alarm"] = 30 //报警数量 m["TodayConsumption"] = 9342 //今日电能耗 m["WeekConsumption"] = 30 //本周电能耗 m["MonthConsumption"] = 432 //本月电能耗 m["YearConsumption"] = 133 //本年电能耗 m["Impetus"] = 67 //动力能耗 m["illuminating"] = 432 //照明能耗 m["SpecialElectricity"] = 10 //特殊用电能耗 m["AirConditioningSockets"] = 30 //空调插座能耗 m["TodaysTicket"] = 30 //今日工单 m["ConductedTicket"] = 909 //进行工单 m["TimeoutTicket"] = 30 //超时工单 m["Demands"] = 30 //诉求总数 m["DisposeDemands"] = 30 //已处理诉求 m["UnDisposeDemands"] = 30 //未处理诉求 m["TodayDisposeDemands"] = 30 //今日新增 m["OccupationDriveway"] = 321 //占用车位 m["IdleDriveway"] = 30 //空闲车位 Alarm["2025-5-1"] = 10 Alarm["2025-5-2"] = 2210 Alarm["2025-5-3"] = 30 Alarm["2025-5-4"] = 40 Alarm["2025-5-5"] = 5320 Alarm["2025-5-6"] = 60 Alarm["2025-5-7"] = 70 m["AlarmCount"] = Alarm //报警统计 resp.HandleSuccess(ctx, m) }