grid_open_log.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package model
  2. import (
  3. "dy-admin/internal/pcmserver/common"
  4. "gorm.io/gorm"
  5. "strconv"
  6. "time"
  7. )
  8. type GridOpenLog struct {
  9. common.Model
  10. DepartmentID int `json:"departmentId" gorm:"comment:'部门id'"`
  11. DepartmentName string `json:"departmentName" gorm:"size:128;comment:部门名称"`
  12. StaffID int `json:"staffId" gorm:"comment:'人员id'"`
  13. StaffName string `json:"staffName" gorm:"size:128;comment:人员名字"`
  14. CabinetID int `json:"cabinetId" gorm:"comment:'柜子id'"`
  15. CabinetName string `json:"cabinetName" gorm:"size:128;comment:柜子名字"`
  16. GridDeviceID int `json:"gridDeviceId" gorm:"comment:'格子id'"`
  17. OpenState string `json:"openState" gorm:"size:128;comment:开关门"`
  18. common.YearMonthWeek
  19. common.ModelTime
  20. }
  21. type LogStatistics struct {
  22. StaffName string `json:"staffName"`
  23. Total string `json:"total"`
  24. }
  25. func (m *GridOpenLog) BeforeCreate(_ *gorm.DB) (err error) {
  26. now := time.Now()
  27. year, week := now.ISOWeek()
  28. m.Year = year
  29. m.Month, _ = strconv.Atoi(now.Format("01"))
  30. m.Week = week
  31. return
  32. }
  33. func (m *GridOpenLog) TableName() string {
  34. return "bus_grid_open_logs"
  35. }