优化worker处理及航线修改为简称

This commit is contained in:
zhouyuejun
2019-01-09 19:21:07 +08:00
parent 6f486bad94
commit ec59a1dc4c
10 changed files with 1321 additions and 72 deletions
@@ -18,17 +18,17 @@ import {ToastConfig} from './toast-model';
state('fancy', style([{transform: 'translateX(0)'},{transform: 'translateY(0)'}, {opacity: 1}, {maxWidth: 450}])),
transition('void => fancy', [
style({opacity: 0, maxWidth: 450, transform: 'translateX(100%)'}),
animate('300ms ease-in-out')
animate('1000ms ease-in-out')
]),
transition('fancy => void', [
animate('300ms ease-in-out', style({transform: 'translateX(100%)', height: 0, opacity: 0}))
animate('1000ms ease-in-out', style({transform: 'translateX(100%)', height: 0, opacity: 0}))
]),
transition('void => decent', [
style({opacity: 0, maxWidth: 0}),
animate('300ms ease-in-out')
animate('1000ms ease-in-out')
]),
transition('decent => void', [
animate('300ms ease-in-out', style({width: 0, opacity: 0}))
animate('1000ms ease-in-out', style({width: 0, opacity: 0}))
])
])
]
+8 -8
View File
@@ -196,21 +196,21 @@
[ngClass]="{'selected':row_state['renderFlight']['FLNO']===airline_row['renderFlight']['FLNO']}">
<td style="min-width:55px">{{start+i+1}}</td>
<td style="min-width:120px">
<img class="mr-2" *ngIf="getVipNotes(airline_row)" src="/adminweb/assets/images/important-notes/vip.png"
<img class="mr-2" *ngIf="getVipNotes(airline_row)" src="/assets/images/important-notes/vip.png"
alt="">
<img class="mr-2" *ngIf="getOutplanNotes(airline_row)" src="/adminweb/assets/images/important-notes/out_plan.png"
<img class="mr-2" *ngIf="getOutplanNotes(airline_row)" src="/assets/images/important-notes/out_plan.png"
alt="">
<img class="mr-2" *ngIf="getAlternateNotes(airline_row)" src="/adminweb/assets/images/important-notes/alternate.png"
<img class="mr-2" *ngIf="getAlternateNotes(airline_row)" src="/assets/images/important-notes/alternate.png"
alt="">
<img class="mr-2" *ngIf="getDelay30Notes(airline_row)" src="/adminweb/assets/images/important-notes/delay_30.png"
<img class="mr-2" *ngIf="getDelay30Notes(airline_row)" src="/assets/images/important-notes/delay_30.png"
alt="">
<img class="mr-2" *ngIf="getDelayNotes(airline_row)" src="/adminweb/assets/images/important-notes/delay.png"
<img class="mr-2" *ngIf="getDelayNotes(airline_row)" src="/assets/images/important-notes/delay.png"
alt="">
<img class="mr-2" *ngIf="getReturnNotes(airline_row)" src="/adminweb/assets/images/important-notes/return.png"
<img class="mr-2" *ngIf="getReturnNotes(airline_row)" src="/assets/images/important-notes/return.png"
alt="">
<img class="mr-2" *ngIf="getCancleNotes(airline_row)" src="/adminweb/assets/images/important-notes/cancle.png"
<img class="mr-2" *ngIf="getCancleNotes(airline_row)" src="/assets/images/important-notes/cancle.png"
alt="">
<img class="mr-2" *ngIf="getStopoverNotes(airline_row)" src="/adminweb/assets/images/important-notes/stopover.png"
<img class="mr-2" *ngIf="getStopoverNotes(airline_row)" src="/assets/images/important-notes/stopover.png"
alt="">
</td>
<td style="min-width:165px">{{airline_row['renderFlight']['FLID']}}</td>
+31 -7
View File
@@ -145,7 +145,6 @@ export class MainComponent implements OnInit {
console.log(message);
//是否可以开始处理动态消息
if (this.canHandleDynamicMessage) {
// this.webWorkerService.terminate(promise);
this.dynamicMessageHandle(message);
} else {
this.dynamicMessageArray.push(message);
@@ -328,7 +327,8 @@ export class MainComponent implements OnInit {
this.visibleCount = Math.ceil(this.tableBody.nativeElement.clientHeight / this.trItemHeight);
const scrollTop = this.tableBody.nativeElement.scrollTop;
const fixedScrollTop = scrollTop - scrollTop % this.trItemHeight;
this.tableContent.nativeElement.style.webkitTransform = `translateY(${fixedScrollTop}px)`;
this.tableContent.nativeElement.style.transform = `translateY(${fixedScrollTop}px)`;
this.start = Math.floor(scrollTop / this.trItemHeight);
this.end = this.start + this.visibleCount;
this.render_data = this.wait_render_data.slice(this.start, this.end);
@@ -463,6 +463,14 @@ export class MainComponent implements OnInit {
this.flightTypeSelections.push(this.flightTypes[index]);
}
this.creatWorkers();
}
/**
* 创建线程并执行
*/
creatWorkers() {
let dynamicData = {
raw_data: this.raw_data,
col_lists: this.col_lists,
@@ -472,10 +480,19 @@ export class MainComponent implements OnInit {
flightStatus: this.flightStatus,
flightTypes: this.flightTypes
}
// const promise = new Worker('/assets/web-worker-handle.js');
// promise.postMessage(dynamicData);
// promise.onmessage = function (e) {
// console.log('=====');
// this.combined_data = e.data;
// this.selectChange('dynamic');
// // promise.terminate();
// }.bind(this);
const promise = this.webWorkerService.run(webWorkerHandle, dynamicData);
promise.then(function (response) {
this.combined_data = response;
this.selectChange('dynamic');
this.webWorkerService.terminate(promise);
}.bind(this));
}
@@ -503,13 +520,20 @@ export class MainComponent implements OnInit {
'FLOP-FLBG': this.alertMessageHandle.flopFlbg.bind(this.alertMessageHandle),
'FLOP-RENO': this.alertMessageHandle.flopReno.bind(this.alertMessageHandle),
'FLOP-ABTM': this.alertMessageHandle.flopAbtm.bind(this.alertMessageHandle),
'FLOP-CHDT': this.alertMessageHandle.flopChdt.bind(this.alertMessageHandle),
'FLOP-CHOT': this.alertMessageHandle.flopChot.bind(this.alertMessageHandle),
'FLOP-TRML': this.alertMessageHandle.flopTrml.bind(this.alertMessageHandle),
}
dynamicAlertHandle(message) {
let alertType = message.META.TYPE + '-' + message.META.STYP;
let index = this.airline_message_alert.findIndex(val => val['COL_CODE'] === alertType);
if (index > -1) {
if (alertType === 'FLOP-FDEL') {
let index = this.raw_data.findIndex(element => element['FLID'] === message.FLOP.FLID);
if (index > -1) {
this.raw_data.splice(index, 1);
this.creatWorkers()
}
}
let alertText = this.alertMessage[alertType](message, this.airports);
const toastCfg = new ToastConfig(ToastType.SUCCESS, '', alertText, 600000);
this.toastService.toast(toastCfg);
@@ -576,7 +600,7 @@ export class MainComponent implements OnInit {
for (const key in filterItems) {
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
if (key === 'Abnormal_state') {
if (item['preFlight'][filterItems[key]]) {
if (item['preFlight'][filterItems[key]] && item['preFlight'][filterItems[key]].length > 0) {
is_satis = true;
continue;
} else {
@@ -620,7 +644,7 @@ export class MainComponent implements OnInit {
for (const key in filterItems) {
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
if (key === 'Abnormal_state') {
if (item['reaFlight'][filterItems[key]]) {
if (item['reaFlight'][filterItems[key]] && item['reaFlight'][filterItems[key]].length > 0) {
is_satis = true;
continue;
} else {
@@ -665,7 +689,7 @@ export class MainComponent implements OnInit {
for (const key in filterItems) {
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
if (key === 'Abnormal_state') {
if (item['preFlight'][filterItems[key]]) {
if (item['preFlight'][filterItems[key]] && item['preFlight'][filterItems[key]].length > 0) {
pre_satis = true;
continue;
} else {
@@ -706,7 +730,7 @@ export class MainComponent implements OnInit {
for (const key in filterItems) {
if (filterItems.hasOwnProperty(key) && filterItems[key]) {
if (key === 'Abnormal_state') {
if (item['reaFlight'][filterItems[key]]) {
if (item['reaFlight'][filterItems[key]] && item['reaFlight'][filterItems[key]].length > 0) {
rea_satis = true;
continue;
} else {
+1 -1
View File
@@ -150,7 +150,7 @@ export class AlertMessageHandle {
public flopAbtm(message,airports,citys) {
return message.FLOP.FFID + '靠桥撤桥消息';
}
public flopChdt(message,airports,citys) {
public flopChot(message,airports,citys) {
return message.FLOP.FFID + '上下轮档消息';
}
public flopTrml(message,airports,citys) {
+100 -10
View File
@@ -27,13 +27,42 @@ export class FlightsDataHandle {
'SODT': this.transferHandle.sodtFormatter.bind(this.transferHandle),
'GTDT': this.transferHandle.gateFormatter.bind(this.transferHandle),
'PADT': this.transferHandle.padtFormatter.bind(this.transferHandle),
'FLDT':this.transferHandle.fldtFormatter.bind(this.transferHandle)
'FLDT': this.transferHandle.fldtFormatter.bind(this.transferHandle)
}
public orderHandle = new DynamicFlightOrder();
public findLinkFlights(raw_flights) {
if (typeof Object.assign != 'function') {
// Must be writable: true, enumerable: false, configurable: true
Object.defineProperty(Object, "assign", {
value: function assign(target, varArgs) { // .length of function is 2
'use strict';
if (target == null) { // TypeError if undefined or null
throw new TypeError('Cannot convert undefined or null to object');
}
var to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];
if (nextSource != null) { // Skip over if undefined or null
for (var nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
},
writable: true,
configurable: true
});
}
let combined_raw_flights: Array<any> = [];
let copy_raw_flights = [];
raw_flights.forEach(element => {
@@ -76,6 +105,35 @@ export class FlightsDataHandle {
}
public flightsRenderTransfer(item, col_lists) {
if (typeof Object.assign != 'function') {
// Must be writable: true, enumerable: false, configurable: true
Object.defineProperty(Object, "assign", {
value: function assign(target, varArgs) { // .length of function is 2
'use strict';
if (target == null) { // TypeError if undefined or null
throw new TypeError('Cannot convert undefined or null to object');
}
var to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];
if (nextSource != null) { // Skip over if undefined or null
for (var nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
},
writable: true,
configurable: true
});
}
let render_flight = {},
render_pre_flight = {},
render_rea_flight = {},
@@ -125,7 +183,11 @@ export class FlightsDataHandle {
}
} else if (preHasValue && reaHasValue) {
if (preHasValue === reaHasValue) {
render_flight[key] = preHasValue;
if(key==='FLNO'){
render_flight[key] = preHasValue + ' / ' + reaHasValue;
}else{
render_flight[key] = preHasValue;
}
} else {
if (key === 'ERUT') {
render_flight[key] = preHasValue.split(' - ').slice(0, -1).join(' - ') + ' - ' + reaHasValue;
@@ -160,8 +222,15 @@ export class FlightsDataHandle {
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);
if(airportIndex>-1){
if(airports[airportIndex].briefNameChn){
erutChnArray.push(airports[airportIndex].briefNameChn);
}else{
erutChnArray.push(airports[airportIndex].airportNameChn);
}
}else{
erutChnArray.push(erutCodeArray[i]);
}
} catch (error) {
erutChnArray.push(erutCodeArray[i]);
}
@@ -181,8 +250,15 @@ export class FlightsDataHandle {
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);
if(airportIndex>-1){
if(airports[airportIndex].briefNameChn){
erutLinkChnArray.push(airports[airportIndex].briefNameChn);
}else{
erutLinkChnArray.push(airports[airportIndex].airportNameChn);
}
}else{
erutLinkChnArray.push(erutLinkCodeArray[i]);
}
} catch (error) {
erutLinkChnArray.push(erutLinkCodeArray[i]);
}
@@ -213,8 +289,15 @@ export class FlightsDataHandle {
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);
if(airportIndex>-1){
if(airports[airportIndex].briefNameChn){
erutPreChnArray.push(airports[airportIndex].briefNameChn);
}else{
erutPreChnArray.push(airports[airportIndex].airportNameChn);
}
}else{
erutPreChnArray.push(erutPreCodeArray[i]);
}
} catch (error) {
erutPreChnArray.push(erutPreCodeArray[i]);
}
@@ -235,8 +318,15 @@ export class FlightsDataHandle {
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);
if(airportIndex>-1){
if(airports[airportIndex].briefNameChn){
erutReaChnArray.push(airports[airportIndex].briefNameChn);
}else{
erutReaChnArray.push(airports[airportIndex].airportNameChn);
}
}else{
erutReaChnArray.push(erutReaCodeArray[i]);
}
} catch (error) {
erutReaChnArray.push(erutReaCodeArray[i]);
}
+79 -16
View File
@@ -1,11 +1,42 @@
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
if (typeof Object.assign != 'function') {
// Must be writable: true, enumerable: false, configurable: true
Object.defineProperty(Object, "assign", {
value: function assign(target, varArgs) { // .length of function is 2
'use strict';
if (target == null) { // TypeError if undefined or null
throw new TypeError('Cannot convert undefined or null to object');
}
var to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];
if (nextSource != null) { // Skip over if undefined or null
for (var nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
},
writable: true,
configurable: true
});
}
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
@@ -847,7 +878,11 @@ export default function (dynamicData) {
}
} else if (preHasValue && reaHasValue) {
if (preHasValue === reaHasValue) {
render_flight[key] = preHasValue;
if (key === 'FLNO') {
render_flight[key] = preHasValue + ' / ' + reaHasValue;
} else {
render_flight[key] = preHasValue;
}
} else {
if (key === 'ERUT') {
render_flight[key] = preHasValue.split(' - ').slice(0, -1).join(' - ') + ' - ' + reaHasValue;
@@ -886,8 +921,15 @@ export default function (dynamicData) {
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);
if(airportIndex>-1){
if(airports[airportIndex].briefNameChn){
erutChnArray.push(airports[airportIndex].briefNameChn);
}else{
erutChnArray.push(airports[airportIndex].airportNameChn);
}
}else{
erutChnArray.push(erutCodeArray[i]);
}
} catch (error) {
erutChnArray.push(erutCodeArray[i]);
}
@@ -907,8 +949,15 @@ export default function (dynamicData) {
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);
if(airportIndex>-1){
if(airports[airportIndex].briefNameChn){
erutLinkChnArray.push(airports[airportIndex].briefNameChn);
}else{
erutLinkChnArray.push(airports[airportIndex].airportNameChn);
}
}else{
erutLinkChnArray.push(erutLinkCodeArray[i]);
}
} catch (error) {
erutLinkChnArray.push(erutLinkCodeArray[i]);
}
@@ -939,8 +988,15 @@ export default function (dynamicData) {
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);
if(airportIndex>-1){
if(airports[airportIndex].briefNameChn){
erutPreChnArray.push(airports[airportIndex].briefNameChn);
}else{
erutPreChnArray.push(airports[airportIndex].airportNameChn);
}
}else{
erutPreChnArray.push(erutPreCodeArray[i]);
}
} catch (error) {
erutPreChnArray.push(erutPreCodeArray[i]);
}
@@ -961,8 +1017,15 @@ export default function (dynamicData) {
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);
if(airportIndex>-1){
if(airports[airportIndex].briefNameChn){
erutReaChnArray.push(airports[airportIndex].briefNameChn);
}else{
erutReaChnArray.push(airports[airportIndex].airportNameChn);
}
}else{
erutReaChnArray.push(erutReaCodeArray[i]);
}
} catch (error) {
erutReaChnArray.push(erutReaCodeArray[i]);
}

Before

Width:  |  Height:  |  Size: 864 B

After

Width:  |  Height:  |  Size: 864 B

File diff suppressed because it is too large Load Diff
+37 -25
View File
@@ -3,40 +3,52 @@
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
<title>航班信息查询系统</title>
<!--[if lt IE 9]>
<script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="./assets/theme/default/laydate.css?v=5.0.9" id="layuicss-laydate">
<style>
@-webkit-keyframes spin {
0% {
transform: rotate(0deg)
}
to {
transform: rotate(1turn)
}
0% {
transform: rotate(0deg)
}
@-moz-keyframes spin {
0% {
-moz-transform: rotate(0deg)
}
to {
-moz-transform: rotate(1turn)
}
to {
transform: rotate(1turn)
}
@keyframes spin {
0% {
transform: rotate(0deg)
}
to {
transform: rotate(1turn)
}
}
@-moz-keyframes spin {
0% {
-moz-transform: rotate(0deg)
}
/* .spin-container {
to {
-moz-transform: rotate(1turn)
}
}
@keyframes spin {
0% {
transform: rotate(0deg)
}
to {
transform: rotate(1turn)
}
}
/* .spin-container {
position: fixed;
top: 0;
left: 0;
@@ -87,7 +99,7 @@
border-top-color: #e7ba08;
animation: spin 1.5s linear infinite
} */
</style>
</style>
</head>
<body>
+1 -1
View File
@@ -38,7 +38,7 @@ import 'core-js/es6/set';
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/** IE10 and IE11 requires the following for the Reflect API. */
// import 'core-js/es6/reflect';
import 'core-js/es6/reflect';
/** Evergreen browsers require these. **/