Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
IoTSharp
IoTSharp
提交
9906c063
IoTSharp
项目概览
IoTSharp
/
IoTSharp
11 个月 前同步成功
通知
15
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
IoTSharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9906c063
编写于
3月 23, 2022
作者:
麦壳饼
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修正 遥测数据 的时间格式。
上级
a470c2fd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
75 addition
and
3 deletion
+75
-3
IoTSharp.Data/Enums.cs
IoTSharp.Data/Enums.cs
+21
-0
IoTSharp/Controllers/DevicesController.cs
IoTSharp/Controllers/DevicesController.cs
+9
-2
IoTSharp/Dtos/TelemetryDataDto.cs
IoTSharp/Dtos/TelemetryDataDto.cs
+40
-1
IoTSharp/IoTSharp.xml
IoTSharp/IoTSharp.xml
+5
-0
未找到文件。
IoTSharp.Data/Enums.cs
浏览文件 @
9906c063
...
...
@@ -173,12 +173,33 @@ namespace IoTSharp.Data
/// 不使用
/// </summary>
None
,
/// <summary>
/// 平均数
/// </summary>
Mean
,
/// <summary>
/// 中值
/// </summary>
Median
,
/// <summary>
/// 最后一个值
/// </summary>
Last
,
/// <summary>
/// 第一个值
/// </summary>
First
,
/// <summary>
/// 最大
/// </summary>
Max
,
/// <summary>
/// 最小
/// </summary>
Min
,
/// <summary>
/// 合计
/// </summary>
Sum
}
...
...
IoTSharp/Controllers/DevicesController.cs
浏览文件 @
9906c063
...
...
@@ -527,8 +527,15 @@ namespace IoTSharp.Controllers
/// <summary>
/// 返回指定设备的的遥测数据, 按照keyname 和指定时间范围获取,如果keyname 为 all , 则返回全部key 的数据
/// </summary>
/// <param name="deviceId">Which device do you read?</param>
/// <param name="queryDto">查询条件</param>
/// <param name="deviceId">指定设备ID</param>
/// <param name="queryDto">查询条件例子:
///{
/// "keys": "",
/// "begin": "2022-03-23T11:44:56.488Z",
/// "every": "1.03:14:56:166",
/// "aggregate": "Mean"
/// }
/// </param>
/// <returns></returns>
[
Authorize
(
Roles
=
nameof
(
UserRole
.
NormalUser
))]
[
HttpPost
(
"{deviceId}/TelemetryData"
)]
...
...
IoTSharp/Dtos/TelemetryDataDto.cs
浏览文件 @
9906c063
...
...
@@ -3,6 +3,7 @@ using System;
using
System.Collections.Generic
;
using
System.ComponentModel.DataAnnotations
;
using
System.Linq
;
using
System.Text.Json
;
using
System.Threading.Tasks
;
namespace
IoTSharp.Dtos
...
...
@@ -16,6 +17,39 @@ namespace IoTSharp.Dtos
public
object
Value
{
get
;
set
;
}
}
public
class
TimespanConverterNewtonsoft
:
Newtonsoft
.
Json
.
JsonConverter
<
TimeSpan
>
{
/// <summary>
/// Format: Days.Hours:Minutes:Seconds:Milliseconds
/// </summary>
public
const
string
TimeSpanFormatString
=
@"d\.hh\:mm\:ss\:FFF"
;
public
override
void
WriteJson
(
Newtonsoft
.
Json
.
JsonWriter
writer
,
TimeSpan
value
,
Newtonsoft
.
Json
.
JsonSerializer
serializer
)
{
var
timespanFormatted
=
$"
{
value
.
ToString
(
TimeSpanFormatString
)}
"
;
writer
.
WriteValue
(
timespanFormatted
);
}
public
override
TimeSpan
ReadJson
(
Newtonsoft
.
Json
.
JsonReader
reader
,
Type
objectType
,
TimeSpan
existingValue
,
bool
hasExistingValue
,
Newtonsoft
.
Json
.
JsonSerializer
serializer
)
{
TimeSpan
parsedTimeSpan
;
TimeSpan
.
TryParseExact
((
string
)
reader
.
Value
,
TimeSpanFormatString
,
null
,
out
parsedTimeSpan
);
return
parsedTimeSpan
;
}
}
public
class
TimeSpanConverter
:
System
.
Text
.
Json
.
Serialization
.
JsonConverter
<
TimeSpan
>
{
public
override
TimeSpan
Read
(
ref
Utf8JsonReader
reader
,
Type
typeToConvert
,
JsonSerializerOptions
options
)
{
return
TimeSpan
.
Parse
(
reader
.
GetString
());
}
public
override
void
Write
(
Utf8JsonWriter
writer
,
TimeSpan
value
,
JsonSerializerOptions
options
)
{
writer
.
WriteStringValue
(
value
.
ToString
());
}
}
/// <summary>
/// 查询历史遥测数据请求结构体
/// </summary>
...
...
@@ -24,7 +58,7 @@ namespace IoTSharp.Dtos
/// <summary>
/// 要获取的键值, 如果为空, 则为全部
/// </summary>
public
string
keys
{
get
;
set
;
}=
S
tring
.
Empty
;
public
string
keys
{
get
;
set
;
}=
s
tring
.
Empty
;
/// <summary>
/// 开始时间
/// </summary>
...
...
@@ -36,6 +70,11 @@ namespace IoTSharp.Dtos
/// <summary>
/// 数据截面聚合间隔
/// </summary>
/// <example>1.03:14:56:166</example>
/// <remarks>d.hh:mm:ss:FFF</remarks>
[
Newtonsoft
.
Json
.
JsonConverter
(
typeof
(
TimespanConverterNewtonsoft
))]
[
Newtonsoft
.
Json
.
JsonProperty
(
TypeNameHandling
=
Newtonsoft
.
Json
.
TypeNameHandling
.
All
)]
[
System
.
Text
.
Json
.
Serialization
.
JsonConverter
(
typeof
(
TimeSpanConverter
))]
public
TimeSpan
every
{
get
;
set
;
}=
TimeSpan
.
Zero
;
/// <summary>
/// 数据截面计算方式,
...
...
IoTSharp/IoTSharp.xml
浏览文件 @
9906c063
...
...
@@ -701,6 +701,11 @@
是否被安装
</summary>
</member>
<member
name=
"F:IoTSharp.Dtos.TimespanConverterNewtonsoft.TimeSpanFormatString"
>
<summary>
Format: Days.Hours:Minutes:Seconds:Milliseconds
</summary>
</member>
<member
name=
"T:IoTSharp.Dtos.TelemetryDataQueryDto"
>
<summary>
查询历史遥测数据请求结构体
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录