|
|
|
@ -16,7 +16,7 @@ from website.db.enterprise_busi_model import enterprise_busi_model_node_device a
|
|
|
|
|
from website.db.enterprise_device import enterprise_device as DB_Device
|
|
|
|
|
from website.db.enterprise_node import enterprise_node as DB_Node
|
|
|
|
|
from website.db.enterprise_node import enterprise_node_base_model_conf as DB_NodeBaseModelConf
|
|
|
|
|
from website.handler import APIHandler, authenticated
|
|
|
|
|
from website.handler import APIHandler, authenticated, operation_log
|
|
|
|
|
from website.util import date_util
|
|
|
|
|
from website.util import shortuuid
|
|
|
|
|
|
|
|
|
@ -37,6 +37,7 @@ class DeviceClassificationAddHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("企业管理", "设备管理", consts.op_type_add_str, "添加设备分类")
|
|
|
|
|
def post(self):
|
|
|
|
|
name = self.get_escaped_argument("name", "")
|
|
|
|
|
with self.app_mysql.connect() as conn:
|
|
|
|
@ -82,11 +83,23 @@ class DeviceClassificationHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("企业管理", "设备管理", consts.op_type_list_str, "设备分类列表")
|
|
|
|
|
def post(self):
|
|
|
|
|
with self.app_mysql.connect() as conn:
|
|
|
|
|
cur = conn.execute(
|
|
|
|
|
text(
|
|
|
|
|
"SELECT id, suid, name FROM device_classification where del=0 ORDER BY id DESC"
|
|
|
|
|
"""
|
|
|
|
|
SELECT id, suid, name,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN EXISTS (
|
|
|
|
|
SELECT 1
|
|
|
|
|
FROM enterprise_device
|
|
|
|
|
WHERE classification = device_classification.suid
|
|
|
|
|
) THEN '1'
|
|
|
|
|
ELSE '0'
|
|
|
|
|
END AS used
|
|
|
|
|
FROM device_classification where del=0 ORDER BY id DESC
|
|
|
|
|
"""
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
res = db_mysql.to_json_list(cur)
|
|
|
|
@ -105,6 +118,7 @@ class DeviceClassificationDeleteHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("企业管理", "设备管理", consts.op_type_delete_str, "删除设备分类")
|
|
|
|
|
def post(self):
|
|
|
|
|
did = self.get_int_argument("id")
|
|
|
|
|
|
|
|
|
@ -112,9 +126,9 @@ class DeviceClassificationDeleteHandler(APIHandler):
|
|
|
|
|
cur = conn.execute(
|
|
|
|
|
text(
|
|
|
|
|
"""
|
|
|
|
|
select d.id from enterprise_device d, device_classification c
|
|
|
|
|
where d.classification=c.suid and c.id=:id and c.del=0
|
|
|
|
|
"""
|
|
|
|
|
select d.id from enterprise_device d, device_classification c
|
|
|
|
|
where d.classification=c.suid and c.id=:id and c.del=0
|
|
|
|
|
"""
|
|
|
|
|
),
|
|
|
|
|
{"id": did},
|
|
|
|
|
)
|
|
|
|
@ -131,6 +145,30 @@ class DeviceClassificationDeleteHandler(APIHandler):
|
|
|
|
|
self.finish()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DeviceClassificationEditHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
- 描述:编辑设备分类
|
|
|
|
|
- 请求方式:post
|
|
|
|
|
- 请求参数:
|
|
|
|
|
>- id
|
|
|
|
|
>- name
|
|
|
|
|
- 返回值:无
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("企业管理", "设备管理", consts.op_type_edit_str, "编辑设备分类")
|
|
|
|
|
def post(self):
|
|
|
|
|
did = self.get_int_argument("id")
|
|
|
|
|
name = self.get_escaped_argument("name", "")
|
|
|
|
|
|
|
|
|
|
with self.app_mysql.connect() as conn:
|
|
|
|
|
conn.execute(
|
|
|
|
|
text("update device_classification set name=:name WHERE id=:id"),
|
|
|
|
|
{"id": did, "name": name},
|
|
|
|
|
)
|
|
|
|
|
conn.commit()
|
|
|
|
|
self.finish()
|
|
|
|
|
|
|
|
|
|
class DeviceAddHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
- 描述:企业节点,添加设备
|
|
|
|
@ -151,6 +189,7 @@ class DeviceAddHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("企业管理", "设备管理", consts.op_type_add_str, "企业节点,添加设备")
|
|
|
|
|
def post(self):
|
|
|
|
|
entity_id = self.get_int_argument("entity_id")
|
|
|
|
|
node_id = self.get_int_argument("node_id")
|
|
|
|
@ -204,6 +243,7 @@ class DeviceEditHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("企业管理", "设备管理", consts.op_type_edit_str, "企业节点,编辑设备")
|
|
|
|
|
def post(self):
|
|
|
|
|
device_id = self.get_int_argument("device_id")
|
|
|
|
|
name = self.get_escaped_argument("name", "")
|
|
|
|
@ -243,6 +283,7 @@ class DeviceDeleteHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("企业管理", "设备管理", consts.op_type_delete_str, "企业节点,删除设备")
|
|
|
|
|
def post(self):
|
|
|
|
|
# node_id = self.get_int_argument('node_id')
|
|
|
|
|
device_id = self.get_int_argument("device_id")
|
|
|
|
@ -281,10 +322,11 @@ class DeviceListHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("企业管理", "设备管理", consts.op_type_list_str, "企业节点,设备列表")
|
|
|
|
|
def post(self):
|
|
|
|
|
node_id = self.get_int_argument("node_id")
|
|
|
|
|
pageNo = self.get_int_argument("pageNo", 1)
|
|
|
|
|
pageSize = self.get_int_argument("pageSize", 20)
|
|
|
|
|
pageSize = self.get_int_argument("pageSize", consts.PAGE_SIZE)
|
|
|
|
|
if not node_id:
|
|
|
|
|
raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "企业节点不能为空")
|
|
|
|
|
db_device = DB_Device.EnterpriseDeviceRepository()
|
|
|
|
@ -329,7 +371,8 @@ class DeviceInfoHandler(APIHandler):
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("企业管理", "设备管理", consts.op_type_list_str, "企业节点,设备信息")
|
|
|
|
|
def post(self):
|
|
|
|
|
device_id = self.get_int_argument("device_id")
|
|
|
|
|
if not device_id:
|
|
|
|
@ -374,6 +417,7 @@ class DeviceBasemodelListHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("企业管理", "节点设置", consts.op_type_list_str, "企业节点,节点信息 -> 设备列表 -> 基础模型配置 -> 模型列表")
|
|
|
|
|
def post(self):
|
|
|
|
|
device_id = self.get_int_argument("device_id")
|
|
|
|
|
if not device_id:
|
|
|
|
@ -381,7 +425,7 @@ class DeviceBasemodelListHandler(APIHandler):
|
|
|
|
|
errors.ERROR_BAD_REQUEST, "企业节点或设备不能为空"
|
|
|
|
|
)
|
|
|
|
|
pageNo = self.get_int_argument("pageNo", 1)
|
|
|
|
|
pageSize = self.get_int_argument("pageSize", 10)
|
|
|
|
|
pageSize = self.get_int_argument("pageSize", consts.PAGE_SIZE)
|
|
|
|
|
db_busi_model = DB_BusiModelNodeDevice.EnterpriseBusiModelNodeDeviceRepository()
|
|
|
|
|
busi_models, count = db_busi_model.get_busi_model_by_device(device_id=device_id, pagination=True,
|
|
|
|
|
page_no=pageNo,
|
|
|
|
@ -395,9 +439,6 @@ class DeviceBasemodelListHandler(APIHandler):
|
|
|
|
|
busi_model_id = item["busi_model_id"]
|
|
|
|
|
busi_model_name = item["name"]
|
|
|
|
|
base_model_list = json.loads(item["base_models"])
|
|
|
|
|
logging.info("##############################################################")
|
|
|
|
|
logging.info(base_model_list)
|
|
|
|
|
logging.info("##############################################################")
|
|
|
|
|
base_models = []
|
|
|
|
|
for base_model in base_model_list:
|
|
|
|
|
base_model_id = base_model["id"]
|
|
|
|
@ -448,6 +489,8 @@ class DeviceBaseModelCustomConfigHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("企业管理", "节点设置", consts.op_type_add_str,
|
|
|
|
|
"企业节点,节点信息 -> 设备列表 -> 基础模型配置 -> 基础模型参数配置")
|
|
|
|
|
def post(self):
|
|
|
|
|
device_id = self.get_int_argument("device_id")
|
|
|
|
|
node_id = self.get_int_argument("node_id")
|
|
|
|
@ -533,13 +576,14 @@ class StatusListHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("企业管理", "设备状态", consts.op_type_list_str,"设备状态列表")
|
|
|
|
|
def post(self):
|
|
|
|
|
entity_id = self.get_int_argument("entity_id")
|
|
|
|
|
group = self.get_int_argument("group")
|
|
|
|
|
classification = self.get_escaped_argument("classification", "")
|
|
|
|
|
status = self.get_int_argument("status", 1000)
|
|
|
|
|
pageNo = self.get_int_argument("pageNo", 1)
|
|
|
|
|
pageSize = self.get_int_argument("pageSize", 20)
|
|
|
|
|
pageSize = self.get_int_argument("pageSize", consts.PAGE_SIZE)
|
|
|
|
|
|
|
|
|
|
if not entity_id:
|
|
|
|
|
raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "企业节点不能为空")
|
|
|
|
@ -599,6 +643,7 @@ class StatusInfoHandler(APIHandler):
|
|
|
|
|
""" """
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("企业管理", "设备状态", consts.op_type_list_str, "设备信息")
|
|
|
|
|
def post(self):
|
|
|
|
|
device_id = self.get_int_argument("id")
|
|
|
|
|
if not device_id:
|
|
|
|
@ -698,7 +743,7 @@ class StatusLogHandler(APIHandler):
|
|
|
|
|
def post(self):
|
|
|
|
|
entity_id = self.get_int_argument("entity_id")
|
|
|
|
|
pageNo = self.get_int_argument("pageNo", 1)
|
|
|
|
|
pageSize = self.get_int_argument("pageSize", 10)
|
|
|
|
|
pageSize = self.get_int_argument("pageSize", consts.PAGE_SIZE)
|
|
|
|
|
|
|
|
|
|
db_device = DB_Device.EnterpriseDeviceRepository()
|
|
|
|
|
res = db_device.list_entity_devices(entity_id=entity_id, pageno=pageNo, pagesize=pageSize)
|
|
|
|
|