Delete async tasks

This commit is contained in:
Salman Manoe 2023-07-12 12:26:43 +07:00
parent 1c277111a9
commit 411ee0619a
29 changed files with 0 additions and 3194 deletions

View File

@ -1,115 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.google.gson.Gson;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.IpsrsMaintenanceService;
import com.jasamedika.medifirst2000.service.PegawaiMutasiSanksiResignService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.IpsrsJadwalPemeliharaanVO;
@Component
public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemeliharaanVO>{
/*
private Boolean flag =false;
private Integer pending = 0;
private String time = new SimpleDateFormat("HH:mm").format(Calendar.getInstance().getTime());
private SimpleDateFormat format = new SimpleDateFormat("HH:mm");
public IpsrsAlertMaintenance() {
if(!Thread.currentThread().isInterrupted()){
try {
new Thread(new RunningTask()).start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
class RunningTask implements Runnable{
public void run() {
new Timer().schedule(new TimerTask(){
@Override
public void run() {
try{
Date timeNow = format.parse(time);
Date timeEnd = format.parse("18:00");
Date timeReset = format.parse("21:00");
if(pending==60*3){
if(timeNow.before(timeEnd)){
if(flag==false){
getAlertlMaintenance();
getDataPlanningByDate();
flag=true;
}
}
pending=0;
} else{
pending++;
if(timeNow.equals(timeReset)){
flag=false;
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
}, 1000L, 1000L);
}
}
@Autowired
private IpsrsMaintenanceService ipsrsMaintenanceService;
public void getAlertlMaintenance(){
try{
if (ipsrsMaintenanceService != null){
Map<String, Object> jadwalMaintenance = ipsrsMaintenanceService.getAlertMaintenance();
if(CommonUtil.isNotNullOrEmpty(jadwalMaintenance)){
BroadcastMessageOther("jadwalMaintenance", jadwalMaintenance);
System.out.println(DateUtil.now()+" task scheduler :");
System.out.println(new Gson().toJson(jadwalMaintenance));
} else{
System.out.println(DateUtil.now()+" task scheduler : tidak ada jadwal maintenance");
}
}
}catch (Exception ex){
ex.printStackTrace();
}
}
@Autowired
private PegawaiMutasiSanksiResignService pegawaiMutasiSanksiResignService;
@SuppressWarnings("unchecked")
public void getDataPlanningByDate(){
try{
if (pegawaiMutasiSanksiResignService != null) {
Map<String, Object> mapData = pegawaiMutasiSanksiResignService.getDataPlanningByDate(DateUtil.now());
if(CommonUtil.isNotNullOrEmpty(mapData)){
for(Map<String, Object> data : (List<Map<String, Object>>) mapData.get("listData")){
Map<String, Object> dataResult = pegawaiMutasiSanksiResignService.updateExecPegawai(data);
System.out.println(DateUtil.now()+" task scheduler : update pegawai "+new Gson().toJson(dataResult));
}
} else{
System.out.println(DateUtil.now()+" task scheduler : tidak ada update data pegawai musare");
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
*/
}

View File

@ -1,186 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
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 com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.dao.PegawaiDao;
import com.jasamedika.medifirst2000.dao.RuanganDao;
import com.jasamedika.medifirst2000.entities.Pegawai;
import com.jasamedika.medifirst2000.entities.Ruangan;
import com.jasamedika.medifirst2000.notification.MessagePublisher;
import com.jasamedika.medifirst2000.service.NotifMessagingSchedulerService;
import com.jasamedika.medifirst2000.service.NotifMessagingService;
import com.jasamedika.medifirst2000.service.NotifikasiMessageObjekModulService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.NotifMessagingSchedulerVO;
import com.jasamedika.medifirst2000.vo.NotifMessagingVO;
import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
@Component
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO>{
/*
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
@Autowired
NotifMessagingSchedulerService<NotifMessagingSchedulerVO> notifMessagingSchedulerService;
@Autowired
NotifMessagingService<NotifMessagingVO> notifMessagingService;
@Autowired
NotifikasiMessageObjekModulService<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulService;
@Autowired
MessagePublisher<String, Object> messagePublisher;
@Autowired
PegawaiDao pegawaiDao;
@Autowired
RuanganDao ruanganDao;
@Scheduled(cron = "0 30 7 * * *")
public void NotificationNormalMaintenanceEvery730AM(){
try{
MessagePublisher.RabbitHole rabbitHole = messagePublisher.getRabbitHole();
List<NotifMessagingSchedulerVO> lNotif = notifMessagingSchedulerService.allNotifBelumTerkirim(new Date());
if (CommonUtil.isNullOrEmpty(lNotif)){
LOG.info(DateUtil.now()+" task scheduler : tidak ada jadwal maintenance");
return;
}
Map<Integer, Integer> pegawaiRuangaAsal = new HashMap<>();
Map<Integer, List<Integer>> ruanganAsalAll = new HashMap<>();
Map<Integer, List<Integer>> notifMapAllRuanganTujuan = new HashMap<>();
List<Integer> notifsId = new ArrayList<>();
List<Integer> ruanganTujuansId = new ArrayList<>();
Integer oldNotifId = 0;
Integer oldRuanganIdTujuan = 0;
for (NotifMessagingSchedulerVO notif:lNotif){
if (notif.getRuanganIdTujuan().intValue() != oldRuanganIdTujuan.intValue()){
ruanganTujuansId = new ArrayList<>();
oldRuanganIdTujuan = notif.getRuanganIdTujuan();
}
ruanganTujuansId.add(notif.getRuanganIdTujuan());
notifMapAllRuanganTujuan.put(notif.getNotifMessagingId(), ruanganTujuansId);
if (notif.getNotifMessagingId().intValue() != oldNotifId.intValue()){
notifsId = new ArrayList<>();
oldNotifId = notif.getNotifMessagingId();
}
notifsId.add(notif.getNotifMessagingId());
ruanganAsalAll.put(notif.getRuanganIdAsal(), notifsId);
pegawaiRuangaAsal.put(notif.getRuanganIdAsal(), notif.getPegawaiId());
}
Set<Integer> ruanganAsalIds = ruanganAsalAll.keySet();
for(Integer ruanganAsalId:ruanganAsalIds){
Integer pegawaiId = pegawaiRuangaAsal.get(ruanganAsalId);
Pegawai pegawai = pegawaiDao.findById(pegawaiId);
Ruangan ruanganAsal = ruanganDao.findById(ruanganAsalId);
notifsId = ruanganAsalAll.get(ruanganAsalId);
for (Integer notifMessagingId:notifsId ){
ruanganTujuansId = notifMapAllRuanganTujuan.get(notifMessagingId);
try{
rabbitHole.sendNotif(rabbitHole, ruanganAsal, pegawai, notifikasiMessageObjekModulService, notifMessagingId, ruanganTujuansId);
}catch(Exception e){
LOG.info(DateUtil.now()+" task scheduler dari Ruangan {} dengan ruanganId {} pada notifMessageId {} ada masalah {}",
ruanganAsal.getNamaRuangan(), ruanganAsalId, notifMessagingId, e.getMessage());
}
}
}
}catch(Exception e){
LOG.info(DateUtil.now() + "Task scheduler gagal penyebab, {} ", e.getMessage());
//e.printStackTrace();
}
}
*/
}
//private void sendNotif(Gson gson, String urlSocket, MessagePublisher.RabbitHole rabbitHole, Integer pegawaiId, Integer ruanganId, Integer notifMessagingId, List<Integer> ruanganTujuansId) throws Exception{
//
//List<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulVOs = notifikasiMessageObjekModulService.findByNotifMessagingIdAndRuanganId(notifMessagingId, ruanganTujuansId);
//
//if (CommonUtil.isNullOrEmpty(notifikasiMessageObjekModulVOs)) {
// return;
//}
//
//Integer ruanganIdtemp = 0;
//boolean connect = false;
//
//PegawaiVO pegawai = pegawaiService.findById(pegawaiId);
//
//for (NotifikasiMessageObjekModulVO vo : notifikasiMessageObjekModulVOs){
// Ruangan ruangan = vo.getRuangan();
// ModulAplikasi modulAplikasi = vo.getModulAplikasi();
// ObjekModulAplikasi objekModulAplikasi = vo.getObjekModulAplikasi();
// String customURLObjekModul = vo.getCustomURLObjekModul();
// String titleNotifikasi = vo.getTitleNotifikasi();
// String pesanNotifikasi = vo.getPesanNotifikasi();
// String namaFungsiFrontEnd = vo.getNamaFungsiFrontEnd();
//
// if (ruangan.getId() == ruanganId){
// continue;
// }
//
// RuanganVO dariRuangan = ruanganService.findById(ruanganId);
//
// if (ruanganIdtemp != ruangan.getId()){
// if (connect){
// rabbitHole.close();
// }
// rabbitHole.connect(urlSocket, String.valueOf(ruangan.getId()));
// connect = true;
// ruanganIdtemp = ruangan.getId();
// }
//
// Map<String, Object> map = new HashMap<>();
// map.put("title", titleNotifikasi);
// map.put("dariRuangan", dariRuangan);
// map.put("ruanganId", ruangan.getId());
// map.put("ruangan", ruangan);
// map.put("modulAplikasi", modulAplikasi);
// map.put("objekModulAplikasi", objekModulAplikasi);
// map.put("titleNotifikasi", titleNotifikasi);
// map.put("pesanNotifikasi", pesanNotifikasi);
// map.put("namaFungsiFrontEnd", namaFungsiFrontEnd);
// map.put("fromPegawai", pegawai);
// map.put("urlForm",CommonUtil.isNullOrEmpty(customURLObjekModul)? objekModulAplikasi.getAlamatUrlForm() : customURLObjekModul);
//
// rabbitHole.sendRabbitMQNotification(gson.toJson(map));
//
// //messagePublisher.BroadcastMessage(map);
//}
//if (connect){
// rabbitHole.close();
//}
//
//}

View File

@ -1,115 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.google.gson.Gson;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.IpsrsMaintenanceService;
import com.jasamedika.medifirst2000.service.PegawaiMutasiSanksiResignService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.IpsrsJadwalPemeliharaanVO;
@Component
public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemeliharaanVO>{
/*
private Boolean flag =false;
private Integer pending = 0;
private String time = new SimpleDateFormat("HH:mm").format(Calendar.getInstance().getTime());
private SimpleDateFormat format = new SimpleDateFormat("HH:mm");
public IpsrsAlertMaintenance() {
if(!Thread.currentThread().isInterrupted()){
try {
new Thread(new RunningTask()).start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
class RunningTask implements Runnable{
public void run() {
new Timer().schedule(new TimerTask(){
@Override
public void run() {
try{
Date timeNow = format.parse(time);
Date timeEnd = format.parse("18:00");
Date timeReset = format.parse("21:00");
if(pending==60*3){
if(timeNow.before(timeEnd)){
if(flag==false){
getAlertlMaintenance();
getDataPlanningByDate();
flag=true;
}
}
pending=0;
} else{
pending++;
if(timeNow.equals(timeReset)){
flag=false;
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
}, 1000L, 1000L);
}
}
@Autowired
private IpsrsMaintenanceService ipsrsMaintenanceService;
public void getAlertlMaintenance(){
try{
if (ipsrsMaintenanceService != null){
Map<String, Object> jadwalMaintenance = ipsrsMaintenanceService.getAlertMaintenance();
if(CommonUtil.isNotNullOrEmpty(jadwalMaintenance)){
BroadcastMessageOther("jadwalMaintenance", jadwalMaintenance);
System.out.println(DateUtil.now()+" task scheduler :");
System.out.println(new Gson().toJson(jadwalMaintenance));
} else{
System.out.println(DateUtil.now()+" task scheduler : tidak ada jadwal maintenance");
}
}
}catch (Exception ex){
ex.printStackTrace();
}
}
@Autowired
private PegawaiMutasiSanksiResignService pegawaiMutasiSanksiResignService;
@SuppressWarnings("unchecked")
public void getDataPlanningByDate(){
try{
if (pegawaiMutasiSanksiResignService != null) {
Map<String, Object> mapData = pegawaiMutasiSanksiResignService.getDataPlanningByDate(DateUtil.now());
if(CommonUtil.isNotNullOrEmpty(mapData)){
for(Map<String, Object> data : (List<Map<String, Object>>) mapData.get("listData")){
Map<String, Object> dataResult = pegawaiMutasiSanksiResignService.updateExecPegawai(data);
System.out.println(DateUtil.now()+" task scheduler : update pegawai "+new Gson().toJson(dataResult));
}
} else{
System.out.println(DateUtil.now()+" task scheduler : tidak ada update data pegawai musare");
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
*/
}

