Commit a9a85907e333412903bc60ea20287898ae159671

Authored by 徐烜
1 parent 8f6b2e0f

时刻表v2.1

基本的一张时刻表已经完成,使用如下步骤:
    1、初始化,计算上标线及圈数,初始计算高峰班次,计算中标线,计算连班分班路牌数
    2、计算分班路牌的班型及对应工时(分隔法,5休2和其他分班)
    3、补足连班路牌班次
    4、根据高峰时间范围修正高峰班次(上行早晚高峰,下行早晚高峰)
    5、按照车辆投入运营要求补足班次(早高峰7:45以前投入运营,晚高峰16:10投入运营)
    6、根据班型补足所有不足班次
    7、补吃饭班次
    8、调整纵向班次间隔
    9、确定末班车
    10、补充进出场例保班次

    时刻表v3预览版
    考虑使用全新的数据结构和算法
src/main/resources/application-dev.properties
... ... @@ -8,9 +8,9 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy
8 8 spring.jpa.database= MYSQL
9 9 spring.jpa.show-sql= false
10 10 spring.datasource.driver-class-name= com.mysql.jdbc.Driver
11   -spring.datasource.url= jdbc:mysql://127.0.0.1/pd_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
  11 +spring.datasource.url= jdbc:mysql://127.0.0.1/control?useUnicode=true&characterEncoding=utf-8&useSSL=false
12 12 spring.datasource.username= root
13   -spring.datasource.password= root
  13 +spring.datasource.password=
14 14  
15 15 #spring.datasource.url= jdbc:mysql://192.168.168.117/pd_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
16 16 #spring.datasource.username= root
... ...
src/main/resources/static/pages/base/timesmodel/js/v2/ParameterObj.js
... ... @@ -18,7 +18,46 @@ var ParameterObj = function() {
18 18 }
19 19 };
20 20  
  21 + // 计算吃饭时间
  22 + var _fnEatTime = function() {
  23 + var aTime = [];
  24 + // 午饭时间
  25 + aTime.push(
  26 + isNaN(_formMap.workeLunch) || parseInt(_formMap.workeLunch) == 0 ?
  27 + 20 : parseInt(_formMap.workeLunch)
  28 + );
  29 + // 晚饭时间
  30 + aTime.push(
  31 + isNaN(_formMap.workeDinner) || parseInt(_formMap.workeDinner) == 0 ?
  32 + 20 : parseInt(_formMap.workeDinner)
  33 + );
  34 +
  35 + return aTime;
  36 + };
  37 + var _aEatTime;
  38 +
  39 + // 计算吃饭地点
  40 + var _fnEatDir = function() {
  41 + var aEatD = [];
  42 +
  43 + if (_formMap.cfdd != undefined && String(_formMap.cfdd) == "") {
  44 + aEatD = false;
  45 + } else if (parseInt(_formMap.cfdd) == 0) {
  46 + aEatD.push(true);
  47 + } else if (parseInt(_formMap.cfdd) == 1) {
  48 + aEatD.push(false);
  49 + } else if (String(_formMap.cfdd) == "allYes") {
  50 + aEatD.push(true);
  51 + aEatD.push(false);
  52 + }
  53 +
  54 + return aEatD;
  55 + };
  56 + var _aEatDir;
  57 +
  58 +
21 59 // 计算行驶时间对象
  60 + // TODO:暂时获取标准信息,之后改成历史数据,可能需要使用promise封装
