property.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. acce := model.AccessRecords{
  57. Name: model.Names[i],
  58. State: 0,
  59. Date: time.Now().Format("2006-01-02 15:04:05"),
  60. }
  61. records := model.GarRecords{
  62. GarName: model.GenerateLicensePlate(),
  63. State: 0,
  64. GarImag: "https://img95.699pic.com/photo/40041/1120.jpg_wh860.jpg",
  65. Date: time.Now().Format("2006-01-02 15:04:05"),
  66. }
  67. garRecords = append(garRecords, records)
  68. accessRecords = append(accessRecords, acce)
  69. }
  70. m["HousesCount"] = rand.Intn(100) //房屋数
  71. m["HouseholdCount"] = rand.Intn(100) //住户数
  72. m["DrivewayCount"] = rand.Intn(100) //车位数
  73. m["PopulationCount"] = rand.Intn(100) //人口总数
  74. m["Under30"] = rand.Intn(100) //30以下
  75. m["Under40"] = rand.Intn(100) //40以下
  76. m["Under50"] = rand.Intn(100) //50以下
  77. m["More60"] = rand.Intn(100) //60以上
  78. m["AccessRecords"] = accessRecords //人员出入记录
  79. m["GarRecords"] = garRecords //车辆出入记录
  80. m["Access"] = access //门禁管理
  81. m["GarageCount"] = access //车库流动管理
  82. resp.HandleSuccess(ctx, m)
  83. }