动态消息处理转为webWorker处理
This commit is contained in:
Generated
+96
@@ -809,6 +809,11 @@
|
||||
"integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=",
|
||||
"dev": true
|
||||
},
|
||||
"angular-in-memory-web-api": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "http://registry.npm.taobao.org/angular-in-memory-web-api/download/angular-in-memory-web-api-0.7.0.tgz",
|
||||
"integrity": "sha1-pupM96oNHtw2ndQfJsh+eFRgw9M="
|
||||
},
|
||||
"ansi-colors": {
|
||||
"version": "3.2.3",
|
||||
"resolved": "http://registry.npm.taobao.org/ansi-colors/download/ansi-colors-3.2.3.tgz",
|
||||
@@ -6014,6 +6019,92 @@
|
||||
"resolved": "http://registry.npm.taobao.org/ngx-color-picker/download/ngx-color-picker-7.2.0.tgz",
|
||||
"integrity": "sha1-l8s/MWQXYuyOKMgZ76nMUD4J9go="
|
||||
},
|
||||
"ngx-web-worker": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "http://registry.npm.taobao.org/ngx-web-worker/download/ngx-web-worker-7.0.0.tgz",
|
||||
"integrity": "sha1-bzMQnhXuQaGeNYKqnEh/81bpeJE=",
|
||||
"requires": {
|
||||
"@angular/common": "7.2.0",
|
||||
"@angular/compiler": "7.2.0",
|
||||
"@angular/core": "7.2.0",
|
||||
"@angular/forms": "7.2.0",
|
||||
"@angular/http": "7.2.0",
|
||||
"@angular/platform-browser": "7.2.0",
|
||||
"@angular/platform-browser-dynamic": "7.2.0",
|
||||
"@angular/router": "7.2.0",
|
||||
"angular-in-memory-web-api": "0.7.0",
|
||||
"core-js": "2.6.1",
|
||||
"rxjs": "6.3.3",
|
||||
"systemjs": "2.1.1",
|
||||
"zone.js": "0.8.26"
|
||||
},
|
||||
"dependencies": {
|
||||
"@angular/common": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "http://registry.npm.taobao.org/@angular/common/download/@angular/common-7.2.0.tgz",
|
||||
"integrity": "sha1-C/D2/ZjvRSiFSjyn8fG3X505zTQ=",
|
||||
"requires": {
|
||||
"tslib": "1.9.3"
|
||||
}
|
||||
},
|
||||
"@angular/compiler": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "http://registry.npm.taobao.org/@angular/compiler/download/@angular/compiler-7.2.0.tgz",
|
||||
"integrity": "sha1-vK9oL3HVAdtgV+U/BEq4XUG2SPA=",
|
||||
"requires": {
|
||||
"tslib": "1.9.3"
|
||||
}
|
||||
},
|
||||
"@angular/core": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "http://registry.npm.taobao.org/@angular/core/download/@angular/core-7.2.0.tgz",
|
||||
"integrity": "sha1-eVc/5mviigR8pDSOhwVm4y5P+OI=",
|
||||
"requires": {
|
||||
"tslib": "1.9.3"
|
||||
}
|
||||
},
|
||||
"@angular/forms": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "http://registry.npm.taobao.org/@angular/forms/download/@angular/forms-7.2.0.tgz",
|
||||
"integrity": "sha1-gJTXlUfMHZ2uBULNQn2McJVlBMI=",
|
||||
"requires": {
|
||||
"tslib": "1.9.3"
|
||||
}
|
||||
},
|
||||
"@angular/http": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "http://registry.npm.taobao.org/@angular/http/download/@angular/http-7.2.0.tgz",
|
||||
"integrity": "sha1-qjqBIU+bNSbKr1kbiX8QW+MnIOw=",
|
||||
"requires": {
|
||||
"tslib": "1.9.3"
|
||||
}
|
||||
},
|
||||
"@angular/platform-browser": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "http://registry.npm.taobao.org/@angular/platform-browser/download/@angular/platform-browser-7.2.0.tgz",
|
||||
"integrity": "sha1-8v1zwQ4hM5lqxXXcb3FeLkEMn7o=",
|
||||
"requires": {
|
||||
"tslib": "1.9.3"
|
||||
}
|
||||
},
|
||||
"@angular/platform-browser-dynamic": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "http://registry.npm.taobao.org/@angular/platform-browser-dynamic/download/@angular/platform-browser-dynamic-7.2.0.tgz",
|
||||
"integrity": "sha1-lSjfRCERhdOCsC3PxWEtCSqmtn0=",
|
||||
"requires": {
|
||||
"tslib": "1.9.3"
|
||||
}
|
||||
},
|
||||
"@angular/router": {
|
||||
"version": "7.2.0",
|
||||
"resolved": "http://registry.npm.taobao.org/@angular/router/download/@angular/router-7.2.0.tgz",
|
||||
"integrity": "sha1-exo1XlGXW/pJ8+bj/7YOnkCZufc=",
|
||||
"requires": {
|
||||
"tslib": "1.9.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"nice-try": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "http://registry.npm.taobao.org/nice-try/download/nice-try-1.0.5.tgz",
|
||||
@@ -8588,6 +8679,11 @@
|
||||
"integrity": "sha1-wiaIrtTqs83C3+rLtWFmBWCgCAQ=",
|
||||
"dev": true
|
||||
},
|
||||
"systemjs": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "http://registry.npm.taobao.org/systemjs/download/systemjs-2.1.1.tgz",
|
||||
"integrity": "sha1-RToSOqO7LctYHQ6Z+r0vKerb4Q0="
|
||||
},
|
||||
"tapable": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "http://registry.npm.taobao.org/tapable/download/tapable-1.1.1.tgz",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"layui-laydate": "^5.0.9",
|
||||
"ng-zorro-antd": "^1.8.0",
|
||||
"ngx-color-picker": "^7.0.1",
|
||||
"ngx-web-worker": "^7.0.0",
|
||||
"rxjs": "^6.0.0",
|
||||
"zone.js": "^0.8.26",
|
||||
"ztree": "^3.5.24"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Component, OnInit, ViewChild, Renderer2 } from '@angular/core';
|
||||
import { NavigationEnd, Router } from '@angular/router';
|
||||
import { WebWorkerService } from 'ngx-web-worker';
|
||||
|
||||
import { ToastService } from '../../components/toast/toast.service';
|
||||
import { ToastConfig, ToastType } from '../../components/toast/toast-model';
|
||||
@@ -15,6 +16,7 @@ import { CellColorHandle } from '../../utils/cell-color-handle';
|
||||
import { AlertMessageHandle } from '../../utils/alert-message-handle';
|
||||
|
||||
import dateFormatter from '../../utils/date-formatter';
|
||||
import webWorkerHandle from '../../utils/web-worker-handle';
|
||||
|
||||
import { filter } from 'rxjs/operators';
|
||||
import * as $ from 'jquery';
|
||||
@@ -22,12 +24,14 @@ import * as $ from 'jquery';
|
||||
@Component({
|
||||
selector: 'app-main',
|
||||
templateUrl: './main.component.html',
|
||||
styleUrls: ['./main.component.scss']
|
||||
styleUrls: ['./main.component.scss'],
|
||||
providers: [WebWorkerService]
|
||||
})
|
||||
export class MainComponent implements OnInit {
|
||||
constructor(
|
||||
private router: Router,
|
||||
private renderer2: Renderer2,
|
||||
private webWorkerService: WebWorkerService,
|
||||
private basicDataService: BasicDataService,
|
||||
private operateSpinServiceService: OperateSpinServiceService,
|
||||
private httpCilent: HttpClientService,
|
||||
@@ -141,6 +145,7 @@ export class MainComponent implements OnInit {
|
||||
console.log(message);
|
||||
//是否可以开始处理动态消息
|
||||
if (this.canHandleDynamicMessage) {
|
||||
// this.webWorkerService.terminate(promise);
|
||||
this.dynamicMessageHandle(message);
|
||||
} else {
|
||||
this.dynamicMessageArray.push(message);
|
||||
@@ -418,46 +423,35 @@ export class MainComponent implements OnInit {
|
||||
* 动态消息处理方法
|
||||
* @param message
|
||||
*/
|
||||
startposi: number
|
||||
dynamicMessageHandle(message) {
|
||||
this.startposi = new Date().getTime();
|
||||
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);
|
||||
}
|
||||
console.log(new Date().getTime() - this.startposi + '消息更新替换到原始数据所花时间');
|
||||
|
||||
//查找链接航班并将其组合成一条数据
|
||||
this.startposi = new Date().getTime();
|
||||
let combined_linked_data = this.dataHandle.findLinkFlights(this.raw_data);
|
||||
console.log(new Date().getTime() - this.startposi + '找链接航班所花时间')
|
||||
let combined_data = [];
|
||||
this.combined_data = [];
|
||||
this.startposi = new Date().getTime()
|
||||
combined_linked_data.forEach(element => {
|
||||
let flights_item = this.dataHandle.flightsRenderTransfer(element, this.col_lists);
|
||||
this.combined_data.push(flights_item);
|
||||
});
|
||||
console.log(new Date().getTime() - this.startposi + '转换结束所花时间')
|
||||
this.startposi = new Date().getTime();
|
||||
this.combined_data.forEach(item => {
|
||||
combined_data.push(this.dataHandle.basicDataTransHandle(item, this.airports, this.citys, this.airlines, this.flightStatus, this.flightTypes));
|
||||
})
|
||||
console.log(new Date().getTime() - this.startposi + '基础数据转换结束所花时间');
|
||||
this.combined_data = combined_data;
|
||||
this.startposi = new Date().getTime();
|
||||
this.combined_data.forEach(element => {
|
||||
element['ORDER'] = this.orderHandle.sequence(element);
|
||||
})
|
||||
this.combined_data = this.combined_data.sort(function (a, b) {
|
||||
return (a['ORDER'] - b['ORDER']);
|
||||
})
|
||||
// let combined_linked_data = this.dataHandle.findLinkFlights(this.raw_data);
|
||||
// let combined_data = [];
|
||||
// this.combined_data = [];
|
||||
// combined_linked_data.forEach(element => {
|
||||
// let flights_item = this.dataHandle.flightsRenderTransfer(element, this.col_lists);
|
||||
// this.combined_data.push(flights_item);
|
||||
// });
|
||||
// this.combined_data.forEach(item => {
|
||||
// combined_data.push(this.dataHandle.basicDataTransHandle(item, this.airports, this.citys, this.airlines, this.flightStatus, this.flightTypes));
|
||||
// })
|
||||
// this.combined_data = combined_data;
|
||||
// this.combined_data.forEach(element => {
|
||||
// element['ORDER'] = this.orderHandle.sequence(element);
|
||||
// })
|
||||
// this.combined_data = this.combined_data.sort(function (a, b) {
|
||||
// return (a['ORDER'] - b['ORDER']);
|
||||
// })
|
||||
|
||||
console.log(new Date().getTime() - this.startposi + '排序所花时间');
|
||||
|
||||
this.selectChange('dynamic');
|
||||
// this.selectChange('dynamic');
|
||||
|
||||
if (this.airlinesSelections.findIndex(airline => airline.airlineCodeIata === message['ALCD']) === -1) {
|
||||
let index = this.airlines.findIndex(val => val.airlineCodeIata === message['ALCD']);
|
||||
@@ -469,29 +463,20 @@ export class MainComponent implements OnInit {
|
||||
this.flightTypeSelections.push(this.flightTypes[index]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// let dynamicHandleData = this.dataHandle.dynamicMessageHandle(
|
||||
// message,
|
||||
// this.render_data,
|
||||
// this.col_lists,
|
||||
// this.filterItems,
|
||||
// this.LASTSEARCH,
|
||||
// this.LAST_SEL_COL,
|
||||
// this.airports,
|
||||
// this.citys,
|
||||
// this.airlines,
|
||||
// this.flightStatus,
|
||||
// this.flightTypes
|
||||
// )
|
||||
// this.render_data = dynamicHandleData.render_data;
|
||||
|
||||
// this.render_data.forEach(element => {
|
||||
// element['ORDER'] = this.orderHandle.sequence(element);
|
||||
// })
|
||||
// this.render_data = this.render_data.sort(function (a, b) {
|
||||
// return (a['ORDER'] - b['ORDER']);
|
||||
// })
|
||||
let dynamicData = {
|
||||
raw_data: this.raw_data,
|
||||
col_lists: this.col_lists,
|
||||
airports: this.airports,
|
||||
citys: this.citys,
|
||||
airlines: this.airlines,
|
||||
flightStatus: this.flightStatus,
|
||||
flightTypes: this.flightTypes
|
||||
}
|
||||
const promise = this.webWorkerService.run(webWorkerHandle, dynamicData);
|
||||
promise.then(function (response) {
|
||||
this.combined_data = response;
|
||||
this.selectChange('dynamic');
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -575,7 +560,6 @@ export class MainComponent implements OnInit {
|
||||
* 下拉框选择筛选
|
||||
*/
|
||||
selectChange(type) {
|
||||
this.startposi = new Date().getTime()
|
||||
if (type === 'filter') {
|
||||
this.operateSpinServiceService.showSpin();
|
||||
}
|
||||
@@ -835,11 +819,8 @@ export class MainComponent implements OnInit {
|
||||
})
|
||||
}
|
||||
}
|
||||
console.log(new Date().getTime() - this.startposi + '判断是否满足过滤条件所花时间');
|
||||
this.wait_render_data = filterData;
|
||||
this.startposi = new Date().getTime();
|
||||
this.render_data = this.wait_render_data.slice(this.start, this.end);
|
||||
console.log(new Date().getTime() - this.startposi + '渲染结束所花时间');
|
||||
setTimeout(() => {
|
||||
$(".table-body tbody>tr").eq(0).find('td').each((index, element) => {
|
||||
$(".table-head table thead tr").eq(0).find('th').eq(index).attr('width', $(element).innerWidth() + 'px');
|
||||
|
||||
@@ -0,0 +1,997 @@
|
||||
export default function (dynamicData) {
|
||||
let 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
|
||||
/**
|
||||
* 时间转换
|
||||
* @param dataString
|
||||
*/
|
||||
function timeFormatter(dataString) {
|
||||
const monthToNumber = {
|
||||
JAN: '01',
|
||||
FEB: '02',
|
||||
MAR: '03',
|
||||
APR: '04',
|
||||
MAY: '05',
|
||||
JUN: '06',
|
||||
JUL: '07',
|
||||
AUG: '08',
|
||||
SEP: '09',
|
||||
OCT: '10',
|
||||
NOV: '11',
|
||||
DEC: '12',
|
||||
}
|
||||
if (!dataString || dataString.length < 11) {
|
||||
return dataString ? dataString : '';
|
||||
}
|
||||
if (!dataString.substring(7)) {
|
||||
return dataString ? dataString : '';
|
||||
}
|
||||
if (!monthToNumber.hasOwnProperty(dataString.substring(2, 5).toUpperCase())) {
|
||||
return dataString ? dataString : '';
|
||||
}
|
||||
|
||||
let year = "20" + dataString.substring(5, 7);
|
||||
let month = monthToNumber[dataString.substring(2, 5).toUpperCase()];
|
||||
let day = dataString.substring(0, 2);
|
||||
let hour = dataString.substring(7, 9);
|
||||
let min = dataString.substring(9, 11);
|
||||
return hour + ':' + min;
|
||||
}
|
||||
/**
|
||||
* 日期转换
|
||||
* @param dataString
|
||||
*/
|
||||
function dateWithNotimeFormatter(dataString) {
|
||||
const monthToNumber = {
|
||||
JAN: '01',
|
||||
FEB: '02',
|
||||
MAR: '03',
|
||||
APR: '04',
|
||||
MAY: '05',
|
||||
JUN: '06',
|
||||
JUL: '07',
|
||||
AUG: '08',
|
||||
SEP: '09',
|
||||
OCT: '10',
|
||||
NOV: '11',
|
||||
DEC: '12',
|
||||
}
|
||||
if (!dataString || dataString.length < 11) {
|
||||
return dataString ? dataString : '';
|
||||
}
|
||||
if (!dataString.substring(7)) {
|
||||
return dataString ? dataString : '';
|
||||
}
|
||||
if (!monthToNumber.hasOwnProperty(dataString.substring(2, 5).toUpperCase())) {
|
||||
return dataString ? dataString : '';
|
||||
}
|
||||
|
||||
let year = "20" + dataString.substring(5, 7);
|
||||
let month = monthToNumber[dataString.substring(2, 5).toUpperCase()];
|
||||
let day = dataString.substring(0, 2);
|
||||
let hour = dataString.substring(7, 9);
|
||||
let min = dataString.substring(9, 11);
|
||||
return year + '-' + month + '-' + day;
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期时间转换
|
||||
* @param dataString 需要转换成日期时间的字符串
|
||||
*/
|
||||
function dateFormatter(dataString) {
|
||||
const monthToNumber = {
|
||||
JAN: '01',
|
||||
FEB: '02',
|
||||
MAR: '03',
|
||||
APR: '04',
|
||||
MAY: '05',
|
||||
JUN: '06',
|
||||
JUL: '07',
|
||||
AUG: '08',
|
||||
SEP: '09',
|
||||
OCT: '10',
|
||||
NOV: '11',
|
||||
DEC: '12',
|
||||
}
|
||||
if (!dataString || dataString.length < 11) {
|
||||
return dataString ? dataString : '';
|
||||
}
|
||||
if (!dataString.substring(7)) {
|
||||
return dataString ? dataString : '';
|
||||
}
|
||||
if (!monthToNumber.hasOwnProperty(dataString.substring(2, 5).toUpperCase())) {
|
||||
return dataString ? dataString : '';
|
||||
}
|
||||
|
||||
let year = "20" + dataString.substring(5, 7);
|
||||
let month = monthToNumber[dataString.substring(2, 5).toUpperCase()];
|
||||
let day = dataString.substring(0, 2);
|
||||
let hour = dataString.substring(7, 9);
|
||||
let min = dataString.substring(9, 11);
|
||||
return year + '-' + month + '-' + day + ' ' + hour + ':' + min
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 数据转换处理方法集
|
||||
*/
|
||||
let formatter = {
|
||||
'GCTM': function gctmFormatter(flight) {
|
||||
if (flight['GTDT']) {
|
||||
if (Array.isArray(flight['GTDT']) && flight['GTDT'].length > 0) {
|
||||
return timeFormatter(flight['GTDT'][0]['GCTM']);
|
||||
} else if (Object.prototype.toString.call(flight['GTDT']) === '[object Object]') {
|
||||
return timeFormatter(flight['GTDT']['GCTM']);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'BOTM': function botmFormatter(flight) {
|
||||
if (flight['BOTM']) {
|
||||
return timeFormatter(flight['BOTM']);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'ABDG': function abdgFormatter(flight) {
|
||||
if (flight['ABTM']) {
|
||||
if (Array.isArray(flight['ABTM']) && flight['ABTM'].length > 0) {
|
||||
let abdg = [];
|
||||
for (let i = 0; i < flight['ABTM'].length; i++) {
|
||||
abdg.push(flight['ABTM'][i]['ABDG']);
|
||||
}
|
||||
let set = new Set(abdg);
|
||||
return Array.from(set).join(',');
|
||||
} else if (Object.prototype.toString.call(flight['ABTM']) === '[object Object]') {
|
||||
return flight['ABTM']['ABDG'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'AOTM_A': function aotm_aFormatter(flight) {
|
||||
if (flight['ABTM']) {
|
||||
if (Array.isArray(flight['ABTM']) && flight['ABTM'].length > 0) {
|
||||
for (let i = 0; i < flight['ABTM'].length; i++) {
|
||||
if (flight['ABTM'][i]['ABOP'] === 'A') {
|
||||
return timeFormatter(flight['ABTM'][i]['AOTM']);
|
||||
}
|
||||
}
|
||||
} else if (Object.prototype.toString.call(flight['ABTM']) === '[object Object]') {
|
||||
if (flight['ABTM']['ABOP'] === 'A') {
|
||||
return timeFormatter(flight['ABTM']['AOTM']);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'AOTM_D': function aotm_dFormatter(flight) {
|
||||
if (flight['ABTM']) {
|
||||
if (Array.isArray(flight['ABTM']) && flight['ABTM'].length > 0) {
|
||||
for (let i = 0; i < flight['ABTM'].length; i++) {
|
||||
if (flight['ABTM'][i]['ABOP'] === 'D') {
|
||||
return timeFormatter(flight['ABTM'][i]['AOTM']);
|
||||
}
|
||||
}
|
||||
} else if (Object.prototype.toString.call(flight['ABTM']) === '[object Object]') {
|
||||
if (flight['ABTM']['ABOP'] === 'D') {
|
||||
return timeFormatter(flight['ABTM']['AOTM']);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'BELT': function beltFormatter(flight) {
|
||||
if (flight['CLDT']) {
|
||||
if (Array.isArray(flight['CLDT']) && flight['CLDT'].length > 0) {
|
||||
let belt = [];
|
||||
for (let i = 0; i < flight['CLDT'].length; i++) {
|
||||
belt.push(flight['CLDT'][i]['BELT']);
|
||||
}
|
||||
let set = new Set(belt);
|
||||
return Array.from(set).join(',');
|
||||
} else if (Object.prototype.toString.call(flight['CLDT']) === '[object Object]') {
|
||||
return flight['CLDT']['BELT'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'CHKC': function chkcFormatter(flight) {
|
||||
if (flight['CKDT']) {
|
||||
if (Array.isArray(flight['CKDT']) && flight['CKDT'].length > 0) {
|
||||
let chkc = [];
|
||||
for (let i = 0; i < flight['CKDT'].length; i++) {
|
||||
chkc.push(flight['CKDT'][i]['CHKC']);
|
||||
}
|
||||
let set = new Set(chkc);
|
||||
return Array.from(set).join(',');
|
||||
} else if (Object.prototype.toString.call(flight['CKDT']) === '[object Object]') {
|
||||
return flight['CKDT']['CHKC'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'CCTM': function cctmFormatter(flight) {
|
||||
if (flight['CKDT']) {
|
||||
if (Array.isArray(flight['CKDT']) && flight['CKDT'].length > 0) {
|
||||
return timeFormatter(flight['CKDT'][0]['CCTM']);
|
||||
} else if (Object.prototype.toString.call(flight['CKDT']) === '[object Object]') {
|
||||
return timeFormatter(flight['CKDT']['CCTM']);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'COTM': function cotmFormatter(flight) {
|
||||
if (flight['CKDT']) {
|
||||
if (Array.isArray(flight['CKDT']) && flight['CKDT'].length > 0) {
|
||||
return timeFormatter(flight['CKDT'][0]['COTM']);
|
||||
} else if (Object.prototype.toString.call(flight['CKDT']) === '[object Object]') {
|
||||
return timeFormatter(flight['CKDT']['COTM']);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'CHTM_ON': function chtmOnFormatter(flight) {
|
||||
if (flight['CHOT']) {
|
||||
if (Array.isArray(flight['CHOT']) && flight['CHOT'].length > 0) {
|
||||
for (let i = 0; i < flight['CHOT'].length; i++) {
|
||||
if (flight['CHOT'][i]['CHID'] === 'ON') {
|
||||
return timeFormatter(flight['CHOT'][i]['CHTM']);
|
||||
}
|
||||
}
|
||||
} else if (Object.prototype.toString.call(flight['CHOT']) === '[object Object]') {
|
||||
if (flight['CHOT']['CHID'] === 'ON') {
|
||||
return timeFormatter(flight['CHOT']['CHTM']);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'CHTM_OFF': function chtmOffFormatter(flight) {
|
||||
if (flight['CHOT']) {
|
||||
if (Array.isArray(flight['CHOT']) && flight['CHOT'].length > 0) {
|
||||
for (let i = 0; i < flight['CHOT'].length; i++) {
|
||||
if (flight['CHOT'][i]['CHID'] === 'OFF') {
|
||||
return timeFormatter(flight['CHOT'][i]['CHTM']);
|
||||
}
|
||||
}
|
||||
} else if (Object.prototype.toString.call(flight['CHOT']) === '[object Object]') {
|
||||
if (flight['CHOT']['CHID'] === 'OFF') {
|
||||
return timeFormatter(flight['CHOT']['CHTM']);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'LACL': function laclFormatter(flight) {
|
||||
if (flight['LACL']) {
|
||||
return timeFormatter(flight['LACL']);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'CHUT': function chutFormatter(flight) {
|
||||
if (flight['CHDT']) {
|
||||
if (Array.isArray(flight['CHDT']) && flight['CHDT'].length > 0) {
|
||||
let chut = [];
|
||||
for (let i = 0; i < flight['CHDT'].length; i++) {
|
||||
chut.push(flight['CHDT'][i]['CHUT']);
|
||||
}
|
||||
let set = new Set(chut);
|
||||
return Array.from(set).join(',');
|
||||
} else if (Object.prototype.toString.call(flight['CHDT']) === '[object Object]') {
|
||||
return flight['CHDT']['CHUT'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'ACTT': function acttFormatter(flight) {
|
||||
if (flight['ACTT']) {
|
||||
return timeFormatter(flight['ACTT']);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'PSST': function psstFormatter(flight) {
|
||||
if (flight['PSDT']) {
|
||||
if (Array.isArray(flight['PSDT']) && flight['PSDT'].length > 0) {
|
||||
let psst = [];
|
||||
for (let i = 0; i < flight['PSDT'].length; i++) {
|
||||
psst.push(flight['PSDT'][i]['PSST']);
|
||||
}
|
||||
let set = new Set(psst);
|
||||
return Array.from(set).join(',');
|
||||
} else if (Object.prototype.toString.call(flight['PSDT']) === '[object Object]') {
|
||||
return flight['PSDT']['PSST'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'ESTT': function esttFormatter(flight) {
|
||||
if (flight['ESTT']) {
|
||||
return timeFormatter(flight['ESTT']);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'MVIN': function mvinFormatter(flight) {
|
||||
if (flight['MVIN']) {
|
||||
if (flight['MVIN'] === 'A') {
|
||||
return '到达';
|
||||
} else if (flight['MVIN'] === 'D') {
|
||||
return '出发';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'ERUT': function erutFormatter(flight) {
|
||||
if (flight['ERUT']) {
|
||||
if (Array.isArray(flight['ERUT']) && flight['ERUT'].length > 0) {
|
||||
let erut = [];
|
||||
for (let i = 0; i < flight['ERUT'].length; i++) {
|
||||
erut.push(flight['ERUT'][i]['APCD']);
|
||||
}
|
||||
return erut.join(' - ');
|
||||
} else if (Object.prototype.toString.call(flight['ERUT']) === '[object Object]') {
|
||||
return flight['ERUT']['APCD'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'FLIN': function flinFormatter(flight) {
|
||||
const flinChn = {
|
||||
'D': '国内',
|
||||
'I': '国际',
|
||||
'M': '混合',
|
||||
'R': '地区'
|
||||
}
|
||||
if (flight['FLIN']) {
|
||||
return flinChn[flight['FLIN']];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'SODT': function sodtFormatter(flight) {
|
||||
if (flight['SODT']) {
|
||||
return timeFormatter(flight['SODT']);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'GTDT': function gateFormatter(flight) {
|
||||
if (flight['GTDT']) {
|
||||
if (Array.isArray(flight['GTDT']) && flight['GTDT'].length > 0) {
|
||||
let gate = [];
|
||||
for (let i = 0; i < flight['GTDT'].length; i++) {
|
||||
gate.push(flight['GTDT'][i]['GATE']);
|
||||
}
|
||||
let set = new Set(gate);
|
||||
return Array.from(set).join(',');
|
||||
} else if (Object.prototype.toString.call(flight['GTDT']) === '[object Object]') {
|
||||
return flight['GTDT']['GATE'];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'PADT': function padtFormatter(flight) {
|
||||
if (flight['PADT']) {
|
||||
return timeFormatter(flight['PADT']);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'FLDT': function fldtFormatter(flight) {
|
||||
if (flight['SODT']) {
|
||||
return dateWithNotimeFormatter(flight['SODT']);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行排序
|
||||
*/
|
||||
let TOP_1 = 1000000000000;
|
||||
let TOP_2 = 2000000000000;
|
||||
let TOP_3 = 3000000000000;
|
||||
let TOP_4 = 4000000000000;
|
||||
let TOP_5 = 5000000000000;
|
||||
let TOP_6 = 6000000000000;
|
||||
let TOP_7 = 7000000000000;
|
||||
let TOP_8 = 8000000000000;
|
||||
let TOP_9 = 9000000000000;
|
||||
let TOP_10 = 10000000000000;
|
||||
let TOP_11 = 11000000000000;
|
||||
let TOP_12 = 12000000000000;
|
||||
let TOP_13 = 13000000000000;
|
||||
let TOP_14 = 14000000000000;
|
||||
|
||||
/**
|
||||
* 获取航班实际时间
|
||||
* @param flight
|
||||
* @return
|
||||
*/
|
||||
function getActualDatetime(flight) {
|
||||
return flight['ACTT'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取航班预计时间
|
||||
* @param flight
|
||||
* @return
|
||||
*/
|
||||
function getEstimatedDatetime(flight) {
|
||||
return flight['ESTT']
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取航班计划时间
|
||||
* @param flight
|
||||
* @return
|
||||
*/
|
||||
function getScheduledDatetime(flight) {
|
||||
return flight['SODT']
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断航班是否是链接航班
|
||||
* @param flight
|
||||
* @return
|
||||
*/
|
||||
function isLinked(flight) {
|
||||
if (flight['preFlight'] && flight['reaFlight']) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断航班是否是纯离港航班
|
||||
* @param flight
|
||||
* @return
|
||||
*/
|
||||
function isDeptFlight(flight) {
|
||||
if (!flight['preFlight'] && flight['reaFlight']) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断航班是否是纯到港航班
|
||||
* @param flight
|
||||
* @return
|
||||
*/
|
||||
function isArriFlight(flight) {
|
||||
if (flight['preFlight'] && !flight['reaFlight']) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断航班是否已经前站起飞
|
||||
* @param flight
|
||||
* @return
|
||||
*/
|
||||
function isFlying(flight) {
|
||||
if (isArriFlight(flight) || isLinked(flight)) {
|
||||
if (flight['preFlight']['PADT']) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断航班是否取消
|
||||
* @param flight
|
||||
* @return
|
||||
*/
|
||||
function isCancled(flight) {
|
||||
if (isArriFlight(flight)) {
|
||||
if (flight['preFlight']['CNCL']) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if (isDeptFlight(flight)) {
|
||||
if (flight['reaFlight']['CNCL']) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断航班是否延误(只针对纯离港航班或链接航班中的离港航班)
|
||||
* @param flight
|
||||
* @return
|
||||
*/
|
||||
function isDelayed(flight) {
|
||||
if (isDeptFlight(flight) || isLinked(flight)) {
|
||||
if (flight['reaFlight']['DELY']) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断航班是否已经执行完成
|
||||
* @param flight
|
||||
* @return
|
||||
*/
|
||||
function isDone(flight) {
|
||||
if (isLinked(flight) || isDeptFlight(flight)) {
|
||||
if (!getActualDatetime(flight['reaFlight'])) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else if (isArriFlight(flight)) {
|
||||
if (!getActualDatetime(flight['preFlight'])) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断航班是否开始登机
|
||||
* @param flight
|
||||
* @return
|
||||
*/
|
||||
function startBoading(flight) {
|
||||
if (isLinked(flight) || isDeptFlight(flight)) {
|
||||
if (!flight['reaFlight']['BOTM']) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断航班是否正在登机中
|
||||
* @param flight
|
||||
* @return
|
||||
*/
|
||||
function isBoading(flight) {
|
||||
if (isLinked(flight) || isDeptFlight(flight)) {
|
||||
if (flight['reaFlight']['BOTM'] && !(flight['reaFlight']['GTDT'] && flight['reaFlight']['GTDT']['GCTM'])) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断航班是否登机结束
|
||||
* @param flight
|
||||
* @return
|
||||
*/
|
||||
function isOverBoading(flight) {
|
||||
if (isLinked(flight) || isDeptFlight(flight)) {
|
||||
if (flight['reaFlight']['GTDT'] && flight['reaFlight']['GTDT']['GCTM']) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 行排序规则方法
|
||||
* @param flight
|
||||
* @return
|
||||
*/
|
||||
function sequence(flight) {
|
||||
let dateTag: number = 10;
|
||||
let dateToCompare = new Date().getTime();
|
||||
if (!isCancled(flight) && !isDone(flight) && isDelayed(flight)) {
|
||||
if (isLinked(flight)) {
|
||||
if (getActualDatetime(flight['preFlight']) && !getActualDatetime(flight['reaFlight'])) {
|
||||
dateToCompare = new Date(dateFormatter(getActualDatetime(flight['preFlight']))).getTime();
|
||||
dateTag = TOP_1;
|
||||
}
|
||||
else {
|
||||
dateToCompare = new Date(dateFormatter(getScheduledDatetime(flight['reaFlight']))).getTime();
|
||||
dateTag = TOP_2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
dateToCompare = new Date(dateFormatter(getScheduledDatetime(flight['reaFlight']))).getTime();
|
||||
dateTag = TOP_3;
|
||||
}
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!isCancled(flight) && !isDone(flight) && isBoading(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(getScheduledDatetime(flight['reaFlight']))).getTime();
|
||||
dateTag = TOP_4;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!isCancled(flight) && !isDone(flight) && isFlying(flight) && !getActualDatetime(flight['preFlight'])) {
|
||||
if (getEstimatedDatetime(flight['preFlight'])) {
|
||||
dateToCompare = new Date(dateFormatter(getEstimatedDatetime(flight['preFlight']))).getTime();
|
||||
} else {
|
||||
dateToCompare = new Date(dateFormatter(getScheduledDatetime(flight['preFlight']))).getTime();
|
||||
}
|
||||
dateTag = TOP_5;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!isCancled(flight) && !isDone(flight) && isLinked(flight) && getActualDatetime(flight['preFlight']) && !getActualDatetime(flight['reaFlight'])) {
|
||||
dateToCompare = new Date(dateFormatter(getActualDatetime(flight['preFlight']))).getTime();
|
||||
dateTag = TOP_6;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!isCancled(flight) && !isDone(flight) && isDeptFlight(flight) && !startBoading(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(getScheduledDatetime(flight['reaFlight']))).getTime();
|
||||
dateTag = TOP_7;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!isCancled(flight) && isArriFlight(flight) && isDone(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(getActualDatetime(flight['preFlight']))).getTime();
|
||||
dateTag = TOP_8;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!isCancled(flight) && !isDone(flight) && isOverBoading(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(getScheduledDatetime(flight['reaFlight']))).getTime();
|
||||
dateTag = TOP_9;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!isCancled(flight) && !isDone(flight) && !isFlying(flight)) {
|
||||
if (isLinked(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(getScheduledDatetime(flight['reaFlight']))).getTime();
|
||||
dateTag = TOP_10;
|
||||
} else if (isArriFlight(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(getScheduledDatetime(flight['preFlight']))).getTime();
|
||||
dateTag = TOP_11;
|
||||
}
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!isCancled(flight) && isDone(flight) && (isLinked(flight) || isDeptFlight(flight))) {
|
||||
dateToCompare = new Date(dateFormatter(getActualDatetime(flight['reaFlight']))).getTime();
|
||||
dateTag = TOP_12;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (isCancled(flight)) {
|
||||
if (isDeptFlight(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(getScheduledDatetime(flight['reaFlight']))).getTime();
|
||||
} else {
|
||||
dateToCompare = new Date(dateFormatter(getScheduledDatetime(flight['preFlight']))).getTime();
|
||||
}
|
||||
|
||||
dateTag = TOP_13;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
return TOP_14
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找链接航班
|
||||
*/
|
||||
let combined_raw_flights: Array<any> = [];
|
||||
let copy_raw_flights = [];
|
||||
raw_data.forEach(element => {
|
||||
copy_raw_flights.push(Object.assign({}, element))
|
||||
})
|
||||
for (let i = 0; i < copy_raw_flights.length; i++) {
|
||||
if (copy_raw_flights[i]['MVIN'] === 'A') {
|
||||
if (copy_raw_flights[i]['TAID']) {
|
||||
let index = copy_raw_flights.findIndex(val => { return val['FLID'] === copy_raw_flights[i]['TAID'] });
|
||||
if (index > -1) {
|
||||
copy_raw_flights[i]['isLinked'] = true;
|
||||
copy_raw_flights[i]['linkFlight'] = copy_raw_flights[index];
|
||||
if (!copy_raw_flights[i]['linkFlight']['TAID']) {
|
||||
copy_raw_flights[i]['linkFlight']['TAID'] = copy_raw_flights[i]['FLID'];
|
||||
}
|
||||
copy_raw_flights.splice(index, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
copy_raw_flights.forEach(element => {
|
||||
let flights_item = {};
|
||||
if (element['MVIN'] === 'A' && !element['isLinked']) {
|
||||
flights_item['preFlight'] = element;
|
||||
} else if (element['MVIN'] === 'D' && !element['isLinked']) {
|
||||
flights_item['reaFlight'] = element;
|
||||
} else {
|
||||
flights_item['reaFlight'] = element['linkFlight'];
|
||||
delete element['linkFlight'];
|
||||
delete element['isLinked'];
|
||||
flights_item['preFlight'] = element;
|
||||
}
|
||||
|
||||
combined_raw_flights.push(flights_item);
|
||||
});
|
||||
|
||||
/**
|
||||
* 数据转换
|
||||
*/
|
||||
let combined_data = [];
|
||||
combined_raw_flights.forEach(element => {
|
||||
let render_flight = {},
|
||||
render_pre_flight = {},
|
||||
render_rea_flight = {},
|
||||
flights_item = Object.assign({}, element)
|
||||
|
||||
try {
|
||||
if (flights_item['preFlight'] && !flights_item['reaFlight']) {
|
||||
render_flight['FLID'] = flights_item['preFlight']['FLID']
|
||||
for (let i = 0; i < col_lists.length; i++) {
|
||||
let key = col_lists[i]['COL_CODE'];
|
||||
render_flight[key] = formatter.hasOwnProperty(key) ? formatter[key](flights_item['preFlight']) : flights_item['preFlight'][key];
|
||||
}
|
||||
flights_item['renderFlight'] = render_flight;
|
||||
} else if (!flights_item['preFlight'] && flights_item['reaFlight']) {
|
||||
render_flight['FLID'] = flights_item['reaFlight']['FLID']
|
||||
for (let i = 0; i < col_lists.length; i++) {
|
||||
let key = col_lists[i]['COL_CODE']
|
||||
render_flight[key] = formatter.hasOwnProperty(key) ? formatter[key](flights_item['reaFlight']) : flights_item['reaFlight'][key];
|
||||
}
|
||||
flights_item['renderFlight'] = render_flight;
|
||||
} else {
|
||||
render_flight['FLID'] = flights_item['preFlight']['FLID'] + ' / ' + flights_item['reaFlight']['FLID'];
|
||||
render_pre_flight['FLID'] = flights_item['preFlight']['FLID'];
|
||||
render_rea_flight['FLID'] = flights_item['reaFlight']['FLID'];
|
||||
for (let i = 0; i < col_lists.length; i++) {
|
||||
let preHasValue, reaHasValue;
|
||||
let key = col_lists[i]['COL_CODE'];
|
||||
if (formatter.hasOwnProperty(key)) {
|
||||
preHasValue = formatter[key](flights_item['preFlight']);
|
||||
reaHasValue = formatter[key](flights_item['reaFlight']);
|
||||
} else {
|
||||
preHasValue = flights_item['preFlight'][key];
|
||||
reaHasValue = flights_item['reaFlight'][key];
|
||||
}
|
||||
|
||||
if (preHasValue && !reaHasValue) {
|
||||
if (key === 'SODT' || key === 'ESTT' || key === 'ACTT') {
|
||||
render_flight[key] = preHasValue + ' / ';
|
||||
} else {
|
||||
render_flight[key] = preHasValue;
|
||||
}
|
||||
} else if (!preHasValue && reaHasValue) {
|
||||
if (key === 'SODT' || key === 'ESTT' || key === 'ACTT') {
|
||||
render_flight[key] = ' / ' + reaHasValue;
|
||||
} else {
|
||||
render_flight[key] = reaHasValue;
|
||||
}
|
||||
} else if (preHasValue && reaHasValue) {
|
||||
if (preHasValue === reaHasValue) {
|
||||
render_flight[key] = preHasValue;
|
||||
} else {
|
||||
if (key === 'ERUT') {
|
||||
render_flight[key] = preHasValue.split(' - ').slice(0, -1).join(' - ') + ' - ' + reaHasValue;
|
||||
} else {
|
||||
render_flight[key] = preHasValue + ' / ' + reaHasValue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
render_flight[key] = '';
|
||||
}
|
||||
render_pre_flight[key] = preHasValue;
|
||||
render_rea_flight[key] = reaHasValue;
|
||||
}
|
||||
flights_item['renderPreFlight'] = render_pre_flight;
|
||||
flights_item['renderReaFlight'] = render_rea_flight;
|
||||
flights_item['renderFlight'] = Object.assign({}, render_flight);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('数据有误,处理失败,请检查数据');
|
||||
throw error;
|
||||
} finally {
|
||||
combined_data.push(flights_item);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 基础数据转换
|
||||
*/
|
||||
let coustom_data = [];
|
||||
combined_data.forEach(item => {
|
||||
try {
|
||||
if (isArriFlight(item) || isDeptFlight(item)) {
|
||||
//航线处理
|
||||
let erutCodeArray = item['renderFlight']['ERUT'].split(' - ');
|
||||
let erutChnArray = []
|
||||
for (let i = 0; i < erutCodeArray.length; i++) {
|
||||
try {
|
||||
let airportIndex = airports.findIndex(val => val.airportCodeIata === erutCodeArray[i]);
|
||||
let cityIndex = citys.findIndex(val => airports[airportIndex].cityId === val.cityId);
|
||||
erutChnArray.push(citys[cityIndex].cityNameChn);
|
||||
} catch (error) {
|
||||
erutChnArray.push(erutCodeArray[i]);
|
||||
}
|
||||
}
|
||||
item['renderFlight']['ERUT'] = erutChnArray.join(' - ');
|
||||
//航空公司处理
|
||||
let airlineIndex = airlines.findIndex(val => val.airlineCode === item['renderFlight']['ALCD']);
|
||||
item['renderFlight']['ALCD'] = airlines[airlineIndex].airlineName;
|
||||
//运营状态处理
|
||||
item['renderFlight']['FTSS'] = flightStatus.find(val => val.sttc === item['renderFlight']['FTSS']).stdc;
|
||||
//航班类型处理
|
||||
item['renderFlight']['FLTY'] = flightTypes.find(val => val.flightTypeCode === item['renderFlight']['FLTY']).flightTypeNameCn;
|
||||
} else {
|
||||
//航线处理
|
||||
let erutLinkCodeArray = item['renderFlight']['ERUT'].split(' - ');
|
||||
let erutLinkChnArray = []
|
||||
for (let i = 0; i < erutLinkCodeArray.length; i++) {
|
||||
try {
|
||||
let airportIndex = airports.findIndex(val => val.airportCodeIata === erutLinkCodeArray[i]);
|
||||
let cityIndex = citys.findIndex(val => airports[airportIndex].cityId === val.cityId);
|
||||
erutLinkChnArray.push(citys[cityIndex].cityNameChn);
|
||||
} catch (error) {
|
||||
erutLinkChnArray.push(erutLinkCodeArray[i]);
|
||||
}
|
||||
}
|
||||
item['renderFlight']['ERUT'] = erutLinkChnArray.join(' - ');
|
||||
//航空公司处理
|
||||
let airlineLinkIndex = airlines.findIndex(val => val.airlineCode === item['renderFlight']['ALCD']);
|
||||
item['renderFlight']['ALCD'] = airlines[airlineLinkIndex].airlineName;
|
||||
//运营状态处理
|
||||
let ftssLinkCodeArray = item['renderFlight']['FTSS'].split(' / ');
|
||||
let ftssLinkChnArray = [];
|
||||
for (let i = 0; i < ftssLinkCodeArray.length; i++) {
|
||||
ftssLinkChnArray.push(flightStatus.find(val => val.sttc === ftssLinkCodeArray[i]).stdc)
|
||||
}
|
||||
item['renderFlight']['FTSS'] = ftssLinkChnArray.join(' / ');
|
||||
|
||||
//航班类型处理
|
||||
let fltyLinkCodeArray = item['renderFlight']['FLTY'].split(' / ');
|
||||
let fltyLinkChnArray = [];
|
||||
for (let i = 0; i < fltyLinkCodeArray.length; i++) {
|
||||
fltyLinkChnArray.push(flightTypes.find(val => val.flightTypeCode === fltyLinkCodeArray[i]).flightTypeNameCn)
|
||||
}
|
||||
item['renderFlight']['FLTY'] = fltyLinkChnArray.join(' / ');
|
||||
|
||||
//航线处理
|
||||
let erutPreCodeArray = item['renderPreFlight']['ERUT'].split(' - ');
|
||||
let erutPreChnArray = []
|
||||
for (let i = 0; i < erutPreCodeArray.length; i++) {
|
||||
try {
|
||||
let airportIndex = airports.findIndex(val => val.airportCodeIata === erutPreCodeArray[i]);
|
||||
let cityIndex = citys.findIndex(val => airports[airportIndex].cityId === val.cityId);
|
||||
erutPreChnArray.push(citys[cityIndex].cityNameChn);
|
||||
} catch (error) {
|
||||
erutPreChnArray.push(erutPreCodeArray[i]);
|
||||
}
|
||||
}
|
||||
item['renderPreFlight']['ERUT'] = erutPreChnArray.join(' - ');
|
||||
//航空公司处理
|
||||
let airlinePreIndex = airlines.findIndex(val => val.airlineCode === item['renderPreFlight']['ALCD']);
|
||||
item['renderPreFlight']['ALCD'] = airlines[airlinePreIndex].airlineName;
|
||||
//运营状态处理
|
||||
item['renderPreFlight']['FTSS'] = flightStatus.find(val => val.sttc === item['renderPreFlight']['FTSS']).stdc
|
||||
//航班类型处理
|
||||
item['renderPreFlight']['FLTY'] = flightTypes.find(val => val.flightTypeCode === item['renderPreFlight']['FLTY']).flightTypeNameCn;
|
||||
|
||||
|
||||
//航线处理
|
||||
let erutReaCodeArray = item['renderReaFlight']['ERUT'].split(' - ');
|
||||
let erutReaChnArray = []
|
||||
for (let i = 0; i < erutReaCodeArray.length; i++) {
|
||||
try {
|
||||
let airportIndex = airports.findIndex(val => val.airportCodeIata === erutReaCodeArray[i]);
|
||||
let cityIndex = citys.findIndex(val => airports[airportIndex].cityId === val.cityId);
|
||||
erutReaChnArray.push(citys[cityIndex].cityNameChn);
|
||||
} catch (error) {
|
||||
erutReaChnArray.push(erutReaCodeArray[i]);
|
||||
}
|
||||
}
|
||||
item['renderReaFlight']['ERUT'] = erutReaChnArray.join(' - ');
|
||||
//航空公司处理
|
||||
let airlineReaIndex = airlines.findIndex(val => val.airlineCode === item['renderReaFlight']['ALCD']);
|
||||
item['renderReaFlight']['ALCD'] = airlines[airlineReaIndex].airlineName;
|
||||
//运营状态处理
|
||||
item['renderReaFlight']['FTSS'] = flightStatus.find(val => val.sttc === item['renderReaFlight']['FTSS']).stdc
|
||||
//航班类型处理
|
||||
item['renderReaFlight']['FLTY'] = flightTypes.find(val => val.flightTypeCode === item['renderReaFlight']['FLTY']).flightTypeNameCn;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('基础数据转换有误,处理失败,请检查数据');
|
||||
throw error;
|
||||
} finally {
|
||||
coustom_data.push(item)
|
||||
}
|
||||
})
|
||||
combined_data = coustom_data;
|
||||
|
||||
|
||||
combined_data.forEach(element => {
|
||||
element['ORDER'] = sequence(element);
|
||||
})
|
||||
combined_data = combined_data.sort(function (a, b) {
|
||||
return (a['ORDER'] - b['ORDER']);
|
||||
})
|
||||
|
||||
return combined_data;
|
||||
}
|
||||
Reference in New Issue
Block a user