@things-factory/kpi 9.0.31 → 9.0.32

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.
Files changed (324) hide show
  1. package/README.md +1 -2
  2. package/client/charts/kpi-boxplot-chart.ts +182 -42
  3. package/client/charts/kpi-radar-chart.ts +9 -9
  4. package/client/pages/kpi/kpi-list-page.ts +196 -32
  5. package/client/pages/kpi/kpi-overview.ts +9 -11
  6. package/client/pages/kpi/kpi-tree-page.ts +409 -0
  7. package/client/pages/kpi/kpi-view.ts +187 -0
  8. package/client/pages/kpi-dashboard/cards/kpi-level1-card.ts +1 -1
  9. package/client/pages/kpi-dashboard/cards/kpi-level2-comparison.ts +1 -1
  10. package/client/pages/kpi-dashboard/cards/kpi-level3-comparison.ts +1 -1
  11. package/client/pages/kpi-dashboard/components/kpi-left-panel.ts +198 -160
  12. package/client/pages/kpi-dashboard/components/kpi-map-panel.ts +133 -0
  13. package/client/pages/kpi-dashboard/components/kpi-region-popup.ts +3 -2
  14. package/client/pages/kpi-dashboard/kpi-dashboard-map.ts +4 -3
  15. package/client/pages/kpi-dashboard/kpi-dashboard.ts +28 -30
  16. package/client/pages/kpi-history/kpi-history-list-page.ts +11 -11
  17. package/client/pages/kpi-metric/kpi-metric-list-page.ts +10 -2
  18. package/client/pages/kpi-metric-value/kpi-metric-value-editor-page.ts +7 -7
  19. package/client/pages/kpi-metric-value/kpi-metric-value-importer.ts +2 -2
  20. package/client/pages/kpi-metric-value/kpi-metric-value-list-page.ts +16 -8
  21. package/client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.ts +5 -5
  22. package/client/pages/kpi-statistic/kpi-statistic-editor-page.ts +1 -2
  23. package/client/pages/kpi-statistic/kpi-statistic-list-page.ts +10 -2
  24. package/client/pages/kpi-value/kpi-value-editor-page.ts +11 -7
  25. package/client/pages/kpi-value/kpi-value-list-page.ts +31 -7
  26. package/client/route.ts +2 -9
  27. package/design-entities.md +8 -12
  28. package/dist-client/charts/kpi-boxplot-chart.d.ts +2 -0
  29. package/dist-client/charts/kpi-boxplot-chart.js +168 -42
  30. package/dist-client/charts/kpi-boxplot-chart.js.map +1 -1
  31. package/dist-client/charts/kpi-radar-chart.js +9 -9
  32. package/dist-client/charts/kpi-radar-chart.js.map +1 -1
  33. package/dist-client/pages/kpi/kpi-list-page.d.ts +19 -3
  34. package/dist-client/pages/kpi/kpi-list-page.js +188 -32
  35. package/dist-client/pages/kpi/kpi-list-page.js.map +1 -1
  36. package/dist-client/pages/kpi/kpi-overview.js +9 -11
  37. package/dist-client/pages/kpi/kpi-overview.js.map +1 -1
  38. package/dist-client/pages/kpi/kpi-tree-page.d.ts +59 -0
  39. package/dist-client/pages/kpi/kpi-tree-page.js +403 -0
  40. package/dist-client/pages/kpi/kpi-tree-page.js.map +1 -0
  41. package/dist-client/pages/kpi/kpi-view.d.ts +12 -0
  42. package/dist-client/pages/kpi/kpi-view.js +191 -0
  43. package/dist-client/pages/kpi/kpi-view.js.map +1 -0
  44. package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.js +1 -1
  45. package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.js.map +1 -1
  46. package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.js +1 -1
  47. package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.js.map +1 -1
  48. package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.js +1 -1
  49. package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.js.map +1 -1
  50. package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.d.ts +3 -1
  51. package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.js +197 -161
  52. package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.js.map +1 -1
  53. package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.d.ts +5 -0
  54. package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.js +146 -0
  55. package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.js.map +1 -1
  56. package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.js +3 -2
  57. package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.js.map +1 -1
  58. package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.js +4 -3
  59. package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.js.map +1 -1
  60. package/dist-client/pages/kpi-dashboard/kpi-dashboard.js +28 -30
  61. package/dist-client/pages/kpi-dashboard/kpi-dashboard.js.map +1 -1
  62. package/dist-client/pages/kpi-history/kpi-history-list-page.d.ts +6 -1
  63. package/dist-client/pages/kpi-history/kpi-history-list-page.js +11 -11
  64. package/dist-client/pages/kpi-history/kpi-history-list-page.js.map +1 -1
  65. package/dist-client/pages/kpi-metric/kpi-metric-list-page.d.ts +5 -0
  66. package/dist-client/pages/kpi-metric/kpi-metric-list-page.js +10 -2
  67. package/dist-client/pages/kpi-metric/kpi-metric-list-page.js.map +1 -1
  68. package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.d.ts +1 -1
  69. package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.js +8 -8
  70. package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.js.map +1 -1
  71. package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.js +2 -2
  72. package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.js.map +1 -1
  73. package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.d.ts +5 -0
  74. package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js +16 -8
  75. package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js.map +1 -1
  76. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.d.ts +1 -1
  77. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.js +6 -6
  78. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.js.map +1 -1
  79. package/dist-client/pages/kpi-statistic/kpi-statistic-editor-page.js +1 -2
  80. package/dist-client/pages/kpi-statistic/kpi-statistic-editor-page.js.map +1 -1
  81. package/dist-client/pages/kpi-statistic/kpi-statistic-list-page.d.ts +5 -0
  82. package/dist-client/pages/kpi-statistic/kpi-statistic-list-page.js +10 -2
  83. package/dist-client/pages/kpi-statistic/kpi-statistic-list-page.js.map +1 -1
  84. package/dist-client/pages/kpi-value/kpi-value-editor-page.d.ts +2 -1
  85. package/dist-client/pages/kpi-value/kpi-value-editor-page.js +16 -8
  86. package/dist-client/pages/kpi-value/kpi-value-editor-page.js.map +1 -1
  87. package/dist-client/pages/kpi-value/kpi-value-list-page.d.ts +5 -0
  88. package/dist-client/pages/kpi-value/kpi-value-list-page.js +31 -7
  89. package/dist-client/pages/kpi-value/kpi-value-list-page.js.map +1 -1
  90. package/dist-client/route.d.ts +1 -1
  91. package/dist-client/route.js +2 -8
  92. package/dist-client/route.js.map +1 -1
  93. package/dist-client/tsconfig.tsbuildinfo +1 -1
  94. package/dist-server/controllers/kpi-metric-value-provider.d.ts +1 -1
  95. package/dist-server/controllers/kpi-metric-value-provider.js +4 -4
  96. package/dist-server/controllers/kpi-metric-value-provider.js.map +1 -1
  97. package/dist-server/controllers/kpi-value-provider.d.ts +1 -1
  98. package/dist-server/controllers/kpi-value-provider.js +3 -3
  99. package/dist-server/controllers/kpi-value-provider.js.map +1 -1
  100. package/dist-server/migrations/1752190849680-seed-kpi-metrics.d.ts +6 -0
  101. package/dist-server/migrations/1752190849680-seed-kpi-metrics.js +101 -0
  102. package/dist-server/migrations/1752190849680-seed-kpi-metrics.js.map +1 -0
  103. package/dist-server/migrations/1752190849681-seed-kpi.d.ts +5 -0
  104. package/dist-server/migrations/1752190849681-seed-kpi.js +315 -0
  105. package/dist-server/migrations/1752190849681-seed-kpi.js.map +1 -0
  106. package/dist-server/migrations/1752192090123-add-grades-to-kpi.d.ts +7 -0
  107. package/dist-server/migrations/1752192090123-add-grades-to-kpi.js +51 -0
  108. package/dist-server/migrations/1752192090123-add-grades-to-kpi.js.map +1 -0
  109. package/dist-server/migrations/1752192090124-add-kpi-statistics.d.ts +5 -0
  110. package/dist-server/migrations/1752192090124-add-kpi-statistics.js +710 -0
  111. package/dist-server/migrations/1752192090124-add-kpi-statistics.js.map +1 -0
  112. package/dist-server/migrations/1752192090128-seed-kpi-org-scope.d.ts +6 -0
  113. package/dist-server/migrations/1752192090128-seed-kpi-org-scope.js +111 -0
  114. package/dist-server/migrations/1752192090128-seed-kpi-org-scope.js.map +1 -0
  115. package/dist-server/migrations/1752192090129-seed-kpi-values.d.ts +6 -0
  116. package/dist-server/migrations/1752192090129-seed-kpi-values.js +187 -0
  117. package/dist-server/migrations/1752192090129-seed-kpi-values.js.map +1 -0
  118. package/dist-server/migrations/grade-data/x11-performance-table.json +962 -0
  119. package/dist-server/migrations/grade-data/x12-performance-table.json +611 -0
  120. package/dist-server/migrations/grade-data/x14-performance-table.json +42 -0
  121. package/dist-server/migrations/grade-data/x21-performance-table.json +889 -0
  122. package/dist-server/migrations/grade-data/x22-performance-table.json +1064 -0
  123. package/dist-server/migrations/grade-data/x23-performance-table.json +42 -0
  124. package/dist-server/migrations/grade-data/x31-performance-table.json +644 -0
  125. package/dist-server/migrations/grade-data/x32-performance-table.json +993 -0
  126. package/dist-server/migrations/grade-data/x33-performance-table.json +195 -0
  127. package/dist-server/migrations/grade-data/x34-performance-table.json +12 -0
  128. package/dist-server/migrations/grade-data/x35-performance-table.json +42 -0
  129. package/dist-server/migrations/grade-data/x41-performance-table.json +825 -0
  130. package/dist-server/migrations/grade-data/x42-performance-table.json +786 -0
  131. package/dist-server/migrations/grade-data/x43-performance-table.json +12 -0
  132. package/dist-server/migrations/grade-data/x44-performance-table.json +42 -0
  133. package/dist-server/migrations/grade-data/x51-performance-table.json +924 -0
  134. package/dist-server/migrations/grade-data/x52-performance-table.json +42 -0
  135. package/dist-server/migrations/grade-data/x61-performance-table.json +261 -0
  136. package/dist-server/migrations/grade-data/x62-performance-table.json +42 -0
  137. package/dist-server/migrations/seed-data/kpi-metrics-seed.json +454 -0
  138. package/dist-server/migrations/seed-data/kpi-org-scope-seed.json +1676 -0
  139. package/dist-server/migrations/seed-data/kpi-values-seed.json +402 -0
  140. package/dist-server/migrations/seed-data/kpis-seed.json +488 -0
  141. package/dist-server/service/index.d.ts +3 -7
  142. package/dist-server/service/index.js +5 -12
  143. package/dist-server/service/index.js.map +1 -1
  144. package/dist-server/service/kpi/aggregate-kpi.js +30 -13
  145. package/dist-server/service/kpi/aggregate-kpi.js.map +1 -1
  146. package/dist-server/service/kpi/kpi-formula.service.d.ts +15 -0
  147. package/dist-server/service/kpi/kpi-formula.service.js +90 -0
  148. package/dist-server/service/kpi/kpi-formula.service.js.map +1 -1
  149. package/dist-server/service/kpi/kpi-history.d.ts +0 -3
  150. package/dist-server/service/kpi/kpi-history.js +0 -10
  151. package/dist-server/service/kpi/kpi-history.js.map +1 -1
  152. package/dist-server/service/kpi/kpi-mutation.d.ts +1 -1
  153. package/dist-server/service/kpi/kpi-mutation.js +57 -20
  154. package/dist-server/service/kpi/kpi-mutation.js.map +1 -1
  155. package/dist-server/service/kpi/kpi-query.d.ts +7 -3
  156. package/dist-server/service/kpi/kpi-query.js +126 -10
  157. package/dist-server/service/kpi/kpi-query.js.map +1 -1
  158. package/dist-server/service/kpi/kpi-type.d.ts +4 -2
  159. package/dist-server/service/kpi/kpi-type.js +12 -4
  160. package/dist-server/service/kpi/kpi-type.js.map +1 -1
  161. package/dist-server/service/kpi/kpi.d.ts +4 -3
  162. package/dist-server/service/kpi/kpi.js +20 -8
  163. package/dist-server/service/kpi/kpi.js.map +1 -1
  164. package/dist-server/service/kpi-metric/aggregate-kpi-metric.js +46 -11
  165. package/dist-server/service/kpi-metric/aggregate-kpi-metric.js.map +1 -1
  166. package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.d.ts +1 -1
  167. package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js +6 -6
  168. package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js.map +1 -1
  169. package/dist-server/service/kpi-metric-value/kpi-metric-value-type.d.ts +2 -2
  170. package/dist-server/service/kpi-metric-value/kpi-metric-value-type.js +4 -4
  171. package/dist-server/service/kpi-metric-value/kpi-metric-value-type.js.map +1 -1
  172. package/dist-server/service/kpi-metric-value/kpi-metric-value.d.ts +1 -1
  173. package/dist-server/service/kpi-metric-value/kpi-metric-value.js +3 -3
  174. package/dist-server/service/kpi-metric-value/kpi-metric-value.js.map +1 -1
  175. package/dist-server/service/kpi-org-scope/index.d.ts +9 -0
  176. package/dist-server/service/kpi-org-scope/index.js +14 -0
  177. package/dist-server/service/kpi-org-scope/index.js.map +1 -0
  178. package/dist-server/service/kpi-org-scope/kpi-org-scope-mutation.d.ts +8 -0
  179. package/dist-server/service/kpi-org-scope/kpi-org-scope-mutation.js +170 -0
  180. package/dist-server/service/kpi-org-scope/kpi-org-scope-mutation.js.map +1 -0
  181. package/dist-server/service/kpi-org-scope/kpi-org-scope-query.d.ts +14 -0
  182. package/dist-server/service/kpi-org-scope/kpi-org-scope-query.js +152 -0
  183. package/dist-server/service/kpi-org-scope/kpi-org-scope-query.js.map +1 -0
  184. package/dist-server/service/kpi-org-scope/kpi-org-scope-type.d.ts +26 -0
  185. package/dist-server/service/kpi-org-scope/kpi-org-scope-type.js +101 -0
  186. package/dist-server/service/kpi-org-scope/kpi-org-scope-type.js.map +1 -0
  187. package/dist-server/service/kpi-org-scope/kpi-org-scope.d.ts +26 -0
  188. package/dist-server/service/kpi-org-scope/kpi-org-scope.js +135 -0
  189. package/dist-server/service/kpi-org-scope/kpi-org-scope.js.map +1 -0
  190. package/dist-server/service/kpi-statistic/kpi-statistic.d.ts +1 -0
  191. package/dist-server/service/kpi-statistic/kpi-statistic.js +11 -0
  192. package/dist-server/service/kpi-statistic/kpi-statistic.js.map +1 -1
  193. package/dist-server/service/kpi-value/kpi-value-mutation.js +71 -7
  194. package/dist-server/service/kpi-value/kpi-value-mutation.js.map +1 -1
  195. package/dist-server/service/kpi-value/kpi-value-type.d.ts +4 -2
  196. package/dist-server/service/kpi-value/kpi-value-type.js +12 -4
  197. package/dist-server/service/kpi-value/kpi-value-type.js.map +1 -1
  198. package/dist-server/service/kpi-value/kpi-value.d.ts +3 -1
  199. package/dist-server/service/kpi-value/kpi-value.js +11 -5
  200. package/dist-server/service/kpi-value/kpi-value.js.map +1 -1
  201. package/dist-server/service/utils/value-date-util.d.ts +1 -0
  202. package/dist-server/service/utils/value-date-util.js +41 -0
  203. package/dist-server/service/utils/value-date-util.js.map +1 -1
  204. package/dist-server/tsconfig.json +10 -0
  205. package/dist-server/tsconfig.tsbuildinfo +1 -1
  206. package/package.json +7 -6
  207. package/server/@types/index.d.ts +11 -0
  208. package/server/controllers/kpi-metric-value-provider.ts +5 -5
  209. package/server/controllers/kpi-value-provider.ts +4 -4
  210. package/server/migrations/1752190849680-seed-kpi-metrics.ts +124 -0
  211. package/server/migrations/1752190849681-seed-kpi.ts +356 -0
  212. package/server/migrations/1752192090123-add-grades-to-kpi.ts +67 -0
  213. package/server/migrations/1752192090124-add-kpi-statistics.ts +719 -0
  214. package/server/migrations/1752192090128-seed-kpi-org-scope.ts +132 -0
  215. package/server/migrations/1752192090129-seed-kpi-values.ts +207 -0
  216. package/server/migrations/grade-data/x11-performance-table.json +962 -0
  217. package/server/migrations/grade-data/x12-performance-table.json +611 -0
  218. package/server/migrations/grade-data/x14-performance-table.json +42 -0
  219. package/server/migrations/grade-data/x21-performance-table.json +889 -0
  220. package/server/migrations/grade-data/x22-performance-table.json +1064 -0
  221. package/server/migrations/grade-data/x23-performance-table.json +42 -0
  222. package/server/migrations/grade-data/x31-performance-table.json +644 -0
  223. package/server/migrations/grade-data/x32-performance-table.json +993 -0
  224. package/server/migrations/grade-data/x33-performance-table.json +195 -0
  225. package/server/migrations/grade-data/x34-performance-table.json +12 -0
  226. package/server/migrations/grade-data/x35-performance-table.json +42 -0
  227. package/server/migrations/grade-data/x41-performance-table.json +825 -0
  228. package/server/migrations/grade-data/x42-performance-table.json +786 -0
  229. package/server/migrations/grade-data/x43-performance-table.json +12 -0
  230. package/server/migrations/grade-data/x44-performance-table.json +42 -0
  231. package/server/migrations/grade-data/x51-performance-table.json +924 -0
  232. package/server/migrations/grade-data/x52-performance-table.json +42 -0
  233. package/server/migrations/grade-data/x61-performance-table.json +261 -0
  234. package/server/migrations/grade-data/x62-performance-table.json +42 -0
  235. package/server/migrations/seed-data/kpi-metrics-seed.json +454 -0
  236. package/server/migrations/seed-data/kpi-org-scope-seed.json +1676 -0
  237. package/server/migrations/seed-data/kpi-values-seed.json +402 -0
  238. package/server/migrations/seed-data/kpis-seed.json +488 -0
  239. package/server/service/index.ts +5 -12
  240. package/server/service/kpi/aggregate-kpi.ts +31 -13
  241. package/server/service/kpi/kpi-formula.service.ts +101 -0
  242. package/server/service/kpi/kpi-history.ts +0 -8
  243. package/server/service/kpi/kpi-mutation.ts +59 -19
  244. package/server/service/kpi/kpi-query.ts +118 -8
  245. package/server/service/kpi/kpi-type.ts +10 -4
  246. package/server/service/kpi/kpi.ts +17 -7
  247. package/server/service/kpi-metric/aggregate-kpi-metric.ts +55 -11
  248. package/server/service/kpi-metric-value/kpi-metric-value-mutation.ts +6 -6
  249. package/server/service/kpi-metric-value/kpi-metric-value-type.ts +4 -4
  250. package/server/service/kpi-metric-value/kpi-metric-value.ts +3 -3
  251. package/server/service/kpi-org-scope/index.ts +11 -0
  252. package/server/service/kpi-org-scope/kpi-org-scope-mutation.ts +173 -0
  253. package/server/service/kpi-org-scope/kpi-org-scope-query.ts +127 -0
  254. package/server/service/kpi-org-scope/kpi-org-scope-type.ts +68 -0
  255. package/server/service/kpi-org-scope/kpi-org-scope.ts +123 -0
  256. package/server/service/kpi-statistic/kpi-statistic.ts +10 -0
  257. package/server/service/kpi-value/kpi-value-mutation.ts +73 -7
  258. package/server/service/kpi-value/kpi-value-type.ts +10 -4
  259. package/server/service/kpi-value/kpi-value.ts +10 -5
  260. package/server/service/utils/value-date-util.ts +47 -0
  261. package/server/types/global.d.ts +8 -0
  262. package/things-factory.config.js +1 -0
  263. package/translations/en.json +15 -3
  264. package/translations/ja.json +13 -3
  265. package/translations/ko.json +15 -3
  266. package/translations/ms.json +13 -3
  267. package/translations/zh.json +13 -3
  268. package/client/pages/kpi-category/kpi-category-importer.ts +0 -90
  269. package/client/pages/kpi-category/kpi-category-list-page.ts +0 -537
  270. package/client/pages/kpi-category/kpi-category-value-calculator.ts +0 -233
  271. package/client/pages/kpi-category-value/kpi-category-value-list-page.ts +0 -404
  272. package/dist-client/pages/kpi-category/kpi-category-importer.d.ts +0 -23
  273. package/dist-client/pages/kpi-category/kpi-category-importer.js +0 -92
  274. package/dist-client/pages/kpi-category/kpi-category-importer.js.map +0 -1
  275. package/dist-client/pages/kpi-category/kpi-category-list-page.d.ts +0 -74
  276. package/dist-client/pages/kpi-category/kpi-category-list-page.js +0 -517
  277. package/dist-client/pages/kpi-category/kpi-category-list-page.js.map +0 -1
  278. package/dist-client/pages/kpi-category/kpi-category-value-calculator.d.ts +0 -13
  279. package/dist-client/pages/kpi-category/kpi-category-value-calculator.js +0 -256
  280. package/dist-client/pages/kpi-category/kpi-category-value-calculator.js.map +0 -1
  281. package/dist-client/pages/kpi-category-value/kpi-category-value-list-page.d.ts +0 -63
  282. package/dist-client/pages/kpi-category-value/kpi-category-value-list-page.js +0 -393
  283. package/dist-client/pages/kpi-category-value/kpi-category-value-list-page.js.map +0 -1
  284. package/dist-server/service/kpi-category/index.d.ts +0 -6
  285. package/dist-server/service/kpi-category/index.js +0 -10
  286. package/dist-server/service/kpi-category/index.js.map +0 -1
  287. package/dist-server/service/kpi-category/kpi-category-mutation.d.ts +0 -9
  288. package/dist-server/service/kpi-category/kpi-category-mutation.js +0 -221
  289. package/dist-server/service/kpi-category/kpi-category-mutation.js.map +0 -1
  290. package/dist-server/service/kpi-category/kpi-category-query.d.ts +0 -18
  291. package/dist-server/service/kpi-category/kpi-category-query.js +0 -115
  292. package/dist-server/service/kpi-category/kpi-category-query.js.map +0 -1
  293. package/dist-server/service/kpi-category/kpi-category-type.d.ts +0 -24
  294. package/dist-server/service/kpi-category/kpi-category-type.js +0 -100
  295. package/dist-server/service/kpi-category/kpi-category-type.js.map +0 -1
  296. package/dist-server/service/kpi-category/kpi-category.d.ts +0 -22
  297. package/dist-server/service/kpi-category/kpi-category.js +0 -106
  298. package/dist-server/service/kpi-category/kpi-category.js.map +0 -1
  299. package/dist-server/service/kpi-category-value/index.d.ts +0 -6
  300. package/dist-server/service/kpi-category-value/index.js +0 -10
  301. package/dist-server/service/kpi-category-value/index.js.map +0 -1
  302. package/dist-server/service/kpi-category-value/kpi-category-value-mutation.d.ts +0 -8
  303. package/dist-server/service/kpi-category-value/kpi-category-value-mutation.js +0 -102
  304. package/dist-server/service/kpi-category-value/kpi-category-value-mutation.js.map +0 -1
  305. package/dist-server/service/kpi-category-value/kpi-category-value-query.d.ts +0 -13
  306. package/dist-server/service/kpi-category-value/kpi-category-value-query.js +0 -91
  307. package/dist-server/service/kpi-category-value/kpi-category-value-query.js.map +0 -1
  308. package/dist-server/service/kpi-category-value/kpi-category-value-type.d.ts +0 -19
  309. package/dist-server/service/kpi-category-value/kpi-category-value-type.js +0 -73
  310. package/dist-server/service/kpi-category-value/kpi-category-value-type.js.map +0 -1
  311. package/dist-server/service/kpi-category-value/kpi-category-value.d.ts +0 -19
  312. package/dist-server/service/kpi-category-value/kpi-category-value.js +0 -91
  313. package/dist-server/service/kpi-category-value/kpi-category-value.js.map +0 -1
  314. package/helps/kpi/kpi-category.md +0 -160
  315. package/server/service/kpi-category/index.ts +0 -7
  316. package/server/service/kpi-category/kpi-category-mutation.ts +0 -217
  317. package/server/service/kpi-category/kpi-category-query.ts +0 -87
  318. package/server/service/kpi-category/kpi-category-type.ts +0 -73
  319. package/server/service/kpi-category/kpi-category.ts +0 -95
  320. package/server/service/kpi-category-value/index.ts +0 -7
  321. package/server/service/kpi-category-value/kpi-category-value-mutation.ts +0 -88
  322. package/server/service/kpi-category-value/kpi-category-value-query.ts +0 -62
  323. package/server/service/kpi-category-value/kpi-category-value-type.ts +0 -48
  324. package/server/service/kpi-category-value/kpi-category-value.ts +0 -79
