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.NeracaLimbah; /** * Repository class for Departemen * * @author Roberto */ @Repository("NeracaLimbahDao") public interface NeracaLimbahDao extends PagingAndSortingRepository { @Query("select new map(" + "coalesce(p.noRec,null) as noRec," + "to_char(p.periodeAwal,'yyyy-MM-dd') as periodeAwal," + "to_char(p.periodeAhir,'yyyy-MM-dd') as periodeAhir," + "coalesce(p.residu,0.0) as residu," + "coalesce(p.jumlahYangBelumTerkelola,0.0) as jumlahYangBelumTerkelola," + "coalesce(p.kinerjaPengelolaan,0.0) as kinerjaPengelolaan," + "coalesce(p.residu+p.kinerjaPengelolaan,0.0) as totaljmlygtersisa," + "coalesce(p.Catatan,'-') as catatan, " + "coalesce(p.totalLimbahMasuk,0.0) as totalLimbahMasuk " + ")from NeracaLimbah p " + "where p.noRec=:noRec ") Map findNeracaById(@Param("noRec") String noRec); @Query("select new map(n.noRec as noRec, " + " to_char(n.periodeAwal,'yyyy-MM-dd') as periodeAwal, " + " to_char(n.periodeAhir,'yyyy-MM-dd') as periodeAhir, " + " coalesce(n.residu,0.0) as residu, " + " coalesce(n.jumlahYangBelumTerkelola,0.0) as jumlahYangBelumTerkelola, " + " coalesce(n.kinerjaPengelolaan,0.0) as kinerjaPengelolaan, " + " coalesce(n.residu+n.kinerjaPengelolaan,0.0) as totaljmlygtersisa, " + " coalesce(n.Catatan,'-') as catatan, n.totalLimbahMasuk as totalLimbahMasuk) " + " from NeracaLimbah n where n.noRec=:noRec") Map getNeracaByNoRec(@Param("noRec")String noRec); @Query("select new map(" + "p.noRec as noRec," + "j.jenisLimbahB3masuk as jenisLimbahB3Masuk," + "p.jumlah as jumlah" + ")" + "from DetailJenisLimbah p " + "left join p.jenisLimbahB3Masuk j " + "where p.neracaLimbah.noRec=:noRec") List> getNeracaLimbahByNoRec(@Param("noRec") String noRec); @Query("select new map(d.noRec as noRec, " + " coalesce(d.jenisLimbahYangDikelola,'-') as jenisLimbahYangDikelola, " + " coalesce(d.jumlah,0.0) as jumlah, " + " coalesce(p.name,'-') as perlakuan, " + " coalesce(z.name,'-') as perizinan) " + " from DetailPerlakuan d " + " left join d.perlakuan p " + " left join d.neracaLimbah n " + " left join d.perizinanLimbah z " + " where n.noRec=:noRec") List> getNeracaLimbahPerlakuanByNoRec(@Param("noRec")String noRec); @Query("select new map(j.id as id, j.jenisLimbahB3masuk as jenisLimbahB3masuk," + " coalesce(sum(s.qtyproduk),0.0) as ttlqtymasuk)" + " from StrukPelayanan s inner join " + " s.jenisLimbahB3Masuk j where " + " date(s.tglstruk) between date(:startDate) and date(:endDate) " + " and (s.statusEnabled is null or s.statusEnabled is true) "+ " group by j.id,j.jenisLimbahB3masuk") List> getB3MasukJenisLimbahByPeriode(@Param("startDate")String startDate, @Param("endDate")String endDate); @Query("select coalesce(SUM(s.qtyproduk),0.0) as total " + " from StrukPelayanan s inner join s.jenisLimbahB3Masuk j " + " where date(s.tglstruk) between date(:startDate) and date(:endDate) "+ " and (s.statusEnabled is null or s.statusEnabled is true) ") Double getTotalB3MasukByPeriode(@Param("startDate") String startDate, @Param("endDate") String endDate); @Query("select new map(p.id as id, p.name as Perlakuan, " + " sum(l.jumlahLimbahB3Keluar) as ttlqtyKeluar) " + " from LimbahB3Keluar l " + " inner join l.perlakuan p " + " inner join l.jenisLimbahB3Masuk j where " + " date(l.tanggal) between date(:startDate) and date(:endDate) group by p.id, p.name") List> getB3KeluarByPerlakuan(@Param("startDate")String startDate, @Param("endDate")String endDate); @Query("select coalesce(sum(l.jumlahLimbahB3Keluar),0.0) as ttlqtyKeluar " + " from LimbahB3Keluar l " + " inner join l.perlakuan p " + " inner join l.jenisLimbahB3Masuk j where " + " date(l.tanggal) between date(:startDate) and date(:endDate) "+ " and (l.statusEnabled is null or l.statusEnabled is true) ") Double getTotalB3KeluarByPeriode(@Param("startDate")String startDate, @Param("endDate")String endDate); @Query("select new Map(jenisLimbah.jenisLimbahB3masuk as jenisAwalLimbah, "+ "limbahMasuk.jumlah as jumlah) "+ "from NeracaLimbah neracaLimbah "+ "left join neracaLimbah.detailJenisLimbah limbahMasuk "+ "left join limbahMasuk.jenisLimbahB3Masuk jenisLimbah "+ "where neracaLimbah.noRec = :noRec "+ "and (neracaLimbah.statusEnabled is null or neracaLimbah.statusEnabled is true) ") List> getReportLimbahB3Masuk(@Param("noRec")String noRec); @Query("select new Map(perlakuan.name as perlakuan, "+ "limbahKeluar.jumlah as jumlah, "+ "perizinan.name as perizinan) "+ "from NeracaLimbah neracaLimbah "+ "left join neracaLimbah.detailPerlakuan limbahKeluar "+ "left join limbahKeluar.perlakuan perlakuan "+ "left join limbahKeluar.perizinanLimbah perizinan "+ "where neracaLimbah.noRec = :noRec "+ "and (neracaLimbah.statusEnabled is null or neracaLimbah.statusEnabled is true) ") List> getReportLimbahB3Keluar(@Param("noRec")String noRec); @Query("select new Map(neracaLimbah.residu as residu, "+ "neracaLimbah.jumlahYangBelumTerkelola as totalJumlahSisa, "+ "neracaLimbah.kinerjaPengelolaan as persenKinerja) "+ "from NeracaLimbah neracaLimbah "+ "where neracaLimbah.noRec = :noRec") Map getReportNeracaLimbahB3(@Param("noRec")String noRec); }