alsmanager_lib 3.0.216 → 3.0.218
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/modules.js +125 -23
- package/package.json +1 -1
package/lib/modules.js
CHANGED
|
@@ -12064,12 +12064,12 @@ function queryHiddenGroupByType(db_used,dev_type) {
|
|
|
12064
12064
|
//End Get hidden groups by id
|
|
12065
12065
|
// Define getConnectionSetById
|
|
12066
12066
|
function getConnectionSetByIdSQLite(id_conn_set) {
|
|
12067
|
-
var query = "select id, id_set, id_conn, id_adapter, verse from set_connections ";
|
|
12067
|
+
var query = "select id, id_set, id_conn, id_adapter, verse, lunghezza_cm, in_canaletta from set_connections ";
|
|
12068
12068
|
query += "where id = " + id_conn_set;
|
|
12069
12069
|
return query;
|
|
12070
12070
|
}
|
|
12071
12071
|
function getConnectionSetByIdMySQL(id_conn_set) {
|
|
12072
|
-
var query = "select id, id_set, id_conn, id_adapter, verse from set_connections ";
|
|
12072
|
+
var query = "select id, id_set, id_conn, id_adapter, verse, lunghezza_cm, in_canaletta from set_connections ";
|
|
12073
12073
|
query += "where id = :id_conn_set";
|
|
12074
12074
|
return query;
|
|
12075
12075
|
}
|
|
@@ -12099,7 +12099,12 @@ function getConnectionByIdSetSQLite(id_set) {
|
|
|
12099
12099
|
query += "when sc.id_adapter is not null and sc.id_adapter > 0 then concat(ac1.conn_type, ' -> ', ac2.conn_type) ";
|
|
12100
12100
|
query += "else '' ";
|
|
12101
12101
|
query += "end as Adattatore, ";
|
|
12102
|
-
query += "sc.verse as Verso
|
|
12102
|
+
query += "sc.verse as Verso, sc.lunghezza_cm as Lunghezza, ";
|
|
12103
|
+
query += "case ";
|
|
12104
|
+
query += "when sc.in_canaletta is not null and sc.in_canaletta > 0 then 'SI' ";
|
|
12105
|
+
query += "else 'NO' ";
|
|
12106
|
+
query += "end as Incanalato ";
|
|
12107
|
+
query += "from set_connections sc ";
|
|
12103
12108
|
query += "join connection_types ct on ct.id = sc.id_conn ";
|
|
12104
12109
|
query += "left join adapter_types at on sc.id_adapter = at.id ";
|
|
12105
12110
|
query += "left join connection_types ac1 on at.adapt_type_in = ac1.id ";
|
|
@@ -12113,7 +12118,12 @@ function getConnectionByIdSetMySQL(id_set) {
|
|
|
12113
12118
|
query += "when sc.id_adapter is not null and sc.id_adapter > 0 then concat(ac1.conn_type, ' -> ', ac2.conn_type) ";
|
|
12114
12119
|
query += "else '' ";
|
|
12115
12120
|
query += "end as Adattatore, ";
|
|
12116
|
-
query += "sc.verse as Verso
|
|
12121
|
+
query += "sc.verse as Verso, sc.lunghezza_cm as Lunghezza, ";
|
|
12122
|
+
query += "case ";
|
|
12123
|
+
query += "when sc.in_canaletta is not null and sc.in_canaletta > 0 then 'SI' ";
|
|
12124
|
+
query += "else 'NO' ";
|
|
12125
|
+
query += "end as Incanalato ";
|
|
12126
|
+
query += "from set_connections sc ";
|
|
12117
12127
|
query += "join connection_types ct on ct.id = sc.id_conn ";
|
|
12118
12128
|
query += "left join adapter_types at on sc.id_adapter = at.id ";
|
|
12119
12129
|
query += "left join connection_types ac1 on at.adapt_type_in = ac1.id ";
|
|
@@ -12139,24 +12149,30 @@ function getConnectionByIdSet(db_used, id_set) {
|
|
|
12139
12149
|
}
|
|
12140
12150
|
//End Define getConnectionByIdSet
|
|
12141
12151
|
// Define updateConnectionSet
|
|
12142
|
-
function updateConnectionSetSQLite(id_set, id_conn_set, id_conn, verse, id_adapter) {
|
|
12152
|
+
function updateConnectionSetSQLite(id_set, id_conn_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta) {
|
|
12143
12153
|
var query = "update set_connections set ";
|
|
12144
12154
|
if (id_set && id_set > 0) {
|
|
12145
12155
|
query += "id_set = " + id_set + ", ";
|
|
12146
12156
|
}
|
|
12147
12157
|
if (id_conn && id_conn > 0) {
|
|
12148
|
-
query += "id_conn = " + id_conn
|
|
12158
|
+
query += ", id_conn = " + id_conn;
|
|
12149
12159
|
}
|
|
12150
12160
|
if (id_adapter && id_adapter > 0) {
|
|
12151
|
-
query += "id_adapter = " + id_adapter
|
|
12161
|
+
query += ", id_adapter = " + id_adapter;
|
|
12152
12162
|
}
|
|
12153
12163
|
if (verse) {
|
|
12154
|
-
query += "verse = '" + verse
|
|
12164
|
+
query += ", verse = '" + verse;
|
|
12165
|
+
}
|
|
12166
|
+
if (lunghezza_cm) {
|
|
12167
|
+
query += ", lunghezza_cm = " + lunghezza_cm;
|
|
12168
|
+
}
|
|
12169
|
+
if (in_canaletta) {
|
|
12170
|
+
query += ", in_canaletta = " + in_canaletta;
|
|
12155
12171
|
}
|
|
12156
12172
|
query += "where id = " + id_conn_set;
|
|
12157
12173
|
return query;
|
|
12158
12174
|
}
|
|
12159
|
-
function updateConnectionSetMySQL(id_set, id_conn_set, id_conn, verse, id_adapter) {
|
|
12175
|
+
function updateConnectionSetMySQL(id_set, id_conn_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta) {
|
|
12160
12176
|
var query = "update set_connections set ";
|
|
12161
12177
|
if (id_set && id_set > 0) {
|
|
12162
12178
|
query += "id_set = :id_set, ";
|
|
@@ -12173,18 +12189,18 @@ function updateConnectionSetMySQL(id_set, id_conn_set, id_conn, verse, id_adapte
|
|
|
12173
12189
|
query += "where id = :id_conn_set";
|
|
12174
12190
|
return query;
|
|
12175
12191
|
}
|
|
12176
|
-
function updateConnectionSet(db_used, id_set, id_conn_set, id_conn, verse, id_adapter) {
|
|
12192
|
+
function updateConnectionSet(db_used, id_set, id_conn_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta) {
|
|
12177
12193
|
var query = "";
|
|
12178
12194
|
if (db_used) {
|
|
12179
12195
|
switch (db_used) {
|
|
12180
12196
|
case 'SQLITE':
|
|
12181
|
-
query = updateConnectionSetSQLite(id_set, id_conn_set, id_conn, verse, id_adapter);
|
|
12197
|
+
query = updateConnectionSetSQLite(id_set, id_conn_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta);
|
|
12182
12198
|
break;
|
|
12183
12199
|
case 'MYSQL':
|
|
12184
|
-
query = updateConnectionSetMySQL(id_set, id_conn_set, id_conn, verse, id_adapter);
|
|
12200
|
+
query = updateConnectionSetMySQL(id_set, id_conn_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta);
|
|
12185
12201
|
break;
|
|
12186
12202
|
case 'MYSQL2':
|
|
12187
|
-
query = updateConnectionSetSQLite(id_set, id_conn_set, id_conn, verse, id_adapter);
|
|
12203
|
+
query = updateConnectionSetSQLite(id_set, id_conn_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta);
|
|
12188
12204
|
break;
|
|
12189
12205
|
}
|
|
12190
12206
|
}
|
|
@@ -12192,34 +12208,58 @@ function updateConnectionSet(db_used, id_set, id_conn_set, id_conn, verse, id_ad
|
|
|
12192
12208
|
}
|
|
12193
12209
|
// end define updateConnectionSet
|
|
12194
12210
|
// Define insertConnectionSet
|
|
12195
|
-
function insertConnectionSetSQLite(id_set, id_conn, verse, id_adapter) {
|
|
12196
|
-
var
|
|
12211
|
+
function insertConnectionSetSQLite(id_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta, date_start) {
|
|
12212
|
+
var dt_start_str = "2025-09-01";
|
|
12213
|
+
if (date_start) {
|
|
12214
|
+
dt_start_str = convertDateToStringDB(date_start);
|
|
12215
|
+
}
|
|
12216
|
+
var in_canaletta_sw = 0;
|
|
12217
|
+
if (in_canaletta) {
|
|
12218
|
+
in_canaletta_sw = in_canaletta;
|
|
12219
|
+
}
|
|
12220
|
+
var query = "insert into set_connections (id_set, id_conn, id_adapter, verse, lunghezza_cm, in_canaletta, date_start, date_end) values ";
|
|
12197
12221
|
query += "(" + id_set + ", ";
|
|
12198
12222
|
query += id_conn + ", ";
|
|
12199
12223
|
query += id_adapter + ", ";
|
|
12200
|
-
query += "'" + verse + "'
|
|
12224
|
+
query += "'" + verse + "', ";
|
|
12225
|
+
query += in_canaletta_sw + ", ";
|
|
12226
|
+
query += "'" + dt_start_str + "', ";
|
|
12227
|
+
query += "'2999-12-31'"
|
|
12228
|
+
query += ")";
|
|
12201
12229
|
return query;
|
|
12202
12230
|
}
|
|
12203
|
-
function insertConnectionSetMySQL(id_set, id_conn, verse, id_adapter) {
|
|
12204
|
-
var
|
|
12231
|
+
function insertConnectionSetMySQL(id_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta, date_start) {
|
|
12232
|
+
var dt_start_str = "2025-09-01";
|
|
12233
|
+
if (date_start) {
|
|
12234
|
+
dt_start_str = convertDateToStringDB(date_start);
|
|
12235
|
+
}
|
|
12236
|
+
var in_canaletta_sw = 0;
|
|
12237
|
+
if (in_canaletta) {
|
|
12238
|
+
in_canaletta_sw = in_canaletta;
|
|
12239
|
+
}
|
|
12240
|
+
var query = "insert into set_connections (id_set, id_conn, id_adapter, verse, lunghezza_cm, in_canaletta, date_start, date_end) values ";
|
|
12205
12241
|
query += "(:id_set, ";
|
|
12206
12242
|
query += ":id_conn, ";
|
|
12207
12243
|
query += ":id_adapter, ";
|
|
12208
|
-
query += ":verse
|
|
12244
|
+
query += ":verse, ";
|
|
12245
|
+
query += in_canaletta_sw + ", ";
|
|
12246
|
+
query += "'" + dt_start_str + "', ";
|
|
12247
|
+
query += "'2999-12-31'"
|
|
12248
|
+
query += ")";
|
|
12209
12249
|
return query;
|
|
12210
12250
|
}
|
|
12211
|
-
function insertConnectionSet(db_used, id_set, id_conn, verse, id_adapter) {
|
|
12251
|
+
function insertConnectionSet(db_used, id_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta) {
|
|
12212
12252
|
var query = "";
|
|
12213
12253
|
if (db_used) {
|
|
12214
12254
|
switch (db_used) {
|
|
12215
12255
|
case 'SQLITE':
|
|
12216
|
-
query = insertConnectionSetSQLite(id_set, id_conn, verse, id_adapter);
|
|
12256
|
+
query = insertConnectionSetSQLite(id_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta);
|
|
12217
12257
|
break;
|
|
12218
12258
|
case 'MYSQL':
|
|
12219
|
-
query = insertConnectionSetMySQL(id_set, id_conn, verse, id_adapter);
|
|
12259
|
+
query = insertConnectionSetMySQL(id_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta);
|
|
12220
12260
|
break;
|
|
12221
12261
|
case 'MYSQL2':
|
|
12222
|
-
query = insertConnectionSetSQLite(id_set, id_conn, verse, id_adapter);
|
|
12262
|
+
query = insertConnectionSetSQLite(id_set, id_conn, verse, id_adapter, lunghezza_cm, in_canaletta);
|
|
12223
12263
|
break;
|
|
12224
12264
|
}
|
|
12225
12265
|
}
|
|
@@ -12257,6 +12297,66 @@ function removeConnectionSet(db_used, id_set, id_conn_set) {
|
|
|
12257
12297
|
return query;
|
|
12258
12298
|
}
|
|
12259
12299
|
|
|
12300
|
+
function updateConnectionSetAfterRemoveSQLite(id_set) {
|
|
12301
|
+
var query = "update set_connections set date_out = '2999-12-31' ";
|
|
12302
|
+
query += "where id_set = " + id_set + " and date_start = (select max(date_start) from set_connections where id_set = " + id_set + ")";
|
|
12303
|
+
return query;
|
|
12304
|
+
}
|
|
12305
|
+
function updateConnectionSetAfterRemoveMySQL(id_set) {
|
|
12306
|
+
var query = "update set_connections set date_out = '2999-12-31' ";
|
|
12307
|
+
query += "where id_set = :id_set and date_start = (select max(date_start) from set_connections where id_set = :id_set)";
|
|
12308
|
+
return query;
|
|
12309
|
+
}
|
|
12310
|
+
function updateConnectionSetAfterRemove(db_used, id_set) {
|
|
12311
|
+
var query = "";
|
|
12312
|
+
if (db_used) {
|
|
12313
|
+
switch (db_used) {
|
|
12314
|
+
case 'SQLITE':
|
|
12315
|
+
query = updateConnectionSetAfterRemoveSQLite(id_set);
|
|
12316
|
+
break;
|
|
12317
|
+
case 'MYSQL':
|
|
12318
|
+
query = updateConnectionSetAfterRemoveMySQL(id_set);
|
|
12319
|
+
break;
|
|
12320
|
+
case 'MYSQL2':
|
|
12321
|
+
query = updateConnectionSetAfterRemoveSQLite(id_set);
|
|
12322
|
+
break;
|
|
12323
|
+
}
|
|
12324
|
+
}
|
|
12325
|
+
return query;
|
|
12326
|
+
}
|
|
12327
|
+
|
|
12328
|
+
function updateConnectionSetDatesSQLite(id_set) {
|
|
12329
|
+
var query = "update set_connections set date_end = date('now','-1 day') ";
|
|
12330
|
+
query += "where id_set = " + id_set + " and date_start = (select max(date_start) from set_connections where id_set = " + id_set + ")";
|
|
12331
|
+
return query;
|
|
12332
|
+
}
|
|
12333
|
+
function updateConnectionSetDatesMySQL(id_device) {
|
|
12334
|
+
var query = "update set_connections set date_end = DATE_SUB(CURDATE(), INTERVAL 1 DAY) ";
|
|
12335
|
+
query += "where id_set = :id_set and date_start = (select max(date_start) from set_connections where id_set = :id_set)";
|
|
12336
|
+
return query;
|
|
12337
|
+
}
|
|
12338
|
+
function updateConnectionSetDatesMySQL2(id_device) {
|
|
12339
|
+
var query = "update set_connections set date_end = DATE_SUB(CURDATE(), INTERVAL 1 DAY) ";
|
|
12340
|
+
query += "where id_set = " + id_set + " and date_start = (select max(date_start) from set_connections where id_set = " + id_set + ")";
|
|
12341
|
+
return query;
|
|
12342
|
+
}
|
|
12343
|
+
function updateConnectionSetDates(db_used,id_set) {
|
|
12344
|
+
var query = "";
|
|
12345
|
+
if (db_used) {
|
|
12346
|
+
switch (db_used) {
|
|
12347
|
+
case 'SQLITE':
|
|
12348
|
+
query = updateConnectionSetDatesSQLite(id_device);
|
|
12349
|
+
break;
|
|
12350
|
+
case 'MYSQL':
|
|
12351
|
+
query = updateConnectionSetDatesMySQL(id_device);
|
|
12352
|
+
break;
|
|
12353
|
+
case 'MYSQL2':
|
|
12354
|
+
query = updateConnectionSetDatesMySQL2(id_device);
|
|
12355
|
+
break;
|
|
12356
|
+
}
|
|
12357
|
+
}
|
|
12358
|
+
return query;
|
|
12359
|
+
}
|
|
12260
12360
|
// end define removeConnectionSet
|
|
12261
12361
|
|
|
12262
12362
|
function getBeniConsumoTypes() {
|
|
@@ -17097,6 +17197,8 @@ module.exports = {
|
|
|
17097
17197
|
insertConnectionSet,
|
|
17098
17198
|
updateConnectionSet,
|
|
17099
17199
|
removeConnectionSet,
|
|
17200
|
+
updateConnectionSetAfterRemove,
|
|
17201
|
+
updateConnectionSetDates,
|
|
17100
17202
|
getConnectionByIdSet,
|
|
17101
17203
|
getConnectionSetById,
|
|
17102
17204
|
queryDetailsByIdDevice,
|