提交 552a5a45e77f7d994b76b94a650dd34259aeeeb1

作者 nheweijun
1 个父辈 fbf2e83c

服务整合架构调整

... ... @@ -28,7 +28,7 @@ class Api(ApiTemplate):
28 28 service = Service.query.filter_by(guid=guid)
29 29 this_time = datetime.datetime.now()
30 30 image_guids = self.para.get("image_guids")
31   - function_types = self.para.get("function_types")
  31 + functions = self.para.get("functions")
32 32
33 33 service_update = {}
34 34 image_update = {}
... ... @@ -42,15 +42,16 @@ class Api(ApiTemplate):
42 42 image_service = ImageService.query.filter_by(service_guid=guid)
43 43
44 44 # 修改功能
45   - if function_types:
46   - new_types = function_types.split(",")
  45 + if functions:
  46 + new_types = functions.split(",")
47 47 old_functions = ServiceFunction.query.filter_by(service_guid=guid).all()
48 48 for function in old_functions:
49 49 if function.type not in new_types:
50 50 db.session.delete(function)
51 51 for new_type in new_types:
52 52 if new_type not in [fun.type for fun in old_functions]:
53   - service_function = ServiceFunction(guid=uuid.uuid1().__str__())
  53 + service_function = ServiceFunction(guid=uuid.uuid1().__str__(),type=new_type,
  54 + service_guid=guid)
54 55 db.session.add(service_function)
55 56
56 57 #修改影像
... ... @@ -74,7 +75,7 @@ class Api(ApiTemplate):
74 75
75 76 image_update["extent"] = json.dumps(image_service_exetent)
76 77
77   - if service_update or image_update or function_types:
  78 + if service_update or image_update or functions:
78 79 service_update["update_time"] = this_time
79 80 if image_guids:
80 81 register_api = RegisterApi()
... ... @@ -125,7 +126,7 @@ class Api(ApiTemplate):
125 126 "type": "string",
126 127 "description": "[地图服务,切片服务,影像服务]"},
127 128
128   - {"name": "function_types",
  129 + {"name": "functions",
129 130 "in": "formData",
130 131 "type": "string",
131 132 "description": "[地图服务,切片服务,影像服务]以逗号相隔,可选WMTS,WMS"},
... ...
... ... @@ -34,7 +34,7 @@ class Api(ApiTemplate):
34 34 try:
35 35 guids = self.para.get("guids").split(",")
36 36 name = self.para.get("name")
37   - function_types = self.para.get("function_types")
  37 + functions = self.para.get("functions")
38 38
39 39
40 40 image_service_guid = uuid.uuid1().__str__()
... ... @@ -82,7 +82,7 @@ class Api(ApiTemplate):
82 82
83 83
84 84
85   - for type in function_types.split(","):
  85 + for type in functions.split(","):
86 86 service_function = ServiceFunction(guid=service_function_guid,
87 87 service_guid=service_guid,
88 88 type=type)
... ... @@ -98,7 +98,7 @@ class Api(ApiTemplate):
98 98 configure.deploy_ip_host,overview_file)
99 99
100 100 db.session.commit()
101   - res["data"] = image_service_guid
  101 + res["data"] = service_guid
102 102 res["result"] = True
103 103 except Exception as e:
104 104 db.session.rollback()
... ... @@ -108,7 +108,7 @@ class Api(ApiTemplate):
108 108
109 109 def get_overview(self,service,image_service):
110 110
111   - api = RealApi("")
  111 + api = RealApi(service.name)
