Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
IoTSharp
提交
e05f4c4e
I
IoTSharp
项目概览
jobily
/
IoTSharp
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
IoTSharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e05f4c4e
编写于
10月 14, 2022
作者:
W
wq1234wq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
设备创建
上级
50b24fb4
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
170 addition
and
33 deletion
+170
-33
IoTSharp/ClientApp/src/app/routes/devices/deviceform/deviceform.component.html
...c/app/routes/devices/deviceform/deviceform.component.html
+2
-2
IoTSharp/ClientApp/src/app/routes/produce/createdeviceform/createdeviceform.component.html
.../produce/createdeviceform/createdeviceform.component.html
+18
-0
IoTSharp/ClientApp/src/app/routes/produce/createdeviceform/createdeviceform.component.less
.../produce/createdeviceform/createdeviceform.component.less
+0
-0
IoTSharp/ClientApp/src/app/routes/produce/createdeviceform/createdeviceform.component.spec.ts
...oduce/createdeviceform/createdeviceform.component.spec.ts
+25
-0
IoTSharp/ClientApp/src/app/routes/produce/createdeviceform/createdeviceform.component.ts
...es/produce/createdeviceform/createdeviceform.component.ts
+44
-0
IoTSharp/ClientApp/src/app/routes/produce/produce.module.ts
IoTSharp/ClientApp/src/app/routes/produce/produce.module.ts
+2
-1
IoTSharp/ClientApp/src/app/routes/produce/produceform/produceform.component.html
...app/routes/produce/produceform/produceform.component.html
+5
-9
IoTSharp/ClientApp/src/app/routes/produce/producelist/producelist.component.ts
...c/app/routes/produce/producelist/producelist.component.ts
+27
-6
IoTSharp/Controllers/ProducesController.cs
IoTSharp/Controllers/ProducesController.cs
+36
-15
IoTSharp/Dtos/CreateDeviceByProduceDto.cs
IoTSharp/Dtos/CreateDeviceByProduceDto.cs
+11
-0
未找到文件。
IoTSharp/ClientApp/src/app/routes/devices/deviceform/deviceform.component.html
浏览文件 @
e05f4c4e
...
...
@@ -11,13 +11,13 @@
<nz-option
nzValue=
"Gateway"
nzLabel=
"网关"
></nz-option>
</nz-select>
</se>
<!--
<se label="所属产品" error="所属产品" >
<nz-select formControlName="produceId" placeholder="所属产品" >
<nz-option *ngFor="let o of deviceproduce" [nzValue]="o.id" [nzLabel]="o.name"></nz-option>
</nz-select>
</se>
-->
<se
label=
"超时"
error=
"超时"
required
>
<nz-input-number
formControlName=
"timeout"
[nzMin]=
"0"
[nzStep]=
"1"
></nz-input-number>
</se>
...
...
IoTSharp/ClientApp/src/app/routes/produce/createdeviceform/createdeviceform.component.html
0 → 100644
浏览文件 @
e05f4c4e
<div
class=
"modal-header"
>
<div
class=
"modal-title"
>
Title
</div>
</div>
<form
nz-form
[formGroup]=
"form"
(ngSubmit)=
"submit()"
se-container=
"1"
labelWidth=
"200"
>
<se
label=
"名称"
error=
"名称不能为空或者空白字符"
required
>
<input
nz-input
formControlName=
"name"
placeholder=
"名称"
required
/>
</se>
<se>
<button
nz-button
[nzType]=
"'default'"
(click)=
"cancel()"
>
取消
</button>
<button
nz-button
[nzType]=
"'primary'"
[disabled]=
"form.invalid"
type=
"submit"
>
创建
</button>
</se>
</form>
IoTSharp/ClientApp/src/app/routes/produce/createdeviceform/createdeviceform.component.less
0 → 100644
浏览文件 @
e05f4c4e
IoTSharp/ClientApp/src/app/routes/produce/createdeviceform/createdeviceform.component.spec.ts
0 → 100644
浏览文件 @
e05f4c4e
import
{
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
CreatedeviceformComponent
}
from
'
./createdeviceform.component
'
;
describe
(
'
CreatedeviceformComponent
'
,
()
=>
{
let
component
:
CreatedeviceformComponent
;
let
fixture
:
ComponentFixture
<
CreatedeviceformComponent
>
;
beforeEach
(
async
()
=>
{
await
TestBed
.
configureTestingModule
({
declarations
:
[
CreatedeviceformComponent
]
})
.
compileComponents
();
});
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
CreatedeviceformComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'
should create
'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
IoTSharp/ClientApp/src/app/routes/produce/createdeviceform/createdeviceform.component.ts
0 → 100644
浏览文件 @
e05f4c4e
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
FormBuilder
,
FormGroup
,
Validators
}
from
'
@angular/forms
'
;
import
{
_HttpClient
}
from
'
@delon/theme
'
;
import
{
Guid
}
from
'
guid-typescript
'
;
import
{
NzModalRef
}
from
'
ng-zorro-antd/modal
'
;
@
Component
({
selector
:
'
app-createdeviceform
'
,
templateUrl
:
'
./createdeviceform.component.html
'
,
styleUrls
:
[
'
./createdeviceform.component.less
'
]
})
export
class
CreatedeviceformComponent
implements
OnInit
{
constructor
(
private
nzModalRef
:
NzModalRef
,
private
fb
:
FormBuilder
,
private
_httpClient
:
_HttpClient
,)
{
}
id
:
string
form
!
:
FormGroup
;
ngOnInit
():
void
{
this
.
form
=
this
.
fb
.
group
({
name
:
[
''
,
[
Validators
.
required
]],
// produceId: [this.id, []],
});
}
submit
(){
this
.
_httpClient
.
post
(
'
api/Devices/produce/
'
+
this
.
id
,
this
.
form
.
value
).
subscribe
({
next
:
next
=>
{
if
(
next
.
code
==
10000
){
this
.
nzModalRef
.
close
(
next
);
}
else
{
this
.
nzModalRef
.
close
(
next
);
}
},
error
:
error
=>
{},
complete
:()
=>
{},
})
}
cancel
(){
this
.
nzModalRef
.
close
();
}
}
IoTSharp/ClientApp/src/app/routes/produce/produce.module.ts
浏览文件 @
e05f4c4e
import
{
NgModule
}
from
'
@angular/core
'
;
import
{
SharedModule
}
from
'
@shared
'
;
import
{
CreatedeviceformComponent
}
from
'
./createdeviceform/createdeviceform.component
'
;
import
{
ProduceRoutingModule
}
from
'
./produce-routing.module
'
;
import
{
ProducedatadictionaryformComponent
}
from
'
./producedatadictionaryform/producedatadictionaryform.component
'
;
import
{
ProducedataformComponent
}
from
'
./producedataform/producedataform.component
'
;
const
COMPONENTS
=
[
ProducedataformComponent
,
ProducedatadictionaryformComponent
ProducedataformComponent
,
ProducedatadictionaryformComponent
,
CreatedeviceformComponent
];
@
NgModule
({
...
...
IoTSharp/ClientApp/src/app/routes/produce/produceform/produceform.component.html
浏览文件 @
e05f4c4e
...
...
@@ -20,21 +20,17 @@
</nz-select>
</se>
<se
label=
"默认网关
类型"
error=
"默认网关类型
"
*ngIf=
"this.form.value.gatewayType==='Customize'"
>
<se
label=
"默认网关
配置"
error=
"默认网关配置
"
*ngIf=
"this.form.value.gatewayType==='Customize'"
>
<nz-code-editor
formControlName=
"gatewayConfigurationJson"
[class.full-screen]=
"fullScreen"
style=
"width: 100%; height: 500px; padding-top: 1rem"
class=
"editor"
[nzEditorOption]=
"{ theme: 'vs',language: 'json' }"
>
</nz-code-editor>
</se>
<se
label=
"默认网关
类型"
error=
"默认网关类型
"
*ngIf=
"this.form.value.gatewayType!=='Unknow'&&this.form.value.gatewayType!=='Customize'"
>
<input
nz-input
formControlName=
"gatewayConfigurationName"
placeholder=
"名称"
/>
<se
label=
"默认网关
配置名称"
error=
"默认网关配置名称
"
*ngIf=
"this.form.value.gatewayType!=='Unknow'&&this.form.value.gatewayType!=='Customize'"
>
<input
nz-input
formControlName=
"gatewayConfigurationName"
placeholder=
"
默认网关配置
名称"
/>
</se>
<se
label=
"默认超时"
error=
"默认超时"
required
>
<nz-select
formControlName=
"defaultDeviceType"
placeholder=
"默认网关类型"
>
<se
label=
"默认设备类型"
error=
"默认设备类型"
required
>
<nz-select
formControlName=
"defaultDeviceType"
placeholder=
"默认设备类型"
>
<nz-option
nzValue=
"Device"
nzLabel=
"Device"
></nz-option>
<nz-option
nzValue=
"Gateway"
nzLabel=
"Gateway"
></nz-option>
</nz-select>
...
...
IoTSharp/ClientApp/src/app/routes/produce/producelist/producelist.component.ts
浏览文件 @
e05f4c4e
...
...
@@ -6,6 +6,7 @@ import { Guid } from 'guid-typescript';
import
{
NzDrawerService
}
from
'
ng-zorro-antd/drawer
'
;
import
{
NzMessageService
}
from
'
ng-zorro-antd/message
'
;
import
{
appmessage
}
from
'
src/app/models/appmessage
'
;
import
{
CreatedeviceformComponent
}
from
'
../createdeviceform/createdeviceform.component
'
;
import
{
ProducedatadictionaryformComponent
}
from
'
../producedatadictionaryform/producedatadictionaryform.component
'
;
import
{
ProducedataformComponent
}
from
'
../producedataform/producedataform.component
'
;
import
{
ProduceformComponent
}
from
'
../produceform/produceform.component
'
;
...
...
@@ -92,21 +93,16 @@ export class ProducelistComponent implements OnInit {
Gateway
:
{
text
:
'
网关
'
,
color
:
'
blue
'
}
};
devicecolumns
:
STColumn
[]
=
[
{
title
:
'
id
'
,
index
:
'
id
'
,
},
{
title
:
'
名称
'
,
index
:
'
name
'
,
render
:
'
name
'
,
type
:
'
link
'
,
},
{
title
:
'
设备类型
'
,
index
:
'
deviceType
'
,
type
:
'
tag
'
,
tag
:
this
.
DeviceTAG
},
{
title
:
'
在线状态
'
,
index
:
'
active
'
,
type
:
'
badge
'
,
badge
:
this
.
BADGE
,
sort
:
true
},
{
title
:
'
最后活动时间
'
,
index
:
'
lastActivityDateTime
'
,
type
:
'
date
'
},
{
title
:
'
认证方式
'
,
index
:
'
identityType
'
,
type
:
'
tag
'
,
tag
:
this
.
TAG
},
]
@
ViewChild
(
'
st
'
,
{
static
:
true
})
...
...
@@ -153,6 +149,13 @@ export class ProducelistComponent implements OnInit {
this
.
editdic
(
item
.
id
);
}
},
{
text
:
'
创建设备
'
,
acl
:
56
,
click
:
(
item
:
any
)
=>
{
this
.
createdevice
(
item
.
id
);
}
},
{
text
:
'
删除
'
,
pop
:
{
...
...
@@ -173,6 +176,24 @@ export class ProducelistComponent implements OnInit {
ngOnInit
()
{
}
createdevice
(
id
:
string
){
this
.
modal
.
create
(
CreatedeviceformComponent
,
{
id
}).
subscribe
(
res
=>
{
if
(
res
&&
res
.
code
===
10000
){
this
.
msg
.
success
(
'
保存成功
'
)
}
else
{
this
.
msg
.
warning
(
'
保存失败:
'
+
res
.
msg
)
}
});
}
openComponent
(
id
:
string
):
void
{
var
{
nzMaskClosable
,
width
}
=
this
.
settingService
.
getData
(
'
drawerconfig
'
);
var
title
=
id
==
Guid
.
EMPTY
?
'
新增产品
'
:
'
修改产品
'
;
...
...
@@ -203,7 +224,7 @@ export class ProducelistComponent implements OnInit {
const
drawerRef
=
this
.
drawerService
.
create
<
ProducedataformComponent
,
{
id
:
string
},
string
>
({
nzTitle
:
title
,
nzContent
:
ProducedataformComponent
,
nzWidth
:
width
,
nzWidth
:
'
80%
'
,
nzMaskClosable
:
nzMaskClosable
,
nzContentParams
:
{
id
:
id
...
...
IoTSharp/Controllers/ProducesController.cs
浏览文件 @
e05f4c4e
...
...
@@ -53,11 +53,12 @@ namespace IoTSharp.Controllers
if
(
m
.
limit
>
1
)
{
{
return
new
ApiResult
<
PagedData
<
ProduceDto
>>(
ApiCode
.
Success
,
"OK"
,
new
PagedData
<
ProduceDto
>
{
total
=
await
_context
.
Produces
.
CountAsync
(
condition
),
rows
=
_context
.
Produces
.
Include
(
c
=>
c
.
Devices
).
Where
(
condition
).
Skip
((
m
.
offset
)
*
m
.
limit
).
Take
(
m
.
limit
)
rows
=
_context
.
Produces
.
Include
(
c
=>
c
.
Devices
).
Where
(
condition
).
Skip
((
m
.
offset
)
*
m
.
limit
)
.
Take
(
m
.
limit
)
.
ToList
().
Select
(
c
=>
new
ProduceDto
{
Id
=
c
.
Id
,
...
...
@@ -88,7 +89,7 @@ namespace IoTSharp.Controllers
});
}
}
...
...
@@ -249,19 +250,20 @@ namespace IoTSharp.Controllers
[
HttpGet
]
public
async
Task
<
ApiResult
<
List
<
ProduceDataItemDto
>>>
GetProduceData
(
Guid
produceId
)
{
var
produce
=
await
_context
.
Produces
var
produce
=
await
_context
.
Produces
.
Include
(
c
=>
c
.
DefaultAttributes
)
.
SingleOrDefaultAsync
(
c
=>
c
.
Id
==
produceId
);
if
(
produce
!=
null
)
{
//var result = _context.ProduceDatas.Where(c => c.Owner.Id == produceId).Select(c => new ProduceDataItemDto
//var result = _context.ProduceDatas.
Include(c=>c.Owner).
Where(c => c.Owner.Id == produceId).Select(c => new ProduceDataItemDto
//{ KeyName = c.KeyName, DataSide = c.DataSide, Type = c.Type }).ToList();
var
result
=
_context
.
DataStorage
.
Where
(
c
=>
c
.
DeviceId
==
Guid
.
Empty
).
Select
(
c
=>
var
result
=
_context
.
DataStorage
.
Where
(
c
=>
c
.
DeviceId
==
produceId
).
Select
(
c
=>
new
ProduceDataItemDto
{
KeyName
=
c
.
KeyName
,
DataSide
=
c
.
DataSide
,
Type
=
c
.
Type
}).
ToList
();
return
new
ApiResult
<
List
<
ProduceDataItemDto
>>(
ApiCode
.
Success
,
"Ok"
,
result
);
}
return
new
ApiResult
<
List
<
ProduceDataItemDto
>>(
ApiCode
.
CantFindObject
,
"Produce is not found"
,
null
);
}
...
...
@@ -279,13 +281,18 @@ namespace IoTSharp.Controllers
try
{
var
produce
=
await
_context
.
Produces
.
Include
(
c
=>
c
.
DefaultAttributes
).
SingleOrDefaultAsync
(
c
=>
c
.
Id
==
dto
.
produceId
);
var
produce
=
await
_context
.
Produces
.
Include
(
c
=>
c
.
DefaultAttributes
)
.
SingleOrDefaultAsync
(
c
=>
c
.
Id
==
dto
.
produceId
);
if
(
produce
!=
null
)
{
var
pds
=
_context
.
ProduceDatas
.
Where
(
c
=>
c
.
Owner
==
produce
).
ToList
();
var
pds
=
_context
.
ProduceDatas
.
Include
(
c
=>
c
.
Owner
).
Where
(
c
=>
c
.
Owner
.
Id
==
dto
.
produceId
).
ToList
();
if
(
dto
.
ProduceData
!=
null
&&
dto
.
ProduceData
.
Length
>
0
)
{
var
data
=
dto
.
ProduceData
.
Select
(
c
=>
new
ProduceData
{
KeyName
=
c
.
KeyName
,
DataSide
=
c
.
DataSide
,
Type
=
c
.
Type
,
Owner
=
produce
,
DateTime
=
DateTime
.
Now
}).
ToList
();
var
data
=
dto
.
ProduceData
.
Select
(
c
=>
new
ProduceData
{
KeyName
=
c
.
KeyName
,
DataSide
=
c
.
DataSide
,
Type
=
c
.
Type
,
Owner
=
produce
,
DateTime
=
DateTime
.
Now
}).
ToList
();
foreach
(
var
item
in
data
)
{
var
pd
=
pds
.
FirstOrDefault
(
c
=>
c
.
KeyName
.
ToLower
()
==
item
.
KeyName
.
ToLower
());
...
...
@@ -297,15 +304,18 @@ namespace IoTSharp.Controllers
}
else
{
item
.
DeviceId
=
dto
.
produceId
;
_context
.
ProduceDatas
.
Add
(
item
);
}
}
await
_context
.
SaveChangesAsync
();
var
delete_keynames
=
pds
.
Select
(
c
=>
c
.
KeyName
.
ToLower
())
.
Except
(
dto
.
ProduceData
.
Select
(
c
=>
c
.
KeyName
.
ToLower
())).
ToArray
();
if
(
delete_keynames
.
Length
>
0
)
{
var
deleteattr
=
pds
.
Join
(
delete_keynames
,
x
=>
x
.
KeyName
.
ToLower
(),
y
=>
y
,
(
x
,
y
)
=>
x
).
ToArray
();
var
deleteattr
=
pds
.
Join
(
delete_keynames
,
x
=>
x
.
KeyName
.
ToLower
(),
y
=>
y
,
(
x
,
y
)
=>
x
)
.
ToArray
();
_context
.
ProduceDatas
.
RemoveRange
(
deleteattr
);
await
_context
.
SaveChangesAsync
();
...
...
@@ -313,8 +323,10 @@ namespace IoTSharp.Controllers
return
new
ApiResult
<
bool
>(
ApiCode
.
Success
,
"Ok"
,
true
);
}
return
new
ApiResult
<
bool
>(
ApiCode
.
CantFindObject
,
"Produce data is not found"
,
false
);
}
return
new
ApiResult
<
bool
>(
ApiCode
.
CantFindObject
,
"Produce is not found"
,
false
);
}
catch
(
Exception
e
)
...
...
@@ -341,6 +353,7 @@ namespace IoTSharp.Controllers
{
return
new
ApiResult
<
List
<
ProduceDictionary
>>(
ApiCode
.
Success
,
"Ok"
,
produce
.
Dictionaries
);
}
return
new
ApiResult
<
List
<
ProduceDictionary
>>(
ApiCode
.
CantFindObject
,
"Produce is not found"
,
null
);
}
...
...
@@ -358,7 +371,8 @@ namespace IoTSharp.Controllers
var
profile
=
this
.
GetUserProfile
();
try
{
var
produce
=
await
_context
.
Produces
.
Include
(
c
=>
c
.
Dictionaries
).
SingleOrDefaultAsync
(
c
=>
c
.
Id
==
dto
.
produceId
);
var
produce
=
await
_context
.
Produces
.
Include
(
c
=>
c
.
Dictionaries
)
.
SingleOrDefaultAsync
(
c
=>
c
.
Id
==
dto
.
produceId
);
if
(
produce
!=
null
)
{
...
...
@@ -386,7 +400,8 @@ namespace IoTSharp.Controllers
}
else
{
var
produceDictionary
=
await
_context
.
ProduceDictionaries
.
SingleOrDefaultAsync
(
c
=>
c
.
Id
==
item
.
Id
);
var
produceDictionary
=
await
_context
.
ProduceDictionaries
.
SingleOrDefaultAsync
(
c
=>
c
.
Id
==
item
.
Id
);
if
(
produceDictionary
!=
null
)
{
produceDictionary
.
KeyName
=
item
.
KeyName
;
...
...
@@ -406,12 +421,16 @@ namespace IoTSharp.Controllers
}
}
var
deletedic
=
produce
.
Dictionaries
.
Select
(
c
=>
c
.
Id
).
Except
(
dto
.
ProduceDictionaryData
.
Select
(
c
=>
c
.
Id
)).
ToList
();
_context
.
ProduceDictionaries
.
RemoveRange
(
produce
.
Dictionaries
.
Where
(
c
=>
deletedic
.
Any
(
p
=>
p
==
c
.
Id
)).
ToList
());
var
deletedic
=
produce
.
Dictionaries
.
Select
(
c
=>
c
.
Id
)
.
Except
(
dto
.
ProduceDictionaryData
.
Select
(
c
=>
c
.
Id
)).
ToList
();
_context
.
ProduceDictionaries
.
RemoveRange
(
produce
.
Dictionaries
.
Where
(
c
=>
deletedic
.
Any
(
p
=>
p
==
c
.
Id
)).
ToList
());
await
_context
.
SaveChangesAsync
();
return
new
ApiResult
<
bool
>(
ApiCode
.
Success
,
"Ok"
,
true
);
}
return
new
ApiResult
<
bool
>(
ApiCode
.
CantFindObject
,
"Produce is not found"
,
false
);
}
catch
(
Exception
e
)
...
...
@@ -422,6 +441,8 @@ namespace IoTSharp.Controllers
}
}
}
IoTSharp/Dtos/CreateDeviceByProduceDto.cs
0 → 100644
浏览文件 @
e05f4c4e
using
System
;
namespace
IoTSharp.Dtos
{
public
class
CreateDeviceByProduceDto
{
public
string
DeviceName
{
get
;
set
;
}
public
Guid
ProduceId
{
get
;
set
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录