优化worker处理及航线修改为简称
This commit is contained in:
@@ -145,7 +145,6 @@ export class MainComponent implements OnInit {
|
||||
console.log(message);
|
||||
//是否可以开始处理动态消息
|
||||
if (this.canHandleDynamicMessage) {
|
||||
// this.webWorkerService.terminate(promise);
|
||||
this.dynamicMessageHandle(message);
|
||||
} else {
|
||||
this.dynamicMessageArray.push(message);
|
||||
@@ -328,7 +327,8 @@ export class MainComponent implements OnInit {
|
||||
this.visibleCount = Math.ceil(this.tableBody.nativeElement.clientHeight / this.trItemHeight);
|
||||
const scrollTop = this.tableBody.nativeElement.scrollTop;
|
||||
const fixedScrollTop = scrollTop - scrollTop % this.trItemHeight;
|
||||
this.tableContent.nativeElement.style.webkitTransform = `translateY(${fixedScrollTop}px)`;
|
||||
this.tableContent.nativeElement.style.transform = `translateY(${fixedScrollTop}px)`;
|
||||
|
||||
this.start = Math.floor(scrollTop / this.trItemHeight);
|
||||
this.end = this.start + this.visibleCount;
|
||||
this.render_data = this.wait_render_data.slice(this.start, this.end);
|
||||
@@ -463,6 +463,14 @@ export class MainComponent implements OnInit {
|
||||
this.flightTypeSelections.push(this.flightTypes[index]);
|
||||
}
|
||||
|
||||
this.creatWorkers();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建线程并执行
|
||||
*/
|
||||
creatWorkers() {
|
||||
let dynamicData = {
|
||||
raw_data: this.raw_data,
|
||||
col_lists: this.col_lists,
|
||||
@@ -472,10 +480,19 @@ export class MainComponent implements OnInit {
|
||||
flightStatus: this.flightStatus,
|
||||
flightTypes: this.flightTypes
|
||||
}
|
||||
// const promise = new Worker('/assets/web-worker-handle.js');
|
||||
// promise.postMessage(dynamicData);
|
||||
// promise.onmessage = function (e) {
|
||||
// console.log('=====');
|
||||
// this.combined_data = e.data;
|
||||
// this.selectChange('dynamic');
|
||||
// // promise.terminate();
|
||||
// }.bind(this);
|
||||
const promise = this.webWorkerService.run(webWorkerHandle, dynamicData);
|
||||
promise.then(function (response) {
|
||||
this.combined_data = response;
|
||||
this.selectChange('dynamic');
|
||||
this.webWorkerService.terminate(promise);
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
@@ -503,13 +520,20 @@ export class MainComponent implements OnInit {
|
||||
'FLOP-FLBG': this.alertMessageHandle.flopFlbg.bind(this.alertMessageHandle),
|
||||
'FLOP-RENO': this.alertMessageHandle.flopReno.bind(this.alertMessageHandle),
|
||||
'FLOP-ABTM': this.alertMessageHandle.flopAbtm.bind(this.alertMessageHandle),
|
||||
'FLOP-CHDT': this.alertMessageHandle.flopChdt.bind(this.alertMessageHandle),
|
||||
'FLOP-CHOT': this.alertMessageHandle.flopChot.bind(this.alertMessageHandle),
|
||||
'FLOP-TRML': this.alertMessageHandle.flopTrml.bind(this.alertMessageHandle),
|
||||
}
|
||||
dynamicAlertHandle(message) {
|
||||
let alertType = message.META.TYPE + '-' + message.META.STYP;
|
||||
let index = this.airline_message_alert.findIndex(val => val['COL_CODE'] === alertType);
|
||||
if (index > -1) {
|
||||
if (alertType === 'FLOP-FDEL') {
|
||||
let index = this.raw_data.findIndex(element => element['FLID'] === message.FLOP.FLID);
|
||||
if (index > -1) {
|
||||
this.raw_data.splice(index, 1);
|
||||
this.creatWorkers()
|
||||
}
|
||||
}
|
||||
let alertText = this.alertMessage[alertType](message, this.airports);
|
||||
const toastCfg = new ToastConfig(ToastType.SUCCESS, '', alertText, 600000);
|
||||
this.toastService.toast(toastCfg);
|
||||
@@ -576,7 +600,7 @@ export class MainComponent implements OnInit {
|
||||
for (const key in filterItems) {
|
||||
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
|
||||
if (key === 'Abnormal_state') {
|
||||
if (item['preFlight'][filterItems[key]]) {
|
||||
if (item['preFlight'][filterItems[key]] && item['preFlight'][filterItems[key]].length > 0) {
|
||||
is_satis = true;
|
||||
continue;
|
||||
} else {
|
||||
@@ -620,7 +644,7 @@ export class MainComponent implements OnInit {
|
||||
for (const key in filterItems) {
|
||||
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
|
||||
if (key === 'Abnormal_state') {
|
||||
if (item['reaFlight'][filterItems[key]]) {
|
||||
if (item['reaFlight'][filterItems[key]] && item['reaFlight'][filterItems[key]].length > 0) {
|
||||
is_satis = true;
|
||||
continue;
|
||||
} else {
|
||||
@@ -665,7 +689,7 @@ export class MainComponent implements OnInit {
|
||||
for (const key in filterItems) {
|
||||
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
|
||||
if (key === 'Abnormal_state') {
|
||||
if (item['preFlight'][filterItems[key]]) {
|
||||
if (item['preFlight'][filterItems[key]] && item['preFlight'][filterItems[key]].length > 0) {
|
||||
pre_satis = true;
|
||||
continue;
|
||||
} else {
|
||||
@@ -706,7 +730,7 @@ export class MainComponent implements OnInit {
|
||||
for (const key in filterItems) {
|
||||
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
|
||||
if (key === 'Abnormal_state') {
|
||||
if (item['reaFlight'][filterItems[key]]) {
|
||||
if (item['reaFlight'][filterItems[key]] && item['reaFlight'][filterItems[key]].length > 0) {
|
||||
rea_satis = true;
|
||||
continue;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user