Commit b2fd772e authored by 金凯强's avatar 金凯强 🎨

远程服务器配置 增加车间

parent 5232a74f
Pipeline #22272 failed with stage
in 11 seconds
......@@ -42,13 +42,13 @@ class ConnectionAPI(ApiController):
'''
return ConnectionService().test_connection(request.json)
@api('remote_server/<string:project_no>/')
def get_remote_server(self, project_no):
@api('remote_server/<string:project_no>/<string:work_shop_no>')
def get_remote_server(self, project_no, work_shop_no):
'''
获取远程服务器连接
:return:
'''
return ConnectionService().get_remote_server_info(project_no)
return ConnectionService().get_remote_server_info(project_no, work_shop_no)
@api('remote_server')
def post_set_remote_server_info(self):
......
......@@ -141,14 +141,14 @@ values
else:
return {'message': '连接失败'}
def get_remote_server_info(self, project_no):
def get_remote_server_info(self, project_no, work_shop_no):
'''
获取远端服务器信息
:return:
'''
with db_driver as session:
remote_server_info = session.retrive_sql(
f"select * from remote_server_info where project_no='{project_no}'")
f"select * from remote_server_info where project_no='{project_no}' and work_shop_no='{work_shop_no}' ")
return remote_server_info
......@@ -161,46 +161,48 @@ values
id = json_data.get('id')
project_no = json_data.get('project_no')
work_shop_no = json_data.get('work_shop_no')
server_ip = json_data.get('server_ip')
server_ssh_port = json_data.get('server_ssh_port')
server_user = json_data.get('server_user')
server_password = json_data.get('server_password')
if project_no is None or server_ip is None or server_ssh_port is None or \
server_user is None or server_password is None:
server_user is None or server_password is None or work_shop_no is None:
raise HSException('以上参数全部必填')
project_no = project_no.strip()
server_ip = server_ip.strip()
server_user = server_user.strip()
server_password = server_password.strip()
work_shop_no = work_shop_no.strip()
with db_driver as session:
if id:
validate_sql = f"select * from remote_server_info where project_no='{project_no}' and id<>'{id}' "
validate_sql = f"select * from remote_server_info where project_no='{project_no}' and work_shop_no='{work_shop_no}' and id<>'{id}' "
validate_data = session.retrive_sql(validate_sql)
if validate_data:
raise HSException(f'{project_no}已经存在')
raise HSException(f'{project_no}-{work_shop_no}已经存在')
update_sql = f'''update remote_server_info
set project_no='{project_no}',server_ip='{server_ip}',server_ssh_port='{server_ssh_port}',server_user='{server_user}'
,server_password='{server_password}'
,server_password='{server_password}',work_shop_no='{work_shop_no}'
where id='{id}' '''
session.exec_sql(update_sql, json_data)
else:
project_no_sql = f"select project_no from remote_server_info where project_no='{project_no}'"
project_no_sql = f"select project_no from remote_server_info where project_no='{project_no}' and work_shop_no='{work_shop_no}'"
project_no_data = session.retrive_sql(project_no_sql)
if project_no_data:
raise HSException(f"{project_no}已经存在")
raise HSException(f"{project_no}-{work_shop_no}已经存在")
id = new_id()
json_data['id'] = id
insert_sql = f'''insert into remote_server_info
(id,project_no,server_ip,server_ssh_port,server_user
,server_password)
,server_password,work_shop_no)
values
('{id}','{project_no}','{server_ip}','{server_ssh_port}','{server_user}','{server_password}') '''
('{id}','{project_no}','{server_ip}','{server_ssh_port}','{server_user}','{server_password}','{work_shop_no}') '''
session.exec_sql(insert_sql, json_data)
return {'message': "保存成功"}
......
......@@ -35,6 +35,7 @@ create_table_sql_list = ['''create table if not exists project_info
, '''create table if not exists remote_server_info
(id bigint
, project_no varchar(50) unique
, work_shop_no varchar(50)
, server_ip varchar(50)
, server_ssh_port varchar(50)
, server_user varchar(50)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment