@things-factory/kpi 10.1.248 → 10.1.249
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/bootstrap.d.ts +2 -0
- package/dist-client/bootstrap.js +7 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/charts/kpi-boxplot-chart.d.ts +24 -0
- package/dist-client/charts/kpi-boxplot-chart.js +324 -0
- package/dist-client/charts/kpi-boxplot-chart.js.map +1 -0
- package/dist-client/charts/kpi-mini-trend-chart.d.ts +14 -0
- package/dist-client/charts/kpi-mini-trend-chart.js +148 -0
- package/dist-client/charts/kpi-mini-trend-chart.js.map +1 -0
- package/dist-client/charts/kpi-radar-chart.d.ts +16 -0
- package/dist-client/charts/kpi-radar-chart.js +138 -0
- package/dist-client/charts/kpi-radar-chart.js.map +1 -0
- package/dist-client/charts/kpi-trend-chart.d.ts +25 -0
- package/dist-client/charts/kpi-trend-chart.js +186 -0
- package/dist-client/charts/kpi-trend-chart.js.map +1 -0
- package/dist-client/google-map/common-google-map.d.ts +34 -0
- package/dist-client/google-map/common-google-map.js +333 -0
- package/dist-client/google-map/common-google-map.js.map +1 -0
- package/dist-client/google-map/google-map-loader.d.ts +8 -0
- package/dist-client/google-map/google-map-loader.js +22 -0
- package/dist-client/google-map/google-map-loader.js.map +1 -0
- package/dist-client/index.d.ts +1 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/kpi/kpi-grade-editor.d.ts +35 -0
- package/dist-client/pages/kpi/kpi-grade-editor.js +165 -0
- package/dist-client/pages/kpi/kpi-grade-editor.js.map +1 -0
- package/dist-client/pages/kpi/kpi-importer.d.ts +23 -0
- package/dist-client/pages/kpi/kpi-importer.js +92 -0
- package/dist-client/pages/kpi/kpi-importer.js.map +1 -0
- package/dist-client/pages/kpi/kpi-list-page.d.ts +136 -0
- package/dist-client/pages/kpi/kpi-list-page.js +948 -0
- package/dist-client/pages/kpi/kpi-list-page.js.map +1 -0
- package/dist-client/pages/kpi/kpi-overview-sample.d.ts +36 -0
- package/dist-client/pages/kpi/kpi-overview-sample.js +264 -0
- package/dist-client/pages/kpi/kpi-overview-sample.js.map +1 -0
- package/dist-client/pages/kpi/kpi-overview.d.ts +14 -0
- package/dist-client/pages/kpi/kpi-overview.js +361 -0
- package/dist-client/pages/kpi/kpi-overview.js.map +1 -0
- package/dist-client/pages/kpi/kpi-tree-page.d.ts +51 -0
- package/dist-client/pages/kpi/kpi-tree-page.js +355 -0
- package/dist-client/pages/kpi/kpi-tree-page.js.map +1 -0
- package/dist-client/pages/kpi/kpi-view.d.ts +12 -0
- package/dist-client/pages/kpi/kpi-view.js +193 -0
- package/dist-client/pages/kpi/kpi-view.js.map +1 -0
- package/dist-client/pages/kpi/kpi-viz-editor.d.ts +19 -0
- package/dist-client/pages/kpi/kpi-viz-editor.js +562 -0
- package/dist-client/pages/kpi/kpi-viz-editor.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.d.ts +17 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.js +279 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.d.ts +19 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.js +385 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.d.ts +23 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.js +465 -0
- package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-chart-toggle.d.ts +8 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-chart-toggle.js +78 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-chart-toggle.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.d.ts +24 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.js +440 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.d.ts +33 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.js +444 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.d.ts +23 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.js +369 -0
- package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-alert-panel.d.ts +18 -0
- package/dist-client/pages/kpi-dashboard/kpi-alert-panel.js +128 -0
- package/dist-client/pages/kpi-dashboard/kpi-alert-panel.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.d.ts +31 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.js +493 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard.d.ts +50 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard.js +884 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-grade-visualization.d.ts +12 -0
- package/dist-client/pages/kpi-dashboard/kpi-grade-visualization.js +82 -0
- package/dist-client/pages/kpi-dashboard/kpi-grade-visualization.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-history-viewer.d.ts +11 -0
- package/dist-client/pages/kpi-dashboard/kpi-history-viewer.js +65 -0
- package/dist-client/pages/kpi-dashboard/kpi-history-viewer.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-list-summary.d.ts +13 -0
- package/dist-client/pages/kpi-dashboard/kpi-list-summary.js +115 -0
- package/dist-client/pages/kpi-dashboard/kpi-list-summary.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-performance-summary.d.ts +15 -0
- package/dist-client/pages/kpi-dashboard/kpi-performance-summary.js +146 -0
- package/dist-client/pages/kpi-dashboard/kpi-performance-summary.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-value-entry.d.ts +7 -0
- package/dist-client/pages/kpi-dashboard/kpi-value-entry.js +86 -0
- package/dist-client/pages/kpi-dashboard/kpi-value-entry.js.map +1 -0
- package/dist-client/pages/kpi-history/kpi-history-list-page.d.ts +21 -0
- package/dist-client/pages/kpi-history/kpi-history-list-page.js +160 -0
- package/dist-client/pages/kpi-history/kpi-history-list-page.js.map +1 -0
- package/dist-client/pages/kpi-metric/kpi-metric-importer.d.ts +23 -0
- package/dist-client/pages/kpi-metric/kpi-metric-importer.js +92 -0
- package/dist-client/pages/kpi-metric/kpi-metric-importer.js.map +1 -0
- package/dist-client/pages/kpi-metric/kpi-metric-list-page.d.ts +65 -0
- package/dist-client/pages/kpi-metric/kpi-metric-list-page.js +415 -0
- package/dist-client/pages/kpi-metric/kpi-metric-list-page.js.map +1 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.d.ts +52 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.js +678 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.js.map +1 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.d.ts +23 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.js +75 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.js.map +1 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.d.ts +64 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js +311 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js.map +1 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.d.ts +12 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.js +175 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.js.map +1 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.d.ts +35 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.js +161 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.js.map +1 -0
- package/dist-client/pages/kpi-statistic/kpi-statistic-editor-page.d.ts +47 -0
- package/dist-client/pages/kpi-statistic/kpi-statistic-editor-page.js +655 -0
- package/dist-client/pages/kpi-statistic/kpi-statistic-editor-page.js.map +1 -0
- package/dist-client/pages/kpi-statistic/kpi-statistic-importer.d.ts +23 -0
- package/dist-client/pages/kpi-statistic/kpi-statistic-importer.js +92 -0
- package/dist-client/pages/kpi-statistic/kpi-statistic-importer.js.map +1 -0
- package/dist-client/pages/kpi-statistic/kpi-statistic-list-page.d.ts +65 -0
- package/dist-client/pages/kpi-statistic/kpi-statistic-list-page.js +416 -0
- package/dist-client/pages/kpi-statistic/kpi-statistic-list-page.js.map +1 -0
- package/dist-client/pages/kpi-value/kpi-value-editor-page.d.ts +50 -0
- package/dist-client/pages/kpi-value/kpi-value-editor-page.js +700 -0
- package/dist-client/pages/kpi-value/kpi-value-editor-page.js.map +1 -0
- package/dist-client/pages/kpi-value/kpi-value-importer.d.ts +23 -0
- package/dist-client/pages/kpi-value/kpi-value-importer.js +92 -0
- package/dist-client/pages/kpi-value/kpi-value-importer.js.map +1 -0
- package/dist-client/pages/kpi-value/kpi-value-list-page.d.ts +73 -0
- package/dist-client/pages/kpi-value/kpi-value-list-page.js +403 -0
- package/dist-client/pages/kpi-value/kpi-value-list-page.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +47 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-client/viewparts/kpi-metric-input.d.ts +23 -0
- package/dist-client/viewparts/kpi-metric-input.js +140 -0
- package/dist-client/viewparts/kpi-metric-input.js.map +1 -0
- package/dist-client/viewparts/kpi-metric-meta-editor.d.ts +36 -0
- package/dist-client/viewparts/kpi-metric-meta-editor.js +321 -0
- package/dist-client/viewparts/kpi-metric-meta-editor.js.map +1 -0
- package/dist-client/viewparts/metric-input-hint.d.ts +26 -0
- package/dist-client/viewparts/metric-input-hint.js +19 -0
- package/dist-client/viewparts/metric-input-hint.js.map +1 -0
- package/dist-client/viewparts/metric-input.test.d.ts +1 -0
- package/dist-client/viewparts/metric-input.test.js +43 -0
- package/dist-client/viewparts/metric-input.test.js.map +1 -0
- package/dist-client/viewparts/metric-renderer-registry.d.ts +18 -0
- package/dist-client/viewparts/metric-renderer-registry.js +29 -0
- package/dist-client/viewparts/metric-renderer-registry.js.map +1 -0
- package/dist-client/viewparts/ox-grist-editor-metric-input-hint.d.ts +19 -0
- package/dist-client/viewparts/ox-grist-editor-metric-input-hint.js +76 -0
- package/dist-client/viewparts/ox-grist-editor-metric-input-hint.js.map +1 -0
- package/dist-server/calculator/calculator.test.d.ts +1 -0
- package/dist-server/calculator/calculator.test.js +126 -0
- package/dist-server/calculator/calculator.test.js.map +1 -0
- package/dist-server/calculator/evaluator.d.ts +8 -0
- package/dist-server/calculator/evaluator.js +42 -0
- package/dist-server/calculator/evaluator.js.map +1 -0
- package/dist-server/calculator/functions.d.ts +3 -0
- package/dist-server/calculator/functions.js +62 -0
- package/dist-server/calculator/functions.js.map +1 -0
- package/dist-server/calculator/index.d.ts +6 -0
- package/dist-server/calculator/index.js +10 -0
- package/dist-server/calculator/index.js.map +1 -0
- package/dist-server/calculator/parser.d.ts +34 -0
- package/dist-server/calculator/parser.js +185 -0
- package/dist-server/calculator/parser.js.map +1 -0
- package/dist-server/calculator/provider.d.ts +8 -0
- package/dist-server/calculator/provider.js +13 -0
- package/dist-server/calculator/provider.js.map +1 -0
- package/dist-server/calculator/score.d.ts +21 -0
- package/dist-server/calculator/score.js +36 -0
- package/dist-server/calculator/score.js.map +1 -0
- package/dist-server/calculator/score.test.d.ts +1 -0
- package/dist-server/calculator/score.test.js +47 -0
- package/dist-server/calculator/score.test.js.map +1 -0
- package/dist-server/calculator/validate.d.ts +15 -0
- package/dist-server/calculator/validate.js +30 -0
- package/dist-server/calculator/validate.js.map +1 -0
- package/dist-server/calculator/validate.test.d.ts +1 -0
- package/dist-server/calculator/validate.test.js +45 -0
- package/dist-server/calculator/validate.test.js.map +1 -0
- package/dist-server/controllers/index.d.ts +2 -0
- package/dist-server/controllers/index.js +6 -0
- package/dist-server/controllers/index.js.map +1 -0
- package/dist-server/controllers/kpi-metric-value-provider.d.ts +11 -0
- package/dist-server/controllers/kpi-metric-value-provider.js +97 -0
- package/dist-server/controllers/kpi-metric-value-provider.js.map +1 -0
- package/dist-server/controllers/kpi-value-provider.d.ts +11 -0
- package/dist-server/controllers/kpi-value-provider.js +50 -0
- package/dist-server/controllers/kpi-value-provider.js.map +1 -0
- package/dist-server/index.d.ts +5 -0
- package/dist-server/index.js +9 -0
- package/dist-server/index.js.map +1 -0
- package/dist-server/migrations/1752190849680-seed-kpi-metrics.d.ts +6 -0
- package/dist-server/migrations/1752190849680-seed-kpi-metrics.js +102 -0
- package/dist-server/migrations/1752190849680-seed-kpi-metrics.js.map +1 -0
- package/dist-server/migrations/1752190849681-seed-kpi.d.ts +5 -0
- package/dist-server/migrations/1752190849681-seed-kpi.js +315 -0
- package/dist-server/migrations/1752190849681-seed-kpi.js.map +1 -0
- package/dist-server/migrations/1752192090123-add-grades-to-kpi.d.ts +7 -0
- package/dist-server/migrations/1752192090123-add-grades-to-kpi.js +51 -0
- package/dist-server/migrations/1752192090123-add-grades-to-kpi.js.map +1 -0
- package/dist-server/migrations/1752192090124-add-kpi-statistics.d.ts +5 -0
- package/dist-server/migrations/1752192090124-add-kpi-statistics.js +710 -0
- package/dist-server/migrations/1752192090124-add-kpi-statistics.js.map +1 -0
- package/dist-server/migrations/1752192090128-seed-kpi-org-scope.d.ts +6 -0
- package/dist-server/migrations/1752192090128-seed-kpi-org-scope.js +111 -0
- package/dist-server/migrations/1752192090128-seed-kpi-org-scope.js.map +1 -0
- package/dist-server/migrations/1752192090129-seed-kpi-values.d.ts +6 -0
- package/dist-server/migrations/1752192090129-seed-kpi-values.js +187 -0
- package/dist-server/migrations/1752192090129-seed-kpi-values.js.map +1 -0
- package/dist-server/migrations/1752192090200-add-meta-to-kpi-metric.d.ts +10 -0
- package/dist-server/migrations/1752192090200-add-meta-to-kpi-metric.js +26 -0
- package/dist-server/migrations/1752192090200-add-meta-to-kpi-metric.js.map +1 -0
- package/dist-server/migrations/1752192090201-backfill-kpi-metric-meta.d.ts +11 -0
- package/dist-server/migrations/1752192090201-backfill-kpi-metric-meta.js +54 -0
- package/dist-server/migrations/1752192090201-backfill-kpi-metric-meta.js.map +1 -0
- package/dist-server/migrations/grade-data/x11-performance-table.json +962 -0
- package/dist-server/migrations/grade-data/x12-performance-table.json +611 -0
- package/dist-server/migrations/grade-data/x14-performance-table.json +42 -0
- package/dist-server/migrations/grade-data/x21-performance-table.json +889 -0
- package/dist-server/migrations/grade-data/x22-performance-table.json +1064 -0
- package/dist-server/migrations/grade-data/x23-performance-table.json +42 -0
- package/dist-server/migrations/grade-data/x31-performance-table.json +644 -0
- package/dist-server/migrations/grade-data/x32-performance-table.json +993 -0
- package/dist-server/migrations/grade-data/x33-performance-table.json +195 -0
- package/dist-server/migrations/grade-data/x34-performance-table.json +12 -0
- package/dist-server/migrations/grade-data/x35-performance-table.json +42 -0
- package/dist-server/migrations/grade-data/x41-performance-table.json +825 -0
- package/dist-server/migrations/grade-data/x42-performance-table.json +786 -0
- package/dist-server/migrations/grade-data/x43-performance-table.json +12 -0
- package/dist-server/migrations/grade-data/x44-performance-table.json +42 -0
- package/dist-server/migrations/grade-data/x51-performance-table.json +924 -0
- package/dist-server/migrations/grade-data/x52-performance-table.json +42 -0
- package/dist-server/migrations/grade-data/x61-performance-table.json +261 -0
- package/dist-server/migrations/grade-data/x62-performance-table.json +42 -0
- package/dist-server/migrations/index.d.ts +1 -0
- package/dist-server/migrations/index.js +12 -0
- package/dist-server/migrations/index.js.map +1 -0
- package/dist-server/migrations/seed-data/kpi-metrics-seed.json +517 -0
- package/dist-server/migrations/seed-data/kpi-org-scope-seed.json +1676 -0
- package/dist-server/migrations/seed-data/kpi-scopes-seed.json +121 -0
- package/dist-server/migrations/seed-data/kpi-values-seed.json +402 -0
- package/dist-server/migrations/seed-data/kpis-seed.json +488 -0
- package/dist-server/migrations/seed-data/scope-definitions-seed.json +90 -0
- package/dist-server/routes.d.ts +1 -0
- package/dist-server/routes.js +72 -0
- package/dist-server/routes.js.map +1 -0
- package/dist-server/service/index.d.ts +15 -0
- package/dist-server/service/index.js +49 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/service/kpi/aggregate-kpi.d.ts +8 -0
- package/dist-server/service/kpi/aggregate-kpi.js +123 -0
- package/dist-server/service/kpi/aggregate-kpi.js.map +1 -0
- package/dist-server/service/kpi/event-subscriber.d.ts +9 -0
- package/dist-server/service/kpi/event-subscriber.js +31 -0
- package/dist-server/service/kpi/event-subscriber.js.map +1 -0
- package/dist-server/service/kpi/index.d.ts +8 -0
- package/dist-server/service/kpi/index.js +12 -0
- package/dist-server/service/kpi/index.js.map +1 -0
- package/dist-server/service/kpi/kpi-formula.service.d.ts +49 -0
- package/dist-server/service/kpi/kpi-formula.service.js +165 -0
- package/dist-server/service/kpi/kpi-formula.service.js.map +1 -0
- package/dist-server/service/kpi/kpi-grade.types.d.ts +22 -0
- package/dist-server/service/kpi/kpi-grade.types.js +3 -0
- package/dist-server/service/kpi/kpi-grade.types.js.map +1 -0
- package/dist-server/service/kpi/kpi-history.d.ts +29 -0
- package/dist-server/service/kpi/kpi-history.js +148 -0
- package/dist-server/service/kpi/kpi-history.js.map +1 -0
- package/dist-server/service/kpi/kpi-mutation.d.ts +14 -0
- package/dist-server/service/kpi/kpi-mutation.js +553 -0
- package/dist-server/service/kpi/kpi-mutation.js.map +1 -0
- package/dist-server/service/kpi/kpi-query.d.ts +24 -0
- package/dist-server/service/kpi/kpi-query.js +309 -0
- package/dist-server/service/kpi/kpi-query.js.map +1 -0
- package/dist-server/service/kpi/kpi-type.d.ts +48 -0
- package/dist-server/service/kpi/kpi-type.js +221 -0
- package/dist-server/service/kpi/kpi-type.js.map +1 -0
- package/dist-server/service/kpi/kpi.d.ts +130 -0
- package/dist-server/service/kpi/kpi.js +356 -0
- package/dist-server/service/kpi/kpi.js.map +1 -0
- package/dist-server/service/kpi-alert/index.d.ts +2 -0
- package/dist-server/service/kpi-alert/index.js +6 -0
- package/dist-server/service/kpi-alert/index.js.map +1 -0
- package/dist-server/service/kpi-alert/kpi-alert-query.d.ts +4 -0
- package/dist-server/service/kpi-alert/kpi-alert-query.js +72 -0
- package/dist-server/service/kpi-alert/kpi-alert-query.js.map +1 -0
- package/dist-server/service/kpi-alert/kpi-alert-type.d.ts +8 -0
- package/dist-server/service/kpi-alert/kpi-alert-type.js +33 -0
- package/dist-server/service/kpi-alert/kpi-alert-type.js.map +1 -0
- package/dist-server/service/kpi-metric/aggregate-kpi-metric.d.ts +8 -0
- package/dist-server/service/kpi-metric/aggregate-kpi-metric.js +126 -0
- package/dist-server/service/kpi-metric/aggregate-kpi-metric.js.map +1 -0
- package/dist-server/service/kpi-metric/index.d.ts +6 -0
- package/dist-server/service/kpi-metric/index.js +10 -0
- package/dist-server/service/kpi-metric/index.js.map +1 -0
- package/dist-server/service/kpi-metric/kpi-metric-meta.d.ts +46 -0
- package/dist-server/service/kpi-metric/kpi-metric-meta.js +27 -0
- package/dist-server/service/kpi-metric/kpi-metric-meta.js.map +1 -0
- package/dist-server/service/kpi-metric/kpi-metric-meta.test.d.ts +1 -0
- package/dist-server/service/kpi-metric/kpi-metric-meta.test.js +43 -0
- package/dist-server/service/kpi-metric/kpi-metric-meta.test.js.map +1 -0
- package/dist-server/service/kpi-metric/kpi-metric-mutation.d.ts +10 -0
- package/dist-server/service/kpi-metric/kpi-metric-mutation.js +296 -0
- package/dist-server/service/kpi-metric/kpi-metric-mutation.js.map +1 -0
- package/dist-server/service/kpi-metric/kpi-metric-query.d.ts +14 -0
- package/dist-server/service/kpi-metric/kpi-metric-query.js +126 -0
- package/dist-server/service/kpi-metric/kpi-metric-query.js.map +1 -0
- package/dist-server/service/kpi-metric/kpi-metric-type.d.ts +45 -0
- package/dist-server/service/kpi-metric/kpi-metric-type.js +177 -0
- package/dist-server/service/kpi-metric/kpi-metric-type.js.map +1 -0
- package/dist-server/service/kpi-metric/kpi-metric.d.ts +39 -0
- package/dist-server/service/kpi-metric/kpi-metric.js +174 -0
- package/dist-server/service/kpi-metric/kpi-metric.js.map +1 -0
- package/dist-server/service/kpi-metric-value/index.d.ts +6 -0
- package/dist-server/service/kpi-metric-value/index.js +10 -0
- package/dist-server/service/kpi-metric-value/index.js.map +1 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.d.ts +11 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js +283 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js.map +1 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-query.d.ts +13 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-query.js +106 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-query.js.map +1 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-type.d.ts +26 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-type.js +112 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value-type.js.map +1 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value.d.ts +23 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value.js +107 -0
- package/dist-server/service/kpi-metric-value/kpi-metric-value.js.map +1 -0
- package/dist-server/service/kpi-org-scope/index.d.ts +5 -0
- package/dist-server/service/kpi-org-scope/index.js +9 -0
- package/dist-server/service/kpi-org-scope/index.js.map +1 -0
- package/dist-server/service/kpi-org-scope/kpi-org-scope-mutation.d.ts +8 -0
- package/dist-server/service/kpi-org-scope/kpi-org-scope-mutation.js +170 -0
- package/dist-server/service/kpi-org-scope/kpi-org-scope-mutation.js.map +1 -0
- package/dist-server/service/kpi-org-scope/kpi-org-scope-query.d.ts +14 -0
- package/dist-server/service/kpi-org-scope/kpi-org-scope-query.js +152 -0
- package/dist-server/service/kpi-org-scope/kpi-org-scope-query.js.map +1 -0
- package/dist-server/service/kpi-org-scope/kpi-org-scope-type.d.ts +26 -0
- package/dist-server/service/kpi-org-scope/kpi-org-scope-type.js +101 -0
- package/dist-server/service/kpi-org-scope/kpi-org-scope-type.js.map +1 -0
- package/dist-server/service/kpi-org-scope/kpi-org-scope.d.ts +26 -0
- package/dist-server/service/kpi-org-scope/kpi-org-scope.js +135 -0
- package/dist-server/service/kpi-org-scope/kpi-org-scope.js.map +1 -0
- package/dist-server/service/kpi-scope/index.d.ts +9 -0
- package/dist-server/service/kpi-scope/index.js +14 -0
- package/dist-server/service/kpi-scope/index.js.map +1 -0
- package/dist-server/service/kpi-scope/kpi-scope-mutation.d.ts +9 -0
- package/dist-server/service/kpi-scope/kpi-scope-mutation.js +140 -0
- package/dist-server/service/kpi-scope/kpi-scope-mutation.js.map +1 -0
- package/dist-server/service/kpi-scope/kpi-scope-query.d.ts +11 -0
- package/dist-server/service/kpi-scope/kpi-scope-query.js +89 -0
- package/dist-server/service/kpi-scope/kpi-scope-query.js.map +1 -0
- package/dist-server/service/kpi-scope/kpi-scope-type.d.ts +35 -0
- package/dist-server/service/kpi-scope/kpi-scope-type.js +138 -0
- package/dist-server/service/kpi-scope/kpi-scope-type.js.map +1 -0
- package/dist-server/service/kpi-scope/kpi-scope.d.ts +38 -0
- package/dist-server/service/kpi-scope/kpi-scope.js +144 -0
- package/dist-server/service/kpi-scope/kpi-scope.js.map +1 -0
- package/dist-server/service/kpi-statistic/index.d.ts +6 -0
- package/dist-server/service/kpi-statistic/index.js +10 -0
- package/dist-server/service/kpi-statistic/index.js.map +1 -0
- package/dist-server/service/kpi-statistic/kpi-statistic-batch.service.d.ts +43 -0
- package/dist-server/service/kpi-statistic/kpi-statistic-batch.service.js +181 -0
- package/dist-server/service/kpi-statistic/kpi-statistic-batch.service.js.map +1 -0
- package/dist-server/service/kpi-statistic/kpi-statistic-calculation.service.d.ts +50 -0
- package/dist-server/service/kpi-statistic/kpi-statistic-calculation.service.js +324 -0
- package/dist-server/service/kpi-statistic/kpi-statistic-calculation.service.js.map +1 -0
- package/dist-server/service/kpi-statistic/kpi-statistic-mutation.d.ts +14 -0
- package/dist-server/service/kpi-statistic/kpi-statistic-mutation.js +279 -0
- package/dist-server/service/kpi-statistic/kpi-statistic-mutation.js.map +1 -0
- package/dist-server/service/kpi-statistic/kpi-statistic-query.d.ts +17 -0
- package/dist-server/service/kpi-statistic/kpi-statistic-query.js +183 -0
- package/dist-server/service/kpi-statistic/kpi-statistic-query.js.map +1 -0
- package/dist-server/service/kpi-statistic/kpi-statistic-type.d.ts +59 -0
- package/dist-server/service/kpi-statistic/kpi-statistic-type.js +200 -0
- package/dist-server/service/kpi-statistic/kpi-statistic-type.js.map +1 -0
- package/dist-server/service/kpi-statistic/kpi-statistic.d.ts +42 -0
- package/dist-server/service/kpi-statistic/kpi-statistic.js +210 -0
- package/dist-server/service/kpi-statistic/kpi-statistic.js.map +1 -0
- package/dist-server/service/kpi-value/index.d.ts +6 -0
- package/dist-server/service/kpi-value/index.js +10 -0
- package/dist-server/service/kpi-value/index.js.map +1 -0
- package/dist-server/service/kpi-value/kpi-value-mutation.d.ts +13 -0
- package/dist-server/service/kpi-value/kpi-value-mutation.js +447 -0
- package/dist-server/service/kpi-value/kpi-value-mutation.js.map +1 -0
- package/dist-server/service/kpi-value/kpi-value-query.d.ts +22 -0
- package/dist-server/service/kpi-value/kpi-value-query.js +149 -0
- package/dist-server/service/kpi-value/kpi-value-query.js.map +1 -0
- package/dist-server/service/kpi-value/kpi-value-score.service.d.ts +24 -0
- package/dist-server/service/kpi-value/kpi-value-score.service.js +61 -0
- package/dist-server/service/kpi-value/kpi-value-score.service.js.map +1 -0
- package/dist-server/service/kpi-value/kpi-value-type.d.ts +33 -0
- package/dist-server/service/kpi-value/kpi-value-type.js +156 -0
- package/dist-server/service/kpi-value/kpi-value-type.js.map +1 -0
- package/dist-server/service/kpi-value/kpi-value.d.ts +32 -0
- package/dist-server/service/kpi-value/kpi-value.js +175 -0
- package/dist-server/service/kpi-value/kpi-value.js.map +1 -0
- package/dist-server/service/utils/value-date-util.d.ts +4 -0
- package/dist-server/service/utils/value-date-util.js +117 -0
- package/dist-server/service/utils/value-date-util.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KpiValueMutation = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const typeorm_1 = require("typeorm");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
|
+
const kpi_value_1 = require("./kpi-value");
|
|
9
|
+
const kpi_value_type_1 = require("./kpi-value-type");
|
|
10
|
+
const kpi_1 = require("../kpi/kpi");
|
|
11
|
+
const kpi_metric_1 = require("../kpi-metric/kpi-metric");
|
|
12
|
+
const kpi_org_scope_1 = require("../kpi-org-scope/kpi-org-scope");
|
|
13
|
+
const kpi_metric_value_1 = require("../kpi-metric-value/kpi-metric-value");
|
|
14
|
+
const kpi_2 = require("../kpi/kpi");
|
|
15
|
+
const kpi_value_2 = require("./kpi-value");
|
|
16
|
+
const kpi_value_score_service_1 = require("./kpi-value-score.service");
|
|
17
|
+
const parser_1 = require("../../calculator/parser");
|
|
18
|
+
const evaluator_1 = require("../../calculator/evaluator");
|
|
19
|
+
const functions_1 = require("../../calculator/functions");
|
|
20
|
+
const kpi_metric_value_provider_1 = require("../../controllers/kpi-metric-value-provider");
|
|
21
|
+
let KpiValueMutation = class KpiValueMutation {
|
|
22
|
+
async createKpiValue(kpiValue, context) {
|
|
23
|
+
const { domain, user, tx } = context.state;
|
|
24
|
+
let kpi = kpiValue.kpiId ? await (0, shell_1.getRepository)(kpi_1.Kpi).findOne({ where: { id: kpiValue.kpiId } }) : undefined;
|
|
25
|
+
let inputType = undefined;
|
|
26
|
+
if (kpiValue.inputType) {
|
|
27
|
+
if (typeof kpiValue.inputType === 'string') {
|
|
28
|
+
inputType = kpi_value_2.KpiValueInputType[kpiValue.inputType];
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
inputType = kpiValue.inputType;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// KpiOrgScope 처리
|
|
35
|
+
let kpiOrgScope;
|
|
36
|
+
if (kpiValue.kpiOrgScopeId) {
|
|
37
|
+
kpiOrgScope = await (0, shell_1.getRepository)(kpi_org_scope_1.KpiOrgScope, context.state?.tx).findOne({
|
|
38
|
+
where: { id: kpiValue.kpiOrgScopeId, domain: { id: domain.id } }
|
|
39
|
+
});
|
|
40
|
+
if (!kpiOrgScope) {
|
|
41
|
+
throw new Error(`KpiOrgScope not found: ${kpiValue.kpiOrgScopeId}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (kpiValue.org) {
|
|
45
|
+
// Legacy org 처리 - org 문자열로 KpiOrgScope 찾기 또는 생성
|
|
46
|
+
kpiOrgScope = await (0, shell_1.getRepository)(kpi_org_scope_1.KpiOrgScope, context.state?.tx).findOne({
|
|
47
|
+
where: { org: kpiValue.org, domain: { id: domain.id } }
|
|
48
|
+
});
|
|
49
|
+
if (!kpiOrgScope) {
|
|
50
|
+
// 새 KpiOrgScope 생성
|
|
51
|
+
kpiOrgScope = await (0, shell_1.getRepository)(kpi_org_scope_1.KpiOrgScope, context.state?.tx).save({
|
|
52
|
+
entityType: 'Manual',
|
|
53
|
+
entityId: `manual-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
54
|
+
entityName: kpiValue.org,
|
|
55
|
+
org: kpiValue.org,
|
|
56
|
+
domain,
|
|
57
|
+
creator: user,
|
|
58
|
+
updater: user
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const entity = {
|
|
63
|
+
kpi,
|
|
64
|
+
kpiId: kpiValue.kpiId,
|
|
65
|
+
version: kpiValue.version,
|
|
66
|
+
valueDate: kpiValue.valueDate,
|
|
67
|
+
value: kpiValue.value,
|
|
68
|
+
source: kpiValue.source,
|
|
69
|
+
domain: domain,
|
|
70
|
+
creator: user,
|
|
71
|
+
updater: user
|
|
72
|
+
};
|
|
73
|
+
if (kpiOrgScope) {
|
|
74
|
+
entity.kpiOrgScope = kpiOrgScope;
|
|
75
|
+
entity.kpiOrgScopeId = kpiOrgScope.id;
|
|
76
|
+
}
|
|
77
|
+
if (inputType)
|
|
78
|
+
entity.inputType = inputType;
|
|
79
|
+
return await (0, shell_1.getRepository)(kpi_value_1.KpiValue, tx).save(entity);
|
|
80
|
+
}
|
|
81
|
+
async createMultipleKpiValue(values, context) {
|
|
82
|
+
const { domain, user, tx } = context.state;
|
|
83
|
+
const repository = (0, shell_1.getRepository)(kpi_value_1.KpiValue, tx);
|
|
84
|
+
const scoreService = new kpi_value_score_service_1.KpiValueScoreService();
|
|
85
|
+
const entities = [];
|
|
86
|
+
for (const kpiValue of values) {
|
|
87
|
+
let kpi = kpiValue.kpiId ? await (0, shell_1.getRepository)(kpi_1.Kpi).findOne({ where: { id: kpiValue.kpiId } }) : undefined;
|
|
88
|
+
let inputType = undefined;
|
|
89
|
+
if (kpiValue.inputType) {
|
|
90
|
+
if (typeof kpiValue.inputType === 'string') {
|
|
91
|
+
inputType = kpi_value_2.KpiValueInputType[kpiValue.inputType];
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
inputType = kpiValue.inputType;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// KpiOrgScope 처리
|
|
98
|
+
let kpiOrgScope;
|
|
99
|
+
if (kpiValue.kpiOrgScopeId) {
|
|
100
|
+
kpiOrgScope = await (0, shell_1.getRepository)(kpi_org_scope_1.KpiOrgScope, context.state?.tx).findOne({
|
|
101
|
+
where: { id: kpiValue.kpiOrgScopeId, domain: { id: domain.id } }
|
|
102
|
+
});
|
|
103
|
+
if (!kpiOrgScope) {
|
|
104
|
+
throw new Error(`KpiOrgScope not found: ${kpiValue.kpiOrgScopeId}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (kpiValue.org) {
|
|
108
|
+
// Legacy org 처리
|
|
109
|
+
kpiOrgScope = await (0, shell_1.getRepository)(kpi_org_scope_1.KpiOrgScope, context.state?.tx).findOne({
|
|
110
|
+
where: { org: kpiValue.org, domain: { id: domain.id } }
|
|
111
|
+
});
|
|
112
|
+
if (!kpiOrgScope) {
|
|
113
|
+
// 새 KpiOrgScope 생성
|
|
114
|
+
kpiOrgScope = await (0, shell_1.getRepository)(kpi_org_scope_1.KpiOrgScope, context.state?.tx).save({
|
|
115
|
+
entityType: 'Manual',
|
|
116
|
+
entityId: `manual-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
117
|
+
entityName: kpiValue.org,
|
|
118
|
+
org: kpiValue.org,
|
|
119
|
+
domain,
|
|
120
|
+
creator: user,
|
|
121
|
+
updater: user
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const entity = {
|
|
126
|
+
kpi,
|
|
127
|
+
kpiId: kpiValue.kpiId,
|
|
128
|
+
version: kpiValue.version || 1,
|
|
129
|
+
valueDate: kpiValue.valueDate,
|
|
130
|
+
value: kpiValue.value,
|
|
131
|
+
source: kpiValue.source || 'MANUAL',
|
|
132
|
+
domain: domain,
|
|
133
|
+
creator: user,
|
|
134
|
+
updater: user
|
|
135
|
+
};
|
|
136
|
+
if (kpiOrgScope) {
|
|
137
|
+
entity.kpiOrgScope = kpiOrgScope;
|
|
138
|
+
entity.kpiOrgScopeId = kpiOrgScope.id;
|
|
139
|
+
}
|
|
140
|
+
if (inputType)
|
|
141
|
+
entity.inputType = inputType;
|
|
142
|
+
const savedEntity = await repository.save(entity);
|
|
143
|
+
// 성과 점수 자동 계산 및 저장
|
|
144
|
+
if (kpi) {
|
|
145
|
+
await scoreService.calculateAndSaveScore(savedEntity, kpi);
|
|
146
|
+
}
|
|
147
|
+
entities.push(savedEntity);
|
|
148
|
+
}
|
|
149
|
+
return entities;
|
|
150
|
+
}
|
|
151
|
+
async updateKpiValue(id, patch, context) {
|
|
152
|
+
const { domain, user, tx } = context.state;
|
|
153
|
+
const repository = (0, shell_1.getRepository)(kpi_value_1.KpiValue, tx);
|
|
154
|
+
const kpiValue = await repository.findOne({
|
|
155
|
+
where: { domain: { id: domain.id }, id }
|
|
156
|
+
});
|
|
157
|
+
let kpi = patch.kpiId ? await (0, shell_1.getRepository)(kpi_1.Kpi).findOne({ where: { id: patch.kpiId } }) : kpiValue.kpi;
|
|
158
|
+
let inputType = undefined;
|
|
159
|
+
if (patch.inputType) {
|
|
160
|
+
if (typeof patch.inputType === 'string') {
|
|
161
|
+
inputType = kpi_value_2.KpiValueInputType[patch.inputType];
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
inputType = patch.inputType;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
inputType = kpiValue.inputType;
|
|
169
|
+
}
|
|
170
|
+
const entity = {
|
|
171
|
+
...kpiValue,
|
|
172
|
+
...patch,
|
|
173
|
+
kpi,
|
|
174
|
+
updater: user
|
|
175
|
+
};
|
|
176
|
+
if (inputType)
|
|
177
|
+
entity.inputType = inputType;
|
|
178
|
+
return await repository.save(entity);
|
|
179
|
+
}
|
|
180
|
+
async updateMultipleKpiValue(patches, context) {
|
|
181
|
+
const { domain, user, tx } = context.state;
|
|
182
|
+
let results = [];
|
|
183
|
+
const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
|
|
184
|
+
const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
|
|
185
|
+
const kpiValueRepo = (0, shell_1.getRepository)(kpi_value_1.KpiValue, tx);
|
|
186
|
+
if (_createRecords.length > 0) {
|
|
187
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
|
188
|
+
const newRecord = _createRecords[i];
|
|
189
|
+
const kpi = await (0, shell_1.getRepository)(kpi_1.Kpi, tx).findOne({
|
|
190
|
+
where: { domain: { id: domain.id }, id: newRecord.kpiId }
|
|
191
|
+
});
|
|
192
|
+
const result = await kpiValueRepo.save({
|
|
193
|
+
...newRecord,
|
|
194
|
+
kpi,
|
|
195
|
+
version: newRecord.version || kpi.version,
|
|
196
|
+
domain,
|
|
197
|
+
creator: user,
|
|
198
|
+
updater: user
|
|
199
|
+
});
|
|
200
|
+
results.push({ ...result, cuFlag: '+' });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (_updateRecords.length > 0) {
|
|
204
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
|
205
|
+
const updateRecord = _updateRecords[i];
|
|
206
|
+
const kpiValue = await kpiValueRepo.findOne({
|
|
207
|
+
where: { domain: { id: domain.id }, id: updateRecord.id }
|
|
208
|
+
});
|
|
209
|
+
if (!kpiValue) {
|
|
210
|
+
throw new Error(`failed to find kpiValue to update: ${updateRecord.id}`);
|
|
211
|
+
}
|
|
212
|
+
const kpi = await (0, shell_1.getRepository)(kpi_1.Kpi, tx).findOne({
|
|
213
|
+
where: { domain: { id: domain.id }, id: updateRecord.kpiId }
|
|
214
|
+
});
|
|
215
|
+
const result = await kpiValueRepo.save({
|
|
216
|
+
...kpiValue,
|
|
217
|
+
...updateRecord,
|
|
218
|
+
kpi,
|
|
219
|
+
version: updateRecord.version || kpi.version,
|
|
220
|
+
updater: user
|
|
221
|
+
});
|
|
222
|
+
results.push({ ...result, cuFlag: 'M' });
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return results;
|
|
226
|
+
}
|
|
227
|
+
async deleteKpiValue(id, context) {
|
|
228
|
+
const { domain, tx } = context.state;
|
|
229
|
+
await (0, shell_1.getRepository)(kpi_value_1.KpiValue, tx).delete({ domain: { id: domain.id }, id });
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
async deleteKpiValues(ids, context) {
|
|
233
|
+
const { domain, tx } = context.state;
|
|
234
|
+
await (0, shell_1.getRepository)(kpi_value_1.KpiValue, tx).delete({
|
|
235
|
+
domain: { id: domain.id },
|
|
236
|
+
id: (0, typeorm_1.In)(ids)
|
|
237
|
+
});
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
async importKpiValues(kpiValues, context) {
|
|
241
|
+
const { domain, tx } = context.state;
|
|
242
|
+
await Promise.all(kpiValues.map(async (kpiValue) => {
|
|
243
|
+
const createdKpiValue = await (0, shell_1.getRepository)(kpi_value_1.KpiValue, tx).save({ domain, ...kpiValue });
|
|
244
|
+
}));
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
async recalculateScoresForKpi(kpiId, context) {
|
|
248
|
+
const scoreService = new kpi_value_score_service_1.KpiValueScoreService();
|
|
249
|
+
await scoreService.recalculateScoresForKpi(kpiId, context);
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
async recalculateKpiValue(id, context) {
|
|
253
|
+
const { domain, user, tx } = context.state;
|
|
254
|
+
const kpiValueRepo = (0, shell_1.getRepository)(kpi_value_1.KpiValue, tx);
|
|
255
|
+
const kpiRepo = (0, shell_1.getRepository)(kpi_1.Kpi, tx);
|
|
256
|
+
const metricRepo = (0, shell_1.getRepository)(kpi_metric_1.KpiMetric, tx);
|
|
257
|
+
const metricValueRepo = (0, shell_1.getRepository)(kpi_metric_value_1.KpiMetricValue, tx);
|
|
258
|
+
// 1. 기존 KPI Value 인스턴스 조회
|
|
259
|
+
const kpiValue = await kpiValueRepo.findOne({
|
|
260
|
+
where: { id, domain: { id: domain.id } },
|
|
261
|
+
relations: ['kpi', 'kpiOrgScope']
|
|
262
|
+
});
|
|
263
|
+
if (!kpiValue)
|
|
264
|
+
throw new Error('KPI Value not found');
|
|
265
|
+
// 항상 최신 버전의 KPI를 조회하여 사용
|
|
266
|
+
const kpi = await kpiRepo.findOne({
|
|
267
|
+
where: { id: kpiValue.kpiId, domain: { id: domain.id } },
|
|
268
|
+
order: { version: 'DESC' }
|
|
269
|
+
});
|
|
270
|
+
if (!kpi)
|
|
271
|
+
throw new Error('KPI 정보 없음');
|
|
272
|
+
if (!kpi.formula)
|
|
273
|
+
throw new Error('KPI formula 없음');
|
|
274
|
+
const periodType = kpi.periodType || kpi_2.KpiPeriodType.DAY;
|
|
275
|
+
const valueDate = kpiValue.valueDate;
|
|
276
|
+
const kpiOrgScope = kpiValue.kpiOrgScope;
|
|
277
|
+
const org = kpiOrgScope?.entityName || kpiOrgScope?.org || 'unknown'; // KpiOrgScope에서 org 정보 추출
|
|
278
|
+
// 2. formula에서 metric code 추출
|
|
279
|
+
const metricCodes = (kpi.formula.match(/[a-zA-Z_][a-zA-Z0-9_]*/g) || []).filter(code => code !== 'null' && code !== 'undefined');
|
|
280
|
+
const metricMap = {};
|
|
281
|
+
for (const code of metricCodes) {
|
|
282
|
+
const metric = await metricRepo.findOne({ where: { name: code, domain: { id: domain.id } } });
|
|
283
|
+
if (!metric)
|
|
284
|
+
throw new Error(`KPI formula metric '${code}' not found`);
|
|
285
|
+
metricMap[code] = metric;
|
|
286
|
+
}
|
|
287
|
+
// 3. metric 값 집계 (periodType 변환/집계)
|
|
288
|
+
const metricValues = {};
|
|
289
|
+
for (const code of metricCodes) {
|
|
290
|
+
const metric = metricMap[code];
|
|
291
|
+
let value = null;
|
|
292
|
+
if (metric.periodType === periodType) {
|
|
293
|
+
const mv = await metricValueRepo.findOne({
|
|
294
|
+
where: {
|
|
295
|
+
metric: { id: metric.id },
|
|
296
|
+
valueDate,
|
|
297
|
+
periodType,
|
|
298
|
+
org: org ?? '',
|
|
299
|
+
domain: { id: domain.id }
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
value = mv?.value ?? null;
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
let startDate, endDate;
|
|
306
|
+
if (periodType === kpi_2.KpiPeriodType.MONTH && metric.periodType === kpi_2.KpiPeriodType.DAY) {
|
|
307
|
+
startDate = valueDate + '-01';
|
|
308
|
+
endDate = valueDate + '-31';
|
|
309
|
+
const mvs = await metricValueRepo.find({
|
|
310
|
+
where: {
|
|
311
|
+
metric: { id: metric.id },
|
|
312
|
+
valueDate: (0, typeorm_1.Between)(startDate, endDate),
|
|
313
|
+
periodType: metric.periodType,
|
|
314
|
+
org: org ?? '',
|
|
315
|
+
domain: { id: domain.id }
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
value = mvs.reduce((sum, mv) => sum + (mv.value ?? 0), 0);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
throw new Error('KPI/Metric periodType 조합 집계 미지원');
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (value == null)
|
|
325
|
+
throw new Error(`Metric '${code}' 값 없음`);
|
|
326
|
+
metricValues[code] = value;
|
|
327
|
+
}
|
|
328
|
+
// 4. formula 계산 (calculator 기반)
|
|
329
|
+
const ast = (0, parser_1.parseFormula)(kpi.formula);
|
|
330
|
+
const provider = new kpi_metric_value_provider_1.KpiMetricValueProvider({
|
|
331
|
+
valueDate,
|
|
332
|
+
org,
|
|
333
|
+
domainId: domain.id,
|
|
334
|
+
tx
|
|
335
|
+
});
|
|
336
|
+
const evalContext = { functions: functions_1.builtinFunctions, provider };
|
|
337
|
+
const kpiValueResult = await (0, evaluator_1.evaluateFormula)(ast, evalContext);
|
|
338
|
+
if (kpiValueResult == null || isNaN(kpiValueResult))
|
|
339
|
+
throw new Error('KPI formula 결과값 없음');
|
|
340
|
+
// 5. KPI Value 업데이트 (최신 버전으로)
|
|
341
|
+
kpiValue.value = kpiValueResult;
|
|
342
|
+
kpiValue.version = kpi.version || 1;
|
|
343
|
+
kpiValue.updater = user;
|
|
344
|
+
// 6. 성과 점수 자동 계산 및 저장
|
|
345
|
+
const scoreService = new kpi_value_score_service_1.KpiValueScoreService();
|
|
346
|
+
await scoreService.calculateAndSaveScore(kpiValue, kpi);
|
|
347
|
+
return await kpiValueRepo.save(kpiValue);
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
exports.KpiValueMutation = KpiValueMutation;
|
|
351
|
+
tslib_1.__decorate([
|
|
352
|
+
(0, type_graphql_1.Directive)('@privilege(category: "kpi", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
|
353
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
354
|
+
(0, type_graphql_1.Mutation)(returns => kpi_value_1.KpiValue, { description: 'Create a new KPI value with the provided details.' }),
|
|
355
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('kpiValue', { description: 'Input object containing details for the new KPI value.' })),
|
|
356
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
357
|
+
tslib_1.__metadata("design:type", Function),
|
|
358
|
+
tslib_1.__metadata("design:paramtypes", [kpi_value_type_1.NewKpiValue, Object]),
|
|
359
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
360
|
+
], KpiValueMutation.prototype, "createKpiValue", null);
|
|
361
|
+
tslib_1.__decorate([
|
|
362
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
363
|
+
(0, type_graphql_1.Directive)('@privilege(category: "kpi", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
|
364
|
+
(0, type_graphql_1.Mutation)(returns => [kpi_value_1.KpiValue], { description: 'Create multiple KPI values with the provided details.' }),
|
|
365
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('values', type => [kpi_value_type_1.NewKpiValue], {
|
|
366
|
+
description: 'Array of input objects containing details for the new KPI values.'
|
|
367
|
+
})),
|
|
368
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
369
|
+
tslib_1.__metadata("design:type", Function),
|
|
370
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
371
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
372
|
+
], KpiValueMutation.prototype, "createMultipleKpiValue", null);
|
|
373
|
+
tslib_1.__decorate([
|
|
374
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
375
|
+
(0, type_graphql_1.Directive)('@privilege(category: "kpi", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
|
376
|
+
(0, type_graphql_1.Mutation)(returns => kpi_value_1.KpiValue, { description: 'To modify KpiValue information' }),
|
|
377
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
378
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
|
|
379
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
380
|
+
tslib_1.__metadata("design:type", Function),
|
|
381
|
+
tslib_1.__metadata("design:paramtypes", [String, kpi_value_type_1.KpiValuePatch, Object]),
|
|
382
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
383
|
+
], KpiValueMutation.prototype, "updateKpiValue", null);
|
|
384
|
+
tslib_1.__decorate([
|
|
385
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
386
|
+
(0, type_graphql_1.Directive)('@privilege(category: "kpi", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
|
387
|
+
(0, type_graphql_1.Mutation)(returns => [kpi_value_1.KpiValue], { description: "To modify multiple KpiValues' information" }),
|
|
388
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [kpi_value_type_1.KpiValuePatch])),
|
|
389
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
390
|
+
tslib_1.__metadata("design:type", Function),
|
|
391
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
392
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
393
|
+
], KpiValueMutation.prototype, "updateMultipleKpiValue", null);
|
|
394
|
+
tslib_1.__decorate([
|
|
395
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
396
|
+
(0, type_graphql_1.Directive)('@privilege(category: "kpi", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
|
397
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete KpiValue' }),
|
|
398
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
399
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
400
|
+
tslib_1.__metadata("design:type", Function),
|
|
401
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
402
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
403
|
+
], KpiValueMutation.prototype, "deleteKpiValue", null);
|
|
404
|
+
tslib_1.__decorate([
|
|
405
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
406
|
+
(0, type_graphql_1.Directive)('@privilege(category: "kpi", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
|
407
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple KpiValues' }),
|
|
408
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
|
409
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
410
|
+
tslib_1.__metadata("design:type", Function),
|
|
411
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
412
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
413
|
+
], KpiValueMutation.prototype, "deleteKpiValues", null);
|
|
414
|
+
tslib_1.__decorate([
|
|
415
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
416
|
+
(0, type_graphql_1.Directive)('@privilege(category: "kpi", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
|
417
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple KpiValues' }),
|
|
418
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('kpiValues', type => [kpi_value_type_1.KpiValuePatch])),
|
|
419
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
420
|
+
tslib_1.__metadata("design:type", Function),
|
|
421
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
422
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
423
|
+
], KpiValueMutation.prototype, "importKpiValues", null);
|
|
424
|
+
tslib_1.__decorate([
|
|
425
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
426
|
+
(0, type_graphql_1.Directive)('@privilege(category: "kpi", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
|
427
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Recalculate scores for all KpiValues of a specific KPI' }),
|
|
428
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('kpiId')),
|
|
429
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
430
|
+
tslib_1.__metadata("design:type", Function),
|
|
431
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
432
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
433
|
+
], KpiValueMutation.prototype, "recalculateScoresForKpi", null);
|
|
434
|
+
tslib_1.__decorate([
|
|
435
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
436
|
+
(0, type_graphql_1.Directive)('@privilege(category: "kpi", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
|
|
437
|
+
(0, type_graphql_1.Mutation)(returns => kpi_value_1.KpiValue, { description: '기존 KPI Value 인스턴스를 현재 formula/metric 값으로 재계산' }),
|
|
438
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
439
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
440
|
+
tslib_1.__metadata("design:type", Function),
|
|
441
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
442
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
443
|
+
], KpiValueMutation.prototype, "recalculateKpiValue", null);
|
|
444
|
+
exports.KpiValueMutation = KpiValueMutation = tslib_1.__decorate([
|
|
445
|
+
(0, type_graphql_1.Resolver)(kpi_value_1.KpiValue)
|
|
446
|
+
], KpiValueMutation);
|
|
447
|
+
//# sourceMappingURL=kpi-value-mutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kpi-value-mutation.js","sourceRoot":"","sources":["../../../server/service/kpi-value/kpi-value-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAAqC;AACrC,iDAAqD;AAErD,2CAAsC;AACtC,qDAA6D;AAC7D,oCAAgC;AAChC,yDAAoD;AACpD,kEAA4D;AAC5D,2EAAqE;AACrE,oCAA0C;AAE1C,2CAA+C;AAC/C,uEAAgE;AAChE,oDAAsD;AACtD,0DAA4D;AAC5D,0DAA6D;AAC7D,2FAAoF;AAG7E,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAIrB,AAAN,KAAK,CAAC,cAAc,CAC0E,QAAqB,EAC1G,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,IAAI,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,IAAA,qBAAa,EAAC,SAAG,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QAE1G,IAAI,SAAS,GAAkC,SAAS,CAAA;QACxD,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;YACvB,IAAI,OAAO,QAAQ,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;gBAC3C,SAAS,GAAG,6BAAiB,CAAC,QAAQ,CAAC,SAA2C,CAAC,CAAA;YACrF,CAAC;iBAAM,CAAC;gBACN,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;YAChC,CAAC;QACH,CA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AAG,GAAE,CAAA;;;;+DAIhE;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,sGAAsG,CAAC;IACjH,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,oBAAQ,EAAE,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC;IACpE,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAiGtD;2BAhaU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,oBAAQ,CAAC;GACN,gBAAgB,CAia5B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In, Between } from 'typeorm'\nimport { getRepository } from '@things-factory/shell'\n\nimport { KpiValue } from './kpi-value'\nimport { NewKpiValue, KpiValuePatch } from './kpi-value-type'\nimport { Kpi } from '../kpi/kpi'\nimport { KpiMetric } from '../kpi-metric/kpi-metric'\nimport { KpiOrgScope } from '../kpi-org-scope/kpi-org-scope'\nimport { KpiMetricValue } from '../kpi-metric-value/kpi-metric-value'\nimport { KpiPeriodType } from '../kpi/kpi'\nimport { getDefaultValueDate } from '../utils/value-date-util'\nimport { KpiValueInputType } from './kpi-value'\nimport { KpiValueScoreService } from './kpi-value-score.service'\nimport { parseFormula } from '../../calculator/parser'\nimport { evaluateFormula } from '../../calculator/evaluator'\nimport { builtinFunctions } from '../../calculator/functions'\nimport { KpiMetricValueProvider } from '../../controllers/kpi-metric-value-provider'\n\n@Resolver(KpiValue)\nexport class KpiValueMutation {\n @Directive('@privilege(category: \"kpi\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)')\n @Directive('@transaction')\n @Mutation(returns => KpiValue, { description: 'Create a new KPI value with the provided details.' })\n async createKpiValue(\n @Arg('kpiValue', { description: 'Input object containing details for the new KPI value.' }) kpiValue: NewKpiValue,\n @Ctx() context: ResolverContext\n ): Promise<KpiValue> {\n const { domain, user, tx } = context.state\n\n let kpi = kpiValue.kpiId ? await getRepository(Kpi).findOne({ where: { id: kpiValue.kpiId } }) : undefined\n\n let inputType: KpiValueInputType | undefined = undefined\n if (kpiValue.inputType) {\n if (typeof kpiValue.inputType === 'string') {\n inputType = KpiValueInputType[kpiValue.inputType as keyof typeof KpiValueInputType]\n } else {\n inputType = kpiValue.inputType\n }\n }\n\n // KpiOrgScope 처리\n let kpiOrgScope: KpiOrgScope | undefined\n if (kpiValue.kpiOrgScopeId) {\n kpiOrgScope = await getRepository(KpiOrgScope, context.state?.tx).findOne({\n where: { id: kpiValue.kpiOrgScopeId, domain: { id: domain.id } }\n })\n if (!kpiOrgScope) {\n throw new Error(`KpiOrgScope not found: ${kpiValue.kpiOrgScopeId}`)\n }\n } else if (kpiValue.org) {\n // Legacy org 처리 - org 문자열로 KpiOrgScope 찾기 또는 생성\n kpiOrgScope = await getRepository(KpiOrgScope, context.state?.tx).findOne({\n where: { org: kpiValue.org, domain: { id: domain.id } }\n })\n if (!kpiOrgScope) {\n // 새 KpiOrgScope 생성\n kpiOrgScope = await getRepository(KpiOrgScope, context.state?.tx).save({\n entityType: 'Manual',\n entityId: `manual-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,\n entityName: kpiValue.org,\n org: kpiValue.org,\n domain,\n creator: user,\n updater: user\n })\n }\n }\n\n const entity: Partial<KpiValue> = {\n kpi,\n kpiId: kpiValue.kpiId,\n version: kpiValue.version,\n valueDate: kpiValue.valueDate,\n value: kpiValue.value,\n source: kpiValue.source,\n domain: domain,\n creator: user,\n updater: user\n }\n \n if (kpiOrgScope) {\n entity.kpiOrgScope = kpiOrgScope\n entity.kpiOrgScopeId = kpiOrgScope.id\n }\n if (inputType) entity.inputType = inputType\n\n return await getRepository(KpiValue, tx).save(entity)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"kpi\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)')\n @Mutation(returns => [KpiValue], { description: 'Create multiple KPI values with the provided details.' })\n async createMultipleKpiValue(\n @Arg('values', type => [NewKpiValue], {\n description: 'Array of input objects containing details for the new KPI values.'\n })\n values: NewKpiValue[],\n @Ctx() context: ResolverContext\n ): Promise<KpiValue[]> {\n const { domain, user, tx } = context.state\n const repository = getRepository(KpiValue, tx)\n const scoreService = new KpiValueScoreService()\n\n const entities: KpiValue[] = []\n\n for (const kpiValue of values) {\n let kpi = kpiValue.kpiId ? await getRepository(Kpi).findOne({ where: { id: kpiValue.kpiId } }) : undefined\n\n let inputType: KpiValueInputType | undefined = undefined\n if (kpiValue.inputType) {\n if (typeof kpiValue.inputType === 'string') {\n inputType = KpiValueInputType[kpiValue.inputType as keyof typeof KpiValueInputType]\n } else {\n inputType = kpiValue.inputType\n }\n }\n\n // KpiOrgScope 처리\n let kpiOrgScope: KpiOrgScope | undefined\n if (kpiValue.kpiOrgScopeId) {\n kpiOrgScope = await getRepository(KpiOrgScope, context.state?.tx).findOne({\n where: { id: kpiValue.kpiOrgScopeId, domain: { id: domain.id } }\n })\n if (!kpiOrgScope) {\n throw new Error(`KpiOrgScope not found: ${kpiValue.kpiOrgScopeId}`)\n }\n } else if (kpiValue.org) {\n // Legacy org 처리\n kpiOrgScope = await getRepository(KpiOrgScope, context.state?.tx).findOne({\n where: { org: kpiValue.org, domain: { id: domain.id } }\n })\n if (!kpiOrgScope) {\n // 새 KpiOrgScope 생성\n kpiOrgScope = await getRepository(KpiOrgScope, context.state?.tx).save({\n entityType: 'Manual',\n entityId: `manual-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,\n entityName: kpiValue.org,\n org: kpiValue.org,\n domain,\n creator: user,\n updater: user\n })\n }\n }\n\n const entity: Partial<KpiValue> = {\n kpi,\n kpiId: kpiValue.kpiId,\n version: kpiValue.version || 1,\n valueDate: kpiValue.valueDate,\n value: kpiValue.value,\n source: kpiValue.source || 'MANUAL',\n domain: domain,\n creator: user,\n updater: user\n }\n\n if (kpiOrgScope) {\n entity.kpiOrgScope = kpiOrgScope\n entity.kpiOrgScopeId = kpiOrgScope.id\n }\n if (inputType) entity.inputType = inputType\n\n const savedEntity = await repository.save(entity)\n\n // 성과 점수 자동 계산 및 저장\n if (kpi) {\n await scoreService.calculateAndSaveScore(savedEntity, kpi)\n }\n\n entities.push(savedEntity)\n }\n\n return entities\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"kpi\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)')\n @Mutation(returns => KpiValue, { description: 'To modify KpiValue information' })\n async updateKpiValue(\n @Arg('id') id: string,\n @Arg('patch') patch: KpiValuePatch,\n @Ctx() context: ResolverContext\n ): Promise<KpiValue> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(KpiValue, tx)\n const kpiValue = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n let kpi = patch.kpiId ? await getRepository(Kpi).findOne({ where: { id: patch.kpiId } }) : kpiValue.kpi\n\n let inputType: KpiValueInputType | undefined = undefined\n if (patch.inputType) {\n if (typeof patch.inputType === 'string') {\n inputType = KpiValueInputType[patch.inputType as keyof typeof KpiValueInputType]\n } else {\n inputType = patch.inputType\n }\n } else {\n inputType = kpiValue.inputType\n }\n\n const entity: any = {\n ...kpiValue,\n ...patch,\n kpi,\n updater: user\n }\n if (inputType) entity.inputType = inputType\n\n return await repository.save(entity)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"kpi\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)')\n @Mutation(returns => [KpiValue], { description: \"To modify multiple KpiValues' information\" })\n async updateMultipleKpiValue(\n @Arg('patches', type => [KpiValuePatch]) patches: KpiValuePatch[],\n @Ctx() context: ResolverContext\n ): Promise<KpiValue[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const kpiValueRepo = getRepository(KpiValue, tx)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const kpi = await getRepository(Kpi, tx).findOne({\n where: { domain: { id: domain.id }, id: newRecord.kpiId }\n })\n\n const result = await kpiValueRepo.save({\n ...newRecord,\n kpi,\n version: newRecord.version || kpi.version,\n domain,\n creator: user,\n updater: user\n } as any)\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const kpiValue = await kpiValueRepo.findOne({\n where: { domain: { id: domain.id }, id: updateRecord.id }\n })\n\n if (!kpiValue) {\n throw new Error(`failed to find kpiValue to update: ${updateRecord.id}`)\n }\n\n const kpi = await getRepository(Kpi, tx).findOne({\n where: { domain: { id: domain.id }, id: updateRecord.kpiId }\n })\n\n const result = await kpiValueRepo.save({\n ...kpiValue,\n ...updateRecord,\n kpi,\n version: updateRecord.version || kpi.version,\n updater: user\n } as any)\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"kpi\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete KpiValue' })\n async deleteKpiValue(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(KpiValue, tx).delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"kpi\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete multiple KpiValues' })\n async deleteKpiValues(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(KpiValue, tx).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"kpi\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)')\n @Mutation(returns => Boolean, { description: 'To import multiple KpiValues' })\n async importKpiValues(\n @Arg('kpiValues', type => [KpiValuePatch]) kpiValues: KpiValuePatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n kpiValues.map(async (kpiValue: KpiValuePatch) => {\n const createdKpiValue: KpiValue = await getRepository(KpiValue, tx).save({ domain, ...kpiValue } as any)\n })\n )\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"kpi\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)')\n @Mutation(returns => Boolean, { description: 'Recalculate scores for all KpiValues of a specific KPI' })\n async recalculateScoresForKpi(@Arg('kpiId') kpiId: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const scoreService = new KpiValueScoreService()\n await scoreService.recalculateScoresForKpi(kpiId, context)\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"kpi\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)')\n @Mutation(returns => KpiValue, { description: '기존 KPI Value 인스턴스를 현재 formula/metric 값으로 재계산' })\n async recalculateKpiValue(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<KpiValue> {\n const { domain, user, tx } = context.state\n const kpiValueRepo = getRepository(KpiValue, tx)\n const kpiRepo = getRepository(Kpi, tx)\n const metricRepo = getRepository(KpiMetric, tx)\n const metricValueRepo = getRepository(KpiMetricValue, tx)\n\n // 1. 기존 KPI Value 인스턴스 조회\n const kpiValue = await kpiValueRepo.findOne({\n where: { id, domain: { id: domain.id } },\n relations: ['kpi', 'kpiOrgScope']\n })\n if (!kpiValue) throw new Error('KPI Value not found')\n // 항상 최신 버전의 KPI를 조회하여 사용\n const kpi = await kpiRepo.findOne({\n where: { id: kpiValue.kpiId, domain: { id: domain.id } },\n order: { version: 'DESC' }\n })\n if (!kpi) throw new Error('KPI 정보 없음')\n if (!kpi.formula) throw new Error('KPI formula 없음')\n const periodType = kpi.periodType || KpiPeriodType.DAY\n const valueDate = kpiValue.valueDate\n const kpiOrgScope = kpiValue.kpiOrgScope\n const org = kpiOrgScope?.entityName || kpiOrgScope?.org || 'unknown' // KpiOrgScope에서 org 정보 추출\n\n // 2. formula에서 metric code 추출\n const metricCodes = (kpi.formula.match(/[a-zA-Z_][a-zA-Z0-9_]*/g) || []).filter(\n code => code !== 'null' && code !== 'undefined'\n )\n const metricMap: Record<string, KpiMetric> = {}\n for (const code of metricCodes) {\n const metric = await metricRepo.findOne({ where: { name: code, domain: { id: domain.id } } })\n if (!metric) throw new Error(`KPI formula metric '${code}' not found`)\n metricMap[code] = metric\n }\n\n // 3. metric 값 집계 (periodType 변환/집계)\n const metricValues: Record<string, number> = {}\n for (const code of metricCodes) {\n const metric = metricMap[code]\n let value = null\n if (metric.periodType === periodType) {\n const mv = await metricValueRepo.findOne({\n where: {\n metric: { id: metric.id },\n valueDate,\n periodType,\n org: org ?? '',\n domain: { id: domain.id }\n }\n })\n value = mv?.value ?? null\n } else {\n let startDate: string, endDate: string\n if (periodType === KpiPeriodType.MONTH && metric.periodType === KpiPeriodType.DAY) {\n startDate = valueDate + '-01'\n endDate = valueDate + '-31'\n const mvs = await metricValueRepo.find({\n where: {\n metric: { id: metric.id },\n valueDate: Between(startDate, endDate),\n periodType: metric.periodType,\n org: org ?? '',\n domain: { id: domain.id }\n }\n })\n value = mvs.reduce((sum, mv) => sum + (mv.value ?? 0), 0)\n } else {\n throw new Error('KPI/Metric periodType 조합 집계 미지원')\n }\n }\n if (value == null) throw new Error(`Metric '${code}' 값 없음`)\n metricValues[code] = value\n }\n\n // 4. formula 계산 (calculator 기반)\n const ast = parseFormula(kpi.formula)\n const provider = new KpiMetricValueProvider({\n valueDate,\n org,\n domainId: domain.id,\n tx\n })\n const evalContext = { functions: builtinFunctions, provider }\n const kpiValueResult = await evaluateFormula(ast, evalContext)\n if (kpiValueResult == null || isNaN(kpiValueResult)) throw new Error('KPI formula 결과값 없음')\n\n // 5. KPI Value 업데이트 (최신 버전으로)\n kpiValue.value = kpiValueResult\n kpiValue.version = kpi.version || 1\n kpiValue.updater = user\n\n // 6. 성과 점수 자동 계산 및 저장\n const scoreService = new KpiValueScoreService()\n await scoreService.calculateAndSaveScore(kpiValue, kpi)\n\n return await kpiValueRepo.save(kpiValue)\n }\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Domain, ListParam } from '@things-factory/shell';
|
|
2
|
+
import { User } from '@things-factory/auth-base';
|
|
3
|
+
import { KpiValue } from './kpi-value';
|
|
4
|
+
import { KpiValueList } from './kpi-value-type';
|
|
5
|
+
import { Kpi } from '../kpi/kpi';
|
|
6
|
+
export declare class KpiValueQuery {
|
|
7
|
+
kpiValue(id: string, context: ResolverContext): Promise<KpiValue>;
|
|
8
|
+
kpiValues(params: ListParam, context: ResolverContext): Promise<KpiValueList>;
|
|
9
|
+
/**
|
|
10
|
+
* 같은 (domain, kpi, valueDate, kpiOrgScope) 좌표에서 version 이 가장 큰 row 만 반환.
|
|
11
|
+
* 차트·최종 KPI 계산 등 "최신 상태" 만 필요한 사용처용.
|
|
12
|
+
*
|
|
13
|
+
* 구현: subquery 로 (domain, kpi, valueDate, kpiOrgScope) 그룹별 MAX(version) 를 구한 뒤
|
|
14
|
+
* 본 테이블과 매칭. 기존 kpiValues 와 동일하게 ListParam (filters/sortings/pagination)
|
|
15
|
+
* 지원, 도메인 inheritance 적용.
|
|
16
|
+
*/
|
|
17
|
+
latestKpiValues(params: ListParam, context: ResolverContext): Promise<KpiValueList>;
|
|
18
|
+
domain(kpiValue: KpiValue): Promise<Domain>;
|
|
19
|
+
updater(kpiValue: KpiValue): Promise<User>;
|
|
20
|
+
creator(kpiValue: KpiValue): Promise<User>;
|
|
21
|
+
kpi(kpiValue: KpiValue): Promise<Kpi | null>;
|
|
22
|
+
}
|