import 'package:json_annotation/json_annotation.dart'; part 'job_task_item.g.dart'; @JsonSerializable() class JobTaskItem extends Object { @JsonKey(name: 'id') int id; @JsonKey(name: 'title') String title; @JsonKey(name: 'subjectName') String subjectName; @JsonKey(name: 'genderName') String genderName; @JsonKey(name: 'isFinish') bool isFinish; @JsonKey(name: 'studentCount') int studentCount; @JsonKey(name: 'commitStudentCount') int commitStudentCount; @JsonKey(name: 'totalCount') int totalCount; @JsonKey(name: 'finishCount') int finishCount; @JsonKey(name: 'objectivePrecision') double objectivePrecision; @JsonKey(name: 'subjectivePrecision') double subjectivePrecision; @JsonKey(name: 'precision') double precision; @JsonKey(name: 'markingTasks') List markingTasks; @JsonKey(name: 'createTime') String createTime; @JsonKey(name: 'progressPercentage') double progressPercentage; // 进度百分比 JobTaskItem( this.id, this.title, this.subjectName, this.genderName, this.isFinish, this.studentCount, this.commitStudentCount, this.totalCount, this.finishCount, this.objectivePrecision, this.subjectivePrecision, this.precision, this.markingTasks, this.createTime, { this.progressPercentage = 0, }) { try { progressPercentage = (finishCount / totalCount) * 100; if (progressPercentage.isNaN) { progressPercentage = 0; } else { progressPercentage = double.parse(progressPercentage.toStringAsFixed(2)); } } catch (e) { progressPercentage = 0; } } factory JobTaskItem.fromJson(Map srcJson) => _$JobTaskItemFromJson(srcJson); Map toJson() => _$JobTaskItemToJson(this); } @JsonSerializable() class MarkingTasks extends Object { @JsonKey(name: 'id') int id; @JsonKey(name: 'className') String className; @JsonKey(name: 'teacherName') String teacherName; @JsonKey(name: 'isFinish') bool isFinish; @JsonKey(name: 'finishTime') String? finishTime; @JsonKey(name: 'studentCount') int studentCount; @JsonKey(name: 'commitStudentCount') int commitStudentCount; @JsonKey(name: 'totalCount') int totalCount; @JsonKey(name: 'finishCount') int finishCount; @JsonKey(name: 'objectivePrecision') // 客观题正确率 double objectivePrecision; @JsonKey(name: 'subjectivePrecision') // 主观题正确率 double subjectivePrecision; @JsonKey(name: 'precision') // 综合正确率 double precision; @JsonKey(name: 'canMarking') bool canMarking; /** 前端自定义字段 */ @JsonKey(name: 'progressPercentage') double progressPercentage; // 进度百分比 /** 前端自定义字段 */ @JsonKey(name: 'canGoReview') bool canGoReview; // 是否能批阅 MarkingTasks( this.id, this.className, this.teacherName, this.isFinish, this.studentCount, this.commitStudentCount, this.totalCount, this.finishCount, this.objectivePrecision, this.subjectivePrecision, this.precision, this.canMarking, { this.progressPercentage = 0, this.canGoReview = true, this.finishTime, }) { try { progressPercentage = (finishCount / totalCount) * 100; if (progressPercentage.isNaN) progressPercentage = 0; else progressPercentage = double.parse(progressPercentage.toStringAsFixed(2)); } catch (e) { progressPercentage = 0; } canGoReview = totalCount > 0 && canMarking && !isFinish; } factory MarkingTasks.fromJson(Map srcJson) => _$MarkingTasksFromJson(srcJson); Map toJson() => _$MarkingTasksToJson(this); }