@things-factory/dataset 8.0.5 → 8.0.8
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/tsconfig.tsbuildinfo +1 -1
- package/dist-server/activities/activity-data-collect.js +2 -2
- package/dist-server/activities/activity-data-collect.js.map +1 -1
- package/dist-server/controllers/create-data-sample.js +11 -11
- package/dist-server/controllers/create-data-sample.js.map +1 -1
- package/dist-server/controllers/finalize-data-collection.js +22 -2
- package/dist-server/controllers/finalize-data-collection.js.map +1 -1
- package/dist-server/controllers/issue-ooc-resolve.d.ts +2 -2
- package/dist-server/controllers/issue-ooc-resolve.js +2 -2
- package/dist-server/controllers/issue-ooc-resolve.js.map +1 -1
- package/dist-server/service/data-sensor/data-sensor.d.ts +2 -0
- package/dist-server/service/data-sensor/data-sensor.js +10 -0
- package/dist-server/service/data-sensor/data-sensor.js.map +1 -1
- package/dist-server/service/index.d.ts +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/server/activities/activity-data-collect.ts +2 -2
- package/server/controllers/create-data-sample.ts +12 -12
- package/server/controllers/finalize-data-collection.ts +38 -6
- package/server/controllers/issue-ooc-resolve.ts +2 -2
- package/server/service/data-sensor/data-sensor.ts +9 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/dataset",
|
3
|
-
"version": "8.0.
|
3
|
+
"version": "8.0.8",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "dist-client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -40,21 +40,21 @@
|
|
40
40
|
"@operato/shell": "^8.0.0",
|
41
41
|
"@operato/styles": "^8.0.0",
|
42
42
|
"@operato/utils": "^8.0.0",
|
43
|
-
"@things-factory/auth-base": "^8.0.
|
44
|
-
"@things-factory/aws-base": "^8.0.
|
45
|
-
"@things-factory/board-service": "^8.0.
|
46
|
-
"@things-factory/env": "^8.0.
|
47
|
-
"@things-factory/integration-base": "^8.0.
|
48
|
-
"@things-factory/organization": "^8.0.
|
49
|
-
"@things-factory/personalization": "^8.0.
|
50
|
-
"@things-factory/scheduler-client": "^8.0.
|
51
|
-
"@things-factory/shell": "^8.0.
|
52
|
-
"@things-factory/work-shift": "^8.0.
|
53
|
-
"@things-factory/worklist": "^8.0.
|
43
|
+
"@things-factory/auth-base": "^8.0.8",
|
44
|
+
"@things-factory/aws-base": "^8.0.8",
|
45
|
+
"@things-factory/board-service": "^8.0.8",
|
46
|
+
"@things-factory/env": "^8.0.8",
|
47
|
+
"@things-factory/integration-base": "^8.0.8",
|
48
|
+
"@things-factory/organization": "^8.0.8",
|
49
|
+
"@things-factory/personalization": "^8.0.8",
|
50
|
+
"@things-factory/scheduler-client": "^8.0.8",
|
51
|
+
"@things-factory/shell": "^8.0.8",
|
52
|
+
"@things-factory/work-shift": "^8.0.8",
|
53
|
+
"@things-factory/worklist": "^8.0.8",
|
54
54
|
"cron-parser": "^4.3.0",
|
55
55
|
"moment-timezone": "^0.5.45",
|
56
56
|
"simple-statistics": "^7.8.3",
|
57
57
|
"statistics": "^3.3.0"
|
58
58
|
},
|
59
|
-
"gitHead": "
|
59
|
+
"gitHead": "2f53ec5833616a278c1f5fc057a5ce50f309cebd"
|
60
60
|
}
|
@@ -7,8 +7,8 @@ import {
|
|
7
7
|
ActivityInstanceStatus,
|
8
8
|
UpdateActivityInstanceStateAddendum
|
9
9
|
} from '@things-factory/worklist'
|
10
|
-
import { NewDataSample } from 'service/data-sample/data-sample-type'
|
11
|
-
import { createDataSample } from '../controllers/create-data-sample'
|
10
|
+
import { NewDataSample } from '../service/data-sample/data-sample-type.js'
|
11
|
+
import { createDataSample } from '../controllers/create-data-sample.js'
|
12
12
|
|
13
13
|
async function callback(
|
14
14
|
activityInstance: ActivityInstance,
|
@@ -4,7 +4,7 @@ import { In } from 'typeorm'
|
|
4
4
|
import { Attachment, createAttachment } from '@things-factory/attachment-base'
|
5
5
|
import { Role } from '@things-factory/auth-base'
|
6
6
|
import { logger } from '@things-factory/env'
|
7
|
-
import { getRedirectSubdomainPath, pubsub } from '@things-factory/shell'
|
7
|
+
import { getRepository, getRedirectSubdomainPath, pubsub } from '@things-factory/shell'
|
8
8
|
import { getWorkDateAndShift } from '@things-factory/work-shift'
|
9
9
|
import { Scenario, publishData } from '@things-factory/integration-base'
|
10
10
|
import { Activity } from '@things-factory/worklist'
|
@@ -59,7 +59,7 @@ const formatDate = (keys, _moment) => {
|
|
59
59
|
export async function createDataSample(newDataSample: NewDataSample, context: ResolverContext): Promise<DataSample> {
|
60
60
|
const { domain, user, tx } = context.state
|
61
61
|
|
62
|
-
const dataSet = await
|
62
|
+
const dataSet = await getRepository(DataSet, tx).findOne({
|
63
63
|
where: { domain: { id: In([domain.id, domain.parentId].filter(Boolean)) }, id: newDataSample.dataSet.id },
|
64
64
|
relations: ['dataKeySet']
|
65
65
|
})
|
@@ -96,7 +96,7 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
96
96
|
|
97
97
|
const { ooc, oos, judgment } = DataUseCase.evaluate(dataSet, dataItems, newDataSample.data) || {}
|
98
98
|
|
99
|
-
const old = await
|
99
|
+
const old = await getRepository(DataSample, tx).findOne({
|
100
100
|
where: {
|
101
101
|
domain: { id: domain.id },
|
102
102
|
dataSet: { id: dataSet.id },
|
@@ -139,7 +139,7 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
139
139
|
context
|
140
140
|
)
|
141
141
|
|
142
|
-
const fetched = await
|
142
|
+
const fetched = await getRepository(Attachment, tx).findOneBy({ id: attachment.id })
|
143
143
|
if (fetched) {
|
144
144
|
attachments.push(fetched)
|
145
145
|
paths.push({
|
@@ -165,7 +165,7 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
165
165
|
}
|
166
166
|
}
|
167
167
|
|
168
|
-
const dataSample = await
|
168
|
+
const dataSample = await getRepository(DataSample, tx).save({
|
169
169
|
...old,
|
170
170
|
name: dataSet.name,
|
171
171
|
description: dataSet.description,
|
@@ -193,7 +193,7 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
193
193
|
/* post-process for for file attachment. */
|
194
194
|
if (attachments.length > 0) {
|
195
195
|
attachments.forEach(attachment => (attachment.refId = dataSample.id))
|
196
|
-
|
196
|
+
getRepository(Attachment, tx).save(attachments)
|
197
197
|
}
|
198
198
|
|
199
199
|
if (ooc || oos) {
|
@@ -207,7 +207,7 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
207
207
|
type: 'error',
|
208
208
|
title: `[OOC] ${dataSet.name}`,
|
209
209
|
body: `Data OOC occurred on '${dataSet.name}'`,
|
210
|
-
url: getRedirectSubdomainPath(context, domain
|
210
|
+
url: getRedirectSubdomainPath(context, domain, `/data-ooc/${dataOoc.id}`),
|
211
211
|
timestamp: collectedAt
|
212
212
|
}
|
213
213
|
})
|
@@ -216,7 +216,7 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
216
216
|
}
|
217
217
|
} else {
|
218
218
|
if (normalScenarioId) {
|
219
|
-
const scenario = await
|
219
|
+
const scenario = await getRepository(Scenario, tx).findOne({
|
220
220
|
where: {
|
221
221
|
domain: { id: In([domain.id, domain.parentId].filter(Boolean)) },
|
222
222
|
id: normalScenarioId
|
@@ -257,7 +257,7 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
257
257
|
}
|
258
258
|
|
259
259
|
if (dataSet.requiresReview) {
|
260
|
-
const activity = (await
|
260
|
+
const activity = (await getRepository(Activity, tx).findOneBy({
|
261
261
|
domain: { id: In([domain.id, domain.parentId].filter(Boolean)) },
|
262
262
|
name: 'Data Review'
|
263
263
|
})) as Activity
|
@@ -265,7 +265,7 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
265
265
|
if (activity) {
|
266
266
|
const assigneeRole =
|
267
267
|
dataSet.supervisoryRoleId &&
|
268
|
-
(await
|
268
|
+
(await getRepository(Role, tx).findOneBy({
|
269
269
|
domain: { id: In([domain.id, domain.parentId].filter(Boolean)) },
|
270
270
|
id: dataSet.supervisoryRoleId
|
271
271
|
}))
|
@@ -292,7 +292,7 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
292
292
|
}
|
293
293
|
|
294
294
|
dataSample.reviewActivityInstance = await issue(activityInstance as any, context)
|
295
|
-
await
|
295
|
+
await getRepository(DataSample, tx).save(dataSample)
|
296
296
|
|
297
297
|
try {
|
298
298
|
pubsub.publish('notification', {
|
@@ -301,7 +301,7 @@ export async function createDataSample(newDataSample: NewDataSample, context: Re
|
|
301
301
|
type: 'info',
|
302
302
|
title: `[Data Review] ${dataSet.name}`,
|
303
303
|
body: `Data Review occurred on '${dataSet.name}'`,
|
304
|
-
url: getRedirectSubdomainPath(context, domain
|
304
|
+
url: getRedirectSubdomainPath(context, domain, `/data-sample/${dataSample.id}`),
|
305
305
|
timestamp: collectedAt
|
306
306
|
}
|
307
307
|
})
|
@@ -20,7 +20,7 @@ import { DataSet, DataSetSummaryPeriodType } from '../service/data-set/data-set'
|
|
20
20
|
import { DataSummary } from '../service/data-summary/data-summary'
|
21
21
|
import { DataKeyItem } from '../service/data-key-set/data-key-item-type'
|
22
22
|
|
23
|
-
import { DataItem } from 'service'
|
23
|
+
import { DataItem } from '../service/data-set/data-item-type.js'
|
24
24
|
|
25
25
|
const STAT_FUNCTION_MAP = {
|
26
26
|
sum: 'sum',
|
@@ -90,7 +90,11 @@ const calculateSummary = (dataItems: DataItem[], base: { [tag: string]: any[] })
|
|
90
90
|
}, {})
|
91
91
|
}
|
92
92
|
|
93
|
-
const fillSummaryResult = (
|
93
|
+
const fillSummaryResult = (
|
94
|
+
dataSummary: Partial<DataSummary>,
|
95
|
+
dataItems: DataItem[],
|
96
|
+
base: { [tag: string]: any[] }
|
97
|
+
): void => {
|
94
98
|
const summary = calculateSummary(dataItems, base)
|
95
99
|
|
96
100
|
dataSummary.summary = summary
|
@@ -100,7 +104,10 @@ const fillSummaryResult = (dataSummary: Partial<DataSummary>, dataItems: DataIte
|
|
100
104
|
})
|
101
105
|
}
|
102
106
|
|
103
|
-
async function getLatestTimesForPeriod(
|
107
|
+
async function getLatestTimesForPeriod(
|
108
|
+
periodType: DataSetSummaryPeriodType,
|
109
|
+
context: ResolverContext
|
110
|
+
): Promise<{ date?: string; period?: string; range: Date[] }> {
|
104
111
|
const { domain } = context.state
|
105
112
|
const now = moment()
|
106
113
|
|
@@ -278,7 +285,17 @@ export async function finalizeLatestDataCollection(dataSetId: string, context: R
|
|
278
285
|
page++
|
279
286
|
} while (true)
|
280
287
|
|
281
|
-
tx.getRepository(DataSummary).upsert(summaries, [
|
288
|
+
tx.getRepository(DataSummary).upsert(summaries, [
|
289
|
+
'domain',
|
290
|
+
'dataSet',
|
291
|
+
'key01',
|
292
|
+
'key02',
|
293
|
+
'key03',
|
294
|
+
'key04',
|
295
|
+
'key05',
|
296
|
+
'date',
|
297
|
+
'period'
|
298
|
+
])
|
282
299
|
|
283
300
|
return true
|
284
301
|
} catch (e) {
|
@@ -288,7 +305,12 @@ export async function finalizeLatestDataCollection(dataSetId: string, context: R
|
|
288
305
|
return false
|
289
306
|
}
|
290
307
|
|
291
|
-
export async function finalizeDataCollection(
|
308
|
+
export async function finalizeDataCollection(
|
309
|
+
dataSetId: string,
|
310
|
+
date: string,
|
311
|
+
period: string,
|
312
|
+
context: ResolverContext
|
313
|
+
): Promise<boolean> {
|
292
314
|
const { domain, user, tx } = context.state
|
293
315
|
|
294
316
|
try {
|
@@ -377,7 +399,17 @@ export async function finalizeDataCollection(dataSetId: string, date: string, pe
|
|
377
399
|
page++
|
378
400
|
} while (true)
|
379
401
|
|
380
|
-
tx.getRepository(DataSummary).upsert(summaries, [
|
402
|
+
tx.getRepository(DataSummary).upsert(summaries, [
|
403
|
+
'domain',
|
404
|
+
'dataSet',
|
405
|
+
'key01',
|
406
|
+
'key02',
|
407
|
+
'key03',
|
408
|
+
'key04',
|
409
|
+
'key05',
|
410
|
+
'date',
|
411
|
+
'period'
|
412
|
+
])
|
381
413
|
|
382
414
|
return true
|
383
415
|
} catch (e) {
|
@@ -3,8 +3,8 @@ import { Activity } from '@things-factory/worklist'
|
|
3
3
|
import { issue } from '@things-factory/worklist/dist-server/controllers/activity-instance/issue'
|
4
4
|
import { Role } from '@things-factory/auth-base'
|
5
5
|
|
6
|
-
import { DataOoc } from '../service/data-ooc/data-ooc'
|
7
|
-
import { DataSet } from 'service'
|
6
|
+
import { DataOoc } from '../service/data-ooc/data-ooc.js'
|
7
|
+
import { DataSet } from '../service/data-set/data-set.js'
|
8
8
|
|
9
9
|
export async function issueOocResolve(
|
10
10
|
dataOoc: DataOoc,
|
@@ -10,7 +10,7 @@ import {
|
|
10
10
|
UpdateDateColumn
|
11
11
|
} from 'typeorm'
|
12
12
|
|
13
|
-
import { Domain } from '@things-factory/shell'
|
13
|
+
import { Domain, roundTransformer } from '@things-factory/shell'
|
14
14
|
import { Appliance, User } from '@things-factory/auth-base'
|
15
15
|
import { Scenario } from '@things-factory/integration-base'
|
16
16
|
|
@@ -74,6 +74,14 @@ export class DataSensor {
|
|
74
74
|
@Field({ nullable: true })
|
75
75
|
tag?: string
|
76
76
|
|
77
|
+
@Column({ type: 'float', nullable: true, comment: '용량', transformer: roundTransformer })
|
78
|
+
@Field({ nullable: true })
|
79
|
+
capacity?: number
|
80
|
+
|
81
|
+
@Column({ nullable: true, comment: '용량 단위' })
|
82
|
+
@Field({ nullable: true })
|
83
|
+
unit?: string
|
84
|
+
|
77
85
|
@Column({ nullable: true })
|
78
86
|
@Field({ nullable: true })
|
79
87
|
refBy?: string
|