Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
LAE
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
文靖昊
LAE
Commits
8c390c1f
Commit
8c390c1f
authored
Nov 29, 2024
by
tinywell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
厂商设备在线率优化
parent
68cb482d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
tool_rate.py
src/agent/tool_rate.py
+5
-3
No files found.
src/agent/tool_rate.py
View file @
8c390c1f
...
...
@@ -71,7 +71,7 @@ class RegionRateArgs(BaseModel):
end_time
:
str
=
Field
(
""
,
description
=
"结束时间 (YYYY-MM-DD)"
)
month_statistics
:
bool
=
Field
(
False
,
description
=
"是否按月度查看一年内的在线率统计结果,默认不需要"
)
device_items
:
str
=
Field
(
""
,
description
=
"监测项集合,多个逗号隔开,支持:滑坡仪、设备、传感器、雨量、地表位移、裂缝、倾角、加速度、土壤含水率、泥水位,默认为空"
)
manufacturer_name
:
str
=
Field
(
""
,
description
=
"设备厂商,默认为空"
)
manufacturer_name
:
str
=
Field
(
""
,
description
=
"
指定
设备厂商,默认为空"
)
class
RegionRateTool
(
BaseRateTool
):
"""查询全国或者特定地区设备在线率的工具"""
...
...
@@ -126,7 +126,7 @@ class RegionRateTool(BaseRateTool):
result_data
.
append
(
rate_date
)
sorted_data
=
[
result_data
[
0
]]
if
len
(
result_data
)
>
1
:
sorted_data
.
extend
(
sorted
(
result_data
[
1
:],
key
=
lambda
x
:
x
[
'在线率'
]))
sorted_data
.
extend
(
sorted
(
result_data
[
1
:],
key
=
lambda
x
:
x
[
'
设备
在线率'
]))
# 将数据改成表格形式,表头提取之后,数据一行行显示
table_header
=
list
(
result_data
[
0
]
.
keys
())
...
...
@@ -142,6 +142,7 @@ class RegionRateTool(BaseRateTool):
data
=
{
'region'
:
region_name
,
'region_code'
:
code
,
'summary'
:
f
"找到符合条件的数据 {len(result_data)} 条"
,
'rate_data'
:
result_data
,
}
...
...
@@ -168,7 +169,7 @@ class RegionRateTool(BaseRateTool):
result_data
=
{}
for
index
,
item
in
enumerate
(
df
.
resultdata
):
month_data
=
self
.
_extract_rate_data
(
item
)
result_data
[
item
[
'month'
]
]
=
month_data
result_data
[
f
"{item['month']}月"
]
=
month_data
# 排序
result_data
=
sorted
(
result_data
.
items
(),
key
=
lambda
x
:
x
[
0
])
...
...
@@ -188,6 +189,7 @@ class RegionRateTool(BaseRateTool):
data
=
{
'region'
:
region_name
,
'region_code'
:
code
,
'summary'
:
f
"找到符合条件的数据 {len(result_data)} 条,包含{year}年{result_data.keys()}月份的数据"
,
'rate_data'
:
result_data
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment