Commit c19196e390b0536fb62b2e0580be8f16fb90d31b

Authored by 徐烜
1 parent 70749641

时刻表v2.7.11

1、修改计算停站时间的方法
2、修改平衡路牌班次停站时间的方法
3、修改平衡车距的方法
4、添加v2.1时刻表的版本,供以后使用

Too many changes to show.

To preserve performance only 2 of 9 files are displayed.

src/main/resources/static/pages/base/timesmodel/js/v2/ParameterObj.js
@@ -913,7 +913,7 @@ var ParameterObj = function() { @@ -913,7 +913,7 @@ var ParameterObj = function() {
913 }, 913 },
914 914
915 /** 915 /**
916 - * 获取固定的停站时间(固定停站时间都是选的最大值,非平均停站) 916 + * 获取固定的停站时间(使用平均停站)
917 * @param oTimeObj 时间对象 917 * @param oTimeObj 时间对象
918 * @param bIsUp 是否上行 918 * @param bIsUp 是否上行
919 * @param iXXTime 行驶时间 919 * @param iXXTime 行驶时间
@@ -921,181 +921,185 @@ var ParameterObj = function() { @@ -921,181 +921,185 @@ var ParameterObj = function() {
921 */ 921 */
922 fnCalcuFixedStopNumber: function(oTimeObj, bIsUp, iXXTime) { 922 fnCalcuFixedStopNumber: function(oTimeObj, bIsUp, iXXTime) {
923 _validInternal(); // 验证 923 _validInternal(); // 验证
924 - var oParam = this;  
925 -  
926 - var iPeakStopTime; // 高峰停站时间  
927 - var iTroughStopTime; // 低谷停站时间  
928 - var iSecondaryStopTime; // 副站停站时间  
929 924
930 - var iXXTime_temp;  
931 -  
932 - // 双向停站  
933 - if (oParam.isTwoWayStop()) {  
934 - if (bIsUp) { // 上行  
935 - if (this.isMPeakBc(oTimeObj)) { // 早高峰  
936 - iXXTime_temp = iXXTime == undefined ? oParam.getUpMPeakTime() : iXXTime;  
937 - iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%  
938 - if (iPeakStopTime < 3) { // 不少于3分钟  
939 - iPeakStopTime = 3;  
940 - }  
941 - return iPeakStopTime;  
942 - } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰  
943 - iXXTime_temp = iXXTime == undefined ? oParam.getUpEPeakTime() : iXXTime;  
944 - iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%  
945 - if (iPeakStopTime < 3) { // 不少于3分钟  
946 - iPeakStopTime = 3;  
947 - }  
948 - return iPeakStopTime;  
949 - } else { // 低谷  
950 - if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前  
951 - iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;  
952 - iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%  
953 - if (iTroughStopTime < 10) { // 不少于10分钟  
954 - iTroughStopTime = 10;  
955 - }  
956 - return iTroughStopTime;  
957 - } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后  
958 - iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;  
959 - iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%  
960 - if (iTroughStopTime < 10) { // 不少于10分钟  
961 - iTroughStopTime = 10;  
962 - }  
963 - return iTroughStopTime;  
964 - } else { // 早高峰,晚高峰之间  
965 - iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;  
966 - iTroughStopTime = Math.floor(iXXTime_temp * 0.15); // 行驶时间15%  
967 - if (iTroughStopTime < 10) { // 不少于10分钟  
968 - iTroughStopTime = 10;  
969 - }  
970 - return iTroughStopTime;  
971 - }  
972 - }  
973 - } else { // 下行  
974 - if (this.isMPeakBc(oTimeObj)) { // 早高峰  
975 - iXXTime_temp = iXXTime == undefined ? oParam.getDownMPeakTime() : iXXTime;  
976 - iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%  
977 - if (iPeakStopTime < 3) { // 不少于3分钟  
978 - iPeakStopTime = 3;  
979 - }  
980 - return iPeakStopTime;  
981 - } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰  
982 - iXXTime_temp = iXXTime == undefined ? oParam.getDownEPeakTime() : iXXTime;  
983 - iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%  
984 - if (iPeakStopTime < 3) { // 不少于3分钟  
985 - iPeakStopTime = 3;  
986 - }  
987 - return iPeakStopTime;  
988 - } else { // 低谷  
989 - if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前  
990 - iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;  
991 - iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%  
992 - if (iTroughStopTime < 10) { // 不少于10分钟  
993 - iTroughStopTime = 10;  
994 - }  
995 - return iTroughStopTime;  
996 - } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后  
997 - iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;  
998 - iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%  
999 - if (iTroughStopTime < 10) { // 不少于10分钟  
1000 - iTroughStopTime = 10;  
1001 - }  
1002 - return iTroughStopTime;  
1003 - } else { // 早高峰,晚高峰之间  
1004 - iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;  
1005 - iTroughStopTime = Math.floor(iXXTime_temp * 0.15); // 行驶时间15%  
1006 - if (iTroughStopTime < 10) { // 不少于10分钟  
1007 - iTroughStopTime = 10;  
1008 - }  
1009 - return iTroughStopTime;  
1010 - }  
1011 - }  
1012 - }  
1013 - } else { // 主站停站  
1014 - if (bIsUp == oParam.isUpOneWayStop()) {  
1015 - if (bIsUp) { // 上行  
1016 - if (this.isMPeakBc(oTimeObj)) { // 早高峰  
1017 - iXXTime_temp = iXXTime == undefined ? oParam.getUpMPeakTime() : iXXTime;  
1018 - iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%  
1019 - if (iPeakStopTime < 3) { // 不少于3分钟  
1020 - iPeakStopTime = 3;  
1021 - }  
1022 - return iPeakStopTime;  
1023 - } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰  
1024 - iXXTime_temp = iXXTime == undefined ? oParam.getUpEPeakTime() : iXXTime;  
1025 - iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%  
1026 - if (iPeakStopTime < 3) { // 不少于3分钟  
1027 - iPeakStopTime = 3;  
1028 - }  
1029 - return iPeakStopTime;  
1030 - } else { // 低谷  
1031 - if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前  
1032 - iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;  
1033 - iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%  
1034 - if (iTroughStopTime < 10) { // 不少于10分钟  
1035 - iTroughStopTime = 10;  
1036 - }  
1037 - return iTroughStopTime;  
1038 - } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后  
1039 - iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;  
1040 - iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%  
1041 - if (iTroughStopTime < 10) { // 不少于10分钟  
1042 - iTroughStopTime = 10;  
1043 - }  
1044 - return iTroughStopTime;  
1045 - } else { // 早高峰,晚高峰之间  
1046 - iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;  
1047 - iTroughStopTime = Math.floor(iXXTime_temp * 0.15); // 行驶时间15%  
1048 - if (iTroughStopTime < 10) { // 不少于10分钟  
1049 - iTroughStopTime = 10;  
1050 - }  
1051 - return iTroughStopTime;  
1052 - }  
1053 - }  
1054 - } else { // 下行  
1055 - if (this.isMPeakBc(oTimeObj)) { // 早高峰  
1056 - iXXTime_temp = iXXTime == undefined ? oParam.getDownMPeakTime() : iXXTime;  
1057 - iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%  
1058 - if (iPeakStopTime < 3) { // 不少于3分钟  
1059 - iPeakStopTime = 3;  
1060 - }  
1061 - return iPeakStopTime;  
1062 - } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰  
1063 - iXXTime_temp = iXXTime == undefined ? oParam.getDownEPeakTime() : iXXTime;  
1064 - iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%  
1065 - if (iPeakStopTime < 3) { // 不少于3分钟  
1066 - iPeakStopTime = 3;  
1067 - }  
1068 - return iPeakStopTime;  
1069 - } else { // 低谷  
1070 - if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前  
1071 - iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;  
1072 - iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%  
1073 - if (iTroughStopTime < 10) { // 不少于10分钟  
1074 - iTroughStopTime = 10;  
1075 - }  
1076 - return iTroughStopTime;  
1077 - } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后  
1078 - iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;  
1079 - iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%  
1080 - if (iTroughStopTime < 10) { // 不少于10分钟  
1081 - iTroughStopTime = 10;  
1082 - }  
1083 - return iTroughStopTime;  
1084 - } else { // 早高峰,晚高峰之间  
1085 - iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;  
1086 - iTroughStopTime = Math.floor(iXXTime_temp * 0.15); // 行驶时间15%  
1087 - if (iTroughStopTime < 10) { // 不少于10分钟  
1088 - iTroughStopTime = 10;  
1089 - }  
1090 - return iTroughStopTime;  
1091 - }  
1092 - }  
1093 - }  
1094 - } else { // 副站停战,2到3分钟  
1095 - iSecondaryStopTime = 3;  
1096 - return iSecondaryStopTime; // 直接返回3分钟  
1097 - }  
1098 - } 925 + return this.calcuTripAvgLayoverTime(oTimeObj, bIsUp,
  926 + this.calcuTripLayoverTimeRange(oTimeObj, bIsUp, iXXTime));
  927 +
  928 + // var oParam = this;
  929 + //
  930 + // var iPeakStopTime; // 高峰停站时间
  931 + // var iTroughStopTime; // 低谷停站时间
  932 + // var iSecondaryStopTime; // 副站停站时间
  933 + //
  934 + // var iXXTime_temp;
  935 + //
  936 + // // 双向停站
  937 + // if (oParam.isTwoWayStop()) {
  938 + // if (bIsUp) { // 上行
  939 + // if (this.isMPeakBc(oTimeObj)) { // 早高峰
  940 + // iXXTime_temp = iXXTime == undefined ? oParam.getUpMPeakTime() : iXXTime;
  941 + // iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  942 + // if (iPeakStopTime < 3) { // 不少于3分钟
  943 + // iPeakStopTime = 3;
  944 + // }
  945 + // return iPeakStopTime;
  946 + // } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  947 + // iXXTime_temp = iXXTime == undefined ? oParam.getUpEPeakTime() : iXXTime;
  948 + // iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  949 + // if (iPeakStopTime < 3) { // 不少于3分钟
  950 + // iPeakStopTime = 3;
  951 + // }
  952 + // return iPeakStopTime;
  953 + // } else { // 低谷
  954 + // if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  955 + // iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;
  956 + // iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  957 + // if (iTroughStopTime < 10) { // 不少于10分钟
  958 + // iTroughStopTime = 10;
  959 + // }
  960 + // return iTroughStopTime;
  961 + // } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  962 + // iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;
  963 + // iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  964 + // if (iTroughStopTime < 10) { // 不少于10分钟
  965 + // iTroughStopTime = 10;
  966 + // }
  967 + // return iTroughStopTime;
  968 + // } else { // 早高峰,晚高峰之间
  969 + // iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;
  970 + // iTroughStopTime = Math.floor(iXXTime_temp * 0.15); // 行驶时间15%
  971 + // if (iTroughStopTime < 10) { // 不少于10分钟
  972 + // iTroughStopTime = 10;
  973 + // }
  974 + // return iTroughStopTime;
  975 + // }
  976 + // }
  977 + // } else { // 下行
  978 + // if (this.isMPeakBc(oTimeObj)) { // 早高峰
  979 + // iXXTime_temp = iXXTime == undefined ? oParam.getDownMPeakTime() : iXXTime;
  980 + // iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  981 + // if (iPeakStopTime < 3) { // 不少于3分钟
  982 + // iPeakStopTime = 3;
  983 + // }
  984 + // return iPeakStopTime;
  985 + // } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  986 + // iXXTime_temp = iXXTime == undefined ? oParam.getDownEPeakTime() : iXXTime;
  987 + // iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  988 + // if (iPeakStopTime < 3) { // 不少于3分钟
  989 + // iPeakStopTime = 3;
  990 + // }
  991 + // return iPeakStopTime;
  992 + // } else { // 低谷
  993 + // if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  994 + // iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;
  995 + // iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  996 + // if (iTroughStopTime < 10) { // 不少于10分钟
  997 + // iTroughStopTime = 10;
  998 + // }
  999 + // return iTroughStopTime;
  1000 + // } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  1001 + // iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;
  1002 + // iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  1003 + // if (iTroughStopTime < 10) { // 不少于10分钟
  1004 + // iTroughStopTime = 10;
  1005 + // }
  1006 + // return iTroughStopTime;
  1007 + // } else { // 早高峰,晚高峰之间
  1008 + // iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;
  1009 + // iTroughStopTime = Math.floor(iXXTime_temp * 0.15); // 行驶时间15%
  1010 + // if (iTroughStopTime < 10) { // 不少于10分钟
  1011 + // iTroughStopTime = 10;
  1012 + // }
  1013 + // return iTroughStopTime;
  1014 + // }
  1015 + // }
  1016 + // }
  1017 + // } else { // 主站停站
  1018 + // if (bIsUp == oParam.isUpOneWayStop()) {
  1019 + // if (bIsUp) { // 上行
  1020 + // if (this.isMPeakBc(oTimeObj)) { // 早高峰
  1021 + // iXXTime_temp = iXXTime == undefined ? oParam.getUpMPeakTime() : iXXTime;
  1022 + // iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  1023 + // if (iPeakStopTime < 3) { // 不少于3分钟
  1024 + // iPeakStopTime = 3;
  1025 + // }
  1026 + // return iPeakStopTime;
  1027 + // } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  1028 + // iXXTime_temp = iXXTime == undefined ? oParam.getUpEPeakTime() : iXXTime;
  1029 + // iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  1030 + // if (iPeakStopTime < 3) { // 不少于3分钟
  1031 + // iPeakStopTime = 3;
  1032 + // }
  1033 + // return iPeakStopTime;
  1034 + // } else { // 低谷
  1035 + // if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  1036 + // iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;
  1037 + // iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  1038 + // if (iTroughStopTime < 10) { // 不少于10分钟
  1039 + // iTroughStopTime = 10;
  1040 + // }
  1041 + // return iTroughStopTime;
  1042 + // } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  1043 + // iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;
  1044 + // iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  1045 + // if (iTroughStopTime < 10) { // 不少于10分钟
  1046 + // iTroughStopTime = 10;
  1047 + // }
  1048 + // return iTroughStopTime;
  1049 + // } else { // 早高峰,晚高峰之间
  1050 + // iXXTime_temp = iXXTime == undefined ? oParam.getUpTroughTime() : iXXTime;
  1051 + // iTroughStopTime = Math.floor(iXXTime_temp * 0.15); // 行驶时间15%
  1052 + // if (iTroughStopTime < 10) { // 不少于10分钟
  1053 + // iTroughStopTime = 10;
  1054 + // }
  1055 + // return iTroughStopTime;
  1056 + // }
  1057 + // }
  1058 + // } else { // 下行
  1059 + // if (this.isMPeakBc(oTimeObj)) { // 早高峰
  1060 + // iXXTime_temp = iXXTime == undefined ? oParam.getDownMPeakTime() : iXXTime;
  1061 + // iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  1062 + // if (iPeakStopTime < 3) { // 不少于3分钟
  1063 + // iPeakStopTime = 3;
  1064 + // }
  1065 + // return iPeakStopTime;
  1066 + // } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  1067 + // iXXTime_temp = iXXTime == undefined ? oParam.getDownEPeakTime() : iXXTime;
  1068 + // iPeakStopTime = Math.floor(iXXTime_temp * 0.1); // 行驶时间的10%
  1069 + // if (iPeakStopTime < 3) { // 不少于3分钟
  1070 + // iPeakStopTime = 3;
  1071 + // }
  1072 + // return iPeakStopTime;
  1073 + // } else { // 低谷
  1074 + // if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  1075 + // iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;
  1076 + // iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  1077 + // if (iTroughStopTime < 10) { // 不少于10分钟
  1078 + // iTroughStopTime = 10;
  1079 + // }
  1080 + // return iTroughStopTime;
  1081 + // } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  1082 + // iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;
  1083 + // iTroughStopTime = Math.floor(iXXTime_temp * 0.2); // 行驶时间20%
  1084 + // if (iTroughStopTime < 10) { // 不少于10分钟
  1085 + // iTroughStopTime = 10;
  1086 + // }
  1087 + // return iTroughStopTime;
  1088 + // } else { // 早高峰,晚高峰之间
  1089 + // iXXTime_temp = iXXTime == undefined ? oParam.getDownTroughTime() : iXXTime;
  1090 + // iTroughStopTime = Math.floor(iXXTime_temp * 0.15); // 行驶时间15%
  1091 + // if (iTroughStopTime < 10) { // 不少于10分钟
  1092 + // iTroughStopTime = 10;
  1093 + // }
  1094 + // return iTroughStopTime;
  1095 + // }
  1096 + // }
  1097 + // }
  1098 + // } else { // 副站停战,2到3分钟
  1099 + // iSecondaryStopTime = 3;
  1100 + // return iSecondaryStopTime; // 直接返回3分钟
  1101 + // }
  1102 + // }
