正在显示
30 个修改的文件
包含
123 行增加
和
75 行删除
@@ -169,7 +169,7 @@ Include ports.conf | @@ -169,7 +169,7 @@ Include ports.conf | ||
169 | 169 | ||
170 | <Directory /var/www/> | 170 | <Directory /var/www/> |
171 | Options Indexes FollowSymLinks | 171 | Options Indexes FollowSymLinks |
172 | - AllowOverride None | 172 | + AllowOverride All |
173 | Require all granted | 173 | Require all granted |
174 | </Directory> | 174 | </Directory> |
175 | 175 | ||
@@ -180,8 +180,6 @@ Include ports.conf | @@ -180,8 +180,6 @@ Include ports.conf | ||
180 | #</Directory> | 180 | #</Directory> |
181 | 181 | ||
182 | 182 | ||
183 | - | ||
184 | - | ||
185 | # AccessFileName: The name of the file to look for in each directory | 183 | # AccessFileName: The name of the file to look for in each directory |
186 | # for additional configuration directives. See also the AllowOverride | 184 | # for additional configuration directives. See also the AllowOverride |
187 | # directive. | 185 | # directive. |
@@ -225,4 +223,6 @@ IncludeOptional conf-enabled/*.conf | @@ -225,4 +223,6 @@ IncludeOptional conf-enabled/*.conf | ||
225 | IncludeOptional sites-enabled/*.conf | 223 | IncludeOptional sites-enabled/*.conf |
226 | 224 | ||
227 | LoadModule wsgi_module "/usr/lib/apache2/modules/mod_wsgi-py38.cpython-38-x86_64-linux-gnu.so" | 225 | LoadModule wsgi_module "/usr/lib/apache2/modules/mod_wsgi-py38.cpython-38-x86_64-linux-gnu.so" |
228 | -WSGIPythonHome "/usr" | ||
226 | +WSGIPythonHome "/usr" | ||
227 | + | ||
228 | +LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so |
@@ -16,11 +16,7 @@ from app.util.component.StructuredPrint import StructurePrint | @@ -16,11 +16,7 @@ from app.util.component.StructuredPrint import StructurePrint | ||
16 | from app.util.component.PGUtil import PGUtil | 16 | from app.util.component.PGUtil import PGUtil |
17 | import os | 17 | import os |
18 | from app.modules.monitor.schedule import start_schedule | 18 | from app.modules.monitor.schedule import start_schedule |
19 | -import datetime | ||
20 | - | ||
21 | - | ||
22 | - | ||
23 | - | 19 | +import requests |
24 | 20 | ||
25 | class JSONEncoder(_JSONEncoder): | 21 | class JSONEncoder(_JSONEncoder): |
26 | """ | 22 | """ |
@@ -100,11 +96,6 @@ def create_app(): | @@ -100,11 +96,6 @@ def create_app(): | ||
100 | # 不检测https | 96 | # 不检测https |
101 | os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1' | 97 | os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1' |
102 | 98 | ||
103 | - | ||
104 | - @app.before_first_request | ||
105 | - def init_data(): | ||
106 | - pass | ||
107 | - | ||
108 | # start_schedule() | 99 | # start_schedule() |
109 | return app | 100 | return app |
110 | 101 | ||
@@ -122,7 +113,6 @@ def create_schedule(): | @@ -122,7 +113,6 @@ def create_schedule(): | ||
122 | 113 | ||
123 | # swagger设置 | 114 | # swagger设置 |
124 | swagger_config = Swagger.DEFAULT_CONFIG | 115 | swagger_config = Swagger.DEFAULT_CONFIG |
125 | - swagger_config.update(configure.swagger_configure) | ||
126 | Swagger(monitor, config=swagger_config) | 116 | Swagger(monitor, config=swagger_config) |
127 | 117 | ||
128 | # 创建数据库 | 118 | # 创建数据库 |
@@ -143,4 +133,5 @@ def create_schedule(): | @@ -143,4 +133,5 @@ def create_schedule(): | ||
143 | # 不检测https | 133 | # 不检测https |
144 | os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1' | 134 | os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1' |
145 | start_schedule() | 135 | start_schedule() |
136 | + | ||
146 | return monitor | 137 | return monitor |
@@ -10,7 +10,6 @@ from app.util.component.PGUtil import PGUtil | @@ -10,7 +10,6 @@ from app.util.component.PGUtil import PGUtil | ||
10 | import configure | 10 | import configure |
11 | from osgeo.ogr import DataSource | 11 | from osgeo.ogr import DataSource |
12 | from flask import current_app | 12 | from flask import current_app |
13 | -from authlib.integrations.flask_oauth2 import current_token | ||
14 | from app.util.component.UserCheck import UserCheck | 13 | from app.util.component.UserCheck import UserCheck |
15 | 14 | ||
16 | 15 |
@@ -9,7 +9,6 @@ from sqlalchemy import create_engine | @@ -9,7 +9,6 @@ from sqlalchemy import create_engine | ||
9 | import datetime | 9 | import datetime |
10 | from . import database_alias_check | 10 | from . import database_alias_check |
11 | from app.util.component.ApiTemplate import ApiTemplate | 11 | from app.util.component.ApiTemplate import ApiTemplate |
12 | -from authlib.integrations.flask_oauth2 import current_token | ||
13 | from app.util.component.UserCheck import UserCheck | 12 | from app.util.component.UserCheck import UserCheck |
14 | from app.util.component.PGUtil import PGUtil | 13 | from app.util.component.PGUtil import PGUtil |
15 | class Api(ApiTemplate): | 14 | class Api(ApiTemplate): |
@@ -54,10 +54,7 @@ class Api(ApiTemplate): | @@ -54,10 +54,7 @@ class Api(ApiTemplate): | ||
54 | 54 | ||
55 | # 提示信息 | 55 | # 提示信息 |
56 | res["msg"] = "下载格式为shp时,属性名长度超过10个字符将截取为10个字符,binary类型的属性将改成integer类型且值为0。" | 56 | res["msg"] = "下载格式为shp时,属性名长度超过10个字符将截取为10个字符,binary类型的属性将改成integer类型且值为0。" |
57 | - # table_names = self.para.get("table_name").split(",") | ||
58 | - # | ||
59 | - # for tn in table_names: | ||
60 | - # table = Table.query.filter_by() | 57 | + |
61 | 58 | ||
62 | res["msg"] = "" | 59 | res["msg"] = "" |
63 | res["result"] = True | 60 | res["result"] = True |
@@ -55,17 +55,19 @@ class Api(ApiTemplate): | @@ -55,17 +55,19 @@ class Api(ApiTemplate): | ||
55 | 55 | ||
56 | for meta in meta_list: | 56 | for meta in meta_list: |
57 | layers:dict = meta.get("layer") | 57 | layers:dict = meta.get("layer") |
58 | + | ||
58 | for layer_name_origin in layers.keys(): | 59 | for layer_name_origin in layers.keys(): |
60 | + | ||
59 | layer_name = layers.get(layer_name_origin) | 61 | layer_name = layers.get(layer_name_origin) |
60 | if pg_ds.GetLayerByName(layer_name) or InsertingLayerName.query.filter_by(name=layer_name).one_or_none(): | 62 | if pg_ds.GetLayerByName(layer_name) or InsertingLayerName.query.filter_by(name=layer_name).one_or_none(): |
61 | - res["data"][layer_name_origin]=0 | 63 | + res["data"][layer_name]=0 |
62 | res["result"] = False | 64 | res["result"] = False |
63 | # 判断特殊字符 | 65 | # 判断特殊字符 |
64 | elif re.search(r"\W",layer_name): | 66 | elif re.search(r"\W",layer_name): |
65 | - res["data"][layer_name_origin]=-1 | 67 | + res["data"][layer_name]=-1 |
66 | res["result"] = False | 68 | res["result"] = False |
67 | else : | 69 | else : |
68 | - res["data"][layer_name_origin] = 1 | 70 | + res["data"][layer_name] = 1 |
69 | 71 | ||
70 | if pg_ds: | 72 | if pg_ds: |
71 | try: | 73 | try: |
@@ -34,7 +34,7 @@ class Api(ApiTemplate): | @@ -34,7 +34,7 @@ class Api(ApiTemplate): | ||
34 | store_path = ZipUtil.unzip(self.para.get("data_path"),True) | 34 | store_path = ZipUtil.unzip(self.para.get("data_path"),True) |
35 | spatial_files = FileProcess.get_spatial_file(store_path) | 35 | spatial_files = FileProcess.get_spatial_file(store_path) |
36 | 36 | ||
37 | - elif self.para.get("data_path").endswith("shp"): | 37 | + elif self.para.get("data_path").endswith("shp"): |
38 | data_path=self.para.get("data_path") | 38 | data_path=self.para.get("data_path") |
39 | encoding_cpg_path = data_path.split(".shp")[0]+".cpg" | 39 | encoding_cpg_path = data_path.split(".shp")[0]+".cpg" |
40 | if not os.path.exists(encoding_cpg_path): | 40 | if not os.path.exists(encoding_cpg_path): |
@@ -96,7 +96,8 @@ class Api(ApiTemplate): | @@ -96,7 +96,8 @@ class Api(ApiTemplate): | ||
96 | if not ds: | 96 | if not ds: |
97 | raise Exception("打开数据失败!") | 97 | raise Exception("打开数据失败!") |
98 | layer: Layer = ds.GetLayer(0) | 98 | layer: Layer = ds.GetLayer(0) |
99 | - layer_name[layer.GetName().lower()] = layer.GetName().lower() | 99 | + |
100 | + layer_name[layer.GetName()] = layer.GetName() | ||
100 | 101 | ||
101 | if data_path.endswith("gdb"): | 102 | if data_path.endswith("gdb"): |
102 | info["type"] = "gdb" | 103 | info["type"] = "gdb" |
@@ -106,7 +107,9 @@ class Api(ApiTemplate): | @@ -106,7 +107,9 @@ class Api(ApiTemplate): | ||
106 | raise Exception("打开数据失败!") | 107 | raise Exception("打开数据失败!") |
107 | for i in range(ds.GetLayerCount()): | 108 | for i in range(ds.GetLayerCount()): |
108 | layer: Layer = ds.GetLayer(i) | 109 | layer: Layer = ds.GetLayer(i) |
109 | - layer_name[layer.GetName().lower()] = layer.GetName().lower() | 110 | + |
111 | + layer_name[layer.GetName()] = layer.GetName() | ||
112 | + | ||
110 | except Exception as e : | 113 | except Exception as e : |
111 | print(traceback.format_exc()) | 114 | print(traceback.format_exc()) |
112 | info={} | 115 | info={} |
@@ -28,7 +28,6 @@ class EntryDataVacuate: | @@ -28,7 +28,6 @@ class EntryDataVacuate: | ||
28 | try: | 28 | try: |
29 | metas: list = parameter.get("meta") | 29 | metas: list = parameter.get("meta") |
30 | 30 | ||
31 | - | ||
32 | # 总的入库是否成功 | 31 | # 总的入库是否成功 |
33 | is_success=True | 32 | is_success=True |
34 | 33 | ||
@@ -41,7 +40,7 @@ class EntryDataVacuate: | @@ -41,7 +40,7 @@ class EntryDataVacuate: | ||
41 | for meta in metas: | 40 | for meta in metas: |
42 | #设置编码 | 41 | #设置编码 |
43 | encoding = parameter.get("encoding") | 42 | encoding = parameter.get("encoding") |
44 | - if encoding: | 43 | + if encoding and encoding in ["GBK","gbk","UTF-8","utf-8"]: |
45 | gdal.SetConfigOption("SHAPE_ENCODING",encoding) | 44 | gdal.SetConfigOption("SHAPE_ENCODING",encoding) |
46 | else: | 45 | else: |
47 | gdal.SetConfigOption("SHAPE_ENCODING", "GBK") | 46 | gdal.SetConfigOption("SHAPE_ENCODING", "GBK") |
@@ -148,7 +147,7 @@ class EntryDataVacuate: | @@ -148,7 +147,7 @@ class EntryDataVacuate: | ||
148 | for i in range(ds.GetLayerCount()): | 147 | for i in range(ds.GetLayerCount()): |
149 | 148 | ||
150 | layer: Layer = ds.GetLayer(i) | 149 | layer: Layer = ds.GetLayer(i) |
151 | - if layer.GetName().lower() not in meta.get("layer").keys(): | 150 | + if layer.GetName() not in meta.get("layer").keys(): |
152 | continue | 151 | continue |
153 | is_success, new_layer_name = self.entry_one_layer(layer,this_task,meta) | 152 | is_success, new_layer_name = self.entry_one_layer(layer,this_task,meta) |
154 | new_layer_names.append(new_layer_name) | 153 | new_layer_names.append(new_layer_name) |
@@ -176,18 +175,19 @@ class EntryDataVacuate: | @@ -176,18 +175,19 @@ class EntryDataVacuate: | ||
176 | overwrite = parameter.get("overwrite") if parameter.get("overwrite") is not None and parameter.get("overwrite")=="yes" else "no" | 175 | overwrite = parameter.get("overwrite") if parameter.get("overwrite") is not None and parameter.get("overwrite")=="yes" else "no" |
177 | geom_name = parameter.get("geom_name") if parameter.get("geom_name") is not None else "geom" | 176 | geom_name = parameter.get("geom_name") if parameter.get("geom_name") is not None else "geom" |
178 | fid = parameter.get("fid") if parameter.get("fid") is not None else "fid" | 177 | fid = parameter.get("fid") if parameter.get("fid") is not None else "fid" |
179 | - options = ["OVERWRITE={}".format(overwrite), "FID={}".format(fid), "GEOMETRY_NAME={}".format(geom_name),"PRECISION=NO"] | ||
180 | 178 | ||
179 | + options = ["OVERWRITE={}".format(overwrite), "FID={}".format(fid), "GEOMETRY_NAME={}".format(geom_name),"PRECISION=NO","LAUNDER=NO"] | ||
181 | 180 | ||
182 | # 将线/面转多线多面 | 181 | # 将线/面转多线多面 |
183 | geom_type = GeometryAdapter.change_geom_type(layer.GetGeomType()) | 182 | geom_type = GeometryAdapter.change_geom_type(layer.GetGeomType()) |
184 | 183 | ||
185 | # 更改图层名 | 184 | # 更改图层名 |
186 | change_name = False | 185 | change_name = False |
187 | - origin_name = layer.GetName().lower() | 186 | + origin_name = layer.GetName() |
188 | 187 | ||
189 | # 新图层名 | 188 | # 新图层名 |
190 | new_layer_name: str = meta.get("layer").get(origin_name) | 189 | new_layer_name: str = meta.get("layer").get(origin_name) |
190 | + | ||
191 | origin_name = new_layer_name | 191 | origin_name = new_layer_name |
192 | no = 1 | 192 | no = 1 |
193 | while overwrite.__eq__("no") and this_task.pg_ds.GetLayerByName(new_layer_name) : | 193 | while overwrite.__eq__("no") and this_task.pg_ds.GetLayerByName(new_layer_name) : |
@@ -248,7 +248,7 @@ class EntryDataVacuate: | @@ -248,7 +248,7 @@ class EntryDataVacuate: | ||
248 | else: | 248 | else: |
249 | is_vacuate = 0 | 249 | is_vacuate = 0 |
250 | 250 | ||
251 | - this_task.register_table(pg_layer,new_layer_name,overwrite,parameter.get("creator"),is_vacuate,table_guid) | 251 | + this_task.register_table(pg_layer,parameter.get("creator"),is_vacuate,table_guid) |
252 | 252 | ||
253 | # 注册抽稀表 | 253 | # 注册抽稀表 |
254 | if vacuate: | 254 | if vacuate: |
@@ -312,7 +312,7 @@ class ThisTask: | @@ -312,7 +312,7 @@ class ThisTask: | ||
312 | self.process_session.add(task_process) | 312 | self.process_session.add(task_process) |
313 | self.process_session.commit() | 313 | self.process_session.commit() |
314 | 314 | ||
315 | - def register_table(self, layer: Layer, new_layer_name, overwrite, creator,is_vacuate,table_guid): | 315 | + def register_table(self, layer: Layer,creator,is_vacuate,table_guid): |
316 | ''' | 316 | ''' |
317 | 注册表 | 317 | 注册表 |
318 | :param layer: 图层 | 318 | :param layer: 图层 |
@@ -335,7 +335,9 @@ class ThisTask: | @@ -335,7 +335,9 @@ class ThisTask: | ||
335 | table = Table(guid=table_guid, | 335 | table = Table(guid=table_guid, |
336 | database_guid=self.database.guid, | 336 | database_guid=self.database.guid, |
337 | creator=creator, | 337 | creator=creator, |
338 | - name=new_layer_name, create_time=this_time, update_time=this_time, | 338 | + # name=new_layer_name, |
339 | + name=layer.GetName(), | ||
340 | + create_time=this_time, update_time=this_time, | ||
339 | catalog_guid=self.catalog_guid, table_type=GeometryAdapter.get_table_type(geom_type), | 341 | catalog_guid=self.catalog_guid, table_type=GeometryAdapter.get_table_type(geom_type), |
340 | extent=extent, | 342 | extent=extent, |
341 | feature_count=layer.GetFeatureCount(), | 343 | feature_count=layer.GetFeatureCount(), |
@@ -343,10 +345,10 @@ class ThisTask: | @@ -343,10 +345,10 @@ class ThisTask: | ||
343 | ) | 345 | ) |
344 | # 删除遗留业务数据 | 346 | # 删除遗留业务数据 |
345 | try: | 347 | try: |
346 | - history_table = self.sys_session.query(Table).filter_by(name=new_layer_name,database_guid=self.database.guid).all() | 348 | + history_table = self.sys_session.query(Table).filter_by(name=layer.GetName(),database_guid=self.database.guid).all() |
347 | except: | 349 | except: |
348 | self.sys_session: Session = PGUtil.get_db_session(configure.SQLALCHEMY_DATABASE_URI) | 350 | self.sys_session: Session = PGUtil.get_db_session(configure.SQLALCHEMY_DATABASE_URI) |
349 | - history_table = self.sys_session.query(Table).filter_by(name=new_layer_name,database_guid=self.database.guid).all() | 351 | + history_table = self.sys_session.query(Table).filter_by(name=layer.GetName(),database_guid=self.database.guid).all() |
350 | 352 | ||
351 | if history_table: | 353 | if history_table: |
352 | for ht in history_table: | 354 | for ht in history_table: |
@@ -357,7 +359,7 @@ class ThisTask: | @@ -357,7 +359,7 @@ class ThisTask: | ||
357 | 359 | ||
358 | for i in range(feature_defn.GetFieldCount()): | 360 | for i in range(feature_defn.GetFieldCount()): |
359 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) | 361 | field_defn: FieldDefn = feature_defn.GetFieldDefn(i) |
360 | - field_name = field_defn.GetName().lower() | 362 | + field_name = field_defn.GetName() |
361 | field_alias = field_name if field_defn.GetAlternativeName() is None or field_defn.GetAlternativeName().__eq__( | 363 | field_alias = field_name if field_defn.GetAlternativeName() is None or field_defn.GetAlternativeName().__eq__( |
362 | "") else field_defn.GetAlternativeName() | 364 | "") else field_defn.GetAlternativeName() |
363 | column = Columns(guid=uuid.uuid1().__str__(), table_guid=table_guid, | 365 | column = Columns(guid=uuid.uuid1().__str__(), table_guid=table_guid, |
@@ -6,7 +6,6 @@ from ..models import Columns | @@ -6,7 +6,6 @@ from ..models import Columns | ||
6 | import datetime | 6 | import datetime |
7 | from app.models import db | 7 | from app.models import db |
8 | from app.util.component.ApiTemplate import ApiTemplate | 8 | from app.util.component.ApiTemplate import ApiTemplate |
9 | -from authlib.integrations.flask_oauth2 import current_token | ||
10 | from app.util.component.UserCheck import UserCheck | 9 | from app.util.component.UserCheck import UserCheck |
11 | 10 | ||
12 | class Api(ApiTemplate): | 11 | class Api(ApiTemplate): |
@@ -9,7 +9,6 @@ from app.util.component.ApiTemplate import ApiTemplate | @@ -9,7 +9,6 @@ from app.util.component.ApiTemplate import ApiTemplate | ||
9 | from app.util.component.PGUtil import PGUtil | 9 | from app.util.component.PGUtil import PGUtil |
10 | import configure | 10 | import configure |
11 | from flask import current_app | 11 | from flask import current_app |
12 | -from authlib.integrations.flask_oauth2 import current_token | ||
13 | from app.util.component.UserCheck import UserCheck | 12 | from app.util.component.UserCheck import UserCheck |
14 | 13 | ||
15 | class Api(ApiTemplate): | 14 | class Api(ApiTemplate): |
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | #email: nheweijun@sina.com | 3 | #email: nheweijun@sina.com |
4 | 4 | ||
5 | import traceback | 5 | import traceback |
6 | -from ..models import Table,Database,Columns,db,TableVacuate,Task,Process,DES | 6 | +from ..models import Table,Database,Columns,db,TableVacuate,Task,DES |
7 | from osgeo.ogr import DataSource,FeatureDefn,FieldDefn,Layer | 7 | from osgeo.ogr import DataSource,FeatureDefn,FieldDefn,Layer |
8 | import datetime | 8 | import datetime |
9 | import uuid | 9 | import uuid |
@@ -17,7 +17,6 @@ from app.util.component.TaskController import TaskController | @@ -17,7 +17,6 @@ from app.util.component.TaskController import TaskController | ||
17 | from app.util.component.TaskWriter import TaskWriter | 17 | from app.util.component.TaskWriter import TaskWriter |
18 | import multiprocessing | 18 | import multiprocessing |
19 | import configure | 19 | import configure |
20 | -from authlib.integrations.flask_oauth2 import current_token | ||
21 | from app.util.component.UserCheck import UserCheck | 20 | from app.util.component.UserCheck import UserCheck |
22 | class Api(ApiTemplate): | 21 | class Api(ApiTemplate): |
23 | api_name = "数据刷新" | 22 | api_name = "数据刷新" |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | 5 | ||
6 | import datetime | 6 | import datetime |
7 | import traceback | 7 | import traceback |
8 | -from ..models import Table, Database, DES,Task,db,TableVacuate,Process | 8 | +from ..models import Table, Database, DES,Task,db,TableVacuate |
9 | from app.util.component.ApiTemplate import ApiTemplate | 9 | from app.util.component.ApiTemplate import ApiTemplate |
10 | from app.util.component.PGUtil import PGUtil | 10 | from app.util.component.PGUtil import PGUtil |
11 | from app.util.component.StructuredPrint import StructurePrint | 11 | from app.util.component.StructuredPrint import StructurePrint |
@@ -14,7 +14,6 @@ import uuid | @@ -14,7 +14,6 @@ import uuid | ||
14 | import configure | 14 | import configure |
15 | from osgeo.ogr import DataSource,Layer,Geometry | 15 | from osgeo.ogr import DataSource,Layer,Geometry |
16 | from osgeo import ogr | 16 | from osgeo import ogr |
17 | -from authlib.integrations.flask_oauth2 import current_token | ||
18 | from app.util.component.UserCheck import UserCheck | 17 | from app.util.component.UserCheck import UserCheck |
19 | from app.util.component.VacuateConf import VacuateConf | 18 | from app.util.component.VacuateConf import VacuateConf |
20 | from app.util.component.TaskController import TaskController | 19 | from app.util.component.TaskController import TaskController |
@@ -10,6 +10,9 @@ from app.util.component.ApiTemplate import ApiTemplate | @@ -10,6 +10,9 @@ from app.util.component.ApiTemplate import ApiTemplate | ||
10 | from app.util.component.PGUtil import PGUtil | 10 | from app.util.component.PGUtil import PGUtil |
11 | import json | 11 | import json |
12 | import decimal | 12 | import decimal |
13 | + | ||
14 | + | ||
15 | + | ||
13 | class Api(ApiTemplate): | 16 | class Api(ApiTemplate): |
14 | api_name = "数据浏览" | 17 | api_name = "数据浏览" |
15 | def process(self): | 18 | def process(self): |
@@ -56,6 +59,8 @@ class Api(ApiTemplate): | @@ -56,6 +59,8 @@ class Api(ApiTemplate): | ||
56 | d[column] = value.strftime('%Y-%m-%d %H:%M:%S') | 59 | d[column] = value.strftime('%Y-%m-%d %H:%M:%S') |
57 | elif isinstance(value, decimal.Decimal): | 60 | elif isinstance(value, decimal.Decimal): |
58 | d[column] = float(value) | 61 | d[column] = float(value) |
62 | + elif isinstance(value,datetime.date): | ||
63 | + d[column] = value.strftime('%Y-%m-%d %H:%M:%S') | ||
59 | else: | 64 | else: |
60 | d[column]=value | 65 | d[column]=value |
61 | pkey_dict.update(d) | 66 | pkey_dict.update(d) |
@@ -66,7 +71,7 @@ class Api(ApiTemplate): | @@ -66,7 +71,7 @@ class Api(ApiTemplate): | ||
66 | finally: | 71 | finally: |
67 | if db_session: | 72 | if db_session: |
68 | db_session.close() | 73 | db_session.close() |
69 | - return json.dumps(res) | 74 | + return json.dumps(res,ensure_ascii=False) |
70 | 75 | ||
71 | api_doc={ | 76 | api_doc={ |
72 | "tags":["管理接口"], | 77 | "tags":["管理接口"], |
@@ -5,7 +5,6 @@ | @@ -5,7 +5,6 @@ | ||
5 | 5 | ||
6 | from ..models import db,Task | 6 | from ..models import db,Task |
7 | from app.util.component.ApiTemplate import ApiTemplate | 7 | from app.util.component.ApiTemplate import ApiTemplate |
8 | -from authlib.integrations.flask_oauth2 import current_token | ||
9 | from app.util.component.UserCheck import UserCheck | 8 | from app.util.component.UserCheck import UserCheck |
10 | 9 | ||
11 | class Api(ApiTemplate): | 10 | class Api(ApiTemplate): |
@@ -4,17 +4,15 @@ | @@ -4,17 +4,15 @@ | ||
4 | #email: nheweijun@sina.com | 4 | #email: nheweijun@sina.com |
5 | 5 | ||
6 | from ..models import db,Task,Table,InsertingLayerName,Process | 6 | from ..models import db,Task,Table,InsertingLayerName,Process |
7 | - | ||
8 | from app.util.component.ApiTemplate import ApiTemplate | 7 | from app.util.component.ApiTemplate import ApiTemplate |
9 | from app.util.component.StructuredPrint import StructurePrint | 8 | from app.util.component.StructuredPrint import StructurePrint |
10 | import os | 9 | import os |
11 | import signal | 10 | import signal |
12 | import platform | 11 | import platform |
13 | -import json | ||
14 | import datetime | 12 | import datetime |
15 | import uuid | 13 | import uuid |
16 | -from authlib.integrations.flask_oauth2 import current_token | ||
17 | from app.util.component.UserCheck import UserCheck | 14 | from app.util.component.UserCheck import UserCheck |
15 | + | ||
18 | class Api(ApiTemplate): | 16 | class Api(ApiTemplate): |
19 | api_name = "停止任务" | 17 | api_name = "停止任务" |
20 | def para_check(self): | 18 | def para_check(self): |
@@ -12,8 +12,7 @@ from app.util.component.StructuredPrint import StructurePrint | @@ -12,8 +12,7 @@ from app.util.component.StructuredPrint import StructurePrint | ||
12 | class Api(ApiTemplate): | 12 | class Api(ApiTemplate): |
13 | 13 | ||
14 | def process(self): | 14 | def process(self): |
15 | - StructurePrint().print("test") | ||
16 | - return {"Name":socket.gethostname(),"Type":"DMapDMS"} | 15 | + return {"Name":socket.gethostname(),"Type":"DMapManager"} |
17 | 16 | ||
18 | api_doc={ | 17 | api_doc={ |
19 | "tags":["Index接口"], | 18 | "tags":["Index接口"], |
@@ -6,7 +6,6 @@ | @@ -6,7 +6,6 @@ | ||
6 | 6 | ||
7 | from app.util.component.ApiTemplate import ApiTemplate | 7 | from app.util.component.ApiTemplate import ApiTemplate |
8 | import requests | 8 | import requests |
9 | -from authlib.integrations.flask_oauth2 import current_token | ||
10 | from app.util.component.UserCheck import UserCheck | 9 | from app.util.component.UserCheck import UserCheck |
11 | 10 | ||
12 | class Api(ApiTemplate): | 11 | class Api(ApiTemplate): |
@@ -6,7 +6,6 @@ | @@ -6,7 +6,6 @@ | ||
6 | 6 | ||
7 | from app.util.component.ApiTemplate import ApiTemplate | 7 | from app.util.component.ApiTemplate import ApiTemplate |
8 | import requests | 8 | import requests |
9 | -from authlib.integrations.flask_oauth2 import current_token | ||
10 | from app.util.component.UserCheck import UserCheck | 9 | from app.util.component.UserCheck import UserCheck |
11 | 10 | ||
12 | class Api(ApiTemplate): | 11 | class Api(ApiTemplate): |
@@ -11,7 +11,6 @@ import requests | @@ -11,7 +11,6 @@ import requests | ||
11 | import configure | 11 | import configure |
12 | import json | 12 | import json |
13 | import datetime | 13 | import datetime |
14 | -from authlib.integrations.flask_oauth2 import current_token | ||
15 | from app.util.component.UserCheck import UserCheck | 14 | from app.util.component.UserCheck import UserCheck |
16 | 15 | ||
17 | class Api(ApiTemplate): | 16 | class Api(ApiTemplate): |
@@ -8,7 +8,6 @@ from app.models import db | @@ -8,7 +8,6 @@ from app.models import db | ||
8 | from app.modules.service.models import Service | 8 | from app.modules.service.models import Service |
9 | from app.modules.service.models import TileService | 9 | from app.modules.service.models import TileService |
10 | from app.modules.service.models import MapService | 10 | from app.modules.service.models import MapService |
11 | -from authlib.integrations.flask_oauth2 import current_token | ||
12 | from app.util.component.UserCheck import UserCheck | 11 | from app.util.component.UserCheck import UserCheck |
13 | 12 | ||
14 | class Api(ApiTemplate): | 13 | class Api(ApiTemplate): |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | 5 | ||
6 | from app.util.component.ApiTemplate import ApiTemplate | 6 | from app.util.component.ApiTemplate import ApiTemplate |
7 | from app.modules.service.models import Service | 7 | from app.modules.service.models import Service |
8 | -import requests | 8 | + |
9 | 9 | ||
10 | 10 | ||
11 | class Api(ApiTemplate): | 11 | class Api(ApiTemplate): |
@@ -70,7 +70,7 @@ class Api(ApiTemplate): | @@ -70,7 +70,7 @@ class Api(ApiTemplate): | ||
70 | else: | 70 | else: |
71 | raw_json = response.json()["data"]["list"] | 71 | raw_json = response.json()["data"]["list"] |
72 | if state: | 72 | if state: |
73 | - raw_json = [ service for service in raw_json if service["state"] == state] | 73 | + raw_json = [ service for service in raw_json if service["state"] == int(state)] |
74 | if type: | 74 | if type: |
75 | raw_json = [service for service in raw_json if service["type"] == type] | 75 | raw_json = [service for service in raw_json if service["type"] == type] |
76 | if catalog_guid: | 76 | if catalog_guid: |
@@ -6,9 +6,7 @@ | @@ -6,9 +6,7 @@ | ||
6 | 6 | ||
7 | from app.util.component.ApiTemplate import ApiTemplate | 7 | from app.util.component.ApiTemplate import ApiTemplate |
8 | from .models import TileService,db,Service,MapService | 8 | from .models import TileService,db,Service,MapService |
9 | -import configure | ||
10 | from app.util.component.ModelVisitor import ModelVisitor | 9 | from app.util.component.ModelVisitor import ModelVisitor |
11 | - | ||
12 | from .tile_service.util.ProjectFile import ProjectFile | 10 | from .tile_service.util.ProjectFile import ProjectFile |
13 | 11 | ||
14 | 12 |
@@ -3,11 +3,11 @@ | @@ -3,11 +3,11 @@ | ||
3 | #createtime: 2021/9/14 | 3 | #createtime: 2021/9/14 |
4 | #email: nheweijun@sina.com | 4 | #email: nheweijun@sina.com |
5 | 5 | ||
6 | - | ||
7 | - | ||
8 | - | 6 | +from app.util.component.UserCheck import UserCheck |
9 | from app.util.component.ApiTemplate import ApiTemplate | 7 | from app.util.component.ApiTemplate import ApiTemplate |
10 | from .models import Service,db | 8 | from .models import Service,db |
9 | +import requests | ||
10 | + | ||
11 | class Api(ApiTemplate): | 11 | class Api(ApiTemplate): |
12 | api_name = "修改服务状态" | 12 | api_name = "修改服务状态" |
13 | def process(self): | 13 | def process(self): |
@@ -17,10 +17,10 @@ class Api(ApiTemplate): | @@ -17,10 +17,10 @@ class Api(ApiTemplate): | ||
17 | state = int(self.para.get("state")) | 17 | state = int(self.para.get("state")) |
18 | s_type = self.para.get("type") | 18 | s_type = self.para.get("type") |
19 | 19 | ||
20 | - | ||
21 | - #删除本地服务 | ||
22 | if s_type in ["切片服务","地图服务","地址匹配"]: | 20 | if s_type in ["切片服务","地图服务","地址匹配"]: |
23 | service = Service.query.filter_by(guid=guid).one_or_none() | 21 | service = Service.query.filter_by(guid=guid).one_or_none() |
22 | + # 验证权限 | ||
23 | + UserCheck.verify(service.creator) | ||
24 | 24 | ||
25 | if service: | 25 | if service: |
26 | service.state = state | 26 | service.state = state |
@@ -30,10 +30,18 @@ class Api(ApiTemplate): | @@ -30,10 +30,18 @@ class Api(ApiTemplate): | ||
30 | raise Exception("服务不存在!") | 30 | raise Exception("服务不存在!") |
31 | # 删除影像服务 | 31 | # 删除影像服务 |
32 | else: | 32 | else: |
33 | - from app.modules.service.image_service.image_service_edit import Api as RealApi | ||
34 | - api = RealApi() | ||
35 | - api.para = self.para | ||
36 | - res = api.process() | 33 | + user_req: requests.Response = requests.post("{}/API/Service/Info".format(self.para.get("url")), |
34 | + data={"guid": self.para.get("guid")}) | ||
35 | + if not user_req.json().get("result"): | ||
36 | + raise Exception("服务不存在!") | ||
37 | + # 验证权限 | ||
38 | + UserCheck.verify(user_req.json().get("data").get("service").get("creator")) | ||
39 | + | ||
40 | + url = "{}/API/Service/State".format(self.para.get("url")) | ||
41 | + response: requests.Response = requests.post(url, data=self.para) | ||
42 | + if not response.json().get("result"): | ||
43 | + raise Exception("由于{},影像服务修改失败!".format(response.json().get("msg"))) | ||
44 | + res["result"] = True | ||
37 | 45 | ||
38 | except Exception as e: | 46 | except Exception as e: |
39 | raise e | 47 | raise e |
@@ -14,7 +14,6 @@ from .util.ProjectFile import ProjectFile | @@ -14,7 +14,6 @@ from .util.ProjectFile import ProjectFile | ||
14 | import json | 14 | import json |
15 | from requests import Response | 15 | from requests import Response |
16 | import configure | 16 | import configure |
17 | -from authlib.integrations.flask_oauth2 import current_token | ||
18 | from app.util.component.UserCheck import UserCheck | 17 | from app.util.component.UserCheck import UserCheck |
19 | 18 | ||
20 | class Api(ApiTemplate): | 19 | class Api(ApiTemplate): |
@@ -29,7 +28,7 @@ class Api(ApiTemplate): | @@ -29,7 +28,7 @@ class Api(ApiTemplate): | ||
29 | if not service: | 28 | if not service: |
30 | raise Exception("服务不存在!") | 29 | raise Exception("服务不存在!") |
31 | #验证权限 | 30 | #验证权限 |
32 | - UserCheck.verify(service.creator) | 31 | + UserCheck.verify(service.one_or_none().creator) |
33 | 32 | ||
34 | this_time = datetime.datetime.now() | 33 | this_time = datetime.datetime.now() |
35 | 34 |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | 5 | ||
6 | 6 | ||
7 | from app.util.component.ApiTemplate import ApiTemplate | 7 | from app.util.component.ApiTemplate import ApiTemplate |
8 | -from app.util.component.ModelVisitor import ModelVisitor | 8 | +from app.util.component.StructuredPrint import StructurePrint |
9 | import uuid | 9 | import uuid |
10 | from ..models import TileService,Service,db,ServiceFunction,TileScheme | 10 | from ..models import TileService,Service,db,ServiceFunction,TileScheme |
11 | 11 | ||
@@ -41,8 +41,12 @@ class Api(ApiTemplate): | @@ -41,8 +41,12 @@ class Api(ApiTemplate): | ||
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), |
42 | headers={'Content-Type':'application/json'},timeout=3 | 42 | headers={'Content-Type':'application/json'},timeout=3 |
43 | ) | 43 | ) |
44 | + | ||
44 | resp.encoding="utf-8" | 45 | resp.encoding="utf-8" |
45 | resp_json = resp.json() | 46 | resp_json = resp.json() |
47 | + StructurePrint().print(para) | ||
48 | + StructurePrint().print(resp_json) | ||
49 | + | ||
46 | if not resp_json["status"]=="1": | 50 | if not resp_json["status"]=="1": |
47 | raise Exception("调用切片服务的注册服务接口失败!") | 51 | raise Exception("调用切片服务的注册服务接口失败!") |
48 | 52 | ||
@@ -105,7 +109,7 @@ class Api(ApiTemplate): | @@ -105,7 +109,7 @@ class Api(ApiTemplate): | ||
105 | res["result"] = True | 109 | res["result"] = True |
106 | except Exception as e: | 110 | except Exception as e: |
107 | db.session.rollback() | 111 | db.session.rollback() |
108 | - raise Exception("数据库错误!") | 112 | + raise e |
109 | return res | 113 | return res |
110 | 114 | ||
111 | 115 |
@@ -30,7 +30,7 @@ class ModelVisitor: | @@ -30,7 +30,7 @@ class ModelVisitor: | ||
30 | continue | 30 | continue |
31 | if isinstance(value, datetime.datetime): | 31 | if isinstance(value, datetime.datetime): |
32 | value = value.strftime('%Y-%m-%d %H:%M:%S') | 32 | value = value.strftime('%Y-%m-%d %H:%M:%S') |
33 | - elif isinstance(value, datetime.time): | 33 | + elif isinstance(value, datetime.time) or isinstance(value, datetime.date): |
34 | value = value.strftime('%H:%M:%S') | 34 | value = value.strftime('%H:%M:%S') |
35 | yield k,value | 35 | yield k,value |
36 | return dict(generator()) | 36 | return dict(generator()) |
@@ -3,7 +3,7 @@ import logging | @@ -3,7 +3,7 @@ import logging | ||
3 | # 程序部署ip:host | 3 | # 程序部署ip:host |
4 | deploy_ip_host = "172.26.40.105:8840" | 4 | deploy_ip_host = "172.26.40.105:8840" |
5 | # 系统数据库 | 5 | # 系统数据库 |
6 | -SQLALCHEMY_DATABASE_URI = "postgresql://postgres:chinadci@172.26.60.100:5432/dmap_manager" | 6 | +SQLALCHEMY_DATABASE_URI = "postgresql://postgres:chinadci@172.26.60.101:5432/dmap_manager" |
7 | 7 | ||
8 | # 指定精华表所在位置(必须为空间库),设置为None则存放在各自的实体库中 | 8 | # 指定精华表所在位置(必须为空间库),设置为None则存放在各自的实体库中 |
9 | #VACUATE_DB_URI = None | 9 | #VACUATE_DB_URI = None |
run.manager.sh
0 → 100644
1 | +#! /bin/sh | ||
2 | +container_name="dmapmanager" | ||
3 | +#停止容器 | ||
4 | +echo "正在关闭容器..." | ||
5 | +docker stop $container_name | ||
6 | +docker rm $container_name | ||
7 | + | ||
8 | +curPath=$(readlink -f $(dirname $0)) | ||
9 | + | ||
10 | + | ||
11 | +#设置日志权限 | ||
12 | +chmod -R 777 $curPath | ||
13 | + | ||
14 | +#设置端口 | ||
15 | +port="" | ||
16 | +if [ ! -n "$1" ] ;then | ||
17 | + | ||
18 | +port1="8830" | ||
19 | +echo "未设置端口1,使用默认8830端口..." | ||
20 | +else | ||
21 | +port1=$1 | ||
22 | +echo "端口1设置为$1 ..." | ||
23 | +fi | ||
24 | + | ||
25 | +port2="" | ||
26 | +if [ ! -n "$2" ] ;then | ||
27 | +port2="8840" | ||
28 | +echo "未设置端口2,使用默认8840端口..." | ||
29 | +else | ||
30 | +port2=$2 | ||
31 | +echo "端口2设置为$2 ..." | ||
32 | +fi | ||
33 | + | ||
34 | +port3="" | ||
35 | +if [ ! -n "$3" ] ;then | ||
36 | +port3="8841" | ||
37 | +echo "未设置端口3,使用默认8841端口..." | ||
38 | +else | ||
39 | +port3=$3 | ||
40 | +echo "端口3设置为$3 ..." | ||
41 | +fi | ||
42 | + | ||
43 | +#启动容器 | ||
44 | +echo "正在启动容器..." | ||
45 | + | ||
46 | +set="--restart=always -e ALLOW_IP_RANGE=0.0.0.0/0 -p $port1:80 -p $port2:81 -p $port3:82" | ||
47 | +codeMap="-v ${curPath}:/usr/src/app -v ${curPath}/html:/var/www/html" | ||
48 | +apacheMap="-v ${curPath}/apache2.conf:/etc/apache2/apache2.conf -v ${curPath}/dmapmanager.conf:/etc/apache2/sites-enabled/dmapmanager.conf -v ${curPath}/envvars:/etc/apache2/envvars" | ||
49 | + | ||
50 | +docker run -it -d --name ${container_name} ${set} ${codeMap} ${apacheMap} dci/dmapmanager:4.1 | ||
51 | +sleep 5 | ||
52 | +curl localhost:$port2/release | ||
53 | +curl localhost:$port3 |
@@ -34,7 +34,7 @@ fi | @@ -34,7 +34,7 @@ fi | ||
34 | #启动容器和apache | 34 | #启动容器和apache |
35 | echo "正在启动容器..." | 35 | echo "正在启动容器..." |
36 | set="--privileged=true -e TZ="Asia/Shanghai" --restart=always -e ALLOW_IP_RANGE=0.0.0.0/0 -e LAND=C.UTF-8" | 36 | set="--privileged=true -e TZ="Asia/Shanghai" --restart=always -e ALLOW_IP_RANGE=0.0.0.0/0 -e LAND=C.UTF-8" |
37 | -docker run -it -d --name ${container_name} ${set} -p ${port}:80 -p ${port2}:81 -v ${curPath}:/usr/src/app -v ${curPath}/apache2.conf:/etc/apache2/apache2.conf -v ${curPath}/dmapmanager.conf:/etc/apache2/sites-enabled/dmapmanager.conf -v ${curPath}/envvars:/etc/apache2/envvars dci/dmapserver:build | 37 | +docker run -it -d --name ${container_name} ${set} -p ${port}:81 -p ${port2}:82 -v ${curPath}:/usr/src/app -v ${curPath}/apache2.conf:/etc/apache2/apache2.conf -v ${curPath}/dmapmanager.conf:/etc/apache2/sites-enabled/dmapmanager.conf -v ${curPath}/envvars:/etc/apache2/envvars dci/dmapserver:build |
38 | docker exec -d $container_name service apache2 start | 38 | docker exec -d $container_name service apache2 start |
39 | sleep 5 | 39 | sleep 5 |
40 | curl localhost:$port/release | 40 | curl localhost:$port/release |
请
注册
或
登录
后发表评论