2018-12-07 11:28:45 +08:00
|
|
|
import gctmFormatter from '../../../utils/gctm-formatter';
|
|
|
|
|
import botmFormatter from '../../../utils/botm-formatter';
|
|
|
|
|
import abdgFormatter from '../../../utils/abdg-formatter';
|
|
|
|
|
import aotm_aFormatter from '../../../utils/aotm_a-formatter';
|
|
|
|
|
import aotm_dFormatter from '../../../utils/aotm_d-formatter';
|
|
|
|
|
import beltFormatter from '../../../utils/belt-formatter';
|
|
|
|
|
import chkcFormatter from '../../../utils/chkc-formatter';
|
|
|
|
|
import cctmFormatter from '../../../utils/cctm-formatter';
|
|
|
|
|
import cotmFormatter from '../../../utils/cotm-formatter';
|
|
|
|
|
import chtmOnFormatter from '../../../utils/chtm_on-formatter';
|
|
|
|
|
import chtmOffFormatter from '../../../utils/chtm_off-formatter';
|
|
|
|
|
import laclFormatter from '../../../utils/lacl-formatter';
|
|
|
|
|
import chutFormatter from '../../../utils/chut-formatter';
|
|
|
|
|
import acttFormatter from '../../../utils/actt-formatter';
|
|
|
|
|
import psstFormatter from '../../../utils/psst-formatter';
|
|
|
|
|
import esttFormatter from '../../../utils/estt-formatter';
|
|
|
|
|
import mvinFormatter from '../../../utils/mvin-formatter';
|
|
|
|
|
import erutFormatter from '../../../utils/erut-formatter';
|
|
|
|
|
import flinFormatter from '../../../utils/flin-formatter';
|
|
|
|
|
import sodtFormatter from '../../../utils/sodt-formatter';
|
|
|
|
|
import gateFormatter from '../../../utils/gate-formatter';
|
|
|
|
|
import padtFormatter from '../../../utils/padt-formatter';
|
|
|
|
|
|
|
|
|
|
import { DynamicFlightOrder } from './dynamic-flight-order';
|
|
|
|
|
|
|
|
|
|
export class FlightsDataHandle {
|
|
|
|
|
public formatter = {
|
|
|
|
|
'GCTM': gctmFormatter,
|
|
|
|
|
'BOTM': botmFormatter,
|
|
|
|
|
'ABDG': abdgFormatter,
|
|
|
|
|
'AOTM_A': aotm_aFormatter,
|
|
|
|
|
'AOTM_D': aotm_dFormatter,
|
|
|
|
|
'BELT': beltFormatter,
|
|
|
|
|
'CHKC': chkcFormatter,
|
|
|
|
|
'CCTM': cctmFormatter,
|
|
|
|
|
'COTM': cotmFormatter,
|
|
|
|
|
'CHTM_ON': chtmOnFormatter,
|
|
|
|
|
'CHTM_OFF': chtmOffFormatter,
|
|
|
|
|
'LACL': laclFormatter,
|
|
|
|
|
'CHUT': chutFormatter,
|
|
|
|
|
'ACTT': acttFormatter,
|
|
|
|
|
'PSST': psstFormatter,
|
|
|
|
|
'ESTT': esttFormatter,
|
|
|
|
|
'MVIN': mvinFormatter,
|
|
|
|
|
'ERUT': erutFormatter,
|
|
|
|
|
'FLIN': flinFormatter,
|
|
|
|
|
'SODT': sodtFormatter,
|
|
|
|
|
'GATE': gateFormatter,
|
|
|
|
|
'PADT': padtFormatter
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public orderHandle = new DynamicFlightOrder();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public findLinkFlights(raw_flights) {
|
|
|
|
|
let combined_raw_flights: Array<any> = [];
|
2018-12-12 18:27:21 +08:00
|
|
|
let copy_raw_flights = [];
|
|
|
|
|
raw_flights.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'] });
|
2018-12-07 11:28:45 +08:00
|
|
|
if (index > -1) {
|
2018-12-12 18:27:21 +08:00
|
|
|
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'];
|
2018-12-07 11:28:45 +08:00
|
|
|
}
|
2018-12-12 18:27:21 +08:00
|
|
|
copy_raw_flights.splice(index, 1);
|
2018-12-07 11:28:45 +08:00
|
|
|
i--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-12 18:27:21 +08:00
|
|
|
copy_raw_flights.forEach(element => {
|
2018-12-07 11:28:45 +08:00
|
|
|
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 {
|
2018-12-12 18:27:21 +08:00
|
|
|
flights_item['reaFlight'] = element['linkFlight'];
|
2018-12-07 11:28:45 +08:00
|
|
|
delete element['linkFlight'];
|
|
|
|
|
delete element['isLinked'];
|
2018-12-12 18:27:21 +08:00
|
|
|
flights_item['preFlight'] = element;
|
2018-12-07 11:28:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
combined_raw_flights.push(flights_item);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return combined_raw_flights;
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-12 18:27:21 +08:00
|
|
|
public flightsRenderTransfer(item, col_lists) {
|
2018-12-07 11:28:45 +08:00
|
|
|
let render_flight = {},
|
|
|
|
|
render_pre_flight = {},
|
2018-12-12 18:27:21 +08:00
|
|
|
render_rea_flight = {},
|
|
|
|
|
flights_item = Object.assign({}, item)
|
2018-12-07 11:28:45 +08:00
|
|
|
|
|
|
|
|
if (flights_item['preFlight'] && !flights_item['reaFlight']) {
|
|
|
|
|
for (let i = 0; i < col_lists.length; i++) {
|
|
|
|
|
let key = col_lists[i]['COL_CODE'];
|
|
|
|
|
render_flight[key] = this.formatter.hasOwnProperty(key) ? this.formatter[key](flights_item['preFlight']) : flights_item['preFlight'][key];
|
|
|
|
|
}
|
|
|
|
|
flights_item['renderFlight'] = render_flight;
|
|
|
|
|
} else if (!flights_item['preFlight'] && flights_item['reaFlight']) {
|
|
|
|
|
for (let i = 0; i < col_lists.length; i++) {
|
|
|
|
|
let key = col_lists[i]['COL_CODE']
|
|
|
|
|
render_flight[key] = this.formatter.hasOwnProperty(key) ? this.formatter[key](flights_item['reaFlight']) : flights_item['reaFlight'][key];
|
|
|
|
|
}
|
|
|
|
|
flights_item['renderFlight'] = render_flight;
|
|
|
|
|
} else {
|
|
|
|
|
for (let i = 0; i < col_lists.length; i++) {
|
|
|
|
|
let preHasValue, reaHasValue;
|
|
|
|
|
let key = col_lists[i]['COL_CODE'];
|
|
|
|
|
if (this.formatter.hasOwnProperty(key)) {
|
|
|
|
|
preHasValue = this.formatter[key](flights_item['preFlight']);
|
|
|
|
|
reaHasValue = this.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;
|
|
|
|
|
}
|
2018-12-12 18:27:21 +08:00
|
|
|
flights_item['renderCombinedFlight'] = render_flight;
|
2018-12-07 11:28:45 +08:00
|
|
|
flights_item['renderPreFlight'] = render_pre_flight;
|
|
|
|
|
flights_item['renderReaFlight'] = render_rea_flight;
|
2018-12-12 18:27:21 +08:00
|
|
|
flights_item['renderFlight'] = Object.assign({}, render_flight);
|
2018-12-07 11:28:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return flights_item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 基础数据转换
|
|
|
|
|
*/
|
2018-12-12 18:27:21 +08:00
|
|
|
basicDataTransHandle(item, airports, citys, airlines, flightStatus) {
|
|
|
|
|
if (this.orderHandle.isArriFlight(item) || this.orderHandle.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]);
|
2018-12-07 11:28:45 +08:00
|
|
|
}
|
|
|
|
|
}
|
2018-12-12 18:27:21 +08:00
|
|
|
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
|
|
|
|
|
} 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 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
|
|
|
|
|
|
|
|
|
|
//航线处理
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
// //航线处理
|
|
|
|
|
// let erutCombinedCodeArray = item['renderCombinedFlight']['ERUT'].split(' - ');
|
|
|
|
|
// let erutCombinedChnArray = []
|
|
|
|
|
// for (let i = 0; i < erutCombinedCodeArray.length; i++) {
|
|
|
|
|
// try {
|
|
|
|
|
// let airportIndex = airports.findIndex(val => val.airportCodeIata === erutCombinedCodeArray[i]);
|
|
|
|
|
// let cityIndex = citys.findIndex(val => airports[airportIndex].cityId === val.cityId);
|
|
|
|
|
// erutCombinedChnArray.push(citys[cityIndex].cityNameChn);
|
|
|
|
|
// } catch (error) {
|
|
|
|
|
// erutCombinedChnArray.push(erutCombinedCodeArray[i]);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// item['renderCombinedFlight']['ERUT'] = erutCombinedChnArray.join(' - ');
|
|
|
|
|
// //航空公司处理
|
|
|
|
|
// let airlineCombinedIndex = airlines.findIndex(val => val.airlineCode === item['renderCombinedFlight']['ALCD']);
|
|
|
|
|
// item['renderCombinedFlight']['ALCD'] = airlines[airlineCombinedIndex].airlineName;
|
|
|
|
|
// //运营状态处理
|
|
|
|
|
// let ftssCombinedCodeArray = item['renderCombinedFlight']['FTSS'].split(' / ');
|
|
|
|
|
// let ftssCombinedChnArray = [];
|
|
|
|
|
// for (let i = 0; i < ftssCombinedCodeArray.length; i++) {
|
|
|
|
|
// ftssCombinedChnArray.push(flightStatus.find(val => val.sttc === ftssCombinedCodeArray[i]).stdc)
|
|
|
|
|
// }
|
|
|
|
|
// item['renderCombinedFlight']['FTSS'] = ftssCombinedChnArray.join(' / ');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return item;
|
2018-12-07 11:28:45 +08:00
|
|
|
}
|
|
|
|
|
}
|