Commit 5af824efe3960929f52e5c0c416a95e98f6fe6bd

Authored by 徐烜
1 parent 680c90de

时刻表v2_2.3.3

Main_v2_2_ExcelObj.js基本搞定,可以导出吃饭和正常班次,每个分班点会空1圈的位置方便后续加出场报道班次,防止excel格子不够
TODO:报道,出场,进场,离场班次会在v2_2.3.4中加
TODO:这里假设排序的班次是按照从早到晚,每一圈班次按照路牌顺序排列,如果同一圈班次有混排不完全按照路牌顺序排,导出格式可能会乱,这个在v2_2.3.4和v2_2_3.5中一起解决
src/main/resources/static/pages/base/timesmodel/js/v2_2/Main_v2_2_ExcelObj.js
1 -/**  
2 - * v2_2版本时刻表excel对象。  
3 - */  
4 -var Main_v2_2_ExcelObj = (function() {  
5 - // html5导出下载文件方法  
6 - var _fnDownloadFile = function(data, mimeType, fileName) {  
7 - var success = false;  
8 - var blob = new Blob([data], { type: mimeType });  
9 - try {  
10 - if (navigator.msSaveBlob)  
11 - navigator.msSaveBlob(blob, fileName);  
12 - else {  
13 - // Try using other saveBlob implementations, if available  
14 - var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;  
15 - if (saveBlob === undefined) throw "Not supported";  
16 - saveBlob(blob, fileName);  
17 - }  
18 - success = true;  
19 - } catch (ex) {  
20 - console.log("saveBlob method failed with the following exception:");  
21 - console.log(ex);  
22 - }  
23 -  
24 - if (!success) {  
25 - // Get the blob url creator  
26 - var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;  
27 - if (urlCreator) {  
28 - // Try to use a download link  
29 - var link = document.createElement('a');  
30 - if ('download' in link) {  
31 - // Try to simulate a click  
32 - try {  
33 - // Prepare a blob URL  
34 - var url = urlCreator.createObjectURL(blob);  
35 - link.setAttribute('href', url);  
36 -  
37 - // Set the download attribute (Supported in Chrome 14+ / Firefox 20+)  
38 - link.setAttribute("download", fileName);  
39 -  
40 - // Simulate clicking the download link  
41 - var event = document.createEvent('MouseEvents');  
42 - event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);  
43 - link.dispatchEvent(event);  
44 - success = true;  
45 -  
46 - } catch (ex) {  
47 - console.log("Download link method with simulated click failed with the following exception:");  
48 - console.log(ex);  
49 - }  
50 - }  
51 -  
52 - if (!success) {  
53 - // Fallback to window.location method  
54 - try {  
55 - // Prepare a blob URL  
56 - // Use application/octet-stream when using window.location to force download  
57 - var url = urlCreator.createObjectURL(blob);  
58 - window.location = url;  
59 - console.log("Download link method with window.location succeeded");  
60 - success = true;  
61 - } catch (ex) {  
62 - console.log("Download link method with window.location failed with the following exception:");  
63 - console.log(ex);  
64 - }  
65 - }  
66 - }  
67 - }  
68 -  
69 - if (!success) {  
70 - // Fallback to window.open method  
71 - console.log("No methods worked for saving the arraybuffer, using last resort window.open");  
72 - window.open("", '_blank', '');  
73 - }  
74 - };  
75 -  
76 - // 计算导出参数sheet数据。  
77 - var _fnCalcuExportParam_sheet = function(_paramObj) {  
78 - return [  
79 - {'paramItem' : '上行首班时间', 'paramValue' : _paramObj.getUpFirstDTimeObj().format("HH:mm")},  
80 - {'paramItem' : '上行末班时间', 'paramValue' : _paramObj.getUpLastDtimeObj().format("HH:mm")},  
81 - {'paramItem' : '下行首班时间', 'paramValue' : _paramObj.getDownFirstDTimeObj().format("HH:mm")},  
82 - {'paramItem' : '下行末班时间', 'paramValue' : _paramObj.getDownLastDTimeObj().format("HH:mm")},  
83 - {'paramItem' : '早高峰开始时间', 'paramValue' : _paramObj.getMPeakStartTimeObj().format("HH:mm")},  
84 - {'paramItem' : '早高峰结束时间', 'paramValue' : _paramObj.getMPeakEndTimeObj().format("HH:mm")},  
85 - {'paramItem' : '晚高峰开始时间', 'paramValue' : _paramObj.getEPeakStartTimeObj().format("HH:mm")},  
86 - {'paramItem' : '晚高峰结束时间', 'paramValue' : _paramObj.getEPeakEndTimeObj().format("HH:mm")},  
87 - {'paramItem' : '上行进场时间', 'paramValue' : _paramObj.getUpInTime()},  
88 - {'paramItem' : '上行出场时间', 'paramValue' : _paramObj.getUpOutTime()},  
89 - {'paramItem' : '下行进场时间', 'paramValue' : _paramObj.getDownInTime()},  
90 - {'paramItem' : '下行出场时间', 'paramValue' : _paramObj.getDownOutTime()},  
91 - {'paramItem' : '早高峰上行时间', 'paramValue' : _paramObj.getUpMPeakTime()},  
92 - {'paramItem' : '早高峰下行时间', 'paramValue' : _paramObj.getDownMPeakTime()},  
93 - {'paramItem' : '晚高峰上行时间', 'paramValue' : _paramObj.getUpEPeakTime()},  
94 - {'paramItem' : '晚高峰下行时间', 'paramValue' : _paramObj.getDownEPeakTime()},  
95 - {'paramItem' : '低谷上行时间', 'paramValue' : _paramObj.getUpTroughTime()},  
96 - {'paramItem' : '低谷下行时间', 'paramValue' : _paramObj.getDownTroughTime()},  
97 - {'paramItem' : '线路规划类型', 'paramValue' : "双向"},  
98 - {'paramItem' : '吃饭地点', 'paramValue' : _paramObj.fnIsEat() ? (_paramObj.fnIsBothEat() ? "上下行" : (_paramObj.fnIsUpEat() ? "上行" : "下行")) : "不吃饭"},  
99 - {'paramItem' : '早晚例行保养', 'paramValue' : _paramObj.getLbTime()},  
100 - {'paramItem' : '停车场', 'paramValue' : _paramObj.getTccId()},  
101 - {'paramItem' : '工作餐午餐时间', 'paramValue' : _paramObj.fnGetLunchTime()},  
102 - {'paramItem' : '工作餐晚餐时间', 'paramValue' : _paramObj.fnGetDinnerTime()},  
103 - {'paramItem' : '早高峰发车间隔', 'paramValue' : "[" + _paramObj.getMPeakMinFcjx() + "," + _paramObj.getMPeakMaxFcjx() + "]"},  
104 - {'paramItem' : '晚高峰发车间隔', 'paramValue' : "[" + _paramObj.getEPeakMinFcjx() + "," + _paramObj.getEPeakMaxFcjx() + "]"},  
105 - {'paramItem' : '低谷发车间隔', 'paramValue' : "[" + _paramObj.getTroughMinFcjx() + "," + _paramObj.getTroughMaxFcjx() + "]"},  
106 - {'paramItem' : '建议加班路牌数', 'paramValue' : _paramObj.getJBLpes()},  
107 - {'paramItem' : '停站类型', 'paramValue' : _paramObj.isTwoWayStop() ? "双向停站" : (_paramObj.isUpOneWayStop() ? "上行主站" : "下行主站") },  
108 - {'paramItem' : '建议高峰配车数', 'paramValue' : _paramObj.getAdvicePeakClzs()}  
109 - ]  
110 - };  
111 -  
112 - // 计算班次统计数据sheet数据。  
113 - var _fnCalcuExportStatInfo_sheet = function(aBc, oParam) {  
114 - var countBc = 0, // 总班次  
115 - serviceBc = 0, // 营运班次  
116 - jcbc = 0, // 进场总班次.  
117 - ccbc = 0, // 出场总班次.  
118 - cfbc = 0, // 吃饭总班次.  
119 - zwlbbc = 0, // 早晚例保总班次.  
120 - countGs = 0.0, // 总工时  
121 - servicesj = 0, // 营运班次总时间  
122 - jcsj = 0.0, // 进场总时间.  
123 - ccsj = 0.0, // 出场总时间.  
124 - cfsj = 0.0, // 吃饭总时间.  
125 - zwlbsj = 0.0, // 早晚例保总时间.  
126 - ksBc = 0, // 空驶班次  
127 - serviceLc = 0.0, // 营运里程  
128 - ksLc = 0.0, // 空驶里程  
129 - avgTzjx = 0.0, // 平均停站间隙  
130 - gfServiceBc = 0, // 高峰营运班次  
131 - dgServiceBc = 0, // 低谷营运班次  
132 - gfAvgTzjx = 0.0, // 高峰平均停站间隙  
133 - dgAvgTzjx = 0.0; // 低谷平均停站间隙  
134 -  
135 - var i;  
136 - var oBc;  
137 - for (i = 0; i < aBc.length; i++) {  
138 - oBc = aBc[i];  
139 -  
140 - if (oBc.bcsj > 0) {  
141 - countBc = countBc + 1;  
142 - countGs = countGs + oBc.STOPTIME + oBc.bcsj;  
143 - if (oParam.isTroughBc(oParam.toTimeObj(oBc.fcsj))) {  
144 - if (oBc.bcType == "normal") {  
145 - dgServiceBc = dgServiceBc + 1;  
146 - dgAvgTzjx = dgAvgTzjx + oBc.STOPTIME;  
147 - }  
148 - } else {  
149 - if (oBc.bcType == "normal") {  
150 - gfServiceBc = gfServiceBc + 1;  
151 - gfAvgTzjx = gfAvgTzjx + oBc.STOPTIME;  
152 - }  
153 - }  
154 -  
155 - if (oBc.bcType == "normal" || oBc.bcType == "cf") {  
156 - serviceBc = serviceBc + 1;  
157 - serviceLc = serviceLc + oBc.jhlc;  
158 - servicesj = servicesj + oBc.bcsj;  
159 - avgTzjx = avgTzjx + oBc.STOPTIME;  
160 -  
161 - if (oBc.bcType == "cf") {  
162 - cfbc = cfbc + 1;  
163 - cfsj = cfsj + oBc.bcsj;  
164 - }  
165 - } else if (oBc.bcType == "in") {  
166 - jcbc = jcbc + 1;  
167 - jcsj = jcsj + oBc.bcsj;  
168 - } else if (oBc.bcType == "out") {  
169 - ccbc = ccbc + 1;  
170 - ccsj = ccsj + oBc.bcsj;  
171 - } else if (oBc.bcType == "bd") {  
172 - zwlbbc = zwlbbc + 1;  
173 - zwlbsj = zwlbsj + oBc.bcsj;  
174 - } else if (oBc.bcType == "lc") {  
175 - zwlbbc = zwlbbc + 1;  
176 - zwlbsj = zwlbsj + oBc.bcsj;  
177 - }  
178 - }  
179 - }  
180 -  
181 - dgAvgTzjx = dgAvgTzjx / dgServiceBc;  
182 - gfAvgTzjx = gfAvgTzjx / gfServiceBc;  
183 - avgTzjx = avgTzjx / dgServiceBc;  
184 -  
185 - return [  
186 - {'statItem': '总班次(包括进出场、吃饭时间、早晚例保、营运且班次时间大于零的班次)', 'statValue': countBc},  
187 - {'statItem': '进场总班次(包括进场且班次时间大于零的班次)', 'statValue': jcbc},  
188 - {'statItem': '出场总班次(包括进场且班次时间大于零的班次)', 'statValue': ccbc},  
189 - {'statItem': '吃饭总班次(包括吃饭且班次时间大于零的班次)', 'statValue': cfbc},  
190 - {'statItem': '早晚例保总班次(包括早晚例保且时间大于零的班次)', 'statValue': zwlbbc},  
191 - {'statItem': '营运总班次(包括正常、区间、放大站且班次时间大于零班次)','statValue': serviceBc},  
192 - {'statItem': '进场总时间(包括进场班次且班次时间大于零)', 'statValue': jcsj/60},  
193 - {'statItem': '出场总时间(包括进场班次且班次时间大于零)', 'statValue': ccsj/60},  
194 - {'statItem': '吃饭总时间(包括吃饭班次且班次时间大于零)', 'statValue': cfsj/60},  
195 - {'statItem': '早晚例保总时间(包括早晚例保班次且时间大于零的)', 'statValue': zwlbsj/60},  
196 - {'statItem': '营运班次总时间(包括正常、区间、放大站且班次时间大于零)', 'statValue': servicesj/60},  
197 - {'statItem': '总工时(包括进出场、吃饭时间、早晚例保、营运班次时间)', 'statValue': countGs/60},  
198 - {'statItem': '空驶班次(包括直放班次)', 'statValue': ksBc},  
199 - {'statItem': '营运里程(包括正常、区间、放大站里程)', 'statValue': serviceLc},  
200 - {'statItem': '空驶里程(包括直放里程)', 'statValue': ksLc},  
201 - {'statItem': '平均停站时间(营运班次停站时间总和/营运总班次)', 'statValue': avgTzjx},  
202 - {'statItem': '高峰营运班次(包括早晚高峰时段的正常、区间、放大站班次)', 'statValue': gfServiceBc},  
203 - {'statItem': '低谷营运班次(包括低谷时段的正常、区间、放大站班次)', 'statValue': dgServiceBc},  
204 - {'statItem': '高峰平均停站间隙(高峰营运班次停站时间总和/高峰营运班次总和)', 'statValue': gfAvgTzjx},  
205 - {'statItem': '低谷平均停站间隙(低谷营运班次停站时间总和/低谷营运班次总和)', 'statValue': dgAvgTzjx},  
206 - {'statItem': '综合评估', 'statValue': 3}  
207 - ];  
208 -  
209 - };  
210 -  
211 - /**  
212 - * 内部计算Excel班次方法1,  
213 - * 这里是假设班次按照从早到晚排序,并且路牌也是从小到大排序。  
214 - * @param aExcelLp excel显示用路牌  
215 - * @param aGanttBc 甘特图班次列表  
216 - * @param oParam 参数对象  
217 - * @param bQIsUp 每一圈是上行开始还是下行开始  
218 - * @private  
219 - */  
220 - function InternalCalcuExcelBc1(aExcelLp, aGanttBc, oParam, bQIsUp) {  
221 - this._aExcelLp = aExcelLp;  
222 - this._oParam = oParam;  
223 - this._bQIsUp = bQIsUp;  
224 -  
225 - this._iUpGroupIndex = 0;  
226 - this._iDownGroupIndex = 0;  
227 -  
228 - // {"路牌名字":{"isFlag": 是否为标记班次(表示扫描过但是没有班次对象),"normal":正常班次}}  
229 - this._oLpGroupNormalGanttBc = {};  
230 - // {"路牌名字":{"cf":吃饭班次}}  
231 - this._oLpGroupCfGanttBc = {};  
232 -  
233 - // TODO:其他类型的班次再议  
234 -  
235 - // 计算上行gantt班次列表,下行gantt班次列表,并排序  
236 - var i;  
237 - var oGanttBc;  
238 - this._aUpGanttBc = [];  
239 - this._aDownGanttBc = [];  
240 - for (i = 0; i < aGanttBc.length; i++) {  
241 - oGanttBc = aGanttBc[i];  
242 - if (oGanttBc.xlDir == "relationshipGraph-up") {  
243 - this._aUpGanttBc.push(oGanttBc);  
244 - } else {  
245 - this._aDownGanttBc.push(oGanttBc);  
246 - }  
247 - }  
248 - this._aUpGanttBc.sort(function (o1, o2) { // 时间从早到晚排序  
249 - if (oParam.toTimeObj(o1.fcsj).isBefore(oParam.toTimeObj(o2.fcsj))) {  
250 - return -1;  
251 - } else {  
252 - return 1;  
253 - }  
254 - });  
255 - this._aDownGanttBc.sort(function (o1, o2) { // 时间从早到晚排序  
256 - if (oParam.toTimeObj(o1.fcsj).isBefore(oParam.toTimeObj(o2.fcsj))) {  
257 - return -1;  
258 - } else {  
259 - return 1;  
260 - }  
261 - });  
262 -  
263 - }  
264 -  
265 - //----------------------- 外部方法 -----------------------//  
266 - InternalCalcuExcelBc1.prototype.fnCalcuExcelLpBcList = function() {  
267 - // 计算Excel班次  
268 - this._calcuExcelBc(true); // 上行  
269 - // this._calcuExcelBc(false); // 下行  
270 -  
271 - // 设置路牌圈数,路由id  
272 - var iGroupCount = this._iUpGroupIndex > this._iDownGroupIndex ?  
273 - (this._iUpGroupIndex + 1) : (this._iDownGroupIndex + 1);  
274 -  
275 - var i;  
276 - var stationRouteId1;  
277 - var stationRouteId2;  
278 - var oGanttBc;  
279 - for (i = 0; i < this._aUpGanttBc.length; i++) {  
280 - oGanttBc = this._aUpGanttBc[i];  
281 - if (oGanttBc.bcType == "normal") {  
282 - if (this._bQIsUp) {  
283 - stationRouteId1 = oGanttBc.qdz;  
284 - break;  
285 - } else {  
286 - stationRouteId2 = oGanttBc.qdz;  
287 - break;  
288 - }  
289 - }  
290 - }  
291 - for (i = 0; i < this._aDownGanttBc.length; i++) {  
292 - oGanttBc = this._aUpGanttBc[i];  
293 - if (oGanttBc.bcType == "normal") {  
294 - if (!this._bQIsUp) {  
295 - stationRouteId1 = oGanttBc.qdz;  
296 - break;  
297 - } else {  
298 - stationRouteId2 = oGanttBc.qdz;  
299 - break;  
300 - }  
301 - }  
302 - }  
303 -  
304 - var oExcelLp;  
305 - for (i = 0; i < this._aExcelLp.length; i++) {  
306 - oExcelLp = this._aExcelLp[i];  
307 - oExcelLp.groupCount = iGroupCount;  
308 - oExcelLp.stationRouteId1 = stationRouteId1;  
309 - oExcelLp.stationRouteId2 = stationRouteId2;  
310 - }  
311 -  
312 - return this._aExcelLp;  
313 - };  
314 -  
315 - //----------------------- 内部方法 ------------------------//  
316 - /**  
317 - * 重新计算Excel显示班次。  
318 - * @param bIsUp 是否上行  
319 - */  
320 - InternalCalcuExcelBc1.prototype._calcuExcelBc = function(bIsUp) {  
321 - this._oLpGroupNormalGanttBc = {};  
322 - this._oLpGroupCfGanttBc = {};  
323 -  
324 - var i;  
325 - var j = 0;  
326 - var oExcelLp;  
327 - var oGanttBc;  
328 - var aGBc = bIsUp ? this._aUpGanttBc : this._aDownGanttBc;  
329 - for (i = 0; i < aGBc.length; i++) {  
330 - oGanttBc = aGBc[i];  
331 - while (j < this._aExcelLp.length) {  
332 - oExcelLp = this._aExcelLp[j];  
333 - if (this._isResetCalcuGroup(oGanttBc)) {  
334 - this._resetCalcuGroup(bIsUp);  
335 - j = 0;  
336 - i--;  
337 - break;  
338 - } else {  
339 - // TODO:其他类型班次再议  
340 -  
341 - if (oGanttBc.bcType == "cf") {  
342 - this._oLpGroupCfGanttBc[oGanttBc.lpName] = {  
343 - "cf": oGanttBc  
344 - };  
345 - break;  
346 - }  
347 -  
348 - if (oExcelLp.lpname == oGanttBc.lpName) {  
349 - if (oGanttBc.bcType == "normal") {  
350 - this._oLpGroupNormalGanttBc[oGanttBc.lpName] = {  
351 - "isFlag": false, "normal": oGanttBc  
352 - };  
353 - }  
354 - j = (j + 1) % this._aExcelLp.length;  
355 - break;  
356 - } else { // 当前路牌无对应班次,标记找过班次  
357 - this._oLpGroupNormalGanttBc[oExcelLp.lpname] = {  
358 - "isFlag": true, "normal": null  
359 - };  
360 - j = (j + 1) % this._aExcelLp.length;  
361 - }  
362 - }  
363 - }  
364 -  
365 - }  
366 -  
367 - };  
368 - InternalCalcuExcelBc1.prototype._resetCalcuGroup = function(bIsUp) {  
369 - // 重置计算圈及班次  
370 - var oExcelLp;  
371 - var oGroupGanttNormalBc;  
372 - var oGroupGanttEatBc;  
373 - for (var i = 0; i < this._aExcelLp.length; i++) {  
374 - oExcelLp = this._aExcelLp[i];  
375 - if (this._oLpGroupNormalGanttBc[oExcelLp.lpname]) {  
376 - if (!this._oLpGroupNormalGanttBc[oExcelLp.lpname].isFlag) { // 非标记班次  
377 - oGroupGanttNormalBc = this._oLpGroupNormalGanttBc[oExcelLp.lpname].normal;  
378 - }  
379 - }  
380 - if (this._oLpGroupCfGanttBc[oExcelLp.lpname]) {  
381 - oGroupGanttEatBc = this._oLpGroupCfGanttBc[oExcelLp.lpname].cf;  
382 - }  
383 - if (oGroupGanttNormalBc) {  
384 - oExcelLp.bcObjList.push({  
385 - "bcsj": oGroupGanttNormalBc.bcsj, // 班次时间  
386 - "ssj": oGroupGanttNormalBc.STOPTIME, // 停站时间  
387 - "eatsj": oGroupGanttEatBc ? oGroupGanttEatBc.bcsj : 0, // 吃饭时间  
388 -  
389 - "tccid": oGroupGanttNormalBc.tcc, // 停车场id  
390 - "qdzid": oGroupGanttNormalBc.qdz, // 起点站id  
391 - "zdzid": oGroupGanttNormalBc.zdz, // 终点站id  
392 -  
393 - "isUp": bIsUp, // 是否上行  
394 -  
395 - "bcType": oGroupGanttNormalBc.bcType, // 班次类型  
396 - "fcsj": oGroupGanttEatBc ?  
397 - ("*" + oGroupGanttNormalBc.fcsj) :  
398 - oGroupGanttNormalBc.fcsj, // 发车时间描述  
399 - "fcsjDesc": oGroupGanttEatBc ?  
400 - ("(吃" + oGroupGanttNormalBc.fcsj + ")") :  
401 - oGroupGanttNormalBc.fcsj, // 发车时间描述2  
402 -  
403 - "groupNo": bIsUp ? this._iUpGroupIndex : this._iDownGroupIndex, // 第几圈  
404 - "groupBcNo": bIsUp == this._bQIsUp ? 0 : 1 // 圈里第几个班次  
405 -  
406 - });  
407 - }  
408 - }  
409 -  
410 - if (bIsUp) {  
411 - this._iUpGroupIndex ++;  
412 - } else {  
413 - this._iDownGroupIndex ++;  
414 - }  
415 - this._oLpGroupNormalGanttBc = {};  
416 - this._oLpGroupCfGanttBc = {};  
417 - };  
418 - InternalCalcuExcelBc1.prototype._isResetCalcuGroup = function(oGanttBc) {  
419 - // 是否重置计算圈,当oGanttBc存在相同路牌的班次或者标记班次,算下一个圈  
420 - if (oGanttBc.bcType == "cf") {  
421 - return false;  
422 - }  
423 - if (this._oLpGroupNormalGanttBc[oGanttBc.lpName]) {  
424 - return true;  
425 - } else {  
426 - return false;  
427 - }  
428 -  
429 - };  
430 -  
431 - /**  
432 - * 内部Excel对象。  
433 - * @param oParam 参数对象  
434 - * @param fnGetGanttBcArray 返回gantt用的班次列表  
435 - * @constructor  
436 - */  
437 - function InternalExcelObj(oParam, fnGetGanttBcArray) {  
438 - this._oParam = oParam;  
439 - this.aGanttBc = fnGetGanttBcArray();  
440 -  
441 - // 每一圈是上行开始还是下行开始  
442 - this._qIsUp = oParam.getUpFirstDTimeObj().diff(oParam.getDownFirstDTimeObj()) <= 0 ? false : true;  
443 -  
444 - // 构造显示用lp对象  
445 - var oTempLpFlag = {};  
446 - var oGanttBc;  
447 - var aLp = [];  
448 - var oLp;  
449 - var i;  
450 - for (i = 0; i < this.aGanttBc.length; i++) {  
451 - oGanttBc = this.aGanttBc[i];  
452 - if (oTempLpFlag[oGanttBc.lpName]) {  
453 - // 已经存在路牌,不处理  
454 - continue;  
455 - }  
456 -  
457 - oLp = {  
458 - "lpname": oGanttBc.lpName, // 路牌名字  
459 - "isUp": this._qIsUp, // 每圈的第一个班次是否上行  
460 - "bcObjList": [], // 内部班次列表(后面计算班次列表)  
461 - "groupCount": 0, // 总圈数(后面计算总圈数)  
462 - "zlc": 0, // 总里程  
463 - "yylc": 0, // 营运里程  
464 - "kslc": 0, // 空驶里程  
465 - "zgs": 0, // 总工时  
466 - "zbc": 0, // 总班次  
467 - "yygs": 0, // 营运工时  
468 - "yybc": 0, // 营运班次  
469 - "stationRouteId1": 0, // 第一个班次起点站路由id  
470 - "stationRouteId2": 0 // 第二个班次起点站路由id  
471 - };  
472 - oTempLpFlag[oGanttBc.lpName] = {"flag" : true}; // 标记一下  
473 - aLp.push(oLp);  
474 - }  
475 -  
476 - // 计算Excel班次  
477 - this._celb = new InternalCalcuExcelBc1(aLp, this.aGanttBc, oParam, this._qIsUp);  
478 -  
479 - }  
480 -  
481 - // html5导出excel方法  
482 - InternalExcelObj.prototype.downloadFile = function(data, mimeType, fileName) {  
483 - _fnDownloadFile(data, mimeType, fileName);  
484 - };  
485 - /**  
486 - * 获取班次统计数据。  
487 - */  
488 - InternalExcelObj.prototype.fnGetStatInfoList = function() {  
489 - return _fnCalcuExportStatInfo_sheet(this.aGanttBc, this._oParam);  
490 - };  
491 - /**  
492 - * 获取参数数据。  
493 - */  
494 - InternalExcelObj.prototype.fnGetParamInfoList = function() {  
495 - return _fnCalcuExportParam_sheet(this._oParam);  
496 - };  
497 - /**  
498 - * 获取路牌班次数据。  
499 - * @return {*}  
500 - */  
501 - InternalExcelObj.prototype.fnGetLpBcInfoList = function() {  
502 - return this._celb.fnCalcuExcelLpBcList();  
503 - };  
504 -  
505 - return InternalExcelObj;  
506 - 1 +/**
  2 + * v2_2版本时刻表excel对象。
  3 + */
  4 +var Main_v2_2_ExcelObj = (function() {
  5 + // html5导出下载文件方法
  6 + var _fnDownloadFile = function(data, mimeType, fileName) {
  7 + var success = false;
  8 + var blob = new Blob([data], { type: mimeType });
  9 + try {
  10 + if (navigator.msSaveBlob)
  11 + navigator.msSaveBlob(blob, fileName);
  12 + else {
  13 + // Try using other saveBlob implementations, if available
  14 + var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;
  15 + if (saveBlob === undefined) throw "Not supported";
  16 + saveBlob(blob, fileName);
  17 + }
  18 + success = true;
  19 + } catch (ex) {
  20 + console.log("saveBlob method failed with the following exception:");
  21 + console.log(ex);
  22 + }
  23 +
  24 + if (!success) {
  25 + // Get the blob url creator
  26 + var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
  27 + if (urlCreator) {
  28 + // Try to use a download link
  29 + var link = document.createElement('a');
  30 + if ('download' in link) {
  31 + // Try to simulate a click
  32 + try {
  33 + // Prepare a blob URL
  34 + var url = urlCreator.createObjectURL(blob);
  35 + link.setAttribute('href', url);
  36 +
  37 + // Set the download attribute (Supported in Chrome 14+ / Firefox 20+)
  38 + link.setAttribute("download", fileName);
  39 +
  40 + // Simulate clicking the download link
  41 + var event = document.createEvent('MouseEvents');
  42 + event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
  43 + link.dispatchEvent(event);
  44 + success = true;
  45 +
  46 + } catch (ex) {
  47 + console.log("Download link method with simulated click failed with the following exception:");
  48 + console.log(ex);
  49 + }
  50 + }
  51 +
  52 + if (!success) {
  53 + // Fallback to window.location method
  54 + try {
  55 + // Prepare a blob URL
  56 + // Use application/octet-stream when using window.location to force download
  57 + var url = urlCreator.createObjectURL(blob);
  58 + window.location = url;
  59 + console.log("Download link method with window.location succeeded");
  60 + success = true;
  61 + } catch (ex) {
  62 + console.log("Download link method with window.location failed with the following exception:");
  63 + console.log(ex);
  64 + }
  65 + }
  66 + }
  67 + }
  68 +
  69 + if (!success) {
  70 + // Fallback to window.open method
  71 + console.log("No methods worked for saving the arraybuffer, using last resort window.open");
  72 + window.open("", '_blank', '');
  73 + }
  74 + };
  75 +
  76 + // 计算导出参数sheet数据。
  77 + var _fnCalcuExportParam_sheet = function(_paramObj) {
  78 + return [
  79 + {'paramItem' : '上行首班时间', 'paramValue' : _paramObj.getUpFirstDTimeObj().format("HH:mm")},
  80 + {'paramItem' : '上行末班时间', 'paramValue' : _paramObj.getUpLastDtimeObj().format("HH:mm")},
  81 + {'paramItem' : '下行首班时间', 'paramValue' : _paramObj.getDownFirstDTimeObj().format("HH:mm")},
  82 + {'paramItem' : '下行末班时间', 'paramValue' : _paramObj.getDownLastDTimeObj().format("HH:mm")},
  83 + {'paramItem' : '早高峰开始时间', 'paramValue' : _paramObj.getMPeakStartTimeObj().format("HH:mm")},
  84 + {'paramItem' : '早高峰结束时间', 'paramValue' : _paramObj.getMPeakEndTimeObj().format("HH:mm")},
  85 + {'paramItem' : '晚高峰开始时间', 'paramValue' : _paramObj.getEPeakStartTimeObj().format("HH:mm")},
  86 + {'paramItem' : '晚高峰结束时间', 'paramValue' : _paramObj.getEPeakEndTimeObj().format("HH:mm")},
  87 + {'paramItem' : '上行进场时间', 'paramValue' : _paramObj.getUpInTime()},
  88 + {'paramItem' : '上行出场时间', 'paramValue' : _paramObj.getUpOutTime()},
  89 + {'paramItem' : '下行进场时间', 'paramValue' : _paramObj.getDownInTime()},
  90 + {'paramItem' : '下行出场时间', 'paramValue' : _paramObj.getDownOutTime()},
  91 + {'paramItem' : '早高峰上行时间', 'paramValue' : _paramObj.getUpMPeakTime()},
  92 + {'paramItem' : '早高峰下行时间', 'paramValue' : _paramObj.getDownMPeakTime()},
  93 + {'paramItem' : '晚高峰上行时间', 'paramValue' : _paramObj.getUpEPeakTime()},
  94 + {'paramItem' : '晚高峰下行时间', 'paramValue' : _paramObj.getDownEPeakTime()},
  95 + {'paramItem' : '低谷上行时间', 'paramValue' : _paramObj.getUpTroughTime()},
  96 + {'paramItem' : '低谷下行时间', 'paramValue' : _paramObj.getDownTroughTime()},
  97 + {'paramItem' : '线路规划类型', 'paramValue' : "双向"},
  98 + {'paramItem' : '吃饭地点', 'paramValue' : _paramObj.fnIsEat() ? (_paramObj.fnIsBothEat() ? "上下行" : (_paramObj.fnIsUpEat() ? "上行" : "下行")) : "不吃饭"},
  99 + {'paramItem' : '早晚例行保养', 'paramValue' : _paramObj.getLbTime()},
  100 + {'paramItem' : '停车场', 'paramValue' : _paramObj.getTccId()},
  101 + {'paramItem' : '工作餐午餐时间', 'paramValue' : _paramObj.fnGetLunchTime()},
  102 + {'paramItem' : '工作餐晚餐时间', 'paramValue' : _paramObj.fnGetDinnerTime()},
  103 + {'paramItem' : '早高峰发车间隔', 'paramValue' : "[" + _paramObj.getMPeakMinFcjx() + "," + _paramObj.getMPeakMaxFcjx() + "]"},
  104 + {'paramItem' : '晚高峰发车间隔', 'paramValue' : "[" + _paramObj.getEPeakMinFcjx() + "," + _paramObj.getEPeakMaxFcjx() + "]"},
  105 + {'paramItem' : '低谷发车间隔', 'paramValue' : "[" + _paramObj.getTroughMinFcjx() + "," + _paramObj.getTroughMaxFcjx() + "]"},
  106 + {'paramItem' : '建议加班路牌数', 'paramValue' : _paramObj.getJBLpes()},
  107 + {'paramItem' : '停站类型', 'paramValue' : _paramObj.isTwoWayStop() ? "双向停站" : (_paramObj.isUpOneWayStop() ? "上行主站" : "下行主站") },
  108 + {'paramItem' : '建议高峰配车数', 'paramValue' : _paramObj.getAdvicePeakClzs()}
  109 + ]
  110 + };
  111 +
  112 + // 计算班次统计数据sheet数据。
  113 + var _fnCalcuExportStatInfo_sheet = function(aBc, oParam) {
  114 + var countBc = 0, // 总班次
  115 + serviceBc = 0, // 营运班次
  116 + jcbc = 0, // 进场总班次.
  117 + ccbc = 0, // 出场总班次.
  118 + cfbc = 0, // 吃饭总班次.
  119 + zwlbbc = 0, // 早晚例保总班次.
  120 + countGs = 0.0, // 总工时
  121 + servicesj = 0, // 营运班次总时间
  122 + jcsj = 0.0, // 进场总时间.
  123 + ccsj = 0.0, // 出场总时间.
  124 + cfsj = 0.0, // 吃饭总时间.
  125 + zwlbsj = 0.0, // 早晚例保总时间.
  126 + ksBc = 0, // 空驶班次
  127 + serviceLc = 0.0, // 营运里程
  128 + ksLc = 0.0, // 空驶里程
  129 + avgTzjx = 0.0, // 平均停站间隙
  130 + gfServiceBc = 0, // 高峰营运班次
  131 + dgServiceBc = 0, // 低谷营运班次
  132 + gfAvgTzjx = 0.0, // 高峰平均停站间隙
  133 + dgAvgTzjx = 0.0; // 低谷平均停站间隙
  134 +
  135 + var i;
  136 + var oBc;
  137 + for (i = 0; i < aBc.length; i++) {
  138 + oBc = aBc[i];
  139 +
  140 + if (oBc.bcsj > 0) {
  141 + countBc = countBc + 1;
  142 + countGs = countGs + oBc.STOPTIME + oBc.bcsj;
  143 + if (oParam.isTroughBc(oParam.toTimeObj(oBc.fcsj))) {
  144 + if (oBc.bcType == "normal") {
  145 + dgServiceBc = dgServiceBc + 1;
  146 + dgAvgTzjx = dgAvgTzjx + oBc.STOPTIME;
  147 + }
  148 + } else {
  149 + if (oBc.bcType == "normal") {
  150 + gfServiceBc = gfServiceBc + 1;
  151 + gfAvgTzjx = gfAvgTzjx + oBc.STOPTIME;
  152 + }
  153 + }
  154 +
  155 + if (oBc.bcType == "normal" || oBc.bcType == "cf") {
  156 + serviceBc = serviceBc + 1;
  157 + serviceLc = serviceLc + oBc.jhlc;
  158 + servicesj = servicesj + oBc.bcsj;
  159 + avgTzjx = avgTzjx + oBc.STOPTIME;
  160 +
  161 + if (oBc.bcType == "cf") {
  162 + cfbc = cfbc + 1;
  163 + cfsj = cfsj + oBc.bcsj;
  164 + }
  165 + } else if (oBc.bcType == "in") {
  166 + jcbc = jcbc + 1;
  167 + jcsj = jcsj + oBc.bcsj;
  168 + } else if (oBc.bcType == "out") {
  169 + ccbc = ccbc + 1;
  170 + ccsj = ccsj + oBc.bcsj;
  171 + } else if (oBc.bcType == "bd") {
  172 + zwlbbc = zwlbbc + 1;
  173 + zwlbsj = zwlbsj + oBc.bcsj;
  174 + } else if (oBc.bcType == "lc") {
  175 + zwlbbc = zwlbbc + 1;
  176 + zwlbsj = zwlbsj + oBc.bcsj;
  177 + }
  178 + }
  179 + }
  180 +
  181 + dgAvgTzjx = dgAvgTzjx / dgServiceBc;
  182 + gfAvgTzjx = gfAvgTzjx / gfServiceBc;
  183 + avgTzjx = avgTzjx / dgServiceBc;
  184 +
  185 + return [
  186 + {'statItem': '总班次(包括进出场、吃饭时间、早晚例保、营运且班次时间大于零的班次)', 'statValue': countBc},
  187 + {'statItem': '进场总班次(包括进场且班次时间大于零的班次)', 'statValue': jcbc},
  188 + {'statItem': '出场总班次(包括进场且班次时间大于零的班次)', 'statValue': ccbc},
  189 + {'statItem': '吃饭总班次(包括吃饭且班次时间大于零的班次)', 'statValue': cfbc},
  190 + {'statItem': '早晚例保总班次(包括早晚例保且时间大于零的班次)', 'statValue': zwlbbc},
  191 + {'statItem': '营运总班次(包括正常、区间、放大站且班次时间大于零班次)','statValue': serviceBc},
  192 + {'statItem': '进场总时间(包括进场班次且班次时间大于零)', 'statValue': jcsj/60},
  193 + {'statItem': '出场总时间(包括进场班次且班次时间大于零)', 'statValue': ccsj/60},
  194 + {'statItem': '吃饭总时间(包括吃饭班次且班次时间大于零)', 'statValue': cfsj/60},
  195 + {'statItem': '早晚例保总时间(包括早晚例保班次且时间大于零的)', 'statValue': zwlbsj/60},
  196 + {'statItem': '营运班次总时间(包括正常、区间、放大站且班次时间大于零)', 'statValue': servicesj/60},
  197 + {'statItem': '总工时(包括进出场、吃饭时间、早晚例保、营运班次时间)', 'statValue': countGs/60},
  198 + {'statItem': '空驶班次(包括直放班次)', 'statValue': ksBc},
  199 + {'statItem': '营运里程(包括正常、区间、放大站里程)', 'statValue': serviceLc},
  200 + {'statItem': '空驶里程(包括直放里程)', 'statValue': ksLc},
  201 + {'statItem': '平均停站时间(营运班次停站时间总和/营运总班次)', 'statValue': avgTzjx},
  202 + {'statItem': '高峰营运班次(包括早晚高峰时段的正常、区间、放大站班次)', 'statValue': gfServiceBc},
  203 + {'statItem': '低谷营运班次(包括低谷时段的正常、区间、放大站班次)', 'statValue': dgServiceBc},
  204 + {'statItem': '高峰平均停站间隙(高峰营运班次停站时间总和/高峰营运班次总和)', 'statValue': gfAvgTzjx},
  205 + {'statItem': '低谷平均停站间隙(低谷营运班次停站时间总和/低谷营运班次总和)', 'statValue': dgAvgTzjx},
  206 + {'statItem': '综合评估', 'statValue': 3}
  207 + ];
  208 +
  209 + };
  210 +
  211 + /**
  212 + * 内部计算Excel班次方法1,
  213 + * 这里是假设班次按照从早到晚排序,并且路牌也是从小到大排序。
  214 + * @param aExcelLp excel显示用路牌
  215 + * @param aGanttBc 甘特图班次列表
  216 + * @param oParam 参数对象
  217 + * @param bQIsUp 每一圈是上行开始还是下行开始
  218 + * @private
  219 + */
  220 + function InternalCalcuExcelBc1(aExcelLp, aGanttBc, oParam, bQIsUp) {
  221 + this._aExcelLp = aExcelLp;
  222 + this._oParam = oParam;
  223 + this._bQIsUp = bQIsUp;
  224 +
  225 + this._iUpGroupIndex = 0;
  226 + this._iDownGroupIndex = 0;
  227 +
  228 + // {"路牌名字":{"isFlag": 是否为标记班次(表示扫描过但是没有班次对象),"normal":正常班次}}
  229 + this._oLpGroupNormalGanttBc = {};
  230 + // [吃饭类型班次]
  231 + this._aLpGroupCfGanttBc = [];
  232 +
  233 + // TODO:其他类型的班次再议
  234 +
  235 + // 计算上行gantt班次列表,下行gantt班次列表,并排序
  236 + var i;
  237 + var oGanttBc;
  238 + this._aUpGanttBc = [];
  239 + this._aDownGanttBc = [];
  240 + for (i = 0; i < aGanttBc.length; i++) {
  241 + oGanttBc = aGanttBc[i];
  242 + if (oGanttBc.xlDir == "relationshipGraph-up") {
  243 + this._aUpGanttBc.push(oGanttBc);
  244 + } else {
  245 + this._aDownGanttBc.push(oGanttBc);
  246 + }
  247 + }
  248 + // 排序班次
  249 + this._fnSortBc(this._aUpGanttBc);
  250 + this._fnSortBc(this._aDownGanttBc);
  251 +
  252 + if (this._aUpGanttBc.length == 0) {
  253 + throw "没有上行班次,不能导出数据!";
  254 + }
  255 + if (this._aDownGanttBc.length == 0) {
  256 + throw "没有下行班次,不能导出数据!"
  257 + }
  258 +
  259 + }
  260 +
  261 + //----------------------- 外部方法 -----------------------//
  262 + InternalCalcuExcelBc1.prototype.fnGenerateExcelLpBcList = function() {
  263 + // 计算Excel班次
  264 + this._calcuExcelBc();
  265 +
  266 + // 设置路牌圈数
  267 + var iGroupCount = this._iUpGroupIndex > this._iDownGroupIndex ?
  268 + (this._iUpGroupIndex + 1) : (this._iDownGroupIndex + 1);
  269 +
  270 + // 设置路由id
  271 + var oUpNormalBc;
  272 + var oDownNormalBc;
  273 + var i;
  274 + for (i = 0; i < this._aUpGanttBc.length; i++) {
  275 + if (this._aUpGanttBc[i].bcType == "normal") {
  276 + oUpNormalBc = this._aUpGanttBc[i];
  277 + break;
  278 + }
  279 + }
  280 + for (i = 0; i < this._aDownGanttBc.length; i++) {
  281 + if (this._aDownGanttBc[i].bcType == "normal") {
  282 + oDownNormalBc = this._aDownGanttBc[i];
  283 + break;
  284 + }
  285 + }
  286 +
  287 + var stationRouteId1;
  288 + var stationRouteId2;
  289 + if (this._bQIsUp) {
  290 + stationRouteId1 = oUpNormalBc.qdz;
  291 + stationRouteId2 = oDownNormalBc.qdz;
  292 + } else {
  293 + stationRouteId1 = oDownNormalBc.qdz;
  294 + stationRouteId2 = oUpNormalBc.qdz;
  295 + }
  296 +
  297 + var oExcelLp;
  298 + for (i = 0; i < this._aExcelLp.length; i++) {
  299 + oExcelLp = this._aExcelLp[i];
  300 + oExcelLp.groupCount = iGroupCount;
  301 + oExcelLp.stationRouteId1 = stationRouteId1;
  302 + oExcelLp.stationRouteId2 = stationRouteId2;
  303 + }
  304 +
  305 + return this._aExcelLp;
  306 + };
  307 +
  308 + //----------------------- 内部方法 ------------------------//
  309 + // 排序班次
  310 + InternalCalcuExcelBc1.prototype._fnSortBc = function(aGanttBc) {
  311 + var oParam = this._oParam;
  312 + aGanttBc.sort(function (o1, o2) { // 时间从早到晚排序
  313 + if (oParam.toTimeObj(o1.fcsj).isBefore(oParam.toTimeObj(o2.fcsj))) {
  314 + return -1;
  315 + } else {
  316 + return 1;
  317 + }
  318 + });
  319 + // 此处假设班次按照从早倒晚排,每一圈按照路牌顺序排
  320 +
  321 + // TODO:如果发生同一圈路牌交叉发车,不是按照路牌排序的,导出时有问题,再议
  322 + };
  323 +
  324 + InternalCalcuExcelBc1.prototype._calcuExcelBc = function() {
  325 + var i = 0;
  326 + var j = 0;
  327 +
  328 + var aUpBc;
  329 + var aDownBc;
  330 + if (this._bQIsUp) {
  331 + aUpBc = this._aUpGanttBc;
  332 + aDownBc = this._aDownGanttBc;
  333 + } else {
  334 + aUpBc = this._aDownGanttBc;
  335 + aDownBc = this._aUpGanttBc;
  336 + }
  337 +
  338 + do {
  339 + i = this._calcuExcelBcPerGroup(this._bQIsUp, i);
  340 + j = this._calcuExcelBcPerGroup(!this._bQIsUp, j);
  341 + } while(i < aUpBc.length || j < aDownBc.length);
  342 +
  343 + };
  344 +
  345 + /**
  346 + * 重新计算Excel显示班次(计算1圈)。
  347 + * @param bIsUp 是否上行
  348 + * @param iBcIndex 班次索引
  349 + * @return 下一次计算索引
  350 + */
  351 + InternalCalcuExcelBc1.prototype._calcuExcelBcPerGroup = function(bIsUp, iBcIndex) {
  352 + this._oLpGroupNormalGanttBc = {};
  353 + this._aLpGroupCfGanttBc = [];
  354 +
  355 + var i;
  356 + var j = 0;
  357 + var oExcelLp;
  358 + var oGanttBc;
  359 + var aGBc = bIsUp ? this._aUpGanttBc : this._aDownGanttBc;
  360 +
  361 + for (i = iBcIndex; i < aGBc.length; i++) {
  362 + oGanttBc = aGBc[i];
  363 +
  364 + while(j < this._aExcelLp.length) {
  365 + oExcelLp = this._aExcelLp[j];
  366 +
  367 + if (oGanttBc.bcType == "cf") { // 吃饭班次
  368 + this._aLpGroupCfGanttBc.push(oGanttBc);
  369 + break;
  370 + }
  371 +
  372 + if (oGanttBc.bcType == "normal") { // 正常班次
  373 + this._oLpGroupNormalGanttBc[oExcelLp.lpname] = {
  374 + "isFlag": true, "normal": null
  375 + };
  376 + if (oExcelLp.lpname == oGanttBc.lpName) {
  377 + this._oLpGroupNormalGanttBc[oExcelLp.lpname].isFlag = false;
  378 + this._oLpGroupNormalGanttBc[oExcelLp.lpname].normal = oGanttBc;
  379 + j++;
  380 + break;
  381 + } else {
  382 + j++;
  383 + }
  384 + }
  385 +
  386 + }
  387 +
  388 + if (j == this._aExcelLp.length) { // 完整的一圈处理
  389 + this._resetCalcuGroup(bIsUp);
  390 + j = 0;
  391 + if (oGanttBc.lpName !=
  392 + this._aExcelLp[this._aExcelLp.length - 1].lpname) {
  393 + i--;
  394 + break;
  395 +
  396 + }
  397 +
  398 + break;
  399 + }
  400 +
  401 + }
  402 +
  403 + // 最后一圈reset一下
  404 + if (j > 0) {
  405 + this._resetCalcuGroup(bIsUp);
  406 + }
  407 + return i + 1;
  408 +
  409 + };
  410 +
  411 + InternalCalcuExcelBc1.prototype._resetCalcuGroup = function(bIsUp) {
  412 + // 判定是否开始分班,添加圈数
  413 + if (bIsUp) {
  414 + if (this._fnIsFBcQ(bIsUp)) {
  415 + this._iUpGroupIndex += 1;
  416 + this._iDownGroupIndex += 1;
  417 + }
  418 + } else {
  419 + if (this._fnIsFBcQ(!bIsUp)) {
  420 + this._iUpGroupIndex += 1;
  421 + this._iDownGroupIndex += 1;
  422 + }
  423 + }
  424 +
  425 + // 重置计算圈及班次
  426 + var oExcelLp;
  427 + var oGroupGanttNormalBc;
  428 + var oGroupGanttEatBc;
  429 + for (var i = 0; i < this._aExcelLp.length; i++) {
  430 + oExcelLp = this._aExcelLp[i];
  431 + if (this._oLpGroupNormalGanttBc[oExcelLp.lpname]) {
  432 + if (!this._oLpGroupNormalGanttBc[oExcelLp.lpname].isFlag) { // 非标记班次
  433 + oGroupGanttNormalBc = this._oLpGroupNormalGanttBc[oExcelLp.lpname].normal;
  434 +
  435 + // 获取吃饭班次
  436 + if (this._aLpGroupCfGanttBc.length > 0) {
  437 + if (this._aLpGroupCfGanttBc[0].lpName == oExcelLp.lpname) {
  438 + if (this._oParam.toTimeObj(this._aLpGroupCfGanttBc[0].fcsj).isBefore(
  439 + this._oParam.toTimeObj(oGroupGanttNormalBc.fcsj))) {
  440 + oGroupGanttEatBc = this._aLpGroupCfGanttBc.shift();
  441 + }
  442 + }
  443 + } else {
  444 + oGroupGanttEatBc = null;
  445 + }
  446 +
  447 + oExcelLp.bcObjList.push({
  448 + "bcsj": oGroupGanttNormalBc.bcsj, // 班次时间
  449 + "ssj": oGroupGanttNormalBc.STOPTIME, // 停站时间
  450 + "eatsj": oGroupGanttEatBc ? oGroupGanttEatBc.bcsj : 0, // 吃饭时间
  451 +
  452 + "tccid": oGroupGanttNormalBc.tcc, // 停车场id
  453 + "qdzid": oGroupGanttNormalBc.qdz, // 起点站id
  454 + "zdzid": oGroupGanttNormalBc.zdz, // 终点站id
  455 +
  456 + "isUp": bIsUp, // 是否上行
  457 +
  458 + "bcType": oGroupGanttNormalBc.bcType, // 班次类型
  459 + "fcsj": oGroupGanttEatBc ?
  460 + ("*" + oGroupGanttNormalBc.fcsj) :
  461 + oGroupGanttNormalBc.fcsj, // 发车时间描述
  462 + "fcsjDesc": oGroupGanttEatBc ?
  463 + ("(吃" + oGroupGanttNormalBc.fcsj + ")") :
  464 + oGroupGanttNormalBc.fcsj, // 发车时间描述2
  465 +
  466 + "groupNo": bIsUp ? this._iUpGroupIndex : this._iDownGroupIndex, // 第几圈
  467 + "groupBcNo": bIsUp == this._bQIsUp ? 0 : 1 // 圈里第几个班次
  468 +
  469 + });
  470 + }
  471 + }
  472 + }
  473 +
  474 + if (bIsUp) {
  475 + this._iUpGroupIndex ++;
  476 + } else {
  477 + this._iDownGroupIndex ++;
  478 + }
  479 + this._oLpGroupNormalGanttBc = {};
  480 + };
  481 + // 判定当前圈是否是有分班后的第一个normal班次
  482 + InternalCalcuExcelBc1.prototype._fnIsFBcQ = function(bIsUp) {
  483 + var oExcelLp;
  484 + var i;
  485 + var oLpPreExcelBc;
  486 + var oLpCurGranttBc;
  487 + var oPreBcFcsj;
  488 + var oCurBcFcsj;
  489 + var idiffTime;
  490 + var bFbFlag = false;
  491 + for (i = 0; i < this._aExcelLp.length; i++) {
  492 + oExcelLp = this._aExcelLp[i];
  493 + if (oExcelLp.bcObjList.length > 0) {
  494 + oLpPreExcelBc = oExcelLp.bcObjList[oExcelLp.bcObjList.length - 1];
  495 + if (oLpPreExcelBc.bcType == "normal") {
  496 + oPreBcFcsj = this._oParam.toTimeObj(
  497 + oLpPreExcelBc.fcsj.indexOf("*") >= 0 ? oLpPreExcelBc.fcsj.substr(1) : oLpPreExcelBc.fcsj
  498 + );
  499 + if (this._oLpGroupNormalGanttBc[oExcelLp.lpname]) {
  500 + oLpCurGranttBc = this._oLpGroupNormalGanttBc[oExcelLp.lpname].normal;
  501 + if (oLpCurGranttBc) {
  502 + oCurBcFcsj = this._oParam.toTimeObj(oLpCurGranttBc.fcsj);
  503 + idiffTime = oCurBcFcsj.diff(oPreBcFcsj, "m");
  504 + if (idiffTime > oLpPreExcelBc.bcsj * 3) {
  505 + bFbFlag = true;
  506 + break;
  507 + }
  508 + }
  509 + }
  510 + }
  511 + }
  512 +
  513 + }
  514 +
  515 + return bFbFlag;
  516 +
  517 + }
  518 +
  519 + /**
  520 + * 内部Excel对象。
  521 + * @param oParam 参数对象
  522 + * @param fnGetGanttBcArray 返回gantt用的班次列表
  523 + * @constructor
  524 + */
  525 + function InternalExcelObj(oParam, fnGetGanttBcArray) {
  526 + // 参数对象
  527 + this._oParam = oParam;
  528 + // 获取gantt班次的方法
  529 + this._fnBc = fnGetGanttBcArray;
  530 +
  531 + // 每一圈是上行开始还是下行开始
  532 + this._qIsUp = oParam.getUpFirstDTimeObj().diff(oParam.getDownFirstDTimeObj()) <= 0 ? false : true;
  533 +
  534 + }
  535 +
  536 + // html5导出excel方法
  537 + InternalExcelObj.prototype.downloadFile = function(data, mimeType, fileName) {
  538 + _fnDownloadFile(data, mimeType, fileName);
  539 + };
  540 + /**
  541 + * 获取班次统计数据。
  542 + */
  543 + InternalExcelObj.prototype.fnGetStatInfoList = function() {
  544 + return _fnCalcuExportStatInfo_sheet(this._fnBc(), this._oParam);
  545 + };
  546 + /**
  547 + * 获取参数数据。
  548 + */
  549 + InternalExcelObj.prototype.fnGetParamInfoList = function() {
  550 + return _fnCalcuExportParam_sheet(this._oParam);
  551 + };
  552 + /**
  553 + * 获取路牌班次数据。
  554 + * @return {*}
  555 + */
  556 + InternalExcelObj.prototype.fnGetLpBcInfoList = function() {
  557 + // 构造显示用lp对象
  558 + var oTempLpFlag = {};
  559 + var aGanttBc = this._fnBc();
  560 + var oGanttBc;
  561 + var aLp = [];
  562 + var oLp;
  563 + var i;
  564 + for (i = 0; i < aGanttBc.length; i++) {
  565 + oGanttBc = aGanttBc[i];
  566 + if (oTempLpFlag[oGanttBc.lpName]) {
  567 + // 已经存在路牌,不处理
  568 + continue;
  569 + }
  570 +
  571 + oLp = {
  572 + "lpname": oGanttBc.lpName, // 路牌名字
  573 + "isUp": this._qIsUp, // 每圈的第一个班次是否上行
  574 + "bcObjList": [], // 内部班次列表(后面计算班次列表)
  575 + "groupCount": 0, // 总圈数(后面计算总圈数)
  576 + "zlc": 0, // 总里程
  577 + "yylc": 0, // 营运里程
  578 + "kslc": 0, // 空驶里程
  579 + "zgs": 0, // 总工时
  580 + "zbc": 0, // 总班次
  581 + "yygs": 0, // 营运工时
  582 + "yybc": 0, // 营运班次
  583 + "stationRouteId1": 0, // 第一个班次起点站路由id
  584 + "stationRouteId2": 0 // 第二个班次起点站路由id
  585 + };
  586 + oTempLpFlag[oGanttBc.lpName] = {"flag" : true}; // 标记一下
  587 + aLp.push(oLp);
  588 + }
  589 +
  590 + // 计算Excel班次
  591 + var _celb = new InternalCalcuExcelBc1(aLp, aGanttBc, this._oParam, this._qIsUp);
  592 + return _celb.fnGenerateExcelLpBcList();
  593 + };
  594 +
  595 + return InternalExcelObj;
  596 +
507 } ()); 597 } ());
508 \ No newline at end of file 598 \ No newline at end of file