Compare commits

..

1 Commits

Author SHA1 Message Date
邵佳豪 418881cb3a [修改]改名 2 years ago
  1. 2
      package.json
  2. 4
      proxy.config.json
  3. 1
      src/app/app.component.ts
  4. 3
      src/app/app.module.ts
  5. 71
      src/app/http-interceptors/base-interceptor.ts
  6. 3
      src/app/pages/login/login.component.html
  7. 114
      src/app/service/objectsSimple.service.ts
  8. 13
      src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.html
  9. 15
      src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.scss
  10. 31
      src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.ts
  11. 23
      src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.html
  12. 28
      src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.scss
  13. 25
      src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.spec.ts
  14. 179
      src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.ts
  15. 12
      src/app/system-management/condition-monitoring/condition-monitoring.component.html
  16. 338
      src/app/system-management/condition-monitoring/condition-monitoring.component.ts
  17. 9
      src/app/system-management/host-config/addcamera/addcamera.component.html
  18. 1
      src/app/system-management/host-config/addcamera/addcamera.component.ts
  19. 9
      src/app/system-management/host-config/editcamera/editcamera.component.html
  20. 21
      src/app/system-management/host-config/editcamera/editcamera.component.ts
  21. 1
      src/app/system-management/host-config/host-config.component.html
  22. 65
      src/app/system-management/host-config/host-config.component.ts
  23. 82
      src/app/system-management/host-config/simulate-data/simulate-data.component.html
  24. 16
      src/app/system-management/host-config/simulate-data/simulate-data.component.scss
  25. 25
      src/app/system-management/host-config/simulate-data/simulate-data.component.spec.ts
  26. 327
      src/app/system-management/host-config/simulate-data/simulate-data.component.ts
  27. 2
      src/app/system-management/iframe/iframe.component.html
  28. 0
      src/app/system-management/iframe/iframe.component.scss
  29. 25
      src/app/system-management/iframe/iframe.component.spec.ts
  30. 27
      src/app/system-management/iframe/iframe.component.ts
  31. 5
      src/app/system-management/image-label-anxin/image-label-anxin.component.ts
  32. 3
      src/app/system-management/navigation/navigation.component.html
  33. 4
      src/app/system-management/organization/change-or/change-or.component.html
  34. 4
      src/app/system-management/organization/change-or/change-or.component.scss
  35. 25
      src/app/system-management/organization/change-or/change-or.component.spec.ts
  36. 55
      src/app/system-management/organization/change-or/change-or.component.ts
  37. 3
      src/app/system-management/organization/organization.component.html
  38. 46
      src/app/system-management/organization/organization.component.ts
  39. 4
      src/app/system-management/system-management-routing.module.ts
  40. 10
      src/app/system-management/system-management.module.ts
  41. BIN
      src/assets/images/noImg.png
  42. 8
      src/index.html

2
package.json

@ -3,7 +3,7 @@
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"start": "ng serve --proxy-config proxy.config.json --open --port 1234", "start": "ng serve --proxy-config proxy.config.json --open --port 1234 ",
"build": "ng build", "build": "ng build",
"watch": "ng build --watch --configuration development", "watch": "ng build --watch --configuration development",
"test": "ng test" "test": "ng test"

4
proxy.config.json

@ -1,13 +1,13 @@
{ {
"/api": { "/api": {
"target": "http://121.36.37.70:8080/", "target": "http://10.156.134.53:9001/",
"测试":"http://121.36.37.70:8080/", "测试":"http://121.36.37.70:8080/",
"生产":"http://10.156.134.53:9001/", "生产":"http://10.156.134.53:9001/",
"secure": false, "secure": false,
"changeOrigin": true "changeOrigin": true
}, },
"/signalr": { "/signalr": {
"target": "http://121.36.37.70:8080/", "target": "http://10.156.134.53:9001/",
"secure": false, "secure": false,
"ws": true, "ws": true,
"logLevel": "debug" "logLevel": "debug"

1
src/app/app.component.ts

@ -13,6 +13,5 @@ export class AppComponent {
//调用服务中的function刷新token //调用服务中的function刷新token
this.token.startUp() this.token.startUp()
} }
console.log('更新日期:20241213')
} }
} }

3
src/app/app.module.ts

