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
|
||||
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());
|
||||
@ -111,5 +111,5 @@ public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemelihar
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
@ -13,173 +13,190 @@ 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>{
|
||||
|
||||
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());
|
||||
@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){
|
||||
} catch (Exception e) {
|
||||
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{
|
||||
//
|
||||
//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();
|
||||
//}
|
||||
//
|
||||
//}
|
||||
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();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@ -13,173 +13,190 @@ 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>{
|
||||
|
||||
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());
|
||||
@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){
|
||||
} catch (Exception e) {
|
||||
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{
|
||||
//
|
||||
//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();
|
||||
//}
|
||||
//
|
||||
//}
|
||||
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();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@ -21,7 +21,7 @@ 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());
|
||||
@ -111,5 +111,5 @@ public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemelihar
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
|
||||
|
||||
@Component
|
||||
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO>{
|
||||
|
||||
/*
|
||||
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
|
||||
|
||||
@Autowired
|
||||
@ -38,7 +38,7 @@ public class NotificationSchedulerMaintenanceTask extends LocaleController<Notif
|
||||
|
||||
@Autowired
|
||||
RuanganDao ruanganDao;
|
||||
|
||||
*/
|
||||
// @Scheduled(cron = "0 30 7 * * *")
|
||||
// public void NotificationNormalMaintenanceEvery730AM(){
|
||||
// try{
|
||||
|
||||
@ -21,7 +21,7 @@ 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());
|
||||
@ -111,5 +111,5 @@ public class IpsrsAlertMaintenance extends LocaleController<IpsrsJadwalPemelihar
|
||||
// ex.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ import com.jasamedika.medifirst2000.vo.NotifikasiMessageObjekModulVO;
|
||||
|
||||
@Component
|
||||
public class NotificationSchedulerMaintenanceTask extends LocaleController<NotifMessagingSchedulerVO>{
|
||||
|
||||
/*
|
||||
private final Logger LOG = LoggerFactory.getLogger(NotificationSchedulerMaintenanceTask.class);
|
||||
|
||||
@Autowired
|
||||
@ -53,6 +53,7 @@ public class NotificationSchedulerMaintenanceTask extends LocaleController<Notif
|
||||
|
||||
@Scheduled(cron = "0 30 7 * * *")
|
||||
public void NotificationNormalMaintenanceEvery730AM(){
|
||||
|
||||
// try{
|
||||
// MessagePublisher.RabbitHole rabbitHole = messagePublisher.getRabbitHole();
|
||||
//
|
||||
@ -120,6 +121,7 @@ public class NotificationSchedulerMaintenanceTask extends LocaleController<Notif
|
||||
// //e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user