View File

@ -1,202 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
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 com.google.gson.Gson;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.dao.PegawaiDao;
import com.jasamedika.medifirst2000.dao.RuanganDao;
import com.jasamedika.medifirst2000.entities.ModulAplikasi;
import com.jasamedika.medifirst2000.entities.ObjekModulAplikasi;
import com.jasamedika.medifirst2000.entities.Pegawai;
import com.jasamedika.medifirst2000.entities.Ruangan;
import com.jasamedika.medifirst2000.notification.MessagePublisher;
import com.jasamedika.medifirst2000.service.NotifMessagingSchedulerService;
import com.jasamedika.medifirst2000.service.NotifMessagingService;
import com.jasamedika.medifirst2000.service.NotifikasiMessageObjekModulService;
import com.jasamedika.medifirst2000.service.PegawaiService;
import com.jasamedika.medifirst2000.service.RuanganService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.NotifMessagingSchedulerVO;
import com.jasamedika.medifirst2000.vo.NotifMessagingVO;
import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
import com.jasamedika.medifirst2000.vo.PegawaiVO;
import com.jasamedika.medifirst2000.vo.RuanganVO;
@Component
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO> {
/*
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
@Autowired
NotifMessagingSchedulerService<NotifMessagingSchedulerVO> notifMessagingSchedulerService;
@Autowired
NotifMessagingService<NotifMessagingVO> notifMessagingService;
@Autowired
NotifikasiMessageObjekModulService<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulService;
@Autowired
PegawaiService pegawaiService;
@Autowired
RuanganService<RuanganVO> ruanganService;
@Autowired
MessagePublisher<String, Object> messagePublisher;
@Autowired
PegawaiDao pegawaiDao;
@Autowired
RuanganDao ruanganDao;
@Scheduled(cron = "0 30 7 * * *")
public void NotificationNormalMaintenanceEvery730AM() {
try {
MessagePublisher.RabbitHole rabbitHole = messagePublisher.getRabbitHole();
List<NotifMessagingSchedulerVO> lNotif = notifMessagingSchedulerService.allNotifBelumTerkirim(new Date());
if (CommonUtil.isNullOrEmpty(lNotif)) {
LOG.info(DateUtil.now() + " task scheduler : tidak ada jadwal maintenance");
return;
}
Map<Integer, Integer> pegawaiRuangaAsal = new HashMap<>();
Map<Integer, List<Integer>> ruanganAsalAll = new HashMap<>();
Map<Integer, List<Integer>> notifMapAllRuanganTujuan = new HashMap<>();
List<Integer> notifsId = new ArrayList<>();
List<Integer> ruanganTujuansId = new ArrayList<>();
Integer oldNotifId = 0;
Integer oldRuanganIdTujuan = 0;
for (NotifMessagingSchedulerVO notif : lNotif) {
if (notif.getRuanganIdTujuan().intValue() != oldRuanganIdTujuan.intValue()) {
ruanganTujuansId = new ArrayList<>();
oldRuanganIdTujuan = notif.getRuanganIdTujuan();
}
ruanganTujuansId.add(notif.getRuanganIdTujuan());
notifMapAllRuanganTujuan.put(notif.getNotifMessagingId(), ruanganTujuansId);
if (notif.getNotifMessagingId().intValue() != oldNotifId.intValue()) {
notifsId = new ArrayList<>();
oldNotifId = notif.getNotifMessagingId();
}
notifsId.add(notif.getNotifMessagingId());
ruanganAsalAll.put(notif.getRuanganIdAsal(), notifsId);
pegawaiRuangaAsal.put(notif.getRuanganIdAsal(), notif.getPegawaiId());
}
Set<Integer> ruanganAsalIds = ruanganAsalAll.keySet();
for (Integer ruanganAsalId : ruanganAsalIds) {
Integer pegawaiId = pegawaiRuangaAsal.get(ruanganAsalId);
Pegawai pegawai = pegawaiDao.findById(pegawaiId);
Ruangan ruanganAsal = ruanganDao.findById(ruanganAsalId);
notifsId = ruanganAsalAll.get(ruanganAsalId);
for (Integer notifMessagingId : notifsId) {
ruanganTujuansId = notifMapAllRuanganTujuan.get(notifMessagingId);
try {
rabbitHole.sendNotif(rabbitHole, ruanganAsal, pegawai, notifikasiMessageObjekModulService,
notifMessagingId, ruanganTujuansId);
} catch (Exception e) {
LOG.info(
DateUtil.now()
+ " task scheduler dari Ruangan {} dengan ruanganId {} pada notifMessageId {} ada masalah {}",
ruanganAsal.getNamaRuangan(), ruanganAsalId, notifMessagingId, e.getMessage());
}
}
}
} catch (Exception e) {
LOG.info(DateUtil.now() + "Task scheduler gagal penyebab, {} ", e.getMessage());
// e.printStackTrace();
}
}
private void sendNotif(Gson gson, String urlSocket, MessagePublisher.RabbitHole rabbitHole, Integer pegawaiId,
Integer ruanganId, Integer notifMessagingId, List<Integer> ruanganTujuansId) throws Exception {
List<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulVOs = notifikasiMessageObjekModulService
.findByNotifMessagingIdAndRuanganId(notifMessagingId, ruanganTujuansId);
if (CommonUtil.isNullOrEmpty(notifikasiMessageObjekModulVOs)) {
return;
}
Integer ruanganIdtemp = 0;
boolean connect = false;
PegawaiVO pegawai = pegawaiService.findById(pegawaiId);
for (NotifikasiMessageObjekModulVO vo : notifikasiMessageObjekModulVOs) {
Ruangan ruangan = vo.getRuangan();
ModulAplikasi modulAplikasi = vo.getModulAplikasi();
ObjekModulAplikasi objekModulAplikasi = vo.getObjekModulAplikasi();
String customURLObjekModul = vo.getCustomURLObjekModul();
String titleNotifikasi = vo.getTitleNotifikasi();
String pesanNotifikasi = vo.getPesanNotifikasi();
String namaFungsiFrontEnd = vo.getNamaFungsiFrontEnd();
if (ruangan.getId() == ruanganId) {
continue;
}
RuanganVO dariRuangan = ruanganService.findById(ruanganId);
if (ruanganIdtemp != ruangan.getId()) {
if (connect) {
rabbitHole.close();
}
rabbitHole.connect(urlSocket, String.valueOf(ruangan.getId()));
connect = true;
ruanganIdtemp = ruangan.getId();
}
Map<String, Object> map = new HashMap<>();
map.put("title", titleNotifikasi);
map.put("dariRuangan", dariRuangan);
map.put("ruanganId", ruangan.getId());
map.put("ruangan", ruangan);
map.put("modulAplikasi", modulAplikasi);
map.put("objekModulAplikasi", objekModulAplikasi);
map.put("titleNotifikasi", titleNotifikasi);
map.put("pesanNotifikasi", pesanNotifikasi);
map.put("namaFungsiFrontEnd", namaFungsiFrontEnd);
map.put("fromPegawai", pegawai);
map.put("urlForm", CommonUtil.isNullOrEmpty(customURLObjekModul) ? objekModulAplikasi.getAlamatUrlForm()
: customURLObjekModul);
rabbitHole.sendRabbitMQNotification(gson.toJson(map));
messagePublisher.BroadcastMessage(map);
}
if (connect) {
rabbitHole.close();
}
}
*/
}

View File

@ -1,115 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.google.gson.Gson;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.IpsrsMaintenanceService;
import com.jasamedika.medifirst2000.service.PegawaiMutasiSanksiResignService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.IpsrsJadwalPemeliharaanVO;
@Component
public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemeliharaanVO>{
/*
private Boolean flag =false;
private Integer pending = 0;
private String time = new SimpleDateFormat("HH:mm").format(Calendar.getInstance().getTime());
private SimpleDateFormat format = new SimpleDateFormat("HH:mm");
public IpsrsAlertMaintenance() {
if(!Thread.currentThread().isInterrupted()){
try {
new Thread(new RunningTask()).start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
class RunningTask implements Runnable{
public void run() {
new Timer().schedule(new TimerTask(){
@Override
public void run() {
try{
Date timeNow = format.parse(time);
Date timeEnd = format.parse("18:00");
Date timeReset = format.parse("21:00");
if(pending==60*3){
if(timeNow.before(timeEnd)){
if(flag==false){
getAlertlMaintenance();
getDataPlanningByDate();
flag=true;
}
}
pending=0;
} else{
pending++;
if(timeNow.equals(timeReset)){
flag=false;
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
}, 1000L, 1000L);
}
}
@Autowired
private IpsrsMaintenanceService ipsrsMaintenanceService;
public void getAlertlMaintenance(){
try{
if (ipsrsMaintenanceService != null){
Map<String, Object> jadwalMaintenance = ipsrsMaintenanceService.getAlertMaintenance();
if(CommonUtil.isNotNullOrEmpty(jadwalMaintenance)){
BroadcastMessageOther("jadwalMaintenance", jadwalMaintenance);
System.out.println(DateUtil.now()+" task scheduler :");
System.out.println(new Gson().toJson(jadwalMaintenance));
} else{
System.out.println(DateUtil.now()+" task scheduler : tidak ada jadwal maintenance");
}
}
}catch (Exception ex){
ex.printStackTrace();
}
}
@Autowired
private PegawaiMutasiSanksiResignService pegawaiMutasiSanksiResignService;
@SuppressWarnings("unchecked")
public void getDataPlanningByDate(){
try{
if (pegawaiMutasiSanksiResignService != null) {
Map<String, Object> mapData = pegawaiMutasiSanksiResignService.getDataPlanningByDate(DateUtil.now());
if(CommonUtil.isNotNullOrEmpty(mapData)){
for(Map<String, Object> data : (List<Map<String, Object>>) mapData.get("listData")){
Map<String, Object> dataResult = pegawaiMutasiSanksiResignService.updateExecPegawai(data);
System.out.println(DateUtil.now()+" task scheduler : update pegawai "+new Gson().toJson(dataResult));
}
} else{
System.out.println(DateUtil.now()+" task scheduler : tidak ada update data pegawai musare");
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
*/
}

View File