@ -14,9 +14,6 @@ import { TreeService } from './service/tree.service';
import { RouteReuseStrategy } from '@angular/router'; import { RouteReuseStrategy } from '@angular/router';
import { CustomReuseStrategy } from './CustomReuseStrategy'; import { CustomReuseStrategy } from './CustomReuseStrategy';
import { ConfigFormDataService } from './service/configFormData.service'; import { ConfigFormDataService } from './service/configFormData.service';
import { registerLocaleData } from '@angular/common';
import zh from '@angular/common/locales/zh';
registerLocaleData(zh);
@NgModule({ @NgModule({
declarations: [AppComponent], declarations: [AppComponent],
imports: [ imports: [

71
src/app/http-interceptors/base-interceptor.ts

@ -1,28 +1,23 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { import {
HttpClient, HttpClient, HttpInterceptor, HttpHandler, HttpRequest,
HttpInterceptor, HttpErrorResponse
HttpHandler,
HttpRequest,
HttpErrorResponse,
} from '@angular/common/http'; } from '@angular/common/http';
import { throwError } from 'rxjs'; import { throwError } from 'rxjs'
import { catchError } from 'rxjs/operators'; import { catchError } from 'rxjs/operators';
import { Router } from '@angular/router'; import { Router } from '@angular/router'
import { CacheTokenService } from '../service/cache-token.service'; import { CacheTokenService } from '../service/cache-token.service'
import { NzMessageService } from 'ng-zorro-antd/message'; import { NzMessageService } from 'ng-zorro-antd/message';
//baseurl //baseurl
// const baseurl = 'http://39.106.78.171:8008'; // const baseurl = 'http://39.106.78.171:8008';
@Injectable() @Injectable()
export class BaseInterceptor implements HttpInterceptor { export class BaseInterceptor implements HttpInterceptor {
constructor(
private router: Router, constructor(private router: Router, public token: CacheTokenService, private message: NzMessageService) { }
public token: CacheTokenService,
private message: NzMessageService
) {}
intercept(req: any, next: HttpHandler) { intercept(req: any, next: HttpHandler) {
let params = req.params; let params = req.params;
for (const key of req.params.keys()) { for (const key of req.params.keys()) {
if (params.get(key) === undefined || params.get(key) === null) { if (params.get(key) === undefined || params.get(key) === null) {
@ -37,47 +32,45 @@ export class BaseInterceptor implements HttpInterceptor {
}); });
if (!req.cancelToken) { if (!req.cancelToken) {
/*获取token*/ /*获取token*/
let token = sessionStorage.getItem('token'); let token = sessionStorage.getItem('token')
if (req.url == '/api/Data/ViolationRecordPush') {
token =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhbnhpbiIsIm5hbWUiOiLlronkv6EiLCJyb2xlIjoiUHJvZmlsZSIsIm5iZiI6MTY4NTQzNjIzNCwiZXhwIjoyMDAwNzk2MjM0LCJpc3MiOiJhbnhpbjk5LmNvbSIsImF1ZCI6IkVDTElFTlQifQ.obkc9epvwk2Xain4hqL9OrsRtBrAJ2C690CA1OJIqAo';
}
/*此处设置额外请求头,token令牌*/ /*此处设置额外请求头,token令牌*/
newReq.headers = newReq.headers.set('Authorization', `Bearer ${token}`); newReq.headers =
newReq.headers.set('Authorization', `Bearer ${token}`)
} }
// 携带请求头发送下一次请求 // 携带请求头发送下一次请求
return next.handle(newReq).pipe( return next.handle(newReq)
//箭头函数,注意this指向 .pipe(
catchError((err) => this.handleError(err)) //箭头函数,注意this指向
); catchError((err) => this.handleError(err))
)
} }
// 捕获错误 // 捕获错误
//401 token过期 403没权限!!! 400参数错误 404未找到 614刷新令牌过期!!! //401 token过期 403没权限!!! 400参数错误 404未找到 614刷新令牌过期!!!
private handleError(error: HttpErrorResponse) { private handleError(error: HttpErrorResponse) {
console.log('http错误', error); console.log('http错误', error)
// 用户认证失败返回登录页 // 用户认证失败返回登录页
if (error.status === 401) { if (error.status === 401) {
this.token.delete(); this.token.delete()
sessionStorage.clear(); sessionStorage.clear()
localStorage.removeItem('isautologin'); localStorage.removeItem("isautologin")
this.message.create('error', `用户认证信息过期,请重新登录!`); this.message.create('error', `用户认证信息过期,请重新登录!`);
this.router.navigate(['/login']); this.router.navigate(['/login'])
return; return
} }
if (error.status === 403) { if (error.status === 403) {
this.message.create('error', `对不起,您无此权限!`); this.message.create('error', `对不起,您无此权限!`);
return; return
} }
if (error.status === 400) { if (error.status === 400) {
this.message.create('error', error.error); this.message.create('error', error.error);
return; return
} }
if (error.status === 503) { if (error.status === 503) {
this.message.create('error', error.error.detail); this.message.create('error', error.error.detail);
return; return
} }
if (error.error instanceof ErrorEvent) { if (error.error instanceof ErrorEvent) {
// 发生客户端或网络错误。相应处理。 // 发生客户端或网络错误。相应处理。
@ -85,12 +78,14 @@ export class BaseInterceptor implements HttpInterceptor {
} else { } else {
// 服务端返回http状态码 // 服务端返回http状态码
// 服务端返回错误信息 // 服务端返回错误信息
console.error(`状态码${error.status}, ` + `错误内容:${error.error}`); console.error(
this.message.create('error', error.error); `状态码${error.status}, ` +
`错误内容:${error.error}`);
this.message.create('error', error.error);
} }
// 返回带有面向用户的错误信息 // 返回带有面向用户的错误信息
return throwError(() => { return throwError(() => {
new Error('error'); new Error('error')
}); });
} };
} }

3
src/app/pages/login/login.component.html

@ -1,7 +1,8 @@
<div class="login" id="login"> <div class="login" id="login">
<div class="card"> <div class="card">
<h1 class="cardheader">欢迎登录</h1> <h1 class="cardheader">欢迎登录</h1>
<h1 class="cardheader">加油站边缘主机管理系统</h1> <!-- <h1 class="cardheader">加油站边缘主机管理系统</h1> -->
<h1 class="cardheader">非煤矿业企业安全风险监测预警系统</h1>
<form nz-form [formGroup]="validateForm" class="login-form" (ngSubmit)="submitForm()"> <form nz-form [formGroup]="validateForm" class="login-form" (ngSubmit)="submitForm()">
<nz-form-item> <nz-form-item>

114
src/app/service/objectsSimple.service.ts

@ -1,114 +0,0 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root',
})
export class ObjectsSimpleService {
static readonly c_apiRoot = '/api/'; //普通上传的API根路径
static readonly c_apiRoot_Multipart = '/api/'; //分块上传的API根路径
constructor(private http: HttpClient) {}
static getBucketName() {
let bucket = '/test/';
return bucket;
}
//普通上传,单个文件上限5M
static baseUrl =
ObjectsSimpleService.c_apiRoot +
'Objects' +
ObjectsSimpleService.getBucketName();
postFile(extensionPath: string, file: File): Observable<Object> {
let formData = new FormData();
formData.append('file', file, file.name);
let data = { keepOriginalName: 'true' };
return this.http.post(
ObjectsSimpleService.baseUrl + extensionPath,
formData,
{ params: data }
);
}
//分块上传
static baseUrl_MultipartUpload =
ObjectsSimpleService.c_apiRoot_Multipart +
'NewMultipartUpload' +
ObjectsSimpleService.getBucketName();
postFile_MultipartUpload(extensionPath: string, file: File): Promise<Object> {
// let formData = new FormData()
// formData.append("file", file, file.name)
// return this.http.post(ObjectsSimpleService.baseUrl + extensionPath, formData);
let data = { keepOriginalName: 'true', filename: file.name };
return new Promise((resolve, reject) => {
this.http
.post(
ObjectsSimpleService.baseUrl_MultipartUpload + extensionPath,
{},
{ params: data }
)
.subscribe(async (data: any) => {
//初始化分段上传
let objectName = data.objectName;
let uploadId = data.uploadId;
let PartNumberETag = []; //每次返回需要保存的信息
//分块 处理
let fileSize = file.size || null; //上传文件的总大小
let shardSize = 5 * 1024 * 1024; //5MB一个分片
let allSlice = Math.ceil(fileSize / shardSize); //总文件/5MB===共分多少段
console.log('共分多少段' + allSlice);
for (let i = 0; i < allSlice; i++) {
//循环分段上传
let start = i * shardSize; //切割文件开始位置
let end = Math.min(fileSize, start + shardSize); //切割文件结束位置
let formData = new FormData();
formData.append('file', file.slice(start, end));
//同步写法实现异步调用
let result = await new Promise((resolve, reject) => {
// await 需要后面返回一个 promise 对象
this.http
.post(
ObjectsSimpleService.c_apiRoot_Multipart +
`MultipartUpload` +
+ObjectsSimpleService.getBucketName() +
`${objectName}?uploadId=${uploadId}&partNumber=${i + 1}`,
formData
)
.subscribe((data: any) => {
let msg = {
partNumber: data.partNumber || null,
eTag: data.eTag || null,
};
resolve(msg); // 调用 promise 内置方法处理成功
});
});
PartNumberETag.push(result);
if (PartNumberETag.length === allSlice) {
//分块上传完成
let data = PartNumberETag;
let paramsData = { uploadId: uploadId };
let path =
ObjectsSimpleService.c_apiRoot_Multipart +
'CompleteMultipartUpload' +
ObjectsSimpleService.getBucketName() +
objectName;
this.http
.post(path, data, { params: paramsData })
.subscribe((data) => {
let objData: any = new Object();
objData.fileName = file.name;
objData.filePath = ObjectsSimpleService.baseUrl + objectName;
resolve(objData);
});
}
} //for循环
//分块 处理
});
});
}
}

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

@ -12,11 +12,8 @@
</div> </div>
<div class="treeTitle"> <div class="treeTitle">
<span>组织机构</span> <span>组织机构</span>
</div> </div>
<div class="treebox"> <div class="treebox">
<a (click)="workerTag(1)">批量更新workerTag</a>
<a (click)="workerTag(2)">批量更新oilin_sleep_m</a>
<nz-tree [nzHideUnMatched]='true' [nzSearchValue]="searchValue" #nzTreeComponent [nzData]="nodes" <nz-tree [nzHideUnMatched]='true' [nzSearchValue]="searchValue" #nzTreeComponent [nzData]="nodes"
[nzExpandAll]="nzExpandAll" [nzExpandedKeys]="defaultExpandedKeys" [nzSelectedKeys]='nzSelectedKeys' [nzExpandAll]="nzExpandAll" [nzExpandedKeys]="defaultExpandedKeys" [nzSelectedKeys]='nzSelectedKeys'
(nzClick)="nzClick($event)"> (nzClick)="nzClick($event)">
@ -55,6 +52,16 @@
<td class="operation"> <td class="operation">
<a (click)="edit(data)" style="margin-right: 12px;">编辑</a> <a (click)="edit(data)" style="margin-right: 12px;">编辑</a>
<a (click)="config(data)" style="margin-right: 12px;">配置</a> <a (click)="config(data)" style="margin-right: 12px;">配置</a>
<!-- <nz-modal [(nzVisible)]="isVisible" [nzWidth]="350" nzTitle="请选择要配置的边缘主机" (nzOnCancel)="handleCancel()"
(nzOnOk)="handleOk()">
<ng-container *nzModalContent>
<nz-radio-group [(ngModel)]="radioValue">
<label nz-radio nzValue="警旗1">警旗1</label>
<label nz-radio nzValue="警旗2">警旗2</label>
<label nz-radio nzValue="警旗3">警旗3</label>
</nz-radio-group>
</ng-container>
</nz-modal> -->
<a (click)="download(data)" style="margin-right: 12px;">下载设备编号</a> <a (click)="download(data)" style="margin-right: 12px;">下载设备编号</a>
<a class="red" (click)="delete(data)">删除</a> <a class="red" (click)="delete(data)">删除</a>
</td> </td>

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

@ -8,6 +8,7 @@
font-size: 15px; font-size: 15px;
} }
.orbox { .orbox {
width: 375px; width: 375px;
height: 100%; height: 100%;
@ -26,7 +27,7 @@
.lefttop { .lefttop {
span { span {
color: #000d21; color: #000D21;
margin-right: 16px; margin-right: 16px;
} }
@ -55,17 +56,16 @@
line-height: 36px; line-height: 36px;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
color: #000d21; color: #000D21;
box-sizing: border-box; box-sizing: border-box;
padding: 0 30px; padding-left: 30px;
padding-right: 180px;
background: rgba(145, 204, 255, 0.2); background: rgba(145, 204, 255, 0.2);
border: 1px solid rgba(145, 204, 255, 0.2); border: 1px solid rgba(145, 204, 255, 0.2);
} }
.treebox { .treebox {
flex: 1; flex: 1;
display: flex;
flex-direction: column;
overflow-y: auto; overflow-y: auto;
border: 1px solid rgba(145, 204, 255, 0.2); border: 1px solid rgba(145, 204, 255, 0.2);
border-top: 0px; border-top: 0px;
@ -73,6 +73,7 @@
padding: 10px 6px; padding: 10px 6px;
tr { tr {
th, th,
td { td {
text-align: center !important; text-align: center !important;
@ -94,6 +95,6 @@
margin-top: 16px; margin-top: 16px;
} }
.red:hover { .red:hover{
color: red; color: red;
} }

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

@ -19,7 +19,6 @@ import { AddhostComponent } from './addhost/addhost.component';
import { EdithostComponent } from './edithost/edithost.component'; import { EdithostComponent } from './edithost/edithost.component';
import { NavigationEnd, Router } from '@angular/router'; import { NavigationEnd, Router } from '@angular/router';
import { filter } from 'rxjs'; import { filter } from 'rxjs';
import { WorkerTagComponent } from './worker-tag/worker-tag.component';
@Component({ @Component({
selector: 'app-analysis-of-the-host', selector: 'app-analysis-of-the-host',
templateUrl: './analysis-of-the-host.component.html', templateUrl: './analysis-of-the-host.component.html',
@ -70,9 +69,6 @@ export class AnalysisOfTheHostComponent implements OnInit {
element.selectable = false; element.selectable = false;
if (element.isGasStation) { if (element.isGasStation) {
element.isLeaf = true; element.isLeaf = true;
element.disableCheckbox = false;
} else {
element.disableCheckbox = true;
} }
}); });
this.nodes = [...this.toTree.toTree(data.items)]; this.nodes = [...this.toTree.toTree(data.items)];
@ -224,19 +220,10 @@ export class AnalysisOfTheHostComponent implements OnInit {
isVisible = false; isVisible = false;
radioValue = '警旗1'; radioValue = '警旗1';
configdata; configdata;
deviceProviderObj = {
0: '警旗1',
1: '警旗2',
2: '警旗3',
4: '警旗3',
};
config(data: any) { config(data: any) {
sessionStorage.setItem('hostIPAddress', data.hostIPAddress);
// this.isVisible = true; // this.isVisible = true;
this.configdata = data; this.configdata = data;
console.log(this.configdata); console.log(this.configdata);
// return;
let body = { let body = {
deviceProvider: this.configdata.deviceProvider, deviceProvider: this.configdata.deviceProvider,
}; };
@ -247,7 +234,7 @@ export class AnalysisOfTheHostComponent implements OnInit {
queryParams: { queryParams: {
hostId: this.configdata.id, hostId: this.configdata.id,
orId: this.selectedOilStation.id, orId: this.selectedOilStation.id,
type: this.deviceProviderObj[this.configdata.deviceProvider], type: DeviceProvider[this.configdata.deviceProvider],
}, },
}); });
}, 0); }, 0);
@ -313,24 +300,10 @@ export class AnalysisOfTheHostComponent implements OnInit {
}, },
}); });
} }
workerTag(type: number) {
this.modal.create({
nzTitle: type == 1 ? '批量更新workerTag' : '批量更新oilin_sleep_m',
nzContent: WorkerTagComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 500,
nzComponentParams: {
type: type,
tree: this.nodes,
},
nzFooter: null,
});
}
} }
enum DeviceProvider { enum DeviceProvider {
'警旗1' = 0, '警旗1' = 0,
'警旗2' = 1, '警旗2' = 1,
'警旗3' = 2 | 4, '警旗3' = 2,
} }

