正在显示
11 个修改的文件
包含
44 行增加
和
139 行删除
| ... | ... | @@ -164,7 +164,7 @@ class Api(ApiTemplate): |
| 164 | 164 | |
| 165 | 165 | for i in range(feature_defn.GetFieldCount()): |
| 166 | 166 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) |
| 167 | - field_name = field_defn.GetName().lower() | |
| 167 | + field_name = field_defn.GetName() | |
| 168 | 168 | field_alias = field_name if field_defn.GetAlternativeName() is None or field_defn.GetAlternativeName().__eq__( |
| 169 | 169 | "") else field_defn.GetAlternativeName() |
| 170 | 170 | column = Columns(guid=uuid.uuid1().__str__(), table_guid=table_guid, | ... | ... |
| ... | ... | @@ -358,12 +358,16 @@ class ThisTask: |
| 358 | 358 | feature_defn: FeatureDefn = layer.GetLayerDefn() |
| 359 | 359 | |
| 360 | 360 | for i in range(feature_defn.GetFieldCount()): |
| 361 | + | |
| 361 | 362 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) |
| 362 | 363 | field_name = field_defn.GetName() |
| 364 | + | |
| 363 | 365 | field_alias = field_name if field_defn.GetAlternativeName() is None or field_defn.GetAlternativeName().__eq__( |
| 364 | 366 | "") else field_defn.GetAlternativeName() |
| 367 | + | |
| 365 | 368 | column = Columns(guid=uuid.uuid1().__str__(), table_guid=table_guid, |
| 366 | 369 | name=field_name, alias=field_alias, create_time=this_time, update_time=this_time) |
| 370 | + | |
| 367 | 371 | self.sys_session.add(column) |
| 368 | 372 | return table_guid |
| 369 | 373 | ... | ... |
| ... | ... | @@ -250,7 +250,7 @@ class Api(ApiTemplate): |
| 250 | 250 | |
| 251 | 251 | for i in range(feature_defn.GetFieldCount()): |
| 252 | 252 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) |
| 253 | - field_name = field_defn.GetName().lower() | |
| 253 | + field_name = field_defn.GetName() | |
| 254 | 254 | field_alias = field_name if field_defn.GetAlternativeName() is None or field_defn.GetAlternativeName().__eq__( |
| 255 | 255 | "") else field_defn.GetAlternativeName() |
| 256 | 256 | column = Columns(guid=uuid.uuid1().__str__(), table_guid=table_guid, |
| ... | ... | @@ -337,7 +337,7 @@ class Api(ApiTemplate): |
| 337 | 337 | # 增加列 |
| 338 | 338 | for i in range(feature_defn.GetFieldCount()): |
| 339 | 339 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) |
| 340 | - field_name = field_defn.GetName().lower() | |
| 340 | + field_name = field_defn.GetName() | |
| 341 | 341 | db_columns_names.append(field_name) |
| 342 | 342 | |
| 343 | 343 | if field_name not in columns_names: | ... | ... |
| ... | ... | @@ -484,7 +484,7 @@ def add_spatail_table(database,pg_ds,sys_session,spatial_tables_names,this_time, |
| 484 | 484 | |
| 485 | 485 | for i in range(feature_defn.GetFieldCount()): |
| 486 | 486 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) |
| 487 | - field_name = field_defn.GetName().lower() | |
| 487 | + field_name = field_defn.GetName() | |
| 488 | 488 | field_alias = field_name if field_defn.GetAlternativeName() is None or field_defn.GetAlternativeName().__eq__( |
| 489 | 489 | "") else field_defn.GetAlternativeName() |
| 490 | 490 | column = Columns(guid=uuid.uuid1().__str__(), table_guid=table_guid, |
| ... | ... | @@ -571,7 +571,7 @@ def edit_spatial_table(pg_ds,sys_session,spatial_tables,db_tables_names,this_tim |
| 571 | 571 | # 增加列 |
| 572 | 572 | for i in range(feature_defn.GetFieldCount()): |
| 573 | 573 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) |
| 574 | - field_name = field_defn.GetName().lower() | |
| 574 | + field_name = field_defn.GetName() | |
| 575 | 575 | db_columns_names.append(field_name) |
| 576 | 576 | |
| 577 | 577 | if field_name not in columns_names: | ... | ... |
| ... | ... | @@ -12,7 +12,7 @@ import platform |
| 12 | 12 | import datetime |
| 13 | 13 | import uuid |
| 14 | 14 | from app.util.component.UserCheck import UserCheck |
| 15 | - | |
| 15 | +import requests | |
| 16 | 16 | class Api(ApiTemplate): |
| 17 | 17 | api_name = "停止任务" |
| 18 | 18 | def para_check(self): |
| ... | ... | @@ -35,11 +35,21 @@ class Api(ApiTemplate): |
| 35 | 35 | exec_result = os.popen('taskkill.exe /pid:' + str(pid)) |
| 36 | 36 | |
| 37 | 37 | else: |
| 38 | - #分布式下,很难吧,还需要记录机器,分布式是不可行的 | |
| 39 | - os.kill(pid,signal.SIGILL) | |
| 38 | + if task.task_type == 5: | |
| 39 | + url = "{}/API/Image/TaskKill".format(task.parameter) | |
| 40 | + StructurePrint().print(url) | |
| 41 | + response: requests.Response = requests.post(url, {"pid":pid}) | |
| 42 | + if response.status_code == 200: | |
| 43 | + if response.json()["result"]: | |
| 44 | + pass | |
| 45 | + else: | |
| 46 | + raise Exception(response.json()["msg"]) | |
| 47 | + else: | |
| 48 | + raise Exception("影像服务器连接失败!") | |
| 49 | + else: | |
| 50 | + os.kill(pid,signal.SIGILL) | |
| 40 | 51 | except Exception as e: |
| 41 | - StructurePrint.print("Kill task 失败") | |
| 42 | - raise e | |
| 52 | + StructurePrint().print("Kill task 失败") | |
| 43 | 53 | |
| 44 | 54 | #处理kill任务后的事情 |
| 45 | 55 | self.fix_task(task) | ... | ... |
| ... | ... | @@ -21,7 +21,9 @@ class Api(ApiTemplate): |
| 21 | 21 | task_guid = self.para.get("task_guid") |
| 22 | 22 | msg = self.para.get("msg") |
| 23 | 23 | task:Task = Task.query.filter_by(guid=task_guid) |
| 24 | - task.update(json.loads(self.para.get("update"))) | |
| 24 | + update = json.loads(self.para.get("update")) | |
| 25 | + update["update_time"] = datetime.datetime.now() | |
| 26 | + task.update(update) | |
| 25 | 27 | |
| 26 | 28 | if msg: |
| 27 | 29 | message = "{} {}".format(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), msg) | ... | ... |
| 1 | -# coding=utf-8 | |
| 2 | -#author: 4N | |
| 3 | -#createtime: 2021/7/19 | |
| 4 | -#email: nheweijun@sina.com | |
| 5 | - | |
| 6 | -import configure | |
| 7 | -from app.util.component.ApiTemplate import ApiTemplate | |
| 8 | -from app.util.component.StructurePrint import StructurePrint | |
| 9 | -from app.models import db | |
| 10 | -from app.modules.data.models import Task | |
| 11 | -import multiprocessing | |
| 12 | -import uuid | |
| 13 | -import datetime | |
| 14 | -import requests | |
| 15 | -from app.util.component.TaskController import TaskController | |
| 16 | -from app.util.component.TaskWriter import TaskWriter | |
| 17 | -class Api(ApiTemplate): | |
| 18 | - | |
| 19 | - api_name = "创建影像金字塔" | |
| 20 | - | |
| 21 | - def process(self): | |
| 22 | - | |
| 23 | - # 返回结果 | |
| 24 | - res = {} | |
| 25 | - try: | |
| 26 | - task_guid = uuid.uuid1().__str__() | |
| 27 | - | |
| 28 | - | |
| 29 | - pyramid_process = multiprocessing.Process(target=self.task, args=(task_guid,self.para)) | |
| 30 | - pyramid_process.start() | |
| 31 | - | |
| 32 | - task = Task(guid=task_guid, | |
| 33 | - name="{}构建影像金字塔".format(self.para.get("alias")), | |
| 34 | - create_time=datetime.datetime.now(), | |
| 35 | - state=0, | |
| 36 | - task_type=5, | |
| 37 | - creator=self.para.get("creator"), | |
| 38 | - process="影像创建金字塔中", | |
| 39 | - task_pid=pyramid_process.pid) | |
| 40 | - | |
| 41 | - db.session.add(task) | |
| 42 | - db.session.commit() | |
| 43 | - | |
| 44 | - res["data"] = "创建影像金字塔任务已提交!" | |
| 45 | - res["result"] = True | |
| 46 | - | |
| 47 | - except Exception as e: | |
| 48 | - raise Exception("数据库错误!") | |
| 49 | - | |
| 50 | - return res | |
| 51 | - | |
| 52 | - | |
| 53 | - def task(self,task_guid,para): | |
| 54 | - task_writer = None | |
| 55 | - try: | |
| 56 | - | |
| 57 | - #任务控制,等待执行 | |
| 58 | - TaskController.wait(task_guid) | |
| 59 | - task_writer = TaskWriter(task_guid) | |
| 60 | - | |
| 61 | - task_writer.update_task({"state":2,"update_time":datetime.datetime.now(),"process" : "创建中"}) | |
| 62 | - task_writer.update_process("开始创建...") | |
| 63 | - | |
| 64 | - url = "{}/API/Service/Image/BuildPyramid".format(para.get("url")) | |
| 65 | - | |
| 66 | - # s = requests.session() | |
| 67 | - # s.keep_alive = True | |
| 68 | - # s.post() | |
| 69 | - | |
| 70 | - self.para["from"] = configure.deploy_ip_host | |
| 71 | - | |
| 72 | - response:requests.Response = requests.post(url,data=self.para) | |
| 73 | - | |
| 74 | - if response.status_code==200: | |
| 75 | - if not response.json().get("result"): | |
| 76 | - raise Exception("由于{},影像服务修改失败!".format(response.json().get("msg"))) | |
| 77 | - | |
| 78 | - task_writer.update_task({"state":1,"update_time":datetime.datetime.now(),"process" : "创建完成"}) | |
| 79 | - task_writer.update_process("创建完成!") | |
| 80 | - else: | |
| 81 | - raise Exception("影像服务器连接失败!") | |
| 82 | - except Exception as e: | |
| 83 | - try: | |
| 84 | - task_writer.update_task({"state": -1,"update_time":datetime.datetime.now(),"process": "创建失败"}) | |
| 85 | - task_writer.update_process(e.__str__()) | |
| 86 | - task_writer.update_process("任务中止!") | |
| 87 | - except Exception as ee: | |
| 88 | - StructurePrint().print(ee.__str__()) | |
| 89 | - raise e | |
| 90 | - finally: | |
| 91 | - try: | |
| 92 | - task_writer.close() | |
| 93 | - except Exception as e: | |
| 94 | - StructurePrint().print(e.__str__()) | |
| 95 | - | |
| 96 | - | |
| 97 | - api_doc = { | |
| 98 | - "tags": ["影像服务接口"], | |
| 99 | - "parameters": [ | |
| 100 | - {"name": "guid", | |
| 101 | - "in": "formData", | |
| 102 | - "type": "string", | |
| 103 | - "description": "guid"}, | |
| 104 | - {"name": "url", | |
| 105 | - "in": "formData", | |
| 106 | - "type": "string", | |
| 107 | - "description": "url"}, | |
| 108 | - {"name": "alias", | |
| 109 | - "in": "formData", | |
| 110 | - "type": "string", | |
| 111 | - "description": "影像alias"}, | |
| 112 | - ], | |
| 113 | - "responses": { | |
| 114 | - 200: { | |
| 115 | - "schema": { | |
| 116 | - "properties": { | |
| 117 | - } | |
| 118 | - } | |
| 119 | - } | |
| 120 | - } | |
| 121 | - } | |
| 122 | - |
| 1 | 1 | Listen 81 |
| 2 | 2 | <VirtualHost *:81> |
| 3 | - ServerName 172.26.60.100 | |
| 3 | + ServerName 172.26.60.101 | |
| 4 | 4 | WSGIDaemonProcess yourapplication processes=4 threads=16 |
| 5 | 5 | WSGIScriptAlias / /usr/src/app/run.wsgi |
| 6 | 6 | WSGIPassAuthorization On |
| ... | ... | @@ -14,7 +14,7 @@ Listen 81 |
| 14 | 14 | </VirtualHost> |
| 15 | 15 | Listen 82 |
| 16 | 16 | <VirtualHost *:82> |
| 17 | - ServerName 172.26.60.100 | |
| 17 | + ServerName 172.26.60.101 | |
| 18 | 18 | WSGIDaemonProcess monitormanager processes=1 threads=8 |
| 19 | 19 | WSGIScriptAlias / /usr/src/app/monitor.wsgi |
| 20 | 20 | WSGIPassAuthorization On | ... | ... |
| ... | ... | @@ -7,7 +7,7 @@ from osgeo import gdal,osr,ogr |
| 7 | 7 | from osgeo.gdal import * |
| 8 | 8 | from osgeo.ogr import * |
| 9 | 9 | |
| 10 | - | |
| 10 | +import os | |
| 11 | 11 | import json |
| 12 | 12 | |
| 13 | 13 | |
| ... | ... | @@ -65,9 +65,18 @@ def getInfo( path): |
| 65 | 65 | return json.dumps(info) |
| 66 | 66 | |
| 67 | 67 | if __name__ == '__main__': |
| 68 | + data_path = r"E:\Data\矢量数据\广州\广州\dataset.gdb" | |
| 69 | + | |
| 70 | + driver: Driver = ogr.GetDriverByName("OpenFileGDB") | |
| 71 | + ds: DataSource = driver.Open(data_path, 0) | |
| 72 | + layer : Layer = ds.GetLayer(0) | |
| 73 | + | |
| 74 | + | |
| 75 | + print(layer.GetMetadata()) | |
| 76 | + print(layer.GetDescription()) | |
| 77 | + print(layer.GetStyleTable()) | |
| 68 | 78 | |
| 69 | - path = r"E:\Data\zh.gdb" | |
| 70 | - print(getInfo(path)) | |
| 79 | + print(ds.GetStyleTable()) | |
| 71 | 80 | |
| 72 | 81 | |
| 73 | 82 | ... | ... |
请
注册
或
登录
后发表评论