@ -1,202 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
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 com.google.gson.Gson;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.dao.PegawaiDao;
import com.jasamedika.medifirst2000.dao.RuanganDao;
import com.jasamedika.medifirst2000.entities.ModulAplikasi;
import com.jasamedika.medifirst2000.entities.ObjekModulAplikasi;
import com.jasamedika.medifirst2000.entities.Pegawai;
import com.jasamedika.medifirst2000.entities.Ruangan;
import com.jasamedika.medifirst2000.notification.MessagePublisher;
import com.jasamedika.medifirst2000.service.NotifMessagingSchedulerService;
import com.jasamedika.medifirst2000.service.NotifMessagingService;
import com.jasamedika.medifirst2000.service.NotifikasiMessageObjekModulService;
import com.jasamedika.medifirst2000.service.PegawaiService;
import com.jasamedika.medifirst2000.service.RuanganService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.NotifMessagingSchedulerVO;
import com.jasamedika.medifirst2000.vo.NotifMessagingVO;
import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
import com.jasamedika.medifirst2000.vo.PegawaiVO;
import com.jasamedika.medifirst2000.vo.RuanganVO;
@Component
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO> {
/*
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
@Autowired
NotifMessagingSchedulerService<NotifMessagingSchedulerVO> notifMessagingSchedulerService;
@Autowired
NotifMessagingService<NotifMessagingVO> notifMessagingService;
@Autowired
NotifikasiMessageObjekModulService<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulService;
@Autowired
PegawaiService pegawaiService;
@Autowired
RuanganService<RuanganVO> ruanganService;
@Autowired
MessagePublisher<String, Object> messagePublisher;
@Autowired
PegawaiDao pegawaiDao;
@Autowired
RuanganDao ruanganDao;
@Scheduled(cron = "0 30 7 * * *")
public void NotificationNormalMaintenanceEvery730AM() {
try {
MessagePublisher.RabbitHole rabbitHole = messagePublisher.getRabbitHole();
List<NotifMessagingSchedulerVO> lNotif = notifMessagingSchedulerService.allNotifBelumTerkirim(new Date());
if (CommonUtil.isNullOrEmpty(lNotif)) {
LOG.info(DateUtil.now() + " task scheduler : tidak ada jadwal maintenance");
return;
}
Map<Integer, Integer> pegawaiRuangaAsal = new HashMap<>();
Map<Integer, List<Integer>> ruanganAsalAll = new HashMap<>();
Map<Integer, List<Integer>> notifMapAllRuanganTujuan = new HashMap<>();
List<Integer> notifsId = new ArrayList<>();
List<Integer> ruanganTujuansId = new ArrayList<>();
Integer oldNotifId = 0;
Integer oldRuanganIdTujuan = 0;
for (NotifMessagingSchedulerVO notif : lNotif) {
if (notif.getRuanganIdTujuan().intValue() != oldRuanganIdTujuan.intValue()) {
ruanganTujuansId = new ArrayList<>();
oldRuanganIdTujuan = notif.getRuanganIdTujuan();
}
ruanganTujuansId.add(notif.getRuanganIdTujuan());
notifMapAllRuanganTujuan.put(notif.getNotifMessagingId(), ruanganTujuansId);
if (notif.getNotifMessagingId().intValue() != oldNotifId.intValue()) {
notifsId = new ArrayList<>();
oldNotifId = notif.getNotifMessagingId();
}
notifsId.add(notif.getNotifMessagingId());
ruanganAsalAll.put(notif.getRuanganIdAsal(), notifsId);
pegawaiRuangaAsal.put(notif.getRuanganIdAsal(), notif.getPegawaiId());
}
Set<Integer> ruanganAsalIds = ruanganAsalAll.keySet();
for (Integer ruanganAsalId : ruanganAsalIds) {
Integer pegawaiId = pegawaiRuangaAsal.get(ruanganAsalId);
Pegawai pegawai = pegawaiDao.findById(pegawaiId);
Ruangan ruanganAsal = ruanganDao.findById(ruanganAsalId);
notifsId = ruanganAsalAll.get(ruanganAsalId);
for (Integer notifMessagingId : notifsId) {
ruanganTujuansId = notifMapAllRuanganTujuan.get(notifMessagingId);
try {
rabbitHole.sendNotif(rabbitHole, ruanganAsal, pegawai, notifikasiMessageObjekModulService,
notifMessagingId, ruanganTujuansId);
} catch (Exception e) {
LOG.info(
DateUtil.now()
+ " task scheduler dari Ruangan {} dengan ruanganId {} pada notifMessageId {} ada masalah {}",
ruanganAsal.getNamaRuangan(), ruanganAsalId, notifMessagingId, e.getMessage());
}
}
}
} catch (Exception e) {
LOG.info(DateUtil.now() + "Task scheduler gagal penyebab, {} ", e.getMessage());
// e.printStackTrace();
}
}
private void sendNotif(Gson gson, String urlSocket, MessagePublisher.RabbitHole rabbitHole, Integer pegawaiId,
Integer ruanganId, Integer notifMessagingId, List<Integer> ruanganTujuansId) throws Exception {
List<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulVOs = notifikasiMessageObjekModulService
.findByNotifMessagingIdAndRuanganId(notifMessagingId, ruanganTujuansId);
if (CommonUtil.isNullOrEmpty(notifikasiMessageObjekModulVOs)) {
return;
}
Integer ruanganIdtemp = 0;
boolean connect = false;
PegawaiVO pegawai = pegawaiService.findById(pegawaiId);
for (NotifikasiMessageObjekModulVO vo : notifikasiMessageObjekModulVOs) {
Ruangan ruangan = vo.getRuangan();
ModulAplikasi modulAplikasi = vo.getModulAplikasi();
ObjekModulAplikasi objekModulAplikasi = vo.getObjekModulAplikasi();
String customURLObjekModul = vo.getCustomURLObjekModul();
String titleNotifikasi = vo.getTitleNotifikasi();
String pesanNotifikasi = vo.getPesanNotifikasi();
String namaFungsiFrontEnd = vo.getNamaFungsiFrontEnd();
if (ruangan.getId() == ruanganId) {
continue;
}
RuanganVO dariRuangan = ruanganService.findById(ruanganId);
if (ruanganIdtemp != ruangan.getId()) {
if (connect) {
rabbitHole.close();
}
rabbitHole.connect(urlSocket, String.valueOf(ruangan.getId()));
connect = true;
ruanganIdtemp = ruangan.getId();
}
Map<String, Object> map = new HashMap<>();
map.put("title", titleNotifikasi);
map.put("dariRuangan", dariRuangan);
map.put("ruanganId", ruangan.getId());
map.put("ruangan", ruangan);
map.put("modulAplikasi", modulAplikasi);
map.put("objekModulAplikasi", objekModulAplikasi);
map.put("titleNotifikasi", titleNotifikasi);
map.put("pesanNotifikasi", pesanNotifikasi);
map.put("namaFungsiFrontEnd", namaFungsiFrontEnd);
map.put("fromPegawai", pegawai);
map.put("urlForm", CommonUtil.isNullOrEmpty(customURLObjekModul) ? objekModulAplikasi.getAlamatUrlForm()
: customURLObjekModul);
rabbitHole.sendRabbitMQNotification(gson.toJson(map));
messagePublisher.BroadcastMessage(map);
}
if (connect) {
rabbitHole.close();
}
}
*/
}

View File

@ -1,115 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.google.gson.Gson;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.IpsrsMaintenanceService;
import com.jasamedika.medifirst2000.service.PegawaiMutasiSanksiResignService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.IpsrsJadwalPemeliharaanVO;
@Component
public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemeliharaanVO>{
/*
private Boolean flag =false;
private Integer pending = 0;
private String time = new SimpleDateFormat("HH:mm").format(Calendar.getInstance().getTime());
private SimpleDateFormat format = new SimpleDateFormat("HH:mm");
public IpsrsAlertMaintenance() {
if(!Thread.currentThread().isInterrupted()){
try {
new Thread(new RunningTask()).start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
class RunningTask implements Runnable{
public void run() {
new Timer().schedule(new TimerTask(){
@Override
public void run() {
try{
Date timeNow = format.parse(time);
Date timeEnd = format.parse("18:00");
Date timeReset = format.parse("21:00");
if(pending==60*3){
if(timeNow.before(timeEnd)){
if(flag==false){
getAlertlMaintenance();
getDataPlanningByDate();
flag=true;
}
}
pending=0;
} else{
pending++;
if(timeNow.equals(timeReset)){
flag=false;
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
}, 1000L, 1000L);
}
}
@Autowired
private IpsrsMaintenanceService ipsrsMaintenanceService;
public void getAlertlMaintenance(){
try{
if (ipsrsMaintenanceService != null){
Map<String, Object> jadwalMaintenance = ipsrsMaintenanceService.getAlertMaintenance();
if(CommonUtil.isNotNullOrEmpty(jadwalMaintenance)){
BroadcastMessageOther("jadwalMaintenance", jadwalMaintenance);
System.out.println(DateUtil.now()+" task scheduler :");
System.out.println(new Gson().toJson(jadwalMaintenance));
} else{
System.out.println(DateUtil.now()+" task scheduler : tidak ada jadwal maintenance");
}
}
}catch (Exception ex){
ex.printStackTrace();
}
}
@Autowired
private PegawaiMutasiSanksiResignService pegawaiMutasiSanksiResignService;
@SuppressWarnings("unchecked")
public void getDataPlanningByDate(){
try{
if (pegawaiMutasiSanksiResignService != null) {
Map<String, Object> mapData = pegawaiMutasiSanksiResignService.getDataPlanningByDate(DateUtil.now());
if(CommonUtil.isNotNullOrEmpty(mapData)){
for(Map<String, Object> data : (List<Map<String, Object>>) mapData.get("listData")){
Map<String, Object> dataResult = pegawaiMutasiSanksiResignService.updateExecPegawai(data);
System.out.println(DateUtil.now()+" task scheduler : update pegawai "+new Gson().toJson(dataResult));
}
} else{
System.out.println(DateUtil.now()+" task scheduler : tidak ada update data pegawai musare");
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
*/
}

View File

@ -1,186 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
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 com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.dao.PegawaiDao;
import com.jasamedika.medifirst2000.dao.RuanganDao;
import com.jasamedika.medifirst2000.entities.Pegawai;
import com.jasamedika.medifirst2000.entities.Ruangan;
import com.jasamedika.medifirst2000.notification.MessagePublisher;
import com.jasamedika.medifirst2000.service.NotifMessagingSchedulerService;
import com.jasamedika.medifirst2000.service.NotifMessagingService;
import com.jasamedika.medifirst2000.service.NotifikasiMessageObjekModulService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.NotifMessagingSchedulerVO;
import com.jasamedika.medifirst2000.vo.NotifMessagingVO;
import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
@Component
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO>{
/*
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
@Autowired
NotifMessagingSchedulerService<NotifMessagingSchedulerVO> notifMessagingSchedulerService;
@Autowired
NotifMessagingService<NotifMessagingVO> notifMessagingService;
@Autowired
NotifikasiMessageObjekModulService<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulService;
@Autowired
MessagePublisher<String, Object> messagePublisher;
@Autowired
PegawaiDao pegawaiDao;
@Autowired
RuanganDao ruanganDao;
@Scheduled(cron = "0 30 7 * * *")
public void NotificationNormalMaintenanceEvery730AM(){
try{
MessagePublisher.RabbitHole rabbitHole = messagePublisher.getRabbitHole();
List<NotifMessagingSchedulerVO> lNotif = notifMessagingSchedulerService.allNotifBelumTerkirim(new Date());
if (CommonUtil.isNullOrEmpty(lNotif)){
LOG.info(DateUtil.now()+" task scheduler : tidak ada jadwal maintenance");
return;
}
Map<Integer, Integer> pegawaiRuangaAsal = new HashMap<>();
Map<Integer, List<Integer>> ruanganAsalAll = new HashMap<>();
Map<Integer, List<Integer>> notifMapAllRuanganTujuan = new HashMap<>();
List<Integer> notifsId = new ArrayList<>();
List<Integer> ruanganTujuansId = new ArrayList<>();
Integer oldNotifId = 0;
Integer oldRuanganIdTujuan = 0;
for (NotifMessagingSchedulerVO notif:lNotif){
if (notif.getRuanganIdTujuan().intValue() != oldRuanganIdTujuan.intValue()){
ruanganTujuansId = new ArrayList<>();
oldRuanganIdTujuan = notif.getRuanganIdTujuan();
}
ruanganTujuansId.add(notif.getRuanganIdTujuan());
notifMapAllRuanganTujuan.put(notif.getNotifMessagingId(), ruanganTujuansId);
if (notif.getNotifMessagingId().intValue() != oldNotifId.intValue()){
notifsId = new ArrayList<>();
oldNotifId = notif.getNotifMessagingId();
}
notifsId.add(notif.getNotifMessagingId());
ruanganAsalAll.put(notif.getRuanganIdAsal(), notifsId);
pegawaiRuangaAsal.put(notif.getRuanganIdAsal(), notif.getPegawaiId());
}
Set<Integer> ruanganAsalIds = ruanganAsalAll.keySet();
for(Integer ruanganAsalId:ruanganAsalIds){
Integer pegawaiId = pegawaiRuangaAsal.get(ruanganAsalId);
Pegawai pegawai = pegawaiDao.findById(pegawaiId);
Ruangan ruanganAsal = ruanganDao.findById(ruanganAsalId);
notifsId = ruanganAsalAll.get(ruanganAsalId);
for (Integer notifMessagingId:notifsId ){
ruanganTujuansId = notifMapAllRuanganTujuan.get(notifMessagingId);
try{
rabbitHole.sendNotif(rabbitHole, ruanganAsal, pegawai, notifikasiMessageObjekModulService, notifMessagingId, ruanganTujuansId);
}catch(Exception e){
LOG.info(DateUtil.now()+" task scheduler dari Ruangan {} dengan ruanganId {} pada notifMessageId {} ada masalah {}",
ruanganAsal.getNamaRuangan(), ruanganAsalId, notifMessagingId, e.getMessage());
}
}
}
}catch(Exception e){
LOG.info(DateUtil.now() + "Task scheduler gagal penyebab, {} ", e.getMessage());
//e.printStackTrace();
}
}
*/
}
//private void sendNotif(Gson gson, String urlSocket, MessagePublisher.RabbitHole rabbitHole, Integer pegawaiId, Integer ruanganId, Integer notifMessagingId, List<Integer> ruanganTujuansId) throws Exception{
//
//List<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulVOs = notifikasiMessageObjekModulService.findByNotifMessagingIdAndRuanganId(notifMessagingId, ruanganTujuansId);
//
//if (CommonUtil.isNullOrEmpty(notifikasiMessageObjekModulVOs)) {
// return;
//}
//
//Integer ruanganIdtemp = 0;
//boolean connect = false;
//
//PegawaiVO pegawai = pegawaiService.findById(pegawaiId);
//
//for (NotifikasiMessageObjekModulVO vo : notifikasiMessageObjekModulVOs){
// Ruangan ruangan = vo.getRuangan();
// ModulAplikasi modulAplikasi = vo.getModulAplikasi();
// ObjekModulAplikasi objekModulAplikasi = vo.getObjekModulAplikasi();
// String customURLObjekModul = vo.getCustomURLObjekModul();
// String titleNotifikasi = vo.getTitleNotifikasi();
// String pesanNotifikasi = vo.getPesanNotifikasi();
// String namaFungsiFrontEnd = vo.getNamaFungsiFrontEnd();
//
// if (ruangan.getId() == ruanganId){
// continue;
// }
//
// RuanganVO dariRuangan = ruanganService.findById(ruanganId);
//
// if (ruanganIdtemp != ruangan.getId()){
// if (connect){
// rabbitHole.close();
// }
// rabbitHole.connect(urlSocket, String.valueOf(ruangan.getId()));
// connect = true;
// ruanganIdtemp = ruangan.getId();
// }
//
// Map<String, Object> map = new HashMap<>();
// map.put("title", titleNotifikasi);
// map.put("dariRuangan", dariRuangan);
// map.put("ruanganId", ruangan.getId());
// map.put("ruangan", ruangan);
// map.put("modulAplikasi", modulAplikasi);
// map.put("objekModulAplikasi", objekModulAplikasi);
// map.put("titleNotifikasi", titleNotifikasi);
// map.put("pesanNotifikasi", pesanNotifikasi);
// map.put("namaFungsiFrontEnd", namaFungsiFrontEnd);
// map.put("fromPegawai", pegawai);
// map.put("urlForm",CommonUtil.isNullOrEmpty(customURLObjekModul)? objekModulAplikasi.getAlamatUrlForm() : customURLObjekModul);
//
// rabbitHole.sendRabbitMQNotification(gson.toJson(map));
//
// //messagePublisher.BroadcastMessage(map);
//}
//if (connect){
// rabbitHole.close();
//}
//
//}

