update Mi 29. Apr 10:01:01 CEST 2020
This commit is contained in:
parent
a7bb8d70f6
commit
9886e9ffca
@ -236,7 +236,7 @@ module.exports = function(app, sql, uuidv4, app_cfg, passport, auth, waip, udp)
|
||||
if (result) {
|
||||
req.flash('successMessage', 'Rückmeldung erfolgreich gesendet, auf zum Einsatz!');
|
||||
res.redirect('/rmld/' + waip_uuid + '/' + rmld_uuid );
|
||||
waip.reuckmeldung_verteilen_by_uuid(waip_uuid, rmld_uuid);
|
||||
waip.rmld_verteilen_by_uuid(waip_uuid, rmld_uuid);
|
||||
} else {
|
||||
req.flash('errorMessage', 'Fehler beim Senden der Rückmeldung!');
|
||||
res.redirect('/rmld/' + waip_uuid + '/' + rmld_uuid );
|
||||
|
||||
@ -38,9 +38,9 @@ module.exports = function (io, sql, app_cfg, waip) {
|
||||
var waip_id = result_einsatz[0].waip_einsaetze_ID;
|
||||
sql.db_log('WAIP', 'Einsatz ' + waip_id + ' für Wache ' + wachen_id + ' vorhanden, wird jetzt an Client ' + socket.id + ' gesendet.');
|
||||
//letzten Einsatz verteilen
|
||||
waip.einsatz_verteilen(waip_id, socket, wachen_id);
|
||||
waip.waip_verteilen(waip_id, socket, wachen_id);
|
||||
//vorhandene Rückmeldungen verteilen
|
||||
waip.rueckmeldung_verteilen_for_client(waip_id, socket, wachen_id);
|
||||
waip.rueckmeldung_verteilen_for_one_client(waip_id, socket, wachen_id);
|
||||
} else {
|
||||
sql.db_log('WAIP', 'Kein Einsatz für Wache ' + wachen_id + ' vorhanden, gehe in Standby');
|
||||
// falls kein Einsatz vorhanden ist, dann Standby senden
|
||||
|
||||
@ -244,7 +244,9 @@ module.exports = function (db, uuidv4, turf, app_cfg) {
|
||||
};
|
||||
|
||||
function db_get_einsatz_rooms(waip_id, callback) {
|
||||
db.all(`select w.nr_kreis room from waip_wachen w
|
||||
db.all(`select '0' room
|
||||
union all
|
||||
select w.nr_kreis room from waip_wachen w
|
||||
left join waip_einsatzmittel em on em.wachenname = w.name_wache
|
||||
where em.waip_einsaetze_ID = ? group by w.nr_kreis
|
||||
union all
|
||||
@ -257,10 +259,6 @@ module.exports = function (db, uuidv4, turf, app_cfg) {
|
||||
where em.waip_einsaetze_ID = ? group by w.nr_wache`, [waip_id, waip_id, waip_id],
|
||||
function (err, rows) {
|
||||
if (err == null && rows.length > 0) {
|
||||
// falls einsätze vorhanden, auch die null hinzufuegen
|
||||
rows.push({
|
||||
"room": 0
|
||||
});
|
||||
callback && callback(rows);
|
||||
} else {
|
||||
callback && callback(null);
|
||||
|
||||
@ -14,7 +14,7 @@ module.exports = function (io, sql, tw, async, app_cfg) {
|
||||
if (typeof room_sockets !== 'undefined') {
|
||||
//Object.keys(room_sockets.sockets).forEach(function (socketId) {
|
||||
Object.keys(room_sockets).forEach(function (socket) {
|
||||
einsatz_verteilen(waip_id, socket, rooms.room);
|
||||
waip_verteilen(waip_id, socket, rooms.room);
|
||||
sql.db_log('WAIP', 'Einsatz ' + waip_id + ' wird an ' + socket.id + ' (' + rooms.room + ') gesendet');
|
||||
});
|
||||
};
|
||||
@ -44,7 +44,7 @@ module.exports = function (io, sql, tw, async, app_cfg) {
|
||||
};
|
||||
|
||||
// Einsatz an Client verteilen
|
||||
function einsatz_verteilen(waip_id, socket, wachen_nr) {
|
||||
function waip_verteilen(waip_id, socket, wachen_nr) {
|
||||
// Einsatzdaten für eine Wache aus Datenbank laden
|
||||
var user_obj = socket.request.user;
|
||||
sql.db_get_einsatzdaten(waip_id, wachen_nr, user_obj.id, function (einsatzdaten) {
|
||||
@ -87,7 +87,7 @@ module.exports = function (io, sql, tw, async, app_cfg) {
|
||||
});
|
||||
};
|
||||
|
||||
function reuckmeldung_verteilen_by_uuid(waip_uuid, rmld_uuid) {
|
||||
function rmld_verteilen_by_uuid(waip_uuid, rmld_uuid) {
|
||||
// Einsatz-ID mittels Einsatz-UUID ermitteln
|
||||
sql.db_get_waipid_by_uuid(waip_uuid, function (waip_id) {
|
||||
// am Einsatz beteilite Socket-Räume ermitteln
|
||||
@ -98,17 +98,12 @@ module.exports = function (io, sql, tw, async, app_cfg) {
|
||||
if (rmld_obj) {
|
||||
// Rückmeldung an Clients/Räume senden
|
||||
socket_rooms.forEach(function (rooms) {
|
||||
var room_sockets = io.sockets.adapter.rooms[rooms.room];
|
||||
if (typeof room_sockets !== 'undefined') {
|
||||
//Object.keys(room_sockets.sockets).forEach(function (socketId) {
|
||||
Object.keys(room_sockets).forEach(function (socket) {
|
||||
console.log('rooms: ' + JSON.stringify(socket_rooms));
|
||||
console.log('rooms: ' + JSON.stringify(rooms));
|
||||
socket.emit('io.response', rmld_obj);
|
||||
|
||||
var nsp_waip = io.of('/waip');
|
||||
nsp_waip.to(rooms.room).emit('io.response', rmld_obj);
|
||||
sql.db_log('RMLD', 'Rückmeldung ' + rmld_uuid + ' für den Einsatz mit der ID ' + waip_id + ' an Raum ' + rooms.room + ' gesendet.');
|
||||
sql.db_log('DEBUG', 'Rückmeldung JSON: ' + JSON.stringify(rmld_obj));
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
};
|
||||
});
|
||||
@ -117,7 +112,7 @@ module.exports = function (io, sql, tw, async, app_cfg) {
|
||||
});
|
||||
};
|
||||
|
||||
function rueckmeldung_verteilen_for_client(waip_id, socket, wachen_id) {
|
||||
function rueckmeldung_verteilen_for_one_client(waip_id, socket, wachen_id) {
|
||||
if (typeof socket !== 'undefined') {
|
||||
sql.db_get_response_for_wache(waip_id, wachen_id, function (rmld) {
|
||||
if (rmld) {
|
||||
@ -336,9 +331,9 @@ module.exports = function (io, sql, tw, async, app_cfg) {
|
||||
|
||||
return {
|
||||
einsatz_speichern: einsatz_speichern,
|
||||
einsatz_verteilen: einsatz_verteilen,
|
||||
waip_verteilen: waip_verteilen,
|
||||
dbrd_verteilen: dbrd_verteilen,
|
||||
rueckmeldung_verteilen_for_client: rueckmeldung_verteilen_for_client,
|
||||
reuckmeldung_verteilen_by_uuid: reuckmeldung_verteilen_by_uuid
|
||||
rmld_verteilen_for_one_client: rueckmeldung_verteilen_for_one_client,
|
||||
rmld_verteilen_by_uuid: rmld_verteilen_by_uuid
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user