This commit is contained in:
Robert Richter 2020-01-31 14:20:52 +01:00
parent db4d5dd813
commit ae902a59ef
6 changed files with 122 additions and 47 deletions

0
misc/hexagon_brb_2km.geojson Executable file → Normal file
View File

View File

@ -474,19 +474,17 @@ $('#rueckmeldung').each(function(index) {
});
$('#send_response').on('click', function() {
// Rückmeldung senden
socket.emit(
'response',
waip_id,
$('#radios_res_ek').prop('checked'),
$('#radios_res_ma').prop('checked'),
$('#radios_res_fk').prop('checked'),
$('#cb_res_agt').prop('checked')
);
// Rückmeldung sammeln
var respo = {};
respo.einsatzkraft = $('#radios_res_ek').prop('checked');
respo.maschinist = $('#radios_res_ma').prop('checked');
respo.fuehrungskraft = $('#radios_res_fk').prop('checked');
respo.atemschutz = $('#cb_res_agt').prop('checked');
socket.emit('response',waip_id,respo);
});
socket.on('io.response', function(data) {
// Rückmeldungen hinterlegen
// neue Rückmeldungen hinterlegen
$('#rueckmeldung').empty();
//{einsatzkraft: "0", maschinist: "0", fuehrungskraft: "0", atemschutz: "0"}
for (var i in data) {

12
server/socket.js Executable file → Normal file
View File

@ -60,12 +60,12 @@ socket_api.emit('CH01', 'me', 'test msg');
};
});
});
socket.on('response', function(waip_id, ek, ma, fk, agt) {
var i_ek = ek ? 1 : 0;
var i_ma = ma ? 1 : 0;
var i_fk = fk ? 1 : 0;
var i_agt = agt ? 1 : 0;
sql.db_update_response(waip_id, i_ek, i_ma, i_fk, i_agt, function(result){
socket.on('response', function(waip_id, responseobj) {
//var i_ek = ek ? 1 : 0;
//var i_ma = ma ? 1 : 0;
//var i_fk = fk ? 1 : 0;
//var i_agt = agt ? 1 : 0;
sql.db_update_response(waip_id, responseobj, function(result){
waip.reuckmeldung_verteilen(waip_id, result);
});
});

View File

@ -28,7 +28,8 @@ module.exports = function (fs, bcrypt, app_cfg) {
db.serialize(function () {
// Einsatz-Tabelle erstellen
db.run(`CREATE TABLE waip_einsaetze (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
uuid TEXT,
zeitstempel DATETIME DEFAULT CURRENT_TIMESTAMP,
einsatznummer TEXT,
alarmzeit TEXT,
@ -44,7 +45,9 @@ module.exports = function (fs, bcrypt, app_cfg) {
objektart TEXT,
wachenfolge INTEGER,
wgs84_x TEXT,
wgs84_y TEXT)`);
wgs84_y TEXT,
wgs84_area,
UNIQUE (id, uuid))`);
// Einsatzmittel-Tabelle erstellen
// TODO: Erweitern um Status, Staerke, AGT
db.run(`CREATE TABLE waip_einsatzmittel (
@ -86,10 +89,7 @@ module.exports = function (fs, bcrypt, app_cfg) {
db.run(`CREATE TABLE waip_response (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
waip_einsaetze_id INTEGER NOT NULL,
einsatzkraft TEXT,
maschinist TEXT,
fuehrungskraft TEXT,
atemschutz TEXT)`);
response_json TEXT)`);
// Benutzer-Tabelle erstellen
db.run(`CREATE TABLE waip_users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
@ -778,10 +778,11 @@ module.exports = function (fs, bcrypt, app_cfg) {
db.run(`INSERT OR REPLACE INTO waip_ttsreplace (
einsatzmittel_typ, einsatzmittel_rufname)
VALUES
(\'10\',\'ELW\'),
(\'10\',\'KDOW\'),
(\'11\',\'ELW\'),
(\'12\',\'ELW 2\'),
(\'14\',\'KDOW\'),
(\'19\',\'MTW\'),
(\'19\',\'MTF\'),
(\'20\',\'Tanklöschfahrzeug\'),
(\'21\',\'Tanklöschfahrzeug\'),
(\'22\',\'Vorauslöschfahrzeug\'),
@ -789,13 +790,14 @@ module.exports = function (fs, bcrypt, app_cfg) {
(\'24\',\'Tanklöschfahrzeug\'),
(\'25\',\'Großtanklöschfahrzeug\'),
(\'26\',\'Tanklöschfahrzeug\'),
(\'27\',\'Tanklöschfahrzeug\'),
(\'29\',\'Großtanklöschfahrzeug\'),
(\'30\',\'Drehleiter\'),
(\'31\',\'Drehleiter\'),
(\'32\',\'Drehleiter\'),
(\'33\',\'Drehleiter\'),
(\'34\',\'Hubarbeitsbühne\'),
(\'35\',\'Drehleiter\'),
(\'35\',\'Gelenkmast\'),
(\'36\',\'Teleskopmast\'),
(\'37\',\'Teleskopmast \'),
(\'38\',\'Hubretter\'),
@ -808,11 +810,21 @@ module.exports = function (fs, bcrypt, app_cfg) {
(\'46\',\'Löschfahrzeug\'),
(\'47\',\'TSF\'),
(\'48\',\'TSF\'),
(\'49\',\'Speziallöschfahrzeug\'),
(\'51\',\'Rüstwagen\'),
(\'52\',\'Rüstwagen\'),
(\'59\',\'Rüstwagen\'),
(\'53\',\'Rüstwagen\'),
(\'59\',\'Gerätewagen\'),
(\'61\',\'Schlauchwagen\'),
(\'62\',\'Schlauchwagen\'),
(\'63\',\'Schlauchwagen\'),
(\'64\',\'Schlauchtransportwagen\'),
(\'65\',\'Wechsellader\'),
(\'66\',\'Wechsellader\'),
(\'67\',\'Wechsellader\'),
(\'69\',\'TSA\'),
(\'76\',\'Krad\'),
(\'78\',\'Löschboot\'),
(\'79\',\'Mehrzweckboot\'),
(\'82\',\'NEF\'),
(\'83\',\'RTW\'),

View File

@ -1,5 +1,8 @@
module.exports = function(db, async, app_cfg) {
// Module laden
const uuidv4 = require('uuid/v4');
// ermittelt den letzten vorhanden Einsatz zu einer Wache
function db_einsatz_vorhanden(wachen_id, user_id, callback) {
var select_reset_counter;
@ -39,12 +42,17 @@ module.exports = function(db, async, app_cfg) {
};
function db_einsatz_speichern(content, callback) {
// uuid erzeugen und zuweisen falls nicht vorhanden
if (!content.einsatzdaten.uuid) {
content.einsatzdaten.uuid = uuidv4();
};
db.serialize(function() {
// Einsatzdaten speichern
db.run(`INSERT OR REPLACE INTO waip_einsaetze (
id, einsatznummer, alarmzeit, einsatzart, stichwort, sondersignal, besonderheiten, ort, ortsteil, strasse, objekt, objektnr, objektart, wachenfolge, wgs84_x, wgs84_y)
id, uuid, einsatznummer, alarmzeit, einsatzart, stichwort, sondersignal, besonderheiten, ort, ortsteil, strasse, objekt, objektnr, objektart, wachenfolge, wgs84_x, wgs84_y)
VALUES (
(select ID from waip_einsaetze where einsatznummer like \'` + content.einsatzdaten.nummer + `\'),
\'` + content.einsatzdaten.uuid + `\',
\'` + content.einsatzdaten.nummer + `\',
\'` + content.einsatzdaten.alarmzeit + `\',
\'` + content.einsatzdaten.art + `\',
@ -68,7 +76,7 @@ module.exports = function(db, async, app_cfg) {
function loop_done(waip_id) {
callback && callback(waip_id);
//console.log('all done');
}
};
var itemsProcessed = 0;
content.alarmdaten.forEach(function (item, index, array) {
@ -80,18 +88,18 @@ module.exports = function(db, async, app_cfg) {
\'` + item.wachenname + `\',
\'` + item.einsatzmittel + `\',
\'` + item.zeit_a + `\')`,
function(err) {
if (err == null) {
itemsProcessed++;
function (err) {
if (err == null) {
itemsProcessed++;
if (itemsProcessed === array.length) {
loop_done(id);
if (itemsProcessed === array.length) {
loop_done(id);
};
} else {
callback && callback(err);
};
} else {
callback && callback(err);
};
});
});
});
/*async.concat(content.alarmdaten, function(item, done) {
db.run(`INSERT OR REPLACE INTO waip_einsatzmittel (id, waip_einsaetze_ID, waip_wachen_ID, wachenname, einsatzmittel, zeitstempel)
VALUES (
@ -556,7 +564,8 @@ module.exports = function(db, async, app_cfg) {
});
};
function db_update_response(waip_id, i_ek, i_ma, i_fk, i_agt, callback) {
//veraltet
/*function db_update_response(waip_id, i_ek, i_ma, i_fk, i_agt, callback) {
db.run(`
UPDATE waip_response SET
einsatzkraft = einsatzkraft + \'` + i_ek + `\',
@ -593,19 +602,76 @@ module.exports = function(db, async, app_cfg) {
callback && callback(null);
};
});
};
};*/
function db_get_response(waip_id, callback){
db.get(`SELECT einsatzkraft EK, maschinist MA, fuehrungskraft FK, atemschutz AGT FROM waip_response
WHERE waip_einsaetze_id = ?`, [waip_id], function(err, row) {
if (err == null && row) {
callback && callback(row);
function db_save_response(waip_id, responseobj, callback) {
db.run((`INSERT INTO waip_response
(waip_einsaetze_id, response_json)
VALUES (
\'` + waip_id + `\',
\'` + responseobj + `\')`), function(err) {
if (err == null) {
callback && callback();
} else {
callback && callback(null);
};
});
};
function db_get_response_gesamter_einsatz(waip_einsaetze_id, callback){
db.all(`SELECT response_json FROM waip_response
WHERE waip_einsaetze_id = ?`, [waip_einsaetze_id], function(err, row) {
if (err == null && rows) {
callback && callback(rows);
} else {
callback && callback(null);
};
});
};
function db_get_response_wache(waip_einsaetze_id, wachen_nr, callback) {
db.all(`SELECT response_json FROM waip_response WHERE waip_einsaetze_id = ?`, [waip_einsaetze_id], function (err, row) {
if (err == null && rows) {
// Zeilen einzelnen durchgehen
function loop_done(waip_id) {
callback && callback(waip_id);
};
var itemsProcessed = 0;
var response_wache = {};
rows.forEach(function (item, index, array) {
if (item.wachen_nr.startsWith(wachen_nr)) {
// hier jsonobjekt increment erstellen
};
db.run(`INSERT OR REPLACE INTO waip_einsatzmittel (id, waip_einsaetze_ID, waip_wachen_ID, wachenname, einsatzmittel, zeitstempel)
VALUES (
(select ID from waip_einsatzmittel where einsatzmittel like \'` + item.einsatzmittel + `\'),
\'` + id + `\',
(select id from waip_wachen where name_wache like \'` + item.wachenname + `\'),
\'` + item.wachenname + `\',
\'` + item.einsatzmittel + `\',
\'` + item.zeit_a + `\')`,
function (err) {
if (err == null) {
itemsProcessed++;
if (itemsProcessed === array.length) {
loop_done(id);
};
} else {
callback && callback(null);
};
});
});
//callback && callback(row);
} else {
callback && callback(null);
};
});
};
return {
db_einsatz_speichern: db_einsatz_speichern,
db_einsatz_laden: db_einsatz_laden,

View File

@ -14,7 +14,6 @@ module.exports = function(io, sql, async, app_cfg) {
var room_sockets = io.sockets.adapter.rooms[row.room];
//console.log(row);
//console.log(row.room);
//console.log(room_sockets);
//console.log(io.sockets.adapter);
if (typeof room_sockets !== 'undefined') {