Commit abd1f204967dae6ead9d2fba8a96dc24b8a2872c

Authored by 徐烜
1 parent 3b2743e1

时刻表v2_2.1

1、新版本,只支持单向进出场线路,不是一次性布局,而是一边判定班次,添加班次,修改间隔,修改周转
2、以上标线开始,从第一个副站班次开始向下生成班次,每生成一圈,调整上标线圈结束后的所有班次
3、分班车次链的结束班次必须是副站方向
4、低谷间隔时以频率加步长的形式拉间隔,高峰间隔使用平均间隔(ceil)

Too many changes to show.

To preserve performance only 7 of 10 files are displayed.

src/main/resources/static/pages/base/timesmodel/add.html
... ... @@ -149,7 +149,10 @@
149 149 <input type="radio" class="icheck" name="baseRes" value=1> 班型/人次/车辆
150 150 </label>
151 151 <label>
152   - <input type="radio" class="icheck" name="baseRes" value=2 checked> 发车间隔分析
  152 + <input type="radio" class="icheck" name="baseRes" value=2 > 发车间隔分析(旧:一步调整)
  153 + </label>
  154 + <label>
  155 + <input type="radio" class="icheck" name="baseRes" value=3 checked> 发车间隔分析(新:增量调整-单向进出场)
153 156 </label>
154 157 <label>
155 158 <input type="radio" class="icheck" name="baseRes" value=0> 客流大数据分析
... ...
src/main/resources/static/pages/base/timesmodel/gantt.html
... ... @@ -181,7 +181,14 @@
181 181 <script src="/pages/base/timesmodel/js/v2/strategy/adjust/AdjustTripS4.js"></script>
182 182 <script src="/pages/base/timesmodel/js/v2/strategy/StrategyUtils.js"></script>
183 183 <script src="/pages/base/timesmodel/js/v2/main_v2.js"></script>
184   -<!--<script src="/pages/base/timesmodel/js/d3.relationshipgraph.js"></script>-->
  184 +
  185 +<!--
  186 +使用新的echart画图,暂时不用d3,之后会吧d3的放到新的文件里
  187 +<script src="/pages/base/timesmodel/js/d3.relationshipgraph.js"></script>
  188 +-->
  189 +
  190 +<script src="/pages/base/timesmodel/js/v2_2/InternalScheduleObj.js"></script>
  191 +<script src="/pages/base/timesmodel/js/v2_2/main_v2_2.js"></script>
