Browse Source

[完善]完善平台

develop
邵佳豪 3 years ago
parent
commit
ac71954a73
  1. 9
      src/app/http-interceptors/base-interceptor.ts
  2. 1
      src/app/pages/login/login.component.ts
  3. 4
      src/app/system-management/analysis-of-the-host/analysis-of-the-host.component.ts
  4. 4
      src/app/system-management/config-form/config-form.component.html
  5. 4
      src/app/system-management/config-form/config-form.component.ts
  6. 107
      src/app/system-management/host-config/addcamera/addcamera.component.html
  7. 3
      src/app/system-management/host-config/addcamera/addcamera.component.ts
  8. 107
      src/app/system-management/host-config/editcamera/editcamera.component.html
  9. 3
      src/app/system-management/host-config/editcamera/editcamera.component.ts
  10. 7
      src/app/system-management/host-config/host-config.component.html
  11. 173
      src/app/system-management/host-config/host-config.component.ts
  12. 5
      src/app/system-management/host-config/send-file/send-file.component.html
  13. 20
      src/app/system-management/host-config/send-file/send-file.component.scss
  14. 23
      src/app/system-management/host-config/send-file/send-file.component.ts
  15. 1
      src/app/system-management/image-label2/image-label2.component.html
  16. 132
      src/app/system-management/image-label2/image-label2.component.ts
  17. 5
      src/app/system-management/system-management.module.ts

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

