From 81b360d52b06468ffd67737c01c76eb766272638 Mon Sep 17 00:00:00 2001 From: zhouyuejun <505127606@qq.com> Date: Fri, 18 Jan 2019 10:58:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=A4=84=E7=90=86=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=96=B9=E5=BC=8F=E5=8F=8A=E9=83=A8=E5=88=86=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8F=90=E7=A4=BA=E8=AF=AD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/detail-tab/detail-tab.component.html | 2 +- src/app/pages/main/main.component.ts | 134 +++--------------- .../main/related-tab/related-tab.component.ts | 10 +- src/app/utils/alert-message-handle.ts | 51 ++++--- src/app/utils/web-worker-handle.ts | 36 ++++- src/assets/web-worker-handle.js | 37 ++++- 6 files changed, 127 insertions(+), 143 deletions(-) diff --git a/src/app/pages/main/detail-tab/detail-tab.component.html b/src/app/pages/main/detail-tab/detail-tab.component.html index 64a4fb0..e01f9fb 100644 --- a/src/app/pages/main/detail-tab/detail-tab.component.html +++ b/src/app/pages/main/detail-tab/detail-tab.component.html @@ -19,7 +19,7 @@
资源类 -----------------------------------------

{{showPsst}}

-

{{singleFlight.GATE}}

+

{{singleFlight.GTDT}}

{{singleFlight.CHKC}}

{{singleFlight.CHUT}}