22 61 var _travelTimeObj_fun = function() {
23 62 var upMoningPeakTravelTime =
24 63 isNaN(_formMap.earlyUpTime) || parseInt(_formMap.earlyUpTime) == 0 ?
... ... @@ -62,6 +101,34 @@ var ParameterObj = function() {
62 101 };
63 102 var _travelTimeObj;
64 103  
  104 + // 计算上下行进出场时间
  105 + var _inOutTimeObj_fun = function() {
  106 + var upInTime =
  107 + isNaN(_formMap.upInTimer) || parseInt(_formMap.upInTimer) == 0 ?
  108 + 20 : parseInt(_formMap.upInTimer);
  109 + var upOutTime =
  110 + isNaN(_formMap.upOutTimer) || parseInt(_formMap.upOutTimer) == 0 ?
  111 + 20 : parseInt(_formMap.upOutTimer);
  112 + var downInTime =
  113 + isNaN(_formMap.downInTimer) || parseInt(_formMap.downInTimer) == 0 ?
  114 + 20 : parseInt(_formMap.downInTimer);
  115 + var downOutTime =
  116 + isNaN(_formMap.downOutTimer) || parseInt(_formMap.downOutTimer) == 0 ?
  117 + 20 : parseInt(_formMap.downOutTimer);
  118 +
  119 + return [
  120 + { // 上行
  121 + "out": upOutTime,
  122 + "in": upInTime
  123 + },
  124 + { // 下行
  125 + "out": downOutTime,
  126 + "in": downInTime
  127 + }
  128 + ]
  129 + };
  130 + var _inOutTimeObj;
  131 +
65 132 // 计算行驶里程对象
66 133 var _travelLcObj_fun = function() {
67 134 return [
... ... @@ -274,10 +341,16 @@ var ParameterObj = function() {
274 341  
275 342 _validInternal(); // 验证
276 343  
  344 + // 吃饭时间
  345 + _aEatTime = _fnEatTime();
  346 + // 吃饭地点
  347 + _aEatDir = _fnEatDir();
277 348 // 首班车,末班车行驶时间字符串
278 349 _firstLastDepartureTimeStrObj = _firstLastDepartureTimeStrObj_fun();
279 350 // 行驶时间对象
280 351 _travelTimeObj = _travelTimeObj_fun();
  352 + // 上下行进出场时间
  353 + _inOutTimeObj = _inOutTimeObj_fun();
281 354 // 行驶里程对象
282 355 _travelLcObj = _travelLcObj_fun();
283 356 // 时间段划分对象
... ... @@ -342,6 +415,52 @@ var ParameterObj = function() {
342 415 );
343 416 },
344 417  
  418 + //-------------- 获取吃饭时间 ----------------//
  419 + /**
  420 + * 获取午饭时间。
  421 + * @returns int
  422 + */
  423 + fnGetLunchTime: function() {
  424 + _validInternal(); // 验证
  425 + return _aEatTime[0];
  426 + },
  427 + /**
  428 + * 获取晚饭时间。
  429 + * @returns int
  430 + */
  431 + fnGetDinnerTime: function() {
  432 + _validInternal(); // 验证
  433 + return _aEatTime[1];
  434 + },
  435 +
  436 + //-------------- 获取吃饭地点 ----------------//
  437 + /**
  438 + * 是否吃饭。
  439 + * @returns {boolean}
  440 + */
  441 + fnIsEat: function() {
  442 + _validInternal(); // 验证
  443 + return _aEatDir ? true : false;
  444 + },
  445 +
  446 + /**
  447 + * 是否上行吃饭。
  448 + * @returns {boolean}
  449 + */
  450 + fnIsUpEat: function() {
  451 + _validInternal(); // 验证
  452 + return this.fnIsEat() ? _aEatDir[0] : false;
  453 + },
  454 +
  455 + /**
  456 + * 是否上下行都能吃饭。
  457 + * @returns {boolean}
  458 + */
  459 + fnIsBothEat: function() {
  460 + _validInternal(); // 验证
  461 + return (this.fnIsEat() && _aEatDir.length > 1) ? true : false;
  462 + },
  463 +
345 464 //-------------- 获取行驶时间 ----------------//
346 465 /**
347 466 * 获取上行早高峰行驶时间。
... ... @@ -392,6 +511,39 @@ var ParameterObj = function() {
392 511 return _travelTimeObj.trough[1];
393 512 },
394 513  
  514 + /**
  515 + * 获取上行出场时间。
  516 + * @returns int number
  517 + */
  518 + getUpOutTime: function() {
  519 + _validInternal(); // 验证
  520 + return _inOutTimeObj[0].out;
  521 + },
  522 + /**
  523 + * 获取上行进场时间。
  524 + * @returns int number
  525 + */
  526 + getUpInTime: function() {
  527 + _validInternal(); // 验证
  528 + return _inOutTimeObj[0].in;
  529 + },
  530 + /**
  531 + * 获取下行出场时间。
  532 + * @returns int number
  533 + */
  534 + getDownOutTime: function() {
  535 + _validInternal(); // 验证
  536 + return _inOutTimeObj[1].out;
  537 + },
  538 + /**
  539 + * 获取下行进场时间。
  540 + * @returns int number
  541 + */
  542 + getDownInTime: function() {
  543 + _validInternal(); // 验证
  544 + return _inOutTimeObj[1].in;
  545 + },
  546 +
395 547 //---------------- 获取行驶里程 -----------------//
396 548 /**
397 549 * 获取上行normal班次里程。
... ... @@ -578,6 +730,15 @@ var ParameterObj = function() {
578 730 return parseInt(_formMap.jbclcount);
579 731 },
580 732  
  733 + //----------------- 获取保养信息 ------------------//
  734 + /**
  735 + * 获取例保时间。
  736 + */
  737 + getLbTime: function() {
  738 + _validInternal(); // 验证
  739 + return isNaN(_formMap.lb) || parseInt(_formMap.lb) == 0 ? 5 : parseInt(_formMap.lb);
  740 + },
  741 +
581 742 //----------------- 获取关联数据信息 -----------------//
582 743 /**
583 744 * 获取线路id。
... ... @@ -935,20 +1096,28 @@ var ParameterObj = function() {
935 1096 var paramObj = this;
936 1097  
937 1098 if (isUp) {
938   - if (bcType == "in") {
  1099 + if (bcType == "in_") {
939 1100 return paramObj.getUpInLc();
940 1101 } else if (bcType == "out") {
941 1102 return paramObj.getUpOutLc();
  1103 + } else if (bcType == "bd") {
  1104 + return 0;
  1105 + } else if (bcType == "lc") {
  1106 + return 0;
942 1107 } else {
943 1108 // 基本班次类型,暂时不考虑区间等其他班次类型
944 1109 // 暂时不考虑高峰低谷里程的区分
945 1110 return paramObj.getUpNormalLc();
946 1111 }
947 1112 } else {
948   - if (bcType == "in") {
  1113 + if (bcType == "in_") {
949 1114 return paramObj.getDownInLc();
950 1115 } else if (bcType == "out") {
951 1116 return paramObj.getDownOutLc();
  1117 + } else if (bcType == "bd") {
  1118 + return 0;
  1119 + } else if (bcType == "lc") {
  1120 + return 0;
952 1121 } else {
953 1122 // 基本班次类型,暂时不考虑区间等其他班次类型
954 1123 // 暂时不考虑高峰低谷里程的区分
... ...
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalBcObj.js
... ... @@ -72,6 +72,13 @@ InternalBcObj.prototype.getFcTimeObj = function() {
72 72 return this._$_fcsjObj;
73 73 };
74 74 /**
  75 + * 设置发车时间。
  76 + * @param oFcsj
  77 + */
  78 +InternalBcObj.prototype.setFcTimeObj = function(oFcsj) {
  79 + this._$_fcsjObj = oFcsj;
  80 +};
  81 +/**
75 82 * 获取到达时间。
76 83 * @returns {*|moment.Moment}
77 84 */
... ... @@ -92,10 +99,43 @@ InternalBcObj.prototype.getBcTime = function() {
92 99 InternalBcObj.prototype.getStopTime = function() {
93 100 return this._$_stoptime;
94 101 };
  102 +/**
  103 + * 设置停站时间。
  104 + * @param t int
  105 + */
  106 +InternalBcObj.prototype.setStopTime = function(t) {
  107 + this._$_stoptime = t;
  108 +};
  109 +
  110 +/**
  111 + * 获取发车顺序号。
  112 + * @returns int
  113 + */
  114 +InternalBcObj.prototype.fnGetFcno = function() {
  115 + return this._$_fcno;
  116 +};
  117 +/**
  118 + * 设置发车顺序号。
  119 + * @param t int
  120 + */
  121 +InternalBcObj.prototype.fnSetFcno = function(t) {
  122 + this._$_fcno = t;
  123 +};
  124 +
  125 +
95 126  
96 127 //---------------------- 其他方法 -------------------------//
97 128  
98 129 /**
  130 + * 给发车时间添加时间。
  131 + * @param num
  132 + */
  133 +InternalBcObj.prototype.addMinuteToFcsj = function(num) {
  134 + this._$_fcsjObj.add(num, "m"); // 发车时间不需要clone
  135 + this._$_arrtime.add(num, "m"); // 到达时间也不需要clone
  136 +};
  137 +
  138 +/**
99 139 * 转换成显示用班次对象。
100 140 * @returns {{}}
101 141 */
... ...
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalLpObj.js
... ... @@ -38,12 +38,22 @@ var InternalLpObj = function(
38 38 this._$_bx_isfb_5_2 = false; // 是否5休2分班
39 39 this._$_bx_desc; // 班型描述(默认为路牌编号)
40 40  
  41 + // 其他班次(进出场,例包,吃饭等),TODO:以后再拆
  42 + this._$_other_bc_array = [];
  43 +
41 44 // TODO:
42 45  
43 46 };
44 47  
45 48 //------------------- get/set 方法 -------------------//
46 49  
  50 +InternalLpObj.prototype.getOtherBcArray = function() {
  51 + return this._$_other_bc_array;
  52 +};
  53 +InternalLpObj.prototype.addOtherBcArray = function(ba) {
  54 + this._$_other_bc_array = this._$_other_bc_array.concat(ba);
  55 +};
  56 +
47 57 /**
48 58 * 获取圈
49 59 * @param qIndex 圈index
... ... @@ -248,6 +258,149 @@ InternalLpObj.prototype.getMaxBcObjPosition = function() {
248 258 return bIndex;
249 259 };
250 260  
  261 +InternalLpObj.prototype.getMinBcObj = function() {
  262 + var i;
  263 + var bcObj;
  264 + for (i = 0; i < this._$_groupBcArray.length; i++) {
  265 + bcObj = this._$_groupBcArray[i].getBc1();
  266 + if (bcObj) {
  267 + break;
  268 + }
  269 + bcObj = this._$_groupBcArray[i].getBc2();
  270 + if (bcObj) {
  271 + break;
  272 + }
  273 + }
  274 + return bcObj;
  275 +};
  276 +InternalLpObj.prototype.getMaxBcObj = function() {
  277 + var i;
  278 + var bcObj;
  279 + for (i = this._$_groupBcArray.length - 1; i >= 0; i--) {
  280 + bcObj = this._$_groupBcArray[i].getBc2();
  281 + if (bcObj) {
  282 + break;
  283 + }
  284 + bcObj = this._$_groupBcArray[i].getBc1();
  285 + if (bcObj) {
  286 + break;
  287 + }
  288 + }
  289 + return bcObj;
  290 +};
  291 +
  292 +/**
  293 + * 获取车次链信息。
  294 + * @param num 第几个车次链
  295 + * @returns object {s_q: {开始圈索引},s_b : {开始班次索引},e_q : {结束圈索引},e_b : {结束班次索引}, bcount : {班次数}}
  296 + */
  297 +InternalLpObj.prototype.fnGetBcChainInfo = function(num) {
  298 + // 计算总的车次链信息
  299 + var aChainInfo = [];
  300 + var oChainInfo;
  301 + var aBcIndex = this.getMinBcObjPosition();
  302 + var oBc;
  303 + var iQIndex;
  304 + var iBcIndex;
  305 + var i;
  306 + var bFlag;
  307 +
  308 + var iBcount = 0;
  309 +
  310 + if (aBcIndex.length == 2) {
  311 + iBcount = 1;
  312 + oChainInfo = {s_q : aBcIndex[0], s_b : aBcIndex[1], e_q : aBcIndex[0], e_b : aBcIndex[1], bcount: 1};
  313 + aChainInfo.push(oChainInfo);
  314 + bFlag = true;
  315 +
  316 + // 下一个班次的索引
  317 + iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1;
  318 + iBcIndex = aBcIndex[1] == 0 ? 1 : 0;
  319 +
  320 + for (i = iQIndex; i < this._$_qCount; i++) {
  321 + while (iBcIndex <= 1) {
  322 + oBc = this.getBc(i, iBcIndex);
  323 + if (!oBc) {
  324 + if (bFlag) {
  325 + // 车次链结尾是这个班次的前一个班次
  326 + oChainInfo.e_q = iBcIndex == 0 ? i - 1 : i;
  327 + oChainInfo.e_b = iBcIndex == 0 ? 1 : 0;
  328 + oChainInfo.bcount = iBcount;
  329 + }
  330 +
  331 + bFlag = false;
  332 + } else {
  333 + if (bFlag) {
  334 + iBcount ++;
  335 + oChainInfo.bcount = iBcount;
  336 + } else {
  337 + // 下一个车次链开始
  338 + iBcount = 1;
  339 + oChainInfo = {s_q : i, s_b : iBcIndex, e_q : i, e_b : iBcIndex, bcount: 1};
  340 + aChainInfo.push(oChainInfo);
  341 + bFlag = true;
  342 + }
  343 + }
  344 +
  345 +
  346 + iBcIndex ++;
  347 + }
  348 + iBcIndex = 0;
  349 + }
  350 +
  351 + }
  352 +
  353 + return aChainInfo[num];
  354 +};
  355 +
  356 +/**
  357 + * 获取车次链的个数。
  358 + * @returns int
  359 + */
  360 +InternalLpObj.prototype.fnGetBcChainCount = function() {
  361 + var iChainCount = 0;
  362 + var aBcIndex = this.getMinBcObjPosition();
  363 +
  364 + var oBc;
  365 + var iQIndex;
  366 + var iBcIndex;
  367 + var i;
  368 + var bFlag;
  369 +
  370 + if (aBcIndex.length == 2) {
  371 + iChainCount = 1;
  372 + bFlag = true;
  373 +
  374 + // 下一个班次的索引
  375 + iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1;
  376 + iBcIndex = aBcIndex[1] == 0 ? 1 : 0;
  377 +
  378 + for (i = iQIndex; i < this._$_qCount; i++) {
  379 + while (iBcIndex <= 1) {
  380 + oBc = this.getBc(i, iBcIndex);
  381 + if (!oBc) {
  382 + bFlag = false;
  383 + } else {
  384 + if (bFlag) {
  385 +
  386 + } else {
  387 + iChainCount ++;
  388 + bFlag = true;
  389 + }
  390 + }
  391 +
  392 +
  393 + iBcIndex ++;
  394 + }
  395 + iBcIndex = 0;
  396 + }
  397 +
  398 + }
  399 +
  400 +
  401 + return iChainCount;
  402 +};
  403 +
251 404 /**
252 405 * 在具体位置移除班次。
253 406 * @param qIndex 第几圈
... ... @@ -266,12 +419,14 @@ InternalLpObj.prototype.removeBc = function(qIndex, bcIndex) {
266 419 * 使用指定时间匹配返回离之最近的第几圈第几个班次,
267 420 * 使用时间差的绝度值,比较,取最小的
268 421 * 如果有两个一样的时间差,取比fctime大的时间
269   - * @param fctime 比较用时间
  422 + * @param fctime moment 比较用时间
270 423 * @param groupArray 圈数组
  424 + * @param hasUp boolean 计算上行班次
  425 + * @param hasDown boolean 计算下行班次
271 426 * @returns [{第几圈},{第几个班次}]
272 427 */
273 428 InternalLpObj.prototype.getgetQBcIndexWithFcTimeFromGroupArray = function(
274   - fctime, groupArray
  429 + fctime, groupArray, hasUp, hasDown
275 430 ) {
276 431 var i;
277 432 var timediff; // 时间差取绝对值
... ... @@ -286,7 +441,7 @@ InternalLpObj.prototype.getgetQBcIndexWithFcTimeFromGroupArray = function(
286 441 for (i = 0; i < this._$_qCount; i++) {
287 442 group = groupArray[i];
288 443 if (group) {
289   - if (group.getBc1()) {
  444 + if (group.getBc1() && hasUp) {
290 445 bc1time = group.getBc1().getFcTimeObj();
291 446 tempdiff = Math.abs(bc1time.diff(fctime));
292 447  
... ... @@ -310,7 +465,7 @@ InternalLpObj.prototype.getgetQBcIndexWithFcTimeFromGroupArray = function(
310 465 }
311 466 }
312 467  
313   - if (group.getBc2()) {
  468 + if (group.getBc2() && hasDown) {
314 469 bc2time = group.getBc2().getFcTimeObj();
315 470 tempdiff = Math.abs(bc2time.diff(fctime));
316 471  
... ... @@ -347,13 +502,15 @@ InternalLpObj.prototype.getgetQBcIndexWithFcTimeFromGroupArray = function(
347 502 * 使用指定时间匹配返回离之最近的第几圈第几个班次,
348 503 * 使用时间差的绝度值,比较,取最小的
349 504 * 如果有两个一样的时间差,取比fctime大的时间
350   - * @param fctime 比较用时间
  505 + * @param fctime moment 比较用时间
  506 + * @param hasUp boolean 计算上行班次
  507 + * @param hasDown boolean 计算下行班次
351 508 * @returns [{第几圈},{第几个班次}]
352 509 */
353 510 InternalLpObj.prototype.getQBcIndexWithFcTime = function(
354   - fctime
  511 + fctime, hasUp, hasDown
355 512 ) {
356   - return this.getgetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray);
  513 + return this.getgetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray, hasUp, hasDown);
357 514 };
358 515  
359 516 //---------------------- 内部数据初始化方法(不同于构造函数)---------------------//
... ... @@ -393,6 +550,10 @@ InternalLpObj.prototype.initDataFromTimeToTime = function(
393 550 } while(kssj.isBefore(endTime));
394 551 bcCount--;
395 552  
  553 + //console.log("last -1;" + bcData[bcCount -2].getFcTimeObj().format("HH:mm"));
  554 + //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm"));
  555 + //console.log("endtime: " + endTime.format("HH:mm"));
  556 +
396 557 if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) {
397 558 // 如果最后一个班次的到达时间超过结束时间,也要去除
398 559 bcData.splice(bcCount - 1, 1);
... ... @@ -467,6 +628,9 @@ InternalLpObj.prototype._initDataFromLbBcArray = function(
467 628 );
468 629 _bc1Obj.setGroup(_qObj);
469 630 this._$_groupBcArray[fromQ] = _qObj;
  631 +
  632 + bcArray.splice(0, 1);
  633 + qCount2 --;
470 634 } else {
471 635 break;
472 636 }
... ... @@ -478,6 +642,93 @@ InternalLpObj.prototype._initDataFromLbBcArray = function(
478 642  
479 643 //-------------------------- 其他方法 ----------------------------//
480 644  
  645 +/**
  646 + * 从指定位置的班次开始,往后所有的班次修正发车时间
  647 + * @param groupIndex
  648 + * @param bcIndex
  649 + * @param time
  650 + */
  651 +InternalLpObj.prototype.fnAddMinuteToBcFcsj = function(groupIndex, bcIndex, time) {
  652 + var i;
  653 + var oCurBc;
  654 +
  655 + // 修正之前班次的停站时间
  656 + //oCurBc = this.getBc(
  657 + // bcIndex == 0 ? groupIndex - 1 : groupIndex,
  658 + // bcIndex == 1 ? 0 : 1
  659 + //);
  660 + //if (oCurBc) {
  661 + // oCurBc.setStopTime(oCurBc.getStopTime() + time);
  662 + //}
  663 +
  664 +
  665 + for (i = groupIndex; i < this._$_qCount; i++) {
  666 + if (bcIndex == 0) {
  667 + oCurBc = this.getBc(i, 0);
  668 + if (oCurBc) {
  669 + oCurBc.addMinuteToFcsj(time);
  670 + }
  671 + oCurBc = this.getBc(i, 1);
  672 + if (oCurBc) {
  673 + oCurBc.addMinuteToFcsj(time);
  674 + }
  675 +
  676 + } else {
  677 + oCurBc = this.getBc(i, 1);
  678 + if (oCurBc) {
  679 + oCurBc.addMinuteToFcsj(time);
  680 + }
  681 +
  682 + }
  683 +
  684 + bcIndex = 0;
  685 + }
  686 +};
  687 +
  688 +/**
  689 + * 在指定位置添加一个吃饭班次。
  690 + * 注1:吃饭班次不是普通班次,不记录进圈,记录进_$_other_bc_array
  691 + * 注2:添加吃饭班次时,会修改之前班次的停战时间,所以导致之后的班次的停战都会发生变化
  692 + * @param groupIndex
  693 + * @param bcIndex
  694 + * @param factory
  695 + * @param paramObj
  696 + * @returns int 相差时间(吃饭时间距离和停站时间相差值)
  697 + */
  698 +InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, paramObj) {
  699 + var oPreBc;
  700 + var oEatBc;
  701 + var iBcModifyTime;
  702 + oPreBc = this.getBc( // 前一个邻接班次
  703 + bcIndex == 0 ? groupIndex - 1 : groupIndex,
  704 + bcIndex == 1 ? 0 : 1);
  705 + if (oPreBc) { // 存在前一个班次
  706 + oEatBc = factory.createBcObj(
  707 + this,
  708 + "cf",
  709 + !oPreBc.isUp(), // 和上一个班次方向相反
  710 + 1,
  711 + oPreBc.getArrTimeObj(), // 使用上一个班次的到达时间作为开始时间
  712 + paramObj
  713 + );
  714 +
  715 + //iBcModifyTime = oEatBc.getBcTime() - oPreBc.getStopTime(); // 后续班次要调整的时间
  716 +
  717 + // 修正之后的班次发车时间
  718 + // 注意:之后那个班次发车时间就是吃饭班次的到达时间
  719 + iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m");
  720 + this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime);
  721 +
  722 + oPreBc.setStopTime(0);
  723 + this._$_other_bc_array.push(oEatBc);
  724 +
  725 + return iBcModifyTime;
  726 + } else {
  727 + return false;
  728 + }
  729 +
  730 +};
  731 +
481 732  
482 733 // TODO
483 734  
... ...
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalScheduleObj.js
... ... @@ -14,6 +14,16 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
14 14 var _qIsUp; // 每一圈是上行开始还是下行开始
15 15 var _qCount = 0; // 总的圈数
16 16 var _internalLpArray = []; // 内部对象数组
  17 + var _aBxDesc = [ // 各种班型描述(班型名称,平均工时,平均需要的班次数,平均工时)
  18 + {'sType':'六工一休', 'fHoursV':6.66, 'fBcCount': 0, 'fAverTime': 0},
  19 + {'sType':'五工一休', 'fHoursV':6.85, 'fBcCount': 0, 'fAverTime': 0},
  20 + {'sType':'四工一休', 'fHoursV':7.14, 'fBcCount': 0, 'fAverTime': 0},
  21 + {'sType':'三工一休', 'fHoursV':7.61, 'fBcCount': 0, 'fAverTime': 0},
  22 + {'sType':'二工一休', 'fHoursV':8.57, 'fBcCount': 0, 'fAverTime': 0},
  23 + {'sType':'一工一休', 'fHoursV':11.42, 'fBcCount': 0, 'fAverTime': 0},
  24 + {'sType':'五工二休', 'fHoursV':7.99, 'fBcCount': 0, 'fAverTime': 0},
  25 + {'sType':'无工休', 'fHoursV':5.43, 'fBcCount': 0, 'fAverTime': 0}
  26 + ];
17 27  
18 28 var _initFun1 = function() { // 初始化方法1
19 29  
... ... @@ -38,8 +48,6 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
38 48  
39 49 //------------------------ 2、计算总共有多少圈 ------------------------//
40 50  
41   -
42   -
43 51 // 以开始时间,结束时间,构造上标线用连班班次发车时间
44 52 var bcFcsjArrays = []; // 班次发车时间对象数组
45 53 var bcArsjArrays = []; // 班次到达时间对象数组
... ... @@ -54,7 +62,12 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
54 62 do {
55 63 bcFcsjArrays.push(_kssj);
56 64 bcArsjArrays.push(_arrsj);
  65 +
57 66 _kssj = paramObj.addMinute(_kssj, _bcsj + _stoptime);
  67 + _bcsj = paramObj.calcuTravelTime(_kssj, isUp);
  68 + _arrsj = paramObj.addMinute(_kssj, _bcsj);
  69 + _stoptime = paramObj.calcuFixedStopNumber(_arrsj, !isUp);
  70 +
58 71 bcCount ++;
59 72 isUp = !isUp;
60 73 } while(_kssj.isBefore(et));
... ... @@ -100,6 +113,29 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
100 113 // 初始化上标线,从第1圈开始
101 114 _internalLpArray[0].initDataFromTimeToTime(bcFcsjArrays[0], et, _qIsUp, 1, _paramObj, _factory);
102 115  
  116 + // 以上标线为基础,计算各种班型工时对应的圈数、班次数
  117 + var aBcArray = _internalLpArray[0].getBcArray();
  118 + if (aBcArray.length % 2 != 0) { // 不能整除2,去除一个班次计算
  119 + aBcArray.splice(aBcArray.length - 1, 1);
  120 + }
  121 + var sum = 0;
  122 + // 加吃饭时间
  123 + sum += _paramObj.fnGetLunchTime();
  124 + sum += _paramObj.fnGetDinnerTime();
  125 + // 加进出场时间
  126 + sum += _qIsUp ? _paramObj.getUpOutTime() : _paramObj.getDownOutTime();
  127 + sum += _qIsUp ? _paramObj.getDownInTime() : _paramObj.getUpInTime();
  128 + // 例保时间
  129 + //sum += _paramObj.getLbTime() * 2;
  130 + for (i = 0; i < aBcArray.length; i++) {
  131 + sum += aBcArray[i].getBcTime() + aBcArray[i].getStopTime();
  132 + }
  133 + for (i = 0; i < _aBxDesc.length; i++) {
  134 + _aBxDesc[i].fAverTime = sum / (aBcArray.length / 2);
  135 + _aBxDesc[i].fBcCount = ((_aBxDesc[i].fHoursV * 60) / _aBxDesc[i].fAverTime) * 2;
  136 + }
  137 +
  138 +
103 139 console.log("//---------------- 行车计划,初始化方法1 start ----------------//");
104 140 console.log("上行首班车时间:" + _paramObj.getUpFirstDTimeObj().format("HH:mm") +
105 141 "上行末班车时间:" + _paramObj.getUpLastDtimeObj().format("HH:mm"));
... ... @@ -107,6 +143,8 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
107 143 "下行末班车时间:" + _paramObj.getDownLastDTimeObj().format("HH:mm"));
108 144 console.log("总共计算的圈数:" + _qCount);
109 145 console.log("圈的方向isUP:" + _qIsUp);
  146 + console.log("班型描述(以下):");
  147 + console.log(_aBxDesc);
110 148 console.log("//---------------- 行车计划,初始化方法1 end ----------------//");
111 149  
112 150 };
... ... @@ -127,7 +165,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
127 165 // 以上标线为标准,查找离早高峰开始时间最近的班次作为早高峰开始班次
128 166 // 以这个班次为早高峰起点,全部出车策略
129 167 var qbcIndexArray = _internalLpArray[0].getQBcIndexWithFcTime(
130   - _paramObj.getMPeakStartTimeObj());
  168 + _paramObj.getMPeakStartTimeObj(), true, true);
131 169 var qIndex = qbcIndexArray[0]; // 第几圈
132 170 var bIndex = qbcIndexArray[1]; // 第几个班次
133 171 var startbc = _internalLpArray[0].getBc(qIndex, bIndex);
... ... @@ -163,7 +201,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
163 201 1, _kssj, paramObj)
164 202 );
165 203 // 使用早高峰的发车间隔最为路牌纵向最小发车间隔,,不能整除的话,大的放在后面的路牌
166   - _internalLpArray[_clCount - _c2 + i - 1].setVerticalMinIntervalTime(_c1);
  204 + _internalLpArray[_clCount - _c2 + i - 1].setVerticalMinIntervalTime(_c1 + 1);
167 205 }
168 206  
169 207 _approximate_zgfQIndex = qIndex;
... ... @@ -174,7 +212,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
174 212 // 以上标线为标准,查找离晚高峰开始时间最近的班次作为晚高峰开始班次
175 213 // 以这个班次为早高峰起点,全部出车策略
176 214 qbcIndexArray = _internalLpArray[0].getQBcIndexWithFcTime(
177   - _paramObj.getEPeakStartTimeObj());
  215 + _paramObj.getEPeakStartTimeObj(), true, true);
178 216 qIndex = qbcIndexArray[0]; // 第几圈
179 217 bIndex = qbcIndexArray[1]; // 第几个班次
180 218 startbc = _internalLpArray[0].getBc(qIndex, bIndex);
... ... @@ -213,9 +251,11 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
213 251 _qbcMinIntervalValue = _c1;
214 252  
215 253 console.log("//---------------- 行车计划,初始化方法2 start ----------------//");
  254 + console.log("早高峰周转时间(固定最大停战时间):" + _paramObj.calcuPeakZzsj() + "分钟");
  255 + console.log("早高峰发车时间范围:" + _paramObj.getMPeakMinFcjx() + "分钟 --- " + _paramObj.getMPeakMaxFcjx() + "分钟");
216 256 console.log("预估早高峰第" + _approximate_zgfQIndex + "(index)圈,第" + _approximate_zgfBIndex + "(index)班次车辆全部发出");
217 257 console.log("预估晚高峰第" + _approximate_wgfQIndex + "(index)圈,第" + _approximate_wgfBIndex + "(index)班次车辆全部发出");
218   - console.log("预估同圈同方向班次最小间隔(分钟):" + _qbcMinIntervalValue);
  258 + console.log("预估同圈同方向班次最小间隔:" + _qbcMinIntervalValue + "分钟");
219 259 console.log("//---------------- 行车计划,初始化方法2 end ----------------//");
220 260 };
221 261  
... ... @@ -272,7 +312,9 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
272 312  
273 313 var _ttindex_ = tempLpObj.getgetQBcIndexWithFcTimeFromGroupArray(
274 314 _zb_bcobj.getFcTimeObj(),
275   - _tempq_array
  315 + _tempq_array,
  316 + true,
  317 + true
276 318 );
277 319 _zbx_lpIndex = _ttindex_[0]; // 中标线放在第几个路牌
278 320 tempLpObj.setLp(_lpArray[_zbx_lpIndex]); // 设置原始路牌对象
... ... @@ -280,10 +322,29 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
280 322 _internalLpArray[_zbx_lpIndex].getVerticalMinIntervalTime()
281 323 );
282 324  
283   - // 注意:这里直接把中标线数据替换到指定路牌位置
  325 + // 注意:因为中标线很横向创建的,而高峰的替换路牌的班次班次是纵向间隔创建的
  326 + // 做法1:直接把中标线数据替换到指定路牌位置