View File

@ -1,115 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.google.gson.Gson;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.IpsrsMaintenanceService;
import com.jasamedika.medifirst2000.service.PegawaiMutasiSanksiResignService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.IpsrsJadwalPemeliharaanVO;
@Component
public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemeliharaanVO>{
/*
private Boolean flag =false;
private Integer pending = 0;
private String time = new SimpleDateFormat("HH:mm").format(Calendar.getInstance().getTime());
private SimpleDateFormat format = new SimpleDateFormat("HH:mm");
public IpsrsAlertMaintenance() {
if(!Thread.currentThread().isInterrupted()){
try {
new Thread(new RunningTask()).start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
class RunningTask implements Runnable{
public void run() {
new Timer().schedule(new TimerTask(){
@Override
public void run() {
try{
Date timeNow = format.parse(time);
Date timeEnd = format.parse("18:00");
Date timeReset = format.parse("21:00");
if(pending==60*3){
if(timeNow.before(timeEnd)){
if(flag==false){
getAlertlMaintenance();
getDataPlanningByDate();
flag=true;
}
}
pending=0;
} else{
pending++;
if(timeNow.equals(timeReset)){
flag=false;
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
}, 1000L, 1000L);
}
}
@Autowired
private IpsrsMaintenanceService ipsrsMaintenanceService;
public void getAlertlMaintenance(){
try{
if (ipsrsMaintenanceService != null){
Map<String, Object> jadwalMaintenance = ipsrsMaintenanceService.getAlertMaintenance();
if(CommonUtil.isNotNullOrEmpty(jadwalMaintenance)){
BroadcastMessageOther("jadwalMaintenance", jadwalMaintenance);
System.out.println(DateUtil.now()+" task scheduler :");
System.out.println(new Gson().toJson(jadwalMaintenance));
} else{
System.out.println(DateUtil.now()+" task scheduler : tidak ada jadwal maintenance");
}
}
}catch (Exception ex){
ex.printStackTrace();
}
}
@Autowired
private PegawaiMutasiSanksiResignService pegawaiMutasiSanksiResignService;
@SuppressWarnings("unchecked")
public void getDataPlanningByDate(){
try{
if (pegawaiMutasiSanksiResignService != null) {
Map<String, Object> mapData = pegawaiMutasiSanksiResignService.getDataPlanningByDate(DateUtil.now());
if(CommonUtil.isNotNullOrEmpty(mapData)){
for(Map<String, Object> data : (List<Map<String, Object>>) mapData.get("listData")){
Map<String, Object> dataResult = pegawaiMutasiSanksiResignService.updateExecPegawai(data);
System.out.println(DateUtil.now()+" task scheduler : update pegawai "+new Gson().toJson(dataResult));
}
} else{
System.out.println(DateUtil.now()+" task scheduler : tidak ada update data pegawai musare");
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
*/
}

View File

@ -1,186 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
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 com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.dao.PegawaiDao;
import com.jasamedika.medifirst2000.dao.RuanganDao;
import com.jasamedika.medifirst2000.entities.Pegawai;
import com.jasamedika.medifirst2000.entities.Ruangan;
import com.jasamedika.medifirst2000.notification.MessagePublisher;
import com.jasamedika.medifirst2000.service.NotifMessagingSchedulerService;
import com.jasamedika.medifirst2000.service.NotifMessagingService;
import com.jasamedika.medifirst2000.service.NotifikasiMessageObjekModulService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.NotifMessagingSchedulerVO;
import com.jasamedika.medifirst2000.vo.NotifMessagingVO;
import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
@Component
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO>{
/*
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
@Autowired
NotifMessagingSchedulerService<NotifMessagingSchedulerVO> notifMessagingSchedulerService;
@Autowired
NotifMessagingService<NotifMessagingVO> notifMessagingService;
@Autowired
NotifikasiMessageObjekModulService<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulService;
@Autowired
MessagePublisher<String, Object> messagePublisher;
@Autowired
PegawaiDao pegawaiDao;
@Autowired
RuanganDao ruanganDao;
@Scheduled(cron = "0 30 7 * * *")
public void NotificationNormalMaintenanceEvery730AM(){
try{
MessagePublisher.RabbitHole rabbitHole = messagePublisher.getRabbitHole();
List<NotifMessagingSchedulerVO> lNotif = notifMessagingSchedulerService.allNotifBelumTerkirim(new Date());
if (CommonUtil.isNullOrEmpty(lNotif)){
LOG.info(DateUtil.now()+" task scheduler : tidak ada jadwal maintenance");
return;
}
Map<Integer, Integer> pegawaiRuangaAsal = new HashMap<>();
Map<Integer, List<Integer>> ruanganAsalAll = new HashMap<>();
Map<Integer, List<Integer>> notifMapAllRuanganTujuan = new HashMap<>();
List<Integer> notifsId = new ArrayList<>();
List<Integer> ruanganTujuansId = new ArrayList<>();
Integer oldNotifId = 0;
Integer oldRuanganIdTujuan = 0;
for (NotifMessagingSchedulerVO notif:lNotif){
if (notif.getRuanganIdTujuan().intValue() != oldRuanganIdTujuan.intValue()){
ruanganTujuansId = new ArrayList<>();
oldRuanganIdTujuan = notif.getRuanganIdTujuan();
}
ruanganTujuansId.add(notif.getRuanganIdTujuan());
notifMapAllRuanganTujuan.put(notif.getNotifMessagingId(), ruanganTujuansId);
if (notif.getNotifMessagingId().intValue() != oldNotifId.intValue()){
notifsId = new ArrayList<>();
oldNotifId = notif.getNotifMessagingId();
}
notifsId.add(notif.getNotifMessagingId());
ruanganAsalAll.put(notif.getRuanganIdAsal(), notifsId);
pegawaiRuangaAsal.put(notif.getRuanganIdAsal(), notif.getPegawaiId());
}
Set<Integer> ruanganAsalIds = ruanganAsalAll.keySet();
for(Integer ruanganAsalId:ruanganAsalIds){
Integer pegawaiId = pegawaiRuangaAsal.get(ruanganAsalId);
Pegawai pegawai = pegawaiDao.findById(pegawaiId);
Ruangan ruanganAsal = ruanganDao.findById(ruanganAsalId);
notifsId = ruanganAsalAll.get(ruanganAsalId);
for (Integer notifMessagingId:notifsId ){
ruanganTujuansId = notifMapAllRuanganTujuan.get(notifMessagingId);
try{
rabbitHole.sendNotif(rabbitHole, ruanganAsal, pegawai, notifikasiMessageObjekModulService, notifMessagingId, ruanganTujuansId);
}catch(Exception e){
LOG.info(DateUtil.now()+" task scheduler dari Ruangan {} dengan ruanganId {} pada notifMessageId {} ada masalah {}",
ruanganAsal.getNamaRuangan(), ruanganAsalId, notifMessagingId, e.getMessage());
}
}
}
}catch(Exception e){
LOG.info(DateUtil.now() + "Task scheduler gagal penyebab, {} ", e.getMessage());
//e.printStackTrace();
}
}
*/
}
//private void sendNotif(Gson gson, String urlSocket, MessagePublisher.RabbitHole rabbitHole, Integer pegawaiId, Integer ruanganId, Integer notifMessagingId, List<Integer> ruanganTujuansId) throws Exception{
//
//List<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulVOs = notifikasiMessageObjekModulService.findByNotifMessagingIdAndRuanganId(notifMessagingId, ruanganTujuansId);
//
//if (CommonUtil.isNullOrEmpty(notifikasiMessageObjekModulVOs)) {
// return;
//}
//
//Integer ruanganIdtemp = 0;
//boolean connect = false;
//
//PegawaiVO pegawai = pegawaiService.findById(pegawaiId);
//
//for (NotifikasiMessageObjekModulVO vo : notifikasiMessageObjekModulVOs){
// Ruangan ruangan = vo.getRuangan();
// ModulAplikasi modulAplikasi = vo.getModulAplikasi();
// ObjekModulAplikasi objekModulAplikasi = vo.getObjekModulAplikasi();
// String customURLObjekModul = vo.getCustomURLObjekModul();
// String titleNotifikasi = vo.getTitleNotifikasi();
// String pesanNotifikasi = vo.getPesanNotifikasi();
// String namaFungsiFrontEnd = vo.getNamaFungsiFrontEnd();
//
// if (ruangan.getId() == ruanganId){
// continue;
// }
//
// RuanganVO dariRuangan = ruanganService.findById(ruanganId);
//
// if (ruanganIdtemp != ruangan.getId()){
// if (connect){
// rabbitHole.close();
// }
// rabbitHole.connect(urlSocket, String.valueOf(ruangan.getId()));
// connect = true;
// ruanganIdtemp = ruangan.getId();
// }
//
// Map<String, Object> map = new HashMap<>();
// map.put("title", titleNotifikasi);
// map.put("dariRuangan", dariRuangan);
// map.put("ruanganId", ruangan.getId());
// map.put("ruangan", ruangan);
// map.put("modulAplikasi", modulAplikasi);
// map.put("objekModulAplikasi", objekModulAplikasi);
// map.put("titleNotifikasi", titleNotifikasi);
// map.put("pesanNotifikasi", pesanNotifikasi);
// map.put("namaFungsiFrontEnd", namaFungsiFrontEnd);
// map.put("fromPegawai", pegawai);
// map.put("urlForm",CommonUtil.isNullOrEmpty(customURLObjekModul)? objekModulAplikasi.getAlamatUrlForm() : customURLObjekModul);
//
// rabbitHole.sendRabbitMQNotification(gson.toJson(map));
//
// //messagePublisher.BroadcastMessage(map);
//}
//if (connect){
// rabbitHole.close();
//}
//
//}