185 192 <script src="/pages/base/timesmodel/js/errorinfo.js"></script>
186 193 <script src="/pages/base/timesmodel/js/parameters.js"></script>
187 194 <script src="/pages/base/timesmodel/js/systemTools.js"></script>
... ...
src/main/resources/static/pages/base/timesmodel/js/add-form-wizard.js
... ... @@ -322,7 +322,7 @@ var SKBFormWizard = function() {
322 322 tempName = 'carnum_temp';
323 323 else if(n==1)
324 324 tempName = 'bctype_temp';
325   - else if (n==2)
  325 + else if (n==2 || n == 3)
326 326 tempName = 'fcjx_temp';
327 327 // 2、获参数详情模版html内容.
328 328 $.get('/pages/base/timesmodel/tepms/'+ tempName + '.html', function(html){
... ... @@ -394,7 +394,7 @@ var SKBFormWizard = function() {
394 394 }else if(n==1) {
395 395 // 返回参数详情模版.
396 396 return cb && cb ({'forminput':template(tempName,{map:map}),'datadisplay': template(tempName +'config',{map:null})});
397   - }else if (n==2) {
  397 + }else if (n==2 || n == 3) {
398 398 // 更具站点路由版本获取起点终点站
399 399 var iversion = $('#lineVersionSelect').val();
400 400 $get('/stationroute/all',{'line.id_eq':lineId,'destroy_eq':0, 'versions_eq': iversion},function(result) {
... ... @@ -974,7 +974,7 @@ var SKBFormWizard = function() {
974 974 layer.close(i);
975 975 });
976 976  
977   - } else if (baseRes == 2) { // 发车间隔分析
  977 + } else if (baseRes == 2 || baseRes == 3) { // 发车间隔分析
978 978 // 上下行首末班日期控件
979 979 $('#startStationFirstTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});
980 980 $('#startStationEndTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});
... ...
src/main/resources/static/pages/base/timesmodel/js/d3.relationshipgraph.js
... ... @@ -321,7 +321,7 @@ $(&#39;.parambtn&#39;).on(&#39;click&#39;, function() {
321 321 $.get('/pages/base/timesmodel/paramadd.html', function(m){
322 322 $(pjaxContainer).append(m);
323 323 // 规定被选元素要触发的事件。可以使自定义事件(使用 bind() 函数来附加),或者任何标准事件。
324   - $('#paramadd_mobal').trigger('paramAddMobal.show', Main_v2);
  324 + $('#paramadd_mobal').trigger('paramAddMobal.show', [Main_v2, Main_v2_2]);
325 325 });
326 326 });
327 327  
... ...
src/main/resources/static/pages/base/timesmodel/js/gantt.js
... ... @@ -72,6 +72,10 @@
72 72 _paramObj = Main_v2.getFactory().createParameterObj(map, dataMap);
73 73 map.clzs = _paramObj.calcuClzx();
74 74 CSMap = getMaxCarAndStopSpace1(map);
  75 + } else if (map.baseRes == '3') { // 主站停站使用v2_2版本
  76 + _paramObj = Main_v2.getFactory().createParameterObj(map, dataMap); // TODO:暂时使用v2_1版本的方法,通用的,后续再放到v2_2版本中
  77 + map.clzs = InternalScheduleObj_v2_2.calcuClzx(_paramObj);
  78 + CSMap = getMaxCarAndStopSpace1(map);
75 79 }
76 80  
77 81 // 定义时间参数.
... ... @@ -93,6 +97,9 @@
93 97 // TODO:CSMap.maxCar 之后要设定一下的
94 98 data = Main_v2.BXPplaceClassesTime03(_paramObj, CSMap.maxCar);
95 99 Main_v2.exportDataConfig(data.aInternalLpObj);
  100 + } else if (map.baseRes == '3') { // 主站停站使用v2_2版本
  101 + data = Main_v2_2.BXPplaceClassesTime03(_paramObj, CSMap.maxCar);
  102 + Main_v2_2.exportDataConfig(data.aInternalLpObj);
96 103 }
97 104  
98 105 }else {
... ...
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalLpObj.js
1   -/**
2   - * 内部路牌对象。
3   - * @constructor
4   - */
5   -var InternalLpObj = function(
6   - orilpObj, // 原始路牌对象
7   - qCount, // 总共多少圈
8   - isUp // 圈是以上行开始还是下行开始
9   -) {
10   - // TODO:原始路牌对象(这个路牌是对接外部gantt图像,以后有机会改了)
11   - this._$$_orign_lp_obj = orilpObj;
12   -
13   - this._$_isUp = isUp;
14   -
15   - // 路牌的圈数,注意每个路牌的圈数都是一致的,
16   - // 但并不是每一圈都有值
17   - // 第1圈从上标线开始
18   - // 第0圈表示中标线的第一个班次组成的半圈
19   - // 有多少圈根据最终迭代的结果来看
20   - this._$_qCount = qCount;
21   - // 保存的是 InternalGroupBcObj 对象
22   - this._$_groupBcArray = new Array(qCount);
23   -
24   - var i;
25   - for (i = 0; i < this._$_qCount; i++) {
26   - this._$_groupBcArray[i] = new InternalGroupObj(
27   - this, this._$_isUp, undefined, undefined);
28   - }
29   -
30   - // 距离上一个路牌的最小发车间隔时间
31   - // 用于纵向添加班次的时候使用
32   - // 默认第一个路牌为0
33   - this._$_minVerticalIntervalTime = 0;
34   -
35   - // 详细记录每圈每个方向上的发车间隔时间
36   - // 第一维度表示圈数,第二维度表示第一个方向,第二个方向
37   - // 第一个方向是否上行由 _$_isUp 决定
38   - // 这里的间隔表示下一个路牌上的班次距离本路牌的班次发车时间间隔
39   - // 如果当前是最后一个路牌,表示第一个路牌的下一圈同方向班次距离本班次的间隔
40   - this._$_aVerticalIntervalTime = new Array(this._$_qCount);
41   - for (i = 0; i < this._$_aVerticalIntervalTime.length; i++) {
42   - this._$_aVerticalIntervalTime[i] = new Array(2);
43   - }
44   -
45   - // 班型的相关变量
46   - this._$_bx_isLb = false; // 是否连班
47   - this._$_bx_isfb = false; // 是否分班
48   - this._$_bx_isfb_5_2 = false; // 是否5休2分班
49   - this._$_bx_desc; // 班型描述(默认为路牌编号)
50   -
51   - // 其他班次(进出场,例包,吃饭等),TODO:以后再拆
52   - this._$_other_bc_array = [];
53   -
54   - // TODO:
55   -
56   -};
57   -
58   -//------------------- get/set 方法 -------------------//
59   -
60   -InternalLpObj.prototype.getOtherBcArray = function() {
61   - return this._$_other_bc_array;
62   -};
63   -InternalLpObj.prototype.addOtherBcArray = function(ba) {
64   - this._$_other_bc_array = this._$_other_bc_array.concat(ba);
65   -};
66   -
67   -/**
68   - * 获取圈
69   - * @param qIndex 圈index
70   - */
71   -InternalLpObj.prototype.getGroup = function(qIndex) {
72   - return this._$_groupBcArray[qIndex];
73   -};
74   -
75   -/**
76   - * 获取路牌圈数。
77   - * @returns {*}
78   - */
79   -InternalLpObj.prototype.fnGetGroupCount = function() {
80   - return this._$_qCount;
81   -};
82   -
83   -/**
84   - * 是否上行。
85   - * @returns boolean
86   - */
87   -InternalLpObj.prototype.isUp = function() {
88   - return this._$_isUp;
89   -};
90   -
91   -/**
92   - * 获取班次。
93   - * @param qIndex 第几圈
94   - * @param bcIndex 第几个班次
95   - */
96   -InternalLpObj.prototype.getBc = function(qIndex, bcIndex) {
97   - var group = this._$_groupBcArray[qIndex];
98   - var bc;
99   - if (bcIndex == 0) {
100   - bc = group.getBc1();
101   - } else if (bcIndex == 1) {
102   - bc = group.getBc2();
103   - }
104   - return bc;
105   -};
106   -
107   -/**
108   - * 在具体位置设置班次。
109   - * @param qIndex 第几圈
110   - * @param bcIndex 第几个班次
111   - * @param bc 班次对象
112   - */
113   -InternalLpObj.prototype.setBc = function(qIndex, bcIndex, bc) {
114   - var group = this._$_groupBcArray[qIndex];
115   - if (bcIndex == 0) {
116   - group.setBc1(bc);
117   - bc.setGroup(group);
118   - } else if (bcIndex == 1) {
119   - group.setBc2(bc);
120   - bc.setGroup(group);
121   - }
122   -};
123   -
124   -/**
125   - * 设置原始路牌对象。
126   - * @param lpObj 原始路牌对象
127   - */
128   -InternalLpObj.prototype.setLp = function(lpObj) {
129   - this._$$_orign_lp_obj = lpObj;
130   - var i;
131   - var group;
132   - for (i = 0; i < this._$_groupBcArray.length; i++) {
133   - group = this._$_groupBcArray[i];
134   - if (group) {
135   - group.setLp(this); // 圈和班次保存都是 InternalLpObj 对象
136   - }
137   - }
138   -};
139   -
140   -InternalLpObj.prototype.getLpNo = function() {
141   - return this._$$_orign_lp_obj.lpNo;
142   -};
143   -InternalLpObj.prototype.getLpName = function() {
144   - return this._$$_orign_lp_obj.lpName;
145   -};
146   -InternalLpObj.prototype.setBxFb5_2 = function(fb) {
147   - this._$_bx_isfb_5_2 = fb;
148   -};
149   -InternalLpObj.prototype.isBxFb5_2 = function() {
150   - return this._$_bx_isfb_5_2;
151   -};
152   -InternalLpObj.prototype.setBxLb = function(lb) {
153   - this._$_bx_isLb = lb;
154   -};
155   -InternalLpObj.prototype.isBxLb = function() {
156   - return this._$_bx_isLb;
157   -};
158   -
159   -InternalLpObj.prototype.setBxFb = function(fb) {
160   - this._$_bx_isfb = fb;
161   -};
162   -InternalLpObj.prototype.isBxFb = function() {
163   - return this._$_bx_isfb;
164   -};
165   -
166   -/**
167   - * 设置路牌的班型描述(最终是设置班次的路牌名字)。
168   - * @param desc 描述
169   - */
170   -InternalLpObj.prototype.setBxDesc = function(desc) {
171   - // 最终原始路牌的名字
172   - this._$$_orign_lp_obj.lpName = desc + "_" + this._$$_orign_lp_obj.lpNo;
173   - // 内部对象的班型描述
174   - this._$_bx_desc = desc;
175   -};
176   -/**
177   - * 获取版型描述
178   - * @returns string
179   - */
180   -InternalLpObj.prototype.getBxDesc = function() {
181   - return this._$_bx_desc;
182   -};
183   -
184   -/**
185   - * 设置纵向最小发车间隔时间。
186   - * @param v
187   - */
188   -InternalLpObj.prototype.setVerticalMinIntervalTime = function(v) {
189   - // 第一个路牌,都为0
190   - this._$_minVerticalIntervalTime = v;
191   -};
192   -/**
193   - * 获取纵向最小发车间隔时间。
194   - * @returns {number|*}
195   - */
196   -InternalLpObj.prototype.getVerticalMinIntervalTime = function() {
197   - return this._$_minVerticalIntervalTime;
198   -};
199   -
200   -/**
201   - * 设置纵向发车间隔。
202   - * @param iQindex 圈index
203   - * @param iBindex 班次index
204   - * @param iTime 间隔时间
205   - */
206   -InternalLpObj.prototype.fnSetVerticalIntervalTime = function(iQindex, iBindex, iTime) {
207   - this._$_aVerticalIntervalTime[iQindex][iBindex] = iTime;
208   -};
209   -
210   -/**
211   - * 返回纵向发车间隔。
212   - * @param iQindex 圈index
213   - * @param iBindex 班次index
214   - */
215   -InternalLpObj.prototype.fnGetVerticalIntervalTime = function(iQindex, iBindex) {
216   - return this._$_aVerticalIntervalTime[iQindex][iBindex];
217   -};
218   -
219   -//-------------------- 班次操作方法(查询,统计,删除) -----------------------//
220   -
221   -/**
222   - * 返回总共班次数。
223   - */
224   -InternalLpObj.prototype.getBcCount = function() {
225   - var i;
226   - var group;
227   - var bccount = 0;
228   - for (i = 0; i < this._$_groupBcArray.length; i++) {
229   - group = this._$_groupBcArray[i];
230   - if (group) {
231   - if (group.getBc1()) {
232   - bccount += 1;
233   - }
234   - if (group.getBc2()) {
235   - bccount += 1;
236   - }
237   - }
238   - }
239   -
240   - return bccount;
241   -};
242   -
243   -/**
244   - * 返回班次列表,过滤空的班次,将所有存在的班次连成连续的对象数组返回。
245   - * @returns arrays (InternalBcObj)
246   - */
247   -InternalLpObj.prototype.getBcArray = function() {
248   - var bcArray = [];
249   - var i;
250   - var group;
251   - for (i = 0; i < this._$_groupBcArray.length; i++) {
252   - group = this._$_groupBcArray[i];
253   - if (group) {
254   - group.getBc1() ? bcArray.push(group.getBc1()) : "";
255   - group.getBc2() ? bcArray.push(group.getBc2()) : "";
256   - }
257   - }
258   -
259   - return bcArray;
260   -};
261   -
262   -/**
263   - * 获取最小(最早)班次对象。
264   - * @returns [{圈index},{班次index}]
265   - */
266   -InternalLpObj.prototype.getMinBcObjPosition = function() {
267   - var i;
268   - var bIndex = [];
269   - for (i = 0; i < this._$_groupBcArray.length; i++) {
270   - if (this._$_groupBcArray[i].getBc1()) {
271   - bIndex.push(i);
272   - bIndex.push(0);
273   - break;
274   - }
275   - if (this._$_groupBcArray[i].getBc2()) {
276   - bIndex.push(i);
277   - bIndex.push(1);
278   - break;
279   - }
280   - }
281   - return bIndex;
282   -};
283   -
284   -/**
285   - * 获取最大(最晚)班次对象。
286   - * @returns [{圈index},{班次index}]
287   - */
288   -InternalLpObj.prototype.getMaxBcObjPosition = function() {
289   - var i;
290   - var bIndex = [];
291   - for (i = this._$_groupBcArray.length - 1; i >= 0; i--) {
292   - if (this._$_groupBcArray[i].getBc2()) {
293   - bIndex.push(i);
294   - bIndex.push(1);
295   - break;
296   - }
297   - if (this._$_groupBcArray[i].getBc1()) {
298   - bIndex.push(i);
299   - bIndex.push(0);
300   - break;
301   - }
302   - }
303   - return bIndex;
304   -};
305   -
306   -InternalLpObj.prototype.getMinBcObj = function() {
307   - var i;
308   - var bcObj;
309   - for (i = 0; i < this._$_groupBcArray.length; i++) {
310   - bcObj = this._$_groupBcArray[i].getBc1();
311   - if (bcObj) {
312   - break;
313   - }
314   - bcObj = this._$_groupBcArray[i].getBc2();
315   - if (bcObj) {
316   - break;
317   - }
318   - }
319   - return bcObj;
320   -};
321   -InternalLpObj.prototype.getMaxBcObj = function() {
322   - var i;
323   - var bcObj;
324   - for (i = this._$_groupBcArray.length - 1; i >= 0; i--) {
325   - bcObj = this._$_groupBcArray[i].getBc2();
326   - if (bcObj) {
327   - break;
328   - }
329   - bcObj = this._$_groupBcArray[i].getBc1();
330   - if (bcObj) {
331   - break;
332   - }
333   - }
334   - return bcObj;
335   -};
336   -
337   -/**
338   - * 获取车次链信息。
339   - * @param num 第几个车次链
340   - * @returns object {s_q: {开始圈索引},s_b : {开始班次索引},e_q : {结束圈索引},e_b : {结束班次索引}, bcount : {班次数}}
341   - */
342   -InternalLpObj.prototype.fnGetBcChainInfo = function(num) {
343   - // 计算总的车次链信息
344   - var aChainInfo = [];
345   - var oChainInfo;
346   - var aBcIndex = this.getMinBcObjPosition();
347   - var oBc;
348   - var iQIndex;
349   - var iBcIndex;
350   - var i;
351   - var bFlag;
352   -
353   - var iBcount = 0;
354   -
355   - if (aBcIndex.length == 2) {
356   - iBcount = 1;
357   - oChainInfo = {s_q : aBcIndex[0], s_b : aBcIndex[1], e_q : aBcIndex[0], e_b : aBcIndex[1], bcount: 1};
358   - aChainInfo.push(oChainInfo);
359   - bFlag = true;
360   -
361   - // 下一个班次的索引
362   - iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1;
363   - iBcIndex = aBcIndex[1] == 0 ? 1 : 0;
364   -
365   - for (i = iQIndex; i < this._$_qCount; i++) {
366   - while (iBcIndex <= 1) {
367   - oBc = this.getBc(i, iBcIndex);
368   - if (!oBc) {
369   - if (bFlag) {
370   - // 车次链结尾是这个班次的前一个班次
371   - oChainInfo.e_q = iBcIndex == 0 ? i - 1 : i;
372   - oChainInfo.e_b = iBcIndex == 0 ? 1 : 0;
373   - oChainInfo.bcount = iBcount;
374   - }
375   -
376   - bFlag = false;
377   - } else {
378   - if (bFlag) {
379   - iBcount ++;
380   - oChainInfo.bcount = iBcount;
381   - } else {
382   - // 下一个车次链开始
383   - iBcount = 1;
384   - oChainInfo = {s_q : i, s_b : iBcIndex, e_q : i, e_b : iBcIndex, bcount: 1};
385   - aChainInfo.push(oChainInfo);
386   - bFlag = true;
387   - }
388   - }
389   -
390   -
391   - iBcIndex ++;
392   - }
393   - iBcIndex = 0;
394   - }
395   -
396   - }
397   -
398   - return aChainInfo[num];
399   -};
400   -
401   -/**
402   - * 获取车次链的个数。
403   - * @returns int
404   - */
405   -InternalLpObj.prototype.fnGetBcChainCount = function() {
406   - var iChainCount = 0;
407   - var aBcIndex = this.getMinBcObjPosition();
408   -
409   - var oBc;
410   - var iQIndex;
411   - var iBcIndex;
412   - var i;
413   - var bFlag;
414   -
415   - if (aBcIndex.length == 2) {
416   - iChainCount = 1;
417   - bFlag = true;
418   -
419   - // 下一个班次的索引
420   - iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1;
421   - iBcIndex = aBcIndex[1] == 0 ? 1 : 0;
422   -
423   - for (i = iQIndex; i < this._$_qCount; i++) {
424   - while (iBcIndex <= 1) {
425   - oBc = this.getBc(i, iBcIndex);
426   - if (!oBc) {
427   - bFlag = false;
428   - } else {
429   - if (bFlag) {
430   -
431   - } else {
432   - iChainCount ++;
433   - bFlag = true;
434   - }
435   - }
436   -
437   -
438   - iBcIndex ++;
439   - }
440   - iBcIndex = 0;
441   - }
442   -
443   - }
444   -
445   -
446   - return iChainCount;
447   -};
448   -
449   -/**
450   - * 在具体位置移除班次。
451   - * @param qIndex 第几圈
452   - * @param bcIndex 第几个班次
453   - */
454   -InternalLpObj.prototype.removeBc = function(qIndex, bcIndex) {
455   - var group = this._$_groupBcArray[qIndex];
456   - if (bcIndex == 0) {
457   - group.removeBc1();
458   - } else if (bcIndex == 1) {
459   - group.removeBc2();
460   - }
461   -};
462   -
463   -/**
464   - * 使用指定时间匹配返回离之最近的第几圈第几个班次,
465   - * 使用时间差的绝度值,比较,取最小的
466   - * 如果有两个一样的时间差,取比fctime大的时间
467   - * @param fctime moment 比较用时间
468   - * @param groupArray 圈数组
469   - * @param hasUp boolean 计算上行班次
470   - * @param hasDown boolean 计算下行班次
471   - * @returns [{第几圈},{第几个班次}]
472   - */
473   -InternalLpObj.prototype.fnGetQBcIndexWithFcTimeFromGroupArray = function(
474   - fctime, groupArray, hasUp, hasDown
475   -) {
476   - var i;
477   - var timediff; // 时间差取绝对值
478   - var qIndex;
479   - var bcIndex;
480   -
481   - var group;
482   - var bc1time;
483   - var bc2time;
484   -
485   - var tempdiff;
486   -
487   - console.log("比较时间=" + fctime.format("HH:mm"));
488   -
489   - var oBc;
490   -
491   - for (i = 0; i < this._$_qCount; i++) {
492   - group = groupArray[i];
493   - if (group) {
494   - oBc = group.getBc1();
495   -
496   - if (oBc != undefined && ((hasUp && hasDown) || (hasUp && (oBc.isUp() == hasUp)) || (hasDown && (!oBc.isUp() == hasDown)))) {
497   - bc1time = group.getBc1().getFcTimeObj();
498   - console.log("bc1time=" + bc1time.format("HH:mm") + " tempdiff=" + tempdiff);
499   - tempdiff = Math.abs(bc1time.diff(fctime));
500   -
501   - if (!timediff) {
502   - timediff = Math.abs(tempdiff);
503   - qIndex = i;
504   - bcIndex = 0;
505   - } else {
506   - if (tempdiff < timediff) {
507   - timediff = tempdiff;
508   - qIndex = i;
509   - bcIndex = 0;
510   - } if (Math.abs(tempdiff) == timediff) {
511   - if (bc1time.isAfter(fctime)) {
512   - timediff = tempdiff;
513   - qIndex = i;
514   - bcIndex = 0;
515   - }
516   -
517   - }
518   - }
519   - }
520   -
521   - oBc = group.getBc2();
522   - if (oBc != undefined && ((hasUp && hasDown) || (hasUp && (oBc.isUp() == hasUp)) || (hasDown && (!oBc.isUp() == hasDown)))) {
523   - bc2time = group.getBc2().getFcTimeObj();
524   - console.log("bc2time=" + bc2time.format("HH:mm") + " tempdiff=" + tempdiff);
525   - tempdiff = Math.abs(bc2time.diff(fctime));
526   -
527   - if (!timediff) {
528   - timediff = Math.abs(tempdiff);
529   - qIndex = i;
530   - bcIndex = 1;
531   - } else {
532   - if (tempdiff < timediff) {
533   - timediff = tempdiff;
534   - qIndex = i;
535   - bcIndex = 1;
536   - } if (Math.abs(tempdiff) == timediff) {
537   - if (bc2time.isBefore(fctime)) {
538   - timediff = tempdiff;
539   - qIndex = i;
540   - bcIndex = 1;
541   - }
542   -
543   - }
544   - }
545   - }
546   - }
547   - }
548   -
549   - console.log("中标线对应数组索引=" + qIndex);
550   -
551   - var rst = [];
552   - rst.push(qIndex);
553   - rst.push(bcIndex);
554   -
555   - return rst;
556   -};
557   -
558   -/**
559   - * 使用指定时间匹配返回离之最近的第几圈第几个班次,
560   - * 使用时间差的绝度值,比较,取最小的
561   - * 如果有两个一样的时间差,取比fctime大的时间
562   - * @param fctime moment 比较用时间
563   - * @param hasUp boolean 计算上行班次
564   - * @param hasDown boolean 计算下行班次
565   - * @returns [{第几圈},{第几个班次}]
566   - */
567   -InternalLpObj.prototype.getQBcIndexWithFcTime = function(
568   - fctime, hasUp, hasDown
569   -) {
570   - return this.fnGetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray, hasUp, hasDown);
571   -};
572   -
573   -//---------------------- 内部数据初始化方法(不同于构造函数)---------------------//
574   -
575   -/**
576   - * 从指定开始时间到结束时间创建不间断班次(连班),并初始化路牌
577   - * 注意,之前有班次会删除后再创建。
578   - * @param startTime 开始时间
579   - * @param endTime 结束时间
580   - * @param isUp 第一个班次是上行还是下行
581   - * @param fromQ 从第几圈开始加入
582   - * @param paramObj 参数对象
583   - * @param factory 工厂对象
584   - */
585   -InternalLpObj.prototype.initDataFromTimeToTime = function(
586   - startTime,
587   - endTime,
588   - isUp,
589   - fromQ,
590   - paramObj,
591   - factory) {
592   -
593   - var bcData = []; // 班次数组
594   - var bcObj;
595   - var kssj = startTime;
596   - var fcno = 1; // 发车顺序号
597   - var bcCount = 1; // 班次数
598   - do {
599   - bcObj = factory.createBcObj(
600   - this, "normal", isUp, fcno, kssj, paramObj); // this就是所属路牌对象
601   - bcData.push(bcObj);
602   -
603   - kssj = paramObj.addMinute(kssj, bcObj.getBcTime() + bcObj.getStopTime());
604   - fcno ++;
605   - bcCount ++;
606   - isUp = !isUp;
607   - } while(kssj.isBefore(endTime));
608   - bcCount--;
609   -
610   - //console.log("last -1;" + bcData[bcCount -2].getFcTimeObj().format("HH:mm"));
611   - //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm"));
612   - //console.log("endtime: " + endTime.format("HH:mm"));
613   -
614   - //if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) {
615   - // // 如果最后一个班次的到达时间超过结束时间,也要去除
616   - // bcData.splice(bcCount - 1, 1);
617   - //}
618   -
619   - this._initDataFromLbBcArray(bcData, fromQ);
620   -
621   -};
622   -
623   -/**
624   - * 使用连班的班次数组初始化路牌(相应的圈会被覆盖)。
625   - * @param bcArray 连班班次数组
626   - * @param fromQ 从第几圈开始加入
627   - */
628   -InternalLpObj.prototype._initDataFromLbBcArray = function(
629   - bcArray,
630   - fromQ
631   -) {
632   - var _bc1Obj;
633   - var _bc2Obj;
634   - var _qObj;
635   -
636   - // 第一班次是上行还是下行
637   - var isUp = bcArray[0].isUp();
638   -
639   - if (bcArray.length > 0 && fromQ < this._$_qCount) {
640   - // 构造圈数
641   - if (isUp != this._$_isUp) {
642   - // 如果方向不一致,意味着第一个班次是半圈
643   - // 加半圈,并加在bc2上
644   - _bc2Obj = bcArray.slice(0, 1)[0];
645   - _qObj = new InternalGroupObj(
646   - this,
647   - this._$_isUp,
648   - undefined,
649   - _bc2Obj
650   - );
651   - _bc2Obj.setGroup(_qObj);
652   - this._$_groupBcArray[fromQ] = _qObj;
653   -
654   - bcArray.splice(0, 1);
655   - fromQ ++;
656   - }
657   -
658   - var qCount1 = Math.floor(bcArray.length / 2); // 需要添加多少圈
659   - var qCount2 = bcArray.length % 2; // 最后是否有半圈
660   -
661   - while (fromQ < this._$_qCount) {
662   - if (qCount1 > 0) {
663   - _bc1Obj = bcArray.slice(0, 1)[0];
664   - _bc2Obj = bcArray.slice(1, 2)[0];
665   - _qObj = new InternalGroupObj(
666   - this,
667   - this._$_isUp,
668   - _bc1Obj,
669   - _bc2Obj
670   - );
671   - _bc1Obj.setGroup(_qObj);
672   - _bc2Obj.setGroup(_qObj);
673   - this._$_groupBcArray[fromQ] = _qObj;
674   -
675   - bcArray.splice(0, 2);
676   - qCount1 --;
677   - } else if (qCount2 > 0) {
678   - // 加半圈,并加在bc1上
679   - _bc1Obj = bcArray.slice(0, 1)[0];
680   - _qObj = new InternalGroupObj(
681   - this,
682   - this._$_isUp,
683   - _bc1Obj,
684   - undefined
685   - );
686   - _bc1Obj.setGroup(_qObj);
687   - this._$_groupBcArray[fromQ] = _qObj;
688   -
689   - bcArray.splice(0, 1);
690   - qCount2 --;
691   - } else {
692   - break;
693   - }
694   -
695   - fromQ ++;
696   - }
697   - }
698   -};
699   -
700   -//-------------------------- 其他方法 ----------------------------//
701   -
702   -/**
703   - * 从指定位置的班次开始,往后所有的班次修正发车时间
704   - * @param groupIndex
705   - * @param bcIndex
706   - * @param time
707   - */
708   -InternalLpObj.prototype.fnAddMinuteToBcFcsj = function(groupIndex, bcIndex, time) {
709   - var i;
710   - var oCurBc;
711   -
712   - // 修正之前班次的停站时间
713   - //oCurBc = this.getBc(
714   - // bcIndex == 0 ? groupIndex - 1 : groupIndex,
715   - // bcIndex == 1 ? 0 : 1
716   - //);
717   - //if (oCurBc) {
718   - // oCurBc.setStopTime(oCurBc.getStopTime() + time);
719   - //}
720   -
721   -
722   - for (i = groupIndex; i < this._$_qCount; i++) {
723   - if (bcIndex == 0) {
724   - oCurBc = this.getBc(i, 0);
725   - if (oCurBc) {
726   - oCurBc.addMinuteToFcsj(time);
727   - }
728   - oCurBc = this.getBc(i, 1);
729   - if (oCurBc) {
730   - oCurBc.addMinuteToFcsj(time);
731   - }
732   -
733   - } else {
734   - oCurBc = this.getBc(i, 1);
735   - if (oCurBc) {
736   - oCurBc.addMinuteToFcsj(time);
737   - }
738   -
739   - }
740   -
741   - bcIndex = 0;
742   - }
743   -};
744   -
745   -/**
746   - * 在指定位置添加一个吃饭班次。
747   - * 注1:吃饭班次不是普通班次,不记录进圈,记录进_$_other_bc_array
748   - * 注2:添加吃饭班次时,会修改之前班次的停战时间,所以导致之后的班次的停战都会发生变化
749   - * @param groupIndex
750   - * @param bcIndex
751   - * @param factory
752   - * @param paramObj
753   - * @returns int 相差时间(吃饭时间距离和停站时间相差值)
754   - */
755   -InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, paramObj) {
756   - var oPreBc;
757   - var oEatBc;
758   - var iBcModifyTime;
759   -
760   - if (!this.getBc(groupIndex, bcIndex)) { //
761   - return 0;
762   - }
763   -
764   - oPreBc = this.getBc( // 前一个邻接班次
765   - bcIndex == 0 ? groupIndex - 1 : groupIndex,
766   - bcIndex == 1 ? 0 : 1);
767   - if (oPreBc) { // 存在前一个班次
768   - oEatBc = factory.createBcObj(
769   - this,
770   - "cf",
771   - !oPreBc.isUp(), // 和上一个班次方向相反
772   - 1,
773   - paramObj.addMinute(oPreBc.getArrTimeObj(), oPreBc.getStopTime()), // 使用上一个班次的到达时间作为开始时间
774   - paramObj
775   - );
776   -
777   - //iBcModifyTime = oEatBc.getBcTime() - oPreBc.getStopTime(); // 后续班次要调整的时间
778   -
779   - // 修正之后的班次发车时间
780   - // 注意:之后那个班次发车时间就是吃饭班次的到达时间
781   - iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m");
782   - this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime);
783   -
784   - oPreBc.setStopTime(0); // 不重置停站时间
785   - oPreBc.fnSetEatTime(oEatBc.getBcTime());
786   -
787   - //this._$_other_bc_array.push(oEatBc);
788   -
789   - return iBcModifyTime;
790   - } else {
791   - return false;
792   - }
793   -
794   -};
795   -
796   -/**
797   - * 调整路牌的班次,通过调整停站时间,或者班次发车时间,不能让班次的到达时间和下一个班次的发车时间重叠。
798   - * @param iPeakAverStopTime 高峰平均停站时间
799   - * @param iTroughAverStopTime 低谷平均停站时间
800   - * @param oParam 参数对象
801   - */
802   -InternalLpObj.prototype.fnAdjustBcInterval = function(iPeakAverStopTime, iTroughAverStopTime, oParam) {
803   - // 获取车次链个数
804   - var iBcChainCount = this.fnGetBcChainCount();
805   -
806   - var i;
807   - var j;
808   - var oBcIndex;
809   - var iQIndex;
810   - var iBcIndex;
811   - var iBcCount;
812   - var oBc;
813   - var oNextBc;
814   -
815   - var iBcStopTime;
816   -
817   - for (i = 0; i < iBcChainCount; i++) {
818   - oBcIndex = this.fnGetBcChainInfo(i);
819   - iQIndex = oBcIndex["s_q"];
820   - iBcIndex = oBcIndex["s_b"];
821   - iBcCount = oBcIndex["bcount"];
822   -
823   - for (j = 0; j < iBcCount - 1; j++) {
824   - oBc = this.getBc(iQIndex, iBcIndex);
825   - oNextBc = this.getBc(
826   - iBcIndex == 0 ? iQIndex : iQIndex + 1,
827   - iBcIndex == 0 ? 1 : 0);
828   -
829   - if (oNextBc.fnIsFirstBc()) { // 如果同一路牌连续2个方向首站班次,都不做处理
830   - continue;
831   - }
832   -
833   - // 不改变当前班次的行驶时间,修正停站时间和下一个班次的发车时间
834   - iBcStopTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m");
835   - if (iBcStopTime < 0) {
836   - // 当前班次使用最小停站时间
837   - oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp()));
838   - oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime);
839   -
840   - } else {
841   - if (iBcStopTime == oBc.getStopTime() + oBc.fnGetEatTime()) {
842   - // 停站时间一致,没有问题
843   -
844   -
845   - } else {
846   - // TODO:当前班次使用最小停站时间
847   - oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp()));
848   - oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime);
849   -
850   - }
851   - }
852   -
853   - iBcIndex = iBcIndex == 0 ? 1 : 0;
854   - iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex;
855   - }
856   -
857   - this.getBc(iQIndex, iBcIndex).setStopTime(0);
858   - }
859   -
860   -
861   -};
862   -
863   -/**
864   - * 返回指定班次的上一个班次。
865   - * @param oBc {moment} 指定班次
866   - * @returns {object} 上一个班次,如果没有,返回false
867   - */
868   -InternalLpObj.prototype.getPreBc = function(oBc) {
869   - // 获取车次链个数
870   - var iBcChainCount = this.fnGetBcChainCount();
871   -
872   - var i;
873   - var j;
874   - var oBcIndex;
875   - var iQIndex;
876   - var iBcIndex;
877   - var iBcCount;
878   - var _oPreBc;
879   - var _bFindCurrentBc = false;
880   -
881   - for (i = 0; i < iBcChainCount; i++) {
882   - oBcIndex = this.fnGetBcChainInfo(i);
883   - iQIndex = oBcIndex["s_q"];
884   - iBcIndex = oBcIndex["s_b"];
885   - iBcCount = oBcIndex["bcount"];
886   -
887   - for (j = 0; j < iBcCount - 1; j++) {
888   - if (oBc.getFcTimeObj().format("HH:mm") ==
889   - this.getBc(iQIndex, iBcIndex).getFcTimeObj().format("HH:mm")) {
890   - _bFindCurrentBc = true;
891   - break;
892   - }
893   -
894   - // 进入到下一圈
895   - iBcIndex = iBcIndex == 0 ? 1 : 0;
896   - iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex;
897   - }
898   -
899   - if (_bFindCurrentBc) {
900   - if (iQIndex == oBcIndex["s_q"] && iBcIndex == oBcIndex["s_q"]) { // 第一个班次
901   - break;
902   - } else {
903   - _oPreBc = this.getBc(
904   - iBcIndex == 0 ? iQIndex - 1 : iQIndex,
905   - iBcIndex == 0 ? 1 : 0);
906   - }
907   - }
908   -
909   - }
910   -
911   - return _oPreBc || false;
912   -
913   -};
914   -
915   -/**
916   - * 通过修改layover时间,修正班次的发车,到达时间。
917   - * 如果layover时间不符合范围要求,修改成平均时间。
918   - * @param oParam {ParameterObj} 参数对象
919   - */
920   -InternalLpObj.prototype.fnAdjustBcTime_layover = function(oParam) {
921   - // 获取车次链个数(连班路牌1个,分班路牌2个)
922   - var iBlockCount = this.fnGetBcChainCount();
923   -
924   - var i;
925   - var j;
926   - var aTrip; // 每个block关联的trip列表
927   - var trip; // 当前班次
928   - var nextTrip; // 下一个班次
929   - var layOverTime;
930   - var aLayOverTimeRange;
931   -
932   - var oBcIndex;
933   - var iQIndex; // block开始第几圈缩影
934   - var iBcIndex; // block开始第几个班次
935   - var iBcCount; // block的trip数目
936   -
937   -
938   - for (i = 0; i < iBlockCount; i++) {
939   - // 获取block关联的trip列表
940   - oBcIndex = this.fnGetBcChainInfo(i);
941   - iQIndex = oBcIndex["s_q"];
942   - iBcIndex = oBcIndex["s_b"];
943   - iBcCount = oBcIndex["bcount"];
944   -
945   - aTrip = [];
946   - for (j = 0; j < iBcCount; j++) {
947   - aTrip.push(this.getBc(iQIndex, iBcIndex));
948   - iBcIndex = iBcIndex == 0 ? 1 : 0;
949   - iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex;
950   - }
951   -
952   - if (aTrip.length < 2) {
953   - // 两个trip一起处理,只有1个trip的block不处理
954   - continue;
955   - }
956   - // 迭代block,处理trip的发车,到达,停站时间
957   - for (j = 0; j < aTrip.length - 1; j++) {
958   - trip = aTrip[j];
959   - nextTrip = aTrip[j + 1];
960   -
961   - if (trip.fnIsFirstBc() && nextTrip.fnIsFirstBc()) {
962   - // 如果两个方向的首班车都在一个block上
963   - // 则停站时间不考虑范围,直接发车时间-到达时间
964   - layOverTime = nextTrip.getFcTimeObj().diff(trip.getArrTimeObj(), "m");
965   - trip.setStopTime(layOverTime);
966   - continue;
967   - }
968   -
969   - //------------- 吃饭班次处理 -----------//
970   - // 获取当前trip的layover的范围
971   - aLayOverTimeRange = oParam.calcuTripLayoverTimeRange(
972   - trip.getArrTimeObj(), trip.isUp(), trip.getBcTime()
973   - );
974   - // 重新计算当前班次layover时间
975   - layOverTime = nextTrip.getFcTimeObj().diff(trip.getArrTimeObj(), "m");
976   - if (trip.fnGetEatTime() > 0) {
977   - // 如果当前班次layover是要吃饭的
978   - // 则停站时间没有,变成吃饭时间
979   - trip.setStopTime(0);
980   - // 修改下一个班次的发车时间,到达时间
981   - nextTrip.setFcTimeObj(oParam.addMinute(
982   - trip.getArrTimeObj(),
983   - trip.fnGetEatTime())
984   - );
985   - nextTrip.setBcTime(oParam.calcuTravelTime(nextTrip.getFcTimeObj(), nextTrip.isUp()));
986   - nextTrip.setArrTimeObj(oParam.addMinute(nextTrip.getFcTimeObj(), nextTrip.getBcTime()));
987   - continue;
988   - }
989   -
990   - //------------- 正常班次处理 -----------//
991   - if (layOverTime < aLayOverTimeRange[0] || layOverTime > aLayOverTimeRange[1]) {
992   - // 如果layover时间在范围之外,使用平均值
993   - layOverTime = oParam.fnCalcuFixedStopNumber(
994   - trip.getArrTimeObj(),
995   - trip.isUp(),
996   - oParam.calcuTravelTime(
997   - trip.getFcTimeObj(),
998   - trip.isUp())
999   - );
1000   -
1001   - trip.setStopTime(layOverTime);
1002   - nextTrip.setFcTimeObj(oParam.addMinute(
1003   - trip.getArrTimeObj(),
1004   - trip.getStopTime())
1005   - );
1006   - nextTrip.setBcTime(oParam.calcuTravelTime(nextTrip.getFcTimeObj(), nextTrip.isUp()));
1007   - nextTrip.setArrTimeObj(oParam.addMinute(nextTrip.getFcTimeObj(), nextTrip.getBcTime()));
1008   - }
1009   - }
1010   - // 最后一个trip的layover时间为0
1011   - aTrip[j].setStopTime(0);
1012   -
1013   - }
1014   -};
1015   -
1016   -// TODO
1017   -
1018   -/**
1019   - *
1020   - *
1021   - */
1022   -InternalLpObj.prototype.calcuLpBx = function() {
1023   -
1024   -};
1025   -
1026   -
  1 +/**
  2 + * 内部路牌对象。
  3 + * @constructor
  4 + */
  5 +var InternalLpObj = function(
  6 + orilpObj, // 原始路牌对象
  7 + qCount, // 总共多少圈
  8 + isUp // 圈是以上行开始还是下行开始
  9 +) {
  10 + // TODO:原始路牌对象(这个路牌是对接外部gantt图像,以后有机会改了)
  11 + this._$$_orign_lp_obj = orilpObj;
  12 +
  13 + this._$_isUp = isUp;
  14 +
  15 + // 路牌的圈数,注意每个路牌的圈数都是一致的,
  16 + // 但并不是每一圈都有值
  17 + // 第1圈从上标线开始
  18 + // 第0圈表示中标线的第一个班次组成的半圈
  19 + // 有多少圈根据最终迭代的结果来看
  20 + this._$_qCount = qCount;
  21 + // 保存的是 InternalGroupBcObj 对象
  22 + this._$_groupBcArray = new Array(qCount);
  23 +
  24 + var i;
  25 + for (i = 0; i < this._$_qCount; i++) {
  26 + this._$_groupBcArray[i] = new InternalGroupObj(
  27 + this, this._$_isUp, undefined, undefined);
  28 + }
  29 +
  30 + // 距离上一个路牌的最小发车间隔时间
  31 + // 用于纵向添加班次的时候使用
  32 + // 默认第一个路牌为0
  33 + this._$_minVerticalIntervalTime = 0;
  34 +
  35 + // 详细记录每圈每个方向上的发车间隔时间
  36 + // 第一维度表示圈数,第二维度表示第一个方向,第二个方向
  37 + // 第一个方向是否上行由 _$_isUp 决定
  38 + // 这里的间隔表示下一个路牌上的班次距离本路牌的班次发车时间间隔
  39 + // 如果当前是最后一个路牌,表示第一个路牌的下一圈同方向班次距离本班次的间隔
  40 + this._$_aVerticalIntervalTime = new Array(this._$_qCount);
  41 + for (i = 0; i < this._$_aVerticalIntervalTime.length; i++) {
  42 + this._$_aVerticalIntervalTime[i] = new Array(2);
  43 + }
  44 +
  45 + // 班型的相关变量
  46 + this._$_bx_isLb = false; // 是否连班
  47 + this._$_bx_isfb = false; // 是否分班
  48 + this._$_bx_isfb_5_2 = false; // 是否5休2分班
  49 + this._$_bx_desc; // 班型描述(默认为路牌编号)
  50 +
  51 + // 其他班次(进出场,例包,吃饭等),TODO:以后再拆
  52 + this._$_other_bc_array = [];
  53 +
  54 + // TODO:
  55 +
  56 +};
  57 +
  58 +//------------------- get/set 方法 -------------------//
  59 +
  60 +InternalLpObj.prototype.getOtherBcArray = function() {
  61 + return this._$_other_bc_array;
  62 +};
  63 +InternalLpObj.prototype.addOtherBcArray = function(ba) {
  64 + this._$_other_bc_array = this._$_other_bc_array.concat(ba);
  65 +};
  66 +
  67 +/**
  68 + * 获取圈
  69 + * @param qIndex 圈index
  70 + */
  71 +InternalLpObj.prototype.getGroup = function(qIndex) {
  72 + return this._$_groupBcArray[qIndex];
  73 +};
  74 +
  75 +/**
  76 + * 获取路牌圈数。
  77 + * @returns {*}
  78 + */
  79 +InternalLpObj.prototype.fnGetGroupCount = function() {
  80 + return this._$_qCount;
  81 +};
  82 +
  83 +/**
  84 + * 是否上行。
  85 + * @returns boolean
  86 + */
  87 +InternalLpObj.prototype.isUp = function() {
  88 + return this._$_isUp;
  89 +};
  90 +
  91 +/**
  92 + * 获取班次。
  93 + * @param qIndex 第几圈
  94 + * @param bcIndex 第几个班次
  95 + */
  96 +InternalLpObj.prototype.getBc = function(qIndex, bcIndex) {
  97 + if (qIndex < 0 || qIndex >= this._$_qCount) {
  98 + return undefined;
  99 + }
  100 +
  101 + var group = this._$_groupBcArray[qIndex];
  102 + if (!group) {
  103 + return undefined;
  104 + }
  105 + var bc;
  106 + if (bcIndex == 0) {
  107 + bc = group.getBc1();
  108 + } else if (bcIndex == 1) {
  109 + bc = group.getBc2();
  110 + }
  111 + return bc;
  112 +};
  113 +
  114 +/**
  115 + * 在具体位置设置班次。
  116 + * @param qIndex 第几圈
  117 + * @param bcIndex 第几个班次
  118 + * @param bc 班次对象
  119 + */
  120 +InternalLpObj.prototype.setBc = function(qIndex, bcIndex, bc) {
  121 + var group = this._$_groupBcArray[qIndex];
  122 + if (bcIndex == 0) {
  123 + group.setBc1(bc);
  124 + bc.setGroup(group);
  125 + } else if (bcIndex == 1) {
  126 + group.setBc2(bc);
  127 + bc.setGroup(group);
  128 + }
  129 +};
  130 +
  131 +/**
  132 + * 设置原始路牌对象。
  133 + * @param lpObj 原始路牌对象
  134 + */
  135 +InternalLpObj.prototype.setLp = function(lpObj) {
  136 + this._$$_orign_lp_obj = lpObj;
  137 + var i;
  138 + var group;
  139 + for (i = 0; i < this._$_groupBcArray.length; i++) {
  140 + group = this._$_groupBcArray[i];
  141 + if (group) {
  142 + group.setLp(this); // 圈和班次保存都是 InternalLpObj 对象
  143 + }
  144 + }
  145 +};
  146 +
  147 +InternalLpObj.prototype.getLpNo = function() {
  148 + return this._$$_orign_lp_obj.lpNo;
  149 +};
  150 +InternalLpObj.prototype.getLpName = function() {
  151 + return this._$$_orign_lp_obj.lpName;
  152 +};
  153 +InternalLpObj.prototype.setBxFb5_2 = function(fb) {
  154 + this._$_bx_isfb_5_2 = fb;
  155 +};
  156 +InternalLpObj.prototype.isBxFb5_2 = function() {
  157 + return this._$_bx_isfb_5_2;
  158 +};
  159 +InternalLpObj.prototype.setBxLb = function(lb) {
  160 + this._$_bx_isLb = lb;
  161 +};
  162 +InternalLpObj.prototype.isBxLb = function() {
  163 + return this._$_bx_isLb;
  164 +};
  165 +
  166 +InternalLpObj.prototype.setBxFb = function(fb) {
  167 + this._$_bx_isfb = fb;
  168 +};
  169 +InternalLpObj.prototype.isBxFb = function() {
  170 + return this._$_bx_isfb;
  171 +};
  172 +
  173 +/**
  174 + * 设置路牌的班型描述(最终是设置班次的路牌名字)。
  175 + * @param desc 描述
  176 + */
  177 +InternalLpObj.prototype.setBxDesc = function(desc) {
  178 + // 最终原始路牌的名字
  179 + this._$$_orign_lp_obj.lpName = desc + "_" + this._$$_orign_lp_obj.lpNo;
  180 + // 内部对象的班型描述
  181 + this._$_bx_desc = desc;
  182 +};
  183 +/**
  184 + * 获取版型描述
  185 + * @returns string
  186 + */
  187 +InternalLpObj.prototype.getBxDesc = function() {
  188 + return this._$_bx_desc;
  189 +};
  190 +
  191 +/**
  192 + * 设置纵向最小发车间隔时间。
  193 + * @param v
  194 + */
  195 +InternalLpObj.prototype.setVerticalMinIntervalTime = function(v) {
  196 + // 第一个路牌,都为0
  197 + this._$_minVerticalIntervalTime = v;
  198 +};
  199 +/**
  200 + * 获取纵向最小发车间隔时间。
  201 + * @returns {number|*}
  202 + */
  203 +InternalLpObj.prototype.getVerticalMinIntervalTime = function() {
  204 + return this._$_minVerticalIntervalTime;
  205 +};
  206 +
  207 +/**
  208 + * 设置纵向发车间隔。
  209 + * @param iQindex 圈index
  210 + * @param iBindex 班次index
  211 + * @param iTime 间隔时间
  212 + */
  213 +InternalLpObj.prototype.fnSetVerticalIntervalTime = function(iQindex, iBindex, iTime) {
  214 + this._$_aVerticalIntervalTime[iQindex][iBindex] = iTime;
  215 +};
  216 +
  217 +/**
  218 + * 返回纵向发车间隔。
  219 + * @param iQindex 圈index
  220 + * @param iBindex 班次index
  221 + */
  222 +InternalLpObj.prototype.fnGetVerticalIntervalTime = function(iQindex, iBindex) {
  223 + return this._$_aVerticalIntervalTime[iQindex][iBindex];
  224 +};
  225 +
  226 +//-------------------- 班次操作方法(查询,统计,删除) -----------------------//
  227 +
  228 +/**
  229 + * 返回总共班次数。
  230 + */
  231 +InternalLpObj.prototype.getBcCount = function() {
  232 + var i;
  233 + var group;
  234 + var bccount = 0;
  235 + for (i = 0; i < this._$_groupBcArray.length; i++) {
  236 + group = this._$_groupBcArray[i];
  237 + if (group) {
  238 + if (group.getBc1()) {
  239 + bccount += 1;
  240 + }
  241 + if (group.getBc2()) {
  242 + bccount += 1;
  243 + }
  244 + }
  245 + }
  246 +
  247 + return bccount;
  248 +};
  249 +
  250 +/**
  251 + * 返回班次列表,过滤空的班次,将所有存在的班次连成连续的对象数组返回。
  252 + * @returns arrays (InternalBcObj)
  253 + */
  254 +InternalLpObj.prototype.getBcArray = function() {
  255 + var bcArray = [];
  256 + var i;
  257 + var group;
  258 + for (i = 0; i < this._$_groupBcArray.length; i++) {
  259 + group = this._$_groupBcArray[i];
  260 + if (group) {
  261 + group.getBc1() ? bcArray.push(group.getBc1()) : "";
  262 + group.getBc2() ? bcArray.push(group.getBc2()) : "";
  263 + }
  264 + }
  265 +
  266 + return bcArray;
  267 +};
  268 +
  269 +/**
  270 + * 获取最小(最早)班次对象。
  271 + * @returns [{圈index},{班次index}]
  272 + */
  273 +InternalLpObj.prototype.getMinBcObjPosition = function() {
  274 + var i;
  275 + var bIndex = [];
  276 + for (i = 0; i < this._$_groupBcArray.length; i++) {
  277 + if (this._$_groupBcArray[i].getBc1()) {
  278 + bIndex.push(i);
  279 + bIndex.push(0);
  280 + break;
  281 + }
  282 + if (this._$_groupBcArray[i].getBc2()) {
  283 + bIndex.push(i);
  284 + bIndex.push(1);
  285 + break;
  286 + }
  287 + }
  288 + return bIndex;
  289 +};
  290 +
  291 +/**
  292 + * 获取最大(最晚)班次对象。
  293 + * @returns [{圈index},{班次index}]
  294 + */
  295 +InternalLpObj.prototype.getMaxBcObjPosition = function() {
  296 + var i;
  297 + var bIndex = [];
  298 + for (i = this._$_groupBcArray.length - 1; i >= 0; i--) {
  299 + if (this._$_groupBcArray[i].getBc2()) {
  300 + bIndex.push(i);
  301 + bIndex.push(1);
  302 + break;
  303 + }
  304 + if (this._$_groupBcArray[i].getBc1()) {
  305 + bIndex.push(i);
  306 + bIndex.push(0);
  307 + break;
  308 + }
  309 + }
  310 + return bIndex;
  311 +};
  312 +
  313 +InternalLpObj.prototype.getMinBcObj = function() {
  314 + var i;
  315 + var bcObj;
  316 + for (i = 0; i < this._$_groupBcArray.length; i++) {
  317 + bcObj = this._$_groupBcArray[i].getBc1();
  318 + if (bcObj) {
  319 + break;
  320 + }
  321 + bcObj = this._$_groupBcArray[i].getBc2();
  322 + if (bcObj) {
  323 + break;
  324 + }
  325 + }
  326 + return bcObj;
  327 +};
  328 +InternalLpObj.prototype.getMaxBcObj = function() {
  329 + var i;
  330 + var bcObj;
  331 + for (i = this._$_groupBcArray.length - 1; i >= 0; i--) {
  332 + bcObj = this._$_groupBcArray[i].getBc2();
  333 + if (bcObj) {
  334 + break;
  335 + }
  336 + bcObj = this._$_groupBcArray[i].getBc1();
  337 + if (bcObj) {
  338 + break;
  339 + }
  340 + }
  341 + return bcObj;
  342 +};
  343 +
  344 +/**
  345 + * 获取车次链信息。
  346 + * @param num 第几个车次链
  347 + * @returns object {s_q: {开始圈索引},s_b : {开始班次索引},e_q : {结束圈索引},e_b : {结束班次索引}, bcount : {班次数}}
  348 + */
  349 +InternalLpObj.prototype.fnGetBcChainInfo = function(num) {
  350 + // 计算总的车次链信息
  351 + var aChainInfo = [];
  352 + var oChainInfo;
  353 + var aBcIndex = this.getMinBcObjPosition();
  354 + var oBc;
  355 + var iQIndex;
  356 + var iBcIndex;
  357 + var i;
  358 + var bFlag;
  359 +
  360 + var iBcount = 0;
  361 +
  362 + if (aBcIndex.length == 2) {
  363 + iBcount = 1;
  364 + oChainInfo = {s_q : aBcIndex[0], s_b : aBcIndex[1], e_q : aBcIndex[0], e_b : aBcIndex[1], bcount: 1};
  365 + aChainInfo.push(oChainInfo);
  366 + bFlag = true;
  367 +
  368 + // 下一个班次的索引
  369 + iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1;
  370 + iBcIndex = aBcIndex[1] == 0 ? 1 : 0;
  371 +
  372 + for (i = iQIndex; i < this._$_qCount; i++) {
  373 + while (iBcIndex <= 1) {
  374 + oBc = this.getBc(i, iBcIndex);
  375 + if (!oBc) {
  376 + if (bFlag) {
  377 + // 车次链结尾是这个班次的前一个班次
  378 + oChainInfo.e_q = iBcIndex == 0 ? i - 1 : i;
  379 + oChainInfo.e_b = iBcIndex == 0 ? 1 : 0;
  380 + oChainInfo.bcount = iBcount;
  381 + }
  382 +
  383 + bFlag = false;
  384 + } else {
  385 + if (bFlag) {
  386 + iBcount ++;
  387 + oChainInfo.bcount = iBcount;
  388 + } else {
  389 + // 下一个车次链开始
  390 + iBcount = 1;
  391 + oChainInfo = {s_q : i, s_b : iBcIndex, e_q : i, e_b : iBcIndex, bcount: 1};
  392 + aChainInfo.push(oChainInfo);
  393 + bFlag = true;
  394 + }
  395 + }
  396 +
  397 +
  398 + iBcIndex ++;
  399 + }
  400 + iBcIndex = 0;
  401 + }
  402 +
  403 + }
  404 +
  405 + return aChainInfo[num];
  406 +};
  407 +
  408 +/**
  409 + * 获取车次链的个数。
  410 + * @returns int
  411 + */
  412 +InternalLpObj.prototype.fnGetBcChainCount = function() {
  413 + var iChainCount = 0;
  414 + var aBcIndex = this.getMinBcObjPosition();
  415 +
  416 + var oBc;
  417 + var iQIndex;
  418 + var iBcIndex;
  419 + var i;
  420 + var bFlag;
  421 +
  422 + if (aBcIndex.length == 2) {
  423 + iChainCount = 1;
  424 + bFlag = true;
  425 +
  426 + // 下一个班次的索引
  427 + iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1;
  428 + iBcIndex = aBcIndex[1] == 0 ? 1 : 0;
  429 +
  430 + for (i = iQIndex; i < this._$_qCount; i++) {
  431 + while (iBcIndex <= 1) {
  432 + oBc = this.getBc(i, iBcIndex);
  433 + if (!oBc) {
  434 + bFlag = false;
  435 + } else {
  436 + if (bFlag) {
  437 +
  438 + } else {
  439 + iChainCount ++;
  440 + bFlag = true;
  441 + }
  442 + }
  443 +
  444 +
  445 + iBcIndex ++;
  446 + }
  447 + iBcIndex = 0;
  448 + }
  449 +
  450 + }
  451 +
  452 +
  453 + return iChainCount;
  454 +};
  455 +
  456 +/**
  457 + * 在具体位置移除班次。
  458 + * @param qIndex 第几圈
  459 + * @param bcIndex 第几个班次
  460 + */
  461 +InternalLpObj.prototype.removeBc = function(qIndex, bcIndex) {
  462 + var group = this._$_groupBcArray[qIndex];
  463 + if (bcIndex == 0) {
  464 + group.removeBc1();
  465 + } else if (bcIndex == 1) {
  466 + group.removeBc2();
  467 + }
  468 +};
  469 +
  470 +/**
  471 + * 使用指定时间匹配返回离之最近的第几圈第几个班次,
  472 + * 使用时间差的绝度值,比较,取最小的
  473 + * 如果有两个一样的时间差,取比fctime大的时间
  474 + * @param fctime moment 比较用时间
  475 + * @param groupArray 圈数组
  476 + * @param hasUp boolean 计算上行班次
  477 + * @param hasDown boolean 计算下行班次
  478 + * @returns [{第几圈},{第几个班次}]
  479 + */
  480 +InternalLpObj.prototype.fnGetQBcIndexWithFcTimeFromGroupArray = function(
  481 + fctime, groupArray, hasUp, hasDown
  482 +) {
  483 + var i;
  484 + var timediff; // 时间差取绝对值
  485 + var qIndex;
  486 + var bcIndex;
  487 +
  488 + var group;
  489 + var bc1time;
  490 + var bc2time;
  491 +
  492 + var tempdiff;
  493 +
  494 + console.log("比较时间=" + fctime.format("HH:mm"));
  495 +
  496 + var oBc;
  497 +
  498 + for (i = 0; i < this._$_qCount; i++) {
  499 + group = groupArray[i];
  500 + if (group) {
  501 + oBc = group.getBc1();
  502 +
  503 + if (oBc != undefined && ((hasUp && hasDown) || (hasUp && (oBc.isUp() == hasUp)) || (hasDown && (!oBc.isUp() == hasDown)))) {
  504 + bc1time = group.getBc1().getFcTimeObj();
  505 + console.log("bc1time=" + bc1time.format("HH:mm") + " tempdiff=" + tempdiff);
  506 + tempdiff = Math.abs(bc1time.diff(fctime));
  507 +
  508 + if (!timediff) {
  509 + timediff = Math.abs(tempdiff);
  510 + qIndex = i;
  511 + bcIndex = 0;
  512 + } else {
  513 + if (tempdiff < timediff) {
  514 + timediff = tempdiff;
  515 + qIndex = i;
  516 + bcIndex = 0;
  517 + } if (Math.abs(tempdiff) == timediff) {
  518 + if (bc1time.isAfter(fctime)) {
  519 + timediff = tempdiff;
  520 + qIndex = i;
  521 + bcIndex = 0;
  522 + }
  523 +
  524 + }
  525 + }
  526 + }
  527 +
  528 + oBc = group.getBc2();
  529 + if (oBc != undefined && ((hasUp && hasDown) || (hasUp && (oBc.isUp() == hasUp)) || (hasDown && (!oBc.isUp() == hasDown)))) {
  530 + bc2time = group.getBc2().getFcTimeObj();
  531 + console.log("bc2time=" + bc2time.format("HH:mm") + " tempdiff=" + tempdiff);
  532 + tempdiff = Math.abs(bc2time.diff(fctime));
  533 +
  534 + if (!timediff) {
  535 + timediff = Math.abs(tempdiff);
  536 + qIndex = i;
  537 + bcIndex = 1;
  538 + } else {
  539 + if (tempdiff < timediff) {
  540 + timediff = tempdiff;
  541 + qIndex = i;
  542 + bcIndex = 1;
  543 + } if (Math.abs(tempdiff) == timediff) {
  544 + if (bc2time.isBefore(fctime)) {
  545 + timediff = tempdiff;
  546 + qIndex = i;
  547 + bcIndex = 1;
  548 + }
  549 +
  550 + }
  551 + }
  552 + }
  553 + }
  554 + }
  555 +
  556 + console.log("中标线对应数组索引=" + qIndex);
  557 +
  558 + var rst = [];
  559 + rst.push(qIndex);
  560 + rst.push(bcIndex);
  561 +
  562 + return rst;
  563 +};
  564 +
  565 +/**
  566 + * 使用指定时间匹配返回离之最近的第几圈第几个班次,
  567 + * 使用时间差的绝度值,比较,取最小的
  568 + * 如果有两个一样的时间差,取比fctime大的时间
  569 + * @param fctime moment 比较用时间
  570 + * @param hasUp boolean 计算上行班次
  571 + * @param hasDown boolean 计算下行班次
  572 + * @returns [{第几圈},{第几个班次}]
  573 + */
  574 +InternalLpObj.prototype.getQBcIndexWithFcTime = function(
  575 + fctime, hasUp, hasDown
  576 +) {
  577 + return this.fnGetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray, hasUp, hasDown);
  578 +};
  579 +
  580 +//---------------------- 内部数据初始化方法(不同于构造函数)---------------------//
  581 +
  582 +/**
  583 + * 从指定开始时间到结束时间创建不间断班次(连班),并初始化路牌
  584 + * 注意,之前有班次会删除后再创建。
  585 + * @param startTime 开始时间
  586 + * @param endTime 结束时间
  587 + * @param isUp 第一个班次是上行还是下行
  588 + * @param fromQ 从第几圈开始加入
  589 + * @param paramObj 参数对象
  590 + * @param factory 工厂对象
  591 + */
  592 +InternalLpObj.prototype.initDataFromTimeToTime = function(
  593 + startTime,
  594 + endTime,
  595 + isUp,
  596 + fromQ,
  597 + paramObj,
  598 + factory) {
  599 +
  600 + var bcData = []; // 班次数组
  601 + var bcObj;
  602 + var kssj = startTime;
  603 + var fcno = 1; // 发车顺序号
  604 + var bcCount = 1; // 班次数
  605 + do {
  606 + bcObj = factory.createBcObj(
  607 + this, "normal", isUp, fcno, kssj, paramObj); // this就是所属路牌对象
  608 + bcData.push(bcObj);
  609 +
  610 + kssj = paramObj.addMinute(kssj, bcObj.getBcTime() + bcObj.getStopTime());
  611 + fcno ++;
  612 + bcCount ++;
  613 + isUp = !isUp;
  614 + } while(kssj.isBefore(endTime));
  615 + bcCount--;
  616 +
  617 + //console.log("last -1;" + bcData[bcCount -2].getFcTimeObj().format("HH:mm"));
  618 + //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm"));
  619 + //console.log("endtime: " + endTime.format("HH:mm"));
  620 +
  621 + //if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) {
  622 + // // 如果最后一个班次的到达时间超过结束时间,也要去除
  623 + // bcData.splice(bcCount - 1, 1);
  624 + //}
  625 +
  626 + this._initDataFromLbBcArray(bcData, fromQ);
  627 +
  628 +};
  629 +
  630 +/**
  631 + * 使用连班的班次数组初始化路牌(相应的圈会被覆盖)。
  632 + * @param bcArray 连班班次数组
  633 + * @param fromQ 从第几圈开始加入
  634 + */
  635 +InternalLpObj.prototype._initDataFromLbBcArray = function(
  636 + bcArray,
  637 + fromQ
  638 +) {
  639 + var _bc1Obj;
  640 + var _bc2Obj;
  641 + var _qObj;
  642 +
  643 + // 第一班次是上行还是下行
  644 + if (bcArray.length == 0) {
  645 + return;
  646 + }
  647 + var isUp = bcArray[0].isUp();
  648 +
  649 + if (bcArray.length > 0 && fromQ < this._$_qCount) {
  650 + // 构造圈数
  651 + if (isUp != this._$_isUp) {
  652 + // 如果方向不一致,意味着第一个班次是半圈
  653 + // 加半圈,并加在bc2上
  654 + _bc2Obj = bcArray.slice(0, 1)[0];
  655 + _qObj = new InternalGroupObj(
  656 + this,
  657 + this._$_isUp,
  658 + this.getGroup(fromQ).getBc1(), // 之前group的前半个班次要保留
  659 + _bc2Obj
  660 + );
  661 + _bc2Obj.setGroup(_qObj);
  662 + this._$_groupBcArray[fromQ] = _qObj;
  663 +
  664 + bcArray.splice(0, 1);
  665 + fromQ ++;
  666 + }
  667 +
  668 + var qCount1 = Math.floor(bcArray.length / 2); // 需要添加多少圈
  669 + var qCount2 = bcArray.length % 2; // 最后是否有半圈
  670 +
  671 + while (fromQ < this._$_qCount) {
  672 + if (qCount1 > 0) {
  673 + _bc1Obj = bcArray.slice(0, 1)[0];
  674 + _bc2Obj = bcArray.slice(1, 2)[0];
  675 + _qObj = new InternalGroupObj(
  676 + this,
  677 + this._$_isUp,
  678 + _bc1Obj,
  679 + _bc2Obj
  680 + );
  681 + _bc1Obj.setGroup(_qObj);
  682 + _bc2Obj.setGroup(_qObj);
  683 + this._$_groupBcArray[fromQ] = _qObj;
  684 +
  685 + bcArray.splice(0, 2);
  686 + qCount1 --;
  687 + } else if (qCount2 > 0) {
  688 + // 加半圈,并加在bc1上
  689 + _bc1Obj = bcArray.slice(0, 1)[0];
  690 + _qObj = new InternalGroupObj(
  691 + this,
  692 + this._$_isUp,
  693 + _bc1Obj,
  694 + undefined // 如果之前的组这里有班次,不保留,直接祛除
  695 + );
  696 + _bc1Obj.setGroup(_qObj);
  697 + this._$_groupBcArray[fromQ] = _qObj;
  698 +
  699 + bcArray.splice(0, 1);
  700 + qCount2 --;
  701 + } else {
  702 + break;
  703 + }
  704 +
  705 + fromQ ++;
  706 + }
  707 + }
  708 +};
  709 +
  710 +//-------------------------- 其他方法 ----------------------------//
  711 +
  712 +/**
  713 + * 从指定位置的班次开始,往后所有的班次修正发车时间
  714 + * @param groupIndex
  715 + * @param bcIndex
  716 + * @param time
  717 + */
  718 +InternalLpObj.prototype.fnAddMinuteToBcFcsj = function(groupIndex, bcIndex, time) {
  719 + var i;
  720 + var oCurBc;
  721 +
  722 + // 修正之前班次的停站时间
  723 + //oCurBc = this.getBc(
  724 + // bcIndex == 0 ? groupIndex - 1 : groupIndex,
  725 + // bcIndex == 1 ? 0 : 1
  726 + //);
  727 + //if (oCurBc) {
  728 + // oCurBc.setStopTime(oCurBc.getStopTime() + time);
  729 + //}
  730 +
  731 +
  732 + for (i = groupIndex; i < this._$_qCount; i++) {
  733 + if (bcIndex == 0) {
  734 + oCurBc = this.getBc(i, 0);
  735 + if (oCurBc) {
  736 + oCurBc.addMinuteToFcsj(time);
  737 + }
  738 + oCurBc = this.getBc(i, 1);
  739 + if (oCurBc) {
  740 + oCurBc.addMinuteToFcsj(time);
  741 + }
  742 +
  743 + } else {
  744 + oCurBc = this.getBc(i, 1);
  745 + if (oCurBc) {
  746 + oCurBc.addMinuteToFcsj(time);
  747 + }
  748 +
  749 + }
  750 +
  751 + bcIndex = 0;
  752 + }
  753 +};
  754 +
  755 +/**
  756 + * 在指定位置添加一个吃饭班次。
  757 + * 注1:吃饭班次不是普通班次,不记录进圈,记录进_$_other_bc_array
  758 + * 注2:添加吃饭班次时,会修改之前班次的停战时间,所以导致之后的班次的停战都会发生变化
  759 + * @param groupIndex
  760 + * @param bcIndex
  761 + * @param factory
  762 + * @param paramObj
  763 + * @returns int 相差时间(吃饭时间距离和停站时间相差值)
  764 + */
  765 +InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, paramObj) {
  766 + var oPreBc;
  767 + var oEatBc;
  768 + var iBcModifyTime;
  769 +
  770 + if (!this.getBc(groupIndex, bcIndex)) { //
  771 + return 0;
  772 + }
  773 +
  774 + oPreBc = this.getBc( // 前一个邻接班次
  775 + bcIndex == 0 ? groupIndex - 1 : groupIndex,
  776 + bcIndex == 1 ? 0 : 1);
  777 + if (oPreBc) { // 存在前一个班次
  778 + oEatBc = factory.createBcObj(
  779 + this,
  780 + "cf",
  781 + !oPreBc.isUp(), // 和上一个班次方向相反
  782 + 1,
  783 + paramObj.addMinute(oPreBc.getArrTimeObj(), oPreBc.getStopTime()), // 使用上一个班次的到达时间作为开始时间
  784 + paramObj
  785 + );
  786 +
  787 + //iBcModifyTime = oEatBc.getBcTime() - oPreBc.getStopTime(); // 后续班次要调整的时间
  788 +
  789 + // 修正之后的班次发车时间
  790 + // 注意:之后那个班次发车时间就是吃饭班次的到达时间
  791 + iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m");
  792 + this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime);
  793 +
  794 + oPreBc.setStopTime(0); // 不重置停站时间
  795 + oPreBc.fnSetEatTime(oEatBc.getBcTime());
  796 +
  797 + //this._$_other_bc_array.push(oEatBc);
  798 +
  799 + return iBcModifyTime;
  800 + } else {
  801 + return false;
  802 + }
  803 +
  804 +};
  805 +
  806 +/**
  807 + * 调整路牌的班次,通过调整停站时间,或者班次发车时间,不能让班次的到达时间和下一个班次的发车时间重叠。
  808 + * @param iPeakAverStopTime 高峰平均停站时间
  809 + * @param iTroughAverStopTime 低谷平均停站时间
  810 + * @param oParam 参数对象
  811 + */
  812 +InternalLpObj.prototype.fnAdjustBcInterval = function(iPeakAverStopTime, iTroughAverStopTime, oParam) {
  813 + // 获取车次链个数
  814 + var iBcChainCount = this.fnGetBcChainCount();
  815 +
  816 + var i;
  817 + var j;
  818 + var oBcIndex;
  819 + var iQIndex;
  820 + var iBcIndex;
  821 + var iBcCount;
  822 + var oBc;
  823 + var oNextBc;
  824 +
  825 + var iBcStopTime;
  826 +
  827 + for (i = 0; i < iBcChainCount; i++) {
  828 + oBcIndex = this.fnGetBcChainInfo(i);
  829 + iQIndex = oBcIndex["s_q"];
  830 + iBcIndex = oBcIndex["s_b"];
  831 + iBcCount = oBcIndex["bcount"];
  832 +
  833 + for (j = 0; j < iBcCount - 1; j++) {
  834 + oBc = this.getBc(iQIndex, iBcIndex);
  835 + oNextBc = this.getBc(
  836 + iBcIndex == 0 ? iQIndex : iQIndex + 1,
  837 + iBcIndex == 0 ? 1 : 0);
  838 +
  839 + if (oNextBc.fnIsFirstBc()) { // 如果同一路牌连续2个方向首站班次,都不做处理
  840 + continue;
  841 + }
  842 +
  843 + // 不改变当前班次的行驶时间,修正停站时间和下一个班次的发车时间
  844 + iBcStopTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m");
  845 + if (iBcStopTime < 0) {
  846 + // 当前班次使用最小停站时间
  847 + oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp()));
  848 + oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime);
  849 +
  850 + } else {
  851 + if (iBcStopTime == oBc.getStopTime() + oBc.fnGetEatTime()) {
  852 + // 停站时间一致,没有问题
  853 +
  854 +
  855 + } else {
  856 + // TODO:当前班次使用最小停站时间
  857 + oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp()));
  858 + oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime);
  859 +
  860 + }
  861 + }
  862 +
  863 + iBcIndex = iBcIndex == 0 ? 1 : 0;
  864 + iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex;
  865 + }
  866 +
  867 + this.getBc(iQIndex, iBcIndex).setStopTime(0);
  868 + }
  869 +
  870 +
  871 +};
  872 +
  873 +/**
  874 + * 返回指定班次的上一个班次。
  875 + * @param oBc {moment} 指定班次
  876 + * @returns {object} 上一个班次,如果没有,返回false
  877 + */
  878 +InternalLpObj.prototype.getPreBc = function(oBc) {
  879 + // 获取车次链个数
  880 + var iBcChainCount = this.fnGetBcChainCount();
  881 +
  882 + var i;
  883 + var j;
  884 + var oBcIndex;
  885 + var iQIndex;
  886 + var iBcIndex;
  887 + var iBcCount;
  888 + var _oPreBc;
  889 + var _bFindCurrentBc = false;
  890 +
  891 + for (i = 0; i < iBcChainCount; i++) {
  892 + oBcIndex = this.fnGetBcChainInfo(i);
  893 + iQIndex = oBcIndex["s_q"];
  894 + iBcIndex = oBcIndex["s_b"];
  895 + iBcCount = oBcIndex["bcount"];
  896 +
  897 + for (j = 0; j < iBcCount - 1; j++) {
  898 + if (oBc.getFcTimeObj().format("HH:mm") ==
  899 + this.getBc(iQIndex, iBcIndex).getFcTimeObj().format("HH:mm")) {
  900 + _bFindCurrentBc = true;
  901 + break;
  902 + }
  903 +
  904 + // 进入到下一圈
  905 + iBcIndex = iBcIndex == 0 ? 1 : 0;
  906 + iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex;
  907 + }
  908 +
  909 + if (_bFindCurrentBc) {
  910 + if (iQIndex == oBcIndex["s_q"] && iBcIndex == oBcIndex["s_b"]) { // 第一个班次
  911 + break;
  912 + } else {
  913 + _oPreBc = this.getBc(
  914 + iBcIndex == 0 ? iQIndex - 1 : iQIndex,
  915 + iBcIndex == 0 ? 1 : 0);
  916 + }
  917 + }
  918 +
  919 + }
  920 +
  921 + return _oPreBc || false;
  922 +
  923 +};
  924 +
  925 +/**
  926 + * 通过修改layover时间,修正班次的发车,到达时间。
  927 + * 如果layover时间不符合范围要求,修改成平均时间。
  928 + * @param oParam {ParameterObj} 参数对象
  929 + */
  930 +InternalLpObj.prototype.fnAdjustBcTime_layover = function(oParam) {
  931 + // 获取车次链个数(连班路牌1个,分班路牌2个)
  932 + var iBlockCount = this.fnGetBcChainCount();
  933 +
  934 + var i;
  935 + var j;
  936 + var aTrip; // 每个block关联的trip列表
  937 + var trip; // 当前班次
  938 + var nextTrip; // 下一个班次
  939 + var layOverTime;
  940 + var aLayOverTimeRange;
  941 +
  942 + var oBcIndex;
  943 + var iQIndex; // block开始第几圈缩影
  944 + var iBcIndex; // block开始第几个班次
  945 + var iBcCount; // block的trip数目
  946 +
  947 +
  948 + for (i = 0; i < iBlockCount; i++) {
  949 + // 获取block关联的trip列表
  950 + oBcIndex = this.fnGetBcChainInfo(i);
  951 + iQIndex = oBcIndex["s_q"];
  952 + iBcIndex = oBcIndex["s_b"];
  953 + iBcCount = oBcIndex["bcount"];
  954 +
  955 + aTrip = [];
  956 + for (j = 0; j < iBcCount; j++) {
  957 + aTrip.push(this.getBc(iQIndex, iBcIndex));
  958 + iBcIndex = iBcIndex == 0 ? 1 : 0;
  959 + iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex;
  960 + }
  961 +
  962 + if (aTrip.length < 2) {
  963 + // 两个trip一起处理,只有1个trip的block不处理
  964 + continue;
  965 + }
  966 + // 迭代block,处理trip的发车,到达,停站时间
  967 + for (j = 0; j < aTrip.length - 1; j++) {
  968 + trip = aTrip[j];
  969 + nextTrip = aTrip[j + 1];
  970 +
  971 + if (trip.fnIsFirstBc() && nextTrip.fnIsFirstBc()) {
  972 + // 如果两个方向的首班车都在一个block上
  973 + // 则停站时间不考虑范围,直接发车时间-到达时间
  974 + layOverTime = nextTrip.getFcTimeObj().diff(trip.getArrTimeObj(), "m");
  975 + trip.setStopTime(layOverTime);
  976 + continue;
  977 + }
  978 +
  979 + //------------- 吃饭班次处理 -----------//
  980 + // 获取当前trip的layover的范围
  981 + aLayOverTimeRange = oParam.calcuTripLayoverTimeRange(
  982 + trip.getArrTimeObj(), trip.isUp(), trip.getBcTime()
  983 + );
  984 + // 重新计算当前班次layover时间
  985 + layOverTime = nextTrip.getFcTimeObj().diff(trip.getArrTimeObj(), "m");
  986 + if (trip.fnGetEatTime() > 0) {
  987 + // 如果当前班次layover是要吃饭的
  988 + // 则停站时间没有,变成吃饭时间
  989 + trip.setStopTime(0);
  990 + // 修改下一个班次的发车时间,到达时间
  991 + nextTrip.setFcTimeObj(oParam.addMinute(
  992 + trip.getArrTimeObj(),
  993 + trip.fnGetEatTime())
  994 + );
  995 + nextTrip.setBcTime(oParam.calcuTravelTime(nextTrip.getFcTimeObj(), nextTrip.isUp()));
  996 + nextTrip.setArrTimeObj(oParam.addMinute(nextTrip.getFcTimeObj(), nextTrip.getBcTime()));
  997 + continue;
  998 + }
  999 +
  1000 + //------------- 正常班次处理 -----------//
  1001 + if (layOverTime < aLayOverTimeRange[0] || layOverTime > aLayOverTimeRange[1]) {
  1002 + // 如果layover时间在范围之外,使用平均值
  1003 + layOverTime = oParam.fnCalcuFixedStopNumber(
  1004 + trip.getArrTimeObj(),
  1005 + trip.isUp(),
  1006 + oParam.calcuTravelTime(
  1007 + trip.getFcTimeObj(),
  1008 + trip.isUp())
  1009 + );
  1010 +
  1011 + trip.setStopTime(layOverTime);
  1012 + nextTrip.setFcTimeObj(oParam.addMinute(
  1013 + trip.getArrTimeObj(),
  1014 + trip.getStopTime())
  1015 + );
  1016 + nextTrip.setBcTime(oParam.calcuTravelTime(nextTrip.getFcTimeObj(), nextTrip.isUp()));
  1017 + nextTrip.setArrTimeObj(oParam.addMinute(nextTrip.getFcTimeObj(), nextTrip.getBcTime()));
  1018 + }
  1019 + }
  1020 + // 最后一个trip的layover时间为0
  1021 + aTrip[j].setStopTime(0);
  1022 +
  1023 + }
  1024 +};
  1025 +
  1026 +/**
  1027 + * 从指定区间时间范围内找出指定班次列表。
  1028 + * @param oFromTime 开始时间
  1029 + * @param oEndTime 结束时间
  1030 + * @param isUp 是否上行
  1031 + */
  1032 +InternalLpObj.prototype.fnFindBcWithTimeRange = function(oFromTime, oEndTime, isUp) {
  1033 + // oBc:班次对象,iGroupIndex:圈索引,iBcIndex:第几个班次
  1034 + var oBc;
  1035 + var oBcIndex = {oBc: null, iGroupIndex: 0, iBcIndex: 0};
  1036 + var aBc = [];
  1037 + var iFdiff = 0; // 距离开始时间的差值
  1038 + var iEdiff = 0; // 距离结束时间的差值
  1039 + for (var i = 0; i < this._$_qCount; i++) {
  1040 + for (var j = 0; j < 2; j++) {
  1041 + oBc = this.getBc(i, j);
  1042 + if (oBc) {
  1043 + iFdiff = oBc.getFcTimeObj().diff(oFromTime);
  1044 + iEdiff = oBc.getFcTimeObj().diff(oEndTime);
  1045 + if (iFdiff >= 0 && iEdiff <= 0 && oBc.isUp() == isUp) {
  1046 + oBcIndex = {oBc: oBc, iGroupIndex: i, iBcIndex: j};
  1047 + aBc.push(oBcIndex);
  1048 + }
  1049 + }
  1050 + }
  1051 + }
  1052 +
  1053 + return aBc;
  1054 +};
  1055 +
  1056 +/**
  1057 + * 清空班次。
  1058 + * @param fromQ 从第几圈开始(圈索引)
  1059 + * @param iBcIndex 班次索引
  1060 + */
  1061 +InternalLpObj.prototype.clearBc = function(fromQ, iBcIndex) {
  1062 + var i;
  1063 + var group;
  1064 +
  1065 + if (fromQ >= 0 && fromQ < this._$_qCount) {
  1066 + group = this._$_groupBcArray[fromQ];
  1067 +
  1068 + // 先清除第一圈
  1069 + if (iBcIndex == 1) {
  1070 + group.setBc2(undefined);
  1071 + } else if (iBcIndex == 0) {
  1072 + group.setBc1(undefined);
  1073 + group.setBc2(undefined);
  1074 + }
  1075 +
  1076 + // 清除后续圈的班次
  1077 + for (i = fromQ + 1; i < this._$_qCount; i++) {
  1078 + group = this._$_groupBcArray[i];
  1079 + group.setBc1(undefined);
  1080 + group.setBc2(undefined);
  1081 + }
  1082 + }
  1083 +};
  1084 +
  1085 +/**
  1086 + * 从指定方向,指定时间开始重新生成连续的班次。
  1087 + * @param startTime 开始时间
  1088 + * @param isUp 第一个班次是上行还是下行
  1089 + * @param fromQ 从第几圈开始加入
  1090 + * @param paramObj 参数对象
  1091 + * @param factory 工厂对象
  1092 + */
  1093 +InternalLpObj.prototype.initDataFromTime = function(
  1094 + startTime,
  1095 + isUp,
  1096 + fromQ,
  1097 + paramObj,
  1098 + factory) {
  1099 +
  1100 + var bcData = []; // 班次数组
  1101 + var bcObj;
  1102 + var kssj = startTime;
  1103 + var fcno = 1; // 发车顺序号
  1104 + var endTime = isUp ? paramObj.getUpLastDtimeObj() : paramObj.getDownLastDTimeObj(); // 结束时间
  1105 +
  1106 + while (!kssj.isAfter(endTime)) {
  1107 + bcObj = factory.createBcObj(
  1108 + this, "normal", isUp, fcno, kssj, paramObj); // this就是所属路牌对象
  1109 + bcData.push(bcObj);
  1110 +
  1111 + kssj = paramObj.addMinute(kssj, bcObj.getBcTime() + bcObj.getStopTime());
  1112 + fcno ++;
  1113 + isUp = !isUp;
  1114 + endTime = isUp ? paramObj.getUpLastDtimeObj() : paramObj.getDownLastDTimeObj(); // 结束时间
  1115 + }
  1116 +
  1117 + this._initDataFromLbBcArray(bcData, fromQ);
  1118 +
  1119 +};
  1120 +
  1121 +/**
  1122 + * 修正停站时间(不修改发车时间)。
  1123 + */
  1124 +InternalLpObj.prototype.modifyLayoverTimeWithoutFcTime = function() {
  1125 + var i;
  1126 + var aBc = this.getBcArray();
  1127 + var oBc;
  1128 + var oNextBc;
  1129 + var iDiff;
  1130 + for (i = 0; i < aBc.length; i++) {
  1131 + oBc = aBc[i];
  1132 + if (i == aBc.length - 1) { // 最后一个班次,停站0
  1133 + oBc.setStopTime(0);
  1134 + } else {
  1135 + oNextBc = aBc[i + 1];
  1136 + iDiff = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m");
  1137 + if (oNextBc.fnGetEatTime() > 0) {
  1138 + oBc.setStopTime(iDiff - oNextBc.fnGetEatTime());
  1139 + } else if (iDiff > 60) { // 大于60分钟,肯定车次链结束班次,停站0
  1140 + oBc.setStopTime(0);
  1141 + } else {
  1142 + oBc.setStopTime(iDiff);
  1143 + }
  1144 + }
  1145 + }
  1146 +};
  1147 +
  1148 +
  1149 +// TODO
  1150 +InternalLpObj.prototype.calcuLpBx = function() {
  1151 +
  1152 +};
  1153 +
