/// 加班报表汇总
class OTReportSummary {
  final double totalHours;
  final int totalCount;
  final double compensatoryHours;
  final double overtimePayHours;

  const OTReportSummary({
    this.totalHours = 0,
    this.totalCount = 0,
    this.compensatoryHours = 0,
    this.overtimePayHours = 0,
  });

  factory OTReportSummary.fromJson(Map<String, dynamic> json) {
    return OTReportSummary(
      totalHours: (json['totalHours'] as num?)?.toDouble() ?? 0,
      totalCount: json['totalCount'] as int? ?? 0,
      compensatoryHours: (json['compensatoryHours'] as num?)?.toDouble() ?? 0,
      overtimePayHours: (json['overtimePayHours'] as num?)?.toDouble() ?? 0,
    );
  }
}

/// 月度报表数据
class OTMonthlyItem {
  final int month;
  final double hours;
  final double compensatoryHours;
  final double overtimePayHours;
  final int count;

  const OTMonthlyItem({
    this.month = 0,
    this.hours = 0,
    this.compensatoryHours = 0,
    this.overtimePayHours = 0,
    this.count = 0,
  });

  factory OTMonthlyItem.fromJson(Map<String, dynamic> json) {
    return OTMonthlyItem(
      month: json['month'] as int? ?? 0,
      hours: (json['hours'] as num?)?.toDouble() ?? 0,
      compensatoryHours: (json['compensatoryHours'] as num?)?.toDouble() ?? 0,
      overtimePayHours: (json['overtimePayHours'] as num?)?.toDouble() ?? 0,
      count: json['count'] as int? ?? 0,
    );
  }
}

/// 加班报表汇总+月度数据
class OTReportData {
  final OTReportSummary summary;
  final List<OTMonthlyItem> monthly;

  const OTReportData({
    this.summary = const OTReportSummary(),
    this.monthly = const [],
  });

  factory OTReportData.fromJson(Map<String, dynamic> json) {
    return OTReportData(
      summary: json['summary'] != null
          ? OTReportSummary.fromJson(json['summary'] as Map<String, dynamic>)
          : const OTReportSummary(),
      monthly:
          (json['monthly'] as List<dynamic>?)
              ?.map((e) => OTMonthlyItem.fromJson(e as Map<String, dynamic>))
              .toList() ??
          [],
    );
  }
}

/// 加班报表下属对比
class OTSubordinateItem {
  final String usr;
  final String usrName;
  final double hours;
  final int cnt;

  const OTSubordinateItem({
    this.usr = '',
    this.usrName = '',
    this.hours = 0,
    this.cnt = 0,
  });

  factory OTSubordinateItem.fromJson(Map<String, dynamic> json) {
    return OTSubordinateItem(
      usr: json['usr'] as String? ?? '',
      usrName: json['usrName'] as String? ?? '',
      hours: (json['hours'] as num?)?.toDouble() ?? 0,
      cnt: json['cnt'] as int? ?? 0,
    );
  }
}

/// 加班报表明细项
class OTReportDetailItem {
  final String billNo;
  final String? billDate;
  final String employeeName;
  final double hours;
  final String jbType;
  final String compensationType;
  final String reason;

  const OTReportDetailItem({
    this.billNo = '',
    this.billDate,
    this.employeeName = '',
    this.hours = 0,
    this.jbType = '',
    this.compensationType = '',
    this.reason = '',
  });

  factory OTReportDetailItem.fromJson(Map<String, dynamic> json) {
    return OTReportDetailItem(
      billNo: json['billNo'] as String? ?? '',
      billDate: json['billDate'] as String?,
      employeeName: json['employeeName'] as String? ?? '',
      hours: (json['hours'] as num?)?.toDouble() ?? 0,
      jbType: json['jbType'] as String? ?? '',
      compensationType: json['compensationType'] as String? ?? '',
      reason: json['reason'] as String? ?? '',
    );
  }
}