112 112
113 113
114 114 query_extent = json.loads(image_service.extent)
... ... @@ -171,7 +171,7 @@ class Api(ApiTemplate):
171 171 "in": "formData",
172 172 "type": "string",
173 173 "description": "[影像服务]切片方案"},
174   - {"name": "function_types",
  174 + {"name": "functions",
175 175 "in": "formData",
176 176 "type": "string",
177 177 "description": "[影像服务]功能类型,以逗号相隔,可选WMTS,WMS"},
... ...
... ... @@ -53,8 +53,7 @@ class Cache:
53 53 if type.__eq__("guid"):
54 54 image_service: ImageService = ImageService.query.filter_by(guid=guid_or_name).one_or_none()
55 55 else:
56   - service = Service.query.filter_by(name=guid_or_name).one_or_none()
57   - image_service: ImageService = ImageService.query.filter_by(guid=service.service_guid).one_or_none()
  56 + image_service: ImageService = ImageService.query.filter_by(name=guid_or_name).one_or_none()
58 57 images = image_service.images.all()
59 58
60 59 if image_service.scheme_guid:
... ...
... ... @@ -6,7 +6,7 @@
6 6
7 7 from app.util.component.ApiTemplate import ApiTemplate
8 8 import uuid
9   -from ..models import Service,MapService,db
  9 +from ..models import Service,MapService,db,ServiceFunction
10 10
11 11
12 12 import datetime
... ... @@ -21,6 +21,7 @@ class Api(ApiTemplate):
21 21
22 22 try:
23 23 guid = self.para.get("guid")
  24 + functions = self.para.get("functions")
24 25 service = Service.query.filter_by(guid=guid)
25 26 this_time = datetime.datetime.now()
26 27
... ... @@ -35,6 +36,19 @@ class Api(ApiTemplate):
35 36 map_service_update[key] = self.para.get(key)
36 37
37 38
  39 + # 修改功能
  40 + if functions:
  41 + new_types = functions.split(",")
  42 + old_functions = ServiceFunction.query.filter_by(service_guid=guid).all()
  43 + for function in old_functions:
  44 + if function.type not in new_types:
  45 + db.session.delete(function)
  46 + for new_type in new_types:
  47 + if new_type not in [fun.type for fun in old_functions]:
  48 + service_function = ServiceFunction(guid=uuid.uuid1().__str__(),type=new_type,
  49 + service_guid=guid)
  50 + db.session.add(service_function)
  51 +
38 52 map_service = MapService.query.filter_by(service_guid=guid)
39 53
40 54 if service_update:
... ...
... ... @@ -182,6 +182,7 @@ class TileService(db.Model):
182 182 #基本信息
183 183 name = Column(String,unique = True)
184 184
  185 + tile_type = Column(String(256))
185 186 #厂家
186 187 vendor = Column(String(256))
187 188 create_time = Column(DateTime)
... ...
... ... @@ -46,133 +46,138 @@ class Api(ApiTemplate):
46 46 {"name": "guid",
47 47 "in": "formData",
48 48 "type": "string",
49   - "description": "[WMS,WMTS,影像WMS,影像WMTS,guid]"},
  49 + "description": "[服务guid]"},
50 50
51 51 {"name": "type",
52 52 "in": "formData",
53 53 "type": "string",
54   - "enum": ["WMS/WFS", "WMTS", "TMS", "ImageWMS", "ImageWMTS"],
55   - "description": "[WMS,WMTS,影像WMS,影像WMTS]"},
  54 + "enum": ["地图服务","切片服务","影像服务"],
  55 + "description": "[地图服务,切片服务,影像服务]"},
56 56
57 57 {"name": "name",
58 58 "in": "formData",
59 59 "type": "string",
60   - "description": "[WMS,WMTS,影像WMS,影像WMTS]"},
  60 + "description": "[地图服务,切片服务,影像服务]"},
61 61 {"name": "title",
62 62 "in": "formData",
63 63 "type": "string",
64   - "description": "[WMS,WMTS,影像WMS,影像WMTS]"},
  64 + "description": "[地图服务,切片服务,影像服务]"},
65 65 {"name": "description",
66 66 "in": "formData",
67 67 "type": "string",
68   - "description": "[WMS,WMTS,影像WMS,影像WMTS]"},
  68 + "description": "[地图服务,切片服务,影像服务]"},
69 69
70 70 {"name": "catalog_guid",
71 71 "in": "formData",
72 72 "type": "string",
73   - "description": "[WMS,WMTS,影像WMS,影像WMTS]"},
  73 + "description": "[地图服务,切片服务,影像服务]"},
  74 +
  75 + {"name": "functions",
  76 + "in": "formData",
  77 + "type": "string",
  78 + "description": "[地图服务,影像服务]以逗号相隔,可选WMTS,WMS"},
74 79
75 80 # 影像参数
76 81 {"name": "image_guids",
77 82 "in": "formData",
78 83 "type": "string",
79   - "description": "[影像WMS,影像WMTS]影像guids,以英文逗号相隔"},
  84 + "description": "[影像服务]影像guids,以英文逗号相隔"},
80 85 {"name": "scheme_guid",
81 86 "in": "formData",
82 87 "type": "string",
83   - "description": "[WMTS,影像WMTS]切片方案"},
  88 + "description": "[切片服务,影像服务]切片方案"},
84 89
85   - # WMTS参数
  90 + # 切片参数
