package com.ffii.fpsms.modules.deliveryOrder.entity

import jakarta.persistence.*
import java.time.LocalDateTime
import java.time.LocalTime
import com.ffii.fpsms.modules.deliveryOrder.enums.DoPickOrderStatus
import org.hibernate.annotations.CreationTimestamp
import org.hibernate.annotations.UpdateTimestamp
import java.time.LocalDate

@Entity
@Table(name = "do_pick_order_record")
class DoPickOrderRecord {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    var id: Long? = null
    @Column(name = "record_id")
    var recordId: Long? = null
    @Column(name = "store_id", length = 10)
    var storeId: String? = null
    
    @Column(name = "ticket_no", length = 50)
    var ticketNo: String? = null
    
    @Column(name = "pick_order_id")
    var pickOrderId: Long? = null
    
    @Column(name = "do_order_id")
    var doOrderId: Long? = null
    @Column(name = "pick_order_code", length = 50)
    var pickOrderCode: String? = null

    @Column(name = "delivery_order_code", length = 50)
    var deliveryOrderCode: String? = null

    @Column(name = "deliveryNoteCode", length = 50)
    var deliveryNoteCode: String? = null

    @Column(name = "loading_sequence")
    var loadingSequence: Int? = null
    @Enumerated(EnumType.STRING)
    @Column(name = "ticket_status")
    var ticketStatus: DoPickOrderStatus? = null
    
    @Column(name = "ticket_release_time")
    var ticketReleaseTime: LocalDateTime? = null
    
    @Column(name = "truck_id")
    var truckId: Long? = null
    
    @Column(name = "truck_departure_time")
    var truckDepartureTime: LocalTime? = null
    
    @Column(name = "shop_id")
    var shopId: Long? = null
    
    @Column(name = "handled_by")
    var handledBy: Long? = null
    
    //  新增字段声明
    @Column(name = "ticketCompleteDateTime")
    var ticketCompleteDateTime: LocalDateTime? = null
    
    @Column(name = "TruckLanceCode", length = 50)
    var truckLanceCode: String? = null
    
    @Column(name = "ShopCode", length = 50)
    var shopCode: String? = null
    
    @Column(name = "ShopName", length = 255)
    var shopName: String? = null
    
    @Column(name = "RequiredDeliveryDate")
    var requiredDeliveryDate: LocalDate? = null
    
    @CreationTimestamp
    @Column(name = "created")
    var created: LocalDateTime? = null
    
    @Column(name = "createdBy", length = 30)
    var createdBy: String? = null
    
    @Version
    var version: Int = 0
    
    @UpdateTimestamp
    @Column(name = "modified")
    var modified: LocalDateTime? = null
    
    @Column(name = "modifiedBy", length = 30)
    var modifiedBy: String? = null
    
    @Column(name = "deleted")
    var deleted: Boolean = false
    @Column(name = "handler_name", length = 100)
var handlerName: String? = null
@Column(name = "release_type", length = 100)
var releaseType: String? = null
    @Column(name = "cartonQty")
    var cartonQty: Int? = null
    // Default constructor for Hibernate
    constructor()
    
    // Constructor for creating new instances
    constructor(
        recordId: Long?,
        storeId: String,
        ticketNo: String,
        ticketStatus: DoPickOrderStatus,
        truckId: Long? = null,
        truckDepartureTime: LocalTime? = null,
        pickOrderId: Long? = null,
        doOrderId: Long? = null,
        ticketReleaseTime: LocalDateTime? = null,
        shopId: Long? = null,
        handlerName: String? = null,
        handledBy: Long? = null,
        ticketCompleteDateTime: LocalDateTime? = null,
        truckLanceCode: String? = null,
        shopCode: String? = null,
        shopName: String? = null,
        requiredDeliveryDate: LocalDate? = null,
        createdBy: String? = null,
        modifiedBy: String? = null,
        pickOrderCode: String? = null,
        deliveryOrderCode: String? = null,
        deliveryNoteCode: String? = null,
        loadingSequence: Int? = null,
    ) {
        this.recordId= recordId
        this.storeId = storeId
        this.ticketNo = ticketNo
        this.pickOrderId = pickOrderId
        this.doOrderId = doOrderId
        this.ticketReleaseTime = ticketReleaseTime
        this.ticketStatus = ticketStatus
        this.truckId = truckId
        this.truckDepartureTime = truckDepartureTime
        this.shopId = shopId
        this.handledBy = handledBy
        this.ticketCompleteDateTime = ticketCompleteDateTime
        this.handlerName = handlerName
        this.truckLanceCode = truckLanceCode
        this.shopCode = shopCode
        this.shopName = shopName
        this.requiredDeliveryDate = requiredDeliveryDate
        this.createdBy = createdBy
        this.modifiedBy = modifiedBy
        this.pickOrderCode = pickOrderCode
        this.deliveryOrderCode = deliveryOrderCode
        this.deliveryNoteCode = deliveryNoteCode
        this.loadingSequence = loadingSequence
    }
}