@things-factory/dataset 8.0.0-beta.8 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/client/activities/activity-data-collect-edit.ts +105 -0
- package/client/activities/activity-data-collect-view.ts +91 -0
- package/client/activities/activity-data-review-edit.ts +133 -0
- package/client/activities/activity-data-review-view.ts +145 -0
- package/client/activities/activity-ooc-resolve-edit.ts +195 -0
- package/client/activities/activity-ooc-resolve-view.ts +143 -0
- package/client/activities/activity-ooc-review-edit.ts +173 -0
- package/client/activities/activity-ooc-review-view.ts +129 -0
- package/client/bootstrap.ts +35 -0
- package/client/components/data-entry-form.ts +109 -0
- package/client/index.ts +1 -0
- package/client/pages/data-archive/data-archive-list-page.ts +277 -0
- package/client/pages/data-archive/data-archive-request-popup.ts +177 -0
- package/client/pages/data-entry/data-entry-list-page.ts +464 -0
- package/client/pages/data-key-set/data-key-item-list.ts +183 -0
- package/client/pages/data-key-set/data-key-set-importer.ts +89 -0
- package/client/pages/data-key-set/data-key-set-list-page.ts +413 -0
- package/client/pages/data-ooc/data-ooc-list-page.ts +549 -0
- package/client/pages/data-ooc/data-ooc-page.ts +164 -0
- package/client/pages/data-ooc/data-ooc-view.ts +236 -0
- package/client/pages/data-ooc/data-oocs-page.ts +200 -0
- package/client/pages/data-report/data-report-embed-page.ts +108 -0
- package/client/pages/data-report/data-report-list-page.ts +454 -0
- package/client/pages/data-report/data-report-samples-page.ts +174 -0
- package/client/pages/data-report/jasper-report-oocs-page.ts +110 -0
- package/client/pages/data-report/jasper-report-samples-crosstab-page.ts +110 -0
- package/client/pages/data-report/jasper-report-samples-page.ts +110 -0
- package/client/pages/data-sample/data-sample-list-page.ts +442 -0
- package/client/pages/data-sample/data-sample-page.ts +55 -0
- package/client/pages/data-sample/data-sample-search-page.ts +424 -0
- package/client/pages/data-sample/data-sample-view.ts +292 -0
- package/client/pages/data-sample/data-samples-page.ts +249 -0
- package/client/pages/data-sensor/data-sensor-list-page.ts +456 -0
- package/client/pages/data-set/data-item-list.ts +304 -0
- package/client/pages/data-set/data-set-importer.ts +89 -0
- package/client/pages/data-set/data-set-list-page.ts +1078 -0
- package/client/pages/data-summary/data-summary-list-page.ts +363 -0
- package/client/pages/data-summary/data-summary-period-page.ts +439 -0
- package/client/pages/data-summary/data-summary-search-page.ts +426 -0
- package/client/pages/data-summary/data-summary-view.ts +133 -0
- package/client/route.ts +91 -0
- package/client/tsconfig.json +13 -0
- package/dist-client/pages/data-entry/data-entry-list-page.js +2 -2
- package/dist-client/pages/data-entry/data-entry-list-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/data-sample/data-sample-query.d.ts +1 -1
- package/dist-server/service/data-sample/data-sample-query.js +3 -3
- package/dist-server/service/data-sample/data-sample-query.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +26 -26
- package/server/activities/activity-data-collect.ts +100 -0
- package/server/activities/activity-data-review.ts +82 -0
- package/server/activities/activity-ooc-resolve.ts +123 -0
- package/server/activities/activity-ooc-review.ts +144 -0
- package/server/activities/index.ts +11 -0
- package/server/controllers/create-data-sample.ts +426 -0
- package/server/controllers/data-use-case.ts +98 -0
- package/server/controllers/finalize-data-collection.ts +388 -0
- package/server/controllers/index.ts +3 -0
- package/server/controllers/issue-data-collection-task.ts +70 -0
- package/server/controllers/jasper-report.ts +186 -0
- package/server/controllers/query-data-summary-by-period.ts +178 -0
- package/server/controllers/shiny-report.ts +54 -0
- package/server/engine/index.ts +1 -0
- package/server/engine/task/create-data-sample.ts +100 -0
- package/server/engine/task/index.ts +2 -0
- package/server/engine/task/issue-collect-data.ts +45 -0
- package/server/index.ts +8 -0
- package/server/routes.ts +188 -0
- package/server/service/data-archive/data-archive-mutation.ts +273 -0
- package/server/service/data-archive/data-archive-query.ts +58 -0
- package/server/service/data-archive/data-archive-type.ts +48 -0
- package/server/service/data-archive/data-archive.ts +69 -0
- package/server/service/data-archive/index.ts +6 -0
- package/server/service/data-key-set/data-key-item-type.ts +31 -0
- package/server/service/data-key-set/data-key-set-mutation.ts +201 -0
- package/server/service/data-key-set/data-key-set-query.ts +68 -0
- package/server/service/data-key-set/data-key-set-type.ts +70 -0
- package/server/service/data-key-set/data-key-set.ts +86 -0
- package/server/service/data-key-set/index.ts +6 -0
- package/server/service/data-ooc/data-ooc-mutation.ts +154 -0
- package/server/service/data-ooc/data-ooc-query.ts +106 -0
- package/server/service/data-ooc/data-ooc-subscription.ts +48 -0
- package/server/service/data-ooc/data-ooc-type.ts +71 -0
- package/server/service/data-ooc/data-ooc.ts +259 -0
- package/server/service/data-ooc/index.ts +7 -0
- package/server/service/data-sample/data-sample-mutation.ts +18 -0
- package/server/service/data-sample/data-sample-query.ts +215 -0
- package/server/service/data-sample/data-sample-type.ts +47 -0
- package/server/service/data-sample/data-sample.ts +193 -0
- package/server/service/data-sample/index.ts +6 -0
- package/server/service/data-sensor/data-sensor-mutation.ts +116 -0
- package/server/service/data-sensor/data-sensor-query.ts +76 -0
- package/server/service/data-sensor/data-sensor-type.ts +104 -0
- package/server/service/data-sensor/data-sensor.ts +126 -0
- package/server/service/data-sensor/index.ts +6 -0
- package/server/service/data-set/data-item-type.ts +155 -0
- package/server/service/data-set/data-set-mutation.ts +552 -0
- package/server/service/data-set/data-set-query.ts +461 -0
- package/server/service/data-set/data-set-type.ts +204 -0
- package/server/service/data-set/data-set.ts +326 -0
- package/server/service/data-set/index.ts +6 -0
- package/server/service/data-set-history/data-set-history-query.ts +126 -0
- package/server/service/data-set-history/data-set-history-type.ts +12 -0
- package/server/service/data-set-history/data-set-history.ts +217 -0
- package/server/service/data-set-history/event-subscriber.ts +17 -0
- package/server/service/data-set-history/index.ts +7 -0
- package/server/service/data-spec/data-spec-manager.ts +21 -0
- package/server/service/data-spec/data-spec-query.ts +21 -0
- package/server/service/data-spec/data-spec.ts +45 -0
- package/server/service/data-spec/index.ts +5 -0
- package/server/service/data-summary/data-summary-mutation.ts +45 -0
- package/server/service/data-summary/data-summary-query.ts +179 -0
- package/server/service/data-summary/data-summary-type.ts +86 -0
- package/server/service/data-summary/data-summary.ts +170 -0
- package/server/service/data-summary/index.ts +7 -0
- package/server/service/index.ts +57 -0
- package/server/tsconfig.json +10 -0
- package/server/utils/config-resolver.ts +29 -0
- package/server/utils/index.ts +1 -0
@@ -0,0 +1,193 @@
|
|
1
|
+
import { Field, ID, ObjectType } from 'type-graphql'
|
2
|
+
import {
|
3
|
+
Column,
|
4
|
+
CreateDateColumn,
|
5
|
+
Entity,
|
6
|
+
Index,
|
7
|
+
JoinColumn,
|
8
|
+
ManyToOne,
|
9
|
+
OneToOne,
|
10
|
+
PrimaryGeneratedColumn,
|
11
|
+
RelationId,
|
12
|
+
UpdateDateColumn
|
13
|
+
} from 'typeorm'
|
14
|
+
|
15
|
+
import { User } from '@things-factory/auth-base'
|
16
|
+
import { config } from '@things-factory/env'
|
17
|
+
import { Domain, ScalarObject, json5Transformer } from '@things-factory/shell'
|
18
|
+
import { ActivityInstance } from '@things-factory/worklist'
|
19
|
+
|
20
|
+
import { DataItem } from '../data-set/data-item-type'
|
21
|
+
import { DataSet } from '../data-set/data-set'
|
22
|
+
import { DataOoc } from '../data-ooc/data-ooc'
|
23
|
+
|
24
|
+
const ORMCONFIG = config.get('ormconfig', {})
|
25
|
+
const DATABASE_TYPE = ORMCONFIG.type
|
26
|
+
@Entity()
|
27
|
+
@Index(
|
28
|
+
'ix_data_sample_0',
|
29
|
+
(dataSample: DataSample) => [
|
30
|
+
dataSample.domain,
|
31
|
+
dataSample.dataSet,
|
32
|
+
dataSample.workDate,
|
33
|
+
dataSample.workShift,
|
34
|
+
dataSample.collectedAt
|
35
|
+
],
|
36
|
+
{
|
37
|
+
unique: false
|
38
|
+
}
|
39
|
+
)
|
40
|
+
@Index(
|
41
|
+
'ix_data_sample_1',
|
42
|
+
(dataSample: DataSample) => [dataSample.domain, dataSample.dataSet, dataSample.collectedAt],
|
43
|
+
{ unique: false }
|
44
|
+
)
|
45
|
+
@ObjectType({ description: 'Entity for DataSample' })
|
46
|
+
export class DataSample {
|
47
|
+
@PrimaryGeneratedColumn('uuid')
|
48
|
+
@Field(type => ID)
|
49
|
+
readonly id: string
|
50
|
+
|
51
|
+
@ManyToOne(type => Domain)
|
52
|
+
@Field(type => Domain)
|
53
|
+
domain?: Domain
|
54
|
+
|
55
|
+
@RelationId((dataSample: DataSample) => dataSample.domain)
|
56
|
+
domainId?: string
|
57
|
+
|
58
|
+
@Column()
|
59
|
+
@Field({ nullable: true })
|
60
|
+
name: string
|
61
|
+
|
62
|
+
@Column({ nullable: true })
|
63
|
+
@Field({ nullable: true })
|
64
|
+
description?: string
|
65
|
+
|
66
|
+
@Column({ nullable: true })
|
67
|
+
@Field({ nullable: true })
|
68
|
+
type?: string
|
69
|
+
|
70
|
+
@Column({ nullable: true })
|
71
|
+
@Field({ nullable: true })
|
72
|
+
useCase?: string
|
73
|
+
|
74
|
+
@Column('simple-json', { nullable: true })
|
75
|
+
@Field(type => ScalarObject, { nullable: true })
|
76
|
+
partitionKeys?: { [key: string]: any }
|
77
|
+
|
78
|
+
@ManyToOne(type => DataSet)
|
79
|
+
@Field(type => DataSet, { nullable: false })
|
80
|
+
dataSet?: DataSet
|
81
|
+
|
82
|
+
@RelationId((dataSample: DataSample) => dataSample.dataSet)
|
83
|
+
dataSetId?: string
|
84
|
+
|
85
|
+
@Column({ nullable: true })
|
86
|
+
@Field({ nullable: true })
|
87
|
+
dataSetVersion?: number
|
88
|
+
|
89
|
+
@Column('simple-json', { nullable: true })
|
90
|
+
@Field(type => ScalarObject, { nullable: true })
|
91
|
+
data?: any
|
92
|
+
|
93
|
+
@Column('simple-json', { nullable: true })
|
94
|
+
@Field(type => ScalarObject, { nullable: true })
|
95
|
+
judgment?: any
|
96
|
+
|
97
|
+
@Field(type => [DataItem], { nullable: true })
|
98
|
+
dataItems?: DataItem[]
|
99
|
+
|
100
|
+
@Column({
|
101
|
+
nullable: true,
|
102
|
+
type:
|
103
|
+
DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
104
|
+
? 'longtext'
|
105
|
+
: DATABASE_TYPE == 'oracle'
|
106
|
+
? 'clob'
|
107
|
+
: DATABASE_TYPE == 'mssql'
|
108
|
+
? 'nvarchar'
|
109
|
+
: 'varchar',
|
110
|
+
length: DATABASE_TYPE == 'mssql' ? 'MAX' : undefined,
|
111
|
+
transformer: json5Transformer
|
112
|
+
})
|
113
|
+
@Field({ nullable: true })
|
114
|
+
rawData?: string
|
115
|
+
|
116
|
+
@Column({ nullable: true })
|
117
|
+
@Field({ nullable: true })
|
118
|
+
source?: string
|
119
|
+
|
120
|
+
@Column({ nullable: true })
|
121
|
+
@Field({ nullable: true })
|
122
|
+
ooc?: boolean
|
123
|
+
|
124
|
+
@Column({ nullable: true })
|
125
|
+
@Field({ nullable: true })
|
126
|
+
oos?: boolean
|
127
|
+
|
128
|
+
@Column({ nullable: true, default: '' })
|
129
|
+
@Field({ nullable: true })
|
130
|
+
key01?: string = ''
|
131
|
+
|
132
|
+
@Column({ nullable: true, default: '' })
|
133
|
+
@Field({ nullable: true })
|
134
|
+
key02?: string = ''
|
135
|
+
|
136
|
+
@Column({ nullable: true, default: '' })
|
137
|
+
@Field({ nullable: true })
|
138
|
+
key03?: string = ''
|
139
|
+
|
140
|
+
@Column({ nullable: true, default: '' })
|
141
|
+
@Field({ nullable: true })
|
142
|
+
key04?: string = ''
|
143
|
+
|
144
|
+
@Column({ nullable: true, default: '' })
|
145
|
+
@Field({ nullable: true })
|
146
|
+
key05?: string = ''
|
147
|
+
|
148
|
+
@Column({ nullable: true })
|
149
|
+
@Field({ nullable: true })
|
150
|
+
workDate?: string
|
151
|
+
|
152
|
+
@Column({ nullable: true })
|
153
|
+
@Field({ nullable: true })
|
154
|
+
workShift?: string
|
155
|
+
|
156
|
+
@OneToOne(type => ActivityInstance, { nullable: true })
|
157
|
+
@JoinColumn()
|
158
|
+
@Field({ nullable: true })
|
159
|
+
reviewActivityInstance?: ActivityInstance
|
160
|
+
|
161
|
+
@RelationId((dataSample: DataSample) => dataSample.reviewActivityInstance)
|
162
|
+
reviewActivityInstanceId?: string
|
163
|
+
|
164
|
+
@OneToOne(type => DataOoc, dataOoc => dataOoc.dataSample, { nullable: true })
|
165
|
+
@Field(type => DataOoc, { nullable: true })
|
166
|
+
dataOoc?: DataOoc
|
167
|
+
|
168
|
+
@Column({ nullable: true })
|
169
|
+
@Field({ nullable: true })
|
170
|
+
collectedAt?: Date
|
171
|
+
|
172
|
+
@CreateDateColumn()
|
173
|
+
@Field({ nullable: true })
|
174
|
+
createdAt?: Date
|
175
|
+
|
176
|
+
@UpdateDateColumn()
|
177
|
+
@Field({ nullable: true })
|
178
|
+
updatedAt?: Date
|
179
|
+
|
180
|
+
@ManyToOne(type => User, { nullable: true })
|
181
|
+
@Field(type => User, { nullable: true })
|
182
|
+
creator?: User
|
183
|
+
|
184
|
+
@RelationId((dataSample: DataSample) => dataSample.creator)
|
185
|
+
creatorId?: string
|
186
|
+
|
187
|
+
@ManyToOne(type => User, { nullable: true })
|
188
|
+
@Field(type => User, { nullable: true })
|
189
|
+
updater?: User
|
190
|
+
|
191
|
+
@RelationId((dataSample: DataSample) => dataSample.updater)
|
192
|
+
updaterId?: string
|
193
|
+
}
|
@@ -0,0 +1,116 @@
|
|
1
|
+
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
2
|
+
import { In } from 'typeorm'
|
3
|
+
|
4
|
+
import { DataSensor } from './data-sensor'
|
5
|
+
import { DataSensorPatch, NewDataSensor } from './data-sensor-type'
|
6
|
+
|
7
|
+
@Resolver(DataSensor)
|
8
|
+
export class DataSensorMutation {
|
9
|
+
@Directive('@transaction')
|
10
|
+
@Mutation(returns => DataSensor, { description: 'To create new DataSensor' })
|
11
|
+
async createDataSensor(
|
12
|
+
@Arg('dataSensor') dataSensor: NewDataSensor,
|
13
|
+
@Ctx() context: ResolverContext
|
14
|
+
): Promise<DataSensor> {
|
15
|
+
const { domain, user, tx } = context.state
|
16
|
+
|
17
|
+
return await tx.getRepository(DataSensor).save({
|
18
|
+
...dataSensor,
|
19
|
+
domain,
|
20
|
+
creator: user,
|
21
|
+
updater: user
|
22
|
+
})
|
23
|
+
}
|
24
|
+
|
25
|
+
@Directive('@transaction')
|
26
|
+
@Mutation(returns => DataSensor, { description: 'To modify DataSensor information' })
|
27
|
+
async updateDataSensor(
|
28
|
+
@Arg('id') id: string,
|
29
|
+
@Arg('patch') patch: DataSensorPatch,
|
30
|
+
@Ctx() context: ResolverContext
|
31
|
+
): Promise<DataSensor> {
|
32
|
+
const { domain, user, tx } = context.state
|
33
|
+
|
34
|
+
const repository = tx.getRepository(DataSensor)
|
35
|
+
const dataSensor = await repository.findOne({
|
36
|
+
where: { domain: { id: domain.id }, id }
|
37
|
+
})
|
38
|
+
|
39
|
+
return await repository.save({
|
40
|
+
...dataSensor,
|
41
|
+
...patch,
|
42
|
+
updater: user
|
43
|
+
})
|
44
|
+
}
|
45
|
+
|
46
|
+
@Directive('@transaction')
|
47
|
+
@Mutation(returns => [DataSensor], { description: "To modify multiple DataSensors' information" })
|
48
|
+
async updateMultipleDataSensor(
|
49
|
+
@Arg('patches', type => [DataSensorPatch]) patches: DataSensorPatch[],
|
50
|
+
@Ctx() context: ResolverContext
|
51
|
+
): Promise<DataSensor[]> {
|
52
|
+
const { domain, user, tx } = context.state
|
53
|
+
|
54
|
+
let results = []
|
55
|
+
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
56
|
+
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
57
|
+
const dataSensorRepo = tx.getRepository(DataSensor)
|
58
|
+
|
59
|
+
if (_createRecords.length > 0) {
|
60
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
61
|
+
const newRecord = _createRecords[i]
|
62
|
+
|
63
|
+
const result = await dataSensorRepo.save({
|
64
|
+
...newRecord,
|
65
|
+
domain,
|
66
|
+
creator: user,
|
67
|
+
updater: user
|
68
|
+
})
|
69
|
+
|
70
|
+
results.push({ ...result, cuFlag: '+' })
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
if (_updateRecords.length > 0) {
|
75
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
76
|
+
const newRecord = _updateRecords[i]
|
77
|
+
const dataSensor = await dataSensorRepo.findOneBy({ id: newRecord.id })
|
78
|
+
|
79
|
+
const result = await dataSensorRepo.save({
|
80
|
+
...dataSensor,
|
81
|
+
...newRecord,
|
82
|
+
updater: user
|
83
|
+
})
|
84
|
+
|
85
|
+
results.push({ ...result, cuFlag: 'M' })
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
return results
|
90
|
+
}
|
91
|
+
|
92
|
+
@Directive('@transaction')
|
93
|
+
@Mutation(returns => Boolean, { description: 'To delete DataSensor' })
|
94
|
+
async deleteDataSensor(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
95
|
+
const { domain, tx } = context.state
|
96
|
+
|
97
|
+
await tx.getRepository(DataSensor).delete({ domain: { id: domain.id }, id })
|
98
|
+
return true
|
99
|
+
}
|
100
|
+
|
101
|
+
@Directive('@transaction')
|
102
|
+
@Mutation(returns => Boolean, { description: 'To delete multiple dataSensors' })
|
103
|
+
async deleteDataSensors(
|
104
|
+
@Arg('ids', type => [String]) ids: string[],
|
105
|
+
@Ctx() context: ResolverContext
|
106
|
+
): Promise<boolean> {
|
107
|
+
const { domain, tx } = context.state
|
108
|
+
|
109
|
+
await tx.getRepository(DataSensor).delete({
|
110
|
+
domain: { id: domain.id },
|
111
|
+
id: In(ids)
|
112
|
+
})
|
113
|
+
|
114
|
+
return true
|
115
|
+
}
|
116
|
+
}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'
|
2
|
+
|
3
|
+
import { Appliance, User } from '@things-factory/auth-base'
|
4
|
+
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
5
|
+
import { Scenario } from '@things-factory/integration-base'
|
6
|
+
|
7
|
+
import { DataSet } from '../data-set/data-set'
|
8
|
+
import { DataSensor } from './data-sensor'
|
9
|
+
import { DataSensorList } from './data-sensor-type'
|
10
|
+
|
11
|
+
@Resolver(DataSensor)
|
12
|
+
export class DataSensorQuery {
|
13
|
+
@Query(returns => DataSensor, { description: 'To fetch a DataSensor' })
|
14
|
+
async dataSensor(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<DataSensor> {
|
15
|
+
const { domain } = context.state
|
16
|
+
|
17
|
+
return await getRepository(DataSensor).findOne({
|
18
|
+
where: { domain: { id: domain.id }, id }
|
19
|
+
})
|
20
|
+
}
|
21
|
+
|
22
|
+
@Query(returns => DataSensorList, { description: 'To fetch multiple DataSensors' })
|
23
|
+
async dataSensors(
|
24
|
+
@Args(type => ListParam) params: ListParam,
|
25
|
+
@Ctx() context: ResolverContext
|
26
|
+
): Promise<DataSensorList> {
|
27
|
+
const { domain } = context.state
|
28
|
+
|
29
|
+
const queryBuilder = getQueryBuilderFromListParams({
|
30
|
+
repository: getRepository(DataSensor),
|
31
|
+
params,
|
32
|
+
domain,
|
33
|
+
searchables: ['name', 'description', 'deviceId', 'tag']
|
34
|
+
})
|
35
|
+
|
36
|
+
const [items, total] = await queryBuilder.getManyAndCount()
|
37
|
+
|
38
|
+
return { items, total }
|
39
|
+
}
|
40
|
+
|
41
|
+
@FieldResolver(type => Appliance)
|
42
|
+
async appliance(@Root() dataSensor: DataSensor): Promise<Appliance> {
|
43
|
+
return dataSensor.applianceId && (await getRepository(Appliance).findOneBy({ id: dataSensor.applianceId }))
|
44
|
+
}
|
45
|
+
|
46
|
+
@FieldResolver(type => DataSet)
|
47
|
+
async dataSet(@Root() dataSensor: DataSensor): Promise<DataSet> {
|
48
|
+
return dataSensor.dataSetId && (await getRepository(DataSet).findOneBy({ id: dataSensor.dataSetId }))
|
49
|
+
}
|
50
|
+
|
51
|
+
@FieldResolver(type => Scenario)
|
52
|
+
async decoder(@Root() dataSensor: DataSensor): Promise<Scenario> {
|
53
|
+
return (
|
54
|
+
dataSensor.decoder ||
|
55
|
+
(dataSensor.decoderId &&
|
56
|
+
(await getRepository(Scenario).findOneBy({
|
57
|
+
id: dataSensor.decoderId
|
58
|
+
})))
|
59
|
+
)
|
60
|
+
}
|
61
|
+
|
62
|
+
@FieldResolver(type => Domain)
|
63
|
+
async domain(@Root() dataSensor: DataSensor): Promise<Domain> {
|
64
|
+
return dataSensor.domainId && (await getRepository(Domain).findOneBy({ id: dataSensor.domainId }))
|
65
|
+
}
|
66
|
+
|
67
|
+
@FieldResolver(type => User)
|
68
|
+
async updater(@Root() dataSensor: DataSensor): Promise<User> {
|
69
|
+
return dataSensor.updaterId && (await getRepository(User).findOneBy({ id: dataSensor.updaterId }))
|
70
|
+
}
|
71
|
+
|
72
|
+
@FieldResolver(type => User)
|
73
|
+
async creator(@Root() dataSensor: DataSensor): Promise<User> {
|
74
|
+
return dataSensor.creatorId && (await getRepository(User).findOneBy({ id: dataSensor.creatorId }))
|
75
|
+
}
|
76
|
+
}
|
@@ -0,0 +1,104 @@
|
|
1
|
+
import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'
|
2
|
+
|
3
|
+
import { ObjectRef } from '@things-factory/shell'
|
4
|
+
|
5
|
+
import { DataSensor } from './data-sensor'
|
6
|
+
|
7
|
+
@InputType()
|
8
|
+
export class NewDataSensor {
|
9
|
+
@Field()
|
10
|
+
name: string
|
11
|
+
|
12
|
+
@Field({ nullable: true })
|
13
|
+
description?: string
|
14
|
+
|
15
|
+
@Field({ nullable: true })
|
16
|
+
active?: boolean
|
17
|
+
|
18
|
+
@Field({ nullable: true })
|
19
|
+
deviceId?: string
|
20
|
+
|
21
|
+
@Field({ nullable: true })
|
22
|
+
serialNo?: string
|
23
|
+
|
24
|
+
@Field({ nullable: true })
|
25
|
+
brand?: string
|
26
|
+
|
27
|
+
@Field({ nullable: true })
|
28
|
+
model?: string
|
29
|
+
|
30
|
+
@Field({ nullable: true })
|
31
|
+
netmask?: string
|
32
|
+
|
33
|
+
@Field({ nullable: true })
|
34
|
+
tag?: string
|
35
|
+
|
36
|
+
@Field({ nullable: true })
|
37
|
+
refBy?: string
|
38
|
+
|
39
|
+
@Field(type => ObjectRef, { nullable: true })
|
40
|
+
appliance?: ObjectRef
|
41
|
+
|
42
|
+
@Field(type => ObjectRef, { nullable: true })
|
43
|
+
dataSet?: ObjectRef
|
44
|
+
|
45
|
+
@Field(type => ObjectRef, { nullable: true })
|
46
|
+
decoder?: ObjectRef
|
47
|
+
}
|
48
|
+
|
49
|
+
@InputType()
|
50
|
+
export class DataSensorPatch {
|
51
|
+
@Field(type => ID, { nullable: true })
|
52
|
+
id?: string
|
53
|
+
|
54
|
+
@Field({ nullable: true })
|
55
|
+
name?: string
|
56
|
+
|
57
|
+
@Field({ nullable: true })
|
58
|
+
description?: string
|
59
|
+
|
60
|
+
@Field({ nullable: true })
|
61
|
+
active?: boolean
|
62
|
+
|
63
|
+
@Field({ nullable: true })
|
64
|
+
deviceId?: string
|
65
|
+
|
66
|
+
@Field({ nullable: true })
|
67
|
+
serialNo?: string
|
68
|
+
|
69
|
+
@Field({ nullable: true })
|
70
|
+
brand?: string
|
71
|
+
|
72
|
+
@Field({ nullable: true })
|
73
|
+
model?: string
|
74
|
+
|
75
|
+
@Field({ nullable: true })
|
76
|
+
netmask?: string
|
77
|
+
|
78
|
+
@Field({ nullable: true })
|
79
|
+
tag?: string
|
80
|
+
|
81
|
+
@Field({ nullable: true })
|
82
|
+
refBy?: string
|
83
|
+
|
84
|
+
@Field(type => ObjectRef, { nullable: true })
|
85
|
+
appliance?: ObjectRef
|
86
|
+
|
87
|
+
@Field(type => ObjectRef, { nullable: true })
|
88
|
+
dataSet?: ObjectRef
|
89
|
+
|
90
|
+
@Field(type => ObjectRef, { nullable: true })
|
91
|
+
decoder?: ObjectRef
|
92
|
+
|
93
|
+
@Field()
|
94
|
+
cuFlag: string
|
95
|
+
}
|
96
|
+
|
97
|
+
@ObjectType()
|
98
|
+
export class DataSensorList {
|
99
|
+
@Field(type => [DataSensor])
|
100
|
+
items: DataSensor[]
|
101
|
+
|
102
|
+
@Field(type => Int)
|
103
|
+
total: number
|
104
|
+
}
|
@@ -0,0 +1,126 @@
|
|
1
|
+
import { Field, ID, ObjectType } from 'type-graphql'
|
2
|
+
import {
|
3
|
+
Column,
|
4
|
+
CreateDateColumn,
|
5
|
+
Entity,
|
6
|
+
Index,
|
7
|
+
ManyToOne,
|
8
|
+
PrimaryGeneratedColumn,
|
9
|
+
RelationId,
|
10
|
+
UpdateDateColumn
|
11
|
+
} from 'typeorm'
|
12
|
+
|
13
|
+
import { Domain } from '@things-factory/shell'
|
14
|
+
import { Appliance, User } from '@things-factory/auth-base'
|
15
|
+
import { Scenario } from '@things-factory/integration-base'
|
16
|
+
|
17
|
+
import { DataSet } from '../data-set/data-set'
|
18
|
+
|
19
|
+
@Entity()
|
20
|
+
@Index('ix_data_sensor_0', (dataSensor: DataSensor) => [dataSensor.domain, dataSensor.name], { unique: true })
|
21
|
+
@Index('ix_data_sensor_1', (dataSensor: DataSensor) => [dataSensor.deviceId], { unique: true })
|
22
|
+
@Index('ix_data_sensor_2', (dataSensor: DataSensor) => [dataSensor.domain, dataSensor.refBy], {
|
23
|
+
unique: false
|
24
|
+
})
|
25
|
+
@Index('ix_data_sensor_3', (dataSensor: DataSensor) => [dataSensor.domain, dataSensor.serialNo], {
|
26
|
+
unique: false
|
27
|
+
})
|
28
|
+
@ObjectType({ description: 'Entity for DataSensor' })
|
29
|
+
export class DataSensor {
|
30
|
+
@PrimaryGeneratedColumn('uuid')
|
31
|
+
@Field(type => ID)
|
32
|
+
readonly id: string
|
33
|
+
|
34
|
+
@ManyToOne(type => Domain)
|
35
|
+
@Field(type => Domain)
|
36
|
+
domain?: Domain
|
37
|
+
|
38
|
+
@RelationId((dataSensor: DataSensor) => dataSensor.domain)
|
39
|
+
domainId?: string
|
40
|
+
|
41
|
+
@Column()
|
42
|
+
@Field()
|
43
|
+
name?: string
|
44
|
+
|
45
|
+
@Column({ nullable: true })
|
46
|
+
@Field({ nullable: true })
|
47
|
+
description?: string
|
48
|
+
|
49
|
+
@Column({ nullable: true })
|
50
|
+
@Field({ nullable: true })
|
51
|
+
active?: boolean
|
52
|
+
|
53
|
+
@Column({ nullable: true })
|
54
|
+
@Field({ nullable: true })
|
55
|
+
deviceId?: string
|
56
|
+
|
57
|
+
@Column({ nullable: true })
|
58
|
+
@Field({ nullable: true })
|
59
|
+
serialNo?: string
|
60
|
+
|
61
|
+
@Column({ nullable: true })
|
62
|
+
@Field({ nullable: true })
|
63
|
+
brand?: string
|
64
|
+
|
65
|
+
@Column({ nullable: true })
|
66
|
+
@Field({ nullable: true })
|
67
|
+
model?: string
|
68
|
+
|
69
|
+
@Column({ nullable: true })
|
70
|
+
@Field({ nullable: true })
|
71
|
+
netmask?: string
|
72
|
+
|
73
|
+
@Column({ nullable: true })
|
74
|
+
@Field({ nullable: true })
|
75
|
+
tag?: string
|
76
|
+
|
77
|
+
@Column({ nullable: true })
|
78
|
+
@Field({ nullable: true })
|
79
|
+
refBy?: string
|
80
|
+
|
81
|
+
@ManyToOne(type => Appliance, { nullable: true })
|
82
|
+
@Field({ nullable: true })
|
83
|
+
appliance?: Appliance
|
84
|
+
|
85
|
+
@RelationId((dataSensor: DataSensor) => dataSensor.appliance)
|
86
|
+
applianceId?: string
|
87
|
+
|
88
|
+
@ManyToOne(type => DataSet, { nullable: true })
|
89
|
+
@Field({ nullable: true })
|
90
|
+
dataSet?: DataSet
|
91
|
+
|
92
|
+
@RelationId((dataSensor: DataSensor) => dataSensor.dataSet)
|
93
|
+
dataSetId?: string
|
94
|
+
|
95
|
+
@ManyToOne(type => Scenario, { nullable: true })
|
96
|
+
@Field(type => Scenario, {
|
97
|
+
nullable: true,
|
98
|
+
description: 'The decoder scenario that automatically executes based on the trigger of raw data collection'
|
99
|
+
})
|
100
|
+
decoder?: Scenario
|
101
|
+
|
102
|
+
@RelationId((dataSensor: DataSensor) => dataSensor.decoder)
|
103
|
+
decoderId?: string
|
104
|
+
|
105
|
+
@CreateDateColumn()
|
106
|
+
@Field({ nullable: true })
|
107
|
+
createdAt?: Date
|
108
|
+
|
109
|
+
@UpdateDateColumn()
|
110
|
+
@Field({ nullable: true })
|
111
|
+
updatedAt?: Date
|
112
|
+
|
113
|
+
@ManyToOne(type => User, { nullable: true })
|
114
|
+
@Field(type => User, { nullable: true })
|
115
|
+
creator?: User
|
116
|
+
|
117
|
+
@RelationId((dataSensor: DataSensor) => dataSensor.creator)
|
118
|
+
creatorId?: string
|
119
|
+
|
120
|
+
@ManyToOne(type => User, { nullable: true })
|
121
|
+
@Field(type => User, { nullable: true })
|
122
|
+
updater?: User
|
123
|
+
|
124
|
+
@RelationId((dataSensor: DataSensor) => dataSensor.updater)
|
125
|
+
updaterId?: string
|
126
|
+
}
|