@tmscloud/tbt-knex 0.0.4 → 0.0.6
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/dist/dao/driver-tracking/driver-tracking.dao.d.ts +8 -0
- package/dist/dao/driver-tracking/driver-tracking.dao.js +25 -1
- package/dist/dao/driver-tracking/driver-tracking.dao.js.map +1 -1
- package/dist/dao/duty/duty.dao.d.ts +86 -0
- package/dist/dao/duty/duty.dao.js +416 -0
- package/dist/dao/duty/duty.dao.js.map +1 -0
- package/dist/dao/duty-item-progress/duty-item-progress.dao.d.ts +59 -0
- package/dist/dao/duty-item-progress/duty-item-progress.dao.js +229 -0
- package/dist/dao/duty-item-progress/duty-item-progress.dao.js.map +1 -0
- package/dist/dao/duty-template/duty-template.dao.d.ts +66 -0
- package/dist/dao/duty-template/duty-template.dao.js +369 -0
- package/dist/dao/duty-template/duty-template.dao.js.map +1 -0
- package/dist/dao/duty-track/duty-track.dao.d.ts +52 -0
- package/dist/dao/duty-track/duty-track.dao.js +259 -0
- package/dist/dao/duty-track/duty-track.dao.js.map +1 -0
- package/dist/dao/event/event.dao.js +9 -3
- package/dist/dao/event/event.dao.js.map +1 -1
- package/dist/dao/route/route.dao.d.ts +4 -0
- package/dist/dao/route/route.dao.js +18 -0
- package/dist/dao/route/route.dao.js.map +1 -1
- package/dist/dao/system-setting/system-setting.dao.d.ts +14 -0
- package/dist/dao/system-setting/system-setting.dao.js +99 -0
- package/dist/dao/system-setting/system-setting.dao.js.map +1 -0
- package/dist/dao/trip-track/trip-track.dao.d.ts +7 -0
- package/dist/dao/trip-track/trip-track.dao.js +63 -4
- package/dist/dao/trip-track/trip-track.dao.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces/driver-tracking/driver-tracking.interfaces.d.ts +5 -2
- package/dist/interfaces/duty/duty.interfaces.d.ts +48 -0
- package/dist/interfaces/duty/duty.interfaces.js +3 -0
- package/dist/interfaces/duty/duty.interfaces.js.map +1 -0
- package/dist/interfaces/duty-item-progress/duty-item-progress.interfaces.d.ts +30 -0
- package/dist/interfaces/duty-item-progress/duty-item-progress.interfaces.js +3 -0
- package/dist/interfaces/duty-item-progress/duty-item-progress.interfaces.js.map +1 -0
- package/dist/interfaces/duty-template/duty-template.interfaces.d.ts +75 -0
- package/dist/interfaces/duty-template/duty-template.interfaces.js +3 -0
- package/dist/interfaces/duty-template/duty-template.interfaces.js.map +1 -0
- package/dist/interfaces/duty-track/duty-track.interfaces.d.ts +39 -0
- package/dist/interfaces/duty-track/duty-track.interfaces.js +3 -0
- package/dist/interfaces/duty-track/duty-track.interfaces.js.map +1 -0
- package/dist/interfaces/route/route.interfaces.d.ts +1 -0
- package/dist/interfaces/system-setting/system-setting.interfaces.d.ts +27 -0
- package/dist/interfaces/system-setting/system-setting.interfaces.js +3 -0
- package/dist/interfaces/system-setting/system-setting.interfaces.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DutyTemplateDAO = void 0;
|
|
16
|
+
const KnexConnection_1 = __importDefault(require("../../KnexConnection"));
|
|
17
|
+
class DutyTemplateDAO {
|
|
18
|
+
get knex() {
|
|
19
|
+
if (!this._knex) {
|
|
20
|
+
this._knex = KnexConnection_1.default.getConnection();
|
|
21
|
+
}
|
|
22
|
+
return this._knex;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Parse JSON fields from database results
|
|
26
|
+
*/
|
|
27
|
+
parseTemplateJson(template) {
|
|
28
|
+
if (template.event && typeof template.event === "string") {
|
|
29
|
+
template.event = JSON.parse(template.event);
|
|
30
|
+
}
|
|
31
|
+
if (template.creator && typeof template.creator === "string") {
|
|
32
|
+
template.creator = JSON.parse(template.creator);
|
|
33
|
+
}
|
|
34
|
+
return template;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Parse JSON fields for items (route join)
|
|
38
|
+
*/
|
|
39
|
+
parseItemJson(item) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
if (item.route && typeof item.route === "string") {
|
|
42
|
+
item.route = JSON.parse(item.route);
|
|
43
|
+
}
|
|
44
|
+
if (((_a = item.route) === null || _a === void 0 ? void 0 : _a.geojson) && typeof item.route.geojson === "string") {
|
|
45
|
+
item.route.geojson = JSON.parse(item.route.geojson);
|
|
46
|
+
}
|
|
47
|
+
if (((_b = item.route) === null || _b === void 0 ? void 0 : _b.custom_instructions) &&
|
|
48
|
+
typeof item.route.custom_instructions === "string") {
|
|
49
|
+
item.route.custom_instructions = JSON.parse(item.route.custom_instructions);
|
|
50
|
+
}
|
|
51
|
+
return item;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Base query with event and creator joins
|
|
55
|
+
*/
|
|
56
|
+
baseQuery() {
|
|
57
|
+
return this.knex("duty_templates as dt")
|
|
58
|
+
.leftJoin("events as e", "dt.event_id", "e.id")
|
|
59
|
+
.leftJoin("users as u", "dt.created_by", "u.id")
|
|
60
|
+
.select("dt.*", this.knex.raw("to_jsonb(e.*) as event"), this.knex.raw(`CASE WHEN u.id IS NOT NULL THEN jsonb_build_object(
|
|
61
|
+
'id', u.id,
|
|
62
|
+
'uuid', u.uuid,
|
|
63
|
+
'email', u.email,
|
|
64
|
+
'username', u.username,
|
|
65
|
+
'first_name', u.first_name,
|
|
66
|
+
'last_name', u.last_name,
|
|
67
|
+
'role_id', u.role_id,
|
|
68
|
+
'is_active', u.is_active
|
|
69
|
+
) ELSE NULL END as creator`));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get all duty templates with pagination
|
|
73
|
+
*/
|
|
74
|
+
getAll() {
|
|
75
|
+
return __awaiter(this, arguments, void 0, function* (page = 1, limit = 10) {
|
|
76
|
+
const offset = (page - 1) * limit;
|
|
77
|
+
const rawData = yield this.baseQuery()
|
|
78
|
+
.where("dt.is_active", true)
|
|
79
|
+
.limit(limit)
|
|
80
|
+
.offset(offset)
|
|
81
|
+
.orderBy("dt.created_at", "desc");
|
|
82
|
+
const data = rawData.map((t) => this.parseTemplateJson(t));
|
|
83
|
+
const totalCountResult = yield this.knex("duty_templates")
|
|
84
|
+
.where("is_active", true)
|
|
85
|
+
.count("* as count")
|
|
86
|
+
.first();
|
|
87
|
+
const totalCount = Number((totalCountResult === null || totalCountResult === void 0 ? void 0 : totalCountResult.count) || 0);
|
|
88
|
+
const count = data.length;
|
|
89
|
+
const totalPages = Math.ceil(totalCount / limit);
|
|
90
|
+
return { success: true, data, page, limit, count, totalCount, totalPages };
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get all duty templates by event ID
|
|
95
|
+
*/
|
|
96
|
+
getAllByEventId(eventId_1) {
|
|
97
|
+
return __awaiter(this, arguments, void 0, function* (eventId, page = 1, limit = 10) {
|
|
98
|
+
const offset = (page - 1) * limit;
|
|
99
|
+
const rawData = yield this.baseQuery()
|
|
100
|
+
.where("dt.event_id", eventId)
|
|
101
|
+
.where("dt.is_active", true)
|
|
102
|
+
.limit(limit)
|
|
103
|
+
.offset(offset)
|
|
104
|
+
.orderBy("dt.created_at", "desc");
|
|
105
|
+
const data = rawData.map((t) => this.parseTemplateJson(t));
|
|
106
|
+
const totalCountResult = yield this.knex("duty_templates")
|
|
107
|
+
.where("event_id", eventId)
|
|
108
|
+
.where("is_active", true)
|
|
109
|
+
.count("* as count")
|
|
110
|
+
.first();
|
|
111
|
+
const totalCount = Number((totalCountResult === null || totalCountResult === void 0 ? void 0 : totalCountResult.count) || 0);
|
|
112
|
+
const count = data.length;
|
|
113
|
+
const totalPages = Math.ceil(totalCount / limit);
|
|
114
|
+
return { success: true, data, page, limit, count, totalCount, totalPages };
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get all duty templates by event UUID
|
|
119
|
+
*/
|
|
120
|
+
getAllByEventUuid(eventUuid_1) {
|
|
121
|
+
return __awaiter(this, arguments, void 0, function* (eventUuid, page = 1, limit = 10) {
|
|
122
|
+
const offset = (page - 1) * limit;
|
|
123
|
+
const rawData = yield this.baseQuery()
|
|
124
|
+
.where("e.uuid", eventUuid)
|
|
125
|
+
.where("dt.is_active", true)
|
|
126
|
+
.limit(limit)
|
|
127
|
+
.offset(offset)
|
|
128
|
+
.orderBy("dt.created_at", "desc");
|
|
129
|
+
const data = rawData.map((t) => this.parseTemplateJson(t));
|
|
130
|
+
const totalCountResult = yield this.knex("duty_templates as dt")
|
|
131
|
+
.leftJoin("events as e", "dt.event_id", "e.id")
|
|
132
|
+
.where("e.uuid", eventUuid)
|
|
133
|
+
.where("dt.is_active", true)
|
|
134
|
+
.count("* as count")
|
|
135
|
+
.first();
|
|
136
|
+
const totalCount = Number((totalCountResult === null || totalCountResult === void 0 ? void 0 : totalCountResult.count) || 0);
|
|
137
|
+
const count = data.length;
|
|
138
|
+
const totalPages = Math.ceil(totalCount / limit);
|
|
139
|
+
return { success: true, data, page, limit, count, totalCount, totalPages };
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Get duty template by ID
|
|
144
|
+
*/
|
|
145
|
+
getById(id) {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
const result = yield this.baseQuery()
|
|
148
|
+
.where("dt.id", id)
|
|
149
|
+
.where("dt.is_active", true)
|
|
150
|
+
.first();
|
|
151
|
+
return result ? this.parseTemplateJson(result) : null;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get duty template by UUID
|
|
156
|
+
*/
|
|
157
|
+
getByUuid(uuid) {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
const result = yield this.baseQuery()
|
|
160
|
+
.where("dt.uuid", uuid)
|
|
161
|
+
.where("dt.is_active", true)
|
|
162
|
+
.first();
|
|
163
|
+
return result ? this.parseTemplateJson(result) : null;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get duty template by UUID with full details (segments + items)
|
|
168
|
+
*/
|
|
169
|
+
getByUuidWithDetails(uuid) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
const template = yield this.getByUuid(uuid);
|
|
172
|
+
if (!template || !template.id)
|
|
173
|
+
return null;
|
|
174
|
+
const segments = yield this.getSegmentsByTemplateId(template.id);
|
|
175
|
+
return Object.assign(Object.assign({}, template), { segments });
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Get segments for a template, each with their items (single batch query for items)
|
|
180
|
+
*/
|
|
181
|
+
getSegmentsByTemplateId(templateId) {
|
|
182
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
183
|
+
const segments = yield this.knex("duty_template_segments")
|
|
184
|
+
.select("*")
|
|
185
|
+
.where("duty_template_id", templateId)
|
|
186
|
+
.orderBy("segment_order", "asc");
|
|
187
|
+
if (segments.length === 0)
|
|
188
|
+
return [];
|
|
189
|
+
// Fetch ALL items for all segments in one query
|
|
190
|
+
const segmentIds = segments.map((s) => s.id);
|
|
191
|
+
const rawItems = yield this.knex("duty_template_items as dti")
|
|
192
|
+
.leftJoin("routes as r", "dti.route_id", "r.id")
|
|
193
|
+
.select("dti.*", this.knex.raw("to_jsonb(r.*) as route"))
|
|
194
|
+
.whereIn("dti.segment_id", segmentIds)
|
|
195
|
+
.orderBy("dti.item_order", "asc");
|
|
196
|
+
// Group items by segment_id
|
|
197
|
+
const itemsBySegment = new Map();
|
|
198
|
+
for (const item of rawItems) {
|
|
199
|
+
const parsed = this.parseItemJson(item);
|
|
200
|
+
const segId = item.segment_id;
|
|
201
|
+
if (!itemsBySegment.has(segId)) {
|
|
202
|
+
itemsBySegment.set(segId, []);
|
|
203
|
+
}
|
|
204
|
+
itemsBySegment.get(segId).push(parsed);
|
|
205
|
+
}
|
|
206
|
+
for (const segment of segments) {
|
|
207
|
+
segment.items = itemsBySegment.get(segment.id) || [];
|
|
208
|
+
}
|
|
209
|
+
return segments;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Get items for a segment, with route join for route-type items
|
|
214
|
+
*/
|
|
215
|
+
getItemsBySegmentId(segmentId) {
|
|
216
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
const rawItems = yield this.knex("duty_template_items as dti")
|
|
218
|
+
.leftJoin("routes as r", "dti.route_id", "r.id")
|
|
219
|
+
.select("dti.*", this.knex.raw("to_jsonb(r.*) as route"))
|
|
220
|
+
.where("dti.segment_id", segmentId)
|
|
221
|
+
.orderBy("dti.item_order", "asc");
|
|
222
|
+
return rawItems.map((item) => this.parseItemJson(item));
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Create a duty template with optional segments and items (transactional)
|
|
227
|
+
*/
|
|
228
|
+
create(data) {
|
|
229
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
const inserted = yield this.knex.transaction((trx) => __awaiter(this, void 0, void 0, function* () {
|
|
231
|
+
var _a;
|
|
232
|
+
// Create the template
|
|
233
|
+
const [template] = yield trx("duty_templates")
|
|
234
|
+
.insert({
|
|
235
|
+
event_id: data.event_id,
|
|
236
|
+
name: data.name,
|
|
237
|
+
description: data.description || null,
|
|
238
|
+
created_by: data.created_by || null,
|
|
239
|
+
})
|
|
240
|
+
.returning("*");
|
|
241
|
+
// Create segments and items if provided
|
|
242
|
+
if (data.segments && data.segments.length > 0) {
|
|
243
|
+
for (const segmentData of data.segments) {
|
|
244
|
+
const [segment] = yield trx("duty_template_segments")
|
|
245
|
+
.insert({
|
|
246
|
+
duty_template_id: template.id,
|
|
247
|
+
name: (_a = segmentData.name) !== null && _a !== void 0 ? _a : null,
|
|
248
|
+
segment_order: segmentData.segment_order,
|
|
249
|
+
start_time: segmentData.start_time,
|
|
250
|
+
end_time: segmentData.end_time,
|
|
251
|
+
})
|
|
252
|
+
.returning("*");
|
|
253
|
+
if (segmentData.items && segmentData.items.length > 0) {
|
|
254
|
+
const itemRows = segmentData.items.map((item) => {
|
|
255
|
+
var _a, _b, _c, _d, _e;
|
|
256
|
+
return ({
|
|
257
|
+
segment_id: segment.id,
|
|
258
|
+
item_order: item.item_order,
|
|
259
|
+
item_type: item.item_type,
|
|
260
|
+
route_id: (_a = item.route_id) !== null && _a !== void 0 ? _a : null,
|
|
261
|
+
is_repeating: (_b = item.is_repeating) !== null && _b !== void 0 ? _b : false,
|
|
262
|
+
stop_name: (_c = item.stop_name) !== null && _c !== void 0 ? _c : null,
|
|
263
|
+
stop_latitude: (_d = item.stop_latitude) !== null && _d !== void 0 ? _d : null,
|
|
264
|
+
stop_longitude: (_e = item.stop_longitude) !== null && _e !== void 0 ? _e : null,
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
yield trx("duty_template_items").insert(itemRows);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return template;
|
|
272
|
+
}));
|
|
273
|
+
// Re-fetch with joins after transaction is committed
|
|
274
|
+
return this.getById(inserted.id);
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Update a duty template by ID (metadata only, not segments)
|
|
279
|
+
*/
|
|
280
|
+
update(id, data) {
|
|
281
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
282
|
+
const updateData = {};
|
|
283
|
+
if (data.name !== undefined)
|
|
284
|
+
updateData.name = data.name;
|
|
285
|
+
if (data.description !== undefined)
|
|
286
|
+
updateData.description = data.description;
|
|
287
|
+
if (data.is_active !== undefined)
|
|
288
|
+
updateData.is_active = data.is_active;
|
|
289
|
+
updateData.updated_at = new Date();
|
|
290
|
+
const [result] = yield this.knex("duty_templates")
|
|
291
|
+
.where("id", id)
|
|
292
|
+
.update(updateData)
|
|
293
|
+
.returning("*");
|
|
294
|
+
return result ? this.getById(result.id) : null;
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Replace all segments and items for a template (transactional)
|
|
299
|
+
*/
|
|
300
|
+
replaceSegments(templateId, segments) {
|
|
301
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
302
|
+
yield this.knex.transaction((trx) => __awaiter(this, void 0, void 0, function* () {
|
|
303
|
+
var _a;
|
|
304
|
+
// Get existing segment IDs
|
|
305
|
+
const existingSegments = yield trx("duty_template_segments")
|
|
306
|
+
.select("id")
|
|
307
|
+
.where("duty_template_id", templateId);
|
|
308
|
+
const segmentIds = existingSegments.map((s) => s.id);
|
|
309
|
+
// Delete existing items and segments (cascade would handle items, but be explicit)
|
|
310
|
+
if (segmentIds.length > 0) {
|
|
311
|
+
yield trx("duty_template_items")
|
|
312
|
+
.whereIn("segment_id", segmentIds)
|
|
313
|
+
.delete();
|
|
314
|
+
}
|
|
315
|
+
yield trx("duty_template_segments")
|
|
316
|
+
.where("duty_template_id", templateId)
|
|
317
|
+
.delete();
|
|
318
|
+
// Create new segments and items
|
|
319
|
+
for (const segmentData of segments) {
|
|
320
|
+
const [segment] = yield trx("duty_template_segments")
|
|
321
|
+
.insert({
|
|
322
|
+
duty_template_id: templateId,
|
|
323
|
+
name: (_a = segmentData.name) !== null && _a !== void 0 ? _a : null,
|
|
324
|
+
segment_order: segmentData.segment_order,
|
|
325
|
+
start_time: segmentData.start_time,
|
|
326
|
+
end_time: segmentData.end_time,
|
|
327
|
+
})
|
|
328
|
+
.returning("*");
|
|
329
|
+
if (segmentData.items && segmentData.items.length > 0) {
|
|
330
|
+
const itemRows = segmentData.items.map((item) => {
|
|
331
|
+
var _a, _b, _c, _d, _e;
|
|
332
|
+
return ({
|
|
333
|
+
segment_id: segment.id,
|
|
334
|
+
item_order: item.item_order,
|
|
335
|
+
item_type: item.item_type,
|
|
336
|
+
route_id: (_a = item.route_id) !== null && _a !== void 0 ? _a : null,
|
|
337
|
+
is_repeating: (_b = item.is_repeating) !== null && _b !== void 0 ? _b : false,
|
|
338
|
+
stop_name: (_c = item.stop_name) !== null && _c !== void 0 ? _c : null,
|
|
339
|
+
stop_latitude: (_d = item.stop_latitude) !== null && _d !== void 0 ? _d : null,
|
|
340
|
+
stop_longitude: (_e = item.stop_longitude) !== null && _e !== void 0 ? _e : null,
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
yield trx("duty_template_items").insert(itemRows);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
// Update template timestamp
|
|
347
|
+
yield trx("duty_templates")
|
|
348
|
+
.where("id", templateId)
|
|
349
|
+
.update({ updated_at: new Date() });
|
|
350
|
+
}));
|
|
351
|
+
// Re-fetch after transaction is committed
|
|
352
|
+
return this.getSegmentsByTemplateId(templateId);
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Delete a duty template by ID (soft delete)
|
|
357
|
+
*/
|
|
358
|
+
delete(id) {
|
|
359
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
360
|
+
const result = yield this.knex("duty_templates").where("id", id).update({
|
|
361
|
+
is_active: false,
|
|
362
|
+
updated_at: new Date(),
|
|
363
|
+
});
|
|
364
|
+
return result > 0;
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
exports.DutyTemplateDAO = DutyTemplateDAO;
|
|
369
|
+
//# sourceMappingURL=duty-template.dao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duty-template.dao.js","sourceRoot":"","sources":["../../../src/dao/duty-template/duty-template.dao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,0EAA+C;AAa/C,MAAa,eAAe;IAG1B,IAAY,IAAI;QACd,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,KAAK,GAAG,wBAAW,CAAC,aAAa,EAAE,CAAC;QAC3C,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACK,iBAAiB,CAAC,QAAa;QACrC,IAAI,QAAQ,CAAC,KAAK,IAAI,OAAO,QAAQ,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACzD,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,QAAQ,CAAC,OAAO,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC7D,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAClD,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,IAAS;;QAC7B,IAAI,IAAI,CAAC,KAAK,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACjD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QACD,IAAI,CAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,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import { ITrackPoint, ITrackStatistics } from "../../interfaces/trip-track/trip-track.interfaces";
|
|
3
|
+
export declare class DutyTrackDAO {
|
|
4
|
+
private _knex?;
|
|
5
|
+
private get knex();
|
|
6
|
+
/**
|
|
7
|
+
* Create consolidated duty track
|
|
8
|
+
*/
|
|
9
|
+
create(data: IDutyTrackCreate): Promise<IDutyTrack>;
|
|
10
|
+
/**
|
|
11
|
+
* Get track by duty ID
|
|
12
|
+
*/
|
|
13
|
+
getByDutyId(dutyId: number): Promise<IDutyTrack | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Get track by UUID
|
|
16
|
+
*/
|
|
17
|
+
getByUuid(uuid: string): Promise<IDutyTrack | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a duty already has a consolidated track
|
|
20
|
+
*/
|
|
21
|
+
existsForDuty(dutyId: number): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Delete track by duty ID
|
|
24
|
+
*/
|
|
25
|
+
deleteByDutyId(dutyId: number): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Consolidate track from granular driver_tracking points.
|
|
28
|
+
* Returns null if zero points provided.
|
|
29
|
+
*/
|
|
30
|
+
consolidate(dutyId: number, points: ITrackPoint[]): Promise<IDutyTrack | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Compute statistics from track points (single-pass)
|
|
33
|
+
*/
|
|
34
|
+
computeStatistics(points: ITrackPoint[]): ITrackStatistics;
|
|
35
|
+
/**
|
|
36
|
+
* Calculate distance between two coordinates using Haversine formula.
|
|
37
|
+
* Returns distance in kilometers.
|
|
38
|
+
*/
|
|
39
|
+
private calculateDistance;
|
|
40
|
+
private toRad;
|
|
41
|
+
/**
|
|
42
|
+
* Consolidate a duty's tracking data in a single transaction:
|
|
43
|
+
* reads raw points, computes stats, inserts track record,
|
|
44
|
+
* deletes granular points, and marks the duty as consolidated.
|
|
45
|
+
* Returns null if there were no tracking points.
|
|
46
|
+
*/
|
|
47
|
+
consolidateFromTracking(dutyId: number): Promise<IDutyTrack | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Parse JSONB fields from database result
|
|
50
|
+
*/
|
|
51
|
+
private parseJson;
|
|
52
|
+
}
|