View File

@ -1,115 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.google.gson.Gson;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.IpsrsMaintenanceService;
import com.jasamedika.medifirst2000.service.PegawaiMutasiSanksiResignService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.IpsrsJadwalPemeliharaanVO;
@Component
public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemeliharaanVO>{
/*
private Boolean flag =false;
private Integer pending = 0;
private String time = new SimpleDateFormat("HH:mm").format(Calendar.getInstance().getTime());
private SimpleDateFormat format = new SimpleDateFormat("HH:mm");
public IpsrsAlertMaintenance() {
if(!Thread.currentThread().isInterrupted()){
try {
// new Thread(new RunningTask()).start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
class RunningTask implements Runnable{
public void run() {
new Timer().schedule(new TimerTask(){
@Override
public void run() {
try{
Date timeNow = format.parse(time);
Date timeEnd = format.parse("18:00");
Date timeReset = format.parse("21:00");
if(pending==60*3){
if(timeNow.before(timeEnd)){
if(flag==false){
// getAlertlMaintenance();
// getDataPlanningByDate();
flag=true;
}
}
pending=0;
} else{
pending++;
if(timeNow.equals(timeReset)){
flag=false;
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
}, 1000L, 1000L);
}
}
@Autowired
private IpsrsMaintenanceService ipsrsMaintenanceService;
public void getAlertlMaintenance(){
try{
if (ipsrsMaintenanceService != null){
Map<String, Object> jadwalMaintenance = ipsrsMaintenanceService.getAlertMaintenance();
if(CommonUtil.isNotNullOrEmpty(jadwalMaintenance)){
BroadcastMessageOther("jadwalMaintenance", jadwalMaintenance);
System.out.println(DateUtil.now()+" task scheduler :");
System.out.println(new Gson().toJson(jadwalMaintenance));
} else{
System.out.println(DateUtil.now()+" task scheduler : tidak ada jadwal maintenance");
}
}
}catch (Exception ex){
ex.printStackTrace();
}
}
@Autowired
private PegawaiMutasiSanksiResignService pegawaiMutasiSanksiResignService;
@SuppressWarnings("unchecked")
public void getDataPlanningByDate(){
try{
if (pegawaiMutasiSanksiResignService != null) {
Map<String, Object> mapData = pegawaiMutasiSanksiResignService.getDataPlanningByDate(DateUtil.now());
if(CommonUtil.isNotNullOrEmpty(mapData)){
for(Map<String, Object> data : (List<Map<String, Object>>) mapData.get("listData")){
Map<String, Object> dataResult = pegawaiMutasiSanksiResignService.updateExecPegawai(data);
System.out.println(DateUtil.now()+" task scheduler : update pegawai "+new Gson().toJson(dataResult));
}
} else{
System.out.println(DateUtil.now()+" task scheduler : tidak ada update data pegawai musare");
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
*/
}

View File

@ -1,173 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.dao.PegawaiDao;
import com.jasamedika.medifirst2000.dao.RuanganDao;
import com.jasamedika.medifirst2000.notification.MessagePublisher;
import com.jasamedika.medifirst2000.service.NotifMessagingSchedulerService;
import com.jasamedika.medifirst2000.service.NotifMessagingService;
import com.jasamedika.medifirst2000.service.NotifikasiMessageObjekModulService;
import com.jasamedika.medifirst2000.vo.NotifMessagingSchedulerVO;
import com.jasamedika.medifirst2000.vo.NotifMessagingVO;
import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
@Component
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO>{
/*
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
@Autowired
NotifMessagingSchedulerService<NotifMessagingSchedulerVO> notifMessagingSchedulerService;
@Autowired
NotifMessagingService<NotifMessagingVO> notifMessagingService;
@Autowired
NotifikasiMessageObjekModulService<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulService;
@Autowired
MessagePublisher<String, Object> messagePublisher;
@Autowired
PegawaiDao pegawaiDao;
@Autowired
RuanganDao ruanganDao;
*/
// @Scheduled(cron = "0 30 7 * * *")
// public void NotificationNormalMaintenanceEvery730AM(){
// try{
// MessagePublisher.RabbitHole rabbitHole = messagePublisher.getRabbitHole();
//
// List<NotifMessagingSchedulerVO> lNotif = notifMessagingSchedulerService.allNotifBelumTerkirim(new Date());
//
// if (CommonUtil.isNullOrEmpty(lNotif)){
// LOG.info(DateUtil.now()+" task scheduler : tidak ada jadwal maintenance");
// return;
// }
//
// Map<Integer, Integer> pegawaiRuangaAsal = new HashMap<>();
//
// Map<Integer, List<Integer>> ruanganAsalAll = new HashMap<>();
// Map<Integer, List<Integer>> notifMapAllRuanganTujuan = new HashMap<>();
// List<Integer> notifsId = new ArrayList<>();
// List<Integer> ruanganTujuansId = new ArrayList<>();
//
// Integer oldNotifId = 0;
// Integer oldRuanganIdTujuan = 0;
//
// for (NotifMessagingSchedulerVO notif:lNotif){
//
// if (notif.getRuanganIdTujuan().intValue() != oldRuanganIdTujuan.intValue()){
// ruanganTujuansId = new ArrayList<>();
// oldRuanganIdTujuan = notif.getRuanganIdTujuan();
// }
// ruanganTujuansId.add(notif.getRuanganIdTujuan());
// notifMapAllRuanganTujuan.put(notif.getNotifMessagingId(), ruanganTujuansId);
//
// if (notif.getNotifMessagingId().intValue() != oldNotifId.intValue()){
// notifsId = new ArrayList<>();
// oldNotifId = notif.getNotifMessagingId();
// }
//
// notifsId.add(notif.getNotifMessagingId());
// ruanganAsalAll.put(notif.getRuanganIdAsal(), notifsId);
//
// pegawaiRuangaAsal.put(notif.getRuanganIdAsal(), notif.getPegawaiId());
// }
//
// Set<Integer> ruanganAsalIds = ruanganAsalAll.keySet();
//
// for(Integer ruanganAsalId:ruanganAsalIds){
//
// Integer pegawaiId = pegawaiRuangaAsal.get(ruanganAsalId);
// Pegawai pegawai = pegawaiDao.findById(pegawaiId);
// Ruangan ruanganAsal = ruanganDao.findById(ruanganAsalId);
//
// notifsId = ruanganAsalAll.get(ruanganAsalId);
//
// for (Integer notifMessagingId:notifsId ){
//
// ruanganTujuansId = notifMapAllRuanganTujuan.get(notifMessagingId);
//
// try{
// rabbitHole.sendNotif(rabbitHole, ruanganAsal, pegawai, notifikasiMessageObjekModulService, notifMessagingId, ruanganTujuansId);
// }catch(Exception e){
// LOG.info(DateUtil.now()+" task scheduler dari Ruangan {} dengan ruanganId {} pada notifMessageId {} ada masalah {}",
// ruanganAsal.getNamaRuangan(), ruanganAsalId, notifMessagingId, e.getMessage());
// }
// }
// }
// }catch(Exception e){
// LOG.info(DateUtil.now() + "Task scheduler gagal penyebab, {} ", e.getMessage());
// //e.printStackTrace();
// }
// }
}
//private void sendNotif(Gson gson, String urlSocket, MessagePublisher.RabbitHole rabbitHole, Integer pegawaiId, Integer ruanganId, Integer notifMessagingId, List<Integer> ruanganTujuansId) throws Exception{
//
//List<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulVOs = notifikasiMessageObjekModulService.findByNotifMessagingIdAndRuanganId(notifMessagingId, ruanganTujuansId);
//
//if (CommonUtil.isNullOrEmpty(notifikasiMessageObjekModulVOs)) {
// return;
//}
//
//Integer ruanganIdtemp = 0;
//boolean connect = false;
//
//PegawaiVO pegawai = pegawaiService.findById(pegawaiId);
//
//for (NotifikasiMessageObjekModulVO vo : notifikasiMessageObjekModulVOs){
// Ruangan ruangan = vo.getRuangan();
// ModulAplikasi modulAplikasi = vo.getModulAplikasi();
// ObjekModulAplikasi objekModulAplikasi = vo.getObjekModulAplikasi();
// String customURLObjekModul = vo.getCustomURLObjekModul();
// String titleNotifikasi = vo.getTitleNotifikasi();
// String pesanNotifikasi = vo.getPesanNotifikasi();
// String namaFungsiFrontEnd = vo.getNamaFungsiFrontEnd();
//
// if (ruangan.getId() == ruanganId){
// continue;
// }
//
// RuanganVO dariRuangan = ruanganService.findById(ruanganId);
//
// if (ruanganIdtemp != ruangan.getId()){
// if (connect){
// rabbitHole.close();
// }
// rabbitHole.connect(urlSocket, String.valueOf(ruangan.getId()));
// connect = true;
// ruanganIdtemp = ruangan.getId();
// }
//
// Map<String, Object> map = new HashMap<>();
// map.put("title", titleNotifikasi);
// map.put("dariRuangan", dariRuangan);
// map.put("ruanganId", ruangan.getId());
// map.put("ruangan", ruangan);
// map.put("modulAplikasi", modulAplikasi);
// map.put("objekModulAplikasi", objekModulAplikasi);
// map.put("titleNotifikasi", titleNotifikasi);
// map.put("pesanNotifikasi", pesanNotifikasi);
// map.put("namaFungsiFrontEnd", namaFungsiFrontEnd);
// map.put("fromPegawai", pegawai);
// map.put("urlForm",CommonUtil.isNullOrEmpty(customURLObjekModul)? objekModulAplikasi.getAlamatUrlForm() : customURLObjekModul);
//
// rabbitHole.sendRabbitMQNotification(gson.toJson(map));
//
// //messagePublisher.BroadcastMessage(map);
//}
//if (connect){
// rabbitHole.close();
//}
//
//}

View File

@ -1,69 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.util.Calendar;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import com.jasamedika.medifirst2000.asynctask.timer.KontrakVerificationTimer;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.dao.SettingDataFixedDao;
import com.jasamedika.medifirst2000.service.LogbookKinerjaService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.LogbookKinerjaVO;
@Component
public class AutoKontrakVerification extends LocaleController<LogbookKinerjaVO> {
private final static Logger LOGGER = LoggerFactory.getLogger(AutoKontrakVerification.class);
@Autowired
private LogbookKinerjaService logbookKinerjaService;
@Autowired
private SettingDataFixedDao settingDataFixedDao;
public AutoKontrakVerification() {
// int day = 21;
// int hour = 0;
// int minute = 00;
// KontrakVerificationTimer.schedule(new Runnable() {
// @Override
// public void run() {
// try {
// LOGGER.info("Task Kontrak Verification : Running Task Kontrak Verification");
// autoKontrakVerification();
// } catch (Exception ex) {
// LOGGER.error("Task Kontrak Verification : Task Kontrak Verification " + ex.getMessage());
// } finally {
// LOGGER.info("Task Kontrak Verification : Finishing Task Kontrak Verification");
// }
// }
// }, day, hour, minute);
}
// @Async
public void autoKontrakVerification() {
try {
if (CommonUtil.isNotNullOrEmpty(logbookKinerjaService)) {
LOGGER.info("Task Kontrak Verification : Running Automatic Kontrak Verification");
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, +1);
if (Boolean.parseBoolean(
settingDataFixedDao.getSettingDataFixed("otomatisVerifikasiKontrakKinerjaDokter"))) {
logbookKinerjaService.autoVerifKontrakJamKerjaDokter(cal.getTime());
}
} else {
LOGGER.warn("Task Kontrak Verification : Undefined service");
}
} catch (Exception ex) {
LOGGER.error("Task Kontrak Verification : Automatic Kontrak Verification " + ex.getMessage());
} finally {
LOGGER.info("Task Kontrak Verification : Finishing Automatic Kontrak Verification");
}
}
}

View File

