update Di 24. Mär 15:01:01 CET 2020
This commit is contained in:
parent
6aef654c66
commit
c92f74cab6
@ -201,11 +201,6 @@ module.exports = function(app, sql, uuidv4, app_cfg, passport, auth, waip, udp)
|
||||
app.post('/rmld/:waip_uuid/:rmld_uuid', function(req, res) {
|
||||
var waip_uuid = req.body.waip_uuid;
|
||||
var rmld_uuid = req.body.rmld_uuid;
|
||||
//var rmld_obj = Object.assign(req.params, req.body);
|
||||
|
||||
//console.log(req.params);
|
||||
//console.log(req.body);
|
||||
//console.log(rmld_obj);
|
||||
sql.db_save_rmld(req.body, function(result){
|
||||
if (result) {
|
||||
req.flash('successMessage', 'Rückmeldung erfolgreich gesendet, auf zum Einsatz!');
|
||||
|
||||
@ -221,7 +221,7 @@ module.exports = function(db, uuidv4, turf, app_cfg) {
|
||||
});
|
||||
};
|
||||
|
||||
function db_get_einsatzwachen(waip_id, callback) {
|
||||
function db_get_einsatz_rooms(waip_id, callback) {
|
||||
db.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
|
||||
@ -882,7 +882,7 @@ module.exports = function(db, uuidv4, turf, app_cfg) {
|
||||
db_wache_id_ermitteln: db_wache_id_ermitteln,
|
||||
db_wache_nr_ermitteln: db_wache_nr_ermitteln,
|
||||
db_get_einsatzdaten: db_get_einsatzdaten,
|
||||
db_get_einsatzwachen: db_get_einsatzwachen,
|
||||
db_get_einsatz_rooms: db_get_einsatz_rooms,
|
||||
db_list_wachen: db_list_wachen,
|
||||
db_list_traeger: db_list_traeger,
|
||||
db_list_kreis: db_list_kreis,
|
||||
|
||||
@ -6,7 +6,7 @@ module.exports = function(io, sql, tw, async, app_cfg) {
|
||||
sql.db_einsatz_speichern(JSON.parse(message), function (waip_id) {
|
||||
// nach dem Speichern anhand der waip_id die beteiligten Wachennummern zum Einsatz ermitteln
|
||||
sql.db_log('WAIP', 'DEBUG: ' + waip_id);
|
||||
sql.db_get_einsatzwachen(waip_id, function(data) {
|
||||
sql.db_get_einsatz_rooms(waip_id, function (data) {
|
||||
if (data) {
|
||||
console.log(data);
|
||||
data.forEach(function (row) {
|
||||
@ -87,50 +87,21 @@ module.exports = function(io, sql, tw, async, app_cfg) {
|
||||
};
|
||||
|
||||
function reuckmeldung_verteilen_by_uuid(waip_uuid, rmld_uuid) {
|
||||
console.log(waip_uuid);
|
||||
console.log(rmld_uuid);
|
||||
// Einsatz-ID mittels Einsatz-UUID ermitteln
|
||||
sql.db_get_waipid_by_uuid(waip_uuid, function (waip_id) {
|
||||
|
||||
console.log('rueckmeldung waip_id: '+waip_id);
|
||||
|
||||
|
||||
|
||||
sql.db_get_einsatzwachen(waip_id, function(data) {
|
||||
console.log(data);
|
||||
if (data) {
|
||||
|
||||
|
||||
data.forEach(function(row) {
|
||||
console.log(row.room);
|
||||
|
||||
|
||||
// am Einsatz beteilite Socket-Räume ermitteln
|
||||
sql.db_get_einsatz_rooms(waip_id, function (socket_rooms) {
|
||||
if (socket_rooms) {
|
||||
// wenn Raum zum Einsatz vorhanden ist, dann Rueckmeldung aus DB laden und an diesen versenden
|
||||
sql.db_get_single_response_by_rmlduuid(rmld_uuid, function (rmld) {
|
||||
console.log('vorhandene reuckmeldungen fuer die wache: ' + JSON.stringify(rmld));
|
||||
if (rmld) {
|
||||
//waip.reuckmeldung_senden(socket.id, rmld);
|
||||
io.to(row.room).emit('io.response', rmld);
|
||||
// Rückmeldung an Clients/Räume senden
|
||||
socket_rooms.forEach(function (rooms) {
|
||||
io.to(rooms.room).emit('io.response', rmld);
|
||||
sql.db_log('RMLD', 'Rückmeldung ' + rmld_uuid + ' für den Einsatz mit der ID ' + waip_id + ' an Raum ' + rooms.room + ' gesendet.');
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
/* var room_stockets = io.sockets.adapter.rooms[socketid];
|
||||
if (typeof socketid !== 'undefined') {
|
||||
Object.keys(room_stockets.sockets).forEach(function(socket_id) {
|
||||
io.sockets.to(socketid).emit('io.response', rmld)
|
||||
sql.db_log('WAIP', 'Rückmeldung ' + rmld + ' an Socket ' + socket_id + ' gesendet');
|
||||
});
|
||||
};*/
|
||||
|
||||
|
||||
//sql.db_get_response_wache(waip_id, row.room, function(result){
|
||||
//console.log('response_wache: ' + result);
|
||||
//if (row.room) {
|
||||
//reuckmeldung_verteilen(waip_id, result);
|
||||
//};
|
||||
//});
|
||||
|
||||
});
|
||||
} else {
|
||||
sql.db_log('Fehler-WAIP', 'Fehler: Wache für waip_id ' + waip_id + ' nicht vorhanden, Rückmeldung konnte nicht verteilt werden!');
|
||||
};
|
||||
});
|
||||
});
|
||||
@ -138,7 +109,7 @@ module.exports = function(io, sql, tw, async, app_cfg) {
|
||||
|
||||
function reuckmeldung_senden(socketid, rmld) {
|
||||
//console.log('rueckmeldung alt: '+waip_id + ' ' + result);
|
||||
//sql.db_get_einsatzwachen(waip_id, function(data) {
|
||||
//sql.db_get_einsatz_rooms(waip_id, function(data) {
|
||||
// if (data) {
|
||||
//data.forEach(function(row) {
|
||||
// fuer jede Wache(row.room) die verbundenen Sockets(Clients) ermitteln und Einsatz verteilen
|
||||
@ -284,7 +255,7 @@ module.exports = function(io, sql, tw, async, app_cfg) {
|
||||
if (waip_id) {
|
||||
sql.db_log('WAIP', 'Einsatz mit der ID ' + waip_id + ' ist veraltet und kann gelöscht werden.')
|
||||
//beteiligte Wachen ermitteln
|
||||
sql.db_get_einsatzwachen(waip_id, function(data) {
|
||||
sql.db_get_einsatz_rooms(waip_id, function (data) {
|
||||
if (data) {
|
||||
data.forEach(function (row) {
|
||||
// fuer jede Wache(row.room) die verbundenen Sockets(Clients) ermitteln und Standby senden
|
||||
@ -312,8 +283,6 @@ module.exports = function(io, sql, tw, async, app_cfg) {
|
||||
};
|
||||
});
|
||||
// TODO: löschen alter Sounddaten nach alter (15min) und socket-id (nicht mehr verbunden)
|
||||
// TODO: Löschen alter Einstze nach 24 h
|
||||
// alte mp3s loeschen
|
||||
const fs = require('fs');
|
||||
fs.readdirSync(process.cwd() + app_cfg.global.soundpath).forEach(file => {
|
||||
// nur die mp3s von alten clients loeschen
|
||||
|
||||
Loading…
Reference in New Issue
Block a user