import 'package:deus_app/generated/json/base/json_convert_content.dart';
import 'package:json2dart_safe/json2dart.dart';

import 'ImgVO.dart';

class PatrolJobDataResponseEntity
    with JsonConvert<PatrolJobDataResponseEntity> {
  late int code;
  late PatrolJobDataVO data;
  late String msg;
}

class PatrolJobDataVO with JsonConvert<PatrolJobDataVO> {
  late PatrolJobData query;
  late List<PatrolJobData> list;
}

class PatrolJobDetailResponseEntity
    with JsonConvert<PatrolJobDetailResponseEntity> {
  late int code;
  late PatrolJobDetailData data;
  late String msg;
}

class PatrolJobDeviceResponseData with JsonConvert<PatrolJobDeviceData> {
  late int code;
  late List<PatrolJobDeviceData> data;
  late String msg;
}

class PatrolJobItemResponseData with JsonConvert<PatrolJobItemData> {
  late int code;
  late List<PatrolJobItemData> data;
  late String msg;
}

class PatrolJobDeviceData with JsonConvert<PatrolJobDeviceData> {
  late int id;
  late String name;
  late String showName;
  late String deviceKey;
  late String itemCompleteTime;
  late String itemPerson;

  PatrolJobDeviceData(this.name, this.showName, this.deviceKey,
      this.itemCompleteTime, this.itemPerson,this.id);
}

class PatrolJobDetailData with JsonConvert<PatrolJobDetailData> {
  late String name;
  late String number;
  late String planName;
  late String planNumber;
  late int termType;
  late String startDate;
  late String endDate;
  late String personnel;
  late String finishTime;
  late int status;
  late String remark;
  late List<PatrolJobImageData> fileUrls;

  PatrolJobDetailData(
      this.name,
      this.number,
      this.planName,
      this.planNumber,
      this.termType,
      this.startDate,
      this.endDate,
      this.personnel,
      this.finishTime,
      this.status,
      this.remark);
}

class PatrolJobItemData with JsonConvert<PatrolJobItemData> {
  late String name;
  late String result;
  late int id;
  PatrolJobItemData(this.name,this.result,this.id);
}

class PatrolJobImageData with JsonConvert<PatrolJobImageData> {
  late int id;
  late String url;

  PatrolJobImageData(this.id, this.url);
}

/**
 * 巡检任务列表响应
 */
class PatrolJobResponse {
  int? code;
  PatrolJobQuery? data;
  String? msg;

  PatrolJobResponse({
    this.code,
    this.data,
    this.msg,
  });

  Map<String, dynamic> toJson() {
    return Map<String, dynamic>()
      ..put('code', this.code)
      ..put('data', this.data?.toJson())
      ..put('msg', this.msg);
  }

  PatrolJobResponse.fromJson(Map<String, dynamic> json) {
    if (json['code'] != null) {
      this.code = json.asInt('code');
    }
    if (json['data'] != null) {
      this.data = PatrolJobQuery.fromJson(json['data']);
    }
    if (json['msg'] != null) {
      this.msg = json.asString('msg');
    }
  }

  @override
  String toString(){
    return  'PatrolJobResponse{code: $code,data: $data,msg: $msg}';
  }

  static PatrolJobResponse toBean(Map<String, dynamic> json) =>
      PatrolJobResponse.fromJson(json);
}

class PatrolJobQuery {
  int? total;
  int? index;
  int? size;
  String? sortBy;
  int? sort;
  PatrolJobData? query;
  List<PatrolJobData>? patrolJobVOS;

  @override
  String toString(){
    return 'PatrolJobQuery{total: $total,index: $index,size: $size,sortBy: $sortBy,sort: $sort,query: $query,patrolJobVOS: $patrolJobVOS}';
  }

  PatrolJobQuery({
    this.total,
    this.index,
    this.size,
    this.sortBy,
    this.sort,
    this.query,
    this.patrolJobVOS,
  });

  Map<String, dynamic> toJson() {
    return Map<String, dynamic>()
      ..put('total', this.total)
      ..put('index', this.index)
      ..put('size', this.size)
      ..put('sortBy', this.sortBy)
      ..put('sort', this.sort)
      ..put('query', this.query?.toJson())
      ..put('patrolJobVOS', this.patrolJobVOS?.map((v) => v.toJson()).toList());
  }

