import 'package:deus_app/model/patrol_job_detail_response_entity.dart';

patrolJobDetailResponseEntityFromJson(PatrolJobDetailResponseEntity data, Map<String, dynamic> json) {
	if (json['code'] != null) {
		data.code = json['code'] is String
				? int.tryParse(json['code'])
				: json['code'].toInt();
	}
	if (json['data'] != null) {
		data.data = PatrolJobDetailResponseData().fromJson(json['data']);
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	return data;
}

Map<String, dynamic> patrolJobDetailResponseEntityToJson(PatrolJobDetailResponseEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['code'] = entity.code;
	data['data'] = entity.data.toJson();
	data['msg'] = entity.msg;
	return data;
}

patrolJobDetailResponseDataFromJson(PatrolJobDetailResponseData data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['number'] != null) {
		data.number = json['number'].toString();
	}
	if (json['planName'] != null) {
		data.planName = json['planName'].toString();
	}
	if (json['planNumber'] != null) {
		data.planNumber = json['planNumber'].toString();
	}
	if (json['termType'] != null) {
		data.termType = json['termType'];
	}
	if (json['personnelId'] != null) {
		data.personnelId = json['personnelId'] is String
				? int.tryParse(json['personnelId'])
				: json['personnelId'].toInt();
	}
	if (json['personnel'] != null) {
		data.personnel = json['personnel'].toString();
	}
	if (json['remarks'] != null) {
		data.remarks = json['remarks'].toString();
	}
	if (json['finishTime'] != null) {
		data.finishTime = json['finishTime'].toString();
	}
	if (json['fileUrls'] != null) {
		data.fileUrls = (json['fileUrls'] as List).map((v) => v.toString()).toList().cast<String>();
	}
	if (json['startDate'] != null) {
		data.startDate = json['startDate'].toString();
	}
	if (json['endDate'] != null) {
		data.endDate = json['endDate'].toString();
	}
	if (json['status'] != null) {
		data.status = json['status'] is String
				? int.tryParse(json['status'])
				: json['status'].toInt();
	}
	if (json['closeReason'] != null) {
		data.closeReason = json['closeReason'];
	}
	if (json['customerName'] != null) {
		data.customerName = json['customerName'];
	}
	if (json['channelName'] != null) {
		data.channelName = json['channelName'];
	}
	if (json['closeUser'] != null) {
		data.closeUser = json['closeUser'];
	}
	if (json['closeUserName'] != null) {
		data.closeUserName = json['closeUserName'];
	}
	if (json['closeTime'] != null) {
		data.closeTime = json['closeTime'];
	}
	if (json['createTime'] != null) {
		data.createTime = json['createTime'].toString();
	}
	if (json['creator'] != null) {
		data.creator = json['creator'] is String
				? int.tryParse(json['creator'])
				: json['creator'].toInt();
	}
	if (json['creatorName'] != null) {
		data.creatorName = json['creatorName'].toString();
	}
	if (json['patrolItemVOS'] != null) {
		data.patrolItemVOS = (json['patrolItemVOS'] as List).map((v) => PatrolJobDetailResponseDataPatrolItemVOS().fromJson(v)).toList();
	}
	if (json['equipmentVOS'] != null) {
		data.equipmentVOS = (json['equipmentVOS'] as List).map((v) => PatrolJobDetailResponseDataEquipmentVOS().fromJson(v)).toList();
	}
	return data;
}

Map<String, dynamic> patrolJobDetailResponseDataToJson(PatrolJobDetailResponseData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['name'] = entity.name;
	data['number'] = entity.number;
	data['planName'] = entity.planName;
	data['planNumber'] = entity.planNumber;
	data['termType'] = entity.termType;
	data['personnelId'] = entity.personnelId;
	data['personnel'] = entity.personnel;
	data['remarks'] = entity.remarks;
	data['finishTime'] = entity.finishTime;
	data['fileUrls'] = entity.fileUrls;
	data['startDate'] = entity.startDate;
	data['endDate'] = entity.endDate;
	data['status'] = entity.status;
	data['closeReason'] = entity.closeReason;
	data['customerName'] = entity.customerName;
	data['channelName'] = entity.channelName;
	data['closeUser'] = entity.closeUser;
	data['closeUserName'] = entity.closeUserName;
	data['closeTime'] = entity.closeTime;
	data['createTime'] = entity.createTime;
	data['creator'] = entity.creator;
	data['creatorName'] = entity.creatorName;
	data['patrolItemVOS'] =  entity.patrolItemVOS.map((v) => v.toJson()).toList();
	data['equipmentVOS'] =  entity.equipmentVOS.map((v) => v.toJson()).toList();
	return data;
}

patrolJobDetailResponseDataPatrolItemVOSFromJson(PatrolJobDetailResponseDataPatrolItemVOS data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'].toString();
	}
	if (json['number'] != null) {
		data.number = json['number'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['requirement'] != null) {
		data.requirement = json['requirement'].toString();
	}
	if (json['result'] != null) {
		data.result = json['result'].toString();
	}
	if (json['patrolJobId'] != null) {
		data.patrolJobId = json['patrolJobId'] is String
				? int.tryParse(json['patrolJobId'])
				: json['patrolJobId'].toInt();
	}
	if (json['results'] != null) {
		data.results = json['results'];
	}
	return data;
}

Map<String, dynamic> patrolJobDetailResponseDataPatrolItemVOSToJson(PatrolJobDetailResponseDataPatrolItemVOS entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['number'] = entity.number;
	data['name'] = entity.name;
	data['requirement'] = entity.requirement;
	data['result'] = entity.result;
	data['patrolJobId'] = entity.patrolJobId;
	data['results'] = entity.results;
	return data;
}

patrolJobDetailResponseDataEquipmentVOSFromJson(PatrolJobDetailResponseDataEquipmentVOS data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['equipmentId'] != null) {
		data.equipmentId = json['equipmentId'] is String
				? int.tryParse(json['equipmentId'])
				: json['equipmentId'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['showName'] != null) {
		data.showName = json['showName'].toString();
	}
	if (json['deviceKey'] != null) {
		data.deviceKey = json['deviceKey'].toString();
	}
	if (json['productName'] != null) {
		data.productName = json['productName'].toString();
	}
	if (json['itemCompleteTime'] != null) {
		data.itemCompleteTime = json['itemCompleteTime'].toString();
	}
	if (json['itemPerson'] != null) {
		data.itemPerson = json['itemPerson'].toString();
	}
	if (json['patrolJobId'] != null) {
		data.patrolJobId = json['patrolJobId'] is String
				? int.tryParse(json['patrolJobId'])
				: json['patrolJobId'].toInt();
	}
	if (json['isComplete'] != null) {
		data.isComplete = json['isComplete'] is String
				? int.tryParse(json['isComplete'])
				: json['isComplete'].toInt();
	}
	return data;
}

Map<String, dynamic> patrolJobDetailResponseDataEquipmentVOSToJson(PatrolJobDetailResponseDataEquipmentVOS entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['equipmentId'] = entity.equipmentId;
	data['name'] = entity.name;
	data['showName'] = entity.showName;
	data['deviceKey'] = entity.deviceKey;
	data['productName'] = entity.productName;
	data['itemCompleteTime'] = entity.itemCompleteTime;
	data['itemPerson'] = entity.itemPerson;
	data['patrolJobId'] = entity.patrolJobId;
	data['isComplete'] = entity.isComplete;
	return data;
}