86 91 {"name": "overview",
87 92 "in": "formData",
88 93 "type": "string",
89   - "description": "[WMTS]缩略图"},
90   - {"name": "wmts_type",
  94 + "description": "[切片服务]缩略图"},
  95 + {"name": "tile_type",
91 96 "in": "formData",
92 97 "type": "string",
93   - "description": "[WMTS]wmts_type"},
  98 + "description": "[切片服务]tile_type"},
94 99 {"name": "vendor",
95 100 "in": "formData",
96 101 "type": "string",
97   - "description": "[WMTS]厂商"},
  102 + "description": "[切片服务]厂商"},
98 103 {"name": "crs",
99 104 "in": "formData",
100 105 "type": "string",
101   - "description": "[WMTS]坐标系"},
  106 + "description": "[切片服务]坐标系"},
102 107 {"name": "datasource",
103 108 "in": "formData",
104 109 "type": "string",
105   - "description": "[WMTS]数据路径"},
  110 + "description": "[切片服务]数据路径"},
106 111 {"name": "layer_name",
107 112 "in": "formData",
108 113 "type": "string",
109   - "description": "[WMTS]图层名"},
  114 + "description": "[切片服务]图层名"},
110 115 {"name": "layer_alias",
111 116 "in": "formData",
112 117 "type": "string",
113   - "description": "[WMTS]图层别名"},
  118 + "description": "[切片服务]图层别名"},
114 119 {"name": "layer_title",
115 120 "in": "formData",
116 121 "type": "string",
117   - "description": "[WMTS]图层标题"},
  122 + "description": "[切片服务]图层标题"},
118 123 {"name": "layer_style",
119 124 "in": "formData",
120 125 "type": "string",
121   - "description": "[WMTS,WMS]图层样式"},
  126 + "description": "[地图服务,切片服务]图层样式"},
122 127 {"name": "layer_format",
123 128 "in": "formData",
124 129 "type": "string",
125   - "description": "[WMTS]图层format"},
  130 + "description": "[切片服务]图层format"},
126 131 {"name": "layer_extent",
127 132 "in": "formData",
128 133 "type": "string",
129   - "description": "[WMTS]图层范围"},
  134 + "description": "[切片服务]图层范围"},
130 135 {"name": "layer_description",
131 136 "in": "formData",
132 137 "type": "string",
133   - "description": "[WMTS]图层描述"},
  138 + "description": "[切片服务]图层描述"},
134 139
135 140 # WMS参数
136 141 {"name": "status",
137 142 "in": "formData",
138 143 "type": "string",
139   - "description": "[WMS]status"},
  144 + "description": "[地图服务]status"},
140 145 {"name": "username",
141 146 "in": "formData",
142 147 "type": "string",
143   - "description": "[WMS]username"},
  148 + "description": "[地图服务]username"},
144 149 {"name": "readonly",
145 150 "in": "formData",
146 151 "type": "string",
147   - "description": "[WMS]readonly"},
  152 + "description": "[地图服务]readonly"},
148 153 {"name": "sid",
149 154 "in": "formData",
150 155 "type": "string",
151   - "description": "[WMS]sid"},
  156 + "description": "[地图服务]sid"},
152 157 {"name": "stype",
153 158 "in": "formData",
154 159 "type": "string",
155   - "description": "[WMS]stype"},
  160 + "description": "[地图服务]stype"},
156 161 {"name": "ssupply",
157 162 "in": "formData",
158 163 "type": "string",
159   - "description": "[WMS]ssupply"},
  164 + "description": "[地图服务]ssupply"},
160 165 {"name": "sctime",
161 166 "in": "formData",
162 167 "type": "string",
163   - "description": "[WMS]sctime"},
  168 + "description": "[地图服务]sctime"},
164 169 {"name": "company",
165 170 "in": "formData",
166 171 "type": "string",
167   - "description": "[WMS]company"},
  172 + "description": "[地图服务]company"},
168 173 {"name": "abstract",
169 174 "in": "formData",
170 175 "type": "string",
171   - "description": "[WMS]abstract"},
  176 + "description": "[地图服务]abstract"},
172 177 {"name": "thumbnail",
173 178 "in": "formData",
174 179 "type": "string",
175   - "description": "[WMS]thumbnail"},
  180 + "description": "[地图服务]thumbnail"},