  PatrolJobQuery.fromJson(Map<String, dynamic> json) {
    if (null != json['total']) {
      this.total = json.asInt('total');
    }
    if (null != json['index']) {
      this.index = json.asInt('index');
    }
    if (null != json['size']) {
      this.size = json.asInt('size');
    }
    if (null != json['sortBy']) {
      this.sortBy = json.asString('sortBy');
    }
    if (null != json['sort']) {
      this.sort = json.asInt('sort');
    }
    if (null != json['query']) {
      this.query = PatrolJobData.fromJson(json['query']);
    }
    if (null != json['patrolJobVOS']) {
      this.patrolJobVOS = (json['patrolJobVOS'] as List)
          .map((v) => PatrolJobData.fromJson(v))
          .toList();
    }
  }
}

class PatrolJobData {
  int? id;
  String? name;
  String? number;
  String? planName;
  String? planNumber;
  int? termType;
  int? personnelId;
  String? personnel;
  String? remarks;
  String? finishTime;
  List<FileUrls>? fileUrls;
  String? startDate;
  String? endDate;
  int? status;
  String? closeReason;
  String? customerName;
  String? channelName;
  String? closeUser;
  String? closeUserName;
  String? closeTime;
  String? createTime;
  int? creator;
  String? creatorName;
  List<PatrolItemVOS>? patrolItemVOS;
  List<EquipmentVOS>? equipmentVOS;

  @override
  String toString(){
    return 'PatrolJobData{id: $id,name: $name,number: $number,planName: $planName,planNumber: $planNumber,termType: $termType,personnelId: $personnelId,personnel: $personnel'
        ',remarks: $remarks,finishTime: $finishTime,fileUrls: $fileUrls,startDate: $startDate,endDate: $endDate,status $status,closeReson: $closeReason'
        ',customerName: $customerName,channelName: $channelName,closeUser: $closeUser,closeUserName: $closeUserName,patrolItemVOS: $patrolItemVOS,equipmentVOS: $equipmentVOS}';
  }

  PatrolJobData({
    this.id,
    this.name,
    this.number,
    this.planName,
    this.planNumber,
    this.termType,
    this.personnelId,
    this.personnel,
    this.remarks,
    this.finishTime,
    this.fileUrls,
    this.startDate,
    this.endDate,
    this.status,
    this.closeReason,
    this.customerName,
    this.channelName,
    this.closeUser,
    this.closeUserName,
    this.closeTime,
    this.createTime,
    this.creator,
    this.creatorName,
    this.patrolItemVOS,
    this.equipmentVOS,
  });

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

  PatrolJobData.fromJson(Map<String, dynamic> json) {
    if (null != json['id']) {
      this.id = json.asInt('id');
    }
    if (null != json['name']) {
      this.name = json.asString('name');
    }
    if (null != json['number']) {
      this.number = json.asString('number');
    }
    if (null != json['planName']) {
      this.planName = json.asString('planName');
    }
    if (null != json['planNumber']) {
      this.planNumber = json.asString('planNumber');
    }
    if (null != json['termType']) {
      this.termType = json.asInt('termType');
    }
    if (null != json['personnelId']) {
      this.personnelId = json.asInt('personnelId');
    }
    if (null != json['personnel']) {
      this.personnel = json.asString('personnel');
    }
    if (null != json['remarks']) {
      this.remarks = json.asString('remarks');
    }
    if (null != json['finishTime']) {
      this.finishTime = json.asString('finishTime');
    }
    if (null != json['fileUrls']) {
      this.fileUrls =
          (json['fileUrls'] as List).map((v) => FileUrls.fromJson(v)).toList();
    }
    if (null != json['startDate']) {
      this.startDate = json.asString('startDate');
    }
    if (null != json['endDate']) {
      this.endDate = json.asString('endDate');
    }
    if (null != json['status']) {
      this.status = json.asInt('status');
    }
    if (null != json['closeReason']) {
      this.closeReason = json.asString('closeReason');
    }
    if (null != json['customerName']) {
      this.customerName = json.asString('customerName');
    }
    if (null != json['channelName']) {
      this.channelName = json.asString('channelName');
    }
    if (null != json['closeUser']) {
      this.closeUser = json.asString('closeUser');
    }
    if (null != json['closeUserName']) {
      this.closeUserName = json.asString('closeUserName');
    }
    if (null != json['closeTime']) {
      this.closeTime = json.asString('closeTime');
    }
    if (null != json['createTime']) {
      this.createTime = json.asString('createTime');
    }
    if (null != json['creator']) {
      this.creator = json.asInt('creator');
    }
    if (null != json['creatorName']) {
      this.creatorName = json.asString('creatorName');
    }
    if (null != json['patrolItemVOS']) {
      this.patrolItemVOS = (json['patrolItemVOS'] as List)
          .map((v) => PatrolItemVOS.fromJson(v))
          .toList();
    }
    if (null != json['equipmentVOS']) {
      this.equipmentVOS = (json['equipmentVOS'] as List)
          .map((v) => EquipmentVOS.fromJson(v))
          .toList();
    }
  }
}