@ -58,14 +58,20 @@ export class BaseInterceptor implements HttpInterceptor {
localStorage.removeItem("isautologin")
this.message.create('error', `用户认证信息过期,请重新登录!`);
this.router.navigate(['/login'])
return
}
if (error.status === 403) {
this.message.create('error', `对不起,您无此权限!`);
return
}
if (error.status === 400) {
this.message.create('error', `请核对您的输入信息或格式是否正确!`);
return
}
if (error.status === 503) {
this.message.create('error', error.error.detail);
return
}
if (error.error instanceof ErrorEvent) {
// 发生客户端或网络错误。相应处理。
console.error('An error occurred:', error.error.message);
@ -75,6 +81,7 @@ export class BaseInterceptor implements HttpInterceptor {
console.error(
`状态码${error.status}, ` +
`错误内容:${error.error}`);
this.message.create('error', error.error);
}
// 返回带有面向用户的错误信息
return throwError(() => {

1
src/app/pages/login/login.component.ts

@ -115,6 +115,7 @@ export class LoginComponent implements OnInit {
},
error: (err) => {
this.isLoading = false;
console.log(err)
}
}

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

@ -89,7 +89,7 @@ export class AnalysisOfTheHostComponent implements OnInit {
addHost() {
console.log(this.selectedOilStation)
const modal = this.modal.create({
nzTitle: '新增加油站主机',
nzTitle: '新增边缘盒子',
nzContent: AddhostComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 288,
@ -121,7 +121,7 @@ export class AnalysisOfTheHostComponent implements OnInit {
edit(data) {
console.log(data)
const modal = this.modal.create({
nzTitle: '编辑加油站主机',
nzTitle: '编辑边缘盒子',
nzContent: EdithostComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 288,

4
src/app/system-management/config-form/config-form.component.html

@ -6,10 +6,10 @@
</nz-tab>
<nz-tab nzTitle="config.yaml"> <textarea name="config2" id="config2" [(ngModel)]="config2"></textarea></nz-tab>
<nz-tab nzTitle="producer.yaml"> <textarea name="config3" id="config3" [(ngModel)]="config3"></textarea></nz-tab>
<nz-tab nzTitle="source.yaml"> <textarea name="config4" id="config4" [(ngModel)]="config4"></textarea></nz-tab>
<!-- <nz-tab nzTitle="source.yaml"> <textarea name="config4" id="config4" [(ngModel)]="config4"></textarea></nz-tab> -->
</nz-tabset>
</div>
<div class="btnbox">
<button nz-button nzType="primary" (click)="putConfig()">发送配置文件</button>
<button nz-button nzType="primary" (click)="putConfig()">下发算法配置</button>
</div>
</div>

4
src/app/system-management/config-form/config-form.component.ts

@ -35,7 +35,7 @@ export class ConfigFormComponent implements OnInit {
{ name: 'config_nvdsanalytics.txt', content: this.config1 },
{ name: 'config.yaml', content: this.config2 },
{ name: 'producer.yaml', content: this.config3 },
{ name: 'source.yaml', content: this.config4 }
// { name: 'source.yaml', content: this.config4 }
]
}
this.http.put(`/api/EdgeDevices/${this.hostId}`, body).subscribe({
@ -63,7 +63,7 @@ export class ConfigFormComponent implements OnInit {
Promise.all(promiseArr).then((result) => {
this.message.create('success', `发送文件名成功`);
}).catch((error) => {
this.message.create('error', `发送文件名失败`);
// this.message.create('error', `发送文件名失败`);
console.log('发送文件名失败', error)
})
},

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

@ -1,47 +1,62 @@
<div class="box">
<form nz-form [formGroup]="validateForm">
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="name">名称</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="name" placeholder="请输入名称" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="user">用户名</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="user" placeholder="请输入用户名" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="password">密码</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="password" placeholder="请输入密码" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="uri">地址</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="uri" placeholder="请输入地址" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="type">类型</nz-form-label>
<nz-form-control>
<nz-select formControlName="type" nzPlaceHolder="请选择类型">
<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>
</form>
</div>
<form nz-form [formGroup]="validateForm">
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="name">名称</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="name" placeholder="请输入名称" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="user">用户名</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="user" placeholder="请输入用户名" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="password">密码</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="password" placeholder="请输入密码" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="uri">地址</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="uri" placeholder="请输入地址" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="type">类型</nz-form-label>
<nz-form-control>
<nz-select formControlName="type" nzPlaceHolder="请选择类型">
<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>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="type">序号</nz-form-label>
<nz-form-control>
<nz-select formControlName="order" nzPlaceHolder="请选择序号">
<nz-option [nzValue]="0" nzLabel="0"></nz-option>
<nz-option [nzValue]="1" nzLabel="1"></nz-option>
<nz-option [nzValue]="2" nzLabel="2"></nz-option>
<nz-option [nzValue]="3" nzLabel="3"></nz-option>
<nz-option [nzValue]="4" nzLabel="4"></nz-option>
<nz-option [nzValue]="5" nzLabel="5"></nz-option>
<nz-option [nzValue]="6" nzLabel="6"></nz-option>
<nz-option [nzValue]="7" nzLabel="7"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</form>
</div>

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

@ -18,7 +18,8 @@ export class AddcameraComponent implements OnInit {
user: [null, [Validators.required]],
password: [null, [Validators.required]],
uri: [null, [Validators.required]],
type: [null, [Validators.required]]
type: [null, [Validators.required]],
order: [null, [Validators.required]],
});
}

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

@ -1,47 +1,62 @@
<div class="box">
<form nz-form [formGroup]="validateForm">
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="name">名称</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="name" placeholder="请输入名称" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="user">用户名</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="user" placeholder="请输入用户名" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="password">密码</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="password" placeholder="请输入密码" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="uri">地址</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="uri" placeholder="请输入地址" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="type">类型</nz-form-label>
<nz-form-control>
<nz-select formControlName="type" nzPlaceHolder="请选择类型">
<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>
</form>
</div>
<form nz-form [formGroup]="validateForm">
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="name">名称</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="name" placeholder="请输入名称" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="user">用户名</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="user" placeholder="请输入用户名" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="password">密码</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="password" placeholder="请输入密码" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="uri">地址</nz-form-label>
<nz-form-control>
<nz-input-group>
<input nz-input type="text" formControlName="uri" placeholder="请输入地址" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="type">类型</nz-form-label>
<nz-form-control>
<nz-select formControlName="type" nzPlaceHolder="请选择类型">
<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>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="type">序号</nz-form-label>
<nz-form-control>
<nz-select formControlName="order" nzPlaceHolder="请选择序号">
<nz-option [nzValue]="0" nzLabel="0"></nz-option>
<nz-option [nzValue]="1" nzLabel="1"></nz-option>
<nz-option [nzValue]="2" nzLabel="2"></nz-option>
<nz-option [nzValue]="3" nzLabel="3"></nz-option>
<nz-option [nzValue]="4" nzLabel="4"></nz-option>
<nz-option [nzValue]="5" nzLabel="5"></nz-option>
<nz-option [nzValue]="6" nzLabel="6"></nz-option>
<nz-option [nzValue]="7" nzLabel="7"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</form>
</div>

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

@ -22,7 +22,8 @@ export class EditcameraComponent implements OnInit {
user: [datacopy.user, [Validators.required]],
password: [datacopy.password, [Validators.required]],
uri: [datacopy.uri, [Validators.required]],
type: [datacopy.type, [Validators.required]]
type: [datacopy.type, [Validators.required]],
order: [datacopy.order, [Validators.required]]
});
}

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

@ -9,6 +9,7 @@
<nz-table #basicTable [nzData]="listOfData" [nzShowPagination]="false">
<thead>
<tr>
<th>序号</th>
<th>名称</th>
<th>用户名</th>
<th>密码</th>
@ -20,6 +21,7 @@
</thead>
<tbody>
<tr *ngFor="let item of basicTable.data">
<td>{{ item.order }}</td>
<td>{{ item.name }}</td>
<td>{{ item.user }}</td>
<td>{{ item.password }}</td>
@ -42,7 +44,10 @@
</tbody>
</nz-table>
<div class="footer">
<button nz-button nzType="primary" (click)="connect()">下发摄像头配置</button>
<button [disabled]="isSourceYaml === true" nz-button nzType="primary" (click)="sourceYaml()">下发source.yaml配置</button>
</div>
<div class="footer">
<button [disabled]="isSourceYaml === false" nz-button nzType="primary" (click)="connect()">下发算法配置</button>
</div>
</div>
</div>

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

@ -9,12 +9,14 @@ import { HttpClient, HttpErrorResponse, HttpResponse } from '@angular/common/htt
import { EditcameraComponent } from './editcamera/editcamera.component';
import { catchError, tap } from 'rxjs/operators';
import { ConfigFormDataService } from 'src/app/service/configFormData.service';
import { SendFileComponent } from './send-file/send-file.component';
interface Camera {
name: string;
user: string;
password: string;
uri: string;
type: number;
order: number;
dimensionedPoints: string
}
@ -35,6 +37,30 @@ export class HostConfigComponent implements OnInit {
this.hostId = this.route.snapshot.queryParams.hostId
this.orId = this.route.snapshot.queryParams.orId
this.getCamera()
this.http.get(`/api/EdgeDevices/${this.hostId}`).subscribe(
{
next: ((data: any) => {
console.log(data)
// let isExist = data.configFiles.find((item, index, arr) => {
// if (item.name == 'source.yaml') {
// console.log("存在", index)
// return item
// }
// })
if (data.configFiles) {
this.isSourceYaml = true
} else {
this.isSourceYaml = false
}
}),
error: (err) => {
// this.message.create('error', '请先下发source.yaml配置');
}
}
)
}
listOfData: Camera[] = [];
goback() {
@ -42,7 +68,10 @@ export class HostConfigComponent implements OnInit {
}
//摄像头
getCamera() {
this.http.get('/api/Cameras').subscribe((data: any) => {
let params = {
EdgeDeviceId: this.hostId
}
this.http.get('/api/Cameras',{ params: params }).subscribe((data: any) => {
data.items.forEach(element => {
element.dimensionedPointsObj = JSON.parse(element.dimensionedPoints)
});
@ -67,12 +96,15 @@ export class HostConfigComponent implements OnInit {
password: instance.validateForm.value.password,
uri: instance.validateForm.value.uri,
type: instance.validateForm.value.type,
organizationId: this.orId
organizationId: this.orId,
edgeDeviceId: this.hostId,
order: instance.validateForm.value.order,
}
this.http.post('/api/Cameras', body).subscribe(data => {
resolve(data)
this.message.create('success', '创建成功!');
this.getCamera()
this.isSourceYaml = false
return true
})
})
@ -104,12 +136,15 @@ export class HostConfigComponent implements OnInit {
password: instance.validateForm.value.password,
uri: instance.validateForm.value.uri,
type: instance.validateForm.value.type,
organizationId: this.orId
organizationId: this.orId,
edgeDeviceId: this.hostId,
order: instance.validateForm.value.order,
}
this.http.put(`/api/Cameras/${data.id}`, body).subscribe(data => {
resolve(data)
this.message.create('success', '创建成功!');
this.message.create('success', '编辑成功!');
this.getCamera()
this.isSourceYaml = false
return true
})
})
@ -131,17 +166,59 @@ export class HostConfigComponent implements OnInit {
this.http.delete(`/api/Cameras/${item.id}`).subscribe(data => {
this.message.create('success', '删除成功!');
this.getCamera()
this.isSourceYaml = false
})
},
nzCancelText: '取消'
});
}
isSourceYaml: boolean
label(item) {
this.router.navigate(['/system/host/camera/imageLabel'], { queryParams: { id: item.id } })
this.http.get(`/api/EdgeDevices/${this.hostId}`).subscribe(
{
next: ((data: any) => {
console.log(data)
// let isExist = data.configFiles.find((item, index, arr) => {
// if (item.name == 'source.yaml') {
// console.log("存在", index)
// return item
// }
// })
if (data.configFiles) {
this.router.navigate(['/system/host/camera/imageLabel'], { queryParams: { id: item.id } })
this.isSourceYaml = true
} else {
this.isSourceYaml = false
this.message.create('error', '请先下发source.yaml配置');
}
}),
error: (err) => {
// this.message.create('error', '请先下发source.yaml配置');
}
}
)
}
connect() {
let isAllLabel = this.listOfData.find((item: any) => {
if (item.type != 1 && !item.dimensionedPoints) {
console.log('存在摄像头未标注的情况')
return item
}
})
if (isAllLabel) {
this.message.create('error', '存在摄像头未标注的情况');
return
}
let ids = []
this.listOfData.forEach((item: any) => {
ids.push(item.id)
@ -160,9 +237,77 @@ export class HostConfigComponent implements OnInit {
})
}
sourceYaml() {
let config4 = `video_rate: 5
inference_buffer_second: 10
sources:`
this.listOfData.forEach((item: any, index) => {
config4 += `
- name: '${item.name}'
user: '${item.user}'
password: '${item.password}'
uri: '${item.uri}'
type: ${item.type}
`
})
const modal = this.modal.create({
nzTitle: '下发source.yaml配置',
nzContent: SendFileComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 1000,
nzBodyStyle: {
'border-radius': '0px',
'padding': '7px',
},
nzComponentParams: {
data: config4
},
nzOnOk: async () => {
await new Promise(resolve => {
console.log('表单信息', instance.validateForm)
let body = {
configFiles: [
{ name: 'source.yaml', content: instance.datacopy }
]
}
this.http.put(`/api/EdgeDevices/${this.hostId}`, body).subscribe({
next: (data) => {
this.message.create('success', `文件保存成功`);
resolve('成功了')
this.isSourceYaml = true
let params = {
edgeDeviceId: this.hostId,
fileName: 'source.yaml'
}
this.http.put('/api/EdgeDevices/Commands/PushFile', '', { params: params }).subscribe({
next: (data) => {
this.message.create('success', `发送文件名成功`);
},
error: err => {
// this.message.create('error', `发送文件名失败`);
// reject('失败了')
}
})
},
error: (err) => {
// this.message.create('error', `文件保存失败`);
}
})
})
}
});
const instance = modal.getContentComponent();
}
//整理配置文件数据
disposalData() {
console.log(this.listOfData)
let config1 = `[property]
enable=1
#Width height used for configuration to which below configs are configured
@ -179,20 +324,10 @@ display-font-size=12
let config3 = `test_action: true
logging_interval : 600
`
let config4 = `#RTSP sources for file source, use file as the
#Shoushi Yuan RTSP sources
video_rate: 5
inference_buffer_second: 10`
let xieyouqu = []
this.listOfData.forEach((item: any, index) => {
if (item.type == 2) { xieyouqu.push(item) }
config4 += `
- name: '${item.name} ${index}'
user: '${item.user}'
password: '${item.password}'
uri: '${item.uri}'
type: ${item.type}
`
if (item.type == 0) {
let str = ''
item.dimensionedPointsObj.polygon.forEach(element => {
@ -203,7 +338,7 @@ inference_buffer_second: 10`
console.log('进出口多边形', str)
config1 += `
## Per stream configuration
[roi-filtering-stream-${index}]
[roi-filtering-stream-${item.order}]
#shoushiyuan-out202
#enable or disable following feature
enable=1
@ -219,7 +354,7 @@ class-id=-1
let str = arrowArr[0].startX + ',' + arrowArr[0].startY + ',' + arrowArr[0].endX + ',' + arrowArr[0].endY + ',' + arrowArr[1].startX + ',' + arrowArr[1].startY + ',' + arrowArr[1].endX + ',' + arrowArr[1].endY
console.log('十字箭头', str)
config1 += `
[line-crossing-stream-${index}]
[line-crossing-stream-${item.order}]
enable=1
#Label;direction;lc
line-crossing-Entry=${str}
@ -362,7 +497,5 @@ rule_threshold:
sessionStorage.setItem('config1', config1)
sessionStorage.setItem('config2', config2)
sessionStorage.setItem('config3', config3)
sessionStorage.setItem('config4', config4)
// console.log('config4', config4)
}
}

5
src/app/system-management/host-config/send-file/send-file.component.html

@ -0,0 +1,5 @@
<div class="box">
<div class="content">
<textarea name="config" id="config" [(ngModel)]="datacopy"></textarea>
</div>
</div>

20
src/app/system-management/host-config/send-file/send-file.component.scss

@ -0,0 +1,20 @@
.box {
width: 100%;
height: 100%;
background: #fff;
font-size: 15px;
color: black;
box-sizing: border-box;
display: flex;
flex-direction: column;
overflow-y: auto;
}
.content {
flex: 1;
box-sizing: border-box;
textarea {
width: 100%;
height: 400px;
}
}

23
src/app/system-management/host-config/send-file/send-file.component.ts

@ -0,0 +1,23 @@
import { Component, OnInit, Input } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-send-file',
templateUrl: './send-file.component.html',
styleUrls: ['./send-file.component.scss']
})
export class SendFileComponent implements OnInit {
@Input() data: any
validateForm!: FormGroup;
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient) { }
datacopy
ngOnInit(): void {
this.datacopy = JSON.parse(JSON.stringify(this.data))
console.log(this.datacopy)
}
putConfig() {
}
}

1
src/app/system-management/image-label2/image-label2.component.html

@ -8,6 +8,7 @@
<button nz-button *ngIf="markType === 2" [ngClass]="{selectBtn: isDrawArrow}" (click)="isDrawArrow = true;">箭头方向标绘</button>
<button nz-button *ngIf="markType === 2" [ngClass]="{selectBtn: !isDrawArrow && oilUnloadingArea}" (click)="isDrawArrow = false; oilUnloadingArea = true;">泄油管区域</button>
<button nz-button *ngIf="markType === 2" [ngClass]="{selectBtn: !isDrawArrow && !oilUnloadingArea}" (click)="isDrawArrow = false; oilUnloadingArea = false;">静电接地仪</button>
<button nz-button nzType="primary" (click)="anewgetImg()">重新捕获摄像头图片</button>
<button nz-button nzType="primary" (click)="save()">保存</button>
<button nz-button nzType="primary" nzDanger (click)="clearCanvas()">清空</button>
</div>

132
src/app/system-management/image-label2/image-label2.component.ts

@ -1,4 +1,4 @@
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { NzMessageService } from 'ng-zorro-antd/message';
@ -28,9 +28,9 @@ export class ImageLabel2Component implements OnInit {
}
ngAfterContentInit(): void {
this.getImgMarkData().then((res: any)=>{
this.getImgMarkData().then((res: any) => {
this.imgItem = window.URL.createObjectURL(res)
window.setTimeout(()=>{
window.setTimeout(() => {
this.initBackgroundImg()
}, 0)
}).catch(err => {
@ -38,21 +38,47 @@ export class ImageLabel2Component implements OnInit {
})
}
anewgetImg() {
this.route.queryParams.subscribe(parmas => {
let params = {
cameraId: parmas.id
}
this.http.put('/api/Cameras/Commands/CaptureImages', '', { params: params }).subscribe(
{
next: (value: Object) => {
// console.log(111, value)
this.message.create('success', '向边缘设备发送请求成功,请过一段时间手动刷新页面!');
},
error: (error: HttpErrorResponse) => {
},
complete: () => {
}
}
)
})
}
//获取 摄像头图片/标注点位
getImgMarkData() {
let that = this
return new Promise((resolve, reject) => {
that.route.queryParams.subscribe(parmas => {
that.http.get(`/api/Cameras/${parmas.id}`).subscribe((info: any)=>{
info.dimensionedPoints? info.dimensionedPoints = JSON.parse(info.dimensionedPoints) : null;
that.http.get(`/api/Cameras/${parmas.id}`).subscribe((info: any) => {
info.dimensionedPoints ? info.dimensionedPoints = JSON.parse(info.dimensionedPoints) : null;
that.camerasData = info;
that.markType = info.type;
console.log(that.camerasData,"摄像头数据")
console.log(that.camerasData, "摄像头数据")
const httpOptions = {
responseType: 'blob' as 'json',
params: {cameraId: parmas.id}
params: { cameraId: parmas.id }
};
that.http.get(`/api/Cameras/Images`,httpOptions).subscribe({
that.http.get(`/api/Cameras/Images`, httpOptions).subscribe({
next: (data) => {
resolve(data)
},
@ -70,7 +96,7 @@ export class ImageLabel2Component implements OnInit {
if (!this.camerasData.dimensionedPoints) {
this.camerasData.dimensionedPoints = {
polygon: [],
arrow : [],
arrow: [],
rectangle: [],
}
}
@ -81,7 +107,7 @@ export class ImageLabel2Component implements OnInit {
}
this.camerasData.dimensionedPoints.polygon = this.points
} else if (this.markType === 2) {
if (this.arrowPoints.length != 2 || this.oblongPoints.length != 2 || !this.oblongPoints.find(item=>{ return item.oilUnloadingArea }) || !this.oblongPoints.find(item=>{ return !item.oilUnloadingArea })) {
if (this.arrowPoints.length != 2 || this.oblongPoints.length != 2 || !this.oblongPoints.find(item => { return item.oilUnloadingArea }) || !this.oblongPoints.find(item => { return !item.oilUnloadingArea })) {
this.message.create('warning', '绘制完整后可保存!');
return
}
@ -96,7 +122,7 @@ export class ImageLabel2Component implements OnInit {
}
let paramsData = JSON.parse(JSON.stringify(this.camerasData))
paramsData.dimensionedPoints = JSON.stringify(paramsData.dimensionedPoints)
this.http.put(`/api/Cameras/${this.camerasData.id}`,paramsData).subscribe(data=>{
this.http.put(`/api/Cameras/${this.camerasData.id}`, paramsData).subscribe(data => {
this.message.create('success', '保存成功!');
})
}
@ -104,7 +130,7 @@ export class ImageLabel2Component implements OnInit {
//初始化背景图
initBackgroundImg() {
let canvas = document.getElementById('canvas') as any;
canvas.oncontextmenu = () =>{ return false; };
canvas.oncontextmenu = () => { return false; };
let that = this
let ctx
// 检测canvas支持性
@ -120,7 +146,7 @@ export class ImageLabel2Component implements OnInit {
// 图片加载完后,将其显示在canvas中
var img = new Image();
img.src = that.imgItem? that.imgItem : "../../../assets/images/bgImg.png";
img.src = that.imgItem ? that.imgItem : "../../../assets/images/bgImg.png";
img.onload = () => {
// 等比例缩放图片
var scale = 1;
@ -137,31 +163,31 @@ export class ImageLabel2Component implements OnInit {
}
that.canvasWidth = img.width * scale;
that.canvasHeight = img.height * scale; // 计算等比缩小后图片
window.setTimeout(()=>{ // 加载图片
window.setTimeout(() => { // 加载图片
ctx.drawImage(img, 0, 0, that.canvasWidth, that.canvasHeight);
this.copyCanvas = ctx.getImageData(0, 0, that.canvasWidth, that.canvasHeight)
that.initCanvasEvent(canvas) //监听canvas事件
that.initMark(canvas,ctx) //初始化标绘图形
that.initMark(canvas, ctx) //初始化标绘图形
}, 0)
}
}
//初始化标绘图形
initMark(canvas,context) {
initMark(canvas, context) {
if (!this.camerasData.dimensionedPoints) {
return
}
if (this.markType === 0) {
this.camerasData.dimensionedPoints.polygon.forEach(element => {
this.drawPolygon(element.x,element.y,canvas,context); //绘制多边形
this.drawPolygon(element.x, element.y, canvas, context); //绘制多边形
});
} else if (this.markType === 2) {
this.arrowPoints = this.camerasData.dimensionedPoints.arrow
this.oblongPoints = this.camerasData.dimensionedPoints.rectangle
this.drawLine(this.arrowPoints,context)
this.drawLine(this.arrowPoints, context)
} else if (this.markType === 3) {
this.arrowPoints = this.camerasData.dimensionedPoints.arrow
this.drawLine(this.arrowPoints,context)
this.drawLine(this.arrowPoints, context)
}
}
@ -195,50 +221,50 @@ export class ImageLabel2Component implements OnInit {
let context = canvas.getContext('2d');
context.clearRect(0, 0, canvas.width, canvas.height);
this.copyCanvas? context.putImageData(this.copyCanvas, 0, 0) : null;
this.copyCanvas ? context.putImageData(this.copyCanvas, 0, 0) : null;
}
//初始化 canvas画布 监听事件
initCanvasEvent(canvas) {
let context = canvas.getContext('2d');
canvas.onmousedown = (e)=>{ //鼠标按下事件
canvas.onmousedown = (e) => { //鼠标按下事件
var clickX = e.pageX - canvas.offsetLeft;
var clickY = e.pageY - canvas.offsetTop;
this.downx = clickX
this.downy = clickY
if (this.markType === 0) { //进出口
this.drawPolygon(clickX,clickY,canvas,context); //绘制多边形
this.drawPolygon(clickX, clickY, canvas, context); //绘制多边形
} else if (this.markType === 2 || this.markType === 3) { //卸油区/便利店
//开始绘制
context.beginPath();
context.moveTo(clickX,clickY);
context.moveTo(clickX, clickY);
context.strokeStyle = "green";
context.lineWidth = 3;
canvas.onmousemove = (ev)=>{ //鼠标移动事件
canvas.onmousemove = (ev) => { //鼠标移动事件
var moveX = ev.pageX - canvas.offsetLeft;
var moveY = ev.pageY - canvas.offsetTop;
if (this.isDrawArrow) { //绘制 箭头
if (this.arrowPoints.length === 2) { //限制数量
return
}
context.lineTo(moveX,moveY);
context.lineTo(moveX, moveY);
context.stroke();
} else { //绘制 矩形
if (this.oblongPoints.length === 2) { //限制数量
return
}
this.drawOblong(this.oblongPoints,context)
context.strokeStyle = this.oilUnloadingArea? "green" : "red";
let element = this.getOblongInfo(this.downx,this.downy,moveX,moveY)
context.strokeRect(element.x,element.y,element.width,element.height);
this.drawOblong(this.oblongPoints, context)
context.strokeStyle = this.oilUnloadingArea ? "green" : "red";
let element = this.getOblongInfo(this.downx, this.downy, moveX, moveY)
context.strokeRect(element.x, element.y, element.width, element.height);
}
}
}
}
canvas.onmouseup = (e)=>{ //鼠标松开事件
canvas.onmousemove = (ev)=>{ //鼠标移动事件
canvas.onmouseup = (e) => { //鼠标松开事件
canvas.onmousemove = (ev) => { //鼠标移动事件
return false;
}
if (this.markType != 2 && this.markType != 3) {
@ -258,15 +284,15 @@ export class ImageLabel2Component implements OnInit {
endY: upY,
}
this.arrowPoints.push(point);
this.drawLine(this.arrowPoints,context)
this.drawLine(this.arrowPoints, context)
} else { //绘制 矩形
if (this.oblongPoints.length === 2) { //限制数量
this.message.create('warning', '绘制数量已达上限!');
return
}
let point = this.getOblongInfo(this.downx,this.downy,upX,upY)
let point = this.getOblongInfo(this.downx, this.downy, upX, upY)
this.oblongPoints.push(point)
this.drawOblong(this.oblongPoints,context)
this.drawOblong(this.oblongPoints, context)
}
};
@ -277,23 +303,23 @@ export class ImageLabel2Component implements OnInit {
//canvas 绘制直线
drawLine(pointsList, context, isRepeat: boolean = false) {
context.clearRect(0, 0, this.canvasWidth, this.canvasHeight);
this.copyCanvas? context.putImageData(this.copyCanvas, 0, 0) : null;
this.copyCanvas ? context.putImageData(this.copyCanvas, 0, 0) : null;
if (this.markType === 2 && !isRepeat) { //同时绘制 矩形
this.oblongPoints.forEach(element => {
context.strokeStyle = element.oilUnloadingArea? "green" : "red";
context.strokeStyle = element.oilUnloadingArea ? "green" : "red";
context.lineWidth = 3;
context.strokeRect(element.x,element.y,element.width,element.height);
context.strokeRect(element.x, element.y, element.width, element.height);
});
}
pointsList.forEach((item,index)=>{
if ((index+1)%2 === 0) {
this.drawArrow(item.startX,item.startY,item.endX,item.endY,30,10,3,'green',context)
pointsList.forEach((item, index) => {
if ((index + 1) % 2 === 0) {
this.drawArrow(item.startX, item.startY, item.endX, item.endY, 30, 10, 3, 'green', context)
} else {
context.beginPath();
context.moveTo(item.startX,item.startY);
context.moveTo(item.startX, item.startY);
context.strokeStyle = "green";
context.lineWidth = 3;
context.lineTo(item.endX,item.endY);
context.lineTo(item.endX, item.endY);
context.stroke();
}
})
@ -308,10 +334,10 @@ export class ImageLabel2Component implements OnInit {
// width:箭头线宽度
// color:箭头颜色
theta = typeof(theta) != 'undefined' ? theta : 30;
headlen = typeof(theta) != 'undefined' ? headlen : 10;
width = typeof(width) != 'undefined' ? width : 1;
color = typeof(color) != 'undefined' ? color : '#000';
theta = typeof (theta) != 'undefined' ? theta : 30;
headlen = typeof (theta) != 'undefined' ? headlen : 10;
width = typeof (width) != 'undefined' ? width : 1;
color = typeof (color) != 'undefined' ? color : '#000';
// 计算各角度和对应的P2,P3坐标
var angle = Math.atan2(fromY - toY, fromX - toX) * 180 / Math.PI,
@ -325,7 +351,7 @@ export class ImageLabel2Component implements OnInit {
ctx.beginPath();
var arrowX = fromX - topX,
arrowY = fromY - topY;
arrowY = fromY - topY;
ctx.moveTo(arrowX, arrowY);
ctx.moveTo(fromX, fromY);
@ -346,7 +372,7 @@ export class ImageLabel2Component implements OnInit {
oblongPoints = []; //矩形的点的集合
//获取 矩形左上角点位/宽高
getOblongInfo(startX,startY,endX,endY) {
getOblongInfo(startX, startY, endX, endY) {
let point = {
x: 0,
y: 0,
@ -374,14 +400,14 @@ export class ImageLabel2Component implements OnInit {
//canvas 绘制矩形
drawOblong(oblongList, context) {
context.clearRect(0, 0, this.canvasWidth, this.canvasHeight);
this.copyCanvas? context.putImageData(this.copyCanvas, 0, 0) : null;
this.copyCanvas ? context.putImageData(this.copyCanvas, 0, 0) : null;
if (this.markType === 2) { //同时绘制 直线箭头
this.drawLine(this.arrowPoints,context,true)
this.drawLine(this.arrowPoints, context, true)
}
oblongList.forEach(element => {
context.strokeStyle = element.oilUnloadingArea? "green" : "red";
context.strokeStyle = element.oilUnloadingArea ? "green" : "red";
context.lineWidth = 3;
context.strokeRect(element.x,element.y,element.width,element.height);
context.strokeRect(element.x, element.y, element.width, element.height);
});
}
@ -418,7 +444,7 @@ export class ImageLabel2Component implements OnInit {
}
//如果点击新的位置,则进入下面的代码,绘制点
context.clearRect(0, 0, canvas.width, canvas.height);
this.copyCanvas? context.putImageData(this.copyCanvas, 0, 0) : null;
this.copyCanvas ? context.putImageData(this.copyCanvas, 0, 0) : null;
//遍历数组画圆
var circle = {
x: clickX,

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

@ -36,8 +36,9 @@ import { ImageLabel2Component } from './image-label2/image-label2.component';
import { ConfigFormComponent } from './config-form/config-form.component';
import { NzTabsModule } from 'ng-zorro-antd/tabs';
import { ConditionMonitoringComponent } from './condition-monitoring/condition-monitoring.component';
import { SendFileComponent } from './host-config/send-file/send-file.component';
@NgModule({
declarations: [OrganizationComponent, NavigationComponent, AddorComponent, EditorComponent, AnalysisOfTheHostComponent, AddhostComponent, EdithostComponent, AddcameraComponent, EditcameraComponent, HostConfigComponent, ImageListComponent, ImageLabelComponent, PlottingImageComponent, cameraType, ImageLabel2Component, ConfigFormComponent, ConditionMonitoringComponent],
declarations: [OrganizationComponent, NavigationComponent, AddorComponent, EditorComponent, AnalysisOfTheHostComponent, AddhostComponent, EdithostComponent, AddcameraComponent, EditcameraComponent, HostConfigComponent, ImageListComponent, ImageLabelComponent, PlottingImageComponent, cameraType, ImageLabel2Component, ConfigFormComponent, ConditionMonitoringComponent, SendFileComponent],
imports: [
CommonModule,
SystemRoutingModule,
@ -61,7 +62,7 @@ import { ConditionMonitoringComponent } from './condition-monitoring/condition-m
NzPageHeaderModule,
NzTabsModule
],
entryComponents: [AddorComponent, EditorComponent, AddhostComponent, EdithostComponent, AddcameraComponent, EditcameraComponent]
entryComponents: [AddorComponent, EditorComponent, AddhostComponent, EdithostComponent, AddcameraComponent, EditcameraComponent, SendFileComponent]
})
export class SystemManagementModule { }

Loading…
Cancel
Save