1099 1103
1100 }, 1104 },
1101 1105
@@ -1247,21 +1251,56 @@ var ParameterObj = function() { @@ -1247,21 +1251,56 @@ var ParameterObj = function() {
1247 }, 1251 },
1248 1252
1249 /** 1253 /**
1250 - * 计算高峰周转时间 1254 + * 计算高峰周转时间(早高峰)
1251 * @returns 周转时间 1255 * @returns 周转时间
1252 */ 1256 */
1253 calcuPeakZzsj: function() { 1257 calcuPeakZzsj: function() {
1254 _validInternal(); // 验证 1258 _validInternal(); // 验证
1255 - var paramObj = this; 1259 + // var paramObj = this;
  1260 + //
  1261 + // // 使用早高峰的周转时间
  1262 + // var _time = paramObj.getMPeakStartTimeObj();
  1263 + // var _zzsj = // 早高峰上行行驶时间+停站时间+早高峰下行行驶时间+停站时间
  1264 + // this.calcuTravelTime(_time, true) +
  1265 + // this.fnCalcuFixedStopNumber(_time, true) +
  1266 + // this.calcuTravelTime(_time, false) +
  1267 + // this.fnCalcuFixedStopNumber(_time, false);
  1268 + // return _zzsj;
  1269 +
  1270 + // 改成使用平均停站时间
  1271 + var _oTime = this.getMPeakStartTimeObj();
  1272 + var _iUpRT = this.calcuTravelTime(_oTime, true);
  1273 + var _aUpLTRange = this.calcuTripLayoverTimeRange(
  1274 + _oTime, true, _iUpRT);
  1275 + var _iUpLT = this.calcuTripAvgLayoverTime(
  1276 + _oTime, true, _aUpLTRange);
  1277 + var _iDownRT = this.calcuTravelTime(_oTime, false);
  1278 + var _aDownLTRange = this.calcuTripLayoverTimeRange(
  1279 + _oTime, false, _iDownRT);
  1280 + var _iDownLT = this.calcuTripAvgLayoverTime(
  1281 + _oTime, true, _aDownLTRange);
  1282 + return _iUpRT + _iUpLT + _iDownRT + _iDownLT;
  1283 + },
1256 1284
1257 - // 使用早高峰的周转时间  
1258 - var _time = paramObj.getMPeakStartTimeObj();  
1259 - var _zzsj = // 早高峰上行行驶时间+停站时间+早高峰下行行驶时间+停站时间  
1260 - this.calcuTravelTime(_time, true) +  
1261 - this.fnCalcuFixedStopNumber(_time, true) +  
1262 - this.calcuTravelTime(_time, false) +  
1263 - this.fnCalcuFixedStopNumber(_time, false);  
1264 - return _zzsj; 1285 + /**
  1286 + * 计算晚高峰周转时间(早高峰)。
  1287 + * @returns 周转时间
  1288 + */
  1289 + calcuEPeakZzsj : function() {
  1290 +
  1291 + // 改成使用平均停站时间
  1292 + var _oTime = this.getEPeakStartTimeObj();
  1293 + var _iUpRT = this.calcuTravelTime(_oTime, true);
  1294 + var _aUpLTRange = this.calcuTripLayoverTimeRange(
  1295 + _oTime, true, _iUpRT);
  1296 + var _iUpLT = this.calcuTripAvgLayoverTime(
  1297 + _oTime, true, _aUpLTRange);
  1298 + var _iDownRT = this.calcuTravelTime(_oTime, false);
  1299 + var _aDownLTRange = this.calcuTripLayoverTimeRange(
  1300 + _oTime, false, _iDownRT);
  1301 + var _iDownLT = this.calcuTripAvgLayoverTime(
  1302 + _oTime, true, _aDownLTRange);
  1303 + return _iUpRT + _iUpLT + _iDownRT + _iDownLT;
1265 }, 1304 },
1266 1305
1267 /** 1306 /**
@@ -1270,31 +1309,121 @@ var ParameterObj = function() { @@ -1270,31 +1309,121 @@ var ParameterObj = function() {
1270 */ 1309 */
1271 calcuTroughZzsj: function() { 1310 calcuTroughZzsj: function() {
1272 _validInternal(); // 验证 1311 _validInternal(); // 验证
1273 - var paramObj = this;  
1274 -  
1275 - // 使用低谷的周转时间  
1276 - var _time = this.addMinute(paramObj.getMPeakStartTimeObj(), -1); // 使用任意一个低谷时间  
1277 - var _zzsj = // 低谷上行行驶时间+停站时间+低谷下行行驶时间+停站时间  
1278 - this.calcuTravelTime(_time, true) +  
1279 - this.fnCalcuFixedStopNumber(_time, true) +  
1280 - this.calcuTravelTime(_time, false) +  
1281 - this.fnCalcuFixedStopNumber(_time, false);  
1282 -  
1283 - return _zzsj; 1312 + // var paramObj = this;
  1313 + //
  1314 + // // 使用低谷的周转时间
  1315 + // var _time = this.addMinute(paramObj.getMPeakStartTimeObj(), -1); // 使用任意一个低谷时间
  1316 + // var _zzsj = // 低谷上行行驶时间+停站时间+低谷下行行驶时间+停站时间
  1317 + // this.calcuTravelTime(_time, true) +
  1318 + // this.fnCalcuFixedStopNumber(_time, true) +
  1319 + // this.calcuTravelTime(_time, false) +
  1320 + // this.fnCalcuFixedStopNumber(_time, false);
  1321 + //
  1322 + // return _zzsj;
  1323 +
  1324 + // 改成使用平均停站时间
  1325 + var _oTime = this.addMinute(this.getMPeakStartTimeObj(), -1);
  1326 + var _iUpRT = this.calcuTravelTime(_oTime, true);
  1327 + var _aUpLTRange = this.calcuTripLayoverTimeRange(
  1328 + _oTime, true, _iUpRT);
  1329 + var _iUpLT = this.calcuTripAvgLayoverTime(
  1330 + _oTime, true, _aUpLTRange);
  1331 + var _iDownRT = this.calcuTravelTime(_oTime, false);
  1332 + var _aDownLTRange = this.calcuTripLayoverTimeRange(
  1333 + _oTime, false, _iDownRT);
  1334 + var _iDownLT = this.calcuTripAvgLayoverTime(
  1335 + _oTime, true, _aDownLTRange);
  1336 + return _iUpRT + _iUpLT + _iDownRT + _iDownLT;
1284 }, 1337 },
1285 1338
1286 /** 1339 /**
1287 * 计算车辆总数。 1340 * 计算车辆总数。
1288 - * @returns 车辆数 1341 + * @returns {int} 车辆数
1289 */ 1342 */
1290 calcuClzx: function() { 1343 calcuClzx: function() {
1291 _validInternal(); // 验证 1344 _validInternal(); // 验证
1292 - var paramObj = this; 1345 + // var paramObj = this;
  1346 + //
  1347 + // // 使用早高峰平均间隔
  1348 + // var _fcjx_avg = Math.floor((paramObj.getMPeakMinFcjx() + paramObj.getMPeakMaxFcjx()) / 2);
  1349 + // return Math.round(this.calcuPeakZzsj() / _fcjx_avg);
  1350 +
  1351 + // 计算早高峰车辆数(使用平均间隔)
  1352 + var _iAMPeakFcjx_avg = (this.getMPeakMinFcjx() + this.getMPeakMaxFcjx()) / 2;
  1353 + var _iAMPeakRCTime = this.calcuPeakZzsj();
  1354 + var _iAMPeakVehicleCount = _iAMPeakRCTime / _iAMPeakFcjx_avg;
  1355 +
  1356 + // 计算晚高峰车辆数 (使用平均间隔)
  1357 + var _iPMPeakFcjx_avg = (this.getEPeakMinFcjx() + this.getEPeakMaxFcjx()) / 2;
  1358 + var _iPMPeakRCTime = this.calcuEPeakZzsj();
  1359 + var _iPMPeakVehicleCount = _iPMPeakRCTime / _iPMPeakFcjx_avg;
  1360 +
  1361 + // 取最大值为最终车辆数
  1362 + // 大于或等于的最小整数,人话就是有小数点就加1
  1363 + if (_iAMPeakVehicleCount > _iPMPeakVehicleCount) {
  1364 + return Math.ceil(_iAMPeakVehicleCount);
  1365 + } else {
  1366 + return Math.ceil(_iPMPeakVehicleCount);
  1367 + }
  1368 + },
  1369 +
  1370 + /**
  1371 + * 计算平均Layover时间。
  1372 + * @param arriveTimeObj {moment} 到达时间对象
  1373 + * @param isUp {boolean} 是否上行
  1374 + * @param aRangeTime {array} Layover时间范围
  1375 + * @returns {int} 平均Layover时间
  1376 + */
  1377 + calcuTripAvgLayoverTime : function (arriveTimeObj, isUp, aRangeTime) {
  1378 + return Math.floor((aRangeTime[0] + aRangeTime[1]) / 2);
  1379 + },
1293 1380
1294 - // 使用早高峰平均间隔  
1295 - var _fcjx_avg = Math.floor((paramObj.getMPeakMinFcjx() + paramObj.getMPeakMaxFcjx()) / 2);  
1296 - return Math.round(this.calcuPeakZzsj() / _fcjx_avg); 1381 + /**
  1382 + * 计算班次Layover时间范围。
  1383 + * @param arriveTimeObj {moment} 到达时间对象
  1384 + * @param isUp {boolean} 是否上行
  1385 + * @param runningTime {int} 班次行驶时间
  1386 + * @returns int[] 两个元素,一个最小停站时间-分钟,一个最大停站时间-分钟
  1387 + */
  1388 + calcuTripLayoverTimeRange: function(arriveTimeObj, isUp, runningTime) {
  1389 + var _aLayoverTime = [];
  1390 +
  1391 + var _iMinLayoverTime = 0;
  1392 + var _iMaxlayoverTime = 0;
  1393 +
  1394 + if (this.isTwoWayStop() || isUp == this.isUpOneWayStop()) {
  1395 + // 主站停站
  1396 + // 早晚高峰,行驶时间的10%-15%,最少3分钟
  1397 + // 低谷,行驶时间的15%-20%,最少10分钟
  1398 +
  1399 + if (this.isMPeakBc(arriveTimeObj) || this.isEPeakBc(arriveTimeObj)) {
  1400 + _iMinLayoverTime = Math.floor(runningTime * 0.10);
  1401 + _iMaxlayoverTime = Math.floor(runningTime * 0.15);
  1402 + if (_iMaxlayoverTime < 3) {
  1403 + _iMinLayoverTime = 3;
  1404 + _iMaxlayoverTime = 3;
  1405 + }
  1406 + } else {
  1407 + _iMinLayoverTime = Math.floor(runningTime * 0.15);
  1408 + _iMaxlayoverTime = Math.floor(runningTime * 0.20);
  1409 + if (_iMaxlayoverTime < 10) {
  1410 + _iMinLayoverTime = 10;
  1411 + _iMaxlayoverTime = 10;
  1412 + }
  1413 + }
  1414 + } else {
  1415 + // 副站停站
  1416 + // 所有时间段,1-3分钟
  1417 + _iMinLayoverTime = 1;
  1418 + _iMaxlayoverTime = 3;
  1419 + }
  1420 +
  1421 + _aLayoverTime.push(_iMinLayoverTime);
  1422 + _aLayoverTime.push(_iMaxlayoverTime);
  1423 + return _aLayoverTime;
1297 } 1424 }
1298 1425
  1426 +
  1427 +
