@operato/ops-contract 0.9.49 → 0.9.50
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/contract.d.ts +35 -3
- package/dist/contract.js +47 -6
- package/dist/domain-catalog.d.ts +8 -1
- package/dist/domain-catalog.js +10 -2
- package/dist/energy-ingest.js +4 -1
- package/dist/intralogistics-profile.d.ts +34 -0
- package/dist/intralogistics-profile.js +36 -0
- package/dist/operational-ingest.d.ts +4 -2
- package/dist/operational-ingest.js +78 -4
- package/dist/yms-profile.d.ts +1 -1
- package/dist/yms-profile.js +1 -1
- package/dist-cjs/index.cjs +2266 -2144
- package/package.json +1 -1
package/dist-cjs/index.cjs
CHANGED
|
@@ -53,6 +53,7 @@ __export(index_exports, {
|
|
|
53
53
|
EPCIS_CONTEXT: () => EPCIS_CONTEXT,
|
|
54
54
|
EPCIS_EVENT: () => EPCIS_EVENT,
|
|
55
55
|
EQUIPMENT_LEVEL: () => EQUIPMENT_LEVEL,
|
|
56
|
+
EQUIPMENT_PROPERTY: () => EQUIPMENT_PROPERTY,
|
|
56
57
|
EQUIPMENT_STATUS: () => EQUIPMENT_STATUS,
|
|
57
58
|
ERP_CAPABILITY: () => ERP_CAPABILITY,
|
|
58
59
|
ERP_MASTER_AXIS: () => ERP_MASTER_AXIS,
|
|
@@ -64,8 +65,10 @@ __export(index_exports, {
|
|
|
64
65
|
HEADER_FIELDS_PARTITIONED: () => HEADER_FIELDS_PARTITIONED,
|
|
65
66
|
ILG_ATTENTION_KIND: () => ILG_ATTENTION_KIND,
|
|
66
67
|
ILG_BIZSTEP: () => ILG_BIZSTEP,
|
|
68
|
+
ILG_EQUIPMENT_PROPERTY: () => ILG_EQUIPMENT_PROPERTY,
|
|
67
69
|
ILG_LOCATION_TYPES: () => ILG_LOCATION_TYPES,
|
|
68
70
|
ILG_ORDER_KIND: () => ILG_ORDER_KIND,
|
|
71
|
+
ILG_ROBOT_IDENTITY_PROPERTY: () => ILG_ROBOT_IDENTITY_PROPERTY,
|
|
69
72
|
ILG_TASK_KIND: () => ILG_TASK_KIND,
|
|
70
73
|
ILG_TYPES: () => ILG_TYPES,
|
|
71
74
|
ILMD_ATTR: () => ILMD_ATTR,
|
|
@@ -92,6 +95,7 @@ __export(index_exports, {
|
|
|
92
95
|
PARTY_ROLE: () => PARTY_ROLE,
|
|
93
96
|
PARTY_URI_MAX_LENGTH: () => PARTY_URI_MAX_LENGTH,
|
|
94
97
|
PARTY_URI_RECOMMENDED_LENGTH: () => PARTY_URI_RECOMMENDED_LENGTH,
|
|
98
|
+
PERCENT_UOM: () => PERCENT_UOM,
|
|
95
99
|
PERSON_STATUS: () => PERSON_STATUS,
|
|
96
100
|
PRIORITY_UNSET: () => PRIORITY_UNSET,
|
|
97
101
|
PRIVATE_BIZSTEP: () => PRIVATE_BIZSTEP,
|
|
@@ -106,6 +110,7 @@ __export(index_exports, {
|
|
|
106
110
|
SCHEDULE_STATUS: () => SCHEDULE_STATUS,
|
|
107
111
|
SIGNATURE_REJECTED_REASONS: () => SIGNATURE_REJECTED_REASONS,
|
|
108
112
|
SOURCE_DEST_PARTY_TYPE: () => SOURCE_DEST_PARTY_TYPE,
|
|
113
|
+
SPEED_TO_MPS: () => SPEED_TO_MPS,
|
|
109
114
|
TARIFF_DAY_KINDS: () => TARIFF_DAY_KINDS,
|
|
110
115
|
TARIFF_ISSUE_CODES: () => TARIFF_ISSUE_CODES,
|
|
111
116
|
TARIFF_LOAD_CLASSES: () => TARIFF_LOAD_CLASSES,
|
|
@@ -241,6 +246,7 @@ __export(index_exports, {
|
|
|
241
246
|
isEquipmentStatus: () => isEquipmentStatus,
|
|
242
247
|
isFailureStatus: () => isFailureStatus,
|
|
243
248
|
isFlowOrder: () => isFlowOrder,
|
|
249
|
+
isGuidedType: () => isGuidedType,
|
|
244
250
|
isHeading: () => isHeading,
|
|
245
251
|
isIso4217Code: () => isIso4217Code,
|
|
246
252
|
isIsoDateTime: () => isIsoDateTime,
|
|
@@ -261,6 +267,7 @@ __export(index_exports, {
|
|
|
261
267
|
isTestSpecificationBasis: () => isTestSpecificationBasis,
|
|
262
268
|
isTransformationRecord: () => isTransformationRecord,
|
|
263
269
|
isTransportFailureReason: () => isTransportFailureReason,
|
|
270
|
+
isTravelRecord: () => isTravelRecord,
|
|
264
271
|
isWebhookDeliveryCode: () => isWebhookDeliveryCode,
|
|
265
272
|
isWebhookSecretSegment: () => isWebhookSecretSegment,
|
|
266
273
|
isWorkShiftExecutionBasis: () => isWorkShiftExecutionBasis,
|
|
@@ -340,6 +347,7 @@ __export(index_exports, {
|
|
|
340
347
|
sameItemClass: () => sameItemClass,
|
|
341
348
|
sgtinClass: () => sgtinClass,
|
|
342
349
|
sgtinUri: () => sgtinUri,
|
|
350
|
+
speedMpsOf: () => speedMpsOf,
|
|
343
351
|
splitFlowOrders: () => splitFlowOrders,
|
|
344
352
|
splitRelationIds: () => splitRelationIds,
|
|
345
353
|
ssccDigitsOf: () => ssccDigitsOf,
|
|
@@ -573,7 +581,7 @@ var TASK_TERMINAL_STATUS = ["completed", "cancelled"];
|
|
|
573
581
|
function isTaskTerminal(t) {
|
|
574
582
|
return TASK_TERMINAL_STATUS.includes(String(t?.status ?? ""));
|
|
575
583
|
}
|
|
576
|
-
var ORDER_TERMINAL_STATUS = ["completed", "cancelled"];
|
|
584
|
+
var ORDER_TERMINAL_STATUS = ["completed", "cancelled", "failed"];
|
|
577
585
|
function isOrderTerminal(o) {
|
|
578
586
|
const status = String(o?.status ?? "").trim().toLowerCase();
|
|
579
587
|
if (ORDER_TERMINAL_STATUS.includes(status)) return true;
|
|
@@ -849,6 +857,27 @@ var MATERIAL_PROPERTY = {
|
|
|
849
857
|
/** 기준 단위 하나당 이 단위의 양. `uom` 이 대상 단위. */
|
|
850
858
|
perBaseUnit: "perBaseUnit"
|
|
851
859
|
};
|
|
860
|
+
var EQUIPMENT_PROPERTY = {
|
|
861
|
+
/** 설비의 빠르기 — `uom` 이 `SPEED_TO_MPS` 의 코드. */
|
|
862
|
+
speed: "speed"
|
|
863
|
+
};
|
|
864
|
+
var SPEED_TO_MPS = {
|
|
865
|
+
/** metre per second */
|
|
866
|
+
MTS: 1,
|
|
867
|
+
/** kilometre per hour */
|
|
868
|
+
KMH: 1e3 / 3600,
|
|
869
|
+
/** foot per second */
|
|
870
|
+
"2M": 0.3048,
|
|
871
|
+
/** mile per hour */
|
|
872
|
+
HM: 0.44704
|
|
873
|
+
};
|
|
874
|
+
function speedMpsOf(properties) {
|
|
875
|
+
const speed = (properties ?? []).find((one) => one?.id === EQUIPMENT_PROPERTY.speed);
|
|
876
|
+
if (!speed) return void 0;
|
|
877
|
+
const value = typeof speed.value === "number" ? speed.value : Number(speed.value);
|
|
878
|
+
const factor = speed.uom ? SPEED_TO_MPS[speed.uom] : void 0;
|
|
879
|
+
return Number.isFinite(value) && value > 0 && factor !== void 0 ? value * factor : void 0;
|
|
880
|
+
}
|
|
852
881
|
function conversionFactorOf(def, uom) {
|
|
853
882
|
if (!def || !uom) return void 0;
|
|
854
883
|
for (const p of def.properties ?? []) {
|
|
@@ -1184,9 +1213,8 @@ var OP_EVENT = {
|
|
|
1184
1213
|
* The four facts that carry `EquipmentState.travel` into the journal (state ⊆ events). Sent on change, never per tick.
|
|
1185
1214
|
* Payloads: `TravelPassedFact` · `TravelReservationFact` · `TravelLinkFact` · `TravelPoseFact`.
|
|
1186
1215
|
*
|
|
1187
|
-
* The transport control product sends them as
|
|
1188
|
-
* `
|
|
1189
|
-
* does not show travel.
|
|
1216
|
+
* The transport control product sends them as operational records (`operational-ingest` kinds `travel-passed`,
|
|
1217
|
+
* `travel-reservation`, `travel-link`, `travel-pose`, 2026-12-04); the observed reducer folds them into `EquipmentState.travel`.
|
|
1190
1218
|
*/
|
|
1191
1219
|
travelPassed: "equipment.passed",
|
|
1192
1220
|
travelReservation: "equipment.reservation",
|
|
@@ -2431,6 +2459,92 @@ function isElectricalLocationType(type) {
|
|
|
2431
2459
|
return EMS_LOCATION_TYPES.includes(type);
|
|
2432
2460
|
}
|
|
2433
2461
|
|
|
2462
|
+
// src/intralogistics-profile.ts
|
|
2463
|
+
var ILG_BIZSTEP = {
|
|
2464
|
+
/** The carrier left a port. */
|
|
2465
|
+
departing: "urn:epcglobal:cbv:bizstep:departing",
|
|
2466
|
+
/** The carrier reached a port. */
|
|
2467
|
+
arriving: "urn:epcglobal:cbv:bizstep:arriving",
|
|
2468
|
+
/** The carrier is on its way. */
|
|
2469
|
+
transporting: "urn:epcglobal:cbv:bizstep:transporting"
|
|
2470
|
+
};
|
|
2471
|
+
var ILG_LOCATION_TYPES = ["waypoint", "port", "charger", "parking"];
|
|
2472
|
+
var ILG_LOCATION_LEVEL = {
|
|
2473
|
+
waypoint: "Other",
|
|
2474
|
+
port: "StorageUnit",
|
|
2475
|
+
charger: "Other",
|
|
2476
|
+
parking: "Other"
|
|
2477
|
+
};
|
|
2478
|
+
var ILG_LOCATION_CAPABILITIES = {
|
|
2479
|
+
waypoint: [],
|
|
2480
|
+
port: ["storable"],
|
|
2481
|
+
charger: [],
|
|
2482
|
+
parking: []
|
|
2483
|
+
};
|
|
2484
|
+
var ILG_TYPES = [
|
|
2485
|
+
...ILG_LOCATION_TYPES.map((k) => ({
|
|
2486
|
+
key: k,
|
|
2487
|
+
role: "location",
|
|
2488
|
+
label: `twin.type.${k}`,
|
|
2489
|
+
standardClass: { epcis: "bizLocation" },
|
|
2490
|
+
identity: { scheme: "gs1:SGLN" },
|
|
2491
|
+
level: ILG_LOCATION_LEVEL[k],
|
|
2492
|
+
capabilities: ILG_LOCATION_CAPABILITIES[k]
|
|
2493
|
+
})),
|
|
2494
|
+
/* A forklift under transport control keeps the wms `forklift` type and adds `guided` in the site's own declaration. */
|
|
2495
|
+
{ key: "amr", role: "equipment", label: "twin.type.amr", standardClass: { epcis: "object", iso55000: "Asset" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["mobile", "guided", "operable", "energyStoring"] },
|
|
2496
|
+
{ key: "agv", role: "equipment", label: "twin.type.agv", standardClass: { epcis: "object", iso55000: "Asset" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["mobile", "guided", "operable", "energyStoring"] }
|
|
2497
|
+
];
|
|
2498
|
+
function intralogisticsTypeOf(key) {
|
|
2499
|
+
return ILG_TYPES.find((t) => t.key === key);
|
|
2500
|
+
}
|
|
2501
|
+
function isGuidedType(key) {
|
|
2502
|
+
return intralogisticsTypeOf(key)?.capabilities.includes("guided") ?? false;
|
|
2503
|
+
}
|
|
2504
|
+
var ILG_EQUIPMENT_PROPERTY = {
|
|
2505
|
+
/** State of charge when the simulation starts, percent (`P1`). */
|
|
2506
|
+
charge: "charge",
|
|
2507
|
+
/** Charge used per metre travelled, percentage points (`P1`). */
|
|
2508
|
+
chargeUsePerMetre: "chargeUsePerMetre",
|
|
2509
|
+
/** Charge gained per minute on a charger, percentage points (`P1`). */
|
|
2510
|
+
chargeGainPerMinute: "chargeGainPerMinute"
|
|
2511
|
+
};
|
|
2512
|
+
var ILG_ROBOT_IDENTITY_PROPERTY = {
|
|
2513
|
+
manufacturer: "manufacturer",
|
|
2514
|
+
serialNumber: "serialNumber"
|
|
2515
|
+
};
|
|
2516
|
+
var PERCENT_UOM = "P1";
|
|
2517
|
+
var ILG_ORDER_KIND = {
|
|
2518
|
+
transport: "transport"
|
|
2519
|
+
};
|
|
2520
|
+
var ILG_TASK_KIND = {
|
|
2521
|
+
leg: "transport-leg",
|
|
2522
|
+
charge: "charge",
|
|
2523
|
+
park: "park"
|
|
2524
|
+
};
|
|
2525
|
+
var TRANSPORT_FAILURE_REASON = [
|
|
2526
|
+
"no-route",
|
|
2527
|
+
"destination-unavailable",
|
|
2528
|
+
"carrier-not-found",
|
|
2529
|
+
/** The carrier identified at pick-up is not the one the command named. */
|
|
2530
|
+
"carrier-mismatch",
|
|
2531
|
+
"cancelled-by-source",
|
|
2532
|
+
"equipment-fault"
|
|
2533
|
+
];
|
|
2534
|
+
function isTransportFailureReason(v) {
|
|
2535
|
+
return typeof v === "string" && TRANSPORT_FAILURE_REASON.includes(v);
|
|
2536
|
+
}
|
|
2537
|
+
var ILG_ATTENTION_KIND = {
|
|
2538
|
+
deadlock: "intralogic.traffic-deadlock",
|
|
2539
|
+
blocked: "intralogic.traffic-blocked",
|
|
2540
|
+
lowCharge: "intralogic.low-charge",
|
|
2541
|
+
linkLost: "intralogic.link-lost",
|
|
2542
|
+
noRoute: "intralogic.no-route",
|
|
2543
|
+
rerouted: "intralogic.rerouted",
|
|
2544
|
+
carrierUnidentified: "intralogic.carrier-unidentified",
|
|
2545
|
+
carrierDuplicate: "intralogic.carrier-duplicate"
|
|
2546
|
+
};
|
|
2547
|
+
|
|
2434
2548
|
// src/domain-catalog.ts
|
|
2435
2549
|
var locationKeys = (types) => types.filter((t) => t.role === "location").map((t) => t.key);
|
|
2436
2550
|
var DOMAIN_CATALOG = {
|
|
@@ -2921,7 +3035,7 @@ var levelOfLocationType = (typeKey, system) => {
|
|
|
2921
3035
|
};
|
|
2922
3036
|
var axesOfSystem = (system) => TWIN_AXES.filter((a) => axisAppliesTo(a.axis, system));
|
|
2923
3037
|
function capabilitiesForType(system, typeKey) {
|
|
2924
|
-
return DOMAIN_CATALOG[system]?.types.find((t) => t.key === typeKey)?.capabilities ?? [];
|
|
3038
|
+
return DOMAIN_CATALOG[system]?.types.find((t) => t.key === typeKey)?.capabilities ?? ILG_TYPES.find((t) => t.key === typeKey)?.capabilities ?? [];
|
|
2925
3039
|
}
|
|
2926
3040
|
|
|
2927
3041
|
// src/domain-definition.ts
|
|
@@ -3008,2319 +3122,2319 @@ function validateCatalog(cat) {
|
|
|
3008
3122
|
return v;
|
|
3009
3123
|
}
|
|
3010
3124
|
|
|
3011
|
-
// src/
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
for (const record of arr) {
|
|
3024
|
-
const errors = [];
|
|
3025
|
-
const meterId = String(record?.meterId ?? "").trim();
|
|
3026
|
-
if (!meterId) errors.push("meterId \uC5C6\uC74C \u2014 \uC5B4\uB514\uC758 \uC18C\uBE44\uC778\uC9C0 \uBAA8\uB974\uB294 \uAC12\uC740 \uB204\uC801\uD560 \uC218 \uC5C6\uB2E4");
|
|
3027
|
-
const at2 = String(record?.at ?? "").trim() || opts.defaultEventTime;
|
|
3028
|
-
const atMs = at2 ? Date.parse(at2) : Number.NaN;
|
|
3029
|
-
if (!Number.isFinite(atMs)) errors.push("at \uC5C6\uC74C/\uD615\uC2DD \uC624\uB958 \u2014 \uC9C0\uAE08 \uC2DC\uAC01\uC73C\uB85C \uBA54\uC6B0\uBA74 \uB0A8\uC758 \uC218\uC694 \uAD6C\uAC04\uC5D0 \uC2E4\uB9B0\uB2E4");
|
|
3030
|
-
const num2 = (v, name) => {
|
|
3031
|
-
if (v === void 0 || v === null || v === "") return void 0;
|
|
3032
|
-
const n = Number(v);
|
|
3033
|
-
if (!Number.isFinite(n)) {
|
|
3034
|
-
errors.push(`${name} \uAC00 \uC218\uAC00 \uC544\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
3035
|
-
return void 0;
|
|
3036
|
-
}
|
|
3037
|
-
return n;
|
|
3038
|
-
};
|
|
3039
|
-
const kW = num2(record?.kW, "kW");
|
|
3040
|
-
const kWh = num2(record?.kWh, "kWh");
|
|
3041
|
-
const powerFactor = num2(record?.powerFactor, "powerFactor");
|
|
3042
|
-
if (errors.length) {
|
|
3043
|
-
rejected.push({ record, errors });
|
|
3044
|
-
continue;
|
|
3045
|
-
}
|
|
3046
|
-
const eventTime = new Date(atMs).toISOString();
|
|
3047
|
-
const data = {
|
|
3048
|
-
meterId,
|
|
3049
|
-
/* 계약은 `kW` 를 필수로 두지만 **못 읽은 표본도 사실**이다 — 그 경우 값을 비우고 보낸다.
|
|
3050
|
-
커널이 「받았지만 부하를 못 읽었다」로 세고, 구간 마감에 그 이유를 싣는다. */
|
|
3051
|
-
...kW !== void 0 ? { kW } : {},
|
|
3052
|
-
...kWh !== void 0 ? { kWh } : {},
|
|
3053
|
-
...powerFactor !== void 0 ? { powerFactor } : {},
|
|
3054
|
-
at: eventTime
|
|
3055
|
-
};
|
|
3056
|
-
accepted.push({
|
|
3057
|
-
eventId: `${opts.tenantId}-energy-${++seq}`,
|
|
3058
|
-
eventType: ENERGY_EVENT.measured,
|
|
3059
|
-
eventTime,
|
|
3060
|
-
tenantId: opts.tenantId,
|
|
3061
|
-
data
|
|
3062
|
-
});
|
|
3125
|
+
// src/work-shift-basis.ts
|
|
3126
|
+
var instant = (value) => typeof value === "string" && /(?:Z|[+-]\d{2}:\d{2})$/.test(value) && Number.isFinite(Date.parse(value));
|
|
3127
|
+
var nonempty = (value) => typeof value === "string" && !!value.trim();
|
|
3128
|
+
var clock = (value) => typeof value === "string" && /^(?:[01]\d|2[0-3]):[0-5]\d$/.test(value);
|
|
3129
|
+
function isWorkShiftExecutionBasis(value) {
|
|
3130
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
3131
|
+
const b = value;
|
|
3132
|
+
if (![b.basisId, b.arrangementId, b.revisionId, b.planId, b.contentHash].every(nonempty) || !Number.isSafeInteger(b.revisionNumber) || b.revisionNumber < 1 || !instant(b.businessTime) || !nonempty(b.timezone)) return false;
|
|
3133
|
+
try {
|
|
3134
|
+
new Intl.DateTimeFormat("en", { timeZone: b.timezone }).format(0);
|
|
3135
|
+
} catch {
|
|
3136
|
+
return false;
|
|
3063
3137
|
}
|
|
3064
|
-
|
|
3138
|
+
if (typeof b.workDate !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(b.workDate) || !Number.isFinite(Date.parse(b.workDate)) || new Date(b.workDate).toISOString().slice(0, 10) !== b.workDate) return false;
|
|
3139
|
+
if (!Array.isArray(b.shifts) || !b.shifts.length || b.shifts.length > 64) return false;
|
|
3140
|
+
const names = /* @__PURE__ */ new Set();
|
|
3141
|
+
for (const s of b.shifts) {
|
|
3142
|
+
if (!s || typeof s !== "object" || !nonempty(s.name) || names.has(s.name) || s.description !== void 0 && typeof s.description !== "string" || ![-1, 0, 1].includes(s.fromDate) || ![-1, 0, 1].includes(s.toDate) || !clock(s.fromTime) || !clock(s.toTime) || typeof s.daysOfWeek !== "string" || !/^(?:[0-6](?:,[0-6])*)?$/.test(s.daysOfWeek)) return false;
|
|
3143
|
+
const minutes = (time) => Number(time.slice(0, 2)) * 60 + Number(time.slice(3));
|
|
3144
|
+
const duration = (s.toDate - s.fromDate) * 1440 + minutes(s.toTime) - minutes(s.fromTime);
|
|
3145
|
+
if (duration <= 0 || duration > 1440) return false;
|
|
3146
|
+
names.add(s.name);
|
|
3147
|
+
}
|
|
3148
|
+
if (b.shiftName === void 0) return b.occurrence === void 0;
|
|
3149
|
+
if (!nonempty(b.shiftName) || !names.has(b.shiftName) || !b.occurrence || !instant(b.occurrence.from) || !instant(b.occurrence.to)) return false;
|
|
3150
|
+
const at2 = Date.parse(b.businessTime);
|
|
3151
|
+
return Date.parse(b.occurrence.from) <= at2 && at2 < Date.parse(b.occurrence.to);
|
|
3065
3152
|
}
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3153
|
+
function workShiftAttribution(value) {
|
|
3154
|
+
if (!isWorkShiftExecutionBasis(value)) throw new Error("Invalid pinned work shift evidence");
|
|
3155
|
+
return {
|
|
3156
|
+
workDate: value.workDate,
|
|
3157
|
+
shiftName: value.shiftName,
|
|
3158
|
+
timezone: value.timezone,
|
|
3159
|
+
revisionNumber: value.revisionNumber,
|
|
3160
|
+
occurrence: value.occurrence ? { ...value.occurrence } : void 0
|
|
3161
|
+
};
|
|
3072
3162
|
}
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
const
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
let curtailable;
|
|
3110
|
-
if (r?.curtailable !== void 0 && r?.curtailable !== null) {
|
|
3111
|
-
if (typeof r.curtailable !== "boolean") errors.push(`curtailable \uAC00 \uCC38/\uAC70\uC9D3\uC774 \uC544\uB2C8\uB2E4: ${JSON.stringify(r.curtailable)}`);
|
|
3112
|
-
else curtailable = r.curtailable;
|
|
3163
|
+
|
|
3164
|
+
// src/travel.ts
|
|
3165
|
+
var TRAVEL_LINK_STATE = ["online", "stale", "lost"];
|
|
3166
|
+
var TRAVEL_LINK_JUDGED_BY = ["source", "derived"];
|
|
3167
|
+
function linkStateAt(link, nowTime, thresholds) {
|
|
3168
|
+
if (link.judgedBy === "source") return link;
|
|
3169
|
+
if (!nowTime) return void 0;
|
|
3170
|
+
const now = Date.parse(nowTime);
|
|
3171
|
+
const seen = Date.parse(link.lastSeenAt);
|
|
3172
|
+
const { staleAfterMs, lostAfterMs } = thresholds;
|
|
3173
|
+
if (!Number.isFinite(now) || !Number.isFinite(seen)) return void 0;
|
|
3174
|
+
if (!(staleAfterMs >= 0 && lostAfterMs >= staleAfterMs)) return void 0;
|
|
3175
|
+
const silentMs = now - seen;
|
|
3176
|
+
const state = silentMs > lostAfterMs ? "lost" : silentMs > staleAfterMs ? "stale" : "online";
|
|
3177
|
+
return { ...link, state, judgedBy: "derived" };
|
|
3178
|
+
}
|
|
3179
|
+
function isHeading(v) {
|
|
3180
|
+
return typeof v === "number" && Number.isFinite(v) && v >= 0 && v < 360;
|
|
3181
|
+
}
|
|
3182
|
+
|
|
3183
|
+
// src/operational-ingest.ts
|
|
3184
|
+
function shapeErrors(where, row, shape) {
|
|
3185
|
+
if (!shape) return [];
|
|
3186
|
+
const errors = [];
|
|
3187
|
+
for (const f of shape.required ?? []) {
|
|
3188
|
+
const v = row[f];
|
|
3189
|
+
const empty2 = v === void 0 || v === null || typeof v === "string" && !v.trim();
|
|
3190
|
+
if (empty2) errors.push(`${where}.${f}: \uD544\uC218 \uD544\uB4DC \uB204\uB77D`);
|
|
3191
|
+
}
|
|
3192
|
+
for (const [f, t] of Object.entries(shape.fields ?? {})) {
|
|
3193
|
+
const v = row[f];
|
|
3194
|
+
if (v === void 0 || v === null) continue;
|
|
3195
|
+
if (t === "number" && (typeof v !== "number" || !Number.isFinite(v))) {
|
|
3196
|
+
errors.push(`${where}.${f} \uAC12\uC740 \uC720\uD55C\uD55C \uC22B\uC790\uC5EC\uC57C \uD569\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
3197
|
+
} else if (t !== "number" && typeof v !== t) {
|
|
3198
|
+
errors.push(`${where}.${f} \uAC00 ${t} \uAC00 \uC544\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
3113
3199
|
}
|
|
3114
|
-
const dcVoltage = num2(r?.dcVoltage, "dcVoltage", 0);
|
|
3115
|
-
const dcCurrent = num2(r?.dcCurrent, "dcCurrent", 0);
|
|
3116
|
-
const phases = (raw, name) => {
|
|
3117
|
-
if (raw === void 0 || raw === null) return void 0;
|
|
3118
|
-
if (!Array.isArray(raw)) {
|
|
3119
|
-
errors.push(`${name} \uAC00 \uBC30\uC5F4\uC774 \uC544\uB2C8\uB2E4 \u2014 \uC0C1\uBCC4 \uAC12\uC774\uB77C \uBC30\uC5F4\uB85C \uBC1B\uB294\uB2E4(\uB2E8\uC0C1\uC774\uBA74 \uC6D0\uC18C \uD558\uB098): ${JSON.stringify(raw)}`);
|
|
3120
|
-
return void 0;
|
|
3121
|
-
}
|
|
3122
|
-
if (!raw.length) {
|
|
3123
|
-
errors.push(`${name} \uAC00 \uBE48 \uBC30\uC5F4\uC774\uB2E4 \u2014 \uC7B0 \uC0C1\uC774 \uC5C6\uC73C\uBA74 \uADF8 \uCE78\uC744 \uBCF4\uB0B4\uC9C0 \uC54A\uB294\uB2E4`);
|
|
3124
|
-
return void 0;
|
|
3125
|
-
}
|
|
3126
|
-
const out = [];
|
|
3127
|
-
for (const [i, v] of raw.entries()) {
|
|
3128
|
-
const n = Number(v);
|
|
3129
|
-
if (!Number.isFinite(n)) {
|
|
3130
|
-
errors.push(`${name}[${i}] \uB97C \uC218\uB85C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${JSON.stringify(v)}`);
|
|
3131
|
-
return void 0;
|
|
3132
|
-
}
|
|
3133
|
-
if (n < 0) {
|
|
3134
|
-
errors.push(`${name}[${i}] \uAC00 \uC74C\uC218\uB2E4(${n}) \u2014 \uD06C\uAE30\uB294 \uC74C\uC218\uAC00 \uB418\uC9C0 \uC54A\uB294\uB2E4(\uBC29\uD5A5\uC740 \uB2E4\uB978 \uCD95\uC774 \uB9D0\uD55C\uB2E4)`);
|
|
3135
|
-
return void 0;
|
|
3136
|
-
}
|
|
3137
|
-
out.push(n);
|
|
3138
|
-
}
|
|
3139
|
-
return out;
|
|
3140
|
-
};
|
|
3141
|
-
const acVoltage = phases(r?.acVoltage, "acVoltage");
|
|
3142
|
-
const acCurrent = phases(r?.acCurrent, "acCurrent");
|
|
3143
|
-
if (acVoltage && acCurrent && acVoltage.length !== acCurrent.length) {
|
|
3144
|
-
errors.push(`acVoltage(${acVoltage.length}\uC0C1)\uC640 acCurrent(${acCurrent.length}\uC0C1)\uC758 \uC0C1 \uC218\uAC00 \uB2E4\uB974\uB2E4`);
|
|
3145
|
-
}
|
|
3146
|
-
let position;
|
|
3147
|
-
if (r?.position !== void 0 && r?.position !== null && r?.position !== "") {
|
|
3148
|
-
const p = String(r.position);
|
|
3149
|
-
if (!POSITIONS.has(p)) errors.push(`position \uC774 \uD45C\uC900 \uAC12\uC774 \uC544\uB2C8\uB2E4(open\xB7closed\xB7intermediate\xB7bad): ${JSON.stringify(r.position)}`);
|
|
3150
|
-
else position = p;
|
|
3151
|
-
}
|
|
3152
|
-
const values = { generatedKW, exportKW, soc, chargeKW, dischargeKW, curtailable, minKW, position, dcVoltage, dcCurrent, acVoltage, acCurrent };
|
|
3153
|
-
if (!errors.length && Object.values(values).every((v) => v === void 0)) {
|
|
3154
|
-
errors.push("\uBC14\uAFC0 \uC0C1\uD0DC\uAC00 \uD558\uB098\uB3C4 \uC5C6\uB2E4 \u2014 \uAC12 \uC5C6\uB294 \uBCF4\uACE0\uB294 \uC0AC\uC2E4\uB85C \uC801\uC744 \uAC83\uC774 \uC5C6\uB2E4");
|
|
3155
|
-
}
|
|
3156
|
-
if (errors.length) {
|
|
3157
|
-
rejected.push({ record, errors });
|
|
3158
|
-
continue;
|
|
3159
|
-
}
|
|
3160
|
-
const eventTime = new Date(atMs).toISOString();
|
|
3161
|
-
const data = {
|
|
3162
|
-
equipmentId,
|
|
3163
|
-
at: eventTime,
|
|
3164
|
-
...generatedKW !== void 0 ? { generatedKW } : {},
|
|
3165
|
-
...exportKW !== void 0 ? { exportKW } : {},
|
|
3166
|
-
...soc !== void 0 ? { soc } : {},
|
|
3167
|
-
...chargeKW !== void 0 ? { chargeKW } : {},
|
|
3168
|
-
...dischargeKW !== void 0 ? { dischargeKW } : {},
|
|
3169
|
-
...curtailable !== void 0 ? { curtailable } : {},
|
|
3170
|
-
...minKW !== void 0 ? { minKW } : {},
|
|
3171
|
-
...position !== void 0 ? { position } : {},
|
|
3172
|
-
...dcVoltage !== void 0 ? { dcVoltage } : {},
|
|
3173
|
-
...dcCurrent !== void 0 ? { dcCurrent } : {},
|
|
3174
|
-
...acVoltage !== void 0 ? { acVoltage } : {},
|
|
3175
|
-
...acCurrent !== void 0 ? { acCurrent } : {}
|
|
3176
|
-
};
|
|
3177
|
-
accepted.push({
|
|
3178
|
-
eventId: `${opts.tenantId}-energy-eq-${++seq}`,
|
|
3179
|
-
eventType: ENERGY_EVENT.equipment,
|
|
3180
|
-
eventTime,
|
|
3181
|
-
tenantId: opts.tenantId,
|
|
3182
|
-
data
|
|
3183
|
-
});
|
|
3184
3200
|
}
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
const r = record;
|
|
3191
|
-
return typeof r.equipmentId === "string" && r.equipmentId.trim().length > 0 && r.kWh !== void 0 && r.meterId === void 0 && r.epc === void 0;
|
|
3192
|
-
}
|
|
3193
|
-
function ingestEnergyGenerationRecords(records, opts) {
|
|
3194
|
-
const list = records === void 0 || records === null ? [] : Array.isArray(records) ? records : [records];
|
|
3195
|
-
const accepted = [];
|
|
3196
|
-
const rejected = [];
|
|
3197
|
-
let seq = 0;
|
|
3198
|
-
for (const r of list) {
|
|
3199
|
-
const errors = [];
|
|
3200
|
-
const equipmentId = String(r?.equipmentId ?? "").trim();
|
|
3201
|
-
if (!equipmentId) errors.push("equipmentId \uAC00 \uC5C6\uB2E4 \u2014 \uC5B4\uB290 \uC124\uBE44\uAC00 \uB9CC\uB4E0 \uAC83\uC778\uC9C0 \uC9C0\uC5B4\uB0BC \uC218 \uC5C6\uB2E4");
|
|
3202
|
-
const STATE_FIELDS = ["generatedKW", "exportKW", "soc", "chargeKW", "dischargeKW", "curtailable", "minKW", "position"];
|
|
3203
|
-
const alsoState = STATE_FIELDS.filter((f) => r?.[f] !== void 0);
|
|
3204
|
-
if (alsoState.length) {
|
|
3205
|
-
errors.push(
|
|
3206
|
-
`\uD55C \uB808\uCF54\uB4DC\uC5D0 \uC801\uC0B0\uAC12\uACFC \uC124\uBE44 \uC0C1\uD0DC\uAC00 \uD568\uAED8 \uB4E4\uC5B4 \uC788\uC2B5\uB2C8\uB2E4(${alsoState.join("\xB7")}) \u2014 \uC774 \uACBD\uB85C\uC5D0\uC11C\uB294 \uC801\uC0B0\uAC12\uB9CC \uCC98\uB9AC\uD569\uB2C8\uB2E4. \uC124\uBE44 \uC0C1\uD0DC\uB294 \uBCC4\uB3C4 \uB808\uCF54\uB4DC\uB85C \uBCF4\uB0B4\uC138\uC694.`
|
|
3207
|
-
);
|
|
3208
|
-
}
|
|
3209
|
-
const raw = r?.kWh;
|
|
3210
|
-
const kWh = Number(raw);
|
|
3211
|
-
if (raw === void 0 || raw === null || !Number.isFinite(kWh)) {
|
|
3212
|
-
errors.push("kWh \uAC00 \uC5C6\uB2E4 \u2014 \uC774 \uBB38\uC774 \uBC1B\uB294 \uAC12\uC740 \uC801\uC0B0 \uD558\uB098\uB2E4(\uC21C\uC2DC \uCD9C\uB825\uC740 \uC124\uBE44 \uC0C1\uD0DC\uB85C \uBCF4\uB0B8\uB2E4)");
|
|
3213
|
-
} else if (kWh < 0) {
|
|
3214
|
-
errors.push(`kWh \uAC00 \uC74C\uC218\uB2E4(${kWh}) \u2014 \uC801\uC0B0\uC740 \uB4A4\uB85C \uAC00\uB354\uB77C\uB3C4 \uC74C\uC218\uAC00 \uB418\uC9C0 \uC54A\uB294\uB2E4`);
|
|
3215
|
-
}
|
|
3216
|
-
const eventTime = String(r?.at ?? "").trim() || opts.defaultEventTime || "";
|
|
3217
|
-
if (!eventTime) errors.push("at \uC774 \uC5C6\uACE0 \uAE30\uBCF8 \uC2DC\uAC01\uB3C4 \uC8FC\uC9C0 \uC54A\uC558\uB2E4 \u2014 \uC5B8\uC81C \uC7B0 \uAC83\uC778\uC9C0 \uC9C0\uC5B4\uB0BC \uC218 \uC5C6\uB2E4");
|
|
3218
|
-
let since;
|
|
3219
|
-
const rawSince = r?.kWhSince;
|
|
3220
|
-
if (rawSince !== void 0 && rawSince !== null && String(rawSince).trim()) {
|
|
3221
|
-
const text = String(rawSince).trim();
|
|
3222
|
-
const at2 = Date.parse(text);
|
|
3223
|
-
if (!Number.isFinite(at2)) errors.push(`kWhSince \uB97C \uC2DC\uAC01\uC73C\uB85C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${JSON.stringify(rawSince)}`);
|
|
3224
|
-
else if (Number.isFinite(Date.parse(eventTime)) && at2 > Date.parse(eventTime)) {
|
|
3225
|
-
errors.push(`kWhSince(${text}) \uAC00 \uC7B0 \uC2DC\uAC01(${eventTime})\uBCF4\uB2E4 \uB4A4\uB2E4 \u2014 \uB458 \uC911 \uD558\uB098\uAC00 \uD2C0\uB838\uB2E4`);
|
|
3226
|
-
} else since = text;
|
|
3227
|
-
}
|
|
3228
|
-
const ACCUMULATIONS = ["lifetime", "daily", "monthly", "billing", "unknown"];
|
|
3229
|
-
let accumulation;
|
|
3230
|
-
const rawAcc = r?.kWhAccumulation;
|
|
3231
|
-
if (rawAcc !== void 0 && rawAcc !== null && String(rawAcc).trim()) {
|
|
3232
|
-
const text = String(rawAcc).trim();
|
|
3233
|
-
if (!ACCUMULATIONS.includes(text)) {
|
|
3234
|
-
errors.push(`kWhAccumulation \uC774 \uC544\uB294 \uAC12\uC774 \uC544\uB2C8\uB2E4(${ACCUMULATIONS.join("\xB7")}): ${JSON.stringify(rawAcc)}`);
|
|
3235
|
-
} else accumulation = text;
|
|
3201
|
+
for (const [f, allowed] of Object.entries(shape.enums ?? {})) {
|
|
3202
|
+
const v = row[f];
|
|
3203
|
+
if (v === void 0 || v === null) continue;
|
|
3204
|
+
if (!allowed.includes(String(v))) {
|
|
3205
|
+
errors.push(`${where}.${f}\uC5D0 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uAC12\uC774 \uC9C0\uC815\uB418\uC5C8\uC2B5\uB2C8\uB2E4: ${JSON.stringify(v)} (${allowed.join(" \xB7 ")})`);
|
|
3236
3206
|
}
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3207
|
+
}
|
|
3208
|
+
for (const f of shape.positive ?? []) {
|
|
3209
|
+
const v = row[f];
|
|
3210
|
+
if (v === void 0 || v === null) continue;
|
|
3211
|
+
if (typeof v !== "number" || !(v > 0)) {
|
|
3212
|
+
errors.push(`${where}.${f} \uAC00 0 \uC774\uD558\uB2E4: ${JSON.stringify(v)} \u2014 \uC218\uB7C9\uC744 \uC54C \uC218 \uC5C6\uC73C\uBA74 \uAC12\uC744 \uC0DD\uB7B5\uD558\uC138\uC694.`);
|
|
3240
3213
|
}
|
|
3241
|
-
const data = {
|
|
3242
|
-
equipmentId,
|
|
3243
|
-
kWh,
|
|
3244
|
-
at: eventTime,
|
|
3245
|
-
...since ? { since } : {},
|
|
3246
|
-
...accumulation ? { accumulation } : {}
|
|
3247
|
-
};
|
|
3248
|
-
accepted.push({
|
|
3249
|
-
eventId: `${opts.tenantId}-generated-${++seq}`,
|
|
3250
|
-
eventType: ENERGY_EVENT.generated,
|
|
3251
|
-
eventTime,
|
|
3252
|
-
tenantId: opts.tenantId,
|
|
3253
|
-
data
|
|
3254
|
-
});
|
|
3255
3214
|
}
|
|
3256
|
-
return
|
|
3257
|
-
}
|
|
3258
|
-
function isEnergyUsagePeriodRecord(record) {
|
|
3259
|
-
const r = record;
|
|
3260
|
-
return !!r && typeof r === "object" && r.meterId !== void 0 && r.from !== void 0 && r.to !== void 0 && r.kWh !== void 0;
|
|
3261
|
-
}
|
|
3262
|
-
function isEnergyGenerationPeriodRecord(record) {
|
|
3263
|
-
const r = record;
|
|
3264
|
-
if (!r || typeof r !== "object") return false;
|
|
3265
|
-
if (r.equipmentId === void 0 || r.from === void 0 || r.to === void 0) return false;
|
|
3266
|
-
return r.kWh !== void 0;
|
|
3215
|
+
return errors;
|
|
3267
3216
|
}
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3217
|
+
var SPECS = {
|
|
3218
|
+
task: {
|
|
3219
|
+
eventType: OP_EVENT.task,
|
|
3220
|
+
match: ["taskId"],
|
|
3221
|
+
matchOrder: 50,
|
|
3222
|
+
identity: "taskId",
|
|
3223
|
+
/* 종류가 없으면 성과를 종류별로 모을 수 없고(선언된 시간·수율이 종류로 붙는다) 지어낼 수도 없다. */
|
|
3224
|
+
required: ["taskId", "kind", "status"],
|
|
3225
|
+
fields: {
|
|
3226
|
+
taskId: "string",
|
|
3227
|
+
kind: "string",
|
|
3228
|
+
status: "string",
|
|
3229
|
+
fromNode: "string",
|
|
3230
|
+
toNode: "string",
|
|
3231
|
+
itemRefs: "string[]",
|
|
3232
|
+
resourceRef: "string",
|
|
3233
|
+
resources: "string[]",
|
|
3234
|
+
personnel: "string[]",
|
|
3235
|
+
assets: "string[]",
|
|
3236
|
+
orderId: "string",
|
|
3237
|
+
intent: "string",
|
|
3238
|
+
progress: "number",
|
|
3239
|
+
remainingMs: "number",
|
|
3240
|
+
durationMs: "number",
|
|
3241
|
+
startedAtSimMs: "number",
|
|
3242
|
+
outcome: "string",
|
|
3243
|
+
priority: "number",
|
|
3244
|
+
startTime: "string",
|
|
3245
|
+
endTime: "string",
|
|
3246
|
+
materialActual: "object[]",
|
|
3247
|
+
recordTime: "string",
|
|
3248
|
+
workShiftBasis: "object"
|
|
3249
|
+
},
|
|
3250
|
+
/*
|
|
3251
|
+
* **자재 줄의 안쪽** — 계약의 `MaterialActual` 그대로다.
|
|
3252
|
+
*
|
|
3253
|
+
* `definitionId` 를 요구하는 이유: 이 이름이 없으면 그 줄이 무엇을 가리키는지 아무도 모른다.
|
|
3254
|
+
* 실제로 `materialDefinitionId` 로 온 줄이 저널에 앉았고, 계약의 타입으로 읽으면 비어 있었다.
|
|
3255
|
+
*
|
|
3256
|
+
* `quantity` 를 `positive` 에 두는 이유: 「모른다」는 **비워서** 말한다. 0 으로 실으면 받는
|
|
3257
|
+
* 쪽에서 「0개」와 구별되지 않고, 소요량 집계가 조용히 틀린다.
|
|
3258
|
+
*
|
|
3259
|
+
* `uom` 은 요구하지 않는다 — 계약에서 선택이다(§`MaterialActual`). ERP 경로는 요구하는데
|
|
3260
|
+
* 그것은 **그 경로의 규칙**이다(정산에 단위 없는 수량을 쓸 수 없다). 커널이 그 규칙을 통째로
|
|
3261
|
+
* 물려받으면 단위를 모르는 현장의 사실이 통째로 거절된다.
|
|
3262
|
+
*/
|
|
3263
|
+
shapes: {
|
|
3264
|
+
workShiftBasis: {
|
|
3265
|
+
required: ["basisId", "arrangementId", "revisionId", "revisionNumber", "planId", "contentHash", "businessTime", "timezone", "shifts", "workDate"],
|
|
3266
|
+
fields: { basisId: "string", arrangementId: "string", revisionId: "string", revisionNumber: "number", planId: "string", contentHash: "string", businessTime: "string", timezone: "string", workDate: "string" }
|
|
3267
|
+
// Full nested content and selected occurrence are checked by isWorkShiftExecutionBasis below.
|
|
3268
|
+
},
|
|
3269
|
+
materialActual: {
|
|
3270
|
+
required: ["definitionId", "use"],
|
|
3271
|
+
fields: { definitionId: "string", lotId: "string", quantity: "number", uom: "string" },
|
|
3272
|
+
enums: { use: MATERIAL_ACTUAL_USE },
|
|
3273
|
+
positive: ["quantity"]
|
|
3294
3274
|
}
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
continue;
|
|
3275
|
+
},
|
|
3276
|
+
enums: {
|
|
3277
|
+
status: TASK_STATUS,
|
|
3278
|
+
intent: ["transport", "process", "dwell"],
|
|
3279
|
+
/* 품질 판정은 **있었던 작업만** — 없음은 「양품」이 아니라 「판정하지 않았다」다. */
|
|
3280
|
+
outcome: ["good", "scrap"]
|
|
3302
3281
|
}
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
}
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3282
|
+
},
|
|
3283
|
+
equipment: {
|
|
3284
|
+
eventType: OP_EVENT.equipment,
|
|
3285
|
+
match: ["moverId"],
|
|
3286
|
+
matchOrder: 20,
|
|
3287
|
+
identity: "moverId",
|
|
3288
|
+
// vocabulary-guard: allow 저널 와이어 필드(델타의 이름이 계약이다)
|
|
3289
|
+
required: ["moverId", "kind", "status"],
|
|
3290
|
+
// vocabulary-guard: allow 위와 같은 이유
|
|
3291
|
+
fields: {
|
|
3292
|
+
moverId: "string",
|
|
3293
|
+
kind: "string",
|
|
3294
|
+
status: "string",
|
|
3295
|
+
location: "string",
|
|
3296
|
+
homeLocation: "string",
|
|
3297
|
+
// vocabulary-guard: allow
|
|
3298
|
+
taskId: "string",
|
|
3299
|
+
held: "boolean",
|
|
3300
|
+
effectiveStart: "string",
|
|
3301
|
+
effectiveEnd: "string",
|
|
3302
|
+
recordTime: "string",
|
|
3303
|
+
/* 왜 이 상태가 됐나 — 설비가 알려 주면 싣는다. 사람이 나중에 정하는 사유는 구간 사실에 적는다. */
|
|
3304
|
+
reasonCode: "string",
|
|
3305
|
+
/* 이동 구간 — 실 시스템도 줄 수 있는 사실이다(AGV·RTLS 가 출발·도착·소요를 낸다). 안쪽 필드까지
|
|
3306
|
+
재검사하지는 않는다: 그 모양은 `EquipmentMotion` 계약이고, 여기서 두 번 지키면 두 벌이 된다. */
|
|
3307
|
+
motion: "object"
|
|
3308
|
+
},
|
|
3309
|
+
enums: { status: EQUIPMENT_STATUS }
|
|
3310
|
+
},
|
|
3311
|
+
person: {
|
|
3312
|
+
eventType: OP_EVENT.person,
|
|
3313
|
+
match: ["personId"],
|
|
3314
|
+
matchOrder: 30,
|
|
3315
|
+
identity: "personId",
|
|
3316
|
+
required: ["personId", "status"],
|
|
3317
|
+
fields: {
|
|
3318
|
+
personId: "string",
|
|
3319
|
+
status: "string",
|
|
3320
|
+
personnelClassIds: "string[]",
|
|
3321
|
+
taskId: "string",
|
|
3322
|
+
location: "string",
|
|
3323
|
+
offShift: "boolean",
|
|
3324
|
+
effectiveStart: "string",
|
|
3325
|
+
effectiveEnd: "string",
|
|
3326
|
+
recordTime: "string"
|
|
3327
|
+
},
|
|
3328
|
+
enums: { status: PERSON_STATUS }
|
|
3329
|
+
},
|
|
3330
|
+
asset: {
|
|
3331
|
+
eventType: OP_EVENT.asset,
|
|
3332
|
+
match: ["assetId"],
|
|
3333
|
+
matchOrder: 40,
|
|
3334
|
+
identity: "assetId",
|
|
3335
|
+
required: ["assetId", "status"],
|
|
3336
|
+
fields: {
|
|
3337
|
+
assetId: "string",
|
|
3338
|
+
status: "string",
|
|
3339
|
+
assetClassIds: "string[]",
|
|
3340
|
+
location: "string",
|
|
3341
|
+
taskId: "string",
|
|
3342
|
+
carrying: "string",
|
|
3343
|
+
effectiveStart: "string",
|
|
3344
|
+
effectiveEnd: "string",
|
|
3345
|
+
recordTime: "string"
|
|
3346
|
+
},
|
|
3347
|
+
enums: { status: ASSET_STATUS }
|
|
3348
|
+
},
|
|
3349
|
+
order: {
|
|
3350
|
+
eventType: OP_EVENT.order,
|
|
3351
|
+
match: ["orderId"],
|
|
3352
|
+
matchOrder: 60,
|
|
3353
|
+
identity: "orderId",
|
|
3354
|
+
/*
|
|
3355
|
+
* 요청량·이행량을 **함께** 받는다. 없으면 리듀서가 진척을 0 으로 적는데(`requested ? … : 0`),
|
|
3356
|
+
* 그것은 「모른다」가 아니라 「아무것도 안 됐다」로 읽힌다 — 결측을 0 으로 메우지 않는다.
|
|
3357
|
+
*/
|
|
3358
|
+
required: ["orderId", "kind", "status", "requested", "fulfilled"],
|
|
3359
|
+
fields: {
|
|
3360
|
+
orderId: "string",
|
|
3361
|
+
kind: "string",
|
|
3362
|
+
status: "string",
|
|
3363
|
+
requested: "number",
|
|
3364
|
+
fulfilled: "number",
|
|
3365
|
+
gtin: "string",
|
|
3366
|
+
held: "boolean",
|
|
3367
|
+
lines: "object[]",
|
|
3368
|
+
priority: "number",
|
|
3369
|
+
startTime: "string",
|
|
3370
|
+
endTime: "string",
|
|
3371
|
+
/* 확보분은 `{ epc, qty }` 줄이다(2026-09-19, ADR-0076 보탬) — 옛 EPC 목록은 받지 않는다. */
|
|
3372
|
+
allocated: "object[]",
|
|
3373
|
+
bizTransaction: "string",
|
|
3374
|
+
operationsRequestId: "string",
|
|
3375
|
+
dockDoor: "string",
|
|
3376
|
+
windowStartMs: "number",
|
|
3377
|
+
recordTime: "string",
|
|
3378
|
+
/*
|
|
3379
|
+
* 이 오더를 어느 레시피로 돌리나 — 「이 로트를 무엇으로 만들었나」가 이 칸을 지나 답한다.
|
|
3380
|
+
*
|
|
3381
|
+
* ── 왜 뒤늦게 생겼나 (2026-09-07 측정) ─────────────────────────────────
|
|
3382
|
+
* EPCIS 변환 사건에는 레시피 자리가 없다(표준이 그렇다). 그래서 이력추적이 **변환 → 거래
|
|
3383
|
+
* 식별자 → 그 오더의 `recipeKey`** 로 건너간다(`twin-lineage-query.ts:296-315`).
|
|
3384
|
+
*
|
|
3385
|
+
* 변환이 오더를 가리키게 만든 뒤에 재보니, **가리켜진 오더 행에 그 칸이 없었다.** 실으면
|
|
3386
|
+
* 레코드가 통째로 거절됐다 — `order: 계약에 없는 필드 — recipeKey`. 조용히 버리지 않은 것은
|
|
3387
|
+
* 맞지만, 그래서 실 시스템에서는 그 물음이 계속 답이 없었다.
|
|
3388
|
+
*
|
|
3389
|
+
* 값은 원본에 있다: `job_orders.recipe_key` 35개 중 20개 채움
|
|
3390
|
+
* (`WO-ECU-STD-2609A` = `RECIPE-ECU-STD`).
|
|
3391
|
+
*
|
|
3392
|
+
* 새 어휘가 아니다 — 계약이 `recipeKey` 를 네 자리에서 이미 쓴다. 오더 관측에만 자리가 없었다.
|
|
3393
|
+
*/
|
|
3394
|
+
recipeKey: "string",
|
|
3395
|
+
recipeBasis: "object",
|
|
3396
|
+
materialBasis: "object[]",
|
|
3397
|
+
/* 근거 칸이 빈 까닭 — 닫힌 낱말이다(§`BASIS_UNKNOWN`). 투입이 근거 장치보다 먼저였던 오더도 이행은 사실이다. */
|
|
3398
|
+
basisUnknown: "string",
|
|
3399
|
+
/*
|
|
3400
|
+
* 실패 · 취소로 닫힌 까닭 — 열린 낱말이다(도메인이 소유한다. 구내 반송은 `TRANSPORT_FAILURE_REASON`). 2026-12-04: 반송 지시가
|
|
3401
|
+
* 실패로 닫힐 때(`ORDER_TERMINAL_STATUS` 의 `failed`) 그 사유가 오더에 실린다 — 그 작업은 `cancelled` 로 가서 사유를 들 곳이 없다.
|
|
3402
|
+
*/
|
|
3403
|
+
reasonCode: "string"
|
|
3404
|
+
},
|
|
3405
|
+
/* 상태·종류는 도메인이 소유한다 — 닫지 않는다. 근거가 빈 까닭은 커널이 읽으므로 닫는다. */
|
|
3406
|
+
enums: { basisUnknown: BASIS_UNKNOWN },
|
|
3407
|
+
/*
|
|
3408
|
+
* 확보분의 안쪽을 본다 — 열쇠와 수 둘이다(§`AllocatedQuantity`). 안 보면 틀린 이름이 조용히
|
|
3409
|
+
* 지나가고(`epcs`·`quantity` 따위), 미러는 잡힌 수를 0 으로 읽는다.
|
|
3410
|
+
*/
|
|
3411
|
+
shapes: {
|
|
3412
|
+
materialBasis: {
|
|
3413
|
+
required: ["basisId", "materialId", "revisionId", "revisionNumber", "planId", "contentHash", "businessTime", "material"],
|
|
3414
|
+
fields: { basisId: "string", materialId: "string", revisionId: "string", revisionNumber: "number", planId: "string", contentHash: "string", businessTime: "string" }
|
|
3415
|
+
// Recursive material properties and reference lists are checked by isMaterialExecutionBasis.
|
|
3416
|
+
},
|
|
3417
|
+
recipeBasis: {
|
|
3418
|
+
required: ["basisId", "recipeId", "revisionId", "planId", "contentHash", "businessTime", "recipe"],
|
|
3419
|
+
fields: { basisId: "string", recipeId: "string", revisionId: "string", planId: "string", contentHash: "string", businessTime: "string" }
|
|
3420
|
+
// Owned composition and captured route are additionally checked by isRecipeExecutionBasis below.
|
|
3421
|
+
},
|
|
3422
|
+
allocated: {
|
|
3423
|
+
required: ["epc", "qty"],
|
|
3424
|
+
fields: { epc: "string", qty: "number" },
|
|
3425
|
+
positive: ["qty"]
|
|
3426
|
+
}
|
|
3389
3427
|
}
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3428
|
+
},
|
|
3429
|
+
quality: {
|
|
3430
|
+
eventType: OP_EVENT.quality,
|
|
3431
|
+
match: ["moverId", "good"],
|
|
3432
|
+
matchOrder: 15,
|
|
3433
|
+
identity: "moverId",
|
|
3434
|
+
// vocabulary-guard: allow 저널 와이어 필드
|
|
3435
|
+
/* 누적 카운터가 없으면 OEE 가 양품률을 못 센다 — 판정 하나만으로는 비율이 나오지 않는다. */
|
|
3436
|
+
required: ["moverId", "good", "goodCount", "nonconformingCount"],
|
|
3437
|
+
// vocabulary-guard: allow
|
|
3438
|
+
/*
|
|
3439
|
+
* `taskId` 는 **귀속**이다 — 이 산출이 어느 작업의 것인가. 수량의 뜻은 바뀌지 않는다(설비 누적).
|
|
3440
|
+
*
|
|
3441
|
+
* 왜 필요한가: 작업자가 올리는 실적은 작업 단위인데 이 갈래의 정체는 설비뿐이라, 두 사실이 만나는
|
|
3442
|
+
* 자리가 없었다. 귀속이 없으면 「이 작업에서 몇 개 나왔나」를 저널에서 되짚을 방법이 없다.
|
|
3443
|
+
*
|
|
3444
|
+
* 정체를 `taskId` 로 바꾸지 않는 이유는 OEE 가 설비 단위여서다. 정체를 옮기면 설비 누적을 셀 수
|
|
3445
|
+
* 없어진다.
|
|
3446
|
+
*/
|
|
3447
|
+
fields: { moverId: "string", good: "boolean", goodCount: "number", nonconformingCount: "number", taskId: "string", recordTime: "string" }
|
|
3448
|
+
// vocabulary-guard: allow
|
|
3449
|
+
},
|
|
3450
|
+
/*
|
|
3451
|
+
* **시험 결과** — 대상을 가리켜 들어온다(표준 `TestResult.TestableObjectID`).
|
|
3452
|
+
*
|
|
3453
|
+
* `result` 를 **요구하지 않는다**: 재기만 하고 판정하지 않는 원천이 정상이고, 요구하면 그 원천의
|
|
3454
|
+
* 사실을 아예 담을 수 없다(§`TestResult.result`). 비어 있으면 커널이 선언된 기준으로 판정하고
|
|
3455
|
+
* `derived` 를 세운다 — 판정하지 못하면 비워 둔다.
|
|
3456
|
+
*
|
|
3457
|
+
* `propertyMeasurements` 안쪽은 재검사하지 않는다 — 그 모양은 `PropertyMeasurement` 계약이고,
|
|
3458
|
+
* 여기서 두 번 지키면 두 벌이 된다(설비 `motion` 과 같은 규율).
|
|
3459
|
+
*/
|
|
3460
|
+
/*
|
|
3461
|
+
* **마감된 설비 상태 구간** — 이 설비가 이 구간 동안 이 상태였다.
|
|
3462
|
+
*
|
|
3463
|
+
* ── 전이만으로는 안 되는 이유 (2026-08-30) ───────────────────────────────
|
|
3464
|
+
* 세 가지다. 셋째가 결정적이다.
|
|
3465
|
+
*
|
|
3466
|
+
* 사유가 붙을 자리가 없다 기계가 서는 순간에는 왜 섰는지 아무도 모른다. 작업자가 라인이 다시
|
|
3467
|
+
* 돈 뒤에 적는다. 그 사이에 전이가 더 있으면 어느 전이에 붙일지 정할 수 없다
|
|
3468
|
+
* 계획·비계획을 나중에 정한다 ISO 22400 은 계획정지를 계획 조업 시간에서 빼고 고장은 빼지 않는다.
|
|
3469
|
+
* 그 분류는 전이가 일어난 순간에 모른다
|
|
3470
|
+
* 전이를 내지 않는 정지가 많다 자재 대기 · 앞 공정 대기 · 작업자 부재. 기계는 전원이 켜진 채 `idle`
|
|
3471
|
+
* 이고 신호가 하나도 안 나온다. OEE 에서 가장 크게 깎이는 것이 보통 이 시간이다
|
|
3472
|
+
*
|
|
3473
|
+
* 마지막이 감시 시스템과 MES 가 갈리는 자리이기도 하다. 설비가 말하는 것만 모으면 감시이고,
|
|
3474
|
+
* **설비가 말하지 못하는 것을 사람이 적어 넣는 자리**가 MES 다.
|
|
3475
|
+
*
|
|
3476
|
+
* ── 이름이 `downtime` 이 아닌 이유 ────────────────────────────────────────
|
|
3477
|
+
* 이 구간은 `setup` 과 `planned-stop` 도 나른다. 그 둘은 정지가 아니다. 담는 것은 **상태 구간**이고,
|
|
3478
|
+
* 어느 상태인지는 `status` 가 말한다.
|
|
3479
|
+
*
|
|
3480
|
+
* ── 되돌아가 적는 사실이다 ───────────────────────────────────────────────
|
|
3481
|
+
* 봉투의 사건 시각은 **구간의 끝**(그때 성립한다)이고, 적은 시각은 `recordTime` 이다. 둘이 갈려 있어야
|
|
3482
|
+
* 「언제 일어났나」와 「언제 알았나」를 구별할 수 있다.
|
|
3483
|
+
*/
|
|
3484
|
+
"equipment-period": {
|
|
3485
|
+
eventType: OP_EVENT.equipmentPeriod,
|
|
3486
|
+
match: ["moverId", "status", "from", "to"],
|
|
3487
|
+
matchOrder: 10,
|
|
3488
|
+
identity: "moverId",
|
|
3489
|
+
// vocabulary-guard: allow 저널 와이어 필드 — 전이와 같은 이름을 쓴다
|
|
3490
|
+
required: ["moverId", "status", "from", "to"],
|
|
3491
|
+
// vocabulary-guard: allow 위와 같은 이유
|
|
3492
|
+
fields: {
|
|
3493
|
+
moverId: "string",
|
|
3494
|
+
status: "string",
|
|
3495
|
+
from: "string",
|
|
3496
|
+
to: "string",
|
|
3497
|
+
// vocabulary-guard: allow
|
|
3498
|
+
/* 사람이 정한 사유 — 없을 수 있다(적지 않은 것과 사유가 없는 것은 다르므로 지어내지 않는다). */
|
|
3499
|
+
reasonCode: "string",
|
|
3500
|
+
decidedBy: "string",
|
|
3501
|
+
recordTime: "string",
|
|
3502
|
+
workShiftBasis: "object"
|
|
3503
|
+
},
|
|
3504
|
+
shapes: {
|
|
3505
|
+
workShiftBasis: {
|
|
3506
|
+
required: ["basisId", "arrangementId", "revisionId", "revisionNumber", "planId", "contentHash", "businessTime", "timezone", "shifts", "workDate"],
|
|
3507
|
+
fields: { basisId: "string", arrangementId: "string", revisionId: "string", revisionNumber: "number", planId: "string", contentHash: "string", businessTime: "string", timezone: "string", workDate: "string" }
|
|
3508
|
+
}
|
|
3509
|
+
},
|
|
3510
|
+
enums: { status: EQUIPMENT_STATUS }
|
|
3511
|
+
},
|
|
3512
|
+
/*
|
|
3513
|
+
* **부적합 처분** — 재고 판정을 받은 것을 어떻게 하기로 정했나.
|
|
3514
|
+
*
|
|
3515
|
+
* ── 이 통이 늦게 생긴 이유 (2026-08-30) ──────────────────────────────────
|
|
3516
|
+
* 사건 이름(`OP_EVENT.disposition`)과 모양(`DispositionFact`)을 먼저 만들고 **여기로 오는 길을
|
|
3517
|
+
* 내지 않았다.** 그래서 처분 사실을 보내면 어느 통도 아니어서 떨어진 목록에도 남지 않고 사라졌다.
|
|
3518
|
+
* MES 전문가가 소스를 읽다 찾았다.
|
|
3519
|
+
*
|
|
3520
|
+
* 이 파일의 위 주석이 말한 부류 그대로다 — `OP_EVENT.test` 와 `OP_EVENT.observation` 이 같은 일을
|
|
3521
|
+
* 겪었고 이번이 셋째다. **계약에 자리를 만드는 것과 그 자리로 가는 길을 내는 것은 다른 일이다.**
|
|
3522
|
+
*
|
|
3523
|
+
* ── 판정과 다른 사실이다 ─────────────────────────────────────────────────
|
|
3524
|
+
* 근거가 된 판정(`specId`)을 가리킬 수 있지만 **필수가 아니다** — 판정 없이 현장 재량으로 빼는 일이
|
|
3525
|
+
* 정상이다. 그래서 정체성은 처분 대상(`subjectId`)이다.
|
|
3526
|
+
*/
|
|
3527
|
+
disposition: {
|
|
3528
|
+
eventType: OP_EVENT.disposition,
|
|
3529
|
+
match: ["subjectId", "decision"],
|
|
3530
|
+
matchOrder: 80,
|
|
3531
|
+
identity: "subjectId",
|
|
3532
|
+
/* 무엇을 어떻게 하기로 했나 — 둘 중 하나가 없으면 그 결정은 아무 데도 붙지 못한다. */
|
|
3533
|
+
required: ["subjectId", "decision"],
|
|
3534
|
+
fields: {
|
|
3535
|
+
subjectId: "string",
|
|
3536
|
+
decision: "string",
|
|
3537
|
+
quantity: "number",
|
|
3538
|
+
uom: "string",
|
|
3539
|
+
specId: "string",
|
|
3540
|
+
decidedBy: "string",
|
|
3541
|
+
reason: "string",
|
|
3542
|
+
decidedAt: "string",
|
|
3543
|
+
recordTime: "string"
|
|
3544
|
+
},
|
|
3545
|
+
enums: { decision: DISPOSITION_DECISION }
|
|
3546
|
+
},
|
|
3547
|
+
/*
|
|
3548
|
+
* **로트 상태** — ISA-95 `MaterialLot.Status`. 출하 승인(batch release)이 들어오는 문(§`OP_EVENT.materialLot`).
|
|
3549
|
+
*
|
|
3550
|
+
* `disposition`(subjectId + decision) 과 필드가 겹치지 않는다 — 여기는 `lotId` + `status`. 정체 이름이 표준
|
|
3551
|
+
* `MaterialLotID` 인 이유가 하나 더 있다: 이 문은 `epc` 를 든 레코드를 EPCIS 어휘로 보고 받지 않는다
|
|
3552
|
+
* (§`operationalKindOf`). 값은 로트의 식별자(`ItemState.epc` 와 같은 값)다. 상태 낱말은 열려 있어 enum 이
|
|
3553
|
+
* 없다(오더 상태와 같은 규율). 로트 전체의 사실이므로 부분(`subLotId`)은 받지 않는다 — 부분마다 다른 상태가
|
|
3554
|
+
* 필요해지면 그것은 다른 사실이다.
|
|
3555
|
+
*
|
|
3556
|
+
* ── 낱말은 열리고 **효과는 닫힌다** (2026-09-19, ADR-0080 결정 2) ────────────
|
|
3557
|
+
* `status` 는 현장의 낱말이다(`on-hold` · `quarantine` · `검사대기` — 도메인이 소유한다). 커널이 그
|
|
3558
|
+
* 낱말을 읽어 「보류면 할당에서 뺀다」를 정하면, 현장이 다른 낱말을 쓰는 날 조용히 샌다.
|
|
3559
|
+
*
|
|
3560
|
+
* 그래서 **효과를 따로 싣는다**: `use` 는 닫힌 둘(`allowed` · `blocked`)이고 기계가 읽는다. 낱말의
|
|
3561
|
+
* 주인이 둘을 같이 정한다 — 자원 속성에서 이미 선 원칙 그대로다(속성은 열리고 효과는 닫힌다).
|
|
3562
|
+
*
|
|
3563
|
+
* **`use` 가 없는 레코드는 `allowed` 가 아니라 「모름」이다.** 그래서 필수로 만들지 않는다: 이 문을
|
|
3564
|
+
* 이미 쓰고 있는 원본이 있으면 그 사실이 통째로 거절되는 것이 더 나쁘다. 모르는 것을 할당이 어떻게
|
|
3565
|
+
* 다루는지는 커널이 한 곳에서 정하고 그 수를 센다.
|
|
3566
|
+
*/
|
|
3567
|
+
"material-lot": {
|
|
3568
|
+
eventType: OP_EVENT.materialLot,
|
|
3569
|
+
match: ["lotId", "status"],
|
|
3570
|
+
matchOrder: 85,
|
|
3571
|
+
identity: "lotId",
|
|
3572
|
+
required: ["lotId", "status"],
|
|
3573
|
+
fields: { lotId: "string", status: "string", use: "string", decidedBy: "string", reason: "string", decidedAt: "string", recordTime: "string" },
|
|
3574
|
+
enums: { use: MATERIAL_LOT_USE }
|
|
3575
|
+
},
|
|
3576
|
+
test: {
|
|
3577
|
+
eventType: OP_EVENT.test,
|
|
3578
|
+
match: ["testableObjectId"],
|
|
3579
|
+
matchOrder: 70,
|
|
3580
|
+
identity: "testableObjectId",
|
|
3581
|
+
/* 무엇을 어느 기준으로 시험했나 — 둘 중 하나가 없으면 그 결과는 아무 데도 붙지 못한다. */
|
|
3582
|
+
required: ["testableObjectId", "specId"],
|
|
3583
|
+
fields: {
|
|
3584
|
+
testableObjectId: "string",
|
|
3585
|
+
specId: "string",
|
|
3586
|
+
result: "string",
|
|
3587
|
+
at: "string",
|
|
3588
|
+
expiresAt: "string",
|
|
3589
|
+
derived: "boolean",
|
|
3590
|
+
propertyMeasurements: "object[]",
|
|
3591
|
+
specificationBasis: "object",
|
|
3592
|
+
recordTime: "string"
|
|
3593
|
+
},
|
|
3594
|
+
shapes: {
|
|
3595
|
+
specificationBasis: {
|
|
3596
|
+
required: ["id", "revisionId", "planId", "contentHash", "businessTime", "criteria"],
|
|
3597
|
+
fields: { id: "string", revisionId: "string", planId: "string", contentHash: "string", businessTime: "string" }
|
|
3598
|
+
}
|
|
3599
|
+
},
|
|
3600
|
+
enums: { result: ["pass", "fail"] }
|
|
3601
|
+
},
|
|
3602
|
+
/*
|
|
3603
|
+
* **자리의 물리 관측** — 어느 자리의 어느 속성을 언제 얼마로 쟀나.
|
|
3604
|
+
*
|
|
3605
|
+
* 값에 **단위를 함께** 받는다(`ValueType`). 단위 없는 물리량은 판정의 재료가 못 된다 — 3 이 섭씨인지
|
|
3606
|
+
* 화씨인지 모르면 어떤 기준으로도 판정할 수 없다. 다만 **요구하지는 않는다**: 단위를 비우는 실 원본이
|
|
3607
|
+
* 흔하고, 요구하면 그 원본의 관측을 아예 담지 못한다(그때 판정은 커널이 거부한다 — `outsideLimit`).
|
|
3608
|
+
*
|
|
3609
|
+
* `effectiveTime` 도 요구하지 않는다. 없으면 봉투의 시각이 그 자리를 대신한다(§`resolve`) — 원본이
|
|
3610
|
+
* 시각을 말하지 않는 수기 점검이 실재하고, 그때 지어낸 시각보다 폴링 시각이 정직하다.
|
|
3611
|
+
*/
|
|
3612
|
+
/*
|
|
3613
|
+
* **이 목록이 전부다** — 연결된 시스템이 현재 목록을 한 바퀴 다 보낸 뒤 알린다.
|
|
3614
|
+
*
|
|
3615
|
+
* 둘 다 요구한다: 어느 목록인지와 그 주기를 **시작한** 시각. 시각이 없으면 무엇을 지울지 가릴 수
|
|
3616
|
+
* 없고, 그때 지우면 전부 지운다 — 받지 않는 것이 옳다.
|
|
3617
|
+
*/
|
|
3618
|
+
complete: {
|
|
3619
|
+
eventType: OP_EVENT.complete,
|
|
3620
|
+
match: ["completeAxis"],
|
|
3621
|
+
matchOrder: 100,
|
|
3622
|
+
identity: "completeAxis",
|
|
3623
|
+
required: ["completeAxis", "since"],
|
|
3624
|
+
fields: { completeAxis: "string", since: "string", recordTime: "string" }
|
|
3625
|
+
},
|
|
3626
|
+
observation: {
|
|
3627
|
+
eventType: OP_EVENT.observation,
|
|
3628
|
+
match: ["locationId", "propertyId"],
|
|
3629
|
+
matchOrder: 90,
|
|
3630
|
+
identity: "locationId",
|
|
3631
|
+
/* 자리와 속성 — 둘 중 하나가 없으면 그 관측은 아무 데도 붙지 못한다. */
|
|
3632
|
+
required: ["locationId", "propertyId"],
|
|
3633
|
+
fields: {
|
|
3634
|
+
locationId: "string",
|
|
3635
|
+
propertyId: "string",
|
|
3636
|
+
value: "string",
|
|
3637
|
+
dataType: "string",
|
|
3638
|
+
uom: "string",
|
|
3639
|
+
effectiveTime: "string",
|
|
3640
|
+
effectiveEndTime: "string",
|
|
3641
|
+
recordTime: "string",
|
|
3642
|
+
source: "string",
|
|
3643
|
+
derived: "boolean"
|
|
3644
|
+
}
|
|
3645
|
+
},
|
|
3646
|
+
/*
|
|
3647
|
+
* ── 경로망 위의 운행 (2026-12-04, operato-application ADR-0266 결정 8 ②, `travel.ts`) ─────────────────────────────────────
|
|
3648
|
+
*
|
|
3649
|
+
* 구내 반송 제품이 보내는 넷. 사건 이름 · 데이터 모양은 이미 있었고(`OP_EVENT.travel*`, 커널의 접기도 섰다) 들어올 문만 없었다 —
|
|
3650
|
+
* 그래서 이 표에 선다(고칠 자리가 셋인 까닭, 위 `match` 의 머리말).
|
|
3651
|
+
*
|
|
3652
|
+
* 장비를 `equipmentId` 로 부른다(`travel.ts` 의 결정 — 옛 와이어 이름이 아니다). 그 이름은 설비 **에너지** 상태의 것이기도 해서,
|
|
3653
|
+
* 갈래는 **함께 오는 칸**으로 가른다: 지난 자리(`location`) · 잡은 구간(`connectionIds`) · 통신(`link`) · 위치(`pose`). 에너지 문은
|
|
3654
|
+
* 이 넷을 밀어낸다(`isEnergyEquipmentRecord` — 판정끼리 배타). 이 갈래들은 다른 어떤 갈래보다 먼저 본다 — 정체 칸이 다른 갈래와
|
|
3655
|
+
* 겹치지 않으므로 순서는 넷 사이의 것이다.
|
|
3656
|
+
*/
|
|
3657
|
+
"travel-passed": {
|
|
3658
|
+
eventType: OP_EVENT.travelPassed,
|
|
3659
|
+
match: ["equipmentId", "location"],
|
|
3660
|
+
matchOrder: 5,
|
|
3661
|
+
identity: "equipmentId",
|
|
3662
|
+
required: ["equipmentId", "location"],
|
|
3663
|
+
fields: { equipmentId: "string", location: "string", heading: "number", recordTime: "string" }
|
|
3664
|
+
},
|
|
3665
|
+
"travel-reservation": {
|
|
3666
|
+
eventType: OP_EVENT.travelReservation,
|
|
3667
|
+
match: ["equipmentId", "connectionIds"],
|
|
3668
|
+
matchOrder: 5,
|
|
3669
|
+
identity: "equipmentId",
|
|
3670
|
+
/* 빈 목록은 「전부 놓았다」는 말이다 — 비어 있어도 받는다(아래 `ingest` 의 빈 값 규칙은 배열을 비었다고 보지 않는다). */
|
|
3671
|
+
required: ["equipmentId", "connectionIds"],
|
|
3672
|
+
fields: { equipmentId: "string", connectionIds: "string[]", recordTime: "string" }
|
|
3673
|
+
},
|
|
3674
|
+
"travel-link": {
|
|
3675
|
+
eventType: OP_EVENT.travelLink,
|
|
3676
|
+
match: ["equipmentId", "link"],
|
|
3677
|
+
matchOrder: 5,
|
|
3678
|
+
identity: "equipmentId",
|
|
3679
|
+
required: ["equipmentId", "link"],
|
|
3680
|
+
fields: { equipmentId: "string", link: "object", recordTime: "string" },
|
|
3681
|
+
shapes: {
|
|
3682
|
+
link: {
|
|
3683
|
+
required: ["state", "lastSeenAt", "judgedBy"],
|
|
3684
|
+
fields: { lastSeenAt: "string", lastLocation: "string" },
|
|
3685
|
+
enums: { state: TRAVEL_LINK_STATE, judgedBy: TRAVEL_LINK_JUDGED_BY }
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
},
|
|
3689
|
+
"travel-pose": {
|
|
3690
|
+
eventType: OP_EVENT.travelPose,
|
|
3691
|
+
match: ["equipmentId", "pose"],
|
|
3692
|
+
matchOrder: 5,
|
|
3693
|
+
identity: "equipmentId",
|
|
3694
|
+
required: ["equipmentId", "pose"],
|
|
3695
|
+
fields: { equipmentId: "string", pose: "object", recordTime: "string" },
|
|
3696
|
+
shapes: {
|
|
3697
|
+
pose: {
|
|
3698
|
+
required: ["x", "y", "theta", "networkVersion", "at"],
|
|
3699
|
+
fields: { x: "number", y: "number", theta: "number", networkVersion: "string", at: "string", deviationM: "number" }
|
|
3700
|
+
}
|
|
3393
3701
|
}
|
|
3394
|
-
const data = {
|
|
3395
|
-
from: span.from,
|
|
3396
|
-
to: span.to,
|
|
3397
|
-
...billingDemandKW !== void 0 ? { billingDemandKW } : {},
|
|
3398
|
-
...demandChargePerKW !== void 0 ? { demandChargePerKW } : {},
|
|
3399
|
-
...currency ? { currency } : {}
|
|
3400
|
-
};
|
|
3401
|
-
accepted.push({
|
|
3402
|
-
eventId: periodFactId(opts.tenantId, ENERGY_EVENT.tariffBasis, "", span.from, span.to),
|
|
3403
|
-
eventType: ENERGY_EVENT.tariffBasis,
|
|
3404
|
-
/* **시작 시각**이다 — 그때부터 유효하다(§ 위 주석). */
|
|
3405
|
-
eventTime: span.from,
|
|
3406
|
-
tenantId: opts.tenantId,
|
|
3407
|
-
data
|
|
3408
|
-
});
|
|
3409
3702
|
}
|
|
3410
|
-
|
|
3703
|
+
};
|
|
3704
|
+
var TRAVEL_KINDS = Object.keys(SPECS).filter((kind) => SPECS[kind].identity === "equipmentId");
|
|
3705
|
+
function isTravelRecord(record) {
|
|
3706
|
+
const kind = operationalKindOf(record);
|
|
3707
|
+
return kind !== void 0 && TRAVEL_KINDS.includes(kind);
|
|
3411
3708
|
}
|
|
3412
|
-
function
|
|
3709
|
+
function operationalKindOf(record) {
|
|
3710
|
+
if (!record || typeof record !== "object") return void 0;
|
|
3413
3711
|
const r = record;
|
|
3414
|
-
if (
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
const
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
if (declared) return { subject: declared, basis: "declared" };
|
|
3429
|
-
return { subject: opts.scopeId ? `${opts.scopeId}/${localId}` : localId, basis: "twin-local" };
|
|
3712
|
+
if (r.epc !== void 0 || r.meterId !== void 0) return void 0;
|
|
3713
|
+
const travelOnly = r.equipmentId !== void 0;
|
|
3714
|
+
const present = (k) => {
|
|
3715
|
+
const v = r[k];
|
|
3716
|
+
if (v === void 0 || v === null) return false;
|
|
3717
|
+
return typeof v === "string" ? v.trim().length > 0 : true;
|
|
3718
|
+
};
|
|
3719
|
+
for (const kind of MATCH_ORDER) {
|
|
3720
|
+
const spec = SPECS[kind];
|
|
3721
|
+
if (travelOnly !== (spec.identity === "equipmentId")) continue;
|
|
3722
|
+
const fields = spec.match ?? [spec.identity];
|
|
3723
|
+
if (fields.every(present)) return kind;
|
|
3724
|
+
}
|
|
3725
|
+
return void 0;
|
|
3430
3726
|
}
|
|
3431
|
-
function
|
|
3432
|
-
|
|
3727
|
+
function unknownKindReason() {
|
|
3728
|
+
const shapes = MATCH_ORDER.map((kind) => {
|
|
3729
|
+
const spec = SPECS[kind];
|
|
3730
|
+
const fields = spec.match ?? [spec.identity];
|
|
3731
|
+
return `${kind}: ${fields.join("+")}`;
|
|
3732
|
+
});
|
|
3733
|
+
return `\uC6B4\uC601 \uB808\uCF54\uB4DC\uC758 \uC720\uD615\uC744 \uD310\uBCC4\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. \uC720\uD615\uC744 \uC2DD\uBCC4\uD560 \uD544\uB4DC\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4(${shapes.join(" \xB7 ")}). epc\uAC00 \uD3EC\uD568\uB41C \uB808\uCF54\uB4DC\uB294 EPCIS \uCC98\uB9AC \uACBD\uB85C\uC5D0 \uC81C\uCD9C\uD558\uC138\uC694.`;
|
|
3433
3734
|
}
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
if (!from || !Number.isFinite(fromMs)) errors.push(`from \uC744 \uC2DC\uAC01\uC73C\uB85C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${JSON.stringify(r?.from)}`);
|
|
3440
|
-
if (!to || !Number.isFinite(toMs)) errors.push(`to \uB97C \uC2DC\uAC01\uC73C\uB85C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${JSON.stringify(r?.to)}`);
|
|
3441
|
-
if (Number.isFinite(fromMs) && Number.isFinite(toMs) && !(toMs > fromMs)) {
|
|
3442
|
-
errors.push(`\uAD6C\uAC04\uC774 \uB4A4\uC9D1\uD614\uAC70\uB098 \uAE38\uC774\uAC00 \uC5C6\uB2E4(${from} \u2192 ${to}) \u2014 \uC5B4\uB290 \uCABD\uC774 \uD2C0\uB838\uB294\uC9C0 \uC6B0\uB9AC\uAC00 \uC815\uD560 \uC218 \uC5C6\uB2E4`);
|
|
3443
|
-
}
|
|
3444
|
-
return errors.length ? void 0 : { from, to };
|
|
3735
|
+
var MATCH_ORDER = Object.keys(SPECS).sort(
|
|
3736
|
+
(a, b) => (SPECS[a].matchOrder ?? 1e3) - (SPECS[b].matchOrder ?? 1e3)
|
|
3737
|
+
);
|
|
3738
|
+
function operationalIdentityField(kind) {
|
|
3739
|
+
return kind ? SPECS[kind]?.identity : void 0;
|
|
3445
3740
|
}
|
|
3446
|
-
function
|
|
3447
|
-
|
|
3448
|
-
const v = Number(raw);
|
|
3449
|
-
if (!Number.isFinite(v)) {
|
|
3450
|
-
errors.push(`${name} \uB97C \uC218\uB85C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${JSON.stringify(raw)}`);
|
|
3451
|
-
return void 0;
|
|
3452
|
-
}
|
|
3453
|
-
if (v < 0) {
|
|
3454
|
-
errors.push(`${name} \uAC00 \uC74C\uC218\uB2E4(${v})`);
|
|
3455
|
-
return void 0;
|
|
3456
|
-
}
|
|
3457
|
-
return v;
|
|
3741
|
+
function isOperationalRecord(record) {
|
|
3742
|
+
return operationalKindOf(record) !== void 0;
|
|
3458
3743
|
}
|
|
3459
|
-
function
|
|
3460
|
-
const
|
|
3744
|
+
function ingestOperationalRecords(records, opts) {
|
|
3745
|
+
const arr = Array.isArray(records) ? records : records ? [records] : [];
|
|
3461
3746
|
const accepted = [];
|
|
3462
3747
|
const rejected = [];
|
|
3463
|
-
|
|
3748
|
+
let seq = 0;
|
|
3749
|
+
for (const record of arr) {
|
|
3750
|
+
const kind = operationalKindOf(record);
|
|
3751
|
+
if (!kind) {
|
|
3752
|
+
rejected.push({ record, errors: [unknownKindReason()] });
|
|
3753
|
+
continue;
|
|
3754
|
+
}
|
|
3755
|
+
const spec = SPECS[kind];
|
|
3756
|
+
const r = record;
|
|
3464
3757
|
const errors = [];
|
|
3465
|
-
const
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
const
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
errors.push("kWh \uAC00 \uC5C6\uB2E4 \u2014 \uC774 \uBB38\uC774 \uBC1B\uB294 \uAC12\uC740 \uADF8 \uAD6C\uAC04\uC5D0 \uC4F4 \uC591\uC774\uB2E4");
|
|
3472
|
-
} else {
|
|
3473
|
-
kWh = readAmount(rawKWh, "kWh", errors);
|
|
3758
|
+
const ENVELOPE_FIELDS = ["at", "description"];
|
|
3759
|
+
const unknown = Object.keys(r).filter((k) => !ENVELOPE_FIELDS.includes(k) && spec.fields[k] === void 0);
|
|
3760
|
+
if (unknown.length) errors.push(`${kind}: \uACC4\uC57D\uC5D0 \uC5C6\uB294 \uD544\uB4DC \u2014 ${unknown.join(", ")}`);
|
|
3761
|
+
for (const name of spec.required) {
|
|
3762
|
+
const v = r[name];
|
|
3763
|
+
if (v === void 0 || v === null || v === "") errors.push(`${kind}: ${name}: \uD544\uC218 \uAC12 \uB204\uB77D`);
|
|
3474
3764
|
}
|
|
3475
|
-
const
|
|
3476
|
-
const
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3765
|
+
const data = {};
|
|
3766
|
+
for (const [name, type] of Object.entries(spec.fields)) {
|
|
3767
|
+
const v = r[name];
|
|
3768
|
+
if (v === void 0 || v === null || v === "") continue;
|
|
3769
|
+
switch (type) {
|
|
3770
|
+
case "string": {
|
|
3771
|
+
if (typeof v !== "string") {
|
|
3772
|
+
errors.push(`${kind}.${name} \uAC12\uC740 \uBB38\uC790\uC5F4\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
3773
|
+
break;
|
|
3774
|
+
}
|
|
3775
|
+
const allowed = spec.enums?.[name];
|
|
3776
|
+
if (allowed && !allowed.includes(v)) {
|
|
3777
|
+
errors.push(`${kind}.${name}\uC5D0 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uAC12\uC774 \uC9C0\uC815\uB418\uC5C8\uC2B5\uB2C8\uB2E4: ${JSON.stringify(v)} \u2014 \uD5C8\uC6A9 \uAC12: ${allowed.join(" \xB7 ")}`);
|
|
3778
|
+
break;
|
|
3779
|
+
}
|
|
3780
|
+
data[name] = v;
|
|
3781
|
+
break;
|
|
3782
|
+
}
|
|
3783
|
+
case "number": {
|
|
3784
|
+
const n = Number(v);
|
|
3785
|
+
if (typeof v === "boolean" || !Number.isFinite(n)) {
|
|
3786
|
+
errors.push(`${kind}.${name} \uAC12\uC740 \uC720\uD55C\uD55C \uC22B\uC790\uC5EC\uC57C \uD569\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
3787
|
+
break;
|
|
3788
|
+
}
|
|
3789
|
+
if (name === "progress" && (n < 0 || n > 1)) {
|
|
3790
|
+
errors.push(`${kind}.progress \uB294 0~1 \uBE44\uC728\uC774\uB2E4: ${n}`);
|
|
3791
|
+
break;
|
|
3792
|
+
}
|
|
3793
|
+
if ((name === "requested" || name === "fulfilled" || name === "goodCount" || name === "nonconformingCount") && n < 0) {
|
|
3794
|
+
errors.push(`${kind}.${name} \uAC00 \uC74C\uC218\uB2E4: ${n}`);
|
|
3795
|
+
break;
|
|
3796
|
+
}
|
|
3797
|
+
data[name] = n;
|
|
3798
|
+
break;
|
|
3799
|
+
}
|
|
3800
|
+
case "boolean": {
|
|
3801
|
+
if (typeof v !== "boolean") {
|
|
3802
|
+
errors.push(`${kind}.${name} \uAC12\uC740 \uBD88\uB9AC\uC5B8\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
3803
|
+
break;
|
|
3804
|
+
}
|
|
3805
|
+
data[name] = v;
|
|
3806
|
+
break;
|
|
3807
|
+
}
|
|
3808
|
+
case "string[]": {
|
|
3809
|
+
if (!Array.isArray(v) || v.some((x) => typeof x !== "string")) {
|
|
3810
|
+
errors.push(`${kind}.${name} \uAC12\uC740 \uBB38\uC790\uC5F4 \uBC30\uC5F4\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
3811
|
+
break;
|
|
3812
|
+
}
|
|
3813
|
+
data[name] = v.slice();
|
|
3814
|
+
break;
|
|
3815
|
+
}
|
|
3816
|
+
case "object": {
|
|
3817
|
+
if (Array.isArray(v) || typeof v !== "object") {
|
|
3818
|
+
errors.push(`${kind}.${name} \uAC12\uC740 \uAC1D\uCCB4\uC5EC\uC57C \uD569\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
3819
|
+
break;
|
|
3820
|
+
}
|
|
3821
|
+
errors.push(...shapeErrors(`${kind}.${name}`, v, spec.shapes?.[name]));
|
|
3822
|
+
data[name] = { ...v };
|
|
3823
|
+
break;
|
|
3824
|
+
}
|
|
3825
|
+
case "object[]": {
|
|
3826
|
+
if (!Array.isArray(v) || v.some((x) => !x || typeof x !== "object")) {
|
|
3827
|
+
errors.push(`${kind}.${name} \uAC12\uC740 \uAC1D\uCCB4 \uBC30\uC5F4\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
3828
|
+
break;
|
|
3829
|
+
}
|
|
3830
|
+
v.forEach(
|
|
3831
|
+
(x, i) => errors.push(...shapeErrors(`${kind}.${name}[${i}]`, x, spec.shapes?.[name]))
|
|
3832
|
+
);
|
|
3833
|
+
data[name] = v.map((x) => ({ ...x }));
|
|
3834
|
+
break;
|
|
3835
|
+
}
|
|
3836
|
+
}
|
|
3486
3837
|
}
|
|
3487
|
-
if (
|
|
3488
|
-
|
|
3489
|
-
|
|
3838
|
+
if ((kind === "task" || kind === "equipment-period") && r.workShiftBasis !== void 0) {
|
|
3839
|
+
if (!isWorkShiftExecutionBasis(r.workShiftBasis) || kind === "equipment-period" && Date.parse(r.workShiftBasis.businessTime) !== Date.parse(String(r.from)) || kind === "task" && (r.startTime ?? r.endTime) !== void 0 && Date.parse(r.workShiftBasis.businessTime) !== Date.parse(String(r.startTime ?? r.endTime))) {
|
|
3840
|
+
errors.push(kind + ".workShiftBasis: invalid pinned shift evidence");
|
|
3841
|
+
} else data.workShiftBasis = structuredClone(r.workShiftBasis);
|
|
3490
3842
|
}
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
const
|
|
3505
|
-
if (
|
|
3506
|
-
|
|
3843
|
+
if (kind === "test" && r.specificationBasis !== void 0 && !isTestSpecificationBasis(r.specificationBasis)) {
|
|
3844
|
+
errors.push("test.specificationBasis: invalid pinned specification evidence");
|
|
3845
|
+
}
|
|
3846
|
+
if (kind === "order" && r.materialBasis !== void 0) {
|
|
3847
|
+
const bases = r.materialBasis;
|
|
3848
|
+
if (!Array.isArray(bases) || !bases.length || bases.length > 1e3 || !bases.every(isMaterialExecutionBasis) || new Set(bases.map((b) => b.material.id)).size !== bases.length || r.gtin !== void 0 && !bases.some((b) => b.material.id === r.gtin) || isRecipeExecutionBasis(r.recipeBasis) && [...r.recipeBasis.recipe.inputs, ...r.recipeBasis.recipe.outputs].some((line) => !bases.some((b) => b.material.id === line.material)))
|
|
3849
|
+
errors.push("order.materialBasis: invalid pinned material evidence");
|
|
3850
|
+
}
|
|
3851
|
+
if (kind === "order" && r.recipeBasis !== void 0 && (!isRecipeExecutionBasis(r.recipeBasis) || r.recipeKey !== void 0 && r.recipeKey !== r.recipeBasis.recipe.key)) {
|
|
3852
|
+
errors.push("order.recipeBasis: invalid pinned recipe evidence");
|
|
3853
|
+
}
|
|
3854
|
+
const closedPeriodEnd = kind === "equipment-period" ? String(r.to ?? "").trim() : "";
|
|
3855
|
+
const at2 = closedPeriodEnd || String(r.at ?? "").trim() || opts.defaultEventTime;
|
|
3856
|
+
const atMs = at2 ? Date.parse(at2) : Number.NaN;
|
|
3857
|
+
if (!Number.isFinite(atMs)) {
|
|
3858
|
+
errors.push(`${kind}: at \uC5C6\uC74C/\uD615\uC2DD \uC624\uB958 \u2014 \uC774\uC804 \uC774\uBCA4\uD2B8\uAC00 \uB4A4\uB2A6\uAC8C \uB3C4\uCC29\uD588\uB294\uC9C0 \uD310\uB2E8\uD558\uB824\uBA74 \uC2DC\uAC01\uC774 \uD544\uC694\uD569\uB2C8\uB2E4.`);
|
|
3859
|
+
}
|
|
3860
|
+
if (closedPeriodEnd && opts.defaultEventTime) {
|
|
3861
|
+
const nowMs = Date.parse(opts.defaultEventTime);
|
|
3862
|
+
if (Number.isFinite(nowMs) && Number.isFinite(atMs) && atMs > nowMs) {
|
|
3863
|
+
errors.push(`${kind}: \uC544\uC9C1 \uC624\uC9C0 \uC54A\uC740 \uC2DC\uAC01\uC758 \uC0AC\uC2E4\uC774\uB2E4(${closedPeriodEnd}) \u2014 \uC885\uB8CC\uB41C \uAD6C\uAC04\uB9CC \uB9C8\uAC10\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`);
|
|
3864
|
+
}
|
|
3865
|
+
}
|
|
3866
|
+
if (errors.length) {
|
|
3867
|
+
rejected.push({ record, errors });
|
|
3507
3868
|
continue;
|
|
3508
3869
|
}
|
|
3870
|
+
const note = typeof r.description === "string" ? String(r.description).trim() : "";
|
|
3509
3871
|
accepted.push({
|
|
3510
|
-
eventId:
|
|
3511
|
-
eventType:
|
|
3512
|
-
|
|
3513
|
-
eventTime: span.to,
|
|
3872
|
+
eventId: `${opts.tenantId}-op-${kind}-${++seq}`,
|
|
3873
|
+
eventType: spec.eventType,
|
|
3874
|
+
eventTime: new Date(atMs).toISOString(),
|
|
3514
3875
|
tenantId: opts.tenantId,
|
|
3876
|
+
...note ? { description: note } : {},
|
|
3515
3877
|
data
|
|
3516
3878
|
});
|
|
3517
3879
|
}
|
|
3518
3880
|
return { accepted, rejected };
|
|
3519
3881
|
}
|
|
3520
|
-
|
|
3521
|
-
|
|
3882
|
+
|
|
3883
|
+
// src/energy-ingest.ts
|
|
3884
|
+
function isEnergyRecord(record) {
|
|
3885
|
+
if (!record || typeof record !== "object") return false;
|
|
3886
|
+
const r = record;
|
|
3887
|
+
if (!(typeof r.meterId === "string" && r.meterId.trim().length > 0 && r.epc === void 0)) return false;
|
|
3888
|
+
return r.from === void 0 && r.to === void 0;
|
|
3889
|
+
}
|
|
3890
|
+
function ingestEnergyRecords(records, opts) {
|
|
3891
|
+
const arr = Array.isArray(records) ? records : records ? [records] : [];
|
|
3522
3892
|
const accepted = [];
|
|
3523
3893
|
const rejected = [];
|
|
3524
|
-
|
|
3894
|
+
let seq = 0;
|
|
3895
|
+
for (const record of arr) {
|
|
3525
3896
|
const errors = [];
|
|
3526
|
-
const
|
|
3527
|
-
|
|
3528
|
-
const
|
|
3529
|
-
const
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3897
|
+
const meterId = String(record?.meterId ?? "").trim();
|
|
3898
|
+
if (!meterId) errors.push("meterId \uC5C6\uC74C \u2014 \uC5B4\uB514\uC758 \uC18C\uBE44\uC778\uC9C0 \uBAA8\uB974\uB294 \uAC12\uC740 \uB204\uC801\uD560 \uC218 \uC5C6\uB2E4");
|
|
3899
|
+
const at2 = String(record?.at ?? "").trim() || opts.defaultEventTime;
|
|
3900
|
+
const atMs = at2 ? Date.parse(at2) : Number.NaN;
|
|
3901
|
+
if (!Number.isFinite(atMs)) errors.push("at \uC5C6\uC74C/\uD615\uC2DD \uC624\uB958 \u2014 \uC9C0\uAE08 \uC2DC\uAC01\uC73C\uB85C \uBA54\uC6B0\uBA74 \uB0A8\uC758 \uC218\uC694 \uAD6C\uAC04\uC5D0 \uC2E4\uB9B0\uB2E4");
|
|
3902
|
+
const num2 = (v, name) => {
|
|
3903
|
+
if (v === void 0 || v === null || v === "") return void 0;
|
|
3904
|
+
const n = Number(v);
|
|
3905
|
+
if (!Number.isFinite(n)) {
|
|
3906
|
+
errors.push(`${name} \uAC00 \uC218\uAC00 \uC544\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
3907
|
+
return void 0;
|
|
3908
|
+
}
|
|
3909
|
+
return n;
|
|
3910
|
+
};
|
|
3911
|
+
const kW = num2(record?.kW, "kW");
|
|
3912
|
+
const kWh = num2(record?.kWh, "kWh");
|
|
3913
|
+
const powerFactor = num2(record?.powerFactor, "powerFactor");
|
|
3914
|
+
if (errors.length) {
|
|
3915
|
+
rejected.push({ record, errors });
|
|
3538
3916
|
continue;
|
|
3539
3917
|
}
|
|
3918
|
+
const eventTime = new Date(atMs).toISOString();
|
|
3540
3919
|
const data = {
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
...
|
|
3545
|
-
...
|
|
3546
|
-
...
|
|
3547
|
-
|
|
3920
|
+
meterId,
|
|
3921
|
+
/* 계약은 `kW` 를 필수로 두지만 **못 읽은 표본도 사실**이다 — 그 경우 값을 비우고 보낸다.
|
|
3922
|
+
커널이 「받았지만 부하를 못 읽었다」로 세고, 구간 마감에 그 이유를 싣는다. */
|
|
3923
|
+
...kW !== void 0 ? { kW } : {},
|
|
3924
|
+
...kWh !== void 0 ? { kWh } : {},
|
|
3925
|
+
...powerFactor !== void 0 ? { powerFactor } : {},
|
|
3926
|
+
at: eventTime
|
|
3548
3927
|
};
|
|
3549
|
-
const futureError = futureFactError(span.to, opts);
|
|
3550
|
-
if (futureError) {
|
|
3551
|
-
rejected.push({ record: r, errors: [futureError] });
|
|
3552
|
-
continue;
|
|
3553
|
-
}
|
|
3554
3928
|
accepted.push({
|
|
3555
|
-
eventId:
|
|
3556
|
-
eventType: ENERGY_EVENT.
|
|
3557
|
-
eventTime
|
|
3929
|
+
eventId: `${opts.tenantId}-energy-${++seq}`,
|
|
3930
|
+
eventType: ENERGY_EVENT.measured,
|
|
3931
|
+
eventTime,
|
|
3558
3932
|
tenantId: opts.tenantId,
|
|
3559
3933
|
data
|
|
3560
3934
|
});
|
|
3561
3935
|
}
|
|
3562
3936
|
return { accepted, rejected };
|
|
3563
3937
|
}
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
case "end-not-after-start":
|
|
3613
|
-
return `${issue.field}: must be after fromTime (${p.from}~${p.to}); a band crossing midnight is two rows`;
|
|
3614
|
-
case "flat-and-bands":
|
|
3615
|
-
return `${issue.field}: the tariff has bands - leave its flat charge empty`;
|
|
3616
|
-
case "broken-bands":
|
|
3617
|
-
return `${issue.field}: ${p.count} band(s) break the row rules and were left out`;
|
|
3618
|
-
case "gap":
|
|
3619
|
-
return `${issue.field}: ${p.dayKind} ${p.days} - no band ${p.from}~${p.to}`;
|
|
3620
|
-
case "overlap":
|
|
3621
|
-
return `${issue.field}: ${p.dayKind} ${p.days} - ${p.bands} overlap ${p.from}~${p.to}`;
|
|
3622
|
-
}
|
|
3623
|
-
}
|
|
3624
|
-
var empty = (v) => v === void 0 || v === null || typeof v === "string" && v.trim() === "";
|
|
3625
|
-
function isIso4217Code(value) {
|
|
3626
|
-
return typeof value === "string" && /^[A-Z]{3}$/.test(value);
|
|
3627
|
-
}
|
|
3628
|
-
function amountOf(v, field, issues) {
|
|
3629
|
-
if (empty(v)) return void 0;
|
|
3630
|
-
const n = Number(v);
|
|
3631
|
-
if (!Number.isFinite(n)) {
|
|
3632
|
-
issues.push({ field, code: "not-a-number", params: { value: String(v) } });
|
|
3633
|
-
return void 0;
|
|
3634
|
-
}
|
|
3635
|
-
if (n < 0) {
|
|
3636
|
-
issues.push({ field, code: "negative", params: { value: n } });
|
|
3637
|
-
return void 0;
|
|
3638
|
-
}
|
|
3639
|
-
return n;
|
|
3640
|
-
}
|
|
3641
|
-
function minutesOf(text) {
|
|
3642
|
-
const m = /^(\d{2}):(\d{2})$/.exec(String(text ?? "").trim());
|
|
3643
|
-
if (!m) return void 0;
|
|
3644
|
-
const h = Number(m[1]);
|
|
3645
|
-
const min = Number(m[2]);
|
|
3646
|
-
if (min > 59) return void 0;
|
|
3647
|
-
if (h === 24 && min === 0) return 1440;
|
|
3648
|
-
if (h > 23) return void 0;
|
|
3649
|
-
return h * 60 + min;
|
|
3650
|
-
}
|
|
3651
|
-
var DAYS_IN_MONTH = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
3652
|
-
function dayOfYearOf(text) {
|
|
3653
|
-
const m = /^(\d{2})-(\d{2})$/.exec(String(text ?? "").trim());
|
|
3654
|
-
if (!m) return void 0;
|
|
3655
|
-
const month = Number(m[1]);
|
|
3656
|
-
const day = Number(m[2]);
|
|
3657
|
-
if (month < 1 || month > 12 || day < 1 || day > DAYS_IN_MONTH[month - 1]) return void 0;
|
|
3658
|
-
let n = 0;
|
|
3659
|
-
for (let i = 0; i < month - 1; i++) n += DAYS_IN_MONTH[i];
|
|
3660
|
-
return n + day - 1;
|
|
3661
|
-
}
|
|
3662
|
-
function tariffIssues(row) {
|
|
3663
|
-
const issues = [];
|
|
3664
|
-
const d = amountOf(row.demandChargePerKW, "demandChargePerKW", issues);
|
|
3665
|
-
const e = amountOf(row.energyChargePerKWh, "energyChargePerKWh", issues);
|
|
3666
|
-
const currency = String(row.currency ?? "").trim();
|
|
3667
|
-
if ((d !== void 0 || e !== void 0) && !currency) issues.push({ field: "currency", code: "currency-required" });
|
|
3668
|
-
if (currency && !isIso4217Code(currency)) issues.push({ field: "currency", code: "format", params: { format: "ISO 4217 (KRW, USD)", value: currency } });
|
|
3669
|
-
return issues;
|
|
3670
|
-
}
|
|
3671
|
-
function tariffBandIssues(row) {
|
|
3672
|
-
const issues = [];
|
|
3673
|
-
if (empty(row.tariffName)) issues.push({ field: "tariffName", code: "required" });
|
|
3674
|
-
if (empty(row.band)) issues.push({ field: "band", code: "required" });
|
|
3675
|
-
const loadClass = String(row.loadClass ?? "").trim();
|
|
3676
|
-
if (!loadClass) issues.push({ field: "loadClass", code: "required" });
|
|
3677
|
-
else if (!TARIFF_LOAD_CLASSES.includes(loadClass)) {
|
|
3678
|
-
issues.push({ field: "loadClass", code: "not-in-vocabulary", params: { allowed: TARIFF_LOAD_CLASSES.join("|"), value: loadClass } });
|
|
3679
|
-
}
|
|
3680
|
-
const dayKind = empty(row.dayKind) ? "all" : String(row.dayKind).trim();
|
|
3681
|
-
if (!TARIFF_DAY_KINDS.includes(dayKind)) {
|
|
3682
|
-
issues.push({ field: "dayKind", code: "not-in-vocabulary", params: { allowed: TARIFF_DAY_KINDS.join("|"), value: dayKind } });
|
|
3683
|
-
}
|
|
3684
|
-
const sFromEmpty = empty(row.seasonFrom);
|
|
3685
|
-
const sToEmpty = empty(row.seasonTo);
|
|
3686
|
-
if (sFromEmpty !== sToEmpty) issues.push({ field: sFromEmpty ? "seasonFrom" : "seasonTo", code: "season-pair" });
|
|
3687
|
-
if (!sFromEmpty && dayOfYearOf(row.seasonFrom) === void 0) issues.push({ field: "seasonFrom", code: "format", params: { format: "MM-DD", value: String(row.seasonFrom) } });
|
|
3688
|
-
if (!sToEmpty && dayOfYearOf(row.seasonTo) === void 0) issues.push({ field: "seasonTo", code: "format", params: { format: "MM-DD", value: String(row.seasonTo) } });
|
|
3689
|
-
const from = minutesOf(row.fromTime);
|
|
3690
|
-
const to = minutesOf(row.toTime);
|
|
3691
|
-
if (from === void 0 || from === 1440) issues.push({ field: "fromTime", code: "format", params: { format: "HH:mm 00:00..23:59", value: String(row.fromTime ?? "") } });
|
|
3692
|
-
if (to === void 0 || to === 0) issues.push({ field: "toTime", code: "format", params: { format: "HH:mm 00:01..24:00", value: String(row.toTime ?? "") } });
|
|
3693
|
-
if (from !== void 0 && to !== void 0 && from < 1440 && to > 0 && from >= to) {
|
|
3694
|
-
issues.push({ field: "toTime", code: "end-not-after-start", params: { from: String(row.fromTime), to: String(row.toTime) } });
|
|
3695
|
-
}
|
|
3696
|
-
if (empty(row.energyChargePerKWh)) issues.push({ field: "energyChargePerKWh", code: "required" });
|
|
3697
|
-
else amountOf(row.energyChargePerKWh, "energyChargePerKWh", issues);
|
|
3698
|
-
amountOf(row.demandChargePerKW, "demandChargePerKW", issues);
|
|
3699
|
-
return issues;
|
|
3700
|
-
}
|
|
3701
|
-
function seasonHas(band, dayOfYear) {
|
|
3702
|
-
if (empty(band.seasonFrom) && empty(band.seasonTo)) return true;
|
|
3703
|
-
const from = dayOfYearOf(band.seasonFrom);
|
|
3704
|
-
const to = dayOfYearOf(band.seasonTo);
|
|
3705
|
-
if (from === void 0 || to === void 0) return false;
|
|
3706
|
-
return from <= to ? dayOfYear >= from && dayOfYear <= to : dayOfYear >= from || dayOfYear <= to;
|
|
3707
|
-
}
|
|
3708
|
-
function pricesHolidays(bands) {
|
|
3709
|
-
return bands.some((b) => String(b.dayKind ?? "").trim() === "holiday");
|
|
3710
|
-
}
|
|
3711
|
-
function dayKindOf(at2, holidays, isHoliday) {
|
|
3712
|
-
if (holidays && isHoliday?.(at2.month, at2.day)) return "holiday";
|
|
3713
|
-
return at2.weekday === 0 ? "sunday" : at2.weekday === 6 ? "saturday" : "weekday";
|
|
3714
|
-
}
|
|
3715
|
-
function dayKindHas(band, kind) {
|
|
3716
|
-
const k = empty(band.dayKind) ? "all" : String(band.dayKind).trim();
|
|
3717
|
-
return k === "all" || k === kind;
|
|
3718
|
-
}
|
|
3719
|
-
function activeBands(bands, at2) {
|
|
3720
|
-
return bands.filter((b) => empty(b.effectiveEnd) || new Date(b.effectiveEnd).getTime() > at2.getTime());
|
|
3721
|
-
}
|
|
3722
|
-
var hhmm = (m) => `${String(Math.floor(m / 60)).padStart(2, "0")}:${String(m % 60).padStart(2, "0")}`;
|
|
3723
|
-
function mmdd(dayOfYear) {
|
|
3724
|
-
let month = 0;
|
|
3725
|
-
let rest = dayOfYear;
|
|
3726
|
-
while (rest >= DAYS_IN_MONTH[month]) rest -= DAYS_IN_MONTH[month++];
|
|
3727
|
-
return `${String(month + 1).padStart(2, "0")}-${String(rest + 1).padStart(2, "0")}`;
|
|
3728
|
-
}
|
|
3729
|
-
function tariffCoverageIssues(tariff, bands) {
|
|
3730
|
-
const issues = [];
|
|
3731
|
-
if (!bands.length) return issues;
|
|
3732
|
-
const usable = bands.filter((b) => tariffBandIssues(b).length === 0);
|
|
3733
|
-
if (!empty(tariff.energyChargePerKWh)) issues.push({ field: "energyChargePerKWh", code: "flat-and-bands" });
|
|
3734
|
-
if (!String(tariff.currency ?? "").trim()) issues.push({ field: "currency", code: "currency-required" });
|
|
3735
|
-
const holidays = pricesHolidays(usable);
|
|
3736
|
-
if (holidays && empty(tariff.holidayCalendar)) {
|
|
3737
|
-
issues.push({ field: "holidayCalendar", code: "required", params: { because: "the tariff has holiday bands" } });
|
|
3738
|
-
}
|
|
3739
|
-
const broken = bands.length - usable.length;
|
|
3740
|
-
if (broken) issues.push({ field: "bands", code: "broken-bands", params: { count: broken } });
|
|
3741
|
-
const seen = /* @__PURE__ */ new Map();
|
|
3742
|
-
const note = (kind, day, code, from, to, names) => {
|
|
3743
|
-
const key = [kind, code, from, to, names ?? ""].join("\0");
|
|
3744
|
-
const entry = seen.get(key);
|
|
3745
|
-
if (entry) entry.days.push(day);
|
|
3746
|
-
else {
|
|
3747
|
-
const params = { dayKind: kind, from: hhmm(from), to: hhmm(to) };
|
|
3748
|
-
if (names) params.bands = names;
|
|
3749
|
-
seen.set(key, { problem: { field: "bands", code, params }, days: [day] });
|
|
3938
|
+
var POSITIONS = /* @__PURE__ */ new Set(["open", "closed", "intermediate", "bad"]);
|
|
3939
|
+
function isEnergyEquipmentRecord(record) {
|
|
3940
|
+
if (!record || typeof record !== "object") return false;
|
|
3941
|
+
const r = record;
|
|
3942
|
+
return typeof r.equipmentId === "string" && r.equipmentId.trim().length > 0 && r.epc === void 0 && r.meterId === void 0 && /* 적산을 실었으면 발전이다 — 이 문의 값은 상태이고, 적산은 자기 문이 있다. */
|
|
3943
|
+
r.kWh === void 0 && /* 운행 사실(지난 자리 · 잡은 구간 · 통신 · 위치)도 `equipmentId` 를 싣는다 — 그것은 운영 문의 것이다(2026-12-04). */
|
|
3944
|
+
!isTravelRecord(r);
|
|
3945
|
+
}
|
|
3946
|
+
function ingestEnergyEquipmentRecords(records, opts) {
|
|
3947
|
+
const arr = Array.isArray(records) ? records : records ? [records] : [];
|
|
3948
|
+
const accepted = [];
|
|
3949
|
+
const rejected = [];
|
|
3950
|
+
let seq = 0;
|
|
3951
|
+
for (const record of arr) {
|
|
3952
|
+
const errors = [];
|
|
3953
|
+
const r = record;
|
|
3954
|
+
const equipmentId = String(r?.equipmentId ?? "").trim();
|
|
3955
|
+
if (!equipmentId) errors.push("equipmentId \uC5C6\uC74C \u2014 \uC5B4\uB290 \uC124\uBE44\uC758 \uC0C1\uD0DC\uC778\uC9C0 \uBAA8\uB974\uB294 \uAC12\uC740 \uC2E4\uC744 \uC218 \uC5C6\uB2E4");
|
|
3956
|
+
const at2 = String(r?.at ?? "").trim() || opts.defaultEventTime;
|
|
3957
|
+
const atMs = at2 ? Date.parse(at2) : Number.NaN;
|
|
3958
|
+
if (!Number.isFinite(atMs)) errors.push("at \uC5C6\uC74C/\uD615\uC2DD \uC624\uB958 \u2014 \uC9C0\uAE08 \uC2DC\uAC01\uC73C\uB85C \uBA54\uC6B0\uBA74 \uC5B8\uC81C\uC758 \uC0C1\uD0DC\uC778\uC9C0 \uC54C \uC218 \uC5C6\uB2E4");
|
|
3959
|
+
const num2 = (v, name, min, max) => {
|
|
3960
|
+
if (v === void 0 || v === null || v === "") return void 0;
|
|
3961
|
+
const n = Number(v);
|
|
3962
|
+
if (!Number.isFinite(n)) {
|
|
3963
|
+
errors.push(`${name} \uAC00 \uC218\uAC00 \uC544\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
3964
|
+
return void 0;
|
|
3965
|
+
}
|
|
3966
|
+
if (min !== void 0 && n < min) {
|
|
3967
|
+
errors.push(`${name} \uAC00 ${min} \uBCF4\uB2E4 \uC791\uB2E4: ${n}`);
|
|
3968
|
+
return void 0;
|
|
3969
|
+
}
|
|
3970
|
+
if (max !== void 0 && n > max) {
|
|
3971
|
+
errors.push(`${name} \uAC00 ${max} \uBCF4\uB2E4 \uD06C\uB2E4: ${n}`);
|
|
3972
|
+
return void 0;
|
|
3973
|
+
}
|
|
3974
|
+
return n;
|
|
3975
|
+
};
|
|
3976
|
+
const generatedKW = num2(r?.generatedKW, "generatedKW", 0);
|
|
3977
|
+
const exportKW = num2(r?.exportKW, "exportKW");
|
|
3978
|
+
const soc = num2(r?.soc, "soc", 0, 100);
|
|
3979
|
+
const chargeKW = num2(r?.chargeKW, "chargeKW", 0);
|
|
3980
|
+
const dischargeKW = num2(r?.dischargeKW, "dischargeKW", 0);
|
|
3981
|
+
const minKW = num2(r?.minKW, "minKW", 0);
|
|
3982
|
+
let curtailable;
|
|
3983
|
+
if (r?.curtailable !== void 0 && r?.curtailable !== null) {
|
|
3984
|
+
if (typeof r.curtailable !== "boolean") errors.push(`curtailable \uAC00 \uCC38/\uAC70\uC9D3\uC774 \uC544\uB2C8\uB2E4: ${JSON.stringify(r.curtailable)}`);
|
|
3985
|
+
else curtailable = r.curtailable;
|
|
3750
3986
|
}
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3987
|
+
const dcVoltage = num2(r?.dcVoltage, "dcVoltage", 0);
|
|
3988
|
+
const dcCurrent = num2(r?.dcCurrent, "dcCurrent", 0);
|
|
3989
|
+
const phases = (raw, name) => {
|
|
3990
|
+
if (raw === void 0 || raw === null) return void 0;
|
|
3991
|
+
if (!Array.isArray(raw)) {
|
|
3992
|
+
errors.push(`${name} \uAC00 \uBC30\uC5F4\uC774 \uC544\uB2C8\uB2E4 \u2014 \uC0C1\uBCC4 \uAC12\uC774\uB77C \uBC30\uC5F4\uB85C \uBC1B\uB294\uB2E4(\uB2E8\uC0C1\uC774\uBA74 \uC6D0\uC18C \uD558\uB098): ${JSON.stringify(raw)}`);
|
|
3993
|
+
return void 0;
|
|
3994
|
+
}
|
|
3995
|
+
if (!raw.length) {
|
|
3996
|
+
errors.push(`${name} \uAC00 \uBE48 \uBC30\uC5F4\uC774\uB2E4 \u2014 \uC7B0 \uC0C1\uC774 \uC5C6\uC73C\uBA74 \uADF8 \uCE78\uC744 \uBCF4\uB0B4\uC9C0 \uC54A\uB294\uB2E4`);
|
|
3997
|
+
return void 0;
|
|
3998
|
+
}
|
|
3999
|
+
const out = [];
|
|
4000
|
+
for (const [i, v] of raw.entries()) {
|
|
4001
|
+
const n = Number(v);
|
|
4002
|
+
if (!Number.isFinite(n)) {
|
|
4003
|
+
errors.push(`${name}[${i}] \uB97C \uC218\uB85C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${JSON.stringify(v)}`);
|
|
4004
|
+
return void 0;
|
|
3763
4005
|
}
|
|
4006
|
+
if (n < 0) {
|
|
4007
|
+
errors.push(`${name}[${i}] \uAC00 \uC74C\uC218\uB2E4(${n}) \u2014 \uD06C\uAE30\uB294 \uC74C\uC218\uAC00 \uB418\uC9C0 \uC54A\uB294\uB2E4(\uBC29\uD5A5\uC740 \uB2E4\uB978 \uCD95\uC774 \uB9D0\uD55C\uB2E4)`);
|
|
4008
|
+
return void 0;
|
|
4009
|
+
}
|
|
4010
|
+
out.push(n);
|
|
3764
4011
|
}
|
|
3765
|
-
|
|
4012
|
+
return out;
|
|
4013
|
+
};
|
|
4014
|
+
const acVoltage = phases(r?.acVoltage, "acVoltage");
|
|
4015
|
+
const acCurrent = phases(r?.acCurrent, "acCurrent");
|
|
4016
|
+
if (acVoltage && acCurrent && acVoltage.length !== acCurrent.length) {
|
|
4017
|
+
errors.push(`acVoltage(${acVoltage.length}\uC0C1)\uC640 acCurrent(${acCurrent.length}\uC0C1)\uC758 \uC0C1 \uC218\uAC00 \uB2E4\uB974\uB2E4`);
|
|
3766
4018
|
}
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
for (const d of [...days.slice(1), Infinity]) {
|
|
3773
|
-
if (d === prev + 1) {
|
|
3774
|
-
prev = d;
|
|
3775
|
-
continue;
|
|
3776
|
-
}
|
|
3777
|
-
spans.push(start === prev ? mmdd(start) : `${mmdd(start)}~${mmdd(prev)}`);
|
|
3778
|
-
start = prev = d;
|
|
4019
|
+
let position;
|
|
4020
|
+
if (r?.position !== void 0 && r?.position !== null && r?.position !== "") {
|
|
4021
|
+
const p = String(r.position);
|
|
4022
|
+
if (!POSITIONS.has(p)) errors.push(`position \uC774 \uD45C\uC900 \uAC12\uC774 \uC544\uB2C8\uB2E4(open\xB7closed\xB7intermediate\xB7bad): ${JSON.stringify(r.position)}`);
|
|
4023
|
+
else position = p;
|
|
3779
4024
|
}
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
}
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
const
|
|
3789
|
-
|
|
3790
|
-
|
|
4025
|
+
const values = { generatedKW, exportKW, soc, chargeKW, dischargeKW, curtailable, minKW, position, dcVoltage, dcCurrent, acVoltage, acCurrent };
|
|
4026
|
+
if (!errors.length && Object.values(values).every((v) => v === void 0)) {
|
|
4027
|
+
errors.push("\uBC14\uAFC0 \uC0C1\uD0DC\uAC00 \uD558\uB098\uB3C4 \uC5C6\uB2E4 \u2014 \uAC12 \uC5C6\uB294 \uBCF4\uACE0\uB294 \uC0AC\uC2E4\uB85C \uC801\uC744 \uAC83\uC774 \uC5C6\uB2E4");
|
|
4028
|
+
}
|
|
4029
|
+
if (errors.length) {
|
|
4030
|
+
rejected.push({ record, errors });
|
|
4031
|
+
continue;
|
|
4032
|
+
}
|
|
4033
|
+
const eventTime = new Date(atMs).toISOString();
|
|
4034
|
+
const data = {
|
|
4035
|
+
equipmentId,
|
|
4036
|
+
at: eventTime,
|
|
4037
|
+
...generatedKW !== void 0 ? { generatedKW } : {},
|
|
4038
|
+
...exportKW !== void 0 ? { exportKW } : {},
|
|
4039
|
+
...soc !== void 0 ? { soc } : {},
|
|
4040
|
+
...chargeKW !== void 0 ? { chargeKW } : {},
|
|
4041
|
+
...dischargeKW !== void 0 ? { dischargeKW } : {},
|
|
4042
|
+
...curtailable !== void 0 ? { curtailable } : {},
|
|
4043
|
+
...minKW !== void 0 ? { minKW } : {},
|
|
4044
|
+
...position !== void 0 ? { position } : {},
|
|
4045
|
+
...dcVoltage !== void 0 ? { dcVoltage } : {},
|
|
4046
|
+
...dcCurrent !== void 0 ? { dcCurrent } : {},
|
|
4047
|
+
...acVoltage !== void 0 ? { acVoltage } : {},
|
|
4048
|
+
...acCurrent !== void 0 ? { acCurrent } : {}
|
|
4049
|
+
};
|
|
4050
|
+
accepted.push({
|
|
4051
|
+
eventId: `${opts.tenantId}-energy-eq-${++seq}`,
|
|
4052
|
+
eventType: ENERGY_EVENT.equipment,
|
|
4053
|
+
eventTime,
|
|
4054
|
+
tenantId: opts.tenantId,
|
|
4055
|
+
data
|
|
4056
|
+
});
|
|
3791
4057
|
}
|
|
3792
|
-
|
|
3793
|
-
if (day === void 0) return { reason: "no-band" };
|
|
3794
|
-
const holidays = pricesHolidays(usable);
|
|
3795
|
-
const kind = dayKindOf(at2, holidays, isHoliday);
|
|
3796
|
-
const hits = usable.filter(
|
|
3797
|
-
(b) => seasonHas(b, day) && dayKindHas(b, kind) && minutesOf(b.fromTime) <= at2.minutes && at2.minutes < minutesOf(b.toTime)
|
|
3798
|
-
);
|
|
3799
|
-
if (!hits.length) return { reason: "no-band" };
|
|
3800
|
-
if (hits.length > 1) return { reason: "ambiguous", bands: hits.map((b) => String(b.name ?? "")) };
|
|
3801
|
-
const hit = hits[0];
|
|
3802
|
-
const demand = empty(hit.demandChargePerKW) ? void 0 : Number(hit.demandChargePerKW);
|
|
3803
|
-
return {
|
|
3804
|
-
bandName: String(hit.name ?? "") || void 0,
|
|
3805
|
-
band: String(hit.band).trim(),
|
|
3806
|
-
loadClass: String(hit.loadClass).trim(),
|
|
3807
|
-
energyChargePerKWh: Number(hit.energyChargePerKWh),
|
|
3808
|
-
...demand !== void 0 ? { demandChargePerKW: demand } : {},
|
|
3809
|
-
...currency ? { currency } : {},
|
|
3810
|
-
holidayKnown: !holidays || !!isHoliday
|
|
3811
|
-
};
|
|
4058
|
+
return { accepted, rejected };
|
|
3812
4059
|
}
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
"
|
|
3818
|
-
// SSCC
|
|
3819
|
-
"01": 14,
|
|
3820
|
-
// GTIN
|
|
3821
|
-
"02": 14,
|
|
3822
|
-
// 포장 안 품목의 GTIN
|
|
3823
|
-
"11": 6,
|
|
3824
|
-
// 생산일
|
|
3825
|
-
"12": 6,
|
|
3826
|
-
// 지급기일
|
|
3827
|
-
"13": 6,
|
|
3828
|
-
// 포장일
|
|
3829
|
-
"15": 6,
|
|
3830
|
-
// 품질 유지 기한
|
|
3831
|
-
"16": 6,
|
|
3832
|
-
// 판매기한
|
|
3833
|
-
"17": 6,
|
|
3834
|
-
// 사용기한
|
|
3835
|
-
"20": 2,
|
|
3836
|
-
// 제품 변형
|
|
3837
|
-
"414": 13
|
|
3838
|
-
// 물리적 위치의 GLN
|
|
3839
|
-
};
|
|
3840
|
-
var KNOWN_VARIABLE = ["10", "21", "30", "254"];
|
|
3841
|
-
function isBracketed(value) {
|
|
3842
|
-
return /^\(\d{2,4}\)/.test(value);
|
|
4060
|
+
function isEnergyGenerationRecord(record) {
|
|
4061
|
+
if (record?.from !== void 0 || record?.to !== void 0) return false;
|
|
4062
|
+
if (!record || typeof record !== "object") return false;
|
|
4063
|
+
const r = record;
|
|
4064
|
+
return typeof r.equipmentId === "string" && r.equipmentId.trim().length > 0 && r.kWh !== void 0 && r.meterId === void 0 && r.epc === void 0;
|
|
3843
4065
|
}
|
|
3844
|
-
function
|
|
3845
|
-
const
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
const
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
gln: found["414"],
|
|
3860
|
-
glnExtension: found["254"],
|
|
3861
|
-
gtin: found["01"],
|
|
3862
|
-
lot: found["10"],
|
|
3863
|
-
serial: found["21"],
|
|
3864
|
-
useBy: found["17"],
|
|
3865
|
-
/* 숫자가 아니면 담지 않는다 — `NaN` 을 수량으로 두면 더하는 쪽에서 합계가 통째로 사라진다. */
|
|
3866
|
-
count: count !== void 0 && Number.isFinite(count) ? count : void 0,
|
|
3867
|
-
elements: found,
|
|
3868
|
-
raw
|
|
4066
|
+
function ingestEnergyGenerationRecords(records, opts) {
|
|
4067
|
+
const list = records === void 0 || records === null ? [] : Array.isArray(records) ? records : [records];
|
|
4068
|
+
const accepted = [];
|
|
4069
|
+
const rejected = [];
|
|
4070
|
+
let seq = 0;
|
|
4071
|
+
for (const r of list) {
|
|
4072
|
+
const errors = [];
|
|
4073
|
+
const equipmentId = String(r?.equipmentId ?? "").trim();
|
|
4074
|
+
if (!equipmentId) errors.push("equipmentId \uAC00 \uC5C6\uB2E4 \u2014 \uC5B4\uB290 \uC124\uBE44\uAC00 \uB9CC\uB4E0 \uAC83\uC778\uC9C0 \uC9C0\uC5B4\uB0BC \uC218 \uC5C6\uB2E4");
|
|
4075
|
+
const STATE_FIELDS = ["generatedKW", "exportKW", "soc", "chargeKW", "dischargeKW", "curtailable", "minKW", "position"];
|
|
4076
|
+
const alsoState = STATE_FIELDS.filter((f) => r?.[f] !== void 0);
|
|
4077
|
+
if (alsoState.length) {
|
|
4078
|
+
errors.push(
|
|
4079
|
+
`\uD55C \uB808\uCF54\uB4DC\uC5D0 \uC801\uC0B0\uAC12\uACFC \uC124\uBE44 \uC0C1\uD0DC\uAC00 \uD568\uAED8 \uB4E4\uC5B4 \uC788\uC2B5\uB2C8\uB2E4(${alsoState.join("\xB7")}) \u2014 \uC774 \uACBD\uB85C\uC5D0\uC11C\uB294 \uC801\uC0B0\uAC12\uB9CC \uCC98\uB9AC\uD569\uB2C8\uB2E4. \uC124\uBE44 \uC0C1\uD0DC\uB294 \uBCC4\uB3C4 \uB808\uCF54\uB4DC\uB85C \uBCF4\uB0B4\uC138\uC694.`
|
|
4080
|
+
);
|
|
3869
4081
|
}
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
let consumed = 0;
|
|
3877
|
-
while ((match = pattern.exec(raw)) !== null) {
|
|
3878
|
-
const ai = match[1];
|
|
3879
|
-
const value = match[2].trim();
|
|
3880
|
-
const fixed = FIXED_LENGTH[ai];
|
|
3881
|
-
if (fixed !== void 0 && value.length !== fixed) {
|
|
3882
|
-
return { ok: false, because: value.length < fixed ? "truncated" : "unterminated", raw };
|
|
4082
|
+
const raw = r?.kWh;
|
|
4083
|
+
const kWh = Number(raw);
|
|
4084
|
+
if (raw === void 0 || raw === null || !Number.isFinite(kWh)) {
|
|
4085
|
+
errors.push("kWh \uAC00 \uC5C6\uB2E4 \u2014 \uC774 \uBB38\uC774 \uBC1B\uB294 \uAC12\uC740 \uC801\uC0B0 \uD558\uB098\uB2E4(\uC21C\uC2DC \uCD9C\uB825\uC740 \uC124\uBE44 \uC0C1\uD0DC\uB85C \uBCF4\uB0B8\uB2E4)");
|
|
4086
|
+
} else if (kWh < 0) {
|
|
4087
|
+
errors.push(`kWh \uAC00 \uC74C\uC218\uB2E4(${kWh}) \u2014 \uC801\uC0B0\uC740 \uB4A4\uB85C \uAC00\uB354\uB77C\uB3C4 \uC74C\uC218\uAC00 \uB418\uC9C0 \uC54A\uB294\uB2E4`);
|
|
3883
4088
|
}
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
}
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
while (rest.length) {
|
|
3896
|
-
if (rest.startsWith(FNC1)) {
|
|
3897
|
-
rest = rest.slice(1);
|
|
3898
|
-
continue;
|
|
4089
|
+
const eventTime = String(r?.at ?? "").trim() || opts.defaultEventTime || "";
|
|
4090
|
+
if (!eventTime) errors.push("at \uC774 \uC5C6\uACE0 \uAE30\uBCF8 \uC2DC\uAC01\uB3C4 \uC8FC\uC9C0 \uC54A\uC558\uB2E4 \u2014 \uC5B8\uC81C \uC7B0 \uAC83\uC778\uC9C0 \uC9C0\uC5B4\uB0BC \uC218 \uC5C6\uB2E4");
|
|
4091
|
+
let since;
|
|
4092
|
+
const rawSince = r?.kWhSince;
|
|
4093
|
+
if (rawSince !== void 0 && rawSince !== null && String(rawSince).trim()) {
|
|
4094
|
+
const text = String(rawSince).trim();
|
|
4095
|
+
const at2 = Date.parse(text);
|
|
4096
|
+
if (!Number.isFinite(at2)) errors.push(`kWhSince \uB97C \uC2DC\uAC01\uC73C\uB85C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${JSON.stringify(rawSince)}`);
|
|
4097
|
+
else if (Number.isFinite(Date.parse(eventTime)) && at2 > Date.parse(eventTime)) {
|
|
4098
|
+
errors.push(`kWhSince(${text}) \uAC00 \uC7B0 \uC2DC\uAC01(${eventTime})\uBCF4\uB2E4 \uB4A4\uB2E4 \u2014 \uB458 \uC911 \uD558\uB098\uAC00 \uD2C0\uB838\uB2E4`);
|
|
4099
|
+
} else since = text;
|
|
3899
4100
|
}
|
|
3900
|
-
const
|
|
3901
|
-
|
|
3902
|
-
|
|
4101
|
+
const ACCUMULATIONS = ["lifetime", "daily", "monthly", "billing", "unknown"];
|
|
4102
|
+
let accumulation;
|
|
4103
|
+
const rawAcc = r?.kWhAccumulation;
|
|
4104
|
+
if (rawAcc !== void 0 && rawAcc !== null && String(rawAcc).trim()) {
|
|
4105
|
+
const text = String(rawAcc).trim();
|
|
4106
|
+
if (!ACCUMULATIONS.includes(text)) {
|
|
4107
|
+
errors.push(`kWhAccumulation \uC774 \uC544\uB294 \uAC12\uC774 \uC544\uB2C8\uB2E4(${ACCUMULATIONS.join("\xB7")}): ${JSON.stringify(rawAcc)}`);
|
|
4108
|
+
} else accumulation = text;
|
|
3903
4109
|
}
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
if (fixed !== void 0) {
|
|
3907
|
-
if (rest.length < fixed) {
|
|
3908
|
-
return { ok: false, because: "truncated", raw };
|
|
3909
|
-
}
|
|
3910
|
-
const value = rest.slice(0, fixed);
|
|
3911
|
-
if (value.includes(FNC1)) {
|
|
3912
|
-
return { ok: false, because: "truncated", raw };
|
|
3913
|
-
}
|
|
3914
|
-
elements[ai] = value;
|
|
3915
|
-
rest = rest.slice(fixed);
|
|
4110
|
+
if (errors.length) {
|
|
4111
|
+
rejected.push({ record: r, errors });
|
|
3916
4112
|
continue;
|
|
3917
4113
|
}
|
|
3918
|
-
const
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
}
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
const three = rest.slice(0, 3);
|
|
3933
|
-
if (/^\d{3}$/.test(three) && (FIXED_LENGTH[three] !== void 0 || KNOWN_VARIABLE.includes(three))) {
|
|
3934
|
-
return three;
|
|
4114
|
+
const data = {
|
|
4115
|
+
equipmentId,
|
|
4116
|
+
kWh,
|
|
4117
|
+
at: eventTime,
|
|
4118
|
+
...since ? { since } : {},
|
|
4119
|
+
...accumulation ? { accumulation } : {}
|
|
4120
|
+
};
|
|
4121
|
+
accepted.push({
|
|
4122
|
+
eventId: `${opts.tenantId}-generated-${++seq}`,
|
|
4123
|
+
eventType: ENERGY_EVENT.generated,
|
|
4124
|
+
eventTime,
|
|
4125
|
+
tenantId: opts.tenantId,
|
|
4126
|
+
data
|
|
4127
|
+
});
|
|
3935
4128
|
}
|
|
3936
|
-
|
|
3937
|
-
return /^\d{4}$/.test(four) ? four : two;
|
|
4129
|
+
return { accepted, rejected };
|
|
3938
4130
|
}
|
|
3939
|
-
function
|
|
3940
|
-
const
|
|
3941
|
-
return
|
|
4131
|
+
function isEnergyUsagePeriodRecord(record) {
|
|
4132
|
+
const r = record;
|
|
4133
|
+
return !!r && typeof r === "object" && r.meterId !== void 0 && r.from !== void 0 && r.to !== void 0 && r.kWh !== void 0;
|
|
3942
4134
|
}
|
|
3943
|
-
function
|
|
3944
|
-
|
|
4135
|
+
function isEnergyGenerationPeriodRecord(record) {
|
|
4136
|
+
const r = record;
|
|
4137
|
+
if (!r || typeof r !== "object") return false;
|
|
4138
|
+
if (r.equipmentId === void 0 || r.from === void 0 || r.to === void 0) return false;
|
|
4139
|
+
return r.kWh !== void 0;
|
|
3945
4140
|
}
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
const
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
const
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
4141
|
+
function ingestEnergyGenerationPeriodRecords(records, opts) {
|
|
4142
|
+
const list = records === void 0 || records === null ? [] : Array.isArray(records) ? records : [records];
|
|
4143
|
+
const accepted = [];
|
|
4144
|
+
const rejected = [];
|
|
4145
|
+
for (const r of list) {
|
|
4146
|
+
const errors = [];
|
|
4147
|
+
const equipmentId = String(r?.equipmentId ?? "").trim();
|
|
4148
|
+
if (!equipmentId) errors.push("equipmentId \uAC00 \uC5C6\uB2E4 \u2014 \uC5B4\uB290 \uC124\uBE44\uAC00 \uB0B8 \uAC83\uC778\uC9C0 \uC9C0\uC5B4\uB0BC \uC218 \uC5C6\uB2E4");
|
|
4149
|
+
const span = readSpan(r, errors);
|
|
4150
|
+
const kWh = readAmount(r?.kWh, "kWh", errors);
|
|
4151
|
+
if (kWh === void 0 && !errors.length) errors.push("kWh \uAC00 \uC5C6\uB2E4 \u2014 \uC774 \uBB38\uC774 \uBC1B\uB294 \uAC12\uC740 \uADF8 \uAE30\uAC04\uC758 \uBC1C\uC804\uB7C9\uC774\uB2E4");
|
|
4152
|
+
const ACCUMULATIONS = ["lifetime", "daily", "monthly", "billing", "unknown"];
|
|
4153
|
+
let accumulation;
|
|
4154
|
+
const rawAcc = r?.accumulation;
|
|
4155
|
+
if (rawAcc !== void 0 && rawAcc !== null && String(rawAcc).trim()) {
|
|
4156
|
+
const text = String(rawAcc).trim();
|
|
4157
|
+
if (!ACCUMULATIONS.includes(text)) {
|
|
4158
|
+
errors.push(`accumulation \uC774 \uC544\uB294 \uAC12\uC774 \uC544\uB2C8\uB2E4(${ACCUMULATIONS.join("\xB7")}): ${JSON.stringify(rawAcc)}`);
|
|
4159
|
+
} else accumulation = text;
|
|
3959
4160
|
}
|
|
4161
|
+
const readAt = (raw, name) => {
|
|
4162
|
+
if (raw === void 0 || raw === null || !String(raw).trim()) return void 0;
|
|
4163
|
+
const text = String(raw).trim();
|
|
4164
|
+
if (!Number.isFinite(Date.parse(text))) {
|
|
4165
|
+
errors.push(`${name} \uB97C \uC2DC\uAC01\uC73C\uB85C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${JSON.stringify(raw)}`);
|
|
4166
|
+
return void 0;
|
|
4167
|
+
}
|
|
4168
|
+
return text;
|
|
4169
|
+
};
|
|
4170
|
+
const observedFrom = readAt(r?.observedFrom, "observedFrom");
|
|
4171
|
+
const observedTo = readAt(r?.observedTo, "observedTo");
|
|
4172
|
+
if (errors.length || !span || kWh === void 0) {
|
|
4173
|
+
rejected.push({ record: r, errors });
|
|
4174
|
+
continue;
|
|
4175
|
+
}
|
|
4176
|
+
const data = {
|
|
4177
|
+
equipmentId,
|
|
4178
|
+
kWh,
|
|
4179
|
+
periodStart: span.from,
|
|
4180
|
+
periodEnd: span.to,
|
|
4181
|
+
/* 관측 구간을 말하지 않으면 기간 전체를 잰 것으로 둔다 — 지난 기록은 그 원본이 하루를 마감해 준 값이다. */
|
|
4182
|
+
observedFrom: observedFrom ?? span.from,
|
|
4183
|
+
observedTo: observedTo ?? span.to,
|
|
4184
|
+
accumulation: accumulation ?? "daily",
|
|
4185
|
+
/* 밖에서 마감되어 온 것이다 — 우리가 시각 기준으로 닫은 것이 아니다. */
|
|
4186
|
+
boundary: "declared"
|
|
4187
|
+
};
|
|
4188
|
+
const subj = resolveSubject("equipment", equipmentId, opts);
|
|
4189
|
+
data.subject = subj.subject;
|
|
4190
|
+
data.subjectBasis = subj.basis;
|
|
4191
|
+
const futureError = futureFactError(span.to, opts);
|
|
4192
|
+
if (futureError) {
|
|
4193
|
+
rejected.push({ record: r, errors: [futureError] });
|
|
4194
|
+
continue;
|
|
4195
|
+
}
|
|
4196
|
+
accepted.push({
|
|
4197
|
+
eventId: periodFactId(opts.tenantId, ENERGY_EVENT.generationPeriod, subj.subject, span.from, span.to),
|
|
4198
|
+
eventType: ENERGY_EVENT.generationPeriod,
|
|
4199
|
+
eventTime: span.to,
|
|
4200
|
+
tenantId: opts.tenantId,
|
|
4201
|
+
data
|
|
4202
|
+
});
|
|
3960
4203
|
}
|
|
3961
|
-
|
|
3962
|
-
const d = scan.gln;
|
|
3963
|
-
for (const l of PREFIX_LENGTHS) out.push(`urn:epc:id:sgln:${d.slice(0, l)}.${d.slice(l, 12)}.${scan.glnExtension || "0"}`);
|
|
3964
|
-
}
|
|
3965
|
-
return out;
|
|
3966
|
-
}
|
|
3967
|
-
function ssccDigitsOf(uri) {
|
|
3968
|
-
const match = /^urn:epc:id:sscc:(\d+)\.(\d+)$/.exec(uri ?? "");
|
|
3969
|
-
if (!match) return void 0;
|
|
3970
|
-
const [, prefix, reference] = match;
|
|
3971
|
-
const body = reference[0] + prefix + reference.slice(1);
|
|
3972
|
-
if (body.length !== 17) return void 0;
|
|
3973
|
-
return body + checkDigitOf(body);
|
|
3974
|
-
}
|
|
3975
|
-
function gtin14OfItemClass(definitionId) {
|
|
3976
|
-
const match = /^urn:epc:idpat:sgtin:(\d+)\.(\d+)\.\*$/.exec(definitionId ?? "");
|
|
3977
|
-
if (!match) return void 0;
|
|
3978
|
-
const [, prefix, reference] = match;
|
|
3979
|
-
const body = reference[0] + prefix + reference.slice(1);
|
|
3980
|
-
if (body.length !== 13) return void 0;
|
|
3981
|
-
return body + checkDigitOf(body);
|
|
4204
|
+
return { accepted, rejected };
|
|
3982
4205
|
}
|
|
3983
|
-
function
|
|
3984
|
-
const
|
|
3985
|
-
if (
|
|
3986
|
-
|
|
4206
|
+
function isEnergyGenerationPriceRecord(record) {
|
|
4207
|
+
const r = record;
|
|
4208
|
+
if (!r || typeof r !== "object") return false;
|
|
4209
|
+
if (r.from === void 0 || r.to === void 0) return false;
|
|
4210
|
+
if (r.meterId !== void 0 || r.equipmentId !== void 0) return false;
|
|
4211
|
+
return r.unitPrice !== void 0;
|
|
3987
4212
|
}
|
|
3988
|
-
function
|
|
3989
|
-
const
|
|
3990
|
-
|
|
3991
|
-
const
|
|
3992
|
-
|
|
3993
|
-
const
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
if (
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
if (!m || m[1].length + m[2].length !== 12) return raw;
|
|
4012
|
-
const key = m[1] + m[2] + checkDigitOf(m[1] + m[2]);
|
|
4013
|
-
return parsed.scheme === "grai" ? `(8003)0${key}${decoded(m[3])}` : `(253)${key}${decoded(m[3])}`;
|
|
4014
|
-
}
|
|
4015
|
-
if (parsed.scheme === "giai") {
|
|
4016
|
-
const m = /^urn:epc:id:giai:(\d+)\.(.+)$/.exec(raw);
|
|
4017
|
-
return m ? `(8004)${m[1]}${decoded(m[2])}` : raw;
|
|
4213
|
+
function ingestEnergyGenerationPriceRecords(records, opts) {
|
|
4214
|
+
const list = records === void 0 || records === null ? [] : Array.isArray(records) ? records : [records];
|
|
4215
|
+
const accepted = [];
|
|
4216
|
+
const rejected = [];
|
|
4217
|
+
for (const r of list) {
|
|
4218
|
+
const errors = [];
|
|
4219
|
+
const span = readSpan(r, errors);
|
|
4220
|
+
const unitPrice = readAmount(r?.unitPrice, "unitPrice", errors);
|
|
4221
|
+
if (unitPrice === void 0 && !errors.length) errors.push("unitPrice \uAC00 \uC5C6\uB2E4 \u2014 \uC774 \uBB38\uC774 \uBC1B\uB294 \uAC12\uC740 1kWh \uB2F9 \uAC12 \uD558\uB098\uB2E4");
|
|
4222
|
+
const currency = String(r?.currency ?? "").trim();
|
|
4223
|
+
if (!currency) errors.push("currency \uAC00 \uC5C6\uB2E4 \u2014 \uB2E8\uC704 \uC5C6\uB294 \uAC12\uC740 \uB2E4\uB978 \uAE08\uC561\uACFC \uB354\uD560 \uC218 \uC5C6\uB2E4");
|
|
4224
|
+
if (errors.length || !span || unitPrice === void 0) {
|
|
4225
|
+
rejected.push({ record: r, errors });
|
|
4226
|
+
continue;
|
|
4227
|
+
}
|
|
4228
|
+
const data = { from: span.from, to: span.to, unitPrice, currency };
|
|
4229
|
+
accepted.push({
|
|
4230
|
+
eventId: periodFactId(opts.tenantId, ENERGY_EVENT.generationPrice, "", span.from, span.to),
|
|
4231
|
+
eventType: ENERGY_EVENT.generationPrice,
|
|
4232
|
+
eventTime: span.from,
|
|
4233
|
+
tenantId: opts.tenantId,
|
|
4234
|
+
data
|
|
4235
|
+
});
|
|
4018
4236
|
}
|
|
4019
|
-
|
|
4020
|
-
const inHouse = /(?:\/(?:obj|class|bt)\/|:(?:obj|class|bt):)([^/:\s]+)$/.exec(raw);
|
|
4021
|
-
return inHouse ? decoded(inHouse[1]) : raw;
|
|
4022
|
-
}
|
|
4023
|
-
function gtin14OfKey(key) {
|
|
4024
|
-
const m = /^(\d+)\.(\d+)$/.exec(key ?? "");
|
|
4025
|
-
if (!m) return void 0;
|
|
4026
|
-
const body = m[2][0] + m[1] + m[2].slice(1);
|
|
4027
|
-
return body.length === 13 ? body + checkDigitOf(body) : void 0;
|
|
4237
|
+
return { accepted, rejected };
|
|
4028
4238
|
}
|
|
4029
|
-
function
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4239
|
+
function isEnergyTariffBasisRecord(record) {
|
|
4240
|
+
const r = record;
|
|
4241
|
+
if (!r || typeof r !== "object") return false;
|
|
4242
|
+
if (r.from === void 0 || r.to === void 0) return false;
|
|
4243
|
+
if (r.energyCharge !== void 0 || r.demandCharge !== void 0 || r.total !== void 0) return false;
|
|
4244
|
+
return r.billingDemandKW !== void 0 || r.demandChargePerKW !== void 0;
|
|
4035
4245
|
}
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
const
|
|
4044
|
-
|
|
4045
|
-
if (
|
|
4046
|
-
|
|
4246
|
+
function ingestEnergyTariffBasisRecords(records, opts) {
|
|
4247
|
+
const list = records === void 0 || records === null ? [] : Array.isArray(records) ? records : [records];
|
|
4248
|
+
const accepted = [];
|
|
4249
|
+
const rejected = [];
|
|
4250
|
+
for (const r of list) {
|
|
4251
|
+
const errors = [];
|
|
4252
|
+
const span = readSpan(r, errors);
|
|
4253
|
+
const billingDemandKW = readAmount(r?.billingDemandKW, "billingDemandKW", errors);
|
|
4254
|
+
const demandChargePerKW = readAmount(r?.demandChargePerKW, "demandChargePerKW", errors);
|
|
4255
|
+
if (billingDemandKW === void 0 && demandChargePerKW === void 0) {
|
|
4256
|
+
errors.push("\uC694\uAE08 \uAE30\uC900\uC774 \uD558\uB098\uB3C4 \uC5C6\uB2E4 \u2014 \uC801\uC744 \uC0AC\uC2E4\uC774 \uC5C6\uB294 \uAE30\uC900\uC740 \uBC1B\uC9C0 \uC54A\uB294\uB2E4");
|
|
4047
4257
|
}
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4258
|
+
const currency = String(r?.currency ?? "").trim() || void 0;
|
|
4259
|
+
if (demandChargePerKW !== void 0 && !currency) errors.push("demandChargePerKW \uB97C \uC2E4\uC5C8\uB294\uB370 currency \uAC00 \uC5C6\uB2E4");
|
|
4260
|
+
if (r?.demandCharge !== void 0 || r?.total !== void 0) {
|
|
4261
|
+
errors.push("\uAE08\uC561(demandCharge\xB7total)\uC740 \uC774 \uBB38\uC774 \uBC1B\uC9C0 \uC54A\uB294\uB2E4 \u2014 \uC815\uC0B0 \uAE08\uC561\uC740 \uCCAD\uAD6C\uC11C \uBB38\uC73C\uB85C \uBCF4\uB0B8\uB2E4");
|
|
4262
|
+
}
|
|
4263
|
+
if (errors.length || !span) {
|
|
4264
|
+
rejected.push({ record: r, errors });
|
|
4265
|
+
continue;
|
|
4266
|
+
}
|
|
4267
|
+
const data = {
|
|
4268
|
+
from: span.from,
|
|
4269
|
+
to: span.to,
|
|
4270
|
+
...billingDemandKW !== void 0 ? { billingDemandKW } : {},
|
|
4271
|
+
...demandChargePerKW !== void 0 ? { demandChargePerKW } : {},
|
|
4272
|
+
...currency ? { currency } : {}
|
|
4273
|
+
};
|
|
4274
|
+
accepted.push({
|
|
4275
|
+
eventId: periodFactId(opts.tenantId, ENERGY_EVENT.tariffBasis, "", span.from, span.to),
|
|
4276
|
+
eventType: ENERGY_EVENT.tariffBasis,
|
|
4277
|
+
/* **시작 시각**이다 — 그때부터 유효하다(§ 위 주석). */
|
|
4278
|
+
eventTime: span.from,
|
|
4279
|
+
tenantId: opts.tenantId,
|
|
4280
|
+
data
|
|
4281
|
+
});
|
|
4052
4282
|
}
|
|
4053
|
-
|
|
4054
|
-
return { policy };
|
|
4055
|
-
}
|
|
4056
|
-
function foldedOrderCount(folded) {
|
|
4057
|
-
let n = 0;
|
|
4058
|
-
for (const byStatus of Object.values(folded?.counts ?? {})) for (const c of Object.values(byStatus)) n += c;
|
|
4059
|
-
return n;
|
|
4283
|
+
return { accepted, rejected };
|
|
4060
4284
|
}
|
|
4061
|
-
function
|
|
4062
|
-
|
|
4285
|
+
function isEnergyBillRecord(record) {
|
|
4286
|
+
const r = record;
|
|
4287
|
+
if (!r || typeof r !== "object") return false;
|
|
4288
|
+
if (r.from === void 0 || r.to === void 0) return false;
|
|
4289
|
+
return r.energyCharge !== void 0 || r.demandCharge !== void 0 || r.total !== void 0;
|
|
4063
4290
|
}
|
|
4064
|
-
function
|
|
4065
|
-
|
|
4291
|
+
function futureFactError(eventTime, opts) {
|
|
4292
|
+
const nowText = opts.nowISO ?? opts.defaultEventTime;
|
|
4293
|
+
if (!nowText) return void 0;
|
|
4294
|
+
const nowMs = Date.parse(nowText);
|
|
4295
|
+
const atMs = Date.parse(eventTime);
|
|
4296
|
+
if (!Number.isFinite(nowMs) || !Number.isFinite(atMs) || atMs <= nowMs) return void 0;
|
|
4297
|
+
return `\uC544\uC9C1 \uC624\uC9C0 \uC54A\uC740 \uC2DC\uAC01\uC758 \uC0AC\uC2E4\uC774\uB2E4(${eventTime}) \u2014 \uB05D\uB098\uC9C0 \uC54A\uC740 \uAE30\uAC04\uC740 \uB9C8\uAC10\uB41C \uC0AC\uC2E4\uC774 \uC544\uB2C8\uB2E4`;
|
|
4066
4298
|
}
|
|
4067
|
-
function
|
|
4068
|
-
const
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
const add = (status, n) => {
|
|
4072
|
-
const key = String(status ?? "");
|
|
4073
|
-
byStatus[key] = (byStatus[key] ?? 0) + n;
|
|
4074
|
-
count += n;
|
|
4075
|
-
};
|
|
4076
|
-
for (const o of hot) {
|
|
4077
|
-
if (!isFlowOrder(o) || !isOrderTerminal(o)) continue;
|
|
4078
|
-
const at2 = o.terminalAtMs;
|
|
4079
|
-
if (typeof at2 === "number" && at2 >= fromMs && at2 <= nowMs) add(o.status, 1);
|
|
4080
|
-
}
|
|
4081
|
-
for (const [h, byKind] of Object.entries(folded?.hours ?? {})) {
|
|
4082
|
-
if (Number(h) < fromMs || Number(h) > nowMs) continue;
|
|
4083
|
-
for (const [kind, statuses] of Object.entries(byKind)) {
|
|
4084
|
-
if (!isFlowOrder({ kind })) continue;
|
|
4085
|
-
for (const [status, c] of Object.entries(statuses)) add(status, c);
|
|
4086
|
-
}
|
|
4087
|
-
}
|
|
4088
|
-
return { fromMs, toMs: nowMs, count, byStatus };
|
|
4299
|
+
function resolveSubject(kind, localId, opts) {
|
|
4300
|
+
const declared = opts.identityOf?.(kind, localId);
|
|
4301
|
+
if (declared) return { subject: declared, basis: "declared" };
|
|
4302
|
+
return { subject: opts.scopeId ? `${opts.scopeId}/${localId}` : localId, basis: "twin-local" };
|
|
4089
4303
|
}
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
function referencedLocationIds(def) {
|
|
4093
|
-
return new Set((def?.referencedLocations ?? []).map((r) => r.id).filter(Boolean));
|
|
4304
|
+
function periodFactId(tenantId, kind, subject, from, to) {
|
|
4305
|
+
return [tenantId, kind, subject, from, to].join("|");
|
|
4094
4306
|
}
|
|
4095
|
-
function
|
|
4096
|
-
const
|
|
4097
|
-
const
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4307
|
+
function readSpan(r, errors) {
|
|
4308
|
+
const from = String(r?.from ?? "").trim();
|
|
4309
|
+
const to = String(r?.to ?? "").trim();
|
|
4310
|
+
const fromMs = Date.parse(from);
|
|
4311
|
+
const toMs = Date.parse(to);
|
|
4312
|
+
if (!from || !Number.isFinite(fromMs)) errors.push(`from \uC744 \uC2DC\uAC01\uC73C\uB85C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${JSON.stringify(r?.from)}`);
|
|
4313
|
+
if (!to || !Number.isFinite(toMs)) errors.push(`to \uB97C \uC2DC\uAC01\uC73C\uB85C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${JSON.stringify(r?.to)}`);
|
|
4314
|
+
if (Number.isFinite(fromMs) && Number.isFinite(toMs) && !(toMs > fromMs)) {
|
|
4315
|
+
errors.push(`\uAD6C\uAC04\uC774 \uB4A4\uC9D1\uD614\uAC70\uB098 \uAE38\uC774\uAC00 \uC5C6\uB2E4(${from} \u2192 ${to}) \u2014 \uC5B4\uB290 \uCABD\uC774 \uD2C0\uB838\uB294\uC9C0 \uC6B0\uB9AC\uAC00 \uC815\uD560 \uC218 \uC5C6\uB2E4`);
|
|
4102
4316
|
}
|
|
4103
|
-
return {
|
|
4104
|
-
}
|
|
4105
|
-
|
|
4106
|
-
// src/route-network.ts
|
|
4107
|
-
var CONNECTION_DIRECTION = ["one-way", "two-way"];
|
|
4108
|
-
var FIXED_ROUTE_BINDING = ["mandatory", "preferred"];
|
|
4109
|
-
var DEFAULT_CONNECTION_CAPACITY = 1;
|
|
4110
|
-
var ROUTE_NETWORK_ISSUE = {
|
|
4111
|
-
connectionDangling: "route-connection-dangling",
|
|
4112
|
-
connectionSelf: "route-connection-self",
|
|
4113
|
-
connectionLength: "route-connection-length",
|
|
4114
|
-
connectionSpeed: "route-connection-speed",
|
|
4115
|
-
connectionCapacity: "route-connection-capacity",
|
|
4116
|
-
connectionDirection: "route-connection-direction",
|
|
4117
|
-
connectionDuplicate: "route-connection-duplicate",
|
|
4118
|
-
connectionUnknownClass: "route-connection-unknown-class",
|
|
4119
|
-
fixedEmpty: "route-fixed-empty",
|
|
4120
|
-
fixedUnknownConnection: "route-fixed-unknown-connection",
|
|
4121
|
-
fixedBroken: "route-fixed-broken",
|
|
4122
|
-
fixedClass: "route-fixed-class",
|
|
4123
|
-
fixedBinding: "route-fixed-binding",
|
|
4124
|
-
duplicateId: "route-duplicate-id"
|
|
4125
|
-
};
|
|
4126
|
-
var positiveNumber = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
4127
|
-
function traversals(c) {
|
|
4128
|
-
return c.direction === "two-way" ? [{ from: c.from, to: c.to }, { from: c.to, to: c.from }] : [{ from: c.from, to: c.to }];
|
|
4317
|
+
return errors.length ? void 0 : { from, to };
|
|
4129
4318
|
}
|
|
4130
|
-
function
|
|
4131
|
-
if (
|
|
4132
|
-
const
|
|
4133
|
-
|
|
4319
|
+
function readAmount(raw, name, errors) {
|
|
4320
|
+
if (raw === void 0 || raw === null || String(raw).trim() === "") return void 0;
|
|
4321
|
+
const v = Number(raw);
|
|
4322
|
+
if (!Number.isFinite(v)) {
|
|
4323
|
+
errors.push(`${name} \uB97C \uC218\uB85C \uC77D\uC744 \uC218 \uC5C6\uB2E4: ${JSON.stringify(raw)}`);
|
|
4324
|
+
return void 0;
|
|
4325
|
+
}
|
|
4326
|
+
if (v < 0) {
|
|
4327
|
+
errors.push(`${name} \uAC00 \uC74C\uC218\uB2E4(${v})`);
|
|
4328
|
+
return void 0;
|
|
4329
|
+
}
|
|
4330
|
+
return v;
|
|
4134
4331
|
}
|
|
4135
|
-
function
|
|
4136
|
-
const
|
|
4137
|
-
const
|
|
4138
|
-
const
|
|
4139
|
-
const
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
issues.push({ code: ROUTE_NETWORK_ISSUE.connectionDirection, subject: c.id, params: { direction: String(c.direction) } });
|
|
4151
|
-
}
|
|
4152
|
-
if (!positiveNumber(c.lengthM)) issues.push({ code: ROUTE_NETWORK_ISSUE.connectionLength, subject: c.id, params: { lengthM: String(c.lengthM) } });
|
|
4153
|
-
if (c.maxSpeedMps !== void 0 && !positiveNumber(c.maxSpeedMps)) {
|
|
4154
|
-
issues.push({ code: ROUTE_NETWORK_ISSUE.connectionSpeed, subject: c.id, params: { maxSpeedMps: String(c.maxSpeedMps) } });
|
|
4155
|
-
}
|
|
4156
|
-
if (c.capacity !== void 0 && !(Number.isInteger(c.capacity) && c.capacity >= 1)) {
|
|
4157
|
-
issues.push({ code: ROUTE_NETWORK_ISSUE.connectionCapacity, subject: c.id, params: { capacity: String(c.capacity) } });
|
|
4158
|
-
}
|
|
4159
|
-
if (classIds.size > 0) {
|
|
4160
|
-
for (const id of c.equipmentClassIds ?? []) {
|
|
4161
|
-
if (!classIds.has(id)) issues.push({ code: ROUTE_NETWORK_ISSUE.connectionUnknownClass, subject: c.id, params: { equipmentClassId: id } });
|
|
4162
|
-
}
|
|
4163
|
-
}
|
|
4164
|
-
for (const t of traversals(c)) {
|
|
4165
|
-
const key = `${t.from}\0${t.to}`;
|
|
4166
|
-
if (seenEnds.has(key)) issues.push({ code: ROUTE_NETWORK_ISSUE.connectionDuplicate, subject: c.id, params: { from: t.from, to: t.to } });
|
|
4167
|
-
seenEnds.add(key);
|
|
4332
|
+
function ingestEnergyUsagePeriodRecords(records, opts) {
|
|
4333
|
+
const list = records === void 0 || records === null ? [] : Array.isArray(records) ? records : [records];
|
|
4334
|
+
const accepted = [];
|
|
4335
|
+
const rejected = [];
|
|
4336
|
+
for (const r of list) {
|
|
4337
|
+
const errors = [];
|
|
4338
|
+
const meterId = String(r?.meterId ?? "").trim();
|
|
4339
|
+
if (!meterId) errors.push("meterId \uAC00 \uC5C6\uB2E4 \u2014 \uC5B4\uB290 \uC9C0\uC810\uC774 \uC4F4 \uAC83\uC778\uC9C0 \uC9C0\uC5B4\uB0BC \uC218 \uC5C6\uB2E4");
|
|
4340
|
+
const span = readSpan(r, errors);
|
|
4341
|
+
const rawKWh = r?.kWh;
|
|
4342
|
+
let kWh;
|
|
4343
|
+
if (rawKWh === void 0 || rawKWh === null || String(rawKWh).trim() === "") {
|
|
4344
|
+
errors.push("kWh \uAC00 \uC5C6\uB2E4 \u2014 \uC774 \uBB38\uC774 \uBC1B\uB294 \uAC12\uC740 \uADF8 \uAD6C\uAC04\uC5D0 \uC4F4 \uC591\uC774\uB2E4");
|
|
4345
|
+
} else {
|
|
4346
|
+
kWh = readAmount(rawKWh, "kWh", errors);
|
|
4168
4347
|
}
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
if (
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4348
|
+
const maxKW = readAmount(r?.maxKW, "maxKW", errors);
|
|
4349
|
+
const unitPrice = readAmount(r?.unitPrice, "unitPrice", errors);
|
|
4350
|
+
const currency = String(r?.currency ?? "").trim() || void 0;
|
|
4351
|
+
if (unitPrice !== void 0 && !currency) errors.push("unitPrice \uB97C \uC2E4\uC5C8\uB294\uB370 currency \uAC00 \uC5C6\uB2E4 \u2014 \uB2E8\uC704 \uC5C6\uB294 \uAE08\uC561\uC740 \uB354\uD560 \uC218 \uC5C6\uB2E4");
|
|
4352
|
+
let basis;
|
|
4353
|
+
const rawBasis = r?.basis;
|
|
4354
|
+
if (rawBasis !== void 0 && rawBasis !== null && String(rawBasis).trim()) {
|
|
4355
|
+
const text = String(rawBasis).trim();
|
|
4356
|
+
if (!OBSERVATION_BASIS.includes(text)) {
|
|
4357
|
+
errors.push(`basis \uAC00 \uC544\uB294 \uAC12\uC774 \uC544\uB2C8\uB2E4(${OBSERVATION_BASIS.join("\xB7")}): ${JSON.stringify(rawBasis)}`);
|
|
4358
|
+
} else basis = text;
|
|
4176
4359
|
}
|
|
4177
|
-
if (
|
|
4178
|
-
|
|
4360
|
+
if (errors.length || !span || kWh === void 0) {
|
|
4361
|
+
rejected.push({ record: r, errors });
|
|
4179
4362
|
continue;
|
|
4180
4363
|
}
|
|
4181
|
-
const
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4364
|
+
const subj = resolveSubject("meter", meterId, opts);
|
|
4365
|
+
const data = {
|
|
4366
|
+
meterId,
|
|
4367
|
+
subject: subj.subject,
|
|
4368
|
+
subjectBasis: subj.basis,
|
|
4369
|
+
from: span.from,
|
|
4370
|
+
to: span.to,
|
|
4371
|
+
kWh,
|
|
4372
|
+
...maxKW !== void 0 ? { maxKW } : {},
|
|
4373
|
+
...unitPrice !== void 0 ? { unitPrice } : {},
|
|
4374
|
+
...currency ? { currency } : {},
|
|
4375
|
+
...basis ? { basis } : {}
|
|
4376
|
+
};
|
|
4377
|
+
const futureError = futureFactError(span.to, opts);
|
|
4378
|
+
if (futureError) {
|
|
4379
|
+
rejected.push({ record: r, errors: [futureError] });
|
|
4380
|
+
continue;
|
|
4186
4381
|
}
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4382
|
+
accepted.push({
|
|
4383
|
+
eventId: periodFactId(opts.tenantId, ENERGY_EVENT.usagePeriod, subj.subject, span.from, span.to),
|
|
4384
|
+
eventType: ENERGY_EVENT.usagePeriod,
|
|
4385
|
+
/* 구간의 **끝**이 이 사실이 성립한 시각이다 — 시작으로 달면 저널이 그 구간을 미리 안 것이 된다. */
|
|
4386
|
+
eventTime: span.to,
|
|
4387
|
+
tenantId: opts.tenantId,
|
|
4388
|
+
data
|
|
4389
|
+
});
|
|
4390
|
+
}
|
|
4391
|
+
return { accepted, rejected };
|
|
4392
|
+
}
|
|
4393
|
+
function ingestEnergyBillRecords(records, opts) {
|
|
4394
|
+
const list = records === void 0 || records === null ? [] : Array.isArray(records) ? records : [records];
|
|
4395
|
+
const accepted = [];
|
|
4396
|
+
const rejected = [];
|
|
4397
|
+
for (const r of list) {
|
|
4398
|
+
const errors = [];
|
|
4399
|
+
const span = readSpan(r, errors);
|
|
4400
|
+
const energyCharge = readAmount(r?.energyCharge, "energyCharge", errors);
|
|
4401
|
+
const demandCharge = readAmount(r?.demandCharge, "demandCharge", errors);
|
|
4402
|
+
const total = readAmount(r?.total, "total", errors);
|
|
4403
|
+
const billingDemandKW = readAmount(r?.billingDemandKW, "billingDemandKW", errors);
|
|
4404
|
+
if (energyCharge === void 0 && demandCharge === void 0 && total === void 0) {
|
|
4405
|
+
errors.push("\uAE08\uC561\uC774 \uD558\uB098\uB3C4 \uC5C6\uB2E4 \u2014 \uC801\uC744 \uC0AC\uC2E4\uC774 \uC5C6\uB294 \uCCAD\uAD6C\uC11C\uB294 \uBC1B\uC9C0 \uC54A\uB294\uB2E4");
|
|
4196
4406
|
}
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4407
|
+
const currency = String(r?.currency ?? "").trim() || void 0;
|
|
4408
|
+
if (!currency) errors.push("currency \uAC00 \uC5C6\uB2E4 \u2014 \uB2E8\uC704 \uC5C6\uB294 \uAE08\uC561\uC740 \uB2E4\uB978 \uAE08\uC561\uACFC \uB354\uD560 \uC218 \uC5C6\uB2E4");
|
|
4409
|
+
if (errors.length || !span) {
|
|
4410
|
+
rejected.push({ record: r, errors });
|
|
4411
|
+
continue;
|
|
4412
|
+
}
|
|
4413
|
+
const data = {
|
|
4414
|
+
from: span.from,
|
|
4415
|
+
to: span.to,
|
|
4416
|
+
...energyCharge !== void 0 ? { energyCharge } : {},
|
|
4417
|
+
...demandCharge !== void 0 ? { demandCharge } : {},
|
|
4418
|
+
...total !== void 0 ? { total } : {},
|
|
4419
|
+
...currency ? { currency } : {},
|
|
4420
|
+
...billingDemandKW !== void 0 ? { billingDemandKW } : {}
|
|
4421
|
+
};
|
|
4422
|
+
const futureError = futureFactError(span.to, opts);
|
|
4423
|
+
if (futureError) {
|
|
4424
|
+
rejected.push({ record: r, errors: [futureError] });
|
|
4425
|
+
continue;
|
|
4200
4426
|
}
|
|
4427
|
+
accepted.push({
|
|
4428
|
+
eventId: periodFactId(opts.tenantId, ENERGY_EVENT.bill, "", span.from, span.to),
|
|
4429
|
+
eventType: ENERGY_EVENT.bill,
|
|
4430
|
+
eventTime: span.to,
|
|
4431
|
+
tenantId: opts.tenantId,
|
|
4432
|
+
data
|
|
4433
|
+
});
|
|
4201
4434
|
}
|
|
4202
|
-
return
|
|
4203
|
-
}
|
|
4204
|
-
function connectionAdmits(c, equipmentClassIds, classes) {
|
|
4205
|
-
return admits(c, equipmentClassIds, classes);
|
|
4206
|
-
}
|
|
4207
|
-
|
|
4208
|
-
// src/travel.ts
|
|
4209
|
-
var TRAVEL_LINK_STATE = ["online", "stale", "lost"];
|
|
4210
|
-
var TRAVEL_LINK_JUDGED_BY = ["source", "derived"];
|
|
4211
|
-
function linkStateAt(link, nowTime, thresholds) {
|
|
4212
|
-
if (link.judgedBy === "source") return link;
|
|
4213
|
-
if (!nowTime) return void 0;
|
|
4214
|
-
const now = Date.parse(nowTime);
|
|
4215
|
-
const seen = Date.parse(link.lastSeenAt);
|
|
4216
|
-
const { staleAfterMs, lostAfterMs } = thresholds;
|
|
4217
|
-
if (!Number.isFinite(now) || !Number.isFinite(seen)) return void 0;
|
|
4218
|
-
if (!(staleAfterMs >= 0 && lostAfterMs >= staleAfterMs)) return void 0;
|
|
4219
|
-
const silentMs = now - seen;
|
|
4220
|
-
const state = silentMs > lostAfterMs ? "lost" : silentMs > staleAfterMs ? "stale" : "online";
|
|
4221
|
-
return { ...link, state, judgedBy: "derived" };
|
|
4222
|
-
}
|
|
4223
|
-
function isHeading(v) {
|
|
4224
|
-
return typeof v === "number" && Number.isFinite(v) && v >= 0 && v < 360;
|
|
4435
|
+
return { accepted, rejected };
|
|
4225
4436
|
}
|
|
4226
4437
|
|
|
4227
|
-
// src/
|
|
4228
|
-
var
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
level: ILG_LOCATION_LEVEL[k],
|
|
4257
|
-
capabilities: ILG_LOCATION_CAPABILITIES[k]
|
|
4258
|
-
})),
|
|
4259
|
-
/* A forklift under transport control keeps the wms `forklift` type and adds `guided` in the site's own declaration. */
|
|
4260
|
-
{ key: "amr", role: "equipment", label: "twin.type.amr", standardClass: { epcis: "object", iso55000: "Asset" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["mobile", "guided", "operable", "energyStoring"] },
|
|
4261
|
-
{ key: "agv", role: "equipment", label: "twin.type.agv", standardClass: { epcis: "object", iso55000: "Asset" }, identity: { scheme: "gs1:GIAI" }, capabilities: ["mobile", "guided", "operable", "energyStoring"] }
|
|
4262
|
-
];
|
|
4263
|
-
function intralogisticsTypeOf(key) {
|
|
4264
|
-
return ILG_TYPES.find((t) => t.key === key);
|
|
4265
|
-
}
|
|
4266
|
-
var ILG_ORDER_KIND = {
|
|
4267
|
-
transport: "transport"
|
|
4268
|
-
};
|
|
4269
|
-
var ILG_TASK_KIND = {
|
|
4270
|
-
leg: "transport-leg",
|
|
4271
|
-
charge: "charge",
|
|
4272
|
-
park: "park"
|
|
4273
|
-
};
|
|
4274
|
-
var TRANSPORT_FAILURE_REASON = [
|
|
4275
|
-
"no-route",
|
|
4276
|
-
"destination-unavailable",
|
|
4277
|
-
"carrier-not-found",
|
|
4278
|
-
/** The carrier identified at pick-up is not the one the command named. */
|
|
4279
|
-
"carrier-mismatch",
|
|
4280
|
-
"cancelled-by-source",
|
|
4281
|
-
"equipment-fault"
|
|
4438
|
+
// src/tariff.ts
|
|
4439
|
+
var TARIFF_LOAD_CLASSES = ["super-off-peak", "off-peak", "mid-peak", "on-peak"];
|
|
4440
|
+
var TARIFF_DAY_KINDS = ["all", "weekday", "saturday", "sunday", "holiday"];
|
|
4441
|
+
var CONCRETE_DAY_KINDS = ["weekday", "saturday", "sunday", "holiday"];
|
|
4442
|
+
var TARIFF_ISSUE_CODES = [
|
|
4443
|
+
/** A required field is empty. */
|
|
4444
|
+
"required",
|
|
4445
|
+
/** An amount is not a number. */
|
|
4446
|
+
"not-a-number",
|
|
4447
|
+
/** An amount is below zero. */
|
|
4448
|
+
"negative",
|
|
4449
|
+
/** A value is outside its vocabulary - `params.allowed`. */
|
|
4450
|
+
"not-in-vocabulary",
|
|
4451
|
+
/** A text is not in its format - `params.format`. */
|
|
4452
|
+
"format",
|
|
4453
|
+
/** An amount is written without a currency. */
|
|
4454
|
+
"currency-required",
|
|
4455
|
+
/** Season start and end must be written together or both left empty. */
|
|
4456
|
+
"season-pair",
|
|
4457
|
+
/** End time is not after the start - a band crossing midnight is two rows. */
|
|
4458
|
+
"end-not-after-start",
|
|
4459
|
+
/** The tariff has bands and a flat energy charge - which one prices an hour cannot be said. */
|
|
4460
|
+
"flat-and-bands",
|
|
4461
|
+
/** `params.count` bands break the row rules and were left out of the coverage check. */
|
|
4462
|
+
"broken-bands",
|
|
4463
|
+
/** No band covers `params.from`..`params.to` on `params.dayKind` days `params.days`. */
|
|
4464
|
+
"gap",
|
|
4465
|
+
/** Bands `params.bands` overlap `params.from`..`params.to` on `params.dayKind` days `params.days`. */
|
|
4466
|
+
"overlap"
|
|
4282
4467
|
];
|
|
4283
|
-
function
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
}
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
}
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
}
|
|
4310
|
-
var TRAFFIC_CONFLICT_ACTION = ["wait", "replan", "yield"];
|
|
4311
|
-
var TRANSPORT_POLICY_ISSUE = {
|
|
4312
|
-
ruleMissing: "policy-rule-missing",
|
|
4313
|
-
ruleUnknown: "policy-rule-unknown",
|
|
4314
|
-
conflictAction: "policy-conflict-action",
|
|
4315
|
-
horizon: "policy-horizon",
|
|
4316
|
-
soc: "policy-soc",
|
|
4317
|
-
alternateUnknown: "policy-alternate-unknown",
|
|
4318
|
-
alternateSelf: "policy-alternate-self",
|
|
4319
|
-
alternateDuplicate: "policy-alternate-duplicate"
|
|
4320
|
-
};
|
|
4321
|
-
var isPercent = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 100;
|
|
4322
|
-
function validateTransportPolicy(policy, locationIds) {
|
|
4323
|
-
const issues = [];
|
|
4324
|
-
const known = { dispatch: Object.values(DISPATCH_RULE), routing: Object.values(ROUTING_RULE) };
|
|
4325
|
-
for (const part of ["dispatch", "routing"]) {
|
|
4326
|
-
const rule = policy[part]?.rule;
|
|
4327
|
-
if (typeof rule !== "string" || rule.trim() === "") issues.push({ code: TRANSPORT_POLICY_ISSUE.ruleMissing, params: { part } });
|
|
4328
|
-
else if (!known[part].includes(rule)) issues.push({ code: TRANSPORT_POLICY_ISSUE.ruleUnknown, params: { part, rule } });
|
|
4329
|
-
}
|
|
4330
|
-
if (!TRAFFIC_CONFLICT_ACTION.includes(policy.traffic?.onConflict)) {
|
|
4331
|
-
issues.push({ code: TRANSPORT_POLICY_ISSUE.conflictAction, params: { onConflict: String(policy.traffic?.onConflict) } });
|
|
4332
|
-
}
|
|
4333
|
-
const horizon = policy.traffic?.horizonS;
|
|
4334
|
-
if (horizon !== void 0 && !(typeof horizon === "number" && Number.isFinite(horizon) && horizon > 0)) {
|
|
4335
|
-
issues.push({ code: TRANSPORT_POLICY_ISSUE.horizon, params: { horizonS: String(horizon) } });
|
|
4468
|
+
function tariffIssueText(issue) {
|
|
4469
|
+
const p = issue.params ?? {};
|
|
4470
|
+
switch (issue.code) {
|
|
4471
|
+
case "required":
|
|
4472
|
+
return `${issue.field}: required${p.because ? ` (${p.because})` : ""}`;
|
|
4473
|
+
case "not-a-number":
|
|
4474
|
+
return `${issue.field}: not a number (${p.value})`;
|
|
4475
|
+
case "negative":
|
|
4476
|
+
return `${issue.field}: must be 0 or more (${p.value})`;
|
|
4477
|
+
case "not-in-vocabulary":
|
|
4478
|
+
return `${issue.field}: must be one of ${p.allowed} ("${p.value}")`;
|
|
4479
|
+
case "format":
|
|
4480
|
+
return `${issue.field}: must be ${p.format} ("${p.value}")`;
|
|
4481
|
+
case "currency-required":
|
|
4482
|
+
return `${issue.field}: required when an amount is written`;
|
|
4483
|
+
case "season-pair":
|
|
4484
|
+
return `${issue.field}: seasonFrom and seasonTo go together, or both empty for all year`;
|
|
4485
|
+
case "end-not-after-start":
|
|
4486
|
+
return `${issue.field}: must be after fromTime (${p.from}~${p.to}); a band crossing midnight is two rows`;
|
|
4487
|
+
case "flat-and-bands":
|
|
4488
|
+
return `${issue.field}: the tariff has bands - leave its flat charge empty`;
|
|
4489
|
+
case "broken-bands":
|
|
4490
|
+
return `${issue.field}: ${p.count} band(s) break the row rules and were left out`;
|
|
4491
|
+
case "gap":
|
|
4492
|
+
return `${issue.field}: ${p.dayKind} ${p.days} - no band ${p.from}~${p.to}`;
|
|
4493
|
+
case "overlap":
|
|
4494
|
+
return `${issue.field}: ${p.dayKind} ${p.days} - ${p.bands} overlap ${p.from}~${p.to}`;
|
|
4336
4495
|
}
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4496
|
+
}
|
|
4497
|
+
var empty = (v) => v === void 0 || v === null || typeof v === "string" && v.trim() === "";
|
|
4498
|
+
function isIso4217Code(value) {
|
|
4499
|
+
return typeof value === "string" && /^[A-Z]{3}$/.test(value);
|
|
4500
|
+
}
|
|
4501
|
+
function amountOf(v, field, issues) {
|
|
4502
|
+
if (empty(v)) return void 0;
|
|
4503
|
+
const n = Number(v);
|
|
4504
|
+
if (!Number.isFinite(n)) {
|
|
4505
|
+
issues.push({ field, code: "not-a-number", params: { value: String(v) } });
|
|
4506
|
+
return void 0;
|
|
4340
4507
|
}
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
seen.add(a.destination);
|
|
4345
|
-
if (a.alternatives.includes(a.destination)) issues.push({ code: TRANSPORT_POLICY_ISSUE.alternateSelf, params: { destination: a.destination } });
|
|
4346
|
-
if (locationIds) {
|
|
4347
|
-
for (const id of [a.destination, ...a.alternatives]) {
|
|
4348
|
-
if (!locationIds.has(id)) issues.push({ code: TRANSPORT_POLICY_ISSUE.alternateUnknown, params: { location: id } });
|
|
4349
|
-
}
|
|
4350
|
-
}
|
|
4508
|
+
if (n < 0) {
|
|
4509
|
+
issues.push({ field, code: "negative", params: { value: n } });
|
|
4510
|
+
return void 0;
|
|
4351
4511
|
}
|
|
4512
|
+
return n;
|
|
4513
|
+
}
|
|
4514
|
+
function minutesOf(text) {
|
|
4515
|
+
const m = /^(\d{2}):(\d{2})$/.exec(String(text ?? "").trim());
|
|
4516
|
+
if (!m) return void 0;
|
|
4517
|
+
const h = Number(m[1]);
|
|
4518
|
+
const min = Number(m[2]);
|
|
4519
|
+
if (min > 59) return void 0;
|
|
4520
|
+
if (h === 24 && min === 0) return 1440;
|
|
4521
|
+
if (h > 23) return void 0;
|
|
4522
|
+
return h * 60 + min;
|
|
4523
|
+
}
|
|
4524
|
+
var DAYS_IN_MONTH = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
4525
|
+
function dayOfYearOf(text) {
|
|
4526
|
+
const m = /^(\d{2})-(\d{2})$/.exec(String(text ?? "").trim());
|
|
4527
|
+
if (!m) return void 0;
|
|
4528
|
+
const month = Number(m[1]);
|
|
4529
|
+
const day = Number(m[2]);
|
|
4530
|
+
if (month < 1 || month > 12 || day < 1 || day > DAYS_IN_MONTH[month - 1]) return void 0;
|
|
4531
|
+
let n = 0;
|
|
4532
|
+
for (let i = 0; i < month - 1; i++) n += DAYS_IN_MONTH[i];
|
|
4533
|
+
return n + day - 1;
|
|
4534
|
+
}
|
|
4535
|
+
function tariffIssues(row) {
|
|
4536
|
+
const issues = [];
|
|
4537
|
+
const d = amountOf(row.demandChargePerKW, "demandChargePerKW", issues);
|
|
4538
|
+
const e = amountOf(row.energyChargePerKWh, "energyChargePerKWh", issues);
|
|
4539
|
+
const currency = String(row.currency ?? "").trim();
|
|
4540
|
+
if ((d !== void 0 || e !== void 0) && !currency) issues.push({ field: "currency", code: "currency-required" });
|
|
4541
|
+
if (currency && !isIso4217Code(currency)) issues.push({ field: "currency", code: "format", params: { format: "ISO 4217 (KRW, USD)", value: currency } });
|
|
4352
4542
|
return issues;
|
|
4353
4543
|
}
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
if (
|
|
4358
|
-
const
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
let material;
|
|
4363
|
-
if (defs.length === 0 && classes.length === 0) material = void 0;
|
|
4364
|
-
else {
|
|
4365
|
-
const byDef = query.materialDefinitionId !== void 0 && defs.includes(query.materialDefinitionId);
|
|
4366
|
-
const byClass = (query.materialClassIds ?? []).some((id) => classes.includes(id));
|
|
4367
|
-
material = byDef || byClass;
|
|
4544
|
+
function tariffBandIssues(row) {
|
|
4545
|
+
const issues = [];
|
|
4546
|
+
if (empty(row.tariffName)) issues.push({ field: "tariffName", code: "required" });
|
|
4547
|
+
if (empty(row.band)) issues.push({ field: "band", code: "required" });
|
|
4548
|
+
const loadClass = String(row.loadClass ?? "").trim();
|
|
4549
|
+
if (!loadClass) issues.push({ field: "loadClass", code: "required" });
|
|
4550
|
+
else if (!TARIFF_LOAD_CLASSES.includes(loadClass)) {
|
|
4551
|
+
issues.push({ field: "loadClass", code: "not-in-vocabulary", params: { allowed: TARIFF_LOAD_CLASSES.join("|"), value: loadClass } });
|
|
4368
4552
|
}
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
quantity = query.quantity.uom === accepts.maxQuantity.uom ? query.quantity.value <= accepts.maxQuantity.value : void 0;
|
|
4553
|
+
const dayKind = empty(row.dayKind) ? "all" : String(row.dayKind).trim();
|
|
4554
|
+
if (!TARIFF_DAY_KINDS.includes(dayKind)) {
|
|
4555
|
+
issues.push({ field: "dayKind", code: "not-in-vocabulary", params: { allowed: TARIFF_DAY_KINDS.join("|"), value: dayKind } });
|
|
4373
4556
|
}
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4557
|
+
const sFromEmpty = empty(row.seasonFrom);
|
|
4558
|
+
const sToEmpty = empty(row.seasonTo);
|
|
4559
|
+
if (sFromEmpty !== sToEmpty) issues.push({ field: sFromEmpty ? "seasonFrom" : "seasonTo", code: "season-pair" });
|
|
4560
|
+
if (!sFromEmpty && dayOfYearOf(row.seasonFrom) === void 0) issues.push({ field: "seasonFrom", code: "format", params: { format: "MM-DD", value: String(row.seasonFrom) } });
|
|
4561
|
+
if (!sToEmpty && dayOfYearOf(row.seasonTo) === void 0) issues.push({ field: "seasonTo", code: "format", params: { format: "MM-DD", value: String(row.seasonTo) } });
|
|
4562
|
+
const from = minutesOf(row.fromTime);
|
|
4563
|
+
const to = minutesOf(row.toTime);
|
|
4564
|
+
if (from === void 0 || from === 1440) issues.push({ field: "fromTime", code: "format", params: { format: "HH:mm 00:00..23:59", value: String(row.fromTime ?? "") } });
|
|
4565
|
+
if (to === void 0 || to === 0) issues.push({ field: "toTime", code: "format", params: { format: "HH:mm 00:01..24:00", value: String(row.toTime ?? "") } });
|
|
4566
|
+
if (from !== void 0 && to !== void 0 && from < 1440 && to > 0 && from >= to) {
|
|
4567
|
+
issues.push({ field: "toTime", code: "end-not-after-start", params: { from: String(row.fromTime), to: String(row.toTime) } });
|
|
4568
|
+
}
|
|
4569
|
+
if (empty(row.energyChargePerKWh)) issues.push({ field: "energyChargePerKWh", code: "required" });
|
|
4570
|
+
else amountOf(row.energyChargePerKWh, "energyChargePerKWh", issues);
|
|
4571
|
+
amountOf(row.demandChargePerKW, "demandChargePerKW", issues);
|
|
4572
|
+
return issues;
|
|
4377
4573
|
}
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
return
|
|
4574
|
+
function seasonHas(band, dayOfYear) {
|
|
4575
|
+
if (empty(band.seasonFrom) && empty(band.seasonTo)) return true;
|
|
4576
|
+
const from = dayOfYearOf(band.seasonFrom);
|
|
4577
|
+
const to = dayOfYearOf(band.seasonTo);
|
|
4578
|
+
if (from === void 0 || to === void 0) return false;
|
|
4579
|
+
return from <= to ? dayOfYear >= from && dayOfYear <= to : dayOfYear >= from || dayOfYear <= to;
|
|
4384
4580
|
}
|
|
4385
|
-
function
|
|
4386
|
-
|
|
4387
|
-
const r = record;
|
|
4388
|
-
if (r.epc !== void 0 || r.parentID !== void 0) return false;
|
|
4389
|
-
const has = (k) => Array.isArray(r[k]) && r[k].length > 0;
|
|
4390
|
-
return has("inputEPCList") || has("inputQuantityList") || has("outputEPCList") || has("outputQuantityList");
|
|
4581
|
+
function pricesHolidays(bands) {
|
|
4582
|
+
return bands.some((b) => String(b.dayKind ?? "").trim() === "holiday");
|
|
4391
4583
|
}
|
|
4392
|
-
function
|
|
4393
|
-
|
|
4584
|
+
function dayKindOf(at2, holidays, isHoliday) {
|
|
4585
|
+
if (holidays && isHoliday?.(at2.month, at2.day)) return "holiday";
|
|
4586
|
+
return at2.weekday === 0 ? "sunday" : at2.weekday === 6 ? "saturday" : "weekday";
|
|
4394
4587
|
}
|
|
4395
|
-
function
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
const r = get(record, v.slice(2));
|
|
4399
|
-
if (r === void 0 || r === null) return void 0;
|
|
4400
|
-
if (typeof r === "object") {
|
|
4401
|
-
errors.push(`${field} \uAC00 \uAC12\uC774 \uC544\uB2C8\uB77C ${Array.isArray(r) ? "\uBC30\uC5F4" : "\uAC1D\uCCB4"}\uB85C \uC654\uB2E4(${v}) \u2014 \uCEE4\uB125\uD130\uAC00 \uD45C\uC900 \uAD6C\uC870\uB97C \uADF8\uB300\uB85C \uC2E4\uC5C8\uB2E4: ${JSON.stringify(r).slice(0, 80)}`);
|
|
4402
|
-
return void 0;
|
|
4403
|
-
}
|
|
4404
|
-
return String(r);
|
|
4588
|
+
function dayKindHas(band, kind) {
|
|
4589
|
+
const k = empty(band.dayKind) ? "all" : String(band.dayKind).trim();
|
|
4590
|
+
return k === "all" || k === kind;
|
|
4405
4591
|
}
|
|
4406
|
-
function
|
|
4407
|
-
|
|
4408
|
-
const r = get(record, v.startsWith("$.") ? v.slice(2) : v);
|
|
4409
|
-
if (r === void 0 || r === null) return [];
|
|
4410
|
-
if (!Array.isArray(r) || r.some((x) => typeof x !== "string")) {
|
|
4411
|
-
errors.push(`${field} \uAC00 \uBB38\uC790\uC5F4 \uBC30\uC5F4\uC774 \uC544\uB2C8\uB2E4(${v}): ${JSON.stringify(r).slice(0, 80)}`);
|
|
4412
|
-
return [];
|
|
4413
|
-
}
|
|
4414
|
-
return r.slice();
|
|
4592
|
+
function activeBands(bands, at2) {
|
|
4593
|
+
return bands.filter((b) => empty(b.effectiveEnd) || new Date(b.effectiveEnd).getTime() > at2.getTime());
|
|
4415
4594
|
}
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
return [];
|
|
4423
|
-
}
|
|
4424
|
-
return r.map((x) => ({ ...x }));
|
|
4595
|
+
var hhmm = (m) => `${String(Math.floor(m / 60)).padStart(2, "0")}:${String(m % 60).padStart(2, "0")}`;
|
|
4596
|
+
function mmdd(dayOfYear) {
|
|
4597
|
+
let month = 0;
|
|
4598
|
+
let rest = dayOfYear;
|
|
4599
|
+
while (rest >= DAYS_IN_MONTH[month]) rest -= DAYS_IN_MONTH[month++];
|
|
4600
|
+
return `${String(month + 1).padStart(2, "0")}-${String(rest + 1).padStart(2, "0")}`;
|
|
4425
4601
|
}
|
|
4426
|
-
function
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
if (!
|
|
4431
|
-
|
|
4432
|
-
|
|
4602
|
+
function tariffCoverageIssues(tariff, bands) {
|
|
4603
|
+
const issues = [];
|
|
4604
|
+
if (!bands.length) return issues;
|
|
4605
|
+
const usable = bands.filter((b) => tariffBandIssues(b).length === 0);
|
|
4606
|
+
if (!empty(tariff.energyChargePerKWh)) issues.push({ field: "energyChargePerKWh", code: "flat-and-bands" });
|
|
4607
|
+
if (!String(tariff.currency ?? "").trim()) issues.push({ field: "currency", code: "currency-required" });
|
|
4608
|
+
const holidays = pricesHolidays(usable);
|
|
4609
|
+
if (holidays && empty(tariff.holidayCalendar)) {
|
|
4610
|
+
issues.push({ field: "holidayCalendar", code: "required", params: { because: "the tariff has holiday bands" } });
|
|
4433
4611
|
}
|
|
4434
|
-
const
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4612
|
+
const broken = bands.length - usable.length;
|
|
4613
|
+
if (broken) issues.push({ field: "bands", code: "broken-bands", params: { count: broken } });
|
|
4614
|
+
const seen = /* @__PURE__ */ new Map();
|
|
4615
|
+
const note = (kind, day, code, from, to, names) => {
|
|
4616
|
+
const key = [kind, code, from, to, names ?? ""].join("\0");
|
|
4617
|
+
const entry = seen.get(key);
|
|
4618
|
+
if (entry) entry.days.push(day);
|
|
4619
|
+
else {
|
|
4620
|
+
const params = { dayKind: kind, from: hhmm(from), to: hhmm(to) };
|
|
4621
|
+
if (names) params.bands = names;
|
|
4622
|
+
seen.set(key, { problem: { field: "bands", code, params }, days: [day] });
|
|
4623
|
+
}
|
|
4624
|
+
};
|
|
4625
|
+
for (const kind of CONCRETE_DAY_KINDS.filter((k) => k !== "holiday" || holidays)) {
|
|
4626
|
+
for (let day = 0; day < 366; day++) {
|
|
4627
|
+
const today = usable.filter((b) => seasonHas(b, day) && dayKindHas(b, kind)).map((b) => ({ name: String(b.name ?? ""), from: minutesOf(b.fromTime), to: minutesOf(b.toTime) })).sort((a, b) => a.from - b.from || a.to - b.to);
|
|
4628
|
+
let cursor = 0;
|
|
4629
|
+
let last;
|
|
4630
|
+
for (const b of today) {
|
|
4631
|
+
if (b.from > cursor) note(kind, day, "gap", cursor, b.from);
|
|
4632
|
+
if (last && b.from < last.to) note(kind, day, "overlap", b.from, Math.min(last.to, b.to), `${last.name}\xB7${b.name}`);
|
|
4633
|
+
if (b.to > cursor) {
|
|
4634
|
+
cursor = b.to;
|
|
4635
|
+
last = b;
|
|
4636
|
+
}
|
|
4637
|
+
}
|
|
4638
|
+
if (cursor < 1440) note(kind, day, "gap", cursor, 1440);
|
|
4639
|
+
}
|
|
4438
4640
|
}
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4641
|
+
for (const { problem, days } of seen.values()) {
|
|
4642
|
+
const spans = [];
|
|
4643
|
+
let start = days[0];
|
|
4644
|
+
let prev = days[0];
|
|
4645
|
+
for (const d of [...days.slice(1), Infinity]) {
|
|
4646
|
+
if (d === prev + 1) {
|
|
4647
|
+
prev = d;
|
|
4648
|
+
continue;
|
|
4649
|
+
}
|
|
4650
|
+
spans.push(start === prev ? mmdd(start) : `${mmdd(start)}~${mmdd(prev)}`);
|
|
4651
|
+
start = prev = d;
|
|
4652
|
+
}
|
|
4653
|
+
issues.push({ ...problem, params: { ...problem.params, days: spans.join(", ") } });
|
|
4448
4654
|
}
|
|
4449
|
-
|
|
4450
|
-
return Object.keys(o).length ? o : void 0;
|
|
4655
|
+
return issues;
|
|
4451
4656
|
}
|
|
4452
|
-
function
|
|
4453
|
-
|
|
4454
|
-
const
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
errors.push("errorDeclaration\uC5D0 \uC815\uC815 \uC0AC\uC720 \uB610\uB294 \uB300\uC0C1\uC774 \uC788\uC9C0\uB9CC \uC815\uC815 \uC2DC\uAC01(declarationTime)\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
4460
|
-
}
|
|
4461
|
-
return void 0;
|
|
4657
|
+
function bandAt(tariff, bands, at2, isHoliday) {
|
|
4658
|
+
const currency = String(tariff.currency ?? "").trim() || void 0;
|
|
4659
|
+
const usable = bands.filter((b) => tariffBandIssues(b).length === 0);
|
|
4660
|
+
if (!usable.length) {
|
|
4661
|
+
const flat = empty(tariff.energyChargePerKWh) ? NaN : Number(tariff.energyChargePerKWh);
|
|
4662
|
+
if (!Number.isFinite(flat)) return { reason: "no-price" };
|
|
4663
|
+
return { energyChargePerKWh: flat, ...currency ? { currency } : {}, holidayKnown: true };
|
|
4462
4664
|
}
|
|
4665
|
+
const day = dayOfYearOf(`${String(at2.month).padStart(2, "0")}-${String(at2.day).padStart(2, "0")}`);
|
|
4666
|
+
if (day === void 0) return { reason: "no-band" };
|
|
4667
|
+
const holidays = pricesHolidays(usable);
|
|
4668
|
+
const kind = dayKindOf(at2, holidays, isHoliday);
|
|
4669
|
+
const hits = usable.filter(
|
|
4670
|
+
(b) => seasonHas(b, day) && dayKindHas(b, kind) && minutesOf(b.fromTime) <= at2.minutes && at2.minutes < minutesOf(b.toTime)
|
|
4671
|
+
);
|
|
4672
|
+
if (!hits.length) return { reason: "no-band" };
|
|
4673
|
+
if (hits.length > 1) return { reason: "ambiguous", bands: hits.map((b) => String(b.name ?? "")) };
|
|
4674
|
+
const hit = hits[0];
|
|
4675
|
+
const demand = empty(hit.demandChargePerKW) ? void 0 : Number(hit.demandChargePerKW);
|
|
4463
4676
|
return {
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4677
|
+
bandName: String(hit.name ?? "") || void 0,
|
|
4678
|
+
band: String(hit.band).trim(),
|
|
4679
|
+
loadClass: String(hit.loadClass).trim(),
|
|
4680
|
+
energyChargePerKWh: Number(hit.energyChargePerKWh),
|
|
4681
|
+
...demand !== void 0 ? { demandChargePerKW: demand } : {},
|
|
4682
|
+
...currency ? { currency } : {},
|
|
4683
|
+
holidayKnown: !holidays || !!isHoliday
|
|
4467
4684
|
};
|
|
4468
4685
|
}
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
bizLocation
|
|
4505
|
-
}),
|
|
4506
|
-
errors
|
|
4507
|
-
};
|
|
4508
|
-
}
|
|
4509
|
-
if (mapping.type === "AggregationEvent") {
|
|
4510
|
-
const action2 = resolve(mapping.action, record, "action", errors) ?? "";
|
|
4511
|
-
const parentID = resolve(mapping.parentID, record, "parentID", errors) ?? "";
|
|
4512
|
-
const childEPCs = resolveList(mapping.childEPCs, record, "childEPCs", errors);
|
|
4513
|
-
const childQuantityList = resolveQuantityList(mapping.childQuantityList, record, "childQuantityList", errors);
|
|
4514
|
-
return {
|
|
4515
|
-
event: aggregationEvent({
|
|
4516
|
-
eventTime,
|
|
4517
|
-
action: action2,
|
|
4518
|
-
bizStep,
|
|
4519
|
-
disposition,
|
|
4520
|
-
parentID,
|
|
4521
|
-
/* 없는 쪽은 **필드를 만들지 않는다** — 빈 배열을 실으면 「자식이 없다」고 말하는 것이 된다. */
|
|
4522
|
-
...childEPCs.length ? { childEPCs } : {},
|
|
4523
|
-
...childQuantityList.length ? { childQuantityList } : {},
|
|
4524
|
-
...errorDeclaration ? { errorDeclaration } : {},
|
|
4525
|
-
...bizTransactionList.length ? { bizTransactionList } : {},
|
|
4526
|
-
readPoint,
|
|
4527
|
-
bizLocation
|
|
4528
|
-
}),
|
|
4529
|
-
errors
|
|
4530
|
-
};
|
|
4686
|
+
|
|
4687
|
+
// src/gs1.ts
|
|
4688
|
+
var FNC1 = "";
|
|
4689
|
+
var FIXED_LENGTH = {
|
|
4690
|
+
"00": 18,
|
|
4691
|
+
// SSCC
|
|
4692
|
+
"01": 14,
|
|
4693
|
+
// GTIN
|
|
4694
|
+
"02": 14,
|
|
4695
|
+
// 포장 안 품목의 GTIN
|
|
4696
|
+
"11": 6,
|
|
4697
|
+
// 생산일
|
|
4698
|
+
"12": 6,
|
|
4699
|
+
// 지급기일
|
|
4700
|
+
"13": 6,
|
|
4701
|
+
// 포장일
|
|
4702
|
+
"15": 6,
|
|
4703
|
+
// 품질 유지 기한
|
|
4704
|
+
"16": 6,
|
|
4705
|
+
// 판매기한
|
|
4706
|
+
"17": 6,
|
|
4707
|
+
// 사용기한
|
|
4708
|
+
"20": 2,
|
|
4709
|
+
// 제품 변형
|
|
4710
|
+
"414": 13
|
|
4711
|
+
// 물리적 위치의 GLN
|
|
4712
|
+
};
|
|
4713
|
+
var KNOWN_VARIABLE = ["10", "21", "30", "254"];
|
|
4714
|
+
function isBracketed(value) {
|
|
4715
|
+
return /^\(\d{2,4}\)/.test(value);
|
|
4716
|
+
}
|
|
4717
|
+
function parseGs1(value) {
|
|
4718
|
+
const raw = value;
|
|
4719
|
+
if (!raw?.trim()) {
|
|
4720
|
+
return { ok: false, because: "not-gs1", raw };
|
|
4531
4721
|
}
|
|
4532
|
-
const
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
if (!epc && !quantityList.length) {
|
|
4536
|
-
errors.push("epc \uB610\uB294 quantityList\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uAC1C\uCCB4 \uC2DD\uBCC4\uC790\uB098 \uD074\uB798\uC2A4\xB7\uC218\uB7C9\uC744 \uC9C0\uC815\uD558\uC138\uC694.");
|
|
4722
|
+
const parsed = isBracketed(raw) ? fromBracketed(raw) : fromRaw(raw);
|
|
4723
|
+
if (!parsed.ok) {
|
|
4724
|
+
return parsed;
|
|
4537
4725
|
}
|
|
4538
|
-
const
|
|
4726
|
+
const found = parsed.elements;
|
|
4727
|
+
const count = found["30"] !== void 0 ? Number(found["30"]) : void 0;
|
|
4539
4728
|
return {
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4729
|
+
ok: true,
|
|
4730
|
+
scan: {
|
|
4731
|
+
sscc: found["00"],
|
|
4732
|
+
gln: found["414"],
|
|
4733
|
+
glnExtension: found["254"],
|
|
4734
|
+
gtin: found["01"],
|
|
4735
|
+
lot: found["10"],
|
|
4736
|
+
serial: found["21"],
|
|
4737
|
+
useBy: found["17"],
|
|
4738
|
+
/* 숫자가 아니면 담지 않는다 — `NaN` 을 수량으로 두면 더하는 쪽에서 합계가 통째로 사라진다. */
|
|
4739
|
+
count: count !== void 0 && Number.isFinite(count) ? count : void 0,
|
|
4740
|
+
elements: found,
|
|
4741
|
+
raw
|
|
4742
|
+
}
|
|
4554
4743
|
};
|
|
4555
4744
|
}
|
|
4556
|
-
function
|
|
4557
|
-
|
|
4745
|
+
function fromBracketed(raw) {
|
|
4746
|
+
const elements = {};
|
|
4747
|
+
const pattern = /\((\d{2,4})\)([^(]*)/g;
|
|
4748
|
+
let match;
|
|
4749
|
+
let consumed = 0;
|
|
4750
|
+
while ((match = pattern.exec(raw)) !== null) {
|
|
4751
|
+
const ai = match[1];
|
|
4752
|
+
const value = match[2].trim();
|
|
4753
|
+
const fixed = FIXED_LENGTH[ai];
|
|
4754
|
+
if (fixed !== void 0 && value.length !== fixed) {
|
|
4755
|
+
return { ok: false, because: value.length < fixed ? "truncated" : "unterminated", raw };
|
|
4756
|
+
}
|
|
4757
|
+
elements[ai] = value;
|
|
4758
|
+
consumed = match.index + match[0].length;
|
|
4759
|
+
}
|
|
4760
|
+
if (!Object.keys(elements).length || consumed !== raw.length) {
|
|
4761
|
+
return { ok: false, because: "not-gs1", raw };
|
|
4762
|
+
}
|
|
4763
|
+
return { ok: true, elements };
|
|
4558
4764
|
}
|
|
4559
|
-
function
|
|
4560
|
-
const
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
const rule = ruleByType.get(String(record["sourceType"]));
|
|
4566
|
-
if (!rule) {
|
|
4567
|
-
rejected.push({ record, errors: [`\uC77C\uCE58\uD558\uB294 \uB9E4\uD551 \uADDC\uCE59 \uC5C6\uC74C: sourceType=${record["sourceType"]}`] });
|
|
4765
|
+
function fromRaw(raw) {
|
|
4766
|
+
const elements = {};
|
|
4767
|
+
let rest = raw;
|
|
4768
|
+
while (rest.length) {
|
|
4769
|
+
if (rest.startsWith(FNC1)) {
|
|
4770
|
+
rest = rest.slice(1);
|
|
4568
4771
|
continue;
|
|
4569
4772
|
}
|
|
4570
|
-
const
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4773
|
+
const ai = aiAt(rest);
|
|
4774
|
+
if (!ai) {
|
|
4775
|
+
return { ok: false, because: Object.keys(elements).length ? "unterminated" : "not-gs1", raw };
|
|
4776
|
+
}
|
|
4777
|
+
rest = rest.slice(ai.length);
|
|
4778
|
+
const fixed = FIXED_LENGTH[ai];
|
|
4779
|
+
if (fixed !== void 0) {
|
|
4780
|
+
if (rest.length < fixed) {
|
|
4781
|
+
return { ok: false, because: "truncated", raw };
|
|
4782
|
+
}
|
|
4783
|
+
const value = rest.slice(0, fixed);
|
|
4784
|
+
if (value.includes(FNC1)) {
|
|
4785
|
+
return { ok: false, because: "truncated", raw };
|
|
4786
|
+
}
|
|
4787
|
+
elements[ai] = value;
|
|
4788
|
+
rest = rest.slice(fixed);
|
|
4576
4789
|
continue;
|
|
4577
4790
|
}
|
|
4578
|
-
const
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4791
|
+
const end = rest.indexOf(FNC1);
|
|
4792
|
+
elements[ai] = end === -1 ? rest : rest.slice(0, end);
|
|
4793
|
+
rest = end === -1 ? "" : rest.slice(end + 1);
|
|
4794
|
+
}
|
|
4795
|
+
return Object.keys(elements).length ? { ok: true, elements } : { ok: false, because: "not-gs1", raw };
|
|
4796
|
+
}
|
|
4797
|
+
function aiAt(rest) {
|
|
4798
|
+
const two = rest.slice(0, 2);
|
|
4799
|
+
if (!/^\d{2}$/.test(two)) {
|
|
4800
|
+
return void 0;
|
|
4587
4801
|
}
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
const
|
|
4596
|
-
|
|
4597
|
-
if (/\d+Y/.test(s)) return void 0;
|
|
4598
|
-
const tIdx = s.indexOf("T");
|
|
4599
|
-
const datePart = tIdx === -1 ? s : s.slice(0, tIdx);
|
|
4600
|
-
if (/\d+M/.test(datePart)) return void 0;
|
|
4601
|
-
const m = RE.exec(s);
|
|
4602
|
-
if (!m) return void 0;
|
|
4603
|
-
const [, sign, w, d, h, min, sec] = m;
|
|
4604
|
-
if (!w && !d && !h && !min && !sec) return void 0;
|
|
4605
|
-
const ms = (Number(w ?? 0) * 7 + Number(d ?? 0)) * 864e5 + Number(h ?? 0) * 36e5 + Number(min ?? 0) * 6e4 + Number(sec ?? 0) * 1e3;
|
|
4606
|
-
if (!Number.isFinite(ms)) return void 0;
|
|
4607
|
-
return sign ? -ms : ms;
|
|
4802
|
+
if (FIXED_LENGTH[two] !== void 0 || KNOWN_VARIABLE.includes(two)) {
|
|
4803
|
+
return two;
|
|
4804
|
+
}
|
|
4805
|
+
const three = rest.slice(0, 3);
|
|
4806
|
+
if (/^\d{3}$/.test(three) && (FIXED_LENGTH[three] !== void 0 || KNOWN_VARIABLE.includes(three))) {
|
|
4807
|
+
return three;
|
|
4808
|
+
}
|
|
4809
|
+
const four = rest.slice(0, 4);
|
|
4810
|
+
return /^\d{4}$/.test(four) ? four : two;
|
|
4608
4811
|
}
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
/** 품목·로트 클래스의 속성 — 유통기한·로트번호가 여기 온다. */
|
|
4613
|
-
epcClass: "urn:epcglobal:epcis:vtype:EPCClass",
|
|
4614
|
-
/** 관측 지점의 속성. */
|
|
4615
|
-
readPoint: "urn:epcglobal:epcis:vtype:ReadPoint",
|
|
4616
|
-
/** 업무 자리의 속성. */
|
|
4617
|
-
bizLocation: "urn:epcglobal:epcis:vtype:BizLocation"
|
|
4618
|
-
};
|
|
4619
|
-
function isMasterDataRecord(record) {
|
|
4620
|
-
if (!record || typeof record !== "object") return false;
|
|
4621
|
-
const r = record;
|
|
4622
|
-
return typeof r.vocabularyType === "string" && !!r.vocabularyType && typeof r.id === "string" && !!r.id && isPlainObject(r.attributes);
|
|
4812
|
+
function checkDigitOf(body) {
|
|
4813
|
+
const sum = [...body].reverse().reduce((total, digit, at2) => total + Number(digit) * (at2 % 2 === 0 ? 3 : 1), 0);
|
|
4814
|
+
return String((10 - sum % 10) % 10);
|
|
4623
4815
|
}
|
|
4624
|
-
function
|
|
4625
|
-
return !!
|
|
4816
|
+
function wellFormed(digits, length) {
|
|
4817
|
+
return !!digits && digits.length === length && /^\d+$/.test(digits) && checkDigitOf(digits.slice(0, -1)) === digits.slice(-1);
|
|
4626
4818
|
}
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
const
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
const
|
|
4633
|
-
if (!isMasterDataRecord(r)) errors.push("vocabularyType, id, attributes\uB97C \uC9C0\uC815\uD574\uC57C \uD569\uB2C8\uB2E4.");
|
|
4634
|
-
else if (!Object.keys(r.attributes).length) errors.push("attributes\uC5D0 \uC18D\uC131\uC744 \uD558\uB098 \uC774\uC0C1 \uC9C0\uC815\uD574\uC57C \uD569\uB2C8\uB2E4.");
|
|
4635
|
-
if (errors.length) rejected.push({ record: r, errors });
|
|
4636
|
-
else accepted.push({ vocabularyType: r.vocabularyType, id: r.id, attributes: { ...r.attributes } });
|
|
4819
|
+
var PREFIX_LENGTHS = [6, 7, 8, 9, 10, 11, 12];
|
|
4820
|
+
function epcCandidatesOfGs1(scan) {
|
|
4821
|
+
const out = [];
|
|
4822
|
+
if (wellFormed(scan.sscc, 18)) {
|
|
4823
|
+
const d = scan.sscc;
|
|
4824
|
+
for (const l of PREFIX_LENGTHS) out.push(`urn:epc:id:sscc:${d.slice(1, 1 + l)}.${d[0]}${d.slice(1 + l, 17)}`);
|
|
4637
4825
|
}
|
|
4638
|
-
|
|
4826
|
+
if (wellFormed(scan.gtin, 14)) {
|
|
4827
|
+
const d = scan.gtin;
|
|
4828
|
+
for (const l of PREFIX_LENGTHS) {
|
|
4829
|
+
const prefix = d.slice(1, 1 + l);
|
|
4830
|
+
const itemRefAndIndicator = d[0] + d.slice(1 + l, 13);
|
|
4831
|
+
out.push(scan.lot ? lgtinClass(prefix, itemRefAndIndicator, scan.lot) : sgtinClass(prefix, itemRefAndIndicator));
|
|
4832
|
+
}
|
|
4833
|
+
}
|
|
4834
|
+
if (wellFormed(scan.gln, 13)) {
|
|
4835
|
+
const d = scan.gln;
|
|
4836
|
+
for (const l of PREFIX_LENGTHS) out.push(`urn:epc:id:sgln:${d.slice(0, l)}.${d.slice(l, 12)}.${scan.glnExtension || "0"}`);
|
|
4837
|
+
}
|
|
4838
|
+
return out;
|
|
4639
4839
|
}
|
|
4640
|
-
function
|
|
4641
|
-
|
|
4840
|
+
function ssccDigitsOf(uri) {
|
|
4841
|
+
const match = /^urn:epc:id:sscc:(\d+)\.(\d+)$/.exec(uri ?? "");
|
|
4842
|
+
if (!match) return void 0;
|
|
4843
|
+
const [, prefix, reference] = match;
|
|
4844
|
+
const body = reference[0] + prefix + reference.slice(1);
|
|
4845
|
+
if (body.length !== 17) return void 0;
|
|
4846
|
+
return body + checkDigitOf(body);
|
|
4642
4847
|
}
|
|
4643
|
-
function
|
|
4644
|
-
const
|
|
4645
|
-
|
|
4848
|
+
function gtin14OfItemClass(definitionId) {
|
|
4849
|
+
const match = /^urn:epc:idpat:sgtin:(\d+)\.(\d+)\.\*$/.exec(definitionId ?? "");
|
|
4850
|
+
if (!match) return void 0;
|
|
4851
|
+
const [, prefix, reference] = match;
|
|
4852
|
+
const body = reference[0] + prefix + reference.slice(1);
|
|
4853
|
+
if (body.length !== 13) return void 0;
|
|
4854
|
+
return body + checkDigitOf(body);
|
|
4646
4855
|
}
|
|
4647
|
-
function
|
|
4648
|
-
|
|
4649
|
-
if (
|
|
4650
|
-
|
|
4651
|
-
return Number.isNaN(at2) ? void 0 : at2;
|
|
4856
|
+
function gtin14OfItem(definitionId) {
|
|
4857
|
+
const byClass = gtin14OfItemClass(definitionId);
|
|
4858
|
+
if (byClass) return byClass;
|
|
4859
|
+
return /^(\d{8}|\d{12,14})$/.test(definitionId ?? "") ? definitionId.padStart(14, "0") : void 0;
|
|
4652
4860
|
}
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
new Intl.DateTimeFormat("en", { timeZone: b.timezone }).format(0);
|
|
4664
|
-
} catch {
|
|
4665
|
-
return false;
|
|
4861
|
+
function identifierText(uri) {
|
|
4862
|
+
const raw = String(uri ?? "").trim();
|
|
4863
|
+
if (!raw) return "";
|
|
4864
|
+
const parsed = parseEpc(raw);
|
|
4865
|
+
if (parsed.scheme === "sgtin" || parsed.scheme === "lgtin" || parsed.scheme === "idpat") {
|
|
4866
|
+
const gtin = gtin14OfKey(parsed.gtinKey);
|
|
4867
|
+
if (!gtin) return raw;
|
|
4868
|
+
if (parsed.scheme === "sgtin") return parsed.serial ? `(01)${gtin}(21)${decoded(parsed.serial)}` : raw;
|
|
4869
|
+
if (parsed.scheme === "lgtin") return parsed.lot ? `(01)${gtin}(10)${parsed.lot}` : raw;
|
|
4870
|
+
return `(01)${gtin}`;
|
|
4666
4871
|
}
|
|
4667
|
-
if (
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
for (const s of b.shifts) {
|
|
4671
|
-
if (!s || typeof s !== "object" || !nonempty(s.name) || names.has(s.name) || s.description !== void 0 && typeof s.description !== "string" || ![-1, 0, 1].includes(s.fromDate) || ![-1, 0, 1].includes(s.toDate) || !clock(s.fromTime) || !clock(s.toTime) || typeof s.daysOfWeek !== "string" || !/^(?:[0-6](?:,[0-6])*)?$/.test(s.daysOfWeek)) return false;
|
|
4672
|
-
const minutes = (time) => Number(time.slice(0, 2)) * 60 + Number(time.slice(3));
|
|
4673
|
-
const duration = (s.toDate - s.fromDate) * 1440 + minutes(s.toTime) - minutes(s.fromTime);
|
|
4674
|
-
if (duration <= 0 || duration > 1440) return false;
|
|
4675
|
-
names.add(s.name);
|
|
4872
|
+
if (parsed.scheme === "sscc") {
|
|
4873
|
+
const sscc = ssccDigitsOf(raw);
|
|
4874
|
+
return sscc ? `(00)${sscc}` : raw;
|
|
4676
4875
|
}
|
|
4677
|
-
if (
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4876
|
+
if (parsed.scheme === "sgln") {
|
|
4877
|
+
const m = /^urn:epc:id:sgln:(\d+)\.(\d*)\.(.+)$/.exec(raw);
|
|
4878
|
+
if (!m || m[1].length + m[2].length !== 12) return raw;
|
|
4879
|
+
const body = m[1] + m[2];
|
|
4880
|
+
return `(414)${body}${checkDigitOf(body)}${m[3] === "0" ? "" : `(254)${decoded(m[3])}`}`;
|
|
4881
|
+
}
|
|
4882
|
+
if (parsed.scheme === "grai" || parsed.scheme === "gdti") {
|
|
4883
|
+
const m = new RegExp(`^urn:epc:id:${parsed.scheme}:(\\d+)\\.(\\d*)\\.(.*)$`).exec(raw);
|
|
4884
|
+
if (!m || m[1].length + m[2].length !== 12) return raw;
|
|
4885
|
+
const key = m[1] + m[2] + checkDigitOf(m[1] + m[2]);
|
|
4886
|
+
return parsed.scheme === "grai" ? `(8003)0${key}${decoded(m[3])}` : `(253)${key}${decoded(m[3])}`;
|
|
4887
|
+
}
|
|
4888
|
+
if (parsed.scheme === "giai") {
|
|
4889
|
+
const m = /^urn:epc:id:giai:(\d+)\.(.+)$/.exec(raw);
|
|
4890
|
+
return m ? `(8004)${m[1]}${decoded(m[2])}` : raw;
|
|
4891
|
+
}
|
|
4892
|
+
if (parsed.item !== void 0 && parsed.lot !== void 0) return `${parsed.item} \xB7 ${parsed.lot}`;
|
|
4893
|
+
const inHouse = /(?:\/(?:obj|class|bt)\/|:(?:obj|class|bt):)([^/:\s]+)$/.exec(raw);
|
|
4894
|
+
return inHouse ? decoded(inHouse[1]) : raw;
|
|
4681
4895
|
}
|
|
4682
|
-
function
|
|
4683
|
-
|
|
4684
|
-
return
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
timezone: value.timezone,
|
|
4688
|
-
revisionNumber: value.revisionNumber,
|
|
4689
|
-
occurrence: value.occurrence ? { ...value.occurrence } : void 0
|
|
4690
|
-
};
|
|
4896
|
+
function gtin14OfKey(key) {
|
|
4897
|
+
const m = /^(\d+)\.(\d+)$/.exec(key ?? "");
|
|
4898
|
+
if (!m) return void 0;
|
|
4899
|
+
const body = m[2][0] + m[1] + m[2].slice(1);
|
|
4900
|
+
return body.length === 13 ? body + checkDigitOf(body) : void 0;
|
|
4691
4901
|
}
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
for (const f of shape.required ?? []) {
|
|
4698
|
-
const v = row[f];
|
|
4699
|
-
const empty2 = v === void 0 || v === null || typeof v === "string" && !v.trim();
|
|
4700
|
-
if (empty2) errors.push(`${where}.${f}: \uD544\uC218 \uD544\uB4DC \uB204\uB77D`);
|
|
4902
|
+
function decoded(part) {
|
|
4903
|
+
try {
|
|
4904
|
+
return decodeURIComponent(part);
|
|
4905
|
+
} catch {
|
|
4906
|
+
return part;
|
|
4701
4907
|
}
|
|
4702
|
-
|
|
4703
|
-
|
|
4908
|
+
}
|
|
4909
|
+
|
|
4910
|
+
// src/order-fold.ts
|
|
4911
|
+
var ORDER_FOLD_HOUR_MS = 60 * 60 * 1e3;
|
|
4912
|
+
var ORDER_FOLD_DEFAULT = Object.freeze({ afterMs: 24 * 60 * 60 * 1e3, maxTerminal: 1e3 });
|
|
4913
|
+
function orderFoldPolicyOf(declared) {
|
|
4914
|
+
const policy = { ...ORDER_FOLD_DEFAULT };
|
|
4915
|
+
for (const key of ["afterMs", "maxTerminal"]) {
|
|
4916
|
+
const v = declared?.[key];
|
|
4704
4917
|
if (v === void 0 || v === null) continue;
|
|
4705
|
-
if (
|
|
4706
|
-
|
|
4707
|
-
} else if (t !== "number" && typeof v !== t) {
|
|
4708
|
-
errors.push(`${where}.${f} \uAC00 ${t} \uAC00 \uC544\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
4918
|
+
if (typeof v !== "number" || !Number.isFinite(v) || v <= 0) {
|
|
4919
|
+
return { error: `order fold ${key} must be a positive finite number, got ${String(v)} \u2014 a fold that never folds is refused (ADR-0092)` };
|
|
4709
4920
|
}
|
|
4921
|
+
policy[key] = key === "maxTerminal" ? Math.floor(v) : v;
|
|
4710
4922
|
}
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
if (v === void 0 || v === null) continue;
|
|
4714
|
-
if (!allowed.includes(String(v))) {
|
|
4715
|
-
errors.push(`${where}.${f}\uC5D0 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uAC12\uC774 \uC9C0\uC815\uB418\uC5C8\uC2B5\uB2C8\uB2E4: ${JSON.stringify(v)} (${allowed.join(" \xB7 ")})`);
|
|
4716
|
-
}
|
|
4923
|
+
if (policy.afterMs % ORDER_FOLD_HOUR_MS !== 0) {
|
|
4924
|
+
return { error: `order fold afterMs must be a whole number of hours, got ${policy.afterMs} ms \u2014 the window is counted in hour slots (ADR-0092)` };
|
|
4717
4925
|
}
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4926
|
+
if (policy.maxTerminal < 1) return { error: "order fold maxTerminal must be at least 1 (ADR-0092)" };
|
|
4927
|
+
return { policy };
|
|
4928
|
+
}
|
|
4929
|
+
function foldedOrderCount(folded) {
|
|
4930
|
+
let n = 0;
|
|
4931
|
+
for (const byStatus of Object.values(folded?.counts ?? {})) for (const c of Object.values(byStatus)) n += c;
|
|
4932
|
+
return n;
|
|
4933
|
+
}
|
|
4934
|
+
function hourStartOf(ms) {
|
|
4935
|
+
return Math.floor(ms / ORDER_FOLD_HOUR_MS) * ORDER_FOLD_HOUR_MS;
|
|
4936
|
+
}
|
|
4937
|
+
function finishedWindowStartMs(nowMs, policy = ORDER_FOLD_DEFAULT) {
|
|
4938
|
+
return hourStartOf(nowMs) - policy.afterMs;
|
|
4939
|
+
}
|
|
4940
|
+
function finishedFlowOrdersWithin(hot, folded, nowMs, policy = ORDER_FOLD_DEFAULT) {
|
|
4941
|
+
const fromMs = finishedWindowStartMs(nowMs, policy);
|
|
4942
|
+
let count = 0;
|
|
4943
|
+
const byStatus = {};
|
|
4944
|
+
const add = (status, n) => {
|
|
4945
|
+
const key = String(status ?? "");
|
|
4946
|
+
byStatus[key] = (byStatus[key] ?? 0) + n;
|
|
4947
|
+
count += n;
|
|
4948
|
+
};
|
|
4949
|
+
for (const o of hot) {
|
|
4950
|
+
if (!isFlowOrder(o) || !isOrderTerminal(o)) continue;
|
|
4951
|
+
const at2 = o.terminalAtMs;
|
|
4952
|
+
if (typeof at2 === "number" && at2 >= fromMs && at2 <= nowMs) add(o.status, 1);
|
|
4953
|
+
}
|
|
4954
|
+
for (const [h, byKind] of Object.entries(folded?.hours ?? {})) {
|
|
4955
|
+
if (Number(h) < fromMs || Number(h) > nowMs) continue;
|
|
4956
|
+
for (const [kind, statuses] of Object.entries(byKind)) {
|
|
4957
|
+
if (!isFlowOrder({ kind })) continue;
|
|
4958
|
+
for (const [status, c] of Object.entries(statuses)) add(status, c);
|
|
4723
4959
|
}
|
|
4724
4960
|
}
|
|
4725
|
-
return
|
|
4961
|
+
return { fromMs, toMs: nowMs, count, byStatus };
|
|
4726
4962
|
}
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
}
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
required: ["moverId", "kind", "status"],
|
|
4800
|
-
// vocabulary-guard: allow 위와 같은 이유
|
|
4801
|
-
fields: {
|
|
4802
|
-
moverId: "string",
|
|
4803
|
-
kind: "string",
|
|
4804
|
-
status: "string",
|
|
4805
|
-
location: "string",
|
|
4806
|
-
homeLocation: "string",
|
|
4807
|
-
// vocabulary-guard: allow
|
|
4808
|
-
taskId: "string",
|
|
4809
|
-
held: "boolean",
|
|
4810
|
-
effectiveStart: "string",
|
|
4811
|
-
effectiveEnd: "string",
|
|
4812
|
-
recordTime: "string",
|
|
4813
|
-
/* 왜 이 상태가 됐나 — 설비가 알려 주면 싣는다. 사람이 나중에 정하는 사유는 구간 사실에 적는다. */
|
|
4814
|
-
reasonCode: "string",
|
|
4815
|
-
/* 이동 구간 — 실 시스템도 줄 수 있는 사실이다(AGV·RTLS 가 출발·도착·소요를 낸다). 안쪽 필드까지
|
|
4816
|
-
재검사하지는 않는다: 그 모양은 `EquipmentMotion` 계약이고, 여기서 두 번 지키면 두 벌이 된다. */
|
|
4817
|
-
motion: "object"
|
|
4818
|
-
},
|
|
4819
|
-
enums: { status: EQUIPMENT_STATUS }
|
|
4820
|
-
},
|
|
4821
|
-
person: {
|
|
4822
|
-
eventType: OP_EVENT.person,
|
|
4823
|
-
match: ["personId"],
|
|
4824
|
-
matchOrder: 30,
|
|
4825
|
-
identity: "personId",
|
|
4826
|
-
required: ["personId", "status"],
|
|
4827
|
-
fields: {
|
|
4828
|
-
personId: "string",
|
|
4829
|
-
status: "string",
|
|
4830
|
-
personnelClassIds: "string[]",
|
|
4831
|
-
taskId: "string",
|
|
4832
|
-
location: "string",
|
|
4833
|
-
offShift: "boolean",
|
|
4834
|
-
effectiveStart: "string",
|
|
4835
|
-
effectiveEnd: "string",
|
|
4836
|
-
recordTime: "string"
|
|
4837
|
-
},
|
|
4838
|
-
enums: { status: PERSON_STATUS }
|
|
4839
|
-
},
|
|
4840
|
-
asset: {
|
|
4841
|
-
eventType: OP_EVENT.asset,
|
|
4842
|
-
match: ["assetId"],
|
|
4843
|
-
matchOrder: 40,
|
|
4844
|
-
identity: "assetId",
|
|
4845
|
-
required: ["assetId", "status"],
|
|
4846
|
-
fields: {
|
|
4847
|
-
assetId: "string",
|
|
4848
|
-
status: "string",
|
|
4849
|
-
assetClassIds: "string[]",
|
|
4850
|
-
location: "string",
|
|
4851
|
-
taskId: "string",
|
|
4852
|
-
carrying: "string",
|
|
4853
|
-
effectiveStart: "string",
|
|
4854
|
-
effectiveEnd: "string",
|
|
4855
|
-
recordTime: "string"
|
|
4856
|
-
},
|
|
4857
|
-
enums: { status: ASSET_STATUS }
|
|
4858
|
-
},
|
|
4859
|
-
order: {
|
|
4860
|
-
eventType: OP_EVENT.order,
|
|
4861
|
-
match: ["orderId"],
|
|
4862
|
-
matchOrder: 60,
|
|
4863
|
-
identity: "orderId",
|
|
4864
|
-
/*
|
|
4865
|
-
* 요청량·이행량을 **함께** 받는다. 없으면 리듀서가 진척을 0 으로 적는데(`requested ? … : 0`),
|
|
4866
|
-
* 그것은 「모른다」가 아니라 「아무것도 안 됐다」로 읽힌다 — 결측을 0 으로 메우지 않는다.
|
|
4867
|
-
*/
|
|
4868
|
-
required: ["orderId", "kind", "status", "requested", "fulfilled"],
|
|
4869
|
-
fields: {
|
|
4870
|
-
orderId: "string",
|
|
4871
|
-
kind: "string",
|
|
4872
|
-
status: "string",
|
|
4873
|
-
requested: "number",
|
|
4874
|
-
fulfilled: "number",
|
|
4875
|
-
gtin: "string",
|
|
4876
|
-
held: "boolean",
|
|
4877
|
-
lines: "object[]",
|
|
4878
|
-
priority: "number",
|
|
4879
|
-
startTime: "string",
|
|
4880
|
-
endTime: "string",
|
|
4881
|
-
/* 확보분은 `{ epc, qty }` 줄이다(2026-09-19, ADR-0076 보탬) — 옛 EPC 목록은 받지 않는다. */
|
|
4882
|
-
allocated: "object[]",
|
|
4883
|
-
bizTransaction: "string",
|
|
4884
|
-
operationsRequestId: "string",
|
|
4885
|
-
dockDoor: "string",
|
|
4886
|
-
windowStartMs: "number",
|
|
4887
|
-
recordTime: "string",
|
|
4888
|
-
/*
|
|
4889
|
-
* 이 오더를 어느 레시피로 돌리나 — 「이 로트를 무엇으로 만들었나」가 이 칸을 지나 답한다.
|
|
4890
|
-
*
|
|
4891
|
-
* ── 왜 뒤늦게 생겼나 (2026-09-07 측정) ─────────────────────────────────
|
|
4892
|
-
* EPCIS 변환 사건에는 레시피 자리가 없다(표준이 그렇다). 그래서 이력추적이 **변환 → 거래
|
|
4893
|
-
* 식별자 → 그 오더의 `recipeKey`** 로 건너간다(`twin-lineage-query.ts:296-315`).
|
|
4894
|
-
*
|
|
4895
|
-
* 변환이 오더를 가리키게 만든 뒤에 재보니, **가리켜진 오더 행에 그 칸이 없었다.** 실으면
|
|
4896
|
-
* 레코드가 통째로 거절됐다 — `order: 계약에 없는 필드 — recipeKey`. 조용히 버리지 않은 것은
|
|
4897
|
-
* 맞지만, 그래서 실 시스템에서는 그 물음이 계속 답이 없었다.
|
|
4898
|
-
*
|
|
4899
|
-
* 값은 원본에 있다: `job_orders.recipe_key` 35개 중 20개 채움
|
|
4900
|
-
* (`WO-ECU-STD-2609A` = `RECIPE-ECU-STD`).
|
|
4901
|
-
*
|
|
4902
|
-
* 새 어휘가 아니다 — 계약이 `recipeKey` 를 네 자리에서 이미 쓴다. 오더 관측에만 자리가 없었다.
|
|
4903
|
-
*/
|
|
4904
|
-
recipeKey: "string",
|
|
4905
|
-
recipeBasis: "object",
|
|
4906
|
-
materialBasis: "object[]",
|
|
4907
|
-
/* 근거 칸이 빈 까닭 — 닫힌 낱말이다(§`BASIS_UNKNOWN`). 투입이 근거 장치보다 먼저였던 오더도 이행은 사실이다. */
|
|
4908
|
-
basisUnknown: "string"
|
|
4909
|
-
},
|
|
4910
|
-
/* 상태·종류는 도메인이 소유한다 — 닫지 않는다. 근거가 빈 까닭은 커널이 읽으므로 닫는다. */
|
|
4911
|
-
enums: { basisUnknown: BASIS_UNKNOWN },
|
|
4912
|
-
/*
|
|
4913
|
-
* 확보분의 안쪽을 본다 — 열쇠와 수 둘이다(§`AllocatedQuantity`). 안 보면 틀린 이름이 조용히
|
|
4914
|
-
* 지나가고(`epcs`·`quantity` 따위), 미러는 잡힌 수를 0 으로 읽는다.
|
|
4915
|
-
*/
|
|
4916
|
-
shapes: {
|
|
4917
|
-
materialBasis: {
|
|
4918
|
-
required: ["basisId", "materialId", "revisionId", "revisionNumber", "planId", "contentHash", "businessTime", "material"],
|
|
4919
|
-
fields: { basisId: "string", materialId: "string", revisionId: "string", revisionNumber: "number", planId: "string", contentHash: "string", businessTime: "string" }
|
|
4920
|
-
// Recursive material properties and reference lists are checked by isMaterialExecutionBasis.
|
|
4921
|
-
},
|
|
4922
|
-
recipeBasis: {
|
|
4923
|
-
required: ["basisId", "recipeId", "revisionId", "planId", "contentHash", "businessTime", "recipe"],
|
|
4924
|
-
fields: { basisId: "string", recipeId: "string", revisionId: "string", planId: "string", contentHash: "string", businessTime: "string" }
|
|
4925
|
-
// Owned composition and captured route are additionally checked by isRecipeExecutionBasis below.
|
|
4926
|
-
},
|
|
4927
|
-
allocated: {
|
|
4928
|
-
required: ["epc", "qty"],
|
|
4929
|
-
fields: { epc: "string", qty: "number" },
|
|
4930
|
-
positive: ["qty"]
|
|
4963
|
+
|
|
4964
|
+
// src/referenced-location.ts
|
|
4965
|
+
function referencedLocationIds(def) {
|
|
4966
|
+
return new Set((def?.referencedLocations ?? []).map((r) => r.id).filter(Boolean));
|
|
4967
|
+
}
|
|
4968
|
+
function partitionLensLocations(locations, lensSystem) {
|
|
4969
|
+
const own = [];
|
|
4970
|
+
const referenced = [];
|
|
4971
|
+
for (const l of locations) {
|
|
4972
|
+
const system = typeof l.system === "string" ? l.system.trim() : "";
|
|
4973
|
+
if (system && system !== lensSystem) referenced.push({ id: l.id, system });
|
|
4974
|
+
else own.push(l);
|
|
4975
|
+
}
|
|
4976
|
+
return { own, referenced };
|
|
4977
|
+
}
|
|
4978
|
+
|
|
4979
|
+
// src/route-network.ts
|
|
4980
|
+
var CONNECTION_DIRECTION = ["one-way", "two-way"];
|
|
4981
|
+
var FIXED_ROUTE_BINDING = ["mandatory", "preferred"];
|
|
4982
|
+
var DEFAULT_CONNECTION_CAPACITY = 1;
|
|
4983
|
+
var ROUTE_NETWORK_ISSUE = {
|
|
4984
|
+
connectionDangling: "route-connection-dangling",
|
|
4985
|
+
connectionSelf: "route-connection-self",
|
|
4986
|
+
connectionLength: "route-connection-length",
|
|
4987
|
+
connectionSpeed: "route-connection-speed",
|
|
4988
|
+
connectionCapacity: "route-connection-capacity",
|
|
4989
|
+
connectionDirection: "route-connection-direction",
|
|
4990
|
+
connectionDuplicate: "route-connection-duplicate",
|
|
4991
|
+
connectionUnknownClass: "route-connection-unknown-class",
|
|
4992
|
+
fixedEmpty: "route-fixed-empty",
|
|
4993
|
+
fixedUnknownConnection: "route-fixed-unknown-connection",
|
|
4994
|
+
fixedBroken: "route-fixed-broken",
|
|
4995
|
+
fixedClass: "route-fixed-class",
|
|
4996
|
+
fixedBinding: "route-fixed-binding",
|
|
4997
|
+
duplicateId: "route-duplicate-id"
|
|
4998
|
+
};
|
|
4999
|
+
var positiveNumber = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
5000
|
+
function traversals(c) {
|
|
5001
|
+
return c.direction === "two-way" ? [{ from: c.from, to: c.to }, { from: c.to, to: c.from }] : [{ from: c.from, to: c.to }];
|
|
5002
|
+
}
|
|
5003
|
+
function admits(c, classIds, classes) {
|
|
5004
|
+
if (!c.equipmentClassIds || c.equipmentClassIds.length === 0) return true;
|
|
5005
|
+
const allowed = new Set(c.equipmentClassIds);
|
|
5006
|
+
return classIds.every((id) => [...classClosure([id], classes)].some((k) => allowed.has(k)));
|
|
5007
|
+
}
|
|
5008
|
+
function validateRouteNetwork(def) {
|
|
5009
|
+
const issues = [];
|
|
5010
|
+
const places = new Set([...def.locations ?? [], ...def.referencedLocations ?? []].map((l) => l.id));
|
|
5011
|
+
const connections = def.connections ?? [];
|
|
5012
|
+
const classIds = new Set((def.equipmentClasses ?? []).map((c) => c.id));
|
|
5013
|
+
const byId = /* @__PURE__ */ new Map();
|
|
5014
|
+
const seenEnds = /* @__PURE__ */ new Set();
|
|
5015
|
+
for (const c of connections) {
|
|
5016
|
+
if (byId.has(c.id)) issues.push({ code: ROUTE_NETWORK_ISSUE.duplicateId, subject: c.id, params: { kind: "connection" } });
|
|
5017
|
+
byId.set(c.id, c);
|
|
5018
|
+
for (const end of [c.from, c.to]) {
|
|
5019
|
+
if (!places.has(end)) issues.push({ code: ROUTE_NETWORK_ISSUE.connectionDangling, subject: c.id, params: { location: end } });
|
|
5020
|
+
}
|
|
5021
|
+
if (c.from === c.to) issues.push({ code: ROUTE_NETWORK_ISSUE.connectionSelf, subject: c.id, params: { location: c.from } });
|
|
5022
|
+
if (!CONNECTION_DIRECTION.includes(c.direction)) {
|
|
5023
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.connectionDirection, subject: c.id, params: { direction: String(c.direction) } });
|
|
5024
|
+
}
|
|
5025
|
+
if (!positiveNumber(c.lengthM)) issues.push({ code: ROUTE_NETWORK_ISSUE.connectionLength, subject: c.id, params: { lengthM: String(c.lengthM) } });
|
|
5026
|
+
if (c.maxSpeedMps !== void 0 && !positiveNumber(c.maxSpeedMps)) {
|
|
5027
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.connectionSpeed, subject: c.id, params: { maxSpeedMps: String(c.maxSpeedMps) } });
|
|
5028
|
+
}
|
|
5029
|
+
if (c.capacity !== void 0 && !(Number.isInteger(c.capacity) && c.capacity >= 1)) {
|
|
5030
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.connectionCapacity, subject: c.id, params: { capacity: String(c.capacity) } });
|
|
5031
|
+
}
|
|
5032
|
+
if (classIds.size > 0) {
|
|
5033
|
+
for (const id of c.equipmentClassIds ?? []) {
|
|
5034
|
+
if (!classIds.has(id)) issues.push({ code: ROUTE_NETWORK_ISSUE.connectionUnknownClass, subject: c.id, params: { equipmentClassId: id } });
|
|
4931
5035
|
}
|
|
4932
5036
|
}
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
* 여기서 두 번 지키면 두 벌이 된다(설비 `motion` 과 같은 규율).
|
|
4964
|
-
*/
|
|
4965
|
-
/*
|
|
4966
|
-
* **마감된 설비 상태 구간** — 이 설비가 이 구간 동안 이 상태였다.
|
|
4967
|
-
*
|
|
4968
|
-
* ── 전이만으로는 안 되는 이유 (2026-08-30) ───────────────────────────────
|
|
4969
|
-
* 세 가지다. 셋째가 결정적이다.
|
|
4970
|
-
*
|
|
4971
|
-
* 사유가 붙을 자리가 없다 기계가 서는 순간에는 왜 섰는지 아무도 모른다. 작업자가 라인이 다시
|
|
4972
|
-
* 돈 뒤에 적는다. 그 사이에 전이가 더 있으면 어느 전이에 붙일지 정할 수 없다
|
|
4973
|
-
* 계획·비계획을 나중에 정한다 ISO 22400 은 계획정지를 계획 조업 시간에서 빼고 고장은 빼지 않는다.
|
|
4974
|
-
* 그 분류는 전이가 일어난 순간에 모른다
|
|
4975
|
-
* 전이를 내지 않는 정지가 많다 자재 대기 · 앞 공정 대기 · 작업자 부재. 기계는 전원이 켜진 채 `idle`
|
|
4976
|
-
* 이고 신호가 하나도 안 나온다. OEE 에서 가장 크게 깎이는 것이 보통 이 시간이다
|
|
4977
|
-
*
|
|
4978
|
-
* 마지막이 감시 시스템과 MES 가 갈리는 자리이기도 하다. 설비가 말하는 것만 모으면 감시이고,
|
|
4979
|
-
* **설비가 말하지 못하는 것을 사람이 적어 넣는 자리**가 MES 다.
|
|
4980
|
-
*
|
|
4981
|
-
* ── 이름이 `downtime` 이 아닌 이유 ────────────────────────────────────────
|
|
4982
|
-
* 이 구간은 `setup` 과 `planned-stop` 도 나른다. 그 둘은 정지가 아니다. 담는 것은 **상태 구간**이고,
|
|
4983
|
-
* 어느 상태인지는 `status` 가 말한다.
|
|
4984
|
-
*
|
|
4985
|
-
* ── 되돌아가 적는 사실이다 ───────────────────────────────────────────────
|
|
4986
|
-
* 봉투의 사건 시각은 **구간의 끝**(그때 성립한다)이고, 적은 시각은 `recordTime` 이다. 둘이 갈려 있어야
|
|
4987
|
-
* 「언제 일어났나」와 「언제 알았나」를 구별할 수 있다.
|
|
4988
|
-
*/
|
|
4989
|
-
"equipment-period": {
|
|
4990
|
-
eventType: OP_EVENT.equipmentPeriod,
|
|
4991
|
-
match: ["moverId", "status", "from", "to"],
|
|
4992
|
-
matchOrder: 10,
|
|
4993
|
-
identity: "moverId",
|
|
4994
|
-
// vocabulary-guard: allow 저널 와이어 필드 — 전이와 같은 이름을 쓴다
|
|
4995
|
-
required: ["moverId", "status", "from", "to"],
|
|
4996
|
-
// vocabulary-guard: allow 위와 같은 이유
|
|
4997
|
-
fields: {
|
|
4998
|
-
moverId: "string",
|
|
4999
|
-
status: "string",
|
|
5000
|
-
from: "string",
|
|
5001
|
-
to: "string",
|
|
5002
|
-
// vocabulary-guard: allow
|
|
5003
|
-
/* 사람이 정한 사유 — 없을 수 있다(적지 않은 것과 사유가 없는 것은 다르므로 지어내지 않는다). */
|
|
5004
|
-
reasonCode: "string",
|
|
5005
|
-
decidedBy: "string",
|
|
5006
|
-
recordTime: "string",
|
|
5007
|
-
workShiftBasis: "object"
|
|
5008
|
-
},
|
|
5009
|
-
shapes: {
|
|
5010
|
-
workShiftBasis: {
|
|
5011
|
-
required: ["basisId", "arrangementId", "revisionId", "revisionNumber", "planId", "contentHash", "businessTime", "timezone", "shifts", "workDate"],
|
|
5012
|
-
fields: { basisId: "string", arrangementId: "string", revisionId: "string", revisionNumber: "number", planId: "string", contentHash: "string", businessTime: "string", timezone: "string", workDate: "string" }
|
|
5037
|
+
for (const t of traversals(c)) {
|
|
5038
|
+
const key = `${t.from}\0${t.to}`;
|
|
5039
|
+
if (seenEnds.has(key)) issues.push({ code: ROUTE_NETWORK_ISSUE.connectionDuplicate, subject: c.id, params: { from: t.from, to: t.to } });
|
|
5040
|
+
seenEnds.add(key);
|
|
5041
|
+
}
|
|
5042
|
+
}
|
|
5043
|
+
const routeIds = /* @__PURE__ */ new Set();
|
|
5044
|
+
for (const r of def.fixedRoutes ?? []) {
|
|
5045
|
+
if (routeIds.has(r.id)) issues.push({ code: ROUTE_NETWORK_ISSUE.duplicateId, subject: r.id, params: { kind: "fixed-route" } });
|
|
5046
|
+
routeIds.add(r.id);
|
|
5047
|
+
if (!FIXED_ROUTE_BINDING.includes(r.binding)) {
|
|
5048
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.fixedBinding, subject: r.id, params: { binding: String(r.binding) } });
|
|
5049
|
+
}
|
|
5050
|
+
if (!r.connectionIds || r.connectionIds.length === 0) {
|
|
5051
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.fixedEmpty, subject: r.id, params: {} });
|
|
5052
|
+
continue;
|
|
5053
|
+
}
|
|
5054
|
+
const legs = [];
|
|
5055
|
+
for (const id of r.connectionIds) {
|
|
5056
|
+
const c = byId.get(id);
|
|
5057
|
+
if (!c) issues.push({ code: ROUTE_NETWORK_ISSUE.fixedUnknownConnection, subject: r.id, params: { connection: id } });
|
|
5058
|
+
else legs.push(c);
|
|
5059
|
+
}
|
|
5060
|
+
if (legs.length !== r.connectionIds.length) continue;
|
|
5061
|
+
let at2 = new Set(traversals(legs[0]).map((t) => t.to));
|
|
5062
|
+
for (let i = 1; i < legs.length; i++) {
|
|
5063
|
+
const next = new Set(traversals(legs[i]).filter((t) => at2.has(t.from)).map((t) => t.to));
|
|
5064
|
+
if (next.size === 0) {
|
|
5065
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.fixedBroken, subject: r.id, params: { after: legs[i - 1].id, connection: legs[i].id } });
|
|
5066
|
+
break;
|
|
5013
5067
|
}
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
enums: { use: MATERIAL_LOT_USE }
|
|
5080
|
-
},
|
|
5081
|
-
test: {
|
|
5082
|
-
eventType: OP_EVENT.test,
|
|
5083
|
-
match: ["testableObjectId"],
|
|
5084
|
-
matchOrder: 70,
|
|
5085
|
-
identity: "testableObjectId",
|
|
5086
|
-
/* 무엇을 어느 기준으로 시험했나 — 둘 중 하나가 없으면 그 결과는 아무 데도 붙지 못한다. */
|
|
5087
|
-
required: ["testableObjectId", "specId"],
|
|
5088
|
-
fields: {
|
|
5089
|
-
testableObjectId: "string",
|
|
5090
|
-
specId: "string",
|
|
5091
|
-
result: "string",
|
|
5092
|
-
at: "string",
|
|
5093
|
-
expiresAt: "string",
|
|
5094
|
-
derived: "boolean",
|
|
5095
|
-
propertyMeasurements: "object[]",
|
|
5096
|
-
specificationBasis: "object",
|
|
5097
|
-
recordTime: "string"
|
|
5098
|
-
},
|
|
5099
|
-
shapes: {
|
|
5100
|
-
specificationBasis: {
|
|
5101
|
-
required: ["id", "revisionId", "planId", "contentHash", "businessTime", "criteria"],
|
|
5102
|
-
fields: { id: "string", revisionId: "string", planId: "string", contentHash: "string", businessTime: "string" }
|
|
5068
|
+
at2 = next;
|
|
5069
|
+
}
|
|
5070
|
+
for (const classId of r.equipmentClassIds ?? []) {
|
|
5071
|
+
const blocked = legs.find((c) => !admits(c, [classId], def.equipmentClasses));
|
|
5072
|
+
if (blocked) issues.push({ code: ROUTE_NETWORK_ISSUE.fixedClass, subject: r.id, params: { equipmentClassId: classId, connection: blocked.id } });
|
|
5073
|
+
}
|
|
5074
|
+
}
|
|
5075
|
+
return issues;
|
|
5076
|
+
}
|
|
5077
|
+
function connectionAdmits(c, equipmentClassIds, classes) {
|
|
5078
|
+
return admits(c, equipmentClassIds, classes);
|
|
5079
|
+
}
|
|
5080
|
+
|
|
5081
|
+
// src/transport-policy.ts
|
|
5082
|
+
var DISPATCH_RULE = {
|
|
5083
|
+
/** The first available machine in the kernel's own order - what its assignment does today. */
|
|
5084
|
+
firstIdle: "firstIdle",
|
|
5085
|
+
/** The machine that reaches the pick-up soonest; ties by id. */
|
|
5086
|
+
minEta: "minEta"
|
|
5087
|
+
};
|
|
5088
|
+
var ROUTING_RULE = {
|
|
5089
|
+
/** Least travel time, reservations not considered. Connection time = length / effective speed. */
|
|
5090
|
+
shortestTime: "shortestTime",
|
|
5091
|
+
/** Least arrival time over time windows: a connection held past its capacity is waited for or avoided. */
|
|
5092
|
+
timeWindow: "timeWindow"
|
|
5093
|
+
};
|
|
5094
|
+
var TRAFFIC_CONFLICT_ACTION = ["wait", "replan", "yield"];
|
|
5095
|
+
var TRANSPORT_POLICY_ISSUE = {
|
|
5096
|
+
ruleMissing: "policy-rule-missing",
|
|
5097
|
+
ruleUnknown: "policy-rule-unknown",
|
|
5098
|
+
conflictAction: "policy-conflict-action",
|
|
5099
|
+
horizon: "policy-horizon",
|
|
5100
|
+
soc: "policy-soc",
|
|
5101
|
+
alternateUnknown: "policy-alternate-unknown",
|
|
5102
|
+
alternateSelf: "policy-alternate-self",
|
|
5103
|
+
alternateDuplicate: "policy-alternate-duplicate"
|
|
5104
|
+
};
|
|
5105
|
+
var isPercent = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= 100;
|
|
5106
|
+
function validateTransportPolicy(policy, locationIds) {
|
|
5107
|
+
const issues = [];
|
|
5108
|
+
const known = { dispatch: Object.values(DISPATCH_RULE), routing: Object.values(ROUTING_RULE) };
|
|
5109
|
+
for (const part of ["dispatch", "routing"]) {
|
|
5110
|
+
const rule = policy[part]?.rule;
|
|
5111
|
+
if (typeof rule !== "string" || rule.trim() === "") issues.push({ code: TRANSPORT_POLICY_ISSUE.ruleMissing, params: { part } });
|
|
5112
|
+
else if (!known[part].includes(rule)) issues.push({ code: TRANSPORT_POLICY_ISSUE.ruleUnknown, params: { part, rule } });
|
|
5113
|
+
}
|
|
5114
|
+
if (!TRAFFIC_CONFLICT_ACTION.includes(policy.traffic?.onConflict)) {
|
|
5115
|
+
issues.push({ code: TRANSPORT_POLICY_ISSUE.conflictAction, params: { onConflict: String(policy.traffic?.onConflict) } });
|
|
5116
|
+
}
|
|
5117
|
+
const horizon = policy.traffic?.horizonS;
|
|
5118
|
+
if (horizon !== void 0 && !(typeof horizon === "number" && Number.isFinite(horizon) && horizon > 0)) {
|
|
5119
|
+
issues.push({ code: TRANSPORT_POLICY_ISSUE.horizon, params: { horizonS: String(horizon) } });
|
|
5120
|
+
}
|
|
5121
|
+
const { lowSoc, targetSoc } = policy.charging ?? {};
|
|
5122
|
+
if (!isPercent(lowSoc) || !isPercent(targetSoc) || lowSoc >= targetSoc) {
|
|
5123
|
+
issues.push({ code: TRANSPORT_POLICY_ISSUE.soc, params: { lowSoc: String(lowSoc), targetSoc: String(targetSoc) } });
|
|
5124
|
+
}
|
|
5125
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5126
|
+
for (const a of policy.alternates ?? []) {
|
|
5127
|
+
if (seen.has(a.destination)) issues.push({ code: TRANSPORT_POLICY_ISSUE.alternateDuplicate, params: { destination: a.destination } });
|
|
5128
|
+
seen.add(a.destination);
|
|
5129
|
+
if (a.alternatives.includes(a.destination)) issues.push({ code: TRANSPORT_POLICY_ISSUE.alternateSelf, params: { destination: a.destination } });
|
|
5130
|
+
if (locationIds) {
|
|
5131
|
+
for (const id of [a.destination, ...a.alternatives]) {
|
|
5132
|
+
if (!locationIds.has(id)) issues.push({ code: TRANSPORT_POLICY_ISSUE.alternateUnknown, params: { location: id } });
|
|
5103
5133
|
}
|
|
5104
|
-
},
|
|
5105
|
-
enums: { result: ["pass", "fail"] }
|
|
5106
|
-
},
|
|
5107
|
-
/*
|
|
5108
|
-
* **자리의 물리 관측** — 어느 자리의 어느 속성을 언제 얼마로 쟀나.
|
|
5109
|
-
*
|
|
5110
|
-
* 값에 **단위를 함께** 받는다(`ValueType`). 단위 없는 물리량은 판정의 재료가 못 된다 — 3 이 섭씨인지
|
|
5111
|
-
* 화씨인지 모르면 어떤 기준으로도 판정할 수 없다. 다만 **요구하지는 않는다**: 단위를 비우는 실 원본이
|
|
5112
|
-
* 흔하고, 요구하면 그 원본의 관측을 아예 담지 못한다(그때 판정은 커널이 거부한다 — `outsideLimit`).
|
|
5113
|
-
*
|
|
5114
|
-
* `effectiveTime` 도 요구하지 않는다. 없으면 봉투의 시각이 그 자리를 대신한다(§`resolve`) — 원본이
|
|
5115
|
-
* 시각을 말하지 않는 수기 점검이 실재하고, 그때 지어낸 시각보다 폴링 시각이 정직하다.
|
|
5116
|
-
*/
|
|
5117
|
-
/*
|
|
5118
|
-
* **이 목록이 전부다** — 연결된 시스템이 현재 목록을 한 바퀴 다 보낸 뒤 알린다.
|
|
5119
|
-
*
|
|
5120
|
-
* 둘 다 요구한다: 어느 목록인지와 그 주기를 **시작한** 시각. 시각이 없으면 무엇을 지울지 가릴 수
|
|
5121
|
-
* 없고, 그때 지우면 전부 지운다 — 받지 않는 것이 옳다.
|
|
5122
|
-
*/
|
|
5123
|
-
complete: {
|
|
5124
|
-
eventType: OP_EVENT.complete,
|
|
5125
|
-
match: ["completeAxis"],
|
|
5126
|
-
matchOrder: 100,
|
|
5127
|
-
identity: "completeAxis",
|
|
5128
|
-
required: ["completeAxis", "since"],
|
|
5129
|
-
fields: { completeAxis: "string", since: "string", recordTime: "string" }
|
|
5130
|
-
},
|
|
5131
|
-
observation: {
|
|
5132
|
-
eventType: OP_EVENT.observation,
|
|
5133
|
-
match: ["locationId", "propertyId"],
|
|
5134
|
-
matchOrder: 90,
|
|
5135
|
-
identity: "locationId",
|
|
5136
|
-
/* 자리와 속성 — 둘 중 하나가 없으면 그 관측은 아무 데도 붙지 못한다. */
|
|
5137
|
-
required: ["locationId", "propertyId"],
|
|
5138
|
-
fields: {
|
|
5139
|
-
locationId: "string",
|
|
5140
|
-
propertyId: "string",
|
|
5141
|
-
value: "string",
|
|
5142
|
-
dataType: "string",
|
|
5143
|
-
uom: "string",
|
|
5144
|
-
effectiveTime: "string",
|
|
5145
|
-
effectiveEndTime: "string",
|
|
5146
|
-
recordTime: "string",
|
|
5147
|
-
source: "string",
|
|
5148
|
-
derived: "boolean"
|
|
5149
5134
|
}
|
|
5150
5135
|
}
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5136
|
+
return issues;
|
|
5137
|
+
}
|
|
5138
|
+
|
|
5139
|
+
// src/asset-acceptance.ts
|
|
5140
|
+
function acceptsMaterial(accepts, query) {
|
|
5141
|
+
if (!accepts) return void 0;
|
|
5142
|
+
const defs = accepts.materialDefinitionIds ?? [];
|
|
5143
|
+
const classes = accepts.materialClassIds ?? [];
|
|
5144
|
+
const named = query.materialDefinitionId !== void 0 || (query.materialClassIds?.length ?? 0) > 0;
|
|
5145
|
+
if (!named) return void 0;
|
|
5146
|
+
let material;
|
|
5147
|
+
if (defs.length === 0 && classes.length === 0) material = void 0;
|
|
5148
|
+
else {
|
|
5149
|
+
const byDef = query.materialDefinitionId !== void 0 && defs.includes(query.materialDefinitionId);
|
|
5150
|
+
const byClass = (query.materialClassIds ?? []).some((id) => classes.includes(id));
|
|
5151
|
+
material = byDef || byClass;
|
|
5152
|
+
}
|
|
5153
|
+
if (material === false) return false;
|
|
5154
|
+
let quantity = true;
|
|
5155
|
+
if (query.quantity && accepts.maxQuantity) {
|
|
5156
|
+
quantity = query.quantity.uom === accepts.maxQuantity.uom ? query.quantity.value <= accepts.maxQuantity.value : void 0;
|
|
5157
|
+
}
|
|
5158
|
+
if (quantity === false) return false;
|
|
5159
|
+
if (material === void 0 || quantity === void 0) return void 0;
|
|
5160
|
+
return true;
|
|
5161
|
+
}
|
|
5162
|
+
|
|
5163
|
+
// src/face2-adapter.ts
|
|
5164
|
+
function isAggregationRecord(record) {
|
|
5165
|
+
if (!record || typeof record !== "object") return false;
|
|
5166
|
+
const r = record;
|
|
5167
|
+
return typeof r.parentID === "string" && r.parentID.trim().length > 0 && r.epc === void 0;
|
|
5168
|
+
}
|
|
5169
|
+
function isTransformationRecord(record) {
|
|
5170
|
+
if (!record || typeof record !== "object") return false;
|
|
5171
|
+
const r = record;
|
|
5172
|
+
if (r.epc !== void 0 || r.parentID !== void 0) return false;
|
|
5173
|
+
const has = (k) => Array.isArray(r[k]) && r[k].length > 0;
|
|
5174
|
+
return has("inputEPCList") || has("inputQuantityList") || has("outputEPCList") || has("outputQuantityList");
|
|
5175
|
+
}
|
|
5176
|
+
function get(obj, path) {
|
|
5177
|
+
return path.split(".").reduce((o, k) => o == null ? o : o[k], obj);
|
|
5178
|
+
}
|
|
5179
|
+
function resolve(v, record, field, errors) {
|
|
5180
|
+
if (v === void 0) return void 0;
|
|
5181
|
+
if (!v.startsWith("$.")) return v;
|
|
5182
|
+
const r = get(record, v.slice(2));
|
|
5183
|
+
if (r === void 0 || r === null) return void 0;
|
|
5184
|
+
if (typeof r === "object") {
|
|
5185
|
+
errors.push(`${field} \uAC00 \uAC12\uC774 \uC544\uB2C8\uB77C ${Array.isArray(r) ? "\uBC30\uC5F4" : "\uAC1D\uCCB4"}\uB85C \uC654\uB2E4(${v}) \u2014 \uCEE4\uB125\uD130\uAC00 \uD45C\uC900 \uAD6C\uC870\uB97C \uADF8\uB300\uB85C \uC2E4\uC5C8\uB2E4: ${JSON.stringify(r).slice(0, 80)}`);
|
|
5186
|
+
return void 0;
|
|
5187
|
+
}
|
|
5188
|
+
return String(r);
|
|
5189
|
+
}
|
|
5190
|
+
function resolveList(v, record, field, errors) {
|
|
5191
|
+
if (v === void 0) return [];
|
|
5192
|
+
const r = get(record, v.startsWith("$.") ? v.slice(2) : v);
|
|
5193
|
+
if (r === void 0 || r === null) return [];
|
|
5194
|
+
if (!Array.isArray(r) || r.some((x) => typeof x !== "string")) {
|
|
5195
|
+
errors.push(`${field} \uAC00 \uBB38\uC790\uC5F4 \uBC30\uC5F4\uC774 \uC544\uB2C8\uB2E4(${v}): ${JSON.stringify(r).slice(0, 80)}`);
|
|
5196
|
+
return [];
|
|
5197
|
+
}
|
|
5198
|
+
return r.slice();
|
|
5199
|
+
}
|
|
5200
|
+
function resolveQuantityList(v, record, field, errors) {
|
|
5201
|
+
if (v === void 0) return [];
|
|
5202
|
+
const r = get(record, v.startsWith("$.") ? v.slice(2) : v);
|
|
5203
|
+
if (r === void 0 || r === null) return [];
|
|
5204
|
+
if (!Array.isArray(r) || r.some((x) => !x || typeof x !== "object" || Array.isArray(x))) {
|
|
5205
|
+
errors.push(`${field} \uAC00 \uAC1D\uCCB4 \uBC30\uC5F4\uC774 \uC544\uB2C8\uB2E4(${v}): ${JSON.stringify(r).slice(0, 80)}`);
|
|
5206
|
+
return [];
|
|
5207
|
+
}
|
|
5208
|
+
return r.map((x) => ({ ...x }));
|
|
5209
|
+
}
|
|
5210
|
+
function resolveBizTransactionList(v, record, errors) {
|
|
5211
|
+
if (v === void 0) return [];
|
|
5212
|
+
const r = get(record, v.startsWith("$.") ? v.slice(2) : v);
|
|
5213
|
+
if (r === void 0 || r === null) return [];
|
|
5214
|
+
if (!Array.isArray(r) || r.some((x) => !x || typeof x !== "object" || Array.isArray(x))) {
|
|
5215
|
+
errors.push(`bizTransactionList \uAC00 \uAC1D\uCCB4 \uBC30\uC5F4\uC774 \uC544\uB2C8\uB2E4(${v}): ${JSON.stringify(r).slice(0, 80)}`);
|
|
5216
|
+
return [];
|
|
5217
|
+
}
|
|
5218
|
+
const out = [];
|
|
5219
|
+
for (const x of r) {
|
|
5220
|
+
if (typeof x.bizTransaction === "string" && x.bizTransaction.trim()) out.push({ ...x });
|
|
5221
|
+
else errors.push(`bizTransactionList \uC758 \uC6D0\uC18C\uC5D0 bizTransaction \uC774 \uC5C6\uB2E4: ${JSON.stringify(x).slice(0, 80)}`);
|
|
5222
|
+
}
|
|
5223
|
+
return out;
|
|
5224
|
+
}
|
|
5225
|
+
function resolveObject(v, record, field, errors) {
|
|
5226
|
+
if (v === void 0) return void 0;
|
|
5227
|
+
const r = get(record, v.startsWith("$.") ? v.slice(2) : v);
|
|
5228
|
+
if (r === void 0 || r === null) return void 0;
|
|
5229
|
+
if (typeof r !== "object" || Array.isArray(r)) {
|
|
5230
|
+
errors.push(`${field} \uAC00 \uAC1D\uCCB4\uAC00 \uC544\uB2C8\uB2E4(${v}): ${JSON.stringify(r).slice(0, 80)}`);
|
|
5231
|
+
return void 0;
|
|
5232
|
+
}
|
|
5233
|
+
const o = { ...r };
|
|
5234
|
+
return Object.keys(o).length ? o : void 0;
|
|
5235
|
+
}
|
|
5236
|
+
function resolveErrorDeclaration(spec, record, errors) {
|
|
5237
|
+
if (!spec) return void 0;
|
|
5238
|
+
const declarationTime = resolve(spec.declarationTime, record, "errorDeclaration.declarationTime", errors);
|
|
5239
|
+
const reason = resolve(spec.reason, record, "errorDeclaration.reason", errors);
|
|
5240
|
+
const correctiveEventIDs = resolveList(spec.correctiveEventIDs, record, "errorDeclaration.correctiveEventIDs", errors);
|
|
5241
|
+
if (!declarationTime) {
|
|
5242
|
+
if (reason || correctiveEventIDs.length) {
|
|
5243
|
+
errors.push("errorDeclaration\uC5D0 \uC815\uC815 \uC0AC\uC720 \uB610\uB294 \uB300\uC0C1\uC774 \uC788\uC9C0\uB9CC \uC815\uC815 \uC2DC\uAC01(declarationTime)\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
5244
|
+
}
|
|
5245
|
+
return void 0;
|
|
5246
|
+
}
|
|
5247
|
+
return {
|
|
5248
|
+
declarationTime,
|
|
5249
|
+
...reason ? { reason } : {},
|
|
5250
|
+
...correctiveEventIDs.length ? { correctiveEventIDs } : {}
|
|
5251
|
+
};
|
|
5252
|
+
}
|
|
5253
|
+
function mapRecordChecked(record, mapping, eventTime) {
|
|
5254
|
+
const errors = [];
|
|
5255
|
+
const bizStep = resolve(mapping.bizStep, record, "bizStep", errors) ?? "";
|
|
5256
|
+
const disposition = resolve(mapping.disposition, record, "disposition", errors);
|
|
5257
|
+
const readPoint = resolve(mapping.readPoint, record, "readPoint", errors);
|
|
5258
|
+
const bizLocation = resolve(mapping.bizLocation, record, "bizLocation", errors);
|
|
5259
|
+
const errorDeclaration = resolveErrorDeclaration(mapping.errorDeclaration, record, errors);
|
|
5260
|
+
const bizTransactionList = resolveBizTransactionList(mapping.bizTransactionList, record, errors);
|
|
5261
|
+
if (mapping.type === "TransformationEvent") {
|
|
5262
|
+
const inputEPCList = resolveList(mapping.inputEPCList, record, "inputEPCList", errors);
|
|
5263
|
+
const inputQuantityList = resolveQuantityList(mapping.inputQuantityList, record, "inputQuantityList", errors);
|
|
5264
|
+
const outputEPCList = resolveList(mapping.outputEPCList, record, "outputEPCList", errors);
|
|
5265
|
+
const outputQuantityList = resolveQuantityList(mapping.outputQuantityList, record, "outputQuantityList", errors);
|
|
5266
|
+
const transformationID = resolve(mapping.transformationID, record, "transformationID", errors);
|
|
5267
|
+
if (!inputEPCList.length && !inputQuantityList.length) {
|
|
5268
|
+
errors.push("\uBCC0\uD658 \uC774\uBCA4\uD2B8\uC5D0 \uC785\uB825 \uD56D\uBAA9\uC774 \uD544\uC694\uD569\uB2C8\uB2E4.(EPCIS 2.0 \xA77.4.5)");
|
|
5269
|
+
}
|
|
5270
|
+
if (!outputEPCList.length && !outputQuantityList.length) {
|
|
5271
|
+
errors.push("\uBCC0\uD658 \uC774\uBCA4\uD2B8\uC5D0 \uCD9C\uB825 \uD56D\uBAA9\uC774 \uD544\uC694\uD569\uB2C8\uB2E4.(EPCIS 2.0 \xA77.4.5)");
|
|
5272
|
+
}
|
|
5273
|
+
return {
|
|
5274
|
+
event: transformationEvent({
|
|
5275
|
+
eventTime,
|
|
5276
|
+
bizStep,
|
|
5277
|
+
disposition,
|
|
5278
|
+
/* 없는 쪽은 **필드를 만들지 않는다** — 빈 배열을 실으면 「없다」고 말하는 것이 된다.
|
|
5279
|
+
개체로 말한 쪽과 수량으로 말한 쪽 중 하나만 쓰는 것이 정상이다. */
|
|
5280
|
+
...inputEPCList.length ? { inputEPCList } : {},
|
|
5281
|
+
...inputQuantityList.length ? { inputQuantityList } : {},
|
|
5282
|
+
...outputEPCList.length ? { outputEPCList } : {},
|
|
5283
|
+
...outputQuantityList.length ? { outputQuantityList } : {},
|
|
5284
|
+
...transformationID ? { transformationID } : {},
|
|
5285
|
+
...errorDeclaration ? { errorDeclaration } : {},
|
|
5286
|
+
...bizTransactionList.length ? { bizTransactionList } : {},
|
|
5287
|
+
readPoint,
|
|
5288
|
+
bizLocation
|
|
5289
|
+
}),
|
|
5290
|
+
errors
|
|
5291
|
+
};
|
|
5292
|
+
}
|
|
5293
|
+
if (mapping.type === "AggregationEvent") {
|
|
5294
|
+
const action2 = resolve(mapping.action, record, "action", errors) ?? "";
|
|
5295
|
+
const parentID = resolve(mapping.parentID, record, "parentID", errors) ?? "";
|
|
5296
|
+
const childEPCs = resolveList(mapping.childEPCs, record, "childEPCs", errors);
|
|
5297
|
+
const childQuantityList = resolveQuantityList(mapping.childQuantityList, record, "childQuantityList", errors);
|
|
5298
|
+
return {
|
|
5299
|
+
event: aggregationEvent({
|
|
5300
|
+
eventTime,
|
|
5301
|
+
action: action2,
|
|
5302
|
+
bizStep,
|
|
5303
|
+
disposition,
|
|
5304
|
+
parentID,
|
|
5305
|
+
/* 없는 쪽은 **필드를 만들지 않는다** — 빈 배열을 실으면 「자식이 없다」고 말하는 것이 된다. */
|
|
5306
|
+
...childEPCs.length ? { childEPCs } : {},
|
|
5307
|
+
...childQuantityList.length ? { childQuantityList } : {},
|
|
5308
|
+
...errorDeclaration ? { errorDeclaration } : {},
|
|
5309
|
+
...bizTransactionList.length ? { bizTransactionList } : {},
|
|
5310
|
+
readPoint,
|
|
5311
|
+
bizLocation
|
|
5312
|
+
}),
|
|
5313
|
+
errors
|
|
5314
|
+
};
|
|
5315
|
+
}
|
|
5316
|
+
const action = resolve(mapping.action, record, "action", errors) ?? "";
|
|
5317
|
+
const epc = resolve(mapping.epc, record, "epc", errors);
|
|
5318
|
+
const quantityList = resolveQuantityList(mapping.quantityList, record, "quantityList", errors);
|
|
5319
|
+
if (!epc && !quantityList.length) {
|
|
5320
|
+
errors.push("epc \uB610\uB294 quantityList\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uAC1C\uCCB4 \uC2DD\uBCC4\uC790\uB098 \uD074\uB798\uC2A4\xB7\uC218\uB7C9\uC744 \uC9C0\uC815\uD558\uC138\uC694.");
|
|
5165
5321
|
}
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
}
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5322
|
+
const ilmd = resolveObject(mapping.ilmd, record, "ilmd", errors);
|
|
5323
|
+
return {
|
|
5324
|
+
event: objectEvent({
|
|
5325
|
+
eventTime,
|
|
5326
|
+
action,
|
|
5327
|
+
bizStep,
|
|
5328
|
+
disposition,
|
|
5329
|
+
epcList: epc ? [epc] : [],
|
|
5330
|
+
...quantityList.length ? { quantityList } : {},
|
|
5331
|
+
...ilmd ? { ilmd } : {},
|
|
5332
|
+
...errorDeclaration ? { errorDeclaration } : {},
|
|
5333
|
+
...bizTransactionList.length ? { bizTransactionList } : {},
|
|
5334
|
+
readPoint,
|
|
5335
|
+
bizLocation
|
|
5336
|
+
}),
|
|
5337
|
+
errors
|
|
5338
|
+
};
|
|
5181
5339
|
}
|
|
5182
|
-
function
|
|
5183
|
-
return
|
|
5340
|
+
function mapRecord(record, mapping, eventTime) {
|
|
5341
|
+
return mapRecordChecked(record, mapping, eventTime).event;
|
|
5184
5342
|
}
|
|
5185
|
-
function
|
|
5186
|
-
const
|
|
5343
|
+
function ingest(records, rules, opts) {
|
|
5344
|
+
const ruleByType = new Map(rules.map((r) => [r.sourceType, r]));
|
|
5187
5345
|
const accepted = [];
|
|
5188
5346
|
const rejected = [];
|
|
5189
5347
|
let seq = 0;
|
|
5190
|
-
for (const record of
|
|
5191
|
-
const
|
|
5192
|
-
if (!
|
|
5193
|
-
rejected.push({ record, errors: [
|
|
5348
|
+
for (const record of records) {
|
|
5349
|
+
const rule = ruleByType.get(String(record["sourceType"]));
|
|
5350
|
+
if (!rule) {
|
|
5351
|
+
rejected.push({ record, errors: [`\uC77C\uCE58\uD558\uB294 \uB9E4\uD551 \uADDC\uCE59 \uC5C6\uC74C: sourceType=${record["sourceType"]}`] });
|
|
5194
5352
|
continue;
|
|
5195
5353
|
}
|
|
5196
|
-
const
|
|
5197
|
-
const
|
|
5198
|
-
const errors =
|
|
5199
|
-
const
|
|
5200
|
-
const unknown = Object.keys(r).filter((k) => !ENVELOPE_FIELDS.includes(k) && spec.fields[k] === void 0);
|
|
5201
|
-
if (unknown.length) errors.push(`${kind}: \uACC4\uC57D\uC5D0 \uC5C6\uB294 \uD544\uB4DC \u2014 ${unknown.join(", ")}`);
|
|
5202
|
-
for (const name of spec.required) {
|
|
5203
|
-
const v = r[name];
|
|
5204
|
-
if (v === void 0 || v === null || v === "") errors.push(`${kind}: ${name}: \uD544\uC218 \uAC12 \uB204\uB77D`);
|
|
5205
|
-
}
|
|
5206
|
-
const data = {};
|
|
5207
|
-
for (const [name, type] of Object.entries(spec.fields)) {
|
|
5208
|
-
const v = r[name];
|
|
5209
|
-
if (v === void 0 || v === null || v === "") continue;
|
|
5210
|
-
switch (type) {
|
|
5211
|
-
case "string": {
|
|
5212
|
-
if (typeof v !== "string") {
|
|
5213
|
-
errors.push(`${kind}.${name} \uAC12\uC740 \uBB38\uC790\uC5F4\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
5214
|
-
break;
|
|
5215
|
-
}
|
|
5216
|
-
const allowed = spec.enums?.[name];
|
|
5217
|
-
if (allowed && !allowed.includes(v)) {
|
|
5218
|
-
errors.push(`${kind}.${name}\uC5D0 \uD5C8\uC6A9\uB418\uC9C0 \uC54A\uB294 \uAC12\uC774 \uC9C0\uC815\uB418\uC5C8\uC2B5\uB2C8\uB2E4: ${JSON.stringify(v)} \u2014 \uD5C8\uC6A9 \uAC12: ${allowed.join(" \xB7 ")}`);
|
|
5219
|
-
break;
|
|
5220
|
-
}
|
|
5221
|
-
data[name] = v;
|
|
5222
|
-
break;
|
|
5223
|
-
}
|
|
5224
|
-
case "number": {
|
|
5225
|
-
const n = Number(v);
|
|
5226
|
-
if (typeof v === "boolean" || !Number.isFinite(n)) {
|
|
5227
|
-
errors.push(`${kind}.${name} \uAC12\uC740 \uC720\uD55C\uD55C \uC22B\uC790\uC5EC\uC57C \uD569\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
5228
|
-
break;
|
|
5229
|
-
}
|
|
5230
|
-
if (name === "progress" && (n < 0 || n > 1)) {
|
|
5231
|
-
errors.push(`${kind}.progress \uB294 0~1 \uBE44\uC728\uC774\uB2E4: ${n}`);
|
|
5232
|
-
break;
|
|
5233
|
-
}
|
|
5234
|
-
if ((name === "requested" || name === "fulfilled" || name === "goodCount" || name === "nonconformingCount") && n < 0) {
|
|
5235
|
-
errors.push(`${kind}.${name} \uAC00 \uC74C\uC218\uB2E4: ${n}`);
|
|
5236
|
-
break;
|
|
5237
|
-
}
|
|
5238
|
-
data[name] = n;
|
|
5239
|
-
break;
|
|
5240
|
-
}
|
|
5241
|
-
case "boolean": {
|
|
5242
|
-
if (typeof v !== "boolean") {
|
|
5243
|
-
errors.push(`${kind}.${name} \uAC12\uC740 \uBD88\uB9AC\uC5B8\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
5244
|
-
break;
|
|
5245
|
-
}
|
|
5246
|
-
data[name] = v;
|
|
5247
|
-
break;
|
|
5248
|
-
}
|
|
5249
|
-
case "string[]": {
|
|
5250
|
-
if (!Array.isArray(v) || v.some((x) => typeof x !== "string")) {
|
|
5251
|
-
errors.push(`${kind}.${name} \uAC12\uC740 \uBB38\uC790\uC5F4 \uBC30\uC5F4\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
5252
|
-
break;
|
|
5253
|
-
}
|
|
5254
|
-
data[name] = v.slice();
|
|
5255
|
-
break;
|
|
5256
|
-
}
|
|
5257
|
-
case "object": {
|
|
5258
|
-
if (Array.isArray(v) || typeof v !== "object") {
|
|
5259
|
-
errors.push(`${kind}.${name} \uAC12\uC740 \uAC1D\uCCB4\uC5EC\uC57C \uD569\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
5260
|
-
break;
|
|
5261
|
-
}
|
|
5262
|
-
errors.push(...shapeErrors(`${kind}.${name}`, v, spec.shapes?.[name]));
|
|
5263
|
-
data[name] = { ...v };
|
|
5264
|
-
break;
|
|
5265
|
-
}
|
|
5266
|
-
case "object[]": {
|
|
5267
|
-
if (!Array.isArray(v) || v.some((x) => !x || typeof x !== "object")) {
|
|
5268
|
-
errors.push(`${kind}.${name} \uAC12\uC740 \uAC1D\uCCB4 \uBC30\uC5F4\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4: ${JSON.stringify(v)}`);
|
|
5269
|
-
break;
|
|
5270
|
-
}
|
|
5271
|
-
v.forEach(
|
|
5272
|
-
(x, i) => errors.push(...shapeErrors(`${kind}.${name}[${i}]`, x, spec.shapes?.[name]))
|
|
5273
|
-
);
|
|
5274
|
-
data[name] = v.map((x) => ({ ...x }));
|
|
5275
|
-
break;
|
|
5276
|
-
}
|
|
5277
|
-
}
|
|
5278
|
-
}
|
|
5279
|
-
if ((kind === "task" || kind === "equipment-period") && r.workShiftBasis !== void 0) {
|
|
5280
|
-
if (!isWorkShiftExecutionBasis(r.workShiftBasis) || kind === "equipment-period" && Date.parse(r.workShiftBasis.businessTime) !== Date.parse(String(r.from)) || kind === "task" && (r.startTime ?? r.endTime) !== void 0 && Date.parse(r.workShiftBasis.businessTime) !== Date.parse(String(r.startTime ?? r.endTime))) {
|
|
5281
|
-
errors.push(kind + ".workShiftBasis: invalid pinned shift evidence");
|
|
5282
|
-
} else data.workShiftBasis = structuredClone(r.workShiftBasis);
|
|
5283
|
-
}
|
|
5284
|
-
if (kind === "test" && r.specificationBasis !== void 0 && !isTestSpecificationBasis(r.specificationBasis)) {
|
|
5285
|
-
errors.push("test.specificationBasis: invalid pinned specification evidence");
|
|
5286
|
-
}
|
|
5287
|
-
if (kind === "order" && r.materialBasis !== void 0) {
|
|
5288
|
-
const bases = r.materialBasis;
|
|
5289
|
-
if (!Array.isArray(bases) || !bases.length || bases.length > 1e3 || !bases.every(isMaterialExecutionBasis) || new Set(bases.map((b) => b.material.id)).size !== bases.length || r.gtin !== void 0 && !bases.some((b) => b.material.id === r.gtin) || isRecipeExecutionBasis(r.recipeBasis) && [...r.recipeBasis.recipe.inputs, ...r.recipeBasis.recipe.outputs].some((line) => !bases.some((b) => b.material.id === line.material)))
|
|
5290
|
-
errors.push("order.materialBasis: invalid pinned material evidence");
|
|
5291
|
-
}
|
|
5292
|
-
if (kind === "order" && r.recipeBasis !== void 0 && (!isRecipeExecutionBasis(r.recipeBasis) || r.recipeKey !== void 0 && r.recipeKey !== r.recipeBasis.recipe.key)) {
|
|
5293
|
-
errors.push("order.recipeBasis: invalid pinned recipe evidence");
|
|
5294
|
-
}
|
|
5295
|
-
const closedPeriodEnd = kind === "equipment-period" ? String(r.to ?? "").trim() : "";
|
|
5296
|
-
const at2 = closedPeriodEnd || String(r.at ?? "").trim() || opts.defaultEventTime;
|
|
5297
|
-
const atMs = at2 ? Date.parse(at2) : Number.NaN;
|
|
5298
|
-
if (!Number.isFinite(atMs)) {
|
|
5299
|
-
errors.push(`${kind}: at \uC5C6\uC74C/\uD615\uC2DD \uC624\uB958 \u2014 \uC774\uC804 \uC774\uBCA4\uD2B8\uAC00 \uB4A4\uB2A6\uAC8C \uB3C4\uCC29\uD588\uB294\uC9C0 \uD310\uB2E8\uD558\uB824\uBA74 \uC2DC\uAC01\uC774 \uD544\uC694\uD569\uB2C8\uB2E4.`);
|
|
5300
|
-
}
|
|
5301
|
-
if (closedPeriodEnd && opts.defaultEventTime) {
|
|
5302
|
-
const nowMs = Date.parse(opts.defaultEventTime);
|
|
5303
|
-
if (Number.isFinite(nowMs) && Number.isFinite(atMs) && atMs > nowMs) {
|
|
5304
|
-
errors.push(`${kind}: \uC544\uC9C1 \uC624\uC9C0 \uC54A\uC740 \uC2DC\uAC01\uC758 \uC0AC\uC2E4\uC774\uB2E4(${closedPeriodEnd}) \u2014 \uC885\uB8CC\uB41C \uAD6C\uAC04\uB9CC \uB9C8\uAC10\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`);
|
|
5305
|
-
}
|
|
5306
|
-
}
|
|
5354
|
+
const timeErrors = [];
|
|
5355
|
+
const eventTime = (opts.eventTimePath ? resolve("$." + opts.eventTimePath, record, "eventTime", timeErrors) : void 0) ?? opts.defaultEventTime;
|
|
5356
|
+
const { event: ev, errors: mapErrors } = mapRecordChecked(record, rule.mapping, eventTime);
|
|
5357
|
+
const errors = [...timeErrors, ...mapErrors, ...validateEpcisEvent(ev)];
|
|
5307
5358
|
if (errors.length) {
|
|
5308
5359
|
rejected.push({ record, errors });
|
|
5309
5360
|
continue;
|
|
5310
5361
|
}
|
|
5311
|
-
const note = typeof
|
|
5362
|
+
const note = typeof record["description"] === "string" ? String(record["description"]).trim() : "";
|
|
5312
5363
|
accepted.push({
|
|
5313
|
-
eventId: `${opts.tenantId}-
|
|
5314
|
-
eventType:
|
|
5315
|
-
eventTime:
|
|
5364
|
+
eventId: `${opts.tenantId}-ingest-${++seq}`,
|
|
5365
|
+
eventType: `epcis.${ev.type}`,
|
|
5366
|
+
eventTime: ev.eventTime,
|
|
5316
5367
|
tenantId: opts.tenantId,
|
|
5317
5368
|
...note ? { description: note } : {},
|
|
5318
|
-
data
|
|
5369
|
+
data: ev
|
|
5319
5370
|
});
|
|
5320
5371
|
}
|
|
5321
5372
|
return { accepted, rejected };
|
|
5322
5373
|
}
|
|
5323
5374
|
|
|
5375
|
+
// src/iso-duration.ts
|
|
5376
|
+
var RE = /^(-)?P(?:(\d+(?:\.\d+)?)W)?(?:(\d+(?:\.\d+)?)D)?(?:T(?:(\d+(?:\.\d+)?)H)?(?:(\d+(?:\.\d+)?)M)?(?:(\d+(?:\.\d+)?)S)?)?$/;
|
|
5377
|
+
function parseIsoDuration(text) {
|
|
5378
|
+
if (typeof text !== "string") return void 0;
|
|
5379
|
+
const s = text.trim();
|
|
5380
|
+
if (!s || s === "P" || s === "PT") return void 0;
|
|
5381
|
+
if (/\d+Y/.test(s)) return void 0;
|
|
5382
|
+
const tIdx = s.indexOf("T");
|
|
5383
|
+
const datePart = tIdx === -1 ? s : s.slice(0, tIdx);
|
|
5384
|
+
if (/\d+M/.test(datePart)) return void 0;
|
|
5385
|
+
const m = RE.exec(s);
|
|
5386
|
+
if (!m) return void 0;
|
|
5387
|
+
const [, sign, w, d, h, min, sec] = m;
|
|
5388
|
+
if (!w && !d && !h && !min && !sec) return void 0;
|
|
5389
|
+
const ms = (Number(w ?? 0) * 7 + Number(d ?? 0)) * 864e5 + Number(h ?? 0) * 36e5 + Number(min ?? 0) * 6e4 + Number(sec ?? 0) * 1e3;
|
|
5390
|
+
if (!Number.isFinite(ms)) return void 0;
|
|
5391
|
+
return sign ? -ms : ms;
|
|
5392
|
+
}
|
|
5393
|
+
|
|
5394
|
+
// src/master-data.ts
|
|
5395
|
+
var VOCABULARY_TYPE = {
|
|
5396
|
+
/** 품목·로트 클래스의 속성 — 유통기한·로트번호가 여기 온다. */
|
|
5397
|
+
epcClass: "urn:epcglobal:epcis:vtype:EPCClass",
|
|
5398
|
+
/** 관측 지점의 속성. */
|
|
5399
|
+
readPoint: "urn:epcglobal:epcis:vtype:ReadPoint",
|
|
5400
|
+
/** 업무 자리의 속성. */
|
|
5401
|
+
bizLocation: "urn:epcglobal:epcis:vtype:BizLocation"
|
|
5402
|
+
};
|
|
5403
|
+
function isMasterDataRecord(record) {
|
|
5404
|
+
if (!record || typeof record !== "object") return false;
|
|
5405
|
+
const r = record;
|
|
5406
|
+
return typeof r.vocabularyType === "string" && !!r.vocabularyType && typeof r.id === "string" && !!r.id && isPlainObject(r.attributes);
|
|
5407
|
+
}
|
|
5408
|
+
function isPlainObject(v) {
|
|
5409
|
+
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
5410
|
+
}
|
|
5411
|
+
function ingestMasterData(records) {
|
|
5412
|
+
const arr = Array.isArray(records) ? records : records ? [records] : [];
|
|
5413
|
+
const accepted = [];
|
|
5414
|
+
const rejected = [];
|
|
5415
|
+
for (const r of arr) {
|
|
5416
|
+
const errors = [];
|
|
5417
|
+
if (!isMasterDataRecord(r)) errors.push("vocabularyType, id, attributes\uB97C \uC9C0\uC815\uD574\uC57C \uD569\uB2C8\uB2E4.");
|
|
5418
|
+
else if (!Object.keys(r.attributes).length) errors.push("attributes\uC5D0 \uC18D\uC131\uC744 \uD558\uB098 \uC774\uC0C1 \uC9C0\uC815\uD574\uC57C \uD569\uB2C8\uB2E4.");
|
|
5419
|
+
if (errors.length) rejected.push({ record: r, errors });
|
|
5420
|
+
else accepted.push({ vocabularyType: r.vocabularyType, id: r.id, attributes: { ...r.attributes } });
|
|
5421
|
+
}
|
|
5422
|
+
return { accepted, rejected };
|
|
5423
|
+
}
|
|
5424
|
+
function expiryFromAttributes(attrs) {
|
|
5425
|
+
return readEpochMs(attrs?.[ILMD_ATTR.expiry]);
|
|
5426
|
+
}
|
|
5427
|
+
function lotFromAttributes(attrs) {
|
|
5428
|
+
const v = attrs?.[ILMD_ATTR.lot];
|
|
5429
|
+
return typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
5430
|
+
}
|
|
5431
|
+
function readEpochMs(raw) {
|
|
5432
|
+
if (typeof raw === "number") return Number.isFinite(raw) ? raw : void 0;
|
|
5433
|
+
if (typeof raw !== "string" || !raw.trim()) return void 0;
|
|
5434
|
+
const at2 = Date.parse(raw);
|
|
5435
|
+
return Number.isNaN(at2) ? void 0 : at2;
|
|
5436
|
+
}
|
|
5437
|
+
|
|
5324
5438
|
// src/operations-capability.ts
|
|
5325
5439
|
function workingHoursBetween(calendar, fromMs, toMs, utcOffsetMinutes) {
|
|
5326
5440
|
if (!(toMs > fromMs)) return 0;
|
|
@@ -6501,6 +6615,7 @@ function inheritedExpiry(inputExpiries) {
|
|
|
6501
6615
|
EPCIS_CONTEXT,
|
|
6502
6616
|
EPCIS_EVENT,
|
|
6503
6617
|
EQUIPMENT_LEVEL,
|
|
6618
|
+
EQUIPMENT_PROPERTY,
|
|
6504
6619
|
EQUIPMENT_STATUS,
|
|
6505
6620
|
ERP_CAPABILITY,
|
|
6506
6621
|
ERP_MASTER_AXIS,
|
|
@@ -6512,8 +6627,10 @@ function inheritedExpiry(inputExpiries) {
|
|
|
6512
6627
|
HEADER_FIELDS_PARTITIONED,
|
|
6513
6628
|
ILG_ATTENTION_KIND,
|
|
6514
6629
|
ILG_BIZSTEP,
|
|
6630
|
+
ILG_EQUIPMENT_PROPERTY,
|
|
6515
6631
|
ILG_LOCATION_TYPES,
|
|
6516
6632
|
ILG_ORDER_KIND,
|
|
6633
|
+
ILG_ROBOT_IDENTITY_PROPERTY,
|
|
6517
6634
|
ILG_TASK_KIND,
|
|
6518
6635
|
ILG_TYPES,
|
|
6519
6636
|
ILMD_ATTR,
|
|
@@ -6540,6 +6657,7 @@ function inheritedExpiry(inputExpiries) {
|
|
|
6540
6657
|
PARTY_ROLE,
|
|
6541
6658
|
PARTY_URI_MAX_LENGTH,
|
|
6542
6659
|
PARTY_URI_RECOMMENDED_LENGTH,
|
|
6660
|
+
PERCENT_UOM,
|
|
6543
6661
|
PERSON_STATUS,
|
|
6544
6662
|
PRIORITY_UNSET,
|
|
6545
6663
|
PRIVATE_BIZSTEP,
|
|
@@ -6554,6 +6672,7 @@ function inheritedExpiry(inputExpiries) {
|
|
|
6554
6672
|
SCHEDULE_STATUS,
|
|
6555
6673
|
SIGNATURE_REJECTED_REASONS,
|
|
6556
6674
|
SOURCE_DEST_PARTY_TYPE,
|
|
6675
|
+
SPEED_TO_MPS,
|
|
6557
6676
|
TARIFF_DAY_KINDS,
|
|
6558
6677
|
TARIFF_ISSUE_CODES,
|
|
6559
6678
|
TARIFF_LOAD_CLASSES,
|
|
@@ -6689,6 +6808,7 @@ function inheritedExpiry(inputExpiries) {
|
|
|
6689
6808
|
isEquipmentStatus,
|
|
6690
6809
|
isFailureStatus,
|
|
6691
6810
|
isFlowOrder,
|
|
6811
|
+
isGuidedType,
|
|
6692
6812
|
isHeading,
|
|
6693
6813
|
isIso4217Code,
|
|
6694
6814
|
isIsoDateTime,
|
|
@@ -6709,6 +6829,7 @@ function inheritedExpiry(inputExpiries) {
|
|
|
6709
6829
|
isTestSpecificationBasis,
|
|
6710
6830
|
isTransformationRecord,
|
|
6711
6831
|
isTransportFailureReason,
|
|
6832
|
+
isTravelRecord,
|
|
6712
6833
|
isWebhookDeliveryCode,
|
|
6713
6834
|
isWebhookSecretSegment,
|
|
6714
6835
|
isWorkShiftExecutionBasis,
|
|
@@ -6788,6 +6909,7 @@ function inheritedExpiry(inputExpiries) {
|
|
|
6788
6909
|
sameItemClass,
|
|
6789
6910
|
sgtinClass,
|
|
6790
6911
|
sgtinUri,
|
|
6912
|
+
speedMpsOf,
|
|
6791
6913
|
splitFlowOrders,
|
|
6792
6914
|
splitRelationIds,
|
|
6793
6915
|
ssccDigitsOf,
|