数据处理格式调整 -- 单独到/离港航班对象
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ChangeDetectorRef } from '@angular/core';
|
||||
|
||||
import { HttpClientService } from '../../services/http-client.service';
|
||||
|
||||
@@ -13,11 +14,25 @@ import arriDept from '../../utils/arri-dept';
|
||||
styleUrls: ['./main.component.scss']
|
||||
})
|
||||
export class MainComponent implements OnInit {
|
||||
public airline_col_lists: Array<object>;
|
||||
public airline_row_lists: Array<object> = [];
|
||||
|
||||
constructor(
|
||||
private httpCilent: HttpClientService,
|
||||
private changeDetectorRef: ChangeDetectorRef
|
||||
) { }
|
||||
|
||||
public raw_data: Array<object> = []; //原始数据,即航班计划
|
||||
|
||||
public combined_data: Array<object> = []; //组合数据,即链接航班,显示信息等组合好之后的数据
|
||||
|
||||
public render_data: Array<object> = []; //显示数据,即需要显示的数据
|
||||
|
||||
|
||||
|
||||
public col_lists: Array<object>; //列数据
|
||||
public airline_color: Array<object> = [];
|
||||
public row_state: number;
|
||||
|
||||
|
||||
public TOP_1 = 1000000000000;
|
||||
public TOP_2 = 2000000000000;
|
||||
public TOP_3 = 3000000000000;
|
||||
@@ -32,36 +47,42 @@ export class MainComponent implements OnInit {
|
||||
public TOP_12 = 12000000000000;
|
||||
public TOP_13 = 13000000000000;
|
||||
public TOP_14 = 14000000000000;
|
||||
public LEVEL_1 = 100000000000000;
|
||||
public LEVEL_2 = 200000000000000;
|
||||
public LEVEL_3 = 300000000000000;
|
||||
public LEVEL_4 = 400000000000000;
|
||||
public LEVEL_5 = 500000000000000;
|
||||
public LEVEL_6 = 600000000000000;
|
||||
public LEVEL_7 = 700000000000000;
|
||||
public LEVEL_8 = 800000000000000;
|
||||
public LEVEL_9 = 900000000000000;
|
||||
public LEVEL_10 = 1000000000000000;
|
||||
public LEVEL_11 = 1100000000000000;
|
||||
public LEVEL_12 = 1200000000000000;
|
||||
public LEVEL_13 = 1300000000000000;
|
||||
public LEVEL_14 = 1400000000000000;
|
||||
|
||||
filterItems = {
|
||||
SEARCH:'',
|
||||
ALCD:'',
|
||||
FLIN:'',
|
||||
FLTY:'',
|
||||
|
||||
public filterItems = {
|
||||
SEARCH: '', //手动输入条件
|
||||
FLT_POS:'1', //过滤还是定位
|
||||
ALCD: '', //航空公司
|
||||
FLIN: '', //航线类别
|
||||
FLTY: '', //航班类别
|
||||
MVIN: '', //到达/出发
|
||||
TRML: '', //航站楼
|
||||
FHAG: '', //机坪代理
|
||||
MHAG: '', //维护代理
|
||||
PHAG: '', //旅客代理
|
||||
}
|
||||
|
||||
public formatter = {
|
||||
'MVIN': {
|
||||
'A': '到达',
|
||||
'D': '出发',
|
||||
'DF': '其他'
|
||||
},
|
||||
'FLIN': {
|
||||
'D': '国内',
|
||||
'I': '国际',
|
||||
'M': '混合',
|
||||
'R': '地区',
|
||||
'DF': '其他'
|
||||
},
|
||||
'SODT': dateFormatter,
|
||||
'ESTT': dateFormatter,
|
||||
'ACTT': dateFormatter
|
||||
}
|
||||
|
||||
|
||||
constructor(
|
||||
private httpCilent: HttpClientService
|
||||
) { }
|
||||
|
||||
selectRow($event, i) {
|
||||
this.row_state = i;
|
||||
alert(i)
|
||||
}
|
||||
|
||||
getColor(col_CODE) {
|
||||
@@ -73,14 +94,14 @@ export class MainComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.changeDetectorRef.detach();
|
||||
/* 获取显示列 */
|
||||
this.httpCilent.get('/assets/mock-data/airline-col_code.json').subscribe(
|
||||
data => {
|
||||
data.sort(function (a, b) {
|
||||
return (a['COL_ORDER'] - b['COL_ORDER']);
|
||||
})
|
||||
this.airline_col_lists = data;
|
||||
this.col_lists = data;
|
||||
}
|
||||
)
|
||||
/* 获取航班动态信息 */
|
||||
@@ -88,34 +109,93 @@ export class MainComponent implements OnInit {
|
||||
data => {
|
||||
//解析数据
|
||||
data.forEach(element => {
|
||||
let air_message = JSON.parse(element.value);
|
||||
this.airline_row_lists.push(air_message);
|
||||
this.raw_data.push(JSON.parse(element.value));
|
||||
});
|
||||
|
||||
let combined_linked_data = this.raw_data
|
||||
// this.combined_data = this.raw_data
|
||||
|
||||
//查找链接航班并将其组合成一条数据
|
||||
for (let i = 0; i < this.airline_row_lists.length; i++) {
|
||||
if (this.airline_row_lists[i]['MVIN'] === 'D') {
|
||||
if (this.airline_row_lists[i]['TAID']) {
|
||||
let index = this.airline_row_lists.findIndex(val => { return val['FLID'] === this.airline_row_lists[i]['TAID'] });
|
||||
for (let i = 0; i < combined_linked_data.length; i++) {
|
||||
if (combined_linked_data[i]['MVIN'] === 'D') {
|
||||
if (combined_linked_data[i]['TAID']) {
|
||||
let index = combined_linked_data.findIndex(val => { return val['FLID'] === combined_linked_data[i]['TAID'] });
|
||||
if (index > -1) {
|
||||
this.airline_row_lists[i]['isLinked'] = true;
|
||||
this.airline_row_lists[i]['linkFlight'] = this.airline_row_lists[index];
|
||||
this.airline_row_lists.splice(index, 1);
|
||||
combined_linked_data[i]['isLinked'] = true;
|
||||
combined_linked_data[i]['linkFlight'] = combined_linked_data[index];
|
||||
combined_linked_data.splice(index, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//排序
|
||||
this.airline_row_lists.forEach(element => {
|
||||
element['order'] = this.sequence(element)
|
||||
element['ORDER'] = '+' + element['order']
|
||||
combined_linked_data.forEach(element => {
|
||||
let row_flights = {};
|
||||
let render_flight = {};
|
||||
let render_pre_flight = {};
|
||||
let render_rea_flight = {};
|
||||
if (element['MVIN'] === 'A' && !element['isLinked']) {
|
||||
row_flights['preFlight'] = element;
|
||||
|
||||
for (let i = 0; i < this.col_lists.length; i++) {
|
||||
let key = this.col_lists[i]['COL_CODE']
|
||||
render_flight[key] = typeof (this.formatter[key]) === 'function' ? this.formatter[key](row_flights['preFlight'][key],1) : this.formatter[key] ? this.formatter[key][row_flights['preFlight'][key]] : row_flights['preFlight'][key];
|
||||
}
|
||||
row_flights['renderFlight'] = render_flight;
|
||||
|
||||
} else if (element['MVIN'] === 'D' && !element['isLinked']) {
|
||||
row_flights['reaFlight'] = element;
|
||||
for (let i = 0; i < this.col_lists.length; i++) {
|
||||
let key = this.col_lists[i]['COL_CODE']
|
||||
render_flight[key] = typeof (this.formatter[key]) === 'function' ? this.formatter[key](row_flights['reaFlight'][key],1) : this.formatter[key] ? this.formatter[key][row_flights['reaFlight'][key]] : row_flights['reaFlight'][key];
|
||||
}
|
||||
row_flights['renderFlight'] = render_flight;
|
||||
|
||||
} else if (element['isLinked']) {
|
||||
row_flights['preFlight'] = element['linkFlight'];
|
||||
delete element['linkFlight'];
|
||||
delete element['isLinked'];
|
||||
row_flights['reaFlight'] = element;
|
||||
|
||||
for (let i = 0; i < this.col_lists.length; i++) {
|
||||
let key = this.col_lists[i]['COL_CODE']
|
||||
if (this.formatter.hasOwnProperty(key)) {
|
||||
if (typeof (this.formatter[key]) === 'function') {
|
||||
render_flight[key] = this.formatter[key](row_flights['preFlight'][key],1) + '/' + this.formatter[key](row_flights['reaFlight'][key],1);
|
||||
render_pre_flight[key] = this.formatter[key](row_flights['preFlight'][key],1);
|
||||
render_rea_flight[key] = this.formatter[key](row_flights['reaFlight'][key],1);
|
||||
} else {
|
||||
render_flight[key] = this.formatter[key][row_flights['preFlight'][key]] + '/' + this.formatter[key][row_flights['reaFlight'][key]];
|
||||
render_pre_flight[key] = this.formatter[key][row_flights['preFlight'][key]];
|
||||
render_rea_flight[key] = this.formatter[key][row_flights['reaFlight'][key]];
|
||||
}
|
||||
} else {
|
||||
render_flight[key] = row_flights['preFlight'][key] + '/' + row_flights['reaFlight'][key];
|
||||
render_pre_flight[key] = row_flights['preFlight'][key];
|
||||
render_rea_flight[key] = row_flights['reaFlight'][key];
|
||||
}
|
||||
}
|
||||
row_flights['renderFlight'] = render_flight;
|
||||
row_flights['renderPreFlight'] = render_pre_flight;
|
||||
row_flights['renderReaFlight'] = render_rea_flight;
|
||||
}
|
||||
this.combined_data.push(row_flights)
|
||||
})
|
||||
|
||||
this.airline_row_lists.sort(function (a, b) {
|
||||
return (a['order'] - b['order']);
|
||||
//排序
|
||||
this.combined_data.forEach(element => {
|
||||
element['ORDER'] = this.sequence(element)
|
||||
// element['ORDER'] = '+' + element['order']
|
||||
})
|
||||
|
||||
this.combined_data.sort(function (a, b) {
|
||||
return (a['ORDER'] - b['ORDER']);
|
||||
})
|
||||
|
||||
this.render_data = this.combined_data
|
||||
|
||||
this.changeDetectorRef.detectChanges();
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -159,80 +239,77 @@ export class MainComponent implements OnInit {
|
||||
let dateToCompare = new Date().getTime();
|
||||
if (!this.isCancled(flight) && !this.isDone(flight) && this.isDelayed(flight)) {
|
||||
if (this.isLinked(flight)) {
|
||||
if (this.getActualDatetime(flight['linkFlight']) && !this.getActualDatetime(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(this.getActualDatetime(flight['linkFlight']))).getTime();
|
||||
if (this.getActualDatetime(flight['preFlight']) && !this.getActualDatetime(flight['reaFlight'])) {
|
||||
dateToCompare = new Date(dateFormatter(this.getActualDatetime(flight['preFlight']))).getTime();
|
||||
dateTag = this.TOP_1;
|
||||
}
|
||||
else {
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight))).getTime();
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['reaFlight']))).getTime();
|
||||
dateTag = this.TOP_2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight))).getTime();
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['reaFlight']))).getTime();
|
||||
dateTag = this.TOP_3;
|
||||
}
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!this.isCancled(flight) && !this.isDone(flight) && this.isBoading(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight))).getTime();
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['reaFlight']))).getTime();
|
||||
dateTag = this.TOP_4;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!this.isCancled(flight) && !this.isDone(flight) && this.isFlying(flight)) {
|
||||
if (this.isArriFlight(flight)) {
|
||||
if (this.getEstimatedDatetime(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(this.getEstimatedDatetime(flight))).getTime();
|
||||
} else {
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight))).getTime();
|
||||
}
|
||||
} else if (this.isLinked(flight)) {
|
||||
if (this.getEstimatedDatetime(flight['linkFlight'])) {
|
||||
dateToCompare = new Date(dateFormatter(this.getEstimatedDatetime(flight['linkFlight']))).getTime();
|
||||
} else {
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['linkFlight']))).getTime();
|
||||
}
|
||||
if (!this.isCancled(flight) && !this.isDone(flight) && this.isFlying(flight) && !this.getActualDatetime(flight['preFlight'])) {
|
||||
if (this.getEstimatedDatetime(flight['preFlight'])) {
|
||||
dateToCompare = new Date(dateFormatter(this.getEstimatedDatetime(flight['preFlight']))).getTime();
|
||||
} else {
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['preFlight']))).getTime();
|
||||
}
|
||||
dateTag = this.TOP_5;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!this.isCancled(flight) && !this.isDone(flight) && this.isLinked(flight) && this.getActualDatetime(flight['linkFlight']) && !this.getActualDatetime(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(this.getActualDatetime(flight['linkFlight']))).getTime();
|
||||
if (!this.isCancled(flight) && !this.isDone(flight) && this.isLinked(flight) && this.getActualDatetime(flight['preFlight']) && !this.getActualDatetime(flight['reaFlight'])) {
|
||||
dateToCompare = new Date(dateFormatter(this.getActualDatetime(flight['preFlight']))).getTime();
|
||||
dateTag = this.TOP_6;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!this.isCancled(flight) && !this.isDone(flight) && this.isDeptFlight(flight) && !this.startBoading(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight))).getTime();
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['reaFlight']))).getTime();
|
||||
dateTag = this.TOP_7;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!this.isCancled(flight) && this.isArriFlight(flight) && this.isDone(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(this.getActualDatetime(flight))).getTime();
|
||||
dateToCompare = new Date(dateFormatter(this.getActualDatetime(flight['preFlight']))).getTime();
|
||||
dateTag = this.TOP_8;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!this.isCancled(flight) && !this.isDone(flight) && this.isOverBoading(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight))).getTime();
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['reaFlight']))).getTime();
|
||||
dateTag = this.TOP_9;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!this.isCancled(flight) && !this.isDone(flight) && !this.isFlying(flight)) {
|
||||
if (this.isLinked(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight))).getTime();
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['reaFlight']))).getTime();
|
||||
dateTag = this.TOP_10;
|
||||
} else if (this.isArriFlight(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight))).getTime();
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['preFlight']))).getTime();
|
||||
dateTag = this.TOP_11;
|
||||
}
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (!this.isCancled(flight) && this.isDone(flight) && (this.isLinked(flight) || this.isDeptFlight(flight))) {
|
||||
dateToCompare = new Date(dateFormatter(this.getActualDatetime(flight))).getTime();
|
||||
dateToCompare = new Date(dateFormatter(this.getActualDatetime(flight['reaFlight']))).getTime();
|
||||
dateTag = this.TOP_12;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
if (this.isCancled(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight))).getTime();
|
||||
if (this.isDeptFlight(flight)) {
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['reaFlight']))).getTime();
|
||||
} else {
|
||||
dateToCompare = new Date(dateFormatter(this.getScheduledDatetime(flight['preFlight']))).getTime();
|
||||
}
|
||||
|
||||
dateTag = this.TOP_13;
|
||||
return dateToCompare + dateTag;
|
||||
}
|
||||
@@ -273,7 +350,7 @@ export class MainComponent implements OnInit {
|
||||
* @return
|
||||
*/
|
||||
public isLinked(flight) {
|
||||
if (flight.isLinked) {
|
||||
if (flight['preFlight'] && flight['reaFlight']) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@@ -286,7 +363,7 @@ export class MainComponent implements OnInit {
|
||||
* @return
|
||||
*/
|
||||
public isDeptFlight(flight) {
|
||||
if (flight.MVIN === 'D' && !flight.isLinked) {
|
||||
if (!flight['preFlight'] && flight['reaFlight']) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@@ -300,7 +377,7 @@ export class MainComponent implements OnInit {
|
||||
* @return
|
||||
*/
|
||||
public isArriFlight(flight) {
|
||||
if (flight.MVIN === 'A' && !flight.isLinked) {
|
||||
if (flight['preFlight'] && !flight['reaFlight']) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -313,17 +390,11 @@ export class MainComponent implements OnInit {
|
||||
* @return
|
||||
*/
|
||||
public isFlying(flight) {
|
||||
if (this.isArriFlight(flight)) {
|
||||
if (flight['PADT']) {
|
||||
return true
|
||||
if (this.isArriFlight(flight) || this.isLinked(flight)) {
|
||||
if (flight['preFlight']['PADT']) {
|
||||
return true;
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
} else if (this.isLinked(flight)) {
|
||||
if (flight['linkFlight']['PADT']) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
@@ -337,14 +408,20 @@ export class MainComponent implements OnInit {
|
||||
* @return
|
||||
*/
|
||||
public isCancled(flight) {
|
||||
if (this.isArriFlight(flight) || this.isDeptFlight(flight)) {
|
||||
if (flight['CNCL']) {
|
||||
return true
|
||||
if (this.isArriFlight(flight)) {
|
||||
if (flight['preFlight']['CNCL']) {
|
||||
return true;
|
||||
} else {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
} else if (this.isDeptFlight(flight)) {
|
||||
if (flight['reaFlight']['CNCL']) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +432,7 @@ export class MainComponent implements OnInit {
|
||||
*/
|
||||
public isDelayed(flight) {
|
||||
if (this.isDeptFlight(flight) || this.isLinked(flight)) {
|
||||
if (flight['DELY']) {
|
||||
if (flight['reaFlight']['DELY']) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@@ -372,13 +449,13 @@ export class MainComponent implements OnInit {
|
||||
*/
|
||||
public isDone(flight) {
|
||||
if (this.isLinked(flight) || this.isDeptFlight(flight)) {
|
||||
if (!this.getActualDatetime(flight)) {
|
||||
if (!this.getActualDatetime(flight['reaFlight'])) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else if (this.isArriFlight(flight)) {
|
||||
if (!this.getActualDatetime(flight)) {
|
||||
if (!this.getActualDatetime(flight['preFlight'])) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -395,7 +472,7 @@ export class MainComponent implements OnInit {
|
||||
*/
|
||||
public startBoading(flight) {
|
||||
if (this.isLinked(flight) || this.isDeptFlight(flight)) {
|
||||
if (!flight['BOTM']) {
|
||||
if (!flight['reaFlight']['BOTM']) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@@ -413,7 +490,7 @@ export class MainComponent implements OnInit {
|
||||
*/
|
||||
public isBoading(flight) {
|
||||
if (this.isLinked(flight) || this.isDeptFlight(flight)) {
|
||||
if (flight['BOTM'] && !flight['GCTM']) {
|
||||
if (flight['reaFlight']['BOTM'] && !flight['reaFlight']['GCTM']) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user