@things-factory/ops-master 10.1.314 → 10.1.319
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-client/pages/master/electricity-tariff-band.d.ts +13 -0
- package/dist-client/pages/master/electricity-tariff-band.js +50 -0
- package/dist-client/pages/master/electricity-tariff.d.ts +10 -0
- package/dist-client/pages/master/electricity-tariff.js +41 -0
- package/dist-client/pages/master/master-options.d.ts +4 -0
- package/dist-client/pages/master/master-options.js +13 -0
- package/dist-client/pages/master/reference-targets.js +1 -0
- package/dist-client/pages/master-axes.d.ts +1 -1
- package/dist-client/pages/master-axes.js +3 -1
- package/dist-client/route.js +6 -0
- package/dist-server/service/energy/electricity-tariff-band.d.ts +54 -0
- package/dist-server/service/energy/electricity-tariff-band.js +141 -0
- package/dist-server/service/energy/electricity-tariff-resolver.d.ts +37 -0
- package/dist-server/service/energy/electricity-tariff-resolver.js +203 -0
- package/dist-server/service/energy/electricity-tariff.d.ts +57 -0
- package/dist-server/service/energy/electricity-tariff.js +127 -0
- package/dist-server/service/energy/index.d.ts +5 -0
- package/dist-server/service/energy/index.js +9 -0
- package/dist-server/service/energy/tariff-rules.d.ts +163 -0
- package/dist-server/service/energy/tariff-rules.js +395 -0
- package/dist-server/service/index.d.ts +6 -2
- package/dist-server/service/index.js +7 -0
- package/dist-server/service/location/shift-names-of-place.d.ts +35 -0
- package/dist-server/service/location/shift-names-of-place.js +53 -0
- package/dist-server/service/master-axis.js +8 -0
- package/dist-server/service/recipe/index.d.ts +1 -1
- package/dist-server/service/recipe/recipe-revision.d.ts +1 -1
- package/dist-server/service/status/master-status.js +5 -1
- package/helps/ops-master/electricity-tariff-band.ko.md +16 -0
- package/helps/ops-master/electricity-tariff-band.md +16 -0
- package/helps/ops-master/electricity-tariff.ko.md +16 -0
- package/helps/ops-master/electricity-tariff.md +16 -0
- package/package.json +5 -5
- package/translations/en.json +40 -1
- package/translations/es.json +40 -1
- package/translations/ja.json +40 -1
- package/translations/ko.json +40 -1
- package/translations/ms.json +40 -1
- package/translations/zh.json +40 -1
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* ── 임시 사본 (2026-11-27) ───────────────────────────────────────────────────
|
|
4
|
+
* 이 파일은 `@operato/ops-contract` 의 `src/tariff.ts` 를 **글자 그대로** 옮긴 것이다. 규칙의 주인은 계약이다 — 트윈이 구간 단가로
|
|
5
|
+
* 요금을 셀 때 ops-master 화면과 같은 답을 내야 하므로(ADR-0239 결정 7, 계약 세션과 합의).
|
|
6
|
+
* 계약 0.9.48 이 발행되면 **이 파일을 지우고** `@operato/ops-contract` 에서 가져온다. 그때까지 여기서 고치지 않는다 — 계약을 고친다.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* **Electricity tariff rules** — the words of a time-of-use tariff and how to read it.
|
|
10
|
+
*
|
|
11
|
+
* ── Why this is in the contract (2026-11-27) ────────────────────────────────────────────────────────────────────
|
|
12
|
+
* The tariff is site master data and is stored by ops-master (`ElectricityTariff` · `ElectricityTariffBand`). What
|
|
13
|
+
* lives here is the reading: which band applies at a moment, and whether a tariff's bands cover every day. Once the
|
|
14
|
+
* twin prices usage per band (the kernel's `electricityCost({ energyChargeFromPeriods })`), ops-master's screen and the
|
|
15
|
+
* twin must give the same answer for the same moment - a rule two implementations share belongs to the contract.
|
|
16
|
+
* Storage, approval and screens stay with ops-master.
|
|
17
|
+
*
|
|
18
|
+
* Field names are the declaration's (`EMS_DECLARATION` `tariff.*`): `demandChargePerKW`, `energyChargePerKWh`,
|
|
19
|
+
* `currency`. The contract power (`contract.kW`) and billing demand (`tariff.billingDemandKW`) are not tariff rows -
|
|
20
|
+
* one is a property of the supply point, the other a per-cycle fact from the supplier.
|
|
21
|
+
*
|
|
22
|
+
* ── Which price wins ────────────────────────────────────────────────────────────────────────────────────────────
|
|
23
|
+
* A source fact's own price (`EnergyUsagePeriodData.unitPrice`) is what was charged; it wins. A band price from the
|
|
24
|
+
* master is used only for a period whose fact carries no price. The master is a declaration, the fact an observation.
|
|
25
|
+
*
|
|
26
|
+
* ── Times are the site's wall clock ─────────────────────────────────────────────────────────────────────────────
|
|
27
|
+
* Bands are set in local time ("weekdays 09:00-10:00 are on-peak"). These functions do not know time zones: the
|
|
28
|
+
* caller converts an instant to the site's month, day, weekday and minute (`LocalMoment`). Cutting in UTC would make
|
|
29
|
+
* Seoul's 09:00 into 00:00.
|
|
30
|
+
*
|
|
31
|
+
* ── A band does not cross midnight ──────────────────────────────────────────────────────────────────────────────
|
|
32
|
+
* "22:00-08:00 off-peak" is written as two rows (22:00-24:00, 00:00-08:00). A single row would have to say which day
|
|
33
|
+
* it belongs to (does Saturday night run into Sunday morning?), and tariffs answer that differently.
|
|
34
|
+
*
|
|
35
|
+
* ── A new country is rows, not code (2026-11-27) ───────────────────────────────────────────────────────────────
|
|
36
|
+
* Tariff systems differ by country and supplier: how many bands and what they are called, whether a holiday is priced
|
|
37
|
+
* like Sunday, whether demand is charged per band, which days are holidays. A new country must be written as tariff,
|
|
38
|
+
* band and calendar rows - never as a change here, in the kernel or on a screen. So:
|
|
39
|
+
* · the band **code** is the tariff's own (`base` · `intermedia` · `punta`, `super-off-peak` …); only its
|
|
40
|
+
* **load class** - for comparing across tariffs - is a closed, ordered vocabulary (`TARIFF_LOAD_CLASSES`);
|
|
41
|
+
* · `sunday` and `holiday` are separate day kinds; a tariff pricing them alike writes two rows;
|
|
42
|
+
* · the tariff's `demandChargePerKW` is the facility demand charge (any time); a band may carry its own
|
|
43
|
+
* time-of-use `demandChargePerKW`;
|
|
44
|
+
* · the tariff names its holiday calendar (`holidayCalendar`); the calendar's days are not in the contract - the
|
|
45
|
+
* caller passes `isHoliday`.
|
|
46
|
+
* Season bounds are fixed `MM-DD`. A tariff whose season moves each year ("from the first Sunday of April") is written
|
|
47
|
+
* as one tariff per year with its effective dates - not yet seen to need more (to check against CFE tariffs).
|
|
48
|
+
*
|
|
49
|
+
* ── Issues are structured ───────────────────────────────────────────────────────────────────────────────────────
|
|
50
|
+
* Checks return `{ field, code, params }`, not sentences: a screen turns the code into its own language, and
|
|
51
|
+
* `tariffIssueText` gives the one-line English `field: reason` other contract checks use.
|
|
52
|
+
*/
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.TARIFF_ISSUE_CODES = exports.TARIFF_DAY_KINDS = exports.TARIFF_LOAD_CLASSES = void 0;
|
|
55
|
+
exports.tariffIssueText = tariffIssueText;
|
|
56
|
+
exports.isIso4217Code = isIso4217Code;
|
|
57
|
+
exports.minutesOf = minutesOf;
|
|
58
|
+
exports.dayOfYearOf = dayOfYearOf;
|
|
59
|
+
exports.tariffIssues = tariffIssues;
|
|
60
|
+
exports.tariffBandIssues = tariffBandIssues;
|
|
61
|
+
exports.activeBands = activeBands;
|
|
62
|
+
exports.tariffCoverageIssues = tariffCoverageIssues;
|
|
63
|
+
exports.bandAt = bandAt;
|
|
64
|
+
/**
|
|
65
|
+
* Load class of a band - **ordered from lightest to heaviest load**, for comparing bands across tariffs
|
|
66
|
+
* ("how much is shifted out of the heaviest hours"). The band's own code is the tariff's: Mexico's `base` ·
|
|
67
|
+
* `intermedia` · `punta` are classed `off-peak` · `mid-peak` · `on-peak`; a US `super-off-peak` band is that class.
|
|
68
|
+
*/
|
|
69
|
+
exports.TARIFF_LOAD_CLASSES = ['super-off-peak', 'off-peak', 'mid-peak', 'on-peak'];
|
|
70
|
+
/**
|
|
71
|
+
* Which days a band applies to. `all` ignores the day.
|
|
72
|
+
*
|
|
73
|
+
* `holiday` is a day of the tariff's holiday calendar (`holidayCalendar`) and **comes before the weekday**: a holiday
|
|
74
|
+
* falling on a Saturday is a holiday. A tariff that prices holidays like Sundays writes a `sunday` row and a `holiday`
|
|
75
|
+
* row. A tariff with no `holiday` row does not price holidays apart - its holidays are read as their weekday.
|
|
76
|
+
*/
|
|
77
|
+
exports.TARIFF_DAY_KINDS = ['all', 'weekday', 'saturday', 'sunday', 'holiday'];
|
|
78
|
+
/** The kinds a concrete day can be - every day is exactly one of these. */
|
|
79
|
+
const CONCRETE_DAY_KINDS = ['weekday', 'saturday', 'sunday', 'holiday'];
|
|
80
|
+
exports.TARIFF_ISSUE_CODES = [
|
|
81
|
+
/** A required field is empty. */
|
|
82
|
+
'required',
|
|
83
|
+
/** An amount is not a number. */
|
|
84
|
+
'not-a-number',
|
|
85
|
+
/** An amount is below zero. */
|
|
86
|
+
'negative',
|
|
87
|
+
/** A value is outside its vocabulary - `params.allowed`. */
|
|
88
|
+
'not-in-vocabulary',
|
|
89
|
+
/** A text is not in its format - `params.format`. */
|
|
90
|
+
'format',
|
|
91
|
+
/** An amount is written without a currency. */
|
|
92
|
+
'currency-required',
|
|
93
|
+
/** Season start and end must be written together or both left empty. */
|
|
94
|
+
'season-pair',
|
|
95
|
+
/** End time is not after the start - a band crossing midnight is two rows. */
|
|
96
|
+
'end-not-after-start',
|
|
97
|
+
/** The tariff has bands and a flat energy charge - which one prices an hour cannot be said. */
|
|
98
|
+
'flat-and-bands',
|
|
99
|
+
/** `params.count` bands break the row rules and were left out of the coverage check. */
|
|
100
|
+
'broken-bands',
|
|
101
|
+
/** No band covers `params.from`..`params.to` on `params.dayKind` days `params.days`. */
|
|
102
|
+
'gap',
|
|
103
|
+
/** Bands `params.bands` overlap `params.from`..`params.to` on `params.dayKind` days `params.days`. */
|
|
104
|
+
'overlap'
|
|
105
|
+
];
|
|
106
|
+
/** One English line, `field: reason` - the form other contract checks use. */
|
|
107
|
+
function tariffIssueText(issue) {
|
|
108
|
+
const p = issue.params ?? {};
|
|
109
|
+
switch (issue.code) {
|
|
110
|
+
case 'required':
|
|
111
|
+
return `${issue.field}: required${p.because ? ` (${p.because})` : ''}`;
|
|
112
|
+
case 'not-a-number':
|
|
113
|
+
return `${issue.field}: not a number (${p.value})`;
|
|
114
|
+
case 'negative':
|
|
115
|
+
return `${issue.field}: must be 0 or more (${p.value})`;
|
|
116
|
+
case 'not-in-vocabulary':
|
|
117
|
+
return `${issue.field}: must be one of ${p.allowed} ("${p.value}")`;
|
|
118
|
+
case 'format':
|
|
119
|
+
return `${issue.field}: must be ${p.format} ("${p.value}")`;
|
|
120
|
+
case 'currency-required':
|
|
121
|
+
return `${issue.field}: required when an amount is written`;
|
|
122
|
+
case 'season-pair':
|
|
123
|
+
return `${issue.field}: seasonFrom and seasonTo go together, or both empty for all year`;
|
|
124
|
+
case 'end-not-after-start':
|
|
125
|
+
return `${issue.field}: must be after fromTime (${p.from}~${p.to}); a band crossing midnight is two rows`;
|
|
126
|
+
case 'flat-and-bands':
|
|
127
|
+
return `${issue.field}: the tariff has bands - leave its flat charge empty`;
|
|
128
|
+
case 'broken-bands':
|
|
129
|
+
return `${issue.field}: ${p.count} band(s) break the row rules and were left out`;
|
|
130
|
+
case 'gap':
|
|
131
|
+
return `${issue.field}: ${p.dayKind} ${p.days} - no band ${p.from}~${p.to}`;
|
|
132
|
+
case 'overlap':
|
|
133
|
+
return `${issue.field}: ${p.dayKind} ${p.days} - ${p.bands} overlap ${p.from}~${p.to}`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const empty = (v) => v === undefined || v === null || (typeof v === 'string' && v.trim() === '');
|
|
137
|
+
/** An ISO 4217 code - three upper-case letters (KRW, USD). */
|
|
138
|
+
function isIso4217Code(value) {
|
|
139
|
+
return typeof value === 'string' && /^[A-Z]{3}$/.test(value);
|
|
140
|
+
}
|
|
141
|
+
/** An amount field - empty gives `undefined`; not a number or below zero is an issue. */
|
|
142
|
+
function amountOf(v, field, issues) {
|
|
143
|
+
if (empty(v))
|
|
144
|
+
return undefined;
|
|
145
|
+
const n = Number(v);
|
|
146
|
+
if (!Number.isFinite(n)) {
|
|
147
|
+
issues.push({ field, code: 'not-a-number', params: { value: String(v) } });
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
if (n < 0) {
|
|
151
|
+
issues.push({ field, code: 'negative', params: { value: n } });
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
return n;
|
|
155
|
+
}
|
|
156
|
+
/** `HH:mm` → minutes from midnight. `24:00` is 1440 and is only an end. */
|
|
157
|
+
function minutesOf(text) {
|
|
158
|
+
const m = /^(\d{2}):(\d{2})$/.exec(String(text ?? '').trim());
|
|
159
|
+
if (!m)
|
|
160
|
+
return undefined;
|
|
161
|
+
const h = Number(m[1]);
|
|
162
|
+
const min = Number(m[2]);
|
|
163
|
+
if (min > 59)
|
|
164
|
+
return undefined;
|
|
165
|
+
if (h === 24 && min === 0)
|
|
166
|
+
return 1440;
|
|
167
|
+
if (h > 23)
|
|
168
|
+
return undefined;
|
|
169
|
+
return h * 60 + min;
|
|
170
|
+
}
|
|
171
|
+
const DAYS_IN_MONTH = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
172
|
+
/** `MM-DD` → day of a leap year (0..365). Takes 02-29 - that day too must fall in some season. */
|
|
173
|
+
function dayOfYearOf(text) {
|
|
174
|
+
const m = /^(\d{2})-(\d{2})$/.exec(String(text ?? '').trim());
|
|
175
|
+
if (!m)
|
|
176
|
+
return undefined;
|
|
177
|
+
const month = Number(m[1]);
|
|
178
|
+
const day = Number(m[2]);
|
|
179
|
+
if (month < 1 || month > 12 || day < 1 || day > DAYS_IN_MONTH[month - 1])
|
|
180
|
+
return undefined;
|
|
181
|
+
let n = 0;
|
|
182
|
+
for (let i = 0; i < month - 1; i++)
|
|
183
|
+
n += DAYS_IN_MONTH[i];
|
|
184
|
+
return n + day - 1;
|
|
185
|
+
}
|
|
186
|
+
/** One tariff row, before it is saved. Empty when it is sound. */
|
|
187
|
+
function tariffIssues(row) {
|
|
188
|
+
const issues = [];
|
|
189
|
+
const d = amountOf(row.demandChargePerKW, 'demandChargePerKW', issues);
|
|
190
|
+
const e = amountOf(row.energyChargePerKWh, 'energyChargePerKWh', issues);
|
|
191
|
+
const currency = String(row.currency ?? '').trim();
|
|
192
|
+
/* An amount without a unit cannot be added to another amount - the same rule as the energy ingest. */
|
|
193
|
+
if ((d !== undefined || e !== undefined) && !currency)
|
|
194
|
+
issues.push({ field: 'currency', code: 'currency-required' });
|
|
195
|
+
if (currency && !isIso4217Code(currency))
|
|
196
|
+
issues.push({ field: 'currency', code: 'format', params: { format: 'ISO 4217 (KRW, USD)', value: currency } });
|
|
197
|
+
return issues;
|
|
198
|
+
}
|
|
199
|
+
/** One band row, before it is saved. Whether bands cover the day cannot be seen from one row - `tariffCoverageIssues`. */
|
|
200
|
+
function tariffBandIssues(row) {
|
|
201
|
+
const issues = [];
|
|
202
|
+
if (empty(row.tariffName))
|
|
203
|
+
issues.push({ field: 'tariffName', code: 'required' });
|
|
204
|
+
if (empty(row.band))
|
|
205
|
+
issues.push({ field: 'band', code: 'required' });
|
|
206
|
+
const loadClass = String(row.loadClass ?? '').trim();
|
|
207
|
+
if (!loadClass)
|
|
208
|
+
issues.push({ field: 'loadClass', code: 'required' });
|
|
209
|
+
else if (!exports.TARIFF_LOAD_CLASSES.includes(loadClass)) {
|
|
210
|
+
issues.push({ field: 'loadClass', code: 'not-in-vocabulary', params: { allowed: exports.TARIFF_LOAD_CLASSES.join('|'), value: loadClass } });
|
|
211
|
+
}
|
|
212
|
+
const dayKind = empty(row.dayKind) ? 'all' : String(row.dayKind).trim();
|
|
213
|
+
if (!exports.TARIFF_DAY_KINDS.includes(dayKind)) {
|
|
214
|
+
issues.push({ field: 'dayKind', code: 'not-in-vocabulary', params: { allowed: exports.TARIFF_DAY_KINDS.join('|'), value: dayKind } });
|
|
215
|
+
}
|
|
216
|
+
const sFromEmpty = empty(row.seasonFrom);
|
|
217
|
+
const sToEmpty = empty(row.seasonTo);
|
|
218
|
+
if (sFromEmpty !== sToEmpty)
|
|
219
|
+
issues.push({ field: sFromEmpty ? 'seasonFrom' : 'seasonTo', code: 'season-pair' });
|
|
220
|
+
if (!sFromEmpty && dayOfYearOf(row.seasonFrom) === undefined)
|
|
221
|
+
issues.push({ field: 'seasonFrom', code: 'format', params: { format: 'MM-DD', value: String(row.seasonFrom) } });
|
|
222
|
+
if (!sToEmpty && dayOfYearOf(row.seasonTo) === undefined)
|
|
223
|
+
issues.push({ field: 'seasonTo', code: 'format', params: { format: 'MM-DD', value: String(row.seasonTo) } });
|
|
224
|
+
const from = minutesOf(row.fromTime);
|
|
225
|
+
const to = minutesOf(row.toTime);
|
|
226
|
+
if (from === undefined || from === 1440)
|
|
227
|
+
issues.push({ field: 'fromTime', code: 'format', params: { format: 'HH:mm 00:00..23:59', value: String(row.fromTime ?? '') } });
|
|
228
|
+
if (to === undefined || to === 0)
|
|
229
|
+
issues.push({ field: 'toTime', code: 'format', params: { format: 'HH:mm 00:01..24:00', value: String(row.toTime ?? '') } });
|
|
230
|
+
if (from !== undefined && to !== undefined && from < 1440 && to > 0 && from >= to) {
|
|
231
|
+
issues.push({ field: 'toTime', code: 'end-not-after-start', params: { from: String(row.fromTime), to: String(row.toTime) } });
|
|
232
|
+
}
|
|
233
|
+
/* A band without a price cannot price its hours. */
|
|
234
|
+
if (empty(row.energyChargePerKWh))
|
|
235
|
+
issues.push({ field: 'energyChargePerKWh', code: 'required' });
|
|
236
|
+
else
|
|
237
|
+
amountOf(row.energyChargePerKWh, 'energyChargePerKWh', issues);
|
|
238
|
+
amountOf(row.demandChargePerKW, 'demandChargePerKW', issues);
|
|
239
|
+
return issues;
|
|
240
|
+
}
|
|
241
|
+
/** Whether a season holds that day - takes a season wrapping the year. An empty season is all year. */
|
|
242
|
+
function seasonHas(band, dayOfYear) {
|
|
243
|
+
if (empty(band.seasonFrom) && empty(band.seasonTo))
|
|
244
|
+
return true;
|
|
245
|
+
const from = dayOfYearOf(band.seasonFrom);
|
|
246
|
+
const to = dayOfYearOf(band.seasonTo);
|
|
247
|
+
if (from === undefined || to === undefined)
|
|
248
|
+
return false;
|
|
249
|
+
return from <= to ? dayOfYear >= from && dayOfYear <= to : dayOfYear >= from || dayOfYear <= to;
|
|
250
|
+
}
|
|
251
|
+
/** Whether a tariff prices holidays apart - some band names the `holiday` day kind. */
|
|
252
|
+
function pricesHolidays(bands) {
|
|
253
|
+
return bands.some(b => String(b.dayKind ?? '').trim() === 'holiday');
|
|
254
|
+
}
|
|
255
|
+
/** The kind of a concrete day. A holiday comes before the weekday, but only for a tariff that prices holidays apart. */
|
|
256
|
+
function dayKindOf(at, holidays, isHoliday) {
|
|
257
|
+
if (holidays && isHoliday?.(at.month, at.day))
|
|
258
|
+
return 'holiday';
|
|
259
|
+
return at.weekday === 0 ? 'sunday' : at.weekday === 6 ? 'saturday' : 'weekday';
|
|
260
|
+
}
|
|
261
|
+
function dayKindHas(band, kind) {
|
|
262
|
+
const k = empty(band.dayKind) ? 'all' : String(band.dayKind).trim();
|
|
263
|
+
return k === 'all' || k === kind;
|
|
264
|
+
}
|
|
265
|
+
/** Bands still in force at `at` - a band whose end has passed was retired (rows are ended, not deleted). */
|
|
266
|
+
function activeBands(bands, at) {
|
|
267
|
+
return bands.filter(b => empty(b.effectiveEnd) || new Date(b.effectiveEnd).getTime() > at.getTime());
|
|
268
|
+
}
|
|
269
|
+
const hhmm = (m) => `${String(Math.floor(m / 60)).padStart(2, '0')}:${String(m % 60).padStart(2, '0')}`;
|
|
270
|
+
function mmdd(dayOfYear) {
|
|
271
|
+
let month = 0;
|
|
272
|
+
let rest = dayOfYear;
|
|
273
|
+
while (rest >= DAYS_IN_MONTH[month])
|
|
274
|
+
rest -= DAYS_IN_MONTH[month++];
|
|
275
|
+
return `${String(month + 1).padStart(2, '0')}-${String(rest + 1).padStart(2, '0')}`;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Whether one tariff's bands cover **every minute of every day, once**.
|
|
279
|
+
*
|
|
280
|
+
* Looks at all 366 days of a leap year × the concrete day kinds (weekday, saturday, sunday, and holiday when the tariff
|
|
281
|
+
* prices holidays apart). An uncovered hour cannot be priced; an hour
|
|
282
|
+
* covered twice has two prices - either way its charge would be invented. The same problem over consecutive days is
|
|
283
|
+
* one issue (`params.days` like `06-01~08-31`).
|
|
284
|
+
*
|
|
285
|
+
* No bands is not an issue - it is a flat tariff (the tariff row's `energyChargePerKWh`). A tariff passes through
|
|
286
|
+
* wrong states while it is edited, so a screen shows this rather than refusing to save.
|
|
287
|
+
*/
|
|
288
|
+
function tariffCoverageIssues(tariff, bands) {
|
|
289
|
+
const issues = [];
|
|
290
|
+
if (!bands.length)
|
|
291
|
+
return issues;
|
|
292
|
+
const usable = bands.filter(b => tariffBandIssues(b).length === 0);
|
|
293
|
+
if (!empty(tariff.energyChargePerKWh))
|
|
294
|
+
issues.push({ field: 'energyChargePerKWh', code: 'flat-and-bands' });
|
|
295
|
+
/* Band prices are in the tariff's currency - a band amount without one cannot be added to anything. */
|
|
296
|
+
if (!String(tariff.currency ?? '').trim())
|
|
297
|
+
issues.push({ field: 'currency', code: 'currency-required' });
|
|
298
|
+
const holidays = pricesHolidays(usable);
|
|
299
|
+
if (holidays && empty(tariff.holidayCalendar)) {
|
|
300
|
+
issues.push({ field: 'holidayCalendar', code: 'required', params: { because: 'the tariff has holiday bands' } });
|
|
301
|
+
}
|
|
302
|
+
const broken = bands.length - usable.length;
|
|
303
|
+
if (broken)
|
|
304
|
+
issues.push({ field: 'bands', code: 'broken-bands', params: { count: broken } });
|
|
305
|
+
/* (day kind, problem) → the days it happened, in order */
|
|
306
|
+
const seen = new Map();
|
|
307
|
+
const note = (kind, day, code, from, to, names) => {
|
|
308
|
+
const key = [kind, code, from, to, names ?? ''].join('\u0000');
|
|
309
|
+
const entry = seen.get(key);
|
|
310
|
+
if (entry)
|
|
311
|
+
entry.days.push(day);
|
|
312
|
+
else {
|
|
313
|
+
const params = { dayKind: kind, from: hhmm(from), to: hhmm(to) };
|
|
314
|
+
if (names)
|
|
315
|
+
params.bands = names;
|
|
316
|
+
seen.set(key, { problem: { field: 'bands', code, params }, days: [day] });
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
/* A tariff that does not price holidays apart has no holiday to cover - its holidays are their weekdays. */
|
|
320
|
+
for (const kind of CONCRETE_DAY_KINDS.filter(k => k !== 'holiday' || holidays)) {
|
|
321
|
+
for (let day = 0; day < 366; day++) {
|
|
322
|
+
const today = usable
|
|
323
|
+
.filter(b => seasonHas(b, day) && dayKindHas(b, kind))
|
|
324
|
+
.map(b => ({ name: String(b.name ?? ''), from: minutesOf(b.fromTime), to: minutesOf(b.toTime) }))
|
|
325
|
+
.sort((a, b) => a.from - b.from || a.to - b.to);
|
|
326
|
+
let cursor = 0;
|
|
327
|
+
let last;
|
|
328
|
+
for (const b of today) {
|
|
329
|
+
if (b.from > cursor)
|
|
330
|
+
note(kind, day, 'gap', cursor, b.from);
|
|
331
|
+
if (last && b.from < last.to)
|
|
332
|
+
note(kind, day, 'overlap', b.from, Math.min(last.to, b.to), `${last.name}·${b.name}`);
|
|
333
|
+
if (b.to > cursor) {
|
|
334
|
+
cursor = b.to;
|
|
335
|
+
last = b;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (cursor < 1440)
|
|
339
|
+
note(kind, day, 'gap', cursor, 1440);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
for (const { problem, days } of seen.values()) {
|
|
343
|
+
const spans = [];
|
|
344
|
+
let start = days[0];
|
|
345
|
+
let prev = days[0];
|
|
346
|
+
for (const d of [...days.slice(1), Infinity]) {
|
|
347
|
+
if (d === prev + 1) {
|
|
348
|
+
prev = d;
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
spans.push(start === prev ? mmdd(start) : `${mmdd(start)}~${mmdd(prev)}`);
|
|
352
|
+
start = prev = d;
|
|
353
|
+
}
|
|
354
|
+
issues.push({ ...problem, params: { ...problem.params, days: spans.join(', ') } });
|
|
355
|
+
}
|
|
356
|
+
return issues;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* The energy charge at this moment.
|
|
360
|
+
*
|
|
361
|
+
* Without bands the tariff's flat charge applies. With bands **exactly one** must match - none is `no-band`, more than
|
|
362
|
+
* one is `ambiguous`, and no price is picked (taking the first written would be chance).
|
|
363
|
+
*/
|
|
364
|
+
function bandAt(tariff, bands, at, isHoliday) {
|
|
365
|
+
const currency = String(tariff.currency ?? '').trim() || undefined;
|
|
366
|
+
const usable = bands.filter(b => tariffBandIssues(b).length === 0);
|
|
367
|
+
if (!usable.length) {
|
|
368
|
+
const flat = empty(tariff.energyChargePerKWh) ? NaN : Number(tariff.energyChargePerKWh);
|
|
369
|
+
if (!Number.isFinite(flat))
|
|
370
|
+
return { reason: 'no-price' };
|
|
371
|
+
return { energyChargePerKWh: flat, ...(currency ? { currency } : {}), holidayKnown: true };
|
|
372
|
+
}
|
|
373
|
+
const day = dayOfYearOf(`${String(at.month).padStart(2, '0')}-${String(at.day).padStart(2, '0')}`);
|
|
374
|
+
if (day === undefined)
|
|
375
|
+
return { reason: 'no-band' };
|
|
376
|
+
const holidays = pricesHolidays(usable);
|
|
377
|
+
const kind = dayKindOf(at, holidays, isHoliday);
|
|
378
|
+
const hits = usable.filter(b => seasonHas(b, day) && dayKindHas(b, kind) && minutesOf(b.fromTime) <= at.minutes && at.minutes < minutesOf(b.toTime));
|
|
379
|
+
if (!hits.length)
|
|
380
|
+
return { reason: 'no-band' };
|
|
381
|
+
if (hits.length > 1)
|
|
382
|
+
return { reason: 'ambiguous', bands: hits.map(b => String(b.name ?? '')) };
|
|
383
|
+
const hit = hits[0];
|
|
384
|
+
const demand = empty(hit.demandChargePerKW) ? undefined : Number(hit.demandChargePerKW);
|
|
385
|
+
return {
|
|
386
|
+
bandName: String(hit.name ?? '') || undefined,
|
|
387
|
+
band: String(hit.band).trim(),
|
|
388
|
+
loadClass: String(hit.loadClass).trim(),
|
|
389
|
+
energyChargePerKWh: Number(hit.energyChargePerKWh),
|
|
390
|
+
...(demand !== undefined ? { demandChargePerKW: demand } : {}),
|
|
391
|
+
...(currency ? { currency } : {}),
|
|
392
|
+
holidayKnown: !holidays || !!isHoliday
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
//# sourceMappingURL=tariff-rules.js.map
|
|
@@ -37,6 +37,7 @@ export * from './location/location-master';
|
|
|
37
37
|
export * from './location/location-query';
|
|
38
38
|
export * from './location/sites-of-system';
|
|
39
39
|
export * from './location/zone-of-place';
|
|
40
|
+
export * from './location/shift-names-of-place';
|
|
40
41
|
export * from './location/zone-of-home-place';
|
|
41
42
|
export * from './material/material-class';
|
|
42
43
|
export * from './material/material-definition';
|
|
@@ -71,14 +72,17 @@ export * from './test-spec/test-spec-query';
|
|
|
71
72
|
export * from './status/axis-stamp';
|
|
72
73
|
export * from './status/master-status';
|
|
73
74
|
export * from './quality/nonconformance-cause';
|
|
75
|
+
export * from './energy/electricity-tariff';
|
|
76
|
+
export * from './energy/electricity-tariff-band';
|
|
77
|
+
export * from './energy/tariff-rules';
|
|
74
78
|
import { MasterConformanceResolver } from './master-conformance-resolver';
|
|
75
79
|
import { MasterChangePolicy, MasterChangePolicyResolver } from './master-change-policy';
|
|
76
80
|
import { MasterValueClaim } from './assignment/master-value-claim';
|
|
77
81
|
import { SiteOfSystemSubscriber } from './location/sites-of-system';
|
|
78
82
|
export declare const subscribers: (typeof SiteOfSystemSubscriber)[];
|
|
79
|
-
export declare const entities: (typeof import("./equipment/equipment").Equipment | typeof import("./equipment/equipment-class").EquipmentClass | typeof import("./quality/nonconformance-cause").NonconformanceCause | typeof import("./material/material-definition").MaterialDefinition | typeof import("./operation/operation-definition").OperationDefinition | typeof import("./location/operational-location").OperationalLocation | typeof import("./personnel/person").Person | typeof import("./asset/physical-asset").PhysicalAsset | typeof import("./recipe").RecipeDefinition | typeof import("./recipe").RouteDefinition | typeof import("./test-spec/test-specification").TestSpecification | typeof MasterChangePolicy | typeof import("./material/material-revision").MaterialDefinitionRevision | typeof import("./material/material-revision").MaterialDefinitionPlan | typeof import("./material/material-revision").MaterialDefinitionSegment | typeof import("./material/material-revision").MaterialDefinitionBasis | typeof import("./recipe/recipe-revision").RecipeRevision | typeof import("./recipe/recipe-revision").
|
|
83
|
+
export declare const entities: (typeof import("./equipment/equipment").Equipment | typeof import("./equipment/equipment-class").EquipmentClass | typeof import("./quality/nonconformance-cause").NonconformanceCause | typeof import("./energy/electricity-tariff").ElectricityTariff | typeof import("./energy/electricity-tariff-band").ElectricityTariffBand | typeof import("./material/material-definition").MaterialDefinition | typeof import("./operation/operation-definition").OperationDefinition | typeof import("./location/operational-location").OperationalLocation | typeof import("./personnel/person").Person | typeof import("./asset/physical-asset").PhysicalAsset | typeof import("./recipe").RecipeDefinition | typeof import("./recipe").RouteDefinition | typeof import("./test-spec/test-specification").TestSpecification | typeof MasterChangePolicy | typeof import("./material/material-revision").MaterialDefinitionRevision | typeof import("./material/material-revision").MaterialDefinitionPlan | typeof import("./material/material-revision").MaterialDefinitionSegment | typeof import("./material/material-revision").MaterialDefinitionBasis | typeof import("./recipe/recipe-revision").RecipeRevision | typeof import("./recipe/recipe-revision-line").RecipeRevisionOutput | typeof import("./recipe/recipe-revision").RecipePlan | typeof import("./recipe/recipe-revision").RecipeSegment | typeof import("./recipe/recipe-revision").RecipeBasis | typeof import("./test-spec/test-spec-revision").TestSpecificationRevision | typeof import("./test-spec/test-spec-revision").TestSpecificationPlan | typeof import("./test-spec/test-spec-revision").TestSpecificationSegment | typeof import("./test-spec/test-spec-revision").TestSpecificationBasis | typeof MasterValueClaim)[];
|
|
80
84
|
export declare const schema: {
|
|
81
|
-
resolverClasses: (typeof MasterChangePolicyResolver | typeof import("./personnel/personnel-master-resolver").PersonnelClassResolver | typeof import("./personnel/personnel-master-resolver").PersonResolver | typeof import("./equipment/equipment-master-resolver").EquipmentClassResolver | typeof import("./equipment/equipment-master-resolver").EquipmentResolver | typeof import("./equipment/equipment-master-resolver").StopReasonResolver | typeof import("./asset/asset-master-resolver").PhysicalAssetClassResolver | typeof import("./asset/asset-master-resolver").PhysicalAssetResolver | typeof import("./material/material-master-resolver").MaterialClassResolver | typeof import("./material/material-master-resolver").MaterialDefinitionResolver | typeof import("./location/location-master-resolver").OperationalLocationResolver | typeof import("./operation/operation-master-resolver").OperationDefinitionResolver | typeof import("./recipe/recipe-master-resolver").RecipeDefinitionResolver | typeof import("./recipe/recipe-master-resolver").RouteDefinitionResolver | typeof import("./test-spec/test-spec-master-resolver").TestSpecificationResolver | typeof import("./master-change-approval").MasterChangeApprovalResolver | typeof MasterConformanceResolver | typeof import("./personnel/personnel-query").PersonnelQuery | typeof import("./equipment/equipment-query").EquipmentQuery | typeof import("./asset/asset-query").AssetQuery | typeof import("./location/location-query").LocationQuery | typeof import("./material/material-revision-resolver").MaterialDefinitionRevisionResolver | typeof import("./material/material-query").MaterialQuery | typeof import("./operation/operation-query").OperationQuery | typeof import("./operation/operation-readiness-resolver").OperationReadinessResolver | typeof import("./recipe/recipe-revision-resolver").RecipeRevisionResolver | typeof import("./recipe/recipe-query").RecipeQuery | typeof import("./test-spec/test-spec-revision-resolver").TestSpecificationRevisionResolver | typeof import("./test-spec/test-spec-query").TestSpecificationQuery | typeof import("./status/master-status").OpsMasterStatusQuery | typeof import("./equipment/stop-reason-query").StopReasonQuery | typeof import("./quality/nonconformance-cause-resolver").NonconformanceCauseResolver)[];
|
|
85
|
+
resolverClasses: (typeof MasterChangePolicyResolver | typeof import("./personnel/personnel-master-resolver").PersonnelClassResolver | typeof import("./personnel/personnel-master-resolver").PersonResolver | typeof import("./equipment/equipment-master-resolver").EquipmentClassResolver | typeof import("./equipment/equipment-master-resolver").EquipmentResolver | typeof import("./equipment/equipment-master-resolver").StopReasonResolver | typeof import("./asset/asset-master-resolver").PhysicalAssetClassResolver | typeof import("./asset/asset-master-resolver").PhysicalAssetResolver | typeof import("./material/material-master-resolver").MaterialClassResolver | typeof import("./material/material-master-resolver").MaterialDefinitionResolver | typeof import("./location/location-master-resolver").OperationalLocationResolver | typeof import("./operation/operation-master-resolver").OperationDefinitionResolver | typeof import("./recipe/recipe-master-resolver").RecipeDefinitionResolver | typeof import("./recipe/recipe-master-resolver").RouteDefinitionResolver | typeof import("./test-spec/test-spec-master-resolver").TestSpecificationResolver | typeof import("./master-change-approval").MasterChangeApprovalResolver | typeof MasterConformanceResolver | typeof import("./personnel/personnel-query").PersonnelQuery | typeof import("./equipment/equipment-query").EquipmentQuery | typeof import("./asset/asset-query").AssetQuery | typeof import("./location/location-query").LocationQuery | typeof import("./material/material-revision-resolver").MaterialDefinitionRevisionResolver | typeof import("./material/material-query").MaterialQuery | typeof import("./operation/operation-query").OperationQuery | typeof import("./operation/operation-readiness-resolver").OperationReadinessResolver | typeof import("./recipe/recipe-revision-resolver").RecipeRevisionResolver | typeof import("./recipe/recipe-query").RecipeQuery | typeof import("./test-spec/test-spec-revision-resolver").TestSpecificationRevisionResolver | typeof import("./test-spec/test-spec-query").TestSpecificationQuery | typeof import("./status/master-status").OpsMasterStatusQuery | typeof import("./equipment/stop-reason-query").StopReasonQuery | typeof import("./quality/nonconformance-cause-resolver").NonconformanceCauseResolver | typeof import("./energy/electricity-tariff-resolver").ElectricityTariffResolver)[];
|
|
82
86
|
};
|
|
83
87
|
export * from './assignment/master-value-claim';
|
|
84
88
|
export * from './assignment/assignment-history';
|
|
@@ -42,6 +42,7 @@ tslib_1.__exportStar(require("./location/location-master"), exports);
|
|
|
42
42
|
tslib_1.__exportStar(require("./location/location-query"), exports);
|
|
43
43
|
tslib_1.__exportStar(require("./location/sites-of-system"), exports);
|
|
44
44
|
tslib_1.__exportStar(require("./location/zone-of-place"), exports);
|
|
45
|
+
tslib_1.__exportStar(require("./location/shift-names-of-place"), exports);
|
|
45
46
|
tslib_1.__exportStar(require("./location/zone-of-home-place"), exports);
|
|
46
47
|
tslib_1.__exportStar(require("./material/material-class"), exports);
|
|
47
48
|
tslib_1.__exportStar(require("./material/material-definition"), exports);
|
|
@@ -76,6 +77,9 @@ tslib_1.__exportStar(require("./test-spec/test-spec-query"), exports);
|
|
|
76
77
|
tslib_1.__exportStar(require("./status/axis-stamp"), exports);
|
|
77
78
|
tslib_1.__exportStar(require("./status/master-status"), exports);
|
|
78
79
|
tslib_1.__exportStar(require("./quality/nonconformance-cause"), exports);
|
|
80
|
+
tslib_1.__exportStar(require("./energy/electricity-tariff"), exports);
|
|
81
|
+
tslib_1.__exportStar(require("./energy/electricity-tariff-band"), exports);
|
|
82
|
+
tslib_1.__exportStar(require("./energy/tariff-rules"), exports);
|
|
79
83
|
/* IMPORT ENTITIES AND RESOLVERS */
|
|
80
84
|
const asset_1 = require("./asset");
|
|
81
85
|
const equipment_1 = require("./equipment");
|
|
@@ -84,6 +88,7 @@ const material_1 = require("./material");
|
|
|
84
88
|
const operation_1 = require("./operation");
|
|
85
89
|
const personnel_1 = require("./personnel");
|
|
86
90
|
const quality_1 = require("./quality");
|
|
91
|
+
const energy_1 = require("./energy");
|
|
87
92
|
/* 라우팅·레시피 — 품목→지시서를 이으려면 그 사이에 이 둘이 있어야 한다(§`recipe-definition.ts`). */
|
|
88
93
|
const recipe_1 = require("./recipe");
|
|
89
94
|
const status_1 = require("./status");
|
|
@@ -106,6 +111,7 @@ exports.entities = [
|
|
|
106
111
|
master_value_claim_1.MasterValueClaim,
|
|
107
112
|
...personnel_1.entities,
|
|
108
113
|
...quality_1.entities,
|
|
114
|
+
...energy_1.entities,
|
|
109
115
|
...equipment_1.entities,
|
|
110
116
|
...asset_1.entities,
|
|
111
117
|
...location_1.entities,
|
|
@@ -121,6 +127,7 @@ exports.schema = {
|
|
|
121
127
|
...master_change_approval_1.resolvers,
|
|
122
128
|
...personnel_1.resolvers,
|
|
123
129
|
...quality_1.resolvers,
|
|
130
|
+
...energy_1.resolvers,
|
|
124
131
|
...equipment_1.resolvers,
|
|
125
132
|
...asset_1.resolvers,
|
|
126
133
|
...location_1.resolvers,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** The columns the walk reads - a place's name, its row id, its parent, the work shifts it declares and when it was in service. */
|
|
2
|
+
export interface ShiftPlaceRow {
|
|
3
|
+
/** The row id - a child may name its parent by it (`parentId` holds a row id in some sites and a name in others). */
|
|
4
|
+
id?: string;
|
|
5
|
+
name: string;
|
|
6
|
+
parentId?: string | null;
|
|
7
|
+
workShiftNames?: string[] | null;
|
|
8
|
+
effectiveStart?: Date | string | null;
|
|
9
|
+
effectiveEnd?: Date | string | null;
|
|
10
|
+
}
|
|
11
|
+
export interface PlaceShifts {
|
|
12
|
+
/** The places walked, from the start up to and including the one it stopped at. */
|
|
13
|
+
walked: string[];
|
|
14
|
+
/** The place that declares the shifts - the start itself or its nearest ancestor that names any. */
|
|
15
|
+
declaredAt?: ShiftPlaceRow;
|
|
16
|
+
/** The shift names that place declares, each once. */
|
|
17
|
+
shiftNames?: string[];
|
|
18
|
+
/** The walk met a place not in service at the time asked, and stopped there - it does not skip to the grandparent. */
|
|
19
|
+
notInService?: ShiftPlaceRow;
|
|
20
|
+
}
|
|
21
|
+
/** In service at `atMs` - the start is inclusive, the end is not (a place retired at T is not used from T). No time asked, no check. */
|
|
22
|
+
export declare function placeInServiceAt(place: ShiftPlaceRow, atMs?: number): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* **The work shifts a place runs** - its own `workShiftNames`, else the nearest ancestor's (`OperationalLocation.workShiftNames`:
|
|
25
|
+
* "locations below inherit this unless they say their own"). A pure walk over the rows given.
|
|
26
|
+
*
|
|
27
|
+
* - A parent is found by row id first, then by name - both spellings stand in real data (as `zoneOfPlace`).
|
|
28
|
+
* - The walk stops at a loop, at a parent it cannot find, and - when `atMs` is given - at a place not in service then. It does not skip
|
|
29
|
+
* a retired place to inherit the grandparent's shifts: nobody declared that answer, so it says where it stopped instead.
|
|
30
|
+
* - Nothing declared answers no `shiftNames` - "no constraint stated", which is not "no shifts".
|
|
31
|
+
*
|
|
32
|
+
* Lifted on 2026-11-28 from operato-plant (`work-calendar-for`: `walkedLocations` · `declaringAncestor`) and operato-yard
|
|
33
|
+
* (`door-hours-rules`: `inheritedShiftNames`), which had each written the walk and had begun to answer differently.
|
|
34
|
+
*/
|
|
35
|
+
export declare function shiftNamesOfPlace(places: readonly ShiftPlaceRow[], start: string | undefined, atMs?: number): PlaceShifts;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.placeInServiceAt = placeInServiceAt;
|
|
4
|
+
exports.shiftNamesOfPlace = shiftNamesOfPlace;
|
|
5
|
+
const ms = (said) => {
|
|
6
|
+
if (said === null || said === undefined || said === '')
|
|
7
|
+
return undefined;
|
|
8
|
+
const at = said instanceof Date ? said.getTime() : Date.parse(String(said));
|
|
9
|
+
return Number.isNaN(at) ? undefined : at;
|
|
10
|
+
};
|
|
11
|
+
/** In service at `atMs` - the start is inclusive, the end is not (a place retired at T is not used from T). No time asked, no check. */
|
|
12
|
+
function placeInServiceAt(place, atMs) {
|
|
13
|
+
if (atMs === undefined)
|
|
14
|
+
return true;
|
|
15
|
+
const from = ms(place.effectiveStart);
|
|
16
|
+
const to = ms(place.effectiveEnd);
|
|
17
|
+
if (from !== undefined && atMs < from)
|
|
18
|
+
return false;
|
|
19
|
+
return !(to !== undefined && atMs >= to);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* **The work shifts a place runs** - its own `workShiftNames`, else the nearest ancestor's (`OperationalLocation.workShiftNames`:
|
|
23
|
+
* "locations below inherit this unless they say their own"). A pure walk over the rows given.
|
|
24
|
+
*
|
|
25
|
+
* - A parent is found by row id first, then by name - both spellings stand in real data (as `zoneOfPlace`).
|
|
26
|
+
* - The walk stops at a loop, at a parent it cannot find, and - when `atMs` is given - at a place not in service then. It does not skip
|
|
27
|
+
* a retired place to inherit the grandparent's shifts: nobody declared that answer, so it says where it stopped instead.
|
|
28
|
+
* - Nothing declared answers no `shiftNames` - "no constraint stated", which is not "no shifts".
|
|
29
|
+
*
|
|
30
|
+
* Lifted on 2026-11-28 from operato-plant (`work-calendar-for`: `walkedLocations` · `declaringAncestor`) and operato-yard
|
|
31
|
+
* (`door-hours-rules`: `inheritedShiftNames`), which had each written the walk and had begun to answer differently.
|
|
32
|
+
*/
|
|
33
|
+
function shiftNamesOfPlace(places, start, atMs) {
|
|
34
|
+
const walked = [];
|
|
35
|
+
if (!start)
|
|
36
|
+
return { walked };
|
|
37
|
+
const byId = new Map(places.filter(place => place.id).map(place => [place.id, place]));
|
|
38
|
+
const byName = new Map(places.map(place => [place.name, place]));
|
|
39
|
+
const find = (key) => byId.get(key) ?? byName.get(key);
|
|
40
|
+
const seen = new Set();
|
|
41
|
+
let at = byName.get(start) ?? byId.get(start);
|
|
42
|
+
while (at && !seen.has(at)) {
|
|
43
|
+
seen.add(at);
|
|
44
|
+
walked.push(at.name);
|
|
45
|
+
if (!placeInServiceAt(at, atMs))
|
|
46
|
+
return { walked, notInService: at };
|
|
47
|
+
if (at.workShiftNames?.length)
|
|
48
|
+
return { walked, declaredAt: at, shiftNames: [...new Set(at.workShiftNames)] };
|
|
49
|
+
at = at.parentId ? find(at.parentId) : undefined;
|
|
50
|
+
}
|
|
51
|
+
return { walked };
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=shift-names-of-place.js.map
|
|
@@ -6,6 +6,8 @@ const equipment_1 = require("./equipment/equipment");
|
|
|
6
6
|
const equipment_class_1 = require("./equipment/equipment-class");
|
|
7
7
|
const stop_reason_1 = require("./equipment/stop-reason");
|
|
8
8
|
const nonconformance_cause_1 = require("./quality/nonconformance-cause");
|
|
9
|
+
const electricity_tariff_1 = require("./energy/electricity-tariff");
|
|
10
|
+
const electricity_tariff_band_1 = require("./energy/electricity-tariff-band");
|
|
9
11
|
const material_class_1 = require("./material/material-class");
|
|
10
12
|
const material_definition_1 = require("./material/material-definition");
|
|
11
13
|
const operation_definition_1 = require("./operation/operation-definition");
|
|
@@ -24,6 +26,12 @@ exports.MASTER_AXES = [
|
|
|
24
26
|
{ key: 'equipment', entity: equipment_1.Equipment, searchables: ['name', 'description'], hasEffectivePeriod: true, revisable: false },
|
|
25
27
|
{ key: 'stopReason', entity: stop_reason_1.StopReason, searchables: ['name', 'description'], hasEffectivePeriod: true, revisable: false },
|
|
26
28
|
{ key: 'nonconformanceCause', entity: nonconformance_cause_1.NonconformanceCause, searchables: ['name', 'description'], hasEffectivePeriod: true, revisable: false },
|
|
29
|
+
/*
|
|
30
|
+
* 전기 요금제와 시간대 구간 (2026-11-27) — 요금표를 적을 곳이 없어 트윈 모델의 자리 속성(단일 단가)에만 있었다.
|
|
31
|
+
* 시간대 요금은 어디에도 적을 수 없었다. 규칙은 `energy/tariff-rules.ts`.
|
|
32
|
+
*/
|
|
33
|
+
{ key: 'electricityTariff', entity: electricity_tariff_1.ElectricityTariff, searchables: ['name', 'description', 'supplier'], hasEffectivePeriod: true, revisable: false },
|
|
34
|
+
{ key: 'electricityTariffBand', entity: electricity_tariff_band_1.ElectricityTariffBand, searchables: ['name', 'description', 'tariffName'], hasEffectivePeriod: true, revisable: false },
|
|
27
35
|
{ key: 'physicalAssetClass', entity: physical_asset_class_1.PhysicalAssetClass, searchables: ['name', 'description'], hasEffectivePeriod: true, revisable: false },
|
|
28
36
|
{ key: 'physicalAsset', entity: physical_asset_1.PhysicalAsset, searchables: ['name', 'description', 'identity'], hasEffectivePeriod: true, revisable: false },
|
|
29
37
|
{ key: 'materialClass', entity: material_class_1.MaterialClass, searchables: ['name', 'description'], hasEffectivePeriod: true, revisable: false },
|
|
@@ -3,7 +3,7 @@ import { RouteDefinition } from './route-definition';
|
|
|
3
3
|
import { RecipeDefinitionResolver, RouteDefinitionResolver } from './recipe-master-resolver';
|
|
4
4
|
import { RecipeQuery } from './recipe-query';
|
|
5
5
|
import { RecipeRevisionResolver } from './recipe-revision-resolver';
|
|
6
|
-
export declare const entities: (typeof RecipeDefinition | typeof RouteDefinition | typeof import("./recipe-revision").RecipeRevision | typeof import("./recipe-revision").
|
|
6
|
+
export declare const entities: (typeof RecipeDefinition | typeof RouteDefinition | typeof import("./recipe-revision").RecipeRevision | typeof import("./recipe-revision-line").RecipeRevisionOutput | typeof import("./recipe-revision").RecipePlan | typeof import("./recipe-revision").RecipeSegment | typeof import("./recipe-revision").RecipeBasis)[];
|
|
7
7
|
export declare const resolvers: (typeof RecipeDefinitionResolver | typeof RouteDefinitionResolver | typeof RecipeRevisionResolver | typeof RecipeQuery)[];
|
|
8
8
|
export * from './recipe-definition';
|
|
9
9
|
export * from './route-definition';
|
|
@@ -99,4 +99,4 @@ export declare class RecipeBasis {
|
|
|
99
99
|
businessTime: Date;
|
|
100
100
|
resolvedAt: Date;
|
|
101
101
|
}
|
|
102
|
-
export declare const RECIPE_REVISION_ENTITIES: (typeof RecipeRevision | typeof
|
|
102
|
+
export declare const RECIPE_REVISION_ENTITIES: (typeof RecipeRevision | typeof RecipeRevisionOutput | typeof RecipePlan | typeof RecipeSegment | typeof RecipeBasis)[];
|
|
@@ -18,6 +18,8 @@ const personnel_class_1 = require("../personnel/personnel-class");
|
|
|
18
18
|
const recipe_definition_1 = require("../recipe/recipe-definition");
|
|
19
19
|
const route_definition_1 = require("../recipe/route-definition");
|
|
20
20
|
const test_specification_1 = require("../test-spec/test-specification");
|
|
21
|
+
const electricity_tariff_1 = require("../energy/electricity-tariff");
|
|
22
|
+
const electricity_tariff_band_1 = require("../energy/electricity-tariff-band");
|
|
21
23
|
const axis_stamp_1 = require("./axis-stamp");
|
|
22
24
|
/**
|
|
23
25
|
* 축이 언제 바뀌었나 — **당길지 말지를 싸게 판단하는 자리.**
|
|
@@ -110,7 +112,9 @@ let OpsMasterStatusQuery = class OpsMasterStatusQuery {
|
|
|
110
112
|
axisStatus('operations', (0, shell_1.getRepository)(operation_definition_1.OperationDefinition), domain.id),
|
|
111
113
|
axisStatus('recipes', (0, shell_1.getRepository)(recipe_definition_1.RecipeDefinition), domain.id),
|
|
112
114
|
axisStatus('routes', (0, shell_1.getRepository)(route_definition_1.RouteDefinition), domain.id),
|
|
113
|
-
axisStatus('testSpecifications', (0, shell_1.getRepository)(test_specification_1.TestSpecification), domain.id)
|
|
115
|
+
axisStatus('testSpecifications', (0, shell_1.getRepository)(test_specification_1.TestSpecification), domain.id),
|
|
116
|
+
axisStatus('electricityTariffs', (0, shell_1.getRepository)(electricity_tariff_1.ElectricityTariff), domain.id),
|
|
117
|
+
axisStatus('electricityTariffBands', (0, shell_1.getRepository)(electricity_tariff_band_1.ElectricityTariffBand), domain.id)
|
|
114
118
|
]);
|
|
115
119
|
return { axes };
|
|
116
120
|
}
|