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

资产管理,告警查询

上级 0e7333a7
......@@ -18,10 +18,5 @@ namespace IoTSharp.Data
public Customer Customer { get; set; }
public Tenant Tenant { get; set; }
public string path { get; set; }
}
}
......@@ -74,31 +74,27 @@
</div>
<div nz-col nzMd="8" nzSm="24">
<nz-form-item>
<nz-form-label nzFor="DeviceName">告警级别</nz-form-label>
<nz-form-label nzFor="OriginatorType">起因来源</nz-form-label>
<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="0" nzLabel="不确定"></nz-option>
<nz-option nzValue="1" nzLabel="警告"></nz-option>
<nz-option nzValue="2" nzLabel="次要" ></nz-option>
<nz-option nzValue="3" nzLabel="重要" ></nz-option>
<nz-option nzValue="4" nzLabel="错误" ></nz-option>
<nz-option nzValue="0" nzLabel="未知"></nz-option>
<nz-option nzValue="1" nzLabel="设备"></nz-option>
<nz-option nzValue="2" nzLabel="网关" ></nz-option>
<nz-option nzValue="3" nzLabel="资产" ></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</div>
<div nz-col nzMd="8" nzSm="24">
<nz-form-item>
<nz-form-label nzFor="DeviceName">告警级别</nz-form-label>
<nz-form-label nzFor="DeviceName">起因对象</nz-form-label>
<nz-form-control>
<nz-select [(ngModel)]="q.Serverity">
<nz-option nzValue="-1" nzLabel="全部"></nz-option>
<nz-option nzValue="0" nzLabel="不确定"></nz-option>
<nz-option nzValue="1" nzLabel="警告"></nz-option>
<nz-option nzValue="2" nzLabel="次要" ></nz-option>
<nz-option nzValue="3" nzLabel="重要" ></nz-option>
<nz-option nzValue="4" nzLabel="错误" ></nz-option>
</nz-select>
<input nz-input [(ngModel)]="q.OriginatorName" (input)="onOriginatorInput($event)" (ngModelChange)="onOriginatorChange($event)" name="Originator" placeholder="请输入" [nzAutocomplete]="auto"/>
<input type="hidden" [(ngModel)]="q.OriginatorId" name="OriginatorId" placeholder="请输入" />
<nz-autocomplete #auto>
<nz-auto-option *ngFor="let option of originators" [nzValue]="option.name">{{ option.name }}</nz-auto-option>
</nz-autocomplete>
</nz-form-control>
</nz-form-item>
</div>
......@@ -110,10 +106,10 @@
</div>
</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>
<span>{{ 'button.new' | i18n }}</span>
</button>
</button> -->
<!--<button nz-button [nzType]="'primary'" [routerLink]="['/manage/authority/roleform']" [queryParams]="{Id:-1}">
<i nz-icon nzType="plus"></i>
<span>{{ 'button.new' | translate }}</span>
......
......@@ -5,6 +5,7 @@ import { _HttpClient, ModalHelper, SettingsService } from '@delon/theme';
import { Guid } from 'guid-typescript';
import { NzDrawerService } from 'ng-zorro-antd/drawer';
import { NzMessageService } from 'ng-zorro-antd/message';
import { debounceTime } from 'rxjs/operators';
import { AppMessage } from '../../common/AppMessage';
import { AlarmdetailComponent } from '../alarmdetail/alarmdetail.component';
......@@ -14,21 +15,11 @@ import { AlarmdetailComponent } from '../alarmdetail/alarmdetail.component';
styleUrls: ['./alarmlist.component.less']
})
export class AlarmlistComponent implements OnInit {
constructor(
private http: _HttpClient,
public msg: NzMessageService,
private modal: ModalHelper,
private cdr: ChangeDetectorRef,
private _router: Router,
private drawerService: NzDrawerService,
private settingService: SettingsService,
) {}
originators: originator[] = [];
page: STPage = {
front: false,
total: true,
zeroIndexed: true,
zeroIndexed: true
};
q: {
pi: number;
......@@ -36,30 +27,32 @@ export class AlarmlistComponent implements OnInit {
sorter: string;
status: number | null;
Name: string;
AckDateTime:any;
ClearDateTime:any;
EndDateTime:any;
StartDateTime:any;
AlarmType:any;
AlarmStatus:Number;
OriginatorId:any;
Serverity:Number
AckDateTime: any;
ClearDateTime: any;
EndDateTime: any;
StartDateTime: any;
AlarmType: any;
AlarmStatus: Number;
OriginatorId: any;
OriginatorName: string;
Serverity: Number;
OriginatorType: Number;
} = {
pi: 0,
ps: 10,
Name: '',
sorter: '',
status: null,
AckDateTime:null,
ClearDateTime:null,
StartDateTime:null,
EndDateTime:null,
AlarmType:'',
AlarmStatus:-1,
OriginatorId:Guid.EMPTY,
Serverity:-1
AckDateTime: null,
ClearDateTime: null,
StartDateTime: null,
EndDateTime: null,
AlarmType: '',
OriginatorName: '',
AlarmStatus: -1,
OriginatorId: Guid.EMPTY,
Serverity: -1,
OriginatorType: -1
};
total = 0;
......@@ -72,26 +65,26 @@ export class AlarmlistComponent implements OnInit {
text: '已禁用',
value: false,
type: 'processing',
checked: false,
checked: false
},
{
index: -1,
text: '已删除',
value: false,
type: 'processing',
checked: false,
},
checked: false
}
];
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 = {
reName: {
total: 'data.total',
list: 'data.rows',
},
list: 'data.rows'
}
};
@ViewChild('st', { static: true })
......@@ -102,38 +95,36 @@ export class AlarmlistComponent implements OnInit {
1: { text: '警告', color: '#faad14' },
2: { text: '次要', color: '#bae637' },
3: { text: '主要', color: '#1890ff' },
4: { text: '错误', color: '#f5222d' },
4: { text: '错误', color: '#f5222d' }
};
alarmstatusTAG: STColumnTag = {
0: { text: '激活未应答', color: '#ffa39e' },
1: { text: '激活已应答', color: '#f759ab' },
2: { text: '清除未应答', color: '#87e8de' },
3: { text: '清除已应答', color: '#d3f261' },
3: { text: '清除已应答', color: '#d3f261' }
};
ServerityTAG: STColumnTag = {
AccessToken: { text: 'AccessToken', color: 'green' },
X509Certificate: { text: 'X509Certificate', color: 'blue' }
};
columns: STColumn[] = [
{ title: '', index: 'Id', type: 'checkbox' },
{ title: 'id', index: 'id', },
{ title: 'id', index: 'id' },
{
title: '类型',
index: 'AlarmType',
index: 'AlarmType'
},
{ title: '创建时间', index: 'ackDateTime',type: 'date' },
{ title: '清除时间', index: 'clearDateTime' ,type: 'date'},
{ title: '警告持续的开始时间', index: 'startDateTime',type: 'date' },
{ title: '结束时间', index: 'endDateTime' ,type: 'date'},
{ title: '告警状态', index: 'alarmStatus', type:'tag' ,tag: this.alarmstatusTAG },
{ title: '严重程度', index: 'serverity' , type:'tag' ,tag: this.serveritybadge},
{ title: '创建时间', index: 'ackDateTime', type: 'date' },
{ title: '清除时间', index: 'clearDateTime', type: 'date' },
{ title: '警告持续的开始时间', index: 'startDateTime', type: 'date' },
{ title: '结束时间', index: 'endDateTime', type: 'date' },
{ title: '告警状态', index: 'alarmStatus', type: 'tag', tag: this.alarmstatusTAG },
{ title: '严重程度', index: 'serverity', type: 'tag', tag: this.serveritybadge },
{ title: '设备类型', index: 'originatorType' },
{
title: { i18n: 'table.operation' },
buttons: [
......@@ -150,34 +141,75 @@ export class AlarmlistComponent implements OnInit {
// type: 'clone'
// }
// });
},
},
],
},
}
}
]
}
];
selectedRows: STData[] = [];
description = '';
totalCallNo = 0;
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() {}
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) {
console.log(event);
switch (event.type) {
case 'expand':
this.http.post<AppMessage>('api/dictionary/index' ,{
DictionaryGroupId:event.expand.dictionaryGroupId,
offset:0,
limit:100
}).subscribe(
(x) => {
event.expand.Children = x.data.rows;
},
(y) => {},
() => {},
);
this.http
.post<AppMessage>('api/dictionary/index', {
DictionaryGroupId: event.expand.dictionaryGroupId,
offset: 0,
limit: 100
})
.subscribe(
x => {
event.expand.Children = x.data.rows;
},
y => {},
() => {}
);
break;
}
}
......@@ -190,13 +222,13 @@ export class AlarmlistComponent implements OnInit {
nzWidth: width,
nzMaskClosable: nzMaskClosable,
nzContentParams: {
id: id,
},
id: id
}
});
drawerRef.afterOpen.subscribe(() => {});
drawerRef.afterClose.subscribe((data) => {
drawerRef.afterClose.subscribe(data => {
if (typeof data === 'string') {
}
......@@ -217,3 +249,8 @@ export class AlarmlistComponent implements OnInit {
}
setstatus(number: number, status: number) {}
}
export interface originator {
id: string;
name: string;
}
......@@ -13,10 +13,7 @@ import { appmessage } from '../../common/AppMessage';
styleUrls: ['./assetform.component.less']
})
export class AssetformComponent implements OnInit {
@Input() params: any = {
id: Guid.EMPTY,
customerId: '-1',
};
@Input() id: any = Guid.EMPTY;
config:any={ language: 'zh_CN', height: 250,}
title: string = '';
loading = false;
......@@ -38,9 +35,9 @@ export class AssetformComponent implements OnInit {
id: [Guid.EMPTY, []],
});
if (this.params.id !== Guid.EMPTY) {
if (this.id !== Guid.EMPTY) {
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) => {
this.form.patchValue(x.data)
}),
......@@ -51,7 +48,7 @@ export class AssetformComponent implements OnInit {
submit() {
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.submitting = false;
......@@ -65,7 +62,7 @@ export class AssetformComponent implements OnInit {
() => {},
);
} 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.msg.create('success', '设备修改成功');
......@@ -80,6 +77,6 @@ export class AssetformComponent implements OnInit {
}
}
close(): void {
this.drawerRef.close(this.params);
this.drawerRef.close(this.id);
}
}
......@@ -39,13 +39,23 @@
[expand]="expand"
expandRowByClick
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>
</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>
<nz-form-item>
<nz-form-label nzFor="no">描述</nz-form-label>
......
import { ChangeDetectorRef, Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
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 { Guid } from 'guid-typescript';
import { NzDrawerService } from 'ng-zorro-antd/drawer';
import { NzMessageService } from 'ng-zorro-antd/message';
import { title } from 'process';
import { nextTick, title } from 'process';
import { AppMessage } from '../../common/AppMessage';
import { AssetformComponent } from '../assetform/assetform.component';
......@@ -15,16 +15,6 @@ import { AssetformComponent } from '../assetform/assetform.component';
styleUrls: ['./assetlist.component.less']
})
export class AssetlistComponent implements OnInit {
constructor(
private http: _HttpClient,
public msg: NzMessageService,
......@@ -32,13 +22,16 @@ export class AssetlistComponent implements OnInit {
private cdr: ChangeDetectorRef,
private _router: Router,
private drawerService: NzDrawerService,
private settingService: SettingsService,
private settingService: SettingsService
) {}
@ViewChild('expand')
tpl: TemplateRef<any>;
relations = [];
page: STPage = {
front: false,
total: true,
zeroIndexed: true,
zeroIndexed: true
};
q: {
pi: number;
......@@ -52,7 +45,7 @@ export class AssetlistComponent implements OnInit {
ps: 10,
Name: '',
sorter: '',
status: null,
status: null
};
total = 0;
......@@ -65,15 +58,15 @@ export class AssetlistComponent implements OnInit {
text: '已禁用',
value: false,
type: 'processing',
checked: false,
checked: false
},
{
index: -1,
text: '已删除',
value: false,
type: 'processing',
checked: false,
},
checked: false
}
];
url = 'api/asset/list';
......@@ -83,8 +76,8 @@ export class AssetlistComponent implements OnInit {
res: STRes = {
reName: {
total: 'data.total',
list: 'data.rows',
},
list: 'data.rows'
}
};
@ViewChild('st', { static: true })
......@@ -92,28 +85,49 @@ export class AssetlistComponent implements OnInit {
TAG: STColumnTag = {
1: { text: '成功', color: 'red' },
2: { text: '进行中', color: 'blue' },
2: { text: '进行中', color: 'blue' }
};
columnsChildren: STColumn[] = [
{ title: 'id', index: 'id' },
{ title: '字典名', index: 'name' },
{ title: '字典值', index: 'description' },
{ title: '备注', index: 'assetType' },
{ title: '类型', index: 'dictionaryValueTypeName' },
{ title: '名称', index: 'name' },
{ title: '描述', index: 'description' },
{ title: '类型', index: 'assetType' },
{ 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[] = [
{ title: '', index: 'id', type: 'checkbox' },
{ title: 'id', index: 'id', },
{ title: 'id', index: 'id' },
{
title: '资产名称(数量)',
index: 'name',
index: 'name'
},
{ title: '类型', index: 'assetType' },
{ title: '描述', index: 'description' },
{
title: { i18n: 'table.operation' },
buttons: [
......@@ -122,32 +136,8 @@ export class AssetlistComponent implements OnInit {
i18n: 'common.edit',
acl: 60,
click: (item: any) => {
this.openComponent(item.dictionaryGroupId);
//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) => {},
() => {},
);
},
this.openComponent(item.id);
}
},
{
......@@ -155,21 +145,21 @@ export class AssetlistComponent implements OnInit {
pop: {
title: '确认删除字典组?',
okType: 'danger',
icon: 'warning',
icon: 'warning'
},
acl: 61,
click: (item: any) => {
this.http.get('api/dictionarygroup/delete?id=' + item.DdictionaryGroupId).subscribe(
(x) => {
this.http.delete('api/asset/delete?id=' + item.id).subscribe(
x => {
this.getData();
},
(y) => {},
() => {},
y => {},
() => {}
);
},
},
],
},
}
}
]
}
];
selectedRows: STData[] = [];
description = '';
......@@ -177,8 +167,14 @@ export class AssetlistComponent implements OnInit {
expandForm = false;
ngOnInit() {}
submit(i){}
updateEdit(i,edit){
console.log(this.tpl);
this.st.setRow(i, { edit }, { refreshSchema: true });
}
openComponent(id: string): void {
var { nzMaskClosable, width } = this.settingService.getData('drawerconfig');
var title = id == Guid.EMPTY ? '新增资产' : '修改资产';
......@@ -188,13 +184,13 @@ export class AssetlistComponent implements OnInit {
nzWidth: width,
nzMaskClosable: nzMaskClosable,
nzContentParams: {
id: id,
},
id: id
}
});
drawerRef.afterOpen.subscribe(() => {});
drawerRef.afterClose.subscribe((data) => {
drawerRef.afterClose.subscribe(data => {
if (typeof data === 'string') {
}
......@@ -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() {
this.st.req = this.req;
this.st.load(this.st.pi);
......
......@@ -25,11 +25,21 @@
</form>
<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">
<i nz-icon nzType="plus"></i>
<span>设置规则</span>
</button>
<button nz-button [nzType]="'primary'" (click)="exporttoasset([])" acl [acl-ability]="137">
<i nz-icon nzType="plus"></i>
<span>导出到资产</span>
</button>
</div>
</nz-card>
......
......@@ -21,6 +21,7 @@ import { DevicetokendialogComponent } from '../devicetokendialog/devicetokendial
import { fork } from 'child_process';
import { ProppartComponent } from '../deviceprop/proppart/proppart.component';
import { devicemodelcommand } from '../../devicemodel/devicemodelcommandparam';
import { ExporttoassetComponent } from '../exporttoasset/exporttoasset.component';
@Component({
selector: 'app-devicelist',
templateUrl: './devicelist.component.html',
......@@ -64,7 +65,9 @@ export class DevicelistComponent implements OnInit, OnDestroy {
page: STPage = {
front: false,
total: true,
zeroIndexed: true
zeroIndexed: true,
showSize:true,
pageSizes:[10,20,50,100,500]
};
q: {
pi: number;
......@@ -226,8 +229,41 @@ export class DevicelistComponent implements OnInit, OnDestroy {
);
}
downlink(dev: any[]) {
exporttoasset(dev: any[]) {
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) {
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';
import { debounceTime } from 'rxjs/operators';
import { FloweventviewComponent } from '../floweventview/floweventview.component';
@Component({
selector: 'app-flowevents',
templateUrl: './flowevents.component.html',
......@@ -15,16 +14,15 @@ import { FloweventviewComponent } from '../floweventview/floweventview.component
})
export class FloweventsComponent implements OnInit {
devices: creator[] = [{ id: Guid.EMPTY, name: '测试' }];
dateFormat = 'yyyy/MM/dd'
dateFormat = 'yyyy/MM/dd';
TAG: STColumnTag = {
'Normal': { text: '设备', color: 'green' },
'TestPurpose': { text: '测试', color: 'orange' },
Normal: { text: '设备', color: 'green' },
TestPurpose: { text: '测试', color: 'orange' }
};
page: STPage = {
front: false,
total: true,
zeroIndexed: true,
zeroIndexed: true
};
q: {
pi: number;
......@@ -37,16 +35,16 @@ export class FloweventsComponent implements OnInit {
sorter: string;
status: number | null;
} = {
pi: 0,
ps: 10,
Name: '',
Creator: '',
RuleId: '',
CreatorName: '',
CreatTime: [],
sorter: '',
status: null,
};
pi: 0,
ps: 10,
Name: '',
Creator: '',
RuleId: '',
CreatorName: '',
CreatTime: [],
sorter: '',
status: null
};
total = 0;
loading = false;
......@@ -58,8 +56,8 @@ export class FloweventsComponent implements OnInit {
res: STRes = {
reName: {
total: 'data.total',
list: 'data.rows',
},
list: 'data.rows'
}
};
@ViewChild('st', { static: true })
......@@ -79,11 +77,10 @@ export class FloweventsComponent implements OnInit {
text: '回放',
click: (item: baseevent) => {
this.openComponent(item);
},
},
],
},
}
}
]
}
];
selectedRows: STData[] = [];
description = '';
......@@ -98,33 +95,45 @@ export class FloweventsComponent implements OnInit {
nzWidth: 1080,
nzMaskClosable: nzMaskClosable,
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);
if (typeof data === 'string') {
}
});
}
onInput($event: Event) {
var element = $event.target as HTMLInputElement
this.http.get('api/Devices/Customers', {
limit: 20,
offset: 0,
customerId: this.settingService.user.comstomer, name: element?.value ?? ''
}).pipe(debounceTime(500)).subscribe(next => {
this.devices = [...next.data.rows.map(x => { return { id: x.id, name: x.name } }), { id: Guid.EMPTY, name: '测试' }]
}, error => { }, () => { })
var element = $event.target as HTMLInputElement;
this.http
.get('api/Devices/Customers', {
limit: 20,
offset: 0,
customerId: this.settingService.user.comstomer,
name: element?.value ?? ''
})
.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){
this.q.Creator=this.devices.find(c=>c.name==$event)?.id
onChange($event) {
this.q.Creator = this.devices.find(c => c.name == $event)?.id;
}
getData() {
this.st.req = this.req;
......@@ -132,8 +141,7 @@ this.q.Creator=this.devices.find(c=>c.name==$event)?.id
}
reset() {
this.q =
{
this.q = {
pi: 0,
ps: 10,
Name: '',
......@@ -142,25 +150,25 @@ this.q.Creator=this.devices.find(c=>c.name==$event)?.id
RuleId: '',
CreatTime: [],
sorter: '',
status: null,
status: null
};
}
constructor(
private http: _HttpClient,
public msg: NzMessageService,
private drawerService: NzDrawerService,
private settingService: SettingsService,
) {
}
private settingService: SettingsService
) {}
ngOnInit(): void {
this.http.post('api/rules/index', { offset: 0, limit: 100 }).subscribe(next => {
this.rules = next.data.rows;
}, error => { }, () => { })
this.http.post('api/rules/index', { offset: 0, limit: 100 }).subscribe(
next => {
this.rules = next.data.rows;
},
error => {},
() => {}
);
}
}
export interface baseevent {
......@@ -175,11 +183,9 @@ export interface baseevent {
ruleId: string;
createrDateTime: string;
creatorName: string;
}
export interface creator {
id: string;
name: string;
}
\ No newline at end of file
}
......@@ -80,6 +80,7 @@ import { AlarmlistComponent } from './device/alarmlist/alarmlist.component';
import { AssetlistComponent } from './device/assetlist/assetlist.component';
import { AssetformComponent } from './device/assetform/assetform.component';
import { AlarmdetailComponent } from './device/alarmdetail/alarmdetail.component';
import { ExporttoassetComponent } from './device/exporttoasset/exporttoasset.component';
const COMPONENTS: Array<Type<null>> = [];
const Directive: Type<void>[] = [fielddirective, controldirective, toolpaneldirective];
......@@ -159,7 +160,8 @@ const Directive: Type<void>[] = [fielddirective, controldirective, toolpaneldire
AlarmlistComponent,
AssetlistComponent,
AssetformComponent,
AlarmdetailComponent
AlarmdetailComponent,
ExporttoassetComponent
]
})
export class RoutesModule {}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
......@@ -23,42 +24,52 @@ namespace IoTSharp.Controllers
{
private readonly ApplicationDbContext _context;
public AlarmController( ApplicationDbContext context)
public AlarmController(ApplicationDbContext context)
{
_context = context;
}
[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();
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]);
}
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)
{
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]);
}
if (!string.IsNullOrEmpty(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);
}
......@@ -68,32 +79,72 @@ namespace IoTSharp.Controllers
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>
{
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
{
ClearDateTime = c.ClearDateTime,
AckDateTime = c.AckDateTime,
EndDateTime = c.EndDateTime,
AlarmDetail = c.AlarmDetail,
AlarmType = c.AlarmType,
AlarmStatus = c.AlarmStatus,
Id = c.Id,
OriginatorId = c.OriginatorId,
OriginatorType = c.OriginatorType,
Propagate = c.Propagate,
Serverity = c.Serverity,
StartDateTime = c.StartDateTime
}).ToList()
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,
EndDateTime = c.EndDateTime,
AlarmDetail = c.AlarmDetail,
AlarmType = c.AlarmType,
AlarmStatus = c.AlarmStatus,
Id = c.Id,
OriginatorId = c.OriginatorId,
OriginatorType = c.OriginatorType,
Propagate = c.Propagate,
Serverity = c.Serverity,
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.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
......@@ -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]
public async Task<ApiResult<AssetDto>> Get(Guid id)
{
......@@ -59,7 +76,7 @@ namespace IoTSharp.Controllers
}
[HttpPost]
[HttpPut]
public async Task<ApiResult<bool>> Update([FromBody] AssetDto dto)
{
......
......@@ -150,15 +150,16 @@ namespace IoTSharp.Handlers
{
dev.Online = false;
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)
{
dev.Online = true;
dev.LastActive = DateTime.Now;
Task.Run(() => RunRules(dev.Id, status, MountType.Offline));
//真正离线
Task.Run(() => RunRules(dev.Id, status, MountType.Online));
//真正掉线
}
_dbContext.SaveChanges();
}
......
......@@ -19,16 +19,20 @@ namespace IoTSharp.Controllers.Models
public string Name { get; set; }
}
public class AlarmParam : IPageParam
{
public Guid OriginatorId { get; set; }
public Guid? OriginatorId { get; set; }
public int Serverity { get; set; }
public int AlarmStatus { get; set; }
public DateTime[] ClearDateTime { get; set; }
public DateTime[] StartDateTime { get; set; }
public int OriginatorType { get; set; }
public DateTime[] EndDateTime { 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.
先完成此消息的编辑!
想要评论请 注册