//
//  ResponseModel.swift
//  OrderScheduling
//
//  Created by 中道 on 2023/8/7.
//

import Foundation

class ResponseModel<T:Decodable> : Decodable {
    typealias data = T
    var code : Int?
    var msg : String?
    var data : T?
    var time : Int?
    var success : Bool?
    var total : Int?
}

struct CommonError : Error {
    
}

class LoginDataModel : Decodable {
    var accessToken : LoginDataAccessTokenModel
    var refreshToken : LoginDataRefreshTokenModel
    var additionalParameters : LoginDataAdditionalModel
    public class LoginDataAccessTokenModel: Decodable {
        var tokenValue : String
        var issuedAt : Double?
        var expiresAt : Double?
    }
    public class LoginDataRefreshTokenModel: Decodable {
        var tokenValue : String
        var issuedAt : Double?
        var expiresAt : Double?
    }
    public class LoginDataAdditionalModel: Decodable {
        var user_info : LoginDataAdditionalUserModel?
    }
    public class LoginDataAdditionalUserModel: Decodable {
        var userId : Int
        var phone : String?
        var name : String
        var supplierName : String
        var supplierType : Int
        var supplierId : Int
        var username : String
        var userType : String
    }
}

class OrderListDataModel: Decodable {
    var brand : String?
    var model : String?
    var vehiclePointAddress : String?
    var vehiclePointLongitude : Double?
    var vehiclePointLatitude : Double?
    var vehiclePointRemark : String?
    var juheVehicleId : Int?
    var juheVehcileName : String?
    var juheStaffName : String?
    var juheStaffPhone : String?
    var juheSupplierId : Int?
    var destinationAddress : String?
    var positionEnvironment : PositionEnvironmentModel?
    var destinationLongitude : Double?
    var destinationLatitude : Double?
    var destinationRemark : String?
    var appointTime : String?
    var contractName : String
    var taskServiceName : String
    var taskOrderStatusString : String?
    var taskOrderStatus : Int?
    var orderCode : String
    var taskCode : String
    var createTime : String
    var driverName : String?
    var driverPhone : String?
    var environmentPic : String?
    var userOrderId : Int
    var taskOrderId : Int
    var taskFlowId : Int
    var userPhone : String?
    var auditFailReason : String?
    var isSupplierSettle : SupplierSettleModel?
    var supplierSettleRatio : SupplierSettleRatioModel?
    /// 案件类型  0 传统案件 1 聚合派工
    var schedulingFinalRule : Int?
    var showAppealBtn : Bool?
    var taskVehicleId : Int?
    class SupplierSettleModel : Decodable {
        var code : Int
        var label : String
    }
    class SupplierSettleRatioModel : Decodable {
        var code : Int
        var label : String
    }
    class PositionEnvironmentModel : Decodable {
        var code : Int
        var label : String
    }
    enum IsSupplierSettleEnum : Int,Decodable {
        case NO = 0
        case YES = 1
    }
}

enum VehicleStatusCodeEnum : Int, Decodable {
    case offLine = 1
    case onLine = 2
    case lostConnection = 3
    case leisure = 4
    case busy = 6
    case BuyBusy = 5
}

class VehicleStatusModel : Decodable {
    var code : Int
    var label : String
}

class OnlineStatusModel : Decodable {
    var code : Int
    var label : String
    enum OnlineStatusCodeEnum : Int, Decodable {
        case offLine = 1
        case onLine = 2
        case lostConnection = 3
        case leisure = 4
        case busy = 6
        case BuyBusy = 5
    }
}

class DispatchVehicleListDataModel : Decodable {
    var driverId : Int
    var vehicleId : Int
    var vehicleName : String?
    var driverName : String?
    var driverPhone : String?
    var lon : String?
    var lat : String?
    var vehicleStatus : VehicleStatusModel?
    var onlineStatus : OnlineStatusModel?
    var distance : Double?
    var vehicleTypeStr : String?
    var zIndex : Int? = 0
    var isSelected : Bool? = false
}

class ToDoMessageCountDataModel : Decodable {
    var messageCount : Int
    var toDoCount : Int
}

public class VehicleMonitorListDataModel : Decodable {
    var vehicleMonitorCount : VehicleMonitorListCountModel
    var rosterList : [ItemModel]
    var onLineList : [ItemModel]
    var lostConnectionList : [ItemModel]
    var leisureList : [ItemModel]
    var busyList : [ItemModel]
    var alarmList : [ItemModel]
    
    class VehicleMonitorListCountModel: Decodable {
        var rosterCount : Int
        var onLineCount : Int
        var lostConnectionCount : Int
        var leisureCount : Int
        var busyCount : Int
        var alarmCount : Int
    }
    public class ItemModel : Decodable {
        var vehicleId : Int?
        var vehicleName : String?
        var driverId : Int
        var driverName : String?
        var driverPhone : String?
        var vehicleType : String?
        var terminalType : String?
        var vehicleStatus : VehicleStatusModel?
        var onlineStatus : OnlineStatusModel?
        var alarmType : AlarmType?
        var rosterStartTime : String?
        var rosterEndTime : String?
        var rosterType : String?
        var endTime : String?
        var startTime : String?
        var lat : String?
        var lon : String?
        var orderCode : String?
        var serviceName : String?
        var taskStatusString : String?
        var workingCount : Int? = 0
        var shouldShowWorkingCount : Bool {
            if let workingCount, workingCount > 1 {
                return true
            }
            return false
        }
        var vehicleTypeStr : String?
        var taskList : [TaskModel]?
        var isSelected : Bool? = false
        var zIndex : Int? = 0
        var number : String?
        public enum TerminalTypeEnum : String,Decodable {
            case APP = "APP"
            case GPS = "GPS"
        }
        
