incident.go 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package dao
  2. import (
  3. "time"
  4. "wails-app/internal/global"
  5. )
  6. // IncidentRecord 异常事件记录(事件与工单合一)。
  7. // 自动埋点(通行失败、设备离线、人工抬杆)与人工上报共用一张表,
  8. // 处置过程(状态流转、处置方式、金额、处理人)随记录保存。
  9. type IncidentRecord struct {
  10. global.GVA_MODEL
  11. IncidentNo string `gorm:"size:32;uniqueIndex" json:"incident_no"`
  12. Category string `gorm:"size:32;index" json:"category"`
  13. Source string `gorm:"size:20" json:"source"`
  14. Level string `gorm:"size:20" json:"level"`
  15. Status string `gorm:"size:20;default:pending;index;index:idx_incident_device_status,priority:2" json:"status"`
  16. // VehicleRecordID 是停车会话(历史表名 vehicle_record)的关联 ID。
  17. VehicleRecordID uint `gorm:"index" json:"vehicle_record_id"`
  18. DigitalTicketID uint `gorm:"index" json:"digital_ticket_id"`
  19. PaymentRecordID uint `gorm:"index" json:"payment_record_id"`
  20. GateCommandID uint `gorm:"index" json:"gate_command_id"`
  21. TicketNo string `gorm:"size:64" json:"ticket_no"`
  22. PlateNumber string `gorm:"size:20" json:"plate_number"`
  23. RFIDTag string `gorm:"size:40" json:"rfid_tag"`
  24. ParkingLotID uint `json:"parking_lot_id"`
  25. ParkingLotName string `gorm:"size:100" json:"parking_lot_name"`
  26. ChannelID uint `json:"channel_id"`
  27. ChannelCode string `gorm:"size:32" json:"channel_code"`
  28. ChannelName string `gorm:"size:100" json:"channel_name"`
  29. DeviceCode string `gorm:"size:32;index:idx_incident_device_status,priority:1" json:"device_code"`
  30. DeviceName string `gorm:"size:100" json:"device_name"`
  31. OperatorID uint `json:"operator_id"`
  32. Description string `gorm:"size:500" json:"description"`
  33. Detail string `gorm:"type:text" json:"detail"`
  34. HandlerID uint `json:"handler_id"`
  35. HandledAt *time.Time `json:"handled_at"`
  36. HandleType string `gorm:"size:32" json:"handle_type"`
  37. HandleRemark string `gorm:"size:500" json:"handle_remark"`
  38. ForceFreeAmount float64 `json:"force_free_amount"`
  39. EventLog string `gorm:"type:text" json:"event_log"`
  40. }
  41. func (IncidentRecord) TableName() string { return "incident_record" }
  42. // DeviceCommandLog 道闸指令流水:每次开闸/关闸命令的审计记录。
  43. // 开闸失败时通过 incident_id 关联对应的异常事件。
  44. type DeviceCommandLog struct {
  45. global.GVA_MODEL
  46. DeviceCode string `gorm:"size:32;index" json:"device_code"`
  47. DeviceName string `gorm:"size:64" json:"device_name"`
  48. Action string `gorm:"size:10" json:"action"` // open / close
  49. Source string `gorm:"size:20" json:"source"` // passage / manual / test
  50. OperatorID uint `json:"operator_id"`
  51. SessionID uint `json:"session_id"`
  52. IncidentID uint `json:"incident_id"`
  53. Result string `gorm:"size:20" json:"result"` // success / failed
  54. ErrorMessage string `gorm:"size:500" json:"error_message"`
  55. DurationMs int64 `json:"duration_ms"`
  56. }
  57. func (DeviceCommandLog) TableName() string { return "device_command_log" }