package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jasamedika.medifirst2000.base.BaseTransaction;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.CascadeType.ALL;
import static javax.persistence.FetchType.LAZY;

@Getter
@Setter
@Entity
@Table(name = "IpsrsPreventiveMaintenance_T")
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class IpsrsPreventiveMaintenance extends BaseTransaction {

	@ManyToOne(fetch = LAZY)
	@Caption(value = "Registrasi Aset")
	@JoinColumn(name = "ObjectRegistrasiAsetFk")
	private RegistrasiAset registrasiAset;

	@Column(name = "ObjectRegistrasiAsetFk", columnDefinition = "CHAR(32)", insertable = false, updatable = false)
	private String registrasiAsetId;

	@ManyToOne(fetch = LAZY)
	@Caption(value = "Pegawai")
	@JoinColumn(name = "ObjectPegawaiFk")
	private Pegawai pegawai;

	@Column(name = "ObjectPegawaiFk", insertable = false, updatable = false)
	private Integer pegawaiId;

	@Caption(value = "Tanggal")
	@Column(name = "Tanggal", nullable = false)
	private String tanggal;

	@Caption(value = "Teknisi Pendamping")
	@Column(name = "TeknisiPendamping")
	private String teknisiPendamping;

	@Caption(value = "Catatan")
	@Column(name = "Catatan")
	private String catatan;

	@JsonBackReference
	@OneToMany(cascade = ALL, fetch = LAZY, mappedBy = "ipsrsPreventiveMaintenance")
	private Set<IpsrsPemeriksaan> ipsrsPemeriksaan = new HashSet<>();

	@Caption(value = "Kebutuhan Alat Catu Tegangan")
	@Column(name = "KebutuhanAlatCatuTegangan")
	private Float kebutuhanAlatCatuTegangan;

	@Caption(value = "Kebutuhan Alat Temperatur Ruangan")
	@Column(name = "KebutuhanAlatTemperaturRuangan")
	private Float kebutuhanAlatTemperaturRuangan;

	@Caption(value = "Kebutuhan Alat Kelembaban Ruangan")
	@Column(name = "KebutuhanAlatKelembabanRuangan")
	private Float kebutuhanAlatKelembabanRuangan;

	@Caption(value = "Terukur Catu Tegangan")
	@Column(name = "TerukurCatuTegangan")
	private Float terukurCatuTegangan;

	@Caption(value = "Terukur Temperatur Ruangan")
	@Column(name = "TerukurTemperaturRuangan")
	private Float terukurTemperaturRuangan;

	@Caption(value = "Terukur Kelembaban Ruangan")
	@Column(name = "TerukurKelembabanRuangan")
	private Float terukurKelembabanRuangan;

	@ManyToOne(fetch = LAZY)
	@Caption(value = "Rekanan")
	@JoinColumn(name = "ObjectRekananFk")
	private Rekanan rekanan;

	@Column(name = "ObjectRekananFk", insertable = false, updatable = false)
	private Integer rekananId;

	@Caption(value = "Teknisi Luar")
	@Column(name = "TeknisiLuar")
	private String teknisiLuar;

	@Caption(value = "Jenis Preventive")
	@Column(name = "JenisPreventive")
	private String jenisPreventive;

	@Caption(value = "Jenis Penjadwalan")
	@Column(name = "JenisPenjadwalan")
	private Integer jenisPenjadwalan;

	@Caption(value = "NoRec Penjadwalan")
	@Column(name = "NoRecPenjadwalan")
	private String noRecPenjadwalan;

	@Caption(value = "TglPreventive")
	@Column(name = "TglPreventive")
	private Date tglPreventive;

}
