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

/**
 * 分拣员每日统计
 *
 * 一名分拣员一天一条记录
 */
@Entity('t_report_daily_sorter')
@Unique('uk_date_sorter', ['date', 'businessId'])
export class ReportDailySorterEntity extends BaseEntity {
  @Index()
  @Column({
    comment: '日期',
    type: 'date',
  })
  date: string;

  @Index()
  @Column({
    comment: '身份证号',
    length: 32,
  })
  businessId: string;

  @Column({
    comment: '姓名',
    length: 64,
    nullable: true,
  })
  businessName: string;

  @Index()
  @Column({
    comment: '所属单位ID',
    type: 'bigint',
    nullable: true,
  })
  departmentId: number;

  @Column({
    comment: '所属单位名称',
    length: 64,
    nullable: true,
  })
  departmentName: string;

  @Index()
  @Column({
    comment: '工作站点ID',
    nullable: true,
  })
  workSiteId: string;

  @Column({
    comment: '工作站点名称',
    length: 64,
    nullable: true,
  })
  workSiteName: string;

  @Column({
    comment: '签到时间',
    nullable: true,
  })
  checkInTime: Date;

  @Column({
    comment: '签退时间',
    nullable: true,
  })
  checkOutTime: Date;

  @Column({
    comment: '工作时长(小时)',
    type: 'decimal',
    precision: 5,
    scale: 2,
    default: 0.0,
  })
  workHours: number;

  @Column({
    comment: '考勤状态',
    dict: ['正常', '迟到', '早退', '缺卡', '旷工'],
    default: '缺卡',
  })
  attendanceStatus: string;

  @Column({
    comment: 'GPS数据点数量',
    type: 'int',
    default: 0,
  })
  gpsPointCount: number;

  @Column({
    comment: '工作轨迹里程(km)',
    type: 'decimal',
    precision: 10,
    scale: 2,
    default: 0.0,
  })
  totalKm: number;

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

  @Column({
    comment: '回收订单数',
    type: 'int',
    default: 0,
  })
  orderCount: number;

  @Column({
    comment: '完成订单数',
    type: 'int',
    default: 0,
  })
  completedOrderCount: number;

  @Column({
    comment: '预约上门订单数',
    type: 'int',
    default: 0,
  })
  appointmentOrderCount: number;

  @Column({
    comment: '发放碳积分',
    type: 'decimal',
    precision: 12,
    scale: 2,
    default: 0.0,
  })
  totalCarbonPoint: number;

  @Column({
    comment: '健康数据数量',
    type: 'int',
    default: 0,
  })
  healthDataCount: number;

  @Column({
    comment: '健康异常数量',
    type: 'int',
    default: 0,
  })
  healthAbnormalCount: number;

  @Column({
    comment: '健康告警总数',
    type: 'int',
    default: 0,
  })
  alarmCount: number;

  @Column({
    comment: '一般告警次数',
    type: 'int',
    default: 0,
  })
  generalAlarmCount: number;

  @Column({
    comment: '中等告警次数',
    type: 'int',
    default: 0,
  })
  mediumAlarmCount: number;

  @Column({
    comment: '严重告警次数',
    type: 'int',
    default: 0,
  })
  seriousAlarmCount: number;

  @Column({
    comment: '未处理告警次数',
    type: 'int',
    default: 0,
  })
  unhandledAlarmCount: number;
}
