table_vacuate_info.py
2.2 KB
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
# author: 4N
# createtime: 2021/1/27
# email: nheweijun@sina.com
from app.models import Table,TableVacuate,Task
from app.util.component.ApiTemplate import ApiTemplate
from app.util.component.VacuateConf import VacuateConf
import collections
import json
import copy
class Api(ApiTemplate):
api_name = "抽稀info"
def process(self):
res = {}
try:
lonlat_gridsize = VacuateConf.lonlat_gridsize
project_gridsize = VacuateConf.project_gridsize
table_guid = self.para.get("guid")
table: Table = Table.query.filter_by(guid=table_guid).one_or_none()
if not table:
raise Exception("数据不存在!")
tvs = TableVacuate.query.filter_by(table_guid=table_guid).all()
dat = collections.OrderedDict()
if float(table.extent.split(",")[0])<180:
grid_size = copy.copy(lonlat_gridsize)
else:
grid_size = copy.copy(project_gridsize)
now_grid = [tv.pixel_distance for tv in tvs]
grid_size.reverse()
# 正在精华的任务
task_running = Task.query.filter_by(task_type=2,table_guid=table_guid,state=0).all()
grid_running = []
for t in task_running:
grid_running.extend(t.parameter.split(","))
for grid in grid_size:
if grid in now_grid:
dat[str(grid)] = 1
else:
dat[str(grid)] = 0
if str(grid) in grid_running:
dat[str(grid)] = 2
res["data"] = json.dumps(dat)
res["result"] = True
except Exception as e:
raise e
return res
api_doc = {
"tags": ["管理接口"],
"parameters": [
{"name": "guid",
"in": "formData",
"type": "string",
"description": "表guid", "required": "true"},
],
"responses": {
200: {
"schema": {
"properties": {
}
}
}
}
}