import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index, Unique } from 'typeorm';

/**
 * 每日站点汇总
 */
@Entity('t_report_daily_vehicle')
@Unique('uk_date_vehicle', ['date', 'vehicleNo'])
export class ReportDailyVehicleEntity extends BaseEntity {

  @Index()
  @Column({ comment: '日期', type: 'date' })
  date: string;

  @Index()
  @Column({ comment: '车牌号', length: 32 })
  vehicleNo: string;

  @Index()
  @Column({ comment: '所属部门/学校/后勤组ID', type: 'int', nullable: true })
  departmentId: number;

  departmentName: string;

  // ==================== 2. 基础运行指标 ====================

  @Column({
    comment: '当日行驶里程(km)',
    type: 'decimal',
    precision: 10,
    scale: 2,
    default: 0.0,
  })
  totalKm: number;

  @Column({ comment: '未启动时间(分钟)', type: 'int', default: 0 })
  minutesOffline: number;

  @Column({ comment: '纯行驶时长(分钟)', type: 'int', default: 0 })
  minutesMoving: number;

  @Column({ comment: '停车时长(分钟)', type: 'int', default: 0 })
  minutesParked: number;

  @Column({ comment: '异常怠速时长(分钟)', type: 'int', default: 0 })
  minutesAbnormalIdle: number;

  @Column({
    comment: '平均行驶车速(km/h)',
    type: 'decimal',
    precision: 5,
    scale: 1,
    default: 0.0,
  })
  avgSpeed: number;

  // ==================== 3. 安全与驾驶行为指标 ====================

  @Column({ comment: '超速告警次数', type: 'int', default: 0 })
  overspeedCount: number;

  @Column({ comment: '超速累计时长(秒)', type: 'int', default: 0 })
  overspeedDurationSec: number;

  @Column({ comment: '急刹车次数', type: 'int', default: 0 })
  harshBrakeCount: number;

  @Column({ comment: '急加速次数', type: 'int', default: 0 })
  harshAccelCount: number;

  @Column({ comment: '急转弯次数', type: 'int', default: 0 })
  harshTurnCount: number;

  @Column({ comment: '非工作时段异动告警次数', type: 'int', default: 0 })
  offHoursMoveCount: number;


}