@@ -0,0 +1,488 @@
1
+ [
2
+ {
3
+ "name": "Z. 전체스코어",
4
+ "description": "전체 스코어",
5
+ "formula": null,
6
+ "active": true,
7
+ "state": "RELEASE",
8
+ "viz_type": null,
9
+ "viz_meta": null,
10
+ "schedule": null,
11
+ "schedule_id": null,
12
+ "timezone": null,
13
+ "grades": null,
14
+ "period_type": "DAY",
15
+ "weight": 1.0,
16
+ "score_formula": null,
17
+ "is_leaf": false,
18
+ "parent_name": null
19
+ },
20
+ {
21
+ "name": "Y1. 일정성과",
22
+ "description": "프로젝트 일정 준수 및 일정 이탈 수준 평가",
23
+ "formula": null,
24
+ "active": true,
25
+ "state": "RELEASE",
26
+ "viz_type": null,
27
+ "viz_meta": null,
28
+ "schedule": null,
29
+ "schedule_id": null,
30
+ "timezone": null,
31
+ "grades": null,
32
+ "period_type": "DAY",
33
+ "weight": 1.0,
34
+ "score_formula": null,
35
+ "is_leaf": false,
36
+ "parent_name": "Z. 전체스코어"
37
+ },
38
+ {
39
+ "name": "Y2. 비용성과",
40
+ "description": "프로젝트 비용 집행 및 비용성과 수준 평가",
41
+ "formula": null,
42
+ "active": true,
43
+ "state": "RELEASE",
44
+ "viz_type": null,
45
+ "viz_meta": null,
46
+ "schedule": null,
47
+ "schedule_id": null,
48
+ "timezone": null,
49
+ "grades": null,
50
+ "period_type": "DAY",
51
+ "weight": 1.0,
52
+ "score_formula": null,
53
+ "is_leaf": false,
54
+ "parent_name": "Z. 전체스코어"
55
+ },
56
+ {
57
+ "name": "Y3. 품질성과",
58
+ "description": "품질 불합격률, 품질성과 수준 등 품질 관련 성과 측정",
59
+ "formula": null,
60
+ "active": true,
61
+ "state": "RELEASE",
62
+ "viz_type": null,
63
+ "viz_meta": null,
64
+ "schedule": null,
65
+ "schedule_id": null,
66
+ "timezone": null,
67
+ "grades": null,
68
+ "period_type": "DAY",
69
+ "weight": 1.0,
70
+ "score_formula": null,
71
+ "is_leaf": false,
72
+ "parent_name": "Z. 전체스코어"
73
+ },
74
+ {
75
+ "name": "Y4. 안전성과",
76
+ "description": "재해율, SL-PA 등 안전 관련 성과 평가",
77
+ "formula": null,
78
+ "active": true,
79
+ "state": "RELEASE",
80
+ "viz_type": null,
81
+ "viz_meta": null,
82
+ "schedule": null,
83
+ "schedule_id": null,
84
+ "timezone": null,
85
+ "grades": null,
86
+ "period_type": "DAY",
87
+ "weight": 1.0,
88
+ "score_formula": null,
89
+ "is_leaf": false,
90
+ "parent_name": "Z. 전체스코어"
91
+ },
92
+ {
93
+ "name": "Y5. 환경성과",
94
+ "description": "건설폐기물 등 환경 관련 성과 평가",
95
+ "formula": null,
96
+ "active": true,
97
+ "state": "RELEASE",
98
+ "viz_type": null,
99
+ "viz_meta": null,
100
+ "schedule": null,
101
+ "schedule_id": null,
102
+ "timezone": null,
103
+ "grades": null,
104
+ "period_type": "DAY",
105
+ "weight": 1.0,
106
+ "score_formula": null,
107
+ "is_leaf": false,
108
+ "parent_name": "Z. 전체스코어"
109
+ },
110
+ {
111
+ "name": "Y6. 생산성성과",
112
+ "description": "투입인력 생산성 등 생산성 관련 성과 평가",
113
+ "formula": null,
114
+ "active": true,
115
+ "state": "RELEASE",
116
+ "viz_type": null,
117
+ "viz_meta": null,
118
+ "schedule": null,
119
+ "schedule_id": null,
120
+ "timezone": null,
121
+ "grades": null,
122
+ "period_type": "DAY",
123
+ "weight": 1.0,
124
+ "score_formula": null,
125
+ "is_leaf": false,
126
+ "parent_name": "Z. 전체스코어"
127
+ },
128
+ {
129
+ "name": "X11. 연면적 대비 공사기간",
130
+ "description": "연면적 대비 공사기간 평가",
131
+ "formula": "[실제공사기간] / [연면적]",
132
+ "active": true,
133
+ "state": "DRAFT",
134
+ "viz_type": null,
135
+ "viz_meta": null,
136
+ "schedule": null,
137
+ "schedule_id": null,
138
+ "timezone": null,
139
+ "grades": null,
140
+ "period_type": "DAY",
141
+ "weight": 1.0,
142
+ "score_formula": null,
143
+ "is_leaf": true,
144
+ "parent_name": "Y1. 일정성과"
145
+ },
146
+ {
147
+ "name": "X12. 설계변경에 따른 공기 증감률",
148
+ "description": "설계변경에 따른 공기 증감률 평가",
149
+ "formula": "([실제공사기간] - [계획공사기간]) / [계획공사기간]",
150
+ "active": true,
151
+ "state": "DRAFT",
152
+ "viz_type": null,
153
+ "viz_meta": null,
154
+ "schedule": null,
155
+ "schedule_id": null,
156
+ "timezone": null,
157
+ "grades": "[{\"name\":\"1\",\"minValue\":0,\"maxValue\":5,\"score\":1,\"description\":\"샘플값\"}]",
158
+ "period_type": "DAY",
159
+ "weight": 1.0,
160
+ "score_formula": null,
161
+ "is_leaf": true,
162
+ "parent_name": "Y1. 일정성과"
163
+ },
164
+ {
165
+ "name": "X13. 일정 이탈 수준",
166
+ "description": "프로젝트 일정 이탈 수준 평가",
167
+ "formula": "[일정 이탈 수준]",
168
+ "active": true,
169
+ "state": "DRAFT",
170
+ "viz_type": null,
171
+ "viz_meta": null,
172
+ "schedule": null,
173
+ "schedule_id": null,
174
+ "timezone": null,
175
+ "grades": null,
176
+ "period_type": "DAY",
177
+ "weight": 1.0,
178
+ "score_formula": null,
179
+ "is_leaf": true,
180
+ "parent_name": "Y1. 일정성과"
181
+ },
182
+ {
183
+ "name": "X14. 일정성과 수준 평가",
184
+ "description": "일정성과 종합 평가",
185
+ "formula": "[일정성과 수준 평가]",
186
+ "active": true,
187
+ "state": "DRAFT",
188
+ "viz_type": null,
189
+ "viz_meta": null,
190
+ "schedule": null,
191
+ "schedule_id": null,
192
+ "timezone": null,
193
+ "grades": null,
194
+ "period_type": "DAY",
195
+ "weight": 1.0,
196
+ "score_formula": null,
197
+ "is_leaf": true,
198
+ "parent_name": "Y1. 일정성과"
199
+ },
200
+ {
201
+ "name": "X21. 연면적 대비 공사비",
202
+ "description": "연면적 대비 공사비 평가",
203
+ "formula": "[실제공사비] / [연면적]",
204
+ "active": true,
205
+ "state": "DRAFT",
206
+ "viz_type": null,
207
+ "viz_meta": null,
208
+ "schedule": null,
209
+ "schedule_id": null,
210
+ "timezone": null,
211
+ "grades": null,
212
+ "period_type": "DAY",
213
+ "weight": 1.0,
214
+ "score_formula": null,
215
+ "is_leaf": true,
216
+ "parent_name": "Y2. 비용성과"
217
+ },
218
+ {
219
+ "name": "X22. 설계변경에 따른 공사비 증감률",
220
+ "description": "설계변경에 따른 공사비 증감률 평가",
221
+ "formula": "([실제공사비]-[계획공사비]) / [계획공사비]",
222
+ "active": true,
223
+ "state": "DRAFT",
224
+ "viz_type": null,
225
+ "viz_meta": null,
226
+ "schedule": null,
227
+ "schedule_id": null,
228
+ "timezone": null,
229
+ "grades": null,
230
+ "period_type": "DAY",
231
+ "weight": 1.0,
232
+ "score_formula": null,
233
+ "is_leaf": true,
234
+ "parent_name": "Y2. 비용성과"
235
+ },
236
+ {
237
+ "name": "X23. 비용성과 수준 평가",
238
+ "description": "비용성과 종합 평가",
239
+ "formula": "[비용성과 수준 평가]",
240
+ "active": true,
241
+ "state": "DRAFT",
242
+ "viz_type": null,
243
+ "viz_meta": null,
244
+ "schedule": null,
245
+ "schedule_id": null,
246
+ "timezone": null,
247
+ "grades": null,
248
+ "period_type": "DAY",
249
+ "weight": 1.0,
250
+ "score_formula": null,
251
+ "is_leaf": true,
252
+ "parent_name": "Y2. 비용성과"
253
+ },
254
+ {
255
+ "name": "X31. 품질시험 불합격률",
256
+ "description": "품질시험 불합격률 평가",
257
+ "formula": "[품질시험 불합격 건수] / [연면적]",
258
+ "active": true,
259
+ "state": "DRAFT",
260
+ "viz_type": null,
261
+ "viz_meta": null,
262
+ "schedule": null,
263
+ "schedule_id": null,
264
+ "timezone": null,
265
+ "grades": null,
266
+ "period_type": "DAY",
267
+ "weight": 1.0,
268
+ "score_formula": null,
269
+ "is_leaf": true,
270
+ "parent_name": "Y3. 품질성과"
271
+ },
272
+ {
273
+ "name": "X32. 검수자재 불합격률",
274
+ "description": "검수자재 불합격률 평가",
275
+ "formula": "[검수자재 불합격 건수] / [연면적]",
276
+ "active": true,
277
+ "state": "DRAFT",
278
+ "viz_type": null,
279
+ "viz_meta": null,
280
+ "schedule": null,
281
+ "schedule_id": null,
282
+ "timezone": null,
283
+ "grades": null,
284
+ "period_type": "DAY",
285
+ "weight": 1.0,
286
+ "score_formula": "POW([value], 1)",
287
+ "is_leaf": true,
288
+ "parent_name": "Y3. 품질성과"
289
+ },
290
+ {
291
+ "name": "X33. 검측 불합격률",
292
+ "description": "검측 불합격률 평가",
293
+ "formula": "[품질검측 불합격 건수] / [연면적]",
294
+ "active": true,
295
+ "state": "DRAFT",
296
+ "viz_type": null,
297
+ "viz_meta": null,
298
+ "schedule": null,
299
+ "schedule_id": null,
300
+ "timezone": null,
301
+ "grades": null,
302
+ "period_type": "DAY",
303
+ "weight": 1.0,
304
+ "score_formula": null,
305
+ "is_leaf": true,
306
+ "parent_name": "Y3. 품질성과"
307
+ },
308
+ {
309
+ "name": "X34. 품질 SL-PA 결과값",
310
+ "description": "품질 SL-PA 결과",
311
+ "formula": "[SL-PA 품질평가]",
312
+ "active": true,
313
+ "state": "DRAFT",
314
+ "viz_type": null,
315
+ "viz_meta": null,
316
+ "schedule": null,
317
+ "schedule_id": null,
318
+ "timezone": null,
319
+ "grades": null,
320
+ "period_type": "DAY",
321
+ "weight": 1.0,
322
+ "score_formula": "[value]",
323
+ "is_leaf": true,
324
+ "parent_name": "Y3. 품질성과"
325
+ },
326
+ {
327
+ "name": "X35. 품질성과 수준 평가",
328
+ "description": "품질성과 종합 평가",
329
+ "formula": "[품질성과 수준 평가]",
330
+ "active": true,
331
+ "state": "DRAFT",
332
+ "viz_type": null,
333
+ "viz_meta": null,
334
+ "schedule": null,
335
+ "schedule_id": null,
336
+ "timezone": null,
337
+ "grades": null,
338
+ "period_type": "DAY",
339
+ "weight": 1.0,
340
+ "score_formula": "INTEGRATE([value], 1, 2, 3)",
341
+ "is_leaf": true,
342
+ "parent_name": "Y3. 품질성과"
343
+ },
344
+ {
345
+ "name": "X41. 재해율",
346
+ "description": "재해율 평가",
347
+ "formula": "[재해 건수] / [연간 근로자 수] * 100",
348
+ "active": true,
349
+ "state": "DRAFT",
350
+ "viz_type": null,
351
+ "viz_meta": null,
352
+ "schedule": null,
353
+ "schedule_id": null,
354
+ "timezone": null,
355
+ "grades": null,
356
+ "period_type": "DAY",
357
+ "weight": 1.0,
358
+ "score_formula": null,
359
+ "is_leaf": true,
360
+ "parent_name": "Y4. 안전성과"
361
+ },
362
+ {
363
+ "name": "X42. 재해강도율",
364
+ "description": "재해강도율 평가",
365
+ "formula": "[노동손실일수] / ( [총 근로자수] * [1인당 연간 근로 시간] ) * 1000",
366
+ "active": true,
367
+ "state": "DRAFT",
368
+ "viz_type": null,
369
+ "viz_meta": null,
370
+ "schedule": null,
371
+ "schedule_id": null,
372
+ "timezone": null,
373
+ "grades": null,
374
+ "period_type": "DAY",
375
+ "weight": 1.0,
376
+ "score_formula": null,
377
+ "is_leaf": true,
378
+ "parent_name": "Y4. 안전성과"
379
+ },
380
+ {
381
+ "name": "X43. 안전 SL-PA 결과값",
382
+ "description": "안전 SL-PA 결과",
383
+ "formula": "[SL-PA 안전 평가]",
384
+ "active": true,
385
+ "state": "DRAFT",
386
+ "viz_type": null,
387
+ "viz_meta": null,
388
+ "schedule": null,
389
+ "schedule_id": null,
390
+ "timezone": null,
391
+ "grades": null,
392
+ "period_type": "DAY",
393
+ "weight": 1.0,
394
+ "score_formula": null,
395
+ "is_leaf": true,
396
+ "parent_name": "Y4. 안전성과"
397
+ },
398
+ {
399
+ "name": "X44. 안전성과 수준 평가",
400
+ "description": "안전성과 종합 평가",
401
+ "formula": "[안전성과 수준 평가]",
402
+ "active": true,
403
+ "state": "DRAFT",
404
+ "viz_type": null,
405
+ "viz_meta": null,
406
+ "schedule": null,
407
+ "schedule_id": null,
408
+ "timezone": null,
409
+ "grades": null,
410
+ "period_type": "DAY",
411
+ "weight": 1.0,
412
+ "score_formula": null,
413
+ "is_leaf": true,
414
+ "parent_name": "Y4. 안전성과"
415
+ },
416
+ {
417
+ "name": "X51. 건설폐기물 발생량",
418
+ "description": "건설폐기물 발생량 평가",
419
+ "formula": "[총 건설 폐기물 발생량] / [연면적]",
420
+ "active": true,
421
+ "state": "DRAFT",
422
+ "viz_type": null,
423
+ "viz_meta": null,
424
+ "schedule": null,
425
+ "schedule_id": null,
426
+ "timezone": null,
427
+ "grades": null,
428
+ "period_type": "DAY",
429
+ "weight": 1.0,
430
+ "score_formula": null,
431
+ "is_leaf": true,
432
+ "parent_name": "Y5. 환경성과"
433
+ },
434
+ {
435
+ "name": "X52. 환경성과 수준 평가",
436
+ "description": "환경성과 종합 평가",
437
+ "formula": "[환경성과 수준 평가]",
438
+ "active": true,
439
+ "state": "DRAFT",
440
+ "viz_type": null,
441
+ "viz_meta": null,
442
+ "schedule": null,
443
+ "schedule_id": null,
444
+ "timezone": null,
445
+ "grades": null,
446
+ "period_type": "DAY",
447
+ "weight": 1.0,
448
+ "score_formula": null,
449
+ "is_leaf": true,
450
+ "parent_name": "Y5. 환경성과"
451
+ },
452
+ {
453
+ "name": "X61. 투입인력 생산성",
454
+ "description": "투입인력 생산성 평가",
455
+ "formula": "[투입인력] / [연면적]",
456
+ "active": true,
457
+ "state": "DRAFT",
458
+ "viz_type": null,
459
+ "viz_meta": null,
460
+ "schedule": null,
461
+ "schedule_id": null,
462
+ "timezone": null,
463
+ "grades": null,
464
+ "period_type": "DAY",
465
+ "weight": 1.0,
466
+ "score_formula": null,
467
+ "is_leaf": true,
468
+ "parent_name": "Y6. 생산성성과"
469
+ },
470
+ {
471
+ "name": "X62. 생산성성과 수준 평가",
472
+ "description": "생산성과 종합 평가",
473
+ "formula": "[생산성성과 수준 평가]",
474
+ "active": true,
475
+ "state": "DRAFT",
476
+ "viz_type": null,
477
+ "viz_meta": null,
478
+ "schedule": null,
479
+ "schedule_id": null,
480
+ "timezone": null,
481
+ "grades": null,
482
+ "period_type": "DAY",
483
+ "weight": 1.0,
484
+ "score_formula": null,
485
+ "is_leaf": true,
486
+ "parent_name": "Y6. 생산성성과"
487
+ }
488
+ ]
@@ -2,17 +2,13 @@
2
2
  export * from './kpi-statistic/kpi-statistic'