284 327 // TODO:由初始化方法1,初始化方法2得到的2个高峰的班次会被中标线对应班次覆盖
285 328 // TODO:目前使用中标线的班次覆盖,以后相互动态调整
  329 + // _internalLpArray[_zbx_lpIndex] = tempLpObj;
  330 +
  331 + // 做法2:将中标线除头班次外所有班次用间隔法重新创建替换
  332 + var iTempIndex = 0;
  333 + for (i = 1; i < _qCount; i++) {
  334 + while (iTempIndex <= 1) {
  335 + _temp_bc = tempLpObj.getBc(i, iTempIndex);
  336 + if (_temp_bc) { // 中标线存在此路牌,才替换
  337 + tempLpObj.setBc(
  338 + i, iTempIndex,
  339 + _generateBc(_zbx_lpIndex, i , iTempIndex)
  340 + );
  341 + }
286 342  
  343 + iTempIndex ++;
  344 + }
  345 + iTempIndex = 0;
  346 +
  347 + }
287 348 _internalLpArray[_zbx_lpIndex] = tempLpObj;
288 349  
289 350 console.log("//---------------- 行车计划,初始化方法3 start ----------------//");
... ... @@ -405,6 +466,9 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
405 466 * @returns [{路牌index},{圈index},{班次index}]
406 467 */
407 468 var _findUpClosedBcIndexWithTime = function(timeObj, isUp) {
  469 +
  470 + // dododo
  471 +
408 472 var _lpObj;
409 473 var _groupObj;
410 474 var _bcObj;
... ... @@ -540,60 +604,8 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
540 604 // 初始化4,计算连班,分班相关路牌数
541 605 _initFun4();
542 606  
543   - // 测试添加班次
544   - //this._generateBc(8, 1, 0);
545   - //this._generateBc(10, 1, 0);
546   - //this._generateBc(11, 1, 0);
547   - //this._generateBc(12, 1, 0);
548   - //this._generateBc(13, 1, 0);
549   - //this._generateBc(14, 1, 0);
550   - //this._generateBc(15, 1, 0);
551   - //this._generateBc(16, 1, 0);
552   - //this._generateBc(17, 1, 0);
553   - //this._generateBc(18, 1, 0);
554   - //
555   - //this._generateBc(10, 1, 1);
556   - //this._generateBc(11, 1, 1);
557   - //this._generateBc(12, 1, 1);
558   - //this._generateBc(13, 1, 1);
559   - //this._generateBc(14, 1, 1);
560   - //this._generateBc(15, 1, 1);
561   - //this._generateBc(16, 1, 1);
562   - //this._generateBc(17, 1, 1);
563   - //this._generateBc(18, 1, 1);
564   -
565   - // 6:31 8:30
566   - // 16:01 18:00
567   -
568   - // 测试找上界
569   - console.log("上界:" + _findUpClosedBcIndexWithTime(_paramObj.getMPeakStartTimeObj(), false));
570   - console.log("下界:" + _findDownClosedBcIndexWithTime(_paramObj.getMPeakEndTimeObj(), false));
571   -
572   - // TODO:
573   -
574   - // 测试时间判定
575   - //console.log("班次出车时间:" + _internalLpArray[0].getQBcIndexWithFcTime(
576   - // _paramObj.getMPeakStartTimeObj()
577   - // ));
578   -
579   - //// 测试画中标线,第6个路牌的位置,下行中标
580   - //_internalLpArray[7].initDataFromTimeToTime(
581   - // _paramObj.getDownFirstDTimeObj(),
582   - // _paramObj.getUpLastDtimeObj(),
583   - // false,
584   - // 0,
585   - // _paramObj,
586   - // _factory
587   - //);
588   -
589   - // TODO:问题
590   - // 1、中标线是直接赋值在具体位置的,没有修正班次时间
591   - // 2、路牌间隔时间需要修正的
592   -
593 607 },
594 608  
595   - // TODO:
596   -
597 609 /**
598 610 * 调整高峰班次,
599 611 * 初始化生成早高峰,晚高峰班次并不准确,因为根据高峰时间段,并不在一个完整圈内,应该是在两个或多个圈之间
... ... @@ -657,12 +669,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
657 669 _lpIndex = endBcIndex[0];
658 670 _qIndex = endBcIndex[1];
659 671 _bcIndex = endBcIndex[2];
660   - for (j = 0; j < _lpIndex; j++) {
661   - _lp = _internalLpArray[j];
662   - if (!_lp.getBc(_qIndex, _bcIndex)) {
663   - _generateBcAndSetBc(j, _qIndex, _bcIndex);
664   - }
665   - }
  672 +
666 673 // 删除尾部多余的班次
667 674 for (j = _lpIndex; j < _internalLpArray.length; j++) {
668 675 _lp = _internalLpArray[j];
... ... @@ -670,48 +677,208 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
670 677 _lp.removeBc(_qIndex, _bcIndex);
671 678 }
672 679 }
  680 +
  681 + if (startBcIndex[1] != endBcIndex[1]) { // 指定时间范围跨圈
  682 + for (j = 0; j < _lpIndex; j++) {
  683 + _lp = _internalLpArray[j];
  684 + if (!_lp.getBc(_qIndex, _bcIndex)) {
  685 + _generateBcAndSetBc(j, _qIndex, _bcIndex);
  686 + }
  687 + }
  688 + } else {
  689 + // 不跨圈,不用处理,处理头的时候已经加了
  690 + }
  691 +
673 692 }
674 693  
675 694 },
676 695  
677 696 /**
678   - * 补充做5休2的班型班次。
679   - * 1、做5休2的路牌总工时不能超过7个小时
680   - * 2、5休2的路牌全部从早晚高峰班次开始往前补充1个班次,组成早晚2圈
681   - * 3、再根据余下工时及早晚高峰开始时间,确定向前或者向后加班次
  697 + * 按照营运时间要求补充班次,
  698 + * 早高峰7:45分以前出场运营,
  699 + * 晚高峰16:10分以前出场运营
682 700 */
683   - calcuLpBx_5_2: function() {
684   - // 1、先在早晚高峰班次前加1个班次压压惊
  701 + calcuLpBc_yy: function() {
  702 + // 补班次的时候,针对的是分班班型
685 703 var i;
686   - var _lp;
687   - var _zgfbcpos; // 早高峰班次位置
688   - var _wgfbcpos; // 晚高峰班次位置
  704 + var _oLp;
  705 + var _oBc;
  706 + var _aMinBcIndex;
  707 + var _aMaxBcIndex;
  708 +
689 709 var _qIndex;
690 710 var _bIndex;
691 711  
692   - //for (i = 0; i < _internalLpArray.length; i++) {
693   - // _lp = _internalLpArray[i];
694   - // if (_lp.isBxFb5_2()) {
695   - // _zgfbcpos = _lp.getMinBcObjPosition();
696   - // _wgfbcpos = _lp.getMaxBcObjPosition();
697   - //
698   - // // TODO:测试向前添加一个班次
699   - // _qIndex = _zgfbcpos[0];
700   - // _bIndex = _zgfbcpos[1];
701   - // _bIndex == 0 ?
702   - // _generateBcAndSetBc(i, _qIndex - 1, 1) :
703   - // _generateBcAndSetBc(i, _qIndex, 0);
704   - //
705   - // _qIndex = _wgfbcpos[0];
706   - // _bIndex = _wgfbcpos[1];
707   - // _bIndex == 0 ?
708   - // _generateBcAndSetBc(i, _qIndex - 1, 1) :
709   - // _generateBcAndSetBc(i, _qIndex, 0);
710   - //
711   - // }
712   - //}
713   -
714   - // 2、
  712 + var _zgfCDate = _paramObj.toTimeObj("7:45");
  713 + var _wgfCDate = _paramObj.toTimeObj("16:10");
  714 + var _ccsj;
  715 +
  716 + for (i = 0; i < _internalLpArray.length; i++) {
  717 + _oLp = _internalLpArray[i];
  718 + if (_oLp.isBxFb()) { // 分班路牌
  719 + // 早高峰部分
  720 + _aMinBcIndex = _oLp.getMinBcObjPosition();
  721 + _qIndex = _aMinBcIndex[0];
  722 + _bIndex = _aMinBcIndex[1];
  723 + _oBc = _oLp.getBc(_qIndex, _bIndex);
  724 + if (_qIsUp) {
  725 + _ccsj = _bIndex == 0 ?
  726 + _paramObj.getUpOutTime() :
  727 + _paramObj.getDownOutTime();
  728 + } else {
  729 + _ccsj = _bIndex == 0 ?
  730 + _paramObj.getDownOutTime() :
  731 + _paramObj.getUpOutTime();
  732 + }
  733 + if (_zgfCDate.isBefore(_paramObj.addMinute(_oBc.getFcTimeObj(), -_ccsj))) {
  734 + _generateBcAndSetBc(
  735 + i,
  736 + _bIndex == 0 ? _qIndex - 1 : _qIndex,
  737 + _bIndex == 0 ? 1 : 0
  738 + )
  739 + }
  740 +
  741 + // 晚高峰部分
  742 + _aMaxBcIndex = _oLp.getMaxBcObjPosition();
  743 + _qIndex = _aMaxBcIndex[0];
  744 + _bIndex = _aMaxBcIndex[1];
  745 + _oBc = _oLp.getBc(
  746 + _bIndex == 0 ? _qIndex - 1 : _qIndex,
  747 + _bIndex == 0 ? 1 : 0
  748 + );
  749 + if (!_oBc) { // 前一个班次不存在,再判定加不加
  750 + _oBc = _oLp.getBc(_qIndex, _bIndex);
  751 + if (_qIsUp) {
  752 + _ccsj = _bIndex == 0 ?
  753 + _paramObj.getUpOutTime() :
  754 + _paramObj.getDownOutTime();
  755 + } else {
  756 + _ccsj = _bIndex == 0 ?
  757 + _paramObj.getDownOutTime() :
  758 + _paramObj.getUpOutTime();
  759 + }
  760 + if (_wgfCDate.isBefore(_paramObj.addMinute(_oBc.getFcTimeObj(), -_ccsj))) {
  761 + _generateBcAndSetBc(
  762 + i,
  763 + _bIndex == 0 ? _qIndex - 1 : _qIndex,
  764 + _bIndex == 0 ? 1 : 0
  765 + )
  766 + }
  767 + }
  768 + }
  769 + }
  770 + },
  771 +
  772 + /**
  773 + * 补充做5休2的班型班次。
  774 + * 1、确认5_2班型大致多少圈(小数点过.7进位)
  775 + * 2、获取当前5_2两端车次链的信息,每段的班次数目,还差几个班次没加
  776 + * 3、如果前面的车次链班次少,则从前面的车次链开始加
  777 + * 4、如果车次链班次数一样,从从后面的车次链开始加
  778 + * 5、加班次时都是往车次链前方加
  779 + * 6、如果前面车次链不能再加班次了,从后面车次链加
  780 + */
  781 + calcuLpBx_5_2: function() {
  782 + // 计算做5休2班型所需的班次数
  783 + var iBxBcount = _aBxDesc[6].fBcCount;
  784 + if (iBxBcount - Math.floor(iBxBcount) > 0.7) {
  785 + iBxBcount = Math.floor(iBxBcount) + 1;
  786 + } else {
  787 + iBxBcount = Math.floor(iBxBcount);
  788 + }
  789 +
  790 + var i;
  791 + var j;
  792 + var oLp;
  793 + var iAddBcCount;
  794 + var oBcChain1;
  795 + var oBcChain2;
  796 + var iQindex;
  797 + var iBindex;
  798 +
  799 + for (i = 0; i < _internalLpArray.length; i++) {
  800 + oLp = _internalLpArray[i];
  801 + if (oLp.isBxFb5_2()) {
  802 + iAddBcCount = iBxBcount - oLp.getBcArray().length; // 需要添加的班次数
  803 + for (j = 1; j <= iAddBcCount; j++) {
  804 + oBcChain1 = oLp.fnGetBcChainInfo(0);
  805 + oBcChain2 = oLp.fnGetBcChainInfo(1);
  806 +
  807 + if (oBcChain1.bcount < oBcChain2.bcount) {
  808 + iQindex = oBcChain1.s_b == 0 ? oBcChain1.s_q - 1 : oBcChain1.s_q;
  809 + iBindex = oBcChain1.s_b == 0 ? 1 : 0;
  810 + // 往车次链往前不能加,就往后加
  811 + if (_generateBc(i, iQindex, iBindex)) {
  812 + _generateBcAndSetBc(i, iQindex, iBindex);
  813 + } else {
  814 + iQindex = oBcChain1.e_b == 0 ? oBcChain1.e_q : oBcChain1.e_q + 1;
  815 + iBindex = oBcChain1.e_b == 0 ? 1 : 0;
  816 + _generateBcAndSetBc(i, iQindex, iBindex);
  817 + }
  818 +
  819 + } else if (oBcChain1.bcount > oBcChain2.bcount) {
  820 + iQindex = oBcChain2.s_b == 0 ? oBcChain2.s_q - 1 : oBcChain2.s_q;
  821 + iBindex = oBcChain2.s_b == 0 ? 1 : 0;
  822 + _generateBcAndSetBc(i, iQindex, iBindex);
  823 + } else {
  824 + iQindex = oBcChain2.s_b == 0 ? oBcChain2.s_q - 1 : oBcChain2.s_q;
  825 + iBindex = oBcChain2.s_b == 0 ? 1 : 0;
  826 + _generateBcAndSetBc(i, iQindex, iBindex);
  827 + }
  828 + }
  829 + }
  830 + }
  831 +
  832 + },
  833 +
  834 + /**
  835 + * 补其他分班班型班次。
  836 + * 从车次链的后面开始加
  837 + */
  838 + calcuLpBx_other: function() {
  839 + // TODO:暂时使用做2休1的班型
  840 + // 计算做5休2班型所需的班次数
  841 + var iBxBcount = _aBxDesc[4].fBcCount;
  842 + if (iBxBcount - Math.floor(iBxBcount) > 0.7) {
  843 + iBxBcount = Math.floor(iBxBcount) + 1;
  844 + } else {
  845 + iBxBcount = Math.floor(iBxBcount);
  846 + }
  847 +
  848 + var i;
  849 + var j;
  850 + var oLp;
  851 + var iAddBcCount;
  852 + var oBcChain1;
  853 + var oBcChain2;
  854 + var iQindex;
  855 + var iBindex;
  856 +
  857 + for (i = 0; i < _internalLpArray.length; i++) {
  858 + oLp = _internalLpArray[i];
  859 + if (oLp.isBxFb() && !oLp.isBxFb5_2()) {
  860 + iAddBcCount = iBxBcount - oLp.getBcArray().length; // 需要添加的班次数
  861 + for (j = 1; j <= iAddBcCount; j++) {
  862 + oBcChain1 = oLp.fnGetBcChainInfo(0);
  863 + oBcChain2 = oLp.fnGetBcChainInfo(1);
  864 +
  865 + if (oBcChain1.bcount < oBcChain2.bcount) {
  866 + iQindex = oBcChain1.e_b == 0 ? oBcChain1.e_q : oBcChain1.e_q + 1;
  867 + iBindex = oBcChain1.e_b == 0 ? 1 : 0;
  868 + _generateBcAndSetBc(i, iQindex, iBindex);
  869 + } else if (oBcChain1.bcount > oBcChain2.bcount) {
  870 + iQindex = oBcChain2.e_b == 0 ? oBcChain2.e_q : oBcChain2.e_q + 1;
  871 + iBindex = oBcChain2.e_b == 0 ? 1 : 0;
  872 + _generateBcAndSetBc(i, iQindex, iBindex);
  873 + } else {
  874 + iQindex = oBcChain2.e_b == 0 ? oBcChain2.e_q : oBcChain2.e_q + 1;
  875 + iBindex = oBcChain2.e_b == 0 ? 1 : 0;
  876 + _generateBcAndSetBc(i, iQindex, iBindex);
  877 + }
  878 + }
  879 + }
  880 + }
  881 +
715 882 },
716 883  
717 884 /**
... ... @@ -731,27 +898,46 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
731 898 var _minbcPos;
732 899 var _bcObj;
733 900 var i;
  901 + var j;
  902 + var iTempBcIndex;
734 903 for (i = 0; i < _internalLpArray.length; i++) {
735 904 _lp = _internalLpArray[i];
736 905 if (_lp.isBxLb() && i != 0 && i != _zbx_lpIndex) {
737 906 _minbcPos = _lp.getMinBcObjPosition();
738   - _bcObj = _lp.getBc(_minbcPos[0], _minbcPos[1]);
739   - _zgffcsj = _bcObj.getFcTimeObj();
740   - // 重新初始化连班班型班次
741   - _lp.initDataFromTimeToTime(
742   - _zgffcsj,
743   - _etsj,
744   - _bcObj.isUp(),
745   - _minbcPos[0],
746   - _paramObj,
747   - _factory
748   - );
  907 +
  908 + // 使用纵向分隔补充班次
  909 + iTempBcIndex = _minbcPos[1] == 0 ? 1 : 0;
  910 + j = iTempBcIndex == 0 ? _minbcPos[0] + 1 : _minbcPos[0];
  911 + for (; j < _qCount; j++) {
  912 + while (iTempBcIndex <= 1) {
  913 + _bcObj = _generateBc(i, j, iTempBcIndex);
  914 + if (_bcObj && _bcObj.getFcTimeObj().isBefore(_etsj) && _bcObj.getArrTimeObj().isBefore(_etsj)) {
  915 + _lp.setBc(j, iTempBcIndex, _bcObj);
  916 + }
  917 +
  918 + iTempBcIndex++;
  919 + }
  920 + iTempBcIndex = 0;
  921 +
  922 + }
  923 +
  924 + //_bcObj = _lp.getBc(_minbcPos[0], _minbcPos[1]);
  925 +
  926 + //_zgffcsj = _bcObj.getFcTimeObj();
  927 + //// 重新初始化连班班型班次
  928 + //_lp.initDataFromTimeToTime(
  929 + // _zgffcsj,
  930 + // _etsj,
  931 + // _bcObj.isUp(),
  932 + // _minbcPos[0],
  933 + // _paramObj,
  934 + // _factory
  935 + //);
749 936 }
750 937 }
751 938  
752 939 // 还要补充缺失的班次,差上标线几个班次要往前补上
753 940 var _bccount;
754   - var j;
755 941 var _qIndex;
756 942 var _bIndex;
757 943 // 补上标线到中标线之间的连班路牌的班次
... ... @@ -872,7 +1058,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
872 1058 }
873 1059 }
874 1060  
875   - // 使用上面的分隔比率,分隔5休2班型
  1061 + // 使用上面的分隔比率,分隔其他班型
876 1062 _p1_lpcount = _bx_5_2_fb_lpcount * _p1;
877 1063 _p2_lpcount = _bx_5_2_fb_lpcount * _p2;
878 1064 if (parseInt(_p1_lpcount) != _p1_lpcount) { // 没有整除
... ... @@ -892,7 +1078,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
892 1078 }
893 1079 for (i = 1; i <= _c2; i++) {
894 1080 _internalLpArray[notlbIndexes[_c2_start_index + i * (_c1 + 1)]].setBxLb(false);
895   - _internalLpArray[notlbIndexes[_c2_start_index + i * (_c1 + 1)]].setBxLb(true);
  1081 + _internalLpArray[notlbIndexes[_c2_start_index + i * (_c1 + 1)]].setBxFb(true);
896 1082 _internalLpArray[notlbIndexes[_c2_start_index + i * (_c1 + 1)]].setBxFb5_2(true);
897 1083 _internalLpArray[notlbIndexes[_c2_start_index + i * (_c1 + 1)]].setBxDesc("5休2分班");
898 1084 }
... ... @@ -914,7 +1100,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
914 1100 _internalLpArray[notlbIndexes[_c2_start_index + i * (_c1 + 1)]].setBxDesc("5休2分班");
915 1101 }
916 1102  
917   - //-------------------------- 3、余下班次就是其他分班类型 ----------------------//
  1103 + //-------------------------- 3、余下班次就是5休2类型 ----------------------//
918 1104  
919 1105 for (i = 0; i < notlbIndexes.length; i++) {
920 1106 if (!_internalLpArray[notlbIndexes[i]].isBxFb5_2()) {
... ... @@ -951,26 +1137,438 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
951 1137 console.log("5休2分班路牌indexes=" + _5_2_fbIndexes);
952 1138 },
953 1139  
  1140 + /**
  1141 + * 计算末班车(一般都落在连班班型上,因为按照现在的布局方法,分班路牌不会一直连到最后)。
  1142 + * 1、确定末班车早的班次
  1143 + * 2、从后往前找到与这个班次最匹配的班次的位置(第几个路牌,第几圈,第几个班次),然后覆盖
  1144 + * 3、从第2步找的位置,往上找与另一个末班车匹配的班次位置,然后覆盖
  1145 + */
  1146 + calcuLastBc: function() {
  1147 + //-------------------- 1、确定末班车早的方向,时间 -----------------------//
  1148 + var _oLastTime;
  1149 + var _bLastIsUp;
  1150 + if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) {
  1151 + _oLastTime = _paramObj.getUpLastDtimeObj();
  1152 + _bLastIsUp = true;
  1153 + } else {
  1154 + _oLastTime = _paramObj.getDownLastDTimeObj();
  1155 + _bLastIsUp = false;
  1156 + }
  1157 +
  1158 + //-------------------- 2、确定比 _oLastTime 小或者等于的班次位置,并修改班次时间到末班车时间 -----------------//
  1159 + var i;
  1160 + var j;
  1161 + var _oBc;
  1162 + var _oLp;
  1163 + var _aBcIndex;
  1164 +
  1165 + for (i = _qCount - 1; i >= 0; i--) {
  1166 + if (_aBcIndex) {
  1167 + break;
  1168 + }
  1169 + // 从大到小找到第一个合适的班次索引
  1170 + for (j = _internalLpArray.length - 1; j >= 0; j--) {
  1171 + _oLp = _internalLpArray[j];
  1172 + if (_oLp.isBxLb()) {
  1173 + _oBc = _oLp.getBc(i, _qIsUp == _bLastIsUp ? 0 : 1);
  1174 + }
  1175 + if (_oBc != undefined && _oBc.getFcTimeObj().isBefore(_oLastTime)) {
  1176 + _aBcIndex = [];
  1177 + _aBcIndex.push(j); // 路牌索引
  1178 + _aBcIndex.push(i); // 圈索引
  1179 + _aBcIndex.push(_qIsUp == _bLastIsUp ? 0 : 1); // 班次索引
  1180 + break;
  1181 + }
  1182 + }
  1183 + }
  1184 +
  1185 + //-------------------- 3、预估哪个个班次离末班最近,用末班替换,并删除后面的多余班次 -----------------//
  1186 + // 第2步找到的班次不一定是最适合的,需要把之后的班次模拟出来再比较一下
  1187 + var _aBcIndexes = []; // 里面放对象 {lpIndex,qIndex,bcIndex,fcsjTime}
  1188 + _oBc = undefined;
  1189 + for (i = _aBcIndex[0]; i < _internalLpArray.length; i++) {
  1190 + _oLp = _internalLpArray[i];
  1191 + if (_oLp.isBxLb()) {
  1192 + _oBc = _oLp.getBc(_aBcIndex[1], _aBcIndex[2]);
  1193 + if (_oBc == undefined) {
  1194 + _oBc = _generateBc(i, _aBcIndex[1], _aBcIndex[2]);
  1195 + }
  1196 + _aBcIndexes.push({
  1197 + lpIndex: i,
  1198 + qIndex: _aBcIndex[1],
  1199 + bcIndex: _aBcIndex[2],
  1200 + bcObj: _oBc
  1201 + })
  1202 + }
  1203 + }
  1204 + var _oBcIndex_find; // 第几个路牌离末班车最近
  1205 + for (i = _aBcIndexes.length - 1; i >= 0; i--) {
  1206 + if (_aBcIndexes[i].bcObj.getFcTimeObj().isBefore(_oLastTime)) {
  1207 + _oBcIndex_find = _aBcIndexes[i];
  1208 + break;
  1209 + }
  1210 + }
  1211 + // 替换成末班车
  1212 + _oBc = _oBcIndex_find.bcObj;
  1213 + _oBc.addMinuteToFcsj(_oLastTime.diff(_oBc.getFcTimeObj(), "m"));
  1214 + _internalLpArray[_oBcIndex_find.lpIndex].setBc(
  1215 + _oBcIndex_find.qIndex, _oBcIndex_find.bcIndex, _oBc
  1216 + );
  1217 +
  1218 + // 删除多余班次呢
  1219 + for (i = _oBcIndex_find.lpIndex + 1; i < _internalLpArray.length; i++) {
  1220 + _internalLpArray[i].removeBc(_oBcIndex_find.qIndex, _oBcIndex_find.bcIndex);
  1221 + }
  1222 +
  1223 + //---------------------- 4、从第3步找到的位置,开始往上找,确定另一个末班车,并删除后面多余的班次 -------------//
  1224 + // 因为另一个末班车时间晚,肯定在后面,并且必须在之前的路牌
  1225 + // 如果在之后的路牌,则意味着之前那个末班车位置不对,连班连起来会有两个之前的末班车
  1226 + // 计算大的末班车时间
  1227 + if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) {
  1228 + _oLastTime = _paramObj.getDownLastDTimeObj();
  1229 + _bLastIsUp = false;
  1230 + } else {
  1231 + _oLastTime = _paramObj.getUpLastDtimeObj();
  1232 + _bLastIsUp = true;
  1233 + }
  1234 + _aBcIndexes = [];
  1235 + for (i = _oBcIndex_find.lpIndex; i >=0; i--) {
  1236 + _oLp = _internalLpArray[i];
  1237 + if (_oLp.isBxLb()) {
  1238 + _oBc = _oLp.getBc(
  1239 + _oBcIndex_find.bcIndex == 0 ? _oBcIndex_find.qIndex : _oBcIndex_find.qIndex + 1,
  1240 + _oBcIndex_find.bcIndex == 0 ? 1 : 0
  1241 + );
  1242 + if (_oBc == undefined) {
  1243 + _oBc = _generateBc(
  1244 + i,
  1245 + _oBcIndex_find.bcIndex == 0 ? _oBcIndex_find.qIndex : _oBcIndex_find.qIndex + 1,
  1246 + _oBcIndex_find.bcIndex == 0 ? 1 : 0
  1247 + );
  1248 + }
  1249 + if (!_oBc) { // 纵向生成班次失败,用横向生成班次,发车时间取前一班次的到达时间加停战时间
  1250 + _oBc = _factory.createBcObj(
  1251 + _oLp,
  1252 + "normal",
  1253 + _bLastIsUp,
  1254 + 3,
  1255 + _oLp.getBc(_oBcIndex_find.qIndex, _oBcIndex_find.bcIndex).getArrTimeObj(),
  1256 + _paramObj
  1257 + );
  1258 +
  1259 + }
  1260 + _aBcIndexes.push({
  1261 + lpIndex: i,
  1262 + qIndex: _oBcIndex_find.bcIndex == 0 ? _oBcIndex_find.qIndex : _oBcIndex_find.qIndex + 1,
  1263 + bcIndex: _oBcIndex_find.bcIndex == 0 ? 1 : 0,
  1264 + bcObj: _oBc
  1265 + })
  1266 + }
  1267 + }
  1268 +
  1269 + console.log(_aBcIndexes);
  1270 +
  1271 + _oBcIndex_find = _aBcIndexes[0];
  1272 +
  1273 + for (i = 0; i < _aBcIndexes.length; i++) {
  1274 + if (_aBcIndexes[i].bcObj.getFcTimeObj().isBefore(_oLastTime)) {
  1275 + _oBcIndex_find = _aBcIndexes[i];
  1276 + break;
  1277 + }
  1278 + }
  1279 + // 替换成末班车
  1280 + _oBc = _oBcIndex_find.bcObj;
  1281 + _oBc.addMinuteToFcsj(_oLastTime.diff(_oBc.getFcTimeObj(), "m"));
  1282 + _internalLpArray[_oBcIndex_find.lpIndex].setBc(
  1283 + _oBcIndex_find.qIndex, _oBcIndex_find.bcIndex, _oBc
  1284 + );
  1285 +
  1286 + // 删除多余班次呢
  1287 + for (i = _oBcIndex_find.lpIndex + 1; i < _internalLpArray.length; i++) {
  1288 + _internalLpArray[i].removeBc(_oBcIndex_find.qIndex, _oBcIndex_find.bcIndex);
  1289 + }
  1290 +
  1291 +
  1292 + },
  1293 +
  1294 + /**
  1295 + * 添加吃饭班次。
  1296 + */
  1297 + calcuEatBc: function() {
  1298 + // 吃午饭时间范围,10:15 到 12:15
  1299 + // 吃晚饭时间范围,18:00 到 19:00
  1300 +
  1301 + if (!_paramObj.fnIsEat()) {
  1302 + return;
  1303 + }
  1304 +
  1305 + // 午饭index
  1306 + var aLEIndex;
  1307 + // 晚饭index
  1308 + var aDEIndex;
  1309 +
  1310 + // 所有吃饭都默认在一个方向,两个方向暂时不考虑
  1311 + if (_paramObj.fnIsUpEat()) {
  1312 + aLEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("10:15"), true, false);
  1313 + aDEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("18:00"), true, false);
  1314 + } else {
  1315 + aLEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("10:15"), false, true);
  1316 + aDEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("18:00"), false, true);
  1317 + }
  1318 +
  1319 + // 午饭第几圈,第几个班次
  1320 + var iLEQIndex = aLEIndex[0];
  1321 + var iLEBIndex = aLEIndex[1];
  1322 + // 晚饭第几圈,第几个班次
  1323 + var iDEQIndex = aDEIndex[0];
  1324 + var iDEBIndex = aDEIndex[1];
  1325 +
  1326 + // 注意,本模型只有连班才有吃饭
  1327 +
  1328 + var i;
  1329 + var oLp;
  1330 + var aLbIndex = []; // 连班班型的路牌索引
  1331 + for (i = 0; i < _internalLpArray.length; i++) {
  1332 + oLp = _internalLpArray[i];
  1333 + if (oLp.isBxLb()) {
  1334 + aLbIndex.push(i);
  1335 + }
  1336 + }
  1337 +
  1338 + var iLTime;
  1339 + var iDtime;
  1340 + var j;
  1341 + for (i = 0; i < aLbIndex.length; i++) {
  1342 + oLp = _internalLpArray[aLbIndex[i]];
  1343 +
  1344 + // 午饭
  1345 + iLTime = oLp.fnAddEatBc(iLEQIndex, iLEBIndex, _factory, _paramObj);
  1346 + // 晚饭
  1347 + iDtime = oLp.fnAddEatBc(iDEQIndex, iDEBIndex, _factory, _paramObj);
  1348 +
  1349 + if (i == aLbIndex.length - 1) {
  1350 + for (j = aLbIndex[i]; j < _internalLpArray.length; j++) {
  1351 + oLp = _internalLpArray[j];
  1352 + if (oLp.isBxFb()) {
  1353 + // 修正午饭之后路牌班次的发车时间
  1354 + oLp.fnAddMinuteToBcFcsj(iLEQIndex, iLEBIndex, iLTime);
  1355 + oLp.fnAddMinuteToBcFcsj(iDEQIndex, iDEBIndex, iDtime);
  1356 + }
  1357 + }
  1358 + } else {
  1359 + for (j = aLbIndex[i]; j < aLbIndex[i + 1]; j++) {
  1360 + oLp = _internalLpArray[j];
  1361 + if (oLp.isBxFb()) {
  1362 + // 修正午饭之后路牌班次的发车时间
  1363 + oLp.fnAddMinuteToBcFcsj(iLEQIndex, iLEBIndex, iLTime);
  1364 + oLp.fnAddMinuteToBcFcsj(iDEQIndex, iDEBIndex, iDtime);
  1365 + }
  1366 + }
  1367 + }
  1368 + }
  1369 +
  1370 + },
  1371 +
  1372 + /**
  1373 + * 补每个路牌的其他班次(进出场,例保班次)。
  1374 + */
  1375 + calcuOtherBc: function() {
  1376 + var i;
  1377 + var _lpObj;
  1378 + var _minBcIndex;
  1379 + var _maxBcIndex;
  1380 + var _minBc;
  1381 + var _maxBc;
  1382 + var _otherbc = [];
  1383 +
  1384 + for (i = 0; i < _internalLpArray.length; i++) {
  1385 + _lpObj = _internalLpArray[i];
  1386 + _minBcIndex = _lpObj.getMinBcObjPosition();
  1387 + _maxBcIndex = _lpObj.getMaxBcObjPosition();
  1388 + _minBc = _lpObj.getBc(_minBcIndex[0], _minBcIndex[1]);
  1389 + _maxBc = _lpObj.getBc(_maxBcIndex[0], _maxBcIndex[1]);
  1390 +
  1391 + _otherbc = [];
  1392 + //_otherbc.push(_factory.createBcObj(
  1393 + // _lpObj, "bd", true, 1,
  1394 + // _minBc.getFcTimeObj(),
  1395 + // _paramObj
  1396 + //));
  1397 + _otherbc.push(_factory.createBcObj(
  1398 + _lpObj, "out", true, 1,
  1399 + _minBc.getFcTimeObj(),
  1400 + _paramObj
  1401 + ));
  1402 + _maxBc.setStopTime(0);
  1403 + _otherbc.push(_factory.createBcObj(
  1404 + _lpObj, "in", true, 1,
  1405 + _maxBc.getArrTimeObj(),
  1406 + _paramObj
  1407 + ));
  1408 + //_otherbc.push(_factory.createBcObj(
  1409 + // _lpObj, "lc", true, 1,
  1410 + // _maxBc.getArrTimeObj(),
  1411 + // _paramObj
  1412 + //));
  1413 +
  1414 + _lpObj.addOtherBcArray(_otherbc);
  1415 + }
  1416 +
  1417 + },
  1418 +
  1419 + /**
  1420 + * 调整班次纵向间隔(发车时间调整)。
  1421 + * 1、只调整分班班次的发车时间
  1422 + * 2、调整每两个连班之间的分班班次组
  1423 + * 3、如果不是连续的班次才调整
  1424 + */
  1425 + fnAdjust_vertical_bc_interval: function() {
  1426 + var i;
  1427 + var j;
  1428 + var iBIndex = 0;
  1429 + var oLbGroup = {};
  1430 + var oLp;
  1431 + for (i = 0; i < _qCount; i++) {
  1432 + while (iBIndex <= 1) {
  1433 + oLbGroup[i + "_" + iBIndex] = [];
  1434 + for (j = 0; j < _internalLpArray.length; j++) {
  1435 + oLp = _internalLpArray[j];
  1436 + if (oLp.isBxLb()) {
  1437 + if (oLp.getBc(i, iBIndex)) {
  1438 + oLbGroup[i + "_" + iBIndex].push(j);
  1439 + }
  1440 + }
  1441 + }
  1442 + if (oLbGroup[i + "_" + iBIndex].length == 1) {
  1443 + oLbGroup[i + "_" + iBIndex] = [];
  1444 + }
  1445 +
  1446 + iBIndex ++;
  1447 + }
  1448 + iBIndex = 0;
  1449 + }
  1450 +
  1451 + //console.log(oLbGroup);
  1452 +
  1453 + var sKey;
  1454 + var iQindex;
  1455 + var iBindex;
  1456 + var aBcLb = [];
  1457 +
  1458 + var oLbGroup_m = {};
  1459 + var aLbGroup = [];
  1460 +
  1461 +
  1462 + // 计算需要调整的连班区间
  1463 + for (sKey in oLbGroup) {
  1464 + iQindex = sKey.split('_')[0];
  1465 + iBindex = sKey.split('_')[1];
  1466 + oLbGroup_m[sKey] = [];
  1467 + for (i = 0; i < oLbGroup[sKey].length - 1; i++) {
  1468 + aBcLb = [];
  1469 + for (j = oLbGroup[sKey][i] + 1; j <= oLbGroup[sKey][i + 1] - 1; j++) {
  1470 + oLp = _internalLpArray[j];
  1471 + if (oLp.getBc(iQindex, iBindex)) {
  1472 + aBcLb.push(j);
  1473 + }
  1474 + }
  1475 + if (aBcLb.length != 0 && aBcLb.length < (oLbGroup[sKey][i + 1] - oLbGroup[sKey][i] - 1)) {
  1476 + aLbGroup = [];
  1477 + aLbGroup.push(oLbGroup[sKey][i]);
  1478 + aLbGroup.push(oLbGroup[sKey][i + 1]);
  1479 + aLbGroup.push(aBcLb);
  1480 + oLbGroup_m[sKey].push(aLbGroup);
  1481 + }
  1482 + }
  1483 + }
  1484 +
  1485 + console.log(oLbGroup_m);
  1486 +
  1487 + var iStartLpIndex;
  1488 + var iEndLpIndex;
  1489 + var iDCount;
  1490 + var iDiffTime;
  1491 +
  1492 + var iC1;
  1493 + var iC2;
  1494 + var oKssj;
  1495 +
  1496 + for (sKey in oLbGroup_m) {
  1497 + iQindex = sKey.split('_')[0];
  1498 + iBindex = sKey.split('_')[1];
  1499 +
  1500 + for (i = 0; i < oLbGroup_m[sKey].length; i++) {
  1501 + aLbGroup = oLbGroup_m[sKey][i];
  1502 +
  1503 + iStartLpIndex = aLbGroup[0];
  1504 + iEndLpIndex = aLbGroup[1];
  1505 + iDCount = aLbGroup[2].length + 1;
  1506 +
  1507 + iDiffTime = _internalLpArray[iEndLpIndex].getBc(iQindex, iBindex).getFcTimeObj().diff(
  1508 + _internalLpArray[iStartLpIndex].getBc(iQindex, iBindex).getFcTimeObj(), 'm');
  1509 +
  1510 + iC1 = Math.floor(iDiffTime / iDCount);
  1511 + iC2 = iDiffTime % iDCount;
  1512 + oKssj = _internalLpArray[iStartLpIndex].getBc(iQindex, iBindex).getFcTimeObj();
  1513 +
  1514 + for (j = 1; j <= iDCount - iC2; j++) {
  1515 + if (j - 1 < aLbGroup[2].length) {
  1516 + oKssj = _paramObj.addMinute(oKssj, iC1);
  1517 + _internalLpArray[aLbGroup[2][j - 1]].getBc(
  1518 + iQindex, iBindex).setFcTimeObj(oKssj);
  1519 + }
  1520 + }
  1521 +
  1522 + for (j = 1; j < iC2; j++) {
  1523 + oKssj = _paramObj.addMinute(oKssj, iC1 + 1);
  1524 + _internalLpArray[aLbGroup[2][iDCount - iC2 + j - 1]].getBc(
  1525 + iQindex, iBindex).setFcTimeObj(oKssj);
  1526 + }
  1527 +
  1528 + }
  1529 + }
  1530 +
  1531 + },
  1532 +
