Update async tasks
Remove high usage memory cron jobs
This commit is contained in:
parent
215416cecb
commit
0ea5964315
@ -21,7 +21,7 @@ import com.jasamedika.medifirst2000.vo.IpsrsJadwalPemeliharaanVO;
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemeliharaanVO>{
|
public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemeliharaanVO>{
|
||||||
|
/*
|
||||||
private Boolean flag =false;
|
private Boolean flag =false;
|
||||||
private Integer pending = 0;
|
private Integer pending = 0;
|
||||||
private String time = new SimpleDateFormat("HH:mm").format(Calendar.getInstance().getTime());
|
private String time = new SimpleDateFormat("HH:mm").format(Calendar.getInstance().getTime());
|
||||||
@ -111,5 +111,5 @@ public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemelihar
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,173 +13,190 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||||
import com.jasamedika.medifirst2000.dao.PegawaiDao;
|
import com.jasamedika.medifirst2000.dao.PegawaiDao;
|
||||||
import com.jasamedika.medifirst2000.dao.RuanganDao;
|
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.Pegawai;
|
||||||
import com.jasamedika.medifirst2000.entities.Ruangan;
|
import com.jasamedika.medifirst2000.entities.Ruangan;
|
||||||
import com.jasamedika.medifirst2000.notification.MessagePublisher;
|
import com.jasamedika.medifirst2000.notification.MessagePublisher;
|
||||||
import com.jasamedika.medifirst2000.service.NotifMessagingSchedulerService;
|
import com.jasamedika.medifirst2000.service.NotifMessagingSchedulerService;
|
||||||
import com.jasamedika.medifirst2000.service.NotifMessagingService;
|
import com.jasamedika.medifirst2000.service.NotifMessagingService;
|
||||||
import com.jasamedika.medifirst2000.service.NotifikasiMessageObjekModulService;
|
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.CommonUtil;
|
||||||
import com.jasamedika.medifirst2000.util.DateUtil;
|
import com.jasamedika.medifirst2000.util.DateUtil;
|
||||||
import com.jasamedika.medifirst2000.vo.NotifMessagingSchedulerVO;
|
import com.jasamedika.medifirst2000.vo.NotifMessagingSchedulerVO;
|
||||||
import com.jasamedika.medifirst2000.vo.NotifMessagingVO;
|
import com.jasamedika.medifirst2000.vo.NotifMessagingVO;
|
||||||
import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
|
import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
|
||||||
|
import com.jasamedika.medifirst2000.vo.PegawaiVO;
|
||||||
|
import com.jasamedika.medifirst2000.vo.RuanganVO;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO>{
|
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO> {
|
||||||
|
/*
|
||||||
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
|
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
NotifMessagingSchedulerService<NotifMessagingSchedulerVO> notifMessagingSchedulerService;
|
NotifMessagingSchedulerService<NotifMessagingSchedulerVO> notifMessagingSchedulerService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
NotifMessagingService<NotifMessagingVO> notifMessagingService;
|
NotifMessagingService<NotifMessagingVO> notifMessagingService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
NotifikasiMessageObjekModulService<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulService;
|
NotifikasiMessageObjekModulService<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
PegawaiService pegawaiService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
RuanganService<RuanganVO> ruanganService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
MessagePublisher<String, Object> messagePublisher;
|
MessagePublisher<String, Object> messagePublisher;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
PegawaiDao pegawaiDao;
|
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);
|
@Autowired
|
||||||
|
RuanganDao ruanganDao;
|
||||||
for (Integer notifMessagingId:notifsId ){
|
|
||||||
|
@Scheduled(cron = "0 30 7 * * *")
|
||||||
ruanganTujuansId = notifMapAllRuanganTujuan.get(notifMessagingId);
|
public void NotificationNormalMaintenanceEvery730AM() {
|
||||||
|
try {
|
||||||
try{
|
MessagePublisher.RabbitHole rabbitHole = messagePublisher.getRabbitHole();
|
||||||
rabbitHole.sendNotif(rabbitHole, ruanganAsal, pegawai, notifikasiMessageObjekModulService, notifMessagingId, ruanganTujuansId);
|
|
||||||
}catch(Exception e){
|
List<NotifMessagingSchedulerVO> lNotif = notifMessagingSchedulerService.allNotifBelumTerkirim(new Date());
|
||||||
LOG.info(DateUtil.now()+" task scheduler dari Ruangan {} dengan ruanganId {} pada notifMessageId {} ada masalah {}",
|
|
||||||
ruanganAsal.getNamaRuangan(), ruanganAsalId, notifMessagingId, e.getMessage());
|
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) {
|
||||||
}catch(Exception e){
|
|
||||||
LOG.info(DateUtil.now() + "Task scheduler gagal penyebab, {} ", e.getMessage());
|
LOG.info(DateUtil.now() + "Task scheduler gagal penyebab, {} ", e.getMessage());
|
||||||
//e.printStackTrace();
|
// 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);
|
||||||
|
|
||||||
//private void sendNotif(Gson gson, String urlSocket, MessagePublisher.RabbitHole rabbitHole, Integer pegawaiId, Integer ruanganId, Integer notifMessagingId, List<Integer> ruanganTujuansId) throws Exception{
|
if (CommonUtil.isNullOrEmpty(notifikasiMessageObjekModulVOs)) {
|
||||||
//
|
return;
|
||||||
//List<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulVOs = notifikasiMessageObjekModulService.findByNotifMessagingIdAndRuanganId(notifMessagingId, ruanganTujuansId);
|
}
|
||||||
//
|
|
||||||
//if (CommonUtil.isNullOrEmpty(notifikasiMessageObjekModulVOs)) {
|
Integer ruanganIdtemp = 0;
|
||||||
// return;
|
boolean connect = false;
|
||||||
//}
|
|
||||||
//
|
PegawaiVO pegawai = pegawaiService.findById(pegawaiId);
|
||||||
//Integer ruanganIdtemp = 0;
|
|
||||||
//boolean connect = false;
|
for (NotifikasiMessageObjekModulVO vo : notifikasiMessageObjekModulVOs) {
|
||||||
//
|
Ruangan ruangan = vo.getRuangan();
|
||||||
//PegawaiVO pegawai = pegawaiService.findById(pegawaiId);
|
ModulAplikasi modulAplikasi = vo.getModulAplikasi();
|
||||||
//
|
ObjekModulAplikasi objekModulAplikasi = vo.getObjekModulAplikasi();
|
||||||
//for (NotifikasiMessageObjekModulVO vo : notifikasiMessageObjekModulVOs){
|
String customURLObjekModul = vo.getCustomURLObjekModul();
|
||||||
// Ruangan ruangan = vo.getRuangan();
|
String titleNotifikasi = vo.getTitleNotifikasi();
|
||||||
// ModulAplikasi modulAplikasi = vo.getModulAplikasi();
|
String pesanNotifikasi = vo.getPesanNotifikasi();
|
||||||
// ObjekModulAplikasi objekModulAplikasi = vo.getObjekModulAplikasi();
|
String namaFungsiFrontEnd = vo.getNamaFungsiFrontEnd();
|
||||||
// String customURLObjekModul = vo.getCustomURLObjekModul();
|
|
||||||
// String titleNotifikasi = vo.getTitleNotifikasi();
|
if (ruangan.getId() == ruanganId) {
|
||||||
// String pesanNotifikasi = vo.getPesanNotifikasi();
|
continue;
|
||||||
// String namaFungsiFrontEnd = vo.getNamaFungsiFrontEnd();
|
}
|
||||||
//
|
|
||||||
// if (ruangan.getId() == ruanganId){
|
RuanganVO dariRuangan = ruanganService.findById(ruanganId);
|
||||||
// continue;
|
|
||||||
// }
|
if (ruanganIdtemp != ruangan.getId()) {
|
||||||
//
|
if (connect) {
|
||||||
// RuanganVO dariRuangan = ruanganService.findById(ruanganId);
|
rabbitHole.close();
|
||||||
//
|
}
|
||||||
// if (ruanganIdtemp != ruangan.getId()){
|
rabbitHole.connect(urlSocket, String.valueOf(ruangan.getId()));
|
||||||
// if (connect){
|
connect = true;
|
||||||
// rabbitHole.close();
|
ruanganIdtemp = ruangan.getId();
|
||||||
// }
|
}
|
||||||
// rabbitHole.connect(urlSocket, String.valueOf(ruangan.getId()));
|
|
||||||
// connect = true;
|
Map<String, Object> map = new HashMap<>();
|
||||||
// ruanganIdtemp = ruangan.getId();
|
map.put("title", titleNotifikasi);
|
||||||
// }
|
map.put("dariRuangan", dariRuangan);
|
||||||
//
|
map.put("ruanganId", ruangan.getId());
|
||||||
// Map<String, Object> map = new HashMap<>();
|
map.put("ruangan", ruangan);
|
||||||
// map.put("title", titleNotifikasi);
|
map.put("modulAplikasi", modulAplikasi);
|
||||||
// map.put("dariRuangan", dariRuangan);
|
map.put("objekModulAplikasi", objekModulAplikasi);
|
||||||
// map.put("ruanganId", ruangan.getId());
|
map.put("titleNotifikasi", titleNotifikasi);
|
||||||
// map.put("ruangan", ruangan);
|
map.put("pesanNotifikasi", pesanNotifikasi);
|
||||||
// map.put("modulAplikasi", modulAplikasi);
|
map.put("namaFungsiFrontEnd", namaFungsiFrontEnd);
|
||||||
// map.put("objekModulAplikasi", objekModulAplikasi);
|
map.put("fromPegawai", pegawai);
|
||||||
// map.put("titleNotifikasi", titleNotifikasi);
|
map.put("urlForm", CommonUtil.isNullOrEmpty(customURLObjekModul) ? objekModulAplikasi.getAlamatUrlForm()
|
||||||
// map.put("pesanNotifikasi", pesanNotifikasi);
|
: customURLObjekModul);
|
||||||
// map.put("namaFungsiFrontEnd", namaFungsiFrontEnd);
|
|
||||||
// map.put("fromPegawai", pegawai);
|
rabbitHole.sendRabbitMQNotification(gson.toJson(map));
|
||||||
// map.put("urlForm",CommonUtil.isNullOrEmpty(customURLObjekModul)? objekModulAplikasi.getAlamatUrlForm() : customURLObjekModul);
|
|
||||||
//
|
messagePublisher.BroadcastMessage(map);
|
||||||
// rabbitHole.sendRabbitMQNotification(gson.toJson(map));
|
}
|
||||||
//
|
if (connect) {
|
||||||
// //messagePublisher.BroadcastMessage(map);
|
rabbitHole.close();
|
||||||
//}
|
}
|
||||||
//if (connect){
|
}
|
||||||
// rabbitHole.close();
|
*/
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//}
|
|
||||||
@ -13,173 +13,190 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
import com.jasamedika.medifirst2000.controller.base.LocaleController;
|
||||||
import com.jasamedika.medifirst2000.dao.PegawaiDao;
|
import com.jasamedika.medifirst2000.dao.PegawaiDao;
|
||||||
import com.jasamedika.medifirst2000.dao.RuanganDao;
|
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.Pegawai;
|
||||||
import com.jasamedika.medifirst2000.entities.Ruangan;
|
import com.jasamedika.medifirst2000.entities.Ruangan;
|
||||||
import com.jasamedika.medifirst2000.notification.MessagePublisher;
|
import com.jasamedika.medifirst2000.notification.MessagePublisher;
|
||||||
import com.jasamedika.medifirst2000.service.NotifMessagingSchedulerService;
|
import com.jasamedika.medifirst2000.service.NotifMessagingSchedulerService;
|
||||||
import com.jasamedika.medifirst2000.service.NotifMessagingService;
|
import com.jasamedika.medifirst2000.service.NotifMessagingService;
|
||||||
import com.jasamedika.medifirst2000.service.NotifikasiMessageObjekModulService;
|
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.CommonUtil;
|
||||||
import com.jasamedika.medifirst2000.util.DateUtil;
|
import com.jasamedika.medifirst2000.util.DateUtil;
|
||||||
import com.jasamedika.medifirst2000.vo.NotifMessagingSchedulerVO;
|
import com.jasamedika.medifirst2000.vo.NotifMessagingSchedulerVO;
|
||||||
import com.jasamedika.medifirst2000.vo.NotifMessagingVO;
|
import com.jasamedika.medifirst2000.vo.NotifMessagingVO;
|
||||||
import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
|
import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
|
||||||
|
import com.jasamedika.medifirst2000.vo.PegawaiVO;
|
||||||
|
import com.jasamedika.medifirst2000.vo.RuanganVO;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO>{
|
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO> {
|
||||||
|
/*
|
||||||
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
|
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
NotifMessagingSchedulerService<NotifMessagingSchedulerVO> notifMessagingSchedulerService;
|
NotifMessagingSchedulerService<NotifMessagingSchedulerVO> notifMessagingSchedulerService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
NotifMessagingService<NotifMessagingVO> notifMessagingService;
|
NotifMessagingService<NotifMessagingVO> notifMessagingService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
NotifikasiMessageObjekModulService<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulService;
|
NotifikasiMessageObjekModulService<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
PegawaiService pegawaiService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
RuanganService<RuanganVO> ruanganService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
MessagePublisher<String, Object> messagePublisher;
|
MessagePublisher<String, Object> messagePublisher;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
PegawaiDao pegawaiDao;
|
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);
|
@Autowired
|
||||||
|
RuanganDao ruanganDao;
|
||||||
for (Integer notifMessagingId:notifsId ){
|
|
||||||
|
@Scheduled(cron = "0 30 7 * * *")
|
||||||
ruanganTujuansId = notifMapAllRuanganTujuan.get(notifMessagingId);
|
public void NotificationNormalMaintenanceEvery730AM() {
|
||||||
|
try {
|
||||||
try{
|
MessagePublisher.RabbitHole rabbitHole = messagePublisher.getRabbitHole();
|
||||||
rabbitHole.sendNotif(rabbitHole, ruanganAsal, pegawai, notifikasiMessageObjekModulService, notifMessagingId, ruanganTujuansId);
|
|
||||||
}catch(Exception e){
|
List<NotifMessagingSchedulerVO> lNotif = notifMessagingSchedulerService.allNotifBelumTerkirim(new Date());
|
||||||
LOG.info(DateUtil.now()+" task scheduler dari Ruangan {} dengan ruanganId {} pada notifMessageId {} ada masalah {}",
|
|
||||||
ruanganAsal.getNamaRuangan(), ruanganAsalId, notifMessagingId, e.getMessage());
|
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) {
|
||||||
}catch(Exception e){
|
|
||||||
LOG.info(DateUtil.now() + "Task scheduler gagal penyebab, {} ", e.getMessage());
|
LOG.info(DateUtil.now() + "Task scheduler gagal penyebab, {} ", e.getMessage());
|
||||||
//e.printStackTrace();
|
// 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);
|
||||||
|
|
||||||
//private void sendNotif(Gson gson, String urlSocket, MessagePublisher.RabbitHole rabbitHole, Integer pegawaiId, Integer ruanganId, Integer notifMessagingId, List<Integer> ruanganTujuansId) throws Exception{
|
if (CommonUtil.isNullOrEmpty(notifikasiMessageObjekModulVOs)) {
|
||||||
//
|
return;
|
||||||
//List<NotifikasiMessageObjekModulVO> notifikasiMessageObjekModulVOs = notifikasiMessageObjekModulService.findByNotifMessagingIdAndRuanganId(notifMessagingId, ruanganTujuansId);
|
}
|
||||||
//
|
|
||||||
//if (CommonUtil.isNullOrEmpty(notifikasiMessageObjekModulVOs)) {
|
Integer ruanganIdtemp = 0;
|
||||||
// return;
|
boolean connect = false;
|
||||||
//}
|
|
||||||
//
|
PegawaiVO pegawai = pegawaiService.findById(pegawaiId);
|
||||||
//Integer ruanganIdtemp = 0;
|
|
||||||
//boolean connect = false;
|
for (NotifikasiMessageObjekModulVO vo : notifikasiMessageObjekModulVOs) {
|
||||||
//
|
Ruangan ruangan = vo.getRuangan();
|
||||||
//PegawaiVO pegawai = pegawaiService.findById(pegawaiId);
|
ModulAplikasi modulAplikasi = vo.getModulAplikasi();
|
||||||
//
|
ObjekModulAplikasi objekModulAplikasi = vo.getObjekModulAplikasi();
|
||||||
//for (NotifikasiMessageObjekModulVO vo : notifikasiMessageObjekModulVOs){
|
String customURLObjekModul = vo.getCustomURLObjekModul();
|
||||||
// Ruangan ruangan = vo.getRuangan();
|
String titleNotifikasi = vo.getTitleNotifikasi();
|
||||||
// ModulAplikasi modulAplikasi = vo.getModulAplikasi();
|
String pesanNotifikasi = vo.getPesanNotifikasi();
|
||||||
// ObjekModulAplikasi objekModulAplikasi = vo.getObjekModulAplikasi();
|
String namaFungsiFrontEnd = vo.getNamaFungsiFrontEnd();
|
||||||
// String customURLObjekModul = vo.getCustomURLObjekModul();
|
|
||||||
// String titleNotifikasi = vo.getTitleNotifikasi();
|
if (ruangan.getId() == ruanganId) {
|
||||||
// String pesanNotifikasi = vo.getPesanNotifikasi();
|
continue;
|
||||||
// String namaFungsiFrontEnd = vo.getNamaFungsiFrontEnd();
|
}
|
||||||
//
|
|
||||||
// if (ruangan.getId() == ruanganId){
|
RuanganVO dariRuangan = ruanganService.findById(ruanganId);
|
||||||
// continue;
|
|
||||||
// }
|
if (ruanganIdtemp != ruangan.getId()) {
|
||||||
//
|
if (connect) {
|
||||||
// RuanganVO dariRuangan = ruanganService.findById(ruanganId);
|
rabbitHole.close();
|
||||||
//
|
}
|
||||||
// if (ruanganIdtemp != ruangan.getId()){
|
rabbitHole.connect(urlSocket, String.valueOf(ruangan.getId()));
|
||||||
// if (connect){
|
connect = true;
|
||||||
// rabbitHole.close();
|
ruanganIdtemp = ruangan.getId();
|
||||||
// }
|
}
|
||||||
// rabbitHole.connect(urlSocket, String.valueOf(ruangan.getId()));
|
|
||||||
// connect = true;
|
Map<String, Object> map = new HashMap<>();
|
||||||
// ruanganIdtemp = ruangan.getId();
|
map.put("title", titleNotifikasi);
|
||||||
// }
|
map.put("dariRuangan", dariRuangan);
|
||||||
//
|
map.put("ruanganId", ruangan.getId());
|
||||||
// Map<String, Object> map = new HashMap<>();
|
map.put("ruangan", ruangan);
|
||||||
// map.put("title", titleNotifikasi);
|
map.put("modulAplikasi", modulAplikasi);
|
||||||
// map.put("dariRuangan", dariRuangan);
|
map.put("objekModulAplikasi", objekModulAplikasi);
|
||||||
// map.put("ruanganId", ruangan.getId());
|
map.put("titleNotifikasi", titleNotifikasi);
|
||||||
// map.put("ruangan", ruangan);
|
map.put("pesanNotifikasi", pesanNotifikasi);
|
||||||
// map.put("modulAplikasi", modulAplikasi);
|
map.put("namaFungsiFrontEnd", namaFungsiFrontEnd);
|
||||||
// map.put("objekModulAplikasi", objekModulAplikasi);
|
map.put("fromPegawai", pegawai);
|
||||||
// map.put("titleNotifikasi", titleNotifikasi);
|
map.put("urlForm", CommonUtil.isNullOrEmpty(customURLObjekModul) ? objekModulAplikasi.getAlamatUrlForm()
|
||||||
// map.put("pesanNotifikasi", pesanNotifikasi);
|
: customURLObjekModul);
|
||||||
// map.put("namaFungsiFrontEnd", namaFungsiFrontEnd);
|
|
||||||
// map.put("fromPegawai", pegawai);
|
rabbitHole.sendRabbitMQNotification(gson.toJson(map));
|
||||||
// map.put("urlForm",CommonUtil.isNullOrEmpty(customURLObjekModul)? objekModulAplikasi.getAlamatUrlForm() : customURLObjekModul);
|
|
||||||
//
|
messagePublisher.BroadcastMessage(map);
|
||||||
// rabbitHole.sendRabbitMQNotification(gson.toJson(map));
|
}
|
||||||
//
|
if (connect) {
|
||||||
// //messagePublisher.BroadcastMessage(map);
|
rabbitHole.close();
|
||||||
//}
|
}
|
||||||
//if (connect){
|
}
|
||||||
// rabbitHole.close();
|
*/
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//}
|
|
||||||
@ -21,7 +21,7 @@ import com.jasamedika.medifirst2000.vo.IpsrsJadwalPemeliharaanVO;
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemeliharaanVO>{
|
public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemeliharaanVO>{
|
||||||
|
/*
|
||||||
private Boolean flag =false;
|
private Boolean flag =false;
|
||||||
private Integer pending = 0;
|
private Integer pending = 0;
|
||||||
private String time = new SimpleDateFormat("HH:mm").format(Calendar.getInstance().getTime());
|
private String time = new SimpleDateFormat("HH:mm").format(Calendar.getInstance().getTime());
|
||||||
@ -111,5 +111,5 @@ public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemelihar
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO>{
|
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO>{
|
||||||
|
/*
|
||||||
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
|
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -38,7 +38,7 @@ public class NotificationSchedulerMaintenanceTask extends LocaleController<Notif
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RuanganDao ruanganDao;
|
RuanganDao ruanganDao;
|
||||||
|
*/
|
||||||
// @Scheduled(cron = "0 30 7 * * *")
|
// @Scheduled(cron = "0 30 7 * * *")
|
||||||
// public void NotificationNormalMaintenanceEvery730AM(){
|
// public void NotificationNormalMaintenanceEvery730AM(){
|
||||||
// try{
|
// try{
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import com.jasamedika.medifirst2000.vo.IpsrsJadwalPemeliharaanVO;
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemeliharaanVO>{
|
public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemeliharaanVO>{
|
||||||
|
/*
|
||||||
private Boolean flag =false;
|
private Boolean flag =false;
|
||||||
private Integer pending = 0;
|
private Integer pending = 0;
|
||||||
private String time = new SimpleDateFormat("HH:mm").format(Calendar.getInstance().getTime());
|
private String time = new SimpleDateFormat("HH:mm").format(Calendar.getInstance().getTime());
|
||||||
@ -111,5 +111,5 @@ public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemelihar
|
|||||||
// ex.printStackTrace();
|
// ex.printStackTrace();
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO>{
|
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO>{
|
||||||
|
/*
|
||||||
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
|
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -53,6 +53,7 @@ public class NotificationSchedulerMaintenanceTask extends LocaleController<Notif
|
|||||||
|
|
||||||
@Scheduled(cron = "0 30 7 * * *")
|
@Scheduled(cron = "0 30 7 * * *")
|
||||||
public void NotificationNormalMaintenanceEvery730AM(){
|
public void NotificationNormalMaintenanceEvery730AM(){
|
||||||
|
|
||||||
// try{
|
// try{
|
||||||
// MessagePublisher.RabbitHole rabbitHole = messagePublisher.getRabbitHole();
|
// MessagePublisher.RabbitHole rabbitHole = messagePublisher.getRabbitHole();
|
||||||
//
|
//
|
||||||
@ -120,6 +121,7 @@ public class NotificationSchedulerMaintenanceTask extends LocaleController<Notif
|
|||||||
// //e.printStackTrace();
|
// //e.printStackTrace();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user