23
src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.html

@ -1,23 +0,0 @@
<div class="tagbox">
<div class="content">
<nz-tree [hidden]="!(step === 1)" #nzTreeComponent [nzData]="nodes" nzCheckable
[nzCheckedKeys]="defaultCheckedKeys" [nzExpandedKeys]="defaultExpandedKeys"></nz-tree>
<div class="inputbox" [hidden]="!(step === 2)">
<div *ngIf="type==1">
<button (click)="addInput()" nz-button>增加一行</button>
<div class="inputItem" *ngFor="let item of inputList;let key =index">
<input nz-input [(ngModel)]="item.value" [name]="key.toString()" />
</div>
</div>
<div *ngIf="type==2">
<input nz-input [(ngModel)]="oldValue" type="number" placeholder="老值" />
<input nz-input [(ngModel)]="newValue" type="number" placeholder="新值" />
</div>
</div>
</div>
<div class="btnbox">
<button nz-button nzType="primary" (click)="nextStep()" *ngIf="step === 1">下一步</button>
<button nz-button nzType="primary" (click)="back()" *ngIf="step === 2">上一步</button>
<button nz-button nzType="primary" (click)="ok()" *ngIf="step === 2">确定</button>
</div>
</div>

28
src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.scss

@ -1,28 +0,0 @@
.tagbox {
max-height: 600px;
display: flex;
flex-direction: column;
}
.content {
flex: 1;
overflow-y: auto;
.inputbox {
.inputItem {
display: flex;
margin:6px 0px;
}
}
}
.btnbox {
display: flex;
justify-content: flex-end;
align-items: center;
margin-top: 16px;
button{
margin-left: 6px;
}
}

25
src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.spec.ts

@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { WorkerTagComponent } from './worker-tag.component';
describe('WorkerTagComponent', () => {
let component: WorkerTagComponent;
let fixture: ComponentFixture<WorkerTagComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ WorkerTagComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(WorkerTagComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

179
src/app/system-management/analysis-of-the-host/worker-tag/worker-tag.component.ts

@ -1,179 +0,0 @@
import { HttpClient } from '@angular/common/http';
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd/message';
import { NzTreeComponent } from 'ng-zorro-antd/tree';
import { TreeService } from 'src/app/service/tree.service';
@Component({
selector: 'app-worker-tag',
templateUrl: './worker-tag.component.html',
styleUrls: ['./worker-tag.component.scss'],
})
export class WorkerTagComponent implements OnInit {
@Input() tree: any;
@Input() type: number;
@ViewChild('nzTreeComponent', { static: false })
nzTreeComponent!: NzTreeComponent;
defaultCheckedKeys = [];
defaultExpandedKeys = [];
constructor(
private http: HttpClient,
private message: NzMessageService,
private toTree: TreeService
) {}
nodes = [];
inputList = [{ value: '' }];
step = 1;
ngOnInit(): void {
this.getAllOrganization();
}
getAllOrganization() {
let params = {
ContainsChildren: true,
PageSize: 9999,
};
this.http
.get('/api/Organizations', {
params: params,
})
.subscribe((data: any) => {
data.items.forEach((element) => {
element.key = element.id;
element.title = element.name;
element.selectable = false;
if (element.isGasStation) {
element.isLeaf = true;
element.disableCheckbox = false;
} else {
element.disableCheckbox = true;
}
});
this.nodes = [...this.toTree.toTree(data.items)];
// this.defaultExpandedKeys = [this.nodes[0].id];
// this.defaultExpandedKeys = [...this.defaultExpandedKeys];
});
}
nextStep() {
this.step = 2;
}
back() {
this.step = 1;
}
addInput() {
this.inputList.push({ value: '' });
}
oldValue: string;
newValue: string;
ok() {
let ids =
this.nzTreeComponent.getCheckedNodeList().map((item) => {
return item.key;
}) || [];
let workerTags =
this.inputList.map((item) => {
return item.value;
}) || [];
if (ids.length === 0) {
this.message.create('info', '请至少选择一个加油站');
return;
}
if (this.type == 1) {
if (this.inputList.find((v) => !v.value)) {
this.message.create('info', '请将所有输入框填写完整');
return;
}
}
if (this.type == 2) {
if (!this.oldValue || !this.newValue) {
this.message.create('info', '请将所有输入框填写完整');
return;
}
}
let _this = this;
function BatchModifyWorkerTags() {
var a = new Promise<void>((resolve, reject) => {
_this.http
.put('/api/EdgeDevices/BatchModifyWorkerTags', ids, {
params: { workerTags: workerTags },
})
.subscribe({
next: (data: any) => {
_this.message.create('success', '批量修改成功');
resolve(data);
},
error: (err) => {
// _this.message.create('error', '批量修改失败,请重试');
reject(err);
},
});
});
return a;
}
function BatchModifyoi() {
var a = new Promise<void>((resolve, reject) => {
let obj = {
replaceString: 'oilin_sleep_m: ' + _this.newValue,
targetString: 'oilin_sleep_m: ' + _this.oldValue,
};
_this.http
.put('/api/EdgeDevices/BatchModifyConfig', ids, {
params: obj,
})
.subscribe({
next: (data: any) => {
_this.message.create('success', '批量修改成功');
resolve(data);
},
error: (err) => {
// _this.message.create('error', '批量修改失败,请重试');
reject(err);
},
});
});
return a;
}
function BatchPushFile() {
let b = new Promise<void>((resolve, reject) => {
_this.http
.put('/api/EdgeDevices/Commands/BatchPushFile', ids, {
params: { fileName: 'data.yaml' },
})
.subscribe({
next: (data: any) => {
_this.message.create('success', '批量推送成功');
resolve(data);
},
error: (err) => {
// _this.message.create('error', '批量推送失败');
reject(err);
},
});
});
return b;
}
if (this.type == 1) {
BatchModifyWorkerTags()
.then((data) => {
BatchPushFile();
})
.catch((err) => {});
}
if (this.type == 2) {
BatchModifyoi()
.then((data) => {
BatchPushFile();
})
.catch((err) => {});
}
}
}

12
src/app/system-management/condition-monitoring/condition-monitoring.component.html

@ -20,6 +20,7 @@
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
<!-- <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="state">设备状态</nz-form-label> -->
<nz-form-control> <nz-form-control>
<nz-select formControlName="state" nzPlaceHolder="请选择设备状态"> <nz-select formControlName="state" nzPlaceHolder="请选择设备状态">
<nz-option [nzValue]="0" nzLabel="离线"></nz-option> <nz-option [nzValue]="0" nzLabel="离线"></nz-option>
@ -27,16 +28,7 @@
</nz-select> </nz-select>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item>
<nz-form-control>
<nz-select formControlName="updatestate" nzPlaceHolder="请选择识别程序更新状态" nzAllowClear>
<nz-option [nzValue]="'Never'" nzLabel="未更新"></nz-option>
<nz-option [nzValue]="'Updating'" nzLabel="更新中"></nz-option>
<nz-option [nzValue]="'Updated'" nzLabel="已更新"></nz-option>
<nz-option [nzValue]="'UpdatingTimeout'" nzLabel="更新超时"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item class="btn"> <nz-form-item class="btn">
<nz-form-control> <nz-form-control>

338
src/app/system-management/condition-monitoring/condition-monitoring.component.ts

@ -9,51 +9,43 @@ import { ModelComponent } from './model/model.component';
@Component({ @Component({
selector: 'app-condition-monitoring', selector: 'app-condition-monitoring',
templateUrl: './condition-monitoring.component.html', templateUrl: './condition-monitoring.component.html',
styleUrls: ['./condition-monitoring.component.scss'], styleUrls: ['./condition-monitoring.component.scss']
}) })
export class ConditionMonitoringComponent implements OnInit { export class ConditionMonitoringComponent implements OnInit {
constructor(
private http: HttpClient, constructor(private http: HttpClient, private fb: FormBuilder, private toTree: TreeService, private message: NzMessageService, private modal: NzModalService, private viewContainerRef: ViewContainerRef) { }
private fb: FormBuilder,
private toTree: TreeService,
private message: NzMessageService,
private modal: NzModalService,
private viewContainerRef: ViewContainerRef
) {}
validateForm!: FormGroup; validateForm!: FormGroup;
ngOnInit(): void { ngOnInit(): void {
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
organization: [null], organization: [null],
state: [null], state: [null]
updatestate: [null],
}); });
this.getAllOrganization(); this.getAllOrganization()
} }
//获取所有组织机构 //获取所有组织机构
nodes: any = []; nodes: any = []
defaultOrId: string; defaultOrId: string
defaultExpandedKeys = []; defaultExpandedKeys = [];
getAllOrganization() { getAllOrganization() {
let params = { let params = {
ContainsChildren: true, ContainsChildren: true,
pageSize: 9999, pageSize: 9999
}; }
this.http this.http.get('/api/Organizations', {
.get('/api/Organizations', { params: params
params: params, }).subscribe((data: any) => {
}) console.log('组织机构列表', data)
.subscribe((data: any) => { data.items.forEach(element => {
console.log('组织机构列表', data); element.key = element.id
data.items.forEach((element) => { element.title = element.name
element.key = element.id; // element.selectable = false
element.title = element.name;
// element.selectable = false
});
this.nodes = [...this.toTree.toTree(data.items)];
this.defaultOrId = this.nodes[0].id;
this.validateForm.value.organization = this.defaultOrId;
this.getConditionMonitoring();
}); });
this.nodes = [...this.toTree.toTree(data.items)]
this.defaultOrId = this.nodes[0].id
this.validateForm.value.organization = this.defaultOrId
this.getConditionMonitoring()
})
} }
submitForm(): void { submitForm(): void {
@ -61,7 +53,7 @@ export class ConditionMonitoringComponent implements OnInit {
this.validateForm.controls[i].markAsDirty(); this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity(); this.validateForm.controls[i].updateValueAndValidity();
} }
this.getConditionMonitoring(); this.getConditionMonitoring()
} }
resetForm(e: MouseEvent): void { resetForm(e: MouseEvent): void {
e.preventDefault(); e.preventDefault();
@ -73,13 +65,13 @@ export class ConditionMonitoringComponent implements OnInit {
this.validateForm.patchValue({ this.validateForm.patchValue({
organization: this.nodes[0].id, organization: this.nodes[0].id,
}); });
this.PageNumber = 1; this.PageNumber = 1
this.getConditionMonitoring(); this.getConditionMonitoring()
} }
listOfData: any; listOfData: any
num: string; num: string
PageNumber: number = 1; PageNumber: number = 1
isLoading = false; isLoading = false
//获取盒子状态 //获取盒子状态
getConditionMonitoring() { getConditionMonitoring() {
let params = { let params = {
@ -87,27 +79,28 @@ export class ConditionMonitoringComponent implements OnInit {
OrganizationId: this.defaultOrId, OrganizationId: this.defaultOrId,
PageNumber: this.PageNumber, PageNumber: this.PageNumber,
PageSize: 10, PageSize: 10,
HubConnectionState: this.validateForm.value.state, HubConnectionState: this.validateForm.value.state
AppUpdatingState: this.validateForm.value.updatestate, }
}; this.isLoading = true
this.isLoading = true;
this.http.get('/api/EdgeDevices/Statuses', { params: params }).subscribe( this.http.get('/api/EdgeDevices/Statuses', { params: params }).subscribe(
(data: any) => { (data: any) => {
console.log(data); console.log(data)
this.isLoading = false; this.isLoading = false
this.listOfData = data.items; this.listOfData = data.items
this.num = data.totalCount; this.num = data.totalCount
}, }, err => {
(err) => {}
); }
)
} }
pageChange($event) { pageChange($event) {
this.PageNumber = $event; this.PageNumber = $event
this.getConditionMonitoring(); this.getConditionMonitoring()
} }
checked = false; checked = false;
loading; loading
indeterminate = false; indeterminate = false;
listOfCurrentPageData: readonly any[] = []; listOfCurrentPageData: readonly any[] = [];
setOfCheckedId = new Set<number>(); setOfCheckedId = new Set<number>();
@ -125,15 +118,9 @@ export class ConditionMonitoringComponent implements OnInit {
} }
refreshCheckedStatus(): void { refreshCheckedStatus(): void {
const listOfEnabledData = this.listOfCurrentPageData.filter( const listOfEnabledData = this.listOfCurrentPageData.filter(({ disabled }) => !disabled);
({ disabled }) => !disabled this.checked = listOfEnabledData.every(({ id }) => this.setOfCheckedId.has(id));
); this.indeterminate = listOfEnabledData.some(({ id }) => this.setOfCheckedId.has(id)) && !this.checked;
this.checked = listOfEnabledData.every(({ id }) =>
this.setOfCheckedId.has(id)
);
this.indeterminate =
listOfEnabledData.some(({ id }) => this.setOfCheckedId.has(id)) &&
!this.checked;
} }
onItemChecked(id: number, checked: boolean): void { onItemChecked(id: number, checked: boolean): void {
@ -148,64 +135,60 @@ export class ConditionMonitoringComponent implements OnInit {
this.refreshCheckedStatus(); this.refreshCheckedStatus();
} }
selectedBoxId = [];
selectedBoxId = []
updateBox(type, name) { updateBox(type, name) {
const requestData = this.listOfData.filter((data) => const requestData = this.listOfData.filter(data => this.setOfCheckedId.has(data.id));
this.setOfCheckedId.has(data.id) this.selectedBoxId = []
); requestData.forEach(element => {
this.selectedBoxId = []; this.selectedBoxId.push(element.id)
requestData.forEach((element) => {
this.selectedBoxId.push(element.id);
}); });
if (this.selectedBoxId.length == 0) { if (this.selectedBoxId.length == 0) {
this.modal.confirm({ this.modal.confirm({
nzTitle: `<i>确定更新所有边缘主机的${name}吗?</i>`, nzTitle: `<i>确定更新所有边缘主机的${name}吗?</i>`,
nzOnOk: () => { nzOnOk: () => {
console.log('OK'); console.log('OK')
this.sendRequest(type, true); this.sendRequest(type, true)
}, }
}); });
} else { } else {
this.sendRequest(type, false); this.sendRequest(type, false)
} }
} }
sendRequest(type, isAllBox): void { sendRequest(type, isAllBox): void {
let body; let body
if (type != 'UpdateModels') { if (type != 'UpdateModels') {
this.loading = type; this.loading = type;
body = { body = {
edgeDeviceIds: this.selectedBoxId, edgeDeviceIds: this.selectedBoxId,
allEdgeDevices: isAllBox, allEdgeDevices: isAllBox
}; }
this.http this.http.patch('/api/EdgeDevices/Commands', body, { params: { command: type } }).subscribe({
.patch('/api/EdgeDevices/Commands', body, { params: { command: type } }) next: (data: any) => {
.subscribe({ this.message.create('success', '通知边缘盒子成功,请过一段时间手动刷新尝试!');
next: (data: any) => { let str = '更新失败列表<br>'
this.message.create( if (data.failedItems.length != 0) {
'success', data.failedItems.forEach(element => {
'通知边缘盒子成功,请过一段时间手动刷新尝试!' str += element.detail + '<br>'
); });
let str = '更新失败列表<br>'; this.message.create('info', str, {
if (data.failedItems.length != 0) { nzDuration: 3000
data.failedItems.forEach((element) => { });
str += element.detail + '<br>'; }
});
this.message.create('info', str, {
nzDuration: 3000,
});
}
this.setOfCheckedId.clear(); this.setOfCheckedId.clear();
this.refreshCheckedStatus(); this.refreshCheckedStatus();
this.loading = null; this.loading = null;
this.getConditionMonitoring(); this.getConditionMonitoring()
}, },
error: (err) => { error: (err) => {
this.loading = null; this.loading = null;
}, }
}); })
} else { } else {
const modal = this.modal.create({ const modal = this.modal.create({
nzTitle: '选择更新模型类型', nzTitle: '选择更新模型类型',
@ -218,73 +201,66 @@ export class ConditionMonitoringComponent implements OnInit {
body = { body = {
edgeDeviceIds: this.selectedBoxId, edgeDeviceIds: this.selectedBoxId,
modelNames: instance.validateForm.value.type, modelNames: instance.validateForm.value.type,
allEdgeDevices: isAllBox, allEdgeDevices: isAllBox
}; }
await new Promise((resolve) => { await new Promise(resolve => {
this.http this.http.patch('/api/EdgeDevices/Commands', body, { params: { command: type } }).subscribe({
.patch('/api/EdgeDevices/Commands', body, { next: (data: any) => {
params: { command: type }, resolve(data)
}) this.message.create('success', '通知边缘盒子成功,请过一段时间手动刷新尝试!');
.subscribe({ let str = '更新失败列表<br>'
next: (data: any) => { if (data.failedItems.length != 0) {
resolve(data); data.failedItems.forEach(element => {
this.message.create( str += element.detail + '<br>'
'success', });
'通知边缘盒子成功,请过一段时间手动刷新尝试!' this.message.create('info', str, {
); nzDuration: 3000
let str = '更新失败列表<br>'; });
if (data.failedItems.length != 0) { }
data.failedItems.forEach((element) => {
str += element.detail + '<br>';
});
this.message.create('info', str, {
nzDuration: 3000,
});
}
this.setOfCheckedId.clear(); this.setOfCheckedId.clear();
this.refreshCheckedStatus(); this.refreshCheckedStatus();
this.loading = null; this.loading = null;
this.getConditionMonitoring(); this.getConditionMonitoring()
return true; return true
}, },
error: (err) => { error: (err) => {
resolve(err); resolve(err)
this.loading = null; this.loading = null;
return false; return false
}, }
}); })
}); })
} else { } else {
this.message.create('warning', '请填写完整!'); this.message.create('warning', '请填写完整!');
return false; return false
} }
}, }
}); });
const instance = modal.getContentComponent(); const instance = modal.getContentComponent();
} }
} }
updateBoxfile() { updateBoxfile() {
const requestData = this.listOfData.filter((data) => const requestData = this.listOfData.filter(data => this.setOfCheckedId.has(data.id));
this.setOfCheckedId.has(data.id) this.selectedBoxId = []
); requestData.forEach(element => {
this.selectedBoxId = []; this.selectedBoxId.push(element.id)
requestData.forEach((element) => {
this.selectedBoxId.push(element.id);
}); });
if (this.selectedBoxId.length == 0) { if (this.selectedBoxId.length == 0) {
this.modal.confirm({ this.modal.confirm({
nzTitle: `<i>确定更新所有边缘主机的监控程序配置文件吗?</i>`, nzTitle: `<i>确定更新所有边缘主机的监控程序配置文件吗?</i>`,
nzOnOk: () => { nzOnOk: () => {
this.file(true); this.file(true)
}, }
}); });
} else { } else {
this.file(false); this.file(false)
} }
} }
file(isAllBox) { file(isAllBox) {
const modal = this.modal.create({ const modal = this.modal.create({
nzTitle: '配置文件', nzTitle: '配置文件',
@ -300,46 +276,42 @@ export class ConditionMonitoringComponent implements OnInit {
host: instance.validateForm.value.host, host: instance.validateForm.value.host,
port: instance.validateForm.value.port, port: instance.validateForm.value.port,
maxRetries: instance.validateForm.value.maxRetries, maxRetries: instance.validateForm.value.maxRetries,
allEdgeDevices: isAllBox, allEdgeDevices: isAllBox
}; }
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
this.loading = 'file'; this.loading = 'file'
this.http this.http.patch('/api/EdgeDevices/Commands/PushMonitorSettingsJson', body).subscribe({
.patch('/api/EdgeDevices/Commands/PushMonitorSettingsJson', body) next: (data: any) => {
.subscribe({ this.message.create('success', '通知边缘盒子成功,请过一段时间手动刷新尝试!');
next: (data: any) => { let str = '更新失败列表<br>'
this.message.create( if (data.failedItems.length != 0) {
'success', data.failedItems.forEach(element => {
'通知边缘盒子成功,请过一段时间手动刷新尝试!' str += element.detail + '<br>'
); });
let str = '更新失败列表<br>'; this.message.create('info', str, {
if (data.failedItems.length != 0) { nzDuration: 3000
data.failedItems.forEach((element) => { });
str += element.detail + '<br>'; }
}); this.setOfCheckedId.clear();
this.message.create('info', str, { this.refreshCheckedStatus();
nzDuration: 3000, this.getConditionMonitoring()
}); this.loading = null;
} resolve(data)
this.setOfCheckedId.clear(); return true
this.refreshCheckedStatus(); },
this.getConditionMonitoring(); error: (err) => {
this.loading = null; reject(err)
resolve(data); this.loading = null;
return true; }
}, })
error: (err) => { })
reject(err);
this.loading = null;
},
});
});
} else { } else {
this.message.create('warning', '请填写完整!'); this.message.create('warning', '请填写完整!');
return false; return false
} }
}, }
}); });
const instance = modal.getContentComponent(); const instance = modal.getContentComponent();
} }
} }

