package com.jasamedika.medifirst2000.dao;

import java.util.List;
import java.util.Map;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.jasamedika.medifirst2000.entities.HistoriUsulanRincianKegiatan;

@Repository("historiUsulanRincianKegiatanDao")
public interface HistoriUsulanRincianKegiatanDao extends PagingAndSortingRepository<HistoriUsulanRincianKegiatan, String> {
	
	@Query("select new Map(hr.noRec as norec,"
			+ "pg.id as idPegawaiPengusul,pg.namaLengkap as namaLengkapPengusul,"
			+ "hr.detailRincianKegiatan as rincianKegiatanUsulan,"
			+ "ut.id as idUraianTugas,"
			+ "pt.id as idPelaksanaanTugas,pt.pelaksanaanTugas as pelaksanaanTugas,"
			+ "rk.id as idRincianKegiatan,rk.rincianKegiatan as rincianKegiatan,"
			+ "hr.statusEnabled as statusHapus,hr.periode as periodeBerlaku,hr.satuan as satuan,"
			+ "sr.id as satuanIndikatorId,sr.satuanIndikator as satuanIndikator,"
			+ "hr.tglUsulan as tglUsulan) "
			+ "from HistoriUsulanRincianKegiatan hr "
			+ "left join hr.masterUraianTugas ut "
			+ "left join ut.pelaksanaanTugas pt "
			+ "left join hr.rincianKegiatan rk "
			+ "left join hr.satuanIndikator sr "
			+ "left join hr.pegawaiPengusul pg "
			+ "where pt.id = :idPelaksanaanTugas "
			+ "and rk.id = :idRincianKegiatan")
	List<Map<String, Object>> getHistori(@Param("idPelaksanaanTugas") Integer idPelaksanaanTugas, @Param("idRincianKegiatan") Integer idRincianKegiatan);

}
