@dssp/dkpi 1.0.0-alpha.19 → 1.0.0-alpha.21

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.
@@ -0,0 +1,707 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddKpiStatistics1752192090124 = void 0;
4
+ const kpi_1 = require("@things-factory/kpi");
5
+ const kpi_2 = require("@things-factory/kpi");
6
+ const shell_1 = require("@things-factory/shell");
7
+ const KPI_STATISTICS = [
8
+ // X11 데이터 (이미지 수치 그대로)
9
+ {
10
+ kpiName: 'X11. 연면적 대비 공사기간',
11
+ valueDate: '2025-08',
12
+ periodType: kpi_2.KpiPeriodType.MONTH,
13
+ count: 100,
14
+ sum: 153.5945,
15
+ range: 10.775829,
16
+ mean: 1.535945,
17
+ median: 0.596117,
18
+ minimum: 0.096101,
19
+ maximum: 10.87193,
20
+ standardDeviation: 2.123456,
21
+ variance: 4.509123,
22
+ percentile25: 0.16328,
23
+ percentile75: 1.987095,
24
+ iqr: 1.823815,
25
+ lowerFence: -2.57244,
26
+ upperFence: 4.722817,
27
+ additionalStatistics: {
28
+ coefficientOfVariation: 1.382,
29
+ skewness: 2.145,
30
+ kurtosis: 8.234
31
+ },
32
+ metadata: {
33
+ calculationMethod: 'automated',
34
+ lastCalculated: '2025-01-15T10:30:00Z',
35
+ dataCount: 100,
36
+ source: 'production_line_x11'
37
+ }
38
+ },
39
+ // X12 데이터 (이미지 수치 그대로)
40
+ {
41
+ kpiName: 'X12. 설계변경에 따른 공기 증감률',
42
+ valueDate: '2025-08',
43
+ periodType: kpi_2.KpiPeriodType.MONTH,
44
+ count: 95,
45
+ sum: 2.83898,
46
+ range: 0.73448,
47
+ mean: 0.029884,
48
+ median: -0.00059,
49
+ minimum: -0.03448,
50
+ maximum: 0.7,
51
+ standardDeviation: 0.123456,
52
+ variance: 0.015241,
53
+ percentile25: -0.02499,
54
+ percentile75: 0.053692,
55
+ iqr: 0.078682,
56
+ lowerFence: -0.14302,
57
+ upperFence: 0.17172,
58
+ additionalStatistics: {
59
+ coefficientOfVariation: 4.132,
60
+ skewness: 3.456,
61
+ kurtosis: 12.789
62
+ },
63
+ metadata: {
64
+ calculationMethod: 'automated',
65
+ lastCalculated: '2025-01-15T10:30:00Z',
66
+ dataCount: 95,
67
+ source: 'production_line_x12'
68
+ }
69
+ },
70
+ // X13 데이터 (이미지 수치 그대로)
71
+ {
72
+ kpiName: 'X13. 일정 이탈 수준',
73
+ valueDate: '2025-08',
74
+ periodType: kpi_2.KpiPeriodType.MONTH,
75
+ count: 88,
76
+ sum: 407.1584,
77
+ range: 1.0,
78
+ mean: 4.6268,
79
+ median: 5.0,
80
+ minimum: 4.0,
81
+ maximum: 5.0,
82
+ standardDeviation: 0.234567,
83
+ variance: 0.055021,
84
+ percentile25: 4.0,
85
+ percentile75: 5.0,
86
+ iqr: 1.0,
87
+ lowerFence: 2.5,
88
+ upperFence: 6.5,
89
+ additionalStatistics: {
90
+ coefficientOfVariation: 0.051,
91
+ skewness: -0.234,
92
+ kurtosis: 2.456
93
+ },
94
+ metadata: {
95
+ calculationMethod: 'automated',
96
+ lastCalculated: '2025-01-15T10:30:00Z',
97
+ dataCount: 88,
98
+ source: 'production_line_x13'
99
+ }
100
+ },
101
+ // X14 데이터 (이미지 수치 그대로)
102
+ {
103
+ kpiName: 'X14. 일정성과 수준 평가',
104
+ valueDate: '2025-08',
105
+ periodType: kpi_2.KpiPeriodType.MONTH,
106
+ count: 92,
107
+ sum: 368.253,
108
+ range: 2.0,
109
+ mean: 4.00275,
110
+ median: 4.0,
111
+ minimum: 3.0,
112
+ maximum: 5.0,
113
+ standardDeviation: 0.345678,
114
+ variance: 0.119493,
115
+ percentile25: 3.0,
116
+ percentile75: 5.0,
117
+ iqr: 2.0,
118
+ lowerFence: 0.0,
119
+ upperFence: 8.0,
120
+ additionalStatistics: {
121
+ coefficientOfVariation: 0.086,
122
+ skewness: 0.123,
123
+ kurtosis: 2.789
124
+ },
125
+ metadata: {
126
+ calculationMethod: 'automated',
127
+ lastCalculated: '2025-01-15T10:30:00Z',
128
+ dataCount: 92,
129
+ source: 'production_line_x14'
130
+ }
131
+ },
132
+ // X21 데이터 (이미지 수치 그대로)
133
+ {
134
+ kpiName: 'X21. 연면적 대비 공사비',
135
+ valueDate: '2025-08',
136
+ periodType: kpi_2.KpiPeriodType.MONTH,
137
+ count: 85,
138
+ sum: 2.99642,
139
+ range: 0.312186,
140
+ mean: 0.035252,
141
+ median: 0.014745,
142
+ minimum: 0.006322,
143
+ maximum: 0.318508,
144
+ standardDeviation: 0.045678,
145
+ variance: 0.002086,
146
+ percentile25: 0.007259,
147
+ percentile75: 0.042295,
148
+ iqr: 0.035036,
149
+ lowerFence: -0.04529,
150
+ upperFence: 0.094849,
151
+ additionalStatistics: {
152
+ coefficientOfVariation: 1.296,
153
+ skewness: 2.345,
154
+ kurtosis: 7.234
155
+ },
156
+ metadata: {
157
+ calculationMethod: 'automated',
158
+ lastCalculated: '2025-01-15T10:30:00Z',
159
+ dataCount: 85,
160
+ source: 'production_line_x21'
161
+ }
162
+ },
163
+ // X22 데이터 (이미지 수치 그대로)
164
+ {
165
+ kpiName: 'X22. 설계변경에 따른 공사비 증감률',
166
+ valueDate: '2025-08',
167
+ periodType: kpi_2.KpiPeriodType.MONTH,
168
+ count: 87,
169
+ sum: 3.803265,
170
+ range: 0.2023,
171
+ mean: 0.043715,
172
+ median: 0.021246,
173
+ minimum: -0.0053,
174
+ maximum: 0.197,
175
+ standardDeviation: 0.034567,
176
+ variance: 0.001195,
177
+ percentile25: -0.00062,
178
+ percentile75: 0.073369,
179
+ iqr: 0.073989,
180
+ lowerFence: -0.1116,
181
+ upperFence: 0.184352,
182
+ additionalStatistics: {
183
+ coefficientOfVariation: 0.791,
184
+ skewness: 1.567,
185
+ kurtosis: 5.123
186
+ },
187
+ metadata: {
188
+ calculationMethod: 'automated',
189
+ lastCalculated: '2025-01-15T10:30:00Z',
190
+ dataCount: 87,
191
+ source: 'production_line_x22'
192
+ }
193
+ },
194
+ // X23 데이터 (이미지 수치 그대로)
195
+ {
196
+ kpiName: 'X23. 비용성과 수준 평가',
197
+ valueDate: '2025-08',
198
+ periodType: kpi_2.KpiPeriodType.MONTH,
199
+ count: 90,
200
+ sum: 279.5535,
201
+ range: 4.0,
202
+ mean: 3.10615,
203
+ median: 3.0,
204
+ minimum: 1.0,
205
+ maximum: 5.0,
206
+ standardDeviation: 0.456789,
207
+ variance: 0.208656,
208
+ percentile25: 2.0,
209
+ percentile75: 4.0,
210
+ iqr: 2.0,
211
+ lowerFence: -1.0,
212
+ upperFence: 7.0,
213
+ additionalStatistics: {
214
+ coefficientOfVariation: 0.147,
215
+ skewness: 0.234,
216
+ kurtosis: 2.567
217
+ },
218
+ metadata: {
219
+ calculationMethod: 'automated',
220
+ lastCalculated: '2025-01-15T10:30:00Z',
221
+ dataCount: 90,
222
+ source: 'production_line_x23'
223
+ }
224
+ },
225
+ // X31 데이터 (이미지 수치 그대로)
226
+ {
227
+ kpiName: 'X31. 품질시험 불합격률',
228
+ valueDate: '2025-08',
229
+ periodType: kpi_2.KpiPeriodType.MONTH,
230
+ count: 93,
231
+ sum: 26.617623,
232
+ range: 1.8882,
233
+ mean: 0.286211,
234
+ median: 0.108761,
235
+ minimum: 0.0018,
236
+ maximum: 1.89,
237
+ standardDeviation: 0.345678,
238
+ variance: 0.119493,
239
+ percentile25: 0.017687,
240
+ percentile75: 0.393518,
241
+ iqr: 0.375831,
242
+ lowerFence: -0.54606,
243
+ upperFence: 0.957264,
244
+ additionalStatistics: {
245
+ coefficientOfVariation: 1.208,
246
+ skewness: 2.123,
247
+ kurtosis: 6.789
248
+ },
249
+ metadata: {
250
+ calculationMethod: 'automated',
251
+ lastCalculated: '2025-01-15T10:30:00Z',
252
+ dataCount: 93,
253
+ source: 'production_line_x31'
254
+ }
255
+ },
256
+ // X32 데이터 (이미지 수치 그대로)
257
+ {
258
+ kpiName: 'X32. 검수자재 불합격률',
259
+ valueDate: '2025-08',
260
+ periodType: kpi_2.KpiPeriodType.MONTH,
261
+ count: 89,
262
+ sum: 9.519796,
263
+ range: 1.191035,
264
+ mean: 0.106964,
265
+ median: 0.035077,
266
+ minimum: 0.008965,
267
+ maximum: 1.2,
268
+ standardDeviation: 0.234567,
269
+ variance: 0.055021,
270
+ percentile25: 0.011285,
271
+ percentile75: 0.124878,
272
+ iqr: 0.113593,
273
+ lowerFence: -0.15911,
274
+ upperFence: 0.295269,
275
+ additionalStatistics: {
276
+ coefficientOfVariation: 2.193,
277
+ skewness: 3.456,
278
+ kurtosis: 12.345
279
+ },
280
+ metadata: {
281
+ calculationMethod: 'automated',
282
+ lastCalculated: '2025-01-15T10:30:00Z',
283
+ dataCount: 89,
284
+ source: 'production_line_x32'
285
+ }
286
+ },
287
+ // X33 데이터 (이미지 수치 그대로)
288
+ {
289
+ kpiName: 'X33. 검측 불합격률',
290
+ valueDate: '2025-08',
291
+ periodType: kpi_2.KpiPeriodType.MONTH,
292
+ count: 91,
293
+ sum: 8.855573,
294
+ range: 1.0,
295
+ mean: 0.097303,
296
+ median: 0.03431,
297
+ minimum: 0.0,
298
+ maximum: 1.0,
299
+ standardDeviation: 0.123456,
300
+ variance: 0.015241,
301
+ percentile25: 0.0052,
302
+ percentile75: 0.128793,
303
+ iqr: 0.123593,
304
+ lowerFence: -0.18019,
305
+ upperFence: 0.314182,
306
+ additionalStatistics: {
307
+ coefficientOfVariation: 1.269,
308
+ skewness: 2.789,
309
+ kurtosis: 8.567
310
+ },
311
+ metadata: {
312
+ calculationMethod: 'automated',
313
+ lastCalculated: '2025-01-15T10:30:00Z',
314
+ dataCount: 91,
315
+ source: 'production_line_x33'
316
+ }
317
+ },
318
+ // X34 데이터 (이미지 수치 그대로)
319
+ {
320
+ kpiName: 'X34. 품질 SL-PA 결과값',
321
+ valueDate: '2025-08',
322
+ periodType: kpi_2.KpiPeriodType.MONTH,
323
+ count: 94,
324
+ sum: 456.229,
325
+ range: 0.0,
326
+ mean: 4.8535,
327
+ median: 5.0,
328
+ minimum: 5.0,
329
+ maximum: 5.0,
330
+ standardDeviation: 0.0,
331
+ variance: 0.0,
332
+ percentile25: 5.0,
333
+ percentile75: 5.0,
334
+ iqr: 0.0,
335
+ lowerFence: 2.5,
336
+ upperFence: 5.0,
337
+ additionalStatistics: {
338
+ coefficientOfVariation: 0.0,
339
+ skewness: 0.0,
340
+ kurtosis: 0.0
341
+ },
342
+ metadata: {
343
+ calculationMethod: 'automated',
344
+ lastCalculated: '2025-01-15T10:30:00Z',
345
+ dataCount: 94,
346
+ source: 'production_line_x34'
347
+ }
348
+ },
349
+ // X35 데이터 (이미지 수치 그대로)
350
+ {
351
+ kpiName: 'X35. 품질성과 수준 평가',
352
+ valueDate: '2025-08',
353
+ periodType: kpi_2.KpiPeriodType.MONTH,
354
+ count: 96,
355
+ sum: 437.352,
356
+ range: 0.0,
357
+ mean: 4.55575,
358
+ median: 5.0,
359
+ minimum: 5.0,
360
+ maximum: 5.0,
361
+ standardDeviation: 0.0,
362
+ variance: 0.0,
363
+ percentile25: 5.0,
364
+ percentile75: 5.0,
365
+ iqr: 0.0,
366
+ lowerFence: 2.5,
367
+ upperFence: 6.5,
368
+ additionalStatistics: {
369
+ coefficientOfVariation: 0.0,
370
+ skewness: 0.0,
371
+ kurtosis: 0.0
372
+ },
373
+ metadata: {
374
+ calculationMethod: 'automated',
375
+ lastCalculated: '2025-01-15T10:30:00Z',
376
+ dataCount: 96,
377
+ source: 'production_line_x35'
378
+ }
379
+ },
380
+ // X41 데이터 (이미지 수치 그대로)
381
+ {
382
+ kpiName: 'X41. 재해율',
383
+ valueDate: '2025-08',
384
+ periodType: kpi_2.KpiPeriodType.MONTH,
385
+ count: 88,
386
+ sum: 0.59576,
387
+ range: 0.08913,
388
+ mean: 0.00677,
389
+ median: 0.003161,
390
+ minimum: 0.0,
391
+ maximum: 0.08913,
392
+ standardDeviation: 0.012345,
393
+ variance: 0.000152,
394
+ percentile25: 0.000873,
395
+ percentile75: 0.008789,
396
+ iqr: 0.007916,
397
+ lowerFence: -0.011,
398
+ upperFence: 0.020662,
399
+ additionalStatistics: {
400
+ coefficientOfVariation: 1.824,
401
+ skewness: 3.234,
402
+ kurtosis: 11.567
403
+ },
404
+ metadata: {
405
+ calculationMethod: 'automated',
406
+ lastCalculated: '2025-01-15T10:30:00Z',
407
+ dataCount: 88,
408
+ source: 'production_line_x41'
409
+ }
410
+ },
411
+ // X42 데이터 (이미지 수치 그대로)
412
+ {
413
+ kpiName: 'X42. 재해강도율',
414
+ valueDate: '2025-08',
415
+ periodType: kpi_2.KpiPeriodType.MONTH,
416
+ count: 86,
417
+ sum: 0.33411,
418
+ range: 0.021877,
419
+ mean: 0.003885,
420
+ median: 0.000338,
421
+ minimum: 0.000337,
422
+ maximum: 0.022214,
423
+ standardDeviation: 0.004567,
424
+ variance: 0.000021,
425
+ percentile25: 0.000337,
426
+ percentile75: 0.002222,
427
+ iqr: 0.001885,
428
+ lowerFence: -0.00249,
429
+ upperFence: 0.00505,
430
+ additionalStatistics: {
431
+ coefficientOfVariation: 1.175,
432
+ skewness: 2.567,
433
+ kurtosis: 8.234
434
+ },
435
+ metadata: {
436
+ calculationMethod: 'automated',
437
+ lastCalculated: '2025-01-15T10:30:00Z',
438
+ dataCount: 86,
439
+ source: 'production_line_x42'
440
+ }
441
+ },
442
+ // X43 데이터 (이미지 수치 그대로)
443
+ {
444
+ kpiName: 'X43. 안전 SL-PA 결과값',
445
+ valueDate: '2025-08',
446
+ periodType: kpi_2.KpiPeriodType.MONTH,
447
+ count: 92,
448
+ sum: 451.2968,
449
+ range: 5.0,
450
+ mean: 4.9054,
451
+ median: 5.0,
452
+ minimum: 0.0,
453
+ maximum: 5.0,
454
+ standardDeviation: 0.234567,
455
+ variance: 0.055021,
456
+ percentile25: 5.0,
457
+ percentile75: 5.0,
458
+ iqr: 0.0,
459
+ lowerFence: 5.0,
460
+ upperFence: 5.0,
461
+ additionalStatistics: {
462
+ coefficientOfVariation: 0.048,
463
+ skewness: -2.345,
464
+ kurtosis: 5.678
465
+ },
466
+ metadata: {
467
+ calculationMethod: 'automated',
468
+ lastCalculated: '2025-01-15T10:30:00Z',
469
+ dataCount: 92,
470
+ source: 'production_line_x43'
471
+ }
472
+ },
473
+ // X44 데이터 (이미지 수치 그대로)
474
+ {
475
+ kpiName: 'X44. 안전성과 수준 평가',
476
+ valueDate: '2025-08',
477
+ periodType: kpi_2.KpiPeriodType.MONTH,
478
+ count: 90,
479
+ sum: 315.441,
480
+ range: 3.0,
481
+ mean: 3.5049,
482
+ median: 4.0,
483
+ minimum: 2.0,
484
+ maximum: 5.0,
485
+ standardDeviation: 0.456789,
486
+ variance: 0.208656,
487
+ percentile25: 3.0,
488
+ percentile75: 5.0,
489
+ iqr: 2.0,
490
+ lowerFence: 0.0,
491
+ upperFence: 8.0,
492
+ additionalStatistics: {
493
+ coefficientOfVariation: 0.13,
494
+ skewness: 0.123,
495
+ kurtosis: 2.456
496
+ },
497
+ metadata: {
498
+ calculationMethod: 'automated',
499
+ lastCalculated: '2025-01-15T10:30:00Z',
500
+ dataCount: 90,
501
+ source: 'production_line_x44'
502
+ }
503
+ },
504
+ // X51 데이터 (이미지 수치 그대로)
505
+ {
506
+ kpiName: 'X51. 건설폐기물 발생량',
507
+ valueDate: '2025-08',
508
+ periodType: kpi_2.KpiPeriodType.MONTH,
509
+ count: 87,
510
+ sum: 20.065593,
511
+ range: 0.704088,
512
+ mean: 0.230639,
513
+ median: 0.156999,
514
+ minimum: 0.0001,
515
+ maximum: 0.704188,
516
+ standardDeviation: 0.123456,
517
+ variance: 0.015241,
518
+ percentile25: 0.02844,
519
+ percentile75: 0.401985,
520
+ iqr: 0.373545,
521
+ lowerFence: -0.53188,
522
+ upperFence: 0.962303,
523
+ additionalStatistics: {
524
+ coefficientOfVariation: 0.535,
525
+ skewness: 1.234,
526
+ kurtosis: 4.567
527
+ },
528
+ metadata: {
529
+ calculationMethod: 'automated',
530
+ lastCalculated: '2025-01-15T10:30:00Z',
531
+ dataCount: 87,
532
+ source: 'production_line_x51'
533
+ }
534
+ },
535
+ // X52 데이터 (이미지 수치 그대로)
536
+ {
537
+ kpiName: 'X52. 환경성과 수준 평가',
538
+ valueDate: '2025-08',
539
+ periodType: kpi_2.KpiPeriodType.MONTH,
540
+ count: 89,
541
+ sum: 400.60965,
542
+ range: 2.0,
543
+ mean: 4.50685,
544
+ median: 5.0,
545
+ minimum: 3.0,
546
+ maximum: 5.0,
547
+ standardDeviation: 0.345678,
548
+ variance: 0.119493,
549
+ percentile25: 4.0,
550
+ percentile75: 5.0,
551
+ iqr: 1.0,
552
+ lowerFence: 2.5,
553
+ upperFence: 6.5,
554
+ additionalStatistics: {
555
+ coefficientOfVariation: 0.077,
556
+ skewness: -0.234,
557
+ kurtosis: 2.789
558
+ },
559
+ metadata: {
560
+ calculationMethod: 'automated',
561
+ lastCalculated: '2025-01-15T10:30:00Z',
562
+ dataCount: 89,
563
+ source: 'production_line_x52'
564
+ }
565
+ },
566
+ // X61 데이터 (이미지 수치 그대로 - 높은 값)
567
+ {
568
+ kpiName: 'X61. 투입인력 생산성',
569
+ valueDate: '2025-08',
570
+ periodType: kpi_2.KpiPeriodType.MONTH,
571
+ count: 120,
572
+ sum: 284733.0,
573
+ range: 5538.9515,
574
+ mean: 2372.775,
575
+ median: 1849.723,
576
+ minimum: 261.3085,
577
+ maximum: 5800.26,
578
+ standardDeviation: 1234.5678,
579
+ variance: 1524156.789,
580
+ percentile25: 572.8489,
581
+ percentile75: 4074.343,
582
+ iqr: 3501.4941,
583
+ lowerFence: -4679.39,
584
+ upperFence: 9326.583,
585
+ additionalStatistics: {
586
+ coefficientOfVariation: 0.52,
587
+ skewness: 1.234,
588
+ kurtosis: 4.567
589
+ },
590
+ metadata: {
591
+ calculationMethod: 'automated',
592
+ lastCalculated: '2025-01-15T10:30:00Z',
593
+ dataCount: 120,
594
+ source: 'high_value_production_x61'
595
+ }
596
+ },
597
+ // X62 데이터 (이미지 수치 그대로)
598
+ {
599
+ kpiName: 'X62. 생산성성과 수준 평가',
600
+ valueDate: '2025-08',
601
+ periodType: kpi_2.KpiPeriodType.MONTH,
602
+ count: 95,
603
+ sum: 393.87475,
604
+ range: 2.0,
605
+ mean: 4.14605,
606
+ median: 4.0,
607
+ minimum: 3.0,
608
+ maximum: 5.0,
609
+ standardDeviation: 0.456789,
610
+ variance: 0.208656,
611
+ percentile25: 4.0,
612
+ percentile75: 4.0,
613
+ iqr: 0.0,
614
+ lowerFence: 4.0,
615
+ upperFence: 4.0,
616
+ additionalStatistics: {
617
+ coefficientOfVariation: 0.11,
618
+ skewness: 0.123,
619
+ kurtosis: 2.456
620
+ },
621
+ metadata: {
622
+ calculationMethod: 'automated',
623
+ lastCalculated: '2025-01-15T10:30:00Z',
624
+ dataCount: 95,
625
+ source: 'production_line_x62'
626
+ }
627
+ }
628
+ ];
629
+ class AddKpiStatistics1752192090124 {
630
+ async up(queryRunner) {
631
+ const repository = (0, shell_1.getRepository)(kpi_1.KpiStatistic);
632
+ const kpiRepository = (0, shell_1.getRepository)(kpi_1.Kpi);
633
+ const domainRepository = (0, shell_1.getRepository)(shell_1.Domain);
634
+ const domain = await domainRepository.findOneBy({ subdomain: 'system' });
635
+ if (!domain) {
636
+ throw new Error('SYSTEM domain not found');
637
+ }
638
+ // 통계 데이터를 실제 KPI와 연결하여 저장
639
+ const statisticsToSave = [];
640
+ for (const statistic of KPI_STATISTICS) {
641
+ try {
642
+ // KPI 찾기
643
+ const kpi = await kpiRepository.findOneBy({
644
+ name: statistic.kpiName,
645
+ domain: { id: domain.id }
646
+ });
647
+ if (!kpi) {
648
+ console.log(`⚠️ KPI not found: ${statistic.kpiName}`);
649
+ continue;
650
+ }
651
+ // 통계 데이터에 KPI와 도메인 연결
652
+ const statisticWithRelations = Object.assign(Object.assign({}, statistic), { kpi,
653
+ domain });
654
+ statisticsToSave.push(statisticWithRelations);
655
+ console.log(`✅ Prepared statistic for KPI: ${statistic.kpiName}`);
656
+ }
657
+ catch (error) {
658
+ console.error(`❌ Error preparing statistic for ${statistic.kpiName}:`, error);
659
+ }
660
+ }
661
+ // 배치로 저장
662
+ if (statisticsToSave.length > 0) {
663
+ const batchSize = 5;
664
+ for (let i = 0; i < statisticsToSave.length; i += batchSize) {
665
+ const batch = statisticsToSave.slice(i, i + batchSize);
666
+ await repository.save(batch);
667
+ console.log(`✅ Saved batch ${Math.floor(i / batchSize) + 1}/${Math.ceil(statisticsToSave.length / batchSize)}`);
668
+ }
669
+ }
670
+ console.log(`🎉 Successfully saved ${statisticsToSave.length} KPI statistics`);
671
+ }
672
+ async down(queryRunner) {
673
+ const repository = (0, shell_1.getRepository)(kpi_1.KpiStatistic);
674
+ const domainRepository = (0, shell_1.getRepository)(shell_1.Domain);
675
+ const domain = await domainRepository.findOneBy({ subdomain: 'system' });
676
+ if (!domain) {
677
+ console.log('⚠️ SYSTEM domain not found. Nothing to delete.');
678
+ return;
679
+ }
680
+ const results = [];
681
+ for (const statistic of KPI_STATISTICS.reverse()) {
682
+ try {
683
+ const record = await repository.findOneBy({
684
+ kpi: { name: statistic.kpiName },
685
+ valueDate: statistic.valueDate,
686
+ periodType: statistic.periodType,
687
+ domain: { id: domain.id }
688
+ });
689
+ if (record) {
690
+ await repository.remove(record);
691
+ console.log(`✅ Deleted statistic for KPI: ${statistic.kpiName}`);
692
+ results.push(statistic.kpiName);
693
+ }
694
+ else {
695
+ console.log(`⚠️ Statistic not found for KPI: ${statistic.kpiName}`);
696
+ }
697
+ }
698
+ catch (error) {
699
+ console.error(`❌ Error deleting statistic for ${statistic.kpiName}:`, error);
700
+ }
701
+ }
702
+ console.log(`🎉 Successfully deleted ${results.length} KPI statistics`);
703
+ return results;
704
+ }
705
+ }
706
+ exports.AddKpiStatistics1752192090124 = AddKpiStatistics1752192090124;
707
+ //# sourceMappingURL=1752192090124-add-kpi-statistics.js.map