Initial commit
Konfigurasi deploy testing dan exclude scheduler
This commit is contained in:
parent
fb92535629
commit
bfa5fcca98
@ -2,8 +2,8 @@ jdbc.driver = org.postgresql.Driver
|
|||||||
|
|
||||||
hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
|
hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
|
||||||
hibernate.hbm2ddl = none
|
hibernate.hbm2ddl = none
|
||||||
hibernate.format_sql = true
|
hibernate.format_sql = false
|
||||||
hibernate.show_sql = true
|
hibernate.show_sql = false
|
||||||
|
|
||||||
hikari.config.maximum.pool.size = 5
|
hikari.config.maximum.pool.size = 5
|
||||||
|
|
||||||
|
|||||||
@ -1,104 +0,0 @@
|
|||||||
package com.jasamedika.medifirst2000.task.schedule;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.jasamedika.medifirst2000.dao.PasienDao;
|
|
||||||
import com.jasamedika.medifirst2000.dto.PesertaBpjsDto;
|
|
||||||
import com.jasamedika.medifirst2000.entities.Pasien;
|
|
||||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpEntity;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.springframework.http.HttpMethod.GET;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author salmanoe
|
|
||||||
* @version 1.0.0
|
|
||||||
* @since 11/10/2023
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class PasienTask {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(PasienTask.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RestTemplate restTemplate;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private PasienDao pasienDao;
|
|
||||||
|
|
||||||
@Scheduled(fixedRate = 1000 * 60 * 60 * 24)
|
|
||||||
public void nikPesertaBpjs() {
|
|
||||||
LOGGER.info("Start task PasienTask.nikPesertaBpjs {}", LocalDateTime.now());
|
|
||||||
|
|
||||||
adjustNikPesertaBpjs();
|
|
||||||
|
|
||||||
LOGGER.info("End task PasienTask.nikPesertaBpjs {}", LocalDateTime.now());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
private void adjustNikPesertaBpjs() {
|
|
||||||
try {
|
|
||||||
LOGGER.info("Start adjusting NIK Peserta BPJS {}", LocalDateTime.now());
|
|
||||||
|
|
||||||
List<Pasien> pasienValidBpjs = pasienDao.findByValidBpjs();
|
|
||||||
for (Pasien pasien : pasienValidBpjs) {
|
|
||||||
PesertaBpjsDto pesertaBpjsDto = cekKepesertaan(pasien.getNoBpjs());
|
|
||||||
pasien.setNoIdentitas(pesertaBpjsDto.getNik());
|
|
||||||
|
|
||||||
Thread.sleep((long) (Math.random() * 1000 * 60 * 5));
|
|
||||||
}
|
|
||||||
pasienDao.save(pasienValidBpjs);
|
|
||||||
|
|
||||||
LOGGER.info("End adjusting NIK Peserta BPJS {}", LocalDateTime.now());
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.error("Error adjusting NIK Peserta BPJS {}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private PesertaBpjsDto cekKepesertaan(String noKartu) {
|
|
||||||
try {
|
|
||||||
LOGGER.info("Start cek kepesertaan BPJS {} {}", noKartu, LocalDateTime.now());
|
|
||||||
|
|
||||||
URI uri = new URI("https://daftar.rsabhk.co.id/api/data/pasien/jaminan/bpjs/cek-kepesertaan/" + noKartu);
|
|
||||||
HttpEntity<Object> request = new HttpEntity<>(null);
|
|
||||||
ResponseEntity<Object> response = restTemplate.exchange(uri, GET, request, Object.class);
|
|
||||||
if (HttpStatus.OK.equals(response.getStatusCode())) {
|
|
||||||
Map<String, Object> responseBody = objectMapper.convertValue(response.getBody(), Map.class);
|
|
||||||
Map<String, Object> responseMap = objectMapper.convertValue(responseBody.get("response"),
|
|
||||||
HashMap.class);
|
|
||||||
Map<String, Object> responsePeserta = objectMapper.convertValue(responseMap.get("peserta"),
|
|
||||||
HashMap.class);
|
|
||||||
|
|
||||||
LOGGER.info("End cek kepesertaan BPJS {} {}", noKartu, LocalDateTime.now());
|
|
||||||
|
|
||||||
return PesertaBpjsDto.builder().noKartu(responsePeserta.get("noKartu").toString())
|
|
||||||
.nik(responsePeserta.get("nik").toString()).build();
|
|
||||||
} else {
|
|
||||||
LOGGER.error("Error handshake cek kepesertaan BPJS {}", response.getStatusCode().getReasonPhrase());
|
|
||||||
|
|
||||||
throw new ServiceVOException(
|
|
||||||
"Error cek kepesertaan BPJS " + response.getStatusCode().getReasonPhrase());
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.error("Error cek kepesertaan BPJS {}", e.getMessage());
|
|
||||||
|
|
||||||
throw new ServiceVOException("Error cek kepesertaan BPJS " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
</context-param>
|
</context-param>
|
||||||
<context-param>
|
<context-param>
|
||||||
<param-name>spring.profiles.default</param-name>
|
<param-name>spring.profiles.default</param-name>
|
||||||
<param-value>pelayanan</param-value>
|
<param-value>development</param-value>
|
||||||
</context-param>
|
</context-param>
|
||||||
|
|
||||||
<listener>
|
<listener>
|
||||||
|
|||||||
@ -1,387 +0,0 @@
|
|||||||
package com.jasamedika.medifirst2000.task.schedule;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.constants.Master;
|
|
||||||
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
|
|
||||||
import com.jasamedika.medifirst2000.dao.*;
|
|
||||||
import com.jasamedika.medifirst2000.dao.custom.PegawaiDaoCustom;
|
|
||||||
import com.jasamedika.medifirst2000.entities.*;
|
|
||||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
|
||||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
|
||||||
import com.jasamedika.medifirst2000.util.DateUtil;
|
|
||||||
import com.jasamedika.medifirst2000.vo.*;
|
|
||||||
import org.joda.time.Chronology;
|
|
||||||
import org.joda.time.chrono.ISOChronology;
|
|
||||||
import org.joda.time.chrono.IslamicChronology;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Salman
|
|
||||||
* @since 12 Jul 2023
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class ScheduleTask {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ScheduleTask.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private KalenderDao kalenderDao;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private PegawaiDao pegawaiDao;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private PegawaiDaoCustom pegawaiDaoCustom;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private PegawaiJadwalKerjaDao pegawaiJadwalKerjaDao;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ShiftKerjaDao shiftKerjaDao;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SlipGajiDao slipGajiDao;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MapPegawaiJabatanToUnitKerjaDao mappingJabatanDao;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SlipGajiDetailDao slipGajiDetailDao;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BaseConverterImpl<PegawaiJadwalKerjaVO, PegawaiJadwalKerja> pegawaiJadwalKerjaConverter;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BaseConverterImpl<PegawaiVO, Pegawai> pegawaiConverter;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BaseConverterImpl<RuanganVO, Ruangan> ruanganConverter;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BaseConverterImpl<ShiftKerjaVO, ShiftKerja> shiftKerjaConverter;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BaseConverterImpl<KalenderVO, Kalender> kalenderConverter;
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 23 30 6 ?")
|
|
||||||
public void generateKalender() {
|
|
||||||
LOGGER.info("Generate kalender tahun {}",
|
|
||||||
LocalDate.now().plusYears(1).format(DateTimeFormatter.ofPattern("yyyy")));
|
|
||||||
|
|
||||||
saveKalender();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
private void saveKalender() {
|
|
||||||
List<Kalender> kals = new ArrayList<>();
|
|
||||||
Calendar ct = Calendar.getInstance();
|
|
||||||
ct.set(Calendar.MONTH, 0);
|
|
||||||
ct.set(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
ct.set(Calendar.HOUR, 0);
|
|
||||||
ct.set(Calendar.MINUTE, 0);
|
|
||||||
ct.set(Calendar.SECOND, 0);
|
|
||||||
ct.set(Calendar.MILLISECOND, 0);
|
|
||||||
ct.add(Calendar.YEAR, 1);
|
|
||||||
Calendar c = Calendar.getInstance();
|
|
||||||
Date lastDate = kalenderDao.getLastDateData();
|
|
||||||
c.setTime(lastDate);
|
|
||||||
c.add(Calendar.DATE, 1);
|
|
||||||
if (ct.getTime().compareTo(c.getTime()) == 0) {
|
|
||||||
int daysInYear = c.getActualMaximum(Calendar.DAY_OF_YEAR);
|
|
||||||
for (int i = 1; i <= daysInYear; i++) {
|
|
||||||
c.set(Calendar.DAY_OF_YEAR, i);
|
|
||||||
Kalender kal = new Kalender();
|
|
||||||
kal.setKdProfile((short) 0);
|
|
||||||
kal.setStatusEnabled(Master.STATUS_ENABLE_TRUE);
|
|
||||||
kal.setBulanKeDlmTahun((byte) (c.get(Calendar.MONTH) + 1));
|
|
||||||
kal.setHariKeDlmBulan((byte) c.get(Calendar.DAY_OF_MONTH));
|
|
||||||
kal.setHariKeDlmMinggu((byte) c.get(Calendar.WEEK_OF_MONTH));
|
|
||||||
kal.setHariKeDlmTahun((short) c.get(Calendar.DAY_OF_YEAR));
|
|
||||||
kal.setKdTanggal(c.get(Calendar.DAY_OF_YEAR));
|
|
||||||
kal.setNamaBulan(new SimpleDateFormat("MMMM", new java.util.Locale("id")).format(c.getTime()));
|
|
||||||
kal.setNamaHari(new SimpleDateFormat("EEEE", new java.util.Locale("id")).format(c.getTime()));
|
|
||||||
kal.setqTanggal(c.get(Calendar.DAY_OF_YEAR));
|
|
||||||
kal.setTahunKalender((short) c.get(Calendar.YEAR));
|
|
||||||
kal.setTanggal(c.getTime());
|
|
||||||
kals.add(kal);
|
|
||||||
}
|
|
||||||
kalenderDao.save(kals);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 0 1 * ?")
|
|
||||||
public void genarateJadwalPegawaiNonShift() {
|
|
||||||
LOGGER.info("Generate jadwal pegawai bulan {}", LocalDate.now().format(DateTimeFormatter.ofPattern("MM-yyyy")));
|
|
||||||
|
|
||||||
saveJadwalKerjaNonShift();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveJadwalKerjaNonShift() {
|
|
||||||
/*
|
|
||||||
* Perbaikan Method ini mohon untuk diikutsertakan juga memperbaiki
|
|
||||||
* Map<String, Object> findPegawaiByRuanganRev2(Integer ruangan, Integer
|
|
||||||
* tahun, Integer bulan, Integer idPegawai) Map<String, Object>
|
|
||||||
* findPegawaiByRuanganRev2(Integer subUnitKerja, Integer tahun, Integer
|
|
||||||
* bulan)
|
|
||||||
*/
|
|
||||||
// set auto save untuk bulan ini
|
|
||||||
Calendar c = Calendar.getInstance();
|
|
||||||
c.setTime(new Date());
|
|
||||||
Integer tahun = c.get(Calendar.YEAR);
|
|
||||||
Integer bulan = c.get(Calendar.MONTH) + 1;
|
|
||||||
// get list pegawai non shift by subunitkerja
|
|
||||||
List<Integer> listPegawai = pegawaiDao.getPegawaiNonshift();
|
|
||||||
List<PegawaiJadwalKerjaVO> vos = new ArrayList<>();
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(listPegawai)) {
|
|
||||||
for (Integer idPegawai : listPegawai) {
|
|
||||||
// generate jadwal hanya untuk yang belum buat jadwal
|
|
||||||
List<PegawaiJadwalKerja> jadwal = pegawaiJadwalKerjaDao.findJadwalByBulan(tahun, bulan, idPegawai);
|
|
||||||
if (CommonUtil.isNullOrEmpty(jadwal)) {
|
|
||||||
Pegawai pegawai = pegawaiDao.findOne(idPegawai);
|
|
||||||
List<Map<String, Object>> mapListHariLibur = pegawaiDaoCustom.findHariLiburPegawaiNonShift(tahun,
|
|
||||||
bulan);
|
|
||||||
// clear false data
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(mapListHariLibur))
|
|
||||||
for (Map<String, Object> mh : mapListHariLibur)
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(mh.get("statusEnabled"))
|
|
||||||
&& mh.get("statusEnabled").equals(Master.STATUS_ENABLE_FALSE))
|
|
||||||
mh.put("namaHariLibur", null);
|
|
||||||
// Setting Bulan Ramadhan
|
|
||||||
Chronology iso = ISOChronology.getInstance();
|
|
||||||
Chronology hijri = IslamicChronology.getInstance();
|
|
||||||
int bulanHijri;
|
|
||||||
try {
|
|
||||||
Integer idShift = pegawai.getShiftKerjaId();
|
|
||||||
List<Map<String, Object>> listShiftKerja = shiftKerjaDao.findByKelompokShiftId(idShift);
|
|
||||||
// Non Shift +
|
|
||||||
if (idShift == 2)
|
|
||||||
listShiftKerja.addAll(shiftKerjaDao.findByKelompokShiftId(1));
|
|
||||||
List<PegawaiJadwalKerja> resultPegawaiJadwalKerja = pegawaiDaoCustom.findJadwalByTanggal(tahun,
|
|
||||||
bulan, idPegawai);
|
|
||||||
if (resultPegawaiJadwalKerja.isEmpty()) { // Apabila_jadwal_kosong
|
|
||||||
if (idShift == 1 || idShift == 2) { // apabila_pegawai_nonshift
|
|
||||||
for (Map<String, Object> hariLibur : mapListHariLibur) {
|
|
||||||
PegawaiJadwalKerjaVO vo = new PegawaiJadwalKerjaVO();
|
|
||||||
ShiftKerjaVO shiftKerjaPegawai = new ShiftKerjaVO();
|
|
||||||
if (!CommonUtil.isNotNullOrEmpty(hariLibur.get("namaHariLibur"))) {
|
|
||||||
// cek apakah nama harinya adalah jumat,
|
|
||||||
// senin-kamis atau sabtu minggu
|
|
||||||
if (hariLibur.get("namaHari").toString().equals("Minggu")
|
|
||||||
|| hariLibur.get("namaHari").toString().equals("Sabtu")) {
|
|
||||||
shiftKerjaPegawai.setId(8);
|
|
||||||
} else if (hariLibur.get("namaHari").toString().equals("Jumat")) {
|
|
||||||
org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(tahun, bulan,
|
|
||||||
Integer.parseInt(hariLibur.get("tgl").toString()), iso);
|
|
||||||
org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
|
|
||||||
tglIso.toDateTimeAtStartOfDay(), hijri);
|
|
||||||
bulanHijri = tglHijri.getMonthOfYear();
|
|
||||||
if (bulanHijri == 9) {
|
|
||||||
shiftKerjaPegawai.setId(57); // RMJ
|
|
||||||
} else {
|
|
||||||
shiftKerjaPegawai.setId(19);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
org.joda.time.LocalDate tglIso = new org.joda.time.LocalDate(tahun, bulan,
|
|
||||||
Integer.parseInt(hariLibur.get("tgl").toString()), iso);
|
|
||||||
org.joda.time.LocalDate tglHijri = new org.joda.time.LocalDate(
|
|
||||||
tglIso.toDateTimeAtStartOfDay(), hijri);
|
|
||||||
bulanHijri = tglHijri.getMonthOfYear();
|
|
||||||
if (bulanHijri == 9) {
|
|
||||||
shiftKerjaPegawai.setId(56); // RM
|
|
||||||
} else {
|
|
||||||
shiftKerjaPegawai.setId(18);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
shiftKerjaPegawai.setId(8);
|
|
||||||
}
|
|
||||||
PegawaiVO peg = new PegawaiVO();
|
|
||||||
peg.setId(idPegawai);
|
|
||||||
KalenderVO kalendar = new KalenderVO();
|
|
||||||
kalendar.setId(Integer.parseInt(hariLibur.get("idKalendar").toString()));
|
|
||||||
vo.setPegawai(peg);
|
|
||||||
vo.setShift(shiftKerjaPegawai);
|
|
||||||
vo.setTanggal(kalendar);
|
|
||||||
vos.add(vo);
|
|
||||||
}
|
|
||||||
} // end if shift 1
|
|
||||||
else {// Selain shift 1
|
|
||||||
for (Map<String, Object> hariLibur : mapListHariLibur) {
|
|
||||||
PegawaiJadwalKerjaVO vo = new PegawaiJadwalKerjaVO();
|
|
||||||
PegawaiVO peg = new PegawaiVO();
|
|
||||||
peg.setId(idPegawai);
|
|
||||||
ShiftKerjaVO shiftKerjaPegawai = new ShiftKerjaVO();
|
|
||||||
shiftKerjaPegawai.setId(0);
|
|
||||||
KalenderVO kalendar = new KalenderVO();
|
|
||||||
kalendar.setId(Integer.parseInt(hariLibur.get("idKalendar").toString()));
|
|
||||||
vo.setPegawai(peg);
|
|
||||||
vo.setShift(shiftKerjaPegawai);
|
|
||||||
vo.setTanggal(kalendar);
|
|
||||||
vos.add(vo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {// Jadwal tidak kosong
|
|
||||||
Integer idLooping = 0;
|
|
||||||
for (Map<String, Object> map2 : mapListHariLibur) {
|
|
||||||
for (PegawaiJadwalKerja mapPegawaiJadwalKerja : resultPegawaiJadwalKerja) {
|
|
||||||
if (mapPegawaiJadwalKerja.getPegawaiId().equals(idPegawai) && (Integer
|
|
||||||
.parseInt(map2.get("idKalendar").toString()) == mapPegawaiJadwalKerja
|
|
||||||
.getTanggalId())) {
|
|
||||||
mapListHariLibur.remove(idLooping);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
idLooping++;
|
|
||||||
}
|
|
||||||
// Untuk tanggal yang kosong diisi disini
|
|
||||||
for (Map<String, Object> map2 : mapListHariLibur) {
|
|
||||||
PegawaiJadwalKerjaVO vo = new PegawaiJadwalKerjaVO();
|
|
||||||
PegawaiVO peg = new PegawaiVO();
|
|
||||||
peg.setId(idPegawai);
|
|
||||||
ShiftKerjaVO shiftKerjaPegawai = new ShiftKerjaVO();
|
|
||||||
shiftKerjaPegawai.setId(0);
|
|
||||||
KalenderVO kalendar = new KalenderVO();
|
|
||||||
kalendar.setId(Integer.parseInt(map2.get("idKalendar").toString()));
|
|
||||||
vo.setPegawai(peg);
|
|
||||||
vo.setShift(shiftKerjaPegawai);
|
|
||||||
vo.setTanggal(kalendar);
|
|
||||||
vos.add(vo);
|
|
||||||
}
|
|
||||||
} // end else
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
throw new ServiceVOException(e.getMessage());
|
|
||||||
}
|
|
||||||
} // kondisi tidak ada data di pegawai jadwal kerja
|
|
||||||
} // looping pegawai
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(vos))
|
|
||||||
saveListJadwalPegawai(vos, false, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public void saveListJadwalPegawai(List<PegawaiJadwalKerjaVO> vos, boolean isUnggah, boolean isPenangguhan) {
|
|
||||||
for (PegawaiJadwalKerjaVO vo : vos) {
|
|
||||||
boolean editKetidakhadiran = false;
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(vo)) {
|
|
||||||
PegawaiJadwalKerja model = pegawaiJadwalKerjaConverter.transferVOToModel(vo, new PegawaiJadwalKerja());
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(vo.getPegawai()))
|
|
||||||
model.setPegawai(pegawaiConverter.transferVOToModel(vo.getPegawai(), new Pegawai()));
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(vo.getPegawaiGanti()))
|
|
||||||
model.setPegawaiGanti(pegawaiConverter.transferVOToModel(vo.getPegawaiGanti(), new Pegawai()));
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(vo.getRuangan()))
|
|
||||||
model.setRuangan(ruanganConverter.transferVOToModel(vo.getRuangan(), new Ruangan()));
|
|
||||||
if (isPenangguhan && CommonUtil.isNotNullOrEmpty(vo.getShift())
|
|
||||||
&& CommonUtil.isNotNullOrEmpty(vo.getShift().getId()) && vo.getShift().getId().equals(0)) {
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(vo.getTanggal())) {
|
|
||||||
Date tanggal = pegawaiJadwalKerjaDao.getTanggal(vo.getTanggal().getId());
|
|
||||||
Map<String, Object> map = pegawaiJadwalKerjaDao.getJadwal(vo.getPegawai().getId(),
|
|
||||||
new SimpleDateFormat("yyyy-MM-dd").format(tanggal));
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(map) && CommonUtil.isNotNullOrEmpty(map.get("id"))) {
|
|
||||||
pegawaiJadwalKerjaDao.delete(Integer.parseInt(map.get("id").toString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(vo.getShift())) {
|
|
||||||
model.setShift(shiftKerjaConverter.transferVOToModel(vo.getShift(), new ShiftKerja()));
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(vo.getTanggal())) {
|
|
||||||
Date tanggal = pegawaiJadwalKerjaDao.getTanggal(vo.getTanggal().getId());
|
|
||||||
Map<String, Object> map = pegawaiJadwalKerjaDao.getJadwal(vo.getPegawai().getId(),
|
|
||||||
new SimpleDateFormat("yyyy-MM-dd").format(tanggal));
|
|
||||||
model.setTanggal(kalenderConverter.transferVOToModel(vo.getTanggal(), new Kalender()));
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(map) && CommonUtil.isNotNullOrEmpty(map.get("id"))) {
|
|
||||||
model.setId(Integer.parseInt(map.get("id").toString()));
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(map.get("flagKetidakhadiran"))
|
|
||||||
&& Boolean.parseBoolean(map.get("flagKetidakhadiran").toString())) {
|
|
||||||
editKetidakhadiran = true;
|
|
||||||
} else if (isUnggah && vo.getShift().getFlagKetidakhadiran()) {
|
|
||||||
editKetidakhadiran = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(model) && (isPenangguhan || !editKetidakhadiran))
|
|
||||||
pegawaiJadwalKerjaDao.save(model);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 0 1 * ?")
|
|
||||||
public void templateSlipGajiTask() {
|
|
||||||
LOGGER.info("Initiate template slip gaji bulan {}",
|
|
||||||
LocalDate.now().format(DateTimeFormatter.ofPattern("MM-yyyy")));
|
|
||||||
|
|
||||||
initiateDataSlipGaji();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public void initiateDataSlipGaji() {
|
|
||||||
Date now = new Date();
|
|
||||||
Date startMonth = DateUtil.startMonth(now);
|
|
||||||
Date endMonth = DateUtil.endMonth(now);
|
|
||||||
List<Integer> listIdPegawaiSlip = slipGajiDao.findPegawaiByBulan(startMonth, endMonth);
|
|
||||||
List<MapPegawaiJabatanToUnitKerja> listJabatan = mappingJabatanDao.getAll();
|
|
||||||
listJabatan = listJabatan.stream().filter(j -> !listIdPegawaiSlip.contains(j.getPegawaiId()))
|
|
||||||
.sorted(Comparator.comparingInt(MapPegawaiJabatanToUnitKerja::getPegawaiId))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
List<Integer> listIdPegawai = new ArrayList<>();
|
|
||||||
listJabatan.forEach(j -> {
|
|
||||||
if (!listIdPegawai.contains(j.getPegawaiId()))
|
|
||||||
listIdPegawai.add(j.getPegawaiId());
|
|
||||||
});
|
|
||||||
List<SlipGaji> listSlipGaji = new ArrayList<>();
|
|
||||||
List<SlipGajiDetail> listSlipGajiDetail = new ArrayList<>();
|
|
||||||
for (Integer idPegawai : listIdPegawai) {
|
|
||||||
SlipGaji.SlipGajiBuilder b = SlipGaji.builder();
|
|
||||||
for (MapPegawaiJabatanToUnitKerja j : listJabatan)
|
|
||||||
if (idPegawai.equals(j.getPegawaiId())) {
|
|
||||||
Pegawai pegawai = new Pegawai();
|
|
||||||
pegawai.setId(j.getPegawaiId());
|
|
||||||
b.pegawai(pegawai);
|
|
||||||
b.bulan(now);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SlipGaji slipGaji = b.build();
|
|
||||||
listSlipGaji.add(slipGaji);
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(slipGaji))
|
|
||||||
for (MapPegawaiJabatanToUnitKerja j : listJabatan)
|
|
||||||
if (idPegawai.equals(j.getPegawaiId())) {
|
|
||||||
SlipGajiDetail.SlipGajiDetailBuilder detail = SlipGajiDetail.builder();
|
|
||||||
detail.slipGaji(slipGaji);
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(j.getJabatanId())) {
|
|
||||||
Jabatan jabatan = new Jabatan();
|
|
||||||
jabatan.setId(j.getJabatanId());
|
|
||||||
detail.jabatan(jabatan);
|
|
||||||
}
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(j.getUnitKerjaPegawaiId())) {
|
|
||||||
UnitKerjaPegawai unitKerja = new UnitKerjaPegawai();
|
|
||||||
unitKerja.setId(j.getUnitKerjaPegawaiId());
|
|
||||||
detail.unitKerja(unitKerja);
|
|
||||||
}
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(j.getSubUnitKerjaPegawaiId())) {
|
|
||||||
SubUnitKerjaPegawai subunitKerja = new SubUnitKerjaPegawai();
|
|
||||||
subunitKerja.setId(j.getSubUnitKerjaPegawaiId());
|
|
||||||
detail.subUnitKerja(subunitKerja);
|
|
||||||
}
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(j.getGradeId())) {
|
|
||||||
NilaiKelompokJabatan grade = new NilaiKelompokJabatan();
|
|
||||||
grade.setId(j.getGradeId());
|
|
||||||
detail.grade(grade);
|
|
||||||
}
|
|
||||||
listSlipGajiDetail.add(detail.build());
|
|
||||||
}
|
|
||||||
slipGajiDao.save(listSlipGaji);
|
|
||||||
slipGajiDetailDao.save(listSlipGajiDetail);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
</context-param>
|
</context-param>
|
||||||
<context-param>
|
<context-param>
|
||||||
<param-name>spring.profiles.default</param-name>
|
<param-name>spring.profiles.default</param-name>
|
||||||
<param-value>sdm</param-value>
|
<param-value>development</param-value>
|
||||||
</context-param>
|
</context-param>
|
||||||
|
|
||||||
<listener>
|
<listener>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user