home.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package handler
  2. import (
  3. "city_chips/internal/service"
  4. "city_chips/pkg/helper/resp"
  5. "github.com/gin-gonic/gin"
  6. "github.com/spf13/viper"
  7. )
  8. type HomeHandler struct {
  9. *Handler
  10. homeService service.HomeService
  11. conf *viper.Viper
  12. }
  13. func NewHomeHandler(handler *Handler, homeService service.HomeService, conf *viper.Viper) *HomeHandler {
  14. return &HomeHandler{
  15. Handler: handler,
  16. homeService: homeService,
  17. conf: conf,
  18. }
  19. }
  20. // GetHome 获取首页数据
  21. func (h *HomeHandler) GetHome(ctx *gin.Context) {
  22. m := make(map[string]any)
  23. Alarm := make(map[string]any)
  24. m["Area"] = 20000 //建筑面积
  25. m["FloorSpace"] = 20000 //占地面积
  26. m["BuildingHeight"] = 30 //建筑高度
  27. m["Storey"] = 30 //建筑层数
  28. m["Device"] = 30 //设备总数
  29. m["Runing"] = 30 //运行总数
  30. m["Fault"] = 30 //设备故障
  31. m["Alarm"] = 30 //报警数量
  32. m["TodayConsumption"] = 9342 //今日电能耗
  33. m["WeekConsumption"] = 30 //本周电能耗
  34. m["MonthConsumption"] = 432 //本月电能耗
  35. m["YearConsumption"] = 133 //本年电能耗
  36. m["Impetus"] = 67 //动力能耗
  37. m["illuminating"] = 432 //照明能耗
  38. m["SpecialElectricity"] = 10 //特殊用电能耗
  39. m["AirConditioningSockets"] = 30 //空调插座能耗
  40. m["TodaysTicket"] = 30 //今日工单
  41. m["ConductedTicket"] = 909 //进行工单
  42. m["TimeoutTicket"] = 30 //超时工单
  43. m["Demands"] = 30 //诉求总数
  44. m["DisposeDemands"] = 30 //已处理诉求
  45. m["UnDisposeDemands"] = 30 //未处理诉求
  46. m["TodayDisposeDemands"] = 30 //今日新增
  47. m["OccupationDriveway"] = 321 //占用车位
  48. m["IdleDriveway"] = 30 //空闲车位
  49. Alarm["2025-5-1"] = 10
  50. Alarm["2025-5-2"] = 2210
  51. Alarm["2025-5-3"] = 30
  52. Alarm["2025-5-4"] = 40
  53. Alarm["2025-5-5"] = 5320
  54. Alarm["2025-5-6"] = 60
  55. Alarm["2025-5-7"] = 70
  56. m["AlarmCount"] = Alarm //报警统计
  57. resp.HandleSuccess(ctx, m)
  58. }