3
3
  export * from './kpi/kpi'
4
4
  export * from './kpi/kpi-type'
5
- export * from './kpi-category/kpi-category'
6
- export * from './kpi-category/kpi-category-type'
7
- export * from './kpi-category-value/kpi-category-value'
8
- export * from './kpi-category-value/kpi-category-value-type'
9
5
  export * from './kpi-value/kpi-value'
10
6
  export * from './kpi-value/kpi-value-type'
11
7
  export * from './kpi-metric/kpi-metric'
12
8
  export * from './kpi-metric/kpi-metric-type'
13
9
  export * from './kpi-metric-value/kpi-metric-value'
14
10
  export * from './kpi-metric-value/kpi-metric-value-type'
15
- export * from './kpi-alert'
11
+ export * from './kpi-org-scope'
16
12
 
17
13
  /* IMPORT ENTITIES AND RESOLVERS */
18
14
  import {
@@ -21,22 +17,20 @@ import {
21
17
  subscribers as KpiStatisticSubscribers
22
18
  } from './kpi-statistic'
23
19
  import { entities as KpiEntities, resolvers as KpiResolvers } from './kpi'
24
- import { entities as KpiCategoryEntities, resolvers as KpiCategoryResolvers } from './kpi-category'
25
- import { entities as KpiCategoryValueEntities, resolvers as KpiCategoryValueResolvers } from './kpi-category-value'
26
20
  import { entities as KpiValueEntities, resolvers as KpiValueResolvers } from './kpi-value'
27
21
  import { entities as KpiMetricEntities, resolvers as KpiMetricResolvers } from './kpi-metric'
28
22
  import { entities as KpiMetricValueEntities, resolvers as KpiMetricValueResolvers } from './kpi-metric-value'
23
+ import { entities as KpiOrgScopeEntities, resolvers as KpiOrgScopeResolvers } from './kpi-org-scope'
29
24
  import { resolvers as KpiAlertResolvers } from './kpi-alert'
30
25
 
31
26
  export const entities = [
32
27
  /* ENTITIES */
33
28
  ...KpiStatisticEntities,
34
29
  ...KpiEntities,
35
- ...KpiCategoryEntities,
36
- ...KpiCategoryValueEntities,
37
30
  ...KpiValueEntities,
38
31
  ...KpiMetricEntities,
39
- ...KpiMetricValueEntities
32
+ ...KpiMetricValueEntities,
33
+ ...KpiOrgScopeEntities
40
34
  ]
41
35
 
42
36
  export const schema = {
@@ -44,11 +38,10 @@ export const schema = {
44
38
  /* RESOLVER CLASSES */
45
39
  ...KpiStatisticResolvers,
46
40
  ...KpiResolvers,
47
- ...KpiCategoryResolvers,
48
- ...KpiCategoryValueResolvers,
49
41
  ...KpiValueResolvers,
50
42
  ...KpiMetricResolvers,
51
43
  ...KpiMetricValueResolvers,
44
+ ...KpiOrgScopeResolvers,
52
45
  ...KpiAlertResolvers
53
46
  ]
54
47
  }
@@ -2,6 +2,7 @@ import { getRepository } from '@things-factory/shell'
2
2
  import { Kpi } from './kpi'
3
3
  import { KpiMetric } from '../kpi-metric/kpi-metric'
4
4
  import { KpiValue, KpiValueInputType } from '../kpi-value/kpi-value'
5
+ import { KpiOrgScope } from '../kpi-org-scope/kpi-org-scope'
5
6
  import { KpiFormulaService } from './kpi-formula.service'
6
7
  import { aggregateKpiMetricValue } from '../kpi-metric/aggregate-kpi-metric'
7
8
  import { KpiValueScoreService } from '../kpi-value/kpi-value-score.service'
@@ -33,34 +34,50 @@ export async function aggregateKpiValue(kpiId: string, domainId: string, context
33
34
  if (!metric) throw new Error(`KPI formula metric '${code}' not found`)
34
35
  codeValueMap[code] = await aggregateKpiMetricValue(metric.id, domainId, context)
35
36
  }
36
- // group/date/period별로 값 매핑(가장 최근 기준, group key 조합)
37
- const groupKey = v => [v.date, v.period, v.group].join('|')
38
- const groupMap: Record<string, any> = {}
37
+ // org/date/period별로 값 매핑(가장 최근 기준, org key 조합)
38
+ const orgKey = v => [v.date, v.period, v.org].join('|')
39
+ const orgMap: Record<string, any> = {}
39
40
  for (const code of metricCodes) {
40
41
  for (const v of codeValueMap[code]) {
41
- const key = groupKey(v)
42
- groupMap[key] = groupMap[key] || { ...v, _values: {} }
43
- groupMap[key]._values[code] = v.value
42
+ const key = orgKey(v)
43
+ orgMap[key] = orgMap[key] || { ...v, _values: {} }
44
+ orgMap[key]._values[code] = v.value
44
45
  }
45
46
  }
46
47
  // formula 계산 (js eval)
47
48
  const savedValues = []
48
- for (const key in groupMap) {
49
- const ctx = groupMap[key]._values
49
+ for (const key in orgMap) {
50
+ const ctx = orgMap[key]._values
50
51
  let value = null
51
52
  try {
52
53
  value = Function(...Object.keys(ctx), `return (${kpi.formula})`)(...Object.values(ctx))
53
54
  } catch (e) {
54
55
  value = null
55
56
  }
56
- const valueDate = groupMap[key].date
57
- const group = groupMap[key].group
57
+ const valueDate = orgMap[key].date
58
+ const org = orgMap[key].org
58
59
  const version = kpi.version || 1
59
60
  if (value == null || isNaN(value)) continue
60
- // upsert(동일 KPI, valueDate, group, version) 기준으로 저장
61
+ // KpiOrgScope 처리 (org 문자열로 찾기 또는 생성)
62
+ const kpiOrgScopeRepo = getRepository(KpiOrgScope, context.state?.tx)
63
+ let kpiOrgScope = await kpiOrgScopeRepo.findOne({
64
+ where: { org: org, domain: { id: domainId } }
65
+ })
66
+ if (!kpiOrgScope) {
67
+ // 새 KpiOrgScope 생성
68
+ kpiOrgScope = await kpiOrgScopeRepo.save({
69
+ entityType: 'AutoAggregate',
70
+ entityId: `auto-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
71
+ entityName: org,
72
+ org: org,
73
+ domain: kpi.domain
74
+ })
75
+ }
76
+
77
+ // upsert(동일 KPI, valueDate, kpiOrgScope, version) 기준으로 저장
61
78
  const repo = getRepository(KpiValue, context.state?.tx)
62
79
  const existing = await repo.findOne({
63
- where: { kpi: { id: kpi.id }, valueDate, group, version, domain: { id: domainId } }
80
+ where: { kpi: { id: kpi.id }, valueDate, kpiOrgScope: { id: kpiOrgScope.id }, version, domain: { id: domainId } }
64
81
  })
65
82
  let entity = existing || repo.create()
66
83
  entity.kpi = kpi
@@ -68,7 +85,8 @@ export async function aggregateKpiValue(kpiId: string, domainId: string, context
68
85
  entity.version = version
69
86
  entity.valueDate = valueDate
70
87
  entity.value = value
71
- entity.group = group
88
+ entity.kpiOrgScope = kpiOrgScope
89
+ entity.kpiOrgScopeId = kpiOrgScope.id
72
90
  entity.inputType = KpiValueInputType.AUTO
73
91
  entity.source = 'AUTO'
74
92
  entity.domain = kpi.domain