9
src/app/system-management/host-config/addcamera/addcamera.component.html

@ -16,15 +16,6 @@
</nz-input-group> </nz-input-group>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="decoderType">编码类型</nz-form-label>
<nz-form-control>
<nz-select formControlName="decoderType" nzPlaceHolder="请选择编码类型">
<nz-option [nzValue]="264" nzLabel="264"></nz-option>
<nz-option [nzValue]="265" nzLabel="265"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="password">密码</nz-form-label> <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="password">密码</nz-form-label>
<nz-form-control> <nz-form-control>

1
src/app/system-management/host-config/addcamera/addcamera.component.ts

@ -18,7 +18,6 @@ export class AddcameraComponent implements OnInit {
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
name: [null, [Validators.required, namevalidate]], name: [null, [Validators.required, namevalidate]],
user: [null, [Validators.required]], user: [null, [Validators.required]],
decoderType: [null, [Validators.required]],
password: [null, [Validators.required]], password: [null, [Validators.required]],
uri: [null, [Validators.required]], uri: [null, [Validators.required]],
type: [null, [Validators.required]], type: [null, [Validators.required]],

9
src/app/system-management/host-config/editcamera/editcamera.component.html

@ -16,15 +16,6 @@
</nz-input-group> </nz-input-group>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="decoderType">编码类型</nz-form-label>
<nz-form-control>
<nz-select formControlName="decoderType" nzPlaceHolder="请选择编码类型">
<nz-option [nzValue]="264" nzLabel="264"></nz-option>
<nz-option [nzValue]="265" nzLabel="265"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="password">密码</nz-form-label> <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="password">密码</nz-form-label>
<nz-form-control> <nz-form-control>

21
src/app/system-management/host-config/editcamera/editcamera.component.ts

@ -7,29 +7,26 @@ import { MyValidators } from '../addcamera/addcamera.component';
@Component({ @Component({
selector: 'app-editcamera', selector: 'app-editcamera',
templateUrl: './editcamera.component.html', templateUrl: './editcamera.component.html',
styleUrls: ['./editcamera.component.scss'], styleUrls: ['./editcamera.component.scss']
}) })
export class EditcameraComponent implements OnInit { export class EditcameraComponent implements OnInit {
@Input() data: any;
@Input() data: any
validateForm!: FormGroup; validateForm!: FormGroup;
constructor( constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient) { }
private modal: NzModalRef,
private fb: FormBuilder,
private http: HttpClient
) {}
ngOnInit(): void { ngOnInit(): void {
const { namevalidate } = MyValidators; const { namevalidate } = MyValidators;
let datacopy = JSON.parse(JSON.stringify(this.data)); let datacopy = JSON.parse(JSON.stringify(this.data))
console.log('编辑数据', datacopy); console.log('编辑数据', datacopy)
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
name: [datacopy.name, [Validators.required, namevalidate]], name: [datacopy.name, [Validators.required,namevalidate]],
user: [datacopy.user, [Validators.required]], user: [datacopy.user, [Validators.required]],
decoderType: [datacopy.decoderType, [Validators.required]],
password: [datacopy.password, [Validators.required]], password: [datacopy.password, [Validators.required]],
uri: [datacopy.uri, [Validators.required]], uri: [datacopy.uri, [Validators.required]],
type: [datacopy.type, [Validators.required]], type: [datacopy.type, [Validators.required]],
order: [datacopy.order, [Validators.required]], order: [datacopy.order, [Validators.required]]
}); });
} }
} }

1
src/app/system-management/host-config/host-config.component.html

@ -43,7 +43,6 @@
<td> <td>
<span class="blue" style="margin-right: 12px;" (click)="editCamera(item)">编辑</span> <span class="blue" style="margin-right: 12px;" (click)="editCamera(item)">编辑</span>
<span class="blue" style="margin-right: 12px;" (click)="label(item)">标注</span> <span class="blue" style="margin-right: 12px;" (click)="label(item)">标注</span>
<span class="blue" *ngIf="my" style="margin-right: 12px;" (click)="simulate(item)">模拟数据</span>
<ng-container *ngIf="item.isEnabled; else elseTemplate2"> <ng-container *ngIf="item.isEnabled; else elseTemplate2">
<span class="red" style="margin-right: 12px;" (click)="forbidden(item)">禁用</span> <span class="red" style="margin-right: 12px;" (click)="forbidden(item)">禁用</span>
</ng-container> </ng-container>

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

