class RepairListEntity {
  int pageNum;
  int pageCount;
  int total;
  int pageSize;
  bool hasNext;
  bool hasPrev;
  List<RepairItem> rows;

  RepairListEntity.fromJsonMap(Map<String, dynamic> map):
        pageNum = map["pageNum"],
        pageCount = map["pageCount"],
        total = map["total"],
        pageSize = map["pageSize"],
        hasNext = map["hasNext"],
        hasPrev = map["hasPrev"],
        rows = List<RepairItem>.from(map["rows"].map((it) => RepairItem.fromJsonMap(it)));

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['pageNum'] = pageNum;
    data['pageCount'] = pageCount;
    data['total'] = total;
    data['pageSize'] = pageSize;
    data['hasNext'] = hasNext;
    data['hasPrev'] = hasPrev;
    data['rows'] = rows != null ?
    this.rows.map((v) => v.toJson()).toList()
        : null;
    return data;
  }
}

class RepairItem {

  String createDate;
  String creatorId;
  String updateDate;
  String updateId;
  String id;
  String mtCompanyId;
  String liftId;
  String projectId;
  int isTrapped;
  int isCritical;
  String callerFaultDescription;
  int source;
  String callerId;
  String callerName;
  String callerTel;
  String callerDate;
  String stopDate;
  String assignTime;
  String takingTime;
  String arriveTime;
  String recoveryDate;
  String sparepart;
  String charge;
  String workerFaultDescription;
  String fieldDescription;
  String repairProcedure;
  String workerId;
  String workerTel;
  String position;
  int status;
  String readTime;
  int repairReason;
  String partsCost;
  String safetyConfirm;
  String workerId1;
  String costTotal;
  String closeReason;
  String faultPart;
  String faultReason;
  String faultHandle;
  String faultNature;
  String faultDuty;
  String mainSign;
  String secondSign;
  int hasEvaluate;
  String areaName;
  String projectName;
  String projectCode;
  String registrationCode;
  String devicePosition;
  String useCompanyCode;
  int liftCategory;
  String liftCode;
  String workerName;
  String createName;
  String liftCompanyStatus;
//  List<Object> erRecordCosts;
  int repairDiff;
  String repairDuration;
  List<FaultItem> faultParts;
  List<FaultItem> faultReasons;
  List<FaultItem> faultHandles;
  List<FaultItem> faultNatures;
  List<FaultItem> faultDuties;
  Evaluation evaluation;
  List<ErRecordImgs> erRecordImgs;

  String getLiftCategory(){
    String str = "";
    switch(liftCategory){
      case 1:
        str = "曳引梯";
        break;
      case 2:
        str = "液压梯";
        break;
      case 3:
        str = "杂物梯";
        break;
      case 4:
        str = "自动扶梯";
        break;
      case 5:
        str = "自动人行道";
        break;
    }
    return str;
  }

