123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package handler
- import (
- "city_chips/internal/service"
- "city_chips/pkg/helper/resp"
- "github.com/gin-gonic/gin"
- "github.com/spf13/viper"
- "math/rand"
- )
- 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"] = rand.Intn(1000) //建筑面积
- m["FloorSpace"] = rand.Intn(1000) //占地面积
- m["BuildingHeight"] = rand.Intn(1000) //建筑高度
- m["Storey"] = rand.Intn(1000) //建筑层数
- m["Device"] = rand.Intn(1000) //设备总数
- m["Runing"] = rand.Intn(1000) //运行总数
- m["Fault"] = rand.Intn(1000) //设备故障
- m["Alarm"] = rand.Intn(1000) //报警数量
- m["TodayConsumption"] = rand.Intn(1000) //今日电能耗
- m["WeekConsumption"] = rand.Intn(1000) //本周电能耗
- m["MonthConsumption"] = rand.Intn(1000) //本月电能耗
- m["YearConsumption"] = rand.Intn(1000) //本年电能耗
- m["Impetus"] = rand.Intn(1000) //动力能耗
- m["illuminating"] = rand.Intn(1000) //照明能耗
- m["SpecialElectricity"] = rand.Intn(1000) //特殊用电能耗
- m["AirConditioningSockets"] = rand.Intn(1000) //空调插座能耗
- m["TodaysTicket"] = rand.Intn(1000) //今日工单
- m["ConductedTicket"] = rand.Intn(1000) //进行工单
- m["TimeoutTicket"] = rand.Intn(1000) //超时工单
- m["Demands"] = rand.Intn(1000) //诉求总数
- m["DisposeDemands"] = rand.Intn(1000) //已处理诉求
- m["UnDisposeDemands"] = rand.Intn(1000) //未处理诉求
- m["TodayDisposeDemands"] = rand.Intn(1000) //今日新增
- m["OccupationDriveway"] = rand.Intn(1000) //占用车位
- m["IdleDriveway"] = rand.Intn(1000) //空闲车位
- Alarm["2025-5-1"] = rand.Intn(1000)
- Alarm["2025-5-2"] = rand.Intn(1000)
- Alarm["2025-5-3"] = rand.Intn(1000)
- Alarm["2025-5-4"] = rand.Intn(1000)
- Alarm["2025-5-5"] = rand.Intn(1000)
- Alarm["2025-5-6"] = rand.Intn(1000)
- Alarm["2025-5-7"] = rand.Intn(1000)
- m["AlarmCount"] = Alarm //报警统计
- resp.HandleSuccess(ctx, m)
- }
|