busroot-sdk 0.0.8-dev.2804302832 → 0.0.8-dev.2804783613
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/build/index.js +24 -2
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -8518,6 +8518,7 @@ var require_schedules = __commonJS({
|
|
|
8518
8518
|
};
|
|
8519
8519
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
8520
8520
|
exports2.getActiveSchedulesForTimestamp = getActiveSchedulesForTimestamp;
|
|
8521
|
+
exports2.getActiveSchedulesForWindow = getActiveSchedulesForWindow;
|
|
8521
8522
|
exports2.calculateScheduleProgress = calculateScheduleProgress;
|
|
8522
8523
|
exports2.calculateEffectivePerformance = calculateEffectivePerformance;
|
|
8523
8524
|
exports2.calculateIdealEnd = calculateIdealEnd;
|
|
@@ -8541,6 +8542,27 @@ var require_schedules = __commonJS({
|
|
|
8541
8542
|
nextSchedule
|
|
8542
8543
|
};
|
|
8543
8544
|
}
|
|
8545
|
+
function getActiveSchedulesForWindow(schedules, windowStartTimestamp, windowEndTimestamp, now) {
|
|
8546
|
+
const overlapMs = (schedule) => {
|
|
8547
|
+
if (schedule.actualStartAtTimestamp == null) {
|
|
8548
|
+
return 0;
|
|
8549
|
+
}
|
|
8550
|
+
const start = Math.max(schedule.actualStartAtTimestamp, windowStartTimestamp);
|
|
8551
|
+
const end = Math.min(schedule.actualEndAtTimestamp || now + 1, windowEndTimestamp);
|
|
8552
|
+
return Math.max(0, end - start);
|
|
8553
|
+
};
|
|
8554
|
+
const activeSchedules = schedules.filter((schedule) => overlapMs(schedule) > 0).sort((a, b) => overlapMs(b) - overlapMs(a) || (b.actualStartAtTimestamp || 0) - (a.actualStartAtTimestamp || 0));
|
|
8555
|
+
const activeProductionSchedules = activeSchedules.filter((schedule) => schedule.skuCode != void 0);
|
|
8556
|
+
const activeNonProductionSchedules = activeSchedules.filter((schedule) => schedule.nonProductionReasonCode != void 0);
|
|
8557
|
+
const activeSchedule = activeNonProductionSchedules[0] || activeProductionSchedules[0];
|
|
8558
|
+
const nextSchedule = schedules.sort((a, b) => (a.plannedStartAtTimestamp || 0) - (b.plannedStartAtTimestamp || 0)).filter((a) => activeSchedule == null || a.id !== activeSchedule.id)[0];
|
|
8559
|
+
return {
|
|
8560
|
+
activeProductionSchedule: activeProductionSchedules[0],
|
|
8561
|
+
activeNonProductionSchedule: activeNonProductionSchedules[0],
|
|
8562
|
+
activeSchedule,
|
|
8563
|
+
nextSchedule
|
|
8564
|
+
};
|
|
8565
|
+
}
|
|
8544
8566
|
function calculateScheduleProgress(now, stations, schedules) {
|
|
8545
8567
|
return schedules.map((schedule) => {
|
|
8546
8568
|
const station = stations.find((station2) => station2.code === schedule.stationCode);
|
|
@@ -8666,7 +8688,7 @@ var require_schedules = __commonJS({
|
|
|
8666
8688
|
if (window2.shiftMs == null) {
|
|
8667
8689
|
throw new Error("Shift time must be already populated.");
|
|
8668
8690
|
}
|
|
8669
|
-
const { activeNonProductionSchedule, activeProductionSchedule } =
|
|
8691
|
+
const { activeNonProductionSchedule, activeProductionSchedule } = getActiveSchedulesForWindow(schedules, window2.windowStartAtTimestamp, window2.windowEndAtTimestamp, now || (0, moment_timezone_1.default)().valueOf());
|
|
8670
8692
|
const isInShift = window2.shiftMs > 0;
|
|
8671
8693
|
if (isInShift) {
|
|
8672
8694
|
const productionGoodCount = window2.productionGoodCount || 0;
|
|
@@ -8725,7 +8747,7 @@ var require_schedules = __commonJS({
|
|
|
8725
8747
|
unitsPerHour: station.unitsPerHour,
|
|
8726
8748
|
unitsPerMinute: station.unitsPerMinute
|
|
8727
8749
|
});
|
|
8728
|
-
window2.skuCode = isAnyProduction ? "unknown" : void 0;
|
|
8750
|
+
window2.skuCode = isAnyProduction ? window2.skuCode ?? "unknown" : void 0;
|
|
8729
8751
|
window2.workOrderReference = void 0;
|
|
8730
8752
|
window2.productionIdealCount = 0;
|
|
8731
8753
|
window2.productionTargetCount = 0;
|
package/package.json
CHANGED