  RepairItem.fromJsonMap(Map<String, dynamic> map):
        createDate = map["createDate"],
        creatorId = map["creatorId"],
        updateDate = map["updateDate"],
        updateId = map["updateId"],
        id = map["id"],
        mtCompanyId = map["mtCompanyId"],
        liftId = map["liftId"],
        projectId = map["projectId"]??"",
        isTrapped = map["isTrapped"]??0,
        isCritical = map["isCritical"]??0,
        callerFaultDescription = map["callerFaultDescription"]??"",
        source = map["source"]??0,
        callerId = map["callerId"]??"",
        callerName = map["callerName"]??"",
        callerTel = map["callerTel"],
        callerDate = map["callerDate"]??"",
        stopDate = map["stopDate"]??"",
        assignTime = map["assignTime"]??"",
        takingTime = map["takingTime"]??"",
        arriveTime = map["arriveTime"]??"",
        recoveryDate = map["recoveryDate"]??"",
        sparepart = map["sparepart"],
        charge = map["charge"],
        workerFaultDescription = map["workerFaultDescription"],
        fieldDescription = map["fieldDescription"],
        repairProcedure = map["repairProcedure"],
        workerId = map["workerId"],
        workerTel = map["workerTel"],
        position = map["position"],
        status = map["status"],
        readTime = map["readTime"],
        repairReason = map["repairReason"],
        partsCost = "${map["partsCost"]}",
        safetyConfirm = map["safetyConfirm"],
        workerId1 = map["workerId1"],
        costTotal = "${map["costTotal"]}",
        closeReason = map["closeReason"],
        faultPart = map["faultPart"],
        faultReason = map["faultReason"],
        faultHandle = map["faultHandle"],
        faultNature = map["faultNature"],
        faultDuty = map["faultDuty"],
        mainSign = map["mainSign"],
        secondSign = map["secondSign"],
        hasEvaluate = map["hasEvaluate"],
        areaName = map["areaName"],
        projectName = map["projectName"],
        projectCode = map["projectCode"],
        registrationCode = map["registrationCode"],
        devicePosition = map["devicePosition"],
        useCompanyCode = map["useCompanyCode"],
        liftCategory = map["liftCategory"],
        liftCode = map["liftCode"],
        workerName = map["workerName"],
        createName = map["createName"],
        liftCompanyStatus = map["liftCompanyStatus"],
        repairDiff = map["repairDiff"],
        repairDuration = map["repairDuration"],
        faultParts = List<FaultItem>.from((map["faultParts"]??[]).map((it) => FaultItem.fromJsonMap(it))),
        faultReasons = List<FaultItem>.from((map["faultReasons"]??[]).map((it) => FaultItem.fromJsonMap(it))),
        faultHandles =List<FaultItem>.from((map["faultHandles"]??[]).map((it) => FaultItem.fromJsonMap(it))),
        faultNatures =List<FaultItem>.from((map["faultNatures"]??[]).map((it) => FaultItem.fromJsonMap(it))),
        faultDuties = List<FaultItem>.from((map["faultDuties"]??[]).map((it) => FaultItem.fromJsonMap(it))),
        evaluation = Evaluation.fromJsonMap(map["evaluation"]??{}),
        erRecordImgs = List<ErRecordImgs>.from((map["erRecordImgs"]??[]).map((it) => ErRecordImgs.fromJsonMap(it)));

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['createDate'] = createDate;
    data['creatorId'] = creatorId;
    data['updateDate'] = updateDate;
    data['updateId'] = updateId;
    data['id'] = id;
    data['mtCompanyId'] = mtCompanyId;
    data['liftId'] = liftId;
    data['projectId'] = projectId;
    data['isTrapped'] = isTrapped;
    data['isCritical'] = isCritical;
    data['callerFaultDescription'] = callerFaultDescription;
    data['source'] = source;
    data['callerId'] = callerId;
    data['callerName'] = callerName;
    data['callerTel'] = callerTel;
    data['callerDate'] = callerDate;
    data['stopDate'] = stopDate;
    data['assignTime'] = assignTime;
    data['takingTime'] = takingTime;
    data['arriveTime'] = arriveTime;
    data['recoveryDate'] = recoveryDate;
    data['sparepart'] = sparepart;
    data['charge'] = charge;
    data['workerFaultDescription'] = workerFaultDescription;
    data['fieldDescription'] = fieldDescription;
    data['repairProcedure'] = repairProcedure;
    data['workerId'] = workerId;
    data['workerTel'] = workerTel;
    data['position'] = position;
    data['status'] = status;
    data['readTime'] = readTime;
    data['repairReason'] = repairReason;
    data['partsCost'] = partsCost;
    data['safetyConfirm'] = safetyConfirm;
    data['workerId1'] = workerId1;
    data['costTotal'] = costTotal;
    data['closeReason'] = closeReason;
    data['faultPart'] = faultPart;
    data['faultReason'] = faultReason;
    data['faultHandle'] = faultHandle;
    data['faultNature'] = faultNature;
    data['faultDuty'] = faultDuty;
    data['mainSign'] = mainSign;
    data['secondSign'] = secondSign;
    data['hasEvaluate'] = hasEvaluate;
    data['areaName'] = areaName;
    data['projectName'] = projectName;
    data['projectCode'] = projectCode;
    data['registrationCode'] = registrationCode;
    data['devicePosition'] = devicePosition;
    data['useCompanyCode'] = useCompanyCode;
    data['liftCategory'] = liftCategory;
    data['liftCode'] = liftCode;
    data['workerName'] = workerName;
    data['createName'] = createName;
    data['liftCompanyStatus'] = liftCompanyStatus;
    data['repairDiff'] = repairDiff;
    data['repairDuration'] = repairDuration;
    data['faultParts'] = faultParts;
    data['faultReasons'] = faultReasons;
    data['faultHandles'] = faultHandles;
    data['faultNatures'] = faultNatures;
    data['faultDuties'] = faultDuties;
    data['evaluation'] = evaluation;
    data['erRecordImgs'] = erRecordImgs != null ?
    this.erRecordImgs.map((v) => v.toJson()).toList()
        : null;
    return data;
  }
}

