package com.lukouguoji.module_base.bean

import androidx.databinding.Bindable
import androidx.databinding.ObservableBoolean
import com.lukouguoji.module_base.BR
import com.lukouguoji.module_base.interfaces.ICheck
import com.lukouguoji.module_base.ktx.noNull
import dev.utils.DevFinal
import dev.utils.common.DateUtils

class GncCunFangBean : ICheck {
    var activited: String = "" // 0
    var allocationStatus: String = "" // 0
    var boardType: String = "" // null
    var carId: String = "" // 304
    var carWeight: String = "" // null
    var cargoType: String = "" // M
    var cargoWeight: String = "" // 350
    var carrier: String = "" // MU

    // 板车状态-0未复磅、1已复磅
    var checkFlag: String = "" // null
    val checkFlagName: String
        get() {
            return when (checkFlag) {
                "0" -> "未复磅"
                "1" -> "已复磅"
                "2" -> "二次复磅"
                else -> ""
            }
        }
    var copDate: String = "" // null
    var copId: String = "" // null
    var driver: String = "" // null
    var estimatedTakeOff: String = "" // null
    val estimatedTakeOffHM: String
        get() {
            return DateUtils.parseString(
                estimatedTakeOff,
                DevFinal.TIME.yyyyMMddHHmmss_HYPHEN,
                "HH:mm"
            ).noNull(estimatedTakeOff)
        }
    // 计划起飞时间
    var scheduledTackOff: String = ""

    val scheduledTackOffHM: String
        get() {
            return DateUtils.parseString(
                scheduledTackOff,
                DevFinal.TIME.yyyyMMddHHmmss_HYPHEN,
                "HH:mm"
            ).noNull(scheduledTackOff)
        }
    var fclose: String = "" // 0001-01-01 00:00:00
    var fdate: String = "" // 2024-06-19
    var fdep: String = "" // null
    var fdest: String = "" // PEK
    var flight: String = "" // null
    var fno: String = "" // MU2023
    var ldRemark: String = "" // null
    var location: String = "" // null
    var mailWeight: String = "" // null
    var maxWeight: String = "" // null
    var mcn: String = "" // null
    var netWeight: String = "" // null
    var opDate: String = "" // null
    var opId: String = "" // null
    var pc: String = "" // null
    var priority: String = "" // 1
    var remark: String = "" // null
    var spCode: String = "" // null
    var spCodeStatus: String = "" // null
    var standId: String = "" // null
    var storageArea: String = "" // null
    var tcn: String = "" // null
    var totalWeight: String = "" // null
    var transDate: String = "" // null
    var transDep: String = "" // null
    var transDest: String = "" // null
    var transFlag: String = "" // null
    var transId: String = "" // null
    var transStatus: String = "" // null
    var transType: String = "" // null
    var uld: String = "" // null
    var uldWeight: String = "" // null
    var useId: String = "" // 764700
    var username: String = "" // null
    var volume: String = "" // null

    val checked = ObservableBoolean(false)

    /**
     * 校验起飞时间是否明天
     */
    fun verifyTakeOffNextDay(): Boolean {
        if (fdate.isEmpty() || estimatedTakeOff.isEmpty()) {
            return false
        }
        val calendarFDate = DateUtils.getCalendar(fdate, DevFinal.TIME.yyyyMMdd_HYPHEN)
        val calendarTakeOff =
            DateUtils.getCalendar(estimatedTakeOff, DevFinal.TIME.yyyyMMddHHmmss_HYPHEN)
        return DateUtils.getDay(calendarTakeOff) > DateUtils.getDay(calendarFDate)
    }

    override fun getCheckObservable() = checked
}