property.go 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package handler
  2. import (
  3. "city_chips/internal/model"
  4. "city_chips/internal/service"
  5. "city_chips/pkg/helper/resp"
  6. "fmt"
  7. "github.com/gin-gonic/gin"
  8. "github.com/spf13/viper"
  9. "math/rand"
  10. "time"
  11. )
  12. type PropertyHandler struct {
  13. *Handler
  14. propertyService service.PropertyService
  15. conf *viper.Viper
  16. }
  17. func NewPropertyHandler(
  18. handler *Handler,
  19. propertyService service.PropertyService,
  20. conf *viper.Viper,
  21. ) *PropertyHandler {
  22. return &PropertyHandler{
  23. Handler: handler,
  24. propertyService: propertyService,
  25. conf: conf,
  26. }
  27. }
  28. // GetProperty 获取物业管理系统数据
  29. func (h *PropertyHandler) GetProperty(ctx *gin.Context) {
  30. m := make(map[string]any)
  31. access := make(map[string]any)
  32. garageCount := make(map[string]any)
  33. var accessData model.AccessData
  34. var accessRecords []model.AccessRecords
  35. var garRecords []model.GarRecords
  36. var garage model.Garage
  37. m["HousesCount"] = rand.Intn(100) //房屋数
  38. m["HouseholdCount"] = rand.Intn(100) //住户数
  39. m["DrivewayCount"] = rand.Intn(100) //车位数
  40. m["PopulationCount"] = rand.Intn(100) //人口总数
  41. m["Under30"] = rand.Intn(100) //30以下
  42. m["Under40"] = rand.Intn(100) //40以下
  43. m["Under50"] = rand.Intn(100) //50以下
  44. m["More60"] = rand.Intn(100) //60以上
  45. for i := 0; i < 7; i++ {
  46. date := fmt.Sprintf("2025-5-%v", i+1)
  47. accessData.Remote = rand.Intn(100)
  48. accessData.CreditCard = rand.Intn(100)
  49. accessData.BrushFace = rand.Intn(100)
  50. garage.Storage = rand.Intn(100)
  51. garage.OutboundShipments = rand.Intn(100)
  52. access[date] = accessData
  53. garageCount[date] = garage
  54. }
  55. for i := 0; i < 10; i++ {
  56. name := fmt.Sprintf("人员%v", i+1)
  57. records := model.AccessRecords{
  58. Name: name,
  59. State: 0,
  60. Date: time.Now().Format("2006-01-02 15:04:05"),
  61. }
  62. accessRecords = append(accessRecords, records)
  63. }
  64. for i := 0; i < 10; i++ {
  65. name := fmt.Sprintf("贵A%v", i+1)
  66. records := model.GarRecords{
  67. GarName: name,
  68. State: 0,
  69. GarImag: "https://img95.699pic.com/photo/40041/1120.jpg_wh860.jpg",
  70. Date: time.Now().Format("2006-01-02 15:04:05"),
  71. }
  72. garRecords = append(garRecords, records)
  73. }
  74. m["HousesCount"] = rand.Intn(100) //房屋数
  75. m["HouseholdCount"] = rand.Intn(100) //住户数
  76. m["DrivewayCount"] = rand.Intn(100) //车位数
  77. m["PopulationCount"] = rand.Intn(100) //人口总数
  78. m["Under30"] = rand.Intn(100) //30以下
  79. m["Under40"] = rand.Intn(100) //40以下
  80. m["Under50"] = rand.Intn(100) //50以下
  81. m["More60"] = rand.Intn(100) //60以上
  82. m["AccessRecords"] = accessRecords //人员出入记录
  83. m["GarRecords"] = garRecords //车辆出入记录
  84. m["Access"] = access //门禁管理
  85. m["GarageCount"] = access //车库流动管理
  86. resp.HandleSuccess(ctx, m)
  87. }