@olenbetong/synergi-react 5.4.0 → 5.5.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/dist/styles/styles.css +1 -1
- package/dist/styles/styles.css.map +1 -1
- package/es/charts/CallOffDeliveries/TicketScanDialog.d.ts +7 -0
- package/es/charts/CallOffDeliveries/TicketScanDialog.js +47 -0
- package/es/charts/CallOffDeliveries/chartOptions.d.ts +8 -0
- package/es/charts/CallOffDeliveries/chartOptions.js +138 -0
- package/es/charts/CallOffDeliveries/data.d.ts +35 -0
- package/es/charts/CallOffDeliveries/data.js +30 -0
- package/es/charts/CallOffDeliveries/index.css +1 -0
- package/es/charts/CallOffDeliveries/index.d.ts +24 -0
- package/es/charts/CallOffDeliveries/index.js +115 -0
- package/es/charts/CallOffDeliveries/model.d.ts +37 -0
- package/es/charts/CallOffDeliveries/model.js +59 -0
- package/es/charts/ProductionPlan/PlanValueDialog.d.ts +14 -0
- package/es/charts/ProductionPlan/PlanValueDialog.js +47 -0
- package/es/charts/ProductionPlan/chartOptions.d.ts +20 -0
- package/es/charts/ProductionPlan/chartOptions.js +353 -0
- package/es/charts/ProductionPlan/data.d.ts +105 -0
- package/es/charts/ProductionPlan/data.js +61 -0
- package/es/charts/ProductionPlan/index.css +1 -0
- package/es/charts/ProductionPlan/index.d.ts +31 -0
- package/es/charts/ProductionPlan/index.js +203 -0
- package/es/charts/ProductionPlan/model.d.ts +29 -0
- package/es/charts/ProductionPlan/model.js +65 -0
- package/es/charts/Pumping/chartOptions.d.ts +12 -0
- package/es/charts/Pumping/chartOptions.js +197 -0
- package/es/charts/Pumping/data.d.ts +65 -0
- package/es/charts/Pumping/data.js +20 -0
- package/es/charts/Pumping/index.css +1 -0
- package/es/charts/Pumping/index.d.ts +27 -0
- package/es/charts/Pumping/index.js +124 -0
- package/es/charts/Pumping/model.d.ts +34 -0
- package/es/charts/Pumping/model.js +88 -0
- package/es/charts/UnboundPreview/chartOptions.d.ts +3 -0
- package/es/charts/UnboundPreview/chartOptions.js +126 -0
- package/es/charts/UnboundPreview/index.css +1 -0
- package/es/charts/UnboundPreview/index.d.ts +20 -0
- package/es/charts/UnboundPreview/index.js +55 -0
- package/es/charts/UnboundPreview/model.d.ts +49 -0
- package/es/charts/UnboundPreview/model.js +67 -0
- package/es/charts/VehicleDeliveries/chartOptions.d.ts +13 -0
- package/es/charts/VehicleDeliveries/chartOptions.js +270 -0
- package/es/charts/VehicleDeliveries/data.d.ts +71 -0
- package/es/charts/VehicleDeliveries/data.js +20 -0
- package/es/charts/VehicleDeliveries/deliveryXRange.d.ts +4 -0
- package/es/charts/VehicleDeliveries/deliveryXRange.js +62 -0
- package/es/charts/VehicleDeliveries/index.css +1 -0
- package/es/charts/VehicleDeliveries/index.d.ts +24 -0
- package/es/charts/VehicleDeliveries/index.js +129 -0
- package/es/charts/VehicleDeliveries/model.d.ts +24 -0
- package/es/charts/VehicleDeliveries/model.js +106 -0
- package/es/charts/format.d.ts +12 -0
- package/es/charts/format.js +34 -0
- package/es/charts/index.d.ts +5 -0
- package/es/charts/index.js +5 -0
- package/es/charts/storage.d.ts +5 -0
- package/es/charts/storage.js +35 -0
- package/es/components/ColorCard/index.css +8 -8
- package/es/index.css +1 -1
- package/es/vehicles/VehicleInfoDialog/OutOfServiceForm.d.ts +4 -0
- package/es/vehicles/VehicleInfoDialog/OutOfServiceForm.js +51 -0
- package/es/vehicles/VehicleInfoDialog/data/dsDeliveryTickets.d.ts +99 -0
- package/es/vehicles/VehicleInfoDialog/data/dsDeliveryTickets.js +499 -0
- package/es/vehicles/VehicleInfoDialog/data/dsDriverStatus.d.ts +13 -0
- package/es/vehicles/VehicleInfoDialog/data/dsDriverStatus.js +69 -0
- package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfo.d.ts +33 -0
- package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfo.js +164 -0
- package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfoLog.d.ts +15 -0
- package/es/vehicles/VehicleInfoDialog/data/dsVehicleInfoLog.js +80 -0
- package/es/vehicles/VehicleInfoDialog/formatting.d.ts +13 -0
- package/es/vehicles/VehicleInfoDialog/formatting.js +48 -0
- package/es/vehicles/VehicleInfoDialog/index.css +1 -0
- package/es/vehicles/VehicleInfoDialog/index.d.ts +11 -0
- package/es/vehicles/VehicleInfoDialog/index.js +46 -0
- package/es/vehicles/VehicleInfoDialog/tabs.d.ts +6 -0
- package/es/vehicles/VehicleInfoDialog/tabs.js +85 -0
- package/es/vehicles/index.d.ts +1 -0
- package/es/vehicles/index.js +1 -0
- package/package.json +17 -8
- package/src/charts/CallOffDeliveries/TicketScanDialog.tsx +79 -0
- package/src/charts/CallOffDeliveries/chartOptions.ts +160 -0
- package/src/charts/CallOffDeliveries/data.ts +67 -0
- package/src/charts/CallOffDeliveries/index.scss +51 -0
- package/src/charts/CallOffDeliveries/index.tsx +217 -0
- package/src/charts/CallOffDeliveries/model.test.ts +90 -0
- package/src/charts/CallOffDeliveries/model.ts +87 -0
- package/src/charts/ProductionPlan/PlanValueDialog.tsx +107 -0
- package/src/charts/ProductionPlan/chartOptions.ts +406 -0
- package/src/charts/ProductionPlan/data.ts +170 -0
- package/src/charts/ProductionPlan/index.scss +148 -0
- package/src/charts/ProductionPlan/index.tsx +432 -0
- package/src/charts/ProductionPlan/model.test.ts +132 -0
- package/src/charts/ProductionPlan/model.ts +102 -0
- package/src/charts/Pumping/chartOptions.ts +224 -0
- package/src/charts/Pumping/data.ts +91 -0
- package/src/charts/Pumping/index.scss +42 -0
- package/src/charts/Pumping/index.tsx +222 -0
- package/src/charts/Pumping/model.test.ts +122 -0
- package/src/charts/Pumping/model.ts +104 -0
- package/src/charts/UnboundPreview/chartOptions.ts +137 -0
- package/src/charts/UnboundPreview/index.scss +17 -0
- package/src/charts/UnboundPreview/index.tsx +100 -0
- package/src/charts/UnboundPreview/model.test.ts +129 -0
- package/src/charts/UnboundPreview/model.ts +110 -0
- package/src/charts/VehicleDeliveries/chartOptions.ts +311 -0
- package/src/charts/VehicleDeliveries/data.ts +98 -0
- package/src/charts/VehicleDeliveries/deliveryXRange.ts +80 -0
- package/src/charts/VehicleDeliveries/index.scss +43 -0
- package/src/charts/VehicleDeliveries/index.tsx +262 -0
- package/src/charts/VehicleDeliveries/model.test.ts +117 -0
- package/src/charts/VehicleDeliveries/model.ts +139 -0
- package/src/charts/format.ts +38 -0
- package/src/charts/index.ts +20 -0
- package/src/charts/storage.ts +36 -0
- package/src/components/ColorCard/index.css +8 -8
- package/src/vehicles/VehicleInfoDialog/OutOfServiceForm.tsx +127 -0
- package/src/vehicles/VehicleInfoDialog/data/dsDeliveryTickets.ts +600 -0
- package/src/vehicles/VehicleInfoDialog/data/dsDriverStatus.ts +84 -0
- package/src/vehicles/VehicleInfoDialog/data/dsVehicleInfo.ts +198 -0
- package/src/vehicles/VehicleInfoDialog/data/dsVehicleInfoLog.ts +97 -0
- package/src/vehicles/VehicleInfoDialog/formatting.test.ts +57 -0
- package/src/vehicles/VehicleInfoDialog/formatting.ts +58 -0
- package/src/vehicles/VehicleInfoDialog/index.scss +131 -0
- package/src/vehicles/VehicleInfoDialog/index.tsx +106 -0
- package/src/vehicles/VehicleInfoDialog/tabs.tsx +188 -0
- package/src/vehicles/index.ts +1 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/** A load in the plan being edited, before it is saved. */
|
|
2
|
+
export type PlannedDelivery = {
|
|
3
|
+
VehicleID: number;
|
|
4
|
+
StartTime: Date;
|
|
5
|
+
/** Minutes from the start until the vehicle has loaded. */
|
|
6
|
+
LoadTime: number;
|
|
7
|
+
DriveToSiteTime: number;
|
|
8
|
+
WaitTime: number;
|
|
9
|
+
UnloadTime: number;
|
|
10
|
+
DriveFromSiteTime: number;
|
|
11
|
+
EndTime: Date;
|
|
12
|
+
DriverID: string | null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** A load from another call-off that already occupies one of the vehicles. */
|
|
16
|
+
export type OtherDelivery = {
|
|
17
|
+
VehicleID: number;
|
|
18
|
+
StartTime: Date;
|
|
19
|
+
EndTime: Date;
|
|
20
|
+
DriverID: string | null;
|
|
21
|
+
CallOffID: number;
|
|
22
|
+
CustomerAdr1: string | null;
|
|
23
|
+
BuildSiteAdr1: string | null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const MINUTE = 60000;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Times are wall clock carried as UTC. A value without a zone is read as UTC as well, so it is
|
|
30
|
+
* never shifted to the time zone of the browser.
|
|
31
|
+
*/
|
|
32
|
+
export function parseTime(value: string) {
|
|
33
|
+
let hasZone = /(Z|[+-]\d\d:?\d\d)$/i.test(value);
|
|
34
|
+
return new Date(hasZone || !value.includes("T") ? value : `${value}Z`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function text(value: unknown) {
|
|
38
|
+
return typeof value === "string" && value !== "" ? value : null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function parseArray(json: string | null | undefined): Record<string, any>[] {
|
|
42
|
+
if (!json) return [];
|
|
43
|
+
let parsed = JSON.parse(json);
|
|
44
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Reads the plan as the planning dialog sends it. */
|
|
48
|
+
export function parsePlannedDeliveries(json: string | null | undefined): PlannedDelivery[] {
|
|
49
|
+
return parseArray(json).map((row) => ({
|
|
50
|
+
VehicleID: Number(row.VehicleID),
|
|
51
|
+
StartTime: parseTime(row.StartTime),
|
|
52
|
+
LoadTime: Number(row.LoadTime) || 0,
|
|
53
|
+
DriveToSiteTime: Number(row.DriveToSiteTime) || 0,
|
|
54
|
+
WaitTime: Number(row.WaitTime) || 0,
|
|
55
|
+
UnloadTime: Number(row.UnloadTime) || 0,
|
|
56
|
+
DriveFromSiteTime: Number(row.DriveFromSiteTime) || 0,
|
|
57
|
+
EndTime: parseTime(row.EndTime),
|
|
58
|
+
DriverID: text(row.DriverID),
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Reads the other call-offs' loads as the planning dialog sends them. */
|
|
63
|
+
export function parseOtherDeliveries(json: string | null | undefined): OtherDelivery[] {
|
|
64
|
+
return parseArray(json).map((row) => ({
|
|
65
|
+
VehicleID: Number(row.VehicleID),
|
|
66
|
+
StartTime: parseTime(row.StartTime),
|
|
67
|
+
EndTime: parseTime(row.EndTime),
|
|
68
|
+
DriverID: text(row.DriverID),
|
|
69
|
+
CallOffID: Number(row.CallOffID),
|
|
70
|
+
CustomerAdr1: text(row.CustomerAdr1),
|
|
71
|
+
BuildSiteAdr1: text(row.BuildSiteAdr1),
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The vehicles in the plan, in the order they first appear. */
|
|
76
|
+
export function getVehicles(deliveries: PlannedDelivery[]) {
|
|
77
|
+
return [...new Set(deliveries.map((delivery) => delivery.VehicleID))];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type PreviewData = {
|
|
81
|
+
vehicles: number[];
|
|
82
|
+
planned: PlannedDelivery[];
|
|
83
|
+
/** Only the loads on vehicles in the plan: the chart has no row for the others. */
|
|
84
|
+
other: OtherDelivery[];
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export function getPreviewData(planned: PlannedDelivery[], other: OtherDelivery[]): PreviewData {
|
|
88
|
+
let vehicles = getVehicles(planned);
|
|
89
|
+
let inPlan = new Set(vehicles);
|
|
90
|
+
|
|
91
|
+
return { vehicles, planned, other: other.filter((delivery) => inPlan.has(delivery.VehicleID)) };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Arrival on site, start and end of unloading, for the status strip of a planned load. */
|
|
95
|
+
export function getStatusTimes(delivery: PlannedDelivery) {
|
|
96
|
+
let start = delivery.StartTime.getTime();
|
|
97
|
+
let arrival = start + (delivery.LoadTime + delivery.DriveToSiteTime) * MINUTE;
|
|
98
|
+
let unloadStart = arrival + delivery.WaitTime * MINUTE;
|
|
99
|
+
let unloadComplete = unloadStart + delivery.UnloadTime * MINUTE;
|
|
100
|
+
|
|
101
|
+
return { m1: arrival, m2: unloadStart, m3: unloadComplete };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function getChartHeight(vehicleCount: number) {
|
|
105
|
+
return vehicleCount * 30 + 65;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function cropCaption(caption: string, maxLength: number) {
|
|
109
|
+
return caption.length > maxLength ? `${caption.slice(0, Math.max(0, maxLength))}...` : caption;
|
|
110
|
+
}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import Highcharts from "highcharts";
|
|
2
|
+
|
|
3
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
4
|
+
import type { DeliveryRecord } from "./data.js";
|
|
5
|
+
import { type ChartData, cropText, getChartHeight, getVehicleFeature, getVehicleLabel } from "./model.js";
|
|
6
|
+
import { formatTime, escapeHtml, barColor, PLANT_COLORS } from "../format.js";
|
|
7
|
+
|
|
8
|
+
const HOUR = 3600000;
|
|
9
|
+
|
|
10
|
+
export type MoveDelivery = (delivery: DeliveryRecord, prodTime: Date, vehicleId: number) => void;
|
|
11
|
+
|
|
12
|
+
export type ChartSettings = {
|
|
13
|
+
date: Date;
|
|
14
|
+
minOffset: number;
|
|
15
|
+
maxOffset: number;
|
|
16
|
+
thickBars: boolean;
|
|
17
|
+
readOnly: boolean;
|
|
18
|
+
onMove: MoveDelivery;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function plantColor(colorIndex: Map<number, number>, plantId: number) {
|
|
22
|
+
return PLANT_COLORS[(colorIndex.get(plantId) ?? 0) % PLANT_COLORS.length];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function vehicleLabelHtml(data: ChartData, vehicleId: number) {
|
|
26
|
+
let vehicle = data.vehicles.find((candidate) => candidate.ObjectNo === vehicleId);
|
|
27
|
+
if (!vehicle) return "";
|
|
28
|
+
|
|
29
|
+
let home = String(vehicle.LocationID ?? "E");
|
|
30
|
+
let isExternal = !data.plants.some((plant) => String(plant.PlantID) === home);
|
|
31
|
+
let feature = getVehicleFeature(vehicle);
|
|
32
|
+
let label = getVehicleLabel(vehicle);
|
|
33
|
+
|
|
34
|
+
return [
|
|
35
|
+
`<div style="min-width:95px">`,
|
|
36
|
+
vehicle.VirtualVehicle ? `<span>${label}</span>` : `<a href="#vehicle-${vehicleId}">${label}</a>`,
|
|
37
|
+
feature
|
|
38
|
+
? `<span style="background:${feature.color};margin-left:4px;padding:0 2px;color:#000">${feature.label}</span>`
|
|
39
|
+
: "",
|
|
40
|
+
isExternal ? ` (${escapeHtml(home)})` : "",
|
|
41
|
+
`</div>`,
|
|
42
|
+
].join("");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function deliveryTooltip(row: DeliveryRecord) {
|
|
46
|
+
let title = `${row.DeliveryTicketID ?? getLocalizedString("Planned")} (${getLocalizedString("Vehicle")} ${row.VehicleID}${
|
|
47
|
+
row.DriverID ? `, ${getLocalizedString("Driver")}: ${escapeHtml(row.DriverID)}` : ""
|
|
48
|
+
})`;
|
|
49
|
+
|
|
50
|
+
return `<div style="font-size:10px">
|
|
51
|
+
<div style="color:var(--ds-color-info-text-subtle)">${title}</div>
|
|
52
|
+
${row.Telescopic ? `<div style="color:var(--ds-color-info-text-subtle)">${getLocalizedString("Telescopic chute ordered")}</div>` : ""}
|
|
53
|
+
<div>${escapeHtml(row.CustomerAdr1)}</div>
|
|
54
|
+
<div style="color:var(--ds-color-neutral-text-subtle)">${escapeHtml(row.BuildSiteAdr1)}</div>
|
|
55
|
+
<br>
|
|
56
|
+
<div>${getLocalizedString("Production at")} ${formatTime(row.ProdTime)}</div>
|
|
57
|
+
<div>${getLocalizedString("Arrival at")} ${formatTime(row.Arrival)}</div>
|
|
58
|
+
<div>${getLocalizedString("Unloading starts at")} ${formatTime(row.UnloadStart)}</div>
|
|
59
|
+
<div>${getLocalizedString("Unloading complete at")} ${formatTime(row.UnloadComplete)}</div>
|
|
60
|
+
<div>${getLocalizedString("Returns at")} ${formatTime(row.ReturnTime)}</div>
|
|
61
|
+
</div>`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function pumpTooltip(point: any) {
|
|
65
|
+
return `<div style="font-size:10px">
|
|
66
|
+
<div style="color:var(--ds-color-info-text-subtle)">${getLocalizedString("Call-off")} ${point.callOffID} (${getLocalizedString("Plant")}: ${point.plantID})</div>
|
|
67
|
+
<div>${escapeHtml(point.customer)}</div>
|
|
68
|
+
<div style="color:var(--ds-color-neutral-text-subtle)">${escapeHtml(point.buildSite)}</div>
|
|
69
|
+
<br>
|
|
70
|
+
<div>${getLocalizedString("Pumping at")} ${formatTime(point.x)} - ${formatTime(point.x2)}</div>
|
|
71
|
+
</div>`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function deliveryLabel(point: any, thickBars: boolean) {
|
|
75
|
+
let maxLength = point.shapeArgs.width / 6 - 3;
|
|
76
|
+
let id: string = point.deliveryTicketID
|
|
77
|
+
? String(point.deliveryTicketID)
|
|
78
|
+
: `P ${point.callOffID}${point.telescopic ? " <b>[T]</b>" : ""}`;
|
|
79
|
+
let customer = escapeHtml(cropText(point.customer, maxLength));
|
|
80
|
+
let buildSite = escapeHtml(cropText(point.buildSite, maxLength));
|
|
81
|
+
|
|
82
|
+
if (thickBars) {
|
|
83
|
+
return `${cropText(id, maxLength, true)}<br>${customer}<br><i>${buildSite}</i>`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (id.length > maxLength) {
|
|
87
|
+
return cropText(id, maxLength, true);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return escapeHtml(cropText(`${id} ${point.customer ?? ""}`, maxLength)) + ` <i>${buildSite}</i>`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function getChartOptions(data: ChartData, settings: ChartSettings): Highcharts.Options {
|
|
94
|
+
let { date, minOffset, maxOffset, thickBars, readOnly, onMove } = settings;
|
|
95
|
+
let midnight = date.getTime();
|
|
96
|
+
let min = midnight + minOffset * HOUR;
|
|
97
|
+
let max = midnight + maxOffset * HOUR;
|
|
98
|
+
let categories = data.vehicles.map((vehicle) => vehicle.ObjectNo);
|
|
99
|
+
let rowsByKey = new Map(data.deliveries.map((row) => [row.PrimKey, row]));
|
|
100
|
+
|
|
101
|
+
let deliveries = data.deliveries.map((row) => ({
|
|
102
|
+
y: categories.indexOf(row.VehicleID),
|
|
103
|
+
x: row.ProdTime.getTime(),
|
|
104
|
+
x2: row.ReturnTime.getTime(),
|
|
105
|
+
m1: row.Arrival?.getTime(),
|
|
106
|
+
m2: row.UnloadStart?.getTime(),
|
|
107
|
+
m3: row.UnloadComplete?.getTime(),
|
|
108
|
+
primKey: row.PrimKey,
|
|
109
|
+
callOffID: row.CallOffID,
|
|
110
|
+
deliveryTicketID: row.DeliveryTicketID,
|
|
111
|
+
customer: row.CustomerAdr1,
|
|
112
|
+
buildSite: row.BuildSiteAdr1,
|
|
113
|
+
telescopic: row.Telescopic,
|
|
114
|
+
...barColor(plantColor(data.colorIndex, row.PlantID), row.DeliveryTicketID ? 0.6 : 0.2),
|
|
115
|
+
}));
|
|
116
|
+
|
|
117
|
+
let pumpTimes = data.pumpBookings.map((row) => ({
|
|
118
|
+
y: categories.indexOf(row.Pump),
|
|
119
|
+
x: row.PumpEstimatedDepartureDateTime.getTime(),
|
|
120
|
+
x2: row.PumpEstimatedReturnDateTime.getTime(),
|
|
121
|
+
callOffID: row.CallOffID,
|
|
122
|
+
plantID: row.PlantID,
|
|
123
|
+
customer: row.CustomerAdr1,
|
|
124
|
+
buildSite: row.BuildSiteAdr1,
|
|
125
|
+
caption: getLocalizedString("Pumping"),
|
|
126
|
+
...barColor("#bbb", 0.4),
|
|
127
|
+
}));
|
|
128
|
+
|
|
129
|
+
let outOfService = data.outOfService.map((row) => ({
|
|
130
|
+
y: categories.indexOf(row.ObjectNo),
|
|
131
|
+
x: row.FromDateTime.getTime(),
|
|
132
|
+
x2: row.ToDateTime.getTime(),
|
|
133
|
+
caption: row.Comment,
|
|
134
|
+
...barColor("#ff9999", 0.6),
|
|
135
|
+
}));
|
|
136
|
+
|
|
137
|
+
let subtitle = data.merged
|
|
138
|
+
? data.plants
|
|
139
|
+
.map(
|
|
140
|
+
(plant) =>
|
|
141
|
+
`<span style="color:${plantColor(data.colorIndex, plant.PlantID)}">●</span> ${plant.PlantID} - ${escapeHtml(plant.Description)}`,
|
|
142
|
+
)
|
|
143
|
+
.join(" ")
|
|
144
|
+
: `${data.plants[0].PlantID} - ${escapeHtml(data.plants[0].Description)}`;
|
|
145
|
+
|
|
146
|
+
let band = (from: number, to: number) => ({ color: "var(--ds-color-neutral-background-tinted)", from, to });
|
|
147
|
+
let shiftLine = (hour: number) => ({
|
|
148
|
+
color: "var(--ds-color-neutral-border-default)",
|
|
149
|
+
width: 2,
|
|
150
|
+
dashStyle: "Dash" as const,
|
|
151
|
+
value: midnight + hour * HOUR,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
chart: {
|
|
156
|
+
type: "deliveryxrange",
|
|
157
|
+
backgroundColor: "transparent",
|
|
158
|
+
zooming: { type: "x" },
|
|
159
|
+
height: getChartHeight(categories.length, thickBars, data.merged),
|
|
160
|
+
marginTop: data.merged ? 100 : 70,
|
|
161
|
+
marginBottom: 40,
|
|
162
|
+
},
|
|
163
|
+
accessibility: { enabled: false },
|
|
164
|
+
credits: { enabled: false },
|
|
165
|
+
title: { text: undefined },
|
|
166
|
+
subtitle: { useHTML: true, text: subtitle },
|
|
167
|
+
xAxis: [
|
|
168
|
+
{
|
|
169
|
+
type: "datetime",
|
|
170
|
+
min,
|
|
171
|
+
max,
|
|
172
|
+
dateTimeLabelFormats: { hour: "%H", day: "%d.%m" },
|
|
173
|
+
tickInterval: HOUR,
|
|
174
|
+
minorTickInterval: 0.5 * HOUR,
|
|
175
|
+
plotBands: [band(min - 24 * HOUR, midnight + 6 * HOUR), band(midnight + 18 * HOUR, max + 24 * HOUR)],
|
|
176
|
+
plotLines: [
|
|
177
|
+
shiftLine(9),
|
|
178
|
+
shiftLine(12),
|
|
179
|
+
shiftLine(15),
|
|
180
|
+
{
|
|
181
|
+
color: "#ffcc00",
|
|
182
|
+
width: 2,
|
|
183
|
+
dashStyle: "Dot",
|
|
184
|
+
// The bars are wall clock times carried as UTC, so "now" has to be as well.
|
|
185
|
+
value: Date.now() - new Date().getTimezoneOffset() * 60000,
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
{ type: "datetime", linkedTo: 0, opposite: true, dateTimeLabelFormats: { hour: "%H", day: "%d.%m" } },
|
|
190
|
+
],
|
|
191
|
+
yAxis: {
|
|
192
|
+
categories: categories.map(String),
|
|
193
|
+
reversed: true,
|
|
194
|
+
min: 0,
|
|
195
|
+
max: categories.length - 1,
|
|
196
|
+
title: { text: "" },
|
|
197
|
+
tickInterval: 1,
|
|
198
|
+
gridLineColor: "var(--ds-color-neutral-border-subtle)",
|
|
199
|
+
labels: {
|
|
200
|
+
useHTML: true,
|
|
201
|
+
formatter(this: any) {
|
|
202
|
+
return vehicleLabelHtml(data, Number(this.value));
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
tooltip: {
|
|
207
|
+
useHTML: true,
|
|
208
|
+
formatter(this: any) {
|
|
209
|
+
if (this.series.name === "PumpTimes") return pumpTooltip(this.point);
|
|
210
|
+
if (this.series.name !== "Deliveries") return false;
|
|
211
|
+
|
|
212
|
+
let row = rowsByKey.get(this.point.primKey);
|
|
213
|
+
return row ? deliveryTooltip(row) : false;
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
plotOptions: {
|
|
217
|
+
deliveryxrange: {
|
|
218
|
+
animation: false,
|
|
219
|
+
grouping: false,
|
|
220
|
+
groupPadding: 0.065,
|
|
221
|
+
colorByPoint: false,
|
|
222
|
+
borderWidth: 1,
|
|
223
|
+
borderColor: "#888",
|
|
224
|
+
borderRadius: 0,
|
|
225
|
+
dataLabels: {
|
|
226
|
+
enabled: true,
|
|
227
|
+
useHTML: false,
|
|
228
|
+
color: "var(--ds-color-neutral-text-default)",
|
|
229
|
+
align: "left",
|
|
230
|
+
y: 2,
|
|
231
|
+
style: { fontWeight: "normal", fontSize: "10px", textOutline: "none" },
|
|
232
|
+
formatter(this: any) {
|
|
233
|
+
if (this.series.name !== "Deliveries") return this.point.caption;
|
|
234
|
+
return deliveryLabel(this.point, thickBars);
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
dragDrop: {
|
|
238
|
+
draggableX: !readOnly,
|
|
239
|
+
draggableY: !readOnly,
|
|
240
|
+
draggableX1: false,
|
|
241
|
+
draggableX2: false,
|
|
242
|
+
dragPrecisionX: 5 * 60 * 1000,
|
|
243
|
+
liveRedraw: true,
|
|
244
|
+
},
|
|
245
|
+
point: {
|
|
246
|
+
events: {
|
|
247
|
+
dragStart(this: any) {
|
|
248
|
+
let row = rowsByKey.get(this.primKey);
|
|
249
|
+
if (!row) return false;
|
|
250
|
+
|
|
251
|
+
let offset = (value: number | undefined | null) => (value ? value - this.x : null);
|
|
252
|
+
this.dragOffsets = { m1: offset(this.m1), m2: offset(this.m2), m3: offset(this.m3) };
|
|
253
|
+
this.dragRowOffsets = {
|
|
254
|
+
Arrival: offset(row.Arrival?.getTime()),
|
|
255
|
+
UnloadStart: offset(row.UnloadStart?.getTime()),
|
|
256
|
+
UnloadComplete: offset(row.UnloadComplete?.getTime()),
|
|
257
|
+
ReturnTime: offset(row.ReturnTime.getTime()),
|
|
258
|
+
};
|
|
259
|
+
},
|
|
260
|
+
drag(this: any, event: any) {
|
|
261
|
+
if (
|
|
262
|
+
this.series.name !== "Deliveries" ||
|
|
263
|
+
this.deliveryTicketID !== null ||
|
|
264
|
+
!this.dragOffsets ||
|
|
265
|
+
!event.newPoint
|
|
266
|
+
) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
let row = rowsByKey.get(this.primKey) as DeliveryRecord;
|
|
271
|
+
let newX: number = event.newPoint.x;
|
|
272
|
+
let newValues = event.newPoints[this.id].newValues;
|
|
273
|
+
|
|
274
|
+
for (let key of ["m1", "m2", "m3"]) {
|
|
275
|
+
if (this.dragOffsets[key]) newValues[key] = newX + this.dragOffsets[key];
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
row.VehicleID = categories[event.newPoint.y];
|
|
279
|
+
row.DriverID = null;
|
|
280
|
+
row.ProdTime.setTime(newX);
|
|
281
|
+
for (let key of ["Arrival", "UnloadStart", "UnloadComplete", "ReturnTime"] as const) {
|
|
282
|
+
if (this.dragRowOffsets[key]) row[key]?.setTime(newX + this.dragRowOffsets[key]);
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
drop(this: any, event: any) {
|
|
286
|
+
if (
|
|
287
|
+
this.series.name !== "Deliveries" ||
|
|
288
|
+
this.deliveryTicketID !== null ||
|
|
289
|
+
!this.dragOffsets ||
|
|
290
|
+
!event.newPoint
|
|
291
|
+
) {
|
|
292
|
+
event.preventDefault();
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
let row = rowsByKey.get(this.primKey) as DeliveryRecord;
|
|
297
|
+
onMove(row, new Date(event.newPoint.x), categories[event.newPoint.y]);
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
series: { states: { inactive: { opacity: 1 } } },
|
|
303
|
+
} as Highcharts.PlotOptions,
|
|
304
|
+
legend: { enabled: false },
|
|
305
|
+
series: [
|
|
306
|
+
{ type: "deliveryxrange", name: "Deliveries", data: deliveries, cursor: readOnly ? undefined : "move" },
|
|
307
|
+
{ type: "deliveryxrange", name: "PumpTimes", data: pumpTimes },
|
|
308
|
+
{ type: "deliveryxrange", name: "OosTimes", data: outOfService },
|
|
309
|
+
] as unknown as Highcharts.SeriesOptionsType[],
|
|
310
|
+
};
|
|
311
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ProcedureAPI } from "@olenbetong/appframe-data";
|
|
2
|
+
|
|
3
|
+
export type PlantRecord = {
|
|
4
|
+
PlantID: number;
|
|
5
|
+
Description: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type VehicleRecord = {
|
|
9
|
+
LocationID: number | null;
|
|
10
|
+
ObjectNo: number;
|
|
11
|
+
Model: string | null;
|
|
12
|
+
MixerCapacity: number | null;
|
|
13
|
+
BoomLength: number | null;
|
|
14
|
+
IsTruck: boolean | null;
|
|
15
|
+
IsPump: boolean | null;
|
|
16
|
+
BigPump: boolean | null;
|
|
17
|
+
Telescopic: boolean | null;
|
|
18
|
+
ConveyorBelt: boolean | null;
|
|
19
|
+
VirtualVehicle: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type DeliveryRecord = {
|
|
23
|
+
PlantID: number;
|
|
24
|
+
CallOffID: number;
|
|
25
|
+
VehicleID: number;
|
|
26
|
+
DriverID: string | null;
|
|
27
|
+
DeliveryTicketID: number | null;
|
|
28
|
+
CustomerAdr1: string | null;
|
|
29
|
+
BuildSiteAdr1: string | null;
|
|
30
|
+
Telescopic: boolean;
|
|
31
|
+
ProdTime: Date;
|
|
32
|
+
Arrival: Date | null;
|
|
33
|
+
UnloadStart: Date | null;
|
|
34
|
+
UnloadComplete: Date | null;
|
|
35
|
+
ReturnTime: Date;
|
|
36
|
+
PrimKey: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type PumpBookingRecord = {
|
|
40
|
+
PlantID: number;
|
|
41
|
+
CallOffID: number;
|
|
42
|
+
Pump: number;
|
|
43
|
+
PumpEstimatedDepartureDateTime: Date;
|
|
44
|
+
PumpEstimatedReturnDateTime: Date;
|
|
45
|
+
PrimKey: string;
|
|
46
|
+
CustomerAdr1: string | null;
|
|
47
|
+
BuildSiteAdr1: string | null;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type OutOfServiceRecord = {
|
|
51
|
+
ObjectID: number;
|
|
52
|
+
ObjectNo: number;
|
|
53
|
+
FromDateTime: Date;
|
|
54
|
+
ToDateTime: Date;
|
|
55
|
+
Comment: string | null;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type DeliveriesParams = {
|
|
59
|
+
PlantIDs: [number][];
|
|
60
|
+
Date: Date;
|
|
61
|
+
IncludePumpBookings: boolean;
|
|
62
|
+
IncludeAllPlanned: boolean;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type DeliveriesResult = {
|
|
66
|
+
Table: PlantRecord[];
|
|
67
|
+
Table1: VehicleRecord[];
|
|
68
|
+
Table2: DeliveryRecord[];
|
|
69
|
+
Table3: PumpBookingRecord[];
|
|
70
|
+
Table4: OutOfServiceRecord[];
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type MoveDeliveryParams = {
|
|
74
|
+
PrimKey: string;
|
|
75
|
+
ProdDateTime: Date;
|
|
76
|
+
VehicleID: number;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const procDeliveriesByVehicle = new ProcedureAPI<DeliveriesParams, DeliveriesResult>({
|
|
80
|
+
procedureId: "astp_Plant_CallOffs_DeliveriesByVehicle",
|
|
81
|
+
parameters: [
|
|
82
|
+
{ name: "PlantIDs", type: "string", hasDefault: false, required: true },
|
|
83
|
+
{ name: "Date", type: "date", hasDefault: false, required: true },
|
|
84
|
+
{ name: "IncludePumpBookings", type: "boolean", hasDefault: true, required: false },
|
|
85
|
+
{ name: "IncludeAllPlanned", type: "boolean", hasDefault: true, required: false },
|
|
86
|
+
],
|
|
87
|
+
timeout: 30000,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
export const procMovePlannedDelivery = new ProcedureAPI<MoveDeliveryParams, unknown>({
|
|
91
|
+
procedureId: "astp_Plant_CallOffs_MovePlannedDelivery",
|
|
92
|
+
parameters: [
|
|
93
|
+
{ name: "PrimKey", type: "string", hasDefault: false, required: true },
|
|
94
|
+
{ name: "ProdDateTime", type: "date", hasDefault: false, required: true },
|
|
95
|
+
{ name: "VehicleID", type: "number", hasDefault: true, required: false },
|
|
96
|
+
],
|
|
97
|
+
timeout: 30000,
|
|
98
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import Highcharts from "highcharts";
|
|
2
|
+
// In this order: draggable-points only sets up the drag behaviour of series types that already exist.
|
|
3
|
+
import "highcharts/modules/xrange";
|
|
4
|
+
import "highcharts/modules/draggable-points";
|
|
5
|
+
|
|
6
|
+
const STATUS_BAR_HEIGHT = 3;
|
|
7
|
+
const STATUS_COLORS = ["yellow", "green", "orange", "green"];
|
|
8
|
+
|
|
9
|
+
type Segment = { x: number; width: number; color: string };
|
|
10
|
+
|
|
11
|
+
/** The status strip along the top of a bar: to site, waiting, unloading, returning. */
|
|
12
|
+
function getSegments(point: any, shapeArgs: { x: number; width: number }) {
|
|
13
|
+
let { m1, m2, m3, x, x2 } = point;
|
|
14
|
+
let total = x2 - x;
|
|
15
|
+
let limits: number[] = [];
|
|
16
|
+
|
|
17
|
+
if (m1 && m1 >= x && m1 <= x2) {
|
|
18
|
+
limits.push(x, m1);
|
|
19
|
+
if (m2 && m2 >= m1 && m2 <= x2) {
|
|
20
|
+
limits.push(m2);
|
|
21
|
+
if (m3 && m3 >= m2 && m3 <= x2) {
|
|
22
|
+
limits.push(m3, x2);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let segments: Segment[] = [];
|
|
28
|
+
for (let i = 1; i < limits.length; i++) {
|
|
29
|
+
segments.push({
|
|
30
|
+
x: shapeArgs.x + (shapeArgs.width * (limits[i - 1] - x)) / total,
|
|
31
|
+
width: (shapeArgs.width * (limits[i] - limits[i - 1])) / total,
|
|
32
|
+
color: STATUS_COLORS[i - 1],
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return segments;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** An xrange series whose points also show m1, m2 and m3 as a status strip. */
|
|
40
|
+
export function registerDeliveryXRange() {
|
|
41
|
+
let parent = (Highcharts as any).seriesTypes.xrange.prototype;
|
|
42
|
+
|
|
43
|
+
if ((Highcharts as any).seriesTypes.deliveryxrange) return;
|
|
44
|
+
|
|
45
|
+
Highcharts.seriesType(
|
|
46
|
+
"deliveryxrange",
|
|
47
|
+
"xrange",
|
|
48
|
+
{},
|
|
49
|
+
{
|
|
50
|
+
drawPoint(this: any, point: any) {
|
|
51
|
+
parent.drawPoint.apply(this, arguments);
|
|
52
|
+
|
|
53
|
+
let graphics: any[] = point.statusGraphics ?? [];
|
|
54
|
+
let segments = point.isNull || !point.shapeArgs ? [] : getSegments(point, point.shapeArgs);
|
|
55
|
+
|
|
56
|
+
for (let graphic of graphics.splice(segments.length)) {
|
|
57
|
+
graphic.destroy();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
segments.forEach((segment, index) => {
|
|
61
|
+
let attributes = {
|
|
62
|
+
x: segment.x,
|
|
63
|
+
y: point.shapeArgs.y,
|
|
64
|
+
width: segment.width,
|
|
65
|
+
height: STATUS_BAR_HEIGHT,
|
|
66
|
+
fill: segment.color,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
if (graphics[index]) {
|
|
70
|
+
graphics[index].attr(attributes);
|
|
71
|
+
} else {
|
|
72
|
+
graphics[index] = this.chart.renderer.rect().attr(attributes).add(point.graphic);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
point.statusGraphics = graphics;
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.ObVehicleDeliveries {
|
|
2
|
+
padding-block: 0.5rem;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.ObVehicleDeliveries-options {
|
|
6
|
+
display: flex;
|
|
7
|
+
gap: 0.5rem 1rem;
|
|
8
|
+
justify-content: flex-end;
|
|
9
|
+
position: sticky;
|
|
10
|
+
top: 0;
|
|
11
|
+
z-index: 1;
|
|
12
|
+
padding: 5px;
|
|
13
|
+
padding-inline-start: 2.5rem;
|
|
14
|
+
background-color: var(--ds-color-neutral-background-default);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Out of the flow, so the spinner never changes the height of the bar while it loads.
|
|
18
|
+
.ObVehicleDeliveries-status {
|
|
19
|
+
position: absolute;
|
|
20
|
+
inset-block: 0;
|
|
21
|
+
inset-inline-start: 5px;
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
pointer-events: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Highcharts sets `light dark` here, which follows the OS instead of the colour scheme of the site.
|
|
28
|
+
.ObVehicleDeliveries-chart .highcharts-container {
|
|
29
|
+
color-scheme: inherit;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ObVehicleDeliveries-chart a {
|
|
33
|
+
color: var(--ds-color-info-text-subtle);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.ObVehicleDeliveries-legend {
|
|
37
|
+
color: var(--ds-color-neutral-text-subtle);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ObVehicleDeliveries hr {
|
|
41
|
+
border: 0;
|
|
42
|
+
border-block-start: 1px solid var(--ds-color-neutral-border-subtle);
|
|
43
|
+
}
|