@ -1,62 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.util.Calendar;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import com.jasamedika.medifirst2000.asynctask.timer.LogbookVerificationTimer;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.LogbookKinerjaService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.LogbookKinerjaVO;
@Component
public class AutoLogbookVerification extends LocaleController<LogbookKinerjaVO> {
private final static Logger LOGGER = LoggerFactory.getLogger(AutoLogbookVerification.class);
@Autowired
private LogbookKinerjaService logbookKinerjaService;
public AutoLogbookVerification() {
// int day = 5;
// int hour = 0;
// int minute = 00;
// LogbookVerificationTimer.schedule(new Runnable() {
// @Override
// public void run() {
// try {
// LOGGER.info("Task Logbook Verification : Running Task Logbook Verification");
// autoLogbookVerification();
// } catch (Exception ex) {
// LOGGER.error("Task Logbook Verification : Task Logbook Verification " + ex.getMessage());
// } finally {
// LOGGER.info("Task Logbook Verification : Finishing Task Logbook Verification");
// }
// }
// }, day, hour, minute);
}
// @Async
public void autoLogbookVerification() {
try {
if (CommonUtil.isNotNullOrEmpty(logbookKinerjaService)) {
LOGGER.info("Task Logbook Verification : Running Automatic Logbook Verification");
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, -1);
logbookKinerjaService.autoVerifLogbookJamKerjaDokter(cal.getTime());
} else {
LOGGER.warn("Task Logbook Verification : Undefined service");
}
} catch (Exception ex) {
LOGGER.error("Task Logbook Verification : Automatic Logbook Verification " + ex.getMessage());
} finally {
LOGGER.info("Task Logbook Verification : Finishing Automatic Logbook Verification");
}
}
}

View File

@ -1,50 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.KalenderService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.KalenderVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class CalendarSystemGenerating extends LocaleController<KalenderVO> {
private final static Logger LOGGER = LoggerFactory.getLogger(CalendarSystemGenerating.class);
@Autowired
private KalenderService kalenderService;
public CalendarSystemGenerating() {
// int the1st = 1;
// int at0hrs = 0;
// KalenderTimer.schedule(() -> {
// try {
// LOGGER.info("Task Sistem Kalender : Running Task Sistem Kalender");
// genSistemKalender();
// } catch (Exception ex) {
// LOGGER.error("Task Sistem Kalender : Task Sistem Kalender " + ex.getMessage());
// } finally {
// LOGGER.info("Task Sistem Kalender : Finishing Task Sistem Kalender");
// }
// }, the1st, at0hrs);
}
// @Async
public void genSistemKalender() {
try {
if (CommonUtil.isNotNullOrEmpty(kalenderService)) {
LOGGER.info("Task Sistem Kalender : Running Check/Generate Sistem Kalender");
kalenderService.generateAndSaveKalender();
} else {
LOGGER.warn("Task Sistem Kalender : Undefined service");
}
} catch (Exception ex) {
LOGGER.error("Task Sistem Kalender : Check/Generate Sistem Kalender " + ex.getMessage());
} finally {
LOGGER.info("Task Sistem Kalender : Finishing Check/Generate Sistem Kalender");
}
}
}

View File

@ -1,51 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import com.jasamedika.medifirst2000.service.SlipGajiService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author Salman
*
*/
@Component
public class InitiateSlipGaji {
private final static Logger LOGGER = LoggerFactory.getLogger(InitiateSlipGaji.class);
@Autowired
private SlipGajiService slipGajiService;
public InitiateSlipGaji() {
// int the1st = 1;
// int at0hrs = 0;
// InitiateSlipGajiTimer.schedule(() -> {
// try {
// LOGGER.info("Slip Gaji : Call initiate data");
// initiateData();
// } catch (Exception ex) {
// LOGGER.error("Slip Gaji : Error when initiate data " + ex.getMessage());
// } finally {
// LOGGER.info("Slip Gaji : Finishing call initiate data");
// }
// }, the1st, at0hrs);
}
// @Async
public void initiateData() {
try {
if (CommonUtil.isNotNullOrEmpty(slipGajiService)) {
LOGGER.info("Slip Gaji : Initiating");
slipGajiService.init();
} else {
LOGGER.warn("Slip Gaji : Undefined service");
}
} catch (Exception ex) {
LOGGER.error("Slip Gaji : Error when initiating " + ex.getMessage());
} finally {
LOGGER.info("Slip Gaji : Finish initiating");
}
}
}

View File

@ -1,50 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.PegawaiJadwalKerjaService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.PegawaiJadwalKerjaVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class PegawaiJadwalKerjaGenerating extends LocaleController<PegawaiJadwalKerjaVO> {
private final static Logger LOGGER = LoggerFactory.getLogger(PegawaiJadwalKerjaGenerating.class);
@Autowired
private PegawaiJadwalKerjaService pegawaiJadwalKerjaService;
public PegawaiJadwalKerjaGenerating() {
// int the1st = 1;
// int at0hrs = 0;
// JadwalKerjaTimer.schedule(() -> {
// try {
// LOGGER.info("Task Jadwal Kerja : Running Task Jadwal Kerja");
// genJadwalKerja();
// } catch (Exception ex) {
// LOGGER.error("Task Jadwal Kerja : Task Jadwal Kerja " + ex.getMessage());
// } finally {
// LOGGER.info("Task Jadwal Kerja : Finishing Task Jadwal Kerja");
// }
// }, the1st, at0hrs);
}
// @Async
public void genJadwalKerja() {
try {
if (CommonUtil.isNotNullOrEmpty(pegawaiJadwalKerjaService)) {
LOGGER.info("Task Jadwal Kerja : Running Generate Jadwal Kerja");
pegawaiJadwalKerjaService.scheduledSaveJadwalKerjaNonShift();
} else {
LOGGER.warn("Task Jadwal Kerja : Undefined service");
}
} catch (Exception ex) {
LOGGER.error("Task Jadwal Kerja : Generate Jadwal Kerja " + ex.getMessage());
} finally {
LOGGER.info("Task Jadwal Kerja : Finishing Generate Jadwal Kerja");
}
}
}

View File

@ -1,84 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
//import com.jasamedika.medifirst2000.asynctask.timer.TargetLayananTimer;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.IkiDanRemunerasiService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.TargetLayananVO;
@Component
public class TargetLayananGenerating extends LocaleController<TargetLayananVO> {
private final static Logger LOGGER = LoggerFactory.getLogger(TargetLayananGenerating.class);
@Autowired
private IkiDanRemunerasiService remunerasiService;
/**
* Disabled following update business rules
* @since 2022/08/28
*/
public TargetLayananGenerating() {
// int day = 4;
// int hour = 0;
// int minute = 00;
// TargetLayananTimer.schedule(new Runnable() {
// @Override
// public void run() {
// try {
// LOGGER.info("Task Target Layanan : Running Task Target Layanan");
// genTargetLayanan();
// } catch (Exception ex) {
// LOGGER.error("Task Target Layanan : Task Target Layanan " + ex.getMessage());
// } finally {
// LOGGER.info("Task Target Layanan : Finishing Task Target Layanan");
// }
// }
// }, day, hour, minute);
}
// @Async
public void genTargetLayanan() {
// Jam Kerja
try {
if (CommonUtil.isNotNullOrEmpty(remunerasiService)) {
LOGGER.info("Task Target Layanan Jam Kerja : Running Generate Target Layanan Jam Kerja");
remunerasiService
.autoSaveTargetCapaianLayananJamKerja(new SimpleDateFormat("yyyy-MM").format(new Date()));
} else {
LOGGER.warn("Task Target Layanan Jam Kerja : Undefined service");
}
} catch (Exception ex) {
LOGGER.error("Task Target Layanan Jam Kerja : Generate Target Layanan Jam Kerja : " + ex.getMessage());
ex.printStackTrace();
} finally {
LOGGER.info("Task Target Layanan Jam Kerja : Finishing Generate Target Layanan Jam Kerja");
}
// Luar Jam Kerja
try {
if (CommonUtil.isNotNullOrEmpty(remunerasiService)) {
LOGGER.info("Task Target Layanan Luar Jam Kerja : Running Generate Target Layanan Luar Jam Kerja");
remunerasiService
.autoSaveTargetCapaianLayananLuarJamKerja(new SimpleDateFormat("yyyy-MM").format(new Date()));
} else {
LOGGER.warn("Task Target Layanan Luar Jam Kerja : Undefined service");
}
} catch (Exception ex) {
LOGGER.error(
"Task Target Layanan Luar Jam Kerja : Generate Target Layanan Luar Jam Kerja : " + ex.getMessage());
ex.printStackTrace();
} finally {
LOGGER.info("Task Target Layanan Luar Jam Kerja : Finishing Generate Target Layanan Luar Jam Kerja");
}
}
}

View File

@ -1,62 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import com.jasamedika.medifirst2000.asynctask.timer.TargetSkorDokterTimer;
//import com.jasamedika.medifirst2000.asynctask.timer.TargetSkorDokterTimer;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.IkiDanRemunerasiService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.vo.TargetSkorDokterVO;
/**
* @author salmanoe
* @since Dec 29, 2021
*/
@Component
public class TargetSkorDokterGenerating extends LocaleController<TargetSkorDokterVO> {
private final static Logger LOGGER = LoggerFactory.getLogger(TargetSkorDokterGenerating.class);
@Autowired
private IkiDanRemunerasiService remunerasiService;
public TargetSkorDokterGenerating() {
// int the1st = 1;
// int at0hrs = 0;
// TargetSkorDokterTimer.schedule(new Runnable() {
// @Override
// public void run() {
// try {
// LOGGER.info("Task Target Skor Dokter : Running Task Target Skor Dokter");
// generateTargetSkorDokter();
// } catch (Exception ex) {
// LOGGER.error("Task Target Skor Dokter : Task Target Skor Dokter " + ex.getMessage());
// } finally {
// LOGGER.info("Task Target Skor Dokter : Finishing Target Skor Dokter");
// }
// }
// }, the1st, at0hrs);
}
// @Async
public void generateTargetSkorDokter() {
try {
if (CommonUtil.isNotNullOrEmpty(remunerasiService)) {
LOGGER.info("Task Target Skor Dokter : Running Check/Generate Target Skor Dokter");
remunerasiService.autoSaveTargetCapaianLayananJamKerja();
} else {
LOGGER.warn("Task Target Skor Dokter : Undefined service");
}
} catch (Exception ex) {
LOGGER.error("Task Target Skor Dokter : Check/Generate Target Skor Dokter " + ex.getMessage());
} finally {
LOGGER.info("Task Target Skor Dokter : Finishing Check/Generate Target Skor Dokter");
}
}
}

View File

@ -1,81 +0,0 @@
package com.jasamedika.medifirst2000.asynctask.timer;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Salman
*
*/
public class InitiateSlipGajiTimer {
private final static Logger LOGGER = LoggerFactory.getLogger(InitiateSlipGajiTimer.class);
// What to do
private final Runnable whatToDo;
// when
private final int dayOfMonth;
private final int hourOfDay;
// The current timer
private Timer current = new Timer();
public void cancelCurrent() {
LOGGER.info("SlipGajiTimer : Cancel current execution");
current.cancel();
LOGGER.info("SlipGajiTimer : Removes the timertask so it can be garbage collected");
current.purge();
}
public static InitiateSlipGajiTimer schedule(Runnable runnable, int dayOfMonth, int hourOfDay) {
LOGGER.info("SlipGajiTimer : Create a new instance");
return new InitiateSlipGajiTimer(runnable, dayOfMonth, hourOfDay);
}
private InitiateSlipGajiTimer(Runnable runnable, int day, int hour) {
this.whatToDo = runnable;
this.dayOfMonth = day;
this.hourOfDay = hour;
schedule();
}
private void schedule() {
cancelCurrent();
LOGGER.info(
"SlipGajiTimer : Assigning a new instance of Timer, allow the previous Timer to be garbage collected");
current = new Timer();
current.schedule(new TimerTask() {
public void run() {
try {
LOGGER.info("SlipGajiTimer : Running schedule");
whatToDo.run();
} finally {
LOGGER.info("SlipGajiTimer : Schedule for the next month");
schedule();
}
}
}, nextDate());
}
private Date nextDate() {
Calendar runDate = Calendar.getInstance();
runDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
runDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
runDate.set(Calendar.MINUTE, 0);
runDate.set(Calendar.SECOND, 0);
runDate.set(Calendar.MILLISECOND, 0);
runDate.add(Calendar.MONTH, 1);
LOGGER.info("SlipGajiTimer : Set to next month " + runDate.getTime());
return runDate.getTime();
}
}

View File

