package com.ffii.fpsms.modules.pickOrder.entity

import com.ffii.core.entity.BaseEntity
import jakarta.persistence.*
import jakarta.validation.constraints.Size
import java.time.LocalDateTime
import java.time.LocalTime

@Entity
@Table(name = "truck_lane_schedule_line")
open class TruckLaneScheduleLine : BaseEntity<Long>() {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "scheduleId", nullable = false)
    open var schedule: TruckLaneSchedule? = null

    @Enumerated(EnumType.STRING)
    @Column(name = "lineAction", nullable = false, length = 20)
    open var lineAction: TruckLaneScheduleLineAction = TruckLaneScheduleLineAction.MOVE

    @Column(name = "truckRowId")
    open var truckRowId: Long? = null

    @field:Size(max = 50)
    @Column(name = "shopCode", length = 50)
    open var shopCode: String? = null

    @field:Size(max = 255)
    @Column(name = "shopName", length = 255)
    open var shopName: String? = null

    @Column(name = "shopId")
    open var shopId: Long? = null

    @field:Size(max = 100)
    @Column(name = "fromTruckLanceCode", length = 100)
    open var fromTruckLanceCode: String? = null

    @field:Size(max = 255)
    @Column(name = "fromRemark", length = 255)
    open var fromRemark: String? = null

    @field:Size(max = 10)
    @Column(name = "fromStoreId", length = 10)
    open var fromStoreId: String? = null

    @field:Size(max = 100)
    @Column(name = "toTruckLanceCode", nullable = false, length = 100)
    open var toTruckLanceCode: String? = null

    @field:Size(max = 255)
    @Column(name = "toRemark", length = 255)
    open var toRemark: String? = null

    @field:Size(max = 10)
    @Column(name = "toStoreId", nullable = false, length = 10)
    open var toStoreId: String? = null

    @field:Size(max = 255)
    @Column(name = "toDistrictReference", length = 255)
    open var toDistrictReference: String? = null

    @Column(name = "toLoadingSequence")
    open var toLoadingSequence: Int? = null

    @Column(name = "departureTime")
    open var departureTime: LocalTime? = null

    @Column(name = "logisticId")
    open var logisticId: Long? = null

    @Enumerated(EnumType.STRING)
    @Column(name = "lineStatus", nullable = false, length = 20)
    open var lineStatus: TruckLaneScheduleLineStatus = TruckLaneScheduleLineStatus.PENDING

    @field:Size(max = 2000)
    @Column(name = "errorMessage", length = 2000)
    open var errorMessage: String? = null

    @Column(name = "appliedAt")
    open var appliedAt: LocalDateTime? = null
}