diff --git a/src/app/pages/main/main.component.ts b/src/app/pages/main/main.component.ts index 250349d..ef76506 100644 --- a/src/app/pages/main/main.component.ts +++ b/src/app/pages/main/main.component.ts @@ -319,8 +319,6 @@ export class MainComponent implements OnInit { */ calcVisibleCount() { this.renderer2.setStyle(this.tableContainer.nativeElement, 'height', this.pageContent.nativeElement.offsetHeight - this.searchFilter.nativeElement.offsetHeight - 35 + 'px'); - // console.log(this.tableContainer.nativeElement.offsetHeight); - // console.log(this.tableHead.nativeElement.offsetHeight); this.renderer2.setStyle(this.tableBody.nativeElement, 'height', this.tableContainer.nativeElement.offsetHeight - this.tableHead.nativeElement.offsetHeight + 'px'); if (!this.tabClose) { this.renderer2.setStyle(this.tabContainer.nativeElement, 'height', this.pageContent.nativeElement.offsetHeight - this.searchFilter.nativeElement.offsetHeight - 35 + 'px'); @@ -425,33 +423,18 @@ export class MainComponent implements OnInit { * @param message */ dynamicMessageHandle(message) { - let index = this.raw_data.findIndex(element => element['FLID'] === message.FLID); - if (index > -1) { - this.raw_data[index] = message; - } else { - this.raw_data.push(message); - } - - if (this.airlinesSelections.findIndex(airline => airline.airlineCodeIata === message['ALCD']) === -1) { - let index = this.airlines.findIndex(val => val.airlineCodeIata === message['ALCD']); - this.airlinesSelections.push(this.airlines[index]); - } - - if (this.flightTypeSelections.findIndex(flightType => flightType.flightTypeCode === message['FLTY']) === -1) { - let index = this.flightTypes.findIndex(val => val.flightTypeCode === message['FLTY']); - this.flightTypeSelections.push(this.flightTypes[index]); - } - - this.creatWorkers(); - + this.creatWorkers(message); } /** * 创建线程并执行 */ public promise: Worker = new Worker('/adminweb/assets/web-worker-handle.js'); - creatWorkers() { + creatWorkers(message?) { let dynamicData = { + message: message, + airlinesSelections: this.airlinesSelections, + flightTypeSelections: this.flightTypeSelections, raw_data: this.raw_data, col_lists: this.col_lists, airports: this.airports, @@ -462,12 +445,18 @@ export class MainComponent implements OnInit { } this.promise.postMessage(dynamicData); this.promise.onmessage = function (e) { - this.combined_data = e.data; + this.combined_data = e.data.combined_data; + this.raw_data = e.data.raw_data; + this.airlinesSelections = e.data.airlinesSelections; + this.flightTypeSelections = e.data.flightTypeSelections; this.selectChange('dynamic'); }.bind(this); // const promise = this.webWorkerService.run(webWorkerHandle, dynamicData); // promise.then(function (response) { - // this.combined_data = response; + // this.combined_data = response.combined_data; + // this.raw_data = response.raw_data; + // this.airlinesSelections = response.airlinesSelections; + // this.flightTypeSelections = response.flightTypeSelections; // this.selectChange('dynamic'); // this.webWorkerService.terminate(promise); // }.bind(this)); @@ -602,28 +591,7 @@ export class MainComponent implements OnInit { is_satis = false; break; } - } - // else if (key === 'Start_time') { - // let planTime = new Date(dateFormatter(item['preFlight']['SODT'])).getTime(); - // let nowTime = new Date().getTime(); - // if (nowTime - planTime >= +filterItems[key] * 60 * 60 * 1000 || nowTime - planTime < 0) { - // is_satis = false; - // break; - // } else { - // is_satis = true; - // continue; - // } - // } else if (key === 'End_time') { - // let planTime = new Date(dateFormatter(item['preFlight']['SODT'])).getTime(); - // let nowTime = new Date().getTime(); - // if (planTime - nowTime > +filterItems[key] * 60 * 60 * 1000 || planTime - nowTime < 0) { - // is_satis = false; - // break; - // } else { - // is_satis = true; - // continue; - // } - // } + } else { if (item['preFlight'][key] == filterItems[key]) { is_satis = true; @@ -649,28 +617,7 @@ export class MainComponent implements OnInit { break; } } - // else if (key === 'Start_time') { - // let planTime = new Date(dateFormatter(item['reaFlight']['SODT'])).getTime(); - // let nowTime = new Date().getTime(); - // if (nowTime - planTime > +filterItems[key] * 60 * 60 * 1000 || nowTime - planTime < 0) { - // is_satis = false; - // break; - // } else { - // is_satis = true; - // continue; - // } - // } else if (key === 'End_time') { - // let planTime = new Date(dateFormatter(item['reaFlight']['SODT'])).getTime(); - // let nowTime = new Date().getTime(); - // if (planTime - nowTime > +filterItems[key] * 60 * 60 * 1000 || planTime - nowTime < 0) { - // is_satis = false; - // break; - // } else { - // is_satis = true; - // continue; - // } - // } - else { + else { if (item['reaFlight'][key] == filterItems[key]) { is_satis = true; continue; @@ -695,28 +642,7 @@ export class MainComponent implements OnInit { pre_satis = false; break; } - } - // else if (key === 'Start_time') { - // let planTime = new Date(dateFormatter(item['preFlight']['SODT'])).getTime(); - // let nowTime = new Date().getTime(); - // if (nowTime - planTime > +filterItems[key] * 60 * 60 * 1000 || nowTime - planTime < 0) { - // pre_satis = false; - // break; - // } else { - // pre_satis = true; - // continue; - // } - // } else if (key === 'End_time') { - // let planTime = new Date(dateFormatter(item['preFlight']['SODT'])).getTime(); - // let nowTime = new Date().getTime(); - // if (planTime - nowTime > +filterItems[key] * 60 * 60 * 1000 || planTime - nowTime < 0) { - // pre_satis = false; - // break; - // } else { - // pre_satis = true; - // continue; - // } - // } + } else { if (item['preFlight'][key] == filterItems[key]) { pre_satis = true; @@ -738,28 +664,7 @@ export class MainComponent implements OnInit { rea_satis = false; break; } - } - // else if (key === 'Start_time') { - // let planTime = new Date(dateFormatter(item['reaFlight']['SODT'])).getTime(); - // let nowTime = new Date().getTime(); - // if (nowTime - planTime > +filterItems[key] * 60 * 60 * 1000 || nowTime - planTime < 0) { - // rea_satis = false; - // break; - // } else { - // rea_satis = true; - // continue; - // } - // } else if (key === 'End_time') { - // let planTime = new Date(dateFormatter(item['reaFlight']['SODT'])).getTime(); - // let nowTime = new Date().getTime(); - // if (planTime - nowTime > +filterItems[key] * 60 * 60 * 1000 || planTime - nowTime < 0) { - // rea_satis = false; - // break; - // } else { - // rea_satis = true; - // continue; - // } - // } + } else { if (item['reaFlight'][key] == filterItems[key]) { rea_satis = true; @@ -1051,9 +956,10 @@ export class MainComponent implements OnInit { if (this.orderHandle.isArriFlight(flight)) { return false; } else { + let reaDelay = flight['reaFlight']['DELY']; try { - if (flight['reaFlight']['DELY'] && Array.isArray(flight['reaFlight']['DELY']) && flight['reaFlight']['DELY'].length > 0) { - if (parseInt(flight['preFlight']['DELY'][0]['DURA']) - 30 > 0) { + if (reaDelay && Array.isArray(reaDelay) && reaDelay.length > 0) { + if (parseInt(reaDelay[reaDelay.length - 1]['DURA']) - 30 > 0) { return true; } else { return false; diff --git a/src/app/pages/main/related-tab/related-tab.component.ts b/src/app/pages/main/related-tab/related-tab.component.ts index 1b4dd82..d89e41b 100644 --- a/src/app/pages/main/related-tab/related-tab.component.ts +++ b/src/app/pages/main/related-tab/related-tab.component.ts @@ -26,7 +26,7 @@ export class RelatedTabComponent implements OnInit { this.precancle = ''; this.prefdiv = ''; this.prefret = ''; - + this.readelay = ''; this.reacancle = ''; this.reafdiv = ''; @@ -60,11 +60,12 @@ export class RelatedTabComponent implements OnInit { let fretIndex = this.lines.preFlight['ABN'].findIndex(ele => ele.TYPE === 'RTN'); if (delyIndex > -1) { - this.predelay = this.lines.preFlight['ABN'][delyIndex].BODY; + let delyMessage = this.lines.preFlight['ABN'][delyIndex].BODY + this.predelay = delyMessage[delyMessage.length - 1]; this.predelay['STRT'] = new Date(dateFormatter(this.predelay['STRT'])).getTime(); this.predelay['DURA'] = parseInt(this.predelay['DURA'].substr(0, 2)) * 3600000 + parseInt(this.predelay['DURA'].substr(2, 3)) * 60000 + this.predelay['STRT'] } - if (cancleIndex > -1) { + if (cancleIndex > -1) { this.precancle = this.lines.preFlight['ABN'][cancleIndex].BODY; this.precancle = new Date(dateFormatter(this.precancle)).getTime(); } @@ -86,7 +87,8 @@ export class RelatedTabComponent implements OnInit { let fretIndex = this.lines.reaFlight['ABN'].findIndex(ele => ele.TYPE === 'RTN'); if (delyIndex > -1) { - this.readelay = this.lines.reaFlight['ABN'][delyIndex].BODY; + let delyMessage = this.lines.reaFlight['ABN'][delyIndex].BODY + this.readelay = delyMessage[delyMessage.length - 1]; this.readelay['STRT'] = new Date(dateFormatter(this.readelay['STRT'])).getTime(); this.readelay['DURA'] = parseInt(this.readelay['DURA'].substr(0, 2)) * 3600000 + parseInt(this.readelay['DURA'].substr(2, 3)) * 60000 + this.readelay['STRT']; } diff --git a/src/app/utils/alert-message-handle.ts b/src/app/utils/alert-message-handle.ts index 3ad6f98..55072ea 100644 --- a/src/app/utils/alert-message-handle.ts +++ b/src/app/utils/alert-message-handle.ts @@ -25,19 +25,19 @@ export class AlertMessageHandle { // } public flopCncl(message, airports) { - if(message.FLOP.CNCL){ + if (message.FLOP.CNCL) { return message.FLOP.FFID + '航班取消'; - }else{ + } else { return message.FLOP.FFID + '航班恢复'; } } public flopFret(message, airports) { if (message.FLOP.FRET.REID === 'G') { - return message.FLOP.FFID + '航班从地面返回,返回原因:' + message.FLOP.FRET.content || message.FLOP.FRET.VALUE; + return message.FLOP.FFID + '航班从地面返回,返回原因:' + (message.FLOP.FRET.content || message.FLOP.FRET.VALUE); } else if (message.FLOP.FRET.REID === 'A') { - return message.FLOP.FFID + '航班从空中返回,返回原因:' + message.FLOP.FRET.content || message.FLOP.FRET.VALUE; + return message.FLOP.FFID + '航班从空中返回,返回原因:' + (message.FLOP.FRET.content || message.FLOP.FRET.VALUE); } else { - return message.FLOP.FFID + '航班从空中或地面返回,返回原因:' + message.FLOP.FRET.content || message.FLOP.FRET.VALUE; + return message.FLOP.FFID + '航班从空中或地面返回,返回原因:' + (message.FLOP.FRET.content || message.FLOP.FRET.VALUE); } } public flopFdiv(message, airports) { @@ -47,24 +47,37 @@ export class AlertMessageHandle { airportName = airports[index].airportNameChn; } if (message.FLOP.FDIV.DDIR === 'FROM') { - return message.FLOP.FFID + '航班备降自' + airportName + ',备降原因:' + message.FLOP.FDIV.content || message.FLOP.FDIV.VALUE; + return message.FLOP.FFID + '航班备降自' + airportName + ',备降原因:' + (message.FLOP.FDIV.content || message.FLOP.FDIV.VALUE); } else if (message.FLOP.FDIV.DDIR === 'TO') { - return message.FLOP.FFID + '航班备降到' + airportName + ',备降原因:' + message.FLOP.FDIV.content || message.FLOP.FDIV.VALUE; + return message.FLOP.FFID + '航班备降到' + airportName + ',备降原因:' + (message.FLOP.FDIV.content || message.FLOP.FDIV.VALUE); } else { - return message.FLOP.FFID + '航班备降,备降原因:' + message.FLOP.FDIV.content || message.FLOP.FDIV.VALUE; + return message.FLOP.FFID + '航班备降,备降原因:' + (message.FLOP.FDIV.content || message.FLOP.FDIV.VALUE); } } public flopFdel(message, airports) { return message.FLOP.FFID + '航班被删除了' } public flopDely(message, airports) { - return message.FLOP.FFID + '航班延误' + message.FLOP.DELY.DURA + '分钟;延误码:' + message.FLOP.DELY.CODE + ';延误信息:' + message.FLOP.DELY.content || message.FLOP.DELY.VALUE + let delyArray = message.FLOP.DELY; + let delyMessage = delyArray[delyArray.length - 1]; + return message.FLOP.FFID + '航班延误' + (parseInt(delyMessage.DURA.substr(0, 2)) * 60 + parseInt(delyMessage.DURA.substr(2, 3))) + '分钟;延误码:' + delyMessage.CODE + '; 延误信息:' + (delyMessage.content || delyMessage.VALUE) } public flopActt(message, airports) { return message.FLOP.FFID + '航班实际时间:' + dateFormatter(message.FLOP.ACTT); } public flopGtdt(message, airports) { - return message.FLOP.FFID + '登机门分配为:' + message.FLOP.GTDT.GATE + if (Array.isArray(message.FLOP['GTDT']) && message.FLOP['GTDT'].length > 0) { + let gate = []; + for (let i = 0; i < message.FLOP['GTDT'].length; i++) { + gate.push(message.FLOP['GTDT'][i]['GATE']); + } + let set = new Set(gate); + return message.FLOP.FFID + '登机门分配为:' + Array.from(set).join(','); + } else if (Object.prototype.toString.call(message.FLOP['GTDT']) === '[object Object]') { + return message.FLOP.FFID + '登机门分配为:' + message.FLOP['GTDT']['GATE']; + } else { + return message.FLOP.FFID + '登机门分配为:'; + } } public flopPsdt(message, airports) { if (Array.isArray(message.FLOP['PSDT']) && message.FLOP['PSDT'].length > 0) { @@ -140,27 +153,27 @@ export class AlertMessageHandle { return message.FLOP.FFID + '航线更改为:' + rout.join(' - '); } public flopVipp(message, airports, citys) { - return message.FLOP.FFID + 'VIP旅客:' + message.FLOP.VIPP + '人'; + return message.FLOP.FFID + 'VIP旅客:' + (message.FLOP.VIPP || ''); } public flopHnag() { return '航班代理事件'; } - public flopFlbg(message,airports,citys) { + public flopFlbg(message, airports, citys) { return message.FLOP.FFID + '首末件行李到达时间消息'; } - public flopReno(message,airports,citys) { - return message.FLOP.FFID + '更换飞机号:' + message.FLOP.RENO; + public flopReno(message, airports, citys) { + return message.FLOP.FFID + '更换飞机号:' + message.FLOP.RENO; } - public flopAbtm(message,airports,citys) { + public flopAbtm(message, airports, citys) { return message.FLOP.FFID + '靠桥撤桥消息'; } - public flopChot(message,airports,citys) { + public flopChot(message, airports, citys) { return message.FLOP.FFID + '上下轮档消息'; } - public flopTrml(message,airports,citys) { - return message.FLOP.FFID + '航站楼:' + message.FLOP.TRML; + public flopTrml(message, airports, citys) { + return message.FLOP.FFID + '航站楼:' + message.FLOP.TRML; } - public schdDnld(message,airports,citys){ + public schdDnld(message, airports, citys) { return '收到日航班计划'; } } \ No newline at end of file diff --git a/src/app/utils/web-worker-handle.ts b/src/app/utils/web-worker-handle.ts index a29bf91..c91771c 100644 --- a/src/app/utils/web-worker-handle.ts +++ b/src/app/utils/web-worker-handle.ts @@ -1,4 +1,4 @@ -export default function (dynamicData) { +export default function (dynamicData?) { if (typeof Object.assign != 'function') { // Must be writable: true, enumerable: false, configurable: true Object.defineProperty(Object, "assign", { @@ -30,13 +30,38 @@ export default function (dynamicData) { } - let raw_data = dynamicData.raw_data, + let messageArray = dynamicData.message, + airlinesSelections = dynamicData.airlinesSelections, + flightTypeSelections = dynamicData.flightTypeSelections, + raw_data = dynamicData.raw_data, col_lists = dynamicData.col_lists, airports = dynamicData.airports, citys = dynamicData.citys, airlines = dynamicData.airlines, flightStatus = dynamicData.flightStatus, flightTypes = dynamicData.flightTypes + + + if (messageArray && Array.isArray(messageArray) && messageArray.length > 0) { + messageArray.forEach(message => { + let index = raw_data.findIndex(element => element['FLID'] === message.FLID); + if (index > -1) { + raw_data[index] = message; + } else { + raw_data.push(message); + } + + if (airlinesSelections.findIndex(airline => airline.airlineCodeIata === message['ALCD']) === -1) { + let index = airlines.findIndex(val => val.airlineCodeIata === message['ALCD']); + airlinesSelections.push(airlines[index]); + } + + if (flightTypeSelections.findIndex(flightType => flightType.flightTypeCode === message['FLTY']) === -1) { + let index = flightTypes.findIndex(val => val.flightTypeCode === message['FLTY']); + flightTypeSelections.push(flightTypes[index]); + } + }) + } /** * 时间转换 * @param dataString @@ -1101,5 +1126,10 @@ export default function (dynamicData) { return (a['ORDER'] - b['ORDER']); }) - return combined_data; + return { + "raw_data": raw_data, + "airlinesSelections": airlinesSelections, + "flightTypeSelections": flightTypeSelections, + "combined_data": combined_data, + }; } \ No newline at end of file diff --git a/src/assets/web-worker-handle.js b/src/assets/web-worker-handle.js index 6550f6d..4eb434c 100644 --- a/src/assets/web-worker-handle.js +++ b/src/assets/web-worker-handle.js @@ -30,13 +30,39 @@ onmessage = function (dynamicData) { } - let raw_data = dynamicData.data.raw_data, + let messageArray = dynamicData.data.message, + airlinesSelections = dynamicData.data.airlinesSelections, + flightTypeSelections = dynamicData.data.flightTypeSelections, + raw_data = dynamicData.data.raw_data, col_lists = dynamicData.data.col_lists, airports = dynamicData.data.airports, citys = dynamicData.data.citys, airlines = dynamicData.data.airlines, flightStatus = dynamicData.data.flightStatus, flightTypes = dynamicData.data.flightTypes + + + if (messageArray && Array.isArray(messageArray) && messageArray.length > 0) { + messageArray.forEach(message => { + let index = raw_data.findIndex(element => element['FLID'] === message.FLID); + if (index > -1) { + raw_data[index] = message; + } else { + raw_data.push(message); + } + + if (airlinesSelections.findIndex(airline => airline.airlineCodeIata === message['ALCD']) === -1) { + let index = airlines.findIndex(val => val.airlineCodeIata === message['ALCD']); + airlinesSelections.push(airlines[index]); + } + + if (flightTypeSelections.findIndex(flightType => flightType.flightTypeCode === message['FLTY']) === -1) { + let index = flightTypes.findIndex(val => val.flightTypeCode === message['FLTY']); + flightTypeSelections.push(flightTypes[index]); + } + }) + } + /** * 时间转换 * @param dataString @@ -1102,5 +1128,12 @@ onmessage = function (dynamicData) { return (a['ORDER'] - b['ORDER']); }) - postMessage(combined_data); + postMessage( + { + "raw_data":raw_data, + "airlinesSelections":airlinesSelections, + "flightTypeSelections":flightTypeSelections, + "combined_data": combined_data, + } + ); } \ No newline at end of file