package cn.lihongjie.coal.deviceWorkOrder.entity;

import cn.lihongjie.coal.base.entity.OrgCommonEntity;
import cn.lihongjie.coal.device.entity.DeviceEntity;
import cn.lihongjie.coal.deviceWorkOrderDetail.entity.DeviceWorkOrderDetailEntity;
import cn.lihongjie.coal.user.entity.UserEntity;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;

import lombok.Data;

import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Comment;

import java.time.LocalDateTime;
import java.util.List;

@Data
@Entity

@jakarta.persistence.Table(indexes = @jakarta.persistence.Index(name ="idx_device_work_order_org_id", columnList = "organization_id"))

public class DeviceWorkOrderEntity extends OrgCommonEntity {



    @Comment("提单人名称")
    private String proposerName;

    @Comment("提单人联系方式")
    private String proposerContact;


    @ManyToOne
    private DeviceEntity device;

    @Comment("工单时间-开始时间")
    private LocalDateTime time;


    @Comment("工单时间-结束时间")
    private LocalDateTime time2;

    @Comment("负责人")
    private String worker;

    @Comment("工单类型")
    private String type;

    @Comment("工单状态")
    private String orderStatus;

    @Comment("归档状态")
    @ColumnDefault("'0'")
    private String archiveStatus = "0";




    @OneToMany(mappedBy = "workOrder", cascade = {CascadeType.ALL})
    private List<DeviceWorkOrderDetailEntity> details;


    @OneToMany
    private List<UserEntity> workers;

}