@ -40,7 +40,6 @@ interface Camera {
import yaml from 'js-yaml'; import yaml from 'js-yaml';
import { ImageLabelAnxinComponent } from '../image-label-anxin/image-label-anxin.component'; import { ImageLabelAnxinComponent } from '../image-label-anxin/image-label-anxin.component';
import { AnxinConfigComponent } from './anxin-config/anxin-config.component'; import { AnxinConfigComponent } from './anxin-config/anxin-config.component';
import { SimulateDataComponent } from './simulate-data/simulate-data.component';
@Component({ @Component({
selector: 'app-host-config', selector: 'app-host-config',
@ -62,14 +61,13 @@ export class HostConfigComponent implements OnInit {
hostId; //主机id hostId; //主机id
orId; //加油站id orId; //加油站id
hostType; //黄海还是交大的盒子 hostType; //黄海还是交大的盒子
my = false;
hostData; hostData;
ngOnInit(): void { ngOnInit(): void {
this.hostId = this.route.snapshot.queryParams.hostId; this.hostId = this.route.snapshot.queryParams.hostId;
this.orId = this.route.snapshot.queryParams.orId; this.orId = this.route.snapshot.queryParams.orId;
this.hostType = this.route.snapshot.queryParams.type; this.hostType = this.route.snapshot.queryParams.type;
this.my = this.route.snapshot.queryParams.my;
this.getCamera(); this.getCamera();
this.getHostData(); this.getHostData();
} }
@ -137,7 +135,6 @@ export class HostConfigComponent implements OnInit {
let body = { let body = {
name: instance.validateForm.value.name, name: instance.validateForm.value.name,
user: instance.validateForm.value.user, user: instance.validateForm.value.user,
decoderType: instance.validateForm.value.decoderType,
password: instance.validateForm.value.password, password: instance.validateForm.value.password,
uri: instance.validateForm.value.uri, uri: instance.validateForm.value.uri,
type: instance.validateForm.value.type, type: instance.validateForm.value.type,
@ -185,7 +182,6 @@ export class HostConfigComponent implements OnInit {
let body = { let body = {
name: instance.validateForm.value.name, name: instance.validateForm.value.name,
user: instance.validateForm.value.user, user: instance.validateForm.value.user,
decoderType: instance.validateForm.value.decoderType,
password: instance.validateForm.value.password, password: instance.validateForm.value.password,
uri: instance.validateForm.value.uri, uri: instance.validateForm.value.uri,
type: instance.validateForm.value.type, type: instance.validateForm.value.type,
@ -343,51 +339,6 @@ export class HostConfigComponent implements OnInit {
}); });
} }
simulate(item) {
console.log('模拟数据', item);
const modal = this.modal.create({
nzTitle: '模拟数据',
nzContent: SimulateDataComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 1800,
nzComponentParams: {
data: item,
},
nzOnOk: async () => {
if (instance.validateForm.valid) {
await new Promise((resolve) => {
function generateRandomString(length) {
const chars =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; // 字符集合
let result = '';
for (let i = 0; i < length; i++) {
result += chars.charAt(
Math.floor(Math.random() * chars.length)
);
}
return result;
}
const randomString = generateRandomString(16);
let body = JSON.parse(JSON.stringify(instance.validateForm.value));
body.ExternalId = randomString;
const date = new Date(body.ViolateTime);
date.setHours(date.getHours() + 8);
body.ViolateTime = date.toISOString();
this.http
.post(`/api/Data/ViolationRecordPush`, body)
.subscribe((data) => {
this.message.create('success', '上报成功!');
// resolve(data);
});
});
} else {
this.message.create('warning', '请填写完整!');
return false;
}
},
});
const instance = modal.getContentComponent();
}
connect() { connect() {
// let isAllLabel = this.listOfData.find((item: any) => { // let isAllLabel = this.listOfData.find((item: any) => {
// if (item.type != 1 && !item.dimensionedPoints) { // if (item.type != 1 && !item.dimensionedPoints) {
@ -1624,18 +1575,6 @@ rule_threshold:
ip: this.hostData.hostIPAddress, ip: this.hostData.hostIPAddress,
imgScale: 1.5, imgScale: 1.5,
cpuRtsp: false, cpuRtsp: false,
warning: {
open: false,
volume: 6,
continue_s: 5,
dev: 'ttyUSB0',
},
audio: {
open: false,
volume: 0.5,
},
pipline: '',
workerTag: ['worker'],
caps: [], caps: [],
params: { params: {
smoke_sleep_m: 5, smoke_sleep_m: 5,
@ -1653,7 +1592,6 @@ rule_threshold:
smog_continue_s: 3, smog_continue_s: 3,
fire_sleep_m: 5, fire_sleep_m: 5,
fire_continue_s: 3, fire_continue_s: 3,
lossScore: 40, //没检测到物体的惩罚分数
}, },
}; };
console.log(this.hostData); console.log(this.hostData);
@ -1720,7 +1658,6 @@ rule_threshold:
id: item.id, id: item.id,
type: type, type: type,
url: item.uri, url: item.uri,
decoder: item.decoderType,
name: item.name, name: item.name,
user: item.user, user: item.user,
password: item.password, password: item.password,

82
src/app/system-management/host-config/simulate-data/simulate-data.component.html

@ -1,82 +0,0 @@
<div class="box">
<form nz-form [formGroup]="validateForm" [nzLayout]="'inline'">
<nz-form-item>
<nz-form-label nzRequired nzFor="HostIPAddress">主机地址</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="HostIPAddress" placeholder="请输入主机地址" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzRequired nzFor="EventSystemName">预警事件</nz-form-label>
<nz-form-control>
<nz-select formControlName="EventSystemName" nzPlaceHolder="请选择预警事件">
<nz-option *ngFor="let item of eventList" [nzValue]="item" [nzLabel]="item"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzRequired nzFor="ViolateArea">预警区域</nz-form-label>
<nz-form-control>
<nz-select formControlName="ViolateArea" nzPlaceHolder="请选择预警区域">
<nz-option *ngFor="let item of areaList" [nzValue]="item" [nzLabel]="item"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzRequired nzFor="CameraNo">摄像头编号</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="CameraNo" placeholder="请输入摄像头编号" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzRequired nzFor="ViolateTime">选择日期</nz-form-label>
<nz-form-control>
<nz-date-picker nzShowTime formControlName="ViolateTime"></nz-date-picker>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzRequired nzFor="ViolateImage">图片地址</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="ViolateImage" placeholder="请输入图片地址" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzRequired nzFor="violateVideo">视频地址</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="violateVideo" placeholder="请输入图片地址" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label>第一步</nz-form-label>
<button nz-button (click)="getImg()">捕获图片</button>
</nz-form-item>
<nz-form-item>
<button nz-button (click)="getVideo()">捕获视频</button>
</nz-form-item>
<nz-form-item>
<nz-form-label>第二步</nz-form-label>
<button nz-button (click)="updateImg()">更新底图</button>
</nz-form-item>
<nz-form-item>
<button nz-button (click)="updateVideo()">更新视频</button>
</nz-form-item>
</form>
<div class="img_box">
<canvas #canvas (mousedown)="onMouseDown($event)" (mousemove)="onMouseMove($event)" (mouseup)="onMouseUp()"
style="border: 1px solid #ccc;"></canvas>
<video style="width: 500px;height: auto;" [src]="videoUrl" controls></video>
<div>
<button style="margin-bottom: 10px;" nz-button nzType="primary" (click)="uploadImg()">上传预警图片</button>
<button nz-button nzType="primary" (click)="uploadVideo()">上传预警视频</button>
</div>
</div>
</div>

16
src/app/system-management/host-config/simulate-data/simulate-data.component.scss

@ -1,16 +0,0 @@
.ant-form-item {
margin-bottom: 10px;
}
.img_box {
height: auto;
display: flex;
canvas {
max-width: 1000px;
height: auto;
}
button {
margin: 0;
margin-left: 10px;
}
}

25
src/app/system-management/host-config/simulate-data/simulate-data.component.spec.ts

@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SimulateDataComponent } from './simulate-data.component';
describe('SimulateDataComponent', () => {
let component: SimulateDataComponent;
let fixture: ComponentFixture<SimulateDataComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ SimulateDataComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(SimulateDataComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

327
src/app/system-management/host-config/simulate-data/simulate-data.component.ts

@ -1,327 +0,0 @@
import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
import { DomSanitizer } from '@angular/platform-browser';
import { ObjectsSimpleService } from 'src/app/service/objectsSimple.service';
import { NzMessageService } from 'ng-zorro-antd/message';
@Component({
selector: 'app-simulate-data',
templateUrl: './simulate-data.component.html',
styleUrls: ['./simulate-data.component.scss'],
})
export class SimulateDataComponent implements OnInit {
@Input() data: any;
validateForm!: FormGroup;
constructor(
private fb: FormBuilder,
private http: HttpClient,
private objectsSrv: ObjectsSimpleService,
private message: NzMessageService,
private sanitizer: DomSanitizer
) {}
currentTime = null;
arr = ['进出口', '加油区', '卸油区', '便利店'];
ngOnInit(): void {
this.currentTime = new Date().getTime();
let datacopy = JSON.parse(JSON.stringify(this.data));
let HostIPAddress = sessionStorage.getItem('hostIPAddress');
this.validateForm = this.fb.group({
HostIPAddress: [HostIPAddress, [Validators.required]],
EventSystemName: [null, [Validators.required]],
ViolateArea: [this.arr[datacopy.type], [Validators.required]],
CameraNo: [datacopy.name, [Validators.required]],
ViolateTime: [null, [Validators.required]],
ViolateImage: [
`/api/Objects/test/${this.currentTime}/image.png`,
[Validators.required],
],
violateVideo: [
`/api/Objects/test/${this.currentTime}/video.mp4`,
[Validators.required],
],
});
this.getImgMarkData();
this.updateVideo();
}
@ViewChild('canvas') canvasRef: ElementRef<HTMLCanvasElement>;
private ctx: CanvasRenderingContext2D;
imgUrl: string;
isDrawing = false;
startX: number;
startY: number;
endX: number;
endY: number;
img: HTMLImageElement;
//获取 摄像头图片/标注点位
getImgMarkData() {
const httpOptions = {
responseType: 'blob' as 'json',
params: { cameraId: this.data.id },
};
let date = new Date().getTime();
this.http.get(`/api/Cameras/Images?v=${date}`, httpOptions).subscribe({
next: (data: any) => {
setTimeout(() => {
this.initCanvas(data);
}, 0);
},
error: (error) => {
console.error('获取图片数据失败', error);
setTimeout(() => {
this.initCanvas(null);
}, 0);
},
});
}
canvasObj = null;
initCanvas(data) {
if (!data) {
// 如果没有获取到图片数据,使用本地默认图片
this.message.warning('未获取到照片数据,使用默认图片');
this.imgUrl = '../../../../assets/images/bgImg.png'; // 请确保这个路径下有默认图片
} else {
this.imgUrl = window.URL.createObjectURL(data);
}
this.img = new Image();
this.img.src = this.imgUrl;
this.img.onerror = () => {
// 如果图片加载失败,也使用默认图片
this.message.warning('图片加载失败,使用默认图片');
this.img.src = '../../../../assets/images/bgImg.png';
};
this.img.onload = () => {
this.canvasObj = this.canvasRef.nativeElement;
this.ctx = this.canvasObj.getContext('2d');
// 设置 canvas 宽度为 1000px,保持图片的宽高比
const targetWidth = 1000;
this.canvasObj.width = targetWidth;
this.canvasObj.height = (this.img.height / this.img.width) * targetWidth;
// 在 canvas 上绘制图片
this.ctx.drawImage(
this.img,
0,
0,
this.canvasObj.width,
this.canvasObj.height
);
};
}
// 开始绘制红框
onMouseDown(event: MouseEvent): void {
this.isDrawing = true;
this.startX = event.offsetX;
this.startY = event.offsetY;
}
// 实时绘制红框
onMouseMove(event: MouseEvent): void {
if (!this.isDrawing) return;
this.endX = event.offsetX;
this.endY = event.offsetY;
const canvas = this.canvasRef.nativeElement;
this.ctx.clearRect(0, 0, canvas.width, canvas.height); // 清除 canvas
this.ctx.drawImage(this.img, 0, 0, canvas.width, canvas.height); // 重新绘制图片
this.ctx.strokeStyle = 'red';
this.ctx.lineWidth = 2;
this.ctx.strokeRect(
this.startX,
this.startY,
this.endX - this.startX,
this.endY - this.startY
);
}
// 停止绘制红框
onMouseUp(): void {
this.isDrawing = false;
}
async uploadImg() {
const canvas = this.canvasRef.nativeElement;
canvas.toBlob(async (blob: Blob) => {
// 创建 File 对象,'image.png' 为文件名,'image/png' 为文件类型
const file = new File([blob], 'image.png', { type: 'image/png' });
console.log(file);
let url = await this.postFile(file);
console.log(url);
this.validateForm.patchValue({
ViolateImage: url, // 替换为你想要的 ViolateImage 值
});
}, 'image/png');
}
async uploadVideo() {
// 创建 File 对象,'image.png' 为文件名,'image/png' 为文件类型
const file = new File([this.videoBlob], 'video.mp4', { type: 'video/mp4' });
console.log(file);
let url = await this.postFile(file);
console.log(url);
this.validateForm.patchValue({
ViolateImage: url, // 替换为你想要的 ViolateImage 值
});
}
//上传文件
async postFile(file: File) {
return new Promise((resolve, reject) => {
this.objectsSrv
.postFile(`${this.currentTime}/`, file)
.subscribe((data) => {
let dataObj = data as any;
let filePath: string =
ObjectsSimpleService.baseUrl + dataObj.objectName;
this.message.create('success', '上传成功');
resolve(filePath);
});
});
}
getImg() {
let params = {
cameraId: this.data.id,
provider: 1,
};
this.http
.put('/api/Cameras/Commands/CaptureImages', '', { params: params })
.subscribe({
next: (value: Object) => {
this.message.create(
'success',
'发送指令: 捕获图片成功,请过一段时间手动更新底图!'
);
},
});
}
getVideo() {
let params = {
cameraId: this.data.id,
provider: 1,
};
this.http
.put('/api/Cameras/Commands/CaptureVideos', '', { params: params })
.subscribe({
next: (value: Object) => {
this.message.create(
'success',
'发送指令: 捕获视频成功,请过一段时间手动更新视频!'
);
},
});
}
updateImg() {
const httpOptions = {
responseType: 'blob' as 'json',
params: { cameraId: this.data.id },
};
let date = new Date().getTime();
this.http.get(`/api/Cameras/Images?v=${date}`, httpOptions).subscribe({
next: (data: any) => {
this.replaceBackground(data);
},
});
}
replaceBackground(newData: Blob) {
console.log('newData', newData);
const newImgUrl = window.URL.createObjectURL(newData);
this.img = new Image();
this.img.src = newImgUrl;
this.img.onload = () => {
// 清空 canvas 内容
this.ctx.clearRect(0, 0, this.canvasObj.width, this.canvasObj.height);
// 更新 canvas 大小和图片宽高比
const targetWidth = 1000;
this.canvasObj.width = targetWidth;
this.canvasObj.height = (this.img.height / this.img.width) * targetWidth;
// 绘制新的图片
this.ctx.drawImage(
this.img,
0,
0,
this.canvasObj.width,
this.canvasObj.height
);
};
}
videoBlob = null;
videoUrl = null;
updateVideo() {
const httpOptions = {
responseType: 'blob' as 'json',
params: { cameraId: this.data.id },
};
let date = new Date().getTime();
this.http.get(`/api/Cameras/Videos?v=${date}`, httpOptions).subscribe({
next: (data: any) => {
console.log('视频数据', data);
this.videoBlob = data;
// 获取图片数据 (data 是 Blob 类型)
const unsafeUrl = window.URL.createObjectURL(data);
// 使用 DomSanitizer 处理 URL
this.videoUrl = this.sanitizer.bypassSecurityTrustUrl(unsafeUrl);
},
});
}
eventList = [
'油罐区入侵',
'进出口停车',
'站内吸烟',
'前庭接打电话',
'设置卸油隔离区',
'拆除卸油管',
'卸油连接静电接地',
'卸油设置消防器材',
'卸油现场清理',
'油罐车无人卸油',
'连接卸油管',
'卸油中无人监卸',
'证照年检逾期报警',
'证照年检临期提醒',
'证照年检办理提醒',
'普通证照有效期逾期报警',
'证照有效期办理提醒',
'烟雾预警',
'火灾报警',
'设备报废逾期报警',
'设备报废临期提醒',
'收银员着装',
'关键证照有效期逾期报警',
'证照有效期临期提醒',
'设备维保临期提醒',
'设备维保逾期报警',
];
areaList = [
'进出口',
'卸油区',
'加油区',
'收银区',
'发油区',
'油库区',
'监控区',
'消防通道',
'泵房区',
'油罐区',
'停车区',
];
}

2
src/app/system-management/iframe/iframe.component.html

@ -1,2 +0,0 @@
<button (click)="xxx()">向子页面发送信息</button>
<iframe id="iframe" src="http://192.168.1.86:25647/login" frameborder="0" width="100%" height="100%"></iframe>

0
src/app/system-management/iframe/iframe.component.scss

25
src/app/system-management/iframe/iframe.component.spec.ts

@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { IframeComponent } from './iframe.component';
describe('IframeComponent', () => {
let component: IframeComponent;
let fixture: ComponentFixture<IframeComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ IframeComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(IframeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

27
src/app/system-management/iframe/iframe.component.ts

@ -1,27 +0,0 @@
import { Component, OnInit } from '@angular/core';
import { Renderer2} from '@angular/core';
@Component({
selector: 'app-iframe',
templateUrl: './iframe.component.html',
styleUrls: ['./iframe.component.scss']
})
export class IframeComponent implements OnInit {
constructor( private render2: Renderer2) { }
ngOnInit(): void {
}
xxx(){
this.handleToIframe()
}
handleToIframe() {
const child = this.render2.selectRootElement("#iframe");
console.log(child);
let data = {
from: 'parent page',
code: 200,
data: '来自父页面的数据!!!'
};
child.contentWindow.postMessage(data, '*');
}
}

5
src/app/system-management/image-label-anxin/image-label-anxin.component.ts

@ -84,9 +84,6 @@ export class ImageLabelAnxinComponent implements OnInit {
}) })
.catch((err) => { .catch((err) => {
this.message.create('error', '获取图片失败!'); this.message.create('error', '获取图片失败!');
window.setTimeout(() => {
this.initBackgroundImg();
}, 0);
}); });
} }
@ -109,7 +106,7 @@ export class ImageLabelAnxinComponent implements OnInit {
} }
// 图片加载完后,将其显示在canvas中 // 图片加载完后,将其显示在canvas中
var img = new Image(); var img = new Image();
img.src = this.imgItem ? this.imgItem : '../../../assets/images/noImg.png'; img.src = this.imgItem ? this.imgItem : '../../../assets/images/bgImg.png';
console.log('img', img); console.log('img', img);

3
src/app/system-management/navigation/navigation.component.html

@ -30,7 +30,8 @@
</nz-sider> </nz-sider>
<nz-layout> <nz-layout>
<nz-header> <nz-header>
<span>Hey,欢迎登录加油站边缘主机管理系统</span> <!-- <span>Hey,欢迎登录加油站边缘主机管理系统</span> -->
<span>Hey,欢迎登录非煤矿业企业安全风险监测预警系统</span>
<a nz-dropdown [nzDropdownMenu]="menu" [nzTrigger]="'click'" [nzBackdrop]='false'> <a nz-dropdown [nzDropdownMenu]="menu" [nzTrigger]="'click'" [nzBackdrop]='false'>
<i nz-icon nzType="setting"></i> <i nz-icon nzType="setting"></i>
</a> </a>

4
src/app/system-management/organization/change-or/change-or.component.html

@ -1,4 +0,0 @@
<div class="box">
<nz-tree #nzTreeComponent [nzSelectedKeys]="defaultSelectedKeys" [nzData]="nodes"
[nzExpandedKeys]="defaultExpandedKeys"></nz-tree>
</div>

4
src/app/system-management/organization/change-or/change-or.component.scss

@ -1,4 +0,0 @@
.box {
max-height: 500px;
overflow-y: auto;
}

25
src/app/system-management/organization/change-or/change-or.component.spec.ts

@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ChangeOrComponent } from './change-or.component';
describe('ChangeOrComponent', () => {
let component: ChangeOrComponent;
let fixture: ComponentFixture<ChangeOrComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ChangeOrComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ChangeOrComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

55
src/app/system-management/organization/change-or/change-or.component.ts

@ -1,55 +0,0 @@
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
import { TreeService } from 'src/app/service/tree.service';
import { NzTreeComponent } from 'ng-zorro-antd/tree';
@Component({
selector: 'app-change-or',
templateUrl: './change-or.component.html',
styleUrls: ['./change-or.component.scss'],
})
export class ChangeOrComponent implements OnInit {
@Input() data?: any;
@ViewChild('nzTreeComponent', { static: false })
nzTreeComponent!: NzTreeComponent;
constructor(
private modal: NzModalRef,
private fb: FormBuilder,
private http: HttpClient,
private toTree: TreeService
) {}
defaultExpandedKeys = [];
defaultSelectedKeys = [];
ngOnInit(): void {
this.getAllOrganization();
// this.nzTreeComponent.getCheckedNodeList()
}
allOrList: any;
nodes: any;
getAllOrganization() {
let params = {
ContainsChildren: true,
pageSize: 9999,
};
this.http
.get('/api/Organizations', {
params: params,
})
.subscribe((data: any) => {
data.items.forEach((element) => {
element.key = element.id;
element.title = element.name;
});
this.allOrList = data.items.filter((v) => !v.isGasStation);
this.nodes = [...this.toTree.toTree(this.allOrList)];
});
}
destroyModal(): void {
this.modal.destroy({ data: 'this the result data' });
}
}

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

@ -17,14 +17,13 @@
</div> </div>
<nz-tree [nzHideUnMatched]='true' [nzSearchValue]="searchValue" #nzTreeComponent [nzData]="nodes" <nz-tree [nzHideUnMatched]='true' [nzSearchValue]="searchValue" #nzTreeComponent [nzData]="nodes"
[nzExpandAll]="nzExpandAll" [nzExpandedKeys]="defaultExpandedKeys" nzDraggable nzBlockNode [nzExpandAll]="nzExpandAll" [nzExpandedKeys]="defaultExpandedKeys" nzDraggable nzBlockNode
(nzOnDrop)="nzEvent($event)" [nzBeforeDrop]="beforeDrop" [nzTreeTemplate]="nzTreeTemplate"> (nzOnDrop)="nzEvent($event)" [nzBeforeDrop]="beforeDrop">
</nz-tree> </nz-tree>
<ng-template #nzTreeTemplate let-node let-origin="origin"> <ng-template #nzTreeTemplate let-node let-origin="origin">
<div class="nodebox"> <div class="nodebox">
<span class="name">{{ node.title }}</span> <span class="name">{{ node.title }}</span>
<span class="operation"> <span class="operation">
<span class="blue" (click)="addOr(node)" *ngIf="!node.origin.isGasStation">新增</span> <span class="blue" (click)="addOr(node)" *ngIf="!node.origin.isGasStation">新增</span>
<span class="blue" (click)="changeOr(node)">修改所属机构</span>
<span class="blue" (click)="editOr(node)">编辑</span> <span class="blue" (click)="editOr(node)">编辑</span>
<span class="red" (click)="deleteOr(node)">删除</span> <span class="red" (click)="deleteOr(node)">删除</span>
</span> </span>

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

@ -22,7 +22,6 @@ import { NzFormatBeforeDropEvent } from 'ng-zorro-antd/tree';
import { Observable, of } from 'rxjs'; import { Observable, of } from 'rxjs';
import { delay } from 'rxjs/operators'; import { delay } from 'rxjs/operators';
import { CustomReuseStrategy } from 'src/app/CustomReuseStrategy'; import { CustomReuseStrategy } from 'src/app/CustomReuseStrategy';
import { ChangeOrComponent } from './change-or/change-or.component';
@Component({ @Component({
selector: 'app-organization', selector: 'app-organization',
templateUrl: './organization.component.html', templateUrl: './organization.component.html',
@ -85,7 +84,10 @@ export class OrganizationComponent implements OnInit {
allOrList: any; allOrList: any;
getAllOrganization() { getAllOrganization() {
let OrganizationUnitId = '';
let params = { let params = {
// OrganizationUnitId: OrganizationUnitId,
// IsContainsChildren: "true"
ContainsChildren: true, ContainsChildren: true,
pageSize: 9999, pageSize: 9999,
}; };
@ -191,48 +193,6 @@ export class OrganizationComponent implements OnInit {
}); });
const instance = modal.getContentComponent(); const instance = modal.getContentComponent();
} }
changeOr(node) {
console.log(node);
const modal = this.modal.create({
nzTitle: '修改所属组织机构',
nzContent: ChangeOrComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 500,
nzComponentParams: {
data: this.allOrList,
},
nzOnOk: async () => {
let selectedNode =
instance.nzTreeComponent.getSelectedNodeList()[0].key;
if (selectedNode) {
await new Promise((resolve) => {
let body = {
parentId: selectedNode,
isGasStation: node.origin.isGasStation,
};
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;
}
},
});
const instance = modal.getContentComponent();
}
deleteOr(item) { deleteOr(item) {
console.log(item); console.log(item);
if (item.origin.children && item.origin.children.length != 0) { if (item.origin.children && item.origin.children.length != 0) {

4
src/app/system-management/system-management-routing.module.ts

@ -11,7 +11,6 @@ import { ConditionMonitoringComponent } from './condition-monitoring/condition-m
import { KafkaComponent } from './kafka/kafka.component'; import { KafkaComponent } from './kafka/kafka.component';
import { StatusMonitoringComponent } from './status-monitoring/status-monitoring.component'; import { StatusMonitoringComponent } from './status-monitoring/status-monitoring.component';
import { VideoStreamingComponent } from './video-streaming/video-streaming.component'; import { VideoStreamingComponent } from './video-streaming/video-streaming.component';
import { IframeComponent } from './iframe/iframe.component';
const routes: Routes = [ const routes: Routes = [
@ -25,8 +24,7 @@ const routes: Routes = [
{ path: 'conditionMonitoring', component: ConditionMonitoringComponent }, { path: 'conditionMonitoring', component: ConditionMonitoringComponent },
{ path: 'statusMonitoring', component: StatusMonitoringComponent }, { path: 'statusMonitoring', component: StatusMonitoringComponent },
{ path: 'kafka', component: KafkaComponent }, { path: 'kafka', component: KafkaComponent },
{ path: 'videoStreaming', component: VideoStreamingComponent }, { path: 'videoStreaming', component: VideoStreamingComponent }
{ path: 'iframe', component: IframeComponent }
]; ];
@NgModule({ @NgModule({

10
src/app/system-management/system-management.module.ts

@ -50,11 +50,6 @@ import { HuangHaiConfigComponent } from './host-config/huang-hai-config/huang-ha
import { ImageLabelAnxinComponent } from './image-label-anxin/image-label-anxin.component'; import { ImageLabelAnxinComponent } from './image-label-anxin/image-label-anxin.component';
import { AnxinConfigComponent } from './host-config/anxin-config/anxin-config.component'; import { AnxinConfigComponent } from './host-config/anxin-config/anxin-config.component';
import { DragDropModule } from '@angular/cdk/drag-drop'; import { DragDropModule } from '@angular/cdk/drag-drop';
import { IframeComponent } from './iframe/iframe.component';
import { WorkerTagComponent } from './analysis-of-the-host/worker-tag/worker-tag.component';
import { ChangeOrComponent } from './organization/change-or/change-or.component';
import { SimulateDataComponent } from './host-config/simulate-data/simulate-data.component';
import { NzDatePickerModule } from 'ng-zorro-antd/date-picker';
@NgModule({ @NgModule({
declarations: [ declarations: [
OrganizationComponent, OrganizationComponent,
@ -85,10 +80,6 @@ import { NzDatePickerModule } from 'ng-zorro-antd/date-picker';
HuangHaiConfigComponent, HuangHaiConfigComponent,
ImageLabelAnxinComponent, ImageLabelAnxinComponent,
AnxinConfigComponent, AnxinConfigComponent,
IframeComponent,
WorkerTagComponent,
ChangeOrComponent,
SimulateDataComponent,
], ],
imports: [ imports: [
CommonModule, CommonModule,
@ -115,7 +106,6 @@ import { NzDatePickerModule } from 'ng-zorro-antd/date-picker';
NzPopconfirmModule, NzPopconfirmModule,
NzRadioModule, NzRadioModule,
DragDropModule, DragDropModule,
NzDatePickerModule,
], ],
entryComponents: [ entryComponents: [
AddorComponent, AddorComponent,

BIN
src/assets/images/noImg.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

8
src/index.html

@ -1,16 +1,14 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>边缘主机管理系统</title> <!-- <title>边缘主机管理系统</title> -->
<title>非煤矿业企业安全风险监测预警系统</title>
<base href="/"> <base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">
</head> </head>
<body> <body>
<app-root></app-root> <app-root></app-root>
</body> </body>
</html>
</html>

Loading…
Cancel
Save