1299 }; 1428 };
1300 }; 1429 };
1301 \ No newline at end of file 1430 \ No newline at end of file
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 - for (i = 0; i < this._$_qCount; i++) {  
490 - group = groupArray[i];  
491 - if (group) {  
492 - if (group.getBc1() && hasUp) {  
493 - bc1time = group.getBc1().getFcTimeObj();  
494 - console.log("bc1time=" + bc1time.format("HH:mm") + " tempdiff=" + tempdiff);  
495 - tempdiff = Math.abs(bc1time.diff(fctime));  
496 -  
497 - if (!timediff) {  
498 - timediff = Math.abs(tempdiff);  
499 - qIndex = i;  
500 - bcIndex = 0;  
501 - } else {  
502 - if (tempdiff < timediff) {  
503 - timediff = tempdiff;  
504 - qIndex = i;  
505 - bcIndex = 0;  
506 - } if (Math.abs(tempdiff) == timediff) {  
507 - if (bc1time.isAfter(fctime)) {  
508 - timediff = tempdiff;  
509 - qIndex = i;  
510 - bcIndex = 0;  
511 - }  
512 -  
513 - }  
514 - }  
515 - }  
516 -  
517 - if (group.getBc2() && hasDown) {  
518 - bc2time = group.getBc2().getFcTimeObj();  
519 - console.log("bc2time=" + bc2time.format("HH:mm") + " tempdiff=" + tempdiff);  
520 - tempdiff = Math.abs(bc2time.diff(fctime));  
521 -  
522 - if (!timediff) {  
523 - timediff = Math.abs(tempdiff);  
524 - qIndex = i;  
525 - bcIndex = 1;  
526 - } else {  
527 - if (tempdiff < timediff) {  
528 - timediff = tempdiff;  
529 - qIndex = i;  
530 - bcIndex = 1;  
531 - } if (Math.abs(tempdiff) == timediff) {  
532 - if (bc2time.isBefore(fctime)) {  
533 - timediff = tempdiff;  
534 - qIndex = i;  
535 - bcIndex = 1;  
536 - }  
537 -  
538 - }  
539 - }  
540 - }  
541 - }  
542 - }  
543 -  
544 - console.log("中标线对应数组索引=" + qIndex);  
545 -  
546 - var rst = [];  
547 - rst.push(qIndex);  
548 - rst.push(bcIndex);  
549 -  
550 - return rst;  
551 -};  
552 -  
553 -/**  
554 - * 使用指定时间匹配返回离之最近的第几圈第几个班次,  
555 - * 使用时间差的绝度值,比较,取最小的  
556 - * 如果有两个一样的时间差,取比fctime大的时间  
557 - * @param fctime moment 比较用时间  
558 - * @param hasUp boolean 计算上行班次  
559 - * @param hasDown boolean 计算下行班次  
560 - * @returns [{第几圈},{第几个班次}]  
561 - */  
562 -InternalLpObj.prototype.getQBcIndexWithFcTime = function(  
563 - fctime, hasUp, hasDown  
564 -) {  
565 - return this.fnGetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray, hasUp, hasDown);  
566 -};  
567 -  
568 -//---------------------- 内部数据初始化方法(不同于构造函数)---------------------//  
569 -  
570 -/**  
571 - * 从指定开始时间到结束时间创建不间断班次(连班),并初始化路牌  
572 - * 注意,之前有班次会删除后再创建。  
573 - * @param startTime 开始时间  
574 - * @param endTime 结束时间  
575 - * @param isUp 第一个班次是上行还是下行  
576 - * @param fromQ 从第几圈开始加入  
577 - * @param paramObj 参数对象  
578 - * @param factory 工厂对象  
579 - */  
580 -InternalLpObj.prototype.initDataFromTimeToTime = function(  
581 - startTime,  
582 - endTime,  
583 - isUp,  
584 - fromQ,  
585 - paramObj,  
586 - factory) {  
587 -  
588 - var bcData = []; // 班次数组  
589 - var bcObj;  
590 - var kssj = startTime;  
591 - var fcno = 1; // 发车顺序号  
592 - var bcCount = 1; // 班次数  
593 - do {  
594 - bcObj = factory.createBcObj(  
595 - this, "normal", isUp, fcno, kssj, paramObj); // this就是所属路牌对象  
596 - bcData.push(bcObj);  
597 -  
598 - kssj = paramObj.addMinute(kssj, bcObj.getBcTime() + bcObj.getStopTime());  
599 - fcno ++;  
600 - bcCount ++;  
601 - isUp = !isUp;  
602 - } while(kssj.isBefore(endTime));  
603 - bcCount--;  
604 -  
605 - //console.log("last -1;" + bcData[bcCount -2].getFcTimeObj().format("HH:mm"));  
606 - //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm"));  
607 - //console.log("endtime: " + endTime.format("HH:mm"));  
608 -  
609 - //if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) {  
610 - // // 如果最后一个班次的到达时间超过结束时间,也要去除  
611 - // bcData.splice(bcCount - 1, 1);  
612 - //}  
613 -  
614 - this._initDataFromLbBcArray(bcData, fromQ);  
615 -  
616 -};  
617 -  
618 -/**  
619 - * 使用连班的班次数组初始化路牌(相应的圈会被覆盖)。  
620 - * @param bcArray 连班班次数组  
621 - * @param fromQ 从第几圈开始加入  
622 - */  
623 -InternalLpObj.prototype._initDataFromLbBcArray = function(  
624 - bcArray,  
625 - fromQ  
626 -) {  
627 - var _bc1Obj;  
628 - var _bc2Obj;  
629 - var _qObj;  
630 -  
631 - // 第一班次是上行还是下行  
632 - var isUp = bcArray[0].isUp();  
633 -  
634 - if (bcArray.length > 0 && fromQ < this._$_qCount) {  
635 - // 构造圈数  
636 - if (isUp != this._$_isUp) {  
637 - // 如果方向不一致,意味着第一个班次是半圈  
638 - // 加半圈,并加在bc2上  
639 - _bc2Obj = bcArray.slice(0, 1)[0];  
640 - _qObj = new InternalGroupObj(  
641 - this,  
642 - this._$_isUp,  
643 - undefined,  
644 - _bc2Obj  
645 - );  
646 - _bc2Obj.setGroup(_qObj);  
647 - this._$_groupBcArray[fromQ] = _qObj;  
648 -  
649 - bcArray.splice(0, 1);  
650 - fromQ ++;  
651 - }  
652 -  
653 - var qCount1 = Math.floor(bcArray.length / 2); // 需要添加多少圈  
654 - var qCount2 = bcArray.length % 2; // 最后是否有半圈  
655 -  
656 - while (fromQ < this._$_qCount) {  
657 - if (qCount1 > 0) {  
658 - _bc1Obj = bcArray.slice(0, 1)[0];  
659 - _bc2Obj = bcArray.slice(1, 2)[0];  
660 - _qObj = new InternalGroupObj(  
661 - this,  
662 - this._$_isUp,  
663 - _bc1Obj,  
664 - _bc2Obj  
665 - );  
666 - _bc1Obj.setGroup(_qObj);  
667 - _bc2Obj.setGroup(_qObj);  
668 - this._$_groupBcArray[fromQ] = _qObj;  
669 -  
670 - bcArray.splice(0, 2);  
671 - qCount1 --;  
672 - } else if (qCount2 > 0) {  
673 - // 加半圈,并加在bc1上  
674 - _bc1Obj = bcArray.slice(0, 1)[0];  
675 - _qObj = new InternalGroupObj(  
676 - this,  
677 - this._$_isUp,  
678 - _bc1Obj,  
679 - undefined  
680 - );  
681 - _bc1Obj.setGroup(_qObj);  
682 - this._$_groupBcArray[fromQ] = _qObj;  
683 -  
684 - bcArray.splice(0, 1);  
685 - qCount2 --;  
686 - } else {  
687 - break;  
688 - }  
689 -  
690 - fromQ ++;  
691 - }  
692 - }  
693 -};  
694 -  
695 -//-------------------------- 其他方法 ----------------------------//  
696 -  
697 -/**  
698 - * 从指定位置的班次开始,往后所有的班次修正发车时间  
699 - * @param groupIndex  
700 - * @param bcIndex  
701 - * @param time  
702 - */  
703 -InternalLpObj.prototype.fnAddMinuteToBcFcsj = function(groupIndex, bcIndex, time) {  
704 - var i;  
705 - var oCurBc;  
706 -  
707 - // 修正之前班次的停站时间  
708 - //oCurBc = this.getBc(  
709 - // bcIndex == 0 ? groupIndex - 1 : groupIndex,  
710 - // bcIndex == 1 ? 0 : 1  
711 - //);  
712 - //if (oCurBc) {  
713 - // oCurBc.setStopTime(oCurBc.getStopTime() + time);  
714 - //}  
715 -  
716 -  
717 - for (i = groupIndex; i < this._$_qCount; i++) {  
718 - if (bcIndex == 0) {  
719 - oCurBc = this.getBc(i, 0);  
720 - if (oCurBc) {  
721 - oCurBc.addMinuteToFcsj(time);  
722 - }  
723 - oCurBc = this.getBc(i, 1);  
724 - if (oCurBc) {  
725 - oCurBc.addMinuteToFcsj(time);  
726 - }  
727 -  
728 - } else {  
729 - oCurBc = this.getBc(i, 1);  
730 - if (oCurBc) {  
731 - oCurBc.addMinuteToFcsj(time);  
732 - }  
733 -  
734 - }  
735 -  
736 - bcIndex = 0;  
737 - }  
738 -};  
739 -  
740 -/**  
741 - * 在指定位置添加一个吃饭班次。  
742 - * 注1:吃饭班次不是普通班次,不记录进圈,记录进_$_other_bc_array  
743 - * 注2:添加吃饭班次时,会修改之前班次的停战时间,所以导致之后的班次的停战都会发生变化  
744 - * @param groupIndex  
745 - * @param bcIndex  
746 - * @param factory  
747 - * @param paramObj  
748 - * @returns int 相差时间(吃饭时间距离和停站时间相差值)  
749 - */  
750 -InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, paramObj) {  
751 - var oPreBc;  
752 - var oEatBc;  
753 - var iBcModifyTime;  
754 - oPreBc = this.getBc( // 前一个邻接班次  
755 - bcIndex == 0 ? groupIndex - 1 : groupIndex,  
756 - bcIndex == 1 ? 0 : 1);  
757 - if (oPreBc) { // 存在前一个班次  
758 - oEatBc = factory.createBcObj(  
759 - this,  
760 - "cf",  
761 - !oPreBc.isUp(), // 和上一个班次方向相反  
762 - 1,  
763 - paramObj.addMinute(oPreBc.getArrTimeObj(), oPreBc.getStopTime()), // 使用上一个班次的到达时间作为开始时间  
764 - paramObj  
765 - );  
766 -  
767 - //iBcModifyTime = oEatBc.getBcTime() - oPreBc.getStopTime(); // 后续班次要调整的时间  
768 -  
769 - // 修正之后的班次发车时间  
770 - // 注意:之后那个班次发车时间就是吃饭班次的到达时间  
771 - iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m");  
772 - this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime);  
773 -  
774 - oPreBc.setStopTime(0); // 不重置停站时间  
775 - oPreBc.fnSetEatTime(oEatBc.getBcTime());  
776 -  
777 - //this._$_other_bc_array.push(oEatBc);  
778 -  
779 - return iBcModifyTime;  
780 - } else {  
781 - return false;  
782 - }  
783 -  
784 -};  
785 -  
786 -/**  
787 - * 调整路牌的班次,通过调整停站时间,或者班次发车时间,不能让班次的到达时间和下一个班次的发车时间重叠。  
788 - * @param iPeakAverStopTime 高峰平均停站时间  
789 - * @param iTroughAverStopTime 低谷平均停站时间  
790 - * @param oParam 参数对象  
791 - */  
792 -InternalLpObj.prototype.fnAdjustBcInterval = function(iPeakAverStopTime, iTroughAverStopTime, oParam) {  
793 - // 获取车次链个数  
794 - var iBcChainCount = this.fnGetBcChainCount();  
795 -  
796 - var i;  
797 - var j;  
798 - var oBcIndex;  
799 - var iQIndex;  
800 - var iBcIndex;  
801 - var iBcCount;  
802 - var oBc;  
803 - var oNextBc;  
804 -  
805 - var iBcStopTime;  
806 -  
807 - for (i = 0; i < iBcChainCount; i++) {  
808 - oBcIndex = this.fnGetBcChainInfo(i);  
809 - iQIndex = oBcIndex["s_q"];  
810 - iBcIndex = oBcIndex["s_b"];  
811 - iBcCount = oBcIndex["bcount"];  
812 -  
813 - for (j = 0; j < iBcCount - 1; j++) {  
814 - oBc = this.getBc(iQIndex, iBcIndex);  
815 - oNextBc = this.getBc(  
816 - iBcIndex == 0 ? iQIndex : iQIndex + 1,  
817 - iBcIndex == 0 ? 1 : 0);  
818 -  
819 - if (oNextBc.fnIsFirstBc()) { // 如果同一路牌连续2个方向首站班次,都不做处理  
820 - continue;  
821 - }  
822 -  
823 - // 不改变当前班次的行驶时间,修正停站时间和下一个班次的发车时间  
824 - iBcStopTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m");  
825 - if (iBcStopTime < 0) {  
826 - // 当前班次使用最小停站时间  
827 - oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp()));  
828 - oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime);  
829 -  
830 - } else {  
831 - if (iBcStopTime == oBc.getStopTime() + oBc.fnGetEatTime()) {  
832 - // 停站时间一致,没有问题  
833 -  
834 -  
835 - } else {  
836 - // TODO:当前班次使用最小停站时间  
837 - oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp()));  
838 - oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime);  
839 -  
840 - }  
841 - }  
842 -  
843 - iBcIndex = iBcIndex == 0 ? 1 : 0;  
844 - iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex;  
845 - }  
846 -  
847 - this.getBc(iQIndex, iBcIndex).setStopTime(0);  
848 - }  
849 -  
850 -  
851 -};  
852 -  
853 -  
854 -// TODO  
855 -  
856 -/**  
857 - *  
858 - *  
859 - */  
860 -InternalLpObj.prototype.calcuLpBx = function() {  
861 -  
862 -};  
863 -  
864 - 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 + for (i = 0; i < this._$_qCount; i++) {
  490 + group = groupArray[i];
  491 + if (group) {
  492 + if (group.getBc1() && hasUp) {
  493 + bc1time = group.getBc1().getFcTimeObj();
  494 + console.log("bc1time=" + bc1time.format("HH:mm") + " tempdiff=" + tempdiff);
  495 + tempdiff = Math.abs(bc1time.diff(fctime));
  496 +
  497 + if (!timediff) {
  498 + timediff = Math.abs(tempdiff);
  499 + qIndex = i;
  500 + bcIndex = 0;
  501 + } else {
  502 + if (tempdiff < timediff) {
  503 + timediff = tempdiff;
  504 + qIndex = i;
  505 + bcIndex = 0;
  506 + } if (Math.abs(tempdiff) == timediff) {
  507 + if (bc1time.isAfter(fctime)) {
  508 + timediff = tempdiff;
  509 + qIndex = i;
  510 + bcIndex = 0;
  511 + }
  512 +
  513 + }
  514 + }
  515 + }
  516 +
  517 + if (group.getBc2() && hasDown) {
  518 + bc2time = group.getBc2().getFcTimeObj();
  519 + console.log("bc2time=" + bc2time.format("HH:mm") + " tempdiff=" + tempdiff);
  520 + tempdiff = Math.abs(bc2time.diff(fctime));
  521 +
  522 + if (!timediff) {
  523 + timediff = Math.abs(tempdiff);
  524 + qIndex = i;
  525 + bcIndex = 1;
  526 + } else {
  527 + if (tempdiff < timediff) {
  528 + timediff = tempdiff;
  529 + qIndex = i;
  530 + bcIndex = 1;
  531 + } if (Math.abs(tempdiff) == timediff) {
  532 + if (bc2time.isBefore(fctime)) {
  533 + timediff = tempdiff;
  534 + qIndex = i;
  535 + bcIndex = 1;
  536 + }
  537 +
  538 + }
  539 + }
  540 + }
  541 + }
  542 + }
  543 +
  544 + console.log("中标线对应数组索引=" + qIndex);
  545 +
  546 + var rst = [];
  547 + rst.push(qIndex);
  548 + rst.push(bcIndex);
  549 +
  550 + return rst;
  551 +};
  552 +
  553 +/**
  554 + * 使用指定时间匹配返回离之最近的第几圈第几个班次,
  555 + * 使用时间差的绝度值,比较,取最小的
  556 + * 如果有两个一样的时间差,取比fctime大的时间
  557 + * @param fctime moment 比较用时间
  558 + * @param hasUp boolean 计算上行班次
  559 + * @param hasDown boolean 计算下行班次
  560 + * @returns [{第几圈},{第几个班次}]
  561 + */
  562 +InternalLpObj.prototype.getQBcIndexWithFcTime = function(
  563 + fctime, hasUp, hasDown
  564 +) {
  565 + return this.fnGetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray, hasUp, hasDown);
  566 +};
  567 +
  568 +//---------------------- 内部数据初始化方法(不同于构造函数)---------------------//
  569 +
  570 +/**
  571 + * 从指定开始时间到结束时间创建不间断班次(连班),并初始化路牌
  572 + * 注意,之前有班次会删除后再创建。
  573 + * @param startTime 开始时间
  574 + * @param endTime 结束时间
  575 + * @param isUp 第一个班次是上行还是下行
  576 + * @param fromQ 从第几圈开始加入
  577 + * @param paramObj 参数对象
  578 + * @param factory 工厂对象
  579 + */
  580 +InternalLpObj.prototype.initDataFromTimeToTime = function(
  581 + startTime,
  582 + endTime,
  583 + isUp,
  584 + fromQ,
  585 + paramObj,
  586 + factory) {
  587 +
  588 + var bcData = []; // 班次数组
  589 + var bcObj;
  590 + var kssj = startTime;
  591 + var fcno = 1; // 发车顺序号
  592 + var bcCount = 1; // 班次数
  593 + do {
  594 + bcObj = factory.createBcObj(
  595 + this, "normal", isUp, fcno, kssj, paramObj); // this就是所属路牌对象
  596 + bcData.push(bcObj);
  597 +
  598 + kssj = paramObj.addMinute(kssj, bcObj.getBcTime() + bcObj.getStopTime());
  599 + fcno ++;
  600 + bcCount ++;
  601 + isUp = !isUp;
  602 + } while(kssj.isBefore(endTime));
  603 + bcCount--;
  604 +
  605 + //console.log("last -1;" + bcData[bcCount -2].getFcTimeObj().format("HH:mm"));
  606 + //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm"));
  607 + //console.log("endtime: " + endTime.format("HH:mm"));
  608 +
  609 + //if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) {
  610 + // // 如果最后一个班次的到达时间超过结束时间,也要去除
  611 + // bcData.splice(bcCount - 1, 1);
  612 + //}
  613 +
  614 + this._initDataFromLbBcArray(bcData, fromQ);
  615 +
  616 +};
  617 +
  618 +/**
  619 + * 使用连班的班次数组初始化路牌(相应的圈会被覆盖)。
  620 + * @param bcArray 连班班次数组
  621 + * @param fromQ 从第几圈开始加入
  622 + */
  623 +InternalLpObj.prototype._initDataFromLbBcArray = function(
  624 + bcArray,
  625 + fromQ
  626 +) {
  627 + var _bc1Obj;
  628 + var _bc2Obj;
  629 + var _qObj;
  630 +
  631 + // 第一班次是上行还是下行
  632 + var isUp = bcArray[0].isUp();
  633 +
  634 + if (bcArray.length > 0 && fromQ < this._$_qCount) {
  635 + // 构造圈数
  636 + if (isUp != this._$_isUp) {
  637 + // 如果方向不一致,意味着第一个班次是半圈
  638 + // 加半圈,并加在bc2上
  639 + _bc2Obj = bcArray.slice(0, 1)[0];
  640 + _qObj = new InternalGroupObj(
  641 + this,
  642 + this._$_isUp,
  643 + undefined,
  644 + _bc2Obj
  645 + );
  646 + _bc2Obj.setGroup(_qObj);
  647 + this._$_groupBcArray[fromQ] = _qObj;
  648 +
  649 + bcArray.splice(0, 1);
  650 + fromQ ++;
  651 + }
  652 +
  653 + var qCount1 = Math.floor(bcArray.length / 2); // 需要添加多少圈
  654 + var qCount2 = bcArray.length % 2; // 最后是否有半圈
  655 +
  656 + while (fromQ < this._$_qCount) {
  657 + if (qCount1 > 0) {
  658 + _bc1Obj = bcArray.slice(0, 1)[0];
  659 + _bc2Obj = bcArray.slice(1, 2)[0];
  660 + _qObj = new InternalGroupObj(
  661 + this,
  662 + this._$_isUp,
  663 + _bc1Obj,
  664 + _bc2Obj
  665 + );
  666 + _bc1Obj.setGroup(_qObj);
  667 + _bc2Obj.setGroup(_qObj);
  668 + this._$_groupBcArray[fromQ] = _qObj;
  669 +
  670 + bcArray.splice(0, 2);
  671 + qCount1 --;
  672 + } else if (qCount2 > 0) {
  673 + // 加半圈,并加在bc1上
  674 + _bc1Obj = bcArray.slice(0, 1)[0];
  675 + _qObj = new InternalGroupObj(
  676 + this,
  677 + this._$_isUp,
  678 + _bc1Obj,
  679 + undefined
  680 + );
  681 + _bc1Obj.setGroup(_qObj);
  682 + this._$_groupBcArray[fromQ] = _qObj;
  683 +
  684 + bcArray.splice(0, 1);
  685 + qCount2 --;
  686 + } else {
  687 + break;
  688 + }
  689 +
  690 + fromQ ++;
  691 + }
  692 + }
  693 +};
  694 +
  695 +//-------------------------- 其他方法 ----------------------------//
  696 +
  697 +/**
  698 + * 从指定位置的班次开始,往后所有的班次修正发车时间
  699 + * @param groupIndex
  700 + * @param bcIndex
  701 + * @param time
  702 + */
  703 +InternalLpObj.prototype.fnAddMinuteToBcFcsj = function(groupIndex, bcIndex, time) {
  704 + var i;
  705 + var oCurBc;
  706 +
  707 + // 修正之前班次的停站时间
  708 + //oCurBc = this.getBc(
  709 + // bcIndex == 0 ? groupIndex - 1 : groupIndex,
  710 + // bcIndex == 1 ? 0 : 1
  711 + //);
  712 + //if (oCurBc) {
  713 + // oCurBc.setStopTime(oCurBc.getStopTime() + time);
  714 + //}
  715 +
  716 +
  717 + for (i = groupIndex; i < this._$_qCount; i++) {
  718 + if (bcIndex == 0) {
  719 + oCurBc = this.getBc(i, 0);
  720 + if (oCurBc) {
  721 + oCurBc.addMinuteToFcsj(time);
  722 + }
  723 + oCurBc = this.getBc(i, 1);
  724 + if (oCurBc) {
  725 + oCurBc.addMinuteToFcsj(time);
  726 + }
  727 +
  728 + } else {
  729 + oCurBc = this.getBc(i, 1);
  730 + if (oCurBc) {
  731 + oCurBc.addMinuteToFcsj(time);
  732 + }
  733 +
  734 + }
  735 +
  736 + bcIndex = 0;
  737 + }
  738 +};
  739 +
  740 +/**
  741 + * 在指定位置添加一个吃饭班次。
  742 + * 注1:吃饭班次不是普通班次,不记录进圈,记录进_$_other_bc_array
  743 + * 注2:添加吃饭班次时,会修改之前班次的停战时间,所以导致之后的班次的停战都会发生变化
  744 + * @param groupIndex
  745 + * @param bcIndex
  746 + * @param factory
  747 + * @param paramObj
  748 + * @returns int 相差时间(吃饭时间距离和停站时间相差值)
  749 + */
  750 +InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, paramObj) {
  751 + var oPreBc;
  752 + var oEatBc;
  753 + var iBcModifyTime;
  754 + oPreBc = this.getBc( // 前一个邻接班次
  755 + bcIndex == 0 ? groupIndex - 1 : groupIndex,
  756 + bcIndex == 1 ? 0 : 1);
  757 + if (oPreBc) { // 存在前一个班次
  758 + oEatBc = factory.createBcObj(
  759 + this,
  760 + "cf",
  761 + !oPreBc.isUp(), // 和上一个班次方向相反
  762 + 1,
  763 + paramObj.addMinute(oPreBc.getArrTimeObj(), oPreBc.getStopTime()), // 使用上一个班次的到达时间作为开始时间
  764 + paramObj
  765 + );
  766 +
  767 + //iBcModifyTime = oEatBc.getBcTime() - oPreBc.getStopTime(); // 后续班次要调整的时间
  768 +
  769 + // 修正之后的班次发车时间
  770 + // 注意:之后那个班次发车时间就是吃饭班次的到达时间
  771 + iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m");
  772 + this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime);
  773 +
  774 + oPreBc.setStopTime(0); // 不重置停站时间
  775 + oPreBc.fnSetEatTime(oEatBc.getBcTime());
  776 +
  777 + //this._$_other_bc_array.push(oEatBc);
  778 +
  779 + return iBcModifyTime;
  780 + } else {
  781 + return false;
  782 + }
  783 +
  784 +};
  785 +
  786 +/**
  787 + * 调整路牌的班次,通过调整停站时间,或者班次发车时间,不能让班次的到达时间和下一个班次的发车时间重叠。
  788 + * @param iPeakAverStopTime 高峰平均停站时间
  789 + * @param iTroughAverStopTime 低谷平均停站时间
  790 + * @param oParam 参数对象
  791 + */
  792 +InternalLpObj.prototype.fnAdjustBcInterval = function(iPeakAverStopTime, iTroughAverStopTime, oParam) {
  793 + // 获取车次链个数
  794 + var iBcChainCount = this.fnGetBcChainCount();
  795 +
  796 + var i;
  797 + var j;
  798 + var oBcIndex;
  799 + var iQIndex;
  800 + var iBcIndex;
  801 + var iBcCount;
  802 + var oBc;
  803 + var oNextBc;
  804 +
  805 + var iBcStopTime;
  806 +
  807 + for (i = 0; i < iBcChainCount; i++) {
  808 + oBcIndex = this.fnGetBcChainInfo(i);
  809 + iQIndex = oBcIndex["s_q"];
  810 + iBcIndex = oBcIndex["s_b"];
  811 + iBcCount = oBcIndex["bcount"];
  812 +
  813 + for (j = 0; j < iBcCount - 1; j++) {
  814 + oBc = this.getBc(iQIndex, iBcIndex);
  815 + oNextBc = this.getBc(
  816 + iBcIndex == 0 ? iQIndex : iQIndex + 1,
  817 + iBcIndex == 0 ? 1 : 0);
  818 +
  819 + if (oNextBc.fnIsFirstBc()) { // 如果同一路牌连续2个方向首站班次,都不做处理
  820 + continue;
  821 + }
  822 +
  823 + // 不改变当前班次的行驶时间,修正停站时间和下一个班次的发车时间
  824 + iBcStopTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m");
  825 + if (iBcStopTime < 0) {
  826 + // 当前班次使用最小停站时间
  827 + oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp()));
  828 + oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime);
  829 +
  830 + } else {
  831 + if (iBcStopTime == oBc.getStopTime() + oBc.fnGetEatTime()) {
  832 + // 停站时间一致,没有问题
  833 +
  834 +
  835 + } else {
  836 + // TODO:当前班次使用最小停站时间
  837 + oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp()));
  838 + oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime);
  839 +
  840 + }
  841 + }
  842 +
  843 + iBcIndex = iBcIndex == 0 ? 1 : 0;
  844 + iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex;
  845 + }
  846 +
  847 + this.getBc(iQIndex, iBcIndex).setStopTime(0);
  848 + }
  849 +
  850 +
  851 +};
  852 +
  853 +/**
  854 + * 调整车次block的班次停站时间,如果不在范围内,调整成平均停站时间。
  855 + * @param oParam {ParameterObj} 参数对象
  856 + */
  857 +InternalLpObj.prototype.fnAdjustBcTime = function(oParam) {
  858 + // 获取车次链个数
  859 + var iBcChainCount = this.fnGetBcChainCount();
  860 +
  861 + var i;
  862 + var j;
  863 + var oBcIndex;
  864 + var iQIndex;
  865 + var iBcIndex;
  866 + var iBcCount;
  867 + var oBc;
  868 + var oNextBc;
  869 +
  870 + var iBcStopTime;
  871 +
  872 + var aRangeStopTime;
  873 +
  874 + for (i = 0; i < iBcChainCount; i++) {
  875 + oBcIndex = this.fnGetBcChainInfo(i);
  876 + iQIndex = oBcIndex["s_q"];
  877 + iBcIndex = oBcIndex["s_b"];
  878 + iBcCount = oBcIndex["bcount"];
  879 +
  880 + for (j = 0; j < iBcCount - 1; j++) {
  881 + oBc = this.getBc(iQIndex, iBcIndex);
  882 + oNextBc = this.getBc(
  883 + iBcIndex == 0 ? iQIndex : iQIndex + 1,
  884 + iBcIndex == 0 ? 1 : 0);
  885 +
  886 + if (oNextBc.fnIsFirstBc()) { // 如果同一路牌连续2个方向首站班次,都不做处理
  887 + // 两个班次都是头班车,则停站时间不考虑范围,直接计算
  888 + iBcStopTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m");
  889 + oBc.setStopTime(iBcStopTime);
  890 +
  891 + } else {
  892 + // 获取当前班次的停站时间范围
  893 + aRangeStopTime = oParam.calcuTripLayoverTimeRange(
  894 + oBc.getArrTimeObj(), oBc.isUp(), oBc.getBcTime()
  895 + );
  896 + // 获取当前班次停站时间
  897 + iBcStopTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m");
  898 +
  899 + // 不改变当前班次的行驶时间,修正停站时间和下一个班次的发车时间和停站时间
  900 + if (oBc.fnGetEatTime() > 0) {
  901 + // 当前班次后有吃饭时间, 则没有停站时间了
  902 + oBc.setStopTime(0);
  903 + // 修改下一个班次的发车时间,到达时间
  904 + oNextBc.setFcTimeObj(oParam.addMinute(
  905 + oBc.getArrTimeObj(),
  906 + oBc.fnGetEatTime())
  907 + );
  908 + oNextBc.setArrTimeObj(oParam.addMinute(
  909 + oNextBc.getFcTimeObj(),
  910 + oParam.calcuTravelTime(
  911 + oNextBc.getFcTimeObj(),
  912 + oNextBc.isUp())
  913 + ));
  914 + } else {
  915 + if (iBcStopTime >= aRangeStopTime[0] && iBcStopTime<= aRangeStopTime[1]) {
  916 + // 在范围内,重新设置以下停站时间
  917 + oBc.setStopTime(iBcStopTime);
  918 +
  919 + } else if (iBcStopTime < aRangeStopTime[0]) {
  920 + oBc.setStopTime(aRangeStopTime[0]);
  921 + // 修改下一个班次的发车时间,到达时间
  922 + oNextBc.setFcTimeObj(oParam.addMinute(
  923 + oBc.getArrTimeObj(),
  924 + oBc.getStopTime())
  925 + );
  926 + oNextBc.setArrTimeObj(oParam.addMinute(
  927 + oNextBc.getFcTimeObj(),
  928 + oParam.calcuTravelTime(
  929 + oNextBc.getFcTimeObj(),
  930 + oNextBc.isUp())
  931 + ));
  932 + } else {
  933 + oBc.setStopTime(aRangeStopTime[1]);
  934 + // 修改下一个班次的发车时间,到达时间
  935 + oNextBc.setFcTimeObj(oParam.addMinute(
  936 + oBc.getArrTimeObj(),
  937 + oBc.getStopTime())
  938 + );
  939 + oNextBc.setArrTimeObj(oParam.addMinute(
  940 + oNextBc.getFcTimeObj(),
  941 + oParam.calcuTravelTime(
  942 + oNextBc.getFcTimeObj(),
  943 + oNextBc.isUp())
  944 + ));
  945 + }
  946 + }
  947 + }
  948 +
  949 +
  950 + iBcIndex = iBcIndex == 0 ? 1 : 0;
  951 + iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex;
  952 +
  953 + }
  954 +
  955 + // 最后一个班次停站时间为0
  956 + this.getBc(iQIndex, iBcIndex).setStopTime(0);
  957 + }
  958 +};
  959 +
  960 +/**
  961 + * 是否能调整班次的发车时间。
  962 + * @param oBc 指定班次
  963 + * @param iStep 修正步长
  964 + * @param oParam 参数对象
  965 + */
  966 +InternalLpObj.prototype.isModifyBcFcsj = function(oBc, iStep, oParam) {
  967 + // 获取车次链个数
  968 + var iBcChainCount = this.fnGetBcChainCount();
  969 +
  970 + var i;
  971 + var j;
  972 + var oBcIndex;
  973 + var iQIndex;
  974 + var iBcIndex;
  975 + var iBcCount;
  976 + var oBc;
  977 + var oPreBc;
  978 +
  979 + var iBcStopTime;
  980 +
  981 + var aRangeStopTime;
  982 +
  983 + for (i = 0; i < iBcChainCount; i++) {
  984 + oBcIndex = this.fnGetBcChainInfo(i);
  985 + iQIndex = oBcIndex["s_q"];
  986 + iBcIndex = oBcIndex["s_b"];
  987 + iBcCount = oBcIndex["bcount"];
  988 +
  989 + oPreBc = this.getBc(
  990 + iBcIndex == 0 ? iQIndex - 1 : iQIndex,
  991 + iBcIndex == 0 ? 1 : 0);
  992 +
  993 + // 如果是第一个班次
  994 + if (!oPreBc) {
  995 + if (oBc.fnIsFirstBc()) { // 如果是方向头班车
  996 + return false;
  997 + } else {
  998 + return true;
  999 + }
  1000 + }
  1001 +
  1002 + aRangeStopTime = oParam.calcuTripLayoverTimeRange(
  1003 + oPreBc.getArrTimeObj(), oPreBc.isUp(), oPreBc.getBcTime()
  1004 + );
  1005 + iBcStopTime = oPreBc.getStopTime() + iStep;
  1006 + if (iBcStopTime >= aRangeStopTime[0] && iBcStopTime <= aRangeStopTime[1]) {
  1007 + return true;
  1008 + } else {
  1009 + return false;
  1010 + }
  1011 +
  1012 +
  1013 + }
  1014 +
  1015 +};
  1016 +
  1017 +// TODO
  1018 +
  1019 +/**
  1020 + *
  1021 + *
  1022 + */
  1023 +InternalLpObj.prototype.calcuLpBx = function() {
  1024 +
  1025 +};
  1026 +
  1027 +