package com.its.vms.entity;

import com.its.vms.dto.TbVmsScheduleDto;
import com.its.vms.service.VmsFormService;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 *  Entity Class
 */
@Data
@Builder
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class TbVmsSchedule implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long vmsCtlrNmbr;
    private String vmsSchType;
    private Integer vmsSchFormType;
    private Integer phase;
    private Integer vmsFormId;
    private String dsplStrtHh;
    private String dsplEndHh;
    private Integer dsplHh;
    private Long frstVmsIfscId;
    private Long secdVmsIfscId;
    private Long thirVmsIfscId;
    private Long fourVmsIfscId;
    private Long frstImgIfscId;
    private Long secdImgIfscId;
    private Long thirImgIfscId;
    private Long fourImgIfscId;
    private Long symbLibNmbr;
    private String strmAddr;
    private String useYn;
    private String dsplCngsYn;
    private Integer vmsFormTypeCd;
    private Integer vmsFormSubTypeCd;

    public TbVmsScheduleDto toDto() {
        TbVmsScheduleDto dto = TbVmsScheduleDto.builder()
                .vmsCtlrNmbr(this.vmsCtlrNmbr)
                .vmsSchType(this.vmsSchType)
                .vmsSchFormType(this.vmsSchFormType)
                .phase(this.phase)
                .vmsFormId(this.vmsFormId)
                .dsplStrtHh(this.dsplStrtHh)
                .dsplEndHh(this.dsplEndHh)
                .dsplHh(this.dsplHh)
                .frstVmsIfscId(this.frstVmsIfscId)
                .secdVmsIfscId(this.secdVmsIfscId)
                .thirVmsIfscId(this.thirVmsIfscId)
                .fourVmsIfscId(this.fourVmsIfscId)
                .frstImgIfscId(this.frstImgIfscId)
                .secdImgIfscId(this.secdImgIfscId)
                .thirImgIfscId(this.thirImgIfscId)
                .fourImgIfscId(this.fourImgIfscId)
                .symbLibNmbr(this.symbLibNmbr)
                .strmAddr(this.strmAddr)
                .useYn(this.useYn)
                .dsplCngsYn("Y".equals(this.dsplCngsYn))
                .vmsFormTypeCd(this.vmsFormTypeCd)
                .vmsFormSubTypeCd(this.vmsFormSubTypeCd)
                .dnldFormId(VmsFormService.getDnldFormNo(this.vmsFormId))
                .vmsIfscId(0L)
                .event(null)
                .build();

        // 이미지 IFSC ID도 VMS IFSC ID로 설정
        dto.setFrstImgIfscId(this.frstVmsIfscId);
        dto.setSecdImgIfscId(this.secdVmsIfscId);
        dto.setThirImgIfscId(this.thirVmsIfscId);
        dto.setFourImgIfscId(this.fourVmsIfscId);

        return dto;
    }
}
