update Fr 5. Jun 11:31:01 CEST 2020
This commit is contained in:
parent
54185a14ad
commit
33fbda30c4
@ -28,14 +28,11 @@ module.exports = function (io, sql, app_cfg, waip) {
|
||||
});
|
||||
// neue externe Rueckmeldung speichern
|
||||
socket.on('emit_new_rmld', function (data) {
|
||||
sql.db_rmld_save(data, function (result) {
|
||||
if (result) {
|
||||
waip.rmld_verteilen_by_uuid(data.waip_uuid, data.rmld_uuid);
|
||||
sql.db_log('API', 'Rückmeldung von ' + remote_ip + ' gespeichert: ' + result);
|
||||
} else {
|
||||
waip.rmld_speichern(data, remote_ip, function (result) {
|
||||
if (!result) {
|
||||
sql.db_log('API', 'Fehler beim speichern der Rückmeldung von ' + remote_ip + ': ' + data);
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
// Disconnect
|
||||
socket.on('disconnect', function () {
|
||||
@ -79,18 +76,14 @@ module.exports = function (io, sql, app_cfg, waip) {
|
||||
|
||||
// neue Rückmeldung vom Endpoint-Server
|
||||
remote_api.on('get_new_rmld', function (data) {
|
||||
sql.db_rmld_save(data, function (result) {
|
||||
if (result) {
|
||||
waip.rmld_verteilen_by_uuid(data.waip_uuid, data.rmld_uuid);
|
||||
sql.db_log('API', 'Rückmeldung von ' + app_cfg.endpoint.host + ' gespeichert: ' + result);
|
||||
} else {
|
||||
waip.rmld_speichern(data, app_cfg.endpoint.host, function (result) {
|
||||
if (!result) {
|
||||
sql.db_log('API', 'Fehler beim speichern der Rückmeldung von ' + app_cfg.endpoint.host + ': ' + data);
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
function emit_to_endpoint_new_rmld(data) {
|
||||
// Rückmeldung an Remote-Server senden, falls funktion aktiviert
|
||||
if (app_cfg.endpoint.enabled) {
|
||||
|
||||
@ -247,13 +247,13 @@ module.exports = function (app, sql, uuidv4, app_cfg, passport, auth, waip, udp)
|
||||
|
||||
// Rueckmeldung entgegennehmen
|
||||
app.post('/rmld/:waip_uuid/:rmld_uuid', function (req, res) {
|
||||
// TODO Rueckmeldung auf Validiteat pruefen
|
||||
var waip_uuid = req.body.waip_uuid;
|
||||
var rmld_uuid = req.body.rmld_uuid;
|
||||
sql.db_rmld_save(req.body, function (result) {
|
||||
waip.rmld_speichern(req.body, null, function (result) {
|
||||
if (result) {
|
||||
req.flash('successMessage', 'Rückmeldung erfolgreich gesendet, auf zum Einsatz!');
|
||||
res.redirect('/rmld/' + 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);
|
||||
|
||||
@ -80,6 +80,23 @@ module.exports = function (io, sql, brk, async, app_cfg) {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
function rmld_speichern(rueckmeldung, host, callback) {
|
||||
if (!host == null) {
|
||||
host = ' von ' + host;
|
||||
};
|
||||
sql.db_rmld_save(rueckmeldung, function (result) {
|
||||
if (result) {
|
||||
waip.rmld_verteilen_by_uuid(rueckmeldung.waip_uuid, rueckmeldung.rmld_uuid);
|
||||
sql.db_log('RMLD', 'Rückmeldung' + host + ' erhalten und gespeichert: ' + result);
|
||||
callback && callback(result);
|
||||
} else {
|
||||
sql.db_log('RMLD', 'Fehler beim speichern der Rückmeldung' + host + ': ' + rueckmeldung);
|
||||
callback && callback(result);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
function rmld_verteilen_by_uuid(waip_uuid, rmld_uuid) {
|
||||
// Einsatz-ID mittels Einsatz-UUID ermitteln
|
||||
sql.db_einsatz_get_waipid_by_uuid(waip_uuid, function (waip_id) {
|
||||
@ -358,6 +375,7 @@ module.exports = function (io, sql, brk, async, app_cfg) {
|
||||
return {
|
||||
einsatz_speichern: einsatz_speichern,
|
||||
waip_verteilen: waip_verteilen,
|
||||
rmld_speichern: rmld_speichern,
|
||||
dbrd_verteilen: dbrd_verteilen,
|
||||
rmld_verteilen_for_one_client: rmld_verteilen_for_one_client,
|
||||
rmld_verteilen_by_uuid: rmld_verteilen_by_uuid
|
||||
|
||||
Loading…
Reference in New Issue
Block a user