class ErRecordImgs {

  String id;
  String erRecordId;
  String imgUrl;
  int sort;

  ErRecordImgs.fromJsonMap(Map<String, dynamic> map):
        id = map["id"],
        erRecordId = map["erRecordId"],
        imgUrl = map["imgUrl"],
        sort = map["sort"];

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = id;
    data['erRecordId'] = erRecordId;
    data['imgUrl'] = imgUrl;
    data['sort'] = sort;
    return data;
  }
}

class FaultItem {

  String id;
  String code;
  int liftCategory;
  String faultCategory;
  String faultType;
  String faultDesc;

  FaultItem.fromJsonMap(Map<String, dynamic> map):
        id = map["id"],
        code = map["code"],
        liftCategory = map["liftCategory"],
        faultCategory = map["faultCategory"],
        faultType = map["faultType"],
        faultDesc = map["faultDesc"];

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = id;
    data['code'] = code;
    data['liftCategory'] = liftCategory;
    data['faultCategory'] = faultCategory;
    data['faultType'] = faultType;
    data['faultDesc'] = faultDesc;
    return data;
  }
}

class Evaluation{
  String id;
  String liftId;
  String recordId;
  int source;
  int type;
  String advice;
  int serviceLevel;
  int starLevel;
  String imgUrl;
  String postDate;
  String userId;

  Evaluation(
      {this.id,
        this.liftId,
        this.recordId,
        this.source,
        this.type,
        this.advice,
        this.serviceLevel,
        this.starLevel,
        this.imgUrl,
        this.postDate,
        this.userId});

  Evaluation.fromJsonMap(Map<String, dynamic> json) {
    id = json['id'];
    liftId = json['liftId'];
    recordId = json['recordId'];
    source = json['source'];
    type = json['type'];
    advice = json['advice'];
    serviceLevel = json['serviceLevel'];
    starLevel = json['starLevel'];
    imgUrl = json['imgUrl'];
    postDate = json['postDate'];
    userId = json['userId'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['liftId'] = this.liftId;
    data['recordId'] = this.recordId;
    data['source'] = this.source;
    data['type'] = this.type;
    data['advice'] = this.advice;
    data['serviceLevel'] = this.serviceLevel;
    data['starLevel'] = this.starLevel;
    data['imgUrl'] = this.imgUrl;
    data['postDate'] = this.postDate;
    data['userId'] = this.userId;
    return data;
  }
}


class RepairCreateItem {
  String projectId;
  String projectName;
  String registrationCode;
  String liftId;
  String callerName;
  String callerTel;
  String callerDate;
  String callerFaultDescription;
  int isTrapped;//是否关人（0 否；1 是）
  int isCritical;//是否紧急（0 否；1 是）
  int repairReason;//急修原因（0 其他；1 停电；2 故障）

  RepairCreateItem({
    this.projectId="",
    this.projectName="",
    this.registrationCode="",
    this.liftId="",
    this.callerName="",
    this.callerTel="",
    this.callerDate="",
    this.callerFaultDescription="",
    this.isTrapped=0,
    this.isCritical=0,
    this.repairReason=0,
  });
}