Commit 4232a1586d75df1392c5e105d5335a31b9befce7

Authored by 廖磊
2 parents 17265f17 1fed235c

Merge branch 'pudong' of http://222.66.0.204:8090/panzhaov5/bsth_control

into pudong
src/main/java/com/bsth/service/schedule/impl/CarsServiceImpl.java
@@ -89,6 +89,7 @@ public class CarsServiceImpl extends BServiceImpl<Cars, Integer> implements Cars @@ -89,6 +89,7 @@ public class CarsServiceImpl extends BServiceImpl<Cars, Integer> implements Cars
89 if (cars.getId() != null) { 89 if (cars.getId() != null) {
90 param.put("id_ne", cars.getId()); 90 param.put("id_ne", cars.getId());
91 } 91 }
  92 + param.put("scrapState_eq", false);
92 param.put("equipmentCode_eq", cars.getEquipmentCode()); 93 param.put("equipmentCode_eq", cars.getEquipmentCode());
93 if (!CollectionUtils.isEmpty(list(param))) { 94 if (!CollectionUtils.isEmpty(list(param))) {
94 throw new ScheduleException("设备编号重复"); 95 throw new ScheduleException("设备编号重复");
src/main/resources/static/pages/base/timesmodel/js/v2/ParameterObj.js
@@ -895,7 +895,7 @@ var ParameterObj = function() { @@ -895,7 +895,7 @@ var ParameterObj = function() {
895 }, 895 },
896 896
897 /** 897 /**
898 - * 获取固定的停站时间(固定停站时间都是选的最大值 898 + * 获取固定的停站时间(固定停站时间都是选的最大值,非平均停站
899 * @param oTimeObj 时间对象 899 * @param oTimeObj 时间对象
900 * @param bIsUp 是否上行 900 * @param bIsUp 是否上行
901 * @param iXXTime 行驶时间 901 * @param iXXTime 行驶时间
@@ -1082,6 +1082,85 @@ var ParameterObj = function() { @@ -1082,6 +1082,85 @@ var ParameterObj = function() {
1082 }, 1082 },
1083 1083
1084 /** 1084 /**
  1085 + * 获取固定的停站时间(固定停站时间都是选的最小值,非平均停站)
  1086 + * @param oTimeObj 时间对象
  1087 + * @param bIsUp 是否上行
  1088 + * @returns int 停站时间
  1089 + */
  1090 + fnCalcuFixedMinStopNumber: function(oTimeObj, bIsUp) {
  1091 + _validInternal(); // 验证
  1092 + var oParam = this;
  1093 +
  1094 + // 双向停站
  1095 + if (oParam.isTwoWayStop()) {
  1096 + if (bIsUp) { // 上行
  1097 + if (this.isMPeakBc(oTimeObj)) { // 早高峰
  1098 + return 3;
  1099 + } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  1100 + return 3;
  1101 + } else { // 低谷
  1102 + if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  1103 + return 10;
  1104 + } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  1105 + return 10;
  1106 + } else { // 早高峰,晚高峰之间
  1107 + return 10;
  1108 + }
  1109 + }
  1110 +
  1111 + } else { // 下行
  1112 + if (this.isMPeakBc(oTimeObj)) { // 早高峰
  1113 + return 3;
  1114 + } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  1115 + return 3;
  1116 + } else { // 低谷
  1117 + if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  1118 + return 10;
  1119 + } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  1120 + return 10;
  1121 + } else { // 早高峰,晚高峰之间
  1122 + return 10;
  1123 + }
  1124 + }
  1125 + }
  1126 + } else { // 主站停站
  1127 + if (bIsUp == oParam.isUpOneWayStop()) {
  1128 + if (bIsUp) { // 上行
  1129 + if (this.isMPeakBc(oTimeObj)) { // 早高峰
  1130 + return 2;
  1131 + } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  1132 + return 2;
  1133 + } else { // 低谷
  1134 + if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  1135 + return 10;
  1136 + } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  1137 + return 10;
  1138 + } else { // 早高峰,晚高峰之间
  1139 + return 10;
  1140 + }
  1141 + }
  1142 + } else { // 下行
  1143 + if (this.isMPeakBc(oTimeObj)) { // 早高峰
  1144 + return 2;
  1145 + } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  1146 + return 2;
  1147 + } else { // 低谷
  1148 + if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  1149 + return 10;
  1150 + } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  1151 + return 10;
  1152 + } else { // 早高峰,晚高峰之间
  1153 + return 10;
  1154 + }
  1155 + }
  1156 + }
  1157 + } else { // 副站停战,2到3分钟
  1158 + return 2;
  1159 + }
  1160 + }
  1161 + },
  1162 +
  1163 + /**
1085 * 获取行驶时间。 1164 * 获取行驶时间。
1086 * @param timeObj 班次时间字符串 1165 * @param timeObj 班次时间字符串
1087 * @param isUp 是否上行 1166 * @param isUp 是否上行
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalBcObj.js
@@ -32,6 +32,7 @@ var InternalBcObj = function( @@ -32,6 +32,7 @@ var InternalBcObj = function(
32 this._$_bcsj = otherParamObj.bcsj; // 班次历时 32 this._$_bcsj = otherParamObj.bcsj; // 班次历时
33 this._$_arrtime = otherParamObj.arrtime; // 到达时间对象 33 this._$_arrtime = otherParamObj.arrtime; // 到达时间对象
34 this._$_stoptime = otherParamObj.stoptime; // 停站时间 34 this._$_stoptime = otherParamObj.stoptime; // 停站时间
  35 + this._$_iEatTime = 0; // 吃饭时间
35 this._$_tccid = otherParamObj.tccid; // 停车场id 36 this._$_tccid = otherParamObj.tccid; // 停车场id
36 this._$_ttinfoid = otherParamObj.ttinfoid; // 时刻表id 37 this._$_ttinfoid = otherParamObj.ttinfoid; // 时刻表id
37 this._$_xlid = otherParamObj.xl; // 线路id 38 this._$_xlid = otherParamObj.xl; // 线路id
@@ -45,6 +46,13 @@ var InternalBcObj = function( @@ -45,6 +46,13 @@ var InternalBcObj = function(
45 46
46 //------------------- get/set 方法 -------------------// 47 //------------------- get/set 方法 -------------------//
47 48
  49 +InternalBcObj.prototype.fnSetEatTime = function(iTime) {
  50 + this._$_iEatTime = iTime;
  51 +};
  52 +InternalBcObj.prototype.fnGetEatTime = function() {
  53 + return this._$_iEatTime;
  54 +};
  55 +
48 InternalBcObj.prototype.fnSetDelFlag = function(bFlag) { 56 InternalBcObj.prototype.fnSetDelFlag = function(bFlag) {
49 this._$_bDelFlag = bFlag; 57 this._$_bDelFlag = bFlag;
50 }; 58 };
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalLpObj.js
@@ -584,10 +584,10 @@ InternalLpObj.prototype.initDataFromTimeToTime = function( @@ -584,10 +584,10 @@ InternalLpObj.prototype.initDataFromTimeToTime = function(
584 //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm")); 584 //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm"));
585 //console.log("endtime: " + endTime.format("HH:mm")); 585 //console.log("endtime: " + endTime.format("HH:mm"));
586 586
587 - if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) {  
588 - // 如果最后一个班次的到达时间超过结束时间,也要去除  
589 - bcData.splice(bcCount - 1, 1);  
590 - } 587 + //if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) {
  588 + // // 如果最后一个班次的到达时间超过结束时间,也要去除
  589 + // bcData.splice(bcCount - 1, 1);
  590 + //}
591 591
592 this._initDataFromLbBcArray(bcData, fromQ); 592 this._initDataFromLbBcArray(bcData, fromQ);
593 593
@@ -738,7 +738,7 @@ InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, para @@ -738,7 +738,7 @@ InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, para
738 "cf", 738 "cf",
739 !oPreBc.isUp(), // 和上一个班次方向相反 739 !oPreBc.isUp(), // 和上一个班次方向相反
740 1, 740 1,
741 - oPreBc.getArrTimeObj(), // 使用上一个班次的到达时间作为开始时间 741 + paramObj.addMinute(oPreBc.getArrTimeObj(), oPreBc.getStopTime()), // 使用上一个班次的到达时间作为开始时间
742 paramObj 742 paramObj
743 ); 743 );
744 744
@@ -749,8 +749,10 @@ InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, para @@ -749,8 +749,10 @@ InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, para
749 iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m"); 749 iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m");
750 this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime); 750 this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime);
751 751
752 - oPreBc.setStopTime(0);  
753 - this._$_other_bc_array.push(oEatBc); 752 + oPreBc.setStopTime(0); // 不重置停站时间
  753 + oPreBc.fnSetEatTime(oEatBc.getBcTime());
  754 +
  755 + //this._$_other_bc_array.push(oEatBc);
754 756
755 return iBcModifyTime; 757 return iBcModifyTime;
756 } else { 758 } else {
@@ -759,6 +761,69 @@ InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, para @@ -759,6 +761,69 @@ InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, para
759 761
760 }; 762 };
761 763
  764 +/**
  765 + * 调整路牌的班次,通过调整停站时间,或者班次发车时间,不能让班次的到达时间和下一个班次的发车时间重叠。
  766 + * @param iPeakAverStopTime 高峰平均停站时间
  767 + * @param iTroughAverStopTime 低谷平均停站时间
  768 + * @param oParam 参数对象
  769 + */
  770 +InternalLpObj.prototype.fnAdjustBcInterval = function(iPeakAverStopTime, iTroughAverStopTime, oParam) {
  771 + // 获取车次链个数
  772 + var iBcChainCount = this.fnGetBcChainCount();
  773 +
  774 + var i;
  775 + var j;
  776 + var oBcIndex;
  777 + var iQIndex;
  778 + var iBcIndex;
  779 + var iBcCount;
  780 + var oBc;
  781 + var oNextBc;
  782 +
  783 + var iBcStopTime;
  784 +
  785 + for (i = 0; i < iBcChainCount; i++) {
  786 + oBcIndex = this.fnGetBcChainInfo(i);
  787 + iQIndex = oBcIndex["s_q"];
  788 + iBcIndex = oBcIndex["s_b"];
  789 + iBcCount = oBcIndex["bcount"];
  790 +
  791 + for (j = 0; j < iBcCount - 1; j++) {
  792 + oBc = this.getBc(iQIndex, iBcIndex);
  793 + oNextBc = this.getBc(
  794 + iBcIndex == 0 ? iQIndex : iQIndex + 1,
  795 + iBcIndex == 0 ? 1 : 0);
  796 +
  797 + // 不改变当前班次的行驶时间,修正停站时间和下一个班次的发车时间
  798 + iBcStopTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m");
  799 + if (iBcStopTime < 0) {
  800 + // 当前班次使用最小停站时间
  801 + oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp()));
  802 + oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime);
  803 +
  804 + } else {
  805 + if (iBcStopTime == oBc.getStopTime() + oBc.fnGetEatTime()) {
  806 + // 停站时间一致,没有问题
  807 +
  808 +
  809 + } else {
  810 + // TODO:当前班次使用最小停站时间
  811 + oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp()));
  812 + oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime);
  813 +
  814 + }
  815 + }
  816 +
  817 + iBcIndex = iBcIndex == 0 ? 1 : 0;
  818 + iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex;
  819 + }
  820 +
  821 + this.getBc(iQIndex, iBcIndex).setStopTime(0);
  822 + }
  823 +
  824 +
  825 +};
  826 +