@ -1,77 +0,0 @@
package com.jasamedika.medifirst2000.asynctask.timer;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class JadwalKerjaTimer {
private final static Logger LOGGER = LoggerFactory.getLogger(JadwalKerjaTimer.class);
// What to do
private final Runnable whatToDo;
// when
private final int dayOfMonth;
private final int hourOfDay;
// The current timer
private Timer current = new Timer();
public void cancelCurrent() {
LOGGER.info("JadwalKerjaTimer : Cancel current execution");
current.cancel();
LOGGER.info("JadwalKerjaTimer : Removes the timertask so it can be garbage collected");
current.purge();
}
public static JadwalKerjaTimer schedule(Runnable runnable, int dayOfMonth, int hourOfDay) {
LOGGER.info("JadwalKerjaTimer : Create a new instance");
return new JadwalKerjaTimer(runnable, dayOfMonth, hourOfDay);
}
private JadwalKerjaTimer(Runnable runnable, int day, int hour) {
this.whatToDo = runnable;
this.dayOfMonth = day;
this.hourOfDay = hour;
schedule();
}
private void schedule() {
cancelCurrent();
LOGGER.info(
"JadwalKerjaTimer : Assigning a new instance of Timer, allow the previous Timer to be garbage collected");
current = new Timer();
current.schedule(new TimerTask() {
public void run() {
try {
LOGGER.info("JadwalKerjaTimer : Running schedule");
whatToDo.run();
} finally {
LOGGER.info("JadwalKerjaTimer : Schedule for the next month");
schedule();
}
}
}, nextDate());
}
private Date nextDate() {
Calendar runDate = Calendar.getInstance();
runDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
runDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
runDate.set(Calendar.MINUTE, 0);
runDate.set(Calendar.SECOND, 0);
runDate.set(Calendar.MILLISECOND, 0);
runDate.add(Calendar.MONTH, 1);
LOGGER.info("JadwalKerjaTimer : Set to next month " + runDate.getTime());
return runDate.getTime();
}
}

View File

@ -1,78 +0,0 @@
package com.jasamedika.medifirst2000.asynctask.timer;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class KalenderTimer {
private final static Logger LOGGER = LoggerFactory.getLogger(KalenderTimer.class);
// What to do
private final Runnable whatToDo;
// when
private final int dayOfMonth;
private final int hourOfDay;
// The current timer
private Timer current = new Timer();
public void cancelCurrent() {
LOGGER.info("KalenderTimer : Cancel current execution");
current.cancel();
LOGGER.info("KalenderTimer : Removes the timertask so it can be garbage collected");
current.purge();
}
public static KalenderTimer schedule(Runnable runnable, int dayOfMonth, int hourOfDay) {
LOGGER.info("KalenderTimer : Create a new instance");
return new KalenderTimer(runnable, dayOfMonth, hourOfDay);
}
private KalenderTimer(Runnable runnable, int day, int hour) {
this.whatToDo = runnable;
this.dayOfMonth = day;
this.hourOfDay = hour;
schedule();
}
private void schedule() {
cancelCurrent();
LOGGER.info(
"KalenderTimer : Assigning a new instance of Timer, allow the previous Timer to be garbage collected");
current = new Timer();
current.schedule(new TimerTask() {
public void run() {
try {
LOGGER.info("KalenderTimer : Running schedule");
whatToDo.run();
} finally {
LOGGER.info("KalenderTimer : Schedule for the next year");
schedule();
}
}
}, nextDate());
}
private Date nextDate() {
Calendar runDate = Calendar.getInstance();
runDate.set(Calendar.MONTH, 5);
runDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
runDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
runDate.set(Calendar.MINUTE, 0);
runDate.set(Calendar.SECOND, 0);
runDate.set(Calendar.MILLISECOND, 0);
runDate.add(Calendar.YEAR, 1);
LOGGER.info("KalenderTimer : Set to next year " + runDate.getTime());
return runDate.getTime();
}
}

View File

@ -1,90 +0,0 @@
package com.jasamedika.medifirst2000.asynctask.timer;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class KontrakVerificationTimer {
private final static Logger LOGGER = LoggerFactory.getLogger(KontrakVerificationTimer.class);
// What to do
private final Runnable whatToDo;
// when
private final int dayOfMonth;
private final int hourOfDay;
private final int minuteOfHour;
// The current timer
private Timer current = new Timer();
public void cancelCurrent() {
LOGGER.info("KontrakVerificationTimer : Cancel current execution");
current.cancel();
LOGGER.info("KontrakVerificationTimer : Removes the timertask so it can be garbage collected");
current.purge();
}
public static KontrakVerificationTimer schedule(Runnable runnable, int dayOfMonth, int hourOfDay, int minuteOfHour) {
LOGGER.info("KontrakVerificationTimer : Create a new instance");
return new KontrakVerificationTimer(runnable, dayOfMonth, hourOfDay, minuteOfHour);
}
private KontrakVerificationTimer(Runnable runnable, int day, int hour, int minute) {
this.whatToDo = runnable;
this.dayOfMonth = day;
this.hourOfDay = hour;
this.minuteOfHour = minute;
schedule();
}
private void schedule() {
cancelCurrent();
LOGGER.info(
"KontrakVerificationTimer : Assigning a new instance of Timer, allow the previous Timer to be garbage collected");
current = new Timer();
current.schedule(new TimerTask() {
public void run() {
try {
LOGGER.info("KontrakVerificationTimer : Running schedule");
whatToDo.run();
} finally {
LOGGER.info("KontrakVerificationTimer : Schedule for the next month");
schedule();
}
}
}, nextDate());
}
private Date nextDate() {
Calendar curDate = Calendar.getInstance();
Calendar runDate = Calendar.getInstance();
// set_for_compare
runDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
runDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
runDate.set(Calendar.MINUTE, minuteOfHour);
runDate.set(Calendar.SECOND, 0);
runDate.set(Calendar.MILLISECOND, 0);
if (curDate.getTime().after(runDate.getTime())) {
runDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
runDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
runDate.set(Calendar.MINUTE, minuteOfHour);
runDate.set(Calendar.SECOND, 0);
runDate.set(Calendar.MILLISECOND, 0);
runDate.add(Calendar.MONTH, 1);
}
LOGGER.info("KontrakVerificationTimer : Set to next month " + runDate.getTime());
return runDate.getTime();
}
}

View File

@ -1,90 +0,0 @@
package com.jasamedika.medifirst2000.asynctask.timer;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LogbookVerificationTimer {
private final static Logger LOGGER = LoggerFactory.getLogger(LogbookVerificationTimer.class);
// What to do
private final Runnable whatToDo;
// when
private final int dayOfMonth;
private final int hourOfDay;
private final int minuteOfHour;
// The current timer
private Timer current = new Timer();
public void cancelCurrent() {
LOGGER.info("LogbookVerificationTimer : Cancel current execution");
current.cancel();
LOGGER.info("LogbookVerificationTimer : Removes the timertask so it can be garbage collected");
current.purge();
}
public static LogbookVerificationTimer schedule(Runnable runnable, int dayOfMonth, int hourOfDay, int minuteOfHour) {
LOGGER.info("LogbookVerificationTimer : Create a new instance");
return new LogbookVerificationTimer(runnable, dayOfMonth, hourOfDay, minuteOfHour);
}
private LogbookVerificationTimer(Runnable runnable, int day, int hour, int minute) {
this.whatToDo = runnable;
this.dayOfMonth = day;
this.hourOfDay = hour;
this.minuteOfHour = minute;
schedule();
}
private void schedule() {
cancelCurrent();
LOGGER.info(
"LogbookVerificationTimer : Assigning a new instance of Timer, allow the previous Timer to be garbage collected");
current = new Timer();
current.schedule(new TimerTask() {
public void run() {
try {
LOGGER.info("LogbookVerificationTimer : Running schedule");
whatToDo.run();
} finally {
LOGGER.info("LogbookVerificationTimer : Schedule for the next month");
schedule();
}
}
}, nextDate());
}
private Date nextDate() {
Calendar curDate = Calendar.getInstance();
Calendar runDate = Calendar.getInstance();
// set_for_compare
runDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
runDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
runDate.set(Calendar.MINUTE, minuteOfHour);
runDate.set(Calendar.SECOND, 0);
runDate.set(Calendar.MILLISECOND, 0);
if (curDate.getTime().after(runDate.getTime())) {
runDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
runDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
runDate.set(Calendar.MINUTE, minuteOfHour);
runDate.set(Calendar.SECOND, 0);
runDate.set(Calendar.MILLISECOND, 0);
runDate.add(Calendar.MONTH, 1);
}
LOGGER.info("LogbookVerificationTimer : Set to next month " + runDate.getTime());
return runDate.getTime();
}
}

View File

@ -1,90 +0,0 @@
package com.jasamedika.medifirst2000.asynctask.timer;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TargetLayananTimer {
private final static Logger LOGGER = LoggerFactory.getLogger(TargetLayananTimer.class);
// What to do
private final Runnable whatToDo;
// when
private final int dayOfMonth;
private final int hourOfDay;
private final int minuteOfHour;
// The current timer
private Timer current = new Timer();
public void cancelCurrent() {
LOGGER.info("TargetLayananTimer : Cancel current execution");
current.cancel();
LOGGER.info("TargetLayananTimer : Removes the timertask so it can be garbage collected");
current.purge();
}
public static TargetLayananTimer schedule(Runnable runnable, int dayOfMonth, int hourOfDay, int minuteOfHour) {
LOGGER.info("TargetLayananTimer : Create a new instance");
return new TargetLayananTimer(runnable, dayOfMonth, hourOfDay, minuteOfHour);
}
private TargetLayananTimer(Runnable runnable, int day, int hour, int minute) {
this.whatToDo = runnable;
this.dayOfMonth = day;
this.hourOfDay = hour;
this.minuteOfHour = minute;
schedule();
}
private void schedule() {
cancelCurrent();
LOGGER.info(
"TargetLayananTimer : Assigning a new instance of Timer, allow the previous Timer to be garbage collected");
current = new Timer();
current.schedule(new TimerTask() {
public void run() {
try {
LOGGER.info("TargetLayananTimer : Running schedule");
whatToDo.run();
} finally {
LOGGER.info("TargetLayananTimer : Schedule for the next month");
schedule();
}
}
}, nextDate());
}
private Date nextDate() {
Calendar curDate = Calendar.getInstance();
Calendar runDate = Calendar.getInstance();
// set_for_compare
runDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
runDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
runDate.set(Calendar.MINUTE, minuteOfHour);
runDate.set(Calendar.SECOND, 0);
runDate.set(Calendar.MILLISECOND, 0);
if (curDate.getTime().after(runDate.getTime())) {
runDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
runDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
runDate.set(Calendar.MINUTE, minuteOfHour);
runDate.set(Calendar.SECOND, 0);
runDate.set(Calendar.MILLISECOND, 0);
runDate.add(Calendar.MONTH, 1);
}
LOGGER.info("TargetLayananTimer : Set to next month " + runDate.getTime());
return runDate.getTime();
}
}

View File

@ -1,84 +0,0 @@
package com.jasamedika.medifirst2000.asynctask.timer;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author salmanoe
* @since Dec 29, 2021
*/
public class TargetSkorDokterTimer {
private final static Logger LOGGER = LoggerFactory.getLogger(TargetSkorDokterTimer.class);
// What to do
private final Runnable whatToDo;
// when
private final int dayOfMonth;
private final int hourOfDay;
// The current timer
private Timer current = new Timer();
public void cancelCurrent() {
LOGGER.info("TargetSkorDokterTimer : Cancel current execution");
current.cancel();
LOGGER.info("TargetSkorDokterTimer : Removes the timertask so it can be garbage collected");
current.purge();
}
public static TargetSkorDokterTimer schedule(Runnable runnable, int dayOfMonth, int hourOfDay) {
LOGGER.info("TargetSkorDokterTimer : Create a new instance");
return new TargetSkorDokterTimer(runnable, dayOfMonth, hourOfDay);
}
private TargetSkorDokterTimer(Runnable runnable, int day, int hour) {
this.whatToDo = runnable;
this.dayOfMonth = day;
this.hourOfDay = hour;
schedule();
}
private void schedule() {
cancelCurrent();
LOGGER.info(
"TargetSkorDokterTimer : Assigning a new instance of Timer, allow the previous Timer to be garbage collected");
current = new Timer();
current.schedule(new TimerTask() {
public void run() {
try {
LOGGER.info("TargetSkorDokterTimer : Running schedule");
whatToDo.run();
} finally {
LOGGER.info("TargetSkorDokterTimer : Schedule for the next year");
schedule();
}
}
}, nextDate());
}
private Date nextDate() {
Calendar runDate = Calendar.getInstance();
runDate.set(Calendar.MONTH, 0);
runDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
runDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
runDate.set(Calendar.MINUTE, 0);
runDate.set(Calendar.SECOND, 0);
runDate.set(Calendar.MILLISECOND, 0);
runDate.add(Calendar.YEAR, 1);
LOGGER.info("TargetSkorDokterTimer : Set to next year " + runDate.getTime());
return runDate.getTime();
}
}