/**
 * 巡检任务实体类
 */

class PatrolItemVOS {
  int? id;
  String? number;
  String? name;
  String? requirement;
  String? result;
  int? patrolJobId;
  String? results;

  @override
  String toString(){
    return 'PatrolItemVOS{id: $id,number: $number,name: $name,requirement: $requirement,result: $result,patrolJobId: $patrolJobId,results: $results}';
  }

  PatrolItemVOS({
    this.id,
    this.number,
    this.name,
    this.requirement,
    this.result,
    this.patrolJobId,
    this.results,
  });

  Map<String, dynamic> toJson() {
    return Map<String, dynamic>()
      ..put('id', this.id)
      ..put('number', this.number)
      ..put('name', this.name)
      ..put('requirement', this.requirement)
      ..put('result', this.result)
      ..put('patrolJobId', this.patrolJobId)
      ..put('results', this.results);
  }

  PatrolItemVOS.fromJson(Map<String, dynamic> json) {
    if (null != json['id']) {
      this.id = json.asInt('id');
    }
    if (null != json['number']) {
      this.number = json.asString('number');
    }
    if (null != json['name']) {
      this.name = json.asString('name');
    }
    if (null != json['requirement']) {
      this.requirement = json.asString('requirement');
    }
    if (null != json['result']) {
      this.result = json.asString('result');
    }
    if (null != json['patrolJobId']) {
      this.patrolJobId = json.asInt('patrolJobId');
    }
    if (null != json['results']) {
      this.results = json.asString('results');
    }
  }
}

class EquipmentVOS {
  int? id;
  int? equipmentId;
  String? name;
  String? showName;
  String? deviceKey;
  String? productName;
  String? itemCompleteTime;
  String? itemPerson;
  int? patrolJobId;
  int? isComplete;

  @override
  String toString(){
    return 'EquipmentVOS{id: $id,equipmentId: $equipmentId,name: $name,showName: $showName, deviceKey: $deviceKey,productName: $productName, itemCompleteTime: $itemCompleteTime,itemPerson: $itemPerson,patrolJobId: $patrolJobId,isComplete: $isComplete}';
  }

  EquipmentVOS({
    this.id,
    this.equipmentId,
    this.name,
    this.showName,
    this.deviceKey,
    this.productName,
    this.itemCompleteTime,
    this.itemPerson,
    this.patrolJobId,
    this.isComplete,
  });

  Map<String, dynamic> toJson() {
    return Map<String, dynamic>()
      ..put('id', this.id)
      ..put('equipmentId', this.equipmentId)
      ..put('name', this.name)
      ..put('showName', this.showName)
      ..put('deviceKey', this.deviceKey)
      ..put('productName', this.productName)
      ..put('itemCompleteTime', this.itemCompleteTime)
      ..put('itemPerson', this.itemPerson)
      ..put('patrolJobId', this.patrolJobId)
      ..put('isComplete', this.isComplete);
  }

  EquipmentVOS.fromJson(Map<String, dynamic> json) {
    if (null != json['id']) {
      this.id = json.asInt('id');
    }
    if (null != json['equipmentId']) {
      this.equipmentId = json.asInt('equipmentId');
    }
    if (null != json['name']) {
      this.name = json.asString('name');
    }
    if (null != json['showName']) {
      this.showName = json.asString('showName');
    }
    if (null != json['deviceKey']) {
      this.deviceKey = json.asString('deviceKey');
    }
    if (null != json['productName']) {
      this.productName = json.asString('productName');
    }
    if (null != json['itemCompleteTime']) {
      this.itemCompleteTime = json.asString('itemCompleteTime');
    }
    if (null != json['itemPerson']) {
      this.itemPerson = json.asString('itemPerson');
    }
    if (null != json['patrolJobId']) {
      this.patrolJobId = json.asInt('patrolJobId');
    }
    if (null != json['isComplete']) {
      this.isComplete = json.asInt('isComplete');
    }
  }
}
