正在显示
14 个修改的文件
包含
55 行增加
和
14 行删除
@@ -37,7 +37,7 @@ class Api(ApiTemplate): | @@ -37,7 +37,7 @@ class Api(ApiTemplate): | ||
37 | download_process.start() | 37 | download_process.start() |
38 | 38 | ||
39 | task = Task(guid=task_guid, | 39 | task = Task(guid=task_guid, |
40 | - name="{}下载".format(self.para.get("table_name")), | 40 | + name="下载|{}".format(self.para.get("table_name")), |
41 | create_time=datetime.datetime.now(), | 41 | create_time=datetime.datetime.now(), |
42 | state=0, | 42 | state=0, |
43 | task_type=4, | 43 | task_type=4, |
@@ -83,7 +83,7 @@ class Api(ApiTemplate): | @@ -83,7 +83,7 @@ class Api(ApiTemplate): | ||
83 | # 录入数据后台进程,录入主函数为entry | 83 | # 录入数据后台进程,录入主函数为entry |
84 | # 初始化task | 84 | # 初始化task |
85 | task = Task(guid=self.para.get("task_guid"), | 85 | task = Task(guid=self.para.get("task_guid"), |
86 | - name=self.para.get("task_name"), | 86 | + name="入库|{}".format(self.para.get("task_name")), |
87 | create_time=datetime.datetime.now(), | 87 | create_time=datetime.datetime.now(), |
88 | state=0, | 88 | state=0, |
89 | task_type=1, | 89 | task_type=1, |
@@ -39,7 +39,7 @@ class Api(ApiTemplate): | @@ -39,7 +39,7 @@ class Api(ApiTemplate): | ||
39 | refresh_process.start() | 39 | refresh_process.start() |
40 | 40 | ||
41 | task = Task(guid=task_guid, | 41 | task = Task(guid=task_guid, |
42 | - name="数据库{}更新".format(database.alias), | 42 | + name="更新|{}".format(database.alias), |
43 | create_time=datetime.datetime.now(), | 43 | create_time=datetime.datetime.now(), |
44 | state=0, | 44 | state=0, |
45 | task_type=3, | 45 | task_type=3, |
@@ -76,7 +76,7 @@ class Api(ApiTemplate): | @@ -76,7 +76,7 @@ class Api(ApiTemplate): | ||
76 | 76 | ||
77 | 77 | ||
78 | task = Task(guid=task_guid, | 78 | task = Task(guid=task_guid, |
79 | - name="{}构建矢量金字塔".format(table.name), | 79 | + name="矢量金字塔|{}".format(table.name), |
80 | table_guid=table_guid, | 80 | table_guid=table_guid, |
81 | create_time=datetime.datetime.now(), | 81 | create_time=datetime.datetime.now(), |
82 | state=0, | 82 | state=0, |
@@ -79,7 +79,8 @@ class Api(ApiTemplate): | @@ -79,7 +79,8 @@ class Api(ApiTemplate): | ||
79 | 79 | ||
80 | 80 | ||
81 | task = Task(guid=task_guid, | 81 | task = Task(guid=task_guid, |
82 | - name="{}构建矢量金字塔,网格大小:{}".format(table.name,self.para.get("grids")), | 82 | + # name="矢量金字塔|{},网格大小:{}".format(table.name,self.para.get("grids")), |
83 | + name="矢量金字塔|{}".format(table.name), | ||
83 | table_guid=table_guid, | 84 | table_guid=table_guid, |
84 | create_time=datetime.datetime.now(), | 85 | create_time=datetime.datetime.now(), |
85 | state=0, | 86 | state=0, |
@@ -7,7 +7,7 @@ from flask import current_app as app | @@ -7,7 +7,7 @@ from flask import current_app as app | ||
7 | import socket | 7 | import socket |
8 | 8 | ||
9 | from app.util.component.ApiTemplate import ApiTemplate | 9 | from app.util.component.ApiTemplate import ApiTemplate |
10 | -from app.modules.data.models import Task,InsertingLayerName,db | 10 | +from app.modules.data.models import Task,InsertingLayerName,db,Table |
11 | import datetime | 11 | import datetime |
12 | import traceback | 12 | import traceback |
13 | from sqlalchemy import or_ | 13 | from sqlalchemy import or_ |
@@ -22,6 +22,23 @@ class Api(ApiTemplate): | @@ -22,6 +22,23 @@ class Api(ApiTemplate): | ||
22 | if last_lins: | 22 | if last_lins: |
23 | for lin in last_lins: | 23 | for lin in last_lins: |
24 | db.session.delete(lin) | 24 | db.session.delete(lin) |
25 | + | ||
26 | + vacuate_tasks = db.session.query(Task).filter(or_(Task.state == 0, Task.state == 2)).filter_by(task_type = 2).all() | ||
27 | + for t in vacuate_tasks: | ||
28 | + table = Table.query.filter_by(guid=t.table_guid).one_or_none() | ||
29 | + if len(table.relate_table_vacuates.all()) > 0: | ||
30 | + Table.query.filter_by(guid=t.table_guid).update({"is_vacuate": 1}) | ||
31 | + else: | ||
32 | + Table.query.filter_by(guid=t.table_guid).update({"is_vacuate": 0}) | ||
33 | + | ||
34 | + vacutateing_table = Table.query.filter_by(is_vacuate=2).all() | ||
35 | + | ||
36 | + for vit in vacutateing_table: | ||
37 | + if len(vit.relate_table_vacuates.all()) > 0: | ||
38 | + vit.is_vacuate = 1 | ||
39 | + else: | ||
40 | + vit.is_vacuate = 0 | ||
41 | + | ||
25 | db.session.commit() | 42 | db.session.commit() |
26 | except Exception as e: | 43 | except Exception as e: |
27 | # print(e) | 44 | # print(e) |
@@ -33,7 +33,7 @@ class Api(ApiTemplate): | @@ -33,7 +33,7 @@ class Api(ApiTemplate): | ||
33 | 33 | ||
34 | 34 | ||
35 | task = Task(guid=task_guid, | 35 | task = Task(guid=task_guid, |
36 | - name="{}构建影像金字塔".format(self.para.get("alias")), | 36 | + name="影像金字塔|{}".format(self.para.get("alias")), |
37 | create_time=datetime.datetime.now(), | 37 | create_time=datetime.datetime.now(), |
38 | state=0, | 38 | state=0, |
39 | task_type=5, | 39 | task_type=5, |
@@ -32,7 +32,7 @@ class Api(ApiTemplate): | @@ -32,7 +32,7 @@ class Api(ApiTemplate): | ||
32 | "title":self.para.get("title"), | 32 | "title":self.para.get("title"), |
33 | "type":"mapserver", | 33 | "type":"mapserver", |
34 | "capabilities":2, | 34 | "capabilities":2, |
35 | - "project":self.para.get("project")} | 35 | + "project":self.para.get("project"),"state":1} |
36 | 36 | ||
37 | map_service_register_url = "{}/dmap/api/manager/regservice".format(configure.dmap_engine) | 37 | map_service_register_url = "{}/dmap/api/manager/regservice".format(configure.dmap_engine) |
38 | resp: requests.Response = requests.post(map_service_register_url,data=json.dumps(para), | 38 | resp: requests.Response = requests.post(map_service_register_url,data=json.dumps(para), |
@@ -28,13 +28,16 @@ class Api(ApiTemplate): | @@ -28,13 +28,16 @@ class Api(ApiTemplate): | ||
28 | project_file = ProjectFile.create(ModelVisitor.object_to_json(ts)) | 28 | project_file = ProjectFile.create(ModelVisitor.object_to_json(ts)) |
29 | service:Service = Service.query.filter_by(guid=ts.service_guid).one_or_none() | 29 | service:Service = Service.query.filter_by(guid=ts.service_guid).one_or_none() |
30 | para = {"name":service.name,"title":service.title, | 30 | para = {"name":service.name,"title":service.title, |
31 | - "type":"tileserver","capabilities":1 if ts.tile_type=="WMTS" else 16,"project":project_file} | 31 | + "type":"tileserver","capabilities":1 if ts.tile_type=="WMTS" else 16,"project":project_file, |
32 | + "state":service.state} | ||
32 | res["data"]["list"].append(para) | 33 | res["data"]["list"].append(para) |
33 | 34 | ||
34 | #地图服务 | 35 | #地图服务 |
35 | map_services = MapService.query.all() | 36 | map_services = MapService.query.all() |
36 | for ms in map_services: | 37 | for ms in map_services: |
38 | + service: Service = Service.query.filter_by(guid=ms.service_guid).one_or_none() | ||
37 | para = ModelVisitor.object_to_json(ms) | 39 | para = ModelVisitor.object_to_json(ms) |
40 | + para["state"] = service.state | ||
38 | res["data"]["list"].append(para) | 41 | res["data"]["list"].append(para) |
39 | res["data"]["count"] = len(tile_services)+len(map_services) | 42 | res["data"]["count"] = len(tile_services)+len(map_services) |
40 | res["result"] = True | 43 | res["result"] = True |
@@ -8,7 +8,7 @@ from app.util.component.ApiTemplate import ApiTemplate | @@ -8,7 +8,7 @@ from app.util.component.ApiTemplate import ApiTemplate | ||
8 | from .models import Service,db | 8 | from .models import Service,db |
9 | import requests | 9 | import requests |
10 | from .util.ServiceType import ServiceType | 10 | from .util.ServiceType import ServiceType |
11 | - | 11 | +import configure |
12 | 12 | ||
13 | class Api(ApiTemplate): | 13 | class Api(ApiTemplate): |
14 | api_name = "修改服务状态" | 14 | api_name = "修改服务状态" |
@@ -27,6 +27,19 @@ class Api(ApiTemplate): | @@ -27,6 +27,19 @@ class Api(ApiTemplate): | ||
27 | if service: | 27 | if service: |
28 | service.state = state | 28 | service.state = state |
29 | db.session.commit() | 29 | db.session.commit() |
30 | + | ||
31 | + # operate = "startService" if state == 1 else "stopService" | ||
32 | + # server_type = "tileserver" if s_type == "电子地图" else "mapserver" | ||
33 | + # dmap_engine_url = "{}/dmap/api/manager/{}?servicename={}&servername={}".format(configure.dmap_engine, | ||
34 | + # operate,service.name, | ||
35 | + # server_type) | ||
36 | + # state_result = requests.get(dmap_engine_url) | ||
37 | + # if state_result.status_code == 200: | ||
38 | + # if not state_result.json().get("result"): | ||
39 | + # raise Exception("修改服务状态失败!") | ||
40 | + # else: | ||
41 | + # raise Exception("修改服务状态失败!") | ||
42 | + | ||
30 | res["result"] = True | 43 | res["result"] = True |
31 | else: | 44 | else: |
32 | raise Exception("服务不存在!") | 45 | raise Exception("服务不存在!") |
@@ -76,7 +89,7 @@ class Api(ApiTemplate): | @@ -76,7 +89,7 @@ class Api(ApiTemplate): | ||
76 | {"name": "state", | 89 | {"name": "state", |
77 | "in": "formData", | 90 | "in": "formData", |
78 | "type": "int", | 91 | "type": "int", |
79 | - "description": "state"}, | 92 | + "description": "state","enum":[0,1]}, |
80 | ], | 93 | ], |
81 | "responses": { | 94 | "responses": { |
82 | 200: { | 95 | 200: { |
@@ -35,7 +35,7 @@ class Api(ApiTemplate): | @@ -35,7 +35,7 @@ class Api(ApiTemplate): | ||
35 | "title":self.para.get("title"), | 35 | "title":self.para.get("title"), |
36 | "type":"tileserver", | 36 | "type":"tileserver", |
37 | "capabilities":1 if self.para.get("tile_type") == "WMTS" else 16, | 37 | "capabilities":1 if self.para.get("tile_type") == "WMTS" else 16, |
38 | - "project":project_file} | 38 | + "project":project_file,"state":1} |
39 | 39 | ||
40 | tile_service_register_url = "{}/dmap/api/manager/RegService".format(configure.dmap_engine) | 40 | tile_service_register_url = "{}/dmap/api/manager/RegService".format(configure.dmap_engine) |
41 | resp: Response = requests.post(tile_service_register_url,data=json.dumps(para), | 41 | resp: Response = requests.post(tile_service_register_url,data=json.dumps(para), |
@@ -30,7 +30,8 @@ class Api(ApiTemplate): | @@ -30,7 +30,8 @@ class Api(ApiTemplate): | ||
30 | project_file = ProjectFile.create(ModelVisitor.object_to_json(ts)) | 30 | project_file = ProjectFile.create(ModelVisitor.object_to_json(ts)) |
31 | service:Service = Service.query.filter_by(guid=ts.service_guid).one_or_none() | 31 | service:Service = Service.query.filter_by(guid=ts.service_guid).one_or_none() |
32 | para = {"name":service.name,"title":service.title, | 32 | para = {"name":service.name,"title":service.title, |
33 | - "type":"tileserver","capabilities":1 if ts.tile_type=="WMTS" else 16,"project":project_file} | 33 | + "type":"tileserver","capabilities":1 if ts.tile_type=="WMTS" else 16,"project":project_file, |
34 | + "state":service.state} | ||
34 | res["data"]["list"].append(para) | 35 | res["data"]["list"].append(para) |
35 | 36 | ||
36 | res["data"]["count"] = len(tile_services) | 37 | res["data"]["count"] = len(tile_services) |
@@ -11,9 +11,15 @@ fn = "PG: user=%s password=%s host=%s port=%s dbname=%s " % ("postgres","chinadc | @@ -11,9 +11,15 @@ fn = "PG: user=%s password=%s host=%s port=%s dbname=%s " % ("postgres","chinadc | ||
11 | driver = ogr.GetDriverByName("PostgreSQL") | 11 | driver = ogr.GetDriverByName("PostgreSQL") |
12 | if driver is None: | 12 | if driver is None: |
13 | raise Exception("打开PostgreSQL驱动失败,可能是当前GDAL未支持PostgreSQL驱动!") | 13 | raise Exception("打开PostgreSQL驱动失败,可能是当前GDAL未支持PostgreSQL驱动!") |
14 | + | ||
14 | ds:DataSource = driver.Open(fn, 1) | 15 | ds:DataSource = driver.Open(fn, 1) |
15 | 16 | ||
16 | layer:Layer = ds.GetLayerByName("BeijingBusStops") | 17 | layer:Layer = ds.GetLayerByName("BeijingBusStops") |
17 | 18 | ||
18 | 19 | ||
19 | -dd = gdal.Grid('outcome.tif',"J:\Data\矢量数据\北京\北京公交线路和公交站点shp\stops\BeijingBusStops.shp",algorithm = 'linear:radius=0') | ||
20 | +# dd = gdal.Grid('outcome.tif',"J:\Data\矢量数据\北京\北京公交线路和公交站点shp\stops\BeijingBusStops.shp",algorithm = 'linear:radius=0') | ||
21 | +# layers='test', | ||
22 | + | ||
23 | +opts = gdal.GridOptions() | ||
24 | + | ||
25 | +dd = gdal.Grid('outcome.tif',ds,layers=['BeijingBusStops'],algorithm = 'linear:radius=0') |
test/outcome.tif
deleted
100644 → 0
不能预览此文件类型
请
注册
或
登录
后发表评论