Browse Source

[完善]完善黄海配置文件

非煤矿业企业安全风险监测预警系统
邵佳豪 2 years ago
parent
commit
e0750a4b75
  1. 2
      src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.html
  2. 15
      src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.ts
  3. 42
      src/app/system-management/host-config/host-config.component.ts
  4. 1
      src/app/system-management/image-label/image-label.component.ts
  5. 10
      src/app/system-management/organization/organization.component.html
  6. 243
      src/app/system-management/organization/organization.component.ts

2
src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.html

@ -25,7 +25,9 @@
<div class="lefttop">
<span>{{selectedOilStation ? selectedOilStation.displayName : '加油站'}} 边缘盒子列表
<span class="yellowspan">(请从左侧选择加油站)</span>
<i style="cursor: pointer;" (click)="refresh()" nz-icon nzType="redo" nzTheme="outline"></i>
</span>
</div>
<!-- <div class="righttop" *ngIf="selectedOilStation">
<button nz-button nzType="primary" (click)="addHost()"><i nz-icon nzType="plus-circle"

15
src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.ts

@ -118,6 +118,21 @@ export class AnalysisOfTheHostComponent implements OnInit {
});
}
refresh() {
if (!this.selectedOilStation.id) {
return;
}
this.http.put('/api/GasStations/SyncAllGasStations', null).subscribe({
next: (data) => {
this.message.success('同步成功');
this.getHost();
},
error: (err) => {
this.message.error('同步失败');
},
});
}
ngAfterViewInit(): void {}
//新增边缘盒子

42
src/app/system-management/host-config/host-config.component.ts