View File

@ -1,49 +0,0 @@
package com.jasamedika.medifirst2000.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.jasamedika.medifirst2000.service.KalenderService;
import com.jasamedika.medifirst2000.service.PegawaiJadwalKerjaService;
import com.jasamedika.medifirst2000.service.SlipGajiService;
/**
* @author Salman
* @since 08/07/2023
*/
@RestController
@RequestMapping("/task")
public class TaskController {
@Autowired
private KalenderService kalenderService;
@Autowired
private PegawaiJadwalKerjaService pegawaiJadwalKerjaService;
@Autowired
private SlipGajiService slipGajiService;
@RequestMapping(value = "/generate/kalender", method = RequestMethod.GET)
public ResponseEntity<String> generateKalender() {
kalenderService.generateAndSaveKalender();
return new ResponseEntity<>(HttpStatus.OK);
}
@RequestMapping(value = "/generate/pegawai/jadwal", method = RequestMethod.GET)
public ResponseEntity<String> generateJadwalPegawai() {
pegawaiJadwalKerjaService.scheduledSaveJadwalKerjaNonShift();
return new ResponseEntity<>(HttpStatus.OK);
}
@RequestMapping(value = "/initiate/pegawai/slip", method = RequestMethod.GET)
public ResponseEntity<String> initiateSlipGajiPegawai() {
slipGajiService.init();
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -1,115 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.google.gson.Gson;
import com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.service.IpsrsMaintenanceService;
import com.jasamedika.medifirst2000.service.PegawaiMutasiSanksiResignService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.IpsrsJadwalPemeliharaanVO;
@Component
public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemeliharaanVO>{
/*
private Boolean flag =false;
private Integer pending = 0;
private String time = new SimpleDateFormat("HH:mm").format(Calendar.getInstance().getTime());
private SimpleDateFormat format = new SimpleDateFormat("HH:mm");
public IpsrsAlertMaintenance() {
// if(!Thread.currentThread().isInterrupted()){
// try {
// new Thread(new RunningTask()).start();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
}
class RunningTask implements Runnable{
public void run() {
new Timer().schedule(new TimerTask(){
@Override
public void run() {
try{
Date timeNow = format.parse(time);
Date timeEnd = format.parse("18:00");
Date timeReset = format.parse("21:00");
if(pending==60*3){
if(timeNow.before(timeEnd)){
if(flag==false){
// getAlertlMaintenance();
// getDataPlanningByDate();
flag=true;
}
}
pending=0;
} else{
pending++;
if(timeNow.equals(timeReset)){
flag=false;
}
}
}catch(Exception ex){
ex.printStackTrace();
}
}
}, 1000L, 1000L);
}
}
// @Autowired
// private IpsrsMaintenanceService ipsrsMaintenanceService;
//
// public void getAlertlMaintenance(){
// try{
// if (ipsrsMaintenanceService != null){
// Map<String, Object> jadwalMaintenance = ipsrsMaintenanceService.getAlertMaintenance();
// if(CommonUtil.isNotNullOrEmpty(jadwalMaintenance)){
// BroadcastMessageOther("jadwalMaintenance", jadwalMaintenance);
// System.out.println(DateUtil.now()+" task scheduler :");
// System.out.println(new Gson().toJson(jadwalMaintenance));
// } else{
// System.out.println(DateUtil.now()+" task scheduler : tidak ada jadwal maintenance");
// }
// }
// }catch (Exception ex){
// ex.printStackTrace();
// }
// }
// @Autowired
// private PegawaiMutasiSanksiResignService pegawaiMutasiSanksiResignService;
// @SuppressWarnings("unchecked")
// public void getDataPlanningByDate(){
// try{
// if (pegawaiMutasiSanksiResignService != null) {
// Map<String, Object> mapData = pegawaiMutasiSanksiResignService.getDataPlanningByDate(DateUtil.now());
// if(CommonUtil.isNotNullOrEmpty(mapData)){
// for(Map<String, Object> data : (List<Map<String, Object>>) mapData.get("listData")){
// Map<String, Object> dataResult = pegawaiMutasiSanksiResignService.updateExecPegawai(data);
// System.out.println(DateUtil.now()+" task scheduler : update pegawai "+new Gson().toJson(dataResult));
// }
// } else{
// System.out.println(DateUtil.now()+" task scheduler : tidak ada update data pegawai musare");
// }
// }
// }catch(Exception ex){
// ex.printStackTrace();
// }
// }
*/
}

View File

@ -1,187 +0,0 @@
package com.jasamedika.medifirst2000.asynctask;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
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 com.jasamedika.medifirst2000.controller.base.LocaleController;
import com.jasamedika.medifirst2000.dao.PegawaiDao;
import com.jasamedika.medifirst2000.dao.RuanganDao;
import com.jasamedika.medifirst2000.entities.Pegawai;
import com.jasamedika.medifirst2000.entities.Ruangan;
import com.jasamedika.medifirst2000.notification.MessagePublisher;
import com.jasamedika.medifirst2000.service.NotifMessagingSchedulerService;
import com.jasamedika.medifirst2000.service.NotifMessagingService;
import com.jasamedika.medifirst2000.service.NotifikasiMessageObjekModulService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.util.DateUtil;
import com.jasamedika.medifirst2000.vo.NotifMessagingSchedulerVO;
import com.jasamedika.medifirst2000.vo.NotifMessagingVO;
import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
@Component
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO>{
/*
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
@Autowired
NotifMessagingSchedulerService<NotifMessagingSchedulerVO> notifMessagingSchedulerService;
@Autowired
NotifMessagingService<NotifMessagingVO> notifMessagingService;
@Autowired
NotifikasiMessageObjekModulService<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulService;
@Autowired
MessagePublisher<String, Object> messagePublisher;
@Autowired
PegawaiDao pegawaiDao;
@Autowired
RuanganDao ruanganDao;
@Scheduled(cron = "0 30 7 * * *")
public void NotificationNormalMaintenanceEvery730AM(){
// try{
// MessagePublisher.RabbitHole rabbitHole = messagePublisher.getRabbitHole();
//
// List<NotifMessagingSchedulerVO> lNotif = notifMessagingSchedulerService.allNotifBelumTerkirim(new Date());
//
// if (CommonUtil.isNullOrEmpty(lNotif)){
// LOG.info(DateUtil.now()+" task scheduler : tidak ada jadwal maintenance");
// return;
// }
//
// Map<Integer, Integer> pegawaiRuangaAsal = new HashMap<>();
//
// Map<Integer, List<Integer>> ruanganAsalAll = new HashMap<>();
// Map<Integer, List<Integer>> notifMapAllRuanganTujuan = new HashMap<>();
// List<Integer> notifsId = new ArrayList<>();
// List<Integer> ruanganTujuansId = new ArrayList<>();
//
// Integer oldNotifId = 0;
// Integer oldRuanganIdTujuan = 0;
//
// for (NotifMessagingSchedulerVO notif:lNotif){
//
// if (notif.getRuanganIdTujuan().intValue() != oldRuanganIdTujuan.intValue()){
// ruanganTujuansId = new ArrayList<>();
// oldRuanganIdTujuan = notif.getRuanganIdTujuan();
// }
// ruanganTujuansId.add(notif.getRuanganIdTujuan());
// notifMapAllRuanganTujuan.put(notif.getNotifMessagingId(), ruanganTujuansId);
//
// if (notif.getNotifMessagingId().intValue() != oldNotifId.intValue()){
// notifsId = new ArrayList<>();
// oldNotifId = notif.getNotifMessagingId();
// }
//
// notifsId.add(notif.getNotifMessagingId());
// ruanganAsalAll.put(notif.getRuanganIdAsal(), notifsId);
//
// pegawaiRuangaAsal.put(notif.getRuanganIdAsal(), notif.getPegawaiId());
// }
//
// Set<Integer> ruanganAsalIds = ruanganAsalAll.keySet();
//
// for(Integer ruanganAsalId:ruanganAsalIds){
//
// Integer pegawaiId = pegawaiRuangaAsal.get(ruanganAsalId);
// Pegawai pegawai = pegawaiDao.findById(pegawaiId);
// Ruangan ruanganAsal = ruanganDao.findById(ruanganAsalId);
//
// notifsId = ruanganAsalAll.get(ruanganAsalId);
//
// for (Integer notifMessagingId:notifsId ){
//
// ruanganTujuansId = notifMapAllRuanganTujuan.get(notifMessagingId);
//
// try{
// rabbitHole.sendNotif(rabbitHole, ruanganAsal, pegawai, notifikasiMessageObjekModulService, notifMessagingId, ruanganTujuansId);
// }catch(Exception e){
// LOG.info(DateUtil.now()+" task scheduler dari Ruangan {} dengan ruanganId {} pada notifMessageId {} ada masalah {}",
// ruanganAsal.getNamaRuangan(), ruanganAsalId, notifMessagingId, e.getMessage());
// }
// }
// }
// }catch(Exception e){
// LOG.info(DateUtil.now() + "Task scheduler gagal penyebab, {} ", e.getMessage());
// //e.printStackTrace();
// }
}
*/
}
//private void sendNotif(Gson gson, String urlSocket, MessagePublisher.RabbitHole rabbitHole, Integer pegawaiId, Integer ruanganId, Integer notifMessagingId, List<Integer> ruanganTujuansId) throws Exception{
//
//List<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulVOs = notifikasiMessageObjekModulService.findByNotifMessagingIdAndRuanganId(notifMessagingId, ruanganTujuansId);
//
//if (CommonUtil.isNullOrEmpty(notifikasiMessageObjekModulVOs)) {
// return;
//}
//
//Integer ruanganIdtemp = 0;
//boolean connect = false;
//
//PegawaiVO pegawai = pegawaiService.findById(pegawaiId);
//
//for (NotifikasiMessageObjekModulVO vo : notifikasiMessageObjekModulVOs){
// Ruangan ruangan = vo.getRuangan();
// ModulAplikasi modulAplikasi = vo.getModulAplikasi();
// ObjekModulAplikasi objekModulAplikasi = vo.getObjekModulAplikasi();
// String customURLObjekModul = vo.getCustomURLObjekModul();
// String titleNotifikasi = vo.getTitleNotifikasi();
// String pesanNotifikasi = vo.getPesanNotifikasi();
// String namaFungsiFrontEnd = vo.getNamaFungsiFrontEnd();
//
// if (ruangan.getId() == ruanganId){
// continue;
// }
//
// RuanganVO dariRuangan = ruanganService.findById(ruanganId);
//
// if (ruanganIdtemp != ruangan.getId()){
// if (connect){
// rabbitHole.close();
// }
// rabbitHole.connect(urlSocket, String.valueOf(ruangan.getId()));
// connect = true;
// ruanganIdtemp = ruangan.getId();
// }
//
// Map<String, Object> map = new HashMap<>();
// map.put("title", titleNotifikasi);
// map.put("dariRuangan", dariRuangan);
// map.put("ruanganId", ruangan.getId());
// map.put("ruangan", ruangan);
// map.put("modulAplikasi", modulAplikasi);
// map.put("objekModulAplikasi", objekModulAplikasi);
// map.put("titleNotifikasi", titleNotifikasi);
// map.put("pesanNotifikasi", pesanNotifikasi);
// map.put("namaFungsiFrontEnd", namaFungsiFrontEnd);
// map.put("fromPegawai", pegawai);
// map.put("urlForm",CommonUtil.isNullOrEmpty(customURLObjekModul)? objekModulAplikasi.getAlamatUrlForm() : customURLObjekModul);
//
// rabbitHole.sendRabbitMQNotification(gson.toJson(map));
//
// //messagePublisher.BroadcastMessage(map);
//}
//if (connect){
// rabbitHole.close();
//}
//
//}