176 181 ],
177 182 "responses": {
178 183 200: {
... ...
... ... @@ -20,29 +20,24 @@ class Api(ApiTemplate):
20 20 res["data"] = {}
21 21
22 22 if service.type.__eq__("影像服务"):
23   - from app.modules.service.models import ImageService
24   - speci_service = ImageService.query.filter_by(guid=service.service_guid).one_or_none()
  23 + speci_service = service.relate_image_service.one_or_none()
25 24 relate_images = speci_service.images.all()
26 25 res["data"]["speci_service"] = ModelVisitor.object_to_json(speci_service)
27   -
28 26 res["data"]["speci_service"]["images"] = [{"name":im["name"],"guid":im["guid"]} for im in ModelVisitor.objects_to_jsonarray(relate_images)]
29 27 res["data"]["speci_service"]["images"] = sorted(res["data"]["speci_service"]["images"], key=lambda x: x["name"])
30 28
31 29 elif service.type.__eq__("切片服务"):
32   - from app.modules.service.models import MapService
33   - speci_service = MapService.query.filter_by(guid=service.service_guid).one_or_none()
34   -
  30 + speci_service = service.relate_map_service.one_or_none()
35 31 res["data"]["speci_service"] = ModelVisitor.object_to_json(speci_service)
36   -
37 32 elif service.type.__eq__("地图服务"):
38   - from app.modules.service.models import TileService
39   - speci_service = TileService.query.filter_by(guid=service.service_guid).one_or_none()
  33 + speci_service = service.relate_tile_service.one_or_none()
40 34 res["data"]["speci_service"] = ModelVisitor.object_to_json(speci_service)
41 35 else:
42 36 res["data"] = {}
43 37
  38 + functions = ModelVisitor.objects_to_jsonarray(service.relate_service_functions.all())
44 39 res["data"]["service"] = ModelVisitor.object_to_json(service)
45   -
  40 + res["data"]["service"]["functions"] = functions
46 41 except Exception as e:
47 42 raise e
48 43 return res
... ...
... ... @@ -6,7 +6,7 @@
6 6
7 7 from app.util.component.ApiTemplate import ApiTemplate
8 8 from app.util.component.ModelVisitor import ModelVisitor
9   -from .models import Service
  9 +from .models import Service,ServiceFunction
10 10 from sqlalchemy import or_
11 11
12 12
... ... @@ -48,6 +48,11 @@ class Api(ApiTemplate):
48 48 res["data"]["count"] = services.count()
49 49 services = services.limit(page_size).offset(page_index * page_size).all()
50 50 res["data"]["list"] = ModelVisitor.objects_to_jsonarray(services)
  51 +
  52 + for service_json in res["data"]["list"]:
  53 + service_json["functions"] = sorted(ModelVisitor.objects_to_jsonarray(ServiceFunction.query.filter_by(service_guid=service_json["guid"]).all()),
  54 + key=lambda x:x["type"])
  55 +
51 56 res["result"] = True
52 57
53 58
... ...
... ... @@ -68,10 +68,10 @@ class Api(ApiTemplate):
68 68 "in": "formData",
69 69 "type": "string",
70 70 "description": "[切片服务,影像服务]切片方案"},
71   - {"name": "function_types",
  71 + {"name": "functions",
72 72 "in": "formData",
73 73 "type": "string",
74   - "description": "[影像服务]function_types",
  74 + "description": "[影像服务]functions",
75 75 "enum": ["WMS","WMTS"]},
76 76
77 77 # 切片参数
... ...
... ... @@ -5,7 +5,7 @@
5 5
6 6 from app.util.component.ApiTemplate import ApiTemplate
7 7 import uuid
8   -from ..models import TileService,Service,db
  8 +from ..models import TileService,Service,db,ServiceFunction
9 9
10 10
11 11 import datetime
... ... @@ -37,6 +37,20 @@ class Api(ApiTemplate):
37 37 tile_update[key] = self.para.get(key)
38 38
39 39 tile_service = TileService.query.filter_by(service_guid=guid)
  40 +
  41 + tile_type = self.para.get("tile_type")
  42 +
  43 + # 修改功能
  44 + if tile_type:
  45 + old_functions = ServiceFunction.query.filter_by(service_guid=guid).all()
  46 + for function in old_functions:
  47 + if not function.type.__eq__(tile_type):
  48 + db.session.delete(function)
  49 +
  50 + if tile_type not in [fun.type for fun in old_functions]:
  51 + service_function = ServiceFunction(guid=uuid.uuid1().__str__(),type=tile_type,service_guid=guid)
  52 + db.session.add(service_function)
  53 +
40 54 if service_update:
41 55 service.update(service_update)
42 56 if tile_update:
... ...
注册登录 后发表评论