From b0fb9421398d671a681d27506c6d363003403f4b Mon Sep 17 00:00:00 2001 From: zhouyuejun <505127606@qq.com> Date: Thu, 21 Feb 2019 17:49:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E8=81=94=E8=B0=83=E7=99=BB?= =?UTF-8?q?=E6=9C=BA=E9=97=A8=E5=92=8C=E5=80=BC=E6=9C=BA=E6=9F=9C=E5=8F=B0?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/pages/main/main.component.ts | 4 +- src/app/utils/alert-message-handle.ts | 9 ++-- src/app/utils/transfer-render-handle.ts | 58 +++++++++++++++++++++--- src/assets/web-worker-handle.js | 59 +++++++++++++++++++++++-- 4 files changed, 113 insertions(+), 17 deletions(-) diff --git a/src/app/pages/main/main.component.ts b/src/app/pages/main/main.component.ts index 1bd8094..e78b6fe 100644 --- a/src/app/pages/main/main.component.ts +++ b/src/app/pages/main/main.component.ts @@ -132,7 +132,7 @@ export class MainComponent implements OnInit { let data = JSON.parse(event as string); if (data.topic === 'schd') { let message = JSON.parse(data.message); - // console.log(message); + console.log(message); //是否可以开始处理动态消息 if (this.canHandleDynamicMessage) { this.dynamicMessageHandle(message); @@ -141,7 +141,7 @@ export class MainComponent implements OnInit { } } else if (data.topic === 'msg') { let message = JSON.parse(data.message); - // console.log(message); + console.log(message); if (this.canHandleDynamicAlert) { this.dynamicAlertHandle(message); } else { diff --git a/src/app/utils/alert-message-handle.ts b/src/app/utils/alert-message-handle.ts index 31a053b..263ef1d 100644 --- a/src/app/utils/alert-message-handle.ts +++ b/src/app/utils/alert-message-handle.ts @@ -68,9 +68,8 @@ export class AlertMessageHandle { temp2 = reason; } - - alertText += "\n延误码:" + code; - + // alertText += "\n延误码:" + code; + let fimsFlightstatusDefinition = null; if (flightStatusDefinitions && flightStatusDefinitions.length > 0) { @@ -153,8 +152,8 @@ export class AlertMessageHandle { let ckdts = message.FLOP["CKDT"]; for (let i = 0; i < ckdts.length; i++) { let chkc = ckdts[i]["CHKC"], - cotm = ckdts[i]["GOTM"], - cctm = ckdts[i]["GCTM"]; + cotm = ckdts[i]["COTM"], + cctm = ckdts[i]["CCTM"]; if (chkc) { ckdtCode += chkc + ":【值机打开:" + (!cotm ? "待定" : this.utils.dateFormatter(cotm)) + ";值机关闭:" + (!cctm ? "待定" : this.utils.dateFormatter(cctm)) + "】\n"; } diff --git a/src/app/utils/transfer-render-handle.ts b/src/app/utils/transfer-render-handle.ts index 2603d2e..a437528 100644 --- a/src/app/utils/transfer-render-handle.ts +++ b/src/app/utils/transfer-render-handle.ts @@ -58,16 +58,28 @@ export class TransferRenderHandle { } } public gctmFormatter(flight) { + function add0(m) { + return m < 10 ? '0' + m : m + } if (flight['GTDT']) { if (Array.isArray(flight['GTDT']) && flight['GTDT'].length > 0) { let gtdt = flight['GTDT']; + let gctmArray = []; gtdt.forEach(element => { - + if (element['GCTM']) { + let gctmTime = new Date(this.utils.dateFormatter(element['GCTM'])).getTime(); + gctmArray.push(gctmTime) + } }); + if (gctmArray.length > 0) { + let laterTime = Math.max.apply(null, gctmArray); + return add0(new Date(laterTime).getHours()) + ':' + add0(new Date(laterTime).getMinutes()) + } else { + return ''; + } - - return this.utils.timeFormatter(flight['GTDT'][0]['GCTM']); + // return this.utils.timeFormatter(flight['GTDT'][0]['GCTM']); } else if (Object.prototype.toString.call(flight['GTDT']) === '[object Object]') { return this.utils.timeFormatter(flight['GTDT']['GCTM']); } else { @@ -183,9 +195,26 @@ export class TransferRenderHandle { } } public cctmFormatter(flight) { + function add0(m) { + return m < 10 ? '0' + m : m + } if (flight['CKDT']) { if (Array.isArray(flight['CKDT']) && flight['CKDT'].length > 0) { - return this.utils.timeFormatter(flight['CKDT'][0]['CCTM']); + let ckdt = flight['CKDT']; + let cctmArray = []; + ckdt.forEach(element => { + if (element['CCTM']) { + let cctmTime = new Date(this.utils.dateFormatter(element['CCTM'])).getTime(); + cctmArray.push(cctmTime) + } + }); + + if (cctmArray.length > 0) { + let laterTime = Math.max.apply(null, cctmArray); + return add0(new Date(laterTime).getHours()) + ':' + add0(new Date(laterTime).getMinutes()) + } else { + return ''; + } } else if (Object.prototype.toString.call(flight['CKDT']) === '[object Object]') { return this.utils.timeFormatter(flight['CKDT']['CCTM']); } else { @@ -196,11 +225,28 @@ export class TransferRenderHandle { } } public cotmFormatter(flight) { + function add0(m) { + return m < 10 ? '0' + m : m + } if (flight['CKDT']) { if (Array.isArray(flight['CKDT']) && flight['CKDT'].length > 0) { - return this.utils.timeFormatter(flight['CKDT'][0]['COTM']); + let ckdt = flight['CKDT']; + let cotmArray = []; + ckdt.forEach(element => { + if (element['COTM']) { + let cctmTime = new Date(this.utils.dateFormatter(element['COTM'])).getTime(); + cotmArray.push(cctmTime) + } + }); + + if (cotmArray.length > 0) { + let laterTime = Math.min.apply(null, cotmArray); + return add0(new Date(laterTime).getHours()) + ':' + add0(new Date(laterTime).getMinutes()) + } else { + return ''; + } } else if (Object.prototype.toString.call(flight['CKDT']) === '[object Object]') { - return this.utils.timeFormatter(flight['CKDT']['COTM']); + return this.utils.timeFormatter(flight['CKDT']['CCTM']); } else { return ''; } diff --git a/src/assets/web-worker-handle.js b/src/assets/web-worker-handle.js index d396be4..86acfa7 100644 --- a/src/assets/web-worker-handle.js +++ b/src/assets/web-worker-handle.js @@ -234,9 +234,26 @@ onmessage = function (dynamicData) { } }, 'GCTM': function gctmFormatter(flight) { + function add0(m) { + return m < 10 ? '0' + m : m + } if (flight['GTDT']) { if (Array.isArray(flight['GTDT']) && flight['GTDT'].length > 0) { - return timeFormatter(flight['GTDT'][0]['GCTM']); + let gtdt = flight['GTDT']; + let gctmArray = []; + gtdt.forEach(element => { + if (element['GCTM']) { + let gctmTime = new Date(dateFormatter(element['GCTM'])).getTime(); + gctmArray.push(gctmTime) + } + }); + + if (gctmArray.length > 0) { + let laterTime = Math.max.apply(null, gctmArray); + return add0(new Date(laterTime).getHours()) + ':' + add0(new Date(laterTime).getMinutes()) + } else { + return ''; + } } else if (Object.prototype.toString.call(flight['GTDT']) === '[object Object]') { return timeFormatter(flight['GTDT']['GCTM']); } else { @@ -352,9 +369,26 @@ onmessage = function (dynamicData) { } }, 'CCTM': function cctmFormatter(flight) { + function add0(m) { + return m < 10 ? '0' + m : m + } if (flight['CKDT']) { if (Array.isArray(flight['CKDT']) && flight['CKDT'].length > 0) { - return timeFormatter(flight['CKDT'][0]['CCTM']); + let ckdt = flight['CKDT']; + let cctmArray = []; + ckdt.forEach(element => { + if (element['CCTM']) { + let cctmTime = new Date(dateFormatter(element['CCTM'])).getTime(); + cctmArray.push(cctmTime) + } + }); + + if (cctmArray.length > 0) { + let laterTime = Math.max.apply(null, cctmArray); + return add0(new Date(laterTime).getHours()) + ':' + add0(new Date(laterTime).getMinutes()) + } else { + return ''; + } } else if (Object.prototype.toString.call(flight['CKDT']) === '[object Object]') { return timeFormatter(flight['CKDT']['CCTM']); } else { @@ -365,11 +399,28 @@ onmessage = function (dynamicData) { } }, 'COTM': function cotmFormatter(flight) { + function add0(m) { + return m < 10 ? '0' + m : m + } if (flight['CKDT']) { if (Array.isArray(flight['CKDT']) && flight['CKDT'].length > 0) { - return timeFormatter(flight['CKDT'][0]['COTM']); + let ckdt = flight['CKDT']; + let cotmArray = []; + ckdt.forEach(element => { + if (element['COTM']) { + let cctmTime = new Date(dateFormatter(element['COTM'])).getTime(); + cotmArray.push(cctmTime) + } + }); + + if (cotmArray.length > 0) { + let laterTime = Math.min.apply(null, cotmArray); + return add0(new Date(laterTime).getHours()) + ':' + add0(new Date(laterTime).getMinutes()) + } else { + return ''; + } } else if (Object.prototype.toString.call(flight['CKDT']) === '[object Object]') { - return timeFormatter(flight['CKDT']['COTM']); + return timeFormatter(flight['CKDT']['CCTM']); } else { return ''; }