|
@@ -16,7 +16,7 @@ import time, shutil, os
|
|
|
from sqlalchemy import and_, asc, desc
|
|
from sqlalchemy import and_, asc, desc
|
|
|
from functools import partial
|
|
from functools import partial
|
|
|
from service.deal_image import DealImage
|
|
from service.deal_image import DealImage
|
|
|
-from databases import DeviceConfig, SysConfigs, SqlQuery, CRUD, select
|
|
|
|
|
|
|
+from databases import DeviceConfig, SysConfigs, SqlQuery, CRUD, select,DeviceConfigTabs
|
|
|
from service.run_main import RunMain
|
|
from service.run_main import RunMain
|
|
|
import importlib
|
|
import importlib
|
|
|
from service.auto_deal_pics.upload_pic import UploadPic
|
|
from service.auto_deal_pics.upload_pic import UploadPic
|
|
@@ -382,14 +382,52 @@ async def handle_detail(request: Request, params: HandlerDetail):
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+@app.get("/get_device_tabs", description="获取可执行程序命令列表")
|
|
|
|
|
+def get_device_tabs(type:int):
|
|
|
|
|
+ session = SqlQuery()
|
|
|
|
|
+ statement = (
|
|
|
|
|
+ select(DeviceConfigTabs)
|
|
|
|
|
+ .where(DeviceConfigTabs.mode_type == type).order_by(asc("id"))
|
|
|
|
|
+ )
|
|
|
|
|
+ result = session.exec(statement).all()
|
|
|
|
|
+ session.close()
|
|
|
|
|
+ sys = CRUD(SysConfigs)
|
|
|
|
|
+ action_configs = sys.read(session, conditions={"key": "action_configs"})
|
|
|
|
|
+ session.close()
|
|
|
|
|
+ return {
|
|
|
|
|
+ "code": 0,
|
|
|
|
|
+ "msg": "",
|
|
|
|
|
+ "data": {"tabs": result, "select_configs": json.loads(action_configs.value)},
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+@app.post("/update_tab_name", description="更改tab名称")
|
|
|
|
|
+def update_tab_name(params: DeviceConfigTabsReq):
|
|
|
|
|
+ if params.mode_name == "":
|
|
|
|
|
+ return {"code": 1, "msg": "名称不能为空", "data": {}}
|
|
|
|
|
+ session = SqlQuery()
|
|
|
|
|
+ tabModel = CRUD(DeviceConfigTabs)
|
|
|
|
|
+ kwargs = {"mode_name": params.mode_name}
|
|
|
|
|
+ tabModel.updateConditions(session, conditions={"id": params.id}, **kwargs)
|
|
|
|
|
+ session.close()
|
|
|
|
|
+ sys = CRUD(SysConfigs)
|
|
|
|
|
+ action_configs = sys.read(session, conditions={"key": "action_configs"})
|
|
|
|
|
+ session.close()
|
|
|
|
|
+ return {
|
|
|
|
|
+ "code": 0,
|
|
|
|
|
+ "msg": "",
|
|
|
|
|
+ "data": None,
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@app.post("/get_device_configs", description="获取可执行程序命令列表")
|
|
@app.post("/get_device_configs", description="获取可执行程序命令列表")
|
|
|
def get_device_configs(params: ModelGetDeviceConfig):
|
|
def get_device_configs(params: ModelGetDeviceConfig):
|
|
|
- mode_type = params.mode_type
|
|
|
|
|
|
|
+ tab_id = params.tab_id
|
|
|
session = SqlQuery()
|
|
session = SqlQuery()
|
|
|
configModel = CRUD(DeviceConfig)
|
|
configModel = CRUD(DeviceConfig)
|
|
|
configList = configModel.read_all(
|
|
configList = configModel.read_all(
|
|
|
session,
|
|
session,
|
|
|
- conditions={"mode_type": mode_type},
|
|
|
|
|
|
|
+ conditions={"tab_id": tab_id},
|
|
|
order_by="action_index",
|
|
order_by="action_index",
|
|
|
ascending=True,
|
|
ascending=True,
|
|
|
)
|
|
)
|
|
@@ -413,11 +451,13 @@ def get_device_configs(params: ModelGetDeviceConfigDetail):
|
|
|
|
|
|
|
|
@app.post("/device_config_detail_query", description="通过条件获取可执行程序详情")
|
|
@app.post("/device_config_detail_query", description="通过条件获取可执行程序详情")
|
|
|
def get_device_configs(params: ModelGetDeviceConfigDetailQuery):
|
|
def get_device_configs(params: ModelGetDeviceConfigDetailQuery):
|
|
|
- mode_type = params.mode_type
|
|
|
|
|
|
|
+ tab_id = params.tab_id
|
|
|
action_name = params.action_name
|
|
action_name = params.action_name
|
|
|
session = SqlQuery()
|
|
session = SqlQuery()
|
|
|
configModel = CRUD(DeviceConfig)
|
|
configModel = CRUD(DeviceConfig)
|
|
|
- model = configModel.read(session, conditions={"mode_type": mode_type, "action_name": action_name})
|
|
|
|
|
|
|
+ model = configModel.read(
|
|
|
|
|
+ session, conditions={"tab_id": tab_id, "action_name": action_name}
|
|
|
|
|
+ )
|
|
|
if model == None:
|
|
if model == None:
|
|
|
return {"code": 1, "msg": "数据不存在", "data": None}
|
|
return {"code": 1, "msg": "数据不存在", "data": None}
|
|
|
return {"code": 0, "msg": "", "data": model}
|
|
return {"code": 0, "msg": "", "data": model}
|
|
@@ -458,18 +498,18 @@ def save_device_config(params: SaveDeviceConfig):
|
|
|
|
|
|
|
|
@app.post("/reset_config", description="创建或修改一条可执行命令")
|
|
@app.post("/reset_config", description="创建或修改一条可执行命令")
|
|
|
def reset_config(params: ModelGetDeviceConfig):
|
|
def reset_config(params: ModelGetDeviceConfig):
|
|
|
- mode_type = params.mode_type
|
|
|
|
|
- if mode_type == None or mode_type == "":
|
|
|
|
|
|
|
+ tab_id = params.tab_id
|
|
|
|
|
+ if tab_id == None or tab_id == "":
|
|
|
return {"code": 1, "msg": "参数错误", "data": None}
|
|
return {"code": 1, "msg": "参数错误", "data": None}
|
|
|
session = SqlQuery()
|
|
session = SqlQuery()
|
|
|
deviceConfig = CRUD(DeviceConfig)
|
|
deviceConfig = CRUD(DeviceConfig)
|
|
|
- res = deviceConfig.deleteConditions(session, conditions={"mode_type": mode_type})
|
|
|
|
|
|
|
+ res = deviceConfig.deleteConditions(session, conditions={"tab_id": tab_id})
|
|
|
if res is False:
|
|
if res is False:
|
|
|
return {"code": 1, "msg": "操作失败", "data": None}
|
|
return {"code": 1, "msg": "操作失败", "data": None}
|
|
|
actions = json.load(open("action.json", encoding="utf-8"))
|
|
actions = json.load(open("action.json", encoding="utf-8"))
|
|
|
act = []
|
|
act = []
|
|
|
for item in actions:
|
|
for item in actions:
|
|
|
- if item.get("mode_type") == mode_type:
|
|
|
|
|
|
|
+ if item.get("tab_id") == tab_id:
|
|
|
act.append(item)
|
|
act.append(item)
|
|
|
batch_insert_device_configs(session, act)
|
|
batch_insert_device_configs(session, act)
|
|
|
return {"code": 0, "msg": "操作成功", "data": None}
|
|
return {"code": 0, "msg": "操作成功", "data": None}
|