        public class AlarmType : Decodable {
            var code : Int
            var label : String
        }
    }
    
    public class TaskModel : Decodable {
        var userOrderId : Int
        var orderCode : String
        var serviceId : Int
        var serviceName : String
        var taskOrderId : Int
        var taskVehicleId : Int
        var taskStatus : Int
        var taskStatusString : String
        var flowId : Int
        var vehiclePointLongitude : Double?
        var vehiclePointLatitude : Double?
        var vehiclePointAddress : String?
        var destinationLongitude : Double?
        var destinationLatitude : Double?
        var destinationAddress : String?
        var lat : String?
        var lon : String?
    }
}

public class OrderPhotoListDataModel : Decodable {
    var taskStatus : Int
    var taskStatusString : String
    var photoList : [PhotoList]
    class PhotoList : Decodable {
        var tag : String
        var imageTitle : String
        var photoUrl : String?
        var uploadImage : Data?
        var taskStatus : Int?
    }
}

public class GeneralInfoDataModel : Decodable {
    var userId : Int
    var icon : String?
    var phone : String?
    var supplierId : Int
    var supplierName : String
    var vehicleCount : Int?
    var driverCount : Int?
    var addressLat : Double?
    var addressLon : Double?
}

public class NeedConfirmPersonInfoDataModel : Decodable {
}

public class JudgeIfNeedConfirmDataModel : Decodable {
    var needConfirm : Bool?
    var count : Int?
    var isLast : Bool?
}

public class DispatchAppH5UrlDataModel : Decodable {
    var todoList : String?
    var workOrderReconciliation : String
    var vehicleManage : String
    var driverManage : String
    var invoicingNotify : String
    var reporting : String
    var reportingList : String
    var supplySettlement : String
    var workOrderDetail : String
    var trainDocment : String
    var docmentList : String
    var newTrainingList : String
    var kpiIndex : String
    var batteryList : String
    var invoiceListInfo : String
    var indexList : String
    var reportIndex : String
    var vehicleAlarmList : String
    var vehicleAlarmDetail : String
    var kpiCaseNew : String
    var managerPeople : String
    var gjUrl : String
}

public class UpdateVersionDataModel : Decodable {
    var newAppVersion : String?
    var update : Int?
    var description : String?
    public enum ForceUpdate : Int {
        case force = 1
    }
}

public class MessageReminderListDataModel : Decodable {
    var id : Int
    var msgType : MsgType
    class MsgType : Decodable {
        var code : Int
        var label : String
    }
    var title : String
    var titleContent : String?
    var titleColor : String
    var content : String?
    var imgPath : String?
    var createTime : String
    var hasRead : HasRead
    class HasRead : Decodable {
        var code : HasReadEnum
        var label : String
    }
    enum HasReadEnum : Int,Decodable {
        case NO = 0
        case YES = 1
    }
}

public class UserOperationPermissionsDataModel : Decodable {
    enum DataEnum : String,Decodable {
        case rejectDispatchHandle = "rejectDispatchHandle"
        case acceptDispatchHandle = "acceptDispatchHandle"
        case waitdispatchBtn = "waitdispatchBtn"
        case waitModifyDispatchBtn = "waitModifyDispatchBtn"
        case dealWith = "dealWith"
        case supplierRemarkBtn = "supplierRemarkBtn"
        case supplierAuditEditCostBtn = "supplierAuditEditCostBtn"
        case supplierAuditUploadPhotoBtn = "supplierAuditUploadPhotoBtn"
    }
}

public class AppPushRecordListDataModel : Decodable {
    var id : Int?
    var orderId : Int?
    var orderCode : String?
    var supplierId : Int?
    var appType : Int?
    var pushType : String?
    var pushPayload : String?
    var pushPayloadObj : AppPushRecordListDataPayloadModel?
    var regId : String?
    var deviceId : String?
    var pushResult : String?
    var pushState : Int?
    var pushTime : String?
    var handleTime : String?
    var handleUser : String?
    public class AppPushRecordListDataPayloadModel : Decodable {
        var id : Int?
        var userOrderId : Int?
        var taskOrderId : Int?
        var cancelButtonText : String?
        var confirmButtonText : String?
        var title : String?
        var content : String?
    }
}

public class ConfigByCodeDataModel : Decodable {
    var bannerConfig : [ConfigByCodeBannerModel]?
    var supplierAppIsUserNewReport : Bool?
    public class ConfigByCodeBannerModel : Decodable {
        var linkUrl : String?
        var bannerIcon : String?
        var openType : Int?
    }
}

public class JumpPageDataModel : Decodable {
    var jump : Bool?
    var title : String?
    var url : String?
    var content : String?
}

public class AlarmListDataModel : Decodable {
    var vehicleName : String?
    var alarmTypeString : String?
    var code : String?
}

public class GetAlarmByCodeDataModel : Decodable {
    var imei : String?
    var channel : Int?
    var startTime : String?
    var endTime : String?
    var vehicleId : Int?
}

public class GetVideoUrlDataModel : Decodable {
    var channelList : [String]?
    var realtimeList : [String]?
}

public class GetAppealDataModel : Decodable {
    var appealReason : String?
}

public class SaveAppealModel : Decodable {
 
}

public class VehicleMonitorInfoDataModel : Decodable {
    var leftTimeB : Double?
    var leftTimeC : Double?
    var distance : Double?
    var mileageBc : Double?
    var contractName : String?
    var organizeName : String?
    var organizeAbbrName : String?
}
