Commit abd1f204967dae6ead9d2fba8a96dc24b8a2872c

Authored by 徐烜
1 parent 3b2743e1

时刻表v2_2.1

1、新版本,只支持单向进出场线路,不是一次性布局,而是一边判定班次,添加班次,修改间隔,修改周转
2、以上标线开始,从第一个副站班次开始向下生成班次,每生成一圈,调整上标线圈结束后的所有班次
3、分班车次链的结束班次必须是副站方向
4、低谷间隔时以频率加步长的形式拉间隔,高峰间隔使用平均间隔(ceil)
src/main/resources/static/pages/base/timesmodel/add.html
@@ -149,7 +149,10 @@ @@ -149,7 +149,10 @@
149 <input type="radio" class="icheck" name="baseRes" value=1> 班型/人次/车辆 149 <input type="radio" class="icheck" name="baseRes" value=1> 班型/人次/车辆
150 </label> 150 </label>
151 <label> 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 </label> 156 </label>
154 <label> 157 <label>
155 <input type="radio" class="icheck" name="baseRes" value=0> 客流大数据分析 158 <input type="radio" class="icheck" name="baseRes" value=0> 客流大数据分析
src/main/resources/static/pages/base/timesmodel/gantt.html
@@ -181,7 +181,14 @@ @@ -181,7 +181,14 @@
181 <script src="/pages/base/timesmodel/js/v2/strategy/adjust/AdjustTripS4.js"></script> 181 <script src="/pages/base/timesmodel/js/v2/strategy/adjust/AdjustTripS4.js"></script>
182 <script src="/pages/base/timesmodel/js/v2/strategy/StrategyUtils.js"></script> 182 <script src="/pages/base/timesmodel/js/v2/strategy/StrategyUtils.js"></script>
183 <script src="/pages/base/timesmodel/js/v2/main_v2.js"></script> 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 <script src="/pages/base/timesmodel/js/errorinfo.js"></script> 192 <script src="/pages/base/timesmodel/js/errorinfo.js"></script>
186 <script src="/pages/base/timesmodel/js/parameters.js"></script> 193 <script src="/pages/base/timesmodel/js/parameters.js"></script>
187 <script src="/pages/base/timesmodel/js/systemTools.js"></script> 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,7 +322,7 @@ var SKBFormWizard = function() {
322 tempName = 'carnum_temp'; 322 tempName = 'carnum_temp';
323 else if(n==1) 323 else if(n==1)
324 tempName = 'bctype_temp'; 324 tempName = 'bctype_temp';
325 - else if (n==2) 325 + else if (n==2 || n == 3)
326 tempName = 'fcjx_temp'; 326 tempName = 'fcjx_temp';
327 // 2、获参数详情模版html内容. 327 // 2、获参数详情模版html内容.
328 $.get('/pages/base/timesmodel/tepms/'+ tempName + '.html', function(html){ 328 $.get('/pages/base/timesmodel/tepms/'+ tempName + '.html', function(html){
@@ -394,7 +394,7 @@ var SKBFormWizard = function() { @@ -394,7 +394,7 @@ var SKBFormWizard = function() {
394 }else if(n==1) { 394 }else if(n==1) {
395 // 返回参数详情模版. 395 // 返回参数详情模版.
396 return cb && cb ({'forminput':template(tempName,{map:map}),'datadisplay': template(tempName +'config',{map:null})}); 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 var iversion = $('#lineVersionSelect').val(); 399 var iversion = $('#lineVersionSelect').val();
400 $get('/stationroute/all',{'line.id_eq':lineId,'destroy_eq':0, 'versions_eq': iversion},function(result) { 400 $get('/stationroute/all',{'line.id_eq':lineId,'destroy_eq':0, 'versions_eq': iversion},function(result) {
@@ -974,7 +974,7 @@ var SKBFormWizard = function() { @@ -974,7 +974,7 @@ var SKBFormWizard = function() {
974 layer.close(i); 974 layer.close(i);
975 }); 975 });
976 976
977 - } else if (baseRes == 2) { // 发车间隔分析 977 + } else if (baseRes == 2 || baseRes == 3) { // 发车间隔分析
978 // 上下行首末班日期控件 978 // 上下行首末班日期控件
979 $('#startStationFirstTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'}); 979 $('#startStationFirstTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});
980 $('#startStationEndTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'}); 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,7 +321,7 @@ $(&#39;.parambtn&#39;).on(&#39;click&#39;, function() {
321 $.get('/pages/base/timesmodel/paramadd.html', function(m){ 321 $.get('/pages/base/timesmodel/paramadd.html', function(m){
322 $(pjaxContainer).append(m); 322 $(pjaxContainer).append(m);
323 // 规定被选元素要触发的事件。可以使自定义事件(使用 bind() 函数来附加),或者任何标准事件。 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,6 +72,10 @@
72 _paramObj = Main_v2.getFactory().createParameterObj(map, dataMap); 72 _paramObj = Main_v2.getFactory().createParameterObj(map, dataMap);
73 map.clzs = _paramObj.calcuClzx(); 73 map.clzs = _paramObj.calcuClzx();
74 CSMap = getMaxCarAndStopSpace1(map); 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,6 +97,9 @@
93 // TODO:CSMap.maxCar 之后要设定一下的 97 // TODO:CSMap.maxCar 之后要设定一下的
94 data = Main_v2.BXPplaceClassesTime03(_paramObj, CSMap.maxCar); 98 data = Main_v2.BXPplaceClassesTime03(_paramObj, CSMap.maxCar);
95 Main_v2.exportDataConfig(data.aInternalLpObj); 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 }else { 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 +
src/main/resources/static/pages/base/timesmodel/js/v2_2/InternalScheduleObj.js 0 → 100644
  1 +/**
  2 + * v2_2版本的行车计划对象。
  3 + *
  4 + * 本次修正和原来区别,一边生成班次,一边调整班次间隔
  5 + * 1、初始化行车计划基本布局,主要是有几辆车,路牌分布情况(连班,分班,5休2分班),上标线的初始班次列表
  6 + *
  7 + */
  8 +var InternalScheduleObj_v2_2 = (function() {
  9 +
  10 + // 内部utils类
  11 + var _utils = function() {
  12 + return {
  13 + /**
  14 + * 创建班次对象。
  15 + * @param lpObj InternalLpObj路牌对象
  16 + * @param bcType 班次类型(normal等等)
  17 + * @param isUp 是否上行
  18 + * @param fcno 发车顺序号
  19 + * @param fcTimeObj 发车时间对象
  20 + * @param paramObj 参数对象
  21 + * @returns {InternalBcObj}
  22 + */
  23 + createBcObj : function(lpObj, bcType, isUp, fcno, fcTimeObj, paramObj) {
  24 + var _bclc = paramObj.calcuTravelLcNumber(isUp, bcType); // 班次里程
  25 + var _fcsj = fcTimeObj; // 发车时间
  26 + var _bcsj = paramObj.calcuTravelTime(_fcsj, isUp); // 班次历时
  27 + var _arrsj = paramObj.addMinute(_fcsj, _bcsj); // 到达时间
  28 + // 停站时间范围,[最小停站时间,最大停站时间]
  29 + var _stopTimeRange = paramObj.calcuTripLayoverTimeRange(_arrsj, isUp, _bcsj);
  30 + var _stoptime = _stopTimeRange[0]; // 使用最小停站时间
  31 + var _tccid = paramObj.getTTinfoId();
  32 + var _ttinfoid = paramObj.getTTinfoId();
  33 + var _xl = paramObj.getXlId();
  34 + var _qdz = isUp ? paramObj.getUpQdzObj().id : paramObj.getDownQdzObj().id;
  35 + var _zdz = isUp ? paramObj.getUpZdzObj().id : paramObj.getDownZdzObj().id;
  36 +
  37 + if (bcType == "bd") { // 早例保,传过来的发车时间是第一个班次的发车时间
  38 + if (isUp) { // 上行
  39 + _fcsj = paramObj.addMinute(
  40 + _fcsj,
  41 + -(paramObj.getUpOutTime() + paramObj.getLbTime()));
  42 + _bcsj = paramObj.getLbTime();
  43 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  44 + _stoptime = 0;
  45 + } else { // 下行
  46 + _fcsj = paramObj.addMinute(
  47 + _fcsj,
  48 + -(paramObj.getDownOutTime() + paramObj.getLbTime()));
  49 + _bcsj = paramObj.getLbTime();
  50 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  51 + _stoptime = 0;
  52 + }
  53 + } else if (bcType == "lc") { // 晚例保,传过来的发车时间是最后一个班次的到达时间
  54 + if (isUp) { // 上行
  55 + _fcsj = paramObj.addMinute(
  56 + _fcsj,
  57 + paramObj.getUpInTime());
  58 + _bcsj = paramObj.getLbTime();
  59 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  60 + _stoptime = 0;
  61 + } else { // 下行
  62 + _fcsj = paramObj.addMinute(
  63 + _fcsj,
  64 + paramObj.getDownInTime());
  65 + _bcsj = paramObj.getLbTime();
  66 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  67 + _stoptime = 0;
  68 + }
  69 + } else if (bcType == "out") { // 出场,传过来的发车时间是第一个班次的发车时间
  70 + if (isUp) { // 上行
  71 + _fcsj = paramObj.addMinute(
  72 + _fcsj,
  73 + -paramObj.getUpOutTime());
  74 + _bcsj = paramObj.getUpOutTime();
  75 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  76 + _stoptime = 0;
  77 + } else { // 下行
  78 + _fcsj = paramObj.addMinute(
  79 + _fcsj,
  80 + -paramObj.getDownOutTime());
  81 + _bcsj = paramObj.getDownOutTime();
  82 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  83 + _stoptime = 0;
  84 + }
  85 + } else if (bcType == "in") { // 进场,传过来的发车时间是最后一个班次的到达时间
  86 + if (isUp) { // 上行
  87 + _bcsj = paramObj.getUpInTime();
  88 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  89 + _stoptime = 0;
  90 + } else { // 下行
  91 + _bcsj = paramObj.getDownInTime();
  92 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  93 + _stoptime = 0;
  94 + }
  95 + } else if (bcType == "cf") { // 吃饭班次
  96 + // 以13:00为分界,之前的为午饭,之后的为晚饭
  97 + if (fcTimeObj.isBefore(paramObj.toTimeObj("13:00"))) {
  98 + _bcsj = paramObj.fnGetLunchTime();
  99 + } else {
  100 + _bcsj = paramObj.fnGetDinnerTime();
  101 + }
  102 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  103 + _stoptime = 0;
  104 + }
  105 +
  106 + var bcParamObj = {};
  107 + bcParamObj.bcType = bcType; // 班次类型(normal,in_,out, bd, lc, cf等)
  108 + bcParamObj.isUp = isUp; // boolean是否上下行
  109 + bcParamObj.fcno = fcno; // 发车顺序号
  110 + bcParamObj.fcTimeObj = _fcsj; // 发车时间对象
  111 + bcParamObj.bclc = _bclc; // 班次里程
  112 + bcParamObj.bcsj = _bcsj; // 班次历时
  113 + bcParamObj.arrtime = _arrsj; // 到达时间对象
  114 + bcParamObj.stoptime = _stoptime; // 停站时间
  115 + bcParamObj.tccid = _tccid; // 停车场id
  116 + bcParamObj.ttinfoid = _ttinfoid; // 时刻表id
  117 + bcParamObj.xl = _xl; // 线路id
  118 + bcParamObj.qdzid = _qdz; // 起点站id
  119 + bcParamObj.zdzid = _zdz; // 终点站id
  120 +
  121 + return new InternalBcObj(lpObj, bcParamObj);
  122 + },
  123 +
  124 + /**
  125 + * 修正上标线主站方向班次(一圈的结束班次,也是下一圈的开始班次)以及后续说有班次。
  126 + * @param oLp 上标线路牌
  127 + * @param fromFcsj 开始发车时间对象
  128 + * @param fromGroupIndex 开始圈索引
  129 + * @param fromBcIndex 开始班次索引
  130 + * @param isUp 开始班次是上行还是下行
  131 + * @param oParam 参数对象
  132 + */
  133 + modifySBXMasterBc: function(oLp, fromFcsj, fromGroupIndex, fromBcIndex, isUp, oParam) {
  134 + // 清空指定位置班次及后续班次
  135 + oLp.clearBc(fromGroupIndex, fromBcIndex);
  136 + // 初始化上标线,从指定圈索引开始
  137 + oLp.initDataFromTime(fromFcsj, isUp, fromGroupIndex, oParam, _utils);
  138 +
  139 + }
  140 +
  141 + };
  142 + }();
  143 +
  144 + /**
  145 + * 内部行车计划对象。
  146 + * @param oParam 参数封装对象
  147 + * @param aLp 路牌(甘特图用的路牌对象)
  148 + * @constructor
  149 + */
  150 + function InternalScheduleObj(oParam, aLp) {
  151 + // 参数对象和甘特图用路牌数组
  152 + this._oParam = oParam;
  153 + this._aGanttLpArray = aLp;
  154 +
  155 + // 目前这个只支持主站停站
  156 + if (this._oParam.isTwoWayStop()) {
  157 + alert("v2_2版本不支持双向停站类型线路!");
  158 + throw "v2_2版本不支持双向停站类型线路";
  159 + }
  160 +
  161 + console.log("//---------------- v2_2行车计划,初始化1 start ----------------//");
  162 +
  163 + //----------------------- 1、确定上标线的方向,圈的方向 -------------------//
  164 + this._qIsUp = true; // 每一圈是上行开始还是下行开始
  165 +
  166 + // 确定_qIsUp,哪个方向的首班车晚就用哪个
  167 + this._qIsUp = this._oParam.getUpFirstDTimeObj().isBefore(
  168 + this._oParam.getDownFirstDTimeObj()) ? false : true;
  169 + // 上标线开始时间,就是方向的首班车时间
  170 + var st = this._qIsUp ? this._oParam.getUpFirstDTimeObj() : this._oParam.getDownFirstDTimeObj();
  171 + // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向
  172 + var et;
  173 + var et_IsUp;
  174 + if (this._oParam.getUpLastDtimeObj().isBefore(
  175 + this._oParam.getDownLastDTimeObj())) {
  176 + et = this._oParam.getDownLastDTimeObj();
  177 + et_IsUp = false;
  178 + } else {
  179 + et = this._oParam.getUpLastDtimeObj();
  180 + et_IsUp = true;
  181 + }
  182 +
  183 + //------------------------ 2、计算总共有多少圈 ------------------------//
  184 + this._qCount = 0; // 总的圈数
  185 +
  186 + // 以开始时间,结束时间,构造上标线用连班班次发车时间
  187 + var bcFcsjArrays = []; // 班次发车时间对象数组
  188 + var bcArsjArrays = []; // 班次到达时间对象数组
  189 + var isUp = this._qIsUp; // 方向
  190 + var bcCount = 1; // 班次数
  191 +
  192 + var _kssj = st; // 开始时间
  193 + var _bcsj = this._oParam.calcuTravelTime(_kssj, isUp); // 班次历时
  194 + var _arrsj = this._oParam.addMinute(_kssj, _bcsj); // 到达时间
  195 + var _stoptimeRange = this._oParam.calcuTripLayoverTimeRange(_arrsj, isUp, _bcsj);
  196 + var _stoptime = _stoptimeRange[0]; // 最小停站时间
  197 +
  198 + do {
  199 + bcFcsjArrays.push(_kssj);
  200 + bcArsjArrays.push(_arrsj);
  201 +
  202 + _kssj = this._oParam.addMinute(_kssj, _bcsj + _stoptime);
  203 + _bcsj = this._oParam.calcuTravelTime(_kssj, isUp);
  204 + _arrsj = this._oParam.addMinute(_kssj, _bcsj);
  205 + _stoptimeRange = this._oParam.calcuTripLayoverTimeRange(_arrsj, isUp, _bcsj);
  206 + _stoptime = _stoptimeRange[0]; // 最小停站时间
  207 +
  208 + bcCount ++;
  209 + isUp = !isUp;
  210 + } while(_kssj.isBefore(et));
  211 + bcCount--; // 因为先做do,所以总的班次要减1
  212 + //if (bcCount > 0 && bcArsjArrays[bcCount - 1].isAfter(et)) {
  213 + // // 如果最后一个班次的到达时间超过结束时间,也要去除
  214 + // bcFcsjArrays.splice(bcCount - 1, 1);
  215 + // bcArsjArrays.splice(bcCount - 1, 1);
  216 + // bcCount--;
  217 + //}
  218 + var _qCount_p1 = Math.floor(bcCount / 2); // 2个班次一圈
  219 + var _qCount_p2 = bcCount % 2; // 余下的1个班次也算一圈
  220 +
  221 + // 利用连班数组计算圈数
  222 + this._qCount = 1; // 前面加1圈,补中标线的班次
  223 + this._qCount += _qCount_p1;
  224 + this._qCount += _qCount_p2;
  225 +
  226 + // 计算最后是不是还要补一圈
  227 + if (this._qCount > 1) { // 总的圈数就1圈,没必要加了(其实是不可能的,除非参数里问题)
  228 + if (_qCount_p2 == 0) { // 没有余下班次,整数圈数
  229 + // 最后一个班次的方向一定和开始的方向相反,如:上-下,上-下,上-下,一共三圈,最后一个班次为下行
  230 + // 判定最后一个班次的方向和上标线判定结束时间的班次方向是否一致
  231 + if (!this._qIsUp == et_IsUp) {
  232 + // 一致不用加圈数
  233 + } else {
  234 + // 不一致需要加圈补最后一个结束时间班次
  235 + this._qCount ++;
  236 + }
  237 + } else {
  238 + // 有余下的圈数,最后要不补的班次不管上行,下行都在这一圈里
  239 + // 不需要在补圈数了
  240 + }
  241 + }
  242 +
  243 + //------------------------ 3、根据路牌数,圈数创建路牌对象 ----------------------//
  244 + this._internalLpArray = []; // 内部路牌(InternalLpObj对象)数组
  245 +
  246 + // 创建内部的路牌数组
  247 + var i;
  248 + for (i = 0; i < this._aGanttLpArray.length; i++) {
  249 + this._internalLpArray.push(
  250 + new InternalLpObj(this._aGanttLpArray[i], this._qCount, this._qIsUp));
  251 + }
  252 +
  253 + // 初始化上标线,从第1圈开始
  254 + this._internalLpArray[0].initDataFromTimeToTime(
  255 + bcFcsjArrays[0], et, this._qIsUp, 1, this._oParam, _utils);
  256 +
  257 + //------------------------ 4、以上标线为基础,计算各种班型工时对应的圈数、班次数 -----------------------//
  258 + this._aBxDesc = [ // 各种班型描述(班型名称,平均工时,平均需要的班次数,平均工时)
  259 + {'sType':'六工一休', 'fHoursV':6.66, 'fBcCount': 0, 'fAverTime': 0},
  260 + {'sType':'五工一休', 'fHoursV':6.85, 'fBcCount': 0, 'fAverTime': 0},
  261 + {'sType':'四工一休', 'fHoursV':7.14, 'fBcCount': 0, 'fAverTime': 0},
  262 + {'sType':'三工一休', 'fHoursV':7.61, 'fBcCount': 0, 'fAverTime': 0},
  263 + {'sType':'二工一休', 'fHoursV':8.57, 'fBcCount': 0, 'fAverTime': 0},
  264 + {'sType':'一工一休', 'fHoursV':11.42, 'fBcCount': 0, 'fAverTime': 0},
  265 + {'sType':'五工二休', 'fHoursV':7.99, 'fBcCount': 0, 'fAverTime': 0},
  266 + {'sType':'无工休', 'fHoursV':5.43, 'fBcCount': 0, 'fAverTime': 0}
  267 + ];
  268 +
  269 + var aBcArray = this._internalLpArray[0].getBcArray();
  270 + aBcArray[0].fnSetIsFirstBc(true); // 设置首班班次标识
  271 +
  272 + if (aBcArray.length % 2 != 0) { // 不能整除2,去除一个班次计算
  273 + aBcArray.splice(aBcArray.length - 1, 1);
  274 + }
  275 +
  276 + var iLTime = this._oParam.fnGetLunchTime(); // 午饭吃饭时间
  277 + var iDTime = this._oParam.fnGetDinnerTime(); // 晚饭吃饭时间
  278 + var iOutTime = this._qIsUp ? this._oParam.getUpOutTime() : this._oParam.getDownOutTime(); // 出场时间
  279 + var iInTime = this._qIsUp ? this._oParam.getDownInTime() : this._oParam.getUpInTime(); // 进场时间
  280 + var iBTime = this._oParam.getLbTime(); // 例保时间
  281 +
  282 + var sum = 0; // 总班次时间
  283 + for (i = 0; i < aBcArray.length; i++) {
  284 + sum += aBcArray[i].getBcTime() + aBcArray[i].getStopTime();
  285 + }
  286 + sum += iLTime; // 加午饭时间
  287 + sum += iDTime; // 加晚饭时间
  288 + for (i = 0; i < this._aBxDesc.length; i++) {
  289 + this._aBxDesc[i].fAverTime = sum / (aBcArray.length / 2); // 平均周转时间不算进出场,例保时间
  290 +
  291 + // 计算5休2的班次数(双进出场,4个例保)
  292 + if (i == 6) {
  293 + this._aBxDesc[i].fQCount =
  294 + (this._aBxDesc[i].fHoursV * 60 - iOutTime * 2 - iInTime * 2 - iBTime * 4) /
  295 + this._aBxDesc[i].fAverTime;
  296 + this._aBxDesc[i].fBcCount = this._aBxDesc[i].fQCount * 2;
  297 + } else { // 进出场,2个例保
  298 + this._aBxDesc[i].fQCount =
  299 + (this._aBxDesc[i].fHoursV * 60 - iOutTime - iInTime - iBTime * 2) /
  300 + this._aBxDesc[i].fAverTime;
  301 + this._aBxDesc[i].fBcCount = this._aBxDesc[i].fQCount * 2;
  302 + }
  303 + }
  304 +
  305 + // TODO:v2版本里的开头和结尾的标记班次暂时不在v2_2版本里添加
  306 +
  307 + console.log("上行首班车时间:" + this._oParam.getUpFirstDTimeObj().format("HH:mm") +
  308 + "上行末班车时间:" + this._oParam.getUpLastDtimeObj().format("HH:mm"));
  309 + console.log("下行首班车时间:" + this._oParam.getDownFirstDTimeObj().format("HH:mm") +
  310 + "下行末班车时间:" + this._oParam.getDownLastDTimeObj().format("HH:mm"));
  311 + console.log("总共计算的圈数:" + this._qCount);
  312 + console.log("圈的方向isUP:" + this._qIsUp);
  313 + console.log("班型描述(以下):");
  314 + console.log(this._aBxDesc);
  315 + console.log("所有路牌间隔描述(以下):");
  316 + for (i = 0; i < this._internalLpArray.length; i++) {
  317 + console.log(this._internalLpArray[i]._$_aVerticalIntervalTime);
  318 + }
  319 + console.log("//---------------- v2_2行车计划,初始化1 end ----------------//");
  320 +
  321 + console.log("//---------------- v2_2行车计划,初始化2 start ----------------//");
  322 +
  323 + //--------------------- 1、计算分班连班班型车辆分布数 --------------------//
  324 + this._iBx_lb_lpcount = 0; // 连班路牌数
  325 + this._iBx_5_2_fb_lpcount = 0; // 5休2分班路牌数
  326 + this._iBx_other_fb_lpcount = 0; // 其他分班路牌数
  327 +
  328 + // 总共车辆数(高峰最大车辆数)
  329 + var iCls = InternalScheduleObj.calcuClzx(this._oParam);
  330 + // 低谷最少配车(连班车数量)
  331 + var iDgminpc = Math.round(this._oParam.calcuTroughZzsj() / this._oParam.getTroughMaxFcjx());
  332 + // 加班车路牌数(做5休2的路牌数)
  333 + var i_5_2_lpes = this._oParam.getJBLpes();
  334 +
  335 + // 做些简单的验证
  336 + if (iCls < iDgminpc) {
  337 + alert("总配车数小于低谷最小配车");
  338 + throw "总配车数小于低谷最小配车";
  339 + }
  340 +
  341 + if (iDgminpc < 2) {
  342 + // alert("连班路牌小于2,办不到啊");
  343 + // throw "连班路牌小于2,办不到啊";
  344 + console.log("连班路牌小于2,则5休2之外的车辆数则为连班车辆数");
  345 + iDgminpc = iCls - i_5_2_lpes;
  346 + }
  347 + if (iCls - iDgminpc < i_5_2_lpes) {
  348 + // alert("总分班路牌数小于加班路牌数");
  349 + // throw "总分班路牌数小于加班路牌数";
  350 + console.log("总分班路牌数小于加班路牌数,则忽略其他分班路牌数");
  351 + iDgminpc = iCls - i_5_2_lpes;
  352 + }
  353 +
  354 + //// 修正连班路牌数,班次间隔大于20的,加1,直至班次间隔小于20
  355 + //while(_paramObj.calcuPeakZzsj() / iDgminpc > 20) {
  356 + // iDgminpc ++;
  357 + //}
  358 + this._iBx_lb_lpcount = iDgminpc;
  359 +
  360 + this._iBx_5_2_fb_lpcount = i_5_2_lpes;
  361 + this._iBx_other_fb_lpcount = iCls - this._iBx_lb_lpcount - i_5_2_lpes;
  362 +
  363 + //------------------------ 2、利用间隔法计算连班路牌分布 --------------------//
  364 + var j;
  365 + var iC1 = Math.floor(this._internalLpArray.length / this._iBx_lb_lpcount);
  366 + var iC2 = this._internalLpArray.length % this._iBx_lb_lpcount;
  367 + var iLpIndex;
  368 +
  369 + for (i = 0; i < this._iBx_lb_lpcount - iC2; i++) {
  370 + iLpIndex = i * iC1;
  371 + this._internalLpArray[iLpIndex].setBxLb(true);
  372 + this._internalLpArray[iLpIndex].setBxDesc("连班");
  373 + }
  374 + for (j = 0; j < iC2; j++) {
  375 + iLpIndex = i * iC1 + j * (iC1 + 1);
  376 + this._internalLpArray[iLpIndex].setBxLb(true);
  377 + this._internalLpArray[iLpIndex].setBxDesc("连班");
  378 + }
  379 +
  380 + //------------------------ 3、利用间隔法计算分班班型路牌分布 --------------------//
  381 + // 获取分班路牌索引
  382 + var aNotLbIndexes = [];
  383 + for (i = 0; i < this._internalLpArray.length; i++) {
  384 + if (!this._internalLpArray[i].isBxLb()) {
  385 + aNotLbIndexes.push(i);
  386 + }
  387 + }
  388 + // 先5休2分班
  389 + iC1 = Math.floor(aNotLbIndexes.length / this._iBx_5_2_fb_lpcount);
  390 + iC2 = aNotLbIndexes.length % this._iBx_5_2_fb_lpcount;
  391 +
  392 + for (i = 0; i < this._iBx_5_2_fb_lpcount - iC2; i++) {
  393 + iLpIndex = aNotLbIndexes[i * iC1];
  394 + this._internalLpArray[iLpIndex].setBxLb(false);
  395 + this._internalLpArray[iLpIndex].setBxFb(true);
  396 + this._internalLpArray[iLpIndex].setBxFb5_2(true);
  397 + this._internalLpArray[iLpIndex].setBxDesc("5休2分班");
  398 + }
  399 + for (i = 0; i < iC2; i++) {
  400 + iLpIndex = aNotLbIndexes[this._iBx_5_2_fb_lpcount - iC2 + i * (iC1 + 1)];
  401 + this._internalLpArray[iLpIndex].setBxLb(false);
  402 + this._internalLpArray[iLpIndex].setBxFb(true);
  403 + this._internalLpArray[iLpIndex].setBxFb5_2(true);
  404 + this._internalLpArray[iLpIndex].setBxDesc("5休2分班");
  405 + }
  406 + // 其他分班
  407 + for (i = 0; i < aNotLbIndexes.length; i++) {
  408 + iLpIndex = aNotLbIndexes[i];
  409 + if (!this._internalLpArray[iLpIndex].isBxFb5_2()) {
  410 + this._internalLpArray[iLpIndex].setBxLb(false);
  411 + this._internalLpArray[iLpIndex].setBxFb(true);
  412 + this._internalLpArray[iLpIndex].setBxFb5_2(false);
  413 + this._internalLpArray[iLpIndex].setBxDesc("其他分班");
  414 + }
  415 + }
  416 +
  417 + console.log("高峰周转时间:" + this._oParam.calcuPeakZzsj());
  418 + console.log("连班路牌数:" + this._iBx_lb_lpcount);
  419 + console.log("5休2分班路牌数:" + this._iBx_5_2_fb_lpcount);
  420 + console.log("其他分班路牌数:" + this._iBx_other_fb_lpcount);
  421 + var aLbIndexes = [];
  422 + for (i = 0; i < this._internalLpArray.length; i++) {
  423 + if (this._internalLpArray[i].isBxLb()) {
  424 + aLbIndexes.push(i);
  425 + }
  426 + }
  427 + console.log("连班路牌indexes=" + aLbIndexes);
  428 + var a_5_2_fbIndexes = [];
  429 + for (i = 0; i < this._internalLpArray.length; i++) {
  430 + if (this._internalLpArray[i].isBxFb() && this._internalLpArray[i].isBxFb5_2()) {
  431 + a_5_2_fbIndexes.push(i);
  432 + }
  433 + }
  434 + console.log("5休2分班路牌indexes=" + a_5_2_fbIndexes);
  435 + var a_other_fbIndexes = [];
  436 + for (i = 0; i < this._internalLpArray.length; i++) {
  437 + if (this._internalLpArray[i].isBxFb() && !this._internalLpArray[i].isBxFb5_2()) {
  438 + a_other_fbIndexes.push(i);
  439 + }
  440 + }
  441 + console.log("其他分班路牌indexes=" + a_other_fbIndexes);
  442 +
  443 + console.log("//---------------- v2_2行车计划,初始化2 end ----------------//");
  444 +
  445 + console.log("//---------------- v2_3行车计划,初始化3 start ----------------//");
  446 +
  447 + // 计算上标线早高峰时间段里的主站方向班次,如果有多个,取后面一个,如果没有报错
  448 + var bMasterDir = this._oParam.isUpOneWayStop(); // 主站班次方向
  449 + var aMasterBcIndex = this._internalLpArray[0].fnFindBcWithTimeRange( // 在早高峰范围内的主站班次
  450 + this._oParam.getMPeakStartTimeObj(),
  451 + this._oParam.getMPeakEndTimeObj(),
  452 + bMasterDir
  453 + );
  454 + var oMasterBc = undefined;
  455 + var iMasterGroupIndex = undefined;
  456 + var iMasterBcIndex = undefined;
  457 +
  458 + var bSlaveDir = !this._oParam.isUpOneWayStop(); // 副站班次方向
  459 + var aSlaveBcIndex = this._internalLpArray[0].fnFindBcWithTimeRange( // 在早高峰范围内的副站班次
  460 + this._oParam.getMPeakStartTimeObj(),
  461 + this._oParam.getMPeakEndTimeObj(),
  462 + bSlaveDir
  463 + );
  464 + var oSlaveBc = undefined;
  465 + var iSlaveGroupIndex = undefined;
  466 + var iSlaveBcIndex = undefined;
  467 +
  468 + // 由于不同线路的周转时间不一样,可能有的方向不在高峰区间内,但是必定有一个方向有
  469 + // 我们需要找一个副站班次,一个主站班次,副站班次必须在主站前面
  470 + // 如果主站是上标线第一个班次,则不管副站班次了,但是一般副站班次首班车时间晚于主站班次首班车时间,上标线第一个班次一般是副站班次
  471 + if (aMasterBcIndex.length == 0 && aSlaveBcIndex == 0) {
  472 + alert("上标线在早高峰区间内没找到主站或副站班次,这是不可能的!");
  473 + throw "上标线在早高峰区间内没找到主站或副站班次,这是不可能的!";
  474 + } else if (aMasterBcIndex.length > 0) { // 有主站班次,取最后一个班次,然后尝试取前面一个副站班次
  475 + oMasterBc = aMasterBcIndex[aMasterBcIndex.length - 1]["oBc"]; // 取最后一个班次(length - 1)
  476 + iMasterGroupIndex = aMasterBcIndex[aMasterBcIndex.length - 1]["iGroupIndex"];
  477 + iMasterBcIndex = aMasterBcIndex[aMasterBcIndex.length - 1]["iBcIndex"];
  478 +
  479 + oSlaveBc = this._internalLpArray[0].getBc( // 尝试获取前面一个副站班次,可能不存在
  480 + iMasterBcIndex == 0 ? iMasterGroupIndex - 1 : iMasterGroupIndex,
  481 + iMasterBcIndex == 0 ? 1 : 0
  482 + );
  483 + if (oSlaveBc) {
  484 + iSlaveGroupIndex = iMasterBcIndex == 0 ? iMasterGroupIndex - 1 : iMasterGroupIndex;
  485 + iSlaveBcIndex = iMasterBcIndex == 0 ? 1 : 0;
  486 + } else {
  487 + oSlaveBc = undefined;
  488 + }
  489 +
  490 + } else if (aSlaveBcIndex.length > 0) { // 没有主站班次,有副站班次,取最后一个班次,然后取后面一个主站班次
  491 + oSlaveBc = aSlaveBcIndex[aSlaveBcIndex.length - 1]["oBc"];
  492 + iSlaveGroupIndex = aSlaveBcIndex[aSlaveBcIndex.length - 1]["iGroupIndex"];
  493 + iSlaveBcIndex = aSlaveBcIndex[aSlaveBcIndex.length - 1]["iBcIndex"];
  494 +
  495 + oMasterBc = this._internalLpArray[0].getBc(
  496 + iSlaveBcIndex == 0 ? iSlaveGroupIndex : iSlaveGroupIndex + 1,
  497 + iSlaveBcIndex == 0 ? 1 : 0
  498 + );
  499 + iMasterGroupIndex = iSlaveBcIndex == 0 ? iSlaveGroupIndex : iSlaveGroupIndex + 1;
  500 + iMasterBcIndex = iSlaveBcIndex == 0 ? 1 : 0;
  501 + }
  502 +
  503 + console.log("早高峰副站方向(start)班次=" + (oSlaveBc ? oSlaveBc.getFcTimeObj().format("HH:mm") : "未找到"));
  504 + console.log("早高峰副站方向(start)班次圈索引=" + (oSlaveBc ? iSlaveGroupIndex : "未找到"));
  505 + console.log("早高峰副站方向(start)班次索引=" + (oSlaveBc ? iSlaveBcIndex : "未找到"));
  506 + console.log("早高峰主站方向(start)班次=" + (oMasterBc ? oMasterBc.getFcTimeObj().format("HH:mm") : "未找到"));
  507 + console.log("早高峰主站方向(start)班次圈索引=" + (oMasterBc ? iMasterGroupIndex : "未找到"));
  508 + console.log("早高峰主站方向(start)班次索引=" + (oMasterBc ? iMasterBcIndex : "未找到"));
  509 +
  510 + this._oMPeakMasterBc = oMasterBc; // 早高峰主站方向班次
  511 + this._iMPeakMasterBcGroupIndex = iMasterGroupIndex; // 早高峰主站方向圈索引
  512 + this._iMPeakMasterBcIndex = iMasterBcIndex; // 早高峰主站方向班次索引
  513 +
  514 + // 初始化上标线副站班次
  515 + var oPreBc; // 上一个班次(从上标线副站班次开始)
  516 + var oNextBc; // 计算的下一个班次
  517 + var oNextBcFcTime; // 下一个班次的发车时间
  518 + var aBcInterval = []; // 班次间隔数组
  519 + var oBcInterval; // 班次间隔对象
  520 + var iNextBcInterval; // 下一个班次发车间隔
  521 +
  522 + // 当初始化完一圈的副站班次后,最后一个班次是下一圈的上标线副站班次(一圈的周转结束班次),需要调整时间及其前一个主站班次的时间
  523 + var _modifyTimeNextGroupIndex; // 上标线下一圈索引
  524 + var _modifyTimeNextBcIndex; // 上标线下一圈班次索引
  525 + var _modifyBc; // 上标线下一个圈的班次
  526 + var _modifyPreBc; // 上标线下一个圈班次的前一个班次
  527 + var _modifyTime; // 上标线下一个圈班次的前一个班次的调整时间
  528 +
  529 + if (oSlaveBc) {
  530 + aBcInterval = this._$fnGetBcInterval(iSlaveGroupIndex, iSlaveBcIndex, 3);
  531 + oPreBc = this._internalLpArray[0].getBc(iSlaveGroupIndex, iSlaveBcIndex);
  532 + for (i = 1; i < this._internalLpArray.length; i++) {
  533 + oBcInterval = aBcInterval[i - 1];
  534 + if (oBcInterval.hasBc) { // 当前路牌指定圈指定班次索引有班次
  535 + iNextBcInterval = oBcInterval.iFcInterval;
  536 + oNextBcFcTime = this._oParam.addMinute(oPreBc.getFcTimeObj(), iNextBcInterval);
  537 + this._internalLpArray[i].fnSetVerticalIntervalTime(iSlaveGroupIndex, iSlaveBcIndex, iNextBcInterval);
  538 +
  539 + oNextBc = _utils.createBcObj(
  540 + this._internalLpArray[i],
  541 + "normal",
  542 + !this._oParam.isUpOneWayStop(),
  543 + 1,
  544 + oNextBcFcTime,
  545 + this._oParam);
  546 +
  547 + this._internalLpArray[i].setBc(iSlaveGroupIndex, iSlaveBcIndex, oNextBc);
  548 +
  549 + oPreBc = oNextBc;
  550 + }
  551 + }
  552 +
  553 + // 修正上标线副站方向班次(一圈的结束班次,也是下一圈的开始班次)以及后续所有班次
  554 + oBcInterval = aBcInterval[i - 1];
  555 + iNextBcInterval = oBcInterval.iFcInterval;
  556 + _modifyTimeNextGroupIndex = iSlaveGroupIndex + 1;
  557 + _modifyTimeNextBcIndex = iSlaveBcIndex;
  558 +
  559 + _utils.modifySBXMasterBc(
  560 + this._internalLpArray[0],
  561 + this._oParam.addMinute(oPreBc.getFcTimeObj(), iNextBcInterval),
  562 + iSlaveGroupIndex + 1,
  563 + iSlaveBcIndex,
  564 + oPreBc.isUp(),
  565 + this._oParam
  566 + );
  567 +
  568 + // 调整上标线副站班次一圈后的前一个主站班次时间
  569 + _modifyBc = this._internalLpArray[0].getBc(_modifyTimeNextGroupIndex, _modifyTimeNextBcIndex);
  570 + if (_modifyBc) {
  571 + this._internalLpArray[0].fnSetVerticalIntervalTime(_modifyTimeNextGroupIndex, _modifyTimeNextBcIndex, iNextBcInterval);
  572 +
  573 + _modifyPreBc = this._internalLpArray[0].getPreBc(_modifyBc);
  574 + _modifyTime = _modifyBc.getFcTimeObj().diff(_modifyPreBc.getArrTimeObj(), "m") - 1; // 主站到副站停站使用1分钟
  575 + // 修改发车时间,到达时间,不改行驶时间
  576 + _modifyPreBc.getFcTimeObj().add(_modifyTime, "m");
  577 + _modifyPreBc.getArrTimeObj().add(_modifyTime, "m");
  578 +
  579 + }
  580 +
  581 + }
  582 +
  583 + // TODO:补充中标线班次,这里假设,前一半圈就是中标线,以后再精细处理
  584 + // 中标线开始时间,早的首班车时间,和上标线的开始时间方向相反
  585 + var oSt = !this._qIsUp ? this._oParam.getUpFirstDTimeObj() : this._oParam.getDownFirstDTimeObj();
  586 + var iStRuntime; // 中标线方向班次行驶时间(使用低谷)
  587 + if (!this._qIsUp) { // 上行
  588 + if (this._oParam.isTroughBc(oSt)) {
  589 + iStRuntime = this._oParam.getUpTroughTime();
  590 + } else {
  591 + iStRuntime = this._oParam.getUpMPeakTime();
  592 + }
  593 + } else { // 下行
  594 + if (this._oParam.isTroughBc(oSt)) {
  595 + iStRuntime = this._oParam.getDownTroughTime();
  596 + } else {
  597 + iStRuntime = this._oParam.getDownMPeakTime();
  598 + }
  599 + }
  600 +
  601 + var oSLp;
  602 + var oSBc;
  603 + var oSEmuBcFcTime; // 模拟班次发车时间
  604 + var iTimeDiff;
  605 + var iTempTime;
  606 + var iSModifyLpIndex; // 中标线对应路牌索引
  607 + for (i = 1; i < this._internalLpArray.length; i++) {
  608 + oSLp = this._internalLpArray[i];
  609 + oSBc = oSLp.getBc(1, 0); // 第一圈第一个班次
  610 + if (!oSBc) { // 可能没有,跳过
  611 + continue;
  612 + }
  613 + oSEmuBcFcTime = this._oParam.addMinute(
  614 + oSBc.getFcTimeObj(),
  615 + -(iStRuntime + 1)
  616 + );
  617 + iTempTime = oSEmuBcFcTime.diff(oSt, "m");
  618 + if (iTimeDiff == undefined) {
  619 + iTimeDiff = iTempTime;
  620 + iSModifyLpIndex = i;
  621 + } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff) && oSEmuBcFcTime.isAfter(oSt)) {
  622 + iTimeDiff = iTempTime;
  623 + iSModifyLpIndex = i;
  624 + }
  625 + }
  626 +
  627 + // 添加上标线头班次(分班连班都可能)
  628 + this._internalLpArray[iSModifyLpIndex].setBc(
  629 + 0, 1,
  630 + _utils.createBcObj(
  631 + this._internalLpArray[iSModifyLpIndex],
  632 + "normal",
  633 + !this._qIsUp,
  634 + 1,
  635 + oSt,
  636 + this._oParam)
  637 + );
  638 +
  639 + // 从当前班次开始,如果是低谷,隔开方向加班次,如果是高峰,都加班次
  640 + var iSInverval = Math.ceil((this._oParam.getMPeakMinFcjx() + this._oParam.getMPeakMaxFcjx()) / 2);
  641 + for (i = iSModifyLpIndex + 1; i < this._internalLpArray.length; i++) {
  642 + oSLp = this._internalLpArray[i];
  643 + oSEmuBcFcTime = this._oParam.addMinute(oSt, iSInverval * (i - iSModifyLpIndex));
  644 + if (this._oParam.isMPeakBc(oSEmuBcFcTime)) { // 高峰
  645 + if (!this._qIsUp) { // 上行
  646 + iStRuntime = this._oParam.getUpMPeakTime();
  647 + } else { // 下行
  648 + iStRuntime = this._oParam.getDownMPeakTime();
  649 + }
  650 + oSBc = oSLp.getBc(1, 0); // 第一圈第一个班次
  651 + oSLp.setBc(
  652 + 0, 1,
  653 + _utils.createBcObj(
  654 + oSLp,
  655 + "normal",
  656 + !this._qIsUp,
  657 + 1,
  658 + this._oParam.addMinute(oSBc.getFcTimeObj(), -(iStRuntime + 1)),
  659 + this._oParam)
  660 + );
  661 + } else { // 低谷隔开出班次
  662 + if (!this._qIsUp) { // 上行
  663 + iStRuntime = this._oParam.getUpTroughTime();
  664 + } else { // 下行
  665 + iStRuntime = this._oParam.getDownTroughTime();
  666 + }
  667 +
  668 + if (!this._internalLpArray[i - 1].getBc(0, 1)) {
  669 + // 上一个路牌没有班次,添加
  670 + oSBc = oSLp.getBc(1, 0); // 第一圈第一个班次
  671 + oSLp.setBc(
  672 + 0, 1,
  673 + _utils.createBcObj(
  674 + oSLp,
  675 + "normal",
  676 + !this._qIsUp,
  677 + 1,
  678 + this._oParam.addMinute(oSBc.getFcTimeObj(), -(iStRuntime + 1)),
  679 + this._oParam)
  680 + );
  681 +
  682 + // 如果生成的班次行驶时间不足,删除这个班次
  683 + if (oSLp.getBc(1, 0).getFcTimeObj().isBefore(oSLp.getBc(0, 1).getArrTimeObj())) {
  684 + oSLp.getGroup(0).setBc1(undefined);
  685 + oSLp.getGroup(0).setBc2(undefined);
  686 + }
  687 + }
  688 + }
  689 + }
  690 +
  691 + console.log("中标线路牌索引=" + iSModifyLpIndex);
  692 +
  693 + console.log("//---------------- v2_3行车计划,初始化3 end ----------------//");
  694 + }
  695 +
  696 + //------------------------- 核心业务方法 -----------------------//
  697 +
  698 + /**
  699 + * 核型方法,判定班型班次。
  700 + * 主要判定是否需要添加班次(5休2,连班,其他分班班型)。
  701 + * @param oPreBc 上一个班次
  702 + * @param iPreLpIndex 上一个班次路牌索引
  703 + * @param iCurrentLpIndex 当前路牌索引
  704 + * @param iGroupIndex 圈索引
  705 + * @param iBcIndex 班次索引
  706 + * @private
  707 + */
  708 + InternalScheduleObj.prototype._$fnDecideBxBc = function(
  709 + oPreBc, iPreLpIndex,
  710 + iCurrentLpIndex,
  711 + iGroupIndex, iBcIndex) {
  712 +
  713 + var oCurrentLp = this._internalLpArray[iCurrentLpIndex]; // 当前路牌
  714 + var oLpPreBc; // 当前路牌前一个班次
  715 +
  716 + var iBxBcount; // 分班班型的可能班次数
  717 +
  718 + if (oCurrentLp.isBxFb()) { // 分班
  719 + // 关联的因素
  720 + // 1、当前班次方向
  721 + // 2、上一个班次情况
  722 + // 3、同路牌前一个班次情况
  723 + // 4、分班路牌工时限制
  724 +
  725 +
  726 + if (oCurrentLp.isBxFb5_2()) { // 5休2分班
  727 + // 大致计算5休2班型班次数
  728 + iBxBcount = this._aBxDesc[6].fBcCount;
  729 + if (iBxBcount - Math.floor(iBxBcount) > 0.7) {
  730 + iBxBcount = Math.floor(iBxBcount) + 1;
  731 + } else {
  732 + iBxBcount = Math.floor(iBxBcount);
  733 + }
  734 +
  735 + // 计算可能的5休2班次时间,供下一步判定
  736 + var oNext5_2_bc_fctime_m = undefined; // 上午车次链参考班次时间
  737 + var oNext5_2_bc_fctime_e = undefined; // 下午车次链参考班次时间
  738 + if (oPreBc.getFcTimeObj().isBefore(this._oParam.toTimeObj("12:00"))) { // 上午车次链
  739 + oNext5_2_bc_fctime_m = this._oParam.addMinute(
  740 + oPreBc.getFcTimeObj(),
  741 + Math.ceil((this._oParam.getMPeakMinFcjx() + this._oParam.getMPeakMaxFcjx()) / 2)
  742 + );
  743 + } else { // 下午车次链
  744 + oNext5_2_bc_fctime_e = this._oParam.addMinute(
  745 + oPreBc.getFcTimeObj(),
  746 + Math.ceil((this._oParam.getEPeakMinFcjx() + this._oParam.getEPeakMaxFcjx()) / 2)
  747 + );
  748 + }
  749 +
  750 + // 先处理上午车次链
  751 + if (oNext5_2_bc_fctime_m) {
  752 + if (oNext5_2_bc_fctime_m.isBefore(this._oParam.getMPeakStartTimeObj())) {
  753 + // 5休2班型第一个班次,如果在早高峰开始前低谷,不添加
  754 + return false;
  755 + } else if (!oNext5_2_bc_fctime_m.isAfter(this._oParam.getMPeakEndTimeObj())) {
  756 + // 早高峰期间,添加
  757 + return true;
  758 + } else {
  759 + // 早高峰之后低谷到12:00之间
  760 +
  761 + // 当前路牌的前一个班次
  762 + oLpPreBc = oCurrentLp.getBc(iBcIndex == 0 ? iGroupIndex - 1 : iGroupIndex, iBcIndex == 0 ? 1 : 0);
  763 + if (oCurrentLp.getBcArray().length > 0 && (!oLpPreBc)) {
  764 + // 不存在当前路牌的前一个班次,说明车次链已经结束了,不添加
  765 + return false;
  766 + } else {
  767 + if (oCurrentLp.getBcArray().length < Math.ceil(iBxBcount / 2)) {
  768 + // 如果总班次数比iBxBcount的一半的班次(ceil)少,加班次
  769 + return true;
  770 + } else if (oLpPreBc.isUp() == this._oParam.isUpOneWayStop()) {
  771 + // 超过一半的班次,判定当前路牌前一个班次是否主站班次,说明当前班次是副站
  772 + // 作为分班单向进出场的车次链最后一个班次必须副站(因为要抽车),必须添加班次
  773 + return true;
  774 + } else {
  775 + return false;
  776 + }
  777 + }
  778 + }
  779 + }
  780 +
  781 + // 再处理下午车次链
  782 + if (oNext5_2_bc_fctime_e) {
  783 + if (oNext5_2_bc_fctime_e.isBefore(this._oParam.getEPeakStartTimeObj())) {
  784 + // 5休2班型第一个班次,如果在晚高峰开始前低谷,不添加
  785 + return false;
  786 + } else if (!oNext5_2_bc_fctime_e.isAfter(this._oParam.getEPeakEndTimeObj())) {
  787 + // 晚高峰期间,添加
  788 + return true;
  789 + } else {
  790 + // 晚高峰之后低谷
  791 +
  792 + // 当前路牌的前一个班次
  793 + oLpPreBc = oCurrentLp.getBc(iBcIndex == 0 ? iGroupIndex - 1 : iGroupIndex, iBcIndex == 0 ? 1 : 0);
  794 + if (oCurrentLp.getBcArray().length > 0 && (!oLpPreBc)) {
  795 + // 不存在当前路牌的前一个班次,说明车次链已经结束了,不添加
  796 + return false;
  797 + } else {
  798 + if (oCurrentLp.getBcArray().length < iBxBcount) {
  799 + // 如果总班次数比iBxBcount少,加班次
  800 + return true;
  801 + } else if (oLpPreBc.isUp() == this._oParam.isUpOneWayStop()) {
  802 + // 超过一半的班次,判定当前路牌前一个班次是否主站班次,说明当前班次是副站
  803 + // 作为分班单向进出场的车次链最后一个班次必须副站(因为要抽车),必须添加班次
  804 + return true;
  805 + } else {
  806 + return false;
  807 + }
  808 + }
  809 + }
  810 + }
  811 +
  812 + } else { // 其他分班
  813 + // TODO:根据上标线的首班时间确定班型,小于05:59的做一休一,否则做二休一
  814 + var oSt = this._qIsUp ? this._oParam.getUpFirstDTimeObj() : this._oParam.getDownFirstDTimeObj();
  815 + var iBxIndex = 4;
  816 + if (oSt.isBefore(this._oParam.toTimeObj("05:59"))) {
  817 + iBxIndex = 5;
  818 + }
  819 + // 大致计算做其他班型所需的班次数
  820 + var iQBcount = this._aBxDesc[iBxIndex].fQCount;
  821 + iBxBcount = Math.round(iQBcount) * 2;
  822 +
  823 + // 计算可能的其他分班当前班次时间,供下一步判定
  824 + var oNext_other_bc_fctime_m = undefined; // 上午车次链参考班次时间
  825 + var oNext_other_bc_fctime_e = undefined; // 下午车次链参考班次时间
  826 + if (oPreBc.getFcTimeObj().isBefore(this._oParam.toTimeObj("14:00"))) { // 上午车次链
  827 + oNext_other_bc_fctime_m = this._oParam.addMinute(
  828 + oPreBc.getFcTimeObj(),
  829 + Math.ceil((this._oParam.getMPeakMinFcjx() + this._oParam.getMPeakMaxFcjx()) / 2)
  830 + );
  831 + } else { // 下午车次链
  832 + oNext_other_bc_fctime_e = this._oParam.addMinute(
  833 + oPreBc.getFcTimeObj(),
  834 + Math.ceil((this._oParam.getEPeakMinFcjx() + this._oParam.getEPeakMaxFcjx()) / 2)
  835 + );
  836 + }
  837 +
  838 + // TODO:暂时使用5休2的判定方法,测试
  839 +
  840 + // 先处理上午车次链
  841 + if (oNext_other_bc_fctime_m) {
  842 + if (oNext_other_bc_fctime_m.isBefore(this._oParam.getMPeakStartTimeObj())) {
  843 + // 5休2班型第一个班次,如果在早高峰开始前低谷,不添加
  844 + return false;
  845 + } else if (!oNext_other_bc_fctime_m.isAfter(this._oParam.getMPeakEndTimeObj())) {
  846 + // 早高峰期间,添加
  847 + return true;
  848 + } else {
  849 + // 早高峰之后低谷到12:00之间
  850 +
  851 + // 当前路牌的前一个班次
  852 + oLpPreBc = oCurrentLp.getBc(iBcIndex == 0 ? iGroupIndex - 1 : iGroupIndex, iBcIndex == 0 ? 1 : 0);
  853 + if (oCurrentLp.getBcArray().length > 0 && (!oLpPreBc)) {
  854 + // 不存在当前路牌的前一个班次,说明车次链已经结束了,不添加
  855 + return false;
  856 + } else {
  857 + if (oCurrentLp.getBcArray().length < Math.ceil(iBxBcount / 2)) {
  858 + // 如果总班次数比iBxBcount的一半的班次(ceil)少,加班次
  859 + return true;
  860 + } else if (oLpPreBc.isUp() == this._oParam.isUpOneWayStop()) {
  861 + // 超过一半的班次,判定当前路牌前一个班次是否主站班次,说明当前班次是副站
  862 + // 作为分班单向进出场的车次链最后一个班次必须副站(因为要抽车),必须添加班次
  863 + return true;
  864 + } else {
  865 + return false;
  866 + }
  867 + }
  868 + }
  869 + }
  870 +
  871 + // 再处理下午车次链
  872 + if (oNext_other_bc_fctime_e) {
  873 + if (oNext_other_bc_fctime_e.isBefore(this._oParam.getEPeakStartTimeObj())) {
  874 + // 5休2班型第一个班次,如果在晚高峰开始前低谷,不添加
  875 + return false;
  876 + } else if (!oNext_other_bc_fctime_e.isAfter(this._oParam.getEPeakEndTimeObj())) {
  877 + // 晚高峰期间,添加
  878 + return true;
  879 + } else {
  880 + // 晚高峰之后低谷
  881 +
  882 + // 当前路牌的前一个班次
  883 + oLpPreBc = oCurrentLp.getBc(iBcIndex == 0 ? iGroupIndex - 1 : iGroupIndex, iBcIndex == 0 ? 1 : 0);
  884 +
  885 + if (oCurrentLp.getBcArray().length > 0 && (!oLpPreBc)) {
  886 + // 不存在当前路牌的前一个班次,说明车次链已经结束了,不添加
  887 + // TODO:晚高峰后第一个班次也要添加,这里以后细化
  888 + return true;
  889 + } else {
  890 + if (oCurrentLp.getBcArray().length < iBxBcount) {
  891 + // 如果总班次数比iBxBcount少,加班次
  892 + return true;
  893 + } else if (oLpPreBc.isUp() == this._oParam.isUpOneWayStop()) {
  894 + // 超过一半的班次,判定当前路牌前一个班次是否主站班次,说明当前班次是副站
  895 + // 作为分班单向进出场的车次链最后一个班次必须副站(因为要抽车),必须添加班次
  896 + return true;
  897 + } else {
  898 + return false;
  899 + }
  900 + }
  901 + }
  902 + }
  903 +
  904 + }
  905 + } else { // 连班班型,高峰低谷都有班次
  906 + return true;
  907 + }
  908 +
  909 + };
  910 +
  911 + /**
  912 + * 核心方法,从上标线主站班次开始,一圈一圈生成每圈的主站班次,
  913 + * 每生成一个主站班次,尝试生成后面紧邻的副站班次(停站时间1到3分种调整),
  914 + * 配合_$fnGetBcInterval共同生成班次。
  915 + * @public
  916 + */
  917 + InternalScheduleObj.prototype.fnCreateBclistWithMasterBc = function() {
  918 + var i;
  919 + var j;
  920 + var oPreBc = this._oMPeakMasterBc; // 上一个班次(从上标线主站班次开始)
  921 + var oNextBc; // 计算的下一个班次
  922 + var oNextBcFcTime; // 下一个班次的发车时间
  923 + var aBcInterval = []; // 班次间隔数组
  924 + var oBcInterval; // 班次间隔对象
  925 + var iNextBcInterval; // 下一个班次发车间隔
  926 +
  927 + var oPreSlaveBc; // 上一个副站班次(上标线主站后的一个副站班次)
  928 + var oNextSlaveBc; // 下一个副站班次
  929 +
  930 + // 当初始化完一圈的主站班次后,最后一个班次是下一圈的上标线主站班次,需要判定存在然后添加间隔
  931 + var _modifyTimeNextGroupIndex; // 上标线下一圈索引
  932 + var _modifyTimeNextBcIndex; // 上标线下一圈班次索引
  933 + var _modifyBc; // 上标线下一个圈的班次
  934 +
  935 + for (i = this._iMPeakMasterBcGroupIndex; i < this._qCount; i++) {
  936 + aBcInterval = this._$fnGetBcInterval(i, this._iMPeakMasterBcIndex, 3);
  937 + if (aBcInterval.length == 0) {
  938 + // 等于0说明上标线没班次了
  939 + break;
  940 + }
  941 +
  942 + for (j = 1; j < this._internalLpArray.length; j++) {
  943 + oBcInterval = aBcInterval[j - 1];
  944 + if (oBcInterval.hasBc) {
  945 + iNextBcInterval = oBcInterval.iFcInterval;
  946 + oNextBcFcTime = this._oParam.addMinute(oPreBc.getFcTimeObj(), iNextBcInterval);
  947 + this._internalLpArray[j].fnSetVerticalIntervalTime(i, this._iMPeakMasterBcIndex, iNextBcInterval);
  948 +
  949 + oNextBc = _utils.createBcObj(
  950 + this._internalLpArray[j],
  951 + "normal",
  952 + this._oParam.isUpOneWayStop(),
  953 + 1,
  954 + oNextBcFcTime,
  955 + this._oParam);
  956 +
  957 + this._internalLpArray[j].setBc(
  958 + i, this._iMPeakMasterBcIndex, oNextBc);
  959 + oPreBc = oNextBc;
  960 + }
  961 + }
  962 +
  963 + // 修正上标线主站方向班次(一圈的结束班次,也是下一圈的开始班次)以及后续所有班次
  964 + oBcInterval = aBcInterval[j - 1];
  965 + if (oBcInterval.hasBc) {
  966 + iNextBcInterval = oBcInterval.iFcInterval;
  967 + _modifyTimeNextGroupIndex = i + 1;
  968 + _modifyTimeNextBcIndex = this._iMPeakMasterBcIndex;
  969 +
  970 + _utils.modifySBXMasterBc(
  971 + this._internalLpArray[0],
  972 + this._oParam.addMinute(oPreBc.getFcTimeObj(), iNextBcInterval),
  973 + _modifyTimeNextGroupIndex,
  974 + _modifyTimeNextBcIndex,
  975 + oPreBc.isUp(),
  976 + this._oParam
  977 + );
  978 +
  979 + // 修正上标线主站方向的班次后,一圈结束的班次可能不存在(超过末班车时间了),需要判定
  980 + _modifyBc = this._internalLpArray[0].getBc(_modifyTimeNextGroupIndex, _modifyTimeNextBcIndex);
  981 + if (_modifyBc) { // 存在修正间隔值
  982 + this._internalLpArray[0].fnSetVerticalIntervalTime(
  983 + _modifyTimeNextGroupIndex, _modifyTimeNextBcIndex, iNextBcInterval);
  984 + oPreBc = _modifyBc;
  985 + }
  986 +
  987 + }
  988 +
  989 + // 添加副站班次,就是主站班次到达时间加1分钟
  990 + // TODO:因为副站停站时间1分钟到3分钟,几乎没有停站时间,一般前面主站是多少间隔,后面如果有副站的话也是多少间隔
  991 + // TODO:此时,可能出现临界问题,当主站还是高峰接近低谷时,副站已经是低谷,此时副站发车间隔还是高峰间隔
  992 + // TODO:上述情况可以通过让临界的主站高峰班次使用高峰最大间隔,副站使用3分钟的最大停站使副站间隔达到低谷最小间隔
  993 + oPreSlaveBc = this._internalLpArray[0].getBc(
  994 + this._iMPeakMasterBcIndex == 0 ? i : i + 1,
  995 + this._iMPeakMasterBcIndex == 0 ? 1 : 0
  996 + );
  997 + for (j = 1; j < this._internalLpArray.length; j++) {
  998 + if (oPreSlaveBc) {
  999 + if (this._$fnDecideBxBc(oPreSlaveBc, j - 1, j,
  1000 + this._iMPeakMasterBcIndex == 0 ? i : i + 1,
  1001 + this._iMPeakMasterBcIndex == 0 ? 1 : 0)) {
  1002 + // 获取当前路牌前一个主站班次
  1003 + if (this._internalLpArray[j].getBc(
  1004 + i,
  1005 + this._iMPeakMasterBcIndex)) { // 相同路牌上一个主站班次存在
  1006 + oNextSlaveBc = _utils.createBcObj(
  1007 + this._internalLpArray[j],
  1008 + "normal",
  1009 + !this._oParam.isUpOneWayStop(),
  1010 + 1,
  1011 + this._oParam.addMinute( // 使用1分钟副站停站
  1012 + this._internalLpArray[j].getBc(
  1013 + i, this._iMPeakMasterBcIndex).getArrTimeObj(),
  1014 + 1),
  1015 + this._oParam);
  1016 +
  1017 + if (oNextSlaveBc.isUp()) {
  1018 + if (!oNextSlaveBc.getFcTimeObj().isAfter(this._oParam.getUpLastDtimeObj())) {
  1019 + this._internalLpArray[j].setBc(
  1020 + this._iMPeakMasterBcIndex == 0 ? i : i + 1,
  1021 + this._iMPeakMasterBcIndex == 0 ? 1 : 0,
  1022 + oNextSlaveBc);
  1023 + oPreSlaveBc = oNextSlaveBc;
  1024 + }
  1025 + } else {
  1026 + if (!oPreSlaveBc.getFcTimeObj().isAfter(this._oParam.getDownLastDTimeObj())) {
  1027 + this._internalLpArray[j].setBc(
  1028 + this._iMPeakMasterBcIndex == 0 ? i : i + 1,
  1029 + this._iMPeakMasterBcIndex == 0 ? 1 : 0,
  1030 + oNextSlaveBc);
  1031 + oPreSlaveBc = oNextSlaveBc;
  1032 + }
  1033 + }
  1034 + }
  1035 + }
  1036 + }
  1037 + }
  1038 +
  1039 +
  1040 + }
  1041 + };
  1042 +
  1043 + /**
  1044 + * 核心方法,获取发车间隔(从上标线指定班次开始网下拉一圈间隔)。
  1045 + * @param groupIndex 圈索引
  1046 + * @param bcIndex 班次索引
  1047 + * @param normalFre 连续相同发车间隔班次数
  1048 + * @private
  1049 + */
  1050 + InternalScheduleObj.prototype._$fnGetBcInterval = function(
  1051 + groupIndex, bcIndex,
  1052 + normalFre) {
  1053 +
  1054 + if (normalFre < 1 || normalFre > this._internalLpArray.length) {
  1055 + alert("连续相同发车间隔班次数区间[1,路牌数],当前值=" + normalFre);
  1056 + throw "连续相同发车间隔班次数区间[1,路牌数],当前值=" + normalFre;
  1057 + }
  1058 +
  1059 + // 这个方法很重要用于生成每圈每个方向上的班次发车间隔
  1060 + // 1、高峰班次全部高峰最大发车间隔
  1061 + // 2、低谷第一个班次使用低谷最小发车间隔,连续相等的间隔班次数=normalFre,然后加1分钟,最大值是高峰最大发车间隔
  1062 + // 3、TODO:高峰班次的间隔应该从最大缓慢变成最小然后再缓慢变成最大
  1063 + // 4、TODO:分班班型可能在指定位置没有班次,需要合理判定(5休2,其他班型)
  1064 + // 5、TODO:主站方向在低谷拉间隔的时候,低谷拉到多少才是合理的(当行驶时间很大时,低谷最大发车间隔不一定合理),
  1065 + // TODO: 此时需要和连班的间隔分班路牌数(抽车数),以及吃饭时间的大小共同考虑,
  1066 + // TODO: 目前这样考虑,因为要抽车,如果没有足够的停站时间做调整,肯定会大间隔,当要抽车时,
  1067 + // TODO:获取当前连班路牌和上一个连班路牌在前半圈的间隔值,当前连班路牌班次的停站时间至少大于低谷最大发车间隔减去这个值
  1068 +
  1069 + var i;
  1070 + var j;
  1071 + var oPreBc; // 上一个班次(从上标线班次开始)
  1072 + var oCurrentBcFcTime; // 当前班次的发车时间
  1073 + var oCurrentBcInterval; // 当前班次的发车间隔
  1074 +
  1075 + // 班次发车间隔,从oPreBc向前推normalFre个班次
  1076 + var aBcInterval = [];
  1077 + var iBcInterval;
  1078 + var bIsIntervalEquale;
  1079 + var iPreBcIntervalIndex;
  1080 + var aBcInterval_rtn = []; // 最终返回的对象数组
  1081 +
  1082 + oPreBc = this._internalLpArray[0].getBc(groupIndex, bcIndex);
  1083 + if (oPreBc) {
  1084 + // 先尝试获取上标线班次的interval
  1085 + iBcInterval = this._internalLpArray[0].fnGetVerticalIntervalTime(
  1086 + groupIndex, bcIndex);
  1087 + if (iBcInterval) { // 存在发车间隔
  1088 + aBcInterval.push(iBcInterval);
  1089 +
  1090 + // 尝试获取前一圈同方向的(normalFre -1)个班次的发车间隔
  1091 + j = 1;
  1092 + if (groupIndex - 1 >= 0) {
  1093 + for (i = this._internalLpArray.length - 1; i >= 0; i--) {
  1094 + if (j < normalFre) {
  1095 + iBcInterval = this._internalLpArray[i].fnGetVerticalIntervalTime(
  1096 + groupIndex - 1, bcIndex);
  1097 + if (iBcInterval) { // 存在发车间隔
  1098 + aBcInterval.push(iBcInterval);
  1099 + j++;
  1100 + }
  1101 + } else {
  1102 + break;
  1103 + }
  1104 + }
  1105 + }
  1106 + }
  1107 +
  1108 + aBcInterval.reverse();
  1109 + // 上一个班次间隔index
  1110 + iPreBcIntervalIndex = aBcInterval.length - 1;
  1111 +
  1112 + var _iLpIndex;
  1113 + for (i = 1; i <= this._internalLpArray.length; i++) {
  1114 + var oBcInterval_rtn =
  1115 + {iLpIndex: null, hasBc: false, iFcInterval: null, iGroupIndex: null, iBcIndex: null};
  1116 + // 注意这里是 this._internalLpArray.length,最后一个班次是下标线下一圈的同方向班次
  1117 + _iLpIndex = i % this._internalLpArray.length;
  1118 +
  1119 + if (_iLpIndex == 0) { // 下一圈的上标线同方向班次
  1120 + oBcInterval_rtn.iLpIndex = 0;
  1121 + oBcInterval_rtn.iGroupIndex = groupIndex + 1;
  1122 + oBcInterval_rtn.iBcIndex = bcIndex;
  1123 + } else {
  1124 + oBcInterval_rtn.iLpIndex = _iLpIndex;
  1125 + oBcInterval_rtn.iGroupIndex = groupIndex;
  1126 + oBcInterval_rtn.iBcIndex = bcIndex;
  1127 + }
  1128 +
  1129 + // 班型判定
  1130 + if (_iLpIndex != 0) { // 回到上标线不用判定了
  1131 + if (!this._$fnDecideBxBc(
  1132 + oPreBc, _iLpIndex - 1,
  1133 + _iLpIndex,
  1134 + groupIndex, bcIndex
  1135 + )) {
  1136 + aBcInterval_rtn.push(oBcInterval_rtn);
  1137 + continue;
  1138 + }
  1139 + }
  1140 +
  1141 + if (this._oParam.isMPeakBc(oPreBc.getFcTimeObj())) { // 早高峰
  1142 + // 如果上一个班次是早高峰班次,下一个班次使用早高峰平均发车间隔(ceil)
  1143 + // 如果下一个班次(加上早高峰最大发车间隔后)是低谷班次,使用低谷最小发车间隔
  1144 + oCurrentBcFcTime = this._oParam.addMinute(
  1145 + oPreBc.getFcTimeObj(),
  1146 + Math.ceil((this._oParam.getMPeakMaxFcjx() + this._oParam.getMPeakMinFcjx()) / 2));
  1147 + if (this._oParam.isTroughBc(oCurrentBcFcTime)) {
  1148 + oCurrentBcFcTime = this._oParam.addMinute(
  1149 + oPreBc.getFcTimeObj(),
  1150 + this._oParam.getTroughMinFcjx());
  1151 + }
  1152 +
  1153 + } else if (this._oParam.isEPeakBc(oPreBc.getFcTimeObj())) { // 晚高峰
  1154 + // 如果上一个班次是晚高峰班次,下一个班次使用晚高峰平均发车间隔(ceil)
  1155 + // 如果下一个班次(加上晚高峰最大发车间隔后)是低谷班次,使用低谷最小发车间隔
  1156 + oCurrentBcFcTime = this._oParam.addMinute(
  1157 + oPreBc.getFcTimeObj(),
  1158 + Math.ceil((this._oParam.getEPeakMaxFcjx() + this._oParam.getEPeakMinFcjx()) / 2));
  1159 + if (this._oParam.isTroughBc(oCurrentBcFcTime)) {
  1160 + oCurrentBcFcTime = this._oParam.addMinute(
  1161 + oPreBc.getFcTimeObj(),
  1162 + this._oParam.getTroughMinFcjx());
  1163 + }
  1164 + } else {
  1165 +
  1166 + if (aBcInterval.length < normalFre) { // 没有足够的连续班次间隔
  1167 + // 使用低谷最小发车间隔,如果跨入高峰,使用高峰平均发车间隔(ceil)
  1168 + oCurrentBcFcTime = this._oParam.addMinute(
  1169 + oPreBc.getFcTimeObj(),
  1170 + this._oParam.getTroughMinFcjx()
  1171 + );
  1172 + if (this._oParam.isMPeakBc(oCurrentBcFcTime)) {
  1173 + oCurrentBcFcTime = this._oParam.addMinute(
  1174 + oPreBc.getFcTimeObj(),
  1175 + Math.ceil((this._oParam.getMPeakMaxFcjx() + this._oParam.getMPeakMinFcjx()) / 2)
  1176 + );
  1177 + }
  1178 + if (this._oParam.isEPeakBc(oCurrentBcFcTime)) {
  1179 + oCurrentBcFcTime = this._oParam.addMinute(
  1180 + oPreBc.getFcTimeObj(),
  1181 + Math.ceil((this._oParam.getEPeakMaxFcjx() + this._oParam.getEPeakMinFcjx()) / 2)
  1182 + );
  1183 + }
  1184 + } else { // 有足够的连续班次间隔
  1185 + // 看连续班次间隔是否一致,一致+1分钟(不能超过低谷最大发车间隔),不一致就相等间隔
  1186 + // 加了间隔后,如果是高峰班次,则使用高峰平均发车间隔(ceil)
  1187 + // TODO:什么时候开始减低谷发车间隔到最小发车间隔,应该是在吃了饭之后
  1188 +
  1189 + bIsIntervalEquale = true;
  1190 + for (j = iPreBcIntervalIndex; j > iPreBcIntervalIndex - normalFre + 1; j--) {
  1191 + if (aBcInterval[j] != aBcInterval[j - 1]) {
  1192 + bIsIntervalEquale = false;
  1193 + break;
  1194 + }
  1195 + }
  1196 + if (bIsIntervalEquale) {
  1197 + if (aBcInterval[iPreBcIntervalIndex] + 1 > this._oParam.getTroughMaxFcjx()) {
  1198 + oCurrentBcFcTime = this._oParam.addMinute(
  1199 + oPreBc.getFcTimeObj(),
  1200 + this._oParam.getTroughMaxFcjx()
  1201 + );
  1202 + } else {
  1203 + oCurrentBcFcTime = this._oParam.addMinute(
  1204 + oPreBc.getFcTimeObj(),
  1205 + aBcInterval[iPreBcIntervalIndex] + 1
  1206 + );
  1207 + }
  1208 + } else {
  1209 + oCurrentBcFcTime = this._oParam.addMinute(
  1210 + oPreBc.getFcTimeObj(),
  1211 + aBcInterval[iPreBcIntervalIndex]
  1212 + );
  1213 + }
  1214 +
  1215 + if (this._oParam.isMPeakBc(oCurrentBcFcTime)) {
  1216 + oCurrentBcFcTime = this._oParam.addMinute(
  1217 + oPreBc.getFcTimeObj(),
  1218 + Math.ceil((this._oParam.getMPeakMaxFcjx() + this._oParam.getMPeakMinFcjx()) / 2)
  1219 + );
  1220 + }
  1221 + if (this._oParam.isEPeakBc(oCurrentBcFcTime)) {
  1222 + oCurrentBcFcTime = this._oParam.addMinute(
  1223 + oPreBc.getFcTimeObj(),
  1224 + Math.ceil((this._oParam.getEPeakMaxFcjx() + this._oParam.getEPeakMinFcjx()) / 2)
  1225 + );
  1226 + }
  1227 +
  1228 + }
  1229 +
  1230 + }
  1231 +
  1232 + // 判定超出末班车,就没有班次
  1233 + if (oPreBc.isUp()) {
  1234 + if (oCurrentBcFcTime.isAfter(
  1235 + this._oParam.addMinute(this._oParam.getUpLastDtimeObj(), 30))) {
  1236 + aBcInterval_rtn.push(oBcInterval_rtn);
  1237 + continue;
  1238 + }
  1239 + } else {
  1240 + if (oCurrentBcFcTime.isAfter(
  1241 + this._oParam.addMinute(this._oParam.getDownLastDTimeObj(), 30))) {
  1242 + aBcInterval_rtn.push(oBcInterval_rtn);
  1243 + continue;
  1244 + }
  1245 + }
  1246 +
  1247 + oCurrentBcInterval = oCurrentBcFcTime.diff(oPreBc.getFcTimeObj(), "m");
  1248 + aBcInterval.push(oCurrentBcInterval);
  1249 + oPreBc = _utils.createBcObj(
  1250 + this._internalLpArray[_iLpIndex],
  1251 + "normal",
  1252 + oPreBc.isUp(),
  1253 + 1,
  1254 + oCurrentBcFcTime,
  1255 + this._oParam
  1256 + );
  1257 + iPreBcIntervalIndex++;
  1258 + oBcInterval_rtn.hasBc = true;
  1259 + oBcInterval_rtn.iFcInterval = oCurrentBcInterval;
  1260 + aBcInterval_rtn.push(oBcInterval_rtn);
  1261 + }
  1262 +
  1263 + }
  1264 +
  1265 + return aBcInterval_rtn;
  1266 +
  1267 + };
  1268 +
  1269 + //------------- 其他业务方法 -------------//
  1270 +
  1271 + /**
  1272 + * 标记吃饭班次。
  1273 + * TODO:暂时判定只有连班能吃饭,然后如果吃饭时间不足,不吃饭,这个需要在_$fnGetBcInterval中做仔细判定的
  1274 + */
  1275 + InternalScheduleObj.prototype.fnFlagEatBc = function() {
  1276 + var i;
  1277 + var oLp;
  1278 + var j;
  1279 + var aBc;
  1280 + var oBc;
  1281 + var oPreBc;
  1282 + var oEatFlag = {}; // {"路牌编号":{isLaunch: false, isDinner: false},...}
  1283 + for (i = 0; i < this._internalLpArray.length; i++) {
  1284 + oLp = this._internalLpArray[i];
  1285 + if (oLp.isBxLb()) {
  1286 + oEatFlag[oLp.getLpNo()] = {};
  1287 + oEatFlag[oLp.getLpNo()]["isLaunch"] = false;
  1288 + oEatFlag[oLp.getLpNo()]["isDinner"] = false;
  1289 + aBc = oLp.getBcArray();
  1290 + for (j = 0; j < aBc.length; j++) {
  1291 + oBc = aBc[j];
  1292 + // 午饭
  1293 + if (oBc.getFcTimeObj().isAfter(this._oParam.toTimeObj("10:00")) &&
  1294 + oBc.getFcTimeObj().isBefore(this._oParam.toTimeObj("13:00"))) {
  1295 + oPreBc = oLp.getPreBc(oBc);
  1296 +
  1297 + if (!oEatFlag[oLp.getLpNo()]["isLaunch"]) {
  1298 + if (oPreBc && oBc.getFcTimeObj().diff(oPreBc.getArrTimeObj(), 'm') > this._oParam.fnGetLunchTime()) {
  1299 + oBc.fnSetEatTime(this._oParam.fnGetLunchTime());
  1300 + oEatFlag[oLp.getLpNo()]["isLaunch"] = true;
  1301 + }
  1302 + }
  1303 + }
  1304 +
  1305 + // 晚饭
  1306 + if (oBc.getFcTimeObj().isAfter(this._oParam.toTimeObj("16:00")) &&
  1307 + oBc.getFcTimeObj().isBefore(this._oParam.toTimeObj("20:00"))) {
  1308 + oPreBc = oLp.getPreBc(oBc);
  1309 +
  1310 + if (!oEatFlag[oLp.getLpNo()]["isDinner"]) {
  1311 + if (oPreBc && oBc.getFcTimeObj().diff(oPreBc.getArrTimeObj(), 'm') > this._oParam.fnGetDinnerTime()) {
  1312 + oBc.fnSetEatTime(this._oParam.fnGetDinnerTime());
  1313 + oEatFlag[oLp.getLpNo()]["isDinner"] = true;
  1314 + }
  1315 + }
  1316 + }
  1317 + }
  1318 + }
  1319 + }
  1320 + };
  1321 +
  1322 + /**
  1323 + * 计算末班车。
  1324 + * 1、将上下行拉成上下行两个班次列表(包括标记班次)
  1325 + * 2、分别找出离末班车发车时间最近的班次,并替换时间
  1326 + * 3、删除之后的班次
  1327 + */
  1328 + InternalScheduleObj.prototype.fnCalcuLastBc = function() {
  1329 + var i;
  1330 + var iTimeDiff;
  1331 + var iTempTime;
  1332 + var aBc;
  1333 + var oLastBcTime;
  1334 + var oLastBcIsUp;
  1335 + var iModifyIndex;
  1336 +
  1337 + // 查找末班车早的末班车时间和方向
  1338 + if (this._oParam.getUpLastDtimeObj().isBefore(this._oParam.getDownLastDTimeObj())) {
  1339 + oLastBcTime = this._oParam.getUpLastDtimeObj();
  1340 + oLastBcIsUp = true;
  1341 + } else {
  1342 + oLastBcTime = this._oParam.getDownLastDTimeObj();
  1343 + oLastBcIsUp = false;
  1344 + }
  1345 +
  1346 + // 确定早的末班车时间
  1347 + aBc = this.fnGetBcList(oLastBcIsUp);
  1348 + for (i = 0; i < aBc.length; i++) {
  1349 + iTempTime = oLastBcTime.diff(aBc[i].getFcTimeObj(), "m");
  1350 + if (iTimeDiff == undefined) {
  1351 + iTimeDiff = iTempTime;
  1352 + iModifyIndex = i;
  1353 + } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff)) {
  1354 + iTimeDiff = iTempTime;
  1355 + iModifyIndex = i;
  1356 + }
  1357 + }
  1358 + aBc[iModifyIndex].addMinuteToFcsj(iTimeDiff); // 替换成末班车时间
  1359 + aBc[iModifyIndex].fnSetDelFlag(false);
  1360 + aBc[iModifyIndex].fnSetIsLastBc(true);
  1361 + for (i = iModifyIndex + 1; i < aBc.length; i++) { // 删除多余班次
  1362 + this._qIsUp == oLastBcIsUp ?
  1363 + aBc[i]._$$_internal_group_obj.setBc1(undefined) :
  1364 + aBc[i]._$$_internal_group_obj.setBc2(undefined);
  1365 + }
  1366 +
  1367 + // 查找末班车晚的末班车时间和方向
  1368 + if (this._oParam.getUpLastDtimeObj().isBefore(this._oParam.getDownLastDTimeObj())) {
  1369 + oLastBcTime = this._oParam.getDownLastDTimeObj();
  1370 + oLastBcIsUp = false;
  1371 + } else {
  1372 + oLastBcTime = this._oParam.getUpLastDtimeObj();
  1373 + oLastBcIsUp = true;
  1374 + }
  1375 + // 确定晚的末班车时间
  1376 + aBc = this.fnGetBcList(oLastBcIsUp);
  1377 + var oBc;
  1378 + var aBcIndex;
  1379 + var iLpIndex;
  1380 + var iQIndex;
  1381 + var iBcIndex;
  1382 +
  1383 + iTimeDiff = undefined;
  1384 + for (i = 0; i < aBc.length; i++) {
  1385 + oBc = aBc[i];
  1386 + aBcIndex = this.fnGetBcIndex(oBc);
  1387 +
  1388 + iLpIndex = aBcIndex[0];
  1389 + iQIndex = aBcIndex[2] == 0 ? aBcIndex[1] -1 : aBcIndex[1];
  1390 + iBcIndex = aBcIndex[2] == 0 ? 1 : 0;
  1391 +
  1392 + if (!this._internalLpArray[iLpIndex].getBc(iQIndex, iBcIndex)) {
  1393 + continue;
  1394 + }
  1395 +
  1396 + iTempTime = oLastBcTime.diff(aBc[i].getFcTimeObj(), "m");
  1397 + if (iTimeDiff == undefined) {
  1398 + iTimeDiff = iTempTime;
  1399 + iModifyIndex = i;
  1400 + } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff)) {
  1401 + iTimeDiff = iTempTime;
  1402 + iModifyIndex = i;
  1403 + }
  1404 + }
  1405 + aBc[iModifyIndex].addMinuteToFcsj(iTimeDiff); // 替换成末班车时间
  1406 + aBc[iModifyIndex].fnSetDelFlag(false);
  1407 + aBc[iModifyIndex].fnSetIsLastBc(true);
  1408 + for (i = iModifyIndex + 1; i < aBc.length; i++) { // 删除多余班次
  1409 + this._qIsUp == oLastBcIsUp ?
  1410 + aBc[i]._$$_internal_group_obj.setBc1(undefined) :
  1411 + aBc[i]._$$_internal_group_obj.setBc2(undefined);
  1412 + }
  1413 + };
  1414 +
  1415 + /**
  1416 + * 修正停站时间。
  1417 + */
  1418 + InternalScheduleObj.prototype.fnModifyLayoverTime = function() {
  1419 + for (var i = 0; i < this._internalLpArray.length; i++) {
  1420 + this._internalLpArray[i].modifyLayoverTimeWithoutFcTime();
  1421 + }
  1422 + };
  1423 +
  1424 + /**
  1425 + * 补进出场例保班次。
  1426 + */
  1427 + InternalScheduleObj.prototype.fnCalcuOtherBc = function() {
  1428 + var i;
  1429 + var j;
  1430 + var iBcChainCount;
  1431 + var oLp;
  1432 + var aOtherBc;
  1433 + var oStartBc;
  1434 + var oEndBc;
  1435 +
  1436 + for (i = 0; i < this._internalLpArray.length; i++) {
  1437 + aOtherBc = [];
  1438 + oLp = this._internalLpArray[i];
  1439 + iBcChainCount = oLp.fnGetBcChainCount();
  1440 +
  1441 + if (iBcChainCount == 1) { // 只有一个车次链,是连班班型
  1442 + // 头部要添加出场,例保班次
  1443 + oStartBc = oLp.getBc(
  1444 + oLp.fnGetBcChainInfo(0)["s_q"],
  1445 + oLp.fnGetBcChainInfo(0)["s_b"]
  1446 + );
  1447 + aOtherBc.push(_utils.createBcObj(
  1448 + oLp, "bd", oStartBc.isUp(), 1,
  1449 + oStartBc.getFcTimeObj(),
  1450 + this._oParam
  1451 + ));
  1452 + aOtherBc.push(_utils.createBcObj(
  1453 + oLp, "out", oStartBc.isUp(), 1,
  1454 + oStartBc.getFcTimeObj(),
  1455 + this._oParam
  1456 + ));
  1457 +
  1458 + // 尾部需添加进场,例保班次
  1459 + oEndBc = oLp.getBc(
  1460 + oLp.fnGetBcChainInfo(0)["e_q"],
  1461 + oLp.fnGetBcChainInfo(0)["e_b"]
  1462 + );
  1463 + oEndBc.fnSetIsLastBc(false); // 有可能最后一个班次是吃饭班次,重置
  1464 + oEndBc.fnSetEatTime(0); // 有可能最后一个班次是吃饭班次,重置
  1465 + aOtherBc.push(_utils.createBcObj(
  1466 + oLp, "in", !oEndBc.isUp(), 1,
  1467 + oEndBc.getArrTimeObj(),
  1468 + this._oParam
  1469 + ));
  1470 + aOtherBc.push(_utils.createBcObj(
  1471 + oLp, "lc", !oEndBc.isUp(), 1,
  1472 + oEndBc.getArrTimeObj(),
  1473 + this._oParam
  1474 + ));
  1475 + } else if (iBcChainCount == 2) { // 两个车次链,是分班班型
  1476 + // 第一个车次链开头有出场,报到班次,车次链结尾只有进场班次
  1477 + oStartBc = oLp.getBc(
  1478 + oLp.fnGetBcChainInfo(0)["s_q"],
  1479 + oLp.fnGetBcChainInfo(0)["s_b"]
  1480 + );
  1481 + aOtherBc.push(_utils.createBcObj(
  1482 + oLp, "bd", oStartBc.isUp(), 1,
  1483 + oStartBc.getFcTimeObj(),
  1484 + this._oParam
  1485 + ));
  1486 + aOtherBc.push(_utils.createBcObj(
  1487 + oLp, "out", oStartBc.isUp(), 1,
  1488 + oStartBc.getFcTimeObj(),
  1489 + this._oParam
  1490 + ));
  1491 +
  1492 + oEndBc = oLp.getBc(
  1493 + oLp.fnGetBcChainInfo(0)["e_q"],
  1494 + oLp.fnGetBcChainInfo(0)["e_b"]
  1495 + );
  1496 + aOtherBc.push(_utils.createBcObj(
  1497 + oLp, "in", !oEndBc.isUp(), 1,
  1498 + oEndBc.getArrTimeObj(),
  1499 + this._oParam
  1500 + ));
  1501 +
  1502 + // 第二个车次链开头有出场,报到班次,车次链结尾有进场,报到班次
  1503 + oStartBc = oLp.getBc(
  1504 + oLp.fnGetBcChainInfo(1)["s_q"],
  1505 + oLp.fnGetBcChainInfo(1)["s_b"]
  1506 + );
  1507 + aOtherBc.push(_utils.createBcObj(
  1508 + oLp, "bd", oStartBc.isUp(), 1,
  1509 + oStartBc.getFcTimeObj(),
  1510 + this._oParam
  1511 + ));
  1512 + aOtherBc.push(_utils.createBcObj(
  1513 + oLp, "out", oStartBc.isUp(), 1,
  1514 + oStartBc.getFcTimeObj(),
  1515 + this._oParam
  1516 + ));
  1517 +
  1518 + oEndBc = oLp.getBc(
  1519 + oLp.fnGetBcChainInfo(1)["e_q"],
  1520 + oLp.fnGetBcChainInfo(1)["e_b"]
  1521 + );
  1522 + aOtherBc.push(_utils.createBcObj(
  1523 + oLp, "in", !oEndBc.isUp(), 1,
  1524 + oEndBc.getArrTimeObj(),
  1525 + this._oParam
  1526 + ));
  1527 + aOtherBc.push(_utils.createBcObj(
  1528 + oLp, "lc", !oEndBc.isUp(), 1,
  1529 + oEndBc.getArrTimeObj(),
  1530 + this._oParam
  1531 + ));
  1532 +
  1533 +
  1534 + } else {
  1535 + // 2个车次链以上,暂时没有此班型
  1536 + }
  1537 +
  1538 + oLp.addOtherBcArray(aOtherBc);
  1539 + }
  1540 + };
  1541 +
  1542 +
  1543 + //------------- 其他非业务方法方法 -------------//
  1544 + /**
  1545 + * 获取班次列表。
  1546 + * @param isUp boolean 是否上行
  1547 + * @returns [(InternalBcObj)]
  1548 + */
  1549 + InternalScheduleObj.prototype.fnGetBcList = function(isUp) {
  1550 + var i;
  1551 + var j;
  1552 + var oLp;
  1553 + var oBc;
  1554 + var aBc = [];
  1555 +
  1556 + for (j = 0; j < this._qCount; j++) {
  1557 + for (i = 0; i < this._internalLpArray.length; i++) {
  1558 + oLp = this._internalLpArray[i];
  1559 + oBc = oLp.getBc(
  1560 + j,
  1561 + this._qIsUp == isUp ? 0 : 1
  1562 + );
  1563 + if (oBc) {
  1564 + aBc.push(oBc);
  1565 + }
  1566 + }
  1567 + }
  1568 +
  1569 + var aBcFcTime = [];
  1570 + for (i = 0; i < aBc.length; i++) {
  1571 + oBc = aBc[i];
  1572 + aBcFcTime.push(oBc.getFcTimeObj().format("HH:mm"));
  1573 + }
  1574 + console.log((isUp ? "上行班次列表:" : "下行班次列表:") + aBcFcTime.join(","));
  1575 +
  1576 + return aBc;
  1577 + };
  1578 +
  1579 + /**
  1580 + * 获取班次索引。
  1581 + * @param oBc 班次对象
  1582 + * @returns [{路牌索引},{圈索引},{班次索引}]
  1583 + */
  1584 + InternalScheduleObj.prototype.fnGetBcIndex = function(oBc) {
  1585 + // 路牌索引
  1586 + var i;
  1587 + var iLpIndex;
  1588 + for (i = 0; i < this._internalLpArray.length; i++) {
  1589 + if (this._internalLpArray[i]._$$_orign_lp_obj == oBc._$$_internal_lp_obj._$$_orign_lp_obj) {
  1590 + iLpIndex = i;
  1591 + break;
  1592 + }
  1593 + }
  1594 + // 圈索引
  1595 + var j;
  1596 + var iGroupIndex;
  1597 + var bFlag = false;
  1598 + for (i = 0; i < this._internalLpArray.length; i++) {
  1599 + if (bFlag) {
  1600 + break;
  1601 + }
  1602 + for (j = 0; j < this._qCount; j++) {
  1603 + if (this._internalLpArray[i]._$_groupBcArray[j] == oBc._$$_internal_group_obj) {
  1604 + iGroupIndex = j;
  1605 + bFlag = true;
  1606 + break;
  1607 + }
  1608 + }
  1609 + }
  1610 + // 班次索引
  1611 + var iBcIndex = this._qIsUp == oBc.isUp() ? 0 : 1;
  1612 +
  1613 + if (iLpIndex == undefined) {
  1614 + return null;
  1615 + } else {
  1616 + return [].concat(iLpIndex, iGroupIndex, iBcIndex);
  1617 + }
  1618 + };
  1619 +
  1620 + /**
  1621 + * 返回内部路牌数据列表。
  1622 + * @returns {Array}
  1623 + */
  1624 + InternalScheduleObj.prototype.fnGetLpArray = function() {
  1625 + return this._internalLpArray;
  1626 + };
  1627 +
  1628 + /**
  1629 + * 内部数据转化成显示用的班次数组。
  1630 + */
  1631 + InternalScheduleObj.prototype.fnToGanttBcArray = function() {
  1632 + var aAllBc = [];
  1633 + var aLpBc = [];
  1634 + var aEatBc = [];
  1635 + var oLp;
  1636 + var i;
  1637 + var j;
  1638 +
  1639 + for (i = 0; i < this._internalLpArray.length; i++) {
  1640 + oLp = this._internalLpArray[i];
  1641 + aLpBc = [];
  1642 + aLpBc = aLpBc.concat(oLp.getOtherBcArray(), oLp.getBcArray());
  1643 +
  1644 + aEatBc = [];
  1645 + // TODO:根据班次的吃饭时间添加吃饭班次
  1646 + for (j = 0; j < aLpBc.length; j++) {
  1647 + if (aLpBc[j].fnGetEatTime() > 0) {
  1648 + aEatBc.push(_utils.createBcObj(
  1649 + oLp,
  1650 + "cf",
  1651 + aLpBc[j].isUp(), // 和上一个班次方向相反
  1652 + 1,
  1653 + this._oParam.addMinute(aLpBc[j].getFcTimeObj(), -aLpBc[j].fnGetEatTime()),
  1654 + this._oParam
  1655 + ));
  1656 + }
  1657 + }
  1658 + aLpBc = aLpBc.concat(aEatBc);
  1659 +
  1660 + // 按照发车时间排序
  1661 + aLpBc.sort(function(o1, o2) {
  1662 + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) {
  1663 + return -1;
  1664 + } else {
  1665 + return 1;
  1666 + }
  1667 + });
  1668 +
  1669 + // 重新赋值fcno
  1670 + for (j = 0; j < aLpBc.length; j++) {
  1671 + aLpBc[j].fnSetFcno(j + 1);
  1672 + }
  1673 +
  1674 + aAllBc = aAllBc.concat(aLpBc);
  1675 + }
  1676 +
  1677 + var aGanttBc = [];
  1678 + for (i = 0; i < aAllBc.length; i++) {
  1679 + aGanttBc.push(aAllBc[i].toGanttBcObj());
  1680 + }
  1681 +
  1682 + return aGanttBc;
  1683 + };
  1684 +
  1685 + //-------------------- static静态方法 ----------------------//
  1686 + /**
  1687 + * 计算车辆数。
  1688 + * @param oParam 参数对象
  1689 + */
  1690 + InternalScheduleObj.calcuClzx = function(oParam) {
  1691 + var _iUpRT; // 上行行驶时间
  1692 + var _iUpLT; // 上行停站时间
  1693 + var _iDownRT; // 下行行驶时间
  1694 + var _iDownLT; // 下行停站时间
  1695 +
  1696 + // 获取早高峰平均发车间隔
  1697 + var _iAMPeakFcjx_avg = (oParam.getMPeakMinFcjx() + oParam.getMPeakMaxFcjx()) / 2;
  1698 + // 计算早高峰周转时间
  1699 + _iUpRT = oParam.calcuTravelTime(
  1700 + oParam.getMPeakStartTimeObj(), true);
  1701 + _iUpLT = oParam.calcuTripLayoverTimeRange(
  1702 + oParam.getMPeakStartTimeObj(), true, _iUpRT)[0]; // 使用最小停站时间
  1703 + _iDownRT = oParam.calcuTravelTime(
  1704 + oParam.getMPeakStartTimeObj(), false);
  1705 + _iDownLT = oParam.calcuTripLayoverTimeRange(
  1706 + oParam.getMPeakStartTimeObj(), false, _iDownRT)[0]; // 使用最小停站时间
  1707 + var _iAMPeakRCTime = _iUpRT + _iUpLT + _iDownRT + _iDownLT;
  1708 + // 早高峰预估车辆数
  1709 + var _iAMPeakVehicleCount = _iAMPeakRCTime / _iAMPeakFcjx_avg;
  1710 +
  1711 + // 获取晚高峰平均发车间隔
  1712 + var _iPMPeakFcjx_avg = (oParam.getEPeakMinFcjx() + oParam.getEPeakMaxFcjx()) / 2;
  1713 + // 计算晚高峰周转时间
  1714 + _iUpRT = oParam.calcuTravelTime(
  1715 + oParam.getEPeakStartTimeObj(), true);
  1716 + _iUpLT = oParam.calcuTripLayoverTimeRange(
  1717 + oParam.getEPeakStartTimeObj(), true, _iUpRT)[0]; // 使用最小停站时间
  1718 + _iDownRT = oParam.calcuTravelTime(
  1719 + oParam.getEPeakStartTimeObj(), false);
  1720 + _iDownLT = oParam.calcuTripLayoverTimeRange(
  1721 + oParam.getEPeakStartTimeObj(), false, _iDownRT)[0]; // 使用最小停站时间
  1722 + var _iPMPeakRCTime = _iUpRT + _iUpLT + _iDownRT + _iDownLT;
  1723 + // 晚高峰预估车辆数
  1724 + var _iPMPeakVehicleCount = _iPMPeakRCTime / _iPMPeakFcjx_avg;
  1725 +
  1726 + // 取最大值为最终车辆数
  1727 + // 大于或等于的最小整数,人话就是有小数点就加1
  1728 + if (_iAMPeakVehicleCount > _iPMPeakVehicleCount) {
  1729 + return Math.ceil(_iAMPeakVehicleCount);
  1730 + } else {
  1731 + return Math.ceil(_iPMPeakVehicleCount);
  1732 + }
  1733 +
  1734 + };
  1735 +
  1736 +
  1737 + return InternalScheduleObj;
  1738 +}());
0 \ No newline at end of file 1739 \ No newline at end of file
src/main/resources/static/pages/base/timesmodel/js/v2_2/main_v2_2.js 0 → 100644
  1 +/**
  2 + * 主类(v2_2版本)。
  3 + */
  4 +var Main_v2_2 = function() {
  5 +
  6 + var _paramObj; // 参数对象
  7 +
  8 + var _factory = { // TODO:以后移走
  9 + // 创建班次对象
  10 + createBcObj: function(lpObj, bcType, isUp, fcno, fcTimeObj, paramObj) {
  11 + var _bclc = paramObj.calcuTravelLcNumber(isUp, bcType);
  12 + var _fcsj = fcTimeObj;
  13 + var _bcsj = paramObj.calcuTravelTime(_fcsj, isUp);
  14 + var _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  15 + //var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj);
  16 + var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, isUp, paramObj.calcuTravelTime(_fcsj, isUp));
  17 + var _tccid = paramObj.getTTinfoId();
  18 + var _ttinfoid = paramObj.getTTinfoId();
  19 + var _xl = paramObj.getXlId();
  20 + var _qdz = isUp ? paramObj.getUpQdzObj().id : paramObj.getDownQdzObj().id;
  21 + var _zdz = isUp ? paramObj.getUpZdzObj().id : paramObj.getDownZdzObj().id;
  22 +
  23 + if (bcType == "bd") { // 早例保,传过来的发车时间是第一个班次的发车时间
  24 + if (isUp) { // 上行
  25 + _fcsj = paramObj.addMinute(
  26 + _fcsj,
  27 + -(paramObj.getUpOutTime() + paramObj.getLbTime()));
  28 + _bcsj = paramObj.getLbTime();
  29 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  30 + _stoptime = 0;
  31 + } else { // 下行
  32 + _fcsj = paramObj.addMinute(
  33 + _fcsj,
  34 + -(paramObj.getDownOutTime() + paramObj.getLbTime()));
  35 + _bcsj = paramObj.getLbTime();
  36 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  37 + _stoptime = 0;
  38 + }
  39 + } else if (bcType == "lc") { // 晚例保,传过来的发车时间是最后一个班次的到达时间
  40 + if (isUp) { // 上行
  41 + _fcsj = paramObj.addMinute(
  42 + _fcsj,
  43 + paramObj.getUpInTime());
  44 + _bcsj = paramObj.getLbTime();
  45 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  46 + _stoptime = 0;
  47 + } else { // 下行
  48 + _fcsj = paramObj.addMinute(
  49 + _fcsj,
  50 + paramObj.getDownInTime());
  51 + _bcsj = paramObj.getLbTime();
  52 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  53 + _stoptime = 0;
  54 + }
  55 + } else if (bcType == "out") { // 出场,传过来的发车时间是第一个班次的发车时间
  56 + if (isUp) { // 上行
  57 + _fcsj = paramObj.addMinute(
  58 + _fcsj,
  59 + -paramObj.getUpOutTime());
  60 + _bcsj = paramObj.getUpOutTime();
  61 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  62 + _stoptime = 0;
  63 + } else { // 下行
  64 + _fcsj = paramObj.addMinute(
  65 + _fcsj,
  66 + -paramObj.getDownOutTime());
  67 + _bcsj = paramObj.getDownOutTime();
  68 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  69 + _stoptime = 0;
  70 + }
  71 + } else if (bcType == "in") { // 进场,传过来的发车时间是最后一个班次的到达时间
  72 + if (isUp) { // 上行
  73 + _bcsj = paramObj.getUpInTime();
  74 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  75 + _stoptime = 0;
  76 + } else { // 下行
  77 + _bcsj = paramObj.getDownInTime();
  78 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  79 + _stoptime = 0;
  80 + }
  81 + } else if (bcType == "cf") { // 吃饭班次
  82 + // 以13:00为分界,之前的为午饭,之后的为晚饭
  83 + if (fcTimeObj.isBefore(paramObj.toTimeObj("13:00"))) {
  84 + _bcsj = paramObj.fnGetLunchTime();
  85 + } else {
  86 + _bcsj = paramObj.fnGetDinnerTime();
  87 + }
  88 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  89 + _stoptime = 0;
  90 + }
  91 +
  92 + var bcParamObj = {};
  93 + bcParamObj.bcType = bcType; // 班次类型(normal,in_,out, bd, lc, cf等)
  94 + bcParamObj.isUp = isUp; // boolean是否上下行
  95 + bcParamObj.fcno = fcno; // 发车顺序号
  96 + bcParamObj.fcTimeObj = _fcsj; // 发车时间对象
  97 + bcParamObj.bclc = _bclc; // 班次里程
  98 + bcParamObj.bcsj = _bcsj; // 班次历时
  99 + bcParamObj.arrtime = _arrsj; // 到达时间对象
  100 + bcParamObj.stoptime = _stoptime; // 停站时间
  101 + bcParamObj.tccid = _tccid; // 停车场id
  102 + bcParamObj.ttinfoid = _ttinfoid; // 时刻表id
  103 + bcParamObj.xl = _xl; // 线路id
  104 + bcParamObj.qdzid = _qdz; // 起点站id
  105 + bcParamObj.zdzid = _zdz; // 终点站id
  106 +
  107 + return new InternalBcObj(lpObj, bcParamObj);
  108 + }
  109 + };
  110 +
  111 + var _funCalcuExportData_lpObjList = function(aInternalLpObj) {
  112 + // 构造路牌对象
  113 + var aLpObj = [];
  114 + var i;
  115 + var j;
  116 + var z;
  117 + var oInternalLp;
  118 + var oInternalBc;
  119 + var oInternalBc_temp;
  120 + var oLp;
  121 + var iZlc;
  122 + var iYylc;
  123 + var iKslc;
  124 + var iZbc;
  125 + var iZgs;
  126 + var iYygs;
  127 + var iYybc;
  128 + for (i = 0; i < aInternalLpObj.length; i++) {
  129 + oInternalLp = aInternalLpObj[i];
  130 + iZlc = 0;
  131 + iYylc = 0;
  132 + iKslc = 0;
  133 + iZgs = 0;
  134 + iZbc = 0;
  135 + iYygs = 0;
  136 + iYybc = 0;
  137 + oLp = {
  138 + "lpname": oInternalLp.getLpName(), // 路牌名字
  139 + "isUp": oInternalLp.isUp(), // 每圈的第一个班次是否上行
  140 + "bcObjList": [], // 班次列表
  141 + "groupCount": oInternalLp.fnGetGroupCount(), // 总圈数
  142 + "zlc": 0, // 总里程
  143 + "yylc": 0, // 营运里程
  144 + "kslc": 0, // 空驶里程
  145 + "zgs": 0, // 总工时
  146 + "zbc": 0, // 总班次
  147 + "yygs": 0, // 营运工时
  148 + "yybc": 0, // 营运班次
  149 + "stationRouteId1": 0, // 第一个班次起点站路由id
  150 + "stationRouteId2": 0 // 第二个班次起点站路由id
  151 + };
  152 +
  153 + // 将报到班次,进出场班次加到班次的时间上
  154 + var iBcChainCount;
  155 + var oStartBc;
  156 + var oEndBc;
  157 + var oTempBc;
  158 + var aFcsj = [];
  159 +
  160 + iBcChainCount = oInternalLp.fnGetBcChainCount();
  161 + if (iBcChainCount == 1) { // 单一车次链,连班班型
  162 + oStartBc = oInternalLp.getBc(
  163 + oInternalLp.fnGetBcChainInfo(0)["s_q"],
  164 + oInternalLp.fnGetBcChainInfo(0)["s_b"]
  165 + );
  166 + oTempBc = _factory.createBcObj(
  167 + oLp, "bd", oStartBc.isUp(), 1,
  168 + oStartBc.getFcTimeObj(),
  169 + _paramObj
  170 + );
  171 + aFcsj.push("(到" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  172 + oLp.bcObjList.push({ // 报到班次
  173 + "bcsj": oTempBc.getBcTime(), // 班次时间
  174 + "ssj": oTempBc.getStopTime(), // 停站时间
  175 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  176 +
  177 + "tccid": oTempBc._$_tccid, // 停车场id
  178 + "qdzid": oTempBc._$_qdzid, // 起点站id
  179 + "zdzid": oTempBc._$_zdzid, // 终点站id
  180 +
  181 + "isUp": oTempBc._$_isUp, // 是否上行
  182 + "isFb": false, // 是否分班
  183 +
  184 + "bcType": oTempBc._$_bcType, // 班次类型
  185 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  186 +
  187 + "groupNo": -1, // 第几圈
  188 + "groupBcNo": -1 // 圈里第几个班次
  189 +
  190 + });
  191 +
  192 + oTempBc = _factory.createBcObj(
  193 + oLp, "out", oStartBc.isUp(), 1,
  194 + oStartBc.getFcTimeObj(),
  195 + _paramObj
  196 + );
  197 + aFcsj.push("(出" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  198 + aFcsj.push("(" + oStartBc.getFcTimeObj().format("HH:mm") + ")");
  199 + oStartBc._$_fcsj_desc = aFcsj.join("");
  200 +
  201 + oLp.bcObjList.push({ // 出场班次
  202 + "bcsj": oTempBc.getBcTime(), // 班次时间
  203 + "ssj": oTempBc.getStopTime(), // 停站时间
  204 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  205 +
  206 + "tccid": oTempBc._$_tccid, // 停车场id
  207 + "qdzid": oTempBc._$_qdzid, // 起点站id
  208 + "zdzid": oTempBc._$_zdzid, // 终点站id
  209 +
  210 + "isUp": oTempBc._$_isUp, // 是否上行
  211 + "isFb": false, // 是否分班
  212 +
  213 + "bcType": oTempBc._$_bcType, // 班次类型
  214 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  215 +
  216 + "groupNo": -1, // 第几圈
  217 + "groupBcNo": -2 // 圈里第几个班次
  218 +
  219 + });
  220 +
  221 + aFcsj = [];
  222 +
  223 + oEndBc = oInternalLp.getBc(
  224 + oInternalLp.fnGetBcChainInfo(0)["e_q"],
  225 + oInternalLp.fnGetBcChainInfo(0)["e_b"]
  226 + );
  227 + aFcsj.push("(" + oEndBc.getFcTimeObj().format("HH:mm") + ")");
  228 + oTempBc = _factory.createBcObj(
  229 + oLp, "in", !oEndBc.isUp(), 1,
  230 + oEndBc.getArrTimeObj(),
  231 + _paramObj
  232 + );
  233 + aFcsj.push("(进" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  234 +
  235 + oLp.bcObjList.push({ // 进场班次
  236 + "bcsj": oTempBc.getBcTime(), // 班次时间
  237 + "ssj": oTempBc.getStopTime(), // 停站时间
  238 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  239 +
  240 + "tccid": oTempBc._$_tccid, // 停车场id
  241 + "qdzid": oTempBc._$_qdzid, // 起点站id
  242 + "zdzid": oTempBc._$_zdzid, // 终点站id
  243 +
  244 + "isUp": oTempBc._$_isUp, // 是否上行
  245 + "isFb": false, // 是否分班
  246 +
  247 + "bcType": oTempBc._$_bcType, // 班次类型
  248 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  249 +
  250 + "groupNo": oInternalLp.fnGetBcChainInfo(0)["e_b"] == 0 ?
  251 + oInternalLp.fnGetBcChainInfo(0)["e_q"] :
  252 + oInternalLp.fnGetBcChainInfo(0)["e_q"] + 1, // 第几圈
  253 + "groupBcNo": oInternalLp.fnGetBcChainInfo(0)["e_b"] == 0 ? 1 : 0 // 圈里第几个班次
  254 +
  255 + });
  256 +
  257 + oTempBc = _factory.createBcObj(
  258 + oLp, "lc", !oEndBc.isUp(), 1,
  259 + oEndBc.getArrTimeObj(),
  260 + _paramObj
  261 + );
  262 + aFcsj.push("(离" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  263 + oLp.bcObjList.push({ // 离场班次
  264 + "bcsj": oTempBc.getBcTime(), // 班次时间
  265 + "ssj": oTempBc.getStopTime(), // 停站时间
  266 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  267 +
  268 + "tccid": oTempBc._$_tccid, // 停车场id
  269 + "qdzid": oTempBc._$_qdzid, // 起点站id
  270 + "zdzid": oTempBc._$_zdzid, // 终点站id
  271 +
  272 + "isUp": oTempBc._$_isUp, // 是否上行
  273 + "isFb": false, // 是否分班
  274 +
  275 + "bcType": oTempBc._$_bcType, // 班次类型
  276 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  277 +
  278 + "groupNo": -2, // 第几圈
  279 + "groupBcNo": -4 // 圈里第几个班次
  280 +
  281 + });
  282 +
  283 + oEndBc._$_fcsj_desc = aFcsj.join("");
  284 +
  285 + } else if (iBcChainCount == 2) { // 两个车次链,分班班型
  286 + oStartBc = oInternalLp.getBc(
  287 + oInternalLp.fnGetBcChainInfo(0)["s_q"],
  288 + oInternalLp.fnGetBcChainInfo(0)["s_b"]
  289 + );
  290 + oTempBc = _factory.createBcObj(
  291 + oLp, "bd", oStartBc.isUp(), 1,
  292 + oStartBc.getFcTimeObj(),
  293 + _paramObj
  294 + );
  295 + aFcsj.push("(到" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  296 + oLp.bcObjList.push({ // 报到班次
  297 + "bcsj": oTempBc.getBcTime(), // 班次时间
  298 + "ssj": oTempBc.getStopTime(), // 停站时间
  299 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  300 +
  301 + "tccid": oTempBc._$_tccid, // 停车场id
  302 + "qdzid": oTempBc._$_qdzid, // 起点站id
  303 + "zdzid": oTempBc._$_zdzid, // 终点站id
  304 +
  305 + "isUp": oTempBc._$_isUp, // 是否上行
  306 + "isFb": false, // 是否分班
  307 +
  308 + "bcType": oTempBc._$_bcType, // 班次类型
  309 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  310 +
  311 + "groupNo": -1, // 第几圈
  312 + "groupBcNo": -1 // 圈里第几个班次
  313 +
  314 + });
  315 +
  316 + oTempBc = _factory.createBcObj(
  317 + oLp, "out", oStartBc.isUp(), 1,
  318 + oStartBc.getFcTimeObj(),
  319 + _paramObj
  320 + );
  321 + aFcsj.push("(出" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  322 + aFcsj.push("(" + oStartBc.getFcTimeObj().format("HH:mm") + ")");
  323 + oStartBc._$_fcsj_desc = aFcsj.join("");
  324 +
  325 + oLp.bcObjList.push({ // 出场班次
  326 + "bcsj": oTempBc.getBcTime(), // 班次时间
  327 + "ssj": oTempBc.getStopTime(), // 停站时间
  328 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  329 +
  330 + "tccid": oTempBc._$_tccid, // 停车场id
  331 + "qdzid": oTempBc._$_qdzid, // 起点站id
  332 + "zdzid": oTempBc._$_zdzid, // 终点站id
  333 +
  334 + "isUp": oTempBc._$_isUp, // 是否上行
  335 + "isFb": false, // 是否分班
  336 +
  337 + "bcType": oTempBc._$_bcType, // 班次类型
  338 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  339 +
  340 + "groupNo": -1, // 第几圈
  341 + "groupBcNo": -2 // 圈里第几个班次
  342 +
  343 + });
  344 +
  345 + aFcsj = [];
  346 +
  347 + oEndBc = oInternalLp.getBc(
  348 + oInternalLp.fnGetBcChainInfo(0)["e_q"],
  349 + oInternalLp.fnGetBcChainInfo(0)["e_b"]
  350 + );
  351 + aFcsj.push("(" + oEndBc.getFcTimeObj().format("HH:mm") + ")");
  352 + oTempBc = _factory.createBcObj(
  353 + oLp, "in", !oEndBc.isUp(), 1,
  354 + oEndBc.getArrTimeObj(),
  355 + _paramObj
  356 + );
  357 + aFcsj.push("(进" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  358 + oLp.bcObjList.push({ // 进场班次
  359 + "bcsj": oTempBc.getBcTime(), // 班次时间
  360 + "ssj": oTempBc.getStopTime(), // 停站时间
  361 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  362 +
  363 + "tccid": oTempBc._$_tccid, // 停车场id
  364 + "qdzid": oTempBc._$_qdzid, // 起点站id
  365 + "zdzid": oTempBc._$_zdzid, // 终点站id
  366 +
  367 + "isUp": oTempBc._$_isUp, // 是否上行
  368 + "isFb": true, // 是否分班
  369 +
  370 + "bcType": oTempBc._$_bcType, // 班次类型
  371 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  372 +
  373 + "groupNo": oInternalLp.fnGetBcChainInfo(0)["e_b"] == 0 ?
  374 + oInternalLp.fnGetBcChainInfo(0)["e_q"] :
  375 + oInternalLp.fnGetBcChainInfo(0)["e_q"] + 1, // 第几圈
  376 + "groupBcNo": oInternalLp.fnGetBcChainInfo(0)["e_b"] == 0 ? 1 : 0 // 圈里第几个班次
  377 +
  378 + });
  379 + oEndBc._$_fcsj_desc = aFcsj.join("");
  380 +
  381 + aFcsj = [];
  382 +
  383 + oStartBc = oInternalLp.getBc(
  384 + oInternalLp.fnGetBcChainInfo(1)["s_q"],
  385 + oInternalLp.fnGetBcChainInfo(1)["s_b"]
  386 + );
  387 + oTempBc = _factory.createBcObj(
  388 + oLp, "bd", oStartBc.isUp(), 1,
  389 + oStartBc.getFcTimeObj(),
  390 + _paramObj
  391 + );
  392 + aFcsj.push("(到" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  393 + oLp.bcObjList.push({ // 报到班次
  394 + "bcsj": oTempBc.getBcTime(), // 班次时间
  395 + "ssj": oTempBc.getStopTime(), // 停站时间
  396 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  397 +
  398 + "tccid": oTempBc._$_tccid, // 停车场id
  399 + "qdzid": oTempBc._$_qdzid, // 起点站id
  400 + "zdzid": oTempBc._$_zdzid, // 终点站id
  401 +
  402 + "isUp": oTempBc._$_isUp, // 是否上行
  403 + "isFb": true, // 是否分班
  404 +
  405 + "bcType": oTempBc._$_bcType, // 班次类型
  406 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  407 +
  408 + "groupNo": oInternalLp.fnGetBcChainInfo(1)["s_q"] - 1, // 第几圈
  409 + "groupBcNo": oInternalLp.fnGetBcChainInfo(1)["s_b"] // 圈里第几个班次
  410 +
  411 + });
  412 +
  413 + oTempBc = _factory.createBcObj(
  414 + oLp, "out", oStartBc.isUp(), 1,
  415 + oStartBc.getFcTimeObj(),
  416 + _paramObj
  417 + );
  418 + oLp.bcObjList.push({ // 出场班次
  419 + "bcsj": oTempBc.getBcTime(), // 班次时间
  420 + "ssj": oTempBc.getStopTime(), // 停站时间
  421 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  422 +
  423 + "tccid": oTempBc._$_tccid, // 停车场id
  424 + "qdzid": oTempBc._$_qdzid, // 起点站id
  425 + "zdzid": oTempBc._$_zdzid, // 终点站id
  426 +
  427 + "isUp": oTempBc._$_isUp, // 是否上行
  428 + "isFb": true, // 是否分班
  429 +
  430 + "bcType": oTempBc._$_bcType, // 班次类型
  431 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  432 +
  433 + "groupNo": oInternalLp.fnGetBcChainInfo(1)["s_b"] == 0 ?
  434 + oInternalLp.fnGetBcChainInfo(1)["s_q"] - 1 :
  435 + oInternalLp.fnGetBcChainInfo(1)["s_q"], // 第几圈
  436 + "groupBcNo": oInternalLp.fnGetBcChainInfo(1)["s_b"] == 0 ? 1 : 0 // 圈里第几个班次
  437 +
  438 + });
  439 + aFcsj.push("(出" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  440 + aFcsj.push("(" + oStartBc.getFcTimeObj().format("HH:mm") + ")");
  441 + oStartBc._$_fcsj_desc = aFcsj.join("");
  442 +
  443 + aFcsj = [];
  444 +
  445 + oEndBc = oInternalLp.getBc(
  446 + oInternalLp.fnGetBcChainInfo(1)["e_q"],
  447 + oInternalLp.fnGetBcChainInfo(1)["e_b"]
  448 + );
  449 + aFcsj.push("(" + oEndBc.getFcTimeObj().format("HH:mm") + ")");
  450 + oTempBc = _factory.createBcObj(
  451 + oLp, "in", !oEndBc.isUp(), 1,
  452 + oEndBc.getArrTimeObj(),
  453 + _paramObj
  454 + );
  455 + aFcsj.push("(进" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  456 +
  457 + oLp.bcObjList.push({ // 进场班次
  458 + "bcsj": oTempBc.getBcTime(), // 班次时间
  459 + "ssj": oTempBc.getStopTime(), // 停站时间
  460 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  461 +
  462 + "tccid": oTempBc._$_tccid, // 停车场id
  463 + "qdzid": oTempBc._$_qdzid, // 起点站id
  464 + "zdzid": oTempBc._$_zdzid, // 终点站id
  465 +
  466 + "isUp": oTempBc._$_isUp, // 是否上行
  467 + "isFb": false, // 是否分班
  468 +
  469 + "bcType": oTempBc._$_bcType, // 班次类型
  470 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  471 +
  472 + "groupNo": oInternalLp.fnGetBcChainInfo(1)["e_b"] == 0 ?
  473 + oInternalLp.fnGetBcChainInfo(1)["e_q"] :
  474 + oInternalLp.fnGetBcChainInfo(1)["e_q"] + 1, // 第几圈
  475 + "groupBcNo": oInternalLp.fnGetBcChainInfo(1)["e_b"] == 0 ? 1 : 0 // 圈里第几个班次
  476 +
  477 + });
  478 +
  479 + oTempBc = _factory.createBcObj(
  480 + oLp, "lc", !oEndBc.isUp(), 1,
  481 + oEndBc.getArrTimeObj(),
  482 + _paramObj
  483 + );
  484 +
  485 + oLp.bcObjList.push({ // 离场班次
  486 + "bcsj": oTempBc.getBcTime(), // 班次时间
  487 + "ssj": oTempBc.getStopTime(), // 停站时间
  488 + "eatsj": oTempBc.fnGetEatTime(), // 吃饭时间
  489 +
  490 + "tccid": oTempBc._$_tccid, // 停车场id
  491 + "qdzid": oTempBc._$_qdzid, // 起点站id
  492 + "zdzid": oTempBc._$_zdzid, // 终点站id
  493 +
  494 + "isUp": oTempBc._$_isUp, // 是否上行
  495 + "isFb": false, // 是否分班
  496 +
  497 + "bcType": oTempBc._$_bcType, // 班次类型
  498 + "fcsj": oTempBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  499 +
  500 + "groupNo": -2, // 第几圈
  501 + "groupBcNo": -4 // 圈里第几个班次
  502 +
  503 + });
  504 +
  505 + aFcsj.push("(离" + oTempBc.getFcTimeObj().format("HH:mm") + ")");
  506 + oEndBc._$_fcsj_desc = aFcsj.join("");
  507 +
  508 + }
  509 +
  510 + for (j = 0; j < oInternalLp.fnGetGroupCount(); j++) {
  511 + for (z = 0; z < 2; z++) {
  512 + oInternalBc = oInternalLp.getBc(j, z);
  513 + if (oInternalBc) {
  514 + if (oInternalBc.fnGetEatTime() > 0) {
  515 + // 和v2版本不一样,有吃饭时间就是吃饭班次
  516 + oInternalBc._$_isRealEat = true;
  517 + oInternalBc._$_fcsj_desc = "(吃" + oInternalBc.getFcTimeObj().format("HH:mm") + ")";
  518 + }
  519 +
  520 + oLp.bcObjList.push({
  521 + "bcsj": oInternalBc.getBcTime(), // 班次时间
  522 + "ssj": oInternalBc.getStopTime(), // 停站时间
  523 + "eatsj": oInternalBc.fnGetEatTime(), // 吃饭时间
  524 +
  525 + "tccid": oInternalBc._$_tccid, // 停车场id
  526 + "qdzid": oInternalBc._$_qdzid, // 起点站id
  527 + "zdzid": oInternalBc._$_zdzid, // 终点站id
  528 +
  529 + "isUp": oInternalBc._$_isUp, // 是否上行
  530 +
  531 + "bcType": oInternalBc._$_bcType, // 班次类型
  532 + "fcsj": oInternalBc._$_isRealEat ?
  533 + ("*" + oInternalBc._$_fcsjObj.format("HH:mm")) :
  534 + oInternalBc._$_fcsjObj.format("HH:mm"), // 发车时间描述
  535 + "fcsjDesc" : oInternalBc._$_fcsj_desc || oInternalBc._$_fcsjObj.format("HH:mm"),
  536 +
  537 + "groupNo": j, // 第几圈
  538 + "groupBcNo": z // 圈里第几个班次
  539 +
  540 + });
  541 +
  542 + // iZlc = 0;
  543 + // iYylc = 0;
  544 + // iKslc = 0;
  545 + // iZgs = 0;
  546 + // iZbc = 0;
  547 + // iYygs = 0;
  548 + // iYybc = 0;
  549 +
  550 + iZlc = iZlc +
  551 + oInternalBc._$_bclc; // 里程
  552 + iYylc = iYylc +
  553 + oInternalBc._$_bclc; // 里程
  554 + iYygs = iYygs +
  555 + oInternalBc.getBcTime() + // 班次时间
  556 + oInternalBc.getStopTime() + // 停站时间
  557 + oInternalBc.fnGetEatTime(); // 吃饭时间
  558 + iYybc = iYybc + 1;
  559 +
  560 + iZgs = iZgs +
  561 + oInternalBc.getBcTime() + // 班次时间
  562 + oInternalBc.getStopTime() + // 停站时间
  563 + oInternalBc.fnGetEatTime(); // 吃饭时间
  564 + iZbc = iZbc + 1;
  565 +
  566 + // 设置圈站点路由id
  567 + if (oInternalBc.isUp() == oInternalLp.isUp()) { // 第一个班次
  568 + if (oLp.stationRouteId1 == 0) {
  569 + oLp.stationRouteId1 = oInternalBc._$_qdzid;
  570 + }
  571 + } else { // 第二个班次
  572 + if (oLp.stationRouteId2 == 0) {
  573 + oLp.stationRouteId2 = oInternalBc._$_qdzid;
  574 + }
  575 + }
  576 +
  577 + }
  578 + }
  579 +
  580 + }
  581 +
  582 + for (z = 0; z < oInternalLp.getOtherBcArray().length; z++) {
  583 + oInternalBc = oInternalLp.getOtherBcArray()[z];
  584 + iKslc = iKslc +
  585 + oInternalBc._$_bclc; // 里程
  586 + iZlc = iZlc +
  587 + oInternalBc._$_bclc; // 里程
  588 + iZgs = iZgs +
  589 + oInternalBc.getBcTime() + // 班次时间
  590 + oInternalBc.getStopTime(); // 停站时间
  591 + if (oInternalBc._$_bcType != "bd" &&
  592 + oInternalBc._$_bcType != "lc" &&
  593 + oInternalBc._$_bcType != "cf") {
  594 + iZbc = iZbc + 1;
  595 + }
  596 + }
  597 +
  598 + oLp.zlc = iZlc;
  599 + oLp.yylc = iYylc;
  600 + oLp.kslc = iKslc;
  601 + oLp.zgs = iZgs;
  602 + oLp.zbc = iZbc;
  603 + oLp.yygs = iYygs;
  604 + oLp.yybc = iYybc;
  605 + aLpObj.push(oLp);
  606 + }
  607 +
  608 + return aLpObj;
  609 + };
  610 +
  611 + var _funCalcuExportData_statInfoList = function(aInternalLpObj) {
  612 + var countBc = 0, // 总班次
  613 + serviceBc = 0, // 营运班次
  614 + jcbc = 0, // 进场总班次.
  615 + ccbc = 0, // 出场总班次.
  616 + cfbc = 0, // 吃饭总班次.
  617 + zwlbbc = 0, // 早晚例保总班次.
  618 + countGs = 0.0, // 总工时
  619 + servicesj = 0, // 营运班次总时间
  620 + jcsj = 0.0, // 进场总时间.
  621 + ccsj = 0.0, // 出场总时间.
  622 + cfsj = 0.0, // 吃饭总时间.
  623 + zwlbsj = 0.0, // 早晚例保总时间.
  624 + ksBc = 0, // 空驶班次
  625 + serviceLc = 0.0, // 营运里程
  626 + ksLc = 0.0, // 空驶里程
  627 + avgTzjx = 0.0, // 平均停站间隙
  628 + gfServiceBc = 0, // 高峰营运班次
  629 + dgServiceBc = 0, // 低谷营运班次
  630 + gfAvgTzjx = 0.0, // 高峰平均停站间隙
  631 + dgAvgTzjx = 0.0; // 低谷平均停站间隙
  632 +
  633 + var aAllBc = [];
  634 + var oLp;
  635 + var oBc;
  636 + var i;
  637 + var j;
  638 +
  639 + for (i = 0; i < aInternalLpObj.length; i++) {
  640 + oLp = aInternalLpObj[i];
  641 + for (j = 0; j < oLp.getBcArray().length; j++) {
  642 + aAllBc.push(oLp.getBcArray()[j]);
  643 + }
  644 + for (j = 0; j < oLp.getOtherBcArray().length; j++) {
  645 + aAllBc.push(oLp.getOtherBcArray()[j]);
  646 + }
  647 + }
  648 +
  649 + for (i = 0; i < aAllBc.length; i++) {
  650 + oBc = aAllBc[i];
  651 +
  652 + if (oBc.getBcTime() > 0) {
  653 + countBc = countBc + 1;
  654 + countGs = countGs + oBc.getStopTime() + oBc.getBcTime();
  655 + if (_paramObj.isTroughBc(oBc.getFcTimeObj())) {
  656 + if (oBc._$_bcType == "normal") {
  657 + dgServiceBc = dgServiceBc + 1;
  658 + dgAvgTzjx = dgAvgTzjx + oBc.getStopTime();
  659 + }
  660 + } else {
  661 + if (oBc._$_bcType == "normal") {
  662 + gfServiceBc = gfServiceBc + 1;
  663 + gfAvgTzjx = gfAvgTzjx + oBc.getStopTime();
  664 + }
  665 + }
  666 +
  667 + if (oBc._$_bcType == "normal") {
  668 + serviceBc = serviceBc + 1;
  669 + serviceLc = serviceLc + oBc._$_bclc;
  670 + servicesj = servicesj + oBc.getBcTime();
  671 + avgTzjx = avgTzjx + oBc.getStopTime();
  672 +
  673 + if (oBc.fnGetEatTime() > 0) {
  674 + cfbc = cfbc + 1;
  675 + cfsj = cfsj + oBc.fnGetEatTime();
  676 + }
  677 + } else if (oBc._$_bcType == "in") {
  678 + jcbc = jcbc + 1;
  679 + jcsj = jcsj + oBc.getBcTime();
  680 + } else if (oBc._$_bcType == "out") {
  681 + ccbc = ccbc + 1;
  682 + ccsj = ccsj + oBc.getBcTime();
  683 + } else if (oBc._$_bcType == "bd") {
  684 + zwlbbc = zwlbbc + 1;
  685 + zwlbsj = zwlbsj + oBc.getBcTime();
  686 + } else if (oBc._$_bcType == "lc") {
  687 + zwlbbc = zwlbbc + 1;
  688 + zwlbsj = zwlbsj + oBc.getBcTime();
  689 + }
  690 + }
  691 + }
  692 +
  693 + dgAvgTzjx = dgAvgTzjx / dgServiceBc;
  694 + gfAvgTzjx = gfAvgTzjx / gfServiceBc;
  695 + avgTzjx = avgTzjx / dgServiceBc;
  696 +
  697 + return [
  698 + {'statItem': '总班次(包括进出场、吃饭时间、早晚例保、营运且班次时间大于零的班次)', 'statValue': countBc},
  699 + {'statItem': '进场总班次(包括进场且班次时间大于零的班次)', 'statValue': jcbc},
  700 + {'statItem': '出场总班次(包括进场且班次时间大于零的班次)', 'statValue': ccbc},
  701 + {'statItem': '吃饭总班次(包括吃饭且班次时间大于零的班次)', 'statValue': cfbc},
  702 + {'statItem': '早晚例保总班次(包括早晚例保且时间大于零的班次)', 'statValue': zwlbbc},
  703 + {'statItem': '营运总班次(包括正常、区间、放大站且班次时间大于零班次)','statValue': serviceBc},
  704 + {'statItem': '进场总时间(包括进场班次且班次时间大于零)', 'statValue': jcsj/60},
  705 + {'statItem': '出场总时间(包括进场班次且班次时间大于零)', 'statValue': ccsj/60},
  706 + {'statItem': '吃饭总时间(包括吃饭班次且班次时间大于零)', 'statValue': cfsj/60},
  707 + {'statItem': '早晚例保总时间(包括早晚例保班次且时间大于零的)', 'statValue': zwlbsj/60},
  708 + {'statItem': '营运班次总时间(包括正常、区间、放大站且班次时间大于零)', 'statValue': servicesj/60},
  709 + {'statItem': '总工时(包括进出场、吃饭时间、早晚例保、营运班次时间)', 'statValue': countGs/60},
  710 + {'statItem': '空驶班次(包括直放班次)', 'statValue': ksBc},
  711 + {'statItem': '营运里程(包括正常、区间、放大站里程)', 'statValue': serviceLc},
  712 + {'statItem': '空驶里程(包括直放里程)', 'statValue': ksLc},
  713 + {'statItem': '平均停站时间(营运班次停站时间总和/营运总班次)', 'statValue': avgTzjx},
  714 + {'statItem': '高峰营运班次(包括早晚高峰时段的正常、区间、放大站班次)', 'statValue': gfServiceBc},
  715 + {'statItem': '低谷营运班次(包括低谷时段的正常、区间、放大站班次)', 'statValue': dgServiceBc},
  716 + {'statItem': '高峰平均停站间隙(高峰营运班次停站时间总和/高峰营运班次总和)', 'statValue': gfAvgTzjx},
  717 + {'statItem': '低谷平均停站间隙(低谷营运班次停站时间总和/低谷营运班次总和)', 'statValue': dgAvgTzjx},
  718 + {'statItem': '综合评估', 'statValue': 3}
  719 + ];
  720 +
  721 + };
  722 +
  723 + var __funCalcuExportData_paramInfoList = function() {
  724 + return [
  725 + {'paramItem' : '上行首班时间', 'paramValue' : _paramObj.getUpFirstDTimeObj().format("HH:mm")},
  726 + {'paramItem' : '上行末班时间', 'paramValue' : _paramObj.getUpLastDtimeObj().format("HH:mm")},
  727 + {'paramItem' : '下行首班时间', 'paramValue' : _paramObj.getDownFirstDTimeObj().format("HH:mm")},
  728 + {'paramItem' : '下行末班时间', 'paramValue' : _paramObj.getDownLastDTimeObj().format("HH:mm")},
  729 + {'paramItem' : '早高峰开始时间', 'paramValue' : _paramObj.getMPeakStartTimeObj().format("HH:mm")},
  730 + {'paramItem' : '早高峰结束时间', 'paramValue' : _paramObj.getMPeakEndTimeObj().format("HH:mm")},
  731 + {'paramItem' : '晚高峰开始时间', 'paramValue' : _paramObj.getEPeakStartTimeObj().format("HH:mm")},
  732 + {'paramItem' : '晚高峰结束时间', 'paramValue' : _paramObj.getEPeakEndTimeObj().format("HH:mm")},
  733 + {'paramItem' : '上行进场时间', 'paramValue' : _paramObj.getUpInTime()},
  734 + {'paramItem' : '上行出场时间', 'paramValue' : _paramObj.getUpOutTime()},
  735 + {'paramItem' : '下行进场时间', 'paramValue' : _paramObj.getDownInTime()},
  736 + {'paramItem' : '下行出场时间', 'paramValue' : _paramObj.getDownOutTime()},
  737 + {'paramItem' : '早高峰上行时间', 'paramValue' : _paramObj.getUpMPeakTime()},
  738 + {'paramItem' : '早高峰下行时间', 'paramValue' : _paramObj.getDownMPeakTime()},
  739 + {'paramItem' : '晚高峰上行时间', 'paramValue' : _paramObj.getUpEPeakTime()},
  740 + {'paramItem' : '晚高峰下行时间', 'paramValue' : _paramObj.getDownEPeakTime()},
  741 + {'paramItem' : '低谷上行时间', 'paramValue' : _paramObj.getUpTroughTime()},
  742 + {'paramItem' : '低谷下行时间', 'paramValue' : _paramObj.getDownTroughTime()},
  743 + {'paramItem' : '线路规划类型', 'paramValue' : "双向"},
  744 + {'paramItem' : '吃饭地点', 'paramValue' : _paramObj.fnIsEat() ? (_paramObj.fnIsBothEat() ? "上下行" : (_paramObj.fnIsUpEat() ? "上行" : "下行")) : "不吃饭"},
  745 + {'paramItem' : '早晚例行保养', 'paramValue' : _paramObj.getLbTime()},
  746 + {'paramItem' : '停车场', 'paramValue' : _paramObj.getTccId()},
  747 + {'paramItem' : '工作餐午餐时间', 'paramValue' : _paramObj.fnGetLunchTime()},
  748 + {'paramItem' : '工作餐晚餐时间', 'paramValue' : _paramObj.fnGetDinnerTime()},
  749 + {'paramItem' : '早高峰发车间隔', 'paramValue' : "[" + _paramObj.getMPeakMinFcjx() + "," + _paramObj.getMPeakMaxFcjx() + "]"},
  750 + {'paramItem' : '晚高峰发车间隔', 'paramValue' : "[" + _paramObj.getEPeakMinFcjx() + "," + _paramObj.getEPeakMaxFcjx() + "]"},
  751 + {'paramItem' : '低谷发车间隔', 'paramValue' : "[" + _paramObj.getTroughMinFcjx() + "," + _paramObj.getTroughMaxFcjx() + "]"},
  752 + {'paramItem' : '建议加班路牌数', 'paramValue' : _paramObj.getJBLpes()},
  753 + {'paramItem' : '停站类型', 'paramValue' : _paramObj.isTwoWayStop() ? "双向停站" : (_paramObj.isUpOneWayStop() ? "上行主站" : "下行主站") },
  754 + {'paramItem' : '建议高峰配车数', 'paramValue' : _paramObj.getAdvicePeakClzs()}
  755 + ]
  756 + };
  757 +
  758 + return {
  759 + /**
  760 + * 使用发车间隔策略生成时刻表。
  761 + * @param paramObj 参数对象
  762 + * @param lpArray 路牌数组
  763 + * @constructor
  764 + */
  765 + BXPplaceClassesTime03 : function(paramObj, lpArray) {
  766 + // 参数对象
  767 + _paramObj = paramObj;
  768 +
  769 + // 1、初始化行车计划
  770 + var schedule = new InternalScheduleObj_v2_2(paramObj, lpArray);
  771 + // 2、生成班次
  772 + schedule.fnCreateBclistWithMasterBc();
  773 + // 3、标记吃饭班次
  774 + schedule.fnFlagEatBc();
  775 + // 4、计算末班车
  776 + schedule.fnCalcuLastBc();
  777 + // 5、修正停站时间
  778 + schedule.fnModifyLayoverTime();
  779 + // 6、补进出场例保班次
  780 + schedule.fnCalcuOtherBc();
  781 +
  782 + // TODO
  783 +
  784 + //-------------------- 输出ganut图上的班次,班型描述 ----------------------//
  785 + // TODO:班型再议
  786 + return {
  787 + 'json':schedule.fnToGanttBcArray(),'bxrcgs':null,
  788 + 'aInternalLpObj': schedule.fnGetLpArray()
  789 + };
  790 + },
  791 +
  792 + //----------------------------------- 导入导出方法 -----------------------------------//
  793 +
  794 + /**
  795 + * 导出时刻表配置。
  796 + * @param aInternalLpObj 内部路牌对象列表
  797 + */
  798 + exportDataConfig: function(aInternalLpObj) {
  799 + $('.exportAddXls').off('click');
  800 + $('.exportAddXlsx').off('click');
  801 +
  802 + $('.exportAddXls').on('click', function() {
  803 + var aInfos = {
  804 + "lpObjList": _funCalcuExportData_lpObjList(aInternalLpObj), // 路牌班次信息列表
  805 + "statInfoList": _funCalcuExportData_statInfoList(aInternalLpObj), // 统计项目列表
  806 + "parameterInfoList" : __funCalcuExportData_paramInfoList() // 参数对象
  807 + };
  808 +
  809 + console.log(aInfos);
  810 +
  811 + $(".exportAdd").addClass("disabled");
  812 + $(".exportAddSpan").html("正在导出...");
  813 +
  814 + // 提交
  815 + $.ajax({
  816 + type: 'POST',
  817 + url: "/tidc/exportDTDFile/xls",
  818 + dataType: 'binary',
  819 + contentType: "application/json",
  820 + data: JSON.stringify(aInfos),
  821 + success: function(data){
  822 + Main_v2.downloadFile(data, "application/octet-stream", "时刻表信息.xls");
  823 +
  824 + $(".exportAdd").removeClass("disabled");
  825 + $(".exportAddSpan").html(" 导出数据");
  826 + },
  827 + error: function(xhr, type){
  828 + alert('错误:TODO');
  829 +
  830 + $(".exportAdd").removeClass("disabled");
  831 + $(".exportAddSpan").html(" 导出数据");
  832 + }
  833 + });
  834 + });
  835 +
  836 + $('.exportAddXlsx').on('click', function() {
  837 + var aInfos = {
  838 + "lpObjList": _funCalcuExportData_lpObjList(aInternalLpObj), // 路牌班次信息列表
  839 + "statInfoList": _funCalcuExportData_statInfoList(aInternalLpObj), // 统计项目列表
  840 + "parameterInfoList" : __funCalcuExportData_paramInfoList() // 参数对象
  841 + };
  842 +
  843 + console.log(aInfos);
  844 +
  845 + $(".exportAdd").addClass("disabled");
  846 + $(".exportAddSpan").html("正在导出...");
  847 +
  848 + // 提交
  849 + $.ajax({
  850 + type: 'POST',
  851 + url: "/tidc/exportDTDFile/xlsx",
  852 + dataType: 'binary',
  853 + contentType: "application/json",
  854 + data: JSON.stringify(aInfos),
  855 + success: function(data){
  856 + Main_v2.downloadFile(data, "application/octet-stream", "时刻表信息.xlsx");
  857 +
  858 + $(".exportAdd").removeClass("disabled");
  859 + $(".exportAddSpan").html(" 导出数据");
  860 + },
  861 + error: function(xhr, type){
  862 + alert('错误:TODO');
  863 +
  864 + $(".exportAdd").removeClass("disabled");
  865 + $(".exportAddSpan").html(" 导出数据");
  866 + }
  867 + });
  868 + });
  869 + },
  870 +
  871 + downloadFile: function (data, mimeType, fileName) {
  872 + var success = false;
  873 + var blob = new Blob([data], { type: mimeType });
  874 + try {
  875 + if (navigator.msSaveBlob)
  876 + navigator.msSaveBlob(blob, fileName);
  877 + else {
  878 + // Try using other saveBlob implementations, if available
  879 + var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;
  880 + if (saveBlob === undefined) throw "Not supported";
  881 + saveBlob(blob, fileName);
  882 + }
  883 + success = true;
  884 + } catch (ex) {
  885 + console.log("saveBlob method failed with the following exception:");
  886 + console.log(ex);
  887 + }
  888 +
  889 + if (!success) {
  890 + // Get the blob url creator
  891 + var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
  892 + if (urlCreator) {
  893 + // Try to use a download link
  894 + var link = document.createElement('a');
  895 + if ('download' in link) {
  896 + // Try to simulate a click
  897 + try {
  898 + // Prepare a blob URL
  899 + var url = urlCreator.createObjectURL(blob);
  900 + link.setAttribute('href', url);
  901 +
  902 + // Set the download attribute (Supported in Chrome 14+ / Firefox 20+)
  903 + link.setAttribute("download", fileName);
  904 +
  905 + // Simulate clicking the download link
  906 + var event = document.createEvent('MouseEvents');
  907 + event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
  908 + link.dispatchEvent(event);
  909 + success = true;
  910 +
  911 + } catch (ex) {
  912 + console.log("Download link method with simulated click failed with the following exception:");
  913 + console.log(ex);
  914 + }
  915 + }
  916 +
  917 + if (!success) {
  918 + // Fallback to window.location method
  919 + try {
  920 + // Prepare a blob URL
  921 + // Use application/octet-stream when using window.location to force download
  922 + var url = urlCreator.createObjectURL(blob);
  923 + window.location = url;
  924 + console.log("Download link method with window.location succeeded");
  925 + success = true;
  926 + } catch (ex) {
  927 + console.log("Download link method with window.location failed with the following exception:");
  928 + console.log(ex);
  929 + }
  930 + }
  931 + }
  932 + }
  933 +
  934 + if (!success) {
  935 + // Fallback to window.open method
  936 + console.log("No methods worked for saving the arraybuffer, using last resort window.open");
  937 + window.open("", '_blank', '');
  938 + }
  939 + }
  940 + }
  941 +}();
0 \ No newline at end of file 942 \ No newline at end of file
src/main/resources/static/pages/base/timesmodel/paramadd.html
1 -<!-- 统计数据 -->  
2 -<style>  
3 - .form-control:focus {  
4 - border-color: #53ced9;  
5 - }  
6 - .tagsDiv {  
7 - border: 1px solid #c2cad8;  
8 - margin-left: 15px;  
9 - padding: 4px 15px 4px 15px;  
10 - width: 50%;  
11 - }  
12 -</style>  
13 -<div class="modal fade" id="paramadd_mobal" tabindex="-1" role="basic" aria-hidden="true">  
14 - <div class="modal-dialog" style="margin-left: 100px;">  
15 - <div class="modal-content" style="width: 1000px;">  
16 - <div class="modal-header">  
17 - <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>  
18 - <h4 class="modal-title">参数数据 </h4>  
19 - </div>  
20 - <div class="modal-body">  
21 - <form class="form-horizontal" id="param_form" action="/" method="POST" novalidate="novalidate">  
22 - <div class="form-body">  
23 - <div class="alert alert-danger display-hide">  
24 - <button class="close" data-close="alert"></button>  
25 - 您的输入有误,请检查下面的输入项  
26 - </div>  
27 - <div class="alert alert-success display-none">  
28 - <button class="close" data-dismiss="alert"></button>  
29 - 验证成功!  
30 - </div>  
31 -  
32 - </div>  
33 -  
34 - <div class="tab-pane" id="ptab">  
35 -  
36 - </div>  
37 - </form>  
38 - </div>  
39 -  
40 - <div class="modal-footer">  
41 - <button type="button" class="btn default" data-dismiss="modal" id="paramcancel">  
42 - <span class="paramcancelSpan">取消</span>  
43 - </button>  
44 - <button type="button" class="btn btn-primary" id="paramnext">  
45 - <span class="paramnextSpan">确定</span>  
46 - </button>  
47 - </div>  
48 -  
49 - </div>  
50 - </div>  
51 -</div>  
52 -  
53 -<script type="text/html" id = "paramAdd_temp">  
54 - <div class="form-group">  
55 - <div class="col-md-6">  
56 - <label class="control-label col-md-5">  
57 - <span class="required"> * </span> 上行首班时间 :  
58 - </label>  
59 - <div class="col-md-5">  
60 - <input type="text" class="form-control" name="startStationFirstTime" value="{{map.startStationFirstTime}}" id="startStationFirstTime_id"  
61 - placeholder="请输入起始站首班时间">  
62 - </div>  
63 - </div>  
64 - <div class="col-md-6">  
65 - <label class="control-label col-md-5">  
66 - <span class="required"> * </span> 上行末班时间 :  
67 - </label>  
68 - <div class="col-md-5">  
69 - <input type="text" class="form-control" name="startStationEndTime" value="{{map.startStationEndTime}}" id="startStationEndTime_id"  
70 - placeholder="请输入起始站末班时间">  
71 - </div>  
72 - </div>  
73 - </div>  
74 -  
75 - <div class="form-group">  
76 - <div class="col-md-6">  
77 - <label class="control-label col-md-5">  
78 - <span class="required"> * </span> 下行首班时间 :  
79 - </label>  
80 - <div class="col-md-5">  
81 - <input type="text" class="form-control" name="endStationFirstTime" value="{{map.endStationFirstTime}}" id="endStationFirstTime_id"  
82 - placeholder="请输入终点站首班时间">  
83 - </div>  
84 - </div>  
85 - <div class="col-md-6">  
86 - <label class="control-label col-md-5">  
87 - <span class="required"> * </span> 下行末班时间 :  
88 - </label>  
89 - <div class="col-md-5">  
90 - <input type="text" class="form-control" name="endStationEndTime" value="{{map.endStationEndTime}}" id="endStationEndTime_id"  
91 - placeholder="请输入终点站末班时间">  
92 - </div>  
93 - </div>  
94 - </div>  
95 -  
96 - <div class="form-group">  
97 - <div class="col-md-6">  
98 - <label class="control-label col-md-5">  
99 - <span class="required"> * </span> 早高峰开始时间 :  
100 - </label>  
101 - <div class="col-md-5">  
102 - <input type="text" class="form-control" name="earlyStartTime" value="{{map.earlyStartTime}}" id="earlyStartTime_id"  
103 - placeholder="请输入早高峰开始时间">  
104 - </div>  
105 - </div>  
106 - <div class="col-md-6">  
107 - <label class="control-label col-md-5">  
108 - <span class="required"> * </span> 早高峰结束时间 :  
109 - </label>  
110 - <div class="col-md-5">  
111 - <input type="text" class="form-control" name="earlyEndTime" value="{{map.earlyEndTime}}" id="earlyEndTime_id"  
112 - placeholder="请输入早高峰结束时间">  
113 - </div>  
114 - </div>  
115 - </div>  
116 -  
117 - <div class="form-group">  
118 - <div class="col-md-6">  
119 - <label class="control-label col-md-5">  
120 - <span class="required"> * </span> 晚高峰开始时间 :  
121 - </label>  
122 - <div class="col-md-5">  
123 - <input type="text" class="form-control" name="lateStartTime" value="{{map.lateStartTime}}" id="lateStartTime_id"  
124 - placeholder="请输入晚高峰开始时间">  
125 - </div>  
126 - </div>  
127 - <div class="col-md-6">  
128 - <label class="control-label col-md-5">  
129 - <span class="required"> * </span> 晚高峰结束时间 :  
130 - </label>  
131 - <div class="col-md-5">  
132 - <input type="text" class="form-control" name="lateEndTime" value="{{map.lateEndTime}}" id="lateEndTime_id"  
133 - placeholder="请输入晚高峰结束时间">  
134 - </div>  
135 - </div>  
136 - </div>  
137 -  
138 - <div class="form-group">  
139 - <div class="col-md-6">  
140 - <label class="control-label col-md-5">上行进场时间  :  
141 - </label>  
142 - <div class="col-md-5">  
143 - <input type="text" class="form-control" name="upInTimer" value="{{map.upInTimer}}" id="upInTimer_id"  
144 - placeholder="请输入上行进场时间">  
145 - </div>  
146 - </div>  
147 - <div class="col-md-6">  
148 - <label class="control-label col-md-5">上行出场时间  :  
149 - </label>  
150 - <div class="col-md-5">  
151 - <input type="text" class="form-control" name="upOutTimer" value="{{map.upOutTimer}}" id="upOutTimer_id"  
152 - placeholder="请输入上行出场时间">  
153 - </div>  
154 - </div>  
155 - </div>  
156 -  
157 - <div class="form-group">  
158 - <div class="col-md-6">  
159 - <label class="control-label col-md-5">下行进场时间  :  
160 - </label>  
161 - <div class="col-md-5">  
162 - <input type="text" class="form-control" name="downInTimer" value="{{map.downInTimer}}" id="downInTimer_id"  
163 - placeholder="请输入下行进场时间">  
164 - </div>  
165 - </div>  
166 - <div class="col-md-6">  
167 - <label class="control-label col-md-5">下行出场时间  :  
168 - </label>  
169 - <div class="col-md-5">  
170 - <input type="text" class="form-control" name="downOutTimer" value="{{map.downOutTimer}}" id="downOutTimer_id"  
171 - placeholder="请输入下行出场时间">  
172 - </div>  
173 - </div>  
174 - </div>  
175 -  
176 - <div class="form-group">  
177 - <div class="col-md-6">  
178 - <label class="control-label col-md-5">早高峰上行时间 :</label>  
179 - <div class="col-md-5">  
180 - <input type="text" class="form-control" name="earlyUpTime" value="{{map.earlyUpTime}}" id="earlyUpTime_id"  
181 - placeholder="请输入早高峰上行时间">  
182 - </div>  
183 - </div>  
184 - <div class="col-md-6">  
185 - <label class="control-label col-md-5">早高峰下行时间 :</label>  
186 - <div class="col-md-5">  
187 - <input type="text" class="form-control" name="earlyDownTime" value="{{map.earlyDownTime}}" id="earlyDownTime_id"  
188 - placeholder="请输入早高峰下行时间">  
189 - </div>  
190 - </div>  
191 - </div>  
192 -  
193 - <div class="form-group">  
194 - <div class="col-md-6">  
195 - <label class="control-label col-md-5">晚高峰上行时间 :</label>  
196 - <div class="col-md-5">  
197 - <input type="text" class="form-control" name="lateUpTime" value="{{map.lateUpTime}}" id="lateUpTime_id"  
198 - placeholder="请输入晚高峰上行时间">  
199 - </div>  
200 - </div>  
201 - <div class="col-md-6">  
202 - <label class="control-label col-md-5">晚高峰下行时间 :</label>  
203 - <div class="col-md-5">  
204 - <input type="text" class="form-control" name="lateDownTime" value="{{map.lateDownTime}}" id="lateDownTime_id"  
205 - placeholder="请输入晚高峰下行时间">  
206 - </div>  
207 - </div>  
208 - </div>  
209 -  
210 - <div class="form-group">  
211 - <div class="col-md-6">  
212 - <label class="control-label col-md-5">低谷上行时间  :</label>  
213 - <div class="col-md-5">  
214 - <input type="text" class="form-control" name="troughUpTime" value="{{map.troughUpTime}}" id="troughUpTime_id"  
215 - placeholder="请输入低谷上行时间">  
216 - </div>  
217 - </div>  
218 - <div class="col-md-6">  
219 - <label class="control-label col-md-5">低谷下行时间  :</label>  
220 - <div class="col-md-5">  
221 - <input type="text" class="form-control" name="troughDownTime" value="{{map.troughDownTime}}" id="troughDownTime_id"  
222 - placeholder="请输入低谷下行时间">  
223 - </div>  
224 - </div>  
225 - </div>  
226 -  
227 - <div class="form-group">  
228 - <div class="col-md-6">  
229 - <label class="control-label col-md-5">  
230 - <span class="required"> * </span> 线路规划类型  :  
231 - </label>  
232 - <div class="col-md-5">  
233 - <select name="linePlayType" class="form-control" id="linePlayType_id">  
234 - <option value="">-- 请选择线路类型 --</option>  
235 - <option value="0">双向</option>  
236 - <option value="1">环线</option>  
237 - </select>  
238 - </div>  
239 - </div>  
240 - <div class="col-md-6">  
241 - <label class="control-label col-md-5">吃饭地点    :</label>  
242 - <div class="col-md-5">  
243 - <select type="text" class="form-control" name="cfdd" id="cfdd_id">  
244 - <option value="">请选择...</option>  
245 - <option value="0">{{map.startStationName}}</option>  
246 - <option value="1">{{map.endStationName}}</option>  
247 - <option value="allYes">起终点站都可以</option>  
248 - </select>  
249 - </div>  
250 - </div>  
251 - </div>  
252 -  
253 - <div class="form-group">  
254 - <div class="col-md-6">  
255 - <label class="control-label col-md-5">早晚例行保养  :</label>  
256 - <div class="col-md-5">  
257 - <input type="text" class="form-control" name="lb" value="{{map.lb}}" id="lb_id"  
258 - placeholder="请输入早晚例行保养">  
259 - </div>  
260 - </div>  
261 - <div class="col-md-6">  
262 - <label class="control-label col-md-5">停车场     :</label>  
263 - <div class="col-md-5">  
264 - <select name="carPark" class="form-control" id="carPark_id" style="width:100%"></select>  
265 - </div>  
266 - </div>  
267 - </div>  
268 -  
269 -  
270 - <div class="form-group">  
271 - <div class="col-md-6">  
272 - <label class="control-label col-md-5">工作餐午餐时间 :</label>  
273 - <div class="col-md-5">  
274 - <input type="text" class="form-control" name="workeLunch" value="{{map.workeLunch}}" id="workeLunch_id"  
275 - placeholder="请输入工作餐午餐时间">  
276 - </div>  
277 - </div>  
278 - <div class="col-md-6">  
279 - <label class="control-label col-md-5">工作餐晚餐时间 :</label>  
280 - <div class="col-md-5">  
281 - <input type="text" class="form-control" name="workeDinner" value="{{map.workeDinner}}" id="workeDinner_id"  
282 - placeholder="请输入工作餐晚餐时间">  
283 - </div>  
284 - </div>  
285 - </div>  
286 -  
287 - <div class="form-group">  
288 - <div class="col-md-6">  
289 - <label class="control-label col-md-5"><span class="required"> * </span>早高峰发车间隔 :</label>  
290 - <div class="col-md-3" style="padding-right: 0px;">  
291 - <input type="text" class="form-control" name="zgffcjxmin" value="{{map.zgffcjxmin}}" id="zgffcjxmin_id"  
292 - placeholder="最小间隔">  
293 - </div>  
294 - <div class="col-md-1" style="padding-top: 10px; font-size: 85%;">至</div>  
295 - <div class="col-md-3" style="padding-left: 0px;">  
296 - <input type="text" class="form-control" name="zgffcjxmax" value="{{map.zgffcjxmax}}" id="zgffcjxmax_id"  
297 - placeholder="最大间隔">  
298 - </div>  
299 - </div>  
300 - <div class="col-md-6">  
301 - <label class="control-label col-md-5"><span class="required"> * </span>晚高峰发车间隔 :</label>  
302 - <div class="col-md-3" style="padding-right: 0px;">  
303 - <input type="text" class="form-control" name="wffcjxmin" value="{{map.wffcjxmin}}" id="wffcjxmin_id"  
304 - placeholder="最小间隔">  
305 - </div>  
306 - <div class="col-md-1" style="padding-top: 10px; font-size: 85%;">至</div>  
307 - <div class="col-md-3" style="padding-left: 0px;">  
308 - <input type="text" class="form-control" name="wffcjxmax" value="{{map.wffcjxmax}}" id="wffcjxmax_id"  
309 - placeholder="最大间隔">  
310 - </div>  
311 - </div>  
312 - </div>  
313 -  
314 - <div class="form-group">  
315 - <div class="col-md-6">  
316 - <label class="control-label col-md-5"><span class="required"> * </span>低谷发车间隔 :</label>  
317 - <div class="col-md-3" style="padding-right: 0px;">  
318 - <input type="text" class="form-control" name="dgfcjxmin" value="{{map.dgfcjxmin}}" id="dgfcjxmin_id"  
319 - placeholder="最小间隔">  
320 - </div>  
321 - <div class="col-md-1" style="padding-top: 10px; font-size: 85%;">至</div>  
322 - <div class="col-md-3" style="padding-left: 0px;">  
323 - <input type="text" class="form-control" name="dgfcjxmax" value="{{map.dgfcjxmax}}" id="dgfcjxmax_id"  
324 - placeholder="最大间隔">  
325 - </div>  
326 - </div>  
327 - <div class="col-md-6">  
328 - <label class="control-label col-md-5"><span class="required"> * </span>建议加班路牌数 :</label>  
329 - <div class="col-md-5">  
330 - <input type="text" class="form-control" name="jbclcount" value="{{map.jbclcount}}" id="jbclcount_id"  
331 - placeholder="为0表示是周末时刻表">  
332 - </div>  
333 - </div>  
334 - </div>  
335 -  
336 - <div class="form-group">  
337 - <div class="col-md-6">  
338 - <label class="control-label col-md-5"><span class="required"> * </span>停站类型 :</label>  
339 - <div class="col-md-5 tagsDiv">  
340 - <div class="row" style="margin-left: 15px;">  
341 - <input type="text" value="{{map.stt}}" name="stt" id="stoptype_tagsinput" style="display: none;">  
342 - </div>  
343 -  
344 - <div class="row" style="margin-top: 10px;">  
345 - <label class="control-label col-md-4">停站类型:</label>  
346 - <div class="col-md-8">  
347 - <select name="stopType" class="form-control" id="stopType_id">  
348 - <option value="">-- 请选择停站类型 --</option>  
349 - <option value="0">主站停站</option>  
350 - <option value="1">双向停站</option>  
351 - </select>  
352 - </div>  
353 - </div>  
354 -  
355 - <div class="row" style="margin-top: 10px;">  
356 - <label class="control-label col-md-4">主站:</label>  
357 - <div class="col-md-8">  
358 - <select name="masterStop" class="form-control" id="masterStop_id">  
359 - <option value="">请选择...</option>  
360 - <option value="0">{{map.startStationName}}</option>  
361 - <option value="1">{{map.endStationName}}</option>  
362 - </select>  
363 - </div>  
364 - </div>  
365 -  
366 - <div class="row" style="margin-top: 10px;margin-left: 116px;">  
367 - <a href="javascript:" class="btn red" id="stoptype_tagsinput_add">添加</a>  
368 - </div>  
369 - </div>  
370 -  
371 - </div>  
372 -  
373 - <div class="col-md-6">  
374 - <div class="form-group">  
375 - <label class="control-label col-md-5">  
376 - <span class="required"> * </span> 建议高峰配车数 :</label>  
377 - <div class="col-md-5">  
378 - <input type="text" class="form-control" placeholder="车辆数" name="gfjypcs"  
379 - id="gfjypcsInput" min="1" value="{{map.gfjypcs}}">  
380 - </div>  
381 - </div>  
382 - <div class="form-group">  
383 - <label class="control-label col-md-5">  
384 - <span class="required"> * </span> 生成策略  :  
385 - </label>  
386 - <div class="col-md-5">  
387 - <select name="strategy" class="form-control" id="strategy_id">  
388 - <option value="AdjustTripS1" selected>AdjustTripS1</option>  
389 - <option value="AdjustTripS2" disabled>AdjustTripS2</option>  
390 - <option value="AdjustTripS3">AdjustTripS3</option>  
391 - <option value="AdjustTripS4">AdjustTripS4</option>  
392 - </select>  
393 - </div>  
394 - </div>  
395 - </div>  
396 -  
397 -  
398 - </div>  
399 -  
400 -  
401 - <!-- 隐藏字段-时间 -->  
402 - <input type="hidden" name="skbName" value="{{map.skbName}}" id="skbName_id"/>  
403 - <input type="hidden" name="skbmc" value="{{map.skbmc}}" id="skbmc_id"/>  
404 - <input type="hidden" name="xlmc" value="{{map.xlmc}}" id="xlmc_id"/>  
405 - <input type="hidden" name="lineName" value="{{map.lineName}}" id="lineName_id"/>  
406 - <input type="hidden" name="lineVersion" value="{{map.lineVersion}}" id="lineVersion_id"/>  
407 -  
408 - <!-- 上下行行驶时间 -->  
409 - <input type="hidden" name="upTravelTime" value="{{map.upTravelTime}}" id="upTravelTime_id"/>  
410 - <input type="hidden" name="downTravelTime" value="{{map.downTravelTime}}" id="downTravelTime_id"/>  
411 -  
412 - <!-- 隐藏字段-里程 -->  
413 - <!-- 上下行行驶里程 -->  
414 - <input type="hidden" name="upMileage" value="{{map.upMileage}}" id="upMileage_id"/>  
415 - <input type="hidden" name="downMileage" value="{{map.downMileage}}" id="downMileage_id"/>  
416 - <!-- 上下行进场出场里程 -->  
417 - <input type="hidden" name="upInMileage" value="{{map.upInMileage}}" id="upInMileage_id"/>  
418 - <input type="hidden" name="downInMileage" value="{{map.downInMileage}}" id="downInMileage_id"/>  
419 - <input type="hidden" name="upOutMileage" value="{{map.upOutMileage}}" id="upOutMileage_id"/>  
420 - <input type="hidden" name="downOutMileage" value="{{map.downOutMileage}}" id="downOutMileage_id"/>  
421 -  
422 -  
423 -</script>  
424 -  
425 -<script type="text/javascript">  
426 - $('#paramadd_mobal').on('paramAddMobal.show', function(e, mainFun){  
427 -  
428 - var _mainFun = mainFun;  
429 -  
430 - // 加载延迟200毫秒显示mobal  
431 - setTimeout(function(){$('#paramadd_mobal').modal({show : true,backdrop: 'static', keyboard: false});},200);  
432 - var param = JSON.parse(window.localStorage.Gantt_AgursData);  
433 -  
434 - // 获取表单元素  
435 - var form = $('#param_form');  
436 - // 错误提示元素  
437 - var paramAlert = $('.alert-danger', form);  
438 - // 确定事件点击  
439 - $('#paramnext').on('click', function() {  
440 - $("#paramcancel").addClass("disabled");  
441 - $("#paramnext").addClass("disabled");  
442 - $(".paramnextSpan").html("正在生成...");  
443 -  
444 - setTimeout(function() {  
445 - form.submit();// 表单提交  
446 - }, 500);  
447 -  
448 - // $("#paramnext").removeClass("disabled");  
449 - // $("#paramnext").html("确定");  
450 - });  
451 -  
452 - // 表单验证  
453 - form.validate({  
454 - errorElement : 'span',  
455 - errorClass : 'help-block help-block-error',  
456 - focusInvalid : false,  
457 - rules: {  
458 - 'skbName' : {required : true,},// 时刻表名称,必填项.  
459 - 'lineName' : {required : true,},// 线路名称,必填项.  
460 - 'lineVersion': {required: true}, // 站点路由版本,必填项,  
461 - 'startStationFirstTime' : {required : true}, // 起始站首班时间,必填项.  
462 - 'startStationEndTime' : {required : true}, // 起始站末班时间 ,必填项.  
463 - 'endStationFirstTime' : {required : true}, // 终点站首班时间 ,必填项.  
464 - 'endStationEndTime' : {required : true}, // 终点站末班时间,必填项.  
465 - 'earlyStartTime' : {required : true},// 早高峰开始时间,必填项 .  
466 - 'earlyEndTime' : {required : true},// 早高峰结束时间,必填项 .  
467 - 'lateStartTime' : {required : true},// 晚高峰开始时间,必填项 .  
468 - 'lateEndTime' : {required : true},// 晚高峰结束时间,必填项.  
469 - 'upInTimer' : {number : true},// 上行进场时间,必须为数字.  
470 - 'upOutTimer' : {number : true},// 上行出场时间,必须为数字.  
471 - 'downInTimer' : {number : true},// 下行进场时间,必须为数字.  
472 - 'downOutTimer' : {number : true},// 下行出场时间,必须为数字.  
473 - 'earlyUpTime' : {number : true},// 早高峰上行时间,必须为数字.  
474 - 'earlyDownTime' : {number : true},// 早高峰下行时间,必须为数字.  
475 - 'lateUpTime' : {number : true},// 晚高峰上行时间,必须为数字.  
476 - 'lateDownTime' : {number : true},// 晚高峰下行时间,必须为数字.  
477 - 'troughUpTime' : {number : true},// 低谷上行时间,必须为数字.  
478 - 'troughDownTime' : {number : true},// 低谷下行时间,必须为数字.  
479 - 'linePlayType' : {required : true},// 线路规划类型,必填项  
480 - 'lb' : {number : true},// 早晚例行保养,必须为数字.  
481 - 'workeLunch' : {number : true},// 工作餐午餐时间,必须为数字.  
482 - 'workeDinner' : {number : true},// 工作餐晚餐时间,必须为数字.  
483 - 'zgffcjxmin' : {required : true,number : true,digits: true},// 早高峰最小发车间隔.  
484 - 'zgffcjxmax' : {required : true,number : true,digits: true},// 早高峰最大发车间隔.  
485 - 'wffcjxmin' : {required : true,number : true,digits: true},// 晚高峰最小发车间隔.  
486 - 'wffcjxmax' : {required : true,number : true,digits: true},// 晚高峰最大发车间隔.  
487 - 'dgfcjxmin' : {required : true,number : true,digits: true},// 低谷最小发车间隔.  
488 - 'dgfcjxmax' : {required : true,number : true,digits: true},// 低谷最大发车间隔.  
489 - 'jbclcount': {required : true,number : true,digits: true}, // 建议加班车数  
490 - 'upTravelTime' : {required : true,number : true},// 上行行驶时间,必填项、必须为整数.  
491 - 'downTravelTime' : {required : true,number : true},// 下行行驶时间,必填项、必须为整数.  
492 - 'upMileage' : {required : true,number : true},// 上行行驶里程,必填项、必须为整数.  
493 - 'downMileage' : {required : true,number : true},// 下行行驶里程,必填项、必须为整数.  
494 - 'upInMileage' : {number : true},// 上行进场里程,必须为数字.  
495 - 'upOutMileage' : {number : true},// 上行出场里程,必须为数字.  
496 - 'downInMileage' : {number : true},// 下行进场里程,必须为数字.  
497 - 'downOutMileage' : {number : true}, // 下行出场里程,必须为数字.  
498 -  
499 - 'strategy' : {required : true} // 生成策略标识  
500 -  
501 - // TODO  
502 - },  
503 - invalidHandler : function(event, validator) {  
504 - paramAlert.show();  
505 - App.scrollTo(paramAlert, -200);  
506 - },  
507 - highlight : function(element) {  
508 - $(element).closest('.form-group').addClass('has-error');  
509 - },  
510 - unhighlight : function(element) {  
511 - $(element).closest('.form-group').removeClass('has-error');  
512 - },  
513 - success : function(label) {  
514 - label.closest('.form-group').removeClass('has-error');  
515 - },  
516 - submitHandler : function(f) {  
517 - // 1、 获取表单内容,并序列化  
518 - var fp = form.serializeJSON();  
519 -  
520 - console.log(fp);  
521 -  
522 - // 2、重新刷新表单数据  
523 - var ganttMap = JSON.parse(window.localStorage.Gantt_AgursData);  
524 - var key;  
525 - for (key in fp) {  
526 - if (ganttMap[key]) {  
527 - if (ganttMap[key] != fp[key]) {  
528 - ganttMap[key] = fp[key];  
529 - }  
530 - } else {  
531 - ganttMap[key] = fp[key];  
532 - }  
533 - }  
534 - window.localStorage.setItem("Gantt_AgursData",JSON.stringify(ganttMap));  
535 -  
536 - // TODO  
537 - var pp = getParamObjAndDataMap();  
538 - var paramObj = pp[0];  
539 - var dataMap = pp[1];  
540 - var csMap = getCSMap(paramObj);  
541 - // console.log(graph);  
542 -  
543 - var data = _mainFun.BXPplaceClassesTime03(paramObj, csMap.maxCar);  
544 - _mainFun.exportDataConfig(data.aInternalLpObj);  
545 -  
546 - // var data = obj.getDataArray();  
547 - // // 2、 调整路牌对应的班次总数  
548 - // updFormParams(params,data);  
549 - // 删除图形.  
550 - $('svg.svg-chart').remove();  
551 - // 重新创建图形.  
552 - var graph = d3.select('#ganttSvg').relationshipGraph(getGraphArgus(csMap, dataMap, data));  
553 - // 根据数据重新渲染图形.  
554 - graph.data(data.json);  
555 - // 记录早操.并保存历史班次数据  
556 - graph.addHistory();  
557 - // 隐藏错误提示  
558 - paramAlert.hide();  
559 - // 隐藏 reladplus_mobal 弹出层  
560 - $('#paramadd_mobal').modal('hide');  
561 - layer.msg('成功!');  
562 - }  
563 - });  
564 -  
565 -  
566 - // 当模态框对用户可见时触发(将等待 CSS 过渡效果完成)。  
567 - $('#paramadd_mobal').on('show.bs.modal', function () {  
568 - // TODO  
569 - // 把数据填充到模版中  
570 - // var tbodyHtml = template('countAdd_temp',{list:countDate});  
571 - // // 把渲染好的模版html文本追加到表格中  
572 - // $('#datatable_countadd tbody').html(tbodyHtml);  
573 - var htmldata = template('paramAdd_temp', {map : param});  
574 - $('#ptab').html(htmldata);  
575 -  
576 - // 线路规划类型  
577 - $('#linePlayType_id').val(param.linePlayType);  
578 - // 策略类型  
579 - $('#strategy_id').val(param.strategy || "AdjustTripS1");  
580 - // 吃饭地点  
581 - $get('/stationroute/all', {  
582 - 'line.id_eq': param.lineName.split('_')[0],  
583 - 'destroy_eq': 0,  
584 - 'versions_eq': param.lineVersion},  
585 - function(result) {  
586 - var opt = [];  
587 - opt.push('<option value="">请选择...</option>');  
588 - $.each(result, function(i, d) {  
589 - if (d.stationMark == 'B' && d.directions == 0) {  
590 - opt.push("<option value='0'>" + d.stationName + "</option>");  
591 - } else if (d.stationMark == 'E' && d.directions == 0) {  
592 - opt.push("<option value='1'>" + d.stationName + "</option>");  
593 - }  
594 - });  
595 - initTagsinput(opt.join(","));  
596 -  
597 - opt.push("<option value='allYes'>起终点站都可以</option>");  
598 - $('#cfdd_id').html(opt.join(""));  
599 - $('#cfdd_id').val(param.cfdd);  
600 -  
601 - }  
602 - );  
603 - // 停车场  
604 - $get('/carpark/all',null, function(cd) {  
605 - var opt = [];  
606 - opt.push('<option value="">请选择...</option><optgroup label="停车场">');  
607 - var $_len = cd.length;  
608 - if($_len > 0) {  
609 - $.each(cd, function(i, d){  
610 - opt.push('<option value="'+d.parkCode+'">'+d.parkName+'</option>');  
611 - });  
612 - }  
613 - opt.push('</optgroup>');  
614 - $('#carPark_id').html(opt.join(",")).select2();  
615 - $('#carPark_id').select2("val", param.carPark);  
616 - });  
617 -  
618 - // 上下行首末班日期控件  
619 - $('#startStationFirstTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});  
620 - $('#startStationEndTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});  
621 - $('#endStationFirstTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});  
622 - $('#endStationEndTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});  
623 -  
624 - // 早高峰晚高峰日期控件  
625 - $('#earlyStartTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});  
626 - $('#earlyEndTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});  
627 - $('#lateStartTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});  
628 - $('#lateEndTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});  
629 -  
630 - });  
631 -  
632 -  
633 -  
634 - //--------------------- 其他方法 ------------------------//  
635 -  
636 - function initTagsinput(htmlStr) {  
637 - $('#masterStop_id').html(htmlStr);  
638 -  
639 - var elt = $('#stoptype_tagsinput');  
640 - var value = elt.val();  
641 - var stoptype = value.split("/")[0];  
642 - var masterstop = value.split("/")[1];  
643 -  
644 - $('#stopType_id').val(stoptype);  
645 - $('#masterStop_id').val(masterstop);  
646 -  
647 - elt.tagsinput({  
648 - tagClass: function(item) {  
649 - return 'label label-danger label-important';  
650 - },  
651 - itemValue: 'value',  
652 - itemText: 'text'  
653 - });  
654 -  
655 - $('#stoptype_tagsinput').on('beforeItemAdd', function(event) {  
656 - // TODO:这里可以做一些逻辑判定  
657 - });  
658 -  
659 - $('#stoptype_tagsinput_add').on('click', function(){  
660 - var stoptype = $("#stopType_id").val();  
661 - var masterstop = $("#masterStop_id").val();  
662 - var masterstop_text = $("#masterStop_id option:selected").text();  
663 -  
664 - if (stoptype && stoptype != "") {  
665 - if (stoptype == "0" && masterstop && masterstop != "") {  
666 - elt.tagsinput('add', {  
667 - "value": stoptype + '/' + masterstop,  
668 - "text": "主站停站" + "/" + masterstop_text  
669 - });  
670 - } else {  
671 - elt.tagsinput('add', {  
672 - "value": 1,  
673 - "text": "双向停站"  
674 - });  
675 - }  
676 - }  
677 - });  
678 -  
679 - if (stoptype && stoptype != "") {  
680 - elt.tagsinput('add', {  
681 - "value": stoptype + '/' + masterstop,  
682 - "text":  
683 - $("#stopType_id option:selected").text() + "/" +  
684 - $("#masterStop_id option:selected").text()  
685 - });  
686 - }  
687 -  
688 - }  
689 -  
690 - function getMinDate(d1,d2) {  
691 - // 1、定义返回字符串.  
692 - var str = '';  
693 - // 2、判断时间大小.  
694 - if(strToTime(d1)>strToTime(d2))  
695 - str = d2;  
696 - else  
697 - str = d1;  
698 - // 3、返回最小时间(字符串).  
699 - return str;  
700 - }  
701 -  
702 - function strToTime(t) {  
703 - var d = new Date();  
704 - if(t) {  
705 - var _str = t.split(':');  
706 - d.setHours(parseInt(_str[0]));  
707 - d.setMinutes(parseInt(_str[1]));  
708 - }  
709 - return d;  
710 - }  
711 -  
712 - function getMaxDate(d1,d2) {  
713 - // 1、定义返回时间字符串.  
714 - var str = '';  
715 - // 2、判断时间大小.  
716 - if(strToTime(d1)>strToTime(d2))  
717 - str = d1;  
718 - else  
719 - str = d2;  
720 - // 3、返回一个最大时间(字符串).  
721 - return str;  
722 - }  
723 -  
724 - function getEndDate(date) {  
725 - var lastEndDate = Date.now();  
726 - if (date) {  
727 - var str = date.replace(/-/g,"/");  
728 - lastEndDate = new Date(str);  
729 - }  
730 - // Wed Oct 26 2016 00:00:00 GMT+0800 (中国标准时间)  
731 - return lastEndDate;  
732 - }  
733 -  
734 - function formatPairing(v1,v2) {  
735 - v1 = v1 == '' ? 0 : parseInt(v1);  
736 - v2 = v2 == ''? 0 : parseInt(v2) ;  
737 - return [v1,v2];  
738 - }  
739 -  
740 - function qzdz(zd1,zd2) {  
741 - return [zd1,zd2];  
742 - }  
743 -  
744 - function formatksjssj(gp) {  
745 - return [{'kssj':gp.startStationFirstTime,'jssj':gp.startStationEndTime},{'kssj':gp.endStationFirstTime,'jssj':gp.endStationEndTime}];  
746 - }  
747 -  
748 - function getsd(st,ed) {  
749 - return [{'st':st,'ed':ed}];  
750 - }  
751 -  
752 - function getDateTime(time) {  
753 - var dateTime = new Date();  
754 - var timeArr;  
755 - if(time !=null && time !='' && typeof(time) !='undefined') {  
756 - timeArr = time.split(':');  
757 - dateTime.setHours(parseInt(timeArr[0]));  
758 - dateTime.setMinutes(parseInt(timeArr[1]));  
759 - }  
760 - return dateTime;  
761 - }  
762 -  
763 - function getYAxisCarArray(len) {  
764 - var array = new Array();  
765 - if(len>0) {  
766 - for(var y = 0; y<len; y++) {  
767 - array.push({lp:null,lpNo:y+1, parent :y+1, lpName:y+1,lpType:'普通路牌'});//添加一个路牌对象  
768 - };  
769 - }  
770 - return array;  
771 - }  
772 -  
773 - function getylp(arr) {  
774 - var ra = new Array(),name = new Array();  
775 - for(var i = 0 ; i<arr.length;i++) {  
776 - ra.push(arr[i].lpNo);  
777 - name.push(arr[i].lpName);  
778 - }  
779 - return {'lpNoA':ra,'lpNameA':name,};  
780 - }  
781 -  
782 - function getParamObjAndDataMap() {  
783 - var map = JSON.parse(window.localStorage.Gantt_AgursData);  
784 - // seMap  
785 - var seMap = {'s': map.linePlayType == '1' ? map.startStationFirstTime : getMinDate(map.startStationFirstTime,map.endStationFirstTime),  
786 - 'e': map.linePlayType == '1' ? map.startStationEndTime : getMaxDate(map.startStationEndTime,map.endStationEndTime)};  
787 - // dirA  
788 - var dirA = ['relationshipGraph-up', 'relationshipGraph-down'];  
789 - // bcTypeArr  
790 - var bcTypeArr = {  
791 - 'bd': 'bd', 'out': 'out', 'normal': 'normal', 'cf': 'cf', 'in_': 'in', 'lc': 'lc',  
792 - 'major': 'major', 'venting': 'venting', 'region': 'region'  
793 - };  
794 - // seDate  
795 - var newDate = new Date();  
796 - var kssj = d3.time.hour.offset(getEndDate(  
797 - newDate.getFullYear()+ "-" +  
798 - (newDate.getMonth()+1) + "-" +  
799 - newDate.getDate() + ' ' +  
800 - seMap.s.split(':')[0] + ':00'),-1);  
801 -  
802 - var year = '' , month = '',dt = '';  
803 - if(newDate.getDate()+1>31)  
804 - dt = '01';  
805 - else  
806 - dt = newDate.getDate()+1;  
807 - if(newDate.getMonth()+1>12)  
808 - month = '01';  
809 - else if(newDate.getDate()+1>31)  
810 - month = newDate.getMonth()+2;  
811 - else  
812 - month = newDate.getMonth()+1;  
813 - if(newDate.getMonth()+1>12)  
814 - year = newDate.getFullYear()+1;  
815 - else  
816 - year = newDate.getFullYear();  
817 - var jssj = getEndDate(year + '-' + month + '-' + dt + ' ' + '00:00');  
818 - seDate = {'kssj' : kssj, 'jssj' : jssj};  
819 -  
820 - // dataMap  
821 - var dataMap = {'jcsjArr' : formatPairing(map.upInTimer,map.downInTimer),// 进场里程。[下标0代表上;下标1代表下]  
822 - 'ccsjArr' : formatPairing(map.upOutTimer,map.downOutTimer),// 出场时间。[下标0代表上;下标1代表下]  
823 - 'jclcArr' : formatPairing(map.upInMileage,map.downInMileage),// 进场里程。[下标0代表上;下标1代表下]  
824 - 'cclcArr' : formatPairing(map.upOutMileage,map.downOutMileage),// 出场里程。[下标0代表上;下标1代表下]  
825 - 'pcxssjArr' : formatPairing(map.upTravelTime,map.downTravelTime),// 平常行驶时间。[下标0代表上;下标1代表下]  
826 - 'gfxxsjArr' : formatPairing(map.lateUpTime=='' ? map.upTravelTime : map.lateUpTime,  
827 - map.lateDownTime=='' ? map.downTravelTime : map.lateDownTime),// 高峰行驶时间。[下标0代表上;下标1代表下]  
828 - 'dgxxsjArr' : formatPairing(map.troughUpTime=='' ? map.upTravelTime : map.troughUpTime,  
829 - map.troughDownTime=='' ? map.downTravelTime : map.troughDownTime),// 低谷行驶时间。[下标0代表上;下标1代表下]  
830 - 'pcxslcArr' : formatPairing(map.upMileage,map.downMileage),// 行驶里程。[下标0代表上;下标1代表下]  
831 - 'qdzArr' : qzdz(map.up_s.split('_')[0],map.down_s.split('_')[0]),// 起始站。[下标0代表上;下标1代表下]  
832 - 'zdzArr':qzdz(map.up_s.split('_')[1],map.down_s.split('_')[1]),// 终点站。[下标0代表上;下标1代表下]  
833 - 'zwcArr' : formatPairing(map.workeLunch,map.workeDinner),// 午晚餐时间。[下标0代表午;下标1代表晚]  
834 - 'smbcsjArr' : formatksjssj(map), // 起终点站首末班车时间.[下标0代表起始站的首末班车时间;下标1代表终点站的首末班车时间]  
835 - 'zgfsjd' : getsd(getDateTime(map.earlyStartTime),  
836 - getDateTime(map.earlyEndTime)), // 早高峰时间段  
837 - 'wgfsjd' : getsd(getDateTime(map.lateStartTime),  
838 - getDateTime(map.lateEndTime)),// 晚高峰时间段  
839 - 'gfzjsjd' : getsd(getDateTime(map.earlyEndTime),  
840 - getDateTime(map.lateStartTime)),//高峰之间时间段.  
841 - 'wgfzhsjd' : getsd(getDateTime(map.lateEndTime),  
842 - getDateTime(seMap.e)),// 晚高峰之后时间段  
843 - 'zgfzqsjd': getsd(getDateTime(seMap.s),  
844 - getDateTime(map.earlyStartTime)),//早高峰之前时间段.  
845 - 'dira' : dirA,// 方向集合 [下标0代表上;下标1代表下]  
846 - 'bcTypeArr' : bcTypeArr,// 班次类型  
847 - 'lbsj' : map.lb=='' ? 0:parseInt(map.lb),// 例保时间.  
848 - // 'minztjx' : parseInt(gatps.mixstopTime), // 最小停站时间.  
849 - // 'ztjxA' : BaseFun.formatPairing(gatps.upStopTime,gatps.downStopTime), // 停站时间.  
850 - // 'maxztjx' : parseInt(gatps.maxstopTime), // 最大停站时间.  
851 - 'gftzsj': formatPairing(map.gfupStopTime,map.gfdownStopTime),// 高峰停站时间.  
852 - 'dgtzsj' : formatPairing(map.dgupStopTime,map.dgdownStopTime),// 低谷停站时间.  
853 - 'dgmaxtzsj' : parseInt(map.dgmaxtzsj),// 低谷最大停站时间.  
854 - 'dgmaxfcjx' : parseInt(map.dgmaxfcjx),// 低谷最大发车间隙.  
855 - 'map' : map,  
856 - 'zzsj':map.zzsj,// 周转时间.  
857 - };  
858 -  
859 - var _paramObj = _mainFun.getFactory().createParameterObj(map, dataMap);  
860 - map.clzs = _paramObj.calcuClzx();  
861 - return [_paramObj, dataMap];  
862 -  
863 - }  
864 -  
865 - function getCSMap(parmObj) {  
866 - var map = JSON.parse(window.localStorage.Gantt_AgursData);  
867 - return {'gattA':null,  
868 - 'fcjx': {'gffcjx': Math.round(parmObj.calcuPeakZzsj()/parmObj.calcuClzx()) ,  
869 - 'dgfcjx': Math.round(parmObj.calcuTroughZzsj()/parmObj.calcuClzx()),  
870 - 'dgmaxfcjx' : parseInt(map.dgmaxfcjx)},  
871 - 'maxCar':getYAxisCarArray(parseInt(parmObj.calcuClzx()))};  
872 - }  
873 -  
874 - function getGraphArgus(CSMap, dataMap, data) {  
875 - // TODO  
876 - var map = JSON.parse(window.localStorage.Gantt_AgursData);  
877 - var sxsj = parseInt(map.upTravelTime);// 上行时间.  
878 -  
879 - // seMap  
880 - var seMap = {'s': map.linePlayType == '1' ? map.startStationFirstTime : getMinDate(map.startStationFirstTime,map.endStationFirstTime),  
881 - 'e': map.linePlayType == '1' ? map.startStationEndTime : getMaxDate(map.startStationEndTime,map.endStationEndTime)};  
882 -  
883 - // seDate  
884 - var newDate = new Date();  
885 - var kssj = d3.time.hour.offset(getEndDate(  
886 - newDate.getFullYear()+ "-" +  
887 - (newDate.getMonth()+1) + "-" +  
888 - newDate.getDate() + ' ' +  
889 - seMap.s.split(':')[0] + ':00'),-1);  
890 -  
891 - var year = '' , month = '',dt = '';  
892 - if(newDate.getDate()+1>31)  
893 - dt = '01';  
894 - else  
895 - dt = newDate.getDate()+1;  
896 - if(newDate.getMonth()+1>12)  
897 - month = '01';  
898 - else if(newDate.getDate()+1>31)  
899 - month = newDate.getMonth()+2;  
900 - else  
901 - month = newDate.getMonth()+1;  
902 - if(newDate.getMonth()+1>12)  
903 - year = newDate.getFullYear()+1;  
904 - else  
905 - year = newDate.getFullYear();  
906 - var jssj = getEndDate(year + '-' + month + '-' + dt + ' ' + '00:00');  
907 - seDate = {'kssj' : kssj, 'jssj' : jssj};  
908 -  
909 -  
910 - var bs = sxsj > 40 ? 4 : 2;  
911 - var MULTIPLE = Math.round(105/sxsj) >3 ? Math.round(90/sxsj) : Math.round(90/sxsj) *bs;  
912 - var VALUEKEYNAME = 'Worldwide Gross' ,  
913 - DXHOURS = 24,MINUTE = 60,WIDTH = DXHOURS*MINUTE,MARGINLEFT = 380,HEIGHT = CSMap.maxCar.length*60 + 240,  
914 - MARGINBOTTOM = 240,OFFSETX = 90,OFFSETY = 180,OFFSETUPY = 120,OFFSETDOWNY = 60,  
915 - STARTDATETIME = seDate.kssj ,ENDDATETIME = seDate.jssj ,TASKTYPES =CSMap.maxCar ,TICKFORMAT ='%H:%M' ,SHOWTOOLTIPS = true;  
916 - var dx_time = seDate.jssj.getTime() - seDate.kssj.getTime() ;  
917 - // 计算出相差天数  
918 - var days=Math.floor(dx_time/(24*3600*1000));  
919 - // 计算出小时数  
920 - var leave1=dx_time%(24*3600*1000); //计算天数后剩余的毫秒数  
921 - var hours=Math.floor(leave1/(3600*1000));  
922 - DXHOURS = days*24+hours;  
923 - WIDTH = DXHOURS*MINUTE*MULTIPLE;  
924 - // debugger;  
925 - var lpsplitA = getylp(CSMap.maxCar);  
926 -  
927 - var sxsj = parseInt(map.upTravelTime);// 上行时间.  
928 - var xxsj = parseInt(map.downTravelTime);// 下行时间.  
929 - var stopAraay = [{  
930 - 'sxsj':sxsj,// 上行时间.  
931 - 'xxsj':xxsj,// 下行时间.  
932 - 'zzsj':map.zzsj,// 周转时间.  
933 - 'wcsj':parseInt(map.workeLunch),// 午餐时间.  
934 - 'wcsj':parseInt(map.workeDinner),// 晚餐时间.  
935 - 'zgfsxsj':map.earlyUpTime==''? sxsj : parseInt(map.earlyUpTime),// 早高峰上行行驶时间.  
936 - 'zgfxxsj':map.earlyDownTime=='' ? xxsj : parseInt(map.earlyDownTime),// 早高峰下行行驶时间.  
937 - 'wgfsxsj':map.lateUpTime=='' ? sxsj : parseInt(map.lateUpTime),// 晚高峰上行行驶时间.  
938 - 'wgfxxsj':map.lateDownTime== '' ? xxsj: parseInt(map.lateDownTime),// 晚高峰下行行驶时间.  
939 - 'sxjcsj':map.upInTimer == '' ? 0 : parseInt(map.upInTimer),// 上行进场时间.  
940 - 'sxccsj':map.upOutTimer == '' ? 0 : parseInt(map.upOutTimer),// 上行出场时间.  
941 - 'xxjcsj':map.downInTimer =='' ? 0 : parseInt(map.downInTimer),// 下行进场时间.  
942 - 'xxccsj':map.downOutTimer =='' ? 0 : parseInt(map.downOutTimer),// 下行进场时间.  
943 - 'sxjclc':map.upInMileage==''? 0 : parseInt(map.upInMileage),// 上行进场里程.  
944 - 'sxcclc':map.upOutMileage==''? 0:parseInt(map.upOutMileage),// 上行出场里程.  
945 - 'xxjclc':map.downInMileage==''? 0 : parseInt(map.downInMileage),// 下行进场里程.  
946 - 'xxcclc':map.downOutMileage==''?0:parseInt(map.downOutMileage),// 下行出场里程.  
947 - 'lbsj': map.lb==''? 0 : parseInt(map.lb) // 例保时间.  
948 - }];  
949 -  
950 - var args = {  
951 - 'valueKeyName': VALUEKEYNAME,  
952 - 'hours' : DXHOURS,  
953 - 'dxHours' : 24 - DXHOURS,  
954 - 'multiple': MULTIPLE,  
955 - 'width':WIDTH,  
956 - 'widtMargin':MARGINLEFT,  
957 - 'height':HEIGHT,  
958 - 'heightMargin':MARGINBOTTOM,  
959 - 'offsetX':OFFSETX,  
960 - 'offsetY':OFFSETY,  
961 - 'downDy':OFFSETDOWNY,  
962 - 'upDy':OFFSETUPY,  
963 - 'timeDomainStart' :STARTDATETIME,  
964 - 'timeDomainEnd' : ENDDATETIME,  
965 - 'startStr':'' + STARTDATETIME,  
966 - 'endStr': '' +ENDDATETIME,  
967 - 'taskTypes': TASKTYPES,  
968 - 'lpNoA':lpsplitA.lpNoA,  
969 - 'lpNameA':lpsplitA.lpNameA,  
970 - 'tickFormat': TICKFORMAT,  
971 - 'stopAraay' : stopAraay,  
972 - 'dataMap':dataMap,  
973 - 'showTooltips': SHOWTOOLTIPS,  
974 - 'bxrcgs':data.bxrcgs  
975 - };  
976 - return args;  
977 - }  
978 -  
979 -  
980 -  
981 - });  
982 - 1 +<!-- 统计数据 -->
  2 +<style>
  3 + .form-control:focus {
  4 + border-color: #53ced9;
  5 + }
  6 + .tagsDiv {
  7 + border: 1px solid #c2cad8;
  8 + margin-left: 15px;
  9 + padding: 4px 15px 4px 15px;
  10 + width: 50%;
  11 + }
  12 +</style>
  13 +<div class="modal fade" id="paramadd_mobal" tabindex="-1" role="basic" aria-hidden="true">
  14 + <div class="modal-dialog" style="margin-left: 100px;">
  15 + <div class="modal-content" style="width: 1000px;">
  16 + <div class="modal-header">
  17 + <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
  18 + <h4 class="modal-title">参数数据 </h4>
  19 + </div>
  20 + <div class="modal-body">
  21 + <form class="form-horizontal" id="param_form" action="/" method="POST" novalidate="novalidate">
  22 + <div class="form-body">
  23 + <div class="alert alert-danger display-hide">
  24 + <button class="close" data-close="alert"></button>
  25 + 您的输入有误,请检查下面的输入项
  26 + </div>
  27 + <div class="alert alert-success display-none">
  28 + <button class="close" data-dismiss="alert"></button>
  29 + 验证成功!
  30 + </div>
  31 +
  32 + </div>
  33 +
  34 + <div class="tab-pane" id="ptab">
  35 +
  36 + </div>
  37 + </form>
  38 + </div>
  39 +
  40 + <div class="modal-footer">
  41 + <button type="button" class="btn default" data-dismiss="modal" id="paramcancel">
  42 + <span class="paramcancelSpan">取消</span>
  43 + </button>
  44 + <button type="button" class="btn btn-primary" id="paramnext">
  45 + <span class="paramnextSpan">确定</span>
  46 + </button>
  47 + </div>
  48 +
  49 + </div>
  50 + </div>
  51 +</div>
  52 +
  53 +<script type="text/html" id = "paramAdd_temp">
  54 + <div class="form-group">
  55 + <div class="col-md-6">
  56 + <label class="control-label col-md-5">
  57 + <span class="required"> * </span> 上行首班时间 :
  58 + </label>
  59 + <div class="col-md-5">
  60 + <input type="text" class="form-control" name="startStationFirstTime" value="{{map.startStationFirstTime}}" id="startStationFirstTime_id"
  61 + placeholder="请输入起始站首班时间">
  62 + </div>
  63 + </div>
  64 + <div class="col-md-6">
  65 + <label class="control-label col-md-5">
  66 + <span class="required"> * </span> 上行末班时间 :
  67 + </label>
  68 + <div class="col-md-5">
  69 + <input type="text" class="form-control" name="startStationEndTime" value="{{map.startStationEndTime}}" id="startStationEndTime_id"
  70 + placeholder="请输入起始站末班时间">
  71 + </div>
  72 + </div>
  73 + </div>
  74 +
  75 + <div class="form-group">
  76 + <div class="col-md-6">
  77 + <label class="control-label col-md-5">
  78 + <span class="required"> * </span> 下行首班时间 :
  79 + </label>
  80 + <div class="col-md-5">
  81 + <input type="text" class="form-control" name="endStationFirstTime" value="{{map.endStationFirstTime}}" id="endStationFirstTime_id"
  82 + placeholder="请输入终点站首班时间">
  83 + </div>
  84 + </div>
  85 + <div class="col-md-6">
  86 + <label class="control-label col-md-5">
  87 + <span class="required"> * </span> 下行末班时间 :
  88 + </label>
  89 + <div class="col-md-5">
  90 + <input type="text" class="form-control" name="endStationEndTime" value="{{map.endStationEndTime}}" id="endStationEndTime_id"
  91 + placeholder="请输入终点站末班时间">
  92 + </div>
  93 + </div>
  94 + </div>
  95 +
  96 + <div class="form-group">
  97 + <div class="col-md-6">
  98 + <label class="control-label col-md-5">
  99 + <span class="required"> * </span> 早高峰开始时间 :
  100 + </label>
  101 + <div class="col-md-5">
  102 + <input type="text" class="form-control" name="earlyStartTime" value="{{map.earlyStartTime}}" id="earlyStartTime_id"
  103 + placeholder="请输入早高峰开始时间">
  104 + </div>
  105 + </div>
  106 + <div class="col-md-6">
  107 + <label class="control-label col-md-5">
  108 + <span class="required"> * </span> 早高峰结束时间 :
  109 + </label>
  110 + <div class="col-md-5">
  111 + <input type="text" class="form-control" name="earlyEndTime" value="{{map.earlyEndTime}}" id="earlyEndTime_id"
  112 + placeholder="请输入早高峰结束时间">
  113 + </div>
  114 + </div>
  115 + </div>
  116 +
  117 + <div class="form-group">
  118 + <div class="col-md-6">
  119 + <label class="control-label col-md-5">
  120 + <span class="required"> * </span> 晚高峰开始时间 :
  121 + </label>
  122 + <div class="col-md-5">
  123 + <input type="text" class="form-control" name="lateStartTime" value="{{map.lateStartTime}}" id="lateStartTime_id"
  124 + placeholder="请输入晚高峰开始时间">
  125 + </div>
  126 + </div>
  127 + <div class="col-md-6">
  128 + <label class="control-label col-md-5">
  129 + <span class="required"> * </span> 晚高峰结束时间 :
  130 + </label>
  131 + <div class="col-md-5">
  132 + <input type="text" class="form-control" name="lateEndTime" value="{{map.lateEndTime}}" id="lateEndTime_id"
  133 + placeholder="请输入晚高峰结束时间">
  134 + </div>
  135 + </div>
  136 + </div>
  137 +
  138 + <div class="form-group">
  139 + <div class="col-md-6">
  140 + <label class="control-label col-md-5">上行进场时间  :
  141 + </label>
  142 + <div class="col-md-5">
  143 + <input type="text" class="form-control" name="upInTimer" value="{{map.upInTimer}}" id="upInTimer_id"
  144 + placeholder="请输入上行进场时间">
  145 + </div>
  146 + </div>
  147 + <div class="col-md-6">
  148 + <label class="control-label col-md-5">上行出场时间  :
  149 + </label>
  150 + <div class="col-md-5">
  151 + <input type="text" class="form-control" name="upOutTimer" value="{{map.upOutTimer}}" id="upOutTimer_id"
  152 + placeholder="请输入上行出场时间">
  153 + </div>
  154 + </div>
  155 + </div>
  156 +
  157 + <div class="form-group">
  158 + <div class="col-md-6">
  159 + <label class="control-label col-md-5">下行进场时间  :
  160 + </label>
  161 + <div class="col-md-5">
  162 + <input type="text" class="form-control" name="downInTimer" value="{{map.downInTimer}}" id="downInTimer_id"
  163 + placeholder="请输入下行进场时间">
  164 + </div>
  165 + </div>
  166 + <div class="col-md-6">
  167 + <label class="control-label col-md-5">下行出场时间  :
  168 + </label>
  169 + <div class="col-md-5">
  170 + <input type="text" class="form-control" name="downOutTimer" value="{{map.downOutTimer}}" id="downOutTimer_id"
  171 + placeholder="请输入下行出场时间">
  172 + </div>
  173 + </div>
  174 + </div>
  175 +
  176 + <div class="form-group">
  177 + <div class="col-md-6">
  178 + <label class="control-label col-md-5">早高峰上行时间 :</label>
  179 + <div class="col-md-5">
  180 + <input type="text" class="form-control" name="earlyUpTime" value="{{map.earlyUpTime}}" id="earlyUpTime_id"
  181 + placeholder="请输入早高峰上行时间">
  182 + </div>
  183 + </div>
  184 + <div class="col-md-6">
  185 + <label class="control-label col-md-5">早高峰下行时间 :</label>
  186 + <div class="col-md-5">
  187 + <input type="text" class="form-control" name="earlyDownTime" value="{{map.earlyDownTime}}" id="earlyDownTime_id"
  188 + placeholder="请输入早高峰下行时间">
  189 + </div>
  190 + </div>
  191 + </div>
  192 +
  193 + <div class="form-group">
  194 + <div class="col-md-6">
  195 + <label class="control-label col-md-5">晚高峰上行时间 :</label>
  196 + <div class="col-md-5">
  197 + <input type="text" class="form-control" name="lateUpTime" value="{{map.lateUpTime}}" id="lateUpTime_id"
  198 + placeholder="请输入晚高峰上行时间">
  199 + </div>
  200 + </div>
  201 + <div class="col-md-6">
  202 + <label class="control-label col-md-5">晚高峰下行时间 :</label>
  203 + <div class="col-md-5">
  204 + <input type="text" class="form-control" name="lateDownTime" value="{{map.lateDownTime}}" id="lateDownTime_id"
  205 + placeholder="请输入晚高峰下行时间">
  206 + </div>
  207 + </div>
  208 + </div>
  209 +
  210 + <div class="form-group">
  211 + <div class="col-md-6">
  212 + <label class="control-label col-md-5">低谷上行时间  :</label>
  213 + <div class="col-md-5">
  214 + <input type="text" class="form-control" name="troughUpTime" value="{{map.troughUpTime}}" id="troughUpTime_id"
  215 + placeholder="请输入低谷上行时间">
  216 + </div>
  217 + </div>
  218 + <div class="col-md-6">
  219 + <label class="control-label col-md-5">低谷下行时间  :</label>
  220 + <div class="col-md-5">
  221 + <input type="text" class="form-control" name="troughDownTime" value="{{map.troughDownTime}}" id="troughDownTime_id"
  222 + placeholder="请输入低谷下行时间">
  223 + </div>
  224 + </div>
  225 + </div>
  226 +
  227 + <div class="form-group">
  228 + <div class="col-md-6">
  229 + <label class="control-label col-md-5">
  230 + <span class="required"> * </span> 线路规划类型  :
  231 + </label>
  232 + <div class="col-md-5">
  233 + <select name="linePlayType" class="form-control" id="linePlayType_id">
  234 + <option value="">-- 请选择线路类型 --</option>
  235 + <option value="0">双向</option>
  236 + <option value="1">环线</option>
  237 + </select>
  238 + </div>
  239 + </div>
  240 + <div class="col-md-6">
  241 + <label class="control-label col-md-5">吃饭地点    :</label>
  242 + <div class="col-md-5">
  243 + <select type="text" class="form-control" name="cfdd" id="cfdd_id">
  244 + <option value="">请选择...</option>
  245 + <option value="0">{{map.startStationName}}</option>
  246 + <option value="1">{{map.endStationName}}</option>
  247 + <option value="allYes">起终点站都可以</option>
  248 + </select>
  249 + </div>
  250 + </div>
  251 + </div>
  252 +
  253 + <div class="form-group">
  254 + <div class="col-md-6">
  255 + <label class="control-label col-md-5">早晚例行保养  :</label>
  256 + <div class="col-md-5">
  257 + <input type="text" class="form-control" name="lb" value="{{map.lb}}" id="lb_id"
  258 + placeholder="请输入早晚例行保养">
  259 + </div>
  260 + </div>
  261 + <div class="col-md-6">
  262 + <label class="control-label col-md-5">停车场     :</label>
  263 + <div class="col-md-5">
  264 + <select name="carPark" class="form-control" id="carPark_id" style="width:100%"></select>
  265 + </div>
  266 + </div>
  267 + </div>
  268 +
  269 +
  270 + <div class="form-group">
  271 + <div class="col-md-6">
  272 + <label class="control-label col-md-5">工作餐午餐时间 :</label>
  273 + <div class="col-md-5">
  274 + <input type="text" class="form-control" name="workeLunch" value="{{map.workeLunch}}" id="workeLunch_id"
  275 + placeholder="请输入工作餐午餐时间">
  276 + </div>
  277 + </div>
  278 + <div class="col-md-6">
  279 + <label class="control-label col-md-5">工作餐晚餐时间 :</label>
  280 + <div class="col-md-5">
  281 + <input type="text" class="form-control" name="workeDinner" value="{{map.workeDinner}}" id="workeDinner_id"
  282 + placeholder="请输入工作餐晚餐时间">
  283 + </div>
  284 + </div>
  285 + </div>
  286 +
  287 + <div class="form-group">
  288 + <div class="col-md-6">
  289 + <label class="control-label col-md-5"><span class="required"> * </span>早高峰发车间隔 :</label>
  290 + <div class="col-md-3" style="padding-right: 0px;">
  291 + <input type="text" class="form-control" name="zgffcjxmin" value="{{map.zgffcjxmin}}" id="zgffcjxmin_id"
  292 + placeholder="最小间隔">
  293 + </div>
  294 + <div class="col-md-1" style="padding-top: 10px; font-size: 85%;">至</div>
  295 + <div class="col-md-3" style="padding-left: 0px;">
  296 + <input type="text" class="form-control" name="zgffcjxmax" value="{{map.zgffcjxmax}}" id="zgffcjxmax_id"
  297 + placeholder="最大间隔">
  298 + </div>
  299 + </div>
  300 + <div class="col-md-6">
  301 + <label class="control-label col-md-5"><span class="required"> * </span>晚高峰发车间隔 :</label>
  302 + <div class="col-md-3" style="padding-right: 0px;">
  303 + <input type="text" class="form-control" name="wffcjxmin" value="{{map.wffcjxmin}}" id="wffcjxmin_id"
  304 + placeholder="最小间隔">
  305 + </div>
  306 + <div class="col-md-1" style="padding-top: 10px; font-size: 85%;">至</div>
  307 + <div class="col-md-3" style="padding-left: 0px;">
  308 + <input type="text" class="form-control" name="wffcjxmax" value="{{map.wffcjxmax}}" id="wffcjxmax_id"
  309 + placeholder="最大间隔">
  310 + </div>
  311 + </div>
  312 + </div>
  313 +
  314 + <div class="form-group">
  315 + <div class="col-md-6">
  316 + <label class="control-label col-md-5"><span class="required"> * </span>低谷发车间隔 :</label>
  317 + <div class="col-md-3" style="padding-right: 0px;">
  318 + <input type="text" class="form-control" name="dgfcjxmin" value="{{map.dgfcjxmin}}" id="dgfcjxmin_id"
  319 + placeholder="最小间隔">
  320 + </div>
  321 + <div class="col-md-1" style="padding-top: 10px; font-size: 85%;">至</div>
  322 + <div class="col-md-3" style="padding-left: 0px;">
  323 + <input type="text" class="form-control" name="dgfcjxmax" value="{{map.dgfcjxmax}}" id="dgfcjxmax_id"
  324 + placeholder="最大间隔">
  325 + </div>
  326 + </div>
  327 + <div class="col-md-6">
  328 + <label class="control-label col-md-5"><span class="required"> * </span>建议加班路牌数 :</label>
  329 + <div class="col-md-5">
  330 + <input type="text" class="form-control" name="jbclcount" value="{{map.jbclcount}}" id="jbclcount_id"
  331 + placeholder="为0表示是周末时刻表">
  332 + </div>
  333 + </div>
  334 + </div>
  335 +
  336 + <div class="form-group">
  337 + <div class="col-md-6">
  338 + <label class="control-label col-md-5"><span class="required"> * </span>停站类型 :</label>
  339 + <div class="col-md-5 tagsDiv">
  340 + <div class="row" style="margin-left: 15px;">
  341 + <input type="text" value="{{map.stt}}" name="stt" id="stoptype_tagsinput" style="display: none;">
  342 + </div>
  343 +
  344 + <div class="row" style="margin-top: 10px;">
  345 + <label class="control-label col-md-4">停站类型:</label>
  346 + <div class="col-md-8">
  347 + <select name="stopType" class="form-control" id="stopType_id">
  348 + <option value="">-- 请选择停站类型 --</option>
  349 + <option value="0">主站停站</option>
  350 + <option value="1">双向停站</option>
  351 + </select>
  352 + </div>
  353 + </div>
  354 +
  355 + <div class="row" style="margin-top: 10px;">
  356 + <label class="control-label col-md-4">主站:</label>
  357 + <div class="col-md-8">
  358 + <select name="masterStop" class="form-control" id="masterStop_id">
  359 + <option value="">请选择...</option>
  360 + <option value="0">{{map.startStationName}}</option>
  361 + <option value="1">{{map.endStationName}}</option>
  362 + </select>
  363 + </div>
  364 + </div>
  365 +
  366 + <div class="row" style="margin-top: 10px;margin-left: 116px;">
  367 + <a href="javascript:" class="btn red" id="stoptype_tagsinput_add">添加</a>
  368 + </div>
  369 + </div>
  370 +
  371 + </div>
  372 +
  373 + <div class="col-md-6">
  374 + <div class="form-group">
  375 + <label class="control-label col-md-5">
  376 + <span class="required"> * </span> 建议高峰配车数 :</label>
  377 + <div class="col-md-5">
  378 + <input type="text" class="form-control" placeholder="车辆数" name="gfjypcs"
  379 + id="gfjypcsInput" min="1" value="{{map.gfjypcs}}">
  380 + </div>
  381 + </div>
  382 + <div class="form-group">
  383 + <label class="control-label col-md-5">
  384 + <span class="required"> * </span> 生成策略  :
  385 + </label>
  386 + <div class="col-md-5">
  387 + <select name="strategy" class="form-control" id="strategy_id">
  388 + <option value="AdjustTripS1" selected>AdjustTripS1</option>
  389 + <option value="AdjustTripS2" disabled>AdjustTripS2</option>
  390 + <option value="AdjustTripS3">AdjustTripS3</option>
  391 + <option value="AdjustTripS4">AdjustTripS4</option>
  392 + </select>
  393 + </div>
  394 + </div>
  395 + </div>
  396 +
  397 +
  398 + </div>
  399 +
  400 +
  401 + <!-- 隐藏字段-时间 -->
  402 + <input type="hidden" name="skbName" value="{{map.skbName}}" id="skbName_id"/>
  403 + <input type="hidden" name="skbmc" value="{{map.skbmc}}" id="skbmc_id"/>
  404 + <input type="hidden" name="xlmc" value="{{map.xlmc}}" id="xlmc_id"/>
  405 + <input type="hidden" name="lineName" value="{{map.lineName}}" id="lineName_id"/>
  406 + <input type="hidden" name="lineVersion" value="{{map.lineVersion}}" id="lineVersion_id"/>
  407 +
  408 + <!-- 上下行行驶时间 -->
  409 + <input type="hidden" name="upTravelTime" value="{{map.upTravelTime}}" id="upTravelTime_id"/>
  410 + <input type="hidden" name="downTravelTime" value="{{map.downTravelTime}}" id="downTravelTime_id"/>
  411 +
  412 + <!-- 隐藏字段-里程 -->
  413 + <!-- 上下行行驶里程 -->
  414 + <input type="hidden" name="upMileage" value="{{map.upMileage}}" id="upMileage_id"/>
  415 + <input type="hidden" name="downMileage" value="{{map.downMileage}}" id="downMileage_id"/>
  416 + <!-- 上下行进场出场里程 -->
  417 + <input type="hidden" name="upInMileage" value="{{map.upInMileage}}" id="upInMileage_id"/>
  418 + <input type="hidden" name="downInMileage" value="{{map.downInMileage}}" id="downInMileage_id"/>
  419 + <input type="hidden" name="upOutMileage" value="{{map.upOutMileage}}" id="upOutMileage_id"/>
  420 + <input type="hidden" name="downOutMileage" value="{{map.downOutMileage}}" id="downOutMileage_id"/>
  421 +
  422 +
  423 +</script>
  424 +
  425 +<script type="text/javascript">
  426 + $('#paramadd_mobal').on('paramAddMobal.show', function(e, mainFun, mainFun2_2){
  427 + var _mainFun = mainFun;
  428 + var _mainFun_v2_2 = mainFun2_2;
  429 +
  430 + // 加载延迟200毫秒显示mobal
  431 + setTimeout(function(){$('#paramadd_mobal').modal({show : true,backdrop: 'static', keyboard: false});},200);
  432 + var param = JSON.parse(window.localStorage.Gantt_AgursData);
  433 +
  434 + // 获取表单元素
  435 + var form = $('#param_form');
  436 + // 错误提示元素
  437 + var paramAlert = $('.alert-danger', form);
  438 + // 确定事件点击
  439 + $('#paramnext').on('click', function() {
  440 + $("#paramcancel").addClass("disabled");
  441 + $("#paramnext").addClass("disabled");
  442 + $(".paramnextSpan").html("正在生成...");
  443 +
  444 + setTimeout(function() {
  445 + form.submit();// 表单提交
  446 + }, 500);
  447 +
  448 + // $("#paramnext").removeClass("disabled");
  449 + // $("#paramnext").html("确定");
  450 + });
  451 +
  452 + // 表单验证
  453 + form.validate({
  454 + errorElement : 'span',
  455 + errorClass : 'help-block help-block-error',
  456 + focusInvalid : false,
  457 + rules: {
  458 + 'skbName' : {required : true,},// 时刻表名称,必填项.
  459 + 'lineName' : {required : true,},// 线路名称,必填项.
  460 + 'lineVersion': {required: true}, // 站点路由版本,必填项,
  461 + 'startStationFirstTime' : {required : true}, // 起始站首班时间,必填项.
  462 + 'startStationEndTime' : {required : true}, // 起始站末班时间 ,必填项.
  463 + 'endStationFirstTime' : {required : true}, // 终点站首班时间 ,必填项.
  464 + 'endStationEndTime' : {required : true}, // 终点站末班时间,必填项.
  465 + 'earlyStartTime' : {required : true},// 早高峰开始时间,必填项 .
  466 + 'earlyEndTime' : {required : true},// 早高峰结束时间,必填项 .
  467 + 'lateStartTime' : {required : true},// 晚高峰开始时间,必填项 .
  468 + 'lateEndTime' : {required : true},// 晚高峰结束时间,必填项.
  469 + 'upInTimer' : {number : true},// 上行进场时间,必须为数字.
  470 + 'upOutTimer' : {number : true},// 上行出场时间,必须为数字.
  471 + 'downInTimer' : {number : true},// 下行进场时间,必须为数字.
  472 + 'downOutTimer' : {number : true},// 下行出场时间,必须为数字.
  473 + 'earlyUpTime' : {number : true},// 早高峰上行时间,必须为数字.
  474 + 'earlyDownTime' : {number : true},// 早高峰下行时间,必须为数字.
  475 + 'lateUpTime' : {number : true},// 晚高峰上行时间,必须为数字.
  476 + 'lateDownTime' : {number : true},// 晚高峰下行时间,必须为数字.
  477 + 'troughUpTime' : {number : true},// 低谷上行时间,必须为数字.
  478 + 'troughDownTime' : {number : true},// 低谷下行时间,必须为数字.
  479 + 'linePlayType' : {required : true},// 线路规划类型,必填项
  480 + 'lb' : {number : true},// 早晚例行保养,必须为数字.
  481 + 'workeLunch' : {number : true},// 工作餐午餐时间,必须为数字.
  482 + 'workeDinner' : {number : true},// 工作餐晚餐时间,必须为数字.
  483 + 'zgffcjxmin' : {required : true,number : true,digits: true},// 早高峰最小发车间隔.
  484 + 'zgffcjxmax' : {required : true,number : true,digits: true},// 早高峰最大发车间隔.
  485 + 'wffcjxmin' : {required : true,number : true,digits: true},// 晚高峰最小发车间隔.
  486 + 'wffcjxmax' : {required : true,number : true,digits: true},// 晚高峰最大发车间隔.
  487 + 'dgfcjxmin' : {required : true,number : true,digits: true},// 低谷最小发车间隔.
  488 + 'dgfcjxmax' : {required : true,number : true,digits: true},// 低谷最大发车间隔.
  489 + 'jbclcount': {required : true,number : true,digits: true}, // 建议加班车数
  490 + 'upTravelTime' : {required : true,number : true},// 上行行驶时间,必填项、必须为整数.
  491 + 'downTravelTime' : {required : true,number : true},// 下行行驶时间,必填项、必须为整数.
  492 + 'upMileage' : {required : true,number : true},// 上行行驶里程,必填项、必须为整数.
  493 + 'downMileage' : {required : true,number : true},// 下行行驶里程,必填项、必须为整数.
  494 + 'upInMileage' : {number : true},// 上行进场里程,必须为数字.
  495 + 'upOutMileage' : {number : true},// 上行出场里程,必须为数字.
  496 + 'downInMileage' : {number : true},// 下行进场里程,必须为数字.
  497 + 'downOutMileage' : {number : true}, // 下行出场里程,必须为数字.
  498 +
  499 + 'strategy' : {required : true} // 生成策略标识
  500 +
  501 + // TODO
  502 + },
  503 + invalidHandler : function(event, validator) {
  504 + paramAlert.show();
  505 + App.scrollTo(paramAlert, -200);
  506 + },
  507 + highlight : function(element) {
  508 + $(element).closest('.form-group').addClass('has-error');
  509 + },
  510 + unhighlight : function(element) {
  511 + $(element).closest('.form-group').removeClass('has-error');
  512 + },
  513 + success : function(label) {
  514 + label.closest('.form-group').removeClass('has-error');
  515 + },
  516 + submitHandler : function(f) {
  517 + // 1、 获取表单内容,并序列化
  518 + var fp = form.serializeJSON();
  519 +
  520 + console.log(fp);
  521 +
  522 + // 2、重新刷新表单数据
  523 + var ganttMap = JSON.parse(window.localStorage.Gantt_AgursData);
  524 + var key;
  525 + for (key in fp) {
  526 + if (ganttMap[key]) {
  527 + if (ganttMap[key] != fp[key]) {
  528 + ganttMap[key] = fp[key];
  529 + }
  530 + } else {
  531 + ganttMap[key] = fp[key];
  532 + }
  533 + }
  534 + window.localStorage.setItem("Gantt_AgursData",JSON.stringify(ganttMap));
  535 +
  536 + // TODO
  537 + var pp = getParamObjAndDataMap();
  538 + var paramObj = pp[0];
  539 + var dataMap = pp[1];
  540 + var csMap = getCSMap(paramObj);
  541 + // console.log(graph);
  542 +
  543 + var data;
  544 +
  545 + if (ganttMap.baseRes == "2") { // v2版本
  546 + data = _mainFun.BXPplaceClassesTime03(paramObj, csMap.maxCar);
  547 + _mainFun.exportDataConfig(data.aInternalLpObj);
  548 + } else if (ganttMap.baseRes == "3") { // v2_2版本
  549 + csMap = getCSMap_v2(paramObj);
  550 + data = _mainFun_v2_2.BXPplaceClassesTime03(paramObj, csMap.maxCar);
  551 + _mainFun_v2_2.exportDataConfig(data.aInternalLpObj);
  552 + }
  553 +
  554 + // var data = obj.getDataArray();
  555 + // // 2、 调整路牌对应的班次总数
  556 + // updFormParams(params,data);
  557 + // 删除图形.
  558 + $('svg.svg-chart').remove();
  559 + // 重新创建图形.
  560 + var graph = d3.select('#ganttSvg').relationshipGraph(getGraphArgus(csMap, dataMap, data));
  561 + // 根据数据重新渲染图形.
  562 + graph.data(data.json);
  563 + // 记录早操.并保存历史班次数据
  564 + graph.addHistory();
  565 + // 隐藏错误提示
  566 + paramAlert.hide();
  567 + // 隐藏 reladplus_mobal 弹出层
  568 + $('#paramadd_mobal').modal('hide');
  569 + layer.msg('成功!');
  570 + }
  571 + });
  572 +
  573 +
  574 + // 当模态框对用户可见时触发(将等待 CSS 过渡效果完成)。
  575 + $('#paramadd_mobal').on('show.bs.modal', function () {
  576 + // TODO
  577 + // 把数据填充到模版中
  578 + // var tbodyHtml = template('countAdd_temp',{list:countDate});
  579 + // // 把渲染好的模版html文本追加到表格中
  580 + // $('#datatable_countadd tbody').html(tbodyHtml);
  581 + var htmldata = template('paramAdd_temp', {map : param});
  582 + $('#ptab').html(htmldata);
  583 +
  584 + // 线路规划类型
  585 + $('#linePlayType_id').val(param.linePlayType);
  586 + // 策略类型
  587 + $('#strategy_id').val(param.strategy || "AdjustTripS1");
  588 + // 吃饭地点
  589 + $get('/stationroute/all', {
  590 + 'line.id_eq': param.lineName.split('_')[0],
  591 + 'destroy_eq': 0,
  592 + 'versions_eq': param.lineVersion},
  593 + function(result) {
  594 + var opt = [];
  595 + opt.push('<option value="">请选择...</option>');
  596 + $.each(result, function(i, d) {
  597 + if (d.stationMark == 'B' && d.directions == 0) {
  598 + opt.push("<option value='0'>" + d.stationName + "</option>");
  599 + } else if (d.stationMark == 'E' && d.directions == 0) {
  600 + opt.push("<option value='1'>" + d.stationName + "</option>");
  601 + }
  602 + });
  603 + initTagsinput(opt.join(","));
  604 +
  605 + opt.push("<option value='allYes'>起终点站都可以</option>");
  606 + $('#cfdd_id').html(opt.join(""));
  607 + $('#cfdd_id').val(param.cfdd);
  608 +
  609 + }
  610 + );
  611 + // 停车场
  612 + $get('/carpark/all',null, function(cd) {
  613 + var opt = [];
  614 + opt.push('<option value="">请选择...</option><optgroup label="停车场">');
  615 + var $_len = cd.length;
  616 + if($_len > 0) {
  617 + $.each(cd, function(i, d){
  618 + opt.push('<option value="'+d.parkCode+'">'+d.parkName+'</option>');
  619 + });
  620 + }
  621 + opt.push('</optgroup>');
  622 + $('#carPark_id').html(opt.join(",")).select2();
  623 + $('#carPark_id').select2("val", param.carPark);
  624 + });
  625 +
  626 + // 上下行首末班日期控件
  627 + $('#startStationFirstTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});
  628 + $('#startStationEndTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});
  629 + $('#endStationFirstTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});
  630 + $('#endStationEndTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});
  631 +
  632 + // 早高峰晚高峰日期控件
  633 + $('#earlyStartTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});
  634 + $('#earlyEndTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});
  635 + $('#lateStartTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});
  636 + $('#lateEndTime_id').datetimepicker({format : 'HH:mm',locale: 'zh-cn'});
  637 +
  638 + });
  639 +
  640 +
  641 +
  642 + //--------------------- 其他方法 ------------------------//
  643 +
  644 + function initTagsinput(htmlStr) {
  645 + $('#masterStop_id').html(htmlStr);
  646 +
  647 + var elt = $('#stoptype_tagsinput');
  648 + var value = elt.val();
  649 + var stoptype = value.split("/")[0];
  650 + var masterstop = value.split("/")[1];
  651 +
  652 + $('#stopType_id').val(stoptype);
  653 + $('#masterStop_id').val(masterstop);
  654 +
  655 + elt.tagsinput({
  656 + tagClass: function(item) {
  657 + return 'label label-danger label-important';
  658 + },
  659 + itemValue: 'value',
  660 + itemText: 'text'
  661 + });
  662 +
  663 + $('#stoptype_tagsinput').on('beforeItemAdd', function(event) {
  664 + // TODO:这里可以做一些逻辑判定
  665 + });
  666 +
  667 + $('#stoptype_tagsinput_add').on('click', function(){
  668 + var stoptype = $("#stopType_id").val();
  669 + var masterstop = $("#masterStop_id").val();
  670 + var masterstop_text = $("#masterStop_id option:selected").text();
  671 +
  672 + if (stoptype && stoptype != "") {
  673 + if (stoptype == "0" && masterstop && masterstop != "") {
  674 + elt.tagsinput('add', {
  675 + "value": stoptype + '/' + masterstop,
  676 + "text": "主站停站" + "/" + masterstop_text
  677 + });
  678 + } else {
  679 + elt.tagsinput('add', {
  680 + "value": 1,
  681 + "text": "双向停站"
  682 + });
  683 + }
  684 + }
  685 + });
  686 +
  687 + if (stoptype && stoptype != "") {
  688 + elt.tagsinput('add', {
  689 + "value": stoptype + '/' + masterstop,
  690 + "text":
  691 + $("#stopType_id option:selected").text() + "/" +
  692 + $("#masterStop_id option:selected").text()
  693 + });
  694 + }
  695 +
  696 + }
  697 +
  698 + function getMinDate(d1,d2) {
  699 + // 1、定义返回字符串.
  700 + var str = '';
  701 + // 2、判断时间大小.
  702 + if(strToTime(d1)>strToTime(d2))
  703 + str = d2;
  704 + else
  705 + str = d1;
  706 + // 3、返回最小时间(字符串).
  707 + return str;
  708 + }
  709 +
  710 + function strToTime(t) {
  711 + var d = new Date();
  712 + if(t) {
  713 + var _str = t.split(':');
  714 + d.setHours(parseInt(_str[0]));
  715 + d.setMinutes(parseInt(_str[1]));
  716 + }
  717 + return d;
  718 + }
  719 +
  720 + function getMaxDate(d1,d2) {
  721 + // 1、定义返回时间字符串.
  722 + var str = '';
  723 + // 2、判断时间大小.
  724 + if(strToTime(d1)>strToTime(d2))
  725 + str = d1;
  726 + else
  727 + str = d2;
  728 + // 3、返回一个最大时间(字符串).
  729 + return str;
  730 + }
  731 +
  732 + function getEndDate(date) {
  733 + var lastEndDate = Date.now();
  734 + if (date) {
  735 + var str = date.replace(/-/g,"/");
  736 + lastEndDate = new Date(str);
  737 + }
  738 + // Wed Oct 26 2016 00:00:00 GMT+0800 (中国标准时间)
  739 + return lastEndDate;
  740 + }
  741 +
  742 + function formatPairing(v1,v2) {
  743 + v1 = v1 == '' ? 0 : parseInt(v1);
  744 + v2 = v2 == ''? 0 : parseInt(v2) ;
  745 + return [v1,v2];
  746 + }
  747 +
  748 + function qzdz(zd1,zd2) {
  749 + return [zd1,zd2];
  750 + }
  751 +
  752 + function formatksjssj(gp) {
  753 + return [{'kssj':gp.startStationFirstTime,'jssj':gp.startStationEndTime},{'kssj':gp.endStationFirstTime,'jssj':gp.endStationEndTime}];
  754 + }
  755 +
  756 + function getsd(st,ed) {
  757 + return [{'st':st,'ed':ed}];
  758 + }
  759 +
  760 + function getDateTime(time) {
  761 + var dateTime = new Date();
  762 + var timeArr;
  763 + if(time !=null && time !='' && typeof(time) !='undefined') {
  764 + timeArr = time.split(':');
  765 + dateTime.setHours(parseInt(timeArr[0]));
  766 + dateTime.setMinutes(parseInt(timeArr[1]));
  767 + }
  768 + return dateTime;
  769 + }
  770 +
  771 + function getYAxisCarArray(len) {
  772 + var array = new Array();
  773 + if(len>0) {
  774 + for(var y = 0; y<len; y++) {
  775 + array.push({lp:null,lpNo:y+1, parent :y+1, lpName:y+1,lpType:'普通路牌'});//添加一个路牌对象
  776 + };
  777 + }
  778 + return array;
  779 + }
  780 +
  781 + function getylp(arr) {
  782 + var ra = new Array(),name = new Array();
  783 + for(var i = 0 ; i<arr.length;i++) {
  784 + ra.push(arr[i].lpNo);
  785 + name.push(arr[i].lpName);
  786 + }
  787 + return {'lpNoA':ra,'lpNameA':name,};
  788 + }
  789 +
  790 + function getParamObjAndDataMap() {
  791 + var map = JSON.parse(window.localStorage.Gantt_AgursData);
  792 + // seMap
  793 + var seMap = {'s': map.linePlayType == '1' ? map.startStationFirstTime : getMinDate(map.startStationFirstTime,map.endStationFirstTime),
  794 + 'e': map.linePlayType == '1' ? map.startStationEndTime : getMaxDate(map.startStationEndTime,map.endStationEndTime)};
  795 + // dirA
  796 + var dirA = ['relationshipGraph-up', 'relationshipGraph-down'];
  797 + // bcTypeArr
  798 + var bcTypeArr = {
  799 + 'bd': 'bd', 'out': 'out', 'normal': 'normal', 'cf': 'cf', 'in_': 'in', 'lc': 'lc',
  800 + 'major': 'major', 'venting': 'venting', 'region': 'region'
  801 + };
  802 + // seDate
  803 + var newDate = new Date();
  804 + var kssj = d3.time.hour.offset(getEndDate(
  805 + newDate.getFullYear()+ "-" +
  806 + (newDate.getMonth()+1) + "-" +
  807 + newDate.getDate() + ' ' +
  808 + seMap.s.split(':')[0] + ':00'),-1);
  809 +
  810 + var year = '' , month = '',dt = '';
  811 + if(newDate.getDate()+1>31)
  812 + dt = '01';
  813 + else
  814 + dt = newDate.getDate()+1;
  815 + if(newDate.getMonth()+1>12)
  816 + month = '01';
  817 + else if(newDate.getDate()+1>31)
  818 + month = newDate.getMonth()+2;
  819 + else
  820 + month = newDate.getMonth()+1;
  821 + if(newDate.getMonth()+1>12)
  822 + year = newDate.getFullYear()+1;
  823 + else
  824 + year = newDate.getFullYear();
  825 + var jssj = getEndDate(year + '-' + month + '-' + dt + ' ' + '00:00');
  826 + seDate = {'kssj' : kssj, 'jssj' : jssj};
  827 +
  828 + // dataMap
  829 + var dataMap = {'jcsjArr' : formatPairing(map.upInTimer,map.downInTimer),// 进场里程。[下标0代表上;下标1代表下]
  830 + 'ccsjArr' : formatPairing(map.upOutTimer,map.downOutTimer),// 出场时间。[下标0代表上;下标1代表下]
  831 + 'jclcArr' : formatPairing(map.upInMileage,map.downInMileage),// 进场里程。[下标0代表上;下标1代表下]
  832 + 'cclcArr' : formatPairing(map.upOutMileage,map.downOutMileage),// 出场里程。[下标0代表上;下标1代表下]
  833 + 'pcxssjArr' : formatPairing(map.upTravelTime,map.downTravelTime),// 平常行驶时间。[下标0代表上;下标1代表下]
  834 + 'gfxxsjArr' : formatPairing(map.lateUpTime=='' ? map.upTravelTime : map.lateUpTime,
  835 + map.lateDownTime=='' ? map.downTravelTime : map.lateDownTime),// 高峰行驶时间。[下标0代表上;下标1代表下]
  836 + 'dgxxsjArr' : formatPairing(map.troughUpTime=='' ? map.upTravelTime : map.troughUpTime,
  837 + map.troughDownTime=='' ? map.downTravelTime : map.troughDownTime),// 低谷行驶时间。[下标0代表上;下标1代表下]
  838 + 'pcxslcArr' : formatPairing(map.upMileage,map.downMileage),// 行驶里程。[下标0代表上;下标1代表下]
  839 + 'qdzArr' : qzdz(map.up_s.split('_')[0],map.down_s.split('_')[0]),// 起始站。[下标0代表上;下标1代表下]
  840 + 'zdzArr':qzdz(map.up_s.split('_')[1],map.down_s.split('_')[1]),// 终点站。[下标0代表上;下标1代表下]
  841 + 'zwcArr' : formatPairing(map.workeLunch,map.workeDinner),// 午晚餐时间。[下标0代表午;下标1代表晚]
  842 + 'smbcsjArr' : formatksjssj(map), // 起终点站首末班车时间.[下标0代表起始站的首末班车时间;下标1代表终点站的首末班车时间]
  843 + 'zgfsjd' : getsd(getDateTime(map.earlyStartTime),
  844 + getDateTime(map.earlyEndTime)), // 早高峰时间段
  845 + 'wgfsjd' : getsd(getDateTime(map.lateStartTime),
  846 + getDateTime(map.lateEndTime)),// 晚高峰时间段
  847 + 'gfzjsjd' : getsd(getDateTime(map.earlyEndTime),
  848 + getDateTime(map.lateStartTime)),//高峰之间时间段.
  849 + 'wgfzhsjd' : getsd(getDateTime(map.lateEndTime),
  850 + getDateTime(seMap.e)),// 晚高峰之后时间段
  851 + 'zgfzqsjd': getsd(getDateTime(seMap.s),
  852 + getDateTime(map.earlyStartTime)),//早高峰之前时间段.
  853 + 'dira' : dirA,// 方向集合 [下标0代表上;下标1代表下]
  854 + 'bcTypeArr' : bcTypeArr,// 班次类型
  855 + 'lbsj' : map.lb=='' ? 0:parseInt(map.lb),// 例保时间.
  856 + // 'minztjx' : parseInt(gatps.mixstopTime), // 最小停站时间.
  857 + // 'ztjxA' : BaseFun.formatPairing(gatps.upStopTime,gatps.downStopTime), // 停站时间.
  858 + // 'maxztjx' : parseInt(gatps.maxstopTime), // 最大停站时间.
  859 + 'gftzsj': formatPairing(map.gfupStopTime,map.gfdownStopTime),// 高峰停站时间.
  860 + 'dgtzsj' : formatPairing(map.dgupStopTime,map.dgdownStopTime),// 低谷停站时间.
  861 + 'dgmaxtzsj' : parseInt(map.dgmaxtzsj),// 低谷最大停站时间.
  862 + 'dgmaxfcjx' : parseInt(map.dgmaxfcjx),// 低谷最大发车间隙.
  863 + 'map' : map,
  864 + 'zzsj':map.zzsj,// 周转时间.
  865 + };
  866 +
  867 + var _paramObj = _mainFun.getFactory().createParameterObj(map, dataMap);
  868 +
  869 + if (!_paramObj.isTwoWayStop()) { // 主站停站使用v2_2版本
  870 + map.clzs = InternalScheduleObj_v2_2.calcuClzx(_paramObj);
  871 + } else {
  872 + map.clzs = _paramObj.calcuClzx();
  873 + }
  874 +
  875 + return [_paramObj, dataMap];
  876 +
  877 + }
  878 +
  879 + function getCSMap(parmObj) {
  880 + var map = JSON.parse(window.localStorage.Gantt_AgursData);
  881 + return {'gattA':null,
  882 + 'fcjx': {'gffcjx': Math.round(parmObj.calcuPeakZzsj()/parmObj.calcuClzx()) ,
  883 + 'dgfcjx': Math.round(parmObj.calcuTroughZzsj()/parmObj.calcuClzx()),
  884 + 'dgmaxfcjx' : parseInt(map.dgmaxfcjx)},
  885 + 'maxCar':getYAxisCarArray(parseInt(parmObj.calcuClzx()))};
  886 + }
  887 + function getCSMap_v2(parmObj) {
  888 + var map = JSON.parse(window.localStorage.Gantt_AgursData);
  889 + return {'gattA':null,
  890 + 'fcjx': {'gffcjx': Math.round(parmObj.calcuPeakZzsj()/parmObj.calcuClzx()) ,
  891 + 'dgfcjx': Math.round(parmObj.calcuTroughZzsj()/parmObj.calcuClzx()),
  892 + 'dgmaxfcjx' : parseInt(map.dgmaxfcjx)},
  893 + 'maxCar':getYAxisCarArray(InternalScheduleObj_v2_2.calcuClzx(parmObj))};
  894 + }
  895 +
  896 +
  897 + function getGraphArgus(CSMap, dataMap, data) {
  898 + // TODO
  899 + var map = JSON.parse(window.localStorage.Gantt_AgursData);
  900 + var sxsj = parseInt(map.upTravelTime);// 上行时间.
  901 +
  902 + // seMap
  903 + var seMap = {'s': map.linePlayType == '1' ? map.startStationFirstTime : getMinDate(map.startStationFirstTime,map.endStationFirstTime),
  904 + 'e': map.linePlayType == '1' ? map.startStationEndTime : getMaxDate(map.startStationEndTime,map.endStationEndTime)};
  905 +
  906 + // seDate
  907 + var newDate = new Date();
  908 + var kssj = d3.time.hour.offset(getEndDate(
  909 + newDate.getFullYear()+ "-" +
  910 + (newDate.getMonth()+1) + "-" +
  911 + newDate.getDate() + ' ' +
  912 + seMap.s.split(':')[0] + ':00'),-1);
  913 +
  914 + var year = '' , month = '',dt = '';
  915 + if(newDate.getDate()+1>31)
  916 + dt = '01';
  917 + else
  918 + dt = newDate.getDate()+1;
  919 + if(newDate.getMonth()+1>12)
  920 + month = '01';
  921 + else if(newDate.getDate()+1>31)
  922 + month = newDate.getMonth()+2;
  923 + else
  924 + month = newDate.getMonth()+1;
  925 + if(newDate.getMonth()+1>12)
  926 + year = newDate.getFullYear()+1;
  927 + else
  928 + year = newDate.getFullYear();
  929 + var jssj = getEndDate(year + '-' + month + '-' + dt + ' ' + '00:00');
  930 + seDate = {'kssj' : kssj, 'jssj' : jssj};
  931 +
  932 +
  933 + var bs = sxsj > 40 ? 4 : 2;
  934 + var MULTIPLE = Math.round(105/sxsj) >3 ? Math.round(90/sxsj) : Math.round(90/sxsj) *bs;
  935 + var VALUEKEYNAME = 'Worldwide Gross' ,
  936 + DXHOURS = 24,MINUTE = 60,WIDTH = DXHOURS*MINUTE,MARGINLEFT = 380,HEIGHT = CSMap.maxCar.length*60 + 240,
  937 + MARGINBOTTOM = 240,OFFSETX = 90,OFFSETY = 180,OFFSETUPY = 120,OFFSETDOWNY = 60,
  938 + STARTDATETIME = seDate.kssj ,ENDDATETIME = seDate.jssj ,TASKTYPES =CSMap.maxCar ,TICKFORMAT ='%H:%M' ,SHOWTOOLTIPS = true;
  939 + var dx_time = seDate.jssj.getTime() - seDate.kssj.getTime() ;
  940 + // 计算出相差天数
  941 + var days=Math.floor(dx_time/(24*3600*1000));
  942 + // 计算出小时数
  943 + var leave1=dx_time%(24*3600*1000); //计算天数后剩余的毫秒数
  944 + var hours=Math.floor(leave1/(3600*1000));
  945 + DXHOURS = days*24+hours;
  946 + WIDTH = DXHOURS*MINUTE*MULTIPLE;
  947 + // debugger;
  948 + var lpsplitA = getylp(CSMap.maxCar);
  949 +
  950 + var sxsj = parseInt(map.upTravelTime);// 上行时间.
  951 + var xxsj = parseInt(map.downTravelTime);// 下行时间.
  952 + var stopAraay = [{
  953 + 'sxsj':sxsj,// 上行时间.
  954 + 'xxsj':xxsj,// 下行时间.
  955 + 'zzsj':map.zzsj,// 周转时间.
  956 + 'wcsj':parseInt(map.workeLunch),// 午餐时间.
  957 + 'wcsj':parseInt(map.workeDinner),// 晚餐时间.
  958 + 'zgfsxsj':map.earlyUpTime==''? sxsj : parseInt(map.earlyUpTime),// 早高峰上行行驶时间.
  959 + 'zgfxxsj':map.earlyDownTime=='' ? xxsj : parseInt(map.earlyDownTime),// 早高峰下行行驶时间.
  960 + 'wgfsxsj':map.lateUpTime=='' ? sxsj : parseInt(map.lateUpTime),// 晚高峰上行行驶时间.
  961 + 'wgfxxsj':map.lateDownTime== '' ? xxsj: parseInt(map.lateDownTime),// 晚高峰下行行驶时间.
  962 + 'sxjcsj':map.upInTimer == '' ? 0 : parseInt(map.upInTimer),// 上行进场时间.
  963 + 'sxccsj':map.upOutTimer == '' ? 0 : parseInt(map.upOutTimer),// 上行出场时间.
  964 + 'xxjcsj':map.downInTimer =='' ? 0 : parseInt(map.downInTimer),// 下行进场时间.
  965 + 'xxccsj':map.downOutTimer =='' ? 0 : parseInt(map.downOutTimer),// 下行进场时间.
  966 + 'sxjclc':map.upInMileage==''? 0 : parseInt(map.upInMileage),// 上行进场里程.
  967 + 'sxcclc':map.upOutMileage==''? 0:parseInt(map.upOutMileage),// 上行出场里程.
  968 + 'xxjclc':map.downInMileage==''? 0 : parseInt(map.downInMileage),// 下行进场里程.
  969 + 'xxcclc':map.downOutMileage==''?0:parseInt(map.downOutMileage),// 下行出场里程.
  970 + 'lbsj': map.lb==''? 0 : parseInt(map.lb) // 例保时间.
  971 + }];
  972 +
  973 + var args = {
  974 + 'valueKeyName': VALUEKEYNAME,
  975 + 'hours' : DXHOURS,
  976 + 'dxHours' : 24 - DXHOURS,
  977 + 'multiple': MULTIPLE,
  978 + 'width':WIDTH,
  979 + 'widtMargin':MARGINLEFT,
  980 + 'height':HEIGHT,
  981 + 'heightMargin':MARGINBOTTOM,
  982 + 'offsetX':OFFSETX,
  983 + 'offsetY':OFFSETY,
  984 + 'downDy':OFFSETDOWNY,
  985 + 'upDy':OFFSETUPY,
  986 + 'timeDomainStart' :STARTDATETIME,
  987 + 'timeDomainEnd' : ENDDATETIME,
  988 + 'startStr':'' + STARTDATETIME,
  989 + 'endStr': '' +ENDDATETIME,
  990 + 'taskTypes': TASKTYPES,
  991 + 'lpNoA':lpsplitA.lpNoA,
  992 + 'lpNameA':lpsplitA.lpNameA,
  993 + 'tickFormat': TICKFORMAT,
  994 + 'stopAraay' : stopAraay,
  995 + 'dataMap':dataMap,
  996 + 'showTooltips': SHOWTOOLTIPS,
  997 + 'bxrcgs':data.bxrcgs
  998 + };
  999 + return args;
  1000 + }
  1001 +
  1002 +
  1003 +
  1004 + });
  1005 +
983 </script> 1006 </script>
984 \ No newline at end of file 1007 \ No newline at end of file