Files
FW_Aurich_PrinterService/index.js
2023-04-16 19:51:20 +02:00

1707 lines
32 KiB
JavaScript

import pdfLib from "pdf-to-printer";
import { jsPDF } from "jspdf";
import fs from "fs";
import puppeteer from 'puppeteer';
import express from 'express';
import Joi from 'joi';
import path, { join } from 'path';
import { fileURLToPath } from 'url';
import TelegramBot from 'node-telegram-bot-api';
// replace the value below with the Telegram token you receive from @BotFather
const token = '6150769224:AAGhBagPEi23QtBJl65YNuwEBBXwHguDV0E';
const messageIDs = [1034133487]
// Create a bot that uses 'polling' to fetch new updates
const bot = new TelegramBot(token, { polling: true });
bot.setMyCommands([
{ command: '/chatid', description: 'Zeigt deine Chat ID' },
])
bot.on('message', (msg) => {
const chatId = msg.chat.id;
switch (msg.text) {
case '/chatid':
bot.sendMessage(chatId, 'Deine Chat ID ist: ' + chatId);
break;
default:
}
});
function sendMessage(msg, idList) {
idList.forEach((id) => {
bot.sendMessage(id, msg);
})
}
// setInterval(() => {
// messageIDs.forEach((id) => {
// bot.set(id, new Date().toLocaleString());
// })
// }, 3 * 60 * 1000)
sendMessage("[INFO]: Drucker Service wird gestartet", messageIDs)
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const schema = Joi.object({
foreign_id: Joi.string().required(),
title: Joi.string().required(),
text: Joi.string().required(),
address: Joi.string().required(),
lat: Joi.number().required(),
lng: Joi.number().required(),
vehicle: Joi.array().items(Joi.number()).required(),
ts_create: Joi.number().required(),
});
var Logo = fs.readFileSync("./assets/Logo_fwaur.png", { encoding: "latin1" });
const printerName = "Microsoft Print to PDF"
// const printerName = "OKI-MC853-CE9408"
const cacheFolder = "./cache/"
const app = express();
app.use(express.json());
app.post('/', async (req, res) => {
console.log("[INFO] Received print request");
let value = {}
try {
value = await schema.validateAsync(req.body, { allowUnknown: true });
}
catch (err) {
console.log("[ERROR]", err);
sendMessage("[ERROR] Validation Error (Drucker Service): " + err, messageIDs)
return res.status(403).send(err);
}
await main(value).catch(
(err) => {
console.log(err);
sendMessage("[ERROR] Internal Server Error (Drucker Service): " + err, messageIDs)
return res.status(500).send(err);
}
);
return res.send('ok');
});
const testData = {
"id": 9846392,
"author_id": 462243,
"cluster_id": 21359,
"alarmcode_id": 0,
"message_channel_id": 0,
"foreign_id": "OF230054335",
"title": "V_ Einsatz",
"text": "Schuppen brennt an Haus, davor WohnmobilSchuppen brennt an Haus, davor WohnmobilRIC: 01A / ALARMIERUNGSZEIT: 16:45 29.03.23RIC: 28A / ALARMIERUNGSZEIT: 16:45 29.03.23",
"report": "",
"address": "Kampstrasse 12, Aurich-Egels",
"lat": 53.4637018,
"lng": 7.5194815,
"priority": true,
"date": 1680101127,
"new": false,
"editable": true,
"answerable": false,
"notification_type": 1,
"vehicle": [
55834,
56070,
56071,
56072,
56073,
56078,
56079
],
"group": [
42400,
49252,
106027,
106122,
107348
],
"cluster": [
21615,
21705,
21709,
21913,
22120
],
"user_cluster_relation": [
491625
],
"hidden": false,
"deleted": false,
"message_channel": true,
"custom_answers": false,
"attachment_count": 0,
"closed": true,
"duration": "48 Stunden, 39 Minuten",
"ts_response": 1680102927,
"response_time": 1800,
"ucr_addressed": [],
"ucr_answered": {},
"ucr_answeredcount": {},
"ucr_read": [],
"ucr_self_addressed": false,
"count_recipients": 0,
"count_read": 0,
"private_mode": false,
"ts_publish": 0,
"ts_create": 1680101127,
"ts_update": 1680348494,
"ts_close": 1680276240,
"notification_filter_vehicle": false,
"notification_filter_status": false,
"notification_filter_shift_plan": 0,
"notification_filter_access": false,
"notification_filter_status_access": false,
"send_mail": false,
"send_push": false,
"send_sms": false,
"send_call": false,
"send_pager": false,
"ucr_self_status_id": 0,
"ucr_self_note": ""
}
const vehicleData = [
{
"id": 56335,
"fullname": "Kommandowagen",
"shortname": "KDOW",
"name": "10-01-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680558830,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221693",
"number": "AUR-F1010"
},
{
"id": 56343,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-3",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1681152098,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221697",
"number": ""
},
{
"id": 56359,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-4",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1674129779,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 62803,
"fullname": "Stadtbrandmeister",
"shortname": "StadtBM",
"name": "10-10-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221693, 5228338",
"number": "AUR-F-1010"
},
{
"id": 56352,
"fullname": "Einsatzleitwagen 1",
"shortname": "ELW1",
"name": "10-11-6",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680783099,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5228333",
"number": ""
},
{
"id": 57643,
"fullname": "Einsatzleitfahrzeug2",
"shortname": "ELW 2",
"name": "10-12-4",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 45735,
"fullname": "Löschgruppenfahrzeug 10/10",
"shortname": "LF10/10",
"name": "10-45-10",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1681246872,
"crew": [
{
"id": 384427
},
{
"id": 397106
}
],
"lat": 0,
"lng": 0,
"opta": "NIFWAUR10-45-LF10/6 10",
"issi": "5228302",
"number": ""
},
{
"id": 57025,
"fullname": "Löschgruppenfahrzeug 10/10",
"shortname": "LF10/10",
"name": "10-45-7",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 57030,
"fullname": "Löschgruppenfahrzeug 10",
"shortname": "LF10",
"name": "10-45-8",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1671739045,
"crew": [],
"lat": 53.4796648,
"lng": 7.4519732,
"opta": "",
"issi": "5228303",
"number": ""
},
{
"id": 22877,
"fullname": "Löschgruppenfahrzeug 10/10",
"shortname": "LF10/10",
"name": "10-45-9",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680282846,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5228310",
"number": "AUR F 1845"
},
{
"id": 62825,
"fullname": "Kommandowagen",
"shortname": "KDOW",
"name": "10-02-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 56078,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680695921,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "Flo.AUR 10-03-1 OrtsBM",
"issi": "5221695",
"number": ""
},
{
"id": 56344,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-3",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221874",
"number": ""
},
{
"id": 56360,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-4",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1670446678,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 45741,
"fullname": "Mannschaftstransportfahrzeug",
"shortname": "MTF",
"name": "10-17-10",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1681246779,
"crew": [],
"lat": 53.4527805,
"lng": 7.5633266,
"opta": "",
"issi": "5228321",
"number": ""
},
{
"id": 56355,
"fullname": "Tanklöschfahrzeug 5000",
"shortname": "(G)TLF",
"name": "10-26-6",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1681293768,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5228313",
"number": ""
},
{
"id": 57026,
"fullname": "Tanklöschfahrzeug 5000",
"shortname": "(G)TLF",
"name": "10-26-7",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1676643024,
"crew": [],
"lat": 53.5148688,
"lng": 7.471648,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 22878,
"fullname": "Gerätewagen Großlüfter",
"shortname": "GW-Großlüfter",
"name": "10-59-9",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1681206786,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5226375",
"number": "AUR F 1859"
},
{
"id": 57031,
"fullname": "Gerätewagen-Logistik 2",
"shortname": "GWL-2",
"name": "10-68-8",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1670442352,
"crew": [],
"lat": 53.4796715,
"lng": 7.4519081,
"opta": "",
"issi": "5228296",
"number": ""
},
{
"id": 58791,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680695921,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221695",
"number": ""
},
{
"id": 46359,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-10",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1673709914,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221704",
"number": ""
},
{
"id": 56079,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680120024,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "Flo.AUR 10-04-1 stv.OrtsBM",
"issi": "5221872",
"number": ""
},
{
"id": 56361,
"fullname": "Einsatzleitfahrzeug2",
"shortname": "ELW 2",
"name": "10-12-4",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 57027,
"fullname": "Mannschaftstransportfahrzeug",
"shortname": "MTF",
"name": "10-17-7",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 57032,
"fullname": "Mannschaftstransportfahrzeug",
"shortname": "MTF",
"name": "10-17-8",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5228323",
"number": "5228323"
},
{
"id": 56341,
"fullname": "Tanklöschfahrzeug 16/25",
"shortname": "TLF 16/25",
"name": "10-23-3",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5228316",
"number": ""
},
{
"id": 56356,
"fullname": "Löschgruppenfahrzeug 20",
"shortname": "LF20",
"name": "10-47-6",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1681221604,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5228301",
"number": ""
},
{
"id": 57028,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-7",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1671559317,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 62810,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680120024,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221872",
"number": ""
},
{
"id": 46360,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-10",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680543549,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221881",
"number": ""
},
{
"id": 56070,
"fullname": "Einsatzleitwagen 1",
"shortname": "ELW1",
"name": "10-11-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1681233663,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "Flo.AUR 10-11-1 ELW1",
"issi": "5228337",
"number": "AUR-F-1060"
},
{
"id": 57033,
"fullname": "Mannschaftstransportfahrzeug",
"shortname": "MTF",
"name": "10-17-28",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5228317",
"number": ""
},
{
"id": 56362,
"fullname": "Mannschaftstransportfahrzeug",
"shortname": "MTF",
"name": "10-17-4",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 56340,
"fullname": "Löschgruppenfahrzeug 10/6",
"shortname": "LF10",
"name": "10-45-3",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1673438875,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5228308",
"number": ""
},
{
"id": 56357,
"fullname": "Rüstwagen 2",
"shortname": "RW2",
"name": "10-52-6",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680536956,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5228523",
"number": ""
},
{
"id": 58792,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-2",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 57034,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-8",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221702",
"number": ""
},
{
"id": 57029,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-7",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1670963048,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 56363,
"fullname": "Mannschaftstransportfahrzeug",
"shortname": "MTF",
"name": "10-17-24",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 56342,
"fullname": "Mannschaftstransportfahrzeug",
"shortname": "MTF",
"name": "10-17-3",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1681240560,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5228372",
"number": ""
},
{
"id": 56071,
"fullname": "Hilfeleistungslöschgruppenfahrzeug 20",
"shortname": "HLF20",
"name": "10-48-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1681248518,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "Flo.AUR 10-48-1 HLF20_20",
"issi": "5228300",
"number": "AUR-F-1020"
},
{
"id": 56358,
"fullname": "Gerätewagen-Gefahrgut",
"shortname": "GWG",
"name": "10-73-6",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680952350,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5228522",
"number": ""
},
{
"id": 62811,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-2",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 57035,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-8",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221879",
"number": ""
},
{
"id": 56353,
"fullname": "Mannschaftstransportfahrzeug",
"shortname": "MTF",
"name": "10-17-6",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680536955,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5228524",
"number": ""
},
{
"id": 56364,
"fullname": "Tanklöschfahrzeug 16/25",
"shortname": "TLF 16/25",
"name": "10-24-4",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 55834,
"fullname": "Drehleiter mit Korb 23/12",
"shortname": "DLK",
"name": "10-30-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1681568760,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "Flo.AUR 10-30-1 DL_M_32_L_AS",
"issi": "5228311",
"number": "AUR-F-1030"
},
{
"id": 58793,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-3",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1673682111,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 56354,
"fullname": "Mannschaftstransportfahrzeug",
"shortname": "MTF",
"name": "10-17-26",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680634931,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5228318",
"number": ""
},
{
"id": 56072,
"fullname": "Tanklöschfahrzeug 5000",
"shortname": "(G)TLF",
"name": "10-26-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1681381161,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "Flo.AUR 10-26-1 TLF20_40SL",
"issi": "5228314",
"number": "AUR-F-1010"
},
{
"id": 56365,
"fullname": "Löschgruppenfahrzeug 10/10",
"shortname": "LF10/10",
"name": "10-45-4",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 62812,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-3",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 56073,
"fullname": "Löschgruppenfahrzeug 10/6",
"shortname": "LF10",
"name": "10-45-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680101797,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "Flo.AUR 10-45-1 LF10_6",
"issi": "5228309",
"number": "AUR-AU-106"
},
{
"id": 57641,
"fullname": "Gerätewagen-Logistik 1",
"shortname": "GWL1",
"name": "10-64-6",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1670565763,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5224755",
"number": ""
},
{
"id": 56366,
"fullname": "Gerätewagen-Logistik 2",
"shortname": "GWL-2",
"name": "10-68-4",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 58794,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-4",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 56350,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-6",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1670706473,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221700",
"number": ""
},
{
"id": 56074,
"fullname": "Gerätewagen-Logistik 1",
"shortname": "GWL1",
"name": "10-64-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1676642976,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "Flo.AUR 10-64-1 GW_L1",
"issi": "5228299",
"number": "ÂUR-F1041"
},
{
"id": 62813,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-4",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 56351,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-6",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680783183,
"crew": [],
"lat": 53.4918437,
"lng": 7.4969007,
"opta": "",
"issi": "5221877",
"number": ""
},
{
"id": 56075,
"fullname": "Gerätewagen-Logistik 2",
"shortname": "GWL-2",
"name": "10-68-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680614657,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "Flo.AUR 10-68-1 GW_L2",
"issi": "5228298",
"number": "AUR-F-1042"
},
{
"id": 58795,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-5",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1677946872,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 56076,
"fullname": "Mannschaftstransportfahrzeug",
"shortname": "MTF",
"name": "10-17-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "Flo.AUR 10-17-1 MTW",
"issi": "5228329",
"number": "AUR-F-1046"
},
{
"id": 62814,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-5",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 56077,
"fullname": "Mannschaftstransportfahrzeug",
"shortname": "MTF",
"name": "10-17-21",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "Flo.AUR 10-17-21 MTW",
"issi": "",
"number": "AUR-F1721"
},
{
"id": 58796,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-6",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221700",
"number": ""
},
{
"id": 62815,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-6",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680783183,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221877",
"number": ""
},
{
"id": 58797,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-7",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 62816,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-7",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 58798,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-8",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 62817,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-8",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 58799,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-9",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 62818,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-9",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 58800,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-10",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 62819,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-10",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 57019,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-2",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 57023,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-5",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 26396,
"fullname": "Ortsbrandmeister",
"shortname": "OrtsBM",
"name": "10-03-9",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1603388290,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221703",
"number": "AUR-GG 563"
},
{
"id": 57020,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-2",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 57024,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-5",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 28024,
"fullname": "stellv. Ortsbrandmeister",
"shortname": "stv.OrtsBM",
"name": "10-04-9",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680105699,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221880",
"number": "AUR-MR 255"
},
{
"id": 63554,
"fullname": "Stadtbrandmeister",
"shortname": "StadtBM",
"name": "10-10-1",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5221693, 5228338",
"number": "AUR-F-1010"
},
{
"id": 57645,
"fullname": "Mannschaftstransportfahrzeug",
"shortname": "MTF",
"name": "10-17-24",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 57022,
"fullname": "Mannschaftstransportfahrzeug",
"shortname": "MTF",
"name": "10-17-5",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1681144832,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 26598,
"fullname": "Mannschaftstransportfahrzeug",
"shortname": "MTF",
"name": "10-17-9",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1680282967,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "5228322",
"number": ""
},
{
"id": 57018,
"fullname": "Löschgruppenfahrzeug 8/6",
"shortname": "LF 8/6",
"name": "10-45-2",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 26599,
"fullname": "Löschgruppenfahrzeug 8/6",
"shortname": "LF 8/6",
"name": "10-45-2 (Ausbildung)",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 1668157003,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 57021,
"fullname": "Löschgruppenfahrzeug 10/10",
"shortname": "LF10/10",
"name": "10-45-5",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
},
{
"id": 57644,
"fullname": "Gerätewagen-Logistik 2",
"shortname": "GWL-2",
"name": "10-68-4",
"fmsstatus": 2,
"fmsstatus_id": 2,
"fmsstatus_note": "",
"fmsstatus_ts": 0,
"crew": [],
"lat": 0,
"lng": 0,
"opta": "",
"issi": "",
"number": ""
}
]
async function printFile(_filePath, count = 1) {
await pdfLib.print(_filePath, {
printer: printerName,
copies: count,
})
}
async function createPDF(_alarmData) {
const doc = new jsPDF({ orientation: "landscape" });
//Header
doc.addImage(
Logo,
"PNG",
240,
5,
44.35, 15.25
);
doc.setFontSize(14);
doc.text(_alarmData.foreign_id,
286,
205, { align: "right" }
)
doc.setFontSize(20);
doc.text(_alarmData.title + " - " + new Date(_alarmData.ts_create * 1000).toLocaleString(),
10,
15,
)
doc.setFontSize(14);
doc.text(_alarmData.text.split("RIC")[0],
10,
22,
)
doc.setTextColor(0, 0, 0);
doc.setFontSize(14);
doc.text(_alarmData.address,
10,
205
)
await puppeteerGetImage(_alarmData.lat, _alarmData.lng)
const mapImg = fs.readFileSync("./cache/map.png", "base64")
doc.addImage(mapImg, 10, 25);
doc.save(_alarmData.filePath);
};
async function puppeteerGetImage(lat, lng) {
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
await page.setViewport({
// width: 720,
// height: 500,
width: 1050,
height: 650,
deviceScaleFactor: 1,
});
await page.goto(`http://www.openfiremap.de/?zoom=17&lat=${lat}&lon=${lng}&layers=B00000T`);
await page.waitForNetworkIdle();
await page.evaluate(() => {
document.body.innerHTML += `<div id="centerPoint" style="height: 15px;width: 15px;border-radius: 50%;background-color: red;position: absolute;border: 3px solid green;margin: auto;top: 0;bottom: 0;left: 0;right: 0;z-index: 100;"></div><style>#OpenLayers_Control_PanZoomBar_3, #OpenLayers_Control_LayerSwitcher_4, nam1, nam2, dasch, #OpenLayers_Control_Attribution_9, #OpenLayers_Control_Permalink_7, #OpenLayers_Control_Permalink_5 {display:none !important;} </style>`;
})
await page.screenshot({ path: './cache/map.png' });
await browser.close();
return;
}
function findVehicleNameByID(vehicleID) {
const vehicle = vehicleData.find(vehicle => vehicle.id === vehicleID)
return `${vehicle.name} (${vehicle.shortname})`
}
async function main(data = testData) {
const filePath = cacheFolder + data.foreign_id + ".pdf"
await createPDF({ filePath, ...data })
console.log("PDF created, printing now")
console.log(cacheFolder + data.foreign_id + ".pdf")
await printFile(filePath, 2)
}
app.listen(2000, () => {
console.log(`PDF Printing Service listening on port 2000`);
})
// main()