Merge branch 'dev'
This commit is contained in:
commit
e89b009bf5
@ -1,22 +1,20 @@
|
|||||||
package com.jasamedika.medifirst2000.dao;
|
package com.jasamedika.medifirst2000.dao;
|
||||||
|
|
||||||
import java.util.List;
|
import com.jasamedika.medifirst2000.entities.Alamat;
|
||||||
import java.util.Map;
|
import com.jasamedika.medifirst2000.entities.Pasien;
|
||||||
|
|
||||||
import javax.persistence.LockModeType;
|
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Lock;
|
import org.springframework.data.jpa.repository.Lock;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.entities.Alamat;
|
import javax.persistence.LockModeType;
|
||||||
import com.jasamedika.medifirst2000.entities.Pasien;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository class for Pasien
|
* Repository class for Pasien
|
||||||
*
|
*
|
||||||
* @author Askur
|
* @author Askur
|
||||||
*/
|
*/
|
||||||
@Repository("PasienDao")
|
@Repository("PasienDao")
|
||||||
@ -111,4 +109,11 @@ public interface PasienDao extends JpaRepository<Pasien, Integer> {
|
|||||||
+ "and ibu.statusEnabled is true and anak.statusEnabled is true "
|
+ "and ibu.statusEnabled is true and anak.statusEnabled is true "
|
||||||
+ "and to_char(anak.tglLahir,'yyyy-MM-dd') between :tglAwal and :tglAkhir " + "order by ibu.namaPasien")
|
+ "and to_char(anak.tglLahir,'yyyy-MM-dd') between :tglAwal and :tglAkhir " + "order by ibu.namaPasien")
|
||||||
List<Map<String, Object>> findIbuAnak(@Param("tglAwal") String tglAwal, @Param("tglAkhir") String tglAkhir);
|
List<Map<String, Object>> findIbuAnak(@Param("tglAwal") String tglAwal, @Param("tglAkhir") String tglAkhir);
|
||||||
|
|
||||||
|
@Query(value = "select ps.* " + "from pasien_m ps " + "where ps.statusenabled is true "
|
||||||
|
+ "and (ps.nobpjs is not null " + "and trim(ps.nobpjs) <> '' " + "and ps.nobpjs <> '-' "
|
||||||
|
+ "and ps.nobpjs ~ '[0-9]+' " + "and length(ps.nobpjs) = 13) " + "and (ps.noidentitas is null "
|
||||||
|
+ "or length(ps.noidentitas) <> 16) "
|
||||||
|
+ "order by ps.statusenabled, ps.tgldaftar desc limit 300", nativeQuery = true)
|
||||||
|
List<Pasien> findByValidBpjs();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.jasamedika.medifirst2000.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author salmanoe
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 11/10/2023
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class PesertaBpjsDto {
|
||||||
|
private String noKartu;
|
||||||
|
private String nik;
|
||||||
|
}
|
||||||
@ -0,0 +1,104 @@
|
|||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,56 +0,0 @@
|
|||||||
package com.jasamedika.medifirst2000.task.schedule;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.service.KalenderService;
|
|
||||||
import com.jasamedika.medifirst2000.service.PegawaiJadwalKerjaService;
|
|
||||||
import com.jasamedika.medifirst2000.service.SlipGajiService;
|
|
||||||
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 java.time.LocalDate;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Salman
|
|
||||||
* @since 12 Jul 2023
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class ScheduleTask {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ScheduleTask.class);
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private KalenderService kalenderService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private PegawaiJadwalKerjaService pegawaiJadwalKerjaService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SlipGajiService slipGajiService;
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 23 30 6 ?")
|
|
||||||
public void generateKalender() {
|
|
||||||
LOGGER.info("Generate kalender tahun {}",
|
|
||||||
LocalDate.now().plusYears(1).format(DateTimeFormatter.ofPattern("yyyy")));
|
|
||||||
|
|
||||||
kalenderService.generateAndSaveKalender();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 0 1 * ?")
|
|
||||||
public void genarateJadwalPegawaiNonShift() {
|
|
||||||
LOGGER.info("Generate jadwal pegawai bulan {}", LocalDate.now().format(DateTimeFormatter.ofPattern("MM-yyyy")));
|
|
||||||
|
|
||||||
pegawaiJadwalKerjaService.autoSaveJadwalKerjaNonShift();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 0 1 * ?")
|
|
||||||
public void initiateSlipGaji() {
|
|
||||||
LOGGER.info("Initiate template slip gaji bulan {}",
|
|
||||||
LocalDate.now().format(DateTimeFormatter.ofPattern("MM-yyyy")));
|
|
||||||
|
|
||||||
slipGajiService.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,11 +1,13 @@
|
|||||||
package com.jasamedika.medifirst2000.task.schedule.config;
|
package com.jasamedika.medifirst2000.task.schedule.config;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.scheduling.TaskScheduler;
|
import org.springframework.scheduling.TaskScheduler;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Salman
|
* @author Salman
|
||||||
@ -24,4 +26,14 @@ public class ScheduleTaskConfig {
|
|||||||
return threadPoolTaskScheduler;
|
return threadPoolTaskScheduler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ObjectMapper objectMapper() {
|
||||||
|
return new ObjectMapper();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestTemplate restTemplate() {
|
||||||
|
return new RestTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,16 +1,29 @@
|
|||||||
package com.jasamedika.medifirst2000.task.schedule;
|
package com.jasamedika.medifirst2000.task.schedule;
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.service.KalenderService;
|
import com.jasamedika.medifirst2000.constants.Master;
|
||||||
import com.jasamedika.medifirst2000.service.PegawaiJadwalKerjaService;
|
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
|
||||||
import com.jasamedika.medifirst2000.service.SlipGajiService;
|
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.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Salman
|
* @author Salman
|
||||||
@ -18,39 +31,357 @@ import java.time.format.DateTimeFormatter;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class ScheduleTask {
|
public class ScheduleTask {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ScheduleTask.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ScheduleTask.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private KalenderService kalenderService;
|
private KalenderDao kalenderDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PegawaiJadwalKerjaService pegawaiJadwalKerjaService;
|
private PegawaiDao pegawaiDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SlipGajiService slipGajiService;
|
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 ?")
|
@Scheduled(cron = "0 0 23 30 6 ?")
|
||||||
public void generateKalender() {
|
public void generateKalender() {
|
||||||
LOGGER.info("Generate kalender tahun {}",
|
LOGGER.info("Generate kalender tahun {}",
|
||||||
LocalDate.now().plusYears(1).format(DateTimeFormatter.ofPattern("yyyy")));
|
LocalDate.now().plusYears(1).format(DateTimeFormatter.ofPattern("yyyy")));
|
||||||
|
|
||||||
kalenderService.generateAndSaveKalender();
|
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 * ?")
|
@Scheduled(cron = "0 0 0 1 * ?")
|
||||||
public void genarateJadwalPegawaiNonShift() {
|
public void genarateJadwalPegawaiNonShift() {
|
||||||
LOGGER.info("Generate jadwal pegawai bulan {}", LocalDate.now().format(DateTimeFormatter.ofPattern("MM-yyyy")));
|
LOGGER.info("Generate jadwal pegawai bulan {}", LocalDate.now().format(DateTimeFormatter.ofPattern("MM-yyyy")));
|
||||||
|
|
||||||
pegawaiJadwalKerjaService.autoSaveJadwalKerjaNonShift();
|
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 * ?")
|
@Scheduled(cron = "0 0 0 1 * ?")
|
||||||
public void initiateSlipGaji() {
|
public void templateSlipGajiTask() {
|
||||||
LOGGER.info("Initiate template slip gaji bulan {}",
|
LOGGER.info("Initiate template slip gaji bulan {}",
|
||||||
LocalDate.now().format(DateTimeFormatter.ofPattern("MM-yyyy")));
|
LocalDate.now().format(DateTimeFormatter.ofPattern("MM-yyyy")));
|
||||||
|
|
||||||
slipGajiService.init();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user