954 1533 //------------- 其他方法 -------------//
955 1534 /**
956 1535 * 内部数据转化成显示用的班次数组。
957 1536 */
958   - toGanttBcArray: function() {
959   - var bcData = [];
960   - var lpObj;
  1537 + fnToGanttBcArray: function() {
  1538 + var aAllBc = [];
  1539 + var aLpBc = [];
  1540 + var oLp;
  1541 + var i;
  1542 + var j;
  1543 +
961 1544 for (i = 0; i < _internalLpArray.length; i++) {
962   - lpObj = _internalLpArray[i];
963   - bcData = bcData.concat(lpObj.getBcArray());
  1545 + oLp = _internalLpArray[i];
  1546 + aLpBc = [];
  1547 + aLpBc = aLpBc.concat(oLp.getOtherBcArray(), oLp.getBcArray());
  1548 + // 按照发车时间排序
  1549 + aLpBc.sort(function(o1, o2) {
  1550 + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) {
  1551 + return -1;
  1552 + } else {
  1553 + return 1;
  1554 + }
  1555 + });
  1556 +
  1557 + // 重新赋值fcno
  1558 + for (j = 0; j < aLpBc.length; j++) {
  1559 + aLpBc[j].fnSetFcno(j + 1);
  1560 + }
  1561 +
  1562 + aAllBc = aAllBc.concat(aLpBc);
964 1563 }
965 1564  
966   - var ganttBcData = [];
967   - for (i = 0; i < bcData.length; i++) {
968   - ganttBcData.push(bcData[i].toGanttBcObj());
  1565 + var aGanttBc = [];
  1566 + for (i = 0; i < aAllBc.length; i++) {
  1567 + aGanttBc.push(aAllBc[i].toGanttBcObj());
969 1568 }
970 1569  
971   - return ganttBcData;
  1570 + return aGanttBc;
972 1571 }
973 1572  
974   - // TODO:
975 1573 };
976 1574 };
977 1575 \ No newline at end of file
... ...
src/main/resources/static/pages/base/timesmodel/js/v2/main_v2.js
... ... @@ -2,6 +2,7 @@
2 2 * 主类。
3 3 */
4 4 var Main_v2 = function() {
  5 +
5 6 // 内部工厂类
6 7 var _factoryFun = function() {
7 8 return {
... ... @@ -14,8 +15,9 @@ var Main_v2 = function() {
14 15 // 创建班次对象
15 16 createBcObj: function(lpObj, bcType, isUp, fcno, fcTimeObj, paramObj) {
16 17 var _bclc = paramObj.calcuTravelLcNumber(isUp, bcType);
17   - var _bcsj = paramObj.calcuTravelTime(fcTimeObj, isUp);
18   - var _arrsj = paramObj.addMinute(fcTimeObj, _bcsj);
  18 + var _fcsj = fcTimeObj;
  19 + var _bcsj = paramObj.calcuTravelTime(_fcsj, isUp);
  20 + var _arrsj = paramObj.addMinute(_fcsj, _bcsj);
19 21 var _stoptime = paramObj.calcuFixedStopNumber(_arrsj, !isUp);
20 22 var _tccid = paramObj.getTTinfoId();
21 23 var _ttinfoid = paramObj.getTTinfoId();
... ... @@ -23,11 +25,80 @@ var Main_v2 = function() {
23 25 var _qdz = isUp ? paramObj.getUpQdzObj().id : paramObj.getDownQdzObj().id;
24 26 var _zdz = isUp ? paramObj.getUpZdzObj().id : paramObj.getDownZdzObj().id;
25 27  
  28 + if (bcType == "bd") { // 早例保,传过来的发车时间是第一个班次的发车时间
  29 + if (isUp) { // 上行
  30 + _fcsj = paramObj.addMinute(
  31 + _fcsj,
  32 + -(paramObj.getUpOutTime() + paramObj.getLbTime()));
  33 + _bcsj = paramObj.getLbTime();
  34 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  35 + _stoptime = 0;
  36 + } else { // 下行
  37 + _fcsj = paramObj.addMinute(
  38 + _fcsj,
  39 + -(paramObj.getDownOutTime() + paramObj.getLbTime()));
  40 + _bcsj = paramObj.getLbTime();
  41 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  42 + _stoptime = 0;
  43 + }
  44 + } else if (bcType == "lc") { // 晚例保,传过来的发车时间是最后一个班次的到达时间
  45 + if (isUp) { // 上行
  46 + _fcsj = paramObj.addMinute(
  47 + _fcsj,
  48 + paramObj.getUpInTime());
  49 + _bcsj = paramObj.getLbTime();
  50 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  51 + _stoptime = 0;
  52 + } else { // 下行
  53 + _fcsj = paramObj.addMinute(
  54 + _fcsj,
  55 + paramObj.getDownInTime());
  56 + _bcsj = paramObj.getLbTime();
  57 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  58 + _stoptime = 0;
  59 + }
  60 + } else if (bcType == "out") { // 出场,传过来的发车时间是第一个班次的发车时间
  61 + if (isUp) { // 上行
  62 + _fcsj = paramObj.addMinute(
  63 + _fcsj,
  64 + -paramObj.getUpOutTime());
  65 + _bcsj = paramObj.getUpOutTime();
  66 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  67 + _stoptime = 0;
  68 + } else { // 下行
  69 + _fcsj = paramObj.addMinute(
  70 + _fcsj,
  71 + -paramObj.getDownOutTime());
  72 + _bcsj = paramObj.getDownOutTime();
  73 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  74 + _stoptime = 0;
  75 + }
  76 + } else if (bcType == "in") { // 进场,传过来的发车时间是最后一个班次的到达时间
  77 + if (isUp) { // 上行
  78 + _bcsj = paramObj.getUpInTime();
  79 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  80 + _stoptime = 0;
  81 + } else { // 下行
  82 + _bcsj = paramObj.getDownInTime();
  83 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  84 + _stoptime = 0;
  85 + }
  86 + } else if (bcType == "cf") { // 吃饭班次
  87 + // 以13:00为分界,之前的为午饭,之后的为晚饭
  88 + if (fcTimeObj.isBefore(paramObj.toTimeObj("13:00"))) {
  89 + _bcsj = paramObj.fnGetLunchTime();
  90 + } else {
  91 + _bcsj = paramObj.fnGetDinnerTime();
  92 + }
  93 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  94 + _stoptime = 0;
  95 + }
  96 +
26 97 var bcParamObj = {};
27   - bcParamObj.bcType = bcType; // 班次类型(normal,in,out等)
  98 + bcParamObj.bcType = bcType; // 班次类型(normal,in_,out, bd, lc, cf等)
28 99 bcParamObj.isUp = isUp; // boolean是否上下行
29 100 bcParamObj.fcno = fcno; // 发车顺序号
30   - bcParamObj.fcTimeObj = fcTimeObj; // 发车时间对象
  101 + bcParamObj.fcTimeObj = _fcsj; // 发车时间对象
31 102 bcParamObj.bclc = _bclc; // 班次里程
32 103 bcParamObj.bcsj = _bcsj; // 班次历时
33 104 bcParamObj.arrtime = _arrsj; // 到达时间对象
... ... @@ -92,18 +163,29 @@ var Main_v2 = function() {
92 163 schedule.adjustGfbc(false, true); // 修正上行晚高峰
93 164 schedule.adjustGfbc(false, false); // 修正下行晚高峰
94 165  
95   - // 5、TODO:根据班型补充所有的不足班次
  166 + // 5、按照车辆投入运营要求补充班次
  167 + schedule.calcuLpBc_yy();
  168 +
  169 + // 6、根据班型补充所有的不足班次
96 170 schedule.calcuLpBx_5_2();
  171 + schedule.calcuLpBx_other();
  172 +
  173 + // 7、补吃饭班次
  174 + schedule.calcuEatBc();
97 175  
98   - // TODO:6、确定末班车
  176 + // 8、调整纵向班次间隔
  177 + schedule.fnAdjust_vertical_bc_interval();
  178 + // TODO:横向调整
99 179  
100   - // TODO:8、修正不准确的停站时间,微调发车间隔
  180 + // 9、确定末班车
  181 + schedule.calcuLastBc();
101 182  
102   - // TODO:9、补进出场报道班次
103 183  
  184 + // 10、补进出场例保班次
  185 + schedule.calcuOtherBc();
104 186  
105 187 //-------------------- 输出ganut图上的班次,班型描述 ----------------------//
106   - var gBcData = schedule.toGanttBcArray();
  188 + var gBcData = schedule.fnToGanttBcArray();
107 189 // TODO:班型再议
108 190 return {'json':gBcData,'bxrcgs':null};
109 191  
... ...
src/main/resources/static/pages/base/timesmodel/js/v3/core/timetable_bc_obj.js 0 → 100644
  1 +/**
  2 + * 时刻表内部班次对象。
  3 + * @param iLpIndex 路牌索引
  4 + * @param iGroupIndex 圈索引
  5 + * @param oParam 其他参数对象
  6 + * @constructor
  7 + */
  8 +var TimeTableBc = function(
  9 + iLpIndex,
  10 + iGroupIndex,
  11 + oParam
  12 +) {
  13 + // 简单验证
  14 + if (isNaN(iLpIndex)) {
  15 + throw "new TimeTableBc 路牌索引" + iLpIndex + " 不是int";
  16 + }
  17 + if (isNaN(iGroupIndex)) {
  18 + throw "new TimeTableBc 圈索引" + iGroupIndex + " 不是int";
  19 + }
  20 + if (typeof oParam == "undefined") {
  21 + throw "new TimeTableBc 其他参数对象" + oParam + " 未定义";
  22 + }
  23 +
  24 + /** 路牌索引 */
  25 + this._$_iLpIndex = iLpIndex;
  26 + /** 圈索引 */
  27 + this._$_iGroupIndex = iGroupIndex;
  28 +
  29 + // 其他参数对象关联的内部参数
  30 +
  31 + /** 班次类型(normal,in,out等) */
  32 + this._$_sBcType = otherParamObj.bcType;
  33 + /** 是否上下行 */
  34 + this._$_bIsUp = otherParamObj.isUp;
  35 + /** 发车顺序号 */
  36 + this._$_iFcno = otherParamObj.fcno;
  37 + /** 发车时间对象 */
  38 + this._$_oFcsjObj = moment(otherParamObj.fcTimeObj);
  39 + /** 班次里程 */
  40 + this._$_flBclc = otherParamObj.bclc;
  41 + /** 班次历时 */
  42 + this._$_iBcsj = otherParamObj.bcsj;
  43 + /** 到达时间对象 */
  44 + this._$_oArrtime = otherParamObj.arrtime;
  45 + /** 停站时间 */
  46 + this._$_iStoptime = otherParamObj.stoptime;
  47 + /** 停车场id */
  48 + this._$_iTccid = otherParamObj.tccid;
  49 + /** 时刻表id */
  50 + this._$_iTtinfoid = otherParamObj.ttinfoid;
  51 + /** 线路id */
  52 + this._$_iXlid = otherParamObj.xl;
  53 + /** 起点站id */
  54 + this._$_iQdzid = otherParamObj.qdzid;
  55 + /** 终点站id */
  56 + this._$_iZdzid = otherParamObj.zdzid;
  57 +
  58 +};
  59 +
  60 +// TODO
0 61 \ No newline at end of file
... ...
src/main/resources/static/pages/base/timesmodel/js/v3/core/timetable_group_obj.js 0 → 100644
  1 +
  2 +// TODO
  3 +var TimeTableGroup = function() {
  4 +
  5 + /** 一圈几个班次(2个) */
  6 + this._$_iUnitBcCount = 2;
  7 + /** 是否上行(指圈的第一个班次是否上行) */
  8 + this._$_bIsUp;
  9 +
  10 + /** 圈组的开始时间(初始化一般由上标线确定,如:06:00,开始时间计算时是闭区间) */
  11 + this._$_oUnitGroupStartTime;
  12 + /** 圈组的结束时间(初始化一般由上标线确定,如:08:41,结束时间计算时是开区间) */
  13 + this._$_oUnitGroupEndTime;
  14 +
  15 + /** 圈组里圈班次可能的总数目(初始化确定,有几个路牌,一个圈组就有几圈-纵向看) */
  16 + this._$_iAllUnitCount;
  17 + /** 圈组里所有可能班次数组(二维数组,行一班表示有几个路牌,列就表示一圈2个班次) */
  18 + this._$_aAllUnitBces = new Array(this._$_iAllUnitBcCount, this._$_iUnitBcCount);
  19 +
  20 + /** 圈组里每圈之间的发车间隔值数组(第一个间隔为0,上下行一样) */
  21 + this._$_aUnitIntervalTime = new Array(this._$_iAllUnitCount);
  22 +
  23 + // TODO
  24 +};
  25 +
  26 +// TODO
0 27 \ No newline at end of file
... ...
src/main/resources/static/pages/base/timesmodel/js/v3/core/timetable_lp_obj.js 0 → 100644
  1 +
  2 +
  3 +// TODO
  4 +var TimeTableLp = function() {
  5 +
  6 + /** 班次可能的总数目(初始化确定) */
  7 + this._$_iAllBcCount;
  8 + /** 所有可能班次数组 */
  9 + this._$_aAllBces = new Array(this._$_iAllBcCount);
  10 +
  11 + /** 车次链的个数 */
  12 + this._$_iBcChainCount;
  13 + /** 车次链数组(每个车次链又是一个数组) */
  14 + this._$_aBcChaines;
  15 +
  16 + // TODO
  17 +};
  18 +
  19 +// TODO
0 20 \ No newline at end of file
... ...
src/main/resources/static/pages/base/timesmodel/js/v3/core/timetable_schedule_obj.js 0 → 100644
src/main/resources/static/pages/base/timesmodel/js/v3/main.js 0 → 100644
src/main/resources/static/pages/base/timesmodel/js/v3/param/param_wrap.js 0 → 100644