puzhibing
2026-08-21 5fa94b3718b4a78a4fcea4c97652b0ef20b7de3a
app/src/main/java/com/xw/yunwei/model/TaskNormalModel.kt
@@ -1,6 +1,8 @@
package com.xw.yunwei.model
import com.google.gson.annotations.SerializedName
import com.xw.yunwei.extension.dateChangePattern
import kotlin.math.min
/**
 * 常规任务详情
@@ -145,4 +147,30 @@
     */
    @SerializedName("vehicleLon")
    val vehicleLon: Double? = null,
)
){
    //是否能够改派
    fun couldReassignment(): Boolean {
        return status != 2 && taskCategory != 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 {
                ""
            }
        } ?: ""
    }
    //获取显示操作时间
    fun getShowHandleTime(): String?{
        return handleTime?.dateChangePattern("yyyy-MM-dd HH:mm:ss","yyyy/MM/dd HH:mm:ss")
    }
}