提交 361e3069 编写于 作者: W wq1234wq

资产管理,告警查询

上级 0e7333a7
...@@ -18,10 +18,5 @@ namespace IoTSharp.Data ...@@ -18,10 +18,5 @@ namespace IoTSharp.Data
public Customer Customer { get; set; } public Customer Customer { get; set; }
public Tenant Tenant { get; set; } public Tenant Tenant { get; set; }
public string path { get; set; }
} }
} }
...@@ -74,31 +74,27 @@ ...@@ -74,31 +74,27 @@
</div> </div>
<div nz-col nzMd="8" nzSm="24"> <div nz-col nzMd="8" nzSm="24">
<nz-form-item> <nz-form-item>
<nz-form-label nzFor="DeviceName">告警级别</nz-form-label> <nz-form-label nzFor="OriginatorType">起因来源</nz-form-label>
<nz-form-control> <nz-form-control>
<nz-select [(ngModel)]="q.Serverity"> <nz-select [(ngModel)]="q.OriginatorType" (ngModelChange)="onOriginatorTypeChange($event)">
<nz-option nzValue="-1" nzLabel="全部"></nz-option> <nz-option nzValue="-1" nzLabel="全部"></nz-option>
<nz-option nzValue="0" nzLabel="不确定"></nz-option> <nz-option nzValue="0" nzLabel="未知"></nz-option>
<nz-option nzValue="1" nzLabel="警告"></nz-option> <nz-option nzValue="1" nzLabel="设备"></nz-option>
<nz-option nzValue="2" nzLabel="次要" ></nz-option> <nz-option nzValue="2" nzLabel="网关" ></nz-option>
<nz-option nzValue="3" nzLabel="重要" ></nz-option> <nz-option nzValue="3" nzLabel="资产" ></nz-option>
<nz-option nzValue="4" nzLabel="错误" ></nz-option>
</nz-select> </nz-select>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</div> </div>
<div nz-col nzMd="8" nzSm="24"> <div nz-col nzMd="8" nzSm="24">
<nz-form-item> <nz-form-item>
<nz-form-label nzFor="DeviceName">告警级别</nz-form-label> <nz-form-label nzFor="DeviceName">起因对象</nz-form-label>
<nz-form-control> <nz-form-control>
<nz-select [(ngModel)]="q.Serverity"> <input nz-input [(ngModel)]="q.OriginatorName" (input)="onOriginatorInput($event)" (ngModelChange)="onOriginatorChange($event)" name="Originator" placeholder="请输入" [nzAutocomplete]="auto"/>
<nz-option nzValue="-1" nzLabel="全部"></nz-option> <input type="hidden" [(ngModel)]="q.OriginatorId" name="OriginatorId" placeholder="请输入" />
<nz-option nzValue="0" nzLabel="不确定"></nz-option> <nz-autocomplete #auto>
<nz-option nzValue="1" nzLabel="警告"></nz-option> <nz-auto-option *ngFor="let option of originators" [nzValue]="option.name">{{ option.name }}</nz-auto-option>
<nz-option nzValue="2" nzLabel="次要" ></nz-option> </nz-autocomplete>
<nz-option nzValue="3" nzLabel="重要" ></nz-option>
<nz-option nzValue="4" nzLabel="错误" ></nz-option>
</nz-select>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</div> </div>
...@@ -110,10 +106,10 @@ ...@@ -110,10 +106,10 @@
</div> </div>
</form> </form>
<button nz-button [nzType]="'primary'" (click)="openComponent(-1)" acl [acl-ability]="59"> <!-- <button nz-button [nzType]="'primary'" (click)="openComponent(-1)" acl [acl-ability]="59">
<i nz-icon nzType="plus"></i> <i nz-icon nzType="plus"></i>
<span>{{ 'button.new' | i18n }}</span> <span>{{ 'button.new' | i18n }}</span>
</button> </button> -->
<!--<button nz-button [nzType]="'primary'" [routerLink]="['/manage/authority/roleform']" [queryParams]="{Id:-1}"> <!--<button nz-button [nzType]="'primary'" [routerLink]="['/manage/authority/roleform']" [queryParams]="{Id:-1}">
<i nz-icon nzType="plus"></i> <i nz-icon nzType="plus"></i>
<span>{{ 'button.new' | translate }}</span> <span>{{ 'button.new' | translate }}</span>
......
...@@ -5,6 +5,7 @@ import { _HttpClient, ModalHelper, SettingsService } from '@delon/theme'; ...@@ -5,6 +5,7 @@ import { _HttpClient, ModalHelper, SettingsService } from '@delon/theme';
import { Guid } from 'guid-typescript'; import { Guid } from 'guid-typescript';
import { NzDrawerService } from 'ng-zorro-antd/drawer'; import { NzDrawerService } from 'ng-zorro-antd/drawer';
import { NzMessageService } from 'ng-zorro-antd/message'; import { NzMessageService } from 'ng-zorro-antd/message';
import { debounceTime } from 'rxjs/operators';
import { AppMessage } from '../../common/AppMessage'; import { AppMessage } from '../../common/AppMessage';
import { AlarmdetailComponent } from '../alarmdetail/alarmdetail.component'; import { AlarmdetailComponent } from '../alarmdetail/alarmdetail.component';
...@@ -14,21 +15,11 @@ import { AlarmdetailComponent } from '../alarmdetail/alarmdetail.component'; ...@@ -14,21 +15,11 @@ import { AlarmdetailComponent } from '../alarmdetail/alarmdetail.component';
styleUrls: ['./alarmlist.component.less'] styleUrls: ['./alarmlist.component.less']
}) })
export class AlarmlistComponent implements OnInit { export class AlarmlistComponent implements OnInit {
originators: originator[] = [];
constructor(
private http: _HttpClient,
public msg: NzMessageService,
private modal: ModalHelper,
private cdr: ChangeDetectorRef,
private _router: Router,
private drawerService: NzDrawerService,
private settingService: SettingsService,
) {}
page: STPage = { page: STPage = {
front: false, front: false,
total: true, total: true,
zeroIndexed: true, zeroIndexed: true
}; };
q: { q: {
pi: number; pi: number;
...@@ -36,30 +27,32 @@ export class AlarmlistComponent implements OnInit { ...@@ -36,30 +27,32 @@ export class AlarmlistComponent implements OnInit {
sorter: string; sorter: string;
status: number | null; status: number | null;
Name: string; Name: string;
AckDateTime:any; AckDateTime: any;
ClearDateTime:any; ClearDateTime: any;
EndDateTime:any; EndDateTime: any;
StartDateTime:any; StartDateTime: any;
AlarmType:any; AlarmType: any;
AlarmStatus:Number; AlarmStatus: Number;
OriginatorId:any; OriginatorId: any;
OriginatorName: string;
Serverity:Number Serverity: Number;
OriginatorType: Number;
} = { } = {
pi: 0, pi: 0,
ps: 10, ps: 10,
Name: '', Name: '',
sorter: '', sorter: '',
status: null, status: null,
AckDateTime:null, AckDateTime: null,
ClearDateTime:null, ClearDateTime: null,
StartDateTime:null, StartDateTime: null,
EndDateTime:null, EndDateTime: null,
AlarmType:'', AlarmType: '',
AlarmStatus:-1, OriginatorName: '',
OriginatorId:Guid.EMPTY, AlarmStatus: -1,
Serverity:-1 OriginatorId: Guid.EMPTY,
Serverity: -1,
OriginatorType: -1
}; };
total = 0; total = 0;
...@@ -72,26 +65,26 @@ export class AlarmlistComponent implements OnInit { ...@@ -72,26 +65,26 @@ export class AlarmlistComponent implements OnInit {
text: '已禁用', text: '已禁用',
value: false, value: false,
type: 'processing', type: 'processing',
checked: false, checked: false
}, },
{ {
index: -1, index: -1,
text: '已删除', text: '已删除',
value: false, value: false,
type: 'processing', type: 'processing',
checked: false, checked: false
}, }
]; ];
url = 'api/alarm/list'; url = 'api/alarm/list';
req: STReq = { method: 'POST', allInBody: true, reName: { pi: 'offset', ps: 'limit' }, params: this.q , }; req: STReq = { method: 'POST', allInBody: true, reName: { pi: 'offset', ps: 'limit' }, params: this.q };
// 定义返回的参数 // 定义返回的参数
res: STRes = { res: STRes = {
reName: { reName: {
total: 'data.total', total: 'data.total',
list: 'data.rows', list: 'data.rows'
}, }
}; };
@ViewChild('st', { static: true }) @ViewChild('st', { static: true })
...@@ -102,38 +95,36 @@ export class AlarmlistComponent implements OnInit { ...@@ -102,38 +95,36 @@ export class AlarmlistComponent implements OnInit {
1: { text: '警告', color: '#faad14' }, 1: { text: '警告', color: '#faad14' },
2: { text: '次要', color: '#bae637' }, 2: { text: '次要', color: '#bae637' },
3: { text: '主要', color: '#1890ff' }, 3: { text: '主要', color: '#1890ff' },
4: { text: '错误', color: '#f5222d' }, 4: { text: '错误', color: '#f5222d' }
}; };
alarmstatusTAG: STColumnTag = { alarmstatusTAG: STColumnTag = {
0: { text: '激活未应答', color: '#ffa39e' }, 0: { text: '激活未应答', color: '#ffa39e' },
1: { text: '激活已应答', color: '#f759ab' }, 1: { text: '激活已应答', color: '#f759ab' },
2: { text: '清除未应答', color: '#87e8de' }, 2: { text: '清除未应答', color: '#87e8de' },
3: { text: '清除已应答', color: '#d3f261' }, 3: { text: '清除已应答', color: '#d3f261' }
}; };
ServerityTAG: STColumnTag = { ServerityTAG: STColumnTag = {
AccessToken: { text: 'AccessToken', color: 'green' }, AccessToken: { text: 'AccessToken', color: 'green' },
X509Certificate: { text: 'X509Certificate', color: 'blue' } X509Certificate: { text: 'X509Certificate', color: 'blue' }
}; };
columns: STColumn[] = [ columns: STColumn[] = [
{ title: '', index: 'Id', type: 'checkbox' }, { title: '', index: 'Id', type: 'checkbox' },
{ title: 'id', index: 'id', }, { title: 'id', index: 'id' },
{ {
title: '类型', title: '类型',
index: 'AlarmType', index: 'AlarmType'
}, },
{ title: '创建时间', index: 'ackDateTime',type: 'date' }, { title: '创建时间', index: 'ackDateTime', type: 'date' },
{ title: '清除时间', index: 'clearDateTime' ,type: 'date'}, { title: '清除时间', index: 'clearDateTime', type: 'date' },
{ title: '警告持续的开始时间', index: 'startDateTime',type: 'date' }, { title: '警告持续的开始时间', index: 'startDateTime', type: 'date' },
{ title: '结束时间', index: 'endDateTime' ,type: 'date'}, { title: '结束时间', index: 'endDateTime', type: 'date' },
{ title: '告警状态', index: 'alarmStatus', type:'tag' ,tag: this.alarmstatusTAG }, { title: '告警状态', index: 'alarmStatus', type: 'tag', tag: this.alarmstatusTAG },
{ title: '严重程度', index: 'serverity' , type:'tag' ,tag: this.serveritybadge}, { title: '严重程度', index: 'serverity', type: 'tag', tag: this.serveritybadge },
{ title: '设备类型', index: 'originatorType' }, { title: '设备类型', index: 'originatorType' },
{ {
title: { i18n: 'table.operation' }, title: { i18n: 'table.operation' },
buttons: [ buttons: [
...@@ -150,34 +141,75 @@ export class AlarmlistComponent implements OnInit { ...@@ -150,34 +141,75 @@ export class AlarmlistComponent implements OnInit {
// type: 'clone' // type: 'clone'
// } // }
// }); // });
}, }
}, }
]
], }
},
]; ];
selectedRows: STData[] = []; selectedRows: STData[] = [];
description = ''; description = '';
totalCallNo = 0; totalCallNo = 0;
expandForm = false; expandForm = false;
constructor(
private http: _HttpClient,
public msg: NzMessageService,
private modal: ModalHelper,
private cdr: ChangeDetectorRef,
private _router: Router,
private drawerService: NzDrawerService,
private settingService: SettingsService
) {}
ngOnInit() {} ngOnInit() {}
onOriginatorTypeChange($event) {
this.q.OriginatorName = '';
this.q.OriginatorId = Guid.EMPTY;
this.originators=[];
}
onOriginatorInput($event) {
var element = $event.target as HTMLInputElement;
this.http
.post('api/alarm/originators', {
originatorName: element?.value ?? '',
OriginatorType: this.q.OriginatorType
})
.pipe(debounceTime(500))
.subscribe(
next => {
this.originators = [
...next.data.map(x => {
return { id: x.id, name: x.name };
})
];
},
error => {},
() => {}
);
}
onOriginatorChange($event) {
this.q.OriginatorId = this.originators.find(c => c.name == $event)?.id;
}
rowchange(event) { rowchange(event) {
console.log(event);
switch (event.type) { switch (event.type) {
case 'expand': case 'expand':
this.http.post<AppMessage>('api/dictionary/index' ,{ this.http
DictionaryGroupId:event.expand.dictionaryGroupId, .post<AppMessage>('api/dictionary/index', {
offset:0, DictionaryGroupId: event.expand.dictionaryGroupId,
limit:100 offset: 0,
}).subscribe( limit: 100
(x) => { })
event.expand.Children = x.data.rows; .subscribe(
}, x => {
(y) => {}, event.expand.Children = x.data.rows;
() => {}, },
); y => {},
() => {}
);
break; break;
} }
} }
...@@ -190,13 +222,13 @@ export class AlarmlistComponent implements OnInit { ...@@ -190,13 +222,13 @@ export class AlarmlistComponent implements OnInit {
nzWidth: width, nzWidth: width,
nzMaskClosable: nzMaskClosable, nzMaskClosable: nzMaskClosable,
nzContentParams: { nzContentParams: {
id: id, id: id
}, }
}); });
drawerRef.afterOpen.subscribe(() => {}); drawerRef.afterOpen.subscribe(() => {});
drawerRef.afterClose.subscribe((data) => { drawerRef.afterClose.subscribe(data => {
if (typeof data === 'string') { if (typeof data === 'string') {
} }
...@@ -217,3 +249,8 @@ export class AlarmlistComponent implements OnInit { ...@@ -217,3 +249,8 @@ export class AlarmlistComponent implements OnInit {
} }
setstatus(number: number, status: number) {} setstatus(number: number, status: number) {}
} }
export interface originator {
id: string;
name: string;
}
...@@ -13,10 +13,7 @@ import { appmessage } from '../../common/AppMessage'; ...@@ -13,10 +13,7 @@ import { appmessage } from '../../common/AppMessage';
styleUrls: ['./assetform.component.less'] styleUrls: ['./assetform.component.less']
}) })
export class AssetformComponent implements OnInit { export class AssetformComponent implements OnInit {
@Input() params: any = { @Input() id: any = Guid.EMPTY;
id: Guid.EMPTY,
customerId: '-1',
};
config:any={ language: 'zh_CN', height: 250,} config:any={ language: 'zh_CN', height: 250,}
title: string = ''; title: string = '';
loading = false; loading = false;
...@@ -38,9 +35,9 @@ export class AssetformComponent implements OnInit { ...@@ -38,9 +35,9 @@ export class AssetformComponent implements OnInit {
id: [Guid.EMPTY, []], id: [Guid.EMPTY, []],
}); });
if (this.params.id !== Guid.EMPTY) { if (this.id !== Guid.EMPTY) {
concat( concat(
this._httpClient.get<appmessage<any>>('api/asset/get/' + this.params.id).pipe( this._httpClient.get<appmessage<any>>('api/asset/get?id=' + this.id).pipe(
map((x) => { map((x) => {
this.form.patchValue(x.data) this.form.patchValue(x.data)
}), }),
...@@ -51,7 +48,7 @@ export class AssetformComponent implements OnInit { ...@@ -51,7 +48,7 @@ export class AssetformComponent implements OnInit {
submit() { submit() {
this.submitting = true; this.submitting = true;
if (this.params.id == Guid.EMPTY) { if (this.id == Guid.EMPTY) {
this._httpClient.post('api/asset/save', this.form.value).subscribe( this._httpClient.post('api/asset/save', this.form.value).subscribe(
() => { () => {
this.submitting = false; this.submitting = false;
...@@ -65,7 +62,7 @@ export class AssetformComponent implements OnInit { ...@@ -65,7 +62,7 @@ export class AssetformComponent implements OnInit {
() => {}, () => {},
); );
} else { } else {
this._httpClient.put('api/asset/update' + this.params.id, this.form.value).subscribe( this._httpClient.put('api/asset/update', this.form.value).subscribe(
() => { () => {
this.submitting = false; this.submitting = false;
this.msg.create('success', '设备修改成功'); this.msg.create('success', '设备修改成功');
...@@ -80,6 +77,6 @@ export class AssetformComponent implements OnInit { ...@@ -80,6 +77,6 @@ export class AssetformComponent implements OnInit {
} }
} }
close(): void { close(): void {
this.drawerRef.close(this.params); this.drawerRef.close(this.id);
} }
} }
...@@ -39,13 +39,23 @@ ...@@ -39,13 +39,23 @@
[expand]="expand" [expand]="expand"
expandRowByClick expandRowByClick
expandAccordion expandAccordion
(change)="onchange($event)"
> >
<ng-template #expand let-item let-index="index" let-column="column">
<st [data]="item.Children" [columns]="columnsChildren" [page]="{ show: false }"></st>
</ng-template>
</st> </st>
</nz-card> </nz-card>
<ng-template #expand let-item let-index="index" let-column="column">
<st [data]="relations" [columns]="columnsChildren" [page]="{ show: false }">
<ng-template st-row="nameTpl" let-item let-index="index">
<input *ngIf="item.edit" nz-input [ngModel]="item.name" (ngModelChange)="st.setRow(index, { name: $event })" />
<ng-container *ngIf="!item.edit">{{ item.name }}</ng-container>
</ng-template>
</st>
</ng-template>
<ng-template #modalContent> <ng-template #modalContent>
<nz-form-item> <nz-form-item>
<nz-form-label nzFor="no">描述</nz-form-label> <nz-form-label nzFor="no">描述</nz-form-label>
......
import { ChangeDetectorRef, Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; import { ChangeDetectorRef, Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { STColumn, STColumnBadge, STColumnTag, STComponent, STData, STPage, STReq, STRes } from '@delon/abc/st'; import { STChange, STColumn, STColumnBadge, STColumnTag, STComponent, STData, STPage, STReq, STRes } from '@delon/abc/st';
import { _HttpClient, ModalHelper, SettingsService } from '@delon/theme'; import { _HttpClient, ModalHelper, SettingsService } from '@delon/theme';
import { Guid } from 'guid-typescript'; import { Guid } from 'guid-typescript';
import { NzDrawerService } from 'ng-zorro-antd/drawer'; import { NzDrawerService } from 'ng-zorro-antd/drawer';
import { NzMessageService } from 'ng-zorro-antd/message'; import { NzMessageService } from 'ng-zorro-antd/message';
import { title } from 'process'; import { nextTick, title } from 'process';
import { AppMessage } from '../../common/AppMessage'; import { AppMessage } from '../../common/AppMessage';
import { AssetformComponent } from '../assetform/assetform.component'; import { AssetformComponent } from '../assetform/assetform.component';
...@@ -15,16 +15,6 @@ import { AssetformComponent } from '../assetform/assetform.component'; ...@@ -15,16 +15,6 @@ import { AssetformComponent } from '../assetform/assetform.component';
styleUrls: ['./assetlist.component.less'] styleUrls: ['./assetlist.component.less']
}) })
export class AssetlistComponent implements OnInit { export class AssetlistComponent implements OnInit {
constructor( constructor(
private http: _HttpClient, private http: _HttpClient,
public msg: NzMessageService, public msg: NzMessageService,
...@@ -32,13 +22,16 @@ export class AssetlistComponent implements OnInit { ...@@ -32,13 +22,16 @@ export class AssetlistComponent implements OnInit {
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private _router: Router, private _router: Router,
private drawerService: NzDrawerService, private drawerService: NzDrawerService,
private settingService: SettingsService, private settingService: SettingsService
) {} ) {}
@ViewChild('expand')
tpl: TemplateRef<any>;
relations = [];
page: STPage = { page: STPage = {
front: false, front: false,
total: true, total: true,
zeroIndexed: true, zeroIndexed: true
}; };
q: { q: {
pi: number; pi: number;
...@@ -52,7 +45,7 @@ export class AssetlistComponent implements OnInit { ...@@ -52,7 +45,7 @@ export class AssetlistComponent implements OnInit {
ps: 10, ps: 10,
Name: '', Name: '',
sorter: '', sorter: '',
status: null, status: null
}; };
total = 0; total = 0;
...@@ -65,15 +58,15 @@ export class AssetlistComponent implements OnInit { ...@@ -65,15 +58,15 @@ export class AssetlistComponent implements OnInit {
text: '已禁用', text: '已禁用',
value: false, value: false,
type: 'processing', type: 'processing',
checked: false, checked: false
}, },
{ {
index: -1, index: -1,
text: '已删除', text: '已删除',
value: false, value: false,
type: 'processing', type: 'processing',
checked: false, checked: false
}, }
]; ];
url = 'api/asset/list'; url = 'api/asset/list';
...@@ -83,8 +76,8 @@ export class AssetlistComponent implements OnInit { ...@@ -83,8 +76,8 @@ export class AssetlistComponent implements OnInit {
res: STRes = { res: STRes = {
reName: { reName: {
total: 'data.total', total: 'data.total',
list: 'data.rows', list: 'data.rows'
}, }
}; };
@ViewChild('st', { static: true }) @ViewChild('st', { static: true })
...@@ -92,28 +85,49 @@ export class AssetlistComponent implements OnInit { ...@@ -92,28 +85,49 @@ export class AssetlistComponent implements OnInit {
TAG: STColumnTag = { TAG: STColumnTag = {
1: { text: '成功', color: 'red' }, 1: { text: '成功', color: 'red' },
2: { text: '进行中', color: 'blue' }, 2: { text: '进行中', color: 'blue' }
}; };
columnsChildren: STColumn[] = [ columnsChildren: STColumn[] = [
{ title: 'id', index: 'id' }, { title: 'id', index: 'id' },
{ title: '字典名', index: 'name' }, { title: '名称', index: 'name' },
{ title: '字典值', index: 'description' }, { title: '描述', index: 'description' },
{ title: '备注', index: 'assetType' }, { title: '类型', index: 'assetType' },
{ title: '类型', index: 'dictionaryValueTypeName' }, { title: '键名称', index: 'keyName' },
{ title: '数据类型', index: 'dataCatalog' },{
title: 'OP',
buttons: [
{
text: `Edit`,
iif: i => !i.edit,
click: i => this.updateEdit(i, true),
},
{
text: `Save`,
iif: i => i.edit,
click: i => {
this.submit(i);
},
},
{
text: `Cancel`,
iif: i => i.edit,
click: i => this.updateEdit(i, false),
},
],
},
]; ];
columns: STColumn[] = [ columns: STColumn[] = [
{ title: '', index: 'id', type: 'checkbox' }, { title: '', index: 'id', type: 'checkbox' },
{ title: 'id', index: 'id', }, { title: 'id', index: 'id' },
{ {
title: '资产名称(数量)', title: '资产名称(数量)',
index: 'name', index: 'name'
}, },
{ title: '类型', index: 'assetType' }, { title: '类型', index: 'assetType' },
{ title: '描述', index: 'description' }, { title: '描述', index: 'description' },
{ {
title: { i18n: 'table.operation' }, title: { i18n: 'table.operation' },
buttons: [ buttons: [
...@@ -122,32 +136,8 @@ export class AssetlistComponent implements OnInit { ...@@ -122,32 +136,8 @@ export class AssetlistComponent implements OnInit {
i18n: 'common.edit', i18n: 'common.edit',
acl: 60, acl: 60,
click: (item: any) => { click: (item: any) => {
this.openComponent(item.dictionaryGroupId); this.openComponent(item.id);
//this._router.navigate(['manage/role/roleform'], }
// {
// queryParams: {
// UserId: item.UserId,
// type: 'clone'
// }
// });
},
},
{
text: (record) => (record.dictionaryGroupStatus == 1 ? '禁用' : '启用'),
pop: {
title: '确认修改字典组状态?',
okType: 'danger',
icon: 'warning',
},
click: (item: any) => {
this.http.get('api/dictionarygroup/setstatus?id=' + item.DictionaryGroupId).subscribe(
(x) => {
this.getData();
},
(y) => {},
() => {},
);
},
}, },
{ {
...@@ -155,21 +145,21 @@ export class AssetlistComponent implements OnInit { ...@@ -155,21 +145,21 @@ export class AssetlistComponent implements OnInit {
pop: { pop: {
title: '确认删除字典组?', title: '确认删除字典组?',
okType: 'danger', okType: 'danger',
icon: 'warning', icon: 'warning'
}, },
acl: 61, acl: 61,
click: (item: any) => { click: (item: any) => {
this.http.get('api/dictionarygroup/delete?id=' + item.DdictionaryGroupId).subscribe( this.http.delete('api/asset/delete?id=' + item.id).subscribe(
(x) => { x => {
this.getData(); this.getData();
}, },
(y) => {}, y => {},
() => {}, () => {}
); );
}, }
}, }
], ]
}, }
]; ];
selectedRows: STData[] = []; selectedRows: STData[] = [];
description = ''; description = '';
...@@ -177,8 +167,14 @@ export class AssetlistComponent implements OnInit { ...@@ -177,8 +167,14 @@ export class AssetlistComponent implements OnInit {
expandForm = false; expandForm = false;
ngOnInit() {} ngOnInit() {}
submit(i){}
updateEdit(i,edit){
console.log(this.tpl);
this.st.setRow(i, { edit }, { refreshSchema: true });
}
openComponent(id: string): void { openComponent(id: string): void {
var { nzMaskClosable, width } = this.settingService.getData('drawerconfig'); var { nzMaskClosable, width } = this.settingService.getData('drawerconfig');
var title = id == Guid.EMPTY ? '新增资产' : '修改资产'; var title = id == Guid.EMPTY ? '新增资产' : '修改资产';
...@@ -188,13 +184,13 @@ export class AssetlistComponent implements OnInit { ...@@ -188,13 +184,13 @@ export class AssetlistComponent implements OnInit {
nzWidth: width, nzWidth: width,
nzMaskClosable: nzMaskClosable, nzMaskClosable: nzMaskClosable,
nzContentParams: { nzContentParams: {
id: id, id: id
}, }
}); });
drawerRef.afterOpen.subscribe(() => {}); drawerRef.afterOpen.subscribe(() => {});
drawerRef.afterClose.subscribe((data) => { drawerRef.afterClose.subscribe(data => {
if (typeof data === 'string') { if (typeof data === 'string') {
} }
...@@ -202,7 +198,24 @@ export class AssetlistComponent implements OnInit { ...@@ -202,7 +198,24 @@ export class AssetlistComponent implements OnInit {
}); });
} }
r; onchange($events: STChange) {
console.log($events)
switch ($events.type) {
case 'expand':
if ($events.expand.expand) {
this.http.get('api/asset/relations?assetid=' + $events.expand.id).subscribe(
next => {
this.relations = next.data;
},
error => {},
() => {}
);
}
break;
}
}
getData() { getData() {
this.st.req = this.req; this.st.req = this.req;
this.st.load(this.st.pi); this.st.load(this.st.pi);
......
...@@ -25,11 +25,21 @@ ...@@ -25,11 +25,21 @@
</form> </form>
<div nz-col nzMd="8" nzSm="24"> <div nz-col nzMd="8" nzSm="24">
<button nz-button [nzType]="'primary'" (click)="edit('00000000-0000-0000-0000-000000000000')" acl [acl-ability]="137">
<i nz-icon nzType="plus"></i>
<span>{{ 'button.new' | i18n }}</span>
</button>
<button nz-button [nzType]="'primary'" (click)="downlink([])" acl [acl-ability]="137"> <button nz-button [nzType]="'primary'" (click)="downlink([])" acl [acl-ability]="137">
<i nz-icon nzType="plus"></i> <i nz-icon nzType="plus"></i>
<span>设置规则</span> <span>设置规则</span>
</button> </button>
<button nz-button [nzType]="'primary'" (click)="exporttoasset([])" acl [acl-ability]="137">
<i nz-icon nzType="plus"></i>
<span>导出到资产</span>
</button>
</div> </div>
</nz-card> </nz-card>
......
...@@ -21,6 +21,7 @@ import { DevicetokendialogComponent } from '../devicetokendialog/devicetokendial ...@@ -21,6 +21,7 @@ import { DevicetokendialogComponent } from '../devicetokendialog/devicetokendial
import { fork } from 'child_process'; import { fork } from 'child_process';
import { ProppartComponent } from '../deviceprop/proppart/proppart.component'; import { ProppartComponent } from '../deviceprop/proppart/proppart.component';
import { devicemodelcommand } from '../../devicemodel/devicemodelcommandparam'; import { devicemodelcommand } from '../../devicemodel/devicemodelcommandparam';
import { ExporttoassetComponent } from '../exporttoasset/exporttoasset.component';
@Component({ @Component({
selector: 'app-devicelist', selector: 'app-devicelist',
templateUrl: './devicelist.component.html', templateUrl: './devicelist.component.html',
...@@ -64,7 +65,9 @@ export class DevicelistComponent implements OnInit, OnDestroy { ...@@ -64,7 +65,9 @@ export class DevicelistComponent implements OnInit, OnDestroy {
page: STPage = { page: STPage = {
front: false, front: false,
total: true, total: true,
zeroIndexed: true zeroIndexed: true,
showSize:true,
pageSizes:[10,20,50,100,500]
}; };
q: { q: {
pi: number; pi: number;
...@@ -226,8 +229,41 @@ export class DevicelistComponent implements OnInit, OnDestroy { ...@@ -226,8 +229,41 @@ export class DevicelistComponent implements OnInit, OnDestroy {
); );
} }
downlink(dev: any[]) { exporttoasset(dev: any[]) {
console.log(dev); console.log(dev);
if (dev.length == 0) {
dev = this.st.list.filter(c => c.checked);
}
var { nzMaskClosable, width } = this.settingService.getData('drawerconfig');
let title = '属性修改';
const drawerRef = this.drawerService.create<
ExporttoassetComponent,
{
params: {
id: string;
customerId: string;
};
},
any
>({
nzTitle: title,
nzContent: ExporttoassetComponent,
nzWidth: width,
nzMaskClosable: nzMaskClosable,
nzContentParams: {
params: {
dev: dev
}
}
});
drawerRef.afterOpen.subscribe(() => {
this.getData();
});
drawerRef.afterClose.subscribe(() => {});
}
downlink(dev: any[]) {
if (dev.length == 0) { if (dev.length == 0) {
dev = this.st.list.filter(c => c.checked); dev = this.st.list.filter(c => c.checked);
} }
......
<div nz-col nzMd="24" nzXs="24" nzSm="24">
<nz-form-item>
<nz-form-label nzFor="CreateDate">请选择规则</nz-form-label>
<nz-form-control>
<nz-select [(ngModel)]="rule" (ngModelChange)="selectchanged($event)">
<nz-option *ngFor="let c of assets" [nzValue]="c.id" [nzLabel]="c.name"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<st [expandAccordion]="true" #st [data]="params.dev" [columns]="columns" expandAccordion> </st>
<button nz-button [nzType]="'primary'" (click)="expert()" acl [acl-ability]="137">
<i nz-icon nzType="apartment"></i>
<span>规则下发</span>
</button>
</div>
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ExporttoassetComponent } from './exporttoasset.component';
describe('ExporttoassetComponent', () => {
let component: ExporttoassetComponent;
let fixture: ComponentFixture<ExporttoassetComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ExporttoassetComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ExporttoassetComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, Input, OnInit } from '@angular/core';
import { STColumn } from '@delon/abc/st';
import { _HttpClient } from '@delon/theme';
import { Guid } from 'guid-typescript';
import { NzDrawerRef } from 'ng-zorro-antd/drawer';
import { NzMessageService } from 'ng-zorro-antd/message';
import { AppMessage } from '../../common/AppMessage';
@Component({
selector: 'app-exporttoasset',
templateUrl: './exporttoasset.component.html',
styleUrls: ['./exporttoasset.component.less']
})
export class ExporttoassetComponent implements OnInit {
rule = Guid.EMPTY;
columns: STColumn[] = [
{ title: '', index: 'id', type: 'checkbox' },
{ title: 'id', index: 'id' },
{ title: '名称', index: 'name', render: 'name' },
{ title: '设备类型', index: 'email' },
{ title: '所有者', index: 'phone' },
{ title: '租户', index: 'country' },
{ title: '客户', index: 'province' },
];
constructor(private http: _HttpClient, private msg: NzMessageService, private drawerRef: NzDrawerRef<string>,) {}
@Input()
params: any = {
dev: [],
};
assets: any[];
url = 'api/asset/list';
ngOnInit(): void {
this.http
.get<AppMessage>(this.url, {
offset: 0,
limit: 1000,
})
.subscribe(
(x) => {
this.assets = x.data.rows;},
(y) => {},
() => {},
);
}
selectchanged($event) {}
expert() {
if(this.rule===Guid.EMPTY){
this.msg.warning('please select a rule to execute')
return
}
this.http
.post('api/asset/adddevice', {
assetid: this.rule,
relations: this.params.dev.map((x) =>{return {DeviceId:x.id,name:x.name}}),
})
.subscribe(
(next) => {
this.msg.create('success', '设备导出成功');
this.drawerRef.close(this.params);
},
(error) => {
this.msg.create('error', '设备导出失败');
this.drawerRef.close(this.params);
},
() => {},
);
}
}
...@@ -7,7 +7,6 @@ import { NzMessageService } from 'ng-zorro-antd/message'; ...@@ -7,7 +7,6 @@ import { NzMessageService } from 'ng-zorro-antd/message';
import { debounceTime } from 'rxjs/operators'; import { debounceTime } from 'rxjs/operators';
import { FloweventviewComponent } from '../floweventview/floweventview.component'; import { FloweventviewComponent } from '../floweventview/floweventview.component';
@Component({ @Component({
selector: 'app-flowevents', selector: 'app-flowevents',
templateUrl: './flowevents.component.html', templateUrl: './flowevents.component.html',
...@@ -15,16 +14,15 @@ import { FloweventviewComponent } from '../floweventview/floweventview.component ...@@ -15,16 +14,15 @@ import { FloweventviewComponent } from '../floweventview/floweventview.component
}) })
export class FloweventsComponent implements OnInit { export class FloweventsComponent implements OnInit {
devices: creator[] = [{ id: Guid.EMPTY, name: '测试' }]; devices: creator[] = [{ id: Guid.EMPTY, name: '测试' }];
dateFormat = 'yyyy/MM/dd' dateFormat = 'yyyy/MM/dd';
TAG: STColumnTag = { TAG: STColumnTag = {
'Normal': { text: '设备', color: 'green' }, Normal: { text: '设备', color: 'green' },
'TestPurpose': { text: '测试', color: 'orange' }, TestPurpose: { text: '测试', color: 'orange' }
}; };
page: STPage = { page: STPage = {
front: false, front: false,
total: true, total: true,
zeroIndexed: true, zeroIndexed: true
}; };
q: { q: {
pi: number; pi: number;
...@@ -37,16 +35,16 @@ export class FloweventsComponent implements OnInit { ...@@ -37,16 +35,16 @@ export class FloweventsComponent implements OnInit {
sorter: string; sorter: string;
status: number | null; status: number | null;
} = { } = {
pi: 0, pi: 0,
ps: 10, ps: 10,
Name: '', Name: '',
Creator: '', Creator: '',
RuleId: '', RuleId: '',
CreatorName: '', CreatorName: '',
CreatTime: [], CreatTime: [],
sorter: '', sorter: '',
status: null, status: null
}; };
total = 0; total = 0;
loading = false; loading = false;
...@@ -58,8 +56,8 @@ export class FloweventsComponent implements OnInit { ...@@ -58,8 +56,8 @@ export class FloweventsComponent implements OnInit {
res: STRes = { res: STRes = {
reName: { reName: {
total: 'data.total', total: 'data.total',
list: 'data.rows', list: 'data.rows'
}, }
}; };
@ViewChild('st', { static: true }) @ViewChild('st', { static: true })
...@@ -79,11 +77,10 @@ export class FloweventsComponent implements OnInit { ...@@ -79,11 +77,10 @@ export class FloweventsComponent implements OnInit {
text: '回放', text: '回放',
click: (item: baseevent) => { click: (item: baseevent) => {
this.openComponent(item); this.openComponent(item);
}, }
}, }
]
], }
},
]; ];
selectedRows: STData[] = []; selectedRows: STData[] = [];
description = ''; description = '';
...@@ -98,33 +95,45 @@ export class FloweventsComponent implements OnInit { ...@@ -98,33 +95,45 @@ export class FloweventsComponent implements OnInit {
nzWidth: 1080, nzWidth: 1080,
nzMaskClosable: nzMaskClosable, nzMaskClosable: nzMaskClosable,
nzContentParams: { nzContentParams: {
event: event, event: event
}, }
}); });
drawerRef.afterOpen.subscribe(() => { }); drawerRef.afterOpen.subscribe(() => {});
drawerRef.afterClose.subscribe((data) => { drawerRef.afterClose.subscribe(data => {
this.st.load(this.st.pi); this.st.load(this.st.pi);
if (typeof data === 'string') { if (typeof data === 'string') {
} }
}); });
} }
onInput($event: Event) { onInput($event: Event) {
var element = $event.target as HTMLInputElement var element = $event.target as HTMLInputElement;
this.http.get('api/Devices/Customers', { this.http
limit: 20, .get('api/Devices/Customers', {
offset: 0, limit: 20,
customerId: this.settingService.user.comstomer, name: element?.value ?? '' offset: 0,
}).pipe(debounceTime(500)).subscribe(next => { customerId: this.settingService.user.comstomer,
this.devices = [...next.data.rows.map(x => { return { id: x.id, name: x.name } }), { id: Guid.EMPTY, name: '测试' }] name: element?.value ?? ''
}, error => { }, () => { }) })
.pipe(debounceTime(500))
.subscribe(
next => {
this.devices = [
...next.data.rows.map(x => {
return { id: x.id, name: x.name };
}),
{ id: Guid.EMPTY, name: '测试' }
];
},
error => {},
() => {}
);
} }
onChange($event){ onChange($event) {
this.q.Creator=this.devices.find(c=>c.name==$event)?.id this.q.Creator = this.devices.find(c => c.name == $event)?.id;
} }
getData() { getData() {
this.st.req = this.req; this.st.req = this.req;
...@@ -132,8 +141,7 @@ this.q.Creator=this.devices.find(c=>c.name==$event)?.id ...@@ -132,8 +141,7 @@ this.q.Creator=this.devices.find(c=>c.name==$event)?.id
} }
reset() { reset() {
this.q = this.q = {
{
pi: 0, pi: 0,
ps: 10, ps: 10,
Name: '', Name: '',
...@@ -142,25 +150,25 @@ this.q.Creator=this.devices.find(c=>c.name==$event)?.id ...@@ -142,25 +150,25 @@ this.q.Creator=this.devices.find(c=>c.name==$event)?.id
RuleId: '', RuleId: '',
CreatTime: [], CreatTime: [],
sorter: '', sorter: '',
status: null, status: null
}; };
} }
constructor( constructor(
private http: _HttpClient, private http: _HttpClient,
public msg: NzMessageService, public msg: NzMessageService,
private drawerService: NzDrawerService, private drawerService: NzDrawerService,
private settingService: SettingsService, private settingService: SettingsService
) {}
) {
}
ngOnInit(): void { ngOnInit(): void {
this.http.post('api/rules/index', { offset: 0, limit: 100 }).subscribe(next => { this.http.post('api/rules/index', { offset: 0, limit: 100 }).subscribe(
this.rules = next.data.rows; next => {
}, error => { }, () => { }) this.rules = next.data.rows;
},
error => {},
() => {}
);
} }
} }
export interface baseevent { export interface baseevent {
...@@ -175,11 +183,9 @@ export interface baseevent { ...@@ -175,11 +183,9 @@ export interface baseevent {
ruleId: string; ruleId: string;
createrDateTime: string; createrDateTime: string;
creatorName: string; creatorName: string;
} }
export interface creator { export interface creator {
id: string; id: string;
name: string; name: string;
} }
\ No newline at end of file
...@@ -80,6 +80,7 @@ import { AlarmlistComponent } from './device/alarmlist/alarmlist.component'; ...@@ -80,6 +80,7 @@ import { AlarmlistComponent } from './device/alarmlist/alarmlist.component';
import { AssetlistComponent } from './device/assetlist/assetlist.component'; import { AssetlistComponent } from './device/assetlist/assetlist.component';
import { AssetformComponent } from './device/assetform/assetform.component'; import { AssetformComponent } from './device/assetform/assetform.component';
import { AlarmdetailComponent } from './device/alarmdetail/alarmdetail.component'; import { AlarmdetailComponent } from './device/alarmdetail/alarmdetail.component';
import { ExporttoassetComponent } from './device/exporttoasset/exporttoasset.component';
const COMPONENTS: Array<Type<null>> = []; const COMPONENTS: Array<Type<null>> = [];
const Directive: Type<void>[] = [fielddirective, controldirective, toolpaneldirective]; const Directive: Type<void>[] = [fielddirective, controldirective, toolpaneldirective];
...@@ -159,7 +160,8 @@ const Directive: Type<void>[] = [fielddirective, controldirective, toolpaneldire ...@@ -159,7 +160,8 @@ const Directive: Type<void>[] = [fielddirective, controldirective, toolpaneldire
AlarmlistComponent, AlarmlistComponent,
AssetlistComponent, AssetlistComponent,
AssetformComponent, AssetformComponent,
AlarmdetailComponent AlarmdetailComponent,
ExporttoassetComponent
] ]
}) })
export class RoutesModule {} export class RoutesModule {}
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
...@@ -23,42 +24,52 @@ namespace IoTSharp.Controllers ...@@ -23,42 +24,52 @@ namespace IoTSharp.Controllers
{ {
private readonly ApplicationDbContext _context; private readonly ApplicationDbContext _context;
public AlarmController( ApplicationDbContext context)
public AlarmController(ApplicationDbContext context)
{ {
_context = context; _context = context;
} }
[HttpPost] [HttpPost]
public async Task<ApiResult<PagedData<AlarmDto>>> List([FromBody]AlarmParam m) public async Task<ApiResult<PagedData<AlarmDto>>> List([FromBody] AlarmParam m)
{ {
var profile = this.GetUserProfile(); var profile = this.GetUserProfile();
Expression<Func<Alarm, bool>> condition = x => x.Customer.Id == profile.Comstomer && x.Tenant.Id == profile.Tenant; Expression<Func<Alarm, bool>> condition = x =>
x.Customer.Id == profile.Comstomer && x.Tenant.Id == profile.Tenant;
if (m.AckDateTime!=null&&m.AckDateTime.Length == 2) if (m.AckDateTime != null && m.AckDateTime.Length == 2)
{ {
condition = condition.And(x => x.AckDateTime > m.AckDateTime[0] && x.AckDateTime < m.AckDateTime[1]); condition = condition.And(x => x.AckDateTime > m.AckDateTime[0] && x.AckDateTime < m.AckDateTime[1]);
} }
if (m.ClearDateTime!=null&&m.ClearDateTime.Length == 2)
if (m.ClearDateTime != null && m.ClearDateTime.Length == 2)
{ {
condition = condition.And(x => x.ClearDateTime > m.ClearDateTime[0] && x.ClearDateTime < m.ClearDateTime[1]); condition = condition.And(x =>
x.ClearDateTime > m.ClearDateTime[0] && x.ClearDateTime < m.ClearDateTime[1]);
} }
if (m.StartDateTime != null && m.StartDateTime.Length == 2) if (m.StartDateTime != null && m.StartDateTime.Length == 2)
{ {
condition = condition.And(x => x.StartDateTime > m.StartDateTime[0] && x.EndDateTime < m.StartDateTime[1]); condition = condition.And(x =>
x.StartDateTime > m.StartDateTime[0] && x.EndDateTime < m.StartDateTime[1]);
} }
if (m.EndDateTime!=null&&m.EndDateTime.Length == 2)
if (m.EndDateTime != null && m.EndDateTime.Length == 2)
{ {
condition = condition.And(x => x.EndDateTime > m.EndDateTime[0] && x.EndDateTime < m.EndDateTime[1]); condition = condition.And(x => x.EndDateTime > m.EndDateTime[0] && x.EndDateTime < m.EndDateTime[1]);
} }
if (!string.IsNullOrEmpty(m.AlarmType)) if (!string.IsNullOrEmpty(m.AlarmType))
{ {
condition = condition.And(x => x.AlarmType == m.AlarmType); condition = condition.And(x => x.AlarmType == m.AlarmType);
} }
if (m.AlarmStatus!=-1)
if (m.AlarmStatus != -1)
{ {
condition = condition.And(x => x.AlarmStatus == (AlarmStatus) m.AlarmStatus); condition = condition.And(x => x.AlarmStatus == (AlarmStatus) m.AlarmStatus);
} }
...@@ -68,32 +79,72 @@ namespace IoTSharp.Controllers ...@@ -68,32 +79,72 @@ namespace IoTSharp.Controllers
condition = condition.And(x => x.Serverity == (ServerityLevel) m.Serverity); condition = condition.And(x => x.Serverity == (ServerityLevel) m.Serverity);
} }
if (m.OriginatorId != Guid.Empty)
if (m.OriginatorType != -1)
{ {
condition = condition.And(x => x.OriginatorId == m.OriginatorId); condition = condition.And(x => x.OriginatorType == (OriginatorType) m.OriginatorType);
}
else
{
if (m.OriginatorId != Guid.Empty)
{
condition = condition.And(x => x.OriginatorId == m.OriginatorId);
}
} }
return new ApiResult<PagedData<AlarmDto>>(ApiCode.Success, "OK", new PagedData<AlarmDto> return new ApiResult<PagedData<AlarmDto>>(ApiCode.Success, "OK", new PagedData<AlarmDto>
{ {
total = await _context.Alarms.CountAsync(condition), total = await _context.Alarms.CountAsync(condition),
rows = _context.Alarms.Where(condition).Where(condition).Skip((m.offset) * m.limit).Take(m.limit).ToList().Select(c => new AlarmDto rows = _context.Alarms.Where(condition).Where(condition).Skip((m.offset) * m.limit).Take(m.limit)
{ .ToList().Select(c => new AlarmDto
ClearDateTime = c.ClearDateTime, {
AckDateTime = c.AckDateTime, ClearDateTime = c.ClearDateTime,
EndDateTime = c.EndDateTime, AckDateTime = c.AckDateTime,
AlarmDetail = c.AlarmDetail, EndDateTime = c.EndDateTime,
AlarmType = c.AlarmType, AlarmDetail = c.AlarmDetail,
AlarmStatus = c.AlarmStatus, AlarmType = c.AlarmType,
Id = c.Id, AlarmStatus = c.AlarmStatus,
OriginatorId = c.OriginatorId, Id = c.Id,
OriginatorType = c.OriginatorType, OriginatorId = c.OriginatorId,
Propagate = c.Propagate, OriginatorType = c.OriginatorType,
Serverity = c.Serverity, Propagate = c.Propagate,
StartDateTime = c.StartDateTime Serverity = c.Serverity,
}).ToList() StartDateTime = c.StartDateTime
}).ToList()
}); });
} }
[HttpPost]
public async Task<ApiResult<List<ModelOriginatorItem>>> Originators([FromBody] ModelOriginatorSearch m)
{
var profile = this.GetUserProfile();
switch (m.OriginatorType)
{
case 0:
break;
case 1:
return new ApiResult<List<ModelOriginatorItem>>(ApiCode.Success, "OK", await _context.Device.Where(c => c.Name.Contains(m.OriginatorName) && c.DeviceType == DeviceType.Device&&c.Customer.Id==profile.Comstomer&&c.Tenant.Id==profile.Tenant)
.Select(c => new ModelOriginatorItem { Id = c.Id, Name = c.Name }).ToListAsync());
case 2:
return new ApiResult<List<ModelOriginatorItem>>(ApiCode.Success, "OK", await _context.Device.Where(c => c.Name.Contains(m.OriginatorName) && c.DeviceType == DeviceType.Gateway && c.DeviceType == DeviceType.Device && c.Customer.Id == profile.Comstomer && c.Tenant.Id == profile.Tenant)
.Select(c => new ModelOriginatorItem { Id = c.Id, Name = c.Name }).ToListAsync()); ;
case 3:
return new ApiResult<List<ModelOriginatorItem>>(ApiCode.Success, "OK", await _context.Assets.Where(c => c.Name.Contains(m.OriginatorName)&& c.Customer.Id == profile.Comstomer && c.Tenant.Id == profile.Tenant).Select(c => new ModelOriginatorItem { Id = c.Id, Name = c.Name }).ToListAsync());
}
return new ApiResult<List<ModelOriginatorItem>>(ApiCode.Success, "OK", null);
}
} }
} }
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -46,6 +47,22 @@ namespace IoTSharp.Controllers ...@@ -46,6 +47,22 @@ namespace IoTSharp.Controllers
}); });
} }
[HttpGet]
public async Task<ApiResult<List<AssetRelation>>> Relations(Guid assetid)
{
var profile = this.GetUserProfile();
var result= await _context.Assets.Include(c => c.OwnedAssets)
.SingleOrDefaultAsync(c => c.Id == assetid && c.Customer.Id == profile.Comstomer && c.Tenant.Id == profile.Tenant);
return new ApiResult<List<AssetRelation>>(ApiCode.Success, "OK",
new List<AssetRelation>(result?.OwnedAssets??new List<AssetRelation>()));
}
[HttpGet] [HttpGet]
public async Task<ApiResult<AssetDto>> Get(Guid id) public async Task<ApiResult<AssetDto>> Get(Guid id)
{ {
...@@ -59,7 +76,7 @@ namespace IoTSharp.Controllers ...@@ -59,7 +76,7 @@ namespace IoTSharp.Controllers
} }
[HttpPost] [HttpPut]
public async Task<ApiResult<bool>> Update([FromBody] AssetDto dto) public async Task<ApiResult<bool>> Update([FromBody] AssetDto dto)
{ {
......
...@@ -150,15 +150,16 @@ namespace IoTSharp.Handlers ...@@ -150,15 +150,16 @@ namespace IoTSharp.Handlers
{ {
dev.Online = false; dev.Online = false;
dev.LastActive = DateTime.Now; dev.LastActive = DateTime.Now;
Task.Run(() => RunRules(dev.Id, status, MountType.Online)); Task.Run(() => RunRules(dev.Id, status, MountType.Offline));
//真正线 //真正线
} }
else if (dev.Online == false && status.DeviceStatus== Data.DeviceStatus.Good) else if (dev.Online == false && status.DeviceStatus== Data.DeviceStatus.Good)
{ {
dev.Online = true; dev.Online = true;
dev.LastActive = DateTime.Now; dev.LastActive = DateTime.Now;
Task.Run(() => RunRules(dev.Id, status, MountType.Offline)); Task.Run(() => RunRules(dev.Id, status, MountType.Online));
//真正离线 //真正掉线
} }
_dbContext.SaveChanges(); _dbContext.SaveChanges();
} }
......
...@@ -19,16 +19,20 @@ namespace IoTSharp.Controllers.Models ...@@ -19,16 +19,20 @@ namespace IoTSharp.Controllers.Models
public string Name { get; set; } public string Name { get; set; }
} }
public class AlarmParam : IPageParam public class AlarmParam : IPageParam
{ {
public Guid OriginatorId { get; set; } public Guid? OriginatorId { get; set; }
public int Serverity { get; set; } public int Serverity { get; set; }
public int AlarmStatus { get; set; } public int AlarmStatus { get; set; }
public DateTime[] ClearDateTime { get; set; } public DateTime[] ClearDateTime { get; set; }
public DateTime[] StartDateTime { get; set; } public DateTime[] StartDateTime { get; set; }
public int OriginatorType { get; set; }
public DateTime[] EndDateTime { get; set; } public DateTime[] EndDateTime { get; set; }
public DateTime[] AckDateTime { get; set; } public DateTime[] AckDateTime { get; set; }
......
using System;
namespace IoTSharp.Models
{
public class ModelOriginatorSearch
{
public int OriginatorType { get; set; }
public string OriginatorName { get; set; }
}
public class ModelOriginatorItem
{
public Guid Id { get; set; }
public string Name { get; set; }
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册