762 827
763 // TODO 828 // TODO
764 829
@@ -771,3 +836,8 @@ InternalLpObj.prototype.calcuLpBx = function() { @@ -771,3 +836,8 @@ InternalLpObj.prototype.calcuLpBx = function() {
771 }; 836 };
772 837
773 838
  839 +
  840 +
  841 +
  842 +
  843 +
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalScheduleObj.js
@@ -73,12 +73,12 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -73,12 +73,12 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
73 isUp = !isUp; 73 isUp = !isUp;
74 } while(_kssj.isBefore(et)); 74 } while(_kssj.isBefore(et));
75 bcCount--; // 因为先做do,所以总的班次要减1 75 bcCount--; // 因为先做do,所以总的班次要减1
76 - if (bcCount > 0 && bcArsjArrays[bcCount - 1].isAfter(et)) {  
77 - // 如果最后一个班次的到达时间超过结束时间,也要去除  
78 - bcFcsjArrays.splice(bcCount - 1, 1);  
79 - bcArsjArrays.splice(bcCount - 1, 1);  
80 - bcCount--;  
81 - } 76 + //if (bcCount > 0 && bcArsjArrays[bcCount - 1].isAfter(et)) {
  77 + // // 如果最后一个班次的到达时间超过结束时间,也要去除
  78 + // bcFcsjArrays.splice(bcCount - 1, 1);
  79 + // bcArsjArrays.splice(bcCount - 1, 1);
  80 + // bcCount--;
  81 + //}
82 var _qCount_p1 = Math.floor(bcCount / 2); // 2个班次一圈 82 var _qCount_p1 = Math.floor(bcCount / 2); // 2个班次一圈
83 var _qCount_p2 = bcCount % 2; // 余下的1个班次也算一圈 83 var _qCount_p2 = bcCount % 2; // 余下的1个班次也算一圈
84 84
@@ -119,23 +119,42 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -119,23 +119,42 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
119 if (aBcArray.length % 2 != 0) { // 不能整除2,去除一个班次计算 119 if (aBcArray.length % 2 != 0) { // 不能整除2,去除一个班次计算
120 aBcArray.splice(aBcArray.length - 1, 1); 120 aBcArray.splice(aBcArray.length - 1, 1);
121 } 121 }
122 - var sum = 0;  
123 - // 加吃饭时间  
124 - sum += _paramObj.fnGetLunchTime();  
125 - sum += _paramObj.fnGetDinnerTime();  
126 - // 加进出场时间  
127 - sum += _qIsUp ? _paramObj.getUpOutTime() : _paramObj.getDownOutTime();  
128 - sum += _qIsUp ? _paramObj.getDownInTime() : _paramObj.getUpInTime(); 122 +
  123 + // 午饭吃饭时间
  124 + var iLTime = _paramObj.fnGetLunchTime();
  125 + // 晚饭吃饭时间
  126 + var iDTime = _paramObj.fnGetDinnerTime();
  127 + // 出场时间
  128 + var iOutTime = _qIsUp ? _paramObj.getUpOutTime() : _paramObj.getDownOutTime();
  129 + // 进场时间
  130 + var iInTime = _qIsUp ? _paramObj.getDownInTime() : _paramObj.getUpInTime();
129 // 例保时间 131 // 例保时间
130 - //sum += _paramObj.getLbTime() * 2; 132 + var iBTime = _paramObj.getLbTime();
  133 +
  134 + var sum = 0; // 总班次时间
131 for (i = 0; i < aBcArray.length; i++) { 135 for (i = 0; i < aBcArray.length; i++) {
132 sum += aBcArray[i].getBcTime() + aBcArray[i].getStopTime(); 136 sum += aBcArray[i].getBcTime() + aBcArray[i].getStopTime();
133 } 137 }
  138 + sum += iLTime; // 加午饭时间
  139 + sum += iDTime; // 加晚饭时间
134 for (i = 0; i < _aBxDesc.length; i++) { 140 for (i = 0; i < _aBxDesc.length; i++) {
135 - _aBxDesc[i].fAverTime = sum / (aBcArray.length / 2);  
136 - _aBxDesc[i].fBcCount = ((_aBxDesc[i].fHoursV * 60) / _aBxDesc[i].fAverTime) * 2; 141 + _aBxDesc[i].fAverTime = sum / (aBcArray.length / 2); // 平均周转时间不算进出场,例保时间
  142 +
  143 + // 计算5休2的班次数(双进出场,4个例保)
  144 + if (i == 6) {
  145 + _aBxDesc[i].fQCount =
  146 + (_aBxDesc[i].fHoursV * 60 - iOutTime * 2 - iInTime * 2 - iBTime * 4) /
  147 + _aBxDesc[i].fAverTime;
  148 + _aBxDesc[i].fBcCount = _aBxDesc[i].fQCount * 2;
  149 + } else { // 进出场,2个例保
  150 + _aBxDesc[i].fQCount =
  151 + (_aBxDesc[i].fHoursV * 60 - iOutTime - iInTime - iBTime * 2) /
  152 + _aBxDesc[i].fAverTime;
  153 + _aBxDesc[i].fBcCount = _aBxDesc[i].fQCount * 2;
  154 + }
137 } 155 }
138 156
  157 +
139 // 在第一个班次之前再添加一个模拟班次,用于中标线的作用 158 // 在第一个班次之前再添加一个模拟班次,用于中标线的作用
140 // 那一圈必定是低谷,而且圈索引0,班次索引1,暂时标记,最后删除 159 // 那一圈必定是低谷,而且圈索引0,班次索引1,暂时标记,最后删除
141 var iFirstStopTime = 160 var iFirstStopTime =
@@ -342,9 +361,14 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -342,9 +361,14 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
342 throw "总分班路牌数小于加班路牌数"; 361 throw "总分班路牌数小于加班路牌数";
343 } 362 }
344 363
  364 + //// 修正连班路牌数,班次间隔大于20的,加1,直至班次间隔小于20
  365 + //while(_paramObj.calcuPeakZzsj() / iDgminpc > 20) {
  366 + // iDgminpc ++;
  367 + //}
345 _iBx_lb_lpcount = iDgminpc; 368 _iBx_lb_lpcount = iDgminpc;
  369 +
