Commit 56ab5c00 authored by lcn's avatar lcn

bug修复

parent e601b279
...@@ -254,36 +254,3 @@ async def hardware_statistics(company_id): ...@@ -254,36 +254,3 @@ async def hardware_statistics(company_id):
"start_time": start_time, "start_time": start_time,
"power_capacity": power_capacity if power_capacity else "", "power_capacity": power_capacity if power_capacity else "",
} }
async def hardware_statistics_new15(cid):
"""
获取硬件信息总统计
"""
sql = "SELECT c.create_time, p.pid FROM `point` p left join monitor m " \
"on p.mtid=m.mtid LEFT JOIN company c on c.cid =p.cid " \
"where m.demolished=0 and p.cid=%s"
async with MysqlUtil() as conn:
datas = await conn.fetchall(sql=sql, args=(cid,))
if not datas:
point_count, inline_count = 0, 0
start_time, power_capacity = "", ""
else:
point_count = len(datas)
create_time = datas[0]["create_time"]
start_time = datetime.strftime(datetime.fromtimestamp(create_time),
"%Y-%m-%d %H:%M")
inline_sql = "select tc_runtime from inline where cid = %s"
async with MysqlUtil() as conn:
inline_dats = await conn.fetchall(sql=inline_sql, args=(cid,))
inline_count = len(inline_dats)
power_capacity = 0
for inline_data in inline_dats:
if inline_data.get("tc_runtime"):
power_capacity += 1
return {
"installed_number": point_count,
"legal_measurement_number": inline_count,
"start_time": start_time,
"power_capacity": power_capacity if power_capacity else "",
}
\ No newline at end of file
...@@ -5,7 +5,7 @@ from unify_api.modules.product_info.components.hardware_cps import ( ...@@ -5,7 +5,7 @@ from unify_api.modules.product_info.components.hardware_cps import (
HardwareInfoManResq, HardwareInfoListReq, HardwareInfoListResq HardwareInfoManResq, HardwareInfoListReq, HardwareInfoListResq
) )
from unify_api.modules.product_info.procedures.hardware_pds import ( from unify_api.modules.product_info.procedures.hardware_pds import (
company_available, get_user_hardware_info_new15, hardware_statistics_new15 company_available, get_user_hardware_info_new15, hardware_statistics
) )
from pot_libs.logger import log from pot_libs.logger import log
from unify_api.modules.product_info.service.hardware_info import \ from unify_api.modules.product_info.service.hardware_info import \
...@@ -37,7 +37,7 @@ async def post_hardware_info_count(request, ...@@ -37,7 +37,7 @@ async def post_hardware_info_count(request,
body: HardwareInfoCountReq) -> HardwareInfoCountResp: body: HardwareInfoCountReq) -> HardwareInfoCountResp:
company_id = body.cid company_id = body.cid
# statistics_info_map = await hardware_statistics(company_id) # statistics_info_map = await hardware_statistics(company_id)
statistics_info_map = await hardware_statistics_new15(company_id) statistics_info_map = await hardware_statistics(company_id)
return HardwareInfoCountResp( return HardwareInfoCountResp(
installed_number=statistics_info_map["installed_number"], installed_number=statistics_info_map["installed_number"],
legal_measurement_number=statistics_info_map[ legal_measurement_number=statistics_info_map[
......
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