@seedtactics/insight-client 16.4.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/README.md +37 -0
- package/dist/cell-status/buffers.d.ts +36 -0
- package/dist/cell-status/buffers.js +127 -0
- package/dist/cell-status/current-status.d.ts +30 -0
- package/dist/cell-status/current-status.js +200 -0
- package/dist/cell-status/estimated-cycle-times.d.ts +41 -0
- package/dist/cell-status/estimated-cycle-times.js +257 -0
- package/dist/cell-status/inspections.d.ts +55 -0
- package/dist/cell-status/inspections.js +213 -0
- package/dist/cell-status/loading.d.ts +26 -0
- package/dist/cell-status/loading.js +112 -0
- package/dist/cell-status/material-details.d.ts +116 -0
- package/dist/cell-status/material-details.js +422 -0
- package/dist/cell-status/material-summary.d.ts +52 -0
- package/dist/cell-status/material-summary.js +312 -0
- package/dist/cell-status/names.d.ts +19 -0
- package/dist/cell-status/names.js +134 -0
- package/dist/cell-status/pallet-cycles.d.ts +24 -0
- package/dist/cell-status/pallet-cycles.js +78 -0
- package/dist/cell-status/rebookings.d.ts +30 -0
- package/dist/cell-status/rebookings.js +139 -0
- package/dist/cell-status/scheduled-jobs.d.ts +18 -0
- package/dist/cell-status/scheduled-jobs.js +94 -0
- package/dist/cell-status/sim-day-usage.d.ts +14 -0
- package/dist/cell-status/sim-day-usage.js +54 -0
- package/dist/cell-status/sim-production.d.ts +22 -0
- package/dist/cell-status/sim-production.js +91 -0
- package/dist/cell-status/sim-station-use.d.ts +25 -0
- package/dist/cell-status/sim-station-use.js +71 -0
- package/dist/cell-status/station-cycles.d.ts +34 -0
- package/dist/cell-status/station-cycles.js +145 -0
- package/dist/cell-status/tool-replacements.d.ts +44 -0
- package/dist/cell-status/tool-replacements.js +155 -0
- package/dist/cell-status/tool-usage.d.ts +25 -0
- package/dist/cell-status/tool-usage.js +95 -0
- package/dist/components/App.d.ts +15 -0
- package/dist/components/App.js +549 -0
- package/dist/components/AxisAndGrid.d.ts +51 -0
- package/dist/components/AxisAndGrid.js +47 -0
- package/dist/components/BarcodeScanning.d.ts +6 -0
- package/dist/components/BarcodeScanning.js +150 -0
- package/dist/components/ChartTooltip.d.ts +28 -0
- package/dist/components/ChartTooltip.js +95 -0
- package/dist/components/ChooseMode.d.ts +18 -0
- package/dist/components/ChooseMode.js +136 -0
- package/dist/components/ChooseOperator.d.ts +1 -0
- package/dist/components/ChooseOperator.js +93 -0
- package/dist/components/ErrorsAndLoading.d.ts +9 -0
- package/dist/components/ErrorsAndLoading.js +55 -0
- package/dist/components/LoadingIcon.d.ts +1 -0
- package/dist/components/LoadingIcon.js +48 -0
- package/dist/components/LogEntry.d.ts +16 -0
- package/dist/components/LogEntry.js +365 -0
- package/dist/components/ManualSerialEntry.d.ts +5 -0
- package/dist/components/ManualSerialEntry.js +91 -0
- package/dist/components/MonthSelect.d.ts +6 -0
- package/dist/components/MonthSelect.js +67 -0
- package/dist/components/Navigation.d.ts +23 -0
- package/dist/components/Navigation.js +120 -0
- package/dist/components/VerboseLogging.d.ts +1 -0
- package/dist/components/VerboseLogging.js +47 -0
- package/dist/components/analysis/AnalysisSelectToolbar.d.ts +1 -0
- package/dist/components/analysis/AnalysisSelectToolbar.js +55 -0
- package/dist/components/analysis/BufferChart.d.ts +1 -0
- package/dist/components/analysis/BufferChart.js +139 -0
- package/dist/components/analysis/CostPerPiece.d.ts +2 -0
- package/dist/components/analysis/CostPerPiece.js +175 -0
- package/dist/components/analysis/CycleChart.d.ts +42 -0
- package/dist/components/analysis/CycleChart.js +281 -0
- package/dist/components/analysis/DataTable.d.ts +83 -0
- package/dist/components/analysis/DataTable.js +215 -0
- package/dist/components/analysis/EfficiencyPage.d.ts +2 -0
- package/dist/components/analysis/EfficiencyPage.js +138 -0
- package/dist/components/analysis/HeatChart.d.ts +22 -0
- package/dist/components/analysis/HeatChart.js +161 -0
- package/dist/components/analysis/InspectionDataTable.d.ts +10 -0
- package/dist/components/analysis/InspectionDataTable.js +148 -0
- package/dist/components/analysis/InspectionSankey.d.ts +12 -0
- package/dist/components/analysis/InspectionSankey.js +140 -0
- package/dist/components/analysis/PalletCycleCards.d.ts +1 -0
- package/dist/components/analysis/PalletCycleCards.js +137 -0
- package/dist/components/analysis/PartCycleCards.d.ts +2 -0
- package/dist/components/analysis/PartCycleCards.js +331 -0
- package/dist/components/analysis/QualityPage.d.ts +1 -0
- package/dist/components/analysis/QualityPage.js +49 -0
- package/dist/components/analysis/ScheduleHistory.d.ts +3 -0
- package/dist/components/analysis/ScheduleHistory.js +108 -0
- package/dist/components/analysis/StationDataTable.d.ts +25 -0
- package/dist/components/analysis/StationDataTable.js +246 -0
- package/dist/components/analysis/ToolReplacements.d.ts +1 -0
- package/dist/components/analysis/ToolReplacements.js +370 -0
- package/dist/components/operations/AllMaterial.d.ts +5 -0
- package/dist/components/operations/AllMaterial.js +267 -0
- package/dist/components/operations/ChartRangeEdit.d.ts +4 -0
- package/dist/components/operations/ChartRangeEdit.js +148 -0
- package/dist/components/operations/CloseoutReport.d.ts +2 -0
- package/dist/components/operations/CloseoutReport.js +172 -0
- package/dist/components/operations/CompletedParts.d.ts +2 -0
- package/dist/components/operations/CompletedParts.js +286 -0
- package/dist/components/operations/CurrentWorkorders.d.ts +3 -0
- package/dist/components/operations/CurrentWorkorders.js +368 -0
- package/dist/components/operations/Dashboard.d.ts +2 -0
- package/dist/components/operations/Dashboard.js +90 -0
- package/dist/components/operations/OEEChart.d.ts +10 -0
- package/dist/components/operations/OEEChart.js +173 -0
- package/dist/components/operations/Outliers.d.ts +4 -0
- package/dist/components/operations/Outliers.js +69 -0
- package/dist/components/operations/ProgramHighlight.d.ts +1 -0
- package/dist/components/operations/ProgramHighlight.js +9 -0
- package/dist/components/operations/Programs.d.ts +5 -0
- package/dist/components/operations/Programs.js +363 -0
- package/dist/components/operations/Rebookings.d.ts +1 -0
- package/dist/components/operations/Rebookings.js +213 -0
- package/dist/components/operations/RecentCycleChart.d.ts +4 -0
- package/dist/components/operations/RecentCycleChart.js +240 -0
- package/dist/components/operations/RecentProduction.d.ts +2 -0
- package/dist/components/operations/RecentProduction.js +213 -0
- package/dist/components/operations/RecentSchedules.d.ts +12 -0
- package/dist/components/operations/RecentSchedules.js +180 -0
- package/dist/components/operations/RecentStationCycles.d.ts +4 -0
- package/dist/components/operations/RecentStationCycles.js +159 -0
- package/dist/components/operations/ShiftSettings.d.ts +6 -0
- package/dist/components/operations/ShiftSettings.js +134 -0
- package/dist/components/operations/SimDayUsage.d.ts +1 -0
- package/dist/components/operations/SimDayUsage.js +133 -0
- package/dist/components/operations/ToolReport.d.ts +3 -0
- package/dist/components/operations/ToolReport.js +233 -0
- package/dist/components/operations/WorkorderGantt.d.ts +1 -0
- package/dist/components/operations/WorkorderGantt.js +124 -0
- package/dist/components/quality/QualityMaterial.d.ts +2 -0
- package/dist/components/quality/QualityMaterial.js +169 -0
- package/dist/components/quality/QualityPaths.d.ts +1 -0
- package/dist/components/quality/QualityPaths.js +53 -0
- package/dist/components/quality/RecentFailedInspections.d.ts +1 -0
- package/dist/components/quality/RecentFailedInspections.js +123 -0
- package/dist/components/routes.d.ts +170 -0
- package/dist/components/routes.js +301 -0
- package/dist/components/station-monitor/BulkRawMaterial.d.ts +11 -0
- package/dist/components/station-monitor/BulkRawMaterial.js +251 -0
- package/dist/components/station-monitor/Closeout.d.ts +5 -0
- package/dist/components/station-monitor/Closeout.js +162 -0
- package/dist/components/station-monitor/CustomStationMonitorDialog.d.ts +1 -0
- package/dist/components/station-monitor/CustomStationMonitorDialog.js +55 -0
- package/dist/components/station-monitor/Inspection.d.ts +8 -0
- package/dist/components/station-monitor/Inspection.js +164 -0
- package/dist/components/station-monitor/InvalidateCycle.d.ts +33 -0
- package/dist/components/station-monitor/InvalidateCycle.js +262 -0
- package/dist/components/station-monitor/JobDetails.d.ts +7 -0
- package/dist/components/station-monitor/JobDetails.js +108 -0
- package/dist/components/station-monitor/LoadStation.d.ts +10 -0
- package/dist/components/station-monitor/LoadStation.js +450 -0
- package/dist/components/station-monitor/Material.d.ts +77 -0
- package/dist/components/station-monitor/Material.js +489 -0
- package/dist/components/station-monitor/MoveMaterialArrows.d.ts +11 -0
- package/dist/components/station-monitor/MoveMaterialArrows.js +118 -0
- package/dist/components/station-monitor/PrintedLabel.d.ts +29 -0
- package/dist/components/station-monitor/PrintedLabel.js +166 -0
- package/dist/components/station-monitor/QuarantineButton.d.ts +4 -0
- package/dist/components/station-monitor/QuarantineButton.js +184 -0
- package/dist/components/station-monitor/Queues.d.ts +23 -0
- package/dist/components/station-monitor/Queues.js +312 -0
- package/dist/components/station-monitor/QueuesAddMaterial.d.ts +30 -0
- package/dist/components/station-monitor/QueuesAddMaterial.js +248 -0
- package/dist/components/station-monitor/SelectInspType.d.ts +2 -0
- package/dist/components/station-monitor/SelectInspType.js +99 -0
- package/dist/components/station-monitor/SelectWorkorder.d.ts +4 -0
- package/dist/components/station-monitor/SelectWorkorder.js +100 -0
- package/dist/components/station-monitor/StationToolbar.d.ts +3 -0
- package/dist/components/station-monitor/StationToolbar.js +168 -0
- package/dist/components/station-monitor/SystemOverview.d.ts +46 -0
- package/dist/components/station-monitor/SystemOverview.js +439 -0
- package/dist/components/station-monitor/Whiteboard.d.ts +10 -0
- package/dist/components/station-monitor/Whiteboard.js +67 -0
- package/dist/data/all-material-bins.d.ts +45 -0
- package/dist/data/all-material-bins.js +224 -0
- package/dist/data/chart-times.d.ts +20 -0
- package/dist/data/chart-times.js +99 -0
- package/dist/data/cost-per-piece.d.ts +32 -0
- package/dist/data/cost-per-piece.js +183 -0
- package/dist/data/current-cycles.d.ts +13 -0
- package/dist/data/current-cycles.js +144 -0
- package/dist/data/inspection-sankey.d.ts +15 -0
- package/dist/data/inspection-sankey.js +147 -0
- package/dist/data/move-arrows.d.ts +48 -0
- package/dist/data/move-arrows.js +217 -0
- package/dist/data/operators.d.ts +2 -0
- package/dist/data/operators.js +44 -0
- package/dist/data/part-summary.d.ts +17 -0
- package/dist/data/part-summary.js +107 -0
- package/dist/data/path-lookup.d.ts +13 -0
- package/dist/data/path-lookup.js +107 -0
- package/dist/data/queue-material.d.ts +46 -0
- package/dist/data/queue-material.js +256 -0
- package/dist/data/results.bufferchart.d.ts +10 -0
- package/dist/data/results.bufferchart.js +90 -0
- package/dist/data/results.completed-parts.d.ts +26 -0
- package/dist/data/results.completed-parts.js +181 -0
- package/dist/data/results.cycles.d.ts +86 -0
- package/dist/data/results.cycles.js +454 -0
- package/dist/data/results.inspection.d.ts +36 -0
- package/dist/data/results.inspection.js +188 -0
- package/dist/data/results.oee.d.ts +40 -0
- package/dist/data/results.oee.js +330 -0
- package/dist/data/results.schedules.d.ts +23 -0
- package/dist/data/results.schedules.js +157 -0
- package/dist/data/tools-programs.d.ts +78 -0
- package/dist/data/tools-programs.js +376 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +60 -0
- package/dist/network/api.d.ts +1390 -0
- package/dist/network/api.js +4971 -0
- package/dist/network/backend-mock.d.ts +11 -0
- package/dist/network/backend-mock.js +512 -0
- package/dist/network/backend.d.ts +57 -0
- package/dist/network/backend.js +77 -0
- package/dist/network/load-specific-month.d.ts +13 -0
- package/dist/network/load-specific-month.js +77 -0
- package/dist/network/server-settings.d.ts +12 -0
- package/dist/network/server-settings.js +92 -0
- package/dist/network/websocket.d.ts +4 -0
- package/dist/network/websocket.js +165 -0
- package/dist/renderer.d.ts +8 -0
- package/dist/renderer.js +55 -0
- package/dist/seedtactics-logo.d.ts +2 -0
- package/dist/seedtactics-logo.js +4 -0
- package/dist/util/chart-colors.d.ts +1 -0
- package/dist/util/chart-colors.js +116 -0
- package/dist/util/chart-helpers.d.ts +3 -0
- package/dist/util/chart-helpers.js +51 -0
- package/dist/util/parseISODuration.d.ts +4 -0
- package/dist/util/parseISODuration.js +40 -0
- package/docs/client-efficiency.md +355 -0
- package/docs/client-engineering.md +54 -0
- package/docs/client-launch.md +55 -0
- package/docs/client-operations.md +88 -0
- package/docs/client-quality.md +74 -0
- package/docs/client-sales.md +61 -0
- package/docs/client-scanners.md +41 -0
- package/docs/client-station-monitor.md +149 -0
- package/docs/client-tools-programs.md +74 -0
- package/docs/improve-fms.md +141 -0
- package/docs/makino.md +40 -0
- package/docs/material-quarantine.md +82 -0
- package/docs/material-tracking.md +236 -0
- package/docs/mazak.md +115 -0
- package/docs/niigata.md +228 -0
- package/docs/operator-procedures.md +106 -0
- package/docs/part-instructions.md +63 -0
- package/docs/screenshots/insight-all-material.png +0 -0
- package/docs/screenshots/insight-analysis-pallets.png +0 -0
- package/docs/screenshots/insight-analysis-part-completed.png +0 -0
- package/docs/screenshots/insight-analysis-sankey.png +0 -0
- package/docs/screenshots/insight-analysis-station-oee.png +0 -0
- package/docs/screenshots/insight-buffer-occupancy.png +0 -0
- package/docs/screenshots/insight-choose-analysis-month.png +0 -0
- package/docs/screenshots/insight-closeout.png +0 -0
- package/docs/screenshots/insight-cost-percentages.png +0 -0
- package/docs/screenshots/insight-dashboard.png +0 -0
- package/docs/screenshots/insight-event-custom-view.jpg +0 -0
- package/docs/screenshots/insight-event-viewer.jpg +0 -0
- package/docs/screenshots/insight-inspection.png +0 -0
- package/docs/screenshots/insight-load-station-details.png +0 -0
- package/docs/screenshots/insight-load-station.png +0 -0
- package/docs/screenshots/insight-loadcycle-graph.png +0 -0
- package/docs/screenshots/insight-loadstation-small.jpg +0 -0
- package/docs/screenshots/insight-machinecycle-graph.png +0 -0
- package/docs/screenshots/insight-machinecycle-table.png +0 -0
- package/docs/screenshots/insight-machinecycles.png +0 -0
- package/docs/screenshots/insight-machinehours.png +0 -0
- package/docs/screenshots/insight-machineoutliers.png +0 -0
- package/docs/screenshots/insight-monthly-schedules.png +0 -0
- package/docs/screenshots/insight-operations-material.png +0 -0
- package/docs/screenshots/insight-operations-overview.png +0 -0
- package/docs/screenshots/insight-operations-reports.png +0 -0
- package/docs/screenshots/insight-part-cost.png +0 -0
- package/docs/screenshots/insight-program-report.png +0 -0
- package/docs/screenshots/insight-quality-material-details.png +0 -0
- package/docs/screenshots/insight-quality-material.png +0 -0
- package/docs/screenshots/insight-quality-quarantine.png +0 -0
- package/docs/screenshots/insight-quality-sankey.png +0 -0
- package/docs/screenshots/insight-quality-similar-paths.png +0 -0
- package/docs/screenshots/insight-queue-details.png +0 -0
- package/docs/screenshots/insight-queues-jobs-table.png +0 -0
- package/docs/screenshots/insight-queues.png +0 -0
- package/docs/screenshots/insight-sim-day-usage.png +0 -0
- package/docs/screenshots/insight-station-system-overview-buttons.png +0 -0
- package/docs/screenshots/insight-station-system-overview.png +0 -0
- package/docs/screenshots/insight-system-overview.png +0 -0
- package/docs/screenshots/insight-tool-replacements.png +0 -0
- package/docs/screenshots/insight-tool-report.png +0 -0
- package/docs/screenshots/insight-toolbar-btns.png +0 -0
- package/docs/screenshots/insight-workorder-gantt.png +0 -0
- package/docs/screenshots/insight-workorders.png +0 -0
- package/docs/security.md +131 -0
- package/docs/server-config.md +56 -0
- package/docs/server-errors.md +44 -0
- package/package.json +90 -0
- package/src/index.ts +65 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/* Copyright (c) 2024, John Lenz
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
* Redistributions in binary form must reproduce the above
|
|
12
|
+
copyright notice, this list of conditions and the following
|
|
13
|
+
disclaimer in the documentation and/or other materials provided
|
|
14
|
+
with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of John Lenz, Black Maple Software, SeedTactics,
|
|
17
|
+
nor the names of other contributors may be used to endorse or
|
|
18
|
+
promote products derived from this software without specific
|
|
19
|
+
prior written permission.
|
|
20
|
+
|
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
22
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
24
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
25
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
26
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
27
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
28
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
29
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
30
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
31
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
32
|
+
*/
|
|
33
|
+
import { atom } from "jotai";
|
|
34
|
+
import { LogType } from "../network/api";
|
|
35
|
+
import { LazySeq, OrderedMap } from "@seedtactics/immutable-collections";
|
|
36
|
+
import { JobsBackend, LogBackend } from "../network/backend";
|
|
37
|
+
import { loadable } from "jotai/utils";
|
|
38
|
+
import { addDays } from "date-fns";
|
|
39
|
+
import { useCallback, useState } from "react";
|
|
40
|
+
const rebookingEvts = atom(OrderedMap.empty());
|
|
41
|
+
// unscheduled rebookings should be loaded from the last 30 events, but it is
|
|
42
|
+
// possible for some to be older than 30 days, so load them here. But don't
|
|
43
|
+
// wait for them to be loaded before rendering, so everything is wrapped in loadable.
|
|
44
|
+
const unschRebookings = loadable(atom(async (_, { signal }) => {
|
|
45
|
+
const b = await JobsBackend.unscheduledRebookings(signal);
|
|
46
|
+
return OrderedMap.build(b, (b) => b.bookingId);
|
|
47
|
+
}));
|
|
48
|
+
export const last30Rebookings = atom((get) => {
|
|
49
|
+
const evts = get(rebookingEvts);
|
|
50
|
+
const unsch = get(unschRebookings);
|
|
51
|
+
if (unsch.state === "hasData") {
|
|
52
|
+
return evts.union(unsch.data, (fromEvt, fromUnsch) => fromEvt ?? fromUnsch);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return evts;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const canceledRebookingsRW = atom(OrderedMap.empty());
|
|
59
|
+
export const canceledRebookings = canceledRebookingsRW;
|
|
60
|
+
const scheduledRW = atom(OrderedMap.empty());
|
|
61
|
+
export const last30ScheduledBookings = scheduledRW;
|
|
62
|
+
function convertLogToRebooking(log) {
|
|
63
|
+
let qty = 1;
|
|
64
|
+
if (log.details?.["Quantity"]) {
|
|
65
|
+
qty = parseInt(log.details["Quantity"], 10);
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
bookingId: log.result,
|
|
69
|
+
partName: log.program,
|
|
70
|
+
quantity: qty,
|
|
71
|
+
timeUTC: log.endUTC,
|
|
72
|
+
priority: log.locnum,
|
|
73
|
+
notes: log.details?.["Notes"],
|
|
74
|
+
workorder: log.details?.["Workorder"] ?? log.material?.[0]?.workorder,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export const setLast30Rebookings = atom(null, (get, set, log) => {
|
|
78
|
+
set(rebookingEvts, (old) => old.union(LazySeq.of(log)
|
|
79
|
+
.filter((e) => e.type === LogType.Rebooking)
|
|
80
|
+
.toOrderedMap((e) => [e.result, convertLogToRebooking(e)])));
|
|
81
|
+
set(canceledRebookingsRW, (old) => old.union(LazySeq.of(log)
|
|
82
|
+
.filter((e) => e.type === LogType.CancelRebooking)
|
|
83
|
+
.toOrderedMap((e) => [e.result, e.endUTC])));
|
|
84
|
+
});
|
|
85
|
+
function updateJobs(set, jobs, expire) {
|
|
86
|
+
set(scheduledRW, (old) => {
|
|
87
|
+
if (expire) {
|
|
88
|
+
old = old.filter((b) => b.scheduledTime >= expire);
|
|
89
|
+
}
|
|
90
|
+
return old.union(jobs
|
|
91
|
+
.flatMap((j) => (j.bookings ?? []).map((b) => [
|
|
92
|
+
b,
|
|
93
|
+
{
|
|
94
|
+
scheduledTime: j.routeStartUTC,
|
|
95
|
+
jobUnique: j.unique,
|
|
96
|
+
},
|
|
97
|
+
]))
|
|
98
|
+
.toOrderedMap((x) => x));
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export const setLast30RebookingJobs = atom(null, (_, set, historic) => {
|
|
102
|
+
updateJobs(set, LazySeq.ofObject(historic.jobs).map(([_, j]) => j));
|
|
103
|
+
});
|
|
104
|
+
export const updateLast30Rebookings = atom(null, (get, set, { evt, now, expire }) => {
|
|
105
|
+
if (evt.newJobs) {
|
|
106
|
+
updateJobs(set, LazySeq.of(evt.newJobs.jobs), expire ? addDays(now, -30) : undefined);
|
|
107
|
+
}
|
|
108
|
+
else if (evt.logEntry) {
|
|
109
|
+
const e = evt.logEntry;
|
|
110
|
+
if (e.type === LogType.Rebooking) {
|
|
111
|
+
set(rebookingEvts, (old) => old.set(e.result, convertLogToRebooking(e)));
|
|
112
|
+
}
|
|
113
|
+
else if (e.type === LogType.CancelRebooking) {
|
|
114
|
+
set(canceledRebookingsRW, (old) => old.set(e.result, e.endUTC));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
export function useCancelRebooking() {
|
|
119
|
+
const [loading, setLoading] = useState(false);
|
|
120
|
+
const callback = useCallback((bookingId) => {
|
|
121
|
+
setLoading(true);
|
|
122
|
+
return LogBackend.cancelRebooking(bookingId)
|
|
123
|
+
.then(() => { })
|
|
124
|
+
.catch(console.log)
|
|
125
|
+
.finally(() => setLoading(false));
|
|
126
|
+
}, []);
|
|
127
|
+
return [callback, loading];
|
|
128
|
+
}
|
|
129
|
+
export function useNewRebooking() {
|
|
130
|
+
const [loading, setLoading] = useState(false);
|
|
131
|
+
const callback = useCallback((n) => {
|
|
132
|
+
setLoading(true);
|
|
133
|
+
return LogBackend.requestRebooking(n.part, n.qty && !isNaN(n.qty) ? n.qty : 1, n.workorder, n.priority !== undefined && n.priority !== null && !isNaN(n.priority) ? n.priority : undefined, n.notes)
|
|
134
|
+
.then(() => { })
|
|
135
|
+
.catch(console.log)
|
|
136
|
+
.finally(() => setLoading(false));
|
|
137
|
+
}, []);
|
|
138
|
+
return [callback, loading];
|
|
139
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ServerEventAndTime } from "./loading.js";
|
|
2
|
+
import { IHistoricData, IHistoricJob, IRecentHistoricData } from "../network/api.js";
|
|
3
|
+
import { HashMap, HashSet } from "@seedtactics/immutable-collections";
|
|
4
|
+
import { Atom } from "jotai";
|
|
5
|
+
export declare const last30Jobs: Atom<HashMap<string, Readonly<IHistoricJob>>>;
|
|
6
|
+
export declare const last30SchIds: Atom<HashSet<string>>;
|
|
7
|
+
export declare const specificMonthJobs: Atom<HashMap<string, Readonly<IHistoricJob>>>;
|
|
8
|
+
export declare function filterExistingJobs(schIds: HashSet<string>, history: Readonly<IRecentHistoricData>): Readonly<IRecentHistoricData>;
|
|
9
|
+
export declare const setLast30Jobs: import("jotai").WritableAtom<null, [history: Readonly<IHistoricData>], void> & {
|
|
10
|
+
init: null;
|
|
11
|
+
};
|
|
12
|
+
export declare const updateLast30Jobs: import("jotai").WritableAtom<null, [ServerEventAndTime], void> & {
|
|
13
|
+
init: null;
|
|
14
|
+
};
|
|
15
|
+
export declare const updateSpecificMonthJobs: import("jotai").WritableAtom<null, [history: Readonly<IHistoricData>], void> & {
|
|
16
|
+
init: null;
|
|
17
|
+
};
|
|
18
|
+
export declare const last30JobComment: import("jotai-family").AtomFamily<string, import("jotai").WritableAtom<string | null, [newVal: string | null], void>>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* Copyright (c) 2021, John Lenz
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
* Redistributions in binary form must reproduce the above
|
|
12
|
+
copyright notice, this list of conditions and the following
|
|
13
|
+
disclaimer in the documentation and/or other materials provided
|
|
14
|
+
with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of John Lenz, Black Maple Software, SeedTactics,
|
|
17
|
+
nor the names of other contributors may be used to endorse or
|
|
18
|
+
promote products derived from this software without specific
|
|
19
|
+
prior written permission.
|
|
20
|
+
|
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
22
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
24
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
25
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
26
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
27
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
28
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
29
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
30
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
31
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
32
|
+
*/
|
|
33
|
+
import { addDays } from "date-fns";
|
|
34
|
+
import { HashMap, HashSet, LazySeq } from "@seedtactics/immutable-collections";
|
|
35
|
+
import { atom } from "jotai";
|
|
36
|
+
import { atomFamily } from "jotai-family";
|
|
37
|
+
const last30JobsRW = atom(HashMap.empty());
|
|
38
|
+
export const last30Jobs = last30JobsRW;
|
|
39
|
+
const last30SchIdsRW = atom(HashSet.empty());
|
|
40
|
+
export const last30SchIds = last30SchIdsRW;
|
|
41
|
+
const specificMonthJobsRW = atom(HashMap.empty());
|
|
42
|
+
export const specificMonthJobs = specificMonthJobsRW;
|
|
43
|
+
export function filterExistingJobs(schIds, history) {
|
|
44
|
+
if (schIds.size === 0)
|
|
45
|
+
return history;
|
|
46
|
+
const newHistory = {
|
|
47
|
+
...history,
|
|
48
|
+
jobs: { ...history.jobs },
|
|
49
|
+
stationUse: history.stationUse.filter((s) => !schIds.has(s.scheduleId)),
|
|
50
|
+
};
|
|
51
|
+
for (const [u, j] of Object.entries(history.jobs)) {
|
|
52
|
+
if (j.scheduleId && schIds.has(j.scheduleId)) {
|
|
53
|
+
delete newHistory.jobs[u];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return newHistory;
|
|
57
|
+
}
|
|
58
|
+
export const setLast30Jobs = atom(null, (_, set, history) => {
|
|
59
|
+
set(last30JobsRW, (oldJobs) => oldJobs.union(LazySeq.ofObject(history.jobs).toHashMap((x) => x)));
|
|
60
|
+
set(last30SchIdsRW, (oldIds) => oldIds.union(LazySeq.ofObject(history.jobs)
|
|
61
|
+
.collect(([, x]) => x.scheduleId)
|
|
62
|
+
.toHashSet((s) => s)));
|
|
63
|
+
});
|
|
64
|
+
export const updateLast30Jobs = atom(null, (_, set, { evt, now, expire }) => {
|
|
65
|
+
if (evt.newJobs) {
|
|
66
|
+
const schId = evt.newJobs.scheduleId;
|
|
67
|
+
const newJobs = LazySeq.of(evt.newJobs.jobs);
|
|
68
|
+
set(last30JobsRW, (oldJobs) => {
|
|
69
|
+
if (expire) {
|
|
70
|
+
const expire = addDays(now, -30);
|
|
71
|
+
oldJobs = oldJobs.filter((j) => j.routeStartUTC >= expire);
|
|
72
|
+
}
|
|
73
|
+
return oldJobs.union(newJobs.toHashMap((j) => [j.unique, { ...j, copiedToSystem: true }]));
|
|
74
|
+
});
|
|
75
|
+
if (schId) {
|
|
76
|
+
set(last30SchIdsRW, (oldIds) => oldIds.add(schId));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
export const updateSpecificMonthJobs = atom(null, (_, set, history) => {
|
|
81
|
+
set(specificMonthJobsRW, LazySeq.ofObject(history.jobs).toHashMap((x) => x));
|
|
82
|
+
});
|
|
83
|
+
export const last30JobComment = atomFamily((uniq) => atom((get) => get(last30Jobs).get(uniq)?.comment ?? null, (_, set, newVal) => {
|
|
84
|
+
const newComment = newVal === null ? "" : newVal;
|
|
85
|
+
set(last30JobsRW, (oldJobs) => {
|
|
86
|
+
const old = oldJobs.get(uniq);
|
|
87
|
+
if (old !== undefined) {
|
|
88
|
+
return oldJobs.set(uniq, { ...old, comment: newComment ?? undefined });
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
return oldJobs;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Atom } from "jotai";
|
|
2
|
+
import { IRecentHistoricData, ISimulatedDayUsage } from "../network/api";
|
|
3
|
+
import { ServerEventAndTime } from "./loading";
|
|
4
|
+
export type LatestSimDayUsage = {
|
|
5
|
+
readonly simId: string;
|
|
6
|
+
readonly usage: ReadonlyArray<Readonly<ISimulatedDayUsage>>;
|
|
7
|
+
};
|
|
8
|
+
export declare const latestSimDayUsage: Atom<LatestSimDayUsage | null>;
|
|
9
|
+
export declare const setLatestSimDayUsage: import("jotai").WritableAtom<null, [history: Readonly<IRecentHistoricData>], void> & {
|
|
10
|
+
init: null;
|
|
11
|
+
};
|
|
12
|
+
export declare const updateLatestSimDayUsage: import("jotai").WritableAtom<null, [ServerEventAndTime], void> & {
|
|
13
|
+
init: null;
|
|
14
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* Copyright (c) 2023, John Lenz
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
* Redistributions in binary form must reproduce the above
|
|
12
|
+
copyright notice, this list of conditions and the following
|
|
13
|
+
disclaimer in the documentation and/or other materials provided
|
|
14
|
+
with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of John Lenz, Black Maple Software, SeedTactics,
|
|
17
|
+
nor the names of other contributors may be used to endorse or
|
|
18
|
+
promote products derived from this software without specific
|
|
19
|
+
prior written permission.
|
|
20
|
+
|
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
22
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
24
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
25
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
26
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
27
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
28
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
29
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
30
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
31
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
32
|
+
*/
|
|
33
|
+
import { atom } from "jotai";
|
|
34
|
+
const latestUsageRW = atom(null);
|
|
35
|
+
export const latestSimDayUsage = latestUsageRW;
|
|
36
|
+
function update(get, set, schId, usage) {
|
|
37
|
+
const old = get(latestSimDayUsage);
|
|
38
|
+
if (old === null || old.simId < schId) {
|
|
39
|
+
set(latestUsageRW, { simId: schId, usage });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export const setLatestSimDayUsage = atom(null, (get, set, history) => {
|
|
43
|
+
if (!history.mostRecentSimulationId ||
|
|
44
|
+
!history.mostRecentSimDayUsage ||
|
|
45
|
+
history.mostRecentSimDayUsage.length === 0) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
update(get, set, history.mostRecentSimulationId, history.mostRecentSimDayUsage);
|
|
49
|
+
});
|
|
50
|
+
export const updateLatestSimDayUsage = atom(null, (get, set, { evt }) => {
|
|
51
|
+
if (evt.newJobs && evt.newJobs.simDayUsage && evt.newJobs.simDayUsage.length > 0) {
|
|
52
|
+
update(get, set, evt.newJobs.scheduleId, evt.newJobs.simDayUsage);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ServerEventAndTime } from "./loading.js";
|
|
2
|
+
import { IHistoricData } from "../network/api.js";
|
|
3
|
+
import { Atom } from "jotai";
|
|
4
|
+
export interface SimPartCompleted {
|
|
5
|
+
readonly partName: string;
|
|
6
|
+
readonly process: number;
|
|
7
|
+
readonly finalProcess: boolean;
|
|
8
|
+
readonly completeTime: Date;
|
|
9
|
+
readonly quantity: number;
|
|
10
|
+
readonly expectedMachineMins: number;
|
|
11
|
+
}
|
|
12
|
+
export declare const last30SimProduction: Atom<ReadonlyArray<SimPartCompleted>>;
|
|
13
|
+
export declare const specificMonthSimProduction: Atom<ReadonlyArray<SimPartCompleted>>;
|
|
14
|
+
export declare const setLast30JobProduction: import("jotai").WritableAtom<null, [history: Readonly<IHistoricData>], void> & {
|
|
15
|
+
init: null;
|
|
16
|
+
};
|
|
17
|
+
export declare const updateLast30JobProduction: import("jotai").WritableAtom<null, [ServerEventAndTime], void> & {
|
|
18
|
+
init: null;
|
|
19
|
+
};
|
|
20
|
+
export declare const setSpecificMonthJobProduction: import("jotai").WritableAtom<null, [history: Readonly<IHistoricData>], void> & {
|
|
21
|
+
init: null;
|
|
22
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/* Copyright (c) 2021, John Lenz
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
* Redistributions in binary form must reproduce the above
|
|
12
|
+
copyright notice, this list of conditions and the following
|
|
13
|
+
disclaimer in the documentation and/or other materials provided
|
|
14
|
+
with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of John Lenz, Black Maple Software, SeedTactics,
|
|
17
|
+
nor the names of other contributors may be used to endorse or
|
|
18
|
+
promote products derived from this software without specific
|
|
19
|
+
prior written permission.
|
|
20
|
+
|
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
22
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
24
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
25
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
26
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
27
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
28
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
29
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
30
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
31
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
32
|
+
*/
|
|
33
|
+
import { durationToMinutes } from "../util/parseISODuration.js";
|
|
34
|
+
import { LazySeq } from "@seedtactics/immutable-collections";
|
|
35
|
+
import { addDays } from "date-fns";
|
|
36
|
+
import { atom } from "jotai";
|
|
37
|
+
const last30SimProductionRW = atom([]);
|
|
38
|
+
export const last30SimProduction = last30SimProductionRW;
|
|
39
|
+
const specificMonthSimProductionRW = atom([]);
|
|
40
|
+
export const specificMonthSimProduction = specificMonthSimProductionRW;
|
|
41
|
+
function* jobToPartCompleted(jobs) {
|
|
42
|
+
for (const j of jobs) {
|
|
43
|
+
for (let proc = 0; proc < j.procsAndPaths.length; proc++) {
|
|
44
|
+
const procInfo = j.procsAndPaths[proc];
|
|
45
|
+
for (let path = 0; path < procInfo.paths.length; path++) {
|
|
46
|
+
const pathInfo = procInfo.paths[path];
|
|
47
|
+
// machTime is per cycle, and so is pathInfo.simulatedProduction
|
|
48
|
+
// so we are correctly yielding the expected machine time for the entire cycle
|
|
49
|
+
let machTime = 0;
|
|
50
|
+
for (const stop of pathInfo.stops) {
|
|
51
|
+
machTime += durationToMinutes(stop.expectedCycleTime);
|
|
52
|
+
}
|
|
53
|
+
let prevQty = 0;
|
|
54
|
+
for (const prod of pathInfo.simulatedProduction || []) {
|
|
55
|
+
yield {
|
|
56
|
+
partName: j.partName,
|
|
57
|
+
process: proc + 1,
|
|
58
|
+
finalProcess: proc === j.procsAndPaths.length - 1,
|
|
59
|
+
completeTime: prod.timeUTC,
|
|
60
|
+
quantity: prod.quantity - prevQty,
|
|
61
|
+
expectedMachineMins: machTime,
|
|
62
|
+
};
|
|
63
|
+
prevQty = prod.quantity;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export const setLast30JobProduction = atom(null, (_, set, history) => {
|
|
70
|
+
set(last30SimProductionRW, (oldProd) => [...oldProd, ...jobToPartCompleted(Object.values(history.jobs))]);
|
|
71
|
+
});
|
|
72
|
+
export const updateLast30JobProduction = atom(null, (_, set, { evt, now, expire }) => {
|
|
73
|
+
if (evt.newJobs) {
|
|
74
|
+
const apiNewJobs = evt.newJobs.jobs;
|
|
75
|
+
set(last30SimProductionRW, (simProd) => {
|
|
76
|
+
if (expire) {
|
|
77
|
+
const expire = addDays(now, -30);
|
|
78
|
+
// check if nothing to expire and no new data
|
|
79
|
+
const minProd = LazySeq.of(simProd).minBy((e) => e.completeTime.getTime());
|
|
80
|
+
if ((minProd === undefined || minProd.completeTime >= expire) && apiNewJobs.length === 0) {
|
|
81
|
+
return simProd;
|
|
82
|
+
}
|
|
83
|
+
simProd = simProd.filter((e) => e.completeTime >= expire);
|
|
84
|
+
}
|
|
85
|
+
return [...simProd, ...jobToPartCompleted(apiNewJobs)];
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
export const setSpecificMonthJobProduction = atom(null, (_, set, history) => {
|
|
90
|
+
set(specificMonthSimProductionRW, Array.from(jobToPartCompleted(Object.values(history.jobs))));
|
|
91
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ServerEventAndTime } from "./loading.js";
|
|
2
|
+
import { IHistoricData } from "../network/api.js";
|
|
3
|
+
import { Atom } from "jotai";
|
|
4
|
+
export interface SimStationUse {
|
|
5
|
+
readonly station: string;
|
|
6
|
+
readonly start: Date;
|
|
7
|
+
readonly end: Date;
|
|
8
|
+
readonly plannedDown: boolean;
|
|
9
|
+
readonly parts?: ReadonlyArray<{
|
|
10
|
+
readonly uniq: string;
|
|
11
|
+
readonly proc: number;
|
|
12
|
+
readonly path: number;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
export declare const last30SimStationUse: Atom<ReadonlyArray<SimStationUse>>;
|
|
16
|
+
export declare const specificMonthSimStationUse: Atom<ReadonlyArray<SimStationUse>>;
|
|
17
|
+
export declare const setLast30SimStatUse: import("jotai").WritableAtom<null, [history: Readonly<IHistoricData>], void> & {
|
|
18
|
+
init: null;
|
|
19
|
+
};
|
|
20
|
+
export declare const updateLast30SimStatUse: import("jotai").WritableAtom<null, [ServerEventAndTime], void> & {
|
|
21
|
+
init: null;
|
|
22
|
+
};
|
|
23
|
+
export declare const setSpecificMonthSimStatUse: import("jotai").WritableAtom<null, [history: Readonly<IHistoricData>], void> & {
|
|
24
|
+
init: null;
|
|
25
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* Copyright (c) 2021, John Lenz
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
* Redistributions in binary form must reproduce the above
|
|
12
|
+
copyright notice, this list of conditions and the following
|
|
13
|
+
disclaimer in the documentation and/or other materials provided
|
|
14
|
+
with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of John Lenz, Black Maple Software, SeedTactics,
|
|
17
|
+
nor the names of other contributors may be used to endorse or
|
|
18
|
+
promote products derived from this software without specific
|
|
19
|
+
prior written permission.
|
|
20
|
+
|
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
22
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
24
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
25
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
26
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
27
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
28
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
29
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
30
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
31
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
32
|
+
*/
|
|
33
|
+
import { LazySeq } from "@seedtactics/immutable-collections";
|
|
34
|
+
import { addDays } from "date-fns";
|
|
35
|
+
import { atom } from "jotai";
|
|
36
|
+
const last30SimStationUseRW = atom([]);
|
|
37
|
+
export const last30SimStationUse = last30SimStationUseRW;
|
|
38
|
+
const specificMonthSimStationUseRW = atom([]);
|
|
39
|
+
export const specificMonthSimStationUse = specificMonthSimStationUseRW;
|
|
40
|
+
function procSimUse(apiSimUse) {
|
|
41
|
+
return apiSimUse.map((simUse) => ({
|
|
42
|
+
station: simUse.stationGroup + " #" + simUse.stationNum.toString(),
|
|
43
|
+
start: simUse.startUTC,
|
|
44
|
+
end: simUse.endUTC,
|
|
45
|
+
plannedDown: simUse.planDown ?? false,
|
|
46
|
+
part: simUse.parts?.map((p) => ({ uniq: p.jobUnique, proc: p.process, path: p.path })),
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
export const setLast30SimStatUse = atom(null, (_, set, history) => {
|
|
50
|
+
set(last30SimStationUseRW, (oldSimUse) => oldSimUse.concat(procSimUse(history.stationUse)));
|
|
51
|
+
});
|
|
52
|
+
export const updateLast30SimStatUse = atom(null, (_, set, { evt, now, expire }) => {
|
|
53
|
+
if (evt.newJobs?.stationUse) {
|
|
54
|
+
const apiSimUse = evt.newJobs?.stationUse;
|
|
55
|
+
set(last30SimStationUseRW, (simUse) => {
|
|
56
|
+
if (expire) {
|
|
57
|
+
const expireT = addDays(now, -30);
|
|
58
|
+
// check if nothing to expire and no new data
|
|
59
|
+
const minStat = LazySeq.of(simUse).minBy((e) => e.end.getTime());
|
|
60
|
+
if ((minStat === undefined || minStat.start >= expireT) && apiSimUse.length === 0) {
|
|
61
|
+
return simUse;
|
|
62
|
+
}
|
|
63
|
+
simUse = simUse.filter((e) => e.start >= expireT);
|
|
64
|
+
}
|
|
65
|
+
return simUse.concat(procSimUse(apiSimUse));
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
export const setSpecificMonthSimStatUse = atom(null, (_, set, history) => {
|
|
70
|
+
set(specificMonthSimStationUseRW, procSimUse(history.stationUse));
|
|
71
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ILogEntry, ILogMaterial } from "../network/api.js";
|
|
2
|
+
import type { ServerEventAndTime } from "./loading.js";
|
|
3
|
+
import { HashMap } from "@seedtactics/immutable-collections";
|
|
4
|
+
import { Atom } from "jotai";
|
|
5
|
+
export interface PartCycleData {
|
|
6
|
+
readonly endTime: Date;
|
|
7
|
+
readonly elapsedMinsPerMaterial: number;
|
|
8
|
+
readonly cntr: number;
|
|
9
|
+
readonly part: string;
|
|
10
|
+
readonly stationGroup: string;
|
|
11
|
+
readonly stationNumber: number;
|
|
12
|
+
readonly operation: string;
|
|
13
|
+
readonly pallet: number;
|
|
14
|
+
readonly activeMinutes: number;
|
|
15
|
+
readonly isLabor: boolean;
|
|
16
|
+
readonly material: ReadonlyArray<Readonly<ILogMaterial>>;
|
|
17
|
+
readonly operator: string;
|
|
18
|
+
readonly medianCycleMinutes: number;
|
|
19
|
+
readonly MAD_aboveMinutes: number;
|
|
20
|
+
readonly isOutlier: boolean;
|
|
21
|
+
}
|
|
22
|
+
export type StationCyclesByCntr = HashMap<number, PartCycleData>;
|
|
23
|
+
export declare function stat_name_and_num(stationGroup: string, stationNumber: number): string;
|
|
24
|
+
export declare const last30StationCycles: Atom<StationCyclesByCntr>;
|
|
25
|
+
export declare const specificMonthStationCycles: Atom<StationCyclesByCntr>;
|
|
26
|
+
export declare const setLast30StationCycles: import("jotai").WritableAtom<null, [log: readonly Readonly<ILogEntry>[]], void> & {
|
|
27
|
+
init: null;
|
|
28
|
+
};
|
|
29
|
+
export declare const updateLast30StationCycles: import("jotai").WritableAtom<null, [ServerEventAndTime], void> & {
|
|
30
|
+
init: null;
|
|
31
|
+
};
|
|
32
|
+
export declare const setSpecificMonthStationCycles: import("jotai").WritableAtom<null, [log: readonly Readonly<ILogEntry>[]], void> & {
|
|
33
|
+
init: null;
|
|
34
|
+
};
|