346 _iBx_5_2_fb_lpcount = i_5_2_lpes; 370 _iBx_5_2_fb_lpcount = i_5_2_lpes;
347 - _iBx_other_fb_lpcount = iCls - iDgminpc - i_5_2_lpes; 371 + _iBx_other_fb_lpcount = iCls - _iBx_lb_lpcount - i_5_2_lpes;
348 372
349 //------------------------ 2、利用间隔法计算连班路牌分布 --------------------// 373 //------------------------ 2、利用间隔法计算连班路牌分布 --------------------//
350 var i; 374 var i;
@@ -401,7 +425,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -401,7 +425,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
401 } 425 }
402 } 426 }
403 427
404 - 428 + console.log("高峰周转时间:" + _paramObj.calcuPeakZzsj());
405 console.log("连班路牌数:" + _iBx_lb_lpcount); 429 console.log("连班路牌数:" + _iBx_lb_lpcount);
406 console.log("5休2分班路牌数:" + _iBx_5_2_fb_lpcount); 430 console.log("5休2分班路牌数:" + _iBx_5_2_fb_lpcount);
407 console.log("其他分班路牌数:" + _iBx_other_fb_lpcount); 431 console.log("其他分班路牌数:" + _iBx_other_fb_lpcount);
@@ -579,72 +603,75 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -579,72 +603,75 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
579 } 603 }
580 }; 604 };
581 605
582 -  
583 /** 606 /**
584 - * 在指定位置生成班次(内部重要方法)。  
585 - * @param lpIndex 第几个路牌  
586 - * @param qIndex 第几圈  
587 - * @param bcIndex 第几个班次  
588 - * @returns InternalBcObj 607 + * 获取班次列表。
  608 + * @param oIsUp 是否上行
  609 + * @param oStartTime 开始时间对象
  610 + * @returns [(InternalBcObj)]
589 */ 611 */
590 - var _generateBc = function(lpIndex, qIndex, bcIndex) {  
591 - // 在初始化布局后使用,否则没有参照班次加不了  
592 - // 初始化布局后,相当于把时刻表比作一个围棋棋盘,行为路牌数,列为圈数  
593 - // 上标线,中标线,早晚高峰已经布局在棋盘上,其余的空格可以创建班次  
594 -  
595 - // 这个生成班次是以上一班次时间,以发车间隔为基础添加的,纵向加  
596 - // 和生成标线时那种一直往后加班次时不一样,那种是以前一个班次为基础,横向加  
597 -  
598 - // 1、生成的班次以同一圈同一个方向里离它最早的班次的发车时间为基础  
599 - // 2、以每个路牌的纵向最小发车间隔时间为计算发车间隔  
600 - // 3、如果班次发车时间越界不管,有其余方法排除这种情况 612 + var _fnGetBcList2 = function(oIsUp, oStartTime) {
  613 + var i;
  614 + var j;
  615 + var oLp;
  616 + var oBc;
  617 + var aBc = [];
601 618
602 - // 1、查找同圈同方向里最近的班次,找不到报错(因为有标线存在是不可能找不到的)  
603 - var _i;  
604 - var _bcObj;  
605 - for (_i = lpIndex - 1; _i >= 0; _i--) {  
606 - _bcObj = _internalLpArray[_i].getBc(qIndex, bcIndex);  
607 - if (_bcObj) {  
608 - break; 619 + for (j = 0; j < _qCount; j++) {
  620 + for (i = 0; i < _internalLpArray.length; i++) {
  621 + oLp = _internalLpArray[i];
  622 + oBc = oLp.getBc(
  623 + j,
  624 + _qIsUp == oIsUp ? 0 : 1
  625 + );
  626 + if (oBc && oBc.getFcTimeObj().isAfter(oStartTime)) {
  627 + aBc.push(oBc);
  628 + }
609 } 629 }
610 } 630 }
611 - if (!_bcObj) {  
612 - return false;  
613 - //alert("无法在指定位置生成班次");  
614 - //throw "无法在路牌index=" + lpIndex + ",圈index=" + qIndex + ",班次index=" + bcIndex + "生成班次";  
615 - }  
616 631
617 - // 2、计算发车间隔  
618 - var _intervalTime = 0;  
619 - for (_i = _i + 1; _i <= lpIndex; _i++) {  
620 - _intervalTime += _internalLpArray[_i].getVerticalMinIntervalTime(); 632 + var aBcFcTime = [];
  633 + for (i = 0; i < aBc.length; i++) {
  634 + oBc = aBc[i];
  635 + aBcFcTime.push(oBc.getFcTimeObj().format("HH:mm"));
621 } 636 }
  637 + console.log((oIsUp ? "上行班次列表:" : "下行班次列表:") + aBcFcTime.join(","));
622 638
623 - // 3、计算班次并添加班次  
624 - var _kssj = _paramObj.addMinute(_bcObj.getFcTimeObj(), _intervalTime);  
625 - _bcObj = _factory.createBcObj(  
626 - _internalLpArray[lpIndex],  
627 - "normal", _bcObj.isUp(),  
628 - 1, _kssj, _paramObj);  
629 - _bcObj.setGroup(_internalLpArray[lpIndex].getGroup(qIndex));  
630 -  
631 - return _bcObj;  
632 -  
633 - // TODO:这种添加班次的方法,可能造成相邻班次的停站时间问题  
634 - // TODO:主要是由于中标线的问题,但是误差不会很大,  
635 - // TODO:后面有方法直接调整停站时间(所谓的平滑过度时间) 639 + return aBc;
636 }; 640 };
637 641
638 /** 642 /**
639 - * 在指定位置生成班次并添加到路牌指定位置中。  
640 - * @param lpIndex 第几个路牌  
641 - * @param qIndex 第几圈  
642 - * @param bcIndex 第几个班次 643 + * 获取班次列表。
  644 + * @param isUp boolean 是否上行
  645 + * @returns [(InternalBcObj)]
643 */ 646 */
644 - var _generateBcAndSetBc = function(lpIndex, qIndex, bcIndex) {  
645 - var _bcObj = _generateBc(lpIndex, qIndex, bcIndex);  
646 - _internalLpArray[lpIndex].setBc(qIndex, bcIndex, _bcObj); 647 + var _fnGetBcList = function(isUp) {
  648 + var i;
  649 + var j;
  650 + var oLp;
  651 + var oBc;
  652 + var aBc = [];
647 653
  654 + for (j = 0; j < _qCount; j++) {
  655 + for (i = 0; i < _internalLpArray.length; i++) {
  656 + oLp = _internalLpArray[i];
  657 + oBc = oLp.getBc(
  658 + j,
  659 + _qIsUp == isUp ? 0 : 1
  660 + );
  661 + if (oBc) {
  662 + aBc.push(oBc);
  663 + }
  664 + }
  665 + }
  666 +
  667 + var aBcFcTime = [];
  668 + for (i = 0; i < aBc.length; i++) {
  669 + oBc = aBc[i];
  670 + aBcFcTime.push(oBc.getFcTimeObj().format("HH:mm"));
  671 + }
  672 + console.log((isUp ? "上行班次列表:" : "下行班次列表:") + aBcFcTime.join(","));
  673 +
  674 + return aBc;
648 }; 675 };
649 676
650 /** 677 /**
@@ -653,9 +680,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -653,9 +680,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
653 * @param isUp 是否上行 680 * @param isUp 是否上行
654 * @returns [{路牌index},{圈index},{班次index}] 681 * @returns [{路牌index},{圈index},{班次index}]
655 */ 682 */
656 - var _findUpClosedBcIndexWithTime = function(timeObj, isUp) {  
657 -  
658 - // dododo 683 + var _fnFindUpClosedBcIndexWithTime = function(timeObj, isUp) {
659 684
660 var _lpObj; 685 var _lpObj;
661 var _groupObj; 686 var _groupObj;
@@ -672,9 +697,9 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -672,9 +697,9 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
672 for (_j = 0; _j < _internalLpArray.length; _j++) { 697 for (_j = 0; _j < _internalLpArray.length; _j++) {
673 _lpObj = _internalLpArray[_j]; 698 _lpObj = _internalLpArray[_j];
674 _groupObj = _lpObj.getGroup(_i); 699 _groupObj = _lpObj.getGroup(_i);
675 - _bcObj = isUp ? _groupObj.getBc1() : _groupObj.getBc2(); 700 + _bcObj = isUp == _qIsUp ? _groupObj.getBc1() : _groupObj.getBc2();
676 if (!_bcObj) { // 没有班次动态生成一个,可能生成不出的 701 if (!_bcObj) { // 没有班次动态生成一个,可能生成不出的
677 - _bcObj = _generateBc(_j, _i, isUp == _qIsUp ? 0 : 1); 702 + _bcObj = _fnGenerateBc(_j, _i, isUp == _qIsUp ? 0 : 1);
678 } 703 }
679 if (_bcObj) { 704 if (_bcObj) {
680 if (timeObj.diff(_bcObj.getFcTimeObj()) >= 0) { 705 if (timeObj.diff(_bcObj.getFcTimeObj()) >= 0) {
@@ -714,7 +739,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -714,7 +739,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
714 * @param isUp 是否上行 739 * @param isUp 是否上行
715 * @returns [{路牌index},{圈index},{班次index}] 740 * @returns [{路牌index},{圈index},{班次index}]
716 */ 741 */
717 - var _findDownClosedBcIndexWithTime = function(timeObj, isUp) { 742 + var _fnFindDownClosedBcIndexWithTime = function(timeObj, isUp) {
718 var _lpObj; 743 var _lpObj;
719 var _groupObj; 744 var _groupObj;
720 var _bcObj; 745 var _bcObj;
@@ -732,9 +757,10 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -732,9 +757,10 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
732 for (_j = 0; _j < _internalLpArray.length; _j++) { 757 for (_j = 0; _j < _internalLpArray.length; _j++) {
733 _lpObj = _internalLpArray[_j]; 758 _lpObj = _internalLpArray[_j];
734 _groupObj = _lpObj.getGroup(_i); 759 _groupObj = _lpObj.getGroup(_i);
735 - _bcObj = isUp ? _groupObj.getBc1() : _groupObj.getBc2(); 760 + // TODO:bug
  761 + _bcObj = isUp == _qIsUp ? _groupObj.getBc1() : _groupObj.getBc2();
736 if (!_bcObj) { // 没有班次动态生成一个,可能生成不出的 762 if (!_bcObj) { // 没有班次动态生成一个,可能生成不出的
737 - _bcObj = _generateBc(_j, _i, isUp == _qIsUp ? 0 : 1); 763 + _bcObj = _fnGenerateBc(_j, _i, isUp == _qIsUp ? 0 : 1);
738 } 764 }
739 if (_bcObj) { 765 if (_bcObj) {
740 //console.log("timeobj -> bcobj diff flag " + 766 //console.log("timeobj -> bcobj diff flag " +
@@ -777,6 +803,48 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -777,6 +803,48 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
777 return bcindex; 803 return bcindex;
778 }; 804 };
779 805
  806 + /**
  807 + * 获取班次索引。
  808 + * @param oBc 班次对象
  809 + * @returns [{路牌索引},{圈索引},{班次索引}]
  810 + */
  811 + var _fnGetBcIndex = function(oBc) {
  812 + // 路牌索引
  813 + var i;
  814 + var iLpIndex;
  815 + for (i = 0; i < _internalLpArray.length; i++) {
  816 + if (_internalLpArray[i]._$$_orign_lp_obj == oBc._$$_internal_lp_obj._$$_orign_lp_obj) {
  817 + iLpIndex = i;
  818 + break;
  819 + }
  820 + }
  821 + // 圈索引
  822 + var j;
  823 + var iGroupIndex;
  824 + var bFlag = false;
  825 + for (i = 0; i < _internalLpArray.length; i++) {
  826 + if (bFlag) {
  827 + break;
  828 + }
  829 + for (j = 0; j < _qCount; j++) {
  830 + if (_internalLpArray[i]._$_groupBcArray[j] == oBc._$$_internal_group_obj) {
  831 + iGroupIndex = j;
  832 + bFlag = true;
  833 + break;
  834 + }
  835 + }
  836 + }
  837 + // 班次索引
  838 + var iBcIndex = _qIsUp == oBc.isUp() ? 0 : 1;
  839 +
  840 + if (iLpIndex == undefined) {
  841 + return null;
  842 + } else {
  843 + return [].concat(iLpIndex, iGroupIndex, iBcIndex);
  844 + }
  845 +
  846 + };
  847 +
780 return { 848 return {
781 //------------- 布局初始化方法 ------------// 849 //------------- 布局初始化方法 ------------//
782 /** 850 /**
@@ -805,14 +873,14 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -805,14 +873,14 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
805 fnAdjustGfbc : function(isZgf, isUp) { 873 fnAdjustGfbc : function(isZgf, isUp) {
806 var oStartTime; // 开始时间 874 var oStartTime; // 开始时间
807 var oEndTime; // 结束时间 875 var oEndTime; // 结束时间
808 - var iStartBcIndex; // 开始班次索引  
809 - var iEndBcIndex; // 结束班次索引 876 + var aStartBcIndex; // 开始班次索引
  877 + var aEndBcIndex; // 结束班次索引
810 878
811 oStartTime = isZgf ? _paramObj.getMPeakStartTimeObj() : _paramObj.getEPeakStartTimeObj(); 879 oStartTime = isZgf ? _paramObj.getMPeakStartTimeObj() : _paramObj.getEPeakStartTimeObj();
812 oEndTime = isZgf ? _paramObj.getMPeakEndTimeObj() : _paramObj.getEPeakEndTimeObj(); 880 oEndTime = isZgf ? _paramObj.getMPeakEndTimeObj() : _paramObj.getEPeakEndTimeObj();
813 881
814 - aStartBcIndex = _findUpClosedBcIndexWithTime(oStartTime, isUp);  
815 - aEndBcIndex = _findDownClosedBcIndexWithTime(oEndTime, isUp); 882 + aStartBcIndex = _fnFindUpClosedBcIndexWithTime(oStartTime, isUp);
  883 + aEndBcIndex = _fnFindDownClosedBcIndexWithTime(oEndTime, isUp);
816 884
817 var iLpIndex; 885 var iLpIndex;
818 var iQIndex; 886 var iQIndex;
@@ -848,6 +916,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -848,6 +916,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
848 iQInternelCount = aEndBcIndex[1] - aStartBcIndex[1] - 1; 916 iQInternelCount = aEndBcIndex[1] - aStartBcIndex[1] - 1;
849 for (i = 1; i <= iQInternelCount; i++) { 917 for (i = 1; i <= iQInternelCount; i++) {
850 oLp = _internalLpArray[iQIndex + i]; 918 oLp = _internalLpArray[iQIndex + i];
  919 +
851 if (!oLp.getBc(iQIndex + i, iBcIndex)) { 920 if (!oLp.getBc(iQIndex + i, iBcIndex)) {
852 _fnGenerateBcAndSetBc(i, iQIndex + i, iBcIndex); 921 _fnGenerateBcAndSetBc(i, iQIndex + i, iBcIndex);
853 } 922 }
@@ -1024,14 +1093,15 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -1024,14 +1093,15 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
1024 * 从车次链的后面开始加 1093 * 从车次链的后面开始加
1025 */ 1094 */
1026 fnCalcuLpBx_other: function() { 1095 fnCalcuLpBx_other: function() {
1027 - // TODO:暂时使用做2休1的班型  
1028 - // 计算做5休2班型所需的班次数  
1029 - var iBxBcount = _aBxDesc[4].fBcCount;  
1030 - if (iBxBcount - Math.floor(iBxBcount) > 0.7) {  
1031 - iBxBcount = Math.floor(iBxBcount) + 1;  
1032 - } else {  
1033 - iBxBcount = Math.floor(iBxBcount); 1096 + // TODO:根据上标线的首班时间确定班型,小于05:59的做一休一,否则做二休一
  1097 + var oSt = _qIsUp ? _paramObj.getUpFirstDTimeObj() : _paramObj.getDownFirstDTimeObj();
  1098 + var iBxIndex = 4;
  1099 + if (oSt.isBefore(_paramObj.toTimeObj("05:59"))) {
  1100 + iBxIndex = 5;
1034 } 1101 }
  1102 + // 计算做5休2班型所需的班次数
  1103 + var iQBcount = _aBxDesc[iBxIndex].fQCount;
  1104 + var iBxBcount = Math.round(iQBcount) * 2;
1035 1105
1036 var i; 1106 var i;
1037 var j; 1107 var j;
@@ -1110,8 +1180,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -1110,8 +1180,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
1110 while (iTempBcIndex <= 1) { 1180 while (iTempBcIndex <= 1) {
1111 oBc = _fnGenerateBc(aLbLpindexes[i], j, iTempBcIndex); 1181 oBc = _fnGenerateBc(aLbLpindexes[i], j, iTempBcIndex);
1112 if (oBc && 1182 if (oBc &&
1113 - oBc.getFcTimeObj().isBefore(oEndsj) &&  
1114 - oBc.getArrTimeObj().isBefore(oEndsj)) { 1183 + oBc.getFcTimeObj().isBefore(oEndsj) ) {
1115 oLp.setBc(j, iTempBcIndex, oBc); 1184 oLp.setBc(j, iTempBcIndex, oBc);
1116 } 1185 }
1117 iTempBcIndex++; 1186 iTempBcIndex++;
@@ -1177,157 +1246,95 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -1177,157 +1246,95 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
1177 }, 1246 },
1178 1247
1179 /** 1248 /**
1180 - * 计算末班车(一般都落在连班班型上,因为按照现在的布局方法,分班路牌不会一直连到最后)。  
1181 - * 1、确定末班车早的班次  
1182 - * 2、从后往前找到与这个班次最匹配的班次的位置(第几个路牌,第几圈,第几个班次),然后覆盖  
1183 - * 3、从第2步找的位置,往上找与另一个末班车匹配的班次位置,然后覆盖 1249 + * 计算末班车。
  1250 + * 1、将上下行拉成上下行两个班次列表(包括标记班次)
  1251 + * 2、分别找出离末班车发车时间最近的班次,并替换时间
  1252 + * 3、删除之后的班次
1184 */ 1253 */
1185 fnCalcuLastBc: function() { 1254 fnCalcuLastBc: function() {
1186 - //-------------------- 1、确定末班车早的方向,时间 -----------------------//  
1187 - var _oLastTime;  
1188 - var _bLastIsUp; 1255 + var i;
  1256 + var iTimeDiff;
  1257 + var iTempTime;
  1258 + var aBc;
  1259 + var oLastBcTime;
  1260 + var oLastBcIsUp;
  1261 + var iModifyIndex;
  1262 +
  1263 + // 查找末班车早的末班车时间和方向
1189 if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) { 1264 if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) {
1190 - _oLastTime = _paramObj.getUpLastDtimeObj();  
1191 - _bLastIsUp = true; 1265 + oLastBcTime = _paramObj.getUpLastDtimeObj();
  1266 + oLastBcIsUp = true;
1192 } else { 1267 } else {
1193 - _oLastTime = _paramObj.getDownLastDTimeObj();  
1194 - _bLastIsUp = false; 1268 + oLastBcTime = _paramObj.getDownLastDTimeObj();
  1269 + oLastBcIsUp = false;
1195 } 1270 }
1196 1271
1197 - //-------------------- 2、确定比 _oLastTime 小或者等于的班次位置,并修改班次时间到末班车时间 -----------------//  
1198 - var i;  
1199 - var j;  
1200 - var _oBc;  
1201 - var _oLp;  
1202 - var _aBcIndex;  
1203 -  
1204 - for (i = _qCount - 1; i >= 0; i--) {  
1205 - if (_aBcIndex) {  
1206 - break;  
1207 - }  
1208 - // 从大到小找到第一个合适的班次索引  
1209 - for (j = _internalLpArray.length - 1; j >= 0; j--) {  
1210 - _oLp = _internalLpArray[j];  
1211 - if (_oLp.isBxLb()) {  
1212 - _oBc = _oLp.getBc(i, _qIsUp == _bLastIsUp ? 0 : 1);  
1213 - }  
1214 - if (_oBc != undefined && _oBc.getFcTimeObj().isBefore(_oLastTime)) {  
1215 - _aBcIndex = [];  
1216 - _aBcIndex.push(j); // 路牌索引  
1217 - _aBcIndex.push(i); // 圈索引  
1218 - _aBcIndex.push(_qIsUp == _bLastIsUp ? 0 : 1); // 班次索引  
1219 - break;  
1220 - } 1272 + // 确定早的末班车时间
  1273 + aBc = _fnGetBcList(oLastBcIsUp);
  1274 + for (i = 0; i < aBc.length; i++) {
  1275 + iTempTime = oLastBcTime.diff(aBc[i].getFcTimeObj(), "m");
  1276 + if (iTimeDiff == undefined) {
  1277 + iTimeDiff = iTempTime;
  1278 + iModifyIndex = i;
  1279 + } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff)) {
  1280 + iTimeDiff = iTempTime;
  1281 + iModifyIndex = i;
1221 } 1282 }
1222 } 1283 }
1223 -  
1224 - //-------------------- 3、预估哪个个班次离末班最近,用末班替换,并删除后面的多余班次 -----------------//  
1225 - // 第2步找到的班次不一定是最适合的,需要把之后的班次模拟出来再比较一下  
1226 - var _aBcIndexes = []; // 里面放对象 {lpIndex,qIndex,bcIndex,fcsjTime}  
1227 - _oBc = undefined;  
1228 - for (i = _aBcIndex[0]; i < _internalLpArray.length; i++) {  
1229 - _oLp = _internalLpArray[i];  
1230 - if (_oLp.isBxLb()) {  
1231 - _oBc = _oLp.getBc(_aBcIndex[1], _aBcIndex[2]);  
1232 - if (_oBc == undefined) {  
1233 - _oBc = _fnGenerateBc(i, _aBcIndex[1], _aBcIndex[2]);  
1234 - }  
1235 - _aBcIndexes.push({  
1236 - lpIndex: i,  
1237 - qIndex: _aBcIndex[1],  
1238 - bcIndex: _aBcIndex[2],  
1239 - bcObj: _oBc  
1240 - })  
1241 - } 1284 + aBc[iModifyIndex].addMinuteToFcsj(iTimeDiff); // 替换成末班车时间
  1285 + aBc[iModifyIndex].fnSetDelFlag(false);
  1286 + for (i = iModifyIndex + 1; i < aBc.length; i++) { // 删除多余班次
  1287 + _qIsUp == oLastBcIsUp ?
  1288 + aBc[i]._$$_internal_group_obj.setBc1(undefined) :
  1289 + aBc[i]._$$_internal_group_obj.setBc2(undefined);
1242 } 1290 }
1243 - var _oBcIndex_find; // 第几个路牌离末班车最近  
1244 - for (i = _aBcIndexes.length - 1; i >= 0; i--) {  
1245 - if (_aBcIndexes[i].bcObj.getFcTimeObj().isBefore(_oLastTime)) {  
1246 - _oBcIndex_find = _aBcIndexes[i];  
1247 - break;  
1248 - }  
1249 - }  
1250 - // 替换成末班车  
1251 - _oBc = _oBcIndex_find.bcObj;  
1252 - _oBc.addMinuteToFcsj(_oLastTime.diff(_oBc.getFcTimeObj(), "m"));  
1253 - _internalLpArray[_oBcIndex_find.lpIndex].setBc(  
1254 - _oBcIndex_find.qIndex, _oBcIndex_find.bcIndex, _oBc  
1255 - );  
1256 1291
1257 - // 删除多余班次呢  
1258 - for (i = _oBcIndex_find.lpIndex + 1; i < _internalLpArray.length; i++) {  
1259 - _internalLpArray[i].removeBc(_oBcIndex_find.qIndex, _oBcIndex_find.bcIndex);  
1260 - }  
1261 -  
1262 - //---------------------- 4、从第3步找到的位置,开始往上找,确定另一个末班车,并删除后面多余的班次 -------------//  
1263 - // 因为另一个末班车时间晚,肯定在后面,并且必须在之前的路牌  
1264 - // 如果在之后的路牌,则意味着之前那个末班车位置不对,连班连起来会有两个之前的末班车  
1265 - // 计算大的末班车时间 1292 + // 查找末班车晚的末班车时间和方向
1266 if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) { 1293 if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) {
1267 - _oLastTime = _paramObj.getDownLastDTimeObj();  
1268 - _bLastIsUp = false; 1294 + oLastBcTime = _paramObj.getDownLastDTimeObj();
  1295 + oLastBcIsUp = false;
1269 } else { 1296 } else {
1270 - _oLastTime = _paramObj.getUpLastDtimeObj();  
1271 - _bLastIsUp = true; 1297 + oLastBcTime = _paramObj.getUpLastDtimeObj();
  1298 + oLastBcIsUp = true;
1272 } 1299 }
1273 - _aBcIndexes = [];  
1274 - for (i = _oBcIndex_find.lpIndex; i >=0; i--) {  
1275 - _oLp = _internalLpArray[i];  
1276 - if (_oLp.isBxLb()) {  
1277 - _oBc = _oLp.getBc(  
1278 - _oBcIndex_find.bcIndex == 0 ? _oBcIndex_find.qIndex : _oBcIndex_find.qIndex + 1,  
1279 - _oBcIndex_find.bcIndex == 0 ? 1 : 0  
1280 - );  
1281 - if (_oBc == undefined) {  
1282 - _oBc = _fnGenerateBc(  
1283 - i,  
1284 - _oBcIndex_find.bcIndex == 0 ? _oBcIndex_find.qIndex : _oBcIndex_find.qIndex + 1,  
1285 - _oBcIndex_find.bcIndex == 0 ? 1 : 0  
1286 - );  
1287 - }  
1288 - if (!_oBc) { // 纵向生成班次失败,用横向生成班次,发车时间取前一班次的到达时间加停战时间  
1289 - _oBc = _factory.createBcObj(  
1290 - _oLp,  
1291 - "normal",  
1292 - _bLastIsUp,  
1293 - 3,  
1294 - _oLp.getBc(_oBcIndex_find.qIndex, _oBcIndex_find.bcIndex).getArrTimeObj(),  
1295 - _paramObj  
1296 - ); 1300 + // 确定晚的末班车时间
  1301 + aBc = _fnGetBcList(oLastBcIsUp);
  1302 + var oBc;
  1303 + var aBcIndex;
  1304 + var iLpIndex;
  1305 + var iQIndex;
  1306 + var iBcIndex;
1297 1307
1298 - }  
1299 - _aBcIndexes.push({  
1300 - lpIndex: i,  
1301 - qIndex: _oBcIndex_find.bcIndex == 0 ? _oBcIndex_find.qIndex : _oBcIndex_find.qIndex + 1,  
1302 - bcIndex: _oBcIndex_find.bcIndex == 0 ? 1 : 0,  
1303 - bcObj: _oBc  
1304 - })  
1305 - }  
1306 - } 1308 + iTimeDiff = undefined;
  1309 + for (i = 0; i < aBc.length; i++) {
  1310 + oBc = aBc[i];
  1311 + aBcIndex = _fnGetBcIndex(oBc);
1307 1312
1308 - console.log(_aBcIndexes); 1313 + iLpIndex = aBcIndex[0];
  1314 + iQIndex = aBcIndex[2] == 0 ? aBcIndex[1] -1 : aBcIndex[1];
  1315 + iBcIndex = aBcIndex[2] == 0 ? 1 : 0;
1309 1316
1310 - _oBcIndex_find = _aBcIndexes[0]; 1317 + if (!_internalLpArray[iLpIndex].getBc(iQIndex, iBcIndex)) {
  1318 + continue;
  1319 + }
1311 1320
1312 - for (i = 0; i < _aBcIndexes.length; i++) {  
1313 - if (_aBcIndexes[i].bcObj.getFcTimeObj().isBefore(_oLastTime)) {  
1314 - _oBcIndex_find = _aBcIndexes[i];  
1315 - break; 1321 + iTempTime = oLastBcTime.diff(aBc[i].getFcTimeObj(), "m");
  1322 + if (iTimeDiff == undefined) {
  1323 + iTimeDiff = iTempTime;
  1324 + iModifyIndex = i;
  1325 + } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff)) {
  1326 + iTimeDiff = iTempTime;
  1327 + iModifyIndex = i;
1316 } 1328 }
1317 } 1329 }
1318 - // 替换成末班车  
1319 - _oBc = _oBcIndex_find.bcObj;  
1320 - _oBc.addMinuteToFcsj(_oLastTime.diff(_oBc.getFcTimeObj(), "m"));  
1321 - _internalLpArray[_oBcIndex_find.lpIndex].setBc(  
1322 - _oBcIndex_find.qIndex, _oBcIndex_find.bcIndex, _oBc  
1323 - );  
1324 -  
1325 - // 删除多余班次呢  
1326 - for (i = _oBcIndex_find.lpIndex + 1; i < _internalLpArray.length; i++) {  
1327 - _internalLpArray[i].removeBc(_oBcIndex_find.qIndex, _oBcIndex_find.bcIndex); 1330 + aBc[iModifyIndex].addMinuteToFcsj(iTimeDiff); // 替换成末班车时间
  1331 + aBc[iModifyIndex].fnSetDelFlag(false);
  1332 + for (i = iModifyIndex + 1; i < aBc.length; i++) { // 删除多余班次
  1333 + _qIsUp == oLastBcIsUp ?
  1334 + aBc[i]._$$_internal_group_obj.setBc1(undefined) :
  1335 + aBc[i]._$$_internal_group_obj.setBc2(undefined);
1328 } 1336 }
1329 1337
1330 -  
1331 }, 1338 },
1332 1339
1333 /** 1340 /**
@@ -1411,7 +1418,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -1411,7 +1418,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
1411 /** 1418 /**
1412 * 补每个路牌的其他班次(进出场,例保班次)。 1419 * 补每个路牌的其他班次(进出场,例保班次)。
1413 */ 1420 */
1414 - fnCalcuOtherBc: function() { 1421 + fnCalcuOtherBc_: function() {
1415 var i; 1422 var i;
1416 var _lpObj; 1423 var _lpObj;
1417 var _minBcIndex; 1424 var _minBcIndex;
@@ -1419,6 +1426,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -1419,6 +1426,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
1419 var _minBc; 1426 var _minBc;
1420 var _maxBc; 1427 var _maxBc;
1421 var _otherbc = []; 1428 var _otherbc = [];
  1429 + var _oFbbc;
1422 1430
1423 for (i = 0; i < _internalLpArray.length; i++) { 1431 for (i = 0; i < _internalLpArray.length; i++) {
1424 _lpObj = _internalLpArray[i]; 1432 _lpObj = _internalLpArray[i];
@@ -1428,11 +1436,11 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -1428,11 +1436,11 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
1428 _maxBc = _lpObj.getBc(_maxBcIndex[0], _maxBcIndex[1]); 1436 _maxBc = _lpObj.getBc(_maxBcIndex[0], _maxBcIndex[1]);
1429 1437
1430 _otherbc = []; 1438 _otherbc = [];
1431 - //_otherbc.push(_factory.createBcObj(  
1432 - // _lpObj, "bd", true, 1,  
1433 - // _minBc.getFcTimeObj(),  
1434 - // _paramObj  
1435 - //)); 1439 + _otherbc.push(_factory.createBcObj(
  1440 + _lpObj, "bd", true, 1,
  1441 + _minBc.getFcTimeObj(),
  1442 + _paramObj
  1443 + ));
1436 _otherbc.push(_factory.createBcObj( 1444 _otherbc.push(_factory.createBcObj(
1437 _lpObj, "out", true, 1, 1445 _lpObj, "out", true, 1,
1438 _minBc.getFcTimeObj(), 1446 _minBc.getFcTimeObj(),
@@ -1446,11 +1454,30 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -1446,11 +1454,30 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
1446 _maxBc.getArrTimeObj(), 1454 _maxBc.getArrTimeObj(),
1447 _paramObj 1455 _paramObj
1448 )); 1456 ));
1449 - //_otherbc.push(_factory.createBcObj(  
1450 - // _lpObj, "lc", true, 1,  
1451 - // _maxBc.getArrTimeObj(),  
1452 - // _paramObj  
1453 - //)); 1457 + _otherbc.push(_factory.createBcObj(
  1458 + _lpObj, "lc", true, 1,
  1459 + _maxBc.getArrTimeObj(),
  1460 + _paramObj
  1461 + ));
  1462 +
  1463 + // 5休2分班出场例保班次
  1464 + if (_lpObj.isBxFb5_2()) {
  1465 + _oFbbc = _lpObj.getBc(
  1466 + _lpObj.fnGetBcChainInfo(1)["s_q"],
  1467 + _lpObj.fnGetBcChainInfo(1)["s_b"]
  1468 + );
  1469 +
  1470 + _otherbc.push(_factory.createBcObj(
  1471 + _lpObj, "bd", true, 1,
  1472 + _oFbbc.getFcTimeObj(),
  1473 + _paramObj
  1474 + ));
  1475 + _otherbc.push(_factory.createBcObj(
  1476 + _lpObj, "out", true, 1,
  1477 + _oFbbc.getFcTimeObj(),
  1478 + _paramObj
  1479 + ));
  1480 + }
1454 1481
1455 _lpObj.addOtherBcArray(_otherbc); 1482 _lpObj.addOtherBcArray(_otherbc);
1456 } 1483 }
@@ -1458,13 +1485,75 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -1458,13 +1485,75 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
1458 }, 1485 },
1459 1486
1460 /** 1487 /**
1461 - * 祛除上标线有删除标记的班次。 1488 + * 补每个路牌的其他班次(进出场,例保班次)
  1489 + * 所有的车次链前后都加进出场、报道班次
1462 */ 1490 */
1463 - fnRemoveDelFlagBc: function() { 1491 + fnCalcuOtherBc: function() {
  1492 + var i;
  1493 + var j;
  1494 + var iBcChainCount;
  1495 + var oLp;
  1496 + var aOtherBc;
  1497 + var oStartBc;
  1498 + var oEndBc;
  1499 +
  1500 + for (i = 0; i < _internalLpArray.length; i++) {
  1501 + aOtherBc = [];
  1502 + oLp = _internalLpArray[i];
  1503 + iBcChainCount = oLp.fnGetBcChainCount();
  1504 +
  1505 + for (j = 0; j < iBcChainCount; j++) {
  1506 + oStartBc = oLp.getBc(
  1507 + oLp.fnGetBcChainInfo(j)["s_q"],
  1508 + oLp.fnGetBcChainInfo(j)["s_b"]
  1509 + );
  1510 + oEndBc = oLp.getBc(
  1511 + oLp.fnGetBcChainInfo(j)["e_q"],
  1512 + oLp.fnGetBcChainInfo(j)["e_b"]
  1513 + );
  1514 +
  1515 + // 车次链开头添加出场班次
  1516 + aOtherBc.push(_factory.createBcObj(
  1517 + oLp, "bd", true, 1,
  1518 + oStartBc.getFcTimeObj(),
  1519 + _paramObj
  1520 + ));
  1521 + aOtherBc.push(_factory.createBcObj(
  1522 + oLp, "out", true, 1,
  1523 + oStartBc.getFcTimeObj(),
  1524 + _paramObj
  1525 + ));
  1526 +
  1527 + // 车次链结尾添加进场班次
  1528 + aOtherBc.push(_factory.createBcObj(
  1529 + oLp, "in", true, 1,
  1530 + oEndBc.getArrTimeObj(),
  1531 + _paramObj
  1532 + ));
  1533 + aOtherBc.push(_factory.createBcObj(
  1534 + oLp, "lc", true, 1,
  1535 + oEndBc.getArrTimeObj(),
  1536 + _paramObj
  1537 + ));
  1538 + }
  1539 +
  1540 + oLp.addOtherBcArray(aOtherBc);
  1541 + }
  1542 + },
  1543 +
  1544 + /**
  1545 + * 祛除上标线开头的删除标记的班次。
  1546 + */
  1547 + fnRemoveDelFirstFlagBc: function() {
1464 var oLp = _internalLpArray[0]; 1548 var oLp = _internalLpArray[0];
1465 var aMinBcIndex = oLp.getMinBcObjPosition(); 1549 var aMinBcIndex = oLp.getMinBcObjPosition();
1466 oLp.removeBc(aMinBcIndex[0], aMinBcIndex[1]); 1550 oLp.removeBc(aMinBcIndex[0], aMinBcIndex[1]);
1467 - 1551 + },
  1552 + /**
  1553 + * 祛除上标线结尾的删除标记的班次。
  1554 + */
  1555 + fnRemoveDelLastFlagBc: function() {
  1556 + var oLp = _internalLpArray[0];
1468 var aMaxBcIndex = oLp.getMaxBcObjPosition(); 1557 var aMaxBcIndex = oLp.getMaxBcObjPosition();
1469 if (oLp.getBc(aMaxBcIndex[0], aMaxBcIndex[1]).fnIsDelFlag()) { 1558 if (oLp.getBc(aMaxBcIndex[0], aMaxBcIndex[1]).fnIsDelFlag()) {
1470 oLp.removeBc(aMaxBcIndex[0], aMaxBcIndex[1]); 1559 oLp.removeBc(aMaxBcIndex[0], aMaxBcIndex[1]);
@@ -1472,117 +1561,248 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -1472,117 +1561,248 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
1472 }, 1561 },
1473 1562
1474 /** 1563 /**
1475 - * 调整班次纵向间隔(发车时间调整)。  
1476 - * 1、只调整分班班次的发车时间  
1477 - * 2、调整每两个连班之间的分班班次组  
1478 - * 3、如果不是连续的班次才调整 1564 + * 调整路牌班次间隔(核准周转时间,停站时间)。
  1565 + * @param iFre int 迭代次数
1479 */ 1566 */
1480 - fnAdjust_vertical_bc_interval: function() {  
1481 - var i;  
1482 - var j;  
1483 - var iBIndex = 0;  
1484 - var oLbGroup = {};  
1485 - var oLp;  
1486 - for (i = 0; i < _qCount; i++) {  
1487 - while (iBIndex <= 1) {  
1488 - oLbGroup[i + "_" + iBIndex] = [];  
1489 - for (j = 0; j < _internalLpArray.length; j++) {  
1490 - oLp = _internalLpArray[j];  
1491 - if (oLp.isBxLb()) {  
1492 - if (oLp.getBc(i, iBIndex)) {  
1493 - oLbGroup[i + "_" + iBIndex].push(j);  
1494 - } 1567 + fnAdjustLpBcInterval: function(iFre) {
  1568 + if (iFre > 0) {
  1569 + for (var i = 0; i < _internalLpArray.length; i++) {
  1570 + _internalLpArray[i].fnAdjustBcInterval(
  1571 + this.fnCalcuAverPeakStopTime(),
  1572 + this.fnCalcuAverTroughStopTime(),
  1573 + _paramObj);
  1574 + }
  1575 +
  1576 + this.fnAdjustLpBcInterval(iFre - 1);
  1577 + }
  1578 + },
  1579 +
  1580 + /**
  1581 + * 调整班次间隔。
  1582 + * @param bIsUp 是否上行
  1583 + * @param oStartTime 开始时间对象
  1584 + * @param iFre 迭代次数
  1585 + */
  1586 + fnAdjustBcInterval2_: function(bIsUp, oStartTime, iFre) {
  1587 + if (iFre > 0) {
  1588 + var aBc = _fnGetBcList2(bIsUp, oStartTime); // 指定方向的班次列表
  1589 + aBc.sort(function(o1, o2) {
  1590 + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) {
  1591 + return -1;
  1592 + } else {
  1593 + return 1;
  1594 + }
  1595 + });
  1596 + var i;
  1597 + var j;
  1598 +
  1599 + var iBcCountOfGroup = 3; // 3个班次取一次计算
  1600 + var aBcOfGroup; // 3个班次列表
  1601 + var aBcIntervalOfGroup; // 班次间隔列表,如:3个班次,2个间隔
  1602 +
  1603 + for (i = 0; i <= aBc.length - iBcCountOfGroup; i++) {
  1604 + aBcOfGroup = [];
  1605 + aBcIntervalOfGroup = [];
  1606 + for (j = i; j < i + iBcCountOfGroup; j++) {
  1607 + aBcOfGroup.push(aBc[j]);
  1608 + }
  1609 +
  1610 + for (j = 0; j < aBcOfGroup.length; j++) {
  1611 + if (j < aBcOfGroup.length - 1) {
  1612 + aBcIntervalOfGroup.push(aBcOfGroup[j + 1].getFcTimeObj().diff(
  1613 + aBcOfGroup[j].getFcTimeObj(), "m"));
1495 } 1614 }
1496 } 1615 }
1497 - if (oLbGroup[i + "_" + iBIndex].length == 1) {  
1498 - oLbGroup[i + "_" + iBIndex] = []; 1616 +
  1617 + if (aBcIntervalOfGroup[0] < 19) {
  1618 + aBcOfGroup[1].addMinuteToFcsj(1);
  1619 + } else if (aBcIntervalOfGroup[0] > 20) {
  1620 + aBcOfGroup[1].addMinuteToFcsj(-1);
  1621 + } else {
  1622 + if (Math.abs(aBcIntervalOfGroup[0] - aBcIntervalOfGroup[1]) <= 1) {
  1623 + //continue;
  1624 + } else if (aBcIntervalOfGroup[0] > aBcIntervalOfGroup[1]) {
  1625 + aBcOfGroup[1].addMinuteToFcsj(-1);
  1626 + } else {
  1627 + aBcOfGroup[1].addMinuteToFcsj(1);
  1628 + }
1499 } 1629 }
1500 1630
1501 - iBIndex ++;  
1502 } 1631 }
1503 - iBIndex = 0; 1632 +
  1633 + this.fnAdjustBcInterval2(bIsUp, oStartTime, iFre - 1);
1504 } 1634 }
  1635 + },
1505 1636
1506 - //console.log(oLbGroup); 1637 + /**
  1638 + * 调整班次间隔。
  1639 + * @param boolean isUp 是否上行
  1640 + * @param oStartTime 开始时间对象
  1641 + * @param fre int 迭代次数
  1642 + */
  1643 + fnAdjustBcInterval: function(isUp, oStartTime, fre) {
  1644 + if (fre > 0) {
  1645 + var aBc = !oStartTime ? _fnGetBcList(isUp) : _fnGetBcList2(isUp, oStartTime); // 指定方向的班次列表
1507 1646
1508 - var sKey;  
1509 - var iQindex;  
1510 - var iBindex;  
1511 - var aBcLb = []; 1647 + aBc.sort(function(o1, o2) {
  1648 + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) {
  1649 + return -1;
  1650 + } else {
  1651 + return 1;
  1652 + }
  1653 + });
1512 1654
1513 - var oLbGroup_m = {};  
1514 - var aLbGroup = []; 1655 + var i;
  1656 + var j;
1515 1657
  1658 + var iBcCountOfGroup = 3; // 3个班次取一次计算
  1659 + var aBcOfGroup; // 3个班次列表
  1660 + var aBcIntervalOfGroup; // 班次间隔列表,如:3个班次,2个间隔
  1661 + var oBcFcTime; // 班次发车时间
1516 1662
1517 - // 计算需要调整的连班区间  
1518 - for (sKey in oLbGroup) {  
1519 - iQindex = sKey.split('_')[0];  
1520 - iBindex = sKey.split('_')[1];  
1521 - oLbGroup_m[sKey] = [];  
1522 - for (i = 0; i < oLbGroup[sKey].length - 1; i++) {  
1523 - aBcLb = [];  
1524 - for (j = oLbGroup[sKey][i] + 1; j <= oLbGroup[sKey][i + 1] - 1; j++) {  
1525 - oLp = _internalLpArray[j];  
1526 - if (oLp.getBc(iQindex, iBindex)) {  
1527 - aBcLb.push(j); 1663 + for (i = 0; i <= aBc.length - iBcCountOfGroup; i++) {
  1664 + aBcOfGroup = [];
  1665 + aBcIntervalOfGroup = [];
  1666 + for (j = i; j < i + iBcCountOfGroup; j++) {
  1667 + aBcOfGroup.push(aBc[j]);
  1668 + }
  1669 +
  1670 + for (j = 0; j < aBcOfGroup.length; j++) {
  1671 + if (j < aBcOfGroup.length - 1) {
  1672 + aBcIntervalOfGroup.push(aBcOfGroup[j + 1].getFcTimeObj().diff(
  1673 + aBcOfGroup[j].getFcTimeObj(), "m"));
1528 } 1674 }
1529 } 1675 }
1530 - if (aBcLb.length != 0 && aBcLb.length < (oLbGroup[sKey][i + 1] - oLbGroup[sKey][i] - 1)) {  
1531 - aLbGroup = [];  
1532 - aLbGroup.push(oLbGroup[sKey][i]);  
1533 - aLbGroup.push(oLbGroup[sKey][i + 1]);  
1534 - aLbGroup.push(aBcLb);  
1535 - oLbGroup_m[sKey].push(aLbGroup); 1676 +
  1677 + // 判定规则
  1678 + oBcFcTime = aBcOfGroup[1].getFcTimeObj();
  1679 +
  1680 + // 第一个班次发车时间不动,根据间隔,调整中间一个班次
  1681 + // 如果3个班次2个间隔时间差1分钟,不调整
  1682 + // 如果第一个间隔大,调整第二个班次往前1分钟
  1683 + // 如果第二个间隔大,调整第二个班次往后1分钟
  1684 +
  1685 + if (_paramObj.isTroughBc(oBcFcTime) &&
  1686 + aBcIntervalOfGroup[0] > _paramObj.getTroughMaxFcjx()) {
  1687 + aBcOfGroup[1].addMinuteToFcsj(-1);
1536 } 1688 }
1537 - }  
1538 - }  
1539 1689
1540 - console.log(oLbGroup_m); 1690 + //else if (_paramObj.isMPeakBc(oBcFcTime) &&
  1691 + // aBcIntervalOfGroup[0] < _paramObj.getMPeakMinFcjx()) {
  1692 + // aBcOfGroup[1].addMinuteToFcsj(1);
  1693 + //} else if (_paramObj.isMPeakBc(oBcFcTime) &&
  1694 + // aBcIntervalOfGroup[0] > _paramObj.getMPeakMaxFcjx()) {
  1695 + // aBcOfGroup[1].addMinuteToFcsj(-1);
  1696 + //} else if (_paramObj.isEPeakBc(oBcFcTime) &&
  1697 + // aBcIntervalOfGroup[0] < _paramObj.getEPeakMinFcjx()) {
  1698 + // aBcOfGroup[1].addMinuteToFcsj(1);
  1699 + //} else if (_paramObj.isEPeakBc(oBcFcTime) &&
  1700 + // aBcIntervalOfGroup[0] > _paramObj.getEPeakMaxFcjx()) {
  1701 + // aBcOfGroup[1].addMinuteToFcsj(-1);
  1702 + //}
  1703 +
  1704 +
  1705 + else {
  1706 + if (Math.abs(aBcIntervalOfGroup[0] - aBcIntervalOfGroup[1]) <= 1) {
  1707 + //continue;
  1708 + } else if (aBcIntervalOfGroup[0] > aBcIntervalOfGroup[1]) {
  1709 + aBcOfGroup[1].addMinuteToFcsj(-1);
  1710 + } else {
  1711 + aBcOfGroup[1].addMinuteToFcsj(1);
  1712 + }
  1713 + }
1541 1714
1542 - var iStartLpIndex;  
1543 - var iEndLpIndex;  
1544 - var iDCount;  
1545 - var iDiffTime; 1715 + //if (Math.abs(aBcIntervalOfGroup[0] - aBcIntervalOfGroup[1]) <= 1) {
  1716 + // //continue;
  1717 + //} else if (aBcIntervalOfGroup[0] > aBcIntervalOfGroup[1]) {
  1718 + // aBcOfGroup[1].addMinuteToFcsj(-1);
  1719 + //} else {
  1720 + // aBcOfGroup[1].addMinuteToFcsj(1);
  1721 + //}
1546 1722
1547 - var iC1;  
1548 - var iC2;  
1549 - var oKssj;  
1550 1723
1551 - for (sKey in oLbGroup_m) {  
1552 - iQindex = sKey.split('_')[0];  
1553 - iBindex = sKey.split('_')[1]; 1724 + }
1554 1725
1555 - for (i = 0; i < oLbGroup_m[sKey].length; i++) {  
1556 - aLbGroup = oLbGroup_m[sKey][i]; 1726 + this.fnAdjustBcInterval(isUp, oStartTime, fre - 1);
  1727 + }
1557 1728
1558 - iStartLpIndex = aLbGroup[0];  
1559 - iEndLpIndex = aLbGroup[1];  
1560 - iDCount = aLbGroup[2].length + 1; 1729 + },
1561 1730
1562 - iDiffTime = _internalLpArray[iEndLpIndex].getBc(iQindex, iBindex).getFcTimeObj().diff(  
1563 - _internalLpArray[iStartLpIndex].getBc(iQindex, iBindex).getFcTimeObj(), 'm'); 1731 + /**
  1732 + * 调整班次间隔(平均间隔)。
  1733 + * @param bIsUp 是否上行
  1734 + * @param oStartTime 开始时间对象
  1735 + */
  1736 + fnAdjustBcInterval2_avg: function(bIsUp, oStartTime) {
  1737 + var aBc = !oStartTime ? _fnGetBcList(bIsUp) : _fnGetBcList2(bIsUp, oStartTime); // 指定方向的班次列表
  1738 + aBc.sort(function(o1, o2) {
  1739 + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) {
  1740 + return -1;
  1741 + } else {
  1742 + return 1;
  1743 + }
  1744 + });
1564 1745
1565 - iC1 = Math.floor(iDiffTime / iDCount);  
1566 - iC2 = iDiffTime % iDCount;  
1567 - oKssj = _internalLpArray[iStartLpIndex].getBc(iQindex, iBindex).getFcTimeObj(); 1746 + var j;
  1747 + var iCount = aBc.length - 1;
  1748 + var iC1 = Math.floor(aBc[aBc.length - 1].getFcTimeObj().diff(aBc[0].getFcTimeObj(), "m") / iCount);
  1749 + var iC2 = aBc[aBc.length - 1].getFcTimeObj().diff(aBc[0].getFcTimeObj(), "m") % iCount;
  1750 + var iTempTime;
  1751 +
  1752 + for (j = 0; j < iCount - iC2; j++) {
  1753 + iTempTime = aBc[j + 1].getFcTimeObj().diff(aBc[j].getFcTimeObj(), "m");
  1754 + aBc[j + 1].addMinuteToFcsj(iC1 - iTempTime);
  1755 + }
  1756 + for (j = 0; j < iC2; j++) {
  1757 + iTempTime = aBc[iCount - iC2 + j + 1].getFcTimeObj().diff(aBc[iCount - iC2 + j].getFcTimeObj(), "m");
  1758 + aBc[iCount - iC2 + j + 1].addMinuteToFcsj(iC1 + 1 - iTempTime);
  1759 + }
1568 1760
1569 - for (j = 1; j <= iDCount - iC2; j++) {  
1570 - if (j - 1 < aLbGroup[2].length) {  
1571 - oKssj = _paramObj.addMinute(oKssj, iC1);  
1572 - _internalLpArray[aLbGroup[2][j - 1]].getBc(  
1573 - iQindex, iBindex).setFcTimeObj(oKssj);  
1574 - }  
1575 - } 1761 + },
  1762 +
  1763 + /**
  1764 + * 计算高峰平均停站时间。
  1765 + */
  1766 + fnCalcuAverPeakStopTime: function() {
  1767 + var i;
  1768 + var j;
  1769 + var aBc;
  1770 + var iBcCount = 0;
  1771 + var iSum = 0;
  1772 + for (i = 0; i < _internalLpArray.length; i++) {
  1773 + aBc = _internalLpArray[i].getBcArray();
1576 1774
1577 - for (j = 1; j < iC2; j++) {  
1578 - oKssj = _paramObj.addMinute(oKssj, iC1 + 1);  
1579 - _internalLpArray[aLbGroup[2][iDCount - iC2 + j - 1]].getBc(  
1580 - iQindex, iBindex).setFcTimeObj(oKssj); 1775 + for (j = 0; j < aBc.length; j++) {
  1776 + if (!_paramObj.isTroughBc(aBc[j].getArrTimeObj())) {
  1777 + iBcCount ++;
  1778 + iSum += aBc[j].getStopTime();
1581 } 1779 }
  1780 + }
  1781 + }
  1782 +
  1783 + return Math.floor(iSum / iBcCount);
  1784 + },
1582 1785
  1786 + /**
  1787 + * 计算低谷平均停站时间。
  1788 + */
  1789 + fnCalcuAverTroughStopTime: function() {
  1790 + var i;
  1791 + var j;
  1792 + var aBc;
  1793 + var iBcCount = 0;
  1794 + var iSum = 0;
  1795 + for (i = 0; i < _internalLpArray.length; i++) {
  1796 + aBc = _internalLpArray[i].getBcArray();
  1797 + for (j = 0; j < aBc.length; j++) {
  1798 + if (_paramObj.isTroughBc(aBc[j].getArrTimeObj())) {
  1799 + iBcCount ++;
  1800 + iSum += aBc[j].getStopTime();
  1801 + }
1583 } 1802 }
1584 } 1803 }
1585 1804
  1805 + return Math.floor(iSum / iBcCount);
1586 }, 1806 },
1587 1807
1588 //------------- 其他方法 -------------// 1808 //------------- 其他方法 -------------//
@@ -1592,6 +1812,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -1592,6 +1812,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
1592 fnToGanttBcArray: function() { 1812 fnToGanttBcArray: function() {
1593 var aAllBc = []; 1813 var aAllBc = [];
1594 var aLpBc = []; 1814 var aLpBc = [];
  1815 + var aEatBc = [];
1595 var oLp; 1816 var oLp;
1596 var i; 1817 var i;
1597 var j; 1818 var j;
@@ -1600,6 +1821,23 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -1600,6 +1821,23 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
1600 oLp = _internalLpArray[i]; 1821 oLp = _internalLpArray[i];
1601 aLpBc = []; 1822 aLpBc = [];
1602 aLpBc = aLpBc.concat(oLp.getOtherBcArray(), oLp.getBcArray()); 1823 aLpBc = aLpBc.concat(oLp.getOtherBcArray(), oLp.getBcArray());
  1824 +
  1825 + aEatBc = [];
  1826 + // 根据班次的吃饭时间添加吃饭班次
  1827 + for (j = 0; j < aLpBc.length; j++) {
  1828 + if (aLpBc[j].fnGetEatTime() > 0) {
  1829 + aEatBc.push(_factory.createBcObj(
  1830 + oLp,
  1831 + "cf",
  1832 + !aLpBc[j].isUp(), // 和上一个班次方向相反
  1833 + 1,
  1834 + _paramObj.addMinute(aLpBc[j].getArrTimeObj(), aLpBc[j].getStopTime()), // 使用上一个班次的到达时间作为开始时间
  1835 + _paramObj
  1836 + ));
  1837 + }
  1838 + }
  1839 + aLpBc = aLpBc.concat(aEatBc);
  1840 +
1603 // 按照发车时间排序 1841 // 按照发车时间排序
1604 aLpBc.sort(function(o1, o2) { 1842 aLpBc.sort(function(o1, o2) {
1605 if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) { 1843 if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) {
@@ -1626,5 +1864,4 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { @@ -1626,5 +1864,4 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
1626 } 1864 }
1627 1865
1628 }; 1866 };
1629 -  
1630 }; 1867 };
1631 \ No newline at end of file 1868 \ No newline at end of file
src/main/resources/static/pages/base/timesmodel/js/v2/main_v2.js
@@ -18,7 +18,8 @@ var Main_v2 = function() { @@ -18,7 +18,8 @@ var Main_v2 = function() {
18 var _fcsj = fcTimeObj; 18 var _fcsj = fcTimeObj;
19 var _bcsj = paramObj.calcuTravelTime(_fcsj, isUp); 19 var _bcsj = paramObj.calcuTravelTime(_fcsj, isUp);
20 var _arrsj = paramObj.addMinute(_fcsj, _bcsj); 20 var _arrsj = paramObj.addMinute(_fcsj, _bcsj);
21 - var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj); 21 + //var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj);
  22 + var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, undefined);
22 var _tccid = paramObj.getTTinfoId(); 23 var _tccid = paramObj.getTTinfoId();
23 var _ttinfoid = paramObj.getTTinfoId(); 24 var _ttinfoid = paramObj.getTTinfoId();
24 var _xl = paramObj.getXlId(); 25 var _xl = paramObj.getXlId();
@@ -161,6 +162,9 @@ var Main_v2 = function() { @@ -161,6 +162,9 @@ var Main_v2 = function() {
161 schedule.fnAdjustGfbc(false, true); // 修正上行晚高峰 162 schedule.fnAdjustGfbc(false, true); // 修正上行晚高峰
162 schedule.fnAdjustGfbc(false, false); // 修正下行晚高峰 163 schedule.fnAdjustGfbc(false, false); // 修正下行晚高峰
163 164
  165 + // 6、补吃饭班次
  166 + schedule.fnCalcuEatBc();
  167 +
164 // 4、按照车辆投入运营要求补充班次 168 // 4、按照车辆投入运营要求补充班次
165 schedule.fnCalcuLpBc_yy(); 169 schedule.fnCalcuLpBc_yy();
166 170
@@ -168,19 +172,26 @@ var Main_v2 = function() { @@ -168,19 +172,26 @@ var Main_v2 = function() {
168 schedule.fnCalcuLpBx_5_2(); 172 schedule.fnCalcuLpBx_5_2();
169 schedule.fnCalcuLpBx_other(); 173 schedule.fnCalcuLpBx_other();
170 174
171 - // 6、补吃饭班次  
172 - schedule.fnCalcuEatBc(); 175 + // 7、祛除上标线开头有删除标记的班次
  176 + schedule.fnRemoveDelFirstFlagBc();
173 177
174 - // 7、祛除有删除标记的班次  
175 - schedule.fnRemoveDelFlagBc(); 178 + // TODO:8、调整路牌班次间隔
  179 + schedule.fnAdjustLpBcInterval(1);
176 180
177 - // 8、调整纵向班次间隔  
178 - schedule.fnAdjust_vertical_bc_interval();  
179 - // TODO:横向调整 181 + // TODO:9、调整纵向班次间隔
  182 + schedule.fnAdjustBcInterval(true, false, 10);
  183 + schedule.fnAdjustBcInterval(false, false, 10);
180 184
181 - // 9、确定末班车 185 + // 10、确定末班车
182 schedule.fnCalcuLastBc(); 186 schedule.fnCalcuLastBc();
183 187
  188 + // 11、祛除上标线结尾有删除标记的班次
  189 + schedule.fnRemoveDelLastFlagBc();
  190 +
  191 + // TODO:12、平均化指定时间后的班次列表间隔
  192 + schedule.fnAdjustBcInterval2_avg(true, _paramObj.toTimeObj("19:50"));
  193 + schedule.fnAdjustBcInterval2_avg(false, _paramObj.toTimeObj("19:50"));
  194 +
184 // 10、补进出场例保班次 195 // 10、补进出场例保班次
185 schedule.fnCalcuOtherBc(); 196 schedule.fnCalcuOtherBc();
186 197
src/main/resources/static/pages/scheduleApp/module/basicInfo/busInfoManage/edit.html
@@ -234,7 +234,15 @@ @@ -234,7 +234,15 @@
234 placeholder="请输入标准油耗/关空调"/> 234 placeholder="请输入标准油耗/关空调"/>
235 </div> 235 </div>
236 </div> 236 </div>
  237 +
237 <div class="form-group"> 238 <div class="form-group">
  239 + <label class="col-md-2 control-label">是否报废:</label>
  240 + <div class="col-md-3">
  241 + <sa-Radiogroup model="ctrl.busInfoForSave.scrapState" dicgroup="truefalseType" name="scrapState"></sa-Radiogroup>
  242 + </div>
  243 + </div>
  244 +
  245 + <div class="form-group" ng-if="ctrl.busInfoForSave.scrapState == 1">
238 <label class="col-md-2 control-label">报废号:</label> 246 <label class="col-md-2 control-label">报废号:</label>
239 <div class="col-md-4"> 247 <div class="col-md-4">
240 <input type="text" class="form-control" ng-model="ctrl.busInfoForSave.scrapCode" 248 <input type="text" class="form-control" ng-model="ctrl.busInfoForSave.scrapCode"
@@ -242,7 +250,7 @@ @@ -242,7 +250,7 @@
242 </div> 250 </div>
243 </div> 251 </div>
244 252
245 - <div class="form-group"> 253 + <div class="form-group" ng-if="ctrl.busInfoForSave.scrapState == 1">
246 <label class="col-md-2 control-label">报废日期:</label> 254 <label class="col-md-2 control-label">报废日期:</label>
247 <div class="col-md-4"> 255 <div class="col-md-4">
248 <div class="input-group"> 256 <div class="input-group">
src/main/resources/static/pages/scheduleApp/module/basicInfo/busInfoManage/form.html
@@ -235,31 +235,31 @@ @@ -235,31 +235,31 @@
235 placeholder="请输入标准油耗/关空调"/> 235 placeholder="请输入标准油耗/关空调"/>
236 </div> 236 </div>
237 </div> 237 </div>
238 - <div class="form-group">  
239 - <label class="col-md-2 control-label">报废号:</label>  
240 - <div class="col-md-4">  
241 - <input type="text" class="form-control" ng-model="ctrl.busInfoForSave.scrapCode"  
242 - placeholder="请输入报废号"/>  
243 - </div>  
244 - </div>  
245 -  
246 - <div class="form-group">  
247 - <label class="col-md-2 control-label">报废日期:</label>  
248 - <div class="col-md-4">  
249 - <div class="input-group">  
250 - <input type="text" class="form-control"  
251 - name="scrapDate" placeholder="请选择报废日期..."  
252 - uib-datepicker-popup="yyyy年MM月dd日"  
253 - is-open="ctrl.scrapDateOpen"  
254 - ng-model="ctrl.busInfoForSave.scrapDate" readonly/>  
255 - <span class="input-group-btn">  
256 - <button type="button" class="btn btn-default" ng-click="ctrl.scrapDate_open()">  
257 - <i class="glyphicon glyphicon-calendar"></i>  
258 - </button>  
259 - </span>  
260 - </div>  
261 - </div>  
262 - </div> 238 + <!--<div class="form-group">-->
  239 + <!--<label class="col-md-2 control-label">报废号:</label>-->
  240 + <!--<div class="col-md-4">-->
  241 + <!--<input type="text" class="form-control" ng-model="ctrl.busInfoForSave.scrapCode"-->
  242 + <!--placeholder="请输入报废号"/>-->
  243 + <!--</div>-->
  244 + <!--</div>-->
  245 +
  246 + <!--<div class="form-group">-->
  247 + <!--<label class="col-md-2 control-label">报废日期:</label>-->
  248 + <!--<div class="col-md-4">-->
  249 + <!--<div class="input-group">-->
  250 + <!--<input type="text" class="form-control"-->
  251 + <!--name="scrapDate" placeholder="请选择报废日期..."-->
  252 + <!--uib-datepicker-popup="yyyy年MM月dd日"-->
  253 + <!--is-open="ctrl.scrapDateOpen"-->
  254 + <!--ng-model="ctrl.busInfoForSave.scrapDate" readonly/>-->
  255 + <!--<span class="input-group-btn">-->
  256 + <!--<button type="button" class="btn btn-default" ng-click="ctrl.scrapDate_open()">-->
  257 + <!--<i class="glyphicon glyphicon-calendar"></i>-->
  258 + <!--</button>-->
  259 + <!--</span>-->
  260 + <!--</div>-->
  261 + <!--</div>-->
  262 + <!--</div>-->
263 <div class="form-group"> 263 <div class="form-group">
264 <label class="col-md-2 control-label">厂牌型号1:</label> 264 <label class="col-md-2 control-label">厂牌型号1:</label>
265 <div class="col-md-4"> 265 <div class="col-md-4">
src/main/resources/static/pages/scheduleApp/module/basicInfo/busInfoManage/list.html
@@ -12,6 +12,7 @@ @@ -12,6 +12,7 @@
12 <th style="width: 150px;">所在公司</th> 12 <th style="width: 150px;">所在公司</th>
13 <th style="width: 160px;">所在分公司</th> 13 <th style="width: 160px;">所在分公司</th>
14 <th style="width: 60px">电车</th> 14 <th style="width: 60px">电车</th>
  15 + <th style="width: 80px;" >状态</th>
15 <th style="width: 100%">操作</th> 16 <th style="width: 100%">操作</th>
16 </tr> 17 </tr>
17 <tr role="row" class="filter"> 18 <tr role="row" class="filter">
@@ -62,6 +63,11 @@ @@ -62,6 +63,11 @@
62 63
63 </td> 64 </td>
64 <td> 65 <td>
  66 + <label class="checkbox-inline input">
  67 + <input type="checkbox" ng-model="ctrl.searchCondition()['scrapState_eq']" />报废
  68 + </label>
  69 + </td>
  70 + <td>
65 <button class="btn btn-sm green btn-outline filter-submit margin-bottom" 71 <button class="btn btn-sm green btn-outline filter-submit margin-bottom"
66 ng-click="ctrl.doPage()"> 72 ng-click="ctrl.doPage()">
67 <i class="fa fa-search"></i> 搜索</button> 73 <i class="fa fa-search"></i> 搜索</button>
@@ -110,6 +116,9 @@ @@ -110,6 +116,9 @@
110 <span ng-bind="info.sfdc | dict:'truefalseType':'未知' "></span> 116 <span ng-bind="info.sfdc | dict:'truefalseType':'未知' "></span>
111 </td> 117 </td>
112 <td> 118 <td>
  119 + <span ng-bind="info.scrapState | dict:'truefalseType':'未知' "></span>
  120 + </td>
  121 + <td>
113 <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> 122 <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>-->
114 <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> 123 <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>-->
115 <a ui-sref="busInfoManage_detail({id: info.id})" class="btn btn-info btn-sm"> 详细 </a> 124 <a ui-sref="busInfoManage_detail({id: info.id})" class="btn btn-info btn-sm"> 详细 </a>
src/main/resources/static/pages/trafficManage/js/timeTempletUpload.js
@@ -97,6 +97,7 @@ @@ -97,6 +97,7 @@
97 $.each(inputs, function(i, element) { 97 $.each(inputs, function(i, element) {
98 params[$(element).attr("name")] = $(element).val(); 98 params[$(element).attr("name")] = $(element).val();
99 }); 99 });
  100 + params["isCancel_ne"] = true;// 过滤作废时刻表
100 var i = layer.load(2); 101 var i = layer.load(2);
101 $get('/tic_ec', params, function(data) { 102 $get('/tic_ec', params, function(data) {
102 var content = data.data.content; 103 var content = data.data.content;