@things-factory/kpi 9.0.22 → 9.0.24
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/client/pages/kpi/kpi-list-page.ts +180 -22
- package/client/pages/kpi/kpi-viz-editor.ts +1 -1
- package/client/pages/kpi-category/kpi-category-list-page.ts +76 -3
- package/client/pages/kpi-category/kpi-category-value-calculator.ts +233 -0
- package/client/pages/kpi-category-value/kpi-category-value-list-page.ts +404 -0
- package/client/pages/kpi-metric/kpi-metric-list-page.ts +13 -1
- package/client/pages/kpi-metric-value/kpi-metric-value-editor-page.ts +763 -0
- package/client/pages/kpi-metric-value/kpi-metric-value-list-page.ts +55 -1
- package/client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.ts +3 -13
- package/client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.ts +13 -1
- package/client/pages/kpi-value/kpi-value-editor-page.ts +774 -0
- package/client/pages/kpi-value/kpi-value-list-page.ts +58 -1
- package/client/route.ts +16 -0
- package/dist-client/pages/kpi/kpi-list-page.d.ts +2 -1
- package/dist-client/pages/kpi/kpi-list-page.js +180 -22
- package/dist-client/pages/kpi/kpi-list-page.js.map +1 -1
- package/dist-client/pages/kpi/kpi-viz-editor.d.ts +0 -1
- package/dist-client/pages/kpi/kpi-viz-editor.js +1 -1
- package/dist-client/pages/kpi/kpi-viz-editor.js.map +1 -1
- package/dist-client/pages/kpi-category/kpi-category-list-page.d.ts +3 -0
- package/dist-client/pages/kpi-category/kpi-category-list-page.js +71 -3
- package/dist-client/pages/kpi-category/kpi-category-list-page.js.map +1 -1
- package/dist-client/pages/kpi-category/kpi-category-value-calculator.d.ts +13 -0
- package/dist-client/pages/kpi-category/kpi-category-value-calculator.js +256 -0
- package/dist-client/pages/kpi-category/kpi-category-value-calculator.js.map +1 -0
- package/dist-client/pages/kpi-category-value/kpi-category-value-list-page.d.ts +63 -0
- package/dist-client/pages/kpi-category-value/kpi-category-value-list-page.js +393 -0
- package/dist-client/pages/kpi-category-value/kpi-category-value-list-page.js.map +1 -0
- package/dist-client/pages/kpi-metric/kpi-metric-list-page.js +13 -1
- package/dist-client/pages/kpi-metric/kpi-metric-list-page.js.map +1 -1
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.d.ts +58 -0
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.js +736 -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-list-page.d.ts +5 -1
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js +50 -2
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js.map +1 -1
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.js +3 -13
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.js.map +1 -1
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.js +13 -1
- package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.js.map +1 -1
- package/dist-client/pages/kpi-value/kpi-value-editor-page.d.ts +55 -0
- package/dist-client/pages/kpi-value/kpi-value-editor-page.js +748 -0
- package/dist-client/pages/kpi-value/kpi-value-editor-page.js.map +1 -0
- package/dist-client/pages/kpi-value/kpi-value-list-page.d.ts +10 -2
- package/dist-client/pages/kpi-value/kpi-value-list-page.js +57 -1
- package/dist-client/pages/kpi-value/kpi-value-list-page.js.map +1 -1
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +12 -0
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- 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 +4 -0
- package/dist-server/calculator/index.js +8 -0
- package/dist-server/calculator/index.js.map +1 -0
- package/dist-server/calculator/parser.d.ts +21 -0
- package/dist-server/calculator/parser.js +121 -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/controllers/kpi-metric-value-provider.d.ts +11 -0
- package/dist-server/controllers/kpi-metric-value-provider.js +63 -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 +46 -0
- package/dist-server/controllers/kpi-value-provider.js.map +1 -0
- package/dist-server/service/index.d.ts +4 -2
- package/dist-server/service/index.js +5 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/kpi/aggregate-kpi.js +4 -4
- package/dist-server/service/kpi/aggregate-kpi.js.map +1 -1
- package/dist-server/service/kpi/kpi-grade.types.d.ts +11 -10
- package/dist-server/service/kpi/kpi-grade.types.js.map +1 -1
- package/dist-server/service/kpi/kpi-history.d.ts +2 -2
- package/dist-server/service/kpi/kpi-history.js.map +1 -1
- package/dist-server/service/kpi/kpi-mutation.d.ts +2 -0
- package/dist-server/service/kpi/kpi-mutation.js +126 -4
- package/dist-server/service/kpi/kpi-mutation.js.map +1 -1
- package/dist-server/service/kpi/kpi-type.d.ts +8 -5
- package/dist-server/service/kpi/kpi-type.js +22 -8
- package/dist-server/service/kpi/kpi-type.js.map +1 -1
- package/dist-server/service/kpi/kpi.d.ts +6 -3
- package/dist-server/service/kpi/kpi.js +29 -9
- package/dist-server/service/kpi/kpi.js.map +1 -1
- package/dist-server/service/kpi-category/kpi-category-mutation.d.ts +3 -4
- package/dist-server/service/kpi-category/kpi-category-mutation.js +151 -80
- package/dist-server/service/kpi-category/kpi-category-mutation.js.map +1 -1
- package/dist-server/service/kpi-category/kpi-category-query.d.ts +5 -0
- package/dist-server/service/kpi-category/kpi-category-query.js +19 -1
- package/dist-server/service/kpi-category/kpi-category-query.js.map +1 -1
- package/dist-server/service/kpi-category/kpi-category-type.d.ts +3 -0
- package/dist-server/service/kpi-category/kpi-category-type.js +16 -1
- package/dist-server/service/kpi-category/kpi-category-type.js.map +1 -1
- package/dist-server/service/kpi-category/kpi-category.d.ts +2 -0
- package/dist-server/service/kpi-category/kpi-category.js +10 -1
- package/dist-server/service/kpi-category/kpi-category.js.map +1 -1
- package/dist-server/service/kpi-category-value/index.d.ts +6 -0
- package/dist-server/service/kpi-category-value/index.js +10 -0
- package/dist-server/service/kpi-category-value/index.js.map +1 -0
- package/dist-server/service/kpi-category-value/kpi-category-value-mutation.d.ts +8 -0
- package/dist-server/service/kpi-category-value/kpi-category-value-mutation.js +102 -0
- package/dist-server/service/kpi-category-value/kpi-category-value-mutation.js.map +1 -0
- package/dist-server/service/kpi-category-value/kpi-category-value-query.d.ts +13 -0
- package/dist-server/service/kpi-category-value/kpi-category-value-query.js +91 -0
- package/dist-server/service/kpi-category-value/kpi-category-value-query.js.map +1 -0
- package/dist-server/service/kpi-category-value/kpi-category-value-type.d.ts +19 -0
- package/dist-server/service/kpi-category-value/kpi-category-value-type.js +73 -0
- package/dist-server/service/kpi-category-value/kpi-category-value-type.js.map +1 -0
- package/dist-server/service/kpi-category-value/kpi-category-value.d.ts +19 -0
- package/dist-server/service/kpi-category-value/kpi-category-value.js +91 -0
- package/dist-server/service/kpi-category-value/kpi-category-value.js.map +1 -0
- package/dist-server/service/kpi-metric/kpi-metric-type.d.ts +5 -3
- package/dist-server/service/kpi-metric/kpi-metric-type.js +5 -3
- package/dist-server/service/kpi-metric/kpi-metric-type.js.map +1 -1
- package/dist-server/service/kpi-metric/kpi-metric.d.ts +2 -8
- package/dist-server/service/kpi-metric/kpi-metric.js +3 -14
- package/dist-server/service/kpi-metric/kpi-metric.js.map +1 -1
- package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js +87 -45
- package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js.map +1 -1
- package/dist-server/service/kpi-metric-value/kpi-metric-value.js +3 -2
- package/dist-server/service/kpi-metric-value/kpi-metric-value.js.map +1 -1
- package/dist-server/service/kpi-value/kpi-value-mutation.d.ts +3 -1
- package/dist-server/service/kpi-value/kpi-value-mutation.js +174 -6
- package/dist-server/service/kpi-value/kpi-value-mutation.js.map +1 -1
- package/dist-server/service/kpi-value/kpi-value-query.d.ts +0 -2
- package/dist-server/service/kpi-value/kpi-value-query.js +0 -12
- package/dist-server/service/kpi-value/kpi-value-query.js.map +1 -1
- package/dist-server/service/kpi-value/kpi-value-score.service.d.ts +26 -0
- package/dist-server/service/kpi-value/kpi-value-score.service.js +97 -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 +2 -0
- package/dist-server/service/kpi-value/kpi-value-type.js +14 -0
- package/dist-server/service/kpi-value/kpi-value-type.js.map +1 -1
- package/dist-server/service/kpi-value/kpi-value.d.ts +1 -0
- package/dist-server/service/kpi-value/kpi-value.js +9 -1
- package/dist-server/service/kpi-value/kpi-value.js.map +1 -1
- package/dist-server/service/utils/value-date-util.d.ts +3 -0
- package/dist-server/service/utils/value-date-util.js +76 -0
- package/dist-server/service/utils/value-date-util.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/server/calculator/evaluator.ts +45 -0
- package/server/calculator/functions.ts +67 -0
- package/server/calculator/index.ts +4 -0
- package/server/calculator/parser.ts +128 -0
- package/server/calculator/provider.ts +10 -0
- package/server/controllers/kpi-metric-value-provider.ts +66 -0
- package/server/controllers/kpi-value-provider.ts +51 -0
- package/server/service/index.ts +5 -0
- package/server/service/kpi/aggregate-kpi.ts +4 -4
- package/server/service/kpi/kpi-grade.types.ts +11 -10
- package/server/service/kpi/kpi-history.ts +2 -2
- package/server/service/kpi/kpi-mutation.ts +128 -4
- package/server/service/kpi/kpi-type.ts +21 -9
- package/server/service/kpi/kpi.ts +32 -10
- package/server/service/kpi-category/kpi-category-mutation.ts +155 -82
- package/server/service/kpi-category/kpi-category-query.ts +21 -1
- package/server/service/kpi-category/kpi-category-type.ts +17 -6
- package/server/service/kpi-category/kpi-category.ts +10 -1
- package/server/service/kpi-category-value/index.ts +7 -0
- package/server/service/kpi-category-value/kpi-category-value-mutation.ts +88 -0
- package/server/service/kpi-category-value/kpi-category-value-query.ts +62 -0
- package/server/service/kpi-category-value/kpi-category-value-type.ts +48 -0
- package/server/service/kpi-category-value/kpi-category-value.ts +79 -0
- package/server/service/kpi-metric/kpi-metric-type.ts +7 -5
- package/server/service/kpi-metric/kpi-metric.ts +3 -15
- package/server/service/kpi-metric-value/kpi-metric-value-mutation.ts +95 -47
- package/server/service/kpi-metric-value/kpi-metric-value.ts +4 -2
- package/server/service/kpi-value/kpi-value-mutation.ts +176 -6
- package/server/service/kpi-value/kpi-value-query.ts +2 -8
- package/server/service/kpi-value/kpi-value-score.service.ts +112 -0
- package/server/service/kpi-value/kpi-value-type.ts +12 -0
- package/server/service/kpi-value/kpi-value.ts +8 -1
- package/server/service/utils/value-date-util.ts +72 -0
- package/things-factory.config.js +3 -0
- package/translations/en.json +3 -0
- package/translations/ja.json +3 -0
- package/translations/ko.json +3 -0
- package/translations/ms.json +3 -0
- package/translations/zh.json +3 -0
- package/dist-server/service/kpi-value/kpi-value-grade.service.d.ts +0 -34
- package/dist-server/service/kpi-value/kpi-value-grade.service.js +0 -117
- package/dist-server/service/kpi-value/kpi-value-grade.service.js.map +0 -1
- package/server/service/kpi-value/kpi-value-grade.service.ts +0 -127
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@material/web/icon/icon.js';
|
|
3
|
+
import { css, html, LitElement } from 'lit';
|
|
4
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
5
|
+
import { client } from '@operato/graphql';
|
|
6
|
+
import { notify } from '@operato/layout';
|
|
7
|
+
import gql from 'graphql-tag';
|
|
8
|
+
// KpiPeriodType enum 정의 (서버와 동일하게)
|
|
9
|
+
var KpiPeriodType;
|
|
10
|
+
(function (KpiPeriodType) {
|
|
11
|
+
KpiPeriodType["DAY"] = "DAY";
|
|
12
|
+
KpiPeriodType["WEEK"] = "WEEK";
|
|
13
|
+
KpiPeriodType["MONTH"] = "MONTH";
|
|
14
|
+
KpiPeriodType["QUARTER"] = "QUARTER";
|
|
15
|
+
KpiPeriodType["YEAR"] = "YEAR";
|
|
16
|
+
KpiPeriodType["RANGE"] = "RANGE";
|
|
17
|
+
KpiPeriodType["ALLTIME"] = "ALLTIME";
|
|
18
|
+
})(KpiPeriodType || (KpiPeriodType = {}));
|
|
19
|
+
// periodType에 따른 마지막 일자 계산 함수
|
|
20
|
+
function getLastValueDate(periodType = KpiPeriodType.DAY) {
|
|
21
|
+
const now = new Date();
|
|
22
|
+
switch (periodType) {
|
|
23
|
+
case KpiPeriodType.DAY: {
|
|
24
|
+
const d = new Date(now);
|
|
25
|
+
d.setDate(d.getDate() - 1);
|
|
26
|
+
return d.toISOString().slice(0, 10);
|
|
27
|
+
}
|
|
28
|
+
case KpiPeriodType.MONTH: {
|
|
29
|
+
const d = new Date(now);
|
|
30
|
+
d.setMonth(d.getMonth() - 1);
|
|
31
|
+
return d.toISOString().slice(0, 7);
|
|
32
|
+
}
|
|
33
|
+
case KpiPeriodType.QUARTER: {
|
|
34
|
+
let year = now.getFullYear();
|
|
35
|
+
let quarter = Math.floor(now.getMonth() / 3);
|
|
36
|
+
if (quarter === 0) {
|
|
37
|
+
year -= 1;
|
|
38
|
+
quarter = 4;
|
|
39
|
+
}
|
|
40
|
+
return `${year}-Q${quarter}`;
|
|
41
|
+
}
|
|
42
|
+
case KpiPeriodType.WEEK: {
|
|
43
|
+
const d = new Date(now);
|
|
44
|
+
d.setDate(d.getDate() - 7);
|
|
45
|
+
const year = d.getFullYear();
|
|
46
|
+
const week = getISOWeek(d);
|
|
47
|
+
return `${year}-W${week}`;
|
|
48
|
+
}
|
|
49
|
+
case KpiPeriodType.ALLTIME:
|
|
50
|
+
return 'ALLTIME';
|
|
51
|
+
default: {
|
|
52
|
+
const d = new Date(now);
|
|
53
|
+
d.setDate(d.getDate() - 1);
|
|
54
|
+
return d.toISOString().slice(0, 10);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// ISO 주차 계산 함수
|
|
59
|
+
function getISOWeek(date) {
|
|
60
|
+
const tmp = new Date(date.getTime());
|
|
61
|
+
tmp.setHours(0, 0, 0, 0);
|
|
62
|
+
tmp.setDate(tmp.getDate() + 4 - (tmp.getDay() || 7));
|
|
63
|
+
const yearStart = new Date(tmp.getFullYear(), 0, 1);
|
|
64
|
+
const weekNo = Math.ceil(((tmp.getTime() - yearStart.getTime()) / 86400000 + 1) / 7);
|
|
65
|
+
return weekNo;
|
|
66
|
+
}
|
|
67
|
+
let KpiCategoryValueCalculator = class KpiCategoryValueCalculator extends LitElement {
|
|
68
|
+
constructor() {
|
|
69
|
+
super(...arguments);
|
|
70
|
+
this.categoryId = '';
|
|
71
|
+
this.categoryName = '';
|
|
72
|
+
this.valueDate = getLastValueDate();
|
|
73
|
+
this.group = '';
|
|
74
|
+
this.result = null;
|
|
75
|
+
this.loading = false;
|
|
76
|
+
}
|
|
77
|
+
static { this.styles = [
|
|
78
|
+
css `
|
|
79
|
+
:host {
|
|
80
|
+
display: block;
|
|
81
|
+
padding: 20px;
|
|
82
|
+
min-width: 400px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.container {
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
gap: 10px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.form-group {
|
|
92
|
+
display: flex;
|
|
93
|
+
flex-direction: column;
|
|
94
|
+
margin-bottom: 15px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
label {
|
|
98
|
+
display: block;
|
|
99
|
+
margin-bottom: 5px;
|
|
100
|
+
font-weight: bold;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
input,
|
|
104
|
+
select {
|
|
105
|
+
padding: 8px;
|
|
106
|
+
border: 1px solid #ccc;
|
|
107
|
+
border-radius: 4px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.result {
|
|
111
|
+
margin-top: 20px;
|
|
112
|
+
padding: 15px;
|
|
113
|
+
background-color: #f5f5f5;
|
|
114
|
+
border-radius: 4px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.result-value {
|
|
118
|
+
font-size: 18px;
|
|
119
|
+
font-weight: bold;
|
|
120
|
+
color: #2196f3;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.kpi-values {
|
|
124
|
+
margin-top: 10px;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.kpi-value-item {
|
|
128
|
+
display: flex;
|
|
129
|
+
justify-content: space-between;
|
|
130
|
+
padding: 5px 0;
|
|
131
|
+
border-bottom: 1px solid #eee;
|
|
132
|
+
}
|
|
133
|
+
`
|
|
134
|
+
]; }
|
|
135
|
+
render() {
|
|
136
|
+
return html `
|
|
137
|
+
<div class="container">
|
|
138
|
+
<h3>${this.categoryName} - KPI 값 계산</h3>
|
|
139
|
+
|
|
140
|
+
<div class="form-group">
|
|
141
|
+
<label>계산 기준일</label>
|
|
142
|
+
<input type="date" .value=${this.valueDate} @input=${e => (this.valueDate = e.target.value)} />
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div class="form-group">
|
|
146
|
+
<label>그룹</label>
|
|
147
|
+
<input
|
|
148
|
+
type="text"
|
|
149
|
+
placeholder="그룹명 (선택사항)"
|
|
150
|
+
.value=${this.group}
|
|
151
|
+
@input=${e => (this.group = e.target.value)}
|
|
152
|
+
/>
|
|
153
|
+
</div>
|
|
154
|
+
|
|
155
|
+
<button
|
|
156
|
+
@click=${this.calculateValue}
|
|
157
|
+
?disabled=${this.loading}
|
|
158
|
+
style="width: 100%; padding: 10px; background: #2196f3; color: white; border: none; border-radius: 4px; cursor: pointer;"
|
|
159
|
+
>
|
|
160
|
+
${this.loading ? '계산 중...' : '계산하기'}
|
|
161
|
+
</button>
|
|
162
|
+
|
|
163
|
+
${this.result
|
|
164
|
+
? html `
|
|
165
|
+
<div class="result">
|
|
166
|
+
<div class="result-value">
|
|
167
|
+
계산 결과: ${this.result.value !== null ? this.result.value.toFixed(2) : 'N/A'}
|
|
168
|
+
</div>
|
|
169
|
+
${this.result.kpiValues && this.result.kpiValues.length > 0
|
|
170
|
+
? html `
|
|
171
|
+
<div class="kpi-values">
|
|
172
|
+
<h4>개별 KPI 값:</h4>
|
|
173
|
+
${this.result.kpiValues.map(item => html `
|
|
174
|
+
<div class="kpi-value-item">
|
|
175
|
+
<span>KPI ID: ${item.kpiId}</span>
|
|
176
|
+
<span>${item.value !== null ? item.value.toFixed(2) : 'N/A'}</span>
|
|
177
|
+
</div>
|
|
178
|
+
`)}
|
|
179
|
+
</div>
|
|
180
|
+
`
|
|
181
|
+
: ''}
|
|
182
|
+
</div>
|
|
183
|
+
`
|
|
184
|
+
: ''}
|
|
185
|
+
</div>
|
|
186
|
+
`;
|
|
187
|
+
}
|
|
188
|
+
async calculateValue() {
|
|
189
|
+
if (!this.categoryId)
|
|
190
|
+
return;
|
|
191
|
+
this.loading = true;
|
|
192
|
+
try {
|
|
193
|
+
const response = await client.query({
|
|
194
|
+
query: gql `
|
|
195
|
+
query ($categoryId: String!, $valueDate: String, $group: String) {
|
|
196
|
+
calculateKpiValue(categoryId: $categoryId, valueDate: $valueDate, group: $group) {
|
|
197
|
+
value
|
|
198
|
+
valueDate
|
|
199
|
+
group
|
|
200
|
+
kpiValues {
|
|
201
|
+
kpiId
|
|
202
|
+
value
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
`,
|
|
207
|
+
variables: {
|
|
208
|
+
categoryId: this.categoryId,
|
|
209
|
+
valueDate: this.valueDate || null,
|
|
210
|
+
group: this.group || null
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
if (!response.errors) {
|
|
214
|
+
this.result = response.data.calculateKpiValue;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
console.error('KPI 값 계산 중 오류:', error);
|
|
219
|
+
notify({
|
|
220
|
+
message: 'KPI 값 계산 중 오류가 발생했습니다.'
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
finally {
|
|
224
|
+
this.loading = false;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
__decorate([
|
|
229
|
+
property({ type: String }),
|
|
230
|
+
__metadata("design:type", Object)
|
|
231
|
+
], KpiCategoryValueCalculator.prototype, "categoryId", void 0);
|
|
232
|
+
__decorate([
|
|
233
|
+
property({ type: String }),
|
|
234
|
+
__metadata("design:type", Object)
|
|
235
|
+
], KpiCategoryValueCalculator.prototype, "categoryName", void 0);
|
|
236
|
+
__decorate([
|
|
237
|
+
state(),
|
|
238
|
+
__metadata("design:type", Object)
|
|
239
|
+
], KpiCategoryValueCalculator.prototype, "valueDate", void 0);
|
|
240
|
+
__decorate([
|
|
241
|
+
state(),
|
|
242
|
+
__metadata("design:type", Object)
|
|
243
|
+
], KpiCategoryValueCalculator.prototype, "group", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
state(),
|
|
246
|
+
__metadata("design:type", Object)
|
|
247
|
+
], KpiCategoryValueCalculator.prototype, "result", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
state(),
|
|
250
|
+
__metadata("design:type", Object)
|
|
251
|
+
], KpiCategoryValueCalculator.prototype, "loading", void 0);
|
|
252
|
+
KpiCategoryValueCalculator = __decorate([
|
|
253
|
+
customElement('kpi-category-value-calculator')
|
|
254
|
+
], KpiCategoryValueCalculator);
|
|
255
|
+
export { KpiCategoryValueCalculator };
|
|
256
|
+
//# sourceMappingURL=kpi-category-value-calculator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kpi-category-value-calculator.js","sourceRoot":"","sources":["../../../client/pages/kpi-category/kpi-category-value-calculator.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,mCAAmC;AACnC,IAAK,aAQJ;AARD,WAAK,aAAa;IAChB,4BAAW,CAAA;IACX,8BAAa,CAAA;IACb,gCAAe,CAAA;IACf,oCAAmB,CAAA;IACnB,8BAAa,CAAA;IACb,gCAAe,CAAA;IACf,oCAAmB,CAAA;AACrB,CAAC,EARI,aAAa,KAAb,aAAa,QAQjB;AAED,8BAA8B;AAC9B,SAAS,gBAAgB,CAAC,aAA4B,aAAa,CAAC,GAAG;IACrE,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IAEtB,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;YACvB,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;YACvB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;YAC1B,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QACrC,CAAC;QACD,KAAK,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YACzB,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;YACvB,CAAC,CAAC,QAAQ,CAAC,CAAC,CA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C3B,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI;oBACjC,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI;iBAC1B;aACF,CAAC,CAAA;YAEF,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;gBACrB,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAA;YAC/C,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;YACtC,MAAM,CAAC;gBACL,OAAO,EAAE,wBAAwB;aAClC,CAAC,CAAA;QACJ,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QACtB,CAAC;IACH,CAAC;;AApG2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8DAAgB;AACf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gEAAkB;AACpC;IAAR,KAAK,EAAE;;6DAA+B;AAC9B;IAAR,KAAK,EAAE;;yDAAW;AACV;IAAR,KAAK,EAAE;;0DAAmB;AAClB;IAAR,KAAK,EAAE;;2DAAgB;AAjEb,0BAA0B;IADtC,aAAa,CAAC,+BAA+B,CAAC;GAClC,0BAA0B,CAiKtC","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { client } from '@operato/graphql'\nimport { notify } from '@operato/layout'\nimport gql from 'graphql-tag'\n\n// KpiPeriodType enum 정의 (서버와 동일하게)\nenum KpiPeriodType {\n DAY = 'DAY',\n WEEK = 'WEEK',\n MONTH = 'MONTH',\n QUARTER = 'QUARTER',\n YEAR = 'YEAR',\n RANGE = 'RANGE',\n ALLTIME = 'ALLTIME'\n}\n\n// periodType에 따른 마지막 일자 계산 함수\nfunction getLastValueDate(periodType: KpiPeriodType = KpiPeriodType.DAY): string {\n const now = new Date()\n\n switch (periodType) {\n case KpiPeriodType.DAY: {\n const d = new Date(now)\n d.setDate(d.getDate() - 1)\n return d.toISOString().slice(0, 10)\n }\n case KpiPeriodType.MONTH: {\n const d = new Date(now)\n d.setMonth(d.getMonth() - 1)\n return d.toISOString().slice(0, 7)\n }\n case KpiPeriodType.QUARTER: {\n let year = now.getFullYear()\n let quarter = Math.floor(now.getMonth() / 3)\n if (quarter === 0) {\n year -= 1\n quarter = 4\n }\n return `${year}-Q${quarter}`\n }\n case KpiPeriodType.WEEK: {\n const d = new Date(now)\n d.setDate(d.getDate() - 7)\n const year = d.getFullYear()\n const week = getISOWeek(d)\n return `${year}-W${week}`\n }\n case KpiPeriodType.ALLTIME:\n return 'ALLTIME'\n default: {\n const d = new Date(now)\n d.setDate(d.getDate() - 1)\n return d.toISOString().slice(0, 10)\n }\n }\n}\n\n// ISO 주차 계산 함수\nfunction getISOWeek(date: Date): number {\n const tmp = new Date(date.getTime())\n tmp.setHours(0, 0, 0, 0)\n tmp.setDate(tmp.getDate() + 4 - (tmp.getDay() || 7))\n const yearStart = new Date(tmp.getFullYear(), 0, 1)\n const weekNo = Math.ceil(((tmp.getTime() - yearStart.getTime()) / 86400000 + 1) / 7)\n return weekNo\n}\n\n@customElement('kpi-category-value-calculator')\nexport class KpiCategoryValueCalculator extends LitElement {\n static styles = [\n css`\n :host {\n display: block;\n padding: 20px;\n min-width: 400px;\n }\n\n .container {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n\n .form-group {\n display: flex;\n flex-direction: column;\n margin-bottom: 15px;\n }\n\n label {\n display: block;\n margin-bottom: 5px;\n font-weight: bold;\n }\n\n input,\n select {\n padding: 8px;\n border: 1px solid #ccc;\n border-radius: 4px;\n }\n\n .result {\n margin-top: 20px;\n padding: 15px;\n background-color: #f5f5f5;\n border-radius: 4px;\n }\n\n .result-value {\n font-size: 18px;\n font-weight: bold;\n color: #2196f3;\n }\n\n .kpi-values {\n margin-top: 10px;\n }\n\n .kpi-value-item {\n display: flex;\n justify-content: space-between;\n padding: 5px 0;\n border-bottom: 1px solid #eee;\n }\n `\n ]\n\n @property({ type: String }) categoryId = ''\n @property({ type: String }) categoryName = ''\n @state() valueDate = getLastValueDate()\n @state() group = ''\n @state() result: any = null\n @state() loading = false\n\n render() {\n return html`\n <div class=\"container\">\n <h3>${this.categoryName} - KPI 값 계산</h3>\n\n <div class=\"form-group\">\n <label>계산 기준일</label>\n <input type=\"date\" .value=${this.valueDate} @input=${e => (this.valueDate = e.target.value)} />\n </div>\n\n <div class=\"form-group\">\n <label>그룹</label>\n <input\n type=\"text\"\n placeholder=\"그룹명 (선택사항)\"\n .value=${this.group}\n @input=${e => (this.group = e.target.value)}\n />\n </div>\n\n <button\n @click=${this.calculateValue}\n ?disabled=${this.loading}\n style=\"width: 100%; padding: 10px; background: #2196f3; color: white; border: none; border-radius: 4px; cursor: pointer;\"\n >\n ${this.loading ? '계산 중...' : '계산하기'}\n </button>\n\n ${this.result\n ? html`\n <div class=\"result\">\n <div class=\"result-value\">\n 계산 결과: ${this.result.value !== null ? this.result.value.toFixed(2) : 'N/A'}\n </div>\n ${this.result.kpiValues && this.result.kpiValues.length > 0\n ? html`\n <div class=\"kpi-values\">\n <h4>개별 KPI 값:</h4>\n ${this.result.kpiValues.map(\n item => html`\n <div class=\"kpi-value-item\">\n <span>KPI ID: ${item.kpiId}</span>\n <span>${item.value !== null ? item.value.toFixed(2) : 'N/A'}</span>\n </div>\n `\n )}\n </div>\n `\n : ''}\n </div>\n `\n : ''}\n </div>\n `\n }\n\n async calculateValue() {\n if (!this.categoryId) return\n\n this.loading = true\n try {\n const response = await client.query({\n query: gql`\n query ($categoryId: String!, $valueDate: String, $group: String) {\n calculateKpiValue(categoryId: $categoryId, valueDate: $valueDate, group: $group) {\n value\n valueDate\n group\n kpiValues {\n kpiId\n value\n }\n }\n }\n `,\n variables: {\n categoryId: this.categoryId,\n valueDate: this.valueDate || null,\n group: this.group || null\n }\n })\n\n if (!response.errors) {\n this.result = response.data.calculateKpiValue\n }\n } catch (error) {\n console.error('KPI 값 계산 중 오류:', error)\n notify({\n message: 'KPI 값 계산 중 오류가 발생했습니다.'\n })\n } finally {\n this.loading = false\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import '@material/web/icon/icon.js';
|
|
2
|
+
import '@material/web/button/elevated-button.js';
|
|
3
|
+
import '@operato/data-grist/ox-grist.js';
|
|
4
|
+
import '@operato/data-grist/ox-filters-form.js';
|
|
5
|
+
import '@operato/data-grist/ox-record-creator.js';
|
|
6
|
+
import { PageView } from '@operato/shell';
|
|
7
|
+
import { FetchOption } from '@operato/data-grist';
|
|
8
|
+
declare const KpiCategoryValueListPage_base: (new (...args: any[]) => {
|
|
9
|
+
_storeUnsubscribe: import("redux").Unsubscribe;
|
|
10
|
+
connectedCallback(): void;
|
|
11
|
+
disconnectedCallback(): void;
|
|
12
|
+
stateChanged(_state: unknown): void;
|
|
13
|
+
readonly isConnected: boolean;
|
|
14
|
+
}) & (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
|
|
15
|
+
export declare class KpiCategoryValueListPage extends KpiCategoryValueListPage_base {
|
|
16
|
+
static styles: import("lit").CSSResult[];
|
|
17
|
+
gristConfig: any;
|
|
18
|
+
mode: 'CARD' | 'GRID' | 'LIST';
|
|
19
|
+
private grist;
|
|
20
|
+
get context(): {
|
|
21
|
+
title: string;
|
|
22
|
+
search: {
|
|
23
|
+
handler: (search: string) => void;
|
|
24
|
+
value: string;
|
|
25
|
+
};
|
|
26
|
+
filter: {
|
|
27
|
+
handler: () => void;
|
|
28
|
+
};
|
|
29
|
+
help: string;
|
|
30
|
+
actions: {
|
|
31
|
+
icon: string;
|
|
32
|
+
emphasis: {
|
|
33
|
+
raised: boolean;
|
|
34
|
+
outlined: boolean;
|
|
35
|
+
dense: boolean;
|
|
36
|
+
danger: boolean;
|
|
37
|
+
};
|
|
38
|
+
title: string;
|
|
39
|
+
action: () => Promise<void>;
|
|
40
|
+
}[];
|
|
41
|
+
exportable: {
|
|
42
|
+
name: string;
|
|
43
|
+
data: () => Promise<never[]>;
|
|
44
|
+
};
|
|
45
|
+
importable: {
|
|
46
|
+
handler: (records: any) => Promise<void>;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
50
|
+
pageInitialized(lifecycle: any): Promise<void>;
|
|
51
|
+
pageUpdated(changes: any, lifecycle: any): Promise<void>;
|
|
52
|
+
fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
|
|
53
|
+
total: any;
|
|
54
|
+
records: any;
|
|
55
|
+
}>;
|
|
56
|
+
_deleteKpiCategoryValue(): Promise<void>;
|
|
57
|
+
_updateKpiCategoryValue(): Promise<void>;
|
|
58
|
+
_calculateKpiCategoryValue(kpiCategoryValue: any): Promise<void>;
|
|
59
|
+
creationCallback(kpiCategoryValue: any): Promise<void>;
|
|
60
|
+
exportHandler(): Promise<never[]>;
|
|
61
|
+
importHandler(records: any): Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
export {};
|