Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
IoTSharp
IoTSharp
提交
49d59915
IoTSharp
项目概览
IoTSharp
/
IoTSharp
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
49d59915
编写于
12月 20, 2021
作者:
W
wq1234wq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
设备指令发送
上级
9021ff33
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
106 addition
and
27 deletion
+106
-27
IoTSharp/ClientApp/src/app/routes/device/deviceform/deviceform.component.html
...rc/app/routes/device/deviceform/deviceform.component.html
+7
-0
IoTSharp/ClientApp/src/app/routes/device/deviceform/deviceform.component.ts
.../src/app/routes/device/deviceform/deviceform.component.ts
+15
-2
IoTSharp/ClientApp/src/app/routes/device/devicelist/devicelist.component.html
...rc/app/routes/device/devicelist/devicelist.component.html
+22
-0
IoTSharp/ClientApp/src/app/routes/device/devicelist/devicelist.component.ts
.../src/app/routes/device/devicelist/devicelist.component.ts
+29
-1
IoTSharp/ClientApp/src/app/routes/devicemodel/devicemodelcommandparam.ts
...App/src/app/routes/devicemodel/devicemodelcommandparam.ts
+1
-1
IoTSharp/Controllers/DeviceModelController.cs
IoTSharp/Controllers/DeviceModelController.cs
+16
-0
IoTSharp/Controllers/DevicesController.cs
IoTSharp/Controllers/DevicesController.cs
+8
-22
IoTSharp/Dtos/DeviceDetailDto.cs
IoTSharp/Dtos/DeviceDetailDto.cs
+5
-0
IoTSharp/Dtos/DevicePostDto.cs
IoTSharp/Dtos/DevicePostDto.cs
+1
-1
IoTSharp/Dtos/DevicePutDto.cs
IoTSharp/Dtos/DevicePutDto.cs
+2
-0
未找到文件。
IoTSharp/ClientApp/src/app/routes/device/deviceform/deviceform.component.html
浏览文件 @
49d59915
...
...
@@ -11,6 +11,13 @@
<nz-option
nzValue=
"Gateway"
nzLabel=
"网关"
></nz-option>
</nz-select>
</se>
<se
label=
"设备型号"
error=
"设备型号"
>
<nz-select
formControlName=
"deviceModelId"
placeholder=
"设备型号"
>
<nz-option
*ngFor=
"let o of devicemodel"
[nzValue]=
"o.deviceModelId"
[nzLabel]=
"o.modelName"
></nz-option>
</nz-select>
</se>
<se
label=
"认证方式"
error=
"认证方式"
required
>
<nz-select
formControlName=
"identityType"
placeholder=
"设备类型"
>
<nz-option
nzValue=
"AccessToken"
nzLabel=
"AccessToken"
></nz-option>
...
...
IoTSharp/ClientApp/src/app/routes/device/deviceform/deviceform.component.ts
浏览文件 @
49d59915
...
...
@@ -9,6 +9,7 @@ import { concat } from 'rxjs';
import
{
map
}
from
'
rxjs/operators
'
;
import
{
appmessage
,
AppMessage
}
from
'
../../common/AppMessage
'
;
import
{
MyValidators
}
from
'
../../common/validators/MyValidators
'
;
import
{
devicemodel
}
from
'
../../devicemodel/devicemodelcommandparam
'
;
import
{
deviceitem
}
from
'
../devicelist/devicelist.component
'
;
@
Component
({
...
...
@@ -36,6 +37,9 @@ export class DeviceformComponent implements OnInit {
form
!
:
FormGroup
;
submitting
=
false
;
devicemodel
:
devicemodel
[]
=
[];
data
:
deviceitem
=
{
name
:
''
,
deviceType
:
''
,
...
...
@@ -44,15 +48,24 @@ export class DeviceformComponent implements OnInit {
identityType
:
''
,
};
ngOnInit
()
{
console
.
log
();
const
{
nullbigintid
}
=
MyValidators
;
this
.
form
=
this
.
fb
.
group
({
name
:
[
null
,
[
Validators
.
required
]],
deviceType
:
[
null
,
[
Validators
.
required
]],
customerId
:
[
null
,
[]],
deviceModelId
:
[
null
,
[]],
id
:
[
Guid
.
EMPTY
,
[]],
identityType
:
[
Guid
.
EMPTY
,
[]],
});
this
.
_httpClient
.
post
(
'
api/deviceModel/index
'
,{
offset
:
0
,
limit
:
100
}).
subscribe
(
next
=>
{
this
.
devicemodel
=
next
.
data
.
rows
;
},
error
=>
{
},()
=>
{})
if
(
this
.
params
.
id
!==
Guid
.
EMPTY
)
{
concat
(
this
.
_httpClient
.
get
<
appmessage
<
deviceitem
>>
(
'
api/Devices/
'
+
this
.
params
.
id
).
pipe
(
...
...
IoTSharp/ClientApp/src/app/routes/device/devicelist/devicelist.component.html
浏览文件 @
49d59915
...
...
@@ -135,6 +135,28 @@
</tr></tbody>
</nz-table>
</nz-card>
<nz-card
nzTitle=
"操作"
>
<div
nz-row
>
<span
*ngFor=
"let _item of cett; let i = index;"
>
<button
nz-button
nzType=
"primary"
(nzOnConfirm)=
"executeCommand(item, _item)"
nz-popconfirm
nzPopconfirmTitle=
"{{'确认执行'+_item.commandTitle+'?'}}"
nzPopconfirmPlacement=
"topLeft"
>
{{_item.commandTitle}}
</button></span>
</div>
</nz-card>
</ng-template>
</st>
</page-header>
IoTSharp/ClientApp/src/app/routes/device/devicelist/devicelist.component.ts
浏览文件 @
49d59915
...
...
@@ -20,6 +20,7 @@ import { ClipboardService } from 'ngx-clipboard';
import
{
DevicetokendialogComponent
}
from
'
../devicetokendialog/devicetokendialog.component
'
;
import
{
fork
}
from
'
child_process
'
;
import
{
ProppartComponent
}
from
'
../deviceprop/proppart/proppart.component
'
;
import
{
devicemodelcommand
}
from
'
../../devicemodel/devicemodelcommandparam
'
;
@
Component
({
selector
:
'
app-devicelist
'
,
templateUrl
:
'
./devicelist.component.html
'
,
...
...
@@ -59,6 +60,7 @@ export class DevicelistComponent implements OnInit, OnDestroy {
cetd
:
telemetryitem
[]
=
[];
cead
:
attributeitem
[]
=
[];
cerd
:
ruleitem
[]
=
[];
cett
:
devicemodelcommand
[]
=
[];
page
:
STPage
=
{
front
:
false
,
total
:
true
,
...
...
@@ -368,12 +370,14 @@ export class DevicelistComponent implements OnInit, OnDestroy {
this
.
cead
=
[];
this
.
cetd
=
[];
this
.
cerd
=
[];
this
.
cett
=
[];
this
.
obs
=
interval
(
1000
).
subscribe
(
async
()
=>
{
zip
(
this
.
http
.
get
<
appmessage
<
attributeitem
[]
>>
(
'
api/Devices/
'
+
$events
.
expand
?.
id
+
'
/AttributeLatest
'
),
this
.
http
.
get
<
appmessage
<
ruleitem
[]
>>
(
'
api/Rules/GetDeviceRules?deviceId=
'
+
$events
.
expand
?.
id
),
this
.
http
.
get
<
appmessage
<
telemetryitem
[]
>>
(
'
api/Devices/
'
+
$events
.
expand
?.
id
+
'
/TelemetryLatest
'
),
).
subscribe
(([
attributes
,
rules
,
telemetries
])
=>
{
this
.
http
.
get
<
appmessage
<
devicemodelcommand
[]
>>
(
'
api/deviceModel/getCommandsByDevice?id=
'
+
$events
.
expand
?.
id
),
).
subscribe
(([
attributes
,
rules
,
telemetries
,
commands
])
=>
{
// $events.expand.attributes = attributes.data;
// $events.expand.rules = rules.data;
// $events.expand.telemetries = telemetries.data;
...
...
@@ -435,12 +439,18 @@ export class DevicelistComponent implements OnInit, OnDestroy {
}
}
}
if
(
this
.
cett
.
length
==
0
){
this
.
cett
=
commands
.
data
;
}
});
});
}
else
{
this
.
cead
=
[];
this
.
cetd
=
[];
this
.
cerd
=
[];
this
.
cett
=
[];
if
(
this
.
obs
){
this
.
obs
.
unsubscribe
();
}
...
...
@@ -451,6 +461,23 @@ export class DevicelistComponent implements OnInit, OnDestroy {
}
}
executeCommand
(
item
:
deviceitem
,
command
:
devicemodelcommand
){
console
.
log
(
item
)
this
.
http
.
post
(
'
api/Devices/
'
+
item
.
identityId
+
'
/Rpc/
'
+
command
.
commandName
+
'
?timeout=300
'
,{}).
subscribe
(
next
=>
{
},
error
=>
{
},()
=>
{
})
}
removerule
(
item
:
deviceitem
,
rule
:
ruleitem
)
{
this
.
http
.
get
(
'
api/Rules/DeleteDeviceRules?deviceId=
'
+
item
.
id
+
'
&ruleId=
'
+
rule
.
ruleId
).
subscribe
(
()
=>
{
...
...
@@ -470,6 +497,7 @@ export interface deviceitem {
online
?:
string
;
owner
?:
string
;
tenant
?:
string
;
identityId
?:
string
;
timeout
?:
string
;
customerId
?:
string
;
telemetries
?:
telemetryitem
[];
...
...
IoTSharp/ClientApp/src/app/routes/devicemodel/devicemodelcommandparam.ts
浏览文件 @
49d59915
export
interface
devicemodel
{
deviceModelId
:
string
;
mdelName
:
string
;
m
o
delName
:
string
;
modelDesc
:
string
;
modelStatus
:
string
;
createDateTime
:
string
;
...
...
IoTSharp/Controllers/DeviceModelController.cs
浏览文件 @
49d59915
...
...
@@ -10,6 +10,7 @@ using IoTSharp.Dtos;
using
IoTSharp.Models
;
using
LinqKit
;
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.EntityFrameworkCore
;
namespace
IoTSharp.Controllers
{
...
...
@@ -108,6 +109,21 @@ namespace IoTSharp.Controllers
return
new
ApiResult
<
bool
>(
ApiCode
.
CantFindObject
,
"CantFindObject"
,
false
);
}
[
HttpGet
(
"[action]"
)]
public
ApiResult
<
List
<
DeviceModelCommand
>>
GetCommandsByDevice
(
Guid
id
)
{
var
dev
=
_context
.
Device
.
SingleOrDefault
(
c
=>
c
.
Id
==
id
);
if
(
dev
!=
null
&&
dev
.
DeviceModelId
!=
null
&&
dev
.
DeviceModelId
!=
Guid
.
Empty
)
{
return
new
ApiResult
<
List
<
DeviceModelCommand
>>(
ApiCode
.
Success
,
"Ok"
,
_context
.
DeviceModelCommands
.
Where
(
c
=>
c
.
DeviceModelId
==
dev
.
DeviceModelId
&&
c
.
CommandStatus
>-
1
).
ToList
());
}
return
new
ApiResult
<
List
<
DeviceModelCommand
>>(
ApiCode
.
Success
,
"Ok"
,
null
);
}
[
HttpGet
(
"[action]"
)]
public
ApiResult
<
List
<
DeviceModelCommand
>>
GetCommands
(
Guid
id
)
{
...
...
IoTSharp/Controllers/DevicesController.cs
浏览文件 @
49d59915
...
...
@@ -405,15 +405,10 @@ namespace IoTSharp.Controllers
public
async
Task
<
ApiResult
<
List
<
TelemetryDataDto
>>>
GetTelemetryLatest
(
Guid
deviceId
)
{
Device
dev
=
Found
(
deviceId
);
if
(
dev
==
null
)
{
return
new
ApiResult
<
List
<
TelemetryDataDto
>>(
ApiCode
.
NotFoundDeviceIdentity
,
"Device's Identity not found"
,
null
);
}
try
...
...
@@ -428,17 +423,8 @@ namespace IoTSharp.Controllers
null
);
}
}
/// <summary>
/// 获取指定设备的指定key 的遥测数据
/// </summary>
...
...
@@ -465,7 +451,6 @@ namespace IoTSharp.Controllers
}
}
/// <summary>
/// 获取指定设备和指定时间, 指定key的数据
/// </summary>
...
...
@@ -494,8 +479,6 @@ namespace IoTSharp.Controllers
?
await
_storage
.
LoadTelemetryAsync
(
deviceId
,
begin
)
:
await
_storage
.
LoadTelemetryAsync
(
deviceId
,
keys
,
begin
));
}
}
/// <summary>
...
...
@@ -591,6 +574,8 @@ namespace IoTSharp.Controllers
return
new
ApiResult
<
bool
>(
ApiCode
.
DoNotAllow
,
"Do not allow access to devices from other customers or tenants"
,
false
);
// return BadRequest(new ApiResult(ApiCode.DoNotAllow, $"Do not allow access to devices from other customers or tenants"));
}
dev
.
DeviceModel
=
_context
.
DeviceModels
.
FirstOrDefault
(
c
=>
c
.
DeviceModelId
==
device
.
DeviceModelId
);
dev
.
Name
=
device
.
Name
;
try
{
...
...
@@ -636,11 +621,12 @@ namespace IoTSharp.Controllers
{
var
cid
=
User
.
Claims
.
First
(
c
=>
c
.
Type
==
IoTSharpClaimTypes
.
Customer
);
var
tid
=
User
.
Claims
.
First
(
c
=>
c
.
Type
==
IoTSharpClaimTypes
.
Tenant
);
var
devvalue
=
new
Device
()
{
Name
=
device
.
Name
,
DeviceType
=
device
.
DeviceType
,
Timeout
=
300
,
LastActive
=
DateTime
.
Now
,
Status
=
1
,
//CreateDate = DateTime.Today,
//CreateMonth =DateTime.Now.ToString("yyyy-MM"),
//CreateDateTime = DateTime.Now
};
var
devvalue
=
new
Device
()
{
Name
=
device
.
Name
,
DeviceType
=
device
.
DeviceType
,
Timeout
=
300
,
LastActive
=
DateTime
.
Now
,
Status
=
1
,
DeviceModel
=
_context
.
DeviceModels
.
FirstOrDefault
(
c
=>
c
.
DeviceModelId
==
device
.
DeviceModelId
),
//CreateDate = DateTime.Today,
//CreateMonth =DateTime.Now.ToString("yyyy-MM"),
//CreateDateTime = DateTime.Now
};
devvalue
.
Tenant
=
_context
.
Tenant
.
Find
(
new
Guid
(
tid
.
Value
));
devvalue
.
Customer
=
_context
.
Customer
.
Find
(
new
Guid
(
cid
.
Value
));
...
...
IoTSharp/Dtos/DeviceDetailDto.cs
浏览文件 @
49d59915
...
...
@@ -47,5 +47,10 @@ namespace IoTSharp.Dtos
public
string
IdentityValue
{
get
;
set
;
}
public
string
IdentityId
{
get
;
set
;
}
public
DeviceModel
?
Model
{
get
;
set
;
}
}
}
IoTSharp/Dtos/DevicePostDto.cs
浏览文件 @
49d59915
...
...
@@ -10,7 +10,7 @@ namespace IoTSharp.Dtos
{
public
string
Name
{
get
;
set
;
}
public
DeviceType
DeviceType
{
get
;
set
;
}
public
Guid
DeviceModelId
{
get
;
set
;
}
public
IdentityType
IdentityType
{
get
;
set
;
}
}
}
IoTSharp/Dtos/DevicePutDto.cs
浏览文件 @
49d59915
...
...
@@ -10,6 +10,8 @@ namespace IoTSharp.Dtos
{
public
Guid
Id
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
public
Guid
DeviceModelId
{
get
;
set
;
}
public
IdentityType
IdentityType
{
get
;
set
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录