@7365admin1/core 2.41.0 → 2.42.0
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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.js +197 -116
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +417 -330
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -842,7 +842,6 @@ function useFeedbackRepo() {
|
|
|
842
842
|
cacheOptions.from = from;
|
|
843
843
|
cacheOptions.to = to;
|
|
844
844
|
}
|
|
845
|
-
console.log("query", JSON.stringify(query));
|
|
846
845
|
const cacheKey = (0, import_node_server_utils5.makeCacheKey)(feedbacks_namespace_collection, cacheOptions);
|
|
847
846
|
const cachedData = await getCache(cacheKey);
|
|
848
847
|
if (cachedData) {
|
|
@@ -2293,7 +2292,6 @@ function useOccurrenceEntryRepo() {
|
|
|
2293
2292
|
throw new Error("Invalid incident report ID.");
|
|
2294
2293
|
}
|
|
2295
2294
|
}
|
|
2296
|
-
console.log("Updating occurrence entry:", _id, value);
|
|
2297
2295
|
try {
|
|
2298
2296
|
const res = await collection.updateOne(
|
|
2299
2297
|
{ _id },
|
|
@@ -10577,7 +10575,6 @@ function useSubscriptionService() {
|
|
|
10577
10575
|
subscription.nextBillingDate,
|
|
10578
10576
|
"pending"
|
|
10579
10577
|
);
|
|
10580
|
-
console.log("dueInvoice", dueInvoice);
|
|
10581
10578
|
if (value.promoCode) {
|
|
10582
10579
|
const promoCode = await getByCode(value.promoCode);
|
|
10583
10580
|
if (!promoCode) {
|
|
@@ -11597,11 +11594,8 @@ function useFeedbackController() {
|
|
|
11597
11594
|
(acc, [key, value]) => ({ ...acc, [key]: value }),
|
|
11598
11595
|
{}
|
|
11599
11596
|
);
|
|
11600
|
-
console.log("cookies", cookies);
|
|
11601
11597
|
const createdBy = cookies?.["user"].toString() ?? "";
|
|
11602
|
-
console.log("createdBy", createdBy);
|
|
11603
11598
|
const payload = { ...req.body, createdBy };
|
|
11604
|
-
console.log("payload", payload);
|
|
11605
11599
|
const { error } = feedbackSchema.validate(payload);
|
|
11606
11600
|
if (error) {
|
|
11607
11601
|
import_node_server_utils57.logger.log({ level: "error", message: error.message });
|
|
@@ -13501,7 +13495,8 @@ var schemaPerson = import_joi35.default.object({
|
|
|
13501
13495
|
plates: import_joi35.default.array().items(schemaPlate).optional().allow(null),
|
|
13502
13496
|
isOwner: import_joi35.default.boolean().required(),
|
|
13503
13497
|
files: import_joi35.default.array().items(schemaFiles).optional().allow(null),
|
|
13504
|
-
password: import_joi35.default.string().optional().allow(null, "")
|
|
13498
|
+
password: import_joi35.default.string().optional().allow(null, ""),
|
|
13499
|
+
plateNumber: import_joi35.default.string().optional().allow(null, "")
|
|
13505
13500
|
});
|
|
13506
13501
|
var schemaUpdatePerson = import_joi35.default.object({
|
|
13507
13502
|
_id: import_joi35.default.string().hex().required(),
|
|
@@ -13521,7 +13516,8 @@ var schemaUpdatePerson = import_joi35.default.object({
|
|
|
13521
13516
|
plates: import_joi35.default.array().items(schemaFiles).optional().allow(null, ""),
|
|
13522
13517
|
isOwner: import_joi35.default.boolean().optional().allow(null, ""),
|
|
13523
13518
|
files: import_joi35.default.array().items(schemaFiles).optional().allow(null),
|
|
13524
|
-
password: import_joi35.default.string().optional().allow(null, "")
|
|
13519
|
+
password: import_joi35.default.string().optional().allow(null, ""),
|
|
13520
|
+
plateNumber: import_joi35.default.string().optional().allow(null, "")
|
|
13525
13521
|
});
|
|
13526
13522
|
function MPerson(value) {
|
|
13527
13523
|
const { error } = schemaPerson.validate(value);
|
|
@@ -13591,6 +13587,7 @@ function MPerson(value) {
|
|
|
13591
13587
|
plates: value.plates ?? [],
|
|
13592
13588
|
isOwner: value.isOwner ?? false,
|
|
13593
13589
|
files: value.files ?? [],
|
|
13590
|
+
plateNumber: value.plateNumber ?? "",
|
|
13594
13591
|
createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
13595
13592
|
updatedAt: value.updatedAt,
|
|
13596
13593
|
deletedAt: value.deletedAt
|
|
@@ -13924,7 +13921,6 @@ function useVisitorTransactionRepo() {
|
|
|
13924
13921
|
...status && { status },
|
|
13925
13922
|
...tab == "Overnight Parking" && { isOvernightParking: true }
|
|
13926
13923
|
};
|
|
13927
|
-
console.log(query);
|
|
13928
13924
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
13929
13925
|
try {
|
|
13930
13926
|
const basePipeline = [{ $match: query }];
|
|
@@ -14397,8 +14393,8 @@ function MVehicle(value) {
|
|
|
14397
14393
|
const createdAtDate = value.createdAt ? new Date(value.createdAt) : /* @__PURE__ */ new Date();
|
|
14398
14394
|
const expiredDate = new Date(createdAtDate);
|
|
14399
14395
|
expiredDate.setFullYear(expiredDate.getFullYear() + 10);
|
|
14400
|
-
const createdAt = createdAtDate
|
|
14401
|
-
const expiredAt = value.end ?? expiredDate
|
|
14396
|
+
const createdAt = createdAtDate;
|
|
14397
|
+
const expiredAt = value.end ?? expiredDate;
|
|
14402
14398
|
return {
|
|
14403
14399
|
plateNumber: value.plateNumber ?? "",
|
|
14404
14400
|
type: value.type ?? "",
|
|
@@ -14414,8 +14410,8 @@ function MVehicle(value) {
|
|
|
14414
14410
|
nric: value.nric ?? "",
|
|
14415
14411
|
remarks: value.remarks ?? "",
|
|
14416
14412
|
seasonPassType: value.seasonPassType ?? "",
|
|
14417
|
-
start: value.start
|
|
14418
|
-
end: value.end
|
|
14413
|
+
start: value.start ? new Date(value.start) : createdAt,
|
|
14414
|
+
end: value.end ? new Date(value.end) : expiredAt,
|
|
14419
14415
|
status: value.status ?? "active" /* ACTIVE */,
|
|
14420
14416
|
unitName: value.unitName ?? "",
|
|
14421
14417
|
peopleId: value.peopleId ?? "",
|
|
@@ -14544,10 +14540,11 @@ function useVehicleRepo() {
|
|
|
14544
14540
|
const baseQuery = {
|
|
14545
14541
|
...status && { status },
|
|
14546
14542
|
...type && { type },
|
|
14547
|
-
...category && { category }
|
|
14548
|
-
...search && { $text: { search } }
|
|
14543
|
+
...category && { category }
|
|
14549
14544
|
};
|
|
14550
14545
|
let query = { ...baseQuery };
|
|
14546
|
+
if (search)
|
|
14547
|
+
query.$text = { $search: search };
|
|
14551
14548
|
const escapeRegex = (input) => input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
14552
14549
|
const buildGroupedPipeline = (matchQuery) => [
|
|
14553
14550
|
{ $match: matchQuery },
|
|
@@ -15107,7 +15104,7 @@ function useVehicleRepo() {
|
|
|
15107
15104
|
throw error;
|
|
15108
15105
|
}
|
|
15109
15106
|
}
|
|
15110
|
-
async function bulkUpsertVehicles(values
|
|
15107
|
+
async function bulkUpsertVehicles(values) {
|
|
15111
15108
|
try {
|
|
15112
15109
|
if (!Array.isArray(values) || values.length === 0) {
|
|
15113
15110
|
return {
|
|
@@ -15116,7 +15113,7 @@ function useVehicleRepo() {
|
|
|
15116
15113
|
upsertedCount: 0
|
|
15117
15114
|
};
|
|
15118
15115
|
}
|
|
15119
|
-
const now =
|
|
15116
|
+
const now = /* @__PURE__ */ new Date();
|
|
15120
15117
|
const operations = values.map((item) => {
|
|
15121
15118
|
const vehicle = MVehicle(item);
|
|
15122
15119
|
const plateNumber = Array.isArray(vehicle.plateNumber) ? vehicle.plateNumber[0] : vehicle.plateNumber;
|
|
@@ -15124,7 +15121,7 @@ function useVehicleRepo() {
|
|
|
15124
15121
|
return {
|
|
15125
15122
|
updateOne: {
|
|
15126
15123
|
filter: {
|
|
15127
|
-
site: vehicle.site,
|
|
15124
|
+
site: new import_mongodb43.ObjectId(vehicle.site),
|
|
15128
15125
|
plateNumber,
|
|
15129
15126
|
$or: [
|
|
15130
15127
|
{ deletedAt: "" },
|
|
@@ -15135,6 +15132,9 @@ function useVehicleRepo() {
|
|
|
15135
15132
|
update: {
|
|
15136
15133
|
$set: {
|
|
15137
15134
|
...rest,
|
|
15135
|
+
site: new import_mongodb43.ObjectId(vehicle.site),
|
|
15136
|
+
unit: vehicle.unit ? new import_mongodb43.ObjectId(vehicle.unit) : null,
|
|
15137
|
+
org: vehicle.org ? new import_mongodb43.ObjectId(vehicle.org) : null,
|
|
15138
15138
|
plateNumber,
|
|
15139
15139
|
updatedAt: now
|
|
15140
15140
|
},
|
|
@@ -15146,10 +15146,7 @@ function useVehicleRepo() {
|
|
|
15146
15146
|
}
|
|
15147
15147
|
};
|
|
15148
15148
|
});
|
|
15149
|
-
const res = await collection.bulkWrite(operations
|
|
15150
|
-
ordered: false,
|
|
15151
|
-
session
|
|
15152
|
-
});
|
|
15149
|
+
const res = await collection.bulkWrite(operations);
|
|
15153
15150
|
return {
|
|
15154
15151
|
matchedCount: res.matchedCount,
|
|
15155
15152
|
modifiedCount: res.modifiedCount,
|
|
@@ -17218,15 +17215,11 @@ function useVehicleService() {
|
|
|
17218
17215
|
}
|
|
17219
17216
|
}
|
|
17220
17217
|
async function bulkUpsertVehicles(values, site, org) {
|
|
17221
|
-
const session = import_node_server_utils75.useAtlas.getClient()?.startSession();
|
|
17222
|
-
if (!session) {
|
|
17223
|
-
throw new Error("Unable to start session for vehicle service.");
|
|
17224
|
-
}
|
|
17225
17218
|
try {
|
|
17226
17219
|
if (!Array.isArray(values) || values.length === 0) {
|
|
17227
17220
|
throw new Error("Vehicle list is required.");
|
|
17228
17221
|
}
|
|
17229
|
-
const now =
|
|
17222
|
+
const now = /* @__PURE__ */ new Date();
|
|
17230
17223
|
const sanitizedValues = (await Promise.all(
|
|
17231
17224
|
values.map(async (item) => {
|
|
17232
17225
|
const plateNumber = Array.isArray(item.plateNumber) ? item.plateNumber[0] : item.plateNumber;
|
|
@@ -17241,7 +17234,7 @@ function useVehicleService() {
|
|
|
17241
17234
|
...item,
|
|
17242
17235
|
org,
|
|
17243
17236
|
site,
|
|
17244
|
-
start:
|
|
17237
|
+
start: now.toISOString(),
|
|
17245
17238
|
unit: unitId,
|
|
17246
17239
|
plateNumber: typeof plateNumber === "string" ? plateNumber.trim().toUpperCase() : plateNumber
|
|
17247
17240
|
};
|
|
@@ -17271,33 +17264,36 @@ function useVehicleService() {
|
|
|
17271
17264
|
if (!siteCameras.length) {
|
|
17272
17265
|
throw new Error("No site cameras found.");
|
|
17273
17266
|
}
|
|
17274
|
-
|
|
17275
|
-
|
|
17276
|
-
|
|
17277
|
-
|
|
17278
|
-
const
|
|
17279
|
-
|
|
17280
|
-
|
|
17281
|
-
|
|
17282
|
-
|
|
17283
|
-
|
|
17284
|
-
|
|
17285
|
-
|
|
17286
|
-
|
|
17287
|
-
|
|
17288
|
-
|
|
17289
|
-
|
|
17290
|
-
|
|
17291
|
-
|
|
17292
|
-
|
|
17293
|
-
|
|
17294
|
-
|
|
17295
|
-
|
|
17296
|
-
|
|
17267
|
+
await Promise.all(
|
|
17268
|
+
sanitizedValues.map(async (vehicleValue) => {
|
|
17269
|
+
const plateNumber = vehicleValue.plateNumber;
|
|
17270
|
+
const _mode = vehicleValue.type === "whitelist" /* WHITELIST */ ? "TrafficRedList" /* TRAFFIC_REDLIST */ : "TrafficBlackList" /* TRAFFIC_BLACKLIST */;
|
|
17271
|
+
const recNos = await Promise.all(
|
|
17272
|
+
siteCameras.map(async (camera) => {
|
|
17273
|
+
const { host, username, password } = camera;
|
|
17274
|
+
const dahuaPayload = {
|
|
17275
|
+
host,
|
|
17276
|
+
username,
|
|
17277
|
+
password,
|
|
17278
|
+
plateNumber,
|
|
17279
|
+
mode: _mode,
|
|
17280
|
+
...vehicleValue.start ? { start: String(vehicleValue.start) } : {},
|
|
17281
|
+
...vehicleValue.end ? { end: String(vehicleValue.end) } : {},
|
|
17282
|
+
...vehicleValue.name ? { owner: vehicleValue.name } : {},
|
|
17283
|
+
...vehicleValue.vehicleModel ? { vehicleType: vehicleValue.vehicleModel } : {},
|
|
17284
|
+
...vehicleValue.vehicleColor ? { vehicleColor: vehicleValue.vehicleColor } : {}
|
|
17285
|
+
};
|
|
17286
|
+
const dahuaResponse = await _bulkInsertPlateNumber(dahuaPayload);
|
|
17287
|
+
const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
|
|
17288
|
+
return responseData.split("=")[1]?.trim();
|
|
17289
|
+
})
|
|
17290
|
+
);
|
|
17291
|
+
vehicleValue.recNo = recNos.find((r) => r) ?? void 0;
|
|
17292
|
+
})
|
|
17293
|
+
);
|
|
17294
|
+
return await _bulkUpsertVehicles(sanitizedValues);
|
|
17297
17295
|
} catch (error) {
|
|
17298
17296
|
throw error;
|
|
17299
|
-
} finally {
|
|
17300
|
-
session.endSession();
|
|
17301
17297
|
}
|
|
17302
17298
|
}
|
|
17303
17299
|
return {
|
|
@@ -19331,6 +19327,7 @@ function useBuildingUnitController() {
|
|
|
19331
19327
|
var import_node_server_utils87 = require("@7365admin1/node-server-utils");
|
|
19332
19328
|
var import_joi46 = __toESM(require("joi"));
|
|
19333
19329
|
var import_exceljs = __toESM(require("exceljs"));
|
|
19330
|
+
var import_csv_parser = __toESM(require("csv-parser"));
|
|
19334
19331
|
var import_fs2 = __toESM(require("fs"));
|
|
19335
19332
|
function useVehicleController() {
|
|
19336
19333
|
const {
|
|
@@ -19375,8 +19372,15 @@ function useVehicleController() {
|
|
|
19375
19372
|
};
|
|
19376
19373
|
}
|
|
19377
19374
|
function parseExpiryDate(value) {
|
|
19378
|
-
if (!value)
|
|
19379
|
-
|
|
19375
|
+
if (!value) {
|
|
19376
|
+
const today = /* @__PURE__ */ new Date();
|
|
19377
|
+
today.setFullYear(today.getFullYear() + 10);
|
|
19378
|
+
return today.toISOString();
|
|
19379
|
+
}
|
|
19380
|
+
const date = new Date(value);
|
|
19381
|
+
if (!isNaN(date.getTime())) {
|
|
19382
|
+
return date.toISOString();
|
|
19383
|
+
}
|
|
19380
19384
|
const [day, monthStr, yearShort] = value.split("-");
|
|
19381
19385
|
const months = {
|
|
19382
19386
|
Jan: 0,
|
|
@@ -19396,19 +19400,17 @@ function useVehicleController() {
|
|
|
19396
19400
|
if (month === void 0)
|
|
19397
19401
|
return void 0;
|
|
19398
19402
|
const year = 2e3 + Number(yearShort);
|
|
19399
|
-
const
|
|
19400
|
-
return isNaN(
|
|
19403
|
+
const fallbackDate = new Date(year, month, Number(day));
|
|
19404
|
+
return isNaN(fallbackDate.getTime()) ? void 0 : fallbackDate.toISOString();
|
|
19401
19405
|
}
|
|
19402
|
-
async function
|
|
19406
|
+
async function uploadSpreadsheetVehicles(req, res, next) {
|
|
19403
19407
|
try {
|
|
19404
19408
|
if (!req.file) {
|
|
19405
|
-
next(new import_node_server_utils87.BadRequestError("
|
|
19406
|
-
return;
|
|
19407
|
-
}
|
|
19408
|
-
if (!req.file.originalname.toLowerCase().endsWith(".xlsx")) {
|
|
19409
|
-
next(new import_node_server_utils87.BadRequestError("Only .xlsx files are allowed."));
|
|
19409
|
+
next(new import_node_server_utils87.BadRequestError("Spreadsheet file is required."));
|
|
19410
19410
|
return;
|
|
19411
19411
|
}
|
|
19412
|
+
const { originalname, path: path4 } = req.file;
|
|
19413
|
+
const lowerName = originalname.toLowerCase();
|
|
19412
19414
|
const rowSchema = import_joi46.default.object({
|
|
19413
19415
|
fullName: import_joi46.default.string().trim().required(),
|
|
19414
19416
|
userType: import_joi46.default.string().trim().required(),
|
|
@@ -19420,7 +19422,11 @@ function useVehicleController() {
|
|
|
19420
19422
|
plateNumber: import_joi46.default.string().trim().uppercase().required(),
|
|
19421
19423
|
vehicleModel: import_joi46.default.string().trim().allow("", null).optional(),
|
|
19422
19424
|
vehicleColor: import_joi46.default.string().trim().allow("", null).optional(),
|
|
19423
|
-
subscriptionExpiry: import_joi46.default.
|
|
19425
|
+
subscriptionExpiry: import_joi46.default.alternatives().try(
|
|
19426
|
+
import_joi46.default.date().iso(),
|
|
19427
|
+
// ISO format
|
|
19428
|
+
import_joi46.default.string().pattern(/^\d{1,2}-[A-Za-z]{3}-\d{2}$/)
|
|
19429
|
+
).allow("", null).optional()
|
|
19424
19430
|
});
|
|
19425
19431
|
const querySchema = import_joi46.default.object({
|
|
19426
19432
|
site: import_joi46.default.string().hex().length(24).required(),
|
|
@@ -19428,10 +19434,7 @@ function useVehicleController() {
|
|
|
19428
19434
|
});
|
|
19429
19435
|
const { error: queryError, value: queryValue } = querySchema.validate(
|
|
19430
19436
|
req.query,
|
|
19431
|
-
{
|
|
19432
|
-
abortEarly: false,
|
|
19433
|
-
convert: true
|
|
19434
|
-
}
|
|
19437
|
+
{ abortEarly: false, convert: true }
|
|
19435
19438
|
);
|
|
19436
19439
|
if (queryError) {
|
|
19437
19440
|
next(
|
|
@@ -19442,30 +19445,43 @@ function useVehicleController() {
|
|
|
19442
19445
|
return;
|
|
19443
19446
|
}
|
|
19444
19447
|
const { site, org } = queryValue;
|
|
19445
|
-
|
|
19446
|
-
|
|
19447
|
-
|
|
19448
|
-
|
|
19449
|
-
|
|
19450
|
-
|
|
19451
|
-
|
|
19452
|
-
|
|
19453
|
-
|
|
19454
|
-
const headers = (headerRow.values || []).slice(1).map((header) => String(header ?? "").trim());
|
|
19455
|
-
worksheet.eachRow((row, rowNumber) => {
|
|
19456
|
-
if (rowNumber === 1)
|
|
19448
|
+
let rows = [];
|
|
19449
|
+
if (lowerName.endsWith(".xlsx") || lowerName.endsWith(".xls")) {
|
|
19450
|
+
const workbook = new import_exceljs.default.Workbook();
|
|
19451
|
+
await workbook.xlsx.readFile(path4);
|
|
19452
|
+
const worksheet = workbook.worksheets[0];
|
|
19453
|
+
if (!worksheet) {
|
|
19454
|
+
next(
|
|
19455
|
+
new import_node_server_utils87.BadRequestError("No worksheet found in uploaded Excel file.")
|
|
19456
|
+
);
|
|
19457
19457
|
return;
|
|
19458
|
-
|
|
19459
|
-
|
|
19460
|
-
|
|
19458
|
+
}
|
|
19459
|
+
const headerRow = worksheet.getRow(1);
|
|
19460
|
+
const headers = (headerRow.values || []).slice(1).map((header) => String(header ?? "").trim());
|
|
19461
|
+
worksheet.eachRow((row, rowNumber) => {
|
|
19462
|
+
if (rowNumber === 1)
|
|
19463
|
+
return;
|
|
19464
|
+
const rowData = {};
|
|
19465
|
+
headers.forEach((header, index) => {
|
|
19466
|
+
rowData[header] = row.getCell(index + 1).value ?? "";
|
|
19467
|
+
});
|
|
19468
|
+
if (Object.values(rowData).some(
|
|
19469
|
+
(v) => v !== "" && v !== null && v !== void 0
|
|
19470
|
+
)) {
|
|
19471
|
+
rows.push(rowData);
|
|
19472
|
+
}
|
|
19461
19473
|
});
|
|
19462
|
-
|
|
19463
|
-
|
|
19474
|
+
} else if (lowerName.endsWith(".csv")) {
|
|
19475
|
+
rows = await new Promise((resolve, reject) => {
|
|
19476
|
+
const parsed = [];
|
|
19477
|
+
import_fs2.default.createReadStream(path4).pipe((0, import_csv_parser.default)()).on("data", (row) => parsed.push(row)).on("end", () => resolve(parsed)).on("error", reject);
|
|
19478
|
+
});
|
|
19479
|
+
} else {
|
|
19480
|
+
next(
|
|
19481
|
+
new import_node_server_utils87.BadRequestError("Only .xlsx, .xls, or .csv files are allowed.")
|
|
19464
19482
|
);
|
|
19465
|
-
|
|
19466
|
-
|
|
19467
|
-
}
|
|
19468
|
-
});
|
|
19483
|
+
return;
|
|
19484
|
+
}
|
|
19469
19485
|
const validRows = [];
|
|
19470
19486
|
const invalidRows = [];
|
|
19471
19487
|
rows.forEach((row, index) => {
|
|
@@ -19479,9 +19495,9 @@ function useVehicleController() {
|
|
|
19479
19495
|
data: row,
|
|
19480
19496
|
errors: error.details.map((d) => d.message)
|
|
19481
19497
|
});
|
|
19482
|
-
|
|
19498
|
+
} else {
|
|
19499
|
+
validRows.push(value);
|
|
19483
19500
|
}
|
|
19484
|
-
validRows.push(value);
|
|
19485
19501
|
});
|
|
19486
19502
|
const vehicles = validRows.map((row) => mapRowToVehicle(row, site, org));
|
|
19487
19503
|
let data = {};
|
|
@@ -19489,15 +19505,15 @@ function useVehicleController() {
|
|
|
19489
19505
|
data = await _bulkUpsertVehicles(vehicles, site, org);
|
|
19490
19506
|
}
|
|
19491
19507
|
res.status(200).json({
|
|
19492
|
-
message: "
|
|
19493
|
-
|
|
19508
|
+
message: "Spreadsheet import completed.",
|
|
19509
|
+
fileName: originalname,
|
|
19494
19510
|
totalRows: rows.length,
|
|
19495
19511
|
validRows: validRows.length,
|
|
19496
19512
|
invalidRows: invalidRows.length,
|
|
19497
19513
|
validationErrors: invalidRows,
|
|
19498
19514
|
data
|
|
19499
19515
|
});
|
|
19500
|
-
import_fs2.default.unlink(
|
|
19516
|
+
import_fs2.default.unlink(path4, () => {
|
|
19501
19517
|
});
|
|
19502
19518
|
} catch (error) {
|
|
19503
19519
|
import_node_server_utils87.logger.log({ level: "error", message: error.message });
|
|
@@ -19839,8 +19855,7 @@ function useVehicleController() {
|
|
|
19839
19855
|
getVehiclesByNRIC,
|
|
19840
19856
|
reactivateVehicleById,
|
|
19841
19857
|
getAllVehiclesByUnitId,
|
|
19842
|
-
|
|
19843
|
-
uploadExcelVehicles
|
|
19858
|
+
uploadSpreadsheetVehicles
|
|
19844
19859
|
};
|
|
19845
19860
|
}
|
|
19846
19861
|
|
|
@@ -22249,11 +22264,6 @@ var KeyRepo = class {
|
|
|
22249
22264
|
} else if (organization) {
|
|
22250
22265
|
defaultQuery = { organization };
|
|
22251
22266
|
}
|
|
22252
|
-
console.log("key-query: ", {
|
|
22253
|
-
...defaultQuery,
|
|
22254
|
-
...searchQuery,
|
|
22255
|
-
...dateFilter
|
|
22256
|
-
});
|
|
22257
22267
|
try {
|
|
22258
22268
|
const result = await this.collection().aggregate([
|
|
22259
22269
|
{
|
|
@@ -22766,14 +22776,28 @@ function useVisitorTransactionService() {
|
|
|
22766
22776
|
const host = camera.host;
|
|
22767
22777
|
const username = camera.username;
|
|
22768
22778
|
const password = camera.password;
|
|
22769
|
-
const
|
|
22779
|
+
const redlist = "TrafficRedList" /* TRAFFIC_REDLIST */;
|
|
22780
|
+
const blacklist = "TrafficBlackList" /* TRAFFIC_BLACKLIST */;
|
|
22770
22781
|
const _plateNumber = value.plateNumber;
|
|
22782
|
+
const dahuaBlocklistQuery = {
|
|
22783
|
+
host,
|
|
22784
|
+
username,
|
|
22785
|
+
password,
|
|
22786
|
+
plateNumber: _plateNumber,
|
|
22787
|
+
mode: blacklist
|
|
22788
|
+
};
|
|
22789
|
+
const isBlocklistedRaw = await _getPlateNumber(dahuaBlocklistQuery);
|
|
22790
|
+
const rawString = isBlocklistedRaw?.toString?.("utf-8") ?? String(isBlocklistedRaw);
|
|
22791
|
+
const foundMatch = rawString.match(/found=(\d+)/);
|
|
22792
|
+
const found = foundMatch ? Number(foundMatch[1]) : 0;
|
|
22793
|
+
if (found === 1)
|
|
22794
|
+
throw new import_node_server_utils102.BadRequestError("This plate number is blocklisted");
|
|
22771
22795
|
const dahuaQuery = {
|
|
22772
22796
|
host,
|
|
22773
22797
|
username,
|
|
22774
22798
|
password,
|
|
22775
22799
|
plateNumber: _plateNumber,
|
|
22776
|
-
mode
|
|
22800
|
+
mode: redlist
|
|
22777
22801
|
};
|
|
22778
22802
|
const raw = await _getPlateNumber(dahuaQuery);
|
|
22779
22803
|
const parsed = parseDahuaFind(raw);
|
|
@@ -22783,7 +22807,7 @@ function useVisitorTransactionService() {
|
|
|
22783
22807
|
username,
|
|
22784
22808
|
password,
|
|
22785
22809
|
plateNumber: _plateNumber,
|
|
22786
|
-
mode,
|
|
22810
|
+
mode: redlist,
|
|
22787
22811
|
start: startDahuaDate,
|
|
22788
22812
|
end: endDahuaDate,
|
|
22789
22813
|
owner: value.name ?? "",
|
|
@@ -22819,7 +22843,7 @@ function useVisitorTransactionService() {
|
|
|
22819
22843
|
password,
|
|
22820
22844
|
plateNumber: _plateNumber,
|
|
22821
22845
|
recno: parsed.recNo,
|
|
22822
|
-
mode,
|
|
22846
|
+
mode: redlist,
|
|
22823
22847
|
start: startDahuaDate,
|
|
22824
22848
|
end: endDahuaDate,
|
|
22825
22849
|
owner: value.name ?? "",
|
|
@@ -24231,7 +24255,6 @@ function usePersonController() {
|
|
|
24231
24255
|
}
|
|
24232
24256
|
async function getPeopleByUnit(req, res, next) {
|
|
24233
24257
|
const PERSON_TYPES3 = Object.values(PersonTypes);
|
|
24234
|
-
console.log(req.query);
|
|
24235
24258
|
try {
|
|
24236
24259
|
const schema2 = import_joi58.default.object({
|
|
24237
24260
|
unit: import_joi58.default.string().required(),
|
|
@@ -32834,7 +32857,11 @@ var formatEntryPassDate = (date) => {
|
|
|
32834
32857
|
const day = String(newDate.getDate()).padStart(2, "0");
|
|
32835
32858
|
return `${year}${month}${day}`;
|
|
32836
32859
|
};
|
|
32837
|
-
async function removeAccessGroup({
|
|
32860
|
+
async function removeAccessGroup({
|
|
32861
|
+
cardNo,
|
|
32862
|
+
staffNo,
|
|
32863
|
+
url
|
|
32864
|
+
}) {
|
|
32838
32865
|
try {
|
|
32839
32866
|
const commands = readTemplate("delete-qr-card", {
|
|
32840
32867
|
staffNo,
|
|
@@ -32855,8 +32882,6 @@ async function removeAccessGroup({ cardNo, staffNo, url }) {
|
|
|
32855
32882
|
});
|
|
32856
32883
|
const response = await sendCommand(commands, url);
|
|
32857
32884
|
const result = await (0, import_xml2js.parseStringPromise)(response, { explicitArray: false });
|
|
32858
|
-
console.log(result.RESULT.$.STCODE);
|
|
32859
|
-
console.log(commands);
|
|
32860
32885
|
if (result && result.RESULT.$.STCODE !== "0") {
|
|
32861
32886
|
throw new Error("Command failed, server error.");
|
|
32862
32887
|
}
|
|
@@ -38569,7 +38594,6 @@ function useStatementOfAccountController() {
|
|
|
38569
38594
|
try {
|
|
38570
38595
|
const _id = req.params.id;
|
|
38571
38596
|
const status = req.params.status;
|
|
38572
|
-
console.log(_id, status);
|
|
38573
38597
|
const result = await _updateStatusById(_id, { status });
|
|
38574
38598
|
res.status(200).json({ message: result });
|
|
38575
38599
|
return;
|
|
@@ -44209,6 +44233,25 @@ function useManpowerMonitoringRepo() {
|
|
|
44209
44233
|
const namespace_collection = "manpower-settings";
|
|
44210
44234
|
const collection = db.collection(namespace_collection);
|
|
44211
44235
|
const serviceProviderCollection = db.collection("site.service-providers");
|
|
44236
|
+
async function createIndexes() {
|
|
44237
|
+
try {
|
|
44238
|
+
await collection.createIndexes([
|
|
44239
|
+
{
|
|
44240
|
+
key: { siteId: 1 }
|
|
44241
|
+
},
|
|
44242
|
+
{ key: { createdAt: 1 } }
|
|
44243
|
+
]);
|
|
44244
|
+
return `Successfully created indexes for ${namespace_collection}.`;
|
|
44245
|
+
} catch (error) {
|
|
44246
|
+
import_node_server_utils197.logger.log({
|
|
44247
|
+
level: "error",
|
|
44248
|
+
message: error.message
|
|
44249
|
+
});
|
|
44250
|
+
throw new import_node_server_utils197.InternalServerError(
|
|
44251
|
+
"Failed to create general indexes on manpower monitoring."
|
|
44252
|
+
);
|
|
44253
|
+
}
|
|
44254
|
+
}
|
|
44212
44255
|
async function createManpowerMonitoringSettings(value, session) {
|
|
44213
44256
|
try {
|
|
44214
44257
|
value = new MManpowerMonitoring(value);
|
|
@@ -44385,7 +44428,8 @@ function useManpowerMonitoringRepo() {
|
|
|
44385
44428
|
getManpowerSettingsBySiteId,
|
|
44386
44429
|
updateManpowerMonitoringSettings,
|
|
44387
44430
|
multipleManpowerMonitoringSettings,
|
|
44388
|
-
getAllSites
|
|
44431
|
+
getAllSites,
|
|
44432
|
+
createIndexes
|
|
44389
44433
|
};
|
|
44390
44434
|
}
|
|
44391
44435
|
|
|
@@ -44448,6 +44492,25 @@ function useManpowerRemarksRepo() {
|
|
|
44448
44492
|
}
|
|
44449
44493
|
const namespace_collection = "manpower-remarks";
|
|
44450
44494
|
const collection = db.collection(namespace_collection);
|
|
44495
|
+
async function createIndexes() {
|
|
44496
|
+
try {
|
|
44497
|
+
await collection.createIndexes([
|
|
44498
|
+
{
|
|
44499
|
+
key: { siteId: 1 }
|
|
44500
|
+
},
|
|
44501
|
+
{ key: { createdAt: 1 } }
|
|
44502
|
+
]);
|
|
44503
|
+
return `Successfully created indexes for ${namespace_collection}.`;
|
|
44504
|
+
} catch (error) {
|
|
44505
|
+
import_node_server_utils198.logger.log({
|
|
44506
|
+
level: "error",
|
|
44507
|
+
message: error.message
|
|
44508
|
+
});
|
|
44509
|
+
throw new import_node_server_utils198.InternalServerError(
|
|
44510
|
+
"Failed to create general indexes on manpower remarks."
|
|
44511
|
+
);
|
|
44512
|
+
}
|
|
44513
|
+
}
|
|
44451
44514
|
async function createManpowerRemarks(value, session) {
|
|
44452
44515
|
try {
|
|
44453
44516
|
value = new MManpowerRemarks(value);
|
|
@@ -44570,7 +44633,8 @@ function useManpowerRemarksRepo() {
|
|
|
44570
44633
|
getManpowerRemarksAllSite,
|
|
44571
44634
|
getManpowerRemarksBySiteId,
|
|
44572
44635
|
updateManpowerRemarks,
|
|
44573
|
-
updateRemarksStatus
|
|
44636
|
+
updateRemarksStatus,
|
|
44637
|
+
createIndexes
|
|
44574
44638
|
};
|
|
44575
44639
|
}
|
|
44576
44640
|
|
|
@@ -44582,7 +44646,6 @@ function useManpowerMonitoringSrvc() {
|
|
|
44582
44646
|
} = useManpowerMonitoringRepo();
|
|
44583
44647
|
const { createManpowerRemarks: _createManpowerRemarks } = useManpowerRemarksRepo();
|
|
44584
44648
|
async function createManpowerMonitoringSettings(payload) {
|
|
44585
|
-
console.log("Im here now at service");
|
|
44586
44649
|
const session = import_node_server_utils199.useAtlas.getClient()?.startSession();
|
|
44587
44650
|
if (!session) {
|
|
44588
44651
|
throw new import_node_server_utils199.BadRequestError("Database session not available.");
|
|
@@ -44598,7 +44661,6 @@ function useManpowerMonitoringSrvc() {
|
|
|
44598
44661
|
const afternoonAlertTime = afternoonCheckInTime ? import_moment_timezone3.default.tz(afternoonCheckInTime, "HH:mm", "Asia/Singapore").add(afternoonAlertFrequencyMins, "minutes").format("HH:mm") : "";
|
|
44599
44662
|
const nightAlertTime = import_moment_timezone3.default.tz(nightCheckInTime, "HH:mm", "Asia/Singapore").add(nightAlertFrequencyMins, "minutes").format("HH:mm");
|
|
44600
44663
|
const nowSGT = (0, import_moment_timezone3.default)().tz("Asia/Singapore");
|
|
44601
|
-
console.log("im done preparing the payload");
|
|
44602
44664
|
try {
|
|
44603
44665
|
const remarksPayload = {
|
|
44604
44666
|
siteId: payload.siteId,
|
|
@@ -44757,7 +44819,6 @@ function useManpowerMonitoringCtrl() {
|
|
|
44757
44819
|
});
|
|
44758
44820
|
const _id = req.params.id;
|
|
44759
44821
|
const payload = { ...req.body };
|
|
44760
|
-
console.log("_id", _id);
|
|
44761
44822
|
const { error } = validation.validate({ _id, ...payload });
|
|
44762
44823
|
if (error) {
|
|
44763
44824
|
next(new import_node_server_utils200.BadRequestError(error.message));
|
|
@@ -44860,6 +44921,25 @@ function useManpowerDesignationRepo() {
|
|
|
44860
44921
|
}
|
|
44861
44922
|
const namespace_collection = "manpower-designations";
|
|
44862
44923
|
const collection = db.collection(namespace_collection);
|
|
44924
|
+
async function createIndexes() {
|
|
44925
|
+
try {
|
|
44926
|
+
await collection.createIndexes([
|
|
44927
|
+
{
|
|
44928
|
+
key: { siteId: 1 }
|
|
44929
|
+
},
|
|
44930
|
+
{ key: { createdAt: 1 } }
|
|
44931
|
+
]);
|
|
44932
|
+
return `Successfully created indexes for ${namespace_collection}.`;
|
|
44933
|
+
} catch (error) {
|
|
44934
|
+
import_node_server_utils201.logger.log({
|
|
44935
|
+
level: "error",
|
|
44936
|
+
message: error.message
|
|
44937
|
+
});
|
|
44938
|
+
throw new import_node_server_utils201.InternalServerError(
|
|
44939
|
+
"Failed to create general indexes on manpower designations."
|
|
44940
|
+
);
|
|
44941
|
+
}
|
|
44942
|
+
}
|
|
44863
44943
|
async function createManpowerDesignations(value) {
|
|
44864
44944
|
try {
|
|
44865
44945
|
value = new MManpowerDesignations(value);
|
|
@@ -44915,7 +44995,8 @@ function useManpowerDesignationRepo() {
|
|
|
44915
44995
|
return {
|
|
44916
44996
|
createManpowerDesignations,
|
|
44917
44997
|
getManpowerDesignationsBySiteId,
|
|
44918
|
-
updateManpowerDesignations
|
|
44998
|
+
updateManpowerDesignations,
|
|
44999
|
+
createIndexes
|
|
44919
45000
|
};
|
|
44920
45001
|
}
|
|
44921
45002
|
|