Merge remote-tracking branch 'origin/dev'
This commit is contained in:
commit
eda358fdce
@ -113,7 +113,6 @@ public interface PasienDao extends JpaRepository<Pasien, Integer> {
|
|||||||
@Query(value = "select ps.* " + "from pasien_m ps " + "where ps.statusenabled is true "
|
@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 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 "
|
+ "and ps.nobpjs ~ '[0-9]+' " + "and length(ps.nobpjs) = 13) " + "and (ps.noidentitas is null "
|
||||||
+ "or length(ps.noidentitas) <> 16) "
|
+ "or length(ps.noidentitas) <> 16) " + "order by ps.statusenabled, ps.tgldaftar desc", nativeQuery = true)
|
||||||
+ "order by ps.statusenabled, ps.tgldaftar desc limit 300", nativeQuery = true)
|
|
||||||
List<Pasien> findByValidBpjs();
|
List<Pasien> findByValidBpjs();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import com.jasamedika.medifirst2000.dao.PasienDao;
|
import com.jasamedika.medifirst2000.dao.PasienDao;
|
||||||
import com.jasamedika.medifirst2000.dto.PesertaBpjsDto;
|
import com.jasamedika.medifirst2000.dto.PesertaBpjsDto;
|
||||||
import com.jasamedika.medifirst2000.entities.Pasien;
|
import com.jasamedika.medifirst2000.entities.Pasien;
|
||||||
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||||
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;
|
||||||
@ -18,6 +18,7 @@ import org.springframework.web.client.RestTemplate;
|
|||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -44,28 +45,31 @@ public class PasienTask {
|
|||||||
|
|
||||||
@Scheduled(fixedRate = 1000 * 60 * 60 * 24)
|
@Scheduled(fixedRate = 1000 * 60 * 60 * 24)
|
||||||
public void nikPesertaBpjs() {
|
public void nikPesertaBpjs() {
|
||||||
LOGGER.info("Start task PasienTask.nikPesertaBpjs {}", LocalDateTime.now());
|
LOGGER.info("Task PasienTask.nikPesertaBpjs {}", LocalDateTime.now());
|
||||||
|
|
||||||
adjustNikPesertaBpjs();
|
adjustNikPesertaBpjs();
|
||||||
|
|
||||||
LOGGER.info("End task PasienTask.nikPesertaBpjs {}", LocalDateTime.now());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
private void adjustNikPesertaBpjs() {
|
private void adjustNikPesertaBpjs() {
|
||||||
try {
|
try {
|
||||||
LOGGER.info("Start adjusting NIK Peserta BPJS {}", LocalDateTime.now());
|
LOGGER.info("Adjusting NIK Peserta BPJS {}", LocalDateTime.now());
|
||||||
|
|
||||||
|
List<Pasien> listPasien = new ArrayList<>();
|
||||||
List<Pasien> pasienValidBpjs = pasienDao.findByValidBpjs();
|
List<Pasien> pasienValidBpjs = pasienDao.findByValidBpjs();
|
||||||
for (Pasien pasien : pasienValidBpjs) {
|
for (Pasien pasien : pasienValidBpjs) {
|
||||||
PesertaBpjsDto pesertaBpjsDto = cekKepesertaan(pasien.getNoBpjs());
|
PesertaBpjsDto pesertaBpjsDto = cekKepesertaan(pasien.getNoBpjs());
|
||||||
pasien.setNoIdentitas(pesertaBpjsDto.getNik());
|
if (pesertaBpjsDto != null) {
|
||||||
|
Pasien pasien_ = new Pasien();
|
||||||
|
pasien_.setId(pasien.getId());
|
||||||
|
pasien_.setNoIdentitas(pesertaBpjsDto.getNik());
|
||||||
|
listPasien.add(pasien_);
|
||||||
|
}
|
||||||
|
|
||||||
Thread.sleep((long) (Math.random() * 1000 * 60 * 5));
|
Thread.sleep((long) (Math.random() * 1000 * 8));
|
||||||
}
|
}
|
||||||
pasienDao.save(pasienValidBpjs);
|
if (CommonUtil.isNotNullOrEmpty(listPasien))
|
||||||
|
pasienDao.save(listPasien);
|
||||||
LOGGER.info("End adjusting NIK Peserta BPJS {}", LocalDateTime.now());
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error adjusting NIK Peserta BPJS {}", e.getMessage());
|
LOGGER.error("Error adjusting NIK Peserta BPJS {}", e.getMessage());
|
||||||
}
|
}
|
||||||
@ -73,7 +77,7 @@ public class PasienTask {
|
|||||||
|
|
||||||
private PesertaBpjsDto cekKepesertaan(String noKartu) {
|
private PesertaBpjsDto cekKepesertaan(String noKartu) {
|
||||||
try {
|
try {
|
||||||
LOGGER.info("Start cek kepesertaan BPJS {} {}", noKartu, LocalDateTime.now());
|
LOGGER.info("Cek kepesertaan BPJS {} {}", noKartu, LocalDateTime.now());
|
||||||
|
|
||||||
URI uri = new URI("https://daftar.rsabhk.co.id/api/data/pasien/jaminan/bpjs/cek-kepesertaan/" + noKartu);
|
URI uri = new URI("https://daftar.rsabhk.co.id/api/data/pasien/jaminan/bpjs/cek-kepesertaan/" + noKartu);
|
||||||
HttpEntity<Object> request = new HttpEntity<>(null);
|
HttpEntity<Object> request = new HttpEntity<>(null);
|
||||||
@ -84,21 +88,14 @@ public class PasienTask {
|
|||||||
HashMap.class);
|
HashMap.class);
|
||||||
Map<String, Object> responsePeserta = objectMapper.convertValue(responseMap.get("peserta"),
|
Map<String, Object> responsePeserta = objectMapper.convertValue(responseMap.get("peserta"),
|
||||||
HashMap.class);
|
HashMap.class);
|
||||||
|
|
||||||
LOGGER.info("End cek kepesertaan BPJS {} {}", noKartu, LocalDateTime.now());
|
|
||||||
|
|
||||||
return PesertaBpjsDto.builder().noKartu(responsePeserta.get("noKartu").toString())
|
return PesertaBpjsDto.builder().noKartu(responsePeserta.get("noKartu").toString())
|
||||||
.nik(responsePeserta.get("nik").toString()).build();
|
.nik(responsePeserta.get("nik").toString()).build();
|
||||||
} else {
|
} else {
|
||||||
LOGGER.error("Error handshake cek kepesertaan BPJS {}", response.getStatusCode().getReasonPhrase());
|
LOGGER.error("Error handshake cek kepesertaan BPJS {}", response.getStatusCode().getReasonPhrase());
|
||||||
|
|
||||||
throw new ServiceVOException(
|
|
||||||
"Error cek kepesertaan BPJS " + response.getStatusCode().getReasonPhrase());
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error cek kepesertaan BPJS {}", e.getMessage());
|
LOGGER.error("Error cek kepesertaan BPJS {}", e.getMessage());
|
||||||
|
|
||||||
throw new ServiceVOException("Error cek kepesertaan BPJS " + e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user