1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
from dataclasses import dataclass
from pot_libs.common.components.fields import Cid, Item
from pot_libs.sanic_api import Model
from pot_libs.sanic_api.column import Int, List, Opt, Str, Float, Dict, Enum
from unify_api.utils.response_code import DbErr, ServerErr, ParamErr
@dataclass
class ScopeListReq(Model):
'''
录波识别记录-请求格式
'''
cid: Cid
page_size: int = Opt(Int("每页记录数").eg(20))
page_num: int = Opt(Int("当前页码").eg(1))
is_download: int = Int("是否是下载 0-不是 1-是").eg(0)
start: str = Opt(Str("开始时间").eg("2022-06-22 00:00:00"))
end: str = Opt(Str("结束时间").eg("2022-06-22 23:59:59"))
scope_g: str = Opt(List("录波颗粒度").eg(["2s"]))
pids: list = Opt(List("检测点 []表示没有 [-1]表示全部").eg([260, 261, 268]))
@dataclass
class ScopeListDownloadReq(Model):
'''
2s录波识记录下载-请求格式
'''
start: str = Opt(Str("开始时间").eg("2022-06-22 00:00:00"))
end: str = Opt(Str("结束时间").eg("2022-06-22 23:59:59"))
pids: list = Opt(List("监测点 []表示没有 [-1]表示全部").eg([260, 261, 268]))
@dataclass
class ScopeListItem(Model):
'''
录播识别记录-每一条数据
'''
check_dt: str = Str("触发时间").eg("2021-07-01 23:59:59")
point: str = Str('监测点名称').eg('土建区总进线')
message: str = Str('触发原因').eg('B相电压波动')
scope_type: int = Opt(Int('录波颗粒度').eg('0.25ms'))
doc_id: str = Opt(Str('该条信息id').eg('213_over_gap_i__1604302769'))
@dataclass
class ScopeListResp(Model):
'''
录波识别记录-返回格式
'''
total: int = Opt(Int("总条数").eg(20))
rows: list = Opt(List("总数据").items(ScopeListItem))
page_num: int = Int("当前页").eg(1)
@dataclass
class ScopeItemDownload(Model):
"""
录波下载数据详情
"""
datetime: str = Str("时间").eg("2021-07-01 23:59:59")
ua: float = Float('A相电压')
ub: float = Float('B相电压')
uc: float = Float('C相电压')
ia: float = Float('A相电流')
ib: float = Float('B相电流')
ic: float = Float('C相电流')
pttl: float = Float('功率')
lc: float = Float('漏电流')
@dataclass
class ScopeListDownloadResp(Model):
"""
录波下载数据
"""
rows: list = Opt(List("数据列表").items(ScopeItemDownload))
@dataclass
class ScopeContent(Model):
'''
识别详情图表-返回格式
'''
item: Item
value_datas: list = List().items(Float())
@dataclass
class ScopeDetailRep(Model):
'''
识别详情-请求格式
'''
id: str = Opt(Str("doc_id").eg("423_over_gap_i__1655991008"))
@classmethod
def example(cls):
return {
"id": "423_over_gap_i__1655991008"
}
@dataclass
class ScopeDetailsResp(Model, DbErr):
'''
识别详情-返回格式
'''
point: str = Str('监测点名称').eg('土建区总进线')
contin_time: int = Opt(Int('持续时间').eg(2))
scope_type: str = Str('录波颗粒度').eg('0.25ms')
check_dt: str = Str("发生时间").eg("2021-07-01 23:59:59")
ctnum: str = Str("接线法 2-两表法 3-三表法").eg(3)
location: int = Opt(Int('位置').eg(240))
item: str = Item
type: str = Opt(Str().eg('电流波动'))
i: list = List("电流事件录波").items(ScopeContent)
v: list = List("电压事件录波").items(ScopeContent)
residual_current: list = Opt(List("2s录波漏电流").items(ScopeContent))
p: list = Opt(List("2s录波功率").items(ScopeContent))
@classmethod
def example(cls):
return {
"point": "钻孔配电柜",
"contin_time": "400",
"check_dt": "2022-06-23 21:30:08",
"scope_type": "0.25ms",
"item": "A相",
"type": "电流波动",
"i": [{
"item": "ia",
"value_datas": [1.25, -0.34]
}],
"v": [{
"item": "ua",
"value_datas": [86.06, 123.34]
}],
"residual_current": [{
"item": "漏电流",
"value_datas": [86.06, 123.34]
}],
"power": [{
"item": "p",
"value_datas": [86.06, 123.34]
}],
}
@dataclass
class GetScopeConfigReq(Model):
'''
获取录播配置-请求格式
'''
pid: int = Int("监测点id").eg(1754)
@dataclass
class SetScopeConfigReq(Model):
'''
设置录播配置-请求格式
'''
pid: int = Int("监测点id").eg(20)
scope_type: str = Enum("录波颗粒度").of('0.25ms', '0.2s', '2s')
type: str = Enum("提交类型").of("state", "i", "v", "residual_current", "power",
"time")
state: int = Opt(Enum("开启关闭状态").of(0, 1))
umax: int = Opt(Int("电压上限").eg(430))
umin: int = Opt(Int("电压下限").eg(360))
ugap: int = Opt(Int("电压波动阈值").eg(50))
imax: int = Opt(Int("电流上限").eg(40))
igap: int = Opt(Int("电流波动阈值").eg(5))
lcmax: int = Opt(Int("漏电流上限").eg(40))
lcgap: int = Opt(Int("漏电流波动阈值").eg(40))
pttlmax: int = Opt(Int("功率上限").eg(5))
pttlgap: int = Opt(Int("功率波动阈值").eg(40))
one_time: list = Opt(List("第一段时间").items(Str()))
two_time: list = Opt(List("第二段时间").items(Str()))
three_time: list = Opt(List("第三段时间").items(Str()))
@dataclass
class GetScopeConfigResp(Model, ServerErr):
'''
获取录播配置-返回格式
'''
pid: int = Int("监测点id").eg(20)
rows: list = List("配置内容").items(SetScopeConfigReq)
@classmethod
def example(cls):
return {
"pid": 1754,
"rows": {
"0.25ms": {
"state": 1,
"configs": {
"umin": {
"name": "越下限阈值",
"type": "v",
"value": 85
},
"umax": {
"name": "越上限阈值",
"type": "v",
"value": 115
},
"ugap": {
"name": "波动阈值",
"type": "v",
"value": 25
},
"imax": {
"name": "越限阈值",
"type": "i",
"value": 5
},
"igap": {
"name": "波动阈值",
"type": "i",
"value": 20
}
}
},
"0.2s": {
"state": 1,
"configs": {
"umin": {
"name": "越下限阈值",
"type": "v",
"value": 187
},
"umax": {
"name": "越上限阈值",
"type": "v",
"value": 253
},
"ugap": {
"name": "波动阈值",
"type": "v",
"value": 50
},
"imax": {
"name": "越限阈值",
"type": "i",
"value": 5
},
"igap": {
"name": "波动阈值",
"type": "i",
"value": 1
}
}
},
"2s": {
"state": 1,
"configs": {
"umin": {
"name": "越下限阈值",
"type": "v",
"value": 187
},
"umax": {
"name": "越上限阈值",
"type": "v",
"value": 253
},
"ugap": {
"name": "波动阈值",
"type": "v",
"value": 50
},
"imax": {
"name": "越限阈值",
"type": "i",
"value": 5
},
"igap": {
"name": "波动阈值",
"type": "i",
"value": 1
},
"lcmax": {
"name": "越限阈值",
"type": "residual_current",
"value": 1
},
"lcgap": {
"name": "波动阈值",
"type": "residual_current",
"value": 1
},
"pttlmax": {
"name": "越限阈值",
"type": "power",
"value": 5
},
"pttlgap": {
"name": "波动阈值",
"type": "power",
"value": 2
},
"one_time": {
"name": "第一个时间段",
"type": "time",
"value": [
"08:00",
"08:30"
]
},
"two_time": {
"name": "第二个时间段",
"type": "time",
"value": [
"09:00",
"10:00"
]
},
"three_time": {
"name": "第三个时间段",
"type": "time",
"value": [
"14:00",
"15:00"
]
}
}
}
}
}
@dataclass
class InitScopeConfigReq(Model):
'''
初始化配置信息--请求
'''
pids: list = List('pids')
@classmethod
def example(cls):
return {
'pids': [238, 240, 242, 330, 343, 749, 1463, 2248]
}
@dataclass
class FlushScopeEsDataReq(Model):
'''
刷新es录波数据--请求
'''
scope_type_list: list = List('录波类型')
start_time: str = Str('开始时间')
end_time: str = Str('结束时间')
@classmethod
def example(cls):
return {
'scope_type_list': ['200ms', '2s', '0.25ms'],
'start_time': '2022-07-04 17:40:24',
'end_time': '2022-07-21 18:40:24',
}
@dataclass
class GetScopeConfigList(Model):
'''
获取录播配置列表
'''
state: int = Enum("状态 0-关 1-开").of(0, 1)
configs: list = List("返回配置")
@dataclass
class SetScopeConfigResp(Model):
'''
设置录播配置-返回格式
'''
success: int = Int('是否操作成功 0-否 1-是').eg(1)
message: str = Str("返回信息").eg("操作成功")
# 识别记录列表请求举例
scope_list_req_example = {
"范例1": {
"cid": 114,
"page_size": 20,
"page_num": 1,
"is_download": 0,
"start": "2022-06-22 00:00:00",
"end": "2022-06-22 23:59:59",
"pids": []
},
"范例2": {
"cid": 44,
"page_size": 20,
"page_num": 1,
"is_download": 0,
"start": "2022-06-22 00:00:00",
"end": "2022-06-22 23:59:59",
"pids": [260, 261, 268]
}
}
'''
设置录波配置格式
'''
set_scope_config_example = {
"0.25ms设置电压范例": {
"pid": 1754,
"scope_type": "0.25ms",
"type": "v",
"umax": 430,
"umin": 360,
"ugap": 50,
},
"0.25ms设置状态范例": {
"pid": 1754,
"scope_type": "0.25ms",
"type": "state",
"state": 1,
},
"0.2s设置电流范例": {
"pid": 1754,
"scope_type": "0.2s",
"type": "i",
"imax": 40,
"igap": 5,
},
"2s设置漏电流范例": {
"pid": 1754,
"scope_type": "2s",
"type": "residual_current",
"lcmax": 30,
"lcgap": 12
},
"2s设置功率范例": {
"pid": 1754,
"scope_type": "2s",
"type": "power",
"pttlmax": 5,
"pttlgap": 40,
},
"2s设置时间段范例": {
"pid": 1754,
"scope_type": "2s",
"type": "time",
"one_time": ['08:00', '09:00'],
"two_time": ['10:00', '10:30'],
"three_time": ['13:00', '14:00'],
},
}
'''
初始化录播的配置
'''
init_scope_config_example = {
"coef": {
"Kua": 2.843364,
"Bua": 2070.924316,
"Kub": 2.849909,
"Bub": 2058.210205,
"Kuc": 2.854909,
"Buc": 2054.158447,
"Kia": 9.65814,
"Bia": 2056.642578,
"Kib": 9.652307,
"Bib": 2054.431152,
"Kic": 9.65714,
"Bic": 2056.80249
},
"threshold": {
"0.25ms": {
"en_scope": 0,
"umin": 187,
"umax": 253,
"ugap": 11.5,
"igap": 8,
"imax": 167,
},
"0.2s": {
"en_wave_200ms": 0,
"umin": 187,
"umax": 253,
"ugap": 11.5,
"igap": 8,
"imax": 167,
"scop_limit": 50
},
"2s": {
"en_electric_2s": 0,
"start_time_I": "11:00:00",
"stop_time_I": "12:00:00",
"start_time_II": "14:00:00",
"stop_time_II": "15:00:00",
"start_time_III": "15:00:00",
"stop_time_III": "16:00:00",
"umin": 187,
"umax": 253,
"ugap": 11.5,
"igap": 15,
"imax": 167,
"lcmax": 30,
"lcgap": 12,
"pttlgap": 10,
"pttlmax": 110
}
}
}
@dataclass
class ScopeDetail(Model):
name: str = Str("名称").eg("ia")
value: list = List("值")
@dataclass
class ScopeDetails(Model):
item: str = Str("名称").eg("ia")
value_datas: list = List("值")
@dataclass
class ScopeDetailResp(Model):
point: str = Str("监测点名称").eg("华侨新村270栋101")
ctnum: int = Int("接线方式 2-两表法 3-三表法").eg(1)
sid: str = Str("硬件编号").eg("A2270457094")
check_dt: str = Str("触发时间").eg("2022-05-26 15:55:03")
contin_time: str = Str("录波时长").eg("400ms")
item: str = Str("相限").eg("A相")
scope_g: str = Str("录波颗粒度 0.25ms/0.2s/2s").eg("0.25ms")
type: str = Str("录波类型").eg("over_res_cur")
location: int = Int("location触发点").eg(0)
v: list = List("电压曲线").items(ScopeDetails)
i: list = List("电流曲线").items(ScopeDetails)
residual_current: list = List("漏电流曲线").items(ScopeDetails)
p: list = List("功率曲线").items(ScopeDetails)