package cn.lihongjie.coal.acAppointment.dto;

import cn.lihongjie.coal.acDevice.dto.AcDeviceDto;
import cn.lihongjie.coal.base.dto.OrgCommonDto;

import io.hypersistence.utils.hibernate.type.array.ListArrayType;

import jakarta.persistence.ManyToOne;

import lombok.Data;

import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.Type;

import java.util.List;

@Data
public class AcAppointmentDto extends OrgCommonDto {


    @ManyToOne
    private AcDeviceDto device;
    
    @Comment("预约开始时间")
    private java.time.LocalDateTime startTime;

    @Comment("预约结束时间")
    private java.time.LocalDateTime endTime;

    @Comment("车牌号")
    private String plateNo;

    @Comment("姓名")
    private String driverName;

    @Comment("联系电话")
    private String driverPhone;

    @Comment("事由")
    private String reason;

    @Formula("(select array_agg(d.id) from t_ac_device_data d where d.plate_no = plate_no and d.pass_time between start_time and end_time)")
    @Type(ListArrayType.class)
    private List<String> acDeviceDataIds;


    @Comment("下发时间")
    private java.time.LocalDateTime sendTime;

    @Comment("下发状态")
    private String sendStatus;

    @Formula(
            "(select i.name\n"
            + "from t_dictionary d,\n"
            + "     t_dictionary_item i\n"
            + "where d.id = i.dictionary_id\n"
            + "  and d.code = 'common.step.status'\n"
            + "  and i.code = send_status)")
    private String sendStatusName;

    @Comment("下发完成时间")
    private java.time.LocalDateTime sendFinishTime;




    @Comment("删除时间")
    private java.time.LocalDateTime deleteTime;


    @Comment("下发状态")
    private String deleteStatus;

    @Formula(
            "(select i.name\n"
            + "from t_dictionary d,\n"
            + "     t_dictionary_item i\n"
            + "where d.id = i.dictionary_id\n"
            + "  and d.code = 'common.step.status'\n"
            + "  and i.code = delete_status)")
    private String deleteStatusName;

    @Comment("删除完成时间")
    private java.time.LocalDateTime deleteFinishTime;
    private String archiveStatus;

    private String archiveStatusName;

    @Comment("预约状态")
    private String appointmentStatus;

    @Formula(
            "(select i.name\n"
            + "from t_dictionary d,\n"
            + "     t_dictionary_item i\n"
            + "where d.id = i.dictionary_id\n"
            + "  and d.code = 'appointment.status'\n"
            + "  and i.code = appointment_status)")
    private String appointmentStatusName;
}