@ -130,8 +130,11 @@ export class HostConfigComponent implements OnInit {
// order: instance.validateForm.value.order,
};
this.http.post('/api/Cameras', body).subscribe({
next: (data) => {
next: (data: any) => {
resolve(data);
if (this.hostType === '黄海') {
this.anewgetImg(data.id);
}
this.message.create('success', '创建成功!');
this.getCamera();
this.isSourceYaml = false;
@ -175,8 +178,11 @@ export class HostConfigComponent implements OnInit {
edgeDeviceId: this.hostId,
order: instance.validateForm.value.order,
};
this.http.put(`/api/Cameras/${data.id}`, body).subscribe((data) => {
resolve(data);
this.http.put(`/api/Cameras/${data.id}`, body).subscribe((mes) => {
if (this.hostType === '黄海') {
this.anewgetImg(data.id);
}
resolve(mes);
this.message.create('success', '编辑成功!');
this.getCamera();
this.isSourceYaml = false;
@ -191,6 +197,27 @@ export class HostConfigComponent implements OnInit {
});
const instance = modal.getContentComponent();
}
anewgetImg(id) {
let params = {
cameraId: id,
provider: 1,
};
this.http
.put('/api/Cameras/Commands/CaptureImages', '', { params: params })
.subscribe({
next: (value: Object) => {
// this.message.create(
// 'success',
// '向边缘设备发送请求成功,请过一段时间手动刷新页面!'
// );
console.log('向边缘设备发送拉取图片请求成功');
},
error: (error: HttpErrorResponse) => {},
complete: () => {},
});
}
deleteCamera(item) {
console.log(item);
this.modal.confirm({
@ -1186,6 +1213,7 @@ rule_threshold:
})
.subscribe({
next: (data) => {
console.log('牛逼', JSON.parse(instance.datacopy));
this.message.create('success', `发送文件名成功`);
},
});
@ -1227,7 +1255,7 @@ rule_threshold:
let objitem: any = {
nickName: '进出口',
rtsp: item.uri,
cameraName: item.name,
areaName: item.name,
};
if (
item.dimensionedPointsHuanghaiObj &&
@ -1243,7 +1271,7 @@ rule_threshold:
let objitem: any = {
nickName: '加油区',
rtsp: item.uri,
cameraName: item.name,
areaName: item.name,
};
if (
item.dimensionedPointsHuanghaiObj &&
@ -1259,7 +1287,7 @@ rule_threshold:
let objitem: any = {
nickName: '卸油区',
rtsp: item.uri,
cameraName: item.name,
areaName: item.name,
};
if (
item.dimensionedPointsHuanghaiObj &&
@ -1296,7 +1324,7 @@ rule_threshold:
let objitem: any = {
nickName: '便利店',
rtsp: item.uri,
cameraName: item.name,
areaName: item.name,
};
if (
item.dimensionedPointsHuanghaiObj &&

1
src/app/system-management/image-label/image-label.component.ts

@ -67,6 +67,7 @@ export class ImageLabelComponent implements OnInit {
anewgetImg() {
let params = {
cameraId: this.cameraId,
provider: 1,
};
this.http
.put('/api/Cameras/Commands/CaptureImages', '', { params: params })

10
src/app/system-management/organization/organization.component.html

@ -9,17 +9,15 @@
<nz-input-group nzPrefixIcon="search">
<input type="text" nz-input placeholder="请输入单位" [(ngModel)]="searchValue" />
</nz-input-group>
<!-- <button nz-button nzType="primary" (click)="addOr()"><i nz-icon nzType="plus-circle"
nzTheme="outline"></i>新增</button> -->
</div>
</div>
<div class="treeTitle">
<span>组织机构</span>
<!-- <span>操作</span> -->
<span>组织机构 <i style="margin-left: 12px;cursor: pointer;" (click)="refresh()" nz-icon nzType="redo"
nzTheme="outline"></i></span>
</div>
<nz-tree [nzHideUnMatched]='true' [nzSearchValue]="searchValue" #nzTreeComponent [nzData]="nodes"
[nzExpandAll]="nzExpandAll" [nzExpandedKeys]="defaultExpandedKeys" nzDraggable
nzBlockNode (nzOnDrop)="nzEvent($event)" [nzBeforeDrop]="beforeDrop">
[nzExpandAll]="nzExpandAll" [nzExpandedKeys]="defaultExpandedKeys" nzDraggable nzBlockNode
(nzOnDrop)="nzEvent($event)" [nzBeforeDrop]="beforeDrop">
</nz-tree>
<ng-template #nzTreeTemplate let-node let-origin="origin">
<div class="nodebox">

243
src/app/system-management/organization/organization.component.ts

@ -1,7 +1,17 @@
import { HttpClient } from '@angular/common/http';
import { Component, OnInit, AfterViewInit, ViewChild, ViewContainerRef } from '@angular/core';
import {
Component,
OnInit,
AfterViewInit,
ViewChild,
ViewContainerRef,
} from '@angular/core';
import { TreeService } from 'src/app/service/tree.service';
import { NzFormatEmitEvent, NzTreeComponent, NzTreeNodeOptions } from 'ng-zorro-antd/tree';
import {
NzFormatEmitEvent,
NzTreeComponent,
NzTreeNodeOptions,
} from 'ng-zorro-antd/tree';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { NzModalService } from 'ng-zorro-antd/modal';
import { NzMessageService } from 'ng-zorro-antd/message';
@ -15,20 +25,38 @@ import { CustomReuseStrategy } from 'src/app/CustomReuseStrategy';
@Component({
selector: 'app-organization',
templateUrl: './organization.component.html',
styleUrls: ['./organization.component.scss']
styleUrls: ['./organization.component.scss'],
})
export class OrganizationComponent implements OnInit {
validateForm!: FormGroup;
constructor(private fb: FormBuilder, private http: HttpClient, private toTree: TreeService, private modal: NzModalService, private message: NzMessageService, private viewContainerRef: ViewContainerRef) { }
constructor(
private fb: FormBuilder,
private http: HttpClient,
private toTree: TreeService,
private modal: NzModalService,
private message: NzMessageService,
private viewContainerRef: ViewContainerRef
) {}
ngOnInit(): void {
this.validateForm = this.fb.group({
search: [null]
search: [null],
});
this.getAllOrganization()
this.getAllOrganization();
}
// this.deleteRouteSnapshot();
refresh() {
this.http.put('/api/Organizations/SyncAllOrganizations', null).subscribe({
next: (data) => {
this.message.success('同步成功');
this.getAllOrganization();
},
error: (err) => {
this.message.error('同步失败');
},
});
}
deleteRouteSnapshot() {
CustomReuseStrategy.deleteRouteSnapshot('/system/host');
}
@ -43,44 +71,46 @@ export class OrganizationComponent implements OnInit {
//获取所有组织机构
searchValue = '';
nzExpandAll = false;
totalCount: string
totalCount: string;
allOrList: any
allOrList: any;
getAllOrganization() {
let OrganizationUnitId = ''
let OrganizationUnitId = '';
let params = {
// OrganizationUnitId: OrganizationUnitId,
// IsContainsChildren: "true"
ContainsChildren: true,
pageSize: 9999
}
this.http.get('/api/Organizations', {
params: params
}).subscribe((data: any) => {
console.log('组织机构列表', data)
this.totalCount = data.totalCount
data.items.forEach(element => {
element.key = element.id
element.title = element.name
element.selectable = false
if (element.isGasStation) {
element.isLeaf = true
}
pageSize: 9999,
};
this.http
.get('/api/Organizations', {
params: params,
})
.subscribe((data: any) => {
console.log('组织机构列表', data);
this.totalCount = data.totalCount;
data.items.forEach((element) => {
element.key = element.id;
element.title = element.name;
element.selectable = false;
if (element.isGasStation) {
element.isLeaf = true;
}
});
this.allOrList = data.items;
this.nodes = [...this.toTree.toTree(data.items)];
this.defaultExpandedKeys.length == 0
? (this.defaultExpandedKeys = [this.nodes[0].id])
: (this.defaultExpandedKeys = [...this.defaultExpandedKeys]);
});
this.allOrList = data.items
this.nodes = [...this.toTree.toTree(data.items)]
this.defaultExpandedKeys.length == 0 ? this.defaultExpandedKeys = [this.nodes[0].id] : this.defaultExpandedKeys = [...this.defaultExpandedKeys]
})
}
@ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent;
@ViewChild('nzTreeComponent', { static: false })
nzTreeComponent!: NzTreeComponent;
defaultExpandedKeys = [];
nodes: any[] = []
nodes: any[] = [];
addOr(node?: any) {
// console.log(node.key)
@ -92,37 +122,32 @@ export class OrganizationComponent implements OnInit {
nzComponentParams: {},
nzOnOk: async () => {
if (instance.validateForm.valid) {
await new Promise(resolve => {
await new Promise((resolve) => {
let body = {
name: instance.validateForm.value.name,
parentId: node ? node.key : null,
isGasStation: instance.validateForm.value.isGasStation
}
this.http.post('/api/Organizations', body).subscribe(data => {
resolve(data)
isGasStation: instance.validateForm.value.isGasStation,
};
this.http.post('/api/Organizations', body).subscribe((data) => {
resolve(data);
this.message.create('success', '创建成功!');
this.nzTreeComponent.getExpandedNodeList().forEach((item) => {
this.defaultExpandedKeys.push(item.key)
})
this.getAllOrganization()
return true
}, err => {
resolve(err)
this.message.create('warning', '创建失败');
return false
})
})
this.defaultExpandedKeys.push(item.key);
});
this.getAllOrganization();
return true;
});
});
} else {
this.message.create('warning', '请填写完整!');
return false
return false;
}
}
},
});
const instance = modal.getContentComponent();
}
editOr(node) {
console.log(node)
console.log(node);
const modal = this.modal.create({
nzTitle: '编辑组织机构',
nzContent: EditorComponent,
@ -133,36 +158,34 @@ export class OrganizationComponent implements OnInit {
},
nzOnOk: async () => {
if (instance.validateForm.valid) {
await new Promise(resolve => {
await new Promise((resolve) => {
let body = {
name: instance.validateForm.value.name,
isGasStation: instance.validateForm.value.isGasStation,
parentId: node.origin.parentId
}
this.http.put(`/api/Organizations/${node.origin.id}`, body).subscribe(data => {
resolve(data)
this.message.create('success', '编辑成功!');
this.nzTreeComponent.getExpandedNodeList().forEach((item) => {
this.defaultExpandedKeys.push(item.key)
})
this.getAllOrganization()
return true
}, err => {
resolve(err)
this.message.create('warning', '编辑失败');
return false
})
})
parentId: node.origin.parentId,
};
this.http
.put(`/api/Organizations/${node.origin.id}`, body)
.subscribe((data) => {
resolve(data);
this.message.create('success', '编辑成功!');
this.nzTreeComponent.getExpandedNodeList().forEach((item) => {
this.defaultExpandedKeys.push(item.key);
});
this.getAllOrganization();
return true;
});
});
} else {
this.message.create('warning', '请填写完整!');
return false
return false;
}
}
},
});
const instance = modal.getContentComponent();
}
deleteOr(item) {
console.log(item)
console.log(item);
if (item.origin.children && item.origin.children.length != 0) {
this.message.create('warning', '请先删除所有子节点');
} else {
@ -171,66 +194,64 @@ export class OrganizationComponent implements OnInit {
nzOkText: '确定',
nzOkType: 'primary',
nzOnOk: () => {
this.http.delete(`/api/Organizations/${item.origin.id}`).subscribe(data => {
this.nzTreeComponent.getExpandedNodeList().forEach((item) => {
this.defaultExpandedKeys.push(item.key)
})
this.getAllOrganization()
this.message.create('success', '删除成功!');
})
this.http
.delete(`/api/Organizations/${item.origin.id}`)
.subscribe((data) => {
this.nzTreeComponent.getExpandedNodeList().forEach((item) => {
this.defaultExpandedKeys.push(item.key);
});
this.getAllOrganization();
this.message.create('success', '删除成功!');
});
},
nzCancelText: '取消',
nzOnCancel: () => {
}
nzOnCancel: () => {},
});
}
}
nzEvent(event: NzFormatEmitEvent): void {
console.log('event', event)
console.log('event', event);
if (this.isDrag) {
let parentId
if (this.pos == 0) {//目标节点内部
parentId = event.node.key
let parentId;
if (this.pos == 0) {
//目标节点内部
parentId = event.node.key;
} else {
if (event.node.level == 0) {
parentId = null
parentId = null;
} else {
parentId = event.node.origin.parentId
parentId = event.node.origin.parentId;
}
}
let body = {
parentId: parentId,
name: event.dragNode.origin.name,
isGasStation: event.dragNode.origin.isGasStation
}
this.http.put(`/api/Organizations/${event.dragNode.origin.id}`, body).subscribe(data => {
this.message.create('success', '拖拽成功!');
this.nzTreeComponent.getExpandedNodeList().forEach((item) => {
this.defaultExpandedKeys.push(item.key)
})
this.getAllOrganization()
return true
}, err => {
this.message.create('warning', '拖拽失败');
return false
})
isGasStation: event.dragNode.origin.isGasStation,
};
this.http
.put(`/api/Organizations/${event.dragNode.origin.id}`, body)
.subscribe((data) => {
this.message.create('success', '拖拽成功!');
this.nzTreeComponent.getExpandedNodeList().forEach((item) => {
this.defaultExpandedKeys.push(item.key);
});
this.getAllOrganization();
return true;
});
}
}
isDrag //是否可以拖动
pos//放置位置
isDrag; //是否可以拖动
pos; //放置位置
beforeDrop = (arg: NzFormatBeforeDropEvent) => {
console.log('arg', arg)
if (arg.pos != 0 && arg.node.level === 0) {//如果为数据节点则不允许拖到一级节点
console.log('arg', arg);
if (arg.pos != 0 && arg.node.level === 0) {
//如果为数据节点则不允许拖到一级节点
this.message.create('warning', '不允许拖拽到一级节点');
this.isDrag = false
this.isDrag = false;
return of(false);
} else {
return of(true)
return of(true);
}
}
};
}

Loading…
Cancel
Save