package com.xw.yunwei.model import com.google.gson.annotations.SerializedName import com.xw.yunwei.extension.dateChangePattern import kotlin.math.min /** * 任务事故详情 */ data class TaskAccidentModel( /** * 任务创建人 */ @SerializedName("createBy") val createBy: String? = null, /** * 任务创建时间 */ @SerializedName("createTime") val createTime: String? = null, /** * 任务处理时限/结束时间 */ @SerializedName("endTime") val endTime: String? = null, /** * 事故类型列表(层级结构) */ @SerializedName("errorTypeList") val errorTypeList: List? = null, /** * 任务ID */ @SerializedName("id") val id: Long? = null, /** * 车牌号 */ @SerializedName("plateNumber") val plateNumber: String? = null, /** * 车辆VIN码 */ @SerializedName("vehicleVin") val vehicleVin: String? = null, /** * 任务状态 * 0 = 待到达 * 1 = 待处理 * 2 = 已完成 * 3 = 已取消 */ @SerializedName("status") val status: Int? = null, /** * 任务类别 * 1 = 常规任务 * 2 = 事故任务 */ @SerializedName("taskCategory") val taskCategory: Int? = null, /** * 任务编号 */ @SerializedName("taskCode") val taskCode: String? = null, /** * 任务描述 */ @SerializedName("taskDescription") val taskDescription: String? = null, /** * 任务描述图片(URL或Base64) */ @SerializedName("taskImage") val taskImage: String? = null, /** * 任务类型ID * 任务类别为2时:对应数据字典,多个逗号分割 * 任务类别为1时:枚举值 1-9 */ @SerializedName("taskTypeId") val taskTypeId: String? = null, /** * 任务紧急程度 * 0 = P0(最紧急) * 1 = P1 * 2 = P2 * 3 = P3(最不紧急) */ @SerializedName("taskUrgencyLevel") val taskUrgencyLevel: Int? = null, /** * 车辆编码 */ @SerializedName("vehicleCode") val vehicleCode: String? = null, /** * 车辆颜色 */ @SerializedName("vehicleColor") val vehicleColor: String? = null, /** * 车辆ID */ @SerializedName("vehicleId") val vehicleId: Long? = null, /** * 车辆纬度 */ @SerializedName("vehicleLat") val vehicleLat: Double? = null, /** * 车辆位置描述 */ @SerializedName("vehicleLocation") val vehicleLocation: String? = null, /** * 车辆经度 */ @SerializedName("vehicleLon") val vehicleLon: Double? = null, /** * 可以操作到达的配置范围,单位米 */ @SerializedName("canArriveRange") val canArriveRange: Int? = null, /** * 是否已经打开后备箱 1是 前端字段 */ val hadTrunkOpened: String? = null ) { /** * 获取所有事故类型名称列表(扁平化) */ fun getAllErrorTypeNames(): List { val names = mutableListOf() errorTypeList?.forEach { errorType -> names.add(errorType.errorName ?: "") errorType.child?.forEach { child -> names.add(child.errorName ?: "") } } return names.filter { it.isNotEmpty() } } //是否已开启车门 fun hadOpenedDoor(): Boolean { return false } //是否已开启后备箱 fun hadOpenedTrunk(): Boolean { return hadTrunkOpened == "1" } //获取显示创建事件 fun getShowCreateTime(): String?{ return createTime?.dateChangePattern("yyyy-MM-dd HH:mm:ss","yyyy/MM/dd HH:mm:ss") } //获取显示车身编码 fun getShowVehicleCode(maxLength: Int): String { return vehicleCode?.let { if (it.isNotEmpty()) { it.substring(0, min(it.length, maxLength)) } else { "" } } ?: "" } } /** * 事故类型实体 * 目前作为临时表存储,后续可能改为后台配置或数据字典 */ data class XpErrorType( /** * 子事故类型列表 */ @SerializedName("child") val child: List? = null, /** * 记录创建人(前端忽略) */ @SerializedName("createBy") val createBy: String? = null, /** * 记录创建时间(前端忽略) */ @SerializedName("createTime") val createTime: String? = null, /** * 是否删除:false-未删除,true-已删除 */ @SerializedName("deleted") val deleted: Boolean? = null, /** * 事故名称 */ @SerializedName("errorName") val errorName: String? = null, /** * 自增ID */ @SerializedName("id") val id: Long? = null, /** * 父级ID,顶级为0 */ @SerializedName("parentId") val parentId: Long? = null, /** * 记录修改人(前端忽略) */ @SerializedName("upStringBy") val upStringBy: String? = null, /** * 记录修改时间(前端忽略) */ @SerializedName("upStringTime") val upStringTime: String? = null )