... ...
src/main/resources/static/pages/base/timesmodel/js/v2/main_v2.js
1   -/**
2   - * 主类。
3   - */
4   -var Main_v2 = function() {
5   -
6   - // 内部工厂类
7   - var _factoryFun = function() {
8   - return {
9   - // 创建参数
10   - createParameterObj: function(formMap, dataMap) {
11   - var paramObj = ParameterObj();
12   - paramObj.wrap(formMap, dataMap);
13   - return paramObj;
14   - },
15   - // 创建班次对象
16   - createBcObj: function(lpObj, bcType, isUp, fcno, fcTimeObj, paramObj) {
17   - var _bclc = paramObj.calcuTravelLcNumber(isUp, bcType);
18   - var _fcsj = fcTimeObj;
19   - var _bcsj = paramObj.calcuTravelTime(_fcsj, isUp);
20   - var _arrsj = paramObj.addMinute(_fcsj, _bcsj);
21   - //var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj);
22   - var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, isUp, paramObj.calcuTravelTime(_fcsj, isUp));
23   - var _tccid = paramObj.getTTinfoId();
24   - var _ttinfoid = paramObj.getTTinfoId();
25   - var _xl = paramObj.getXlId();
26   - var _qdz = isUp ? paramObj.getUpQdzObj().id : paramObj.getDownQdzObj().id;
27   - var _zdz = isUp ? paramObj.getUpZdzObj().id : paramObj.getDownZdzObj().id;
28   -
29   - if (bcType == "bd") { // 早例保,传过来的发车时间是第一个班次的发车时间
30   - if (isUp) { // 上行
31   - _fcsj = paramObj.addMinute(
32   - _fcsj,
33   - -(paramObj.getUpOutTime() + paramObj.getLbTime()));
34   - _bcsj = paramObj.getLbTime();
35   - _arrsj = paramObj.addMinute(_fcsj, _bcsj);
36   - _stoptime = 0;
37   - } else { // 下行
38   - _fcsj = paramObj.addMinute(
39   - _fcsj,
40   - -(paramObj.getDownOutTime() + paramObj.getLbTime()));
41   - _bcsj = paramObj.getLbTime();
42   - _arrsj = paramObj.addMinute(_fcsj, _bcsj);
43   - _stoptime = 0;
44   - }
45   - } else if (bcType == "lc") { // 晚例保,传过来的发车时间是最后一个班次的到达时间
46   - if (isUp) { // 上行
47   - _fcsj = paramObj.addMinute(
48   - _fcsj,
49   - paramObj.getUpInTime());
50   - _bcsj = paramObj.getLbTime();
51   - _arrsj = paramObj.addMinute(_fcsj, _bcsj);
52   - _stoptime = 0;
53   - } else { // 下行
54   - _fcsj = paramObj.addMinute(
55   - _fcsj,
56   - paramObj.getDownInTime());
57   - _bcsj = paramObj.getLbTime();
58   - _arrsj = paramObj.addMinute(_fcsj, _bcsj);
59   - _stoptime = 0;
60   - }
61   - } else if (bcType == "out") { // 出场,传过来的发车时间是第一个班次的发车时间
62   - if (isUp) { // 上行
63   - _fcsj = paramObj.addMinute(
64   - _fcsj,
65   - -paramObj.getUpOutTime());
66   - _bcsj = paramObj.getUpOutTime();
67   - _arrsj = paramObj.addMinute(_fcsj, _bcsj);
68   - _stoptime = 0;
69   - } else { // 下行
70   - _fcsj = paramObj.addMinute(
71   - _fcsj,
72   - -paramObj.getDownOutTime());
73   - _bcsj = paramObj.getDownOutTime();
74   - _arrsj = paramObj.addMinute(_fcsj, _bcsj);
75   - _stoptime = 0;
76   - }
77   - } else if (bcType == "in") { // 进场,传过来的发车时间是最后一个班次的到达时间
78   - if (isUp) { // 上行
79   - _bcsj = paramObj.getUpInTime();
80   - _arrsj = paramObj.addMinute(_fcsj, _bcsj);
81   - _stoptime = 0;
82   - } else { // 下行
83   - _bcsj = paramObj.getDownInTime();
84   - _arrsj = paramObj.addMinute(_fcsj, _bcsj);
85   - _stoptime = 0;
86   - }
87   - } else if (bcType == "cf") { // 吃饭班次
88   - // 以13:00为分界,之前的为午饭,之后的为晚饭
89   - if (fcTimeObj.isBefore(paramObj.toTimeObj("13:00"))) {
90   - _bcsj = paramObj.fnGetLunchTime();
91   - } else {
92   - _bcsj = paramObj.fnGetDinnerTime();
93   - }
94   - _arrsj = paramObj.addMinute(_fcsj, _bcsj);
95   - _stoptime = 0;
96   - }
97   -
98   - var bcParamObj = {};
99   - bcParamObj.bcType = bcType; // 班次类型(normal,in_,out, bd, lc, cf等)
100   - bcParamObj.isUp = isUp; // boolean是否上下行
101   - bcParamObj.fcno = fcno; // 发车顺序号
102   - bcParamObj.fcTimeObj = _fcsj; // 发车时间对象
103   - bcParamObj.bclc = _bclc; // 班次里程
104   - bcParamObj.bcsj = _bcsj; // 班次历时
105   - bcParamObj.arrtime = _arrsj; // 到达时间对象
106   - bcParamObj.stoptime = _stoptime; // 停站时间
107   - bcParamObj.tccid = _tccid; // 停车场id
108   - bcParamObj.ttinfoid = _ttinfoid; // 时刻表id
109   - bcParamObj.xl = _xl; // 线路id
110   - bcParamObj.qdzid = _qdz; // 起点站id
111   - bcParamObj.zdzid = _zdz; // 终点站id
112   -
113   - return new InternalBcObj(lpObj, bcParamObj);
114   - }
115   - };
116   - };
117   - var _factory = _factoryFun();
118   -
119   - // 所有的时间使用moment.js计算
120   -
121   - var _paramObj; // 参数对象
122   -
123   - var _bxDesc = [ // 班型描述
124   - {'type':'六工一休','hoursV':6.66, 'minueV':'6:40', 'qcount': 0, 'avertime': 0},
125   - {'type':'五工一休','hoursV':6.85, 'minueV':'6:51', 'qcount': 0, 'avertime': 0},
126   - {'type':'四工一休','hoursV':7.14, 'minueV':'7:08', 'qcount': 0, 'avertime': 0},
127   - {'type':'三工一休','hoursV':7.61, 'minueV':'7:37', 'qcount': 0, 'avertime': 0},
128   - {'type':'二工一休','hoursV':8.57, 'minueV':'8:34', 'qcount': 0, 'avertime': 0},
129   - {'type':'一工一休','hoursV':11.42, 'minueV':'11:25', 'qcount': 0, 'avertime': 0},
130   - {'type':'五工二休','hoursV':7.99, 'minueV':'8:00', 'qcount': 0, 'avertime': 0},
131   - {'type':'无工休', 'hoursV':5.43, 'minueV':'5:43', 'qcount': 0, 'avertime': 0}
132   - ];
133   -
134   - var _funCalcuExportData_lpObjList = function(aInternalLpObj) {
135   - // 构造路牌对象
136   - var aLpObj = [];
137   - var i;
138   - var j;
139   - var z;
140   - var oInternalLp;
141   - var oInternalBc;
142   - var oInternalBc_temp;
143   - var oLp;
144   - var iZlc;
145   - var iYylc;
146   - var iKslc;
147   - var iZbc;
148   - var iZgs;
149   - var iYygs;
150   - var iYybc;
151   - for (i = 0; i < aInternalLpObj.length; i++) {
152   - oInternalLp = aInternalLpObj[i];
153   - iZlc = 0;
154   - iYylc = 0;
155   - iKslc = 0;
156   - iZgs = 0;
157   - iZbc = 0;
158   - iYygs = 0;
159   - iYybc = 0;
160   - oLp = {
161   - "lpname": oInternalLp.getLpName(), // 路牌名字
162   - "isUp": oInternalLp.isUp(), // 每圈的第一个班次是否上行
163   - "bcObjList": [], // 班次列表
164   - "groupCount": oInternalLp.fnGetGroupCount(), // 总圈数
165   - "zlc": 0, // 总里程
166   - "yylc": 0, // 营运里程
167   - "kslc": 0, // 空驶里程
168   - "zgs": 0, // 总工时
169   - "zbc": 0, // 总班次
170   - "yygs": 0, // 营运工时
171   - "yybc": 0, // 营运班次
172   - "stationRouteId1": 0, // 第一个班次起点站路由id
173   - "stationRouteId2": 0 // 第二个班次起点站路由id
174   - };
175   -
176   - // 将报到班次,进出场班次加到班次的时间上
177   - var iBcChainCount;
178   - var oStartBc;
179   - var oEndBc;
180   - var oTempBc;
181   - var aFcsj = [];
182   -
183   - iBcChainCount = oInternalLp.fnGetBcChainCount();
184   - if (iBcChainCount == 1) { // 单一车次链,连班班型
185   - oStartBc = oInternalLp.getBc(
186   - oInternalLp.fnGetBcChainInfo(0)["s_q"],
187   - oInternalLp.fnGetBcChainInfo(0)["s_b"]
188   - );
189   - oTempBc = _factory.createBcObj(
190   - oLp, "bd", oStartBc.isUp(), 1,
191   - oStartBc.getFcTimeObj(),
192   - _paramObj
193   - );
194   - aFcsj.push("(到" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
195   - oLp.bcObjList.push({ // 报到班次
196   - "bcsj": oTempBc.getBcTime(), // 班次时间
197   - "ssj": oTempBc.getStopTime(), // 停站时间
198   - "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
199   -
200   - "tccid": oTempBc._$_tccid, // 停车场id
201   - "qdzid": oTempBc._$_qdzid, // 起点站id
202   - "zdzid": oTempBc._$_zdzid, // 终点站id
203   -
204   - "isUp": oTempBc._$_isUp, // 是否上行
205   - "isFb": false, // 是否分班
206   -
207   - "bcType": oTempBc._$_bcType, // 班次类型
208   - "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
209   -
210   - "groupNo": -1, // 第几圈
211   - "groupBcNo": -1 // 圈里第几个班次
212   -
213   - });
214   -
215   - oTempBc = _factory.createBcObj(
216   - oLp, "out", oStartBc.isUp(), 1,
217   - oStartBc.getFcTimeObj(),
218   - _paramObj
219   - );
220   - aFcsj.push("(出" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
221   - aFcsj.push("(" + oStartBc.getFcTimeObj().format("HH:mm") + ")");
222   - oStartBc._$_fcsj_desc = aFcsj.join("");
223   -
224   - oLp.bcObjList.push({ // 出场班次
225   - "bcsj": oTempBc.getBcTime(), // 班次时间
226   - "ssj": oTempBc.getStopTime(), // 停站时间
227   - "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
228   -
229   - "tccid": oTempBc._$_tccid, // 停车场id
230   - "qdzid": oTempBc._$_qdzid, // 起点站id
231   - "zdzid": oTempBc._$_zdzid, // 终点站id
232   -
233   - "isUp": oTempBc._$_isUp, // 是否上行
234   - "isFb": false, // 是否分班
235   -
236   - "bcType": oTempBc._$_bcType, // 班次类型
237   - "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
238   -
239   - "groupNo": -1, // 第几圈
240   - "groupBcNo": -2 // 圈里第几个班次
241   -
242   - });
243   -
244   - aFcsj = [];
245   -
246   - oEndBc = oInternalLp.getBc(
247   - oInternalLp.fnGetBcChainInfo(0)["e_q"],
248   - oInternalLp.fnGetBcChainInfo(0)["e_b"]
249   - );
250   - aFcsj.push("(" + oEndBc.getFcTimeObj().format("HH:mm") + ")");
251   - oTempBc = _factory.createBcObj(
252   - oLp, "in", !oEndBc.isUp(), 1,
253   - oEndBc.getArrTimeObj(),
254   - _paramObj
255   - );
256   - aFcsj.push("(进" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
257   -
258   - oLp.bcObjList.push({ // 进场班次
259   - "bcsj": oTempBc.getBcTime(), // 班次时间
260   - "ssj": oTempBc.getStopTime(), // 停站时间
261   - "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
262   -
263   - "tccid": oTempBc._$_tccid, // 停车场id
264   - "qdzid": oTempBc._$_qdzid, // 起点站id
265   - "zdzid": oTempBc._$_zdzid, // 终点站id
266   -
267   - "isUp": oTempBc._$_isUp, // 是否上行
268   - "isFb": false, // 是否分班
269   -
270   - "bcType": oTempBc._$_bcType, // 班次类型
271   - "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
272   -
273   - "groupNo": oInternalLp.fnGetBcChainInfo(0)["e_b"] == 0 ?
274   - oInternalLp.fnGetBcChainInfo(0)["e_q"] :
275   - oInternalLp.fnGetBcChainInfo(0)["e_q"] + 1, // 第几圈
276   - "groupBcNo": oInternalLp.fnGetBcChainInfo(0)["e_b"] == 0 ? 1 : 0 // 圈里第几个班次
277   -
278   - });
279   -
280   - oTempBc = _factory.createBcObj(
281   - oLp, "lc", !oEndBc.isUp(), 1,
282   - oEndBc.getArrTimeObj(),
283   - _paramObj
284   - );
285   - aFcsj.push("(离" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
286   - oLp.bcObjList.push({ // 离场班次
287   - "bcsj": oTempBc.getBcTime(), // 班次时间
288   - "ssj": oTempBc.getStopTime(), // 停站时间
289   - "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
290   -
291   - "tccid": oTempBc._$_tccid, // 停车场id
292   - "qdzid": oTempBc._$_qdzid, // 起点站id
293   - "zdzid": oTempBc._$_zdzid, // 终点站id
294   -
295   - "isUp": oTempBc._$_isUp, // 是否上行
296   - "isFb": false, // 是否分班
297   -
298   - "bcType": oTempBc._$_bcType, // 班次类型
299   - "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
300   -
301   - "groupNo": -2, // 第几圈
302   - "groupBcNo": -4 // 圈里第几个班次
303   -
304   - });
305   -
306   - oEndBc._$_fcsj_desc = aFcsj.join("");
307   -
308   - } else if (iBcChainCount == 2) { // 两个车次链,分班班型
309   - oStartBc = oInternalLp.getBc(
310   - oInternalLp.fnGetBcChainInfo(0)["s_q"],
311   - oInternalLp.fnGetBcChainInfo(0)["s_b"]
312   - );
313   - oTempBc = _factory.createBcObj(
314   - oLp, "bd", oStartBc.isUp(), 1,
315   - oStartBc.getFcTimeObj(),
316   - _paramObj
317   - );
318   - aFcsj.push("(到" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
319   - oLp.bcObjList.push({ // 报到班次
320   - "bcsj": oTempBc.getBcTime(), // 班次时间
321   - "ssj": oTempBc.getStopTime(), // 停站时间
322   - "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
323   -
324   - "tccid": oTempBc._$_tccid, // 停车场id
325   - "qdzid": oTempBc._$_qdzid, // 起点站id
326   - "zdzid": oTempBc._$_zdzid, // 终点站id
327   -
328   - "isUp": oTempBc._$_isUp, // 是否上行
329   - "isFb": false, // 是否分班
330   -
331   - "bcType": oTempBc._$_bcType, // 班次类型
332   - "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
333   -
334   - "groupNo": -1, // 第几圈
335   - "groupBcNo": -1 // 圈里第几个班次
336   -
337   - });
338   -
339   - oTempBc = _factory.createBcObj(
340   - oLp, "out", oStartBc.isUp(), 1,
341   - oStartBc.getFcTimeObj(),
342   - _paramObj
343   - );
344   - aFcsj.push("(出" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
345   - aFcsj.push("(" + oStartBc.getFcTimeObj().format("HH:mm") + ")");
346   - oStartBc._$_fcsj_desc = aFcsj.join("");
347   -
348   - oLp.bcObjList.push({ // 出场班次
349   - "bcsj": oTempBc.getBcTime(), // 班次时间
350   - "ssj": oTempBc.getStopTime(), // 停站时间
351   - "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
352   -
353   - "tccid": oTempBc._$_tccid, // 停车场id
354   - "qdzid": oTempBc._$_qdzid, // 起点站id
355   - "zdzid": oTempBc._$_zdzid, // 终点站id
356   -
357   - "isUp": oTempBc._$_isUp, // 是否上行
358   - "isFb": false, // 是否分班
359   -
360   - "bcType": oTempBc._$_bcType, // 班次类型
361   - "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
362   -
363   - "groupNo": -1, // 第几圈
364   - "groupBcNo": -2 // 圈里第几个班次
365   -
366   - });
367   -
368   - aFcsj = [];
369   -
370   - oEndBc = oInternalLp.getBc(
371   - oInternalLp.fnGetBcChainInfo(0)["e_q"],
372   - oInternalLp.fnGetBcChainInfo(0)["e_b"]
373   - );
374   - aFcsj.push("(" + oEndBc.getFcTimeObj().format("HH:mm") + ")");
375   - oTempBc = _factory.createBcObj(
376   - oLp, "in", !oEndBc.isUp(), 1,
377   - oEndBc.getArrTimeObj(),
378   - _paramObj
379   - );
380   - aFcsj.push("(进" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
381   - oLp.bcObjList.push({ // 进场班次
382   - "bcsj": oTempBc.getBcTime(), // 班次时间
383   - "ssj": oTempBc.getStopTime(), // 停站时间
384   - "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
385   -
386   - "tccid": oTempBc._$_tccid, // 停车场id
387   - "qdzid": oTempBc._$_qdzid, // 起点站id
388   - "zdzid": oTempBc._$_zdzid, // 终点站id
389   -
390   - "isUp": oTempBc._$_isUp, // 是否上行
391   - "isFb": true, // 是否分班
392   -
393   - "bcType": oTempBc._$_bcType, // 班次类型
394   - "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
395   -
396   - "groupNo": oInternalLp.fnGetBcChainInfo(0)["e_b"] == 0 ?
397   - oInternalLp.fnGetBcChainInfo(0)["e_q"] :
398   - oInternalLp.fnGetBcChainInfo(0)["e_q"] + 1, // 第几圈
399   - "groupBcNo": oInternalLp.fnGetBcChainInfo(0)["e_b"] == 0 ? 1 : 0 // 圈里第几个班次
400   -
401   - });
402   - oEndBc._$_fcsj_desc = aFcsj.join("");
403   -
404   - aFcsj = [];
405   -
406   - oStartBc = oInternalLp.getBc(
407   - oInternalLp.fnGetBcChainInfo(1)["s_q"],
408   - oInternalLp.fnGetBcChainInfo(1)["s_b"]
409   - );
410   - oTempBc = _factory.createBcObj(
411   - oLp, "bd", oStartBc.isUp(), 1,
412   - oStartBc.getFcTimeObj(),
413   - _paramObj
414   - );
415   - aFcsj.push("(到" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
416   - oLp.bcObjList.push({ // 报到班次
417   - "bcsj": oTempBc.getBcTime(), // 班次时间
418   - "ssj": oTempBc.getStopTime(), // 停站时间
419   - "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
420   -
421   - "tccid": oTempBc._$_tccid, // 停车场id
422   - "qdzid": oTempBc._$_qdzid, // 起点站id
423   - "zdzid": oTempBc._$_zdzid, // 终点站id
424   -
425   - "isUp": oTempBc._$_isUp, // 是否上行
426   - "isFb": true, // 是否分班
427   -
428   - "bcType": oTempBc._$_bcType, // 班次类型
429   - "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
430   -
431   - "groupNo": oInternalLp.fnGetBcChainInfo(1)["s_q"] - 1, // 第几圈
432   - "groupBcNo": oInternalLp.fnGetBcChainInfo(1)["s_b"] // 圈里第几个班次
433   -
434   - });
435   -
436   - oTempBc = _factory.createBcObj(
437   - oLp, "out", oStartBc.isUp(), 1,
438   - oStartBc.getFcTimeObj(),
439   - _paramObj
440   - );
441   - oLp.bcObjList.push({ // 出场班次
442   - "bcsj": oTempBc.getBcTime(), // 班次时间
443   - "ssj": oTempBc.getStopTime(), // 停站时间
444   - "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
445   -
446   - "tccid": oTempBc._$_tccid, // 停车场id
447   - "qdzid": oTempBc._$_qdzid, // 起点站id
448   - "zdzid": oTempBc._$_zdzid, // 终点站id
449   -
450   - "isUp": oTempBc._$_isUp, // 是否上行
451   - "isFb": true, // 是否分班
452   -
453   - "bcType": oTempBc._$_bcType, // 班次类型
454   - "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
455   -
456   - "groupNo": oInternalLp.fnGetBcChainInfo(1)["s_b"] == 0 ?
457   - oInternalLp.fnGetBcChainInfo(1)["s_q"] - 1 :
458   - oInternalLp.fnGetBcChainInfo(1)["s_q"], // 第几圈
459   - "groupBcNo": oInternalLp.fnGetBcChainInfo(1)["s_b"] == 0 ? 1 : 0 // 圈里第几个班次
460   -
461   - });
462   - aFcsj.push("(出" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
463   - aFcsj.push("(" + oStartBc.getFcTimeObj().format("HH:mm") + ")");
464   - oStartBc._$_fcsj_desc = aFcsj.join("");
465   -
466   - aFcsj = [];
467   -
468   - oEndBc = oInternalLp.getBc(
469   - oInternalLp.fnGetBcChainInfo(1)["e_q"],
470   - oInternalLp.fnGetBcChainInfo(1)["e_b"]
471   - );
472   - aFcsj.push("(" + oEndBc.getFcTimeObj().format("HH:mm") + ")");
473   - oTempBc = _factory.createBcObj(
474   - oLp, "in", !oEndBc.isUp(), 1,
475   - oEndBc.getArrTimeObj(),
476   - _paramObj
477   - );
478   - aFcsj.push("(进" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
479   -
480   - oLp.bcObjList.push({ // 进场班次
481   - "bcsj": oTempBc.getBcTime(), // 班次时间
482   - "ssj": oTempBc.getStopTime(), // 停站时间
483   - "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
484   -
485   - "tccid": oTempBc._$_tccid, // 停车场id
486   - "qdzid": oTempBc._$_qdzid, // 起点站id
487   - "zdzid": oTempBc._$_zdzid, // 终点站id
488   -
489   - "isUp": oTempBc._$_isUp, // 是否上行
490   - "isFb": false, // 是否分班
491   -
492   - "bcType": oTempBc._$_bcType, // 班次类型
493   - "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
494   -
495   - "groupNo": oInternalLp.fnGetBcChainInfo(1)["e_b"] == 0 ?
496   - oInternalLp.fnGetBcChainInfo(1)["e_q"] :
497   - oInternalLp.fnGetBcChainInfo(1)["e_q"] + 1, // 第几圈
498   - "groupBcNo": oInternalLp.fnGetBcChainInfo(1)["e_b"] == 0 ? 1 : 0 // 圈里第几个班次
499   -
500   - });
501   -
502   - oTempBc = _factory.createBcObj(
503   - oLp, "lc", !oEndBc.isUp(), 1,
504   - oEndBc.getArrTimeObj(),
505   - _paramObj
506   - );
507   -
508   - oLp.bcObjList.push({ // 离场班次
509   - "bcsj": oTempBc.getBcTime(), // 班次时间
510   - "ssj": oTempBc.getStopTime(), // 停站时间
511   - "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
512   -
513   - "tccid": oTempBc._$_tccid, // 停车场id
514   - "qdzid": oTempBc._$_qdzid, // 起点站id
515   - "zdzid": oTempBc._$_zdzid, // 终点站id
516   -
517   - "isUp": oTempBc._$_isUp, // 是否上行
518   - "isFb": false, // 是否分班
519   -
520   - "bcType": oTempBc._$_bcType, // 班次类型
521   - "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
522   -
523   - "groupNo": -2, // 第几圈
524   - "groupBcNo": -4 // 圈里第几个班次
525   -
526   - });
527   -
528   - aFcsj.push("(离" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
529   - oEndBc._$_fcsj_desc = aFcsj.join("");
530   -
531   - }
532   -
533   - for (j = 0; j < oInternalLp.fnGetGroupCount(); j++) {
534   - for (z = 0; z < 2; z++) {
535   - oInternalBc = oInternalLp.getBc(j, z);
536   - if (oInternalBc) {
537   - if (oInternalBc.fnGetEatTime() > 0) {
538   - // 吃饭班次是下一个班次开始吃,和本班次方向相反
539   - oInternalBc_temp = oInternalLp.getBc(
540   - z == 1 ? j + 1 : j,
541   - z == 1 ? 0 : 1);
542   -
543   - oInternalBc_temp._$_isRealEat = true;
544   - oInternalBc_temp._$_fcsj_desc = "(吃" + oInternalBc_temp.getFcTimeObj().format("HH:mm") + ")";
545   - }
546   -
547   - oLp.bcObjList.push({
548   - "bcsj": oInternalBc.getBcTime(), // 班次时间
549   - "ssj": oInternalBc.getStopTime(), // 停站时间
550   - "eatsj": oInternalBc.fnGetEatTime(), // 吃饭时间
551   -
552   - "tccid": oInternalBc._$_tccid, // 停车场id
553   - "qdzid": oInternalBc._$_qdzid, // 起点站id
554   - "zdzid": oInternalBc._$_zdzid, // 终点站id
555   -
556   - "isUp": oInternalBc._$_isUp, // 是否上行
557   -
558   - "bcType": oInternalBc._$_bcType, // 班次类型
559   - "fcsj": oInternalBc._$_isRealEat ?
560   - ("*" + oInternalBc._$_fcsjObj.format("HH:mm")) :
561   - oInternalBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
562   - "fcsjDesc" : oInternalBc._$_fcsj_desc || oInternalBc._$_fcsjObj.format("HH:mm"),
563   -
564   - "groupNo": j, // 第几圈
565   - "groupBcNo": z // 圈里第几个班次
566   -
567   - });
568   -
569   - // iZlc = 0;
570   - // iYylc = 0;
571   - // iKslc = 0;
572   - // iZgs = 0;
573   - // iZbc = 0;
574   - // iYygs = 0;
575   - // iYybc = 0;
576   -
577   - iZlc = iZlc +
578   - oInternalBc._$_bclc; // 里程
579   - iYylc = iYylc +
580   - oInternalBc._$_bclc; // 里程
581   - iYygs = iYygs +
582   - oInternalBc.getBcTime() + // 班次时间
583   - oInternalBc.getStopTime() + // 停站时间
584   - oInternalBc.fnGetEatTime(); // 吃饭时间
585   - iYybc = iYybc + 1;
586   -
587   - iZgs = iZgs +
588   - oInternalBc.getBcTime() + // 班次时间
589   - oInternalBc.getStopTime() + // 停站时间
590   - oInternalBc.fnGetEatTime(); // 吃饭时间
591   - iZbc = iZbc + 1;
592   -
593   - // 设置圈站点路由id
594   - if (oInternalBc.isUp() == oInternalLp.isUp()) { // 第一个班次
595   - if (oLp.stationRouteId1 == 0) {
596   - oLp.stationRouteId1 = oInternalBc._$_qdzid;
597   - }
598   - } else { // 第二个班次
599   - if (oLp.stationRouteId2 == 0) {
600   - oLp.stationRouteId2 = oInternalBc._$_qdzid;
601   - }
602   - }
603   -
604   - }
605   - }
606   -
607   - }
608   -
609   - for (z = 0; z < oInternalLp.getOtherBcArray().length; z++) {
610   - oInternalBc = oInternalLp.getOtherBcArray()[z];
611   - iKslc = iKslc +
612   - oInternalBc._$_bclc; // 里程
613   - iZlc = iZlc +
614   - oInternalBc._$_bclc; // 里程
615   - iZgs = iZgs +
616   - oInternalBc.getBcTime() + // 班次时间
617   - oInternalBc.getStopTime(); // 停站时间
618   - if (oInternalBc._$_bcType != "bd" &&
619   - oInternalBc._$_bcType != "lc" &&
620   - oInternalBc._$_bcType != "cf") {
621   - iZbc = iZbc + 1;
622   - }
623   - }
624   -
625   - oLp.zlc = iZlc;
626   - oLp.yylc = iYylc;
627   - oLp.kslc = iKslc;
628   - oLp.zgs = iZgs;
629   - oLp.zbc = iZbc;
630   - oLp.yygs = iYygs;
631   - oLp.yybc = iYybc;
632   - aLpObj.push(oLp);
633   - }
634   -
635   - return aLpObj;
636   - };
637   -
638   - var _funCalcuExportData_statInfoList = function(aInternalLpObj) {
639   - var countBc = 0, // 总班次
640   - serviceBc = 0, // 营运班次
641   - jcbc = 0, // 进场总班次.
642   - ccbc = 0, // 出场总班次.
643   - cfbc = 0, // 吃饭总班次.
644   - zwlbbc = 0, // 早晚例保总班次.
645   - countGs = 0.0, // 总工时
646   - servicesj = 0, // 营运班次总时间
647   - jcsj = 0.0, // 进场总时间.
648   - ccsj = 0.0, // 出场总时间.
649   - cfsj = 0.0, // 吃饭总时间.
650   - zwlbsj = 0.0, // 早晚例保总时间.
651   - ksBc = 0, // 空驶班次
652   - serviceLc = 0.0, // 营运里程
653   - ksLc = 0.0, // 空驶里程
654   - avgTzjx = 0.0, // 平均停站间隙
655   - gfServiceBc = 0, // 高峰营运班次
656   - dgServiceBc = 0, // 低谷营运班次
657   - gfAvgTzjx = 0.0, // 高峰平均停站间隙
658   - dgAvgTzjx = 0.0; // 低谷平均停站间隙
659   -
660   - var aAllBc = [];
661   - var oLp;
662   - var oBc;
663   - var i;
664   - var j;
665   -
666   - for (i = 0; i < aInternalLpObj.length; i++) {
667   - oLp = aInternalLpObj[i];
668   - for (j = 0; j < oLp.getBcArray().length; j++) {
669   - aAllBc.push(oLp.getBcArray()[j]);
670   - }
671   - for (j = 0; j < oLp.getOtherBcArray().length; j++) {
672   - aAllBc.push(oLp.getOtherBcArray()[j]);
673   - }
674   - }
675   -
676   - for (i = 0; i < aAllBc.length; i++) {
677   - oBc = aAllBc[i];
678   -
679   - if (oBc.getBcTime() > 0) {
680   - countBc = countBc + 1;
681   - countGs = countGs + oBc.getStopTime() + oBc.getBcTime();
682   - if (_paramObj.isTroughBc(oBc.getFcTimeObj())) {
683   - if (oBc._$_bcType == "normal") {
684   - dgServiceBc = dgServiceBc + 1;
685   - dgAvgTzjx = dgAvgTzjx + oBc.getStopTime();
686   - }
687   - } else {
688   - if (oBc._$_bcType == "normal") {
689   - gfServiceBc = gfServiceBc + 1;
690   - gfAvgTzjx = gfAvgTzjx + oBc.getStopTime();
691   - }
692   - }
693   -
694   - if (oBc._$_bcType == "normal") {
695   - serviceBc = serviceBc + 1;
696   - serviceLc = serviceLc + oBc._$_bclc;
697   - servicesj = servicesj + oBc.getBcTime();
698   - avgTzjx = avgTzjx + oBc.getStopTime();
699   -
700   - if (oBc.fnGetEatTime() > 0) {
701   - cfbc = cfbc + 1;
702   - cfsj = cfsj + oBc.fnGetEatTime();
703   - }
704   - } else if (oBc._$_bcType == "in") {
705   - jcbc = jcbc + 1;
706   - jcsj = jcsj + oBc.getBcTime();
707   - } else if (oBc._$_bcType == "out") {
708   - ccbc = ccbc + 1;
709   - ccsj = ccsj + oBc.getBcTime();
710   - } else if (oBc._$_bcType == "bd") {
711   - zwlbbc = zwlbbc + 1;
712   - zwlbsj = zwlbsj + oBc.getBcTime();
713   - } else if (oBc._$_bcType == "lc") {
714   - zwlbbc = zwlbbc + 1;
715   - zwlbsj = zwlbsj + oBc.getBcTime();
716   - }
717   - }
718   - }
719   -
720   - dgAvgTzjx = dgAvgTzjx / dgServiceBc;
721   - gfAvgTzjx = gfAvgTzjx / gfServiceBc;
722   - avgTzjx = avgTzjx / dgServiceBc;
723   -
724   - return [
725   - {'statItem': '总班次(包括进出场、吃饭时间、早晚例保、营运且班次时间大于零的班次)', 'statValue': countBc},
726   - {'statItem': '进场总班次(包括进场且班次时间大于零的班次)', 'statValue': jcbc},
727   - {'statItem': '出场总班次(包括进场且班次时间大于零的班次)', 'statValue': ccbc},
728   - {'statItem': '吃饭总班次(包括吃饭且班次时间大于零的班次)', 'statValue': cfbc},
729   - {'statItem': '早晚例保总班次(包括早晚例保且时间大于零的班次)', 'statValue': zwlbbc},
730   - {'statItem': '营运总班次(包括正常、区间、放大站且班次时间大于零班次)','statValue': serviceBc},
731   - {'statItem': '进场总时间(包括进场班次且班次时间大于零)', 'statValue': jcsj/60},
732   - {'statItem': '出场总时间(包括进场班次且班次时间大于零)', 'statValue': ccsj/60},
733   - {'statItem': '吃饭总时间(包括吃饭班次且班次时间大于零)', 'statValue': cfsj/60},
734   - {'statItem': '早晚例保总时间(包括早晚例保班次且时间大于零的)', 'statValue': zwlbsj/60},
735   - {'statItem': '营运班次总时间(包括正常、区间、放大站且班次时间大于零)', 'statValue': servicesj/60},
736   - {'statItem': '总工时(包括进出场、吃饭时间、早晚例保、营运班次时间)', 'statValue': countGs/60},
737   - {'statItem': '空驶班次(包括直放班次)', 'statValue': ksBc},
738   - {'statItem': '营运里程(包括正常、区间、放大站里程)', 'statValue': serviceLc},
739   - {'statItem': '空驶里程(包括直放里程)', 'statValue': ksLc},
740   - {'statItem': '平均停站时间(营运班次停站时间总和/营运总班次)', 'statValue': avgTzjx},
741   - {'statItem': '高峰营运班次(包括早晚高峰时段的正常、区间、放大站班次)', 'statValue': gfServiceBc},
742   - {'statItem': '低谷营运班次(包括低谷时段的正常、区间、放大站班次)', 'statValue': dgServiceBc},
743   - {'statItem': '高峰平均停站间隙(高峰营运班次停站时间总和/高峰营运班次总和)', 'statValue': gfAvgTzjx},
744   - {'statItem': '低谷平均停站间隙(低谷营运班次停站时间总和/低谷营运班次总和)', 'statValue': dgAvgTzjx},
745   - {'statItem': '综合评估', 'statValue': 3}
746   - ];
747   -
748   - };
749   -
750   - var __funCalcuExportData_paramInfoList = function() {
751   - return [
752   - {'paramItem' : '上行首班时间', 'paramValue' : _paramObj.getUpFirstDTimeObj().format("HH:mm")},
753   - {'paramItem' : '上行末班时间', 'paramValue' : _paramObj.getUpLastDtimeObj().format("HH:mm")},
754   - {'paramItem' : '下行首班时间', 'paramValue' : _paramObj.getDownFirstDTimeObj().format("HH:mm")},
755   - {'paramItem' : '下行末班时间', 'paramValue' : _paramObj.getDownLastDTimeObj().format("HH:mm")},
756   - {'paramItem' : '早高峰开始时间', 'paramValue' : _paramObj.getMPeakStartTimeObj().format("HH:mm")},
757   - {'paramItem' : '早高峰结束时间', 'paramValue' : _paramObj.getMPeakEndTimeObj().format("HH:mm")},
758   - {'paramItem' : '晚高峰开始时间', 'paramValue' : _paramObj.getEPeakStartTimeObj().format("HH:mm")},
759   - {'paramItem' : '晚高峰结束时间', 'paramValue' : _paramObj.getEPeakEndTimeObj().format("HH:mm")},
760   - {'paramItem' : '上行进场时间', 'paramValue' : _paramObj.getUpInTime()},
761   - {'paramItem' : '上行出场时间', 'paramValue' : _paramObj.getUpOutTime()},
762   - {'paramItem' : '下行进场时间', 'paramValue' : _paramObj.getDownInTime()},
763   - {'paramItem' : '下行出场时间', 'paramValue' : _paramObj.getDownOutTime()},
764   - {'paramItem' : '早高峰上行时间', 'paramValue' : _paramObj.getUpMPeakTime()},
765   - {'paramItem' : '早高峰下行时间', 'paramValue' : _paramObj.getDownMPeakTime()},
766   - {'paramItem' : '晚高峰上行时间', 'paramValue' : _paramObj.getUpEPeakTime()},
767   - {'paramItem' : '晚高峰下行时间', 'paramValue' : _paramObj.getDownEPeakTime()},
768   - {'paramItem' : '低谷上行时间', 'paramValue' : _paramObj.getUpTroughTime()},
769   - {'paramItem' : '低谷下行时间', 'paramValue' : _paramObj.getDownTroughTime()},
770   - {'paramItem' : '线路规划类型', 'paramValue' : "双向"},
771   - {'paramItem' : '吃饭地点', 'paramValue' : _paramObj.fnIsEat() ? (_paramObj.fnIsBothEat() ? "上下行" : (_paramObj.fnIsUpEat() ? "上行" : "下行")) : "不吃饭"},
772   - {'paramItem' : '早晚例行保养', 'paramValue' : _paramObj.getLbTime()},
773   - {'paramItem' : '停车场', 'paramValue' : _paramObj.getTccId()},
774   - {'paramItem' : '工作餐午餐时间', 'paramValue' : _paramObj.fnGetLunchTime()},
775   - {'paramItem' : '工作餐晚餐时间', 'paramValue' : _paramObj.fnGetDinnerTime()},
776   - {'paramItem' : '早高峰发车间隔', 'paramValue' : "[" + _paramObj.getMPeakMinFcjx() + "," + _paramObj.getMPeakMaxFcjx() + "]"},
777   - {'paramItem' : '晚高峰发车间隔', 'paramValue' : "[" + _paramObj.getEPeakMinFcjx() + "," + _paramObj.getEPeakMaxFcjx() + "]"},
778   - {'paramItem' : '低谷发车间隔', 'paramValue' : "[" + _paramObj.getTroughMinFcjx() + "," + _paramObj.getTroughMaxFcjx() + "]"},
779   - {'paramItem' : '建议加班路牌数', 'paramValue' : _paramObj.getJBLpes()},
780   - {'paramItem' : '停站类型', 'paramValue' : _paramObj.isTwoWayStop() ? "双向停站" : (_paramObj.isUpOneWayStop() ? "上行主站" : "下行主站") },
781   - {'paramItem' : '建议高峰配车数', 'paramValue' : _paramObj.getAdvicePeakClzs()}
782   - ]
783   - };
784   -
785   - return {
786   - /**
787   - * 工厂对象,创建不同的对象。
788   - * @returns {{createParameterObj, createBcObj}}
789   - */
790   - getFactory: function() {
791   - return _factory;
792   - },
793   -
794   - /**
795   - * 使用发车间隔策略生成时刻表。
796   - * @param paramObj 参数对象
797   - * @param lpArray 路牌数组
798   - * @constructor
799   - */
800   - BXPplaceClassesTime03 : function(paramObj, lpArray) {
801   - // 参数对象
802   - _paramObj = paramObj;
803   -
804   - // 1、初始化行车计划
805   - var schedule = new InternalScheduleObj(_paramObj, lpArray, _factory);
806   - schedule.fnInitDataWithBxLayout();
807   - // 2、将连班路牌的班次补足
808   - schedule.fnCalcuLpBx_lb();
809   -
810   - // 3、修正针对初始化时生成的高峰班次,之前不足的补上,多余的删除
811   - schedule.fnAdjustGfbc(true, true); // 修正上行早高峰
812   - schedule.fnAdjustGfbc(true, false); // 修正下行早高峰
813   - schedule.fnAdjustGfbc(false, true); // 修正上行晚高峰
814   - schedule.fnAdjustGfbc(false, false); // 修正下行晚高峰
815   -
816   - // 6、补吃饭班次
817   - schedule.fnCalcuEatBc();
818   -
819   - // 4、按照车辆投入运营要求补充班次
820   - schedule.fnCalcuLpBc_yy();
821   -
822   - // 5、根据班型补充所有的不足班次
823   - schedule.fnCalcuLpBx_5_2();
824   - schedule.fnCalcuLpBx_other();
825   -
826   - // 7、祛除上标线开头有删除标记的班次
827   - schedule.fnRemoveDelFirstFlagBc();
828   -
829   - // 8、调整路牌班次间隔(使用平均停站时间)
830   - schedule.fnAdjustLpBcInterval(1);
831   -
832   - // 9、调整班次发车间隔
833   - schedule.fnAdjustBcInterval(false);
834   -
835   - // 10、确定末班车
836   - schedule.fnCalcuLastBc();
837   -
838   - // 11、祛除上标线结尾有删除标记的班次
839   - schedule.fnRemoveDelLastFlagBc();
840   -
841   - // TODO:12、平均化指定时间后的班次列表间隔
842   - // // schedule.fnAdjustBcInterval2_avg(true, _paramObj.toTimeObj("19:50"));
843   - // // schedule.fnAdjustBcInterval2_avg(false, _paramObj.toTimeObj("19:50"));
844   - //
845   - // 10、补进出场例保班次
846   - schedule.fnCalcuOtherBc();
847   -
848   - //-------------------- 输出ganut图上的班次,班型描述 ----------------------//
849   - // TODO:班型再议
850   - return {
851   - 'json':schedule.fnToGanttBcArray(),'bxrcgs':null,
852   - 'aInternalLpObj': schedule.fnGetLpArray()
853   - };
854   -
855   - },
856   - /**
857   - * 导出时刻表配置。
858   - * @param aInternalLpObj 内部路牌对象列表
859   - */
860   - exportDataConfig: function(aInternalLpObj) {
861   - $('.exportAddXls').off('click');
862   - $('.exportAddXlsx').off('click');
863   -
864   - $('.exportAddXls').on('click', function() {
865   - var aInfos = {
866   - "lpObjList": _funCalcuExportData_lpObjList(aInternalLpObj), // 路牌班次信息列表
867   - "statInfoList": _funCalcuExportData_statInfoList(aInternalLpObj), // 统计项目列表
868   - "parameterInfoList" : __funCalcuExportData_paramInfoList() // 参数对象
869   - };
870   -
871   - console.log(aInfos);
872   -
873   - $(".exportAdd").addClass("disabled");
874   - $(".exportAddSpan").html("正在导出...");
875   -
876   - // 提交
877   - $.ajax({
878   - type: 'POST',
879   - url: "/tidc/exportDTDFile/xls",
880   - dataType: 'binary',
881   - contentType: "application/json",
882   - data: JSON.stringify(aInfos),
883   - success: function(data){
884   - Main_v2.downloadFile(data, "application/octet-stream", "时刻表信息.xls");
885   -
886   - $(".exportAdd").removeClass("disabled");
887   - $(".exportAddSpan").html(" 导出数据");
888   - },
889   - error: function(xhr, type){
890   - alert('错误:TODO');
891   -
892   - $(".exportAdd").removeClass("disabled");
893   - $(".exportAddSpan").html(" 导出数据");
894   - }
895   - });
896   - });
897   -
898   - $('.exportAddXlsx').on('click', function() {
899   - var aInfos = {
900   - "lpObjList": _funCalcuExportData_lpObjList(aInternalLpObj), // 路牌班次信息列表
901   - "statInfoList": _funCalcuExportData_statInfoList(aInternalLpObj), // 统计项目列表
902   - "parameterInfoList" : __funCalcuExportData_paramInfoList() // 参数对象
903   - };
904   -
905   - console.log(aInfos);
906   -
907   - $(".exportAdd").addClass("disabled");
908   - $(".exportAddSpan").html("正在导出...");
909   -
910   - // 提交
911   - $.ajax({
912   - type: 'POST',
913   - url: "/tidc/exportDTDFile/xlsx",
914   - dataType: 'binary',
915   - contentType: "application/json",
916   - data: JSON.stringify(aInfos),
917   - success: function(data){
918   - Main_v2.downloadFile(data, "application/octet-stream", "时刻表信息.xlsx");
919   -
920   - $(".exportAdd").removeClass("disabled");
921   - $(".exportAddSpan").html(" 导出数据");
922   - },
923   - error: function(xhr, type){
924   - alert('错误:TODO');
925   -
926   - $(".exportAdd").removeClass("disabled");
927   - $(".exportAddSpan").html(" 导出数据");
928   - }
929   - });
930   - });
931   - },
932   -
933   - downloadFile: function (data, mimeType, fileName) {
934   - var success = false;
935   - var blob = new Blob([data], { type: mimeType });
936   - try {
937   - if (navigator.msSaveBlob)
938   - navigator.msSaveBlob(blob, fileName);
939   - else {
940   - // Try using other saveBlob implementations, if available
941   - var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;
942   - if (saveBlob === undefined) throw "Not supported";
943   - saveBlob(blob, fileName);
944   - }
945   - success = true;
946   - } catch (ex) {
947   - console.log("saveBlob method failed with the following exception:");
948   - console.log(ex);
949   - }
950   -
951   - if (!success) {
952   - // Get the blob url creator
953   - var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
954   - if (urlCreator) {
955   - // Try to use a download link
956   - var link = document.createElement('a');
957   - if ('download' in link) {
958   - // Try to simulate a click
959   - try {
960   - // Prepare a blob URL
961   - var url = urlCreator.createObjectURL(blob);
962   - link.setAttribute('href', url);
963   -
964   - // Set the download attribute (Supported in Chrome 14+ / Firefox 20+)
965   - link.setAttribute("download", fileName);
966   -
967   - // Simulate clicking the download link
968   - var event = document.createEvent('MouseEvents');
969   - event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
970   - link.dispatchEvent(event);
971   - success = true;
972   -
973   - } catch (ex) {
974   - console.log("Download link method with simulated click failed with the following exception:");
975   - console.log(ex);
976   - }
977   - }
978   -
979   - if (!success) {
980   - // Fallback to window.location method
981   - try {
982   - // Prepare a blob URL
983   - // Use application/octet-stream when using window.location to force download
984   - var url = urlCreator.createObjectURL(blob);
985   - window.location = url;
986   - console.log("Download link method with window.location succeeded");
987   - success = true;
988   - } catch (ex) {
989   - console.log("Download link method with window.location failed with the following exception:");
990   - console.log(ex);
991   - }
992   - }
993   - }
994   - }
995   -
996   - if (!success) {
997   - // Fallback to window.open method
998   - console.log("No methods worked for saving the arraybuffer, using last resort window.open");
999   - window.open("", '_blank', '');
1000   - }
1001   - }
1002   -
1003   - };
1004   -
1005   -}();
1006   -
1007   -
  1 +/**
  2 + * 主类。
  3 + */
  4 +var Main_v2 = function() {
  5 +
  6 + // 内部工厂类
  7 + var _factoryFun = function() {
  8 + return {
  9 + // 创建参数
  10 + createParameterObj: function(formMap, dataMap) {
  11 + var paramObj = ParameterObj();
  12 + paramObj.wrap(formMap, dataMap);
  13 + return paramObj;
  14 + },
  15 + // 创建班次对象
  16 + createBcObj: function(lpObj, bcType, isUp, fcno, fcTimeObj, paramObj) {
  17 + var _bclc = paramObj.calcuTravelLcNumber(isUp, bcType);
  18 + var _fcsj = fcTimeObj;
  19 + var _bcsj = paramObj.calcuTravelTime(_fcsj, isUp);
  20 + var _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  21 + //var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj);
  22 + var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, isUp, paramObj.calcuTravelTime(_fcsj, isUp));
  23 + var _tccid = paramObj.getTTinfoId();
  24 + var _ttinfoid = paramObj.getTTinfoId();
  25 + var _xl = paramObj.getXlId();
  26 + var _qdz = isUp ? paramObj.getUpQdzObj().id : paramObj.getDownQdzObj().id;
  27 + var _zdz = isUp ? paramObj.getUpZdzObj().id : paramObj.getDownZdzObj().id;
  28 +
  29 + if (bcType == "bd") { // 早例保,传过来的发车时间是第一个班次的发车时间
  30 + if (isUp) { // 上行
  31 + _fcsj = paramObj.addMinute(
  32 + _fcsj,
  33 + -(paramObj.getUpOutTime() + paramObj.getLbTime()));
  34 + _bcsj = paramObj.getLbTime();
  35 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  36 + _stoptime = 0;
  37 + } else { // 下行
  38 + _fcsj = paramObj.addMinute(
  39 + _fcsj,
  40 + -(paramObj.getDownOutTime() + paramObj.getLbTime()));
  41 + _bcsj = paramObj.getLbTime();
  42 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  43 + _stoptime = 0;
  44 + }
  45 + } else if (bcType == "lc") { // 晚例保,传过来的发车时间是最后一个班次的到达时间
  46 + if (isUp) { // 上行
  47 + _fcsj = paramObj.addMinute(
  48 + _fcsj,
  49 + paramObj.getUpInTime());
  50 + _bcsj = paramObj.getLbTime();
  51 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  52 + _stoptime = 0;
  53 + } else { // 下行
  54 + _fcsj = paramObj.addMinute(
  55 + _fcsj,
  56 + paramObj.getDownInTime());
  57 + _bcsj = paramObj.getLbTime();
  58 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  59 + _stoptime = 0;
  60 + }
  61 + } else if (bcType == "out") { // 出场,传过来的发车时间是第一个班次的发车时间
  62 + if (isUp) { // 上行
  63 + _fcsj = paramObj.addMinute(
  64 + _fcsj,
  65 + -paramObj.getUpOutTime());
  66 + _bcsj = paramObj.getUpOutTime();
  67 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  68 + _stoptime = 0;
  69 + } else { // 下行
  70 + _fcsj = paramObj.addMinute(
  71 + _fcsj,
  72 + -paramObj.getDownOutTime());
  73 + _bcsj = paramObj.getDownOutTime();
  74 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  75 + _stoptime = 0;
  76 + }
  77 + } else if (bcType == "in") { // 进场,传过来的发车时间是最后一个班次的到达时间
  78 + if (isUp) { // 上行
  79 + _bcsj = paramObj.getUpInTime();
  80 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  81 + _stoptime = 0;
  82 + } else { // 下行
  83 + _bcsj = paramObj.getDownInTime();
  84 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  85 + _stoptime = 0;
  86 + }
  87 + } else if (bcType == "cf") { // 吃饭班次
  88 + // 以13:00为分界,之前的为午饭,之后的为晚饭
  89 + if (fcTimeObj.isBefore(paramObj.toTimeObj("13:00"))) {
  90 + _bcsj = paramObj.fnGetLunchTime();
  91 + } else {
  92 + _bcsj = paramObj.fnGetDinnerTime();
  93 + }
  94 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  95 + _stoptime = 0;
  96 + }
  97 +
  98 + var bcParamObj = {};
  99 + bcParamObj.bcType = bcType; // 班次类型(normal,in_,out, bd, lc, cf等)
  100 + bcParamObj.isUp = isUp; // boolean是否上下行
  101 + bcParamObj.fcno = fcno; // 发车顺序号
  102 + bcParamObj.fcTimeObj = _fcsj; // 发车时间对象
  103 + bcParamObj.bclc = _bclc; // 班次里程
  104 + bcParamObj.bcsj = _bcsj; // 班次历时
  105 + bcParamObj.arrtime = _arrsj; // 到达时间对象
  106 + bcParamObj.stoptime = _stoptime; // 停站时间
  107 + bcParamObj.tccid = _tccid; // 停车场id
  108 + bcParamObj.ttinfoid = _ttinfoid; // 时刻表id
  109 + bcParamObj.xl = _xl; // 线路id
  110 + bcParamObj.qdzid = _qdz; // 起点站id
  111 + bcParamObj.zdzid = _zdz; // 终点站id
  112 +
  113 + return new InternalBcObj(lpObj, bcParamObj);
  114 + }
  115 + };
  116 + };
  117 + var _factory = _factoryFun();
  118 +
  119 + // 所有的时间使用moment.js计算
  120 +
  121 + var _paramObj; // 参数对象
  122 +
  123 + var _bxDesc = [ // 班型描述
  124 + {'type':'六工一休','hoursV':6.66, 'minueV':'6:40', 'qcount': 0, 'avertime': 0},
  125 + {'type':'五工一休','hoursV':6.85, 'minueV':'6:51', 'qcount': 0, 'avertime': 0},
  126 + {'type':'四工一休','hoursV':7.14, 'minueV':'7:08', 'qcount': 0, 'avertime': 0},
  127 + {'type':'三工一休','hoursV':7.61, 'minueV':'7:37', 'qcount': 0, 'avertime': 0},
  128 + {'type':'二工一休','hoursV':8.57, 'minueV':'8:34', 'qcount': 0, 'avertime': 0},
  129 + {'type':'一工一休','hoursV':11.42, 'minueV':'11:25', 'qcount': 0, 'avertime': 0},
  130 + {'type':'五工二休','hoursV':7.99, 'minueV':'8:00', 'qcount': 0, 'avertime': 0},
  131 + {'type':'无工休', 'hoursV':5.43, 'minueV':'5:43', 'qcount': 0, 'avertime': 0}
  132 + ];
  133 +
  134 + var _funCalcuExportData_lpObjList = function(aInternalLpObj) {
  135 + // 构造路牌对象
  136 + var aLpObj = [];
  137 + var i;
  138 + var j;
  139 + var z;
  140 + var oInternalLp;
  141 + var oInternalBc;
  142 + var oInternalBc_temp;
  143 + var oLp;
  144 + var iZlc;
  145 + var iYylc;
  146 + var iKslc;
  147 + var iZbc;
  148 + var iZgs;
  149 + var iYygs;
  150 + var iYybc;
  151 + for (i = 0; i < aInternalLpObj.length; i++) {
  152 + oInternalLp = aInternalLpObj[i];
  153 + iZlc = 0;
  154 + iYylc = 0;
  155 + iKslc = 0;
  156 + iZgs = 0;
  157 + iZbc = 0;
  158 + iYygs = 0;
  159 + iYybc = 0;
  160 + oLp = {
  161 + "lpname": oInternalLp.getLpName(), // 路牌名字
  162 + "isUp": oInternalLp.isUp(), // 每圈的第一个班次是否上行
  163 + "bcObjList": [], // 班次列表
  164 + "groupCount": oInternalLp.fnGetGroupCount(), // 总圈数
  165 + "zlc": 0, // 总里程
  166 + "yylc": 0, // 营运里程
  167 + "kslc": 0, // 空驶里程
  168 + "zgs": 0, // 总工时
  169 + "zbc": 0, // 总班次
  170 + "yygs": 0, // 营运工时
  171 + "yybc": 0, // 营运班次
  172 + "stationRouteId1": 0, // 第一个班次起点站路由id
  173 + "stationRouteId2": 0 // 第二个班次起点站路由id
  174 + };
  175 +
  176 + // 将报到班次,进出场班次加到班次的时间上
  177 + var iBcChainCount;
  178 + var oStartBc;
  179 + var oEndBc;
  180 + var oTempBc;
  181 + var aFcsj = [];
  182 +
  183 + iBcChainCount = oInternalLp.fnGetBcChainCount();
  184 + if (iBcChainCount == 1) { // 单一车次链,连班班型
  185 + oStartBc = oInternalLp.getBc(
  186 + oInternalLp.fnGetBcChainInfo(0)["s_q"],
  187 + oInternalLp.fnGetBcChainInfo(0)["s_b"]
  188 + );
  189 + oTempBc = _factory.createBcObj(
  190 + oLp, "bd", oStartBc.isUp(), 1,
  191 + oStartBc.getFcTimeObj(),
  192 + _paramObj
  193 + );
  194 + aFcsj.push("(到" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  195 + oLp.bcObjList.push({ // 报到班次
  196 + "bcsj": oTempBc.getBcTime(), // 班次时间
  197 + "ssj": oTempBc.getStopTime(), // 停站时间
  198 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  199 +
  200 + "tccid": oTempBc._$_tccid, // 停车场id
  201 + "qdzid": oTempBc._$_qdzid, // 起点站id
  202 + "zdzid": oTempBc._$_zdzid, // 终点站id
  203 +
  204 + "isUp": oTempBc._$_isUp, // 是否上行
  205 + "isFb": false, // 是否分班
  206 +
  207 + "bcType": oTempBc._$_bcType, // 班次类型
  208 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  209 +
  210 + "groupNo": -1, // 第几圈
  211 + "groupBcNo": -1 // 圈里第几个班次
  212 +
  213 + });
  214 +
  215 + oTempBc = _factory.createBcObj(
  216 + oLp, "out", oStartBc.isUp(), 1,
  217 + oStartBc.getFcTimeObj(),
  218 + _paramObj
  219 + );
  220 + aFcsj.push("(出" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  221 + aFcsj.push("(" + oStartBc.getFcTimeObj().format("HH:mm") + ")");
  222 + oStartBc._$_fcsj_desc = aFcsj.join("");
  223 +
  224 + oLp.bcObjList.push({ // 出场班次
  225 + "bcsj": oTempBc.getBcTime(), // 班次时间
  226 + "ssj": oTempBc.getStopTime(), // 停站时间
  227 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  228 +
  229 + "tccid": oTempBc._$_tccid, // 停车场id
  230 + "qdzid": oTempBc._$_qdzid, // 起点站id
  231 + "zdzid": oTempBc._$_zdzid, // 终点站id
  232 +
  233 + "isUp": oTempBc._$_isUp, // 是否上行
  234 + "isFb": false, // 是否分班
  235 +
  236 + "bcType": oTempBc._$_bcType, // 班次类型
  237 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  238 +
  239 + "groupNo": -1, // 第几圈
  240 + "groupBcNo": -2 // 圈里第几个班次
  241 +
  242 + });
  243 +
  244 + aFcsj = [];
  245 +
  246 + oEndBc = oInternalLp.getBc(
  247 + oInternalLp.fnGetBcChainInfo(0)["e_q"],
  248 + oInternalLp.fnGetBcChainInfo(0)["e_b"]
  249 + );
  250 + aFcsj.push("(" + oEndBc.getFcTimeObj().format("HH:mm") + ")");
  251 + oTempBc = _factory.createBcObj(
  252 + oLp, "in", !oEndBc.isUp(), 1,
  253 + oEndBc.getArrTimeObj(),
  254 + _paramObj
  255 + );
  256 + aFcsj.push("(进" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  257 +
  258 + oLp.bcObjList.push({ // 进场班次
  259 + "bcsj": oTempBc.getBcTime(), // 班次时间
  260 + "ssj": oTempBc.getStopTime(), // 停站时间
  261 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  262 +
  263 + "tccid": oTempBc._$_tccid, // 停车场id
  264 + "qdzid": oTempBc._$_qdzid, // 起点站id
  265 + "zdzid": oTempBc._$_zdzid, // 终点站id
  266 +
  267 + "isUp": oTempBc._$_isUp, // 是否上行
  268 + "isFb": false, // 是否分班
  269 +
  270 + "bcType": oTempBc._$_bcType, // 班次类型
  271 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  272 +
  273 + "groupNo": oInternalLp.fnGetBcChainInfo(0)["e_b"] == 0 ?
  274 + oInternalLp.fnGetBcChainInfo(0)["e_q"] :
  275 + oInternalLp.fnGetBcChainInfo(0)["e_q"] + 1, // 第几圈
  276 + "groupBcNo": oInternalLp.fnGetBcChainInfo(0)["e_b"] == 0 ? 1 : 0 // 圈里第几个班次
  277 +
  278 + });
  279 +
  280 + oTempBc = _factory.createBcObj(
  281 + oLp, "lc", !oEndBc.isUp(), 1,
  282 + oEndBc.getArrTimeObj(),
  283 + _paramObj
  284 + );
  285 + aFcsj.push("(离" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  286 + oLp.bcObjList.push({ // 离场班次
  287 + "bcsj": oTempBc.getBcTime(), // 班次时间
  288 + "ssj": oTempBc.getStopTime(), // 停站时间
  289 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  290 +
  291 + "tccid": oTempBc._$_tccid, // 停车场id
  292 + "qdzid": oTempBc._$_qdzid, // 起点站id
  293 + "zdzid": oTempBc._$_zdzid, // 终点站id
  294 +
  295 + "isUp": oTempBc._$_isUp, // 是否上行
  296 + "isFb": false, // 是否分班
  297 +
  298 + "bcType": oTempBc._$_bcType, // 班次类型
  299 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  300 +
  301 + "groupNo": -2, // 第几圈
  302 + "groupBcNo": -4 // 圈里第几个班次
  303 +
  304 + });
  305 +
  306 + oEndBc._$_fcsj_desc = aFcsj.join("");
  307 +
  308 + } else if (iBcChainCount == 2) { // 两个车次链,分班班型
  309 + oStartBc = oInternalLp.getBc(
  310 + oInternalLp.fnGetBcChainInfo(0)["s_q"],
  311 + oInternalLp.fnGetBcChainInfo(0)["s_b"]
  312 + );
  313 + oTempBc = _factory.createBcObj(
  314 + oLp, "bd", oStartBc.isUp(), 1,
  315 + oStartBc.getFcTimeObj(),
  316 + _paramObj
  317 + );
  318 + aFcsj.push("(到" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  319 + oLp.bcObjList.push({ // 报到班次
  320 + "bcsj": oTempBc.getBcTime(), // 班次时间
  321 + "ssj": oTempBc.getStopTime(), // 停站时间
  322 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  323 +
  324 + "tccid": oTempBc._$_tccid, // 停车场id
  325 + "qdzid": oTempBc._$_qdzid, // 起点站id
  326 + "zdzid": oTempBc._$_zdzid, // 终点站id
  327 +
  328 + "isUp": oTempBc._$_isUp, // 是否上行
  329 + "isFb": false, // 是否分班
  330 +
  331 + "bcType": oTempBc._$_bcType, // 班次类型
  332 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  333 +
  334 + "groupNo": -1, // 第几圈
  335 + "groupBcNo": -1 // 圈里第几个班次
  336 +
  337 + });
  338 +
  339 + oTempBc = _factory.createBcObj(
  340 + oLp, "out", oStartBc.isUp(), 1,
  341 + oStartBc.getFcTimeObj(),
  342 + _paramObj
  343 + );
  344 + aFcsj.push("(出" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  345 + aFcsj.push("(" + oStartBc.getFcTimeObj().format("HH:mm") + ")");
  346 + oStartBc._$_fcsj_desc = aFcsj.join("");
  347 +
  348 + oLp.bcObjList.push({ // 出场班次
  349 + "bcsj": oTempBc.getBcTime(), // 班次时间
  350 + "ssj": oTempBc.getStopTime(), // 停站时间
  351 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  352 +
  353 + "tccid": oTempBc._$_tccid, // 停车场id
  354 + "qdzid": oTempBc._$_qdzid, // 起点站id
  355 + "zdzid": oTempBc._$_zdzid, // 终点站id
  356 +
  357 + "isUp": oTempBc._$_isUp, // 是否上行
  358 + "isFb": false, // 是否分班
  359 +
  360 + "bcType": oTempBc._$_bcType, // 班次类型
  361 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  362 +
  363 + "groupNo": -1, // 第几圈
  364 + "groupBcNo": -2 // 圈里第几个班次
  365 +
  366 + });
  367 +
  368 + aFcsj = [];
  369 +
  370 + oEndBc = oInternalLp.getBc(
  371 + oInternalLp.fnGetBcChainInfo(0)["e_q"],
  372 + oInternalLp.fnGetBcChainInfo(0)["e_b"]
  373 + );
  374 + aFcsj.push("(" + oEndBc.getFcTimeObj().format("HH:mm") + ")");
  375 + oTempBc = _factory.createBcObj(
  376 + oLp, "in", !oEndBc.isUp(), 1,
  377 + oEndBc.getArrTimeObj(),
  378 + _paramObj
  379 + );
  380 + aFcsj.push("(进" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  381 + oLp.bcObjList.push({ // 进场班次
  382 + "bcsj": oTempBc.getBcTime(), // 班次时间
  383 + "ssj": oTempBc.getStopTime(), // 停站时间
  384 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  385 +
  386 + "tccid": oTempBc._$_tccid, // 停车场id
  387 + "qdzid": oTempBc._$_qdzid, // 起点站id
  388 + "zdzid": oTempBc._$_zdzid, // 终点站id
  389 +
  390 + "isUp": oTempBc._$_isUp, // 是否上行
  391 + "isFb": true, // 是否分班
  392 +
  393 + "bcType": oTempBc._$_bcType, // 班次类型
  394 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  395 +
  396 + "groupNo": oInternalLp.fnGetBcChainInfo(0)["e_b"] == 0 ?
  397 + oInternalLp.fnGetBcChainInfo(0)["e_q"] :
  398 + oInternalLp.fnGetBcChainInfo(0)["e_q"] + 1, // 第几圈
  399 + "groupBcNo": oInternalLp.fnGetBcChainInfo(0)["e_b"] == 0 ? 1 : 0 // 圈里第几个班次
  400 +
  401 + });
  402 + oEndBc._$_fcsj_desc = aFcsj.join("");
  403 +
  404 + aFcsj = [];
  405 +
  406 + oStartBc = oInternalLp.getBc(
  407 + oInternalLp.fnGetBcChainInfo(1)["s_q"],
  408 + oInternalLp.fnGetBcChainInfo(1)["s_b"]
  409 + );
  410 + oTempBc = _factory.createBcObj(
  411 + oLp, "bd", oStartBc.isUp(), 1,
  412 + oStartBc.getFcTimeObj(),
  413 + _paramObj
  414 + );
  415 + aFcsj.push("(到" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  416 + oLp.bcObjList.push({ // 报到班次
  417 + "bcsj": oTempBc.getBcTime(), // 班次时间
  418 + "ssj": oTempBc.getStopTime(), // 停站时间
  419 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  420 +
  421 + "tccid": oTempBc._$_tccid, // 停车场id
  422 + "qdzid": oTempBc._$_qdzid, // 起点站id
  423 + "zdzid": oTempBc._$_zdzid, // 终点站id
  424 +
  425 + "isUp": oTempBc._$_isUp, // 是否上行
  426 + "isFb": true, // 是否分班
  427 +
  428 + "bcType": oTempBc._$_bcType, // 班次类型
  429 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  430 +
  431 + "groupNo": oInternalLp.fnGetBcChainInfo(1)["s_q"] - 1, // 第几圈
  432 + "groupBcNo": oInternalLp.fnGetBcChainInfo(1)["s_b"] // 圈里第几个班次
  433 +
  434 + });
  435 +
  436 + oTempBc = _factory.createBcObj(
  437 + oLp, "out", oStartBc.isUp(), 1,
  438 + oStartBc.getFcTimeObj(),
  439 + _paramObj
  440 + );
  441 + oLp.bcObjList.push({ // 出场班次
  442 + "bcsj": oTempBc.getBcTime(), // 班次时间
  443 + "ssj": oTempBc.getStopTime(), // 停站时间
  444 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  445 +
  446 + "tccid": oTempBc._$_tccid, // 停车场id
  447 + "qdzid": oTempBc._$_qdzid, // 起点站id
  448 + "zdzid": oTempBc._$_zdzid, // 终点站id
  449 +
  450 + "isUp": oTempBc._$_isUp, // 是否上行
  451 + "isFb": true, // 是否分班
  452 +
  453 + "bcType": oTempBc._$_bcType, // 班次类型
  454 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  455 +
  456 + "groupNo": oInternalLp.fnGetBcChainInfo(1)["s_b"] == 0 ?
  457 + oInternalLp.fnGetBcChainInfo(1)["s_q"] - 1 :
  458 + oInternalLp.fnGetBcChainInfo(1)["s_q"], // 第几圈
  459 + "groupBcNo": oInternalLp.fnGetBcChainInfo(1)["s_b"] == 0 ? 1 : 0 // 圈里第几个班次
  460 +
  461 + });
  462 + aFcsj.push("(出" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  463 + aFcsj.push("(" + oStartBc.getFcTimeObj().format("HH:mm") + ")");
  464 + oStartBc._$_fcsj_desc = aFcsj.join("");
  465 +
  466 + aFcsj = [];
  467 +
  468 + oEndBc = oInternalLp.getBc(
  469 + oInternalLp.fnGetBcChainInfo(1)["e_q"],
  470 + oInternalLp.fnGetBcChainInfo(1)["e_b"]
  471 + );
  472 + aFcsj.push("(" + oEndBc.getFcTimeObj().format("HH:mm") + ")");
  473 + oTempBc = _factory.createBcObj(
  474 + oLp, "in", !oEndBc.isUp(), 1,
  475 + oEndBc.getArrTimeObj(),
  476 + _paramObj
  477 + );
  478 + aFcsj.push("(进" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  479 +
  480 + oLp.bcObjList.push({ // 进场班次
  481 + "bcsj": oTempBc.getBcTime(), // 班次时间
  482 + "ssj": oTempBc.getStopTime(), // 停站时间
  483 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  484 +
  485 + "tccid": oTempBc._$_tccid, // 停车场id
  486 + "qdzid": oTempBc._$_qdzid, // 起点站id
  487 + "zdzid": oTempBc._$_zdzid, // 终点站id
  488 +
  489 + "isUp": oTempBc._$_isUp, // 是否上行
  490 + "isFb": false, // 是否分班
  491 +
  492 + "bcType": oTempBc._$_bcType, // 班次类型
  493 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  494 +
  495 + "groupNo": oInternalLp.fnGetBcChainInfo(1)["e_b"] == 0 ?
  496 + oInternalLp.fnGetBcChainInfo(1)["e_q"] :
  497 + oInternalLp.fnGetBcChainInfo(1)["e_q"] + 1, // 第几圈
  498 + "groupBcNo": oInternalLp.fnGetBcChainInfo(1)["e_b"] == 0 ? 1 : 0 // 圈里第几个班次
  499 +
  500 + });
  501 +
  502 + oTempBc = _factory.createBcObj(
  503 + oLp, "lc", !oEndBc.isUp(), 1,
  504 + oEndBc.getArrTimeObj(),
  505 + _paramObj
  506 + );
  507 +
  508 + oLp.bcObjList.push({ // 离场班次
  509 + "bcsj": oTempBc.getBcTime(), // 班次时间
  510 + "ssj": oTempBc.getStopTime(), // 停站时间
  511 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  512 +
  513 + "tccid": oTempBc._$_tccid, // 停车场id
  514 + "qdzid": oTempBc._$_qdzid, // 起点站id
  515 + "zdzid": oTempBc._$_zdzid, // 终点站id
  516 +
  517 + "isUp": oTempBc._$_isUp, // 是否上行
  518 + "isFb": false, // 是否分班
  519 +
  520 + "bcType": oTempBc._$_bcType, // 班次类型
  521 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  522 +
  523 + "groupNo": -2, // 第几圈
  524 + "groupBcNo": -4 // 圈里第几个班次
  525 +
  526 + });
  527 +
  528 + aFcsj.push("(离" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  529 + oEndBc._$_fcsj_desc = aFcsj.join("");
  530 +
  531 + }
  532 +
  533 + for (j = 0; j < oInternalLp.fnGetGroupCount(); j++) {
  534 + for (z = 0; z < 2; z++) {
  535 + oInternalBc = oInternalLp.getBc(j, z);
  536 + if (oInternalBc) {
  537 + if (oInternalBc.fnGetEatTime() > 0) {
  538 + // 吃饭班次是下一个班次开始吃,和本班次方向相反
  539 + oInternalBc_temp = oInternalLp.getBc(
  540 + z == 1 ? j + 1 : j,
  541 + z == 1 ? 0 : 1);
  542 +
  543 + oInternalBc_temp._$_isRealEat = true;
  544 + oInternalBc_temp._$_fcsj_desc = "(吃" + oInternalBc_temp.getFcTimeObj().format("HH:mm") + ")";
  545 + }
  546 +
  547 + oLp.bcObjList.push({
  548 + "bcsj": oInternalBc.getBcTime(), // 班次时间
  549 + "ssj": oInternalBc.getStopTime(), // 停站时间
  550 + "eatsj": oInternalBc.fnGetEatTime(), // 吃饭时间
  551 +
  552 + "tccid": oInternalBc._$_tccid, // 停车场id
  553 + "qdzid": oInternalBc._$_qdzid, // 起点站id
  554 + "zdzid": oInternalBc._$_zdzid, // 终点站id
  555 +
  556 + "isUp": oInternalBc._$_isUp, // 是否上行
  557 +
  558 + "bcType": oInternalBc._$_bcType, // 班次类型
  559 + "fcsj": oInternalBc._$_isRealEat ?
  560 + ("*" + oInternalBc._$_fcsjObj.format("HH:mm")) :
  561 + oInternalBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  562 + "fcsjDesc" : oInternalBc._$_fcsj_desc || oInternalBc._$_fcsjObj.format("HH:mm"),
  563 +
  564 + "groupNo": j, // 第几圈
  565 + "groupBcNo": z // 圈里第几个班次
  566 +
  567 + });
  568 +
  569 + // iZlc = 0;
  570 + // iYylc = 0;
  571 + // iKslc = 0;
  572 + // iZgs = 0;
  573 + // iZbc = 0;
  574 + // iYygs = 0;
  575 + // iYybc = 0;
  576 +
  577 + iZlc = iZlc +
  578 + oInternalBc._$_bclc; // 里程
  579 + iYylc = iYylc +
  580 + oInternalBc._$_bclc; // 里程
  581 + iYygs = iYygs +
  582 + oInternalBc.getBcTime() + // 班次时间
  583 + oInternalBc.getStopTime() + // 停站时间
  584 + oInternalBc.fnGetEatTime(); // 吃饭时间
  585 + iYybc = iYybc + 1;
  586 +
  587 + iZgs = iZgs +
  588 + oInternalBc.getBcTime() + // 班次时间
  589 + oInternalBc.getStopTime() + // 停站时间
  590 + oInternalBc.fnGetEatTime(); // 吃饭时间
  591 + iZbc = iZbc + 1;
  592 +
  593 + // 设置圈站点路由id
  594 + if (oInternalBc.isUp() == oInternalLp.isUp()) { // 第一个班次
  595 + if (oLp.stationRouteId1 == 0) {
  596 + oLp.stationRouteId1 = oInternalBc._$_qdzid;
  597 + }
  598 + } else { // 第二个班次
  599 + if (oLp.stationRouteId2 == 0) {
  600 + oLp.stationRouteId2 = oInternalBc._$_qdzid;
  601 + }
  602 + }
  603 +
  604 + }
  605 + }
  606 +
  607 + }
  608 +
  609 + for (z = 0; z < oInternalLp.getOtherBcArray().length; z++) {
  610 + oInternalBc = oInternalLp.getOtherBcArray()[z];
  611 + iKslc = iKslc +
  612 + oInternalBc._$_bclc; // 里程
  613 + iZlc = iZlc +
  614 + oInternalBc._$_bclc; // 里程
  615 + iZgs = iZgs +
  616 + oInternalBc.getBcTime() + // 班次时间
  617 + oInternalBc.getStopTime(); // 停站时间
  618 + if (oInternalBc._$_bcType != "bd" &&
  619 + oInternalBc._$_bcType != "lc" &&
  620 + oInternalBc._$_bcType != "cf") {
  621 + iZbc = iZbc + 1;
  622 + }
  623 + }
  624 +
  625 + oLp.zlc = iZlc;
  626 + oLp.yylc = iYylc;
  627 + oLp.kslc = iKslc;
  628 + oLp.zgs = iZgs;
  629 + oLp.zbc = iZbc;
  630 + oLp.yygs = iYygs;
  631 + oLp.yybc = iYybc;
  632 + aLpObj.push(oLp);
  633 + }
  634 +
  635 + return aLpObj;
  636 + };
  637 +
  638 + var _funCalcuExportData_statInfoList = function(aInternalLpObj) {
  639 + var countBc = 0, // 总班次
  640 + serviceBc = 0, // 营运班次
  641 + jcbc = 0, // 进场总班次.
  642 + ccbc = 0, // 出场总班次.
  643 + cfbc = 0, // 吃饭总班次.
  644 + zwlbbc = 0, // 早晚例保总班次.
  645 + countGs = 0.0, // 总工时
  646 + servicesj = 0, // 营运班次总时间
  647 + jcsj = 0.0, // 进场总时间.
  648 + ccsj = 0.0, // 出场总时间.
  649 + cfsj = 0.0, // 吃饭总时间.
  650 + zwlbsj = 0.0, // 早晚例保总时间.
  651 + ksBc = 0, // 空驶班次
  652 + serviceLc = 0.0, // 营运里程
  653 + ksLc = 0.0, // 空驶里程
  654 + avgTzjx = 0.0, // 平均停站间隙
  655 + gfServiceBc = 0, // 高峰营运班次
  656 + dgServiceBc = 0, // 低谷营运班次
  657 + gfAvgTzjx = 0.0, // 高峰平均停站间隙
  658 + dgAvgTzjx = 0.0; // 低谷平均停站间隙
  659 +
  660 + var aAllBc = [];
  661 + var oLp;
  662 + var oBc;
  663 + var i;
  664 + var j;
  665 +
  666 + for (i = 0; i < aInternalLpObj.length; i++) {
  667 + oLp = aInternalLpObj[i];
  668 + for (j = 0; j < oLp.getBcArray().length; j++) {
  669 + aAllBc.push(oLp.getBcArray()[j]);
  670 + }
  671 + for (j = 0; j < oLp.getOtherBcArray().length; j++) {
  672 + aAllBc.push(oLp.getOtherBcArray()[j]);
  673 + }
  674 + }
  675 +
  676 + for (i = 0; i < aAllBc.length; i++) {
  677 + oBc = aAllBc[i];
  678 +
  679 + if (oBc.getBcTime() > 0) {
  680 + countBc = countBc + 1;
  681 + countGs = countGs + oBc.getStopTime() + oBc.getBcTime();
  682 + if (_paramObj.isTroughBc(oBc.getFcTimeObj())) {
  683 + if (oBc._$_bcType == "normal") {
  684 + dgServiceBc = dgServiceBc + 1;
  685 + dgAvgTzjx = dgAvgTzjx + oBc.getStopTime();
  686 + }
  687 + } else {
  688 + if (oBc._$_bcType == "normal") {
  689 + gfServiceBc = gfServiceBc + 1;
  690 + gfAvgTzjx = gfAvgTzjx + oBc.getStopTime();
  691 + }
  692 + }
  693 +
  694 + if (oBc._$_bcType == "normal") {
  695 + serviceBc = serviceBc + 1;
  696 + serviceLc = serviceLc + oBc._$_bclc;
  697 + servicesj = servicesj + oBc.getBcTime();
  698 + avgTzjx = avgTzjx + oBc.getStopTime();
  699 +
  700 + if (oBc.fnGetEatTime() > 0) {
  701 + cfbc = cfbc + 1;
  702 + cfsj = cfsj + oBc.fnGetEatTime();
  703 + }
  704 + } else if (oBc._$_bcType == "in") {
  705 + jcbc = jcbc + 1;
  706 + jcsj = jcsj + oBc.getBcTime();
  707 + } else if (oBc._$_bcType == "out") {
  708 + ccbc = ccbc + 1;
  709 + ccsj = ccsj + oBc.getBcTime();
  710 + } else if (oBc._$_bcType == "bd") {
  711 + zwlbbc = zwlbbc + 1;
  712 + zwlbsj = zwlbsj + oBc.getBcTime();
  713 + } else if (oBc._$_bcType == "lc") {
  714 + zwlbbc = zwlbbc + 1;
  715 + zwlbsj = zwlbsj + oBc.getBcTime();
  716 + }
  717 + }
  718 + }
  719 +
  720 + dgAvgTzjx = dgAvgTzjx / dgServiceBc;
  721 + gfAvgTzjx = gfAvgTzjx / gfServiceBc;
  722 + avgTzjx = avgTzjx / dgServiceBc;
  723 +
  724 + return [
  725 + {'statItem': '总班次(包括进出场、吃饭时间、早晚例保、营运且班次时间大于零的班次)', 'statValue': countBc},
  726 + {'statItem': '进场总班次(包括进场且班次时间大于零的班次)', 'statValue': jcbc},
  727 + {'statItem': '出场总班次(包括进场且班次时间大于零的班次)', 'statValue': ccbc},
  728 + {'statItem': '吃饭总班次(包括吃饭且班次时间大于零的班次)', 'statValue': cfbc},
  729 + {'statItem': '早晚例保总班次(包括早晚例保且时间大于零的班次)', 'statValue': zwlbbc},
  730 + {'statItem': '营运总班次(包括正常、区间、放大站且班次时间大于零班次)','statValue': serviceBc},
  731 + {'statItem': '进场总时间(包括进场班次且班次时间大于零)', 'statValue': jcsj/60},
  732 + {'statItem': '出场总时间(包括进场班次且班次时间大于零)', 'statValue': ccsj/60},
  733 + {'statItem': '吃饭总时间(包括吃饭班次且班次时间大于零)', 'statValue': cfsj/60},
  734 + {'statItem': '早晚例保总时间(包括早晚例保班次且时间大于零的)', 'statValue': zwlbsj/60},
  735 + {'statItem': '营运班次总时间(包括正常、区间、放大站且班次时间大于零)', 'statValue': servicesj/60},
  736 + {'statItem': '总工时(包括进出场、吃饭时间、早晚例保、营运班次时间)', 'statValue': countGs/60},
  737 + {'statItem': '空驶班次(包括直放班次)', 'statValue': ksBc},
  738 + {'statItem': '营运里程(包括正常、区间、放大站里程)', 'statValue': serviceLc},
  739 + {'statItem': '空驶里程(包括直放里程)', 'statValue': ksLc},
  740 + {'statItem': '平均停站时间(营运班次停站时间总和/营运总班次)', 'statValue': avgTzjx},
  741 + {'statItem': '高峰营运班次(包括早晚高峰时段的正常、区间、放大站班次)', 'statValue': gfServiceBc},
  742 + {'statItem': '低谷营运班次(包括低谷时段的正常、区间、放大站班次)', 'statValue': dgServiceBc},
  743 + {'statItem': '高峰平均停站间隙(高峰营运班次停站时间总和/高峰营运班次总和)', 'statValue': gfAvgTzjx},
  744 + {'statItem': '低谷平均停站间隙(低谷营运班次停站时间总和/低谷营运班次总和)', 'statValue': dgAvgTzjx},
  745 + {'statItem': '综合评估', 'statValue': 3}
  746 + ];
  747 +
  748 + };
  749 +
  750 + var __funCalcuExportData_paramInfoList = function() {
  751 + return [
  752 + {'paramItem' : '上行首班时间', 'paramValue' : _paramObj.getUpFirstDTimeObj().format("HH:mm")},
  753 + {'paramItem' : '上行末班时间', 'paramValue' : _paramObj.getUpLastDtimeObj().format("HH:mm")},
  754 + {'paramItem' : '下行首班时间', 'paramValue' : _paramObj.getDownFirstDTimeObj().format("HH:mm")},
  755 + {'paramItem' : '下行末班时间', 'paramValue' : _paramObj.getDownLastDTimeObj().format("HH:mm")},
  756 + {'paramItem' : '早高峰开始时间', 'paramValue' : _paramObj.getMPeakStartTimeObj().format("HH:mm")},
  757 + {'paramItem' : '早高峰结束时间', 'paramValue' : _paramObj.getMPeakEndTimeObj().format("HH:mm")},
  758 + {'paramItem' : '晚高峰开始时间', 'paramValue' : _paramObj.getEPeakStartTimeObj().format("HH:mm")},
  759 + {'paramItem' : '晚高峰结束时间', 'paramValue' : _paramObj.getEPeakEndTimeObj().format("HH:mm")},
  760 + {'paramItem' : '上行进场时间', 'paramValue' : _paramObj.getUpInTime()},
  761 + {'paramItem' : '上行出场时间', 'paramValue' : _paramObj.getUpOutTime()},
  762 + {'paramItem' : '下行进场时间', 'paramValue' : _paramObj.getDownInTime()},
  763 + {'paramItem' : '下行出场时间', 'paramValue' : _paramObj.getDownOutTime()},
  764 + {'paramItem' : '早高峰上行时间', 'paramValue' : _paramObj.getUpMPeakTime()},
  765 + {'paramItem' : '早高峰下行时间', 'paramValue' : _paramObj.getDownMPeakTime()},
  766 + {'paramItem' : '晚高峰上行时间', 'paramValue' : _paramObj.getUpEPeakTime()},
  767 + {'paramItem' : '晚高峰下行时间', 'paramValue' : _paramObj.getDownEPeakTime()},
  768 + {'paramItem' : '低谷上行时间', 'paramValue' : _paramObj.getUpTroughTime()},
  769 + {'paramItem' : '低谷下行时间', 'paramValue' : _paramObj.getDownTroughTime()},
  770 + {'paramItem' : '线路规划类型', 'paramValue' : "双向"},
  771 + {'paramItem' : '吃饭地点', 'paramValue' : _paramObj.fnIsEat() ? (_paramObj.fnIsBothEat() ? "上下行" : (_paramObj.fnIsUpEat() ? "上行" : "下行")) : "不吃饭"},
  772 + {'paramItem' : '早晚例行保养', 'paramValue' : _paramObj.getLbTime()},
  773 + {'paramItem' : '停车场', 'paramValue' : _paramObj.getTccId()},
  774 + {'paramItem' : '工作餐午餐时间', 'paramValue' : _paramObj.fnGetLunchTime()},
  775 + {'paramItem' : '工作餐晚餐时间', 'paramValue' : _paramObj.fnGetDinnerTime()},
  776 + {'paramItem' : '早高峰发车间隔', 'paramValue' : "[" + _paramObj.getMPeakMinFcjx() + "," + _paramObj.getMPeakMaxFcjx() + "]"},
  777 + {'paramItem' : '晚高峰发车间隔', 'paramValue' : "[" + _paramObj.getEPeakMinFcjx() + "," + _paramObj.getEPeakMaxFcjx() + "]"},
  778 + {'paramItem' : '低谷发车间隔', 'paramValue' : "[" + _paramObj.getTroughMinFcjx() + "," + _paramObj.getTroughMaxFcjx() + "]"},
  779 + {'paramItem' : '建议加班路牌数', 'paramValue' : _paramObj.getJBLpes()},
  780 + {'paramItem' : '停站类型', 'paramValue' : _paramObj.isTwoWayStop() ? "双向停站" : (_paramObj.isUpOneWayStop() ? "上行主站" : "下行主站") },
  781 + {'paramItem' : '建议高峰配车数', 'paramValue' : _paramObj.getAdvicePeakClzs()}
  782 + ]
  783 + };
  784 +
  785 + return {
  786 + setParam: function(paramObj) {
  787 + // 参数对象
  788 + _paramObj = paramObj;
  789 + },
  790 + /**
  791 + * 工厂对象,创建不同的对象。
  792 + * @returns {{createParameterObj, createBcObj}}
  793 + */
  794 + getFactory: function() {
  795 + return _factory;
  796 + },
  797 +
  798 + /**
  799 + * 使用发车间隔策略生成时刻表。
  800 + * @param paramObj 参数对象
  801 + * @param lpArray 路牌数组
  802 + * @constructor
  803 + */
  804 + BXPplaceClassesTime03 : function(paramObj, lpArray) {
  805 + // 参数对象
  806 + _paramObj = paramObj;
  807 +
  808 + // 1、初始化行车计划
  809 + var schedule = new InternalScheduleObj(_paramObj, lpArray, _factory);
  810 + schedule.fnInitDataWithBxLayout();
  811 + // 2、将连班路牌的班次补足
  812 + schedule.fnCalcuLpBx_lb();
  813 +
  814 + // 3、修正针对初始化时生成的高峰班次,之前不足的补上,多余的删除
  815 + schedule.fnAdjustGfbc(true, true); // 修正上行早高峰
  816 + schedule.fnAdjustGfbc(true, false); // 修正下行早高峰
  817 + schedule.fnAdjustGfbc(false, true); // 修正上行晚高峰
  818 + schedule.fnAdjustGfbc(false, false); // 修正下行晚高峰
  819 +
  820 + // 6、补吃饭班次
  821 + schedule.fnCalcuEatBc();
  822 +
  823 + // 4、按照车辆投入运营要求补充班次
  824 + schedule.fnCalcuLpBc_yy();
  825 +
  826 + // 5、根据班型补充所有的不足班次
  827 + schedule.fnCalcuLpBx_5_2();
  828 + schedule.fnCalcuLpBx_other();
  829 +
  830 + // 7、祛除上标线开头有删除标记的班次
  831 + schedule.fnRemoveDelFirstFlagBc();
  832 +
  833 + // 8、调整路牌班次间隔(使用平均停站时间)
  834 + schedule.fnAdjustLpBcInterval(1);
  835 +
  836 + // 9、调整班次发车间隔
  837 + schedule.fnAdjustBcInterval(false);
  838 +
  839 + // 10、确定末班车
  840 + schedule.fnCalcuLastBc();
  841 +
  842 + // 11、祛除上标线结尾有删除标记的班次
  843 + schedule.fnRemoveDelLastFlagBc();
  844 +
  845 + // TODO:12、平均化指定时间后的班次列表间隔
  846 + // // schedule.fnAdjustBcInterval2_avg(true, _paramObj.toTimeObj("19:50"));
  847 + // // schedule.fnAdjustBcInterval2_avg(false, _paramObj.toTimeObj("19:50"));
  848 + //
  849 + // 10、补进出场例保班次
  850 + schedule.fnCalcuOtherBc();
  851 +
  852 + //-------------------- 输出ganut图上的班次,班型描述 ----------------------//
  853 + // TODO:班型再议
  854 + return {
  855 + 'json':schedule.fnToGanttBcArray(),'bxrcgs':null,
  856 + 'aInternalLpObj': schedule.fnGetLpArray()
  857 + };
  858 +
  859 + },
  860 + /**
  861 + * 导出时刻表配置。
  862 + * @param aInternalLpObj 内部路牌对象列表
  863 + */
  864 + exportDataConfig: function(aInternalLpObj) {
  865 + $('.exportAddXls').off('click');
  866 + $('.exportAddXlsx').off('click');
  867 +
  868 + $('.exportAddXls').on('click', function() {
  869 + var aInfos = {
  870 + "lpObjList": _funCalcuExportData_lpObjList(aInternalLpObj), // 路牌班次信息列表
  871 + "statInfoList": _funCalcuExportData_statInfoList(aInternalLpObj), // 统计项目列表
  872 + "parameterInfoList" : __funCalcuExportData_paramInfoList() // 参数对象
  873 + };
  874 +
  875 + console.log(aInfos);
  876 +
  877 + $(".exportAdd").addClass("disabled");
  878 + $(".exportAddSpan").html("正在导出...");
  879 +
  880 + // 提交
  881 + $.ajax({
  882 + type: 'POST',
  883 + url: "/tidc/exportDTDFile/xls",
  884 + dataType: 'binary',
  885 + contentType: "application/json",
  886 + data: JSON.stringify(aInfos),
  887 + success: function(data){
  888 + Main_v2.downloadFile(data, "application/octet-stream", "时刻表信息.xls");
  889 +
  890 + $(".exportAdd").removeClass("disabled");
  891 + $(".exportAddSpan").html(" 导出数据");
  892 + },
  893 + error: function(xhr, type){
  894 + alert('错误:TODO');
  895 +
  896 + $(".exportAdd").removeClass("disabled");
  897 + $(".exportAddSpan").html(" 导出数据");
  898 + }
  899 + });
  900 + });
  901 +
  902 + $('.exportAddXlsx').on('click', function() {
  903 + var aInfos = {
  904 + "lpObjList": _funCalcuExportData_lpObjList(aInternalLpObj), // 路牌班次信息列表
  905 + "statInfoList": _funCalcuExportData_statInfoList(aInternalLpObj), // 统计项目列表
  906 + "parameterInfoList" : __funCalcuExportData_paramInfoList() // 参数对象
  907 + };
  908 +
  909 + console.log(aInfos);
  910 +
  911 + $(".exportAdd").addClass("disabled");
  912 + $(".exportAddSpan").html("正在导出...");
  913 +
  914 + // 提交
  915 + $.ajax({
  916 + type: 'POST',
  917 + url: "/tidc/exportDTDFile/xlsx",
  918 + dataType: 'binary',
  919 + contentType: "application/json",
  920 + data: JSON.stringify(aInfos),
  921 + success: function(data){
  922 + Main_v2.downloadFile(data, "application/octet-stream", "时刻表信息.xlsx");
  923 +
  924 + $(".exportAdd").removeClass("disabled");
  925 + $(".exportAddSpan").html(" 导出数据");
  926 + },
  927 + error: function(xhr, type){
  928 + alert('错误:TODO');
  929 +
  930 + $(".exportAdd").removeClass("disabled");
  931 + $(".exportAddSpan").html(" 导出数据");
  932 + }
  933 + });
  934 + });
  935 + },
  936 +
  937 + downloadFile: function (data, mimeType, fileName) {
  938 + var success = false;
  939 + var blob = new Blob([data], { type: mimeType });
  940 + try {
  941 + if (navigator.msSaveBlob)
  942 + navigator.msSaveBlob(blob, fileName);
  943 + else {
  944 + // Try using other saveBlob implementations, if available
  945 + var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;
  946 + if (saveBlob === undefined) throw "Not supported";
  947 + saveBlob(blob, fileName);
  948 + }
  949 + success = true;
  950 + } catch (ex) {
  951 + console.log("saveBlob method failed with the following exception:");
  952 + console.log(ex);
  953 + }
  954 +
  955 + if (!success) {
  956 + // Get the blob url creator
  957 + var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
  958 + if (urlCreator) {
  959 + // Try to use a download link
  960 + var link = document.createElement('a');
  961 + if ('download' in link) {
  962 + // Try to simulate a click
  963 + try {
  964 + // Prepare a blob URL
  965 + var url = urlCreator.createObjectURL(blob);
  966 + link.setAttribute('href', url);
  967 +
  968 + // Set the download attribute (Supported in Chrome 14+ / Firefox 20+)
  969 + link.setAttribute("download", fileName);
  970 +
  971 + // Simulate clicking the download link
  972 + var event = document.createEvent('MouseEvents');
  973 + event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
  974 + link.dispatchEvent(event);
  975 + success = true;
  976 +
  977 + } catch (ex) {
  978 + console.log("Download link method with simulated click failed with the following exception:");
  979 + console.log(ex);
  980 + }
  981 + }
  982 +
  983 + if (!success) {
  984 + // Fallback to window.location method
  985 + try {
  986 + // Prepare a blob URL
  987 + // Use application/octet-stream when using window.location to force download
  988 + var url = urlCreator.createObjectURL(blob);
  989 + window.location = url;
  990 + console.log("Download link method with window.location succeeded");
  991 + success = true;
  992 + } catch (ex) {
  993 + console.log("Download link method with window.location failed with the following exception:");
  994 + console.log(ex);
  995 + }
  996 + }
  997 + }
  998 + }
  999 +
  1000 + if (!success) {
  1001 + // Fallback to window.open method
  1002 + console.log("No methods worked for saving the arraybuffer, using last resort window.open");
  1003 + window.open("", '_blank', '');
  1004 + }
  1005 + }
  1006 +
  1007 + };
  1008 +
  1009 +}();
  1010 +
... ...