From 33f4e7d9cb1c17bccc5590ccecbb4d545785c1e3 Mon Sep 17 00:00:00 2001 From: salmanoersabhk Date: Fri, 16 Sep 2022 20:43:47 +0700 Subject: [PATCH] Update logbook kinerja service Penyesuaian perhitungan otomatis target skor dokter menjadi periodik --- .../dao/IndeksKinerjaDokterDao.java | 12 ++++++++---- .../service/LogbookKinerjaService.java | 2 +- .../impl/IkiDanRemunerasiServiceImpl.java | 19 ++++++++++++++----- .../impl/LogbookKinerjaServiceImpl.java | 10 ++++++---- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/IndeksKinerjaDokterDao.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/IndeksKinerjaDokterDao.java index aefc9907..df190c4f 100644 --- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/IndeksKinerjaDokterDao.java +++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/dao/IndeksKinerjaDokterDao.java @@ -21,13 +21,17 @@ public interface IndeksKinerjaDokterDao extends PagingAndSortingRepository> findAll(@Param("tahun") String tahun) throws JpaSystemException; + + "where ikid.statusEnabled is true " + + "and to_char(ikid.bulan,'yyyy-MM') between :bulanAwal and :bulanAkhir") + List> findAll(@Param("bulanAwal") String bulanAwal, @Param("bulanAkhir") String bulanAkhir) + throws JpaSystemException; @Query("select new Map(ikid.unitKerjaId as unitKerjaId," + "ikid.subunitKerjaId as subunitKerjaId," + "coalesce(sum(ikid.skorDasar),0) as totalSkorDasar) " + "from IndeksKinerjaDokter ikid " - + "where ikid.statusEnabled is true " + "and to_char(ikid.bulan,'yyyy') = :tahun " + + "where ikid.statusEnabled is true " + + "and to_char(ikid.bulan,'yyyy-MM') between :bulanAwal and :bulanAkhir " + "group by ikid.unitKerjaId, ikid.subunitKerjaId " + "order by ikid.unitKerjaId, ikid.subunitKerjaId") - List> findTotalSkorByKelompokKerja(@Param("tahun") String tahun) throws JpaSystemException; + List> findTotalSkorByKelompokKerja(@Param("bulanAwal") String bulanAwal, + @Param("bulanAkhir") String bulanAkhir) throws JpaSystemException; } diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/LogbookKinerjaService.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/LogbookKinerjaService.java index b162d035..8a76af28 100644 --- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/LogbookKinerjaService.java +++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/LogbookKinerjaService.java @@ -58,7 +58,7 @@ public interface LogbookKinerjaService extends BaseVoService hitungTargetSkorLogbookDokter(String tahun) throws ParseException; + public List hitungTargetSkorLogbookDokter(String bulanAwal, String bulanAkhir) throws ParseException; public List findBobotJenisJabatan(Long periode, Integer idJabatan); diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/IkiDanRemunerasiServiceImpl.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/IkiDanRemunerasiServiceImpl.java index fa33008c..4b7f5000 100644 --- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/IkiDanRemunerasiServiceImpl.java +++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/IkiDanRemunerasiServiceImpl.java @@ -510,11 +510,20 @@ public class IkiDanRemunerasiServiceImpl extends BaseVoServiceImpl implements Ik Date tglHitung = new Date(); LocalDate firstDayOfYear = LocalDate.now().with(TemporalAdjusters.firstDayOfYear()); - Integer lastYear = LocalDate.now().minusYears(1).getYear(); + LocalDate firstDate = LocalDate.now().minusYears(1).withMonth(1); + LocalDate lastDate = LocalDate.now().minusYears(1).withMonth(12); + if (LocalDate.now().getYear() == 2022) { + firstDate = LocalDate.now().withYear(2019).withMonth(5); + lastDate = LocalDate.now().withYear(2020).withMonth(4); + } + String bulanAwal = firstDate.getYear() + "-" + + (firstDate.getMonthValue() < 10 ? "0" + firstDate.getMonthValue() : firstDate.getMonthValue()); + String bulanAkhir = lastDate.getYear() + "-" + + (lastDate.getMonthValue() < 10 ? "0" + lastDate.getMonthValue() : lastDate.getMonthValue()); - List> data = indeksKinerjaDokterDao.findAll(lastYear.toString()); + List> data = indeksKinerjaDokterDao.findAll(bulanAwal, bulanAkhir); if (CommonUtil.isNotNullOrEmpty(data)) { - listSkorDokter = this.logbookKinerjaService.hitungTargetSkorLogbookDokter(lastYear.toString()); + listSkorDokter = this.logbookKinerjaService.hitungTargetSkorLogbookDokter(bulanAwal, bulanAkhir); } for (Map map : data) { @@ -576,8 +585,8 @@ public class IkiDanRemunerasiServiceImpl extends BaseVoServiceImpl implements Ik indeksKinerjaDokterDao.save(models); - List> listTotalSkor = indeksKinerjaDokterDao - .findTotalSkorByKelompokKerja(lastYear.toString()); + List> listTotalSkor = indeksKinerjaDokterDao.findTotalSkorByKelompokKerja(bulanAwal, + bulanAkhir); for (Map totalSkor : listTotalSkor) { TargetSkorDokterVO vo = new TargetSkorDokterVO(); vo.setKdProfile((short) 0); diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/LogbookKinerjaServiceImpl.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/LogbookKinerjaServiceImpl.java index 2d9e0c66..699f09ad 100644 --- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/LogbookKinerjaServiceImpl.java +++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/LogbookKinerjaServiceImpl.java @@ -3289,14 +3289,16 @@ public class LogbookKinerjaServiceImpl extends BaseVoServiceImpl implements Logb } @Override - public List hitungTargetSkorLogbookDokter(String tahun) throws ParseException { + public List hitungTargetSkorLogbookDokter(String bulanAwal, String bulanAkhir) throws ParseException { List result = new ArrayList<>(); DateFormat mf = new SimpleDateFormat("yyyy-MM"); + DateTimeFormatter smf = DateTimeFormatter.ofPattern("yyyy-MM"); byte hitungTargetId = 1; - for (int bulan = 1; bulan <= 12; bulan++) { - List listRs = hitungSkorDokter(mf.parse(tahun + "-" + (bulan < 10 ? "0" + bulan : bulan)), - hitungTargetId); + java.time.LocalDate startDate = java.time.LocalDate.parse(bulanAwal + "-01"); + java.time.LocalDate endDate = java.time.LocalDate.parse(bulanAkhir + "-01"); + for (java.time.LocalDate date = startDate; date.isBefore(endDate); date = date.plusMonths(1)) { + List listRs = hitungSkorDokter(mf.parse(date.format(smf)), hitungTargetId); result.addAll(listRs); }