Commit 100a7c1fc493209688ff878442600ffa5bf2c00e
1 parent
96762b5a
时刻表v2.7.4
1、修改时刻表导出格式,分班进场后加标识X,停驶后加标识※,分班出场前加标识出,加报到班次前加标识报 2、路牌添加路牌统计字段,总工时,营业公里,空驶公里,总工时,营业工时,营运班次 3、POIUtils里的创建double单元格的dataformat格式,默认0.00
Showing
4 changed files
with
2414 additions
and
2277 deletions
Too many changes to show.
To preserve performance only 4 of 5 files are displayed.
src/main/java/com/bsth/service/schedule/datatools/TTInfoDetailDataToolsImpl.java
| ... | ... | @@ -556,15 +556,33 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail |
| 556 | 556 | Station station1 = stationService.findById(lpObjList.get(0).getStationRouteId1()); |
| 557 | 557 | Station station2 = stationService.findById(lpObjList.get(1).getStationRouteId2()); |
| 558 | 558 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (1), |
| 559 | + "报到", new Color(0x96b9d7)); | |
| 560 | + PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (2), | |
| 559 | 561 | "出场", new Color(0x96b9d7)); |
| 560 | 562 | for (int i = 1; i <= groupCount; i++) { |
| 561 | - PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (i * 2), | |
| 562 | - station1.getStationName(), new Color(0x96b9d7)); | |
| 563 | 563 | PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (i * 2 + 1), |
| 564 | + station1.getStationName(), new Color(0x96b9d7)); | |
| 565 | + PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (i * 2 + 2), | |
| 564 | 566 | station2.getStationName(), new Color(0x96b9d7)); |
| 565 | 567 | } |
| 566 | - PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 2), | |
| 568 | + PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 3), | |
| 567 | 569 | "进场", new Color(0x96b9d7)); |
| 570 | + PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 4), | |
| 571 | + "离场", new Color(0x96b9d7)); | |
| 572 | + | |
| 573 | + // 路牌统计字段 | |
| 574 | + PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 5), | |
| 575 | + "总公里", new Color(0x96b9d7)); | |
| 576 | + PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 6), | |
| 577 | + "营业公里", new Color(0x96b9d7)); | |
| 578 | + PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 7), | |
| 579 | + "空驶公里", new Color(0x96b9d7)); | |
| 580 | + PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 8), | |
| 581 | + "总工时", new Color(0x96b9d7)); | |
| 582 | + PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 9), | |
| 583 | + "营业工时", new Color(0x96b9d7)); | |
| 584 | + PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 10), | |
| 585 | + "营运班次", new Color(0x96b9d7)); | |
| 568 | 586 | |
| 569 | 587 | // 构建每个路牌的班次数据 |
| 570 | 588 | for (int i = 0; i < lpObjList.size(); i++) { |
| ... | ... | @@ -572,34 +590,86 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail |
| 572 | 590 | XSSFRow lpRow = sheet.createRow((short) (i + 1)); |
| 573 | 591 | PoiUtils.createStringXSSFCell(wb, lpRow, (short) 0, lpObj.getLpname()); |
| 574 | 592 | PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (1)); |
| 593 | + PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (2)); | |
| 575 | 594 | for (int j = 1; j <= groupCount; j++) { |
| 576 | - PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (j * 2)); | |
| 577 | 595 | PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (j * 2 + 1)); |
| 596 | + PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (j * 2 + 2)); | |
| 578 | 597 | } |
| 579 | - PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (groupCount * 2 + 2)); | |
| 598 | + | |
| 599 | + PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (groupCount * 2 + 3)); | |
| 600 | + PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (groupCount * 2 + 4)); | |
| 580 | 601 | |
| 581 | 602 | for (BcObj bcObj : lpObj.getBcObjList()) { |
| 582 | 603 | if (bcObj.getBcType() == BcType.NORMAL) { |
| 583 | - Cell cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 2)); | |
| 604 | + Cell cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 3)); | |
| 584 | 605 | cell.setCellValue(bcObj.getFcsj()); |
| 606 | + | |
| 607 | + } else if (bcObj.getBcType() == BcType.BD) { | |
| 608 | + if (bcObj.getGroupNo() == -1) { | |
| 609 | + Cell cell = lpRow.getCell((short) 1); | |
| 610 | + cell.setCellValue(bcObj.getFcsj()); | |
| 611 | + } else if (bcObj.getGroupNo() > 0) { // 分班报到 | |
| 612 | + Cell cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 3)); | |
| 613 | + cell.setCellValue("报" + bcObj.getFcsj()); | |
| 614 | + | |
| 615 | + } | |
| 616 | + | |
| 585 | 617 | } else if (bcObj.getBcType() == BcType.OUT) { |
| 586 | - Cell cell = lpRow.getCell((short) (1)); | |
| 587 | - cell.setCellValue(bcObj.getFcsj()); | |
| 618 | + if (bcObj.getGroupNo() == -1) { | |
| 619 | + Cell cell = lpRow.getCell((short) (2)); | |
| 620 | + cell.setCellValue(bcObj.getFcsj()); | |
| 621 | + } else if (bcObj.getGroupNo() > 0) { // 分班出场 | |
| 622 | + Cell cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 3)); | |
| 623 | + cell.setCellValue("出" + bcObj.getFcsj()); | |
| 624 | + } | |
| 625 | + | |
| 588 | 626 | } else if (bcObj.getBcType() == BcType.IN) { |
| 589 | - Cell cell = lpRow.getCell((short) (groupCount * 2 + 2)); | |
| 590 | - cell.setCellValue(bcObj.getFcsj()); | |
| 627 | + if (bcObj.getGroupNo() == -2) { | |
| 628 | + Cell cell = lpRow.getCell((short) (groupCount * 2 + 3)); | |
| 629 | + cell.setCellValue(bcObj.getFcsj()); | |
| 630 | + } else if (bcObj.getGroupNo() > 0) { //分班进场 | |
| 631 | + Cell cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 3)); | |
| 632 | + // 停驶用 ※ | |
| 633 | + cell.setCellValue(bcObj.getFcsj() + "X"); | |
| 634 | + } | |
| 635 | + | |
| 636 | + } else if (bcObj.getBcType() == BcType.LC) { | |
| 637 | + if (bcObj.getGroupNo() == -2) { | |
| 638 | + Cell cell = lpRow.getCell((short) (groupCount * 2 + 4)); | |
| 639 | + cell.setCellValue(bcObj.getFcsj()); | |
| 640 | + } | |
| 641 | + | |
| 591 | 642 | } |
| 592 | 643 | } |
| 644 | + | |
| 645 | + // 路牌统计字段 | |
| 646 | + PoiUtils.createDoubleXSSFCell(wb, lpRow, (short) (groupCount * 2 + 5), lpObj.getZlc()); | |
| 647 | + PoiUtils.createDoubleXSSFCell(wb, lpRow, (short) (groupCount * 2 + 6), lpObj.getYylc()); | |
| 648 | + PoiUtils.createDoubleXSSFCell(wb, lpRow, (short) (groupCount * 2 + 7), lpObj.getKslc()); | |
| 649 | + PoiUtils.createStringXSSFCell(wb, lpRow, (short) (groupCount * 2 + 8), | |
| 650 | + String.format("%d小时%d分钟", (int) (lpObj.getZgs() / 60), (int) (lpObj.getZgs() % 60))); | |
| 651 | + PoiUtils.createStringXSSFCell(wb, lpRow, (short) (groupCount * 2 + 9), | |
| 652 | + String.format("%d小时%d分钟", (int) (lpObj.getYygs() / 60), (int) (lpObj.getYygs() % 60))); | |
| 653 | + PoiUtils.createIntegerXSSFCell(wb, lpRow, (short) (groupCount * 2 + 10), lpObj.getYybc()); | |
| 654 | + | |
| 593 | 655 | } |
| 594 | 656 | |
| 595 | 657 | // 自适应单元格长宽 |
| 596 | 658 | sheet.autoSizeColumn(0); |
| 597 | 659 | sheet.autoSizeColumn(1); |
| 660 | + sheet.autoSizeColumn(2); | |
| 598 | 661 | for (int i = 1; i <= groupCount; i++) { |
| 599 | - sheet.autoSizeColumn(i * 2); | |
| 600 | 662 | sheet.autoSizeColumn(i * 2 + 1); |
| 663 | + sheet.autoSizeColumn(i * 2 + 2); | |
| 601 | 664 | } |
| 602 | - | |
| 665 | + sheet.autoSizeColumn(groupCount * 2 + 3); | |
| 666 | + sheet.autoSizeColumn(groupCount * 2 + 4); | |
| 667 | + sheet.autoSizeColumn(groupCount * 2 + 5); | |
| 668 | + sheet.autoSizeColumn(groupCount * 2 + 6); | |
| 669 | + sheet.autoSizeColumn(groupCount * 2 + 7); | |
| 670 | + sheet.autoSizeColumn(groupCount * 2 + 8); | |
| 671 | + sheet.autoSizeColumn(groupCount * 2 + 9); | |
| 672 | + sheet.autoSizeColumn(groupCount * 2 + 10); | |
| 603 | 673 | } |
| 604 | 674 | |
| 605 | 675 | @Override | ... | ... |
src/main/java/com/bsth/service/schedule/datatools/TTinfoDetailDynamicData.java
| 1 | -package com.bsth.service.schedule.datatools; | |
| 2 | - | |
| 3 | -import com.bsth.service.schedule.exception.ScheduleException; | |
| 4 | -import com.bsth.service.schedule.utils.DataToolsFile; | |
| 5 | -import com.fasterxml.jackson.annotation.JsonCreator; | |
| 6 | -import com.fasterxml.jackson.annotation.JsonValue; | |
| 7 | - | |
| 8 | -import java.util.List; | |
| 9 | - | |
| 10 | -/** | |
| 11 | - * 动态时刻表数据。 | |
| 12 | - */ | |
| 13 | -public interface TTinfoDetailDynamicData { | |
| 14 | - | |
| 15 | - //---------------------- 生成时刻表用对象(以下) ---------------------// | |
| 16 | - public static enum BcType { // 班次类型枚举 | |
| 17 | - IN("in"), // 进场 | |
| 18 | - OUT("out"), // 出场 | |
| 19 | - BD("bd"), // 早例保 | |
| 20 | - LC("lc"), // 晚例保 | |
| 21 | - NORMAL("normal"); // 正常 | |
| 22 | - private String flag; | |
| 23 | - | |
| 24 | - @JsonCreator | |
| 25 | - private BcType(String flag) { | |
| 26 | - this.flag = flag; | |
| 27 | - } | |
| 28 | - | |
| 29 | - @JsonValue | |
| 30 | - public String getFlag() { | |
| 31 | - return flag; | |
| 32 | - } | |
| 33 | - | |
| 34 | - public void setFlag(String flag) { | |
| 35 | - this.flag = flag; | |
| 36 | - } | |
| 37 | - } | |
| 38 | - | |
| 39 | - public static class BcObj { // 班次对象 | |
| 40 | - /** 班次时间 */ | |
| 41 | - private Integer bcsj; | |
| 42 | - /** 停站时间 */ | |
| 43 | - private Integer ssj; | |
| 44 | - /** 吃饭时间 */ | |
| 45 | - private Integer eatsj; | |
| 46 | - | |
| 47 | - /** 停车场id */ | |
| 48 | - private Integer tccid; | |
| 49 | - /** 起点站id */ | |
| 50 | - private Integer qdzid; | |
| 51 | - /** 终点站id */ | |
| 52 | - private Integer zdzid; | |
| 53 | - | |
| 54 | - /** 是否上行 */ | |
| 55 | - private Boolean isUp; | |
| 56 | - | |
| 57 | - /** 班次类型 */ | |
| 58 | - private BcType bcType; | |
| 59 | - /** 发车时刻 */ | |
| 60 | - private String fcsj; | |
| 61 | - /** 用于统计的发车时间描述(把进出场,保养,吃饭时间写在一起) */ | |
| 62 | - private String fcsjDesc; | |
| 63 | - | |
| 64 | - /** 第几圈(从1开始) */ | |
| 65 | - private Integer groupNo; | |
| 66 | - /** 圈里第几个班次(1或者2) */ | |
| 67 | - private Integer groupBcNo; | |
| 68 | - | |
| 69 | - public Integer getBcsj() { | |
| 70 | - return bcsj; | |
| 71 | - } | |
| 72 | - | |
| 73 | - public void setBcsj(Integer bcsj) { | |
| 74 | - this.bcsj = bcsj; | |
| 75 | - } | |
| 76 | - | |
| 77 | - public Integer getSsj() { | |
| 78 | - return ssj; | |
| 79 | - } | |
| 80 | - | |
| 81 | - public void setSsj(Integer ssj) { | |
| 82 | - this.ssj = ssj; | |
| 83 | - } | |
| 84 | - | |
| 85 | - public Integer getEatsj() { | |
| 86 | - return eatsj; | |
| 87 | - } | |
| 88 | - | |
| 89 | - public void setEatsj(Integer eatsj) { | |
| 90 | - this.eatsj = eatsj; | |
| 91 | - } | |
| 92 | - | |
| 93 | - public Integer getTccid() { | |
| 94 | - return tccid; | |
| 95 | - } | |
| 96 | - | |
| 97 | - public void setTccid(Integer tccid) { | |
| 98 | - this.tccid = tccid; | |
| 99 | - } | |
| 100 | - | |
| 101 | - public Integer getQdzid() { | |
| 102 | - return qdzid; | |
| 103 | - } | |
| 104 | - | |
| 105 | - public void setQdzid(Integer qdzid) { | |
| 106 | - this.qdzid = qdzid; | |
| 107 | - } | |
| 108 | - | |
| 109 | - public Integer getZdzid() { | |
| 110 | - return zdzid; | |
| 111 | - } | |
| 112 | - | |
| 113 | - public void setZdzid(Integer zdzid) { | |
| 114 | - this.zdzid = zdzid; | |
| 115 | - } | |
| 116 | - | |
| 117 | - public BcType getBcType() { | |
| 118 | - return bcType; | |
| 119 | - } | |
| 120 | - | |
| 121 | - public void setBcType(BcType bcType) { | |
| 122 | - this.bcType = bcType; | |
| 123 | - } | |
| 124 | - | |
| 125 | - public String getFcsj() { | |
| 126 | - return fcsj; | |
| 127 | - } | |
| 128 | - | |
| 129 | - public void setFcsj(String fcsj) { | |
| 130 | - this.fcsj = fcsj; | |
| 131 | - } | |
| 132 | - | |
| 133 | - public Boolean getIsUp() { | |
| 134 | - return isUp; | |
| 135 | - } | |
| 136 | - | |
| 137 | - public void setIsUp(Boolean isUp) { | |
| 138 | - this.isUp = isUp; | |
| 139 | - } | |
| 140 | - | |
| 141 | - public Integer getGroupNo() { | |
| 142 | - return groupNo; | |
| 143 | - } | |
| 144 | - | |
| 145 | - public void setGroupNo(Integer groupNo) { | |
| 146 | - this.groupNo = groupNo; | |
| 147 | - } | |
| 148 | - | |
| 149 | - public Integer getGroupBcNo() { | |
| 150 | - return groupBcNo; | |
| 151 | - } | |
| 152 | - | |
| 153 | - public void setGroupBcNo(Integer groupBcNo) { | |
| 154 | - this.groupBcNo = groupBcNo; | |
| 155 | - } | |
| 156 | - | |
| 157 | - public Boolean getUp() { | |
| 158 | - return isUp; | |
| 159 | - } | |
| 160 | - | |
| 161 | - public void setUp(Boolean up) { | |
| 162 | - isUp = up; | |
| 163 | - } | |
| 164 | - | |
| 165 | - public String getFcsjDesc() { | |
| 166 | - return fcsjDesc; | |
| 167 | - } | |
| 168 | - | |
| 169 | - public void setFcsjDesc(String fcsjDesc) { | |
| 170 | - this.fcsjDesc = fcsjDesc; | |
| 171 | - } | |
| 172 | - } | |
| 173 | - | |
| 174 | - public static class LpObj { // 路牌对象 | |
| 175 | - /** 路牌名字 */ | |
| 176 | - private String lpname; | |
| 177 | - /** 每圈的第一个班次是否上行 */ | |
| 178 | - private Boolean isUp; | |
| 179 | - | |
| 180 | - /** 第一个班次起点站路由id */ | |
| 181 | - private Integer stationRouteId1; | |
| 182 | - /** 第二个班次起点站路由id */ | |
| 183 | - private Integer stationRouteId2; | |
| 184 | - | |
| 185 | - /** 班次列表 */ | |
| 186 | - private List<BcObj> bcObjList; | |
| 187 | - /** 总圈数 */ | |
| 188 | - private Integer groupCount; | |
| 189 | - | |
| 190 | - /** 总工时 */ | |
| 191 | - private Double zgs; | |
| 192 | - /** 总班次 */ | |
| 193 | - private Integer zbc; | |
| 194 | - | |
| 195 | - | |
| 196 | - public String getLpname() { | |
| 197 | - return lpname; | |
| 198 | - } | |
| 199 | - | |
| 200 | - public void setLpname(String lpname) { | |
| 201 | - this.lpname = lpname; | |
| 202 | - } | |
| 203 | - | |
| 204 | - public Boolean getIsUp() { | |
| 205 | - return isUp; | |
| 206 | - } | |
| 207 | - | |
| 208 | - public void setIsUp(Boolean isUp) { | |
| 209 | - this.isUp = isUp; | |
| 210 | - } | |
| 211 | - | |
| 212 | - public List<BcObj> getBcObjList() { | |
| 213 | - return bcObjList; | |
| 214 | - } | |
| 215 | - | |
| 216 | - public void setBcObjList(List<BcObj> bcObjList) { | |
| 217 | - this.bcObjList = bcObjList; | |
| 218 | - } | |
| 219 | - | |
| 220 | - public Integer getGroupCount() { | |
| 221 | - return groupCount; | |
| 222 | - } | |
| 223 | - | |
| 224 | - public void setGroupCount(Integer groupCount) { | |
| 225 | - this.groupCount = groupCount; | |
| 226 | - } | |
| 227 | - | |
| 228 | - public Double getZgs() { | |
| 229 | - return zgs; | |
| 230 | - } | |
| 231 | - | |
| 232 | - public void setZgs(Double zgs) { | |
| 233 | - this.zgs = zgs; | |
| 234 | - } | |
| 235 | - | |
| 236 | - public Integer getZbc() { | |
| 237 | - return zbc; | |
| 238 | - } | |
| 239 | - | |
| 240 | - public void setZbc(Integer zbc) { | |
| 241 | - this.zbc = zbc; | |
| 242 | - } | |
| 243 | - | |
| 244 | - public Integer getStationRouteId1() { | |
| 245 | - return stationRouteId1; | |
| 246 | - } | |
| 247 | - | |
| 248 | - public void setStationRouteId1(Integer stationRouteId1) { | |
| 249 | - this.stationRouteId1 = stationRouteId1; | |
| 250 | - } | |
| 251 | - | |
| 252 | - public Integer getStationRouteId2() { | |
| 253 | - return stationRouteId2; | |
| 254 | - } | |
| 255 | - | |
| 256 | - public void setStationRouteId2(Integer stationRouteId2) { | |
| 257 | - this.stationRouteId2 = stationRouteId2; | |
| 258 | - } | |
| 259 | - } | |
| 260 | - | |
| 261 | - public static class StatInfo { // 统计数据对象 | |
| 262 | - /** 统计项目 */ | |
| 263 | - private String statItem; | |
| 264 | - /** 统计值 */ | |
| 265 | - private Double statValue; | |
| 266 | - | |
| 267 | - public String getStatItem() { | |
| 268 | - return statItem; | |
| 269 | - } | |
| 270 | - | |
| 271 | - public void setStatItem(String statItem) { | |
| 272 | - this.statItem = statItem; | |
| 273 | - } | |
| 274 | - | |
| 275 | - public Double getStatValue() { | |
| 276 | - return statValue; | |
| 277 | - } | |
| 278 | - | |
| 279 | - public void setStatValue(Double statValue) { | |
| 280 | - this.statValue = statValue; | |
| 281 | - } | |
| 282 | - } | |
| 283 | - | |
| 284 | - public static class DTInfos { // 所有数据信息 | |
| 285 | - /** 路牌班次数据列表 */ | |
| 286 | - private List<LpObj> lpObjList; | |
| 287 | - /** 统计数据列表 */ | |
| 288 | - private List<StatInfo> statInfoList; | |
| 289 | - | |
| 290 | - public List<LpObj> getLpObjList() { | |
| 291 | - return lpObjList; | |
| 292 | - } | |
| 293 | - | |
| 294 | - public void setLpObjList(List<LpObj> lpObjList) { | |
| 295 | - this.lpObjList = lpObjList; | |
| 296 | - } | |
| 297 | - | |
| 298 | - public List<StatInfo> getStatInfoList() { | |
| 299 | - return statInfoList; | |
| 300 | - } | |
| 301 | - | |
| 302 | - public void setStatInfoList(List<StatInfo> statInfoList) { | |
| 303 | - this.statInfoList = statInfoList; | |
| 304 | - } | |
| 305 | - } | |
| 306 | - | |
| 307 | - //---------------------- 生成时刻表用对象(以上) ---------------------// | |
| 308 | - | |
| 309 | - /** | |
| 310 | - * 导出动态时刻表数据。 | |
| 311 | - * @param dtInfos | |
| 312 | - * @return | |
| 313 | - * @throws ScheduleException | |
| 314 | - */ | |
| 315 | - public DataToolsFile exportDynamicTTinfo(DTInfos dtInfos) throws ScheduleException; | |
| 316 | -} | |
| 1 | +package com.bsth.service.schedule.datatools; | |
| 2 | + | |
| 3 | +import com.bsth.service.schedule.exception.ScheduleException; | |
| 4 | +import com.bsth.service.schedule.utils.DataToolsFile; | |
| 5 | +import com.fasterxml.jackson.annotation.JsonCreator; | |
| 6 | +import com.fasterxml.jackson.annotation.JsonValue; | |
| 7 | + | |
| 8 | +import java.util.List; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 动态时刻表数据。 | |
| 12 | + */ | |
| 13 | +public interface TTinfoDetailDynamicData { | |
| 14 | + | |
| 15 | + //---------------------- 生成时刻表用对象(以下) ---------------------// | |
| 16 | + public static enum BcType { // 班次类型枚举 | |
| 17 | + IN("in"), // 进场 | |
| 18 | + OUT("out"), // 出场 | |
| 19 | + BD("bd"), // 早例保 | |
| 20 | + LC("lc"), // 晚例保 | |
| 21 | + NORMAL("normal"); // 正常 | |
| 22 | + private String flag; | |
| 23 | + | |
| 24 | + @JsonCreator | |
| 25 | + private BcType(String flag) { | |
| 26 | + this.flag = flag; | |
| 27 | + } | |
| 28 | + | |
| 29 | + @JsonValue | |
| 30 | + public String getFlag() { | |
| 31 | + return flag; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public void setFlag(String flag) { | |
| 35 | + this.flag = flag; | |
| 36 | + } | |
| 37 | + } | |
| 38 | + | |
| 39 | + public static class BcObj { // 班次对象 | |
| 40 | + /** 班次时间 */ | |
| 41 | + private Integer bcsj; | |
| 42 | + /** 停站时间 */ | |
| 43 | + private Integer ssj; | |
| 44 | + /** 吃饭时间 */ | |
| 45 | + private Integer eatsj; | |
| 46 | + | |
| 47 | + /** 停车场id */ | |
| 48 | + private Integer tccid; | |
| 49 | + /** 起点站id */ | |
| 50 | + private Integer qdzid; | |
| 51 | + /** 终点站id */ | |
| 52 | + private Integer zdzid; | |
| 53 | + | |
| 54 | + /** 是否上行 */ | |
| 55 | + private Boolean isUp; | |
| 56 | + | |
| 57 | + /** 班次类型 */ | |
| 58 | + private BcType bcType; | |
| 59 | + /** 发车时刻 */ | |
| 60 | + private String fcsj; | |
| 61 | + /** 用于统计的发车时间描述(把进出场,保养,吃饭时间写在一起) */ | |
| 62 | + private String fcsjDesc; | |
| 63 | + | |
| 64 | + /** 第几圈(从1开始) */ | |
| 65 | + private Integer groupNo; | |
| 66 | + /** 圈里第几个班次(1或者2) */ | |
| 67 | + private Integer groupBcNo; | |
| 68 | + | |
| 69 | + public Integer getBcsj() { | |
| 70 | + return bcsj; | |
| 71 | + } | |
| 72 | + | |
| 73 | + public void setBcsj(Integer bcsj) { | |
| 74 | + this.bcsj = bcsj; | |
| 75 | + } | |
| 76 | + | |
| 77 | + public Integer getSsj() { | |
| 78 | + return ssj; | |
| 79 | + } | |
| 80 | + | |
| 81 | + public void setSsj(Integer ssj) { | |
| 82 | + this.ssj = ssj; | |
| 83 | + } | |
| 84 | + | |
| 85 | + public Integer getEatsj() { | |
| 86 | + return eatsj; | |
| 87 | + } | |
| 88 | + | |
| 89 | + public void setEatsj(Integer eatsj) { | |
| 90 | + this.eatsj = eatsj; | |
| 91 | + } | |
| 92 | + | |
| 93 | + public Integer getTccid() { | |
| 94 | + return tccid; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public void setTccid(Integer tccid) { | |
| 98 | + this.tccid = tccid; | |
| 99 | + } | |
| 100 | + | |
| 101 | + public Integer getQdzid() { | |
| 102 | + return qdzid; | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void setQdzid(Integer qdzid) { | |
| 106 | + this.qdzid = qdzid; | |
| 107 | + } | |
| 108 | + | |
| 109 | + public Integer getZdzid() { | |
| 110 | + return zdzid; | |
| 111 | + } | |
| 112 | + | |
| 113 | + public void setZdzid(Integer zdzid) { | |
| 114 | + this.zdzid = zdzid; | |
| 115 | + } | |
| 116 | + | |
| 117 | + public BcType getBcType() { | |
| 118 | + return bcType; | |
| 119 | + } | |
| 120 | + | |
| 121 | + public void setBcType(BcType bcType) { | |
| 122 | + this.bcType = bcType; | |
| 123 | + } | |
| 124 | + | |
| 125 | + public String getFcsj() { | |
| 126 | + return fcsj; | |
| 127 | + } | |
| 128 | + | |
| 129 | + public void setFcsj(String fcsj) { | |
| 130 | + this.fcsj = fcsj; | |
| 131 | + } | |
| 132 | + | |
| 133 | + public Boolean getIsUp() { | |
| 134 | + return isUp; | |
| 135 | + } | |
| 136 | + | |
| 137 | + public void setIsUp(Boolean isUp) { | |
| 138 | + this.isUp = isUp; | |
| 139 | + } | |
| 140 | + | |
| 141 | + public Integer getGroupNo() { | |
| 142 | + return groupNo; | |
| 143 | + } | |
| 144 | + | |
| 145 | + public void setGroupNo(Integer groupNo) { | |
| 146 | + this.groupNo = groupNo; | |
| 147 | + } | |
| 148 | + | |
| 149 | + public Integer getGroupBcNo() { | |
| 150 | + return groupBcNo; | |
| 151 | + } | |
| 152 | + | |
| 153 | + public void setGroupBcNo(Integer groupBcNo) { | |
| 154 | + this.groupBcNo = groupBcNo; | |
| 155 | + } | |
| 156 | + | |
| 157 | + public Boolean getUp() { | |
| 158 | + return isUp; | |
| 159 | + } | |
| 160 | + | |
| 161 | + public void setUp(Boolean up) { | |
| 162 | + isUp = up; | |
| 163 | + } | |
| 164 | + | |
| 165 | + public String getFcsjDesc() { | |
| 166 | + return fcsjDesc; | |
| 167 | + } | |
| 168 | + | |
| 169 | + public void setFcsjDesc(String fcsjDesc) { | |
| 170 | + this.fcsjDesc = fcsjDesc; | |
| 171 | + } | |
| 172 | + } | |
| 173 | + | |
| 174 | + public static class LpObj { // 路牌对象 | |
| 175 | + /** 路牌名字 */ | |
| 176 | + private String lpname; | |
| 177 | + /** 每圈的第一个班次是否上行 */ | |
| 178 | + private Boolean isUp; | |
| 179 | + | |
| 180 | + /** 第一个班次起点站路由id */ | |
| 181 | + private Integer stationRouteId1; | |
| 182 | + /** 第二个班次起点站路由id */ | |
| 183 | + private Integer stationRouteId2; | |
| 184 | + | |
| 185 | + /** 班次列表 */ | |
| 186 | + private List<BcObj> bcObjList; | |
| 187 | + /** 总圈数 */ | |
| 188 | + private Integer groupCount; | |
| 189 | + | |
| 190 | + //---------------- 路牌统计 ---------------// | |
| 191 | + /** 总里程 */ | |
| 192 | + private Double zlc; | |
| 193 | + /** 营运里程 */ | |
| 194 | + private Double yylc; | |
| 195 | + /** 空驶里程 */ | |
| 196 | + private Double kslc; | |
| 197 | + /** 总工时 */ | |
| 198 | + private Double zgs; | |
| 199 | + /** 总班次 */ | |
| 200 | + private Integer zbc; | |
| 201 | + /** 营运工时 */ | |
| 202 | + private Double yygs; | |
| 203 | + /** 营运班次 */ | |
| 204 | + private Integer yybc; | |
| 205 | + | |
| 206 | + public String getLpname() { | |
| 207 | + return lpname; | |
| 208 | + } | |
| 209 | + | |
| 210 | + public void setLpname(String lpname) { | |
| 211 | + this.lpname = lpname; | |
| 212 | + } | |
| 213 | + | |
| 214 | + public Boolean getIsUp() { | |
| 215 | + return isUp; | |
| 216 | + } | |
| 217 | + | |
| 218 | + public void setIsUp(Boolean isUp) { | |
| 219 | + this.isUp = isUp; | |
| 220 | + } | |
| 221 | + | |
| 222 | + public List<BcObj> getBcObjList() { | |
| 223 | + return bcObjList; | |
| 224 | + } | |
| 225 | + | |
| 226 | + public void setBcObjList(List<BcObj> bcObjList) { | |
| 227 | + this.bcObjList = bcObjList; | |
| 228 | + } | |
| 229 | + | |
| 230 | + public Integer getGroupCount() { | |
| 231 | + return groupCount; | |
| 232 | + } | |
| 233 | + | |
| 234 | + public void setGroupCount(Integer groupCount) { | |
| 235 | + this.groupCount = groupCount; | |
| 236 | + } | |
| 237 | + | |
| 238 | + public Integer getStationRouteId1() { | |
| 239 | + return stationRouteId1; | |
| 240 | + } | |
| 241 | + | |
| 242 | + public void setStationRouteId1(Integer stationRouteId1) { | |
| 243 | + this.stationRouteId1 = stationRouteId1; | |
| 244 | + } | |
| 245 | + | |
| 246 | + public Integer getStationRouteId2() { | |
| 247 | + return stationRouteId2; | |
| 248 | + } | |
| 249 | + | |
| 250 | + public void setStationRouteId2(Integer stationRouteId2) { | |
| 251 | + this.stationRouteId2 = stationRouteId2; | |
| 252 | + } | |
| 253 | + | |
| 254 | + public Boolean getUp() { | |
| 255 | + return isUp; | |
| 256 | + } | |
| 257 | + | |
| 258 | + public void setUp(Boolean up) { | |
| 259 | + isUp = up; | |
| 260 | + } | |
| 261 | + | |
| 262 | + public Double getZlc() { | |
| 263 | + return zlc; | |
| 264 | + } | |
| 265 | + | |
| 266 | + public void setZlc(Double zlc) { | |
| 267 | + this.zlc = zlc; | |
| 268 | + } | |
| 269 | + | |
| 270 | + public Double getYylc() { | |
| 271 | + return yylc; | |
| 272 | + } | |
| 273 | + | |
| 274 | + public void setYylc(Double yylc) { | |
| 275 | + this.yylc = yylc; | |
| 276 | + } | |
| 277 | + | |
| 278 | + public Double getKslc() { | |
| 279 | + return kslc; | |
| 280 | + } | |
| 281 | + | |
| 282 | + public void setKslc(Double kslc) { | |
| 283 | + this.kslc = kslc; | |
| 284 | + } | |
| 285 | + | |
| 286 | + public Double getZgs() { | |
| 287 | + return zgs; | |
| 288 | + } | |
| 289 | + | |
| 290 | + public void setZgs(Double zgs) { | |
| 291 | + this.zgs = zgs; | |
| 292 | + } | |
| 293 | + | |
| 294 | + public Integer getZbc() { | |
| 295 | + return zbc; | |
| 296 | + } | |
| 297 | + | |
| 298 | + public void setZbc(Integer zbc) { | |
| 299 | + this.zbc = zbc; | |
| 300 | + } | |
| 301 | + | |
| 302 | + public Double getYygs() { | |
| 303 | + return yygs; | |
| 304 | + } | |
| 305 | + | |
| 306 | + public void setYygs(Double yygs) { | |
| 307 | + this.yygs = yygs; | |
| 308 | + } | |
| 309 | + | |
| 310 | + public Integer getYybc() { | |
| 311 | + return yybc; | |
| 312 | + } | |
| 313 | + | |
| 314 | + public void setYybc(Integer yybc) { | |
| 315 | + this.yybc = yybc; | |
| 316 | + } | |
| 317 | + } | |
| 318 | + | |
| 319 | + public static class StatInfo { // 统计数据对象 | |
| 320 | + /** 统计项目 */ | |
| 321 | + private String statItem; | |
| 322 | + /** 统计值 */ | |
| 323 | + private Double statValue; | |
| 324 | + | |
| 325 | + public String getStatItem() { | |
| 326 | + return statItem; | |
| 327 | + } | |
| 328 | + | |
| 329 | + public void setStatItem(String statItem) { | |
| 330 | + this.statItem = statItem; | |
| 331 | + } | |
| 332 | + | |
| 333 | + public Double getStatValue() { | |
| 334 | + return statValue; | |
| 335 | + } | |
| 336 | + | |
| 337 | + public void setStatValue(Double statValue) { | |
| 338 | + this.statValue = statValue; | |
| 339 | + } | |
| 340 | + } | |
| 341 | + | |
| 342 | + public static class DTInfos { // 所有数据信息 | |
| 343 | + /** 路牌班次数据列表 */ | |
| 344 | + private List<LpObj> lpObjList; | |
| 345 | + /** 统计数据列表 */ | |
| 346 | + private List<StatInfo> statInfoList; | |
| 347 | + | |
| 348 | + public List<LpObj> getLpObjList() { | |
| 349 | + return lpObjList; | |
| 350 | + } | |
| 351 | + | |
| 352 | + public void setLpObjList(List<LpObj> lpObjList) { | |
| 353 | + this.lpObjList = lpObjList; | |
| 354 | + } | |
| 355 | + | |
| 356 | + public List<StatInfo> getStatInfoList() { | |
| 357 | + return statInfoList; | |
| 358 | + } | |
| 359 | + | |
| 360 | + public void setStatInfoList(List<StatInfo> statInfoList) { | |
| 361 | + this.statInfoList = statInfoList; | |
| 362 | + } | |
| 363 | + } | |
| 364 | + | |
| 365 | + //---------------------- 生成时刻表用对象(以上) ---------------------// | |
| 366 | + | |
| 367 | + /** | |
| 368 | + * 导出动态时刻表数据。 | |
| 369 | + * @param dtInfos | |
| 370 | + * @return | |
| 371 | + * @throws ScheduleException | |
| 372 | + */ | |
| 373 | + public DataToolsFile exportDynamicTTinfo(DTInfos dtInfos) throws ScheduleException; | |
| 374 | +} | |
| 317 | 375 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/service/schedule/utils/PoiUtils.java
| ... | ... | @@ -82,7 +82,7 @@ public class PoiUtils { |
| 82 | 82 | |
| 83 | 83 | public static XSSFCell createDoubleXSSFCell( |
| 84 | 84 | XSSFWorkbook xssfWorkbook, XSSFRow xssfRow, short column, Double value) { |
| 85 | - return createXSSFCell( | |
| 85 | + XSSFCell xssfCell = createXSSFCell( | |
| 86 | 86 | xssfWorkbook, xssfRow, column, |
| 87 | 87 | value, XSSFCell.CELL_TYPE_NUMERIC, |
| 88 | 88 | HorizontalAlignment.CENTER, VerticalAlignment.CENTER, |
| ... | ... | @@ -90,6 +90,10 @@ public class PoiUtils { |
| 90 | 90 | (short) 13, new Color(0x2765A7), "宋体", |
| 91 | 91 | new Color(0xffffff), FillPatternType.SOLID_FOREGROUND |
| 92 | 92 | ); |
| 93 | + | |
| 94 | + DataFormat dataFormat = xssfWorkbook.createDataFormat(); | |
| 95 | + xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("0.00")); | |
| 96 | + return xssfCell; | |
| 93 | 97 | } |
| 94 | 98 | |
| 95 | 99 | public static XSSFCell createIntegerXSSFCell( | ... | ... |
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalScheduleObj.js
| 1 | -/** | |
| 2 | - * 内部行车计划对象。 | |
| 3 | - * @constructor | |
| 4 | - */ | |
| 5 | -var InternalScheduleObj = function(paramObj, lpArray, factory) { | |
| 6 | - // 参数对象 | |
| 7 | - var _paramObj = paramObj; | |
| 8 | - // 外部的路牌数组 | |
| 9 | - var _lpArray = lpArray; | |
| 10 | - // 工厂对象 | |
| 11 | - var _factory = factory; | |
| 12 | - | |
| 13 | - //------------------ 初始化方法1,以及计算关联的内部变量 -----------------// | |
| 14 | - var _qIsUp; // 每一圈是上行开始还是下行开始 | |
| 15 | - var _qCount = 0; // 总的圈数 | |
| 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 | - ]; | |
| 27 | - | |
| 28 | - var _fnInitFun1 = function() { // 初始化方法1 | |
| 29 | - console.log("//---------------- 行车计划,初始化方法1 start ----------------//"); | |
| 30 | - | |
| 31 | - //----------------------- 1、确定上标线的方向,圈的方向 -------------------// | |
| 32 | - | |
| 33 | - // 确定_qIsUp,哪个方向的首班车晚就用哪个 | |
| 34 | - _qIsUp = _paramObj.getUpFirstDTimeObj().isBefore( | |
| 35 | - _paramObj.getDownFirstDTimeObj()) ? false : true; | |
| 36 | - // 上标线开始时间,就是方向的首班车时间 | |
| 37 | - var st = _qIsUp ? _paramObj.getUpFirstDTimeObj() : _paramObj.getDownFirstDTimeObj(); | |
| 38 | - // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向 | |
| 39 | - var et; | |
| 40 | - var et_IsUp; | |
| 41 | - if (_paramObj.getUpLastDtimeObj().isBefore( | |
| 42 | - _paramObj.getDownLastDTimeObj())) { | |
| 43 | - et = _paramObj.getDownLastDTimeObj(); | |
| 44 | - et_IsUp = false; | |
| 45 | - } else { | |
| 46 | - et = _paramObj.getUpLastDtimeObj(); | |
| 47 | - et_IsUp = true; | |
| 48 | - } | |
| 49 | - | |
| 50 | - //------------------------ 2、计算总共有多少圈 ------------------------// | |
| 51 | - | |
| 52 | - // 以开始时间,结束时间,构造上标线用连班班次发车时间 | |
| 53 | - var bcFcsjArrays = []; // 班次发车时间对象数组 | |
| 54 | - var bcArsjArrays = []; // 班次到达时间对象数组 | |
| 55 | - var isUp = _qIsUp; // 方向 | |
| 56 | - var bcCount = 1; // 班次数 | |
| 57 | - | |
| 58 | - var _kssj = st; // 开始时间 | |
| 59 | - var _bcsj = paramObj.calcuTravelTime(_kssj, isUp); // 班次历时 | |
| 60 | - var _arrsj = paramObj.addMinute(_kssj, _bcsj); // 到达时间 | |
| 61 | - var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj); // 停站时间 | |
| 62 | - | |
| 63 | - do { | |
| 64 | - bcFcsjArrays.push(_kssj); | |
| 65 | - bcArsjArrays.push(_arrsj); | |
| 66 | - | |
| 67 | - _kssj = paramObj.addMinute(_kssj, _bcsj + _stoptime); | |
| 68 | - _bcsj = paramObj.calcuTravelTime(_kssj, isUp); | |
| 69 | - _arrsj = paramObj.addMinute(_kssj, _bcsj); | |
| 70 | - _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj); | |
| 71 | - | |
| 72 | - bcCount ++; | |
| 73 | - isUp = !isUp; | |
| 74 | - } while(_kssj.isBefore(et)); | |
| 75 | - bcCount--; // 因为先做do,所以总的班次要减1 | |
| 76 | - //if (bcCount > 0 && bcArsjArrays[bcCount - 1].isAfter(et)) { | |
| 77 | - // // 如果最后一个班次的到达时间超过结束时间,也要去除 | |
| 78 | - // bcFcsjArrays.splice(bcCount - 1, 1); | |
| 79 | - // bcArsjArrays.splice(bcCount - 1, 1); | |
| 80 | - // bcCount--; | |
| 81 | - //} | |
| 82 | - var _qCount_p1 = Math.floor(bcCount / 2); // 2个班次一圈 | |
| 83 | - var _qCount_p2 = bcCount % 2; // 余下的1个班次也算一圈 | |
| 84 | - | |
| 85 | - // 利用连班数组计算圈数 | |
| 86 | - _qCount = 1; // 前面加1圈,补中标线的班次 | |
| 87 | - _qCount += _qCount_p1; | |
| 88 | - _qCount += _qCount_p2; | |
| 89 | - | |
| 90 | - // 计算最后是不是还要补一圈 | |
| 91 | - if (_qCount > 1) { // 总的圈数就1圈,没必要加了(其实是不可能的,除非参数里问题) | |
| 92 | - if (_qCount_p2 == 0) { // 没有余下班次,整数圈数 | |
| 93 | - // 最后一个班次的方向一定和开始的方向相反,如:上-下,上-下,上-下,一共三圈,最后一个班次为下行 | |
| 94 | - // 判定最后一个班次的方向和上标线判定结束时间的班次方向是否一致 | |
| 95 | - if (!_qIsUp == et_IsUp) { | |
| 96 | - // 一致不用加圈数 | |
| 97 | - } else { | |
| 98 | - // 不一致需要加圈补最后一个结束时间班次 | |
| 99 | - _qCount ++; | |
| 100 | - } | |
| 101 | - } else { | |
| 102 | - // 有余下的圈数,最后要不补的班次不管上行,下行都在这一圈里 | |
| 103 | - // 不需要在补圈数了 | |
| 104 | - } | |
| 105 | - } | |
| 106 | - | |
| 107 | - //------------------------ 3、根据路牌数,圈数创建路牌对象 ----------------------// | |
| 108 | - | |
| 109 | - // 创建内部的路牌数组,并把之前的连班路牌添加进上标线路牌中 | |
| 110 | - var i; | |
| 111 | - for (i = 0; i < _lpArray.length; i++) { | |
| 112 | - _internalLpArray.push(new InternalLpObj(_lpArray[i], _qCount, _qIsUp)); | |
| 113 | - } | |
| 114 | - // 初始化上标线,从第1圈开始 | |
| 115 | - _internalLpArray[0].initDataFromTimeToTime(bcFcsjArrays[0], et, _qIsUp, 1, _paramObj, _factory); | |
| 116 | - | |
| 117 | - // 以上标线为基础,计算各种班型工时对应的圈数、班次数 | |
| 118 | - var aBcArray = _internalLpArray[0].getBcArray(); | |
| 119 | - aBcArray[0].fnSetIsFirstBc(true); // 设置首班班次标识 | |
| 120 | - | |
| 121 | - if (aBcArray.length % 2 != 0) { // 不能整除2,去除一个班次计算 | |
| 122 | - aBcArray.splice(aBcArray.length - 1, 1); | |
| 123 | - } | |
| 124 | - | |
| 125 | - // 午饭吃饭时间 | |
| 126 | - var iLTime = _paramObj.fnGetLunchTime(); | |
| 127 | - // 晚饭吃饭时间 | |
| 128 | - var iDTime = _paramObj.fnGetDinnerTime(); | |
| 129 | - // 出场时间 | |
| 130 | - var iOutTime = _qIsUp ? _paramObj.getUpOutTime() : _paramObj.getDownOutTime(); | |
| 131 | - // 进场时间 | |
| 132 | - var iInTime = _qIsUp ? _paramObj.getDownInTime() : _paramObj.getUpInTime(); | |
| 133 | - // 例保时间 | |
| 134 | - var iBTime = _paramObj.getLbTime(); | |
| 135 | - | |
| 136 | - var sum = 0; // 总班次时间 | |
| 137 | - for (i = 0; i < aBcArray.length; i++) { | |
| 138 | - sum += aBcArray[i].getBcTime() + aBcArray[i].getStopTime(); | |
| 139 | - } | |
| 140 | - sum += iLTime; // 加午饭时间 | |
| 141 | - sum += iDTime; // 加晚饭时间 | |
| 142 | - for (i = 0; i < _aBxDesc.length; i++) { | |
| 143 | - _aBxDesc[i].fAverTime = sum / (aBcArray.length / 2); // 平均周转时间不算进出场,例保时间 | |
| 144 | - | |
| 145 | - // 计算5休2的班次数(双进出场,4个例保) | |
| 146 | - if (i == 6) { | |
| 147 | - _aBxDesc[i].fQCount = | |
| 148 | - (_aBxDesc[i].fHoursV * 60 - iOutTime * 2 - iInTime * 2 - iBTime * 4) / | |
| 149 | - _aBxDesc[i].fAverTime; | |
| 150 | - _aBxDesc[i].fBcCount = _aBxDesc[i].fQCount * 2; | |
| 151 | - } else { // 进出场,2个例保 | |
| 152 | - _aBxDesc[i].fQCount = | |
| 153 | - (_aBxDesc[i].fHoursV * 60 - iOutTime - iInTime - iBTime * 2) / | |
| 154 | - _aBxDesc[i].fAverTime; | |
| 155 | - _aBxDesc[i].fBcCount = _aBxDesc[i].fQCount * 2; | |
| 156 | - } | |
| 157 | - } | |
| 158 | - | |
| 159 | - | |
| 160 | - // 在第一个班次之前再添加一个模拟班次,用于中标线的作用 | |
| 161 | - // 那一圈必定是低谷,而且圈索引0,班次索引1,暂时标记,最后删除 | |
| 162 | - var iFirstStopTime = | |
| 163 | - _paramObj.fnCalcuFixedStopNumber( | |
| 164 | - _paramObj.addMinute(aBcArray[0].getFcTimeObj(), -10), | |
| 165 | - _qIsUp | |
| 166 | - ); | |
| 167 | - var iXXTime = _qIsUp ? _paramObj.getDownTroughTime() : _paramObj.getUpTroughTime(); | |
| 168 | - var oFlagBc = _factory.createBcObj( // 标记班次 | |
| 169 | - _internalLpArray[0], | |
| 170 | - "normal", | |
| 171 | - !_qIsUp, | |
| 172 | - 1, | |
| 173 | - _paramObj.addMinute(aBcArray[0].getFcTimeObj(), -(iFirstStopTime + iXXTime)), | |
| 174 | - _paramObj | |
| 175 | - ); | |
| 176 | - oFlagBc.fnSetDelFlag(true); // 标记了删除记号 | |
| 177 | - | |
| 178 | - _internalLpArray[0].setBc(0, 1, oFlagBc); | |
| 179 | - | |
| 180 | - // 在最后一圈也补上一个或者2个模拟班次,暂时标记,最后需要删除 | |
| 181 | - var aMaxBcIndex = _internalLpArray[0].getMaxBcObjPosition(); | |
| 182 | - if (aMaxBcIndex[0] == _qCount - 1) { // 可能加半圈 | |
| 183 | - oFlagBc = _factory.createBcObj( // 标记班次 | |
| 184 | - _internalLpArray[0], | |
| 185 | - "normal", | |
| 186 | - !_qIsUp, | |
| 187 | - 1, | |
| 188 | - _paramObj.addMinute( | |
| 189 | - _internalLpArray[0].getBc(_qCount - 1, 0).getArrTimeObj(), | |
| 190 | - _internalLpArray[0].getBc(_qCount - 1, 0).getStopTime()), | |
| 191 | - _paramObj | |
| 192 | - ); | |
| 193 | - oFlagBc.fnSetDelFlag(true); // 标记了删除记号 | |
| 194 | - _internalLpArray[0].setBc(_qCount - 1, 1, oFlagBc); | |
| 195 | - | |
| 196 | - } else { // 加完整的一圈 | |
| 197 | - oFlagBc = _factory.createBcObj( // 标记班次 | |
| 198 | - _internalLpArray[0], | |
| 199 | - "normal", | |
| 200 | - _qIsUp, | |
| 201 | - 1, | |
| 202 | - _paramObj.addMinute( | |
| 203 | - _internalLpArray[0].getBc(_qCount - 2, 1).getArrTimeObj(), | |
| 204 | - _internalLpArray[0].getBc(_qCount - 2, 1).getStopTime()), | |
| 205 | - _paramObj | |
| 206 | - ); | |
| 207 | - oFlagBc.fnSetDelFlag(true); // 标记了删除记号 | |
| 208 | - _internalLpArray[0].setBc(_qCount - 1, 0, oFlagBc); | |
| 209 | - | |
| 210 | - oFlagBc = _factory.createBcObj( // 标记班次 | |
| 211 | - _internalLpArray[0], | |
| 212 | - "normal", | |
| 213 | - !_qIsUp, | |
| 214 | - 1, | |
| 215 | - _paramObj.addMinute( | |
| 216 | - _internalLpArray[0].getBc(_qCount - 1, 0).getArrTimeObj(), | |
| 217 | - _internalLpArray[0].getBc(_qCount - 1, 0).getStopTime()), | |
| 218 | - _paramObj | |
| 219 | - ); | |
| 220 | - oFlagBc.fnSetDelFlag(true); // 标记了删除记号 | |
| 221 | - _internalLpArray[0].setBc(_qCount - 1, 1, oFlagBc); | |
| 222 | - | |
| 223 | - } | |
| 224 | - | |
| 225 | - console.log("上行首班车时间:" + _paramObj.getUpFirstDTimeObj().format("HH:mm") + | |
| 226 | - "上行末班车时间:" + _paramObj.getUpLastDtimeObj().format("HH:mm")); | |
| 227 | - console.log("下行首班车时间:" + _paramObj.getDownFirstDTimeObj().format("HH:mm") + | |
| 228 | - "下行末班车时间:" + _paramObj.getDownLastDTimeObj().format("HH:mm")); | |
| 229 | - console.log("总共计算的圈数:" + _qCount); | |
| 230 | - console.log("圈的方向isUP:" + _qIsUp); | |
| 231 | - console.log("班型描述(以下):"); | |
| 232 | - console.log(_aBxDesc); | |
| 233 | - console.log("所有路牌间隔描述(以下):"); | |
| 234 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 235 | - console.log(_internalLpArray[i]._$_aVerticalIntervalTime); | |
| 236 | - } | |
| 237 | - console.log("//---------------- 行车计划,初始化方法1 end ----------------//"); | |
| 238 | - | |
| 239 | - }; | |
| 240 | - | |
| 241 | - //------------------ 初始化方法2,以及计算关联的内部变量 ----------------// | |
| 242 | - var _approximate_zgfQIndex; // 预估早高峰车辆从第几圈开始全部发出 | |
| 243 | - var _approximate_zgfBIndex; // 预估早高峰车辆从第几圈第几个班次开始全部发出(上行或下行) | |
| 244 | - var _approximate_wgfQIndex; // 预估晚高峰车辆从第几圈开始全部发出 | |
| 245 | - var _approximate_wgfBIndex; // 预估晚高峰车辆从第几圈第几个班次开始全部发出(上行或下行) | |
| 246 | - | |
| 247 | - var _fnInitFun2 = function() { // 初始化方法2 | |
| 248 | - console.log("//---------------- 行车计划,初始化方法2 start ----------------//"); | |
| 249 | - | |
| 250 | - //------------------------ 1、计算车辆总数 ------------------------// | |
| 251 | - // 是用高峰上行周转时间除以高峰平均间隔得到的 | |
| 252 | - // 这样算还算合理,车辆不多不少,待以后有新的算法再修正 | |
| 253 | - var iClCount = _paramObj.calcuClzx(); | |
| 254 | - | |
| 255 | - //------------------------ 2、计算所有路牌的发车在各个圈中的间隔 --------------------// | |
| 256 | - var i; | |
| 257 | - var j; | |
| 258 | - var iBindex = 1; | |
| 259 | - var iZzsj; | |
| 260 | - var oLp; | |
| 261 | - var iC1; | |
| 262 | - var iC2; | |
| 263 | - | |
| 264 | - for (i = 0; i < _qCount - 1; i++) { | |
| 265 | - while (iBindex <= 1) { | |
| 266 | - // 每圈每个方向的周转时间不一致,以上标线为主 | |
| 267 | - oLp = _internalLpArray[0]; | |
| 268 | - iZzsj = oLp.getBc(i + 1, iBindex).getFcTimeObj().diff( | |
| 269 | - oLp.getBc(i, iBindex).getFcTimeObj(), "m" | |
| 270 | - ); | |
| 271 | - | |
| 272 | - iC1 = Math.floor(iZzsj / iClCount); | |
| 273 | - iC2 = iZzsj % iClCount; | |
| 274 | - | |
| 275 | - for (j = 0; j < iClCount - iC2; j++) { | |
| 276 | - oLp = _internalLpArray[j]; | |
| 277 | - oLp.fnSetVerticalIntervalTime(i, iBindex, iC1); | |
| 278 | - } | |
| 279 | - | |
| 280 | - for (j = 0; j < iC2; j++) { | |
| 281 | - oLp = _internalLpArray[iClCount - iC2 + j]; | |
| 282 | - oLp.fnSetVerticalIntervalTime(i, iBindex, iC1 + 1); | |
| 283 | - } | |
| 284 | - | |
| 285 | - iBindex ++; | |
| 286 | - | |
| 287 | - } | |
| 288 | - iBindex = 0; | |
| 289 | - } | |
| 290 | - // 最后一圈没有下一圈的参照,周转时间没发获取,由于都是低谷,所以使用倒数第二圈的间隔最为最后一圈的间隔 | |
| 291 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 292 | - oLp = _internalLpArray[i]; | |
| 293 | - oLp.fnSetVerticalIntervalTime(_qCount - 1, 0, oLp.fnGetVerticalIntervalTime(_qCount - 2, 0)); | |
| 294 | - oLp.fnSetVerticalIntervalTime(_qCount - 1, 1, oLp.fnGetVerticalIntervalTime(_qCount - 2, 1)); | |
| 295 | - } | |
| 296 | - | |
| 297 | - //------------------------ 3、预估早高峰全部出车第几圈第几个班次全部出车,计算路牌之间的发车间隔 ------------------// | |
| 298 | - | |
| 299 | - // 以上标线为标准,查找离早高峰开始时间最近的班次作为早高峰开始班次 | |
| 300 | - // 以这个班次为早高峰起点,全部出车策略 | |
| 301 | - var qbcIndexArray = _internalLpArray[0].getQBcIndexWithFcTime( | |
| 302 | - _paramObj.getMPeakStartTimeObj(), true, true); | |
| 303 | - var qIndex = qbcIndexArray[0]; // 第几圈 | |
| 304 | - var bIndex = qbcIndexArray[1]; // 第几个班次 | |
| 305 | - | |
| 306 | - for (i = 1; i < _internalLpArray.length; i++) { | |
| 307 | - _fnGenerateBcAndSetBc(i, qIndex, bIndex); | |
| 308 | - } | |
| 309 | - | |
| 310 | - _approximate_zgfQIndex = qIndex; | |
| 311 | - _approximate_zgfBIndex = bIndex; | |
| 312 | - | |
| 313 | - //------------------------ 4、预估晚高峰全部出车第几圈第几个班次全部出车,计算路牌之间的发车间隔 ------------------// | |
| 314 | - | |
| 315 | - // 以上标线为标准,查找离晚高峰开始时间最近的班次作为晚高峰开始班次 | |
| 316 | - // 以这个班次为早高峰起点,全部出车策略 | |
| 317 | - qbcIndexArray = _internalLpArray[0].getQBcIndexWithFcTime( | |
| 318 | - _paramObj.getEPeakStartTimeObj(), true, true); | |
| 319 | - qIndex = qbcIndexArray[0]; // 第几圈 | |
| 320 | - bIndex = qbcIndexArray[1]; // 第几个班次 | |
| 321 | - | |
| 322 | - for (i = 1; i < _internalLpArray.length; i++) { | |
| 323 | - _fnGenerateBcAndSetBc(i, qIndex, bIndex); | |
| 324 | - } | |
| 325 | - | |
| 326 | - _approximate_wgfQIndex = qIndex; | |
| 327 | - _approximate_wgfBIndex = bIndex; | |
| 328 | - | |
| 329 | - console.log("早高峰周转时间(固定最大停战时间):" + _paramObj.calcuPeakZzsj() + "分钟"); | |
| 330 | - console.log("早高峰发车时间范围:" + _paramObj.getMPeakMinFcjx() + "分钟 --- " + _paramObj.getMPeakMaxFcjx() + "分钟"); | |
| 331 | - console.log("预估早高峰第" + _approximate_zgfQIndex + "(index)圈,第" + _approximate_zgfBIndex + "(index)班次车辆全部发出"); | |
| 332 | - console.log("预估晚高峰第" + _approximate_wgfQIndex + "(index)圈,第" + _approximate_wgfBIndex + "(index)班次车辆全部发出"); | |
| 333 | - console.log("//---------------- 行车计划,初始化方法2 end ----------------//"); | |
| 334 | - }; | |
| 335 | - | |
| 336 | - //----------------------- 初始化方法3,计算连班分班的路牌分布 ----------------// | |
| 337 | - var _iBx_lb_lpcount; // 连班路牌数 | |
| 338 | - var _iBx_5_2_fb_lpcount; // 5休2分班路牌数 | |
| 339 | - var _iBx_other_fb_lpcount; // 其他分班路牌数 | |
| 340 | - | |
| 341 | - var _fnInitFun3 = function() { // 初始化方法3 | |
| 342 | - console.log("//---------------- 行车计划,初始化方法3 start ----------------//"); | |
| 343 | - | |
| 344 | - //--------------------- 1、计算分班连班班型车辆分布数 --------------------// | |
| 345 | - // 总共车辆数(高峰最大车辆数) | |
| 346 | - var iCls = _paramObj.calcuClzx(); | |
| 347 | - // 低谷最少配车(连班车数量) | |
| 348 | - var iDgminpc = Math.round(_paramObj.calcuTroughZzsj() / _paramObj.getTroughMaxFcjx()); | |
| 349 | - // 加班车路牌数(做5休2的路牌数) | |
| 350 | - var i_5_2_lpes = _paramObj.getJBLpes(); | |
| 351 | - | |
| 352 | - // 做些简单的验证 | |
| 353 | - if (iCls < iDgminpc) { | |
| 354 | - alert("总配车数小于低谷最小配车"); | |
| 355 | - throw "总配车数小于低谷最小配车"; | |
| 356 | - } | |
| 357 | - if (iDgminpc < 2) { | |
| 358 | - alert("连班路牌小于2,办不到啊"); | |
| 359 | - throw "连班路牌小于2,办不到啊"; | |
| 360 | - } | |
| 361 | - if (iCls - iDgminpc < i_5_2_lpes) { | |
| 362 | - alert("总分班路牌数小于加班路牌数"); | |
| 363 | - throw "总分班路牌数小于加班路牌数"; | |
| 364 | - } | |
| 365 | - | |
| 366 | - //// 修正连班路牌数,班次间隔大于20的,加1,直至班次间隔小于20 | |
| 367 | - //while(_paramObj.calcuPeakZzsj() / iDgminpc > 20) { | |
| 368 | - // iDgminpc ++; | |
| 369 | - //} | |
| 370 | - _iBx_lb_lpcount = iDgminpc; | |
| 371 | - | |
| 372 | - _iBx_5_2_fb_lpcount = i_5_2_lpes; | |
| 373 | - _iBx_other_fb_lpcount = iCls - _iBx_lb_lpcount - i_5_2_lpes; | |
| 374 | - | |
| 375 | - //------------------------ 2、利用间隔法计算连班路牌分布 --------------------// | |
| 376 | - var i; | |
| 377 | - var j; | |
| 378 | - var iC1 = Math.floor(_internalLpArray.length / _iBx_lb_lpcount); | |
| 379 | - var iC2 = _internalLpArray.length % _iBx_lb_lpcount; | |
| 380 | - var iLpIndex; | |
| 381 | - | |
| 382 | - for (i = 0; i < _iBx_lb_lpcount - iC2; i++) { | |
| 383 | - iLpIndex = i * iC1; | |
| 384 | - _internalLpArray[iLpIndex].setBxLb(true); | |
| 385 | - _internalLpArray[iLpIndex].setBxDesc("连班"); | |
| 386 | - } | |
| 387 | - for (j = 0; j < iC2; j++) { | |
| 388 | - iLpIndex = i * iC1 + j * (iC1 + 1); | |
| 389 | - _internalLpArray[iLpIndex].setBxLb(true); | |
| 390 | - _internalLpArray[iLpIndex].setBxDesc("连班"); | |
| 391 | - } | |
| 392 | - | |
| 393 | - //------------------------ 3、利用间隔法计算分班班型路牌分布 --------------------// | |
| 394 | - // 获取分班路牌索引 | |
| 395 | - var aNotLbIndexes = []; | |
| 396 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 397 | - if (!_internalLpArray[i].isBxLb()) { | |
| 398 | - aNotLbIndexes.push(i); | |
| 399 | - } | |
| 400 | - } | |
| 401 | - // 先5休2分班 | |
| 402 | - iC1 = Math.floor(aNotLbIndexes.length / _iBx_5_2_fb_lpcount); | |
| 403 | - iC2 = aNotLbIndexes.length % _iBx_5_2_fb_lpcount; | |
| 404 | - | |
| 405 | - for (i = 0; i < _iBx_5_2_fb_lpcount - iC2; i++) { | |
| 406 | - iLpIndex = aNotLbIndexes[i * iC1]; | |
| 407 | - _internalLpArray[iLpIndex].setBxLb(false); | |
| 408 | - _internalLpArray[iLpIndex].setBxFb(true); | |
| 409 | - _internalLpArray[iLpIndex].setBxFb5_2(true); | |
| 410 | - _internalLpArray[iLpIndex].setBxDesc("5休2分班"); | |
| 411 | - } | |
| 412 | - for (i = 0; i < iC2; i++) { | |
| 413 | - iLpIndex = aNotLbIndexes[_iBx_5_2_fb_lpcount - iC2 + i * (iC1 + 1)]; | |
| 414 | - _internalLpArray[iLpIndex].setBxLb(false); | |
| 415 | - _internalLpArray[iLpIndex].setBxFb(true); | |
| 416 | - _internalLpArray[iLpIndex].setBxFb5_2(true); | |
| 417 | - _internalLpArray[iLpIndex].setBxDesc("5休2分班"); | |
| 418 | - } | |
| 419 | - // 其他分班 | |
| 420 | - for (i = 0; i < aNotLbIndexes.length; i++) { | |
| 421 | - iLpIndex = aNotLbIndexes[i]; | |
| 422 | - if (!_internalLpArray[iLpIndex].isBxFb5_2()) { | |
| 423 | - _internalLpArray[iLpIndex].setBxLb(false); | |
| 424 | - _internalLpArray[iLpIndex].setBxFb(true); | |
| 425 | - _internalLpArray[iLpIndex].setBxFb5_2(false); | |
| 426 | - _internalLpArray[iLpIndex].setBxDesc("其他分班"); | |
| 427 | - } | |
| 428 | - } | |
| 429 | - | |
| 430 | - console.log("高峰周转时间:" + _paramObj.calcuPeakZzsj()); | |
| 431 | - console.log("连班路牌数:" + _iBx_lb_lpcount); | |
| 432 | - console.log("5休2分班路牌数:" + _iBx_5_2_fb_lpcount); | |
| 433 | - console.log("其他分班路牌数:" + _iBx_other_fb_lpcount); | |
| 434 | - var aLbIndexes = []; | |
| 435 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 436 | - if (_internalLpArray[i].isBxLb()) { | |
| 437 | - aLbIndexes.push(i); | |
| 438 | - } | |
| 439 | - } | |
| 440 | - console.log("连班路牌indexes=" + aLbIndexes); | |
| 441 | - var a_5_2_fbIndexes = []; | |
| 442 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 443 | - if (_internalLpArray[i].isBxFb() && _internalLpArray[i].isBxFb5_2()) { | |
| 444 | - a_5_2_fbIndexes.push(i); | |
| 445 | - } | |
| 446 | - } | |
| 447 | - console.log("5休2分班路牌indexes=" + a_5_2_fbIndexes); | |
| 448 | - var a_other_fbIndexes = []; | |
| 449 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 450 | - if (_internalLpArray[i].isBxFb() && !_internalLpArray[i].isBxFb5_2()) { | |
| 451 | - a_other_fbIndexes.push(i); | |
| 452 | - } | |
| 453 | - } | |
| 454 | - console.log("其他分班路牌indexes=" + a_other_fbIndexes); | |
| 455 | - | |
| 456 | - console.log("//---------------- 行车计划,初始化方法3 end ----------------//"); | |
| 457 | - }; | |
| 458 | - | |
| 459 | - //----------------------- 初始化方法4,计算中标线位置 -------------------------// | |
| 460 | - var _iZbx_lpIndex; // 中标线对应第几个路牌 | |
| 461 | - | |
| 462 | - var _fnInitFun4 = function() { // 初始化方法4 | |
| 463 | - console.log("//---------------- 行车计划,初始化方法4 start ----------------//"); | |
| 464 | - | |
| 465 | - //---------------------------- 1、模拟一个中标线,使用临时路牌 ----------------------// | |
| 466 | - // 构造中标线 | |
| 467 | - // 中标线开始时间,就是方向的首班车时间 | |
| 468 | - var oSt = !_qIsUp ? _paramObj.getUpFirstDTimeObj() : _paramObj.getDownFirstDTimeObj(); | |
| 469 | - // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向 | |
| 470 | - // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向 | |
| 471 | - var oEt; | |
| 472 | - if (_paramObj.getUpLastDtimeObj().isBefore( | |
| 473 | - _paramObj.getDownLastDTimeObj())) { | |
| 474 | - oEt = _paramObj.getDownLastDTimeObj(); | |
| 475 | - } else { | |
| 476 | - oEt = _paramObj.getUpLastDtimeObj(); | |
| 477 | - } | |
| 478 | - | |
| 479 | - var oTempLp = new InternalLpObj({lpNo: -999, lpName: "-999"}, _qCount, _qIsUp); | |
| 480 | - oTempLp.initDataFromTimeToTime( | |
| 481 | - oSt, | |
| 482 | - oEt, | |
| 483 | - !_qIsUp, | |
| 484 | - 0, | |
| 485 | - _paramObj, | |
| 486 | - _factory | |
| 487 | - ); | |
| 488 | - | |
| 489 | - //------------------------ 2、找出中标线的早高峰班次,计算应该插在当前路牌数组的那个位置 ----------------// | |
| 490 | - // 找出中标线对应的早高峰的班次对象 | |
| 491 | - var oZb_gf_bc = oTempLp.getBc(_approximate_zgfQIndex, _approximate_zgfBIndex); | |
| 492 | - //alert(oZb_gf_bc.getFcTimeObj().format("HH:mm")); | |
| 493 | - | |
| 494 | - // 把所有连班路牌高峰班次重新构造成一个一个的圈数组,计算对应中标线最近的是第几个路牌 | |
| 495 | - // 中标线和上标线一样在连班路牌上 | |
| 496 | - var aTempq = []; | |
| 497 | - var oTempq; | |
| 498 | - var oTempb; | |
| 499 | - var i; | |
| 500 | - var oLp; | |
| 501 | - | |
| 502 | - var aLbIndexes = []; // 连班的路牌索引 | |
| 503 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 504 | - if (_internalLpArray[i].isBxLb()) { | |
| 505 | - aLbIndexes.push(i); | |
| 506 | - } | |
| 507 | - } | |
| 508 | - | |
| 509 | - for (i = 0; i < aLbIndexes.length; i++) { | |
| 510 | - oLp = _internalLpArray[aLbIndexes[i]]; | |
| 511 | - | |
| 512 | - oTempb = oLp.getBc(_approximate_zgfQIndex, _approximate_zgfBIndex); | |
| 513 | - if (oTempb.isUp() == _qIsUp) { | |
| 514 | - oTempq = new InternalGroupObj(oLp, _qIsUp, oTempb, undefined); | |
| 515 | - } else { | |
| 516 | - oTempq = new InternalGroupObj(oLp, _qIsUp, undefined, oTempb); | |
| 517 | - } | |
| 518 | - aTempq.push(oTempq); | |
| 519 | - | |
| 520 | - } | |
| 521 | - | |
| 522 | - var aTtindex = oTempLp.fnGetQBcIndexWithFcTimeFromGroupArray( // 找出最接近中标线的路牌索引 | |
| 523 | - oZb_gf_bc.getFcTimeObj(), | |
| 524 | - aTempq, | |
| 525 | - true, | |
| 526 | - true | |
| 527 | - ); | |
| 528 | - | |
| 529 | - _iZbx_lpIndex = aLbIndexes[aTtindex[0]]; // 中标线放在第几个路牌 | |
| 530 | - | |
| 531 | - oTempLp.getMinBcObj().fnSetIsFirstBc(true); // 设置首班班次标识 | |
| 532 | - | |
| 533 | - if (_iZbx_lpIndex == 0) { // 如果中标线和上标线一致 | |
| 534 | - var oFirstBcIndexes = oTempLp.getMinBcObjPosition(); | |
| 535 | - var oFirstBc = oTempLp.getMinBcObj(); | |
| 536 | - oFirstBc.setLp(_internalLpArray[_iZbx_lpIndex]); | |
| 537 | - oFirstBc.fnSetDelFlag(false); | |
| 538 | - _internalLpArray[_iZbx_lpIndex].setBc(oFirstBcIndexes[0], oFirstBcIndexes[1], oFirstBc); | |
| 539 | - } else { | |
| 540 | - oTempLp.setLp(_lpArray[_iZbx_lpIndex]); // 设置原始路牌对象 | |
| 541 | - oTempLp._$_aVerticalIntervalTime = _internalLpArray[_iZbx_lpIndex]._$_aVerticalIntervalTime; // 设置纵向最小发车间隔 | |
| 542 | - oTempLp.setBxLb(_internalLpArray[_iZbx_lpIndex].isBxLb()); | |
| 543 | - oTempLp.setBxFb(_internalLpArray[_iZbx_lpIndex].isBxFb()); | |
| 544 | - oTempLp.setBxFb5_2(_internalLpArray[_iZbx_lpIndex].isBxFb5_2()); | |
| 545 | - | |
| 546 | - // 修正除了第一个班次外,其余其他班次 | |
| 547 | - var iBcindex = 0; | |
| 548 | - for (i = 1; i < _qCount; i++) { | |
| 549 | - while (iBcindex <= 1) { | |
| 550 | - if (oTempLp.getBc(i, iBcindex)) { // 替换存在的班次 | |
| 551 | - oTempLp.setBc(i, iBcindex, _fnGenerateBc(_iZbx_lpIndex, i, iBcindex)); | |
| 552 | - } | |
| 553 | - iBcindex ++; | |
| 554 | - } | |
| 555 | - iBcindex = 0; | |
| 556 | - } | |
| 557 | - | |
| 558 | - _internalLpArray[_iZbx_lpIndex] = oTempLp; | |
| 559 | - } | |
| 560 | - | |
| 561 | - console.log("中标线对应第" + (_iZbx_lpIndex + 1) + "个路牌"); | |
| 562 | - | |
| 563 | - console.log("//---------------- 行车计划,初始化方法4 end ----------------//"); | |
| 564 | - }; | |
| 565 | - | |
| 566 | - //-------------------- 重要的内部方法 -----------------------// | |
| 567 | - /** | |
| 568 | - * 核心方法,利用路牌间隔纵向生成班次。 | |
| 569 | - * @param iLpindex 路牌索引 | |
| 570 | - * @param iQindex 圈索引 | |
| 571 | - * @param iBcindex 班次索引 | |
| 572 | - * @returns object InternalBcObj,失败 false | |
| 573 | - */ | |
| 574 | - var _fnGenerateBc = function(iLpindex, iQindex, iBcindex) { | |
| 575 | - // 以上标线为起始点,使用路牌在不同圈,班次索引的发车间隔,计算班次 | |
| 576 | - // 注意,发车间隔是指下一个班次应该距离当前班次间隔,是从下往上的 | |
| 577 | - | |
| 578 | - // 1、参数验证 | |
| 579 | - if (iLpindex == 0) { // 上标线的班次不需要生成 | |
| 580 | - return false; | |
| 581 | - } | |
| 582 | - | |
| 583 | - // 2、计算间隔 | |
| 584 | - var i; | |
| 585 | - var oLp; | |
| 586 | - var iTime = 0; | |
| 587 | - for (i = 0; i < iLpindex; i++) { | |
| 588 | - oLp = _internalLpArray[i]; | |
| 589 | - iTime += oLp.fnGetVerticalIntervalTime(iQindex, iBcindex); | |
| 590 | - } | |
| 591 | - | |
| 592 | - // 3、生成班次 | |
| 593 | - var _oKsbc = _internalLpArray[0].getBc(iQindex, iBcindex); | |
| 594 | - if (!_oKsbc) { | |
| 595 | - return false; | |
| 596 | - } | |
| 597 | - var _oKssj = _paramObj.addMinute(_oKsbc.getFcTimeObj(), iTime); | |
| 598 | - var _oBc = _factory.createBcObj( | |
| 599 | - _internalLpArray[iLpindex], | |
| 600 | - "normal", _oKsbc.isUp(), | |
| 601 | - 1, _oKssj, _paramObj); | |
| 602 | - | |
| 603 | - return _oBc; | |
| 604 | - | |
| 605 | - }; | |
| 606 | - | |
| 607 | - /** | |
| 608 | - * 核心方法,在指定位置生成班次并添加到路牌指定位置中。 | |
| 609 | - * @param lpIndex 第几个路牌 | |
| 610 | - * @param qIndex 第几圈 | |
| 611 | - * @param bcIndex 第几个班次 | |
| 612 | - */ | |
| 613 | - var _fnGenerateBcAndSetBc = function(lpIndex, qIndex, bcIndex) { | |
| 614 | - var _bcObj = _fnGenerateBc(lpIndex, qIndex, bcIndex); | |
| 615 | - if (_bcObj) { | |
| 616 | - _internalLpArray[lpIndex].setBc(qIndex, bcIndex, _bcObj); | |
| 617 | - } | |
| 618 | - }; | |
| 619 | - | |
| 620 | - /** | |
| 621 | - * 获取班次列表。 | |
| 622 | - * @param oIsUp 是否上行 | |
| 623 | - * @param oStartTime 开始时间对象 | |
| 624 | - * @returns [(InternalBcObj)] | |
| 625 | - */ | |
| 626 | - var _fnGetBcList2 = function(oIsUp, oStartTime) { | |
| 627 | - var i; | |
| 628 | - var j; | |
| 629 | - var oLp; | |
| 630 | - var oBc; | |
| 631 | - var aBc = []; | |
| 632 | - | |
| 633 | - for (j = 0; j < _qCount; j++) { | |
| 634 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 635 | - oLp = _internalLpArray[i]; | |
| 636 | - oBc = oLp.getBc( | |
| 637 | - j, | |
| 638 | - _qIsUp == oIsUp ? 0 : 1 | |
| 639 | - ); | |
| 640 | - if (oBc && oBc.getFcTimeObj().isAfter(oStartTime)) { | |
| 641 | - aBc.push(oBc); | |
| 642 | - } | |
| 643 | - } | |
| 644 | - } | |
| 645 | - | |
| 646 | - var aBcFcTime = []; | |
| 647 | - for (i = 0; i < aBc.length; i++) { | |
| 648 | - oBc = aBc[i]; | |
| 649 | - aBcFcTime.push(oBc.getFcTimeObj().format("HH:mm")); | |
| 650 | - } | |
| 651 | - console.log((oIsUp ? "上行班次列表:" : "下行班次列表:") + aBcFcTime.join(",")); | |
| 652 | - | |
| 653 | - return aBc; | |
| 654 | - }; | |
| 655 | - | |
| 656 | - /** | |
| 657 | - * 获取班次列表。 | |
| 658 | - * @param isUp boolean 是否上行 | |
| 659 | - * @returns [(InternalBcObj)] | |
| 660 | - */ | |
| 661 | - var _fnGetBcList = function(isUp) { | |
| 662 | - var i; | |
| 663 | - var j; | |
| 664 | - var oLp; | |
| 665 | - var oBc; | |
| 666 | - var aBc = []; | |
| 667 | - | |
| 668 | - for (j = 0; j < _qCount; j++) { | |
| 669 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 670 | - oLp = _internalLpArray[i]; | |
| 671 | - oBc = oLp.getBc( | |
| 672 | - j, | |
| 673 | - _qIsUp == isUp ? 0 : 1 | |
| 674 | - ); | |
| 675 | - if (oBc) { | |
| 676 | - aBc.push(oBc); | |
| 677 | - } | |
| 678 | - } | |
| 679 | - } | |
| 680 | - | |
| 681 | - var aBcFcTime = []; | |
| 682 | - for (i = 0; i < aBc.length; i++) { | |
| 683 | - oBc = aBc[i]; | |
| 684 | - aBcFcTime.push(oBc.getFcTimeObj().format("HH:mm")); | |
| 685 | - } | |
| 686 | - console.log((isUp ? "上行班次列表:" : "下行班次列表:") + aBcFcTime.join(",")); | |
| 687 | - | |
| 688 | - return aBc; | |
| 689 | - }; | |
| 690 | - | |
| 691 | - /** | |
| 692 | - * 查找离指定时间最近的前面的班次索引信息 | |
| 693 | - * @param timeObj 查找时间 | |
| 694 | - * @param isUp 是否上行 | |
| 695 | - * @returns [{路牌index},{圈index},{班次index}] | |
| 696 | - */ | |
| 697 | - var _fnFindUpClosedBcIndexWithTime = function(timeObj, isUp) { | |
| 698 | - | |
| 699 | - var _lpObj; | |
| 700 | - var _groupObj; | |
| 701 | - var _bcObj; | |
| 702 | - var _i; | |
| 703 | - var _j; | |
| 704 | - var timediff; // 时间差取绝对值 | |
| 705 | - | |
| 706 | - var _lpIndex; | |
| 707 | - var _up_qIndex; | |
| 708 | - var _up_bIndex; | |
| 709 | - | |
| 710 | - for (_i = 0; _i < _qCount; _i++) { | |
| 711 | - for (_j = 0; _j < _internalLpArray.length; _j++) { | |
| 712 | - _lpObj = _internalLpArray[_j]; | |
| 713 | - _groupObj = _lpObj.getGroup(_i); | |
| 714 | - _bcObj = isUp == _qIsUp ? _groupObj.getBc1() : _groupObj.getBc2(); | |
| 715 | - if (!_bcObj) { // 没有班次动态生成一个,可能生成不出的 | |
| 716 | - _bcObj = _fnGenerateBc(_j, _i, isUp == _qIsUp ? 0 : 1); | |
| 717 | - } | |
| 718 | - if (_bcObj) { | |
| 719 | - if (timeObj.diff(_bcObj.getFcTimeObj()) >= 0) { | |
| 720 | - if (!timediff) { | |
| 721 | - timediff = timeObj.diff(_bcObj.getFcTimeObj()); | |
| 722 | - _lpIndex = _j; | |
| 723 | - _up_qIndex = _i; | |
| 724 | - _up_bIndex = isUp == _qIsUp ? 0 : 1; | |
| 725 | - } else { | |
| 726 | - if (timeObj.diff(_bcObj.getFcTimeObj()) < timediff) { | |
| 727 | - timediff = timeObj.diff(_bcObj.getFcTimeObj()); | |
| 728 | - _lpIndex = _j; | |
| 729 | - _up_qIndex = _i; | |
| 730 | - _up_bIndex = isUp == _qIsUp ? 0 : 1; | |
| 731 | - } | |
| 732 | - } | |
| 733 | - } | |
| 734 | - } | |
| 735 | - } | |
| 736 | - } | |
| 737 | - | |
| 738 | - if (_lpIndex == undefined) { | |
| 739 | - return false; | |
| 740 | - } | |
| 741 | - | |
| 742 | - var bcindex = []; | |
| 743 | - bcindex.push(_lpIndex); | |
| 744 | - bcindex.push(_up_qIndex); | |
| 745 | - bcindex.push(_up_bIndex); | |
| 746 | - | |
| 747 | - return bcindex; | |
| 748 | - }; | |
| 749 | - | |
| 750 | - /** | |
| 751 | - * 查找离指定时间最近的后面的班次索引信息 | |
| 752 | - * @param timeObj 查找时间 | |
| 753 | - * @param isUp 是否上行 | |
| 754 | - * @returns [{路牌index},{圈index},{班次index}] | |
| 755 | - */ | |
| 756 | - var _fnFindDownClosedBcIndexWithTime = function(timeObj, isUp) { | |
| 757 | - var _lpObj; | |
| 758 | - var _groupObj; | |
| 759 | - var _bcObj; | |
| 760 | - var _i; | |
| 761 | - var _j; | |
| 762 | - var timediff; // 时间差取绝对值 | |
| 763 | - | |
| 764 | - var _lpIndex; | |
| 765 | - var _down_qIndex; | |
| 766 | - var _down_bIndex; | |
| 767 | - | |
| 768 | - var flag; | |
| 769 | - | |
| 770 | - for (_i = 0; _i < _qCount; _i++) { | |
| 771 | - for (_j = 0; _j < _internalLpArray.length; _j++) { | |
| 772 | - _lpObj = _internalLpArray[_j]; | |
| 773 | - _groupObj = _lpObj.getGroup(_i); | |
| 774 | - // TODO:bug | |
| 775 | - _bcObj = isUp == _qIsUp ? _groupObj.getBc1() : _groupObj.getBc2(); | |
| 776 | - if (!_bcObj) { // 没有班次动态生成一个,可能生成不出的 | |
| 777 | - _bcObj = _fnGenerateBc(_j, _i, isUp == _qIsUp ? 0 : 1); | |
| 778 | - } | |
| 779 | - if (_bcObj) { | |
| 780 | - //console.log("timeobj -> bcobj diff flag " + | |
| 781 | - // timeObj.format("HH:mm") + "->" + | |
| 782 | - // _bcObj.getFcTimeObj().format("HH:mm") + | |
| 783 | - // timeObj.diff(_bcObj.getFcTimeObj()) + | |
| 784 | - // (timeObj.diff(_bcObj.getFcTimeObj()) <= 0) | |
| 785 | - //); | |
| 786 | - | |
| 787 | - flag = (timeObj.diff(_bcObj.getFcTimeObj())) <= 0; | |
| 788 | - | |
| 789 | - if (flag) { | |
| 790 | - if (!timediff) { | |
| 791 | - timediff = timeObj.diff(_bcObj.getFcTimeObj()); | |
| 792 | - _lpIndex = _j; | |
| 793 | - _down_qIndex = _i; | |
| 794 | - _down_bIndex = isUp == _qIsUp ? 0 : 1; | |
| 795 | - } else { | |
| 796 | - if ((timeObj.diff(_bcObj.getFcTimeObj())) > timediff) { | |
| 797 | - timediff = timeObj.diff(_bcObj.getFcTimeObj()); | |
| 798 | - _lpIndex = _j; | |
| 799 | - _down_qIndex = _i; | |
| 800 | - _down_bIndex = isUp == _qIsUp ? 0 : 1; | |
| 801 | - } | |
| 802 | - } | |
| 803 | - } | |
| 804 | - } | |
| 805 | - } | |
| 806 | - } | |
| 807 | - | |
| 808 | - if (_lpIndex == undefined) { | |
| 809 | - return false; | |
| 810 | - } | |
| 811 | - | |
| 812 | - var bcindex = []; | |
| 813 | - bcindex.push(_lpIndex); | |
| 814 | - bcindex.push(_down_qIndex); | |
| 815 | - bcindex.push(_down_bIndex); | |
| 816 | - | |
| 817 | - return bcindex; | |
| 818 | - }; | |
| 819 | - | |
| 820 | - /** | |
| 821 | - * 获取班次索引。 | |
| 822 | - * @param oBc 班次对象 | |
| 823 | - * @returns [{路牌索引},{圈索引},{班次索引}] | |
| 824 | - */ | |
| 825 | - var _fnGetBcIndex = function(oBc) { | |
| 826 | - // 路牌索引 | |
| 827 | - var i; | |
| 828 | - var iLpIndex; | |
| 829 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 830 | - if (_internalLpArray[i]._$$_orign_lp_obj == oBc._$$_internal_lp_obj._$$_orign_lp_obj) { | |
| 831 | - iLpIndex = i; | |
| 832 | - break; | |
| 833 | - } | |
| 834 | - } | |
| 835 | - // 圈索引 | |
| 836 | - var j; | |
| 837 | - var iGroupIndex; | |
| 838 | - var bFlag = false; | |
| 839 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 840 | - if (bFlag) { | |
| 841 | - break; | |
| 842 | - } | |
| 843 | - for (j = 0; j < _qCount; j++) { | |
| 844 | - if (_internalLpArray[i]._$_groupBcArray[j] == oBc._$$_internal_group_obj) { | |
| 845 | - iGroupIndex = j; | |
| 846 | - bFlag = true; | |
| 847 | - break; | |
| 848 | - } | |
| 849 | - } | |
| 850 | - } | |
| 851 | - // 班次索引 | |
| 852 | - var iBcIndex = _qIsUp == oBc.isUp() ? 0 : 1; | |
| 853 | - | |
| 854 | - if (iLpIndex == undefined) { | |
| 855 | - return null; | |
| 856 | - } else { | |
| 857 | - return [].concat(iLpIndex, iGroupIndex, iBcIndex); | |
| 858 | - } | |
| 859 | - | |
| 860 | - }; | |
| 861 | - | |
| 862 | - return { | |
| 863 | - //------------- 布局初始化方法 ------------// | |
| 864 | - /** | |
| 865 | - * 初始化数据,使用标线初始化 | |
| 866 | - */ | |
| 867 | - fnInitDataWithBxLayout: function() { | |
| 868 | - // 初始化布局1,构造上标线,计算圈数,把上标线数据放入第一个路牌中 | |
| 869 | - _fnInitFun1(); | |
| 870 | - // 初始化布局2,从上标线的某个班次开始,构造所有路牌的早高峰班次,晚高峰班次,计算路牌在各个圈中的间隔 | |
| 871 | - _fnInitFun2(); | |
| 872 | - // 初始化布局3,计算连班分班路牌分布 | |
| 873 | - _fnInitFun3(); | |
| 874 | - // 初始化布局4,计算中标线位置 | |
| 875 | - _fnInitFun4(); | |
| 876 | - | |
| 877 | - }, | |
| 878 | - | |
| 879 | - /** | |
| 880 | - * 调整高峰班次, | |
| 881 | - * 初始化生成早高峰,晚高峰班次并不准确,因为根据高峰时间段,并不在一个完整圈内,应该是在两个或多个圈之间 | |
| 882 | - * 当初始化定好布局后(上标线,中标线),然后确定每个路牌的班型(连班,分班,5休2分班)后 | |
| 883 | - * 然后重新计算框在高峰时间段内的班次索引,不足的添加,之前多加的删除(只删除分班路牌上的) | |
| 884 | - * @param isZgf 是否早高峰 | |
| 885 | - * @param isUp 是否上行 | |
| 886 | - */ | |
| 887 | - fnAdjustGfbc : function(isZgf, isUp) { | |
| 888 | - var oStartTime; // 开始时间 | |
| 889 | - var oEndTime; // 结束时间 | |
| 890 | - var aStartBcIndex; // 开始班次索引 | |
| 891 | - var aEndBcIndex; // 结束班次索引 | |
| 892 | - | |
| 893 | - oStartTime = isZgf ? _paramObj.getMPeakStartTimeObj() : _paramObj.getEPeakStartTimeObj(); | |
| 894 | - oEndTime = isZgf ? _paramObj.getMPeakEndTimeObj() : _paramObj.getEPeakEndTimeObj(); | |
| 895 | - | |
| 896 | - aStartBcIndex = _fnFindUpClosedBcIndexWithTime(oStartTime, isUp); | |
| 897 | - aEndBcIndex = _fnFindDownClosedBcIndexWithTime(oEndTime, isUp); | |
| 898 | - | |
| 899 | - var iLpIndex; | |
| 900 | - var iQIndex; | |
| 901 | - var iBcIndex; | |
| 902 | - var iQInternelCount; // 高峰时间段中间包含的圈数 | |
| 903 | - var i; | |
| 904 | - var j; | |
| 905 | - | |
| 906 | - var oLp; | |
| 907 | - | |
| 908 | - if (aStartBcIndex && aEndBcIndex) { | |
| 909 | - iLpIndex = aStartBcIndex[0]; | |
| 910 | - iQIndex = aStartBcIndex[1]; | |
| 911 | - iBcIndex = aStartBcIndex[2]; | |
| 912 | - | |
| 913 | - // 处理头 | |
| 914 | - // 删除头部多余班次 | |
| 915 | - for (j = 0; j < iLpIndex; j++) { | |
| 916 | - oLp = _internalLpArray[j]; | |
| 917 | - if (oLp.isBxFb() && oLp.getBc(iQIndex, iBcIndex)) { | |
| 918 | - oLp.removeBc(iQIndex, iBcIndex); | |
| 919 | - } | |
| 920 | - } | |
| 921 | - | |
| 922 | - for (j = iLpIndex; j < _internalLpArray.length; j++) { | |
| 923 | - oLp = _internalLpArray[j]; | |
| 924 | - if (!oLp.getBc(iQIndex, iBcIndex)) { | |
| 925 | - _fnGenerateBcAndSetBc(j, iQIndex, iBcIndex); | |
| 926 | - } | |
| 927 | - } | |
| 928 | - | |
| 929 | - // 处理中间 | |
| 930 | - iQInternelCount = aEndBcIndex[1] - aStartBcIndex[1] - 1; | |
| 931 | - for (i = 1; i <= iQInternelCount; i++) { | |
| 932 | - oLp = _internalLpArray[iQIndex + i]; | |
| 933 | - | |
| 934 | - if (!oLp.getBc(iQIndex + i, iBcIndex)) { | |
| 935 | - _fnGenerateBcAndSetBc(i, iQIndex + i, iBcIndex); | |
| 936 | - } | |
| 937 | - } | |
| 938 | - | |
| 939 | - // 处理尾部 | |
| 940 | - iLpIndex = aEndBcIndex[0]; | |
| 941 | - iQIndex = aEndBcIndex[1]; | |
| 942 | - iBcIndex = aEndBcIndex[2]; | |
| 943 | - | |
| 944 | - // 删除尾部多余的班次 | |
| 945 | - for (j = iLpIndex; j < _internalLpArray.length; j++) { | |
| 946 | - oLp = _internalLpArray[j]; | |
| 947 | - if (oLp.isBxFb() && oLp.getBc(iQIndex, iBcIndex)) { | |
| 948 | - oLp.removeBc(iQIndex, iBcIndex); | |
| 949 | - } | |
| 950 | - } | |
| 951 | - | |
| 952 | - if (aStartBcIndex[1] != aEndBcIndex[1]) { // 指定时间范围跨圈 | |
| 953 | - for (j = 0; j < iLpIndex; j++) { | |
| 954 | - oLp = _internalLpArray[j]; | |
| 955 | - if (!oLp.getBc(iQIndex, iBcIndex)) { | |
| 956 | - _fnGenerateBcAndSetBc(j, iQIndex, iBcIndex); | |
| 957 | - } | |
| 958 | - } | |
| 959 | - } else { | |
| 960 | - // 不跨圈,不用处理,处理头的时候已经加了 | |
| 961 | - } | |
| 962 | - | |
| 963 | - } | |
| 964 | - | |
| 965 | - }, | |
| 966 | - | |
| 967 | - /** | |
| 968 | - * 按照营运时间要求补充班次, | |
| 969 | - * 早高峰7:45分以前出场运营, | |
| 970 | - * 晚高峰16:10分以前出场运营 | |
| 971 | - */ | |
| 972 | - fnCalcuLpBc_yy: function() { | |
| 973 | - // 补班次的时候,针对的是分班班型 | |
| 974 | - var i; | |
| 975 | - var _oLp; | |
| 976 | - var _oBc; | |
| 977 | - var _aMinBcIndex; | |
| 978 | - var _aMaxBcIndex; | |
| 979 | - | |
| 980 | - var _qIndex; | |
| 981 | - var _bIndex; | |
| 982 | - | |
| 983 | - var _zgfCDate = _paramObj.toTimeObj("7:45"); | |
| 984 | - var _wgfCDate = _paramObj.toTimeObj("16:10"); | |
| 985 | - var _ccsj; | |
| 986 | - | |
| 987 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 988 | - _oLp = _internalLpArray[i]; | |
| 989 | - if (_oLp.isBxFb()) { // 分班路牌 | |
| 990 | - // 早高峰部分 | |
| 991 | - _aMinBcIndex = _oLp.getMinBcObjPosition(); | |
| 992 | - _qIndex = _aMinBcIndex[0]; | |
| 993 | - _bIndex = _aMinBcIndex[1]; | |
| 994 | - _oBc = _oLp.getBc(_qIndex, _bIndex); | |
| 995 | - if (_qIsUp) { | |
| 996 | - _ccsj = _bIndex == 0 ? | |
| 997 | - _paramObj.getUpOutTime() : | |
| 998 | - _paramObj.getDownOutTime(); | |
| 999 | - } else { | |
| 1000 | - _ccsj = _bIndex == 0 ? | |
| 1001 | - _paramObj.getDownOutTime() : | |
| 1002 | - _paramObj.getUpOutTime(); | |
| 1003 | - } | |
| 1004 | - if (_zgfCDate.isBefore(_paramObj.addMinute(_oBc.getFcTimeObj(), -_ccsj))) { | |
| 1005 | - _fnGenerateBcAndSetBc( | |
| 1006 | - i, | |
| 1007 | - _bIndex == 0 ? _qIndex - 1 : _qIndex, | |
| 1008 | - _bIndex == 0 ? 1 : 0 | |
| 1009 | - ) | |
| 1010 | - } | |
| 1011 | - | |
| 1012 | - // 晚高峰部分 | |
| 1013 | - _aMaxBcIndex = _oLp.getMaxBcObjPosition(); | |
| 1014 | - _qIndex = _aMaxBcIndex[0]; | |
| 1015 | - _bIndex = _aMaxBcIndex[1]; | |
| 1016 | - _oBc = _oLp.getBc( | |
| 1017 | - _bIndex == 0 ? _qIndex - 1 : _qIndex, | |
| 1018 | - _bIndex == 0 ? 1 : 0 | |
| 1019 | - ); | |
| 1020 | - if (!_oBc) { // 前一个班次不存在,再判定加不加 | |
| 1021 | - _oBc = _oLp.getBc(_qIndex, _bIndex); | |
| 1022 | - if (_qIsUp) { | |
| 1023 | - _ccsj = _bIndex == 0 ? | |
| 1024 | - _paramObj.getUpOutTime() : | |
| 1025 | - _paramObj.getDownOutTime(); | |
| 1026 | - } else { | |
| 1027 | - _ccsj = _bIndex == 0 ? | |
| 1028 | - _paramObj.getDownOutTime() : | |
| 1029 | - _paramObj.getUpOutTime(); | |
| 1030 | - } | |
| 1031 | - if (_wgfCDate.isBefore(_paramObj.addMinute(_oBc.getFcTimeObj(), -_ccsj))) { | |
| 1032 | - _fnGenerateBcAndSetBc( | |
| 1033 | - i, | |
| 1034 | - _bIndex == 0 ? _qIndex - 1 : _qIndex, | |
| 1035 | - _bIndex == 0 ? 1 : 0 | |
| 1036 | - ) | |
| 1037 | - } | |
| 1038 | - } | |
| 1039 | - } | |
| 1040 | - } | |
| 1041 | - }, | |
| 1042 | - | |
| 1043 | - /** | |
| 1044 | - * 补充做5休2的班型班次。 | |
| 1045 | - * 1、确认5_2班型大致多少圈(小数点过.7进位) | |
| 1046 | - * 2、获取当前5_2两端车次链的信息,每段的班次数目,还差几个班次没加 | |
| 1047 | - * 3、如果前面的车次链班次少,则从前面的车次链开始加 | |
| 1048 | - * 4、如果车次链班次数一样,从从后面的车次链开始加 | |
| 1049 | - * 5、加班次时都是往车次链前方加 | |
| 1050 | - * 6、如果前面车次链不能再加班次了,从后面车次链加 | |
| 1051 | - */ | |
| 1052 | - fnCalcuLpBx_5_2: function() { | |
| 1053 | - // 计算做5休2班型所需的班次数 | |
| 1054 | - var iBxBcount = _aBxDesc[6].fBcCount; | |
| 1055 | - if (iBxBcount - Math.floor(iBxBcount) > 0.7) { | |
| 1056 | - iBxBcount = Math.floor(iBxBcount) + 1; | |
| 1057 | - } else { | |
| 1058 | - iBxBcount = Math.floor(iBxBcount); | |
| 1059 | - } | |
| 1060 | - | |
| 1061 | - var i; | |
| 1062 | - var j; | |
| 1063 | - var oLp; | |
| 1064 | - var iAddBcCount; | |
| 1065 | - var oBcChain1; | |
| 1066 | - var oBcChain2; | |
| 1067 | - var iQindex; | |
| 1068 | - var iBindex; | |
| 1069 | - | |
| 1070 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 1071 | - oLp = _internalLpArray[i]; | |
| 1072 | - if (oLp.isBxFb5_2()) { | |
| 1073 | - iAddBcCount = iBxBcount - oLp.getBcArray().length; // 需要添加的班次数 | |
| 1074 | - for (j = 1; j <= iAddBcCount; j++) { | |
| 1075 | - oBcChain1 = oLp.fnGetBcChainInfo(0); | |
| 1076 | - oBcChain2 = oLp.fnGetBcChainInfo(1); | |
| 1077 | - | |
| 1078 | - if (oBcChain1.bcount < oBcChain2.bcount) { | |
| 1079 | - iQindex = oBcChain1.s_b == 0 ? oBcChain1.s_q - 1 : oBcChain1.s_q; | |
| 1080 | - iBindex = oBcChain1.s_b == 0 ? 1 : 0; | |
| 1081 | - // 往车次链往前不能加,就往后加 | |
| 1082 | - if (_fnGenerateBc(i, iQindex, iBindex)) { | |
| 1083 | - _fnGenerateBcAndSetBc(i, iQindex, iBindex); | |
| 1084 | - } else { | |
| 1085 | - iQindex = oBcChain1.e_b == 0 ? oBcChain1.e_q : oBcChain1.e_q + 1; | |
| 1086 | - iBindex = oBcChain1.e_b == 0 ? 1 : 0; | |
| 1087 | - _fnGenerateBcAndSetBc(i, iQindex, iBindex); | |
| 1088 | - } | |
| 1089 | - | |
| 1090 | - } else if (oBcChain1.bcount > oBcChain2.bcount) { | |
| 1091 | - iQindex = oBcChain2.s_b == 0 ? oBcChain2.s_q - 1 : oBcChain2.s_q; | |
| 1092 | - iBindex = oBcChain2.s_b == 0 ? 1 : 0; | |
| 1093 | - _fnGenerateBcAndSetBc(i, iQindex, iBindex); | |
| 1094 | - } else { | |
| 1095 | - iQindex = oBcChain2.s_b == 0 ? oBcChain2.s_q - 1 : oBcChain2.s_q; | |
| 1096 | - iBindex = oBcChain2.s_b == 0 ? 1 : 0; | |
| 1097 | - _fnGenerateBcAndSetBc(i, iQindex, iBindex); | |
| 1098 | - } | |
| 1099 | - } | |
| 1100 | - } | |
| 1101 | - } | |
| 1102 | - | |
| 1103 | - }, | |
| 1104 | - | |
| 1105 | - /** | |
| 1106 | - * 补其他分班班型班次。 | |
| 1107 | - * 从车次链的后面开始加 | |
| 1108 | - */ | |
| 1109 | - fnCalcuLpBx_other: function() { | |
| 1110 | - // TODO:根据上标线的首班时间确定班型,小于05:59的做一休一,否则做二休一 | |
| 1111 | - var oSt = _qIsUp ? _paramObj.getUpFirstDTimeObj() : _paramObj.getDownFirstDTimeObj(); | |
| 1112 | - var iBxIndex = 4; | |
| 1113 | - if (oSt.isBefore(_paramObj.toTimeObj("05:59"))) { | |
| 1114 | - iBxIndex = 5; | |
| 1115 | - } | |
| 1116 | - // 计算做5休2班型所需的班次数 | |
| 1117 | - var iQBcount = _aBxDesc[iBxIndex].fQCount; | |
| 1118 | - var iBxBcount = Math.round(iQBcount) * 2; | |
| 1119 | - | |
| 1120 | - var i; | |
| 1121 | - var j; | |
| 1122 | - var oLp; | |
| 1123 | - var iAddBcCount; | |
| 1124 | - var oBcChain1; | |
| 1125 | - var oBcChain2; | |
| 1126 | - var iQindex; | |
| 1127 | - var iBindex; | |
| 1128 | - | |
| 1129 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 1130 | - oLp = _internalLpArray[i]; | |
| 1131 | - if (oLp.isBxFb() && !oLp.isBxFb5_2()) { | |
| 1132 | - iAddBcCount = iBxBcount - oLp.getBcArray().length; // 需要添加的班次数 | |
| 1133 | - for (j = 1; j <= iAddBcCount; j++) { | |
| 1134 | - oBcChain1 = oLp.fnGetBcChainInfo(0); | |
| 1135 | - oBcChain2 = oLp.fnGetBcChainInfo(1); | |
| 1136 | - | |
| 1137 | - if (oBcChain1.bcount < oBcChain2.bcount) { | |
| 1138 | - iQindex = oBcChain1.e_b == 0 ? oBcChain1.e_q : oBcChain1.e_q + 1; | |
| 1139 | - iBindex = oBcChain1.e_b == 0 ? 1 : 0; | |
| 1140 | - _fnGenerateBcAndSetBc(i, iQindex, iBindex); | |
| 1141 | - } else if (oBcChain1.bcount > oBcChain2.bcount) { | |
| 1142 | - iQindex = oBcChain2.e_b == 0 ? oBcChain2.e_q : oBcChain2.e_q + 1; | |
| 1143 | - iBindex = oBcChain2.e_b == 0 ? 1 : 0; | |
| 1144 | - _fnGenerateBcAndSetBc(i, iQindex, iBindex); | |
| 1145 | - } else { | |
| 1146 | - iQindex = oBcChain2.e_b == 0 ? oBcChain2.e_q : oBcChain2.e_q + 1; | |
| 1147 | - iBindex = oBcChain2.e_b == 0 ? 1 : 0; | |
| 1148 | - _fnGenerateBcAndSetBc(i, iQindex, iBindex); | |
| 1149 | - } | |
| 1150 | - } | |
| 1151 | - } | |
| 1152 | - } | |
| 1153 | - | |
| 1154 | - }, | |
| 1155 | - | |
| 1156 | - /** | |
| 1157 | - * 补充连班路牌班次。 | |
| 1158 | - * 1、上标线,中标线中间的连班路牌班次从早高峰班次一直拉到底,从早高峰班次向上标线起始班次靠拢 | |
| 1159 | - * 2、中标线以下的连班路牌班次从早高峰班次一直拉到底,从早高峰班次向中标线起始班次靠拢 | |
| 1160 | - */ | |
| 1161 | - fnCalcuLpBx_lb: function() { | |
| 1162 | - // 补充连班的班次,参照上标线,中标线补充不足的班次 | |
| 1163 | - | |
| 1164 | - var aLbLpindexes = []; // 除上标线,中标线的连班路牌索引 | |
| 1165 | - var i; | |
| 1166 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 1167 | - if (_internalLpArray[i].isBxLb() && i != 0 && i != _iZbx_lpIndex) { | |
| 1168 | - aLbLpindexes.push(i); | |
| 1169 | - } | |
| 1170 | - } | |
| 1171 | - | |
| 1172 | - var oEndsj = // 结束时间 | |
| 1173 | - _paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj()) ? | |
| 1174 | - _paramObj.getDownLastDTimeObj() : | |
| 1175 | - _paramObj.getUpLastDtimeObj(); | |
| 1176 | - | |
| 1177 | - var oLp; | |
| 1178 | - var aMinbcPos; | |
| 1179 | - var oBc; | |
| 1180 | - var j; | |
| 1181 | - var iTempBcIndex; | |
| 1182 | - | |
| 1183 | - // 1、从最小班次开始,往后补充班次 | |
| 1184 | - for (i = 0; i < aLbLpindexes.length; i++) { | |
| 1185 | - oLp = _internalLpArray[aLbLpindexes[i]]; | |
| 1186 | - | |
| 1187 | - // 最小班次索引 | |
| 1188 | - aMinbcPos = oLp.getMinBcObjPosition(); | |
| 1189 | - // 使用纵向分隔补充班次,从最小班次向后补 | |
| 1190 | - iTempBcIndex = aMinbcPos[1] == 0 ? 1 : 0; | |
| 1191 | - j = iTempBcIndex == 0 ? aMinbcPos[0] + 1 : aMinbcPos[0]; | |
| 1192 | - | |
| 1193 | - while (j < _qCount) { | |
| 1194 | - while (iTempBcIndex <= 1) { | |
| 1195 | - oBc = _fnGenerateBc(aLbLpindexes[i], j, iTempBcIndex); | |
| 1196 | - if (oBc && | |
| 1197 | - oBc.getFcTimeObj().isBefore(oEndsj) ) { | |
| 1198 | - oLp.setBc(j, iTempBcIndex, oBc); | |
| 1199 | - } | |
| 1200 | - iTempBcIndex++; | |
| 1201 | - } | |
| 1202 | - iTempBcIndex = 0; | |
| 1203 | - j++; | |
| 1204 | - } | |
| 1205 | - | |
| 1206 | - } | |
| 1207 | - | |
| 1208 | - // 2、上标线中标线之间的路牌,从最小的班次往前补充班次 | |
| 1209 | - | |
| 1210 | - // 还要补充缺失的班次,差上标线几个班次要往前补上 | |
| 1211 | - var iBccount; | |
| 1212 | - var iQindex; | |
| 1213 | - var iBindex; | |
| 1214 | - // 补上标线到中标线之间的连班路牌的班次 | |
| 1215 | - for (i = 0; i < aLbLpindexes.length; i++) { | |
| 1216 | - if (aLbLpindexes[i] > 0 && aLbLpindexes[i] < _iZbx_lpIndex) { | |
| 1217 | - oLp = _internalLpArray[aLbLpindexes[i]]; | |
| 1218 | - aMinbcPos = oLp.getMinBcObjPosition(); | |
| 1219 | - iQindex = aMinbcPos[0]; | |
| 1220 | - iBindex = aMinbcPos[1]; | |
| 1221 | - iBccount = (iQindex - 1) * 2 + iBindex; // 距离上标线起始站点差几个班次 | |
| 1222 | - for (j = 0; j < iBccount; j++) { | |
| 1223 | - if (iBindex == 0) { | |
| 1224 | - iQindex --; | |
| 1225 | - iBindex = 1; | |
| 1226 | - _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex); | |
| 1227 | - } else if (iBindex == 1) { | |
| 1228 | - iBindex --; | |
| 1229 | - _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex); | |
| 1230 | - } | |
| 1231 | - } | |
| 1232 | - | |
| 1233 | - } | |
| 1234 | - | |
| 1235 | - } | |
| 1236 | - | |
| 1237 | - // 3、中标线之后的路牌,从最小的班次往前补充班次 | |
| 1238 | - | |
| 1239 | - // 补中标线以下的连班路牌的班次 | |
| 1240 | - for (i = 0; i < aLbLpindexes.length; i++) { | |
| 1241 | - if (aLbLpindexes[i] > _iZbx_lpIndex) { | |
| 1242 | - oLp = _internalLpArray[aLbLpindexes[i]]; | |
| 1243 | - aMinbcPos = oLp.getMinBcObjPosition(); | |
| 1244 | - iQindex = aMinbcPos[0]; | |
| 1245 | - iBindex = aMinbcPos[1]; | |
| 1246 | - iBccount = (iQindex - 0) * 2 + iBindex - 1; // 距离上标线起始站点差几个班次 | |
| 1247 | - for (j = 0; j < iBccount; j++) { | |
| 1248 | - if (iBindex == 0) { | |
| 1249 | - iQindex --; | |
| 1250 | - iBindex = 1; | |
| 1251 | - _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex); | |
| 1252 | - } else if (iBindex == 1) { | |
| 1253 | - iBindex --; | |
| 1254 | - _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex); | |
| 1255 | - } | |
| 1256 | - } | |
| 1257 | - } | |
| 1258 | - } | |
| 1259 | - | |
| 1260 | - }, | |
| 1261 | - | |
| 1262 | - /** | |
| 1263 | - * 计算末班车。 | |
| 1264 | - * 1、将上下行拉成上下行两个班次列表(包括标记班次) | |
| 1265 | - * 2、分别找出离末班车发车时间最近的班次,并替换时间 | |
| 1266 | - * 3、删除之后的班次 | |
| 1267 | - */ | |
| 1268 | - fnCalcuLastBc: function() { | |
| 1269 | - var i; | |
| 1270 | - var iTimeDiff; | |
| 1271 | - var iTempTime; | |
| 1272 | - var aBc; | |
| 1273 | - var oLastBcTime; | |
| 1274 | - var oLastBcIsUp; | |
| 1275 | - var iModifyIndex; | |
| 1276 | - | |
| 1277 | - // 查找末班车早的末班车时间和方向 | |
| 1278 | - if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) { | |
| 1279 | - oLastBcTime = _paramObj.getUpLastDtimeObj(); | |
| 1280 | - oLastBcIsUp = true; | |
| 1281 | - } else { | |
| 1282 | - oLastBcTime = _paramObj.getDownLastDTimeObj(); | |
| 1283 | - oLastBcIsUp = false; | |
| 1284 | - } | |
| 1285 | - | |
| 1286 | - // 确定早的末班车时间 | |
| 1287 | - aBc = _fnGetBcList(oLastBcIsUp); | |
| 1288 | - for (i = 0; i < aBc.length; i++) { | |
| 1289 | - iTempTime = oLastBcTime.diff(aBc[i].getFcTimeObj(), "m"); | |
| 1290 | - if (iTimeDiff == undefined) { | |
| 1291 | - iTimeDiff = iTempTime; | |
| 1292 | - iModifyIndex = i; | |
| 1293 | - } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff)) { | |
| 1294 | - iTimeDiff = iTempTime; | |
| 1295 | - iModifyIndex = i; | |
| 1296 | - } | |
| 1297 | - } | |
| 1298 | - aBc[iModifyIndex].addMinuteToFcsj(iTimeDiff); // 替换成末班车时间 | |
| 1299 | - aBc[iModifyIndex].fnSetDelFlag(false); | |
| 1300 | - aBc[iModifyIndex].fnSetIsLastBc(true); | |
| 1301 | - for (i = iModifyIndex + 1; i < aBc.length; i++) { // 删除多余班次 | |
| 1302 | - _qIsUp == oLastBcIsUp ? | |
| 1303 | - aBc[i]._$$_internal_group_obj.setBc1(undefined) : | |
| 1304 | - aBc[i]._$$_internal_group_obj.setBc2(undefined); | |
| 1305 | - } | |
| 1306 | - | |
| 1307 | - // 查找末班车晚的末班车时间和方向 | |
| 1308 | - if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) { | |
| 1309 | - oLastBcTime = _paramObj.getDownLastDTimeObj(); | |
| 1310 | - oLastBcIsUp = false; | |
| 1311 | - } else { | |
| 1312 | - oLastBcTime = _paramObj.getUpLastDtimeObj(); | |
| 1313 | - oLastBcIsUp = true; | |
| 1314 | - } | |
| 1315 | - // 确定晚的末班车时间 | |
| 1316 | - aBc = _fnGetBcList(oLastBcIsUp); | |
| 1317 | - var oBc; | |
| 1318 | - var aBcIndex; | |
| 1319 | - var iLpIndex; | |
| 1320 | - var iQIndex; | |
| 1321 | - var iBcIndex; | |
| 1322 | - | |
| 1323 | - iTimeDiff = undefined; | |
| 1324 | - for (i = 0; i < aBc.length; i++) { | |
| 1325 | - oBc = aBc[i]; | |
| 1326 | - aBcIndex = _fnGetBcIndex(oBc); | |
| 1327 | - | |
| 1328 | - iLpIndex = aBcIndex[0]; | |
| 1329 | - iQIndex = aBcIndex[2] == 0 ? aBcIndex[1] -1 : aBcIndex[1]; | |
| 1330 | - iBcIndex = aBcIndex[2] == 0 ? 1 : 0; | |
| 1331 | - | |
| 1332 | - if (!_internalLpArray[iLpIndex].getBc(iQIndex, iBcIndex)) { | |
| 1333 | - continue; | |
| 1334 | - } | |
| 1335 | - | |
| 1336 | - iTempTime = oLastBcTime.diff(aBc[i].getFcTimeObj(), "m"); | |
| 1337 | - if (iTimeDiff == undefined) { | |
| 1338 | - iTimeDiff = iTempTime; | |
| 1339 | - iModifyIndex = i; | |
| 1340 | - } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff)) { | |
| 1341 | - iTimeDiff = iTempTime; | |
| 1342 | - iModifyIndex = i; | |
| 1343 | - } | |
| 1344 | - } | |
| 1345 | - aBc[iModifyIndex].addMinuteToFcsj(iTimeDiff); // 替换成末班车时间 | |
| 1346 | - aBc[iModifyIndex].fnSetDelFlag(false); | |
| 1347 | - aBc[iModifyIndex].fnSetIsLastBc(true); | |
| 1348 | - for (i = iModifyIndex + 1; i < aBc.length; i++) { // 删除多余班次 | |
| 1349 | - _qIsUp == oLastBcIsUp ? | |
| 1350 | - aBc[i]._$$_internal_group_obj.setBc1(undefined) : | |
| 1351 | - aBc[i]._$$_internal_group_obj.setBc2(undefined); | |
| 1352 | - } | |
| 1353 | - | |
| 1354 | - }, | |
| 1355 | - | |
| 1356 | - /** | |
| 1357 | - * 添加吃饭班次。 | |
| 1358 | - */ | |
| 1359 | - fnCalcuEatBc: function() { | |
| 1360 | - // 吃午饭时间范围,10:15 到 12:15 | |
| 1361 | - // 吃晚饭时间范围,18:00 到 19:00 | |
| 1362 | - | |
| 1363 | - if (!_paramObj.fnIsEat()) { | |
| 1364 | - return; | |
| 1365 | - } | |
| 1366 | - | |
| 1367 | - // 午饭index | |
| 1368 | - var aLEIndex; | |
| 1369 | - // 晚饭index | |
| 1370 | - var aDEIndex; | |
| 1371 | - | |
| 1372 | - // 所有吃饭都默认在一个方向,两个方向暂时不考虑 | |
| 1373 | - if (_paramObj.fnIsUpEat()) { | |
| 1374 | - aLEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("10:15"), true, false); | |
| 1375 | - aDEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("18:00"), true, false); | |
| 1376 | - } else { | |
| 1377 | - aLEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("10:15"), false, true); | |
| 1378 | - aDEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("18:00"), false, true); | |
| 1379 | - } | |
| 1380 | - | |
| 1381 | - // 午饭第几圈,第几个班次 | |
| 1382 | - var iLEQIndex = aLEIndex[0]; | |
| 1383 | - var iLEBIndex = aLEIndex[1]; | |
| 1384 | - // 晚饭第几圈,第几个班次 | |
| 1385 | - var iDEQIndex = aDEIndex[0]; | |
| 1386 | - var iDEBIndex = aDEIndex[1]; | |
| 1387 | - | |
| 1388 | - // 注意,本模型只有连班才有吃饭 | |
| 1389 | - | |
| 1390 | - var i; | |
| 1391 | - var oLp; | |
| 1392 | - var aLbIndex = []; // 连班班型的路牌索引 | |
| 1393 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 1394 | - oLp = _internalLpArray[i]; | |
| 1395 | - if (oLp.isBxLb()) { | |
| 1396 | - aLbIndex.push(i); | |
| 1397 | - } | |
| 1398 | - } | |
| 1399 | - | |
| 1400 | - var iLTime; | |
| 1401 | - var iDtime; | |
| 1402 | - var j; | |
| 1403 | - for (i = 0; i < aLbIndex.length; i++) { | |
| 1404 | - oLp = _internalLpArray[aLbIndex[i]]; | |
| 1405 | - | |
| 1406 | - // 午饭 | |
| 1407 | - iLTime = oLp.fnAddEatBc(iLEQIndex, iLEBIndex, _factory, _paramObj); | |
| 1408 | - // 晚饭 | |
| 1409 | - iDtime = oLp.fnAddEatBc(iDEQIndex, iDEBIndex, _factory, _paramObj); | |
| 1410 | - | |
| 1411 | - if (i == aLbIndex.length - 1) { | |
| 1412 | - for (j = aLbIndex[i]; j < _internalLpArray.length; j++) { | |
| 1413 | - oLp = _internalLpArray[j]; | |
| 1414 | - if (oLp.isBxFb()) { // 5休2班型不调整 | |
| 1415 | - // 修正午饭之后路牌班次的发车时间 | |
| 1416 | - oLp.fnAddMinuteToBcFcsj(iLEQIndex, iLEBIndex, iLTime); | |
| 1417 | - oLp.fnAddMinuteToBcFcsj(iDEQIndex, iDEBIndex, iDtime); | |
| 1418 | - } | |
| 1419 | - } | |
| 1420 | - } else { | |
| 1421 | - for (j = aLbIndex[i]; j < aLbIndex[i + 1]; j++) { | |
| 1422 | - oLp = _internalLpArray[j]; | |
| 1423 | - if (oLp.isBxFb()) { | |
| 1424 | - // 修正午饭之后路牌班次的发车时间 | |
| 1425 | - oLp.fnAddMinuteToBcFcsj(iLEQIndex, iLEBIndex, iLTime); | |
| 1426 | - oLp.fnAddMinuteToBcFcsj(iDEQIndex, iDEBIndex, iDtime); | |
| 1427 | - } | |
| 1428 | - } | |
| 1429 | - } | |
| 1430 | - } | |
| 1431 | - | |
| 1432 | - }, | |
| 1433 | - | |
| 1434 | - /** | |
| 1435 | - * 补每个路牌的其他班次(进出场,例保班次)。 | |
| 1436 | - */ | |
| 1437 | - fnCalcuOtherBc_: function() { | |
| 1438 | - var i; | |
| 1439 | - var _lpObj; | |
| 1440 | - var _minBcIndex; | |
| 1441 | - var _maxBcIndex; | |
| 1442 | - var _minBc; | |
| 1443 | - var _maxBc; | |
| 1444 | - var _otherbc = []; | |
| 1445 | - var _oFbbc; | |
| 1446 | - | |
| 1447 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 1448 | - _lpObj = _internalLpArray[i]; | |
| 1449 | - _minBcIndex = _lpObj.getMinBcObjPosition(); | |
| 1450 | - _maxBcIndex = _lpObj.getMaxBcObjPosition(); | |
| 1451 | - _minBc = _lpObj.getBc(_minBcIndex[0], _minBcIndex[1]); | |
| 1452 | - _maxBc = _lpObj.getBc(_maxBcIndex[0], _maxBcIndex[1]); | |
| 1453 | - | |
| 1454 | - _otherbc = []; | |
| 1455 | - _otherbc.push(_factory.createBcObj( | |
| 1456 | - _lpObj, "bd", true, 1, | |
| 1457 | - _minBc.getFcTimeObj(), | |
| 1458 | - _paramObj | |
| 1459 | - )); | |
| 1460 | - _otherbc.push(_factory.createBcObj( | |
| 1461 | - _lpObj, "out", true, 1, | |
| 1462 | - _minBc.getFcTimeObj(), | |
| 1463 | - _paramObj | |
| 1464 | - )); | |
| 1465 | - | |
| 1466 | - _maxBc.setArrTimeObj(_paramObj.addMinute(_maxBc.getFcTimeObj(), _maxBc.getBcTime())); | |
| 1467 | - _maxBc.setStopTime(0); | |
| 1468 | - _otherbc.push(_factory.createBcObj( | |
| 1469 | - _lpObj, "in", true, 1, | |
| 1470 | - _maxBc.getArrTimeObj(), | |
| 1471 | - _paramObj | |
| 1472 | - )); | |
| 1473 | - _otherbc.push(_factory.createBcObj( | |
| 1474 | - _lpObj, "lc", true, 1, | |
| 1475 | - _maxBc.getArrTimeObj(), | |
| 1476 | - _paramObj | |
| 1477 | - )); | |
| 1478 | - | |
| 1479 | - // 5休2分班出场例保班次 | |
| 1480 | - if (_lpObj.isBxFb5_2()) { | |
| 1481 | - _oFbbc = _lpObj.getBc( | |
| 1482 | - _lpObj.fnGetBcChainInfo(1)["s_q"], | |
| 1483 | - _lpObj.fnGetBcChainInfo(1)["s_b"] | |
| 1484 | - ); | |
| 1485 | - | |
| 1486 | - _otherbc.push(_factory.createBcObj( | |
| 1487 | - _lpObj, "bd", true, 1, | |
| 1488 | - _oFbbc.getFcTimeObj(), | |
| 1489 | - _paramObj | |
| 1490 | - )); | |
| 1491 | - _otherbc.push(_factory.createBcObj( | |
| 1492 | - _lpObj, "out", true, 1, | |
| 1493 | - _oFbbc.getFcTimeObj(), | |
| 1494 | - _paramObj | |
| 1495 | - )); | |
| 1496 | - } | |
| 1497 | - | |
| 1498 | - _lpObj.addOtherBcArray(_otherbc); | |
| 1499 | - } | |
| 1500 | - | |
| 1501 | - }, | |
| 1502 | - | |
| 1503 | - /** | |
| 1504 | - * 补每个路牌的其他班次(进出场,例保班次) | |
| 1505 | - * 所有的车次链前后都加进出场、报道班次 | |
| 1506 | - */ | |
| 1507 | - fnCalcuOtherBc: function() { | |
| 1508 | - var i; | |
| 1509 | - var j; | |
| 1510 | - var iBcChainCount; | |
| 1511 | - var oLp; | |
| 1512 | - var aOtherBc; | |
| 1513 | - var oStartBc; | |
| 1514 | - var oEndBc; | |
| 1515 | - | |
| 1516 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 1517 | - aOtherBc = []; | |
| 1518 | - oLp = _internalLpArray[i]; | |
| 1519 | - iBcChainCount = oLp.fnGetBcChainCount(); | |
| 1520 | - | |
| 1521 | - if (iBcChainCount == 1) { // 只有一个车次链,是连班班型 | |
| 1522 | - // 头部要添加出场,例保班次 | |
| 1523 | - oStartBc = oLp.getBc( | |
| 1524 | - oLp.fnGetBcChainInfo(0)["s_q"], | |
| 1525 | - oLp.fnGetBcChainInfo(0)["s_b"] | |
| 1526 | - ); | |
| 1527 | - aOtherBc.push(_factory.createBcObj( | |
| 1528 | - oLp, "bd", true, 1, | |
| 1529 | - oStartBc.getFcTimeObj(), | |
| 1530 | - _paramObj | |
| 1531 | - )); | |
| 1532 | - aOtherBc.push(_factory.createBcObj( | |
| 1533 | - oLp, "out", true, 1, | |
| 1534 | - oStartBc.getFcTimeObj(), | |
| 1535 | - _paramObj | |
| 1536 | - )); | |
| 1537 | - | |
| 1538 | - // 尾部需添加进场,例保班次 | |
| 1539 | - oEndBc = oLp.getBc( | |
| 1540 | - oLp.fnGetBcChainInfo(0)["e_q"], | |
| 1541 | - oLp.fnGetBcChainInfo(0)["e_b"] | |
| 1542 | - ); | |
| 1543 | - aOtherBc.push(_factory.createBcObj( | |
| 1544 | - oLp, "in", true, 1, | |
| 1545 | - oEndBc.getArrTimeObj(), | |
| 1546 | - _paramObj | |
| 1547 | - )); | |
| 1548 | - aOtherBc.push(_factory.createBcObj( | |
| 1549 | - oLp, "lc", true, 1, | |
| 1550 | - oEndBc.getArrTimeObj(), | |
| 1551 | - _paramObj | |
| 1552 | - )); | |
| 1553 | - } else if (iBcChainCount == 2) { // 两个车次链,是分班班型 | |
| 1554 | - // 第一个车次链开头有出场,报到班次,车次链结尾只有进场班次 | |
| 1555 | - oStartBc = oLp.getBc( | |
| 1556 | - oLp.fnGetBcChainInfo(0)["s_q"], | |
| 1557 | - oLp.fnGetBcChainInfo(0)["s_b"] | |
| 1558 | - ); | |
| 1559 | - aOtherBc.push(_factory.createBcObj( | |
| 1560 | - oLp, "bd", true, 1, | |
| 1561 | - oStartBc.getFcTimeObj(), | |
| 1562 | - _paramObj | |
| 1563 | - )); | |
| 1564 | - aOtherBc.push(_factory.createBcObj( | |
| 1565 | - oLp, "out", true, 1, | |
| 1566 | - oStartBc.getFcTimeObj(), | |
| 1567 | - _paramObj | |
| 1568 | - )); | |
| 1569 | - | |
| 1570 | - oEndBc = oLp.getBc( | |
| 1571 | - oLp.fnGetBcChainInfo(0)["e_q"], | |
| 1572 | - oLp.fnGetBcChainInfo(0)["e_b"] | |
| 1573 | - ); | |
| 1574 | - aOtherBc.push(_factory.createBcObj( | |
| 1575 | - oLp, "in", true, 1, | |
| 1576 | - oEndBc.getArrTimeObj(), | |
| 1577 | - _paramObj | |
| 1578 | - )); | |
| 1579 | - | |
| 1580 | - // 第二个车次链开头只有出场班次,车次链结尾有进场,报到班次 | |
| 1581 | - oStartBc = oLp.getBc( | |
| 1582 | - oLp.fnGetBcChainInfo(1)["s_q"], | |
| 1583 | - oLp.fnGetBcChainInfo(1)["s_b"] | |
| 1584 | - ); | |
| 1585 | - aOtherBc.push(_factory.createBcObj( | |
| 1586 | - oLp, "out", true, 1, | |
| 1587 | - oStartBc.getFcTimeObj(), | |
| 1588 | - _paramObj | |
| 1589 | - )); | |
| 1590 | - | |
| 1591 | - oEndBc = oLp.getBc( | |
| 1592 | - oLp.fnGetBcChainInfo(1)["e_q"], | |
| 1593 | - oLp.fnGetBcChainInfo(1)["e_b"] | |
| 1594 | - ); | |
| 1595 | - aOtherBc.push(_factory.createBcObj( | |
| 1596 | - oLp, "in", true, 1, | |
| 1597 | - oEndBc.getArrTimeObj(), | |
| 1598 | - _paramObj | |
| 1599 | - )); | |
| 1600 | - aOtherBc.push(_factory.createBcObj( | |
| 1601 | - oLp, "lc", true, 1, | |
| 1602 | - oEndBc.getArrTimeObj(), | |
| 1603 | - _paramObj | |
| 1604 | - )); | |
| 1605 | - | |
| 1606 | - | |
| 1607 | - } else { | |
| 1608 | - // 2个车次链以上,暂时没有此班型 | |
| 1609 | - } | |
| 1610 | - | |
| 1611 | - oLp.addOtherBcArray(aOtherBc); | |
| 1612 | - } | |
| 1613 | - }, | |
| 1614 | - | |
| 1615 | - /** | |
| 1616 | - * 祛除上标线开头的删除标记的班次。 | |
| 1617 | - */ | |
| 1618 | - fnRemoveDelFirstFlagBc: function() { | |
| 1619 | - var oLp = _internalLpArray[0]; | |
| 1620 | - var aMinBcIndex = oLp.getMinBcObjPosition(); | |
| 1621 | - if (oLp.getBc(aMinBcIndex[0], aMinBcIndex[1]).fnIsDelFlag()) { | |
| 1622 | - oLp.removeBc(aMinBcIndex[0], aMinBcIndex[1]); | |
| 1623 | - } | |
| 1624 | - }, | |
| 1625 | - /** | |
| 1626 | - * 祛除上标线结尾的删除标记的班次。 | |
| 1627 | - */ | |
| 1628 | - fnRemoveDelLastFlagBc: function() { | |
| 1629 | - var oLp = _internalLpArray[0]; | |
| 1630 | - var aMaxBcIndex = oLp.getMaxBcObjPosition(); | |
| 1631 | - if (oLp.getBc(aMaxBcIndex[0], aMaxBcIndex[1]).fnIsDelFlag()) { | |
| 1632 | - oLp.removeBc(aMaxBcIndex[0], aMaxBcIndex[1]); | |
| 1633 | - } | |
| 1634 | - }, | |
| 1635 | - | |
| 1636 | - /** | |
| 1637 | - * 调整路牌班次间隔(核准周转时间,停站时间)。 | |
| 1638 | - * @param iFre int 迭代次数 | |
| 1639 | - */ | |
| 1640 | - fnAdjustLpBcInterval: function(iFre) { | |
| 1641 | - if (iFre > 0) { | |
| 1642 | - for (var i = 0; i < _internalLpArray.length; i++) { | |
| 1643 | - _internalLpArray[i].fnAdjustBcInterval( | |
| 1644 | - this.fnCalcuAverPeakStopTime(), | |
| 1645 | - this.fnCalcuAverTroughStopTime(), | |
| 1646 | - _paramObj); | |
| 1647 | - } | |
| 1648 | - | |
| 1649 | - this.fnAdjustLpBcInterval(iFre - 1); | |
| 1650 | - } | |
| 1651 | - }, | |
| 1652 | - | |
| 1653 | - /** | |
| 1654 | - * 调整班次间隔。 | |
| 1655 | - * @param bIsUp 是否上行 | |
| 1656 | - * @param oStartTime 开始时间对象 | |
| 1657 | - * @param iFre 迭代次数 | |
| 1658 | - */ | |
| 1659 | - fnAdjustBcInterval2_: function(bIsUp, oStartTime, iFre) { | |
| 1660 | - if (iFre > 0) { | |
| 1661 | - var aBc = _fnGetBcList2(bIsUp, oStartTime); // 指定方向的班次列表 | |
| 1662 | - aBc.sort(function(o1, o2) { | |
| 1663 | - if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) { | |
| 1664 | - return -1; | |
| 1665 | - } else { | |
| 1666 | - return 1; | |
| 1667 | - } | |
| 1668 | - }); | |
| 1669 | - var i; | |
| 1670 | - var j; | |
| 1671 | - | |
| 1672 | - var iBcCountOfGroup = 3; // 3个班次取一次计算 | |
| 1673 | - var aBcOfGroup; // 3个班次列表 | |
| 1674 | - var aBcIntervalOfGroup; // 班次间隔列表,如:3个班次,2个间隔 | |
| 1675 | - | |
| 1676 | - for (i = 0; i <= aBc.length - iBcCountOfGroup; i++) { | |
| 1677 | - aBcOfGroup = []; | |
| 1678 | - aBcIntervalOfGroup = []; | |
| 1679 | - for (j = i; j < i + iBcCountOfGroup; j++) { | |
| 1680 | - aBcOfGroup.push(aBc[j]); | |
| 1681 | - } | |
| 1682 | - | |
| 1683 | - for (j = 0; j < aBcOfGroup.length; j++) { | |
| 1684 | - if (j < aBcOfGroup.length - 1) { | |
| 1685 | - aBcIntervalOfGroup.push(aBcOfGroup[j + 1].getFcTimeObj().diff( | |
| 1686 | - aBcOfGroup[j].getFcTimeObj(), "m")); | |
| 1687 | - } | |
| 1688 | - } | |
| 1689 | - | |
| 1690 | - if (aBcIntervalOfGroup[0] < 19) { | |
| 1691 | - aBcOfGroup[1].addMinuteToFcsj(1); | |
| 1692 | - } else if (aBcIntervalOfGroup[0] > 20) { | |
| 1693 | - aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 1694 | - } else { | |
| 1695 | - if (Math.abs(aBcIntervalOfGroup[0] - aBcIntervalOfGroup[1]) <= 1) { | |
| 1696 | - //continue; | |
| 1697 | - } else if (aBcIntervalOfGroup[0] > aBcIntervalOfGroup[1]) { | |
| 1698 | - aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 1699 | - } else { | |
| 1700 | - aBcOfGroup[1].addMinuteToFcsj(1); | |
| 1701 | - } | |
| 1702 | - } | |
| 1703 | - | |
| 1704 | - } | |
| 1705 | - | |
| 1706 | - this.fnAdjustBcInterval2(bIsUp, oStartTime, iFre - 1); | |
| 1707 | - } | |
| 1708 | - }, | |
| 1709 | - | |
| 1710 | - /** | |
| 1711 | - * 调整班次间隔。 | |
| 1712 | - * @param boolean isUp 是否上行 | |
| 1713 | - * @param oStartTime 开始时间对象 | |
| 1714 | - * @param fre int 迭代次数 | |
| 1715 | - */ | |
| 1716 | - fnAdjustBcInterval: function(isUp, oStartTime, fre) { | |
| 1717 | - if (fre > 0) { | |
| 1718 | - var aBc = !oStartTime ? _fnGetBcList(isUp) : _fnGetBcList2(isUp, oStartTime); // 指定方向的班次列表 | |
| 1719 | - | |
| 1720 | - aBc.sort(function(o1, o2) { | |
| 1721 | - if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) { | |
| 1722 | - return -1; | |
| 1723 | - } else { | |
| 1724 | - return 1; | |
| 1725 | - } | |
| 1726 | - }); | |
| 1727 | - | |
| 1728 | - var i; | |
| 1729 | - var j; | |
| 1730 | - | |
| 1731 | - var iBcCountOfGroup = 3; // 3个班次取一次计算 | |
| 1732 | - var aBcOfGroup; // 3个班次列表 | |
| 1733 | - var aBcIntervalOfGroup; // 班次间隔列表,如:3个班次,2个间隔 | |
| 1734 | - var oBcFcTime; // 班次发车时间 | |
| 1735 | - | |
| 1736 | - for (i = 0; i <= aBc.length - iBcCountOfGroup; i++) { | |
| 1737 | - aBcOfGroup = []; | |
| 1738 | - aBcIntervalOfGroup = []; | |
| 1739 | - for (j = i; j < i + iBcCountOfGroup; j++) { | |
| 1740 | - aBcOfGroup.push(aBc[j]); | |
| 1741 | - } | |
| 1742 | - | |
| 1743 | - for (j = 0; j < aBcOfGroup.length; j++) { | |
| 1744 | - if (j < aBcOfGroup.length - 1) { | |
| 1745 | - aBcIntervalOfGroup.push(aBcOfGroup[j + 1].getFcTimeObj().diff( | |
| 1746 | - aBcOfGroup[j].getFcTimeObj(), "m")); | |
| 1747 | - } | |
| 1748 | - } | |
| 1749 | - | |
| 1750 | - // 判定规则 | |
| 1751 | - oBcFcTime = aBcOfGroup[1].getFcTimeObj(); | |
| 1752 | - | |
| 1753 | - // 第一个班次发车时间不动,根据间隔,调整中间一个班次 | |
| 1754 | - // 如果3个班次2个间隔时间差1分钟,不调整 | |
| 1755 | - // 如果第一个间隔大,调整第二个班次往前1分钟 | |
| 1756 | - // 如果第二个间隔大,调整第二个班次往后1分钟 | |
| 1757 | - | |
| 1758 | - if (_paramObj.isTroughBc(oBcFcTime) && | |
| 1759 | - aBcIntervalOfGroup[0] > _paramObj.getTroughMaxFcjx()) { | |
| 1760 | - aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 1761 | - } | |
| 1762 | - | |
| 1763 | - //else if (_paramObj.isMPeakBc(oBcFcTime) && | |
| 1764 | - // aBcIntervalOfGroup[0] < _paramObj.getMPeakMinFcjx()) { | |
| 1765 | - // aBcOfGroup[1].addMinuteToFcsj(1); | |
| 1766 | - //} else if (_paramObj.isMPeakBc(oBcFcTime) && | |
| 1767 | - // aBcIntervalOfGroup[0] > _paramObj.getMPeakMaxFcjx()) { | |
| 1768 | - // aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 1769 | - //} else if (_paramObj.isEPeakBc(oBcFcTime) && | |
| 1770 | - // aBcIntervalOfGroup[0] < _paramObj.getEPeakMinFcjx()) { | |
| 1771 | - // aBcOfGroup[1].addMinuteToFcsj(1); | |
| 1772 | - //} else if (_paramObj.isEPeakBc(oBcFcTime) && | |
| 1773 | - // aBcIntervalOfGroup[0] > _paramObj.getEPeakMaxFcjx()) { | |
| 1774 | - // aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 1775 | - //} | |
| 1776 | - | |
| 1777 | - | |
| 1778 | - else { | |
| 1779 | - if (Math.abs(aBcIntervalOfGroup[0] - aBcIntervalOfGroup[1]) <= 1) { | |
| 1780 | - //continue; | |
| 1781 | - } else if (aBcIntervalOfGroup[0] > aBcIntervalOfGroup[1]) { | |
| 1782 | - aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 1783 | - } else { | |
| 1784 | - aBcOfGroup[1].addMinuteToFcsj(1); | |
| 1785 | - } | |
| 1786 | - } | |
| 1787 | - | |
| 1788 | - //if (Math.abs(aBcIntervalOfGroup[0] - aBcIntervalOfGroup[1]) <= 1) { | |
| 1789 | - // //continue; | |
| 1790 | - //} else if (aBcIntervalOfGroup[0] > aBcIntervalOfGroup[1]) { | |
| 1791 | - // aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 1792 | - //} else { | |
| 1793 | - // aBcOfGroup[1].addMinuteToFcsj(1); | |
| 1794 | - //} | |
| 1795 | - | |
| 1796 | - | |
| 1797 | - } | |
| 1798 | - | |
| 1799 | - this.fnAdjustBcInterval(isUp, oStartTime, fre - 1); | |
| 1800 | - } | |
| 1801 | - | |
| 1802 | - }, | |
| 1803 | - | |
| 1804 | - /** | |
| 1805 | - * 调整班次间隔(平均间隔)。 | |
| 1806 | - * @param bIsUp 是否上行 | |
| 1807 | - * @param oStartTime 开始时间对象 | |
| 1808 | - */ | |
| 1809 | - fnAdjustBcInterval2_avg: function(bIsUp, oStartTime) { | |
| 1810 | - var aBc = !oStartTime ? _fnGetBcList(bIsUp) : _fnGetBcList2(bIsUp, oStartTime); // 指定方向的班次列表 | |
| 1811 | - aBc.sort(function(o1, o2) { | |
| 1812 | - if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) { | |
| 1813 | - return -1; | |
| 1814 | - } else { | |
| 1815 | - return 1; | |
| 1816 | - } | |
| 1817 | - }); | |
| 1818 | - | |
| 1819 | - var j; | |
| 1820 | - var iCount = aBc.length - 1; | |
| 1821 | - var iC1 = Math.floor(aBc[aBc.length - 1].getFcTimeObj().diff(aBc[0].getFcTimeObj(), "m") / iCount); | |
| 1822 | - var iC2 = aBc[aBc.length - 1].getFcTimeObj().diff(aBc[0].getFcTimeObj(), "m") % iCount; | |
| 1823 | - var iTempTime; | |
| 1824 | - | |
| 1825 | - for (j = 0; j < iCount - iC2; j++) { | |
| 1826 | - iTempTime = aBc[j + 1].getFcTimeObj().diff(aBc[j].getFcTimeObj(), "m"); | |
| 1827 | - aBc[j + 1].addMinuteToFcsj(iC1 - iTempTime); | |
| 1828 | - } | |
| 1829 | - for (j = 0; j < iC2; j++) { | |
| 1830 | - iTempTime = aBc[iCount - iC2 + j + 1].getFcTimeObj().diff(aBc[iCount - iC2 + j].getFcTimeObj(), "m"); | |
| 1831 | - aBc[iCount - iC2 + j + 1].addMinuteToFcsj(iC1 + 1 - iTempTime); | |
| 1832 | - } | |
| 1833 | - | |
| 1834 | - }, | |
| 1835 | - | |
| 1836 | - /** | |
| 1837 | - * 计算高峰平均停站时间。 | |
| 1838 | - */ | |
| 1839 | - fnCalcuAverPeakStopTime: function() { | |
| 1840 | - var i; | |
| 1841 | - var j; | |
| 1842 | - var aBc; | |
| 1843 | - var iBcCount = 0; | |
| 1844 | - var iSum = 0; | |
| 1845 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 1846 | - aBc = _internalLpArray[i].getBcArray(); | |
| 1847 | - | |
| 1848 | - for (j = 0; j < aBc.length; j++) { | |
| 1849 | - if (!_paramObj.isTroughBc(aBc[j].getArrTimeObj())) { | |
| 1850 | - iBcCount ++; | |
| 1851 | - iSum += aBc[j].getStopTime(); | |
| 1852 | - } | |
| 1853 | - } | |
| 1854 | - } | |
| 1855 | - | |
| 1856 | - return Math.floor(iSum / iBcCount); | |
| 1857 | - }, | |
| 1858 | - | |
| 1859 | - /** | |
| 1860 | - * 计算低谷平均停站时间。 | |
| 1861 | - */ | |
| 1862 | - fnCalcuAverTroughStopTime: function() { | |
| 1863 | - var i; | |
| 1864 | - var j; | |
| 1865 | - var aBc; | |
| 1866 | - var iBcCount = 0; | |
| 1867 | - var iSum = 0; | |
| 1868 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 1869 | - aBc = _internalLpArray[i].getBcArray(); | |
| 1870 | - for (j = 0; j < aBc.length; j++) { | |
| 1871 | - if (_paramObj.isTroughBc(aBc[j].getArrTimeObj())) { | |
| 1872 | - iBcCount ++; | |
| 1873 | - iSum += aBc[j].getStopTime(); | |
| 1874 | - } | |
| 1875 | - } | |
| 1876 | - } | |
| 1877 | - | |
| 1878 | - return Math.floor(iSum / iBcCount); | |
| 1879 | - }, | |
| 1880 | - | |
| 1881 | - //------------- 其他方法 -------------// | |
| 1882 | - /** | |
| 1883 | - * 返回内部路牌数据列表。 | |
| 1884 | - * @returns {Array} | |
| 1885 | - */ | |
| 1886 | - fnGetLpArray: function() { | |
| 1887 | - return _internalLpArray; | |
| 1888 | - }, | |
| 1889 | - | |
| 1890 | - /** | |
| 1891 | - * 内部数据转化成显示用的班次数组。 | |
| 1892 | - */ | |
| 1893 | - fnToGanttBcArray: function() { | |
| 1894 | - var aAllBc = []; | |
| 1895 | - var aLpBc = []; | |
| 1896 | - var aEatBc = []; | |
| 1897 | - var oLp; | |
| 1898 | - var i; | |
| 1899 | - var j; | |
| 1900 | - | |
| 1901 | - for (i = 0; i < _internalLpArray.length; i++) { | |
| 1902 | - oLp = _internalLpArray[i]; | |
| 1903 | - aLpBc = []; | |
| 1904 | - aLpBc = aLpBc.concat(oLp.getOtherBcArray(), oLp.getBcArray()); | |
| 1905 | - | |
| 1906 | - aEatBc = []; | |
| 1907 | - // 根据班次的吃饭时间添加吃饭班次 | |
| 1908 | - for (j = 0; j < aLpBc.length; j++) { | |
| 1909 | - if (aLpBc[j].fnGetEatTime() > 0) { | |
| 1910 | - aEatBc.push(_factory.createBcObj( | |
| 1911 | - oLp, | |
| 1912 | - "cf", | |
| 1913 | - !aLpBc[j].isUp(), // 和上一个班次方向相反 | |
| 1914 | - 1, | |
| 1915 | - _paramObj.addMinute(aLpBc[j].getArrTimeObj(), aLpBc[j].getStopTime()), // 使用上一个班次的到达时间作为开始时间 | |
| 1916 | - _paramObj | |
| 1917 | - )); | |
| 1918 | - } | |
| 1919 | - } | |
| 1920 | - aLpBc = aLpBc.concat(aEatBc); | |
| 1921 | - | |
| 1922 | - // 按照发车时间排序 | |
| 1923 | - aLpBc.sort(function(o1, o2) { | |
| 1924 | - if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) { | |
| 1925 | - return -1; | |
| 1926 | - } else { | |
| 1927 | - return 1; | |
| 1928 | - } | |
| 1929 | - }); | |
| 1930 | - | |
| 1931 | - // 重新赋值fcno | |
| 1932 | - for (j = 0; j < aLpBc.length; j++) { | |
| 1933 | - aLpBc[j].fnSetFcno(j + 1); | |
| 1934 | - } | |
| 1935 | - | |
| 1936 | - aAllBc = aAllBc.concat(aLpBc); | |
| 1937 | - } | |
| 1938 | - | |
| 1939 | - var aGanttBc = []; | |
| 1940 | - for (i = 0; i < aAllBc.length; i++) { | |
| 1941 | - aGanttBc.push(aAllBc[i].toGanttBcObj()); | |
| 1942 | - } | |
| 1943 | - | |
| 1944 | - return aGanttBc; | |
| 1945 | - } | |
| 1946 | - | |
| 1947 | - }; | |
| 1948 | - | |
| 1 | +/** | |
| 2 | + * 内部行车计划对象。 | |
| 3 | + * @constructor | |
| 4 | + */ | |
| 5 | +var InternalScheduleObj = function(paramObj, lpArray, factory) { | |
| 6 | + // 参数对象 | |
| 7 | + var _paramObj = paramObj; | |
| 8 | + // 外部的路牌数组 | |
| 9 | + var _lpArray = lpArray; | |
| 10 | + // 工厂对象 | |
| 11 | + var _factory = factory; | |
| 12 | + | |
| 13 | + //------------------ 初始化方法1,以及计算关联的内部变量 -----------------// | |
| 14 | + var _qIsUp; // 每一圈是上行开始还是下行开始 | |
| 15 | + var _qCount = 0; // 总的圈数 | |
| 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 | + ]; | |
| 27 | + | |
| 28 | + var _fnInitFun1 = function() { // 初始化方法1 | |
| 29 | + console.log("//---------------- 行车计划,初始化方法1 start ----------------//"); | |
| 30 | + | |
| 31 | + //----------------------- 1、确定上标线的方向,圈的方向 -------------------// | |
| 32 | + | |
| 33 | + // 确定_qIsUp,哪个方向的首班车晚就用哪个 | |
| 34 | + _qIsUp = _paramObj.getUpFirstDTimeObj().isBefore( | |
| 35 | + _paramObj.getDownFirstDTimeObj()) ? false : true; | |
| 36 | + // 上标线开始时间,就是方向的首班车时间 | |
| 37 | + var st = _qIsUp ? _paramObj.getUpFirstDTimeObj() : _paramObj.getDownFirstDTimeObj(); | |
| 38 | + // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向 | |
| 39 | + var et; | |
| 40 | + var et_IsUp; | |
| 41 | + if (_paramObj.getUpLastDtimeObj().isBefore( | |
| 42 | + _paramObj.getDownLastDTimeObj())) { | |
| 43 | + et = _paramObj.getDownLastDTimeObj(); | |
| 44 | + et_IsUp = false; | |
| 45 | + } else { | |
| 46 | + et = _paramObj.getUpLastDtimeObj(); | |
| 47 | + et_IsUp = true; | |
| 48 | + } | |
| 49 | + | |
| 50 | + //------------------------ 2、计算总共有多少圈 ------------------------// | |
| 51 | + | |
| 52 | + // 以开始时间,结束时间,构造上标线用连班班次发车时间 | |
| 53 | + var bcFcsjArrays = []; // 班次发车时间对象数组 | |
| 54 | + var bcArsjArrays = []; // 班次到达时间对象数组 | |
| 55 | + var isUp = _qIsUp; // 方向 | |
| 56 | + var bcCount = 1; // 班次数 | |
| 57 | + | |
| 58 | + var _kssj = st; // 开始时间 | |
| 59 | + var _bcsj = paramObj.calcuTravelTime(_kssj, isUp); // 班次历时 | |
| 60 | + var _arrsj = paramObj.addMinute(_kssj, _bcsj); // 到达时间 | |
| 61 | + var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj); // 停站时间 | |
| 62 | + | |
| 63 | + do { | |
| 64 | + bcFcsjArrays.push(_kssj); | |
| 65 | + bcArsjArrays.push(_arrsj); | |
| 66 | + | |
| 67 | + _kssj = paramObj.addMinute(_kssj, _bcsj + _stoptime); | |
| 68 | + _bcsj = paramObj.calcuTravelTime(_kssj, isUp); | |
| 69 | + _arrsj = paramObj.addMinute(_kssj, _bcsj); | |
| 70 | + _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj); | |
| 71 | + | |
| 72 | + bcCount ++; | |
| 73 | + isUp = !isUp; | |
| 74 | + } while(_kssj.isBefore(et)); | |
| 75 | + bcCount--; // 因为先做do,所以总的班次要减1 | |
| 76 | + //if (bcCount > 0 && bcArsjArrays[bcCount - 1].isAfter(et)) { | |
| 77 | + // // 如果最后一个班次的到达时间超过结束时间,也要去除 | |
| 78 | + // bcFcsjArrays.splice(bcCount - 1, 1); | |
| 79 | + // bcArsjArrays.splice(bcCount - 1, 1); | |
| 80 | + // bcCount--; | |
| 81 | + //} | |
| 82 | + var _qCount_p1 = Math.floor(bcCount / 2); // 2个班次一圈 | |
| 83 | + var _qCount_p2 = bcCount % 2; // 余下的1个班次也算一圈 | |
| 84 | + | |
| 85 | + // 利用连班数组计算圈数 | |
| 86 | + _qCount = 1; // 前面加1圈,补中标线的班次 | |
| 87 | + _qCount += _qCount_p1; | |
| 88 | + _qCount += _qCount_p2; | |
| 89 | + | |
| 90 | + // 计算最后是不是还要补一圈 | |
| 91 | + if (_qCount > 1) { // 总的圈数就1圈,没必要加了(其实是不可能的,除非参数里问题) | |
| 92 | + if (_qCount_p2 == 0) { // 没有余下班次,整数圈数 | |
| 93 | + // 最后一个班次的方向一定和开始的方向相反,如:上-下,上-下,上-下,一共三圈,最后一个班次为下行 | |
| 94 | + // 判定最后一个班次的方向和上标线判定结束时间的班次方向是否一致 | |
| 95 | + if (!_qIsUp == et_IsUp) { | |
| 96 | + // 一致不用加圈数 | |
| 97 | + } else { | |
| 98 | + // 不一致需要加圈补最后一个结束时间班次 | |
| 99 | + _qCount ++; | |
| 100 | + } | |
| 101 | + } else { | |
| 102 | + // 有余下的圈数,最后要不补的班次不管上行,下行都在这一圈里 | |
| 103 | + // 不需要在补圈数了 | |
| 104 | + } | |
| 105 | + } | |
| 106 | + | |
| 107 | + //------------------------ 3、根据路牌数,圈数创建路牌对象 ----------------------// | |
| 108 | + | |
| 109 | + // 创建内部的路牌数组,并把之前的连班路牌添加进上标线路牌中 | |
| 110 | + var i; | |
| 111 | + for (i = 0; i < _lpArray.length; i++) { | |
| 112 | + _internalLpArray.push(new InternalLpObj(_lpArray[i], _qCount, _qIsUp)); | |
| 113 | + } | |
| 114 | + // 初始化上标线,从第1圈开始 | |
| 115 | + _internalLpArray[0].initDataFromTimeToTime(bcFcsjArrays[0], et, _qIsUp, 1, _paramObj, _factory); | |
| 116 | + | |
| 117 | + // 以上标线为基础,计算各种班型工时对应的圈数、班次数 | |
| 118 | + var aBcArray = _internalLpArray[0].getBcArray(); | |
| 119 | + aBcArray[0].fnSetIsFirstBc(true); // 设置首班班次标识 | |
| 120 | + | |
| 121 | + if (aBcArray.length % 2 != 0) { // 不能整除2,去除一个班次计算 | |
| 122 | + aBcArray.splice(aBcArray.length - 1, 1); | |
| 123 | + } | |
| 124 | + | |
| 125 | + // 午饭吃饭时间 | |
| 126 | + var iLTime = _paramObj.fnGetLunchTime(); | |
| 127 | + // 晚饭吃饭时间 | |
| 128 | + var iDTime = _paramObj.fnGetDinnerTime(); | |
| 129 | + // 出场时间 | |
| 130 | + var iOutTime = _qIsUp ? _paramObj.getUpOutTime() : _paramObj.getDownOutTime(); | |
| 131 | + // 进场时间 | |
| 132 | + var iInTime = _qIsUp ? _paramObj.getDownInTime() : _paramObj.getUpInTime(); | |
| 133 | + // 例保时间 | |
| 134 | + var iBTime = _paramObj.getLbTime(); | |
| 135 | + | |
| 136 | + var sum = 0; // 总班次时间 | |
| 137 | + for (i = 0; i < aBcArray.length; i++) { | |
| 138 | + sum += aBcArray[i].getBcTime() + aBcArray[i].getStopTime(); | |
| 139 | + } | |
| 140 | + sum += iLTime; // 加午饭时间 | |
| 141 | + sum += iDTime; // 加晚饭时间 | |
| 142 | + for (i = 0; i < _aBxDesc.length; i++) { | |
| 143 | + _aBxDesc[i].fAverTime = sum / (aBcArray.length / 2); // 平均周转时间不算进出场,例保时间 | |
| 144 | + | |
| 145 | + // 计算5休2的班次数(双进出场,4个例保) | |
| 146 | + if (i == 6) { | |
| 147 | + _aBxDesc[i].fQCount = | |
| 148 | + (_aBxDesc[i].fHoursV * 60 - iOutTime * 2 - iInTime * 2 - iBTime * 4) / | |
| 149 | + _aBxDesc[i].fAverTime; | |
| 150 | + _aBxDesc[i].fBcCount = _aBxDesc[i].fQCount * 2; | |
| 151 | + } else { // 进出场,2个例保 | |
| 152 | + _aBxDesc[i].fQCount = | |
| 153 | + (_aBxDesc[i].fHoursV * 60 - iOutTime - iInTime - iBTime * 2) / | |
| 154 | + _aBxDesc[i].fAverTime; | |
| 155 | + _aBxDesc[i].fBcCount = _aBxDesc[i].fQCount * 2; | |
| 156 | + } | |
| 157 | + } | |
| 158 | + | |
| 159 | + | |
| 160 | + // 在第一个班次之前再添加一个模拟班次,用于中标线的作用 | |
| 161 | + // 那一圈必定是低谷,而且圈索引0,班次索引1,暂时标记,最后删除 | |
| 162 | + var iFirstStopTime = | |
| 163 | + _paramObj.fnCalcuFixedStopNumber( | |
| 164 | + _paramObj.addMinute(aBcArray[0].getFcTimeObj(), -10), | |
| 165 | + _qIsUp | |
| 166 | + ); | |
| 167 | + var iXXTime = _qIsUp ? _paramObj.getDownTroughTime() : _paramObj.getUpTroughTime(); | |
| 168 | + var oFlagBc = _factory.createBcObj( // 标记班次 | |
| 169 | + _internalLpArray[0], | |
| 170 | + "normal", | |
| 171 | + !_qIsUp, | |
| 172 | + 1, | |
| 173 | + _paramObj.addMinute(aBcArray[0].getFcTimeObj(), -(iFirstStopTime + iXXTime)), | |
| 174 | + _paramObj | |
| 175 | + ); | |
| 176 | + oFlagBc.fnSetDelFlag(true); // 标记了删除记号 | |
| 177 | + | |
| 178 | + _internalLpArray[0].setBc(0, 1, oFlagBc); | |
| 179 | + | |
| 180 | + // 在最后一圈也补上一个或者2个模拟班次,暂时标记,最后需要删除 | |
| 181 | + var aMaxBcIndex = _internalLpArray[0].getMaxBcObjPosition(); | |
| 182 | + if (aMaxBcIndex[0] == _qCount - 1) { // 可能加半圈 | |
| 183 | + oFlagBc = _factory.createBcObj( // 标记班次 | |
| 184 | + _internalLpArray[0], | |
| 185 | + "normal", | |
| 186 | + !_qIsUp, | |
| 187 | + 1, | |
| 188 | + _paramObj.addMinute( | |
| 189 | + _internalLpArray[0].getBc(_qCount - 1, 0).getArrTimeObj(), | |
| 190 | + _internalLpArray[0].getBc(_qCount - 1, 0).getStopTime()), | |
| 191 | + _paramObj | |
| 192 | + ); | |
| 193 | + oFlagBc.fnSetDelFlag(true); // 标记了删除记号 | |
| 194 | + _internalLpArray[0].setBc(_qCount - 1, 1, oFlagBc); | |
| 195 | + | |
| 196 | + } else { // 加完整的一圈 | |
| 197 | + oFlagBc = _factory.createBcObj( // 标记班次 | |
| 198 | + _internalLpArray[0], | |
| 199 | + "normal", | |
| 200 | + _qIsUp, | |
| 201 | + 1, | |
| 202 | + _paramObj.addMinute( | |
| 203 | + _internalLpArray[0].getBc(_qCount - 2, 1).getArrTimeObj(), | |
| 204 | + _internalLpArray[0].getBc(_qCount - 2, 1).getStopTime()), | |
| 205 | + _paramObj | |
| 206 | + ); | |
| 207 | + oFlagBc.fnSetDelFlag(true); // 标记了删除记号 | |
| 208 | + _internalLpArray[0].setBc(_qCount - 1, 0, oFlagBc); | |
| 209 | + | |
| 210 | + oFlagBc = _factory.createBcObj( // 标记班次 | |
| 211 | + _internalLpArray[0], | |
| 212 | + "normal", | |
| 213 | + !_qIsUp, | |
| 214 | + 1, | |
| 215 | + _paramObj.addMinute( | |
| 216 | + _internalLpArray[0].getBc(_qCount - 1, 0).getArrTimeObj(), | |
| 217 | + _internalLpArray[0].getBc(_qCount - 1, 0).getStopTime()), | |
| 218 | + _paramObj | |
| 219 | + ); | |
| 220 | + oFlagBc.fnSetDelFlag(true); // 标记了删除记号 | |
| 221 | + _internalLpArray[0].setBc(_qCount - 1, 1, oFlagBc); | |
| 222 | + | |
| 223 | + } | |
| 224 | + | |
| 225 | + console.log("上行首班车时间:" + _paramObj.getUpFirstDTimeObj().format("HH:mm") + | |
| 226 | + "上行末班车时间:" + _paramObj.getUpLastDtimeObj().format("HH:mm")); | |
| 227 | + console.log("下行首班车时间:" + _paramObj.getDownFirstDTimeObj().format("HH:mm") + | |
| 228 | + "下行末班车时间:" + _paramObj.getDownLastDTimeObj().format("HH:mm")); | |
| 229 | + console.log("总共计算的圈数:" + _qCount); | |
| 230 | + console.log("圈的方向isUP:" + _qIsUp); | |
| 231 | + console.log("班型描述(以下):"); | |
| 232 | + console.log(_aBxDesc); | |
| 233 | + console.log("所有路牌间隔描述(以下):"); | |
| 234 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 235 | + console.log(_internalLpArray[i]._$_aVerticalIntervalTime); | |
| 236 | + } | |
| 237 | + console.log("//---------------- 行车计划,初始化方法1 end ----------------//"); | |
| 238 | + | |
| 239 | + }; | |
| 240 | + | |
| 241 | + //------------------ 初始化方法2,以及计算关联的内部变量 ----------------// | |
| 242 | + var _approximate_zgfQIndex; // 预估早高峰车辆从第几圈开始全部发出 | |
| 243 | + var _approximate_zgfBIndex; // 预估早高峰车辆从第几圈第几个班次开始全部发出(上行或下行) | |
| 244 | + var _approximate_wgfQIndex; // 预估晚高峰车辆从第几圈开始全部发出 | |
| 245 | + var _approximate_wgfBIndex; // 预估晚高峰车辆从第几圈第几个班次开始全部发出(上行或下行) | |
| 246 | + | |
| 247 | + var _fnInitFun2 = function() { // 初始化方法2 | |
| 248 | + console.log("//---------------- 行车计划,初始化方法2 start ----------------//"); | |
| 249 | + | |
| 250 | + //------------------------ 1、计算车辆总数 ------------------------// | |
| 251 | + // 是用高峰上行周转时间除以高峰平均间隔得到的 | |
| 252 | + // 这样算还算合理,车辆不多不少,待以后有新的算法再修正 | |
| 253 | + var iClCount = _paramObj.calcuClzx(); | |
| 254 | + | |
| 255 | + //------------------------ 2、计算所有路牌的发车在各个圈中的间隔 --------------------// | |
| 256 | + var i; | |
| 257 | + var j; | |
| 258 | + var iBindex = 1; | |
| 259 | + var iZzsj; | |
| 260 | + var oLp; | |
| 261 | + var iC1; | |
| 262 | + var iC2; | |
| 263 | + | |
| 264 | + for (i = 0; i < _qCount - 1; i++) { | |
| 265 | + while (iBindex <= 1) { | |
| 266 | + // 每圈每个方向的周转时间不一致,以上标线为主 | |
| 267 | + oLp = _internalLpArray[0]; | |
| 268 | + iZzsj = oLp.getBc(i + 1, iBindex).getFcTimeObj().diff( | |
| 269 | + oLp.getBc(i, iBindex).getFcTimeObj(), "m" | |
| 270 | + ); | |
| 271 | + | |
| 272 | + iC1 = Math.floor(iZzsj / iClCount); | |
| 273 | + iC2 = iZzsj % iClCount; | |
| 274 | + | |
| 275 | + for (j = 0; j < iClCount - iC2; j++) { | |
| 276 | + oLp = _internalLpArray[j]; | |
| 277 | + oLp.fnSetVerticalIntervalTime(i, iBindex, iC1); | |
| 278 | + } | |
| 279 | + | |
| 280 | + for (j = 0; j < iC2; j++) { | |
| 281 | + oLp = _internalLpArray[iClCount - iC2 + j]; | |
| 282 | + oLp.fnSetVerticalIntervalTime(i, iBindex, iC1 + 1); | |
| 283 | + } | |
| 284 | + | |
| 285 | + iBindex ++; | |
| 286 | + | |
| 287 | + } | |
| 288 | + iBindex = 0; | |
| 289 | + } | |
| 290 | + // 最后一圈没有下一圈的参照,周转时间没发获取,由于都是低谷,所以使用倒数第二圈的间隔最为最后一圈的间隔 | |
| 291 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 292 | + oLp = _internalLpArray[i]; | |
| 293 | + oLp.fnSetVerticalIntervalTime(_qCount - 1, 0, oLp.fnGetVerticalIntervalTime(_qCount - 2, 0)); | |
| 294 | + oLp.fnSetVerticalIntervalTime(_qCount - 1, 1, oLp.fnGetVerticalIntervalTime(_qCount - 2, 1)); | |
| 295 | + } | |
| 296 | + | |
| 297 | + //------------------------ 3、预估早高峰全部出车第几圈第几个班次全部出车,计算路牌之间的发车间隔 ------------------// | |
| 298 | + | |
| 299 | + // 以上标线为标准,查找离早高峰开始时间最近的班次作为早高峰开始班次 | |
| 300 | + // 以这个班次为早高峰起点,全部出车策略 | |
| 301 | + var qbcIndexArray = _internalLpArray[0].getQBcIndexWithFcTime( | |
| 302 | + _paramObj.getMPeakStartTimeObj(), true, true); | |
| 303 | + var qIndex = qbcIndexArray[0]; // 第几圈 | |
| 304 | + var bIndex = qbcIndexArray[1]; // 第几个班次 | |
| 305 | + | |
| 306 | + for (i = 1; i < _internalLpArray.length; i++) { | |
| 307 | + _fnGenerateBcAndSetBc(i, qIndex, bIndex); | |
| 308 | + } | |
| 309 | + | |
| 310 | + _approximate_zgfQIndex = qIndex; | |
| 311 | + _approximate_zgfBIndex = bIndex; | |
| 312 | + | |
| 313 | + //------------------------ 4、预估晚高峰全部出车第几圈第几个班次全部出车,计算路牌之间的发车间隔 ------------------// | |
| 314 | + | |
| 315 | + // 以上标线为标准,查找离晚高峰开始时间最近的班次作为晚高峰开始班次 | |
| 316 | + // 以这个班次为早高峰起点,全部出车策略 | |
| 317 | + qbcIndexArray = _internalLpArray[0].getQBcIndexWithFcTime( | |
| 318 | + _paramObj.getEPeakStartTimeObj(), true, true); | |
| 319 | + qIndex = qbcIndexArray[0]; // 第几圈 | |
| 320 | + bIndex = qbcIndexArray[1]; // 第几个班次 | |
| 321 | + | |
| 322 | + for (i = 1; i < _internalLpArray.length; i++) { | |
| 323 | + _fnGenerateBcAndSetBc(i, qIndex, bIndex); | |
| 324 | + } | |
| 325 | + | |
| 326 | + _approximate_wgfQIndex = qIndex; | |
| 327 | + _approximate_wgfBIndex = bIndex; | |
| 328 | + | |
| 329 | + console.log("早高峰周转时间(固定最大停战时间):" + _paramObj.calcuPeakZzsj() + "分钟"); | |
| 330 | + console.log("早高峰发车时间范围:" + _paramObj.getMPeakMinFcjx() + "分钟 --- " + _paramObj.getMPeakMaxFcjx() + "分钟"); | |
| 331 | + console.log("预估早高峰第" + _approximate_zgfQIndex + "(index)圈,第" + _approximate_zgfBIndex + "(index)班次车辆全部发出"); | |
| 332 | + console.log("预估晚高峰第" + _approximate_wgfQIndex + "(index)圈,第" + _approximate_wgfBIndex + "(index)班次车辆全部发出"); | |
| 333 | + console.log("//---------------- 行车计划,初始化方法2 end ----------------//"); | |
| 334 | + }; | |
| 335 | + | |
| 336 | + //----------------------- 初始化方法3,计算连班分班的路牌分布 ----------------// | |
| 337 | + var _iBx_lb_lpcount; // 连班路牌数 | |
| 338 | + var _iBx_5_2_fb_lpcount; // 5休2分班路牌数 | |
| 339 | + var _iBx_other_fb_lpcount; // 其他分班路牌数 | |
| 340 | + | |
| 341 | + var _fnInitFun3 = function() { // 初始化方法3 | |
| 342 | + console.log("//---------------- 行车计划,初始化方法3 start ----------------//"); | |
| 343 | + | |
| 344 | + //--------------------- 1、计算分班连班班型车辆分布数 --------------------// | |
| 345 | + // 总共车辆数(高峰最大车辆数) | |
| 346 | + var iCls = _paramObj.calcuClzx(); | |
| 347 | + // 低谷最少配车(连班车数量) | |
| 348 | + var iDgminpc = Math.round(_paramObj.calcuTroughZzsj() / _paramObj.getTroughMaxFcjx()); | |
| 349 | + // 加班车路牌数(做5休2的路牌数) | |
| 350 | + var i_5_2_lpes = _paramObj.getJBLpes(); | |
| 351 | + | |
| 352 | + // 做些简单的验证 | |
| 353 | + if (iCls < iDgminpc) { | |
| 354 | + alert("总配车数小于低谷最小配车"); | |
| 355 | + throw "总配车数小于低谷最小配车"; | |
| 356 | + } | |
| 357 | + if (iDgminpc < 2) { | |
| 358 | + alert("连班路牌小于2,办不到啊"); | |
| 359 | + throw "连班路牌小于2,办不到啊"; | |
| 360 | + } | |
| 361 | + if (iCls - iDgminpc < i_5_2_lpes) { | |
| 362 | + alert("总分班路牌数小于加班路牌数"); | |
| 363 | + throw "总分班路牌数小于加班路牌数"; | |
| 364 | + } | |
| 365 | + | |
| 366 | + //// 修正连班路牌数,班次间隔大于20的,加1,直至班次间隔小于20 | |
| 367 | + //while(_paramObj.calcuPeakZzsj() / iDgminpc > 20) { | |
| 368 | + // iDgminpc ++; | |
| 369 | + //} | |
| 370 | + _iBx_lb_lpcount = iDgminpc; | |
| 371 | + | |
| 372 | + _iBx_5_2_fb_lpcount = i_5_2_lpes; | |
| 373 | + _iBx_other_fb_lpcount = iCls - _iBx_lb_lpcount - i_5_2_lpes; | |
| 374 | + | |
| 375 | + //------------------------ 2、利用间隔法计算连班路牌分布 --------------------// | |
| 376 | + var i; | |
| 377 | + var j; | |
| 378 | + var iC1 = Math.floor(_internalLpArray.length / _iBx_lb_lpcount); | |
| 379 | + var iC2 = _internalLpArray.length % _iBx_lb_lpcount; | |
| 380 | + var iLpIndex; | |
| 381 | + | |
| 382 | + for (i = 0; i < _iBx_lb_lpcount - iC2; i++) { | |
| 383 | + iLpIndex = i * iC1; | |
| 384 | + _internalLpArray[iLpIndex].setBxLb(true); | |
| 385 | + _internalLpArray[iLpIndex].setBxDesc("连班"); | |
| 386 | + } | |
| 387 | + for (j = 0; j < iC2; j++) { | |
| 388 | + iLpIndex = i * iC1 + j * (iC1 + 1); | |
| 389 | + _internalLpArray[iLpIndex].setBxLb(true); | |
| 390 | + _internalLpArray[iLpIndex].setBxDesc("连班"); | |
| 391 | + } | |
| 392 | + | |
| 393 | + //------------------------ 3、利用间隔法计算分班班型路牌分布 --------------------// | |
| 394 | + // 获取分班路牌索引 | |
| 395 | + var aNotLbIndexes = []; | |
| 396 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 397 | + if (!_internalLpArray[i].isBxLb()) { | |
| 398 | + aNotLbIndexes.push(i); | |
| 399 | + } | |
| 400 | + } | |
| 401 | + // 先5休2分班 | |
| 402 | + iC1 = Math.floor(aNotLbIndexes.length / _iBx_5_2_fb_lpcount); | |
| 403 | + iC2 = aNotLbIndexes.length % _iBx_5_2_fb_lpcount; | |
| 404 | + | |
| 405 | + for (i = 0; i < _iBx_5_2_fb_lpcount - iC2; i++) { | |
| 406 | + iLpIndex = aNotLbIndexes[i * iC1]; | |
| 407 | + _internalLpArray[iLpIndex].setBxLb(false); | |
| 408 | + _internalLpArray[iLpIndex].setBxFb(true); | |
| 409 | + _internalLpArray[iLpIndex].setBxFb5_2(true); | |
| 410 | + _internalLpArray[iLpIndex].setBxDesc("5休2分班"); | |
| 411 | + } | |
| 412 | + for (i = 0; i < iC2; i++) { | |
| 413 | + iLpIndex = aNotLbIndexes[_iBx_5_2_fb_lpcount - iC2 + i * (iC1 + 1)]; | |
| 414 | + _internalLpArray[iLpIndex].setBxLb(false); | |
| 415 | + _internalLpArray[iLpIndex].setBxFb(true); | |
| 416 | + _internalLpArray[iLpIndex].setBxFb5_2(true); | |
| 417 | + _internalLpArray[iLpIndex].setBxDesc("5休2分班"); | |
| 418 | + } | |
| 419 | + // 其他分班 | |
| 420 | + for (i = 0; i < aNotLbIndexes.length; i++) { | |
| 421 | + iLpIndex = aNotLbIndexes[i]; | |
| 422 | + if (!_internalLpArray[iLpIndex].isBxFb5_2()) { | |
| 423 | + _internalLpArray[iLpIndex].setBxLb(false); | |
| 424 | + _internalLpArray[iLpIndex].setBxFb(true); | |
| 425 | + _internalLpArray[iLpIndex].setBxFb5_2(false); | |
| 426 | + _internalLpArray[iLpIndex].setBxDesc("其他分班"); | |
| 427 | + } | |
| 428 | + } | |
| 429 | + | |
| 430 | + console.log("高峰周转时间:" + _paramObj.calcuPeakZzsj()); | |
| 431 | + console.log("连班路牌数:" + _iBx_lb_lpcount); | |
| 432 | + console.log("5休2分班路牌数:" + _iBx_5_2_fb_lpcount); | |
| 433 | + console.log("其他分班路牌数:" + _iBx_other_fb_lpcount); | |
| 434 | + var aLbIndexes = []; | |
| 435 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 436 | + if (_internalLpArray[i].isBxLb()) { | |
| 437 | + aLbIndexes.push(i); | |
| 438 | + } | |
| 439 | + } | |
| 440 | + console.log("连班路牌indexes=" + aLbIndexes); | |
| 441 | + var a_5_2_fbIndexes = []; | |
| 442 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 443 | + if (_internalLpArray[i].isBxFb() && _internalLpArray[i].isBxFb5_2()) { | |
| 444 | + a_5_2_fbIndexes.push(i); | |
| 445 | + } | |
| 446 | + } | |
| 447 | + console.log("5休2分班路牌indexes=" + a_5_2_fbIndexes); | |
| 448 | + var a_other_fbIndexes = []; | |
| 449 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 450 | + if (_internalLpArray[i].isBxFb() && !_internalLpArray[i].isBxFb5_2()) { | |
| 451 | + a_other_fbIndexes.push(i); | |
| 452 | + } | |
| 453 | + } | |
| 454 | + console.log("其他分班路牌indexes=" + a_other_fbIndexes); | |
| 455 | + | |
| 456 | + console.log("//---------------- 行车计划,初始化方法3 end ----------------//"); | |
| 457 | + }; | |
| 458 | + | |
| 459 | + //----------------------- 初始化方法4,计算中标线位置 -------------------------// | |
| 460 | + var _iZbx_lpIndex; // 中标线对应第几个路牌 | |
| 461 | + | |
| 462 | + var _fnInitFun4 = function() { // 初始化方法4 | |
| 463 | + console.log("//---------------- 行车计划,初始化方法4 start ----------------//"); | |
| 464 | + | |
| 465 | + //---------------------------- 1、模拟一个中标线,使用临时路牌 ----------------------// | |
| 466 | + // 构造中标线 | |
| 467 | + // 中标线开始时间,就是方向的首班车时间 | |
| 468 | + var oSt = !_qIsUp ? _paramObj.getUpFirstDTimeObj() : _paramObj.getDownFirstDTimeObj(); | |
| 469 | + // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向 | |
| 470 | + // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向 | |
| 471 | + var oEt; | |
| 472 | + if (_paramObj.getUpLastDtimeObj().isBefore( | |
| 473 | + _paramObj.getDownLastDTimeObj())) { | |
| 474 | + oEt = _paramObj.getDownLastDTimeObj(); | |
| 475 | + } else { | |
| 476 | + oEt = _paramObj.getUpLastDtimeObj(); | |
| 477 | + } | |
| 478 | + | |
| 479 | + var oTempLp = new InternalLpObj({lpNo: -999, lpName: "-999"}, _qCount, _qIsUp); | |
| 480 | + oTempLp.initDataFromTimeToTime( | |
| 481 | + oSt, | |
| 482 | + oEt, | |
| 483 | + !_qIsUp, | |
| 484 | + 0, | |
| 485 | + _paramObj, | |
| 486 | + _factory | |
| 487 | + ); | |
| 488 | + | |
| 489 | + //------------------------ 2、找出中标线的早高峰班次,计算应该插在当前路牌数组的那个位置 ----------------// | |
| 490 | + // 找出中标线对应的早高峰的班次对象 | |
| 491 | + var oZb_gf_bc = oTempLp.getBc(_approximate_zgfQIndex, _approximate_zgfBIndex); | |
| 492 | + //alert(oZb_gf_bc.getFcTimeObj().format("HH:mm")); | |
| 493 | + | |
| 494 | + // 把所有连班路牌高峰班次重新构造成一个一个的圈数组,计算对应中标线最近的是第几个路牌 | |
| 495 | + // 中标线和上标线一样在连班路牌上 | |
| 496 | + var aTempq = []; | |
| 497 | + var oTempq; | |
| 498 | + var oTempb; | |
| 499 | + var i; | |
| 500 | + var oLp; | |
| 501 | + | |
| 502 | + var aLbIndexes = []; // 连班的路牌索引 | |
| 503 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 504 | + if (_internalLpArray[i].isBxLb()) { | |
| 505 | + aLbIndexes.push(i); | |
| 506 | + } | |
| 507 | + } | |
| 508 | + | |
| 509 | + for (i = 0; i < aLbIndexes.length; i++) { | |
| 510 | + oLp = _internalLpArray[aLbIndexes[i]]; | |
| 511 | + | |
| 512 | + oTempb = oLp.getBc(_approximate_zgfQIndex, _approximate_zgfBIndex); | |
| 513 | + if (oTempb.isUp() == _qIsUp) { | |
| 514 | + oTempq = new InternalGroupObj(oLp, _qIsUp, oTempb, undefined); | |
| 515 | + } else { | |
| 516 | + oTempq = new InternalGroupObj(oLp, _qIsUp, undefined, oTempb); | |
| 517 | + } | |
| 518 | + aTempq.push(oTempq); | |
| 519 | + | |
| 520 | + } | |
| 521 | + | |
| 522 | + var aTtindex = oTempLp.fnGetQBcIndexWithFcTimeFromGroupArray( // 找出最接近中标线的路牌索引 | |
| 523 | + oZb_gf_bc.getFcTimeObj(), | |
| 524 | + aTempq, | |
| 525 | + true, | |
| 526 | + true | |
| 527 | + ); | |
| 528 | + | |
| 529 | + _iZbx_lpIndex = aLbIndexes[aTtindex[0]]; // 中标线放在第几个路牌 | |
| 530 | + | |
| 531 | + oTempLp.getMinBcObj().fnSetIsFirstBc(true); // 设置首班班次标识 | |
| 532 | + | |
| 533 | + if (_iZbx_lpIndex == 0) { // 如果中标线和上标线一致 | |
| 534 | + var oFirstBcIndexes = oTempLp.getMinBcObjPosition(); | |
| 535 | + var oFirstBc = oTempLp.getMinBcObj(); | |
| 536 | + oFirstBc.setLp(_internalLpArray[_iZbx_lpIndex]); | |
| 537 | + oFirstBc.fnSetDelFlag(false); | |
| 538 | + _internalLpArray[_iZbx_lpIndex].setBc(oFirstBcIndexes[0], oFirstBcIndexes[1], oFirstBc); | |
| 539 | + } else { | |
| 540 | + oTempLp.setLp(_lpArray[_iZbx_lpIndex]); // 设置原始路牌对象 | |
| 541 | + oTempLp._$_aVerticalIntervalTime = _internalLpArray[_iZbx_lpIndex]._$_aVerticalIntervalTime; // 设置纵向最小发车间隔 | |
| 542 | + oTempLp.setBxLb(_internalLpArray[_iZbx_lpIndex].isBxLb()); | |
| 543 | + oTempLp.setBxFb(_internalLpArray[_iZbx_lpIndex].isBxFb()); | |
| 544 | + oTempLp.setBxFb5_2(_internalLpArray[_iZbx_lpIndex].isBxFb5_2()); | |
| 545 | + | |
| 546 | + // 修正除了第一个班次外,其余其他班次 | |
| 547 | + var iBcindex = 0; | |
| 548 | + for (i = 1; i < _qCount; i++) { | |
| 549 | + while (iBcindex <= 1) { | |
| 550 | + if (oTempLp.getBc(i, iBcindex)) { // 替换存在的班次 | |
| 551 | + oTempLp.setBc(i, iBcindex, _fnGenerateBc(_iZbx_lpIndex, i, iBcindex)); | |
| 552 | + } | |
| 553 | + iBcindex ++; | |
| 554 | + } | |
| 555 | + iBcindex = 0; | |
| 556 | + } | |
| 557 | + | |
| 558 | + _internalLpArray[_iZbx_lpIndex] = oTempLp; | |
| 559 | + } | |
| 560 | + | |
| 561 | + console.log("中标线对应第" + (_iZbx_lpIndex + 1) + "个路牌"); | |
| 562 | + | |
| 563 | + console.log("//---------------- 行车计划,初始化方法4 end ----------------//"); | |
| 564 | + }; | |
| 565 | + | |
| 566 | + //-------------------- 重要的内部方法 -----------------------// | |
| 567 | + /** | |
| 568 | + * 核心方法,利用路牌间隔纵向生成班次。 | |
| 569 | + * @param iLpindex 路牌索引 | |
| 570 | + * @param iQindex 圈索引 | |
| 571 | + * @param iBcindex 班次索引 | |
| 572 | + * @returns object InternalBcObj,失败 false | |
| 573 | + */ | |
| 574 | + var _fnGenerateBc = function(iLpindex, iQindex, iBcindex) { | |
| 575 | + // 以上标线为起始点,使用路牌在不同圈,班次索引的发车间隔,计算班次 | |
| 576 | + // 注意,发车间隔是指下一个班次应该距离当前班次间隔,是从下往上的 | |
| 577 | + | |
| 578 | + // 1、参数验证 | |
| 579 | + if (iLpindex == 0) { // 上标线的班次不需要生成 | |
| 580 | + return false; | |
| 581 | + } | |
| 582 | + | |
| 583 | + // 2、计算间隔 | |
| 584 | + var i; | |
| 585 | + var oLp; | |
| 586 | + var iTime = 0; | |
| 587 | + for (i = 0; i < iLpindex; i++) { | |
| 588 | + oLp = _internalLpArray[i]; | |
| 589 | + iTime += oLp.fnGetVerticalIntervalTime(iQindex, iBcindex); | |
| 590 | + } | |
| 591 | + | |
| 592 | + // 3、生成班次 | |
| 593 | + var _oKsbc = _internalLpArray[0].getBc(iQindex, iBcindex); | |
| 594 | + if (!_oKsbc) { | |
| 595 | + return false; | |
| 596 | + } | |
| 597 | + var _oKssj = _paramObj.addMinute(_oKsbc.getFcTimeObj(), iTime); | |
| 598 | + var _oBc = _factory.createBcObj( | |
| 599 | + _internalLpArray[iLpindex], | |
| 600 | + "normal", _oKsbc.isUp(), | |
| 601 | + 1, _oKssj, _paramObj); | |
| 602 | + | |
| 603 | + return _oBc; | |
| 604 | + | |
| 605 | + }; | |
| 606 | + | |
| 607 | + /** | |
| 608 | + * 核心方法,在指定位置生成班次并添加到路牌指定位置中。 | |
| 609 | + * @param lpIndex 第几个路牌 | |
| 610 | + * @param qIndex 第几圈 | |
| 611 | + * @param bcIndex 第几个班次 | |
| 612 | + */ | |
| 613 | + var _fnGenerateBcAndSetBc = function(lpIndex, qIndex, bcIndex) { | |
| 614 | + var _bcObj = _fnGenerateBc(lpIndex, qIndex, bcIndex); | |
| 615 | + if (_bcObj) { | |
| 616 | + _internalLpArray[lpIndex].setBc(qIndex, bcIndex, _bcObj); | |
| 617 | + } | |
| 618 | + }; | |
| 619 | + | |
| 620 | + /** | |
| 621 | + * 获取班次列表。 | |
| 622 | + * @param oIsUp 是否上行 | |
| 623 | + * @param oStartTime 开始时间对象 | |
| 624 | + * @returns [(InternalBcObj)] | |
| 625 | + */ | |
| 626 | + var _fnGetBcList2 = function(oIsUp, oStartTime) { | |
| 627 | + var i; | |
| 628 | + var j; | |
| 629 | + var oLp; | |
| 630 | + var oBc; | |
| 631 | + var aBc = []; | |
| 632 | + | |
| 633 | + for (j = 0; j < _qCount; j++) { | |
| 634 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 635 | + oLp = _internalLpArray[i]; | |
| 636 | + oBc = oLp.getBc( | |
| 637 | + j, | |
| 638 | + _qIsUp == oIsUp ? 0 : 1 | |
| 639 | + ); | |
| 640 | + if (oBc && oBc.getFcTimeObj().isAfter(oStartTime)) { | |
| 641 | + aBc.push(oBc); | |
| 642 | + } | |
| 643 | + } | |
| 644 | + } | |
| 645 | + | |
| 646 | + var aBcFcTime = []; | |
| 647 | + for (i = 0; i < aBc.length; i++) { | |
| 648 | + oBc = aBc[i]; | |
| 649 | + aBcFcTime.push(oBc.getFcTimeObj().format("HH:mm")); | |
| 650 | + } | |
| 651 | + console.log((oIsUp ? "上行班次列表:" : "下行班次列表:") + aBcFcTime.join(",")); | |
| 652 | + | |
| 653 | + return aBc; | |
| 654 | + }; | |
| 655 | + | |
| 656 | + /** | |
| 657 | + * 获取班次列表。 | |
| 658 | + * @param isUp boolean 是否上行 | |
| 659 | + * @returns [(InternalBcObj)] | |
| 660 | + */ | |
| 661 | + var _fnGetBcList = function(isUp) { | |
| 662 | + var i; | |
| 663 | + var j; | |
| 664 | + var oLp; | |
| 665 | + var oBc; | |
| 666 | + var aBc = []; | |
| 667 | + | |
| 668 | + for (j = 0; j < _qCount; j++) { | |
| 669 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 670 | + oLp = _internalLpArray[i]; | |
| 671 | + oBc = oLp.getBc( | |
| 672 | + j, | |
| 673 | + _qIsUp == isUp ? 0 : 1 | |
| 674 | + ); | |
| 675 | + if (oBc) { | |
| 676 | + aBc.push(oBc); | |
| 677 | + } | |
| 678 | + } | |
| 679 | + } | |
| 680 | + | |
| 681 | + var aBcFcTime = []; | |
| 682 | + for (i = 0; i < aBc.length; i++) { | |
| 683 | + oBc = aBc[i]; | |
| 684 | + aBcFcTime.push(oBc.getFcTimeObj().format("HH:mm")); | |
| 685 | + } | |
| 686 | + console.log((isUp ? "上行班次列表:" : "下行班次列表:") + aBcFcTime.join(",")); | |
| 687 | + | |
| 688 | + return aBc; | |
| 689 | + }; | |
| 690 | + | |
| 691 | + /** | |
| 692 | + * 查找离指定时间最近的前面的班次索引信息 | |
| 693 | + * @param timeObj 查找时间 | |
| 694 | + * @param isUp 是否上行 | |
| 695 | + * @returns [{路牌index},{圈index},{班次index}] | |
| 696 | + */ | |
| 697 | + var _fnFindUpClosedBcIndexWithTime = function(timeObj, isUp) { | |
| 698 | + | |
| 699 | + var _lpObj; | |
| 700 | + var _groupObj; | |
| 701 | + var _bcObj; | |
| 702 | + var _i; | |
| 703 | + var _j; | |
| 704 | + var timediff; // 时间差取绝对值 | |
| 705 | + | |
| 706 | + var _lpIndex; | |
| 707 | + var _up_qIndex; | |
| 708 | + var _up_bIndex; | |
| 709 | + | |
| 710 | + for (_i = 0; _i < _qCount; _i++) { | |
| 711 | + for (_j = 0; _j < _internalLpArray.length; _j++) { | |
| 712 | + _lpObj = _internalLpArray[_j]; | |
| 713 | + _groupObj = _lpObj.getGroup(_i); | |
| 714 | + _bcObj = isUp == _qIsUp ? _groupObj.getBc1() : _groupObj.getBc2(); | |
| 715 | + if (!_bcObj) { // 没有班次动态生成一个,可能生成不出的 | |
| 716 | + _bcObj = _fnGenerateBc(_j, _i, isUp == _qIsUp ? 0 : 1); | |
| 717 | + } | |
| 718 | + if (_bcObj) { | |
| 719 | + if (timeObj.diff(_bcObj.getFcTimeObj()) >= 0) { | |
| 720 | + if (!timediff) { | |
| 721 | + timediff = timeObj.diff(_bcObj.getFcTimeObj()); | |
| 722 | + _lpIndex = _j; | |
| 723 | + _up_qIndex = _i; | |
| 724 | + _up_bIndex = isUp == _qIsUp ? 0 : 1; | |
| 725 | + } else { | |
| 726 | + if (timeObj.diff(_bcObj.getFcTimeObj()) < timediff) { | |
| 727 | + timediff = timeObj.diff(_bcObj.getFcTimeObj()); | |
| 728 | + _lpIndex = _j; | |
| 729 | + _up_qIndex = _i; | |
| 730 | + _up_bIndex = isUp == _qIsUp ? 0 : 1; | |
| 731 | + } | |
| 732 | + } | |
| 733 | + } | |
| 734 | + } | |
| 735 | + } | |
| 736 | + } | |
| 737 | + | |
| 738 | + if (_lpIndex == undefined) { | |
| 739 | + return false; | |
| 740 | + } | |
| 741 | + | |
| 742 | + var bcindex = []; | |
| 743 | + bcindex.push(_lpIndex); | |
| 744 | + bcindex.push(_up_qIndex); | |
| 745 | + bcindex.push(_up_bIndex); | |
| 746 | + | |
| 747 | + return bcindex; | |
| 748 | + }; | |
| 749 | + | |
| 750 | + /** | |
| 751 | + * 查找离指定时间最近的后面的班次索引信息 | |
| 752 | + * @param timeObj 查找时间 | |
| 753 | + * @param isUp 是否上行 | |
| 754 | + * @returns [{路牌index},{圈index},{班次index}] | |
| 755 | + */ | |
| 756 | + var _fnFindDownClosedBcIndexWithTime = function(timeObj, isUp) { | |
| 757 | + var _lpObj; | |
| 758 | + var _groupObj; | |
| 759 | + var _bcObj; | |
| 760 | + var _i; | |
| 761 | + var _j; | |
| 762 | + var timediff; // 时间差取绝对值 | |
| 763 | + | |
| 764 | + var _lpIndex; | |
| 765 | + var _down_qIndex; | |
| 766 | + var _down_bIndex; | |
| 767 | + | |
| 768 | + var flag; | |
| 769 | + | |
| 770 | + for (_i = 0; _i < _qCount; _i++) { | |
| 771 | + for (_j = 0; _j < _internalLpArray.length; _j++) { | |
| 772 | + _lpObj = _internalLpArray[_j]; | |
| 773 | + _groupObj = _lpObj.getGroup(_i); | |
| 774 | + // TODO:bug | |
| 775 | + _bcObj = isUp == _qIsUp ? _groupObj.getBc1() : _groupObj.getBc2(); | |
| 776 | + if (!_bcObj) { // 没有班次动态生成一个,可能生成不出的 | |
| 777 | + _bcObj = _fnGenerateBc(_j, _i, isUp == _qIsUp ? 0 : 1); | |
| 778 | + } | |
| 779 | + if (_bcObj) { | |
| 780 | + //console.log("timeobj -> bcobj diff flag " + | |
| 781 | + // timeObj.format("HH:mm") + "->" + | |
| 782 | + // _bcObj.getFcTimeObj().format("HH:mm") + | |
| 783 | + // timeObj.diff(_bcObj.getFcTimeObj()) + | |
| 784 | + // (timeObj.diff(_bcObj.getFcTimeObj()) <= 0) | |
| 785 | + //); | |
| 786 | + | |
| 787 | + flag = (timeObj.diff(_bcObj.getFcTimeObj())) <= 0; | |
| 788 | + | |
| 789 | + if (flag) { | |
| 790 | + if (!timediff) { | |
| 791 | + timediff = timeObj.diff(_bcObj.getFcTimeObj()); | |
| 792 | + _lpIndex = _j; | |
| 793 | + _down_qIndex = _i; | |
| 794 | + _down_bIndex = isUp == _qIsUp ? 0 : 1; | |
| 795 | + } else { | |
| 796 | + if ((timeObj.diff(_bcObj.getFcTimeObj())) > timediff) { | |
| 797 | + timediff = timeObj.diff(_bcObj.getFcTimeObj()); | |
| 798 | + _lpIndex = _j; | |
| 799 | + _down_qIndex = _i; | |
| 800 | + _down_bIndex = isUp == _qIsUp ? 0 : 1; | |
| 801 | + } | |
| 802 | + } | |
| 803 | + } | |
| 804 | + } | |
| 805 | + } | |
| 806 | + } | |
| 807 | + | |
| 808 | + if (_lpIndex == undefined) { | |
| 809 | + return false; | |
| 810 | + } | |
| 811 | + | |
| 812 | + var bcindex = []; | |
| 813 | + bcindex.push(_lpIndex); | |
| 814 | + bcindex.push(_down_qIndex); | |
| 815 | + bcindex.push(_down_bIndex); | |
| 816 | + | |
| 817 | + return bcindex; | |
| 818 | + }; | |
| 819 | + | |
| 820 | + /** | |
| 821 | + * 获取班次索引。 | |
| 822 | + * @param oBc 班次对象 | |
| 823 | + * @returns [{路牌索引},{圈索引},{班次索引}] | |
| 824 | + */ | |
| 825 | + var _fnGetBcIndex = function(oBc) { | |
| 826 | + // 路牌索引 | |
| 827 | + var i; | |
| 828 | + var iLpIndex; | |
| 829 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 830 | + if (_internalLpArray[i]._$$_orign_lp_obj == oBc._$$_internal_lp_obj._$$_orign_lp_obj) { | |
| 831 | + iLpIndex = i; | |
| 832 | + break; | |
| 833 | + } | |
| 834 | + } | |
| 835 | + // 圈索引 | |
| 836 | + var j; | |
| 837 | + var iGroupIndex; | |
| 838 | + var bFlag = false; | |
| 839 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 840 | + if (bFlag) { | |
| 841 | + break; | |
| 842 | + } | |
| 843 | + for (j = 0; j < _qCount; j++) { | |
| 844 | + if (_internalLpArray[i]._$_groupBcArray[j] == oBc._$$_internal_group_obj) { | |
| 845 | + iGroupIndex = j; | |
| 846 | + bFlag = true; | |
| 847 | + break; | |
| 848 | + } | |
| 849 | + } | |
| 850 | + } | |
| 851 | + // 班次索引 | |
| 852 | + var iBcIndex = _qIsUp == oBc.isUp() ? 0 : 1; | |
| 853 | + | |
| 854 | + if (iLpIndex == undefined) { | |
| 855 | + return null; | |
| 856 | + } else { | |
| 857 | + return [].concat(iLpIndex, iGroupIndex, iBcIndex); | |
| 858 | + } | |
| 859 | + | |
| 860 | + }; | |
| 861 | + | |
| 862 | + return { | |
| 863 | + //------------- 布局初始化方法 ------------// | |
| 864 | + /** | |
| 865 | + * 初始化数据,使用标线初始化 | |
| 866 | + */ | |
| 867 | + fnInitDataWithBxLayout: function() { | |
| 868 | + // 初始化布局1,构造上标线,计算圈数,把上标线数据放入第一个路牌中 | |
| 869 | + _fnInitFun1(); | |
| 870 | + // 初始化布局2,从上标线的某个班次开始,构造所有路牌的早高峰班次,晚高峰班次,计算路牌在各个圈中的间隔 | |
| 871 | + _fnInitFun2(); | |
| 872 | + // 初始化布局3,计算连班分班路牌分布 | |
| 873 | + _fnInitFun3(); | |
| 874 | + // 初始化布局4,计算中标线位置 | |
| 875 | + _fnInitFun4(); | |
| 876 | + | |
| 877 | + }, | |
| 878 | + | |
| 879 | + /** | |
| 880 | + * 调整高峰班次, | |
| 881 | + * 初始化生成早高峰,晚高峰班次并不准确,因为根据高峰时间段,并不在一个完整圈内,应该是在两个或多个圈之间 | |
| 882 | + * 当初始化定好布局后(上标线,中标线),然后确定每个路牌的班型(连班,分班,5休2分班)后 | |
| 883 | + * 然后重新计算框在高峰时间段内的班次索引,不足的添加,之前多加的删除(只删除分班路牌上的) | |
| 884 | + * @param isZgf 是否早高峰 | |
| 885 | + * @param isUp 是否上行 | |
| 886 | + */ | |
| 887 | + fnAdjustGfbc : function(isZgf, isUp) { | |
| 888 | + var oStartTime; // 开始时间 | |
| 889 | + var oEndTime; // 结束时间 | |
| 890 | + var aStartBcIndex; // 开始班次索引 | |
| 891 | + var aEndBcIndex; // 结束班次索引 | |
| 892 | + | |
| 893 | + oStartTime = isZgf ? _paramObj.getMPeakStartTimeObj() : _paramObj.getEPeakStartTimeObj(); | |
| 894 | + oEndTime = isZgf ? _paramObj.getMPeakEndTimeObj() : _paramObj.getEPeakEndTimeObj(); | |
| 895 | + | |
| 896 | + aStartBcIndex = _fnFindUpClosedBcIndexWithTime(oStartTime, isUp); | |
| 897 | + aEndBcIndex = _fnFindDownClosedBcIndexWithTime(oEndTime, isUp); | |
| 898 | + | |
| 899 | + var iLpIndex; | |
| 900 | + var iQIndex; | |
| 901 | + var iBcIndex; | |
| 902 | + var iQInternelCount; // 高峰时间段中间包含的圈数 | |
| 903 | + var i; | |
| 904 | + var j; | |
| 905 | + | |
| 906 | + var oLp; | |
| 907 | + | |
| 908 | + if (aStartBcIndex && aEndBcIndex) { | |
| 909 | + iLpIndex = aStartBcIndex[0]; | |
| 910 | + iQIndex = aStartBcIndex[1]; | |
| 911 | + iBcIndex = aStartBcIndex[2]; | |
| 912 | + | |
| 913 | + // 处理头 | |
| 914 | + // 删除头部多余班次 | |
| 915 | + for (j = 0; j < iLpIndex; j++) { | |
| 916 | + oLp = _internalLpArray[j]; | |
| 917 | + if (oLp.isBxFb() && oLp.getBc(iQIndex, iBcIndex)) { | |
| 918 | + oLp.removeBc(iQIndex, iBcIndex); | |
| 919 | + } | |
| 920 | + } | |
| 921 | + | |
| 922 | + for (j = iLpIndex; j < _internalLpArray.length; j++) { | |
| 923 | + oLp = _internalLpArray[j]; | |
| 924 | + if (!oLp.getBc(iQIndex, iBcIndex)) { | |
| 925 | + _fnGenerateBcAndSetBc(j, iQIndex, iBcIndex); | |
| 926 | + } | |
| 927 | + } | |
| 928 | + | |
| 929 | + // 处理中间 | |
| 930 | + iQInternelCount = aEndBcIndex[1] - aStartBcIndex[1] - 1; | |
| 931 | + for (i = 1; i <= iQInternelCount; i++) { | |
| 932 | + oLp = _internalLpArray[iQIndex + i]; | |
| 933 | + | |
| 934 | + if (!oLp.getBc(iQIndex + i, iBcIndex)) { | |
| 935 | + _fnGenerateBcAndSetBc(i, iQIndex + i, iBcIndex); | |
| 936 | + } | |
| 937 | + } | |
| 938 | + | |
| 939 | + // 处理尾部 | |
| 940 | + iLpIndex = aEndBcIndex[0]; | |
| 941 | + iQIndex = aEndBcIndex[1]; | |
| 942 | + iBcIndex = aEndBcIndex[2]; | |
| 943 | + | |
| 944 | + // 删除尾部多余的班次 | |
| 945 | + for (j = iLpIndex; j < _internalLpArray.length; j++) { | |
| 946 | + oLp = _internalLpArray[j]; | |
| 947 | + if (oLp.isBxFb() && oLp.getBc(iQIndex, iBcIndex)) { | |
| 948 | + oLp.removeBc(iQIndex, iBcIndex); | |
| 949 | + } | |
| 950 | + } | |
| 951 | + | |
| 952 | + if (aStartBcIndex[1] != aEndBcIndex[1]) { // 指定时间范围跨圈 | |
| 953 | + for (j = 0; j < iLpIndex; j++) { | |
| 954 | + oLp = _internalLpArray[j]; | |
| 955 | + if (!oLp.getBc(iQIndex, iBcIndex)) { | |
| 956 | + _fnGenerateBcAndSetBc(j, iQIndex, iBcIndex); | |
| 957 | + } | |
| 958 | + } | |
| 959 | + } else { | |
| 960 | + // 不跨圈,不用处理,处理头的时候已经加了 | |
| 961 | + } | |
| 962 | + | |
| 963 | + } | |
| 964 | + | |
| 965 | + }, | |
| 966 | + | |
| 967 | + /** | |
| 968 | + * 按照营运时间要求补充班次, | |
| 969 | + * 早高峰7:45分以前出场运营, | |
| 970 | + * 晚高峰16:10分以前出场运营 | |
| 971 | + */ | |
| 972 | + fnCalcuLpBc_yy: function() { | |
| 973 | + // 补班次的时候,针对的是分班班型 | |
| 974 | + var i; | |
| 975 | + var _oLp; | |
| 976 | + var _oBc; | |
| 977 | + var _aMinBcIndex; | |
| 978 | + var _aMaxBcIndex; | |
| 979 | + | |
| 980 | + var _qIndex; | |
| 981 | + var _bIndex; | |
| 982 | + | |
| 983 | + var _zgfCDate = _paramObj.toTimeObj("7:45"); | |
| 984 | + var _wgfCDate = _paramObj.toTimeObj("16:10"); | |
| 985 | + var _ccsj; | |
| 986 | + | |
| 987 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 988 | + _oLp = _internalLpArray[i]; | |
| 989 | + if (_oLp.isBxFb()) { // 分班路牌 | |
| 990 | + // 早高峰部分 | |
| 991 | + _aMinBcIndex = _oLp.getMinBcObjPosition(); | |
| 992 | + _qIndex = _aMinBcIndex[0]; | |
| 993 | + _bIndex = _aMinBcIndex[1]; | |
| 994 | + _oBc = _oLp.getBc(_qIndex, _bIndex); | |
| 995 | + if (_qIsUp) { | |
| 996 | + _ccsj = _bIndex == 0 ? | |
| 997 | + _paramObj.getUpOutTime() : | |
| 998 | + _paramObj.getDownOutTime(); | |
| 999 | + } else { | |
| 1000 | + _ccsj = _bIndex == 0 ? | |
| 1001 | + _paramObj.getDownOutTime() : | |
| 1002 | + _paramObj.getUpOutTime(); | |
| 1003 | + } | |
| 1004 | + if (_zgfCDate.isBefore(_paramObj.addMinute(_oBc.getFcTimeObj(), -_ccsj))) { | |
| 1005 | + _fnGenerateBcAndSetBc( | |
| 1006 | + i, | |
| 1007 | + _bIndex == 0 ? _qIndex - 1 : _qIndex, | |
| 1008 | + _bIndex == 0 ? 1 : 0 | |
| 1009 | + ) | |
| 1010 | + } | |
| 1011 | + | |
| 1012 | + // 晚高峰部分 | |
| 1013 | + _aMaxBcIndex = _oLp.getMaxBcObjPosition(); | |
| 1014 | + _qIndex = _aMaxBcIndex[0]; | |
| 1015 | + _bIndex = _aMaxBcIndex[1]; | |
| 1016 | + _oBc = _oLp.getBc( | |
| 1017 | + _bIndex == 0 ? _qIndex - 1 : _qIndex, | |
| 1018 | + _bIndex == 0 ? 1 : 0 | |
| 1019 | + ); | |
| 1020 | + if (!_oBc) { // 前一个班次不存在,再判定加不加 | |
| 1021 | + _oBc = _oLp.getBc(_qIndex, _bIndex); | |
| 1022 | + if (_qIsUp) { | |
| 1023 | + _ccsj = _bIndex == 0 ? | |
| 1024 | + _paramObj.getUpOutTime() : | |
| 1025 | + _paramObj.getDownOutTime(); | |
| 1026 | + } else { | |
| 1027 | + _ccsj = _bIndex == 0 ? | |
| 1028 | + _paramObj.getDownOutTime() : | |
| 1029 | + _paramObj.getUpOutTime(); | |
| 1030 | + } | |
| 1031 | + if (_wgfCDate.isBefore(_paramObj.addMinute(_oBc.getFcTimeObj(), -_ccsj))) { | |
| 1032 | + _fnGenerateBcAndSetBc( | |
| 1033 | + i, | |
| 1034 | + _bIndex == 0 ? _qIndex - 1 : _qIndex, | |
| 1035 | + _bIndex == 0 ? 1 : 0 | |
| 1036 | + ) | |
| 1037 | + } | |
| 1038 | + } | |
| 1039 | + } | |
| 1040 | + } | |
| 1041 | + }, | |
| 1042 | + | |
| 1043 | + /** | |
| 1044 | + * 补充做5休2的班型班次。 | |
| 1045 | + * 1、确认5_2班型大致多少圈(小数点过.7进位) | |
| 1046 | + * 2、获取当前5_2两端车次链的信息,每段的班次数目,还差几个班次没加 | |
| 1047 | + * 3、如果前面的车次链班次少,则从前面的车次链开始加 | |
| 1048 | + * 4、如果车次链班次数一样,从从后面的车次链开始加 | |
| 1049 | + * 5、加班次时都是往车次链前方加 | |
| 1050 | + * 6、如果前面车次链不能再加班次了,从后面车次链加 | |
| 1051 | + */ | |
| 1052 | + fnCalcuLpBx_5_2: function() { | |
| 1053 | + // 计算做5休2班型所需的班次数 | |
| 1054 | + var iBxBcount = _aBxDesc[6].fBcCount; | |
| 1055 | + if (iBxBcount - Math.floor(iBxBcount) > 0.7) { | |
| 1056 | + iBxBcount = Math.floor(iBxBcount) + 1; | |
| 1057 | + } else { | |
| 1058 | + iBxBcount = Math.floor(iBxBcount); | |
| 1059 | + } | |
| 1060 | + | |
| 1061 | + var i; | |
| 1062 | + var j; | |
| 1063 | + var oLp; | |
| 1064 | + var iAddBcCount; | |
| 1065 | + var oBcChain1; | |
| 1066 | + var oBcChain2; | |
| 1067 | + var iQindex; | |
| 1068 | + var iBindex; | |
| 1069 | + | |
| 1070 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 1071 | + oLp = _internalLpArray[i]; | |
| 1072 | + if (oLp.isBxFb5_2()) { | |
| 1073 | + iAddBcCount = iBxBcount - oLp.getBcArray().length; // 需要添加的班次数 | |
| 1074 | + for (j = 1; j <= iAddBcCount; j++) { | |
| 1075 | + oBcChain1 = oLp.fnGetBcChainInfo(0); | |
| 1076 | + oBcChain2 = oLp.fnGetBcChainInfo(1); | |
| 1077 | + | |
| 1078 | + if (oBcChain1.bcount < oBcChain2.bcount) { | |
| 1079 | + iQindex = oBcChain1.s_b == 0 ? oBcChain1.s_q - 1 : oBcChain1.s_q; | |
| 1080 | + iBindex = oBcChain1.s_b == 0 ? 1 : 0; | |
| 1081 | + // 往车次链往前不能加,就往后加 | |
| 1082 | + if (_fnGenerateBc(i, iQindex, iBindex)) { | |
| 1083 | + _fnGenerateBcAndSetBc(i, iQindex, iBindex); | |
| 1084 | + } else { | |
| 1085 | + iQindex = oBcChain1.e_b == 0 ? oBcChain1.e_q : oBcChain1.e_q + 1; | |
| 1086 | + iBindex = oBcChain1.e_b == 0 ? 1 : 0; | |
| 1087 | + _fnGenerateBcAndSetBc(i, iQindex, iBindex); | |
| 1088 | + } | |
| 1089 | + | |
| 1090 | + } else if (oBcChain1.bcount > oBcChain2.bcount) { | |
| 1091 | + iQindex = oBcChain2.s_b == 0 ? oBcChain2.s_q - 1 : oBcChain2.s_q; | |
| 1092 | + iBindex = oBcChain2.s_b == 0 ? 1 : 0; | |
| 1093 | + _fnGenerateBcAndSetBc(i, iQindex, iBindex); | |
| 1094 | + } else { | |
| 1095 | + iQindex = oBcChain2.s_b == 0 ? oBcChain2.s_q - 1 : oBcChain2.s_q; | |
| 1096 | + iBindex = oBcChain2.s_b == 0 ? 1 : 0; | |
| 1097 | + _fnGenerateBcAndSetBc(i, iQindex, iBindex); | |
| 1098 | + } | |
| 1099 | + } | |
| 1100 | + } | |
| 1101 | + } | |
| 1102 | + | |
| 1103 | + }, | |
| 1104 | + | |
| 1105 | + /** | |
| 1106 | + * 补其他分班班型班次。 | |
| 1107 | + * 从车次链的后面开始加 | |
| 1108 | + */ | |
| 1109 | + fnCalcuLpBx_other: function() { | |
| 1110 | + // TODO:根据上标线的首班时间确定班型,小于05:59的做一休一,否则做二休一 | |
| 1111 | + var oSt = _qIsUp ? _paramObj.getUpFirstDTimeObj() : _paramObj.getDownFirstDTimeObj(); | |
| 1112 | + var iBxIndex = 4; | |
| 1113 | + if (oSt.isBefore(_paramObj.toTimeObj("05:59"))) { | |
| 1114 | + iBxIndex = 5; | |
| 1115 | + } | |
| 1116 | + // 计算做5休2班型所需的班次数 | |
| 1117 | + var iQBcount = _aBxDesc[iBxIndex].fQCount; | |
| 1118 | + var iBxBcount = Math.round(iQBcount) * 2; | |
| 1119 | + | |
| 1120 | + var i; | |
| 1121 | + var j; | |
| 1122 | + var oLp; | |
| 1123 | + var iAddBcCount; | |
| 1124 | + var oBcChain1; | |
| 1125 | + var oBcChain2; | |
| 1126 | + var iQindex; | |
| 1127 | + var iBindex; | |
| 1128 | + | |
| 1129 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 1130 | + oLp = _internalLpArray[i]; | |
| 1131 | + if (oLp.isBxFb() && !oLp.isBxFb5_2()) { | |
| 1132 | + iAddBcCount = iBxBcount - oLp.getBcArray().length; // 需要添加的班次数 | |
| 1133 | + for (j = 1; j <= iAddBcCount; j++) { | |
| 1134 | + oBcChain1 = oLp.fnGetBcChainInfo(0); | |
| 1135 | + oBcChain2 = oLp.fnGetBcChainInfo(1); | |
| 1136 | + | |
| 1137 | + if (oBcChain1.bcount < oBcChain2.bcount) { | |
| 1138 | + iQindex = oBcChain1.e_b == 0 ? oBcChain1.e_q : oBcChain1.e_q + 1; | |
| 1139 | + iBindex = oBcChain1.e_b == 0 ? 1 : 0; | |
| 1140 | + _fnGenerateBcAndSetBc(i, iQindex, iBindex); | |
| 1141 | + } else if (oBcChain1.bcount > oBcChain2.bcount) { | |
| 1142 | + iQindex = oBcChain2.e_b == 0 ? oBcChain2.e_q : oBcChain2.e_q + 1; | |
| 1143 | + iBindex = oBcChain2.e_b == 0 ? 1 : 0; | |
| 1144 | + _fnGenerateBcAndSetBc(i, iQindex, iBindex); | |
| 1145 | + } else { | |
| 1146 | + iQindex = oBcChain2.e_b == 0 ? oBcChain2.e_q : oBcChain2.e_q + 1; | |
| 1147 | + iBindex = oBcChain2.e_b == 0 ? 1 : 0; | |
| 1148 | + _fnGenerateBcAndSetBc(i, iQindex, iBindex); | |
| 1149 | + } | |
| 1150 | + } | |
| 1151 | + } | |
| 1152 | + } | |
| 1153 | + | |
| 1154 | + }, | |
| 1155 | + | |
| 1156 | + /** | |
| 1157 | + * 补充连班路牌班次。 | |
| 1158 | + * 1、上标线,中标线中间的连班路牌班次从早高峰班次一直拉到底,从早高峰班次向上标线起始班次靠拢 | |
| 1159 | + * 2、中标线以下的连班路牌班次从早高峰班次一直拉到底,从早高峰班次向中标线起始班次靠拢 | |
| 1160 | + */ | |
| 1161 | + fnCalcuLpBx_lb: function() { | |
| 1162 | + // 补充连班的班次,参照上标线,中标线补充不足的班次 | |
| 1163 | + | |
| 1164 | + var aLbLpindexes = []; // 除上标线,中标线的连班路牌索引 | |
| 1165 | + var i; | |
| 1166 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 1167 | + if (_internalLpArray[i].isBxLb() && i != 0 && i != _iZbx_lpIndex) { | |
| 1168 | + aLbLpindexes.push(i); | |
| 1169 | + } | |
| 1170 | + } | |
| 1171 | + | |
| 1172 | + var oEndsj = // 结束时间 | |
| 1173 | + _paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj()) ? | |
| 1174 | + _paramObj.getDownLastDTimeObj() : | |
| 1175 | + _paramObj.getUpLastDtimeObj(); | |
| 1176 | + | |
| 1177 | + var oLp; | |
| 1178 | + var aMinbcPos; | |
| 1179 | + var oBc; | |
| 1180 | + var j; | |
| 1181 | + var iTempBcIndex; | |
| 1182 | + | |
| 1183 | + // 1、从最小班次开始,往后补充班次 | |
| 1184 | + for (i = 0; i < aLbLpindexes.length; i++) { | |
| 1185 | + oLp = _internalLpArray[aLbLpindexes[i]]; | |
| 1186 | + | |
| 1187 | + // 最小班次索引 | |
| 1188 | + aMinbcPos = oLp.getMinBcObjPosition(); | |
| 1189 | + // 使用纵向分隔补充班次,从最小班次向后补 | |
| 1190 | + iTempBcIndex = aMinbcPos[1] == 0 ? 1 : 0; | |
| 1191 | + j = iTempBcIndex == 0 ? aMinbcPos[0] + 1 : aMinbcPos[0]; | |
| 1192 | + | |
| 1193 | + while (j < _qCount) { | |
| 1194 | + while (iTempBcIndex <= 1) { | |
| 1195 | + oBc = _fnGenerateBc(aLbLpindexes[i], j, iTempBcIndex); | |
| 1196 | + if (oBc && | |
| 1197 | + oBc.getFcTimeObj().isBefore(oEndsj) ) { | |
| 1198 | + oLp.setBc(j, iTempBcIndex, oBc); | |
| 1199 | + } | |
| 1200 | + iTempBcIndex++; | |
| 1201 | + } | |
| 1202 | + iTempBcIndex = 0; | |
| 1203 | + j++; | |
| 1204 | + } | |
| 1205 | + | |
| 1206 | + } | |
| 1207 | + | |
| 1208 | + // 2、上标线中标线之间的路牌,从最小的班次往前补充班次 | |
| 1209 | + | |
| 1210 | + // 还要补充缺失的班次,差上标线几个班次要往前补上 | |
| 1211 | + var iBccount; | |
| 1212 | + var iQindex; | |
| 1213 | + var iBindex; | |
| 1214 | + // 补上标线到中标线之间的连班路牌的班次 | |
| 1215 | + for (i = 0; i < aLbLpindexes.length; i++) { | |
| 1216 | + if (aLbLpindexes[i] > 0 && aLbLpindexes[i] < _iZbx_lpIndex) { | |
| 1217 | + oLp = _internalLpArray[aLbLpindexes[i]]; | |
| 1218 | + aMinbcPos = oLp.getMinBcObjPosition(); | |
| 1219 | + iQindex = aMinbcPos[0]; | |
| 1220 | + iBindex = aMinbcPos[1]; | |
| 1221 | + iBccount = (iQindex - 1) * 2 + iBindex; // 距离上标线起始站点差几个班次 | |
| 1222 | + for (j = 0; j < iBccount; j++) { | |
| 1223 | + if (iBindex == 0) { | |
| 1224 | + iQindex --; | |
| 1225 | + iBindex = 1; | |
| 1226 | + _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex); | |
| 1227 | + } else if (iBindex == 1) { | |
| 1228 | + iBindex --; | |
| 1229 | + _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex); | |
| 1230 | + } | |
| 1231 | + } | |
| 1232 | + | |
| 1233 | + } | |
| 1234 | + | |
| 1235 | + } | |
| 1236 | + | |
| 1237 | + // 3、中标线之后的路牌,从最小的班次往前补充班次 | |
| 1238 | + | |
| 1239 | + // 补中标线以下的连班路牌的班次 | |
| 1240 | + for (i = 0; i < aLbLpindexes.length; i++) { | |
| 1241 | + if (aLbLpindexes[i] > _iZbx_lpIndex) { | |
| 1242 | + oLp = _internalLpArray[aLbLpindexes[i]]; | |
| 1243 | + aMinbcPos = oLp.getMinBcObjPosition(); | |
| 1244 | + iQindex = aMinbcPos[0]; | |
| 1245 | + iBindex = aMinbcPos[1]; | |
| 1246 | + iBccount = (iQindex - 0) * 2 + iBindex - 1; // 距离上标线起始站点差几个班次 | |
| 1247 | + for (j = 0; j < iBccount; j++) { | |
| 1248 | + if (iBindex == 0) { | |
| 1249 | + iQindex --; | |
| 1250 | + iBindex = 1; | |
| 1251 | + _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex); | |
| 1252 | + } else if (iBindex == 1) { | |
| 1253 | + iBindex --; | |
| 1254 | + _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex); | |
| 1255 | + } | |
| 1256 | + } | |
| 1257 | + } | |
| 1258 | + } | |
| 1259 | + | |
| 1260 | + }, | |
| 1261 | + | |
| 1262 | + /** | |
| 1263 | + * 计算末班车。 | |
| 1264 | + * 1、将上下行拉成上下行两个班次列表(包括标记班次) | |
| 1265 | + * 2、分别找出离末班车发车时间最近的班次,并替换时间 | |
| 1266 | + * 3、删除之后的班次 | |
| 1267 | + */ | |
| 1268 | + fnCalcuLastBc: function() { | |
| 1269 | + var i; | |
| 1270 | + var iTimeDiff; | |
| 1271 | + var iTempTime; | |
| 1272 | + var aBc; | |
| 1273 | + var oLastBcTime; | |
| 1274 | + var oLastBcIsUp; | |
| 1275 | + var iModifyIndex; | |
| 1276 | + | |
| 1277 | + // 查找末班车早的末班车时间和方向 | |
| 1278 | + if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) { | |
| 1279 | + oLastBcTime = _paramObj.getUpLastDtimeObj(); | |
| 1280 | + oLastBcIsUp = true; | |
| 1281 | + } else { | |
| 1282 | + oLastBcTime = _paramObj.getDownLastDTimeObj(); | |
| 1283 | + oLastBcIsUp = false; | |
| 1284 | + } | |
| 1285 | + | |
| 1286 | + // 确定早的末班车时间 | |
| 1287 | + aBc = _fnGetBcList(oLastBcIsUp); | |
| 1288 | + for (i = 0; i < aBc.length; i++) { | |
| 1289 | + iTempTime = oLastBcTime.diff(aBc[i].getFcTimeObj(), "m"); | |
| 1290 | + if (iTimeDiff == undefined) { | |
| 1291 | + iTimeDiff = iTempTime; | |
| 1292 | + iModifyIndex = i; | |
| 1293 | + } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff)) { | |
| 1294 | + iTimeDiff = iTempTime; | |
| 1295 | + iModifyIndex = i; | |
| 1296 | + } | |
| 1297 | + } | |
| 1298 | + aBc[iModifyIndex].addMinuteToFcsj(iTimeDiff); // 替换成末班车时间 | |
| 1299 | + aBc[iModifyIndex].fnSetDelFlag(false); | |
| 1300 | + aBc[iModifyIndex].fnSetIsLastBc(true); | |
| 1301 | + for (i = iModifyIndex + 1; i < aBc.length; i++) { // 删除多余班次 | |
| 1302 | + _qIsUp == oLastBcIsUp ? | |
| 1303 | + aBc[i]._$$_internal_group_obj.setBc1(undefined) : | |
| 1304 | + aBc[i]._$$_internal_group_obj.setBc2(undefined); | |
| 1305 | + } | |
| 1306 | + | |
| 1307 | + // 查找末班车晚的末班车时间和方向 | |
| 1308 | + if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) { | |
| 1309 | + oLastBcTime = _paramObj.getDownLastDTimeObj(); | |
| 1310 | + oLastBcIsUp = false; | |
| 1311 | + } else { | |
| 1312 | + oLastBcTime = _paramObj.getUpLastDtimeObj(); | |
| 1313 | + oLastBcIsUp = true; | |
| 1314 | + } | |
| 1315 | + // 确定晚的末班车时间 | |
| 1316 | + aBc = _fnGetBcList(oLastBcIsUp); | |
| 1317 | + var oBc; | |
| 1318 | + var aBcIndex; | |
| 1319 | + var iLpIndex; | |
| 1320 | + var iQIndex; | |
| 1321 | + var iBcIndex; | |
| 1322 | + | |
| 1323 | + iTimeDiff = undefined; | |
| 1324 | + for (i = 0; i < aBc.length; i++) { | |
| 1325 | + oBc = aBc[i]; | |
| 1326 | + aBcIndex = _fnGetBcIndex(oBc); | |
| 1327 | + | |
| 1328 | + iLpIndex = aBcIndex[0]; | |
| 1329 | + iQIndex = aBcIndex[2] == 0 ? aBcIndex[1] -1 : aBcIndex[1]; | |
| 1330 | + iBcIndex = aBcIndex[2] == 0 ? 1 : 0; | |
| 1331 | + | |
| 1332 | + if (!_internalLpArray[iLpIndex].getBc(iQIndex, iBcIndex)) { | |
| 1333 | + continue; | |
| 1334 | + } | |
| 1335 | + | |
| 1336 | + iTempTime = oLastBcTime.diff(aBc[i].getFcTimeObj(), "m"); | |
| 1337 | + if (iTimeDiff == undefined) { | |
| 1338 | + iTimeDiff = iTempTime; | |
| 1339 | + iModifyIndex = i; | |
| 1340 | + } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff)) { | |
| 1341 | + iTimeDiff = iTempTime; | |
| 1342 | + iModifyIndex = i; | |
| 1343 | + } | |
| 1344 | + } | |
| 1345 | + aBc[iModifyIndex].addMinuteToFcsj(iTimeDiff); // 替换成末班车时间 | |
| 1346 | + aBc[iModifyIndex].fnSetDelFlag(false); | |
| 1347 | + aBc[iModifyIndex].fnSetIsLastBc(true); | |
| 1348 | + for (i = iModifyIndex + 1; i < aBc.length; i++) { // 删除多余班次 | |
| 1349 | + _qIsUp == oLastBcIsUp ? | |
| 1350 | + aBc[i]._$$_internal_group_obj.setBc1(undefined) : | |
| 1351 | + aBc[i]._$$_internal_group_obj.setBc2(undefined); | |
| 1352 | + } | |
| 1353 | + | |
| 1354 | + }, | |
| 1355 | + | |
| 1356 | + /** | |
| 1357 | + * 添加吃饭班次。 | |
| 1358 | + */ | |
| 1359 | + fnCalcuEatBc: function() { | |
| 1360 | + // 吃午饭时间范围,10:15 到 12:15 | |
| 1361 | + // 吃晚饭时间范围,18:00 到 19:00 | |
| 1362 | + | |
| 1363 | + if (!_paramObj.fnIsEat()) { | |
| 1364 | + return; | |
| 1365 | + } | |
| 1366 | + | |
| 1367 | + // 午饭index | |
| 1368 | + var aLEIndex; | |
| 1369 | + // 晚饭index | |
| 1370 | + var aDEIndex; | |
| 1371 | + | |
| 1372 | + // 所有吃饭都默认在一个方向,两个方向暂时不考虑 | |
| 1373 | + if (_paramObj.fnIsUpEat()) { | |
| 1374 | + aLEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("10:15"), true, false); | |
| 1375 | + aDEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("18:00"), true, false); | |
| 1376 | + } else { | |
| 1377 | + aLEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("10:15"), false, true); | |
| 1378 | + aDEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("18:00"), false, true); | |
| 1379 | + } | |
| 1380 | + | |
| 1381 | + // 午饭第几圈,第几个班次 | |
| 1382 | + var iLEQIndex = aLEIndex[0]; | |
| 1383 | + var iLEBIndex = aLEIndex[1]; | |
| 1384 | + // 晚饭第几圈,第几个班次 | |
| 1385 | + var iDEQIndex = aDEIndex[0]; | |
| 1386 | + var iDEBIndex = aDEIndex[1]; | |
| 1387 | + | |
| 1388 | + // 注意,本模型只有连班才有吃饭 | |
| 1389 | + | |
| 1390 | + var i; | |
| 1391 | + var oLp; | |
| 1392 | + var aLbIndex = []; // 连班班型的路牌索引 | |
| 1393 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 1394 | + oLp = _internalLpArray[i]; | |
| 1395 | + if (oLp.isBxLb()) { | |
| 1396 | + aLbIndex.push(i); | |
| 1397 | + } | |
| 1398 | + } | |
| 1399 | + | |
| 1400 | + var iLTime; | |
| 1401 | + var iDtime; | |
| 1402 | + var j; | |
| 1403 | + for (i = 0; i < aLbIndex.length; i++) { | |
| 1404 | + oLp = _internalLpArray[aLbIndex[i]]; | |
| 1405 | + | |
| 1406 | + // 午饭 | |
| 1407 | + iLTime = oLp.fnAddEatBc(iLEQIndex, iLEBIndex, _factory, _paramObj); | |
| 1408 | + // 晚饭 | |
| 1409 | + iDtime = oLp.fnAddEatBc(iDEQIndex, iDEBIndex, _factory, _paramObj); | |
| 1410 | + | |
| 1411 | + if (i == aLbIndex.length - 1) { | |
| 1412 | + for (j = aLbIndex[i]; j < _internalLpArray.length; j++) { | |
| 1413 | + oLp = _internalLpArray[j]; | |
| 1414 | + if (oLp.isBxFb()) { // 5休2班型不调整 | |
| 1415 | + // 修正午饭之后路牌班次的发车时间 | |
| 1416 | + oLp.fnAddMinuteToBcFcsj(iLEQIndex, iLEBIndex, iLTime); | |
| 1417 | + oLp.fnAddMinuteToBcFcsj(iDEQIndex, iDEBIndex, iDtime); | |
| 1418 | + } | |
| 1419 | + } | |
| 1420 | + } else { | |
| 1421 | + for (j = aLbIndex[i]; j < aLbIndex[i + 1]; j++) { | |
| 1422 | + oLp = _internalLpArray[j]; | |
| 1423 | + if (oLp.isBxFb()) { | |
| 1424 | + // 修正午饭之后路牌班次的发车时间 | |
| 1425 | + oLp.fnAddMinuteToBcFcsj(iLEQIndex, iLEBIndex, iLTime); | |
| 1426 | + oLp.fnAddMinuteToBcFcsj(iDEQIndex, iDEBIndex, iDtime); | |
| 1427 | + } | |
| 1428 | + } | |
| 1429 | + } | |
| 1430 | + } | |
| 1431 | + | |
| 1432 | + }, | |
| 1433 | + | |
| 1434 | + /** | |
| 1435 | + * 补每个路牌的其他班次(进出场,例保班次)。 | |
| 1436 | + */ | |
| 1437 | + fnCalcuOtherBc_: function() { | |
| 1438 | + var i; | |
| 1439 | + var _lpObj; | |
| 1440 | + var _minBcIndex; | |
| 1441 | + var _maxBcIndex; | |
| 1442 | + var _minBc; | |
| 1443 | + var _maxBc; | |
| 1444 | + var _otherbc = []; | |
| 1445 | + var _oFbbc; | |
| 1446 | + | |
| 1447 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 1448 | + _lpObj = _internalLpArray[i]; | |
| 1449 | + _minBcIndex = _lpObj.getMinBcObjPosition(); | |
| 1450 | + _maxBcIndex = _lpObj.getMaxBcObjPosition(); | |
| 1451 | + _minBc = _lpObj.getBc(_minBcIndex[0], _minBcIndex[1]); | |
| 1452 | + _maxBc = _lpObj.getBc(_maxBcIndex[0], _maxBcIndex[1]); | |
| 1453 | + | |
| 1454 | + _otherbc = []; | |
| 1455 | + _otherbc.push(_factory.createBcObj( | |
| 1456 | + _lpObj, "bd", true, 1, | |
| 1457 | + _minBc.getFcTimeObj(), | |
| 1458 | + _paramObj | |
| 1459 | + )); | |
| 1460 | + _otherbc.push(_factory.createBcObj( | |
| 1461 | + _lpObj, "out", true, 1, | |
| 1462 | + _minBc.getFcTimeObj(), | |
| 1463 | + _paramObj | |
| 1464 | + )); | |
| 1465 | + | |
| 1466 | + _maxBc.setArrTimeObj(_paramObj.addMinute(_maxBc.getFcTimeObj(), _maxBc.getBcTime())); | |
| 1467 | + _maxBc.setStopTime(0); | |
| 1468 | + _otherbc.push(_factory.createBcObj( | |
| 1469 | + _lpObj, "in", true, 1, | |
| 1470 | + _maxBc.getArrTimeObj(), | |
| 1471 | + _paramObj | |
| 1472 | + )); | |
| 1473 | + _otherbc.push(_factory.createBcObj( | |
| 1474 | + _lpObj, "lc", true, 1, | |
| 1475 | + _maxBc.getArrTimeObj(), | |
| 1476 | + _paramObj | |
| 1477 | + )); | |
| 1478 | + | |
| 1479 | + // 5休2分班出场例保班次 | |
| 1480 | + if (_lpObj.isBxFb5_2()) { | |
| 1481 | + _oFbbc = _lpObj.getBc( | |
| 1482 | + _lpObj.fnGetBcChainInfo(1)["s_q"], | |
| 1483 | + _lpObj.fnGetBcChainInfo(1)["s_b"] | |
| 1484 | + ); | |
| 1485 | + | |
| 1486 | + _otherbc.push(_factory.createBcObj( | |
| 1487 | + _lpObj, "bd", true, 1, | |
| 1488 | + _oFbbc.getFcTimeObj(), | |
| 1489 | + _paramObj | |
| 1490 | + )); | |
| 1491 | + _otherbc.push(_factory.createBcObj( | |
| 1492 | + _lpObj, "out", true, 1, | |
| 1493 | + _oFbbc.getFcTimeObj(), | |
| 1494 | + _paramObj | |
| 1495 | + )); | |
| 1496 | + } | |
| 1497 | + | |
| 1498 | + _lpObj.addOtherBcArray(_otherbc); | |
| 1499 | + } | |
| 1500 | + | |
| 1501 | + }, | |
| 1502 | + | |
| 1503 | + /** | |
| 1504 | + * 补每个路牌的其他班次(进出场,例保班次) | |
| 1505 | + * 所有的车次链前后都加进出场、报道班次 | |
| 1506 | + */ | |
| 1507 | + fnCalcuOtherBc: function() { | |
| 1508 | + var i; | |
| 1509 | + var j; | |
| 1510 | + var iBcChainCount; | |
| 1511 | + var oLp; | |
| 1512 | + var aOtherBc; | |
| 1513 | + var oStartBc; | |
| 1514 | + var oEndBc; | |
| 1515 | + | |
| 1516 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 1517 | + aOtherBc = []; | |
| 1518 | + oLp = _internalLpArray[i]; | |
| 1519 | + iBcChainCount = oLp.fnGetBcChainCount(); | |
| 1520 | + | |
| 1521 | + if (iBcChainCount == 1) { // 只有一个车次链,是连班班型 | |
| 1522 | + // 头部要添加出场,例保班次 | |
| 1523 | + oStartBc = oLp.getBc( | |
| 1524 | + oLp.fnGetBcChainInfo(0)["s_q"], | |
| 1525 | + oLp.fnGetBcChainInfo(0)["s_b"] | |
| 1526 | + ); | |
| 1527 | + aOtherBc.push(_factory.createBcObj( | |
| 1528 | + oLp, "bd", true, 1, | |
| 1529 | + oStartBc.getFcTimeObj(), | |
| 1530 | + _paramObj | |
| 1531 | + )); | |
| 1532 | + aOtherBc.push(_factory.createBcObj( | |
| 1533 | + oLp, "out", true, 1, | |
| 1534 | + oStartBc.getFcTimeObj(), | |
| 1535 | + _paramObj | |
| 1536 | + )); | |
| 1537 | + | |
| 1538 | + // 尾部需添加进场,例保班次 | |
| 1539 | + oEndBc = oLp.getBc( | |
| 1540 | + oLp.fnGetBcChainInfo(0)["e_q"], | |
| 1541 | + oLp.fnGetBcChainInfo(0)["e_b"] | |
| 1542 | + ); | |
| 1543 | + aOtherBc.push(_factory.createBcObj( | |
| 1544 | + oLp, "in", true, 1, | |
| 1545 | + oEndBc.getArrTimeObj(), | |
| 1546 | + _paramObj | |
| 1547 | + )); | |
| 1548 | + aOtherBc.push(_factory.createBcObj( | |
| 1549 | + oLp, "lc", true, 1, | |
| 1550 | + oEndBc.getArrTimeObj(), | |
| 1551 | + _paramObj | |
| 1552 | + )); | |
| 1553 | + } else if (iBcChainCount == 2) { // 两个车次链,是分班班型 | |
| 1554 | + // 第一个车次链开头有出场,报到班次,车次链结尾只有进场班次 | |
| 1555 | + oStartBc = oLp.getBc( | |
| 1556 | + oLp.fnGetBcChainInfo(0)["s_q"], | |
| 1557 | + oLp.fnGetBcChainInfo(0)["s_b"] | |
| 1558 | + ); | |
| 1559 | + aOtherBc.push(_factory.createBcObj( | |
| 1560 | + oLp, "bd", true, 1, | |
| 1561 | + oStartBc.getFcTimeObj(), | |
| 1562 | + _paramObj | |
| 1563 | + )); | |
| 1564 | + aOtherBc.push(_factory.createBcObj( | |
| 1565 | + oLp, "out", true, 1, | |
| 1566 | + oStartBc.getFcTimeObj(), | |
| 1567 | + _paramObj | |
| 1568 | + )); | |
| 1569 | + | |
| 1570 | + oEndBc = oLp.getBc( | |
| 1571 | + oLp.fnGetBcChainInfo(0)["e_q"], | |
| 1572 | + oLp.fnGetBcChainInfo(0)["e_b"] | |
| 1573 | + ); | |
| 1574 | + aOtherBc.push(_factory.createBcObj( | |
| 1575 | + oLp, "in", true, 1, | |
| 1576 | + oEndBc.getArrTimeObj(), | |
| 1577 | + _paramObj | |
| 1578 | + )); | |
| 1579 | + | |
| 1580 | + // 第二个车次链开头有出场,报到班次,车次链结尾有进场,报到班次 | |
| 1581 | + oStartBc = oLp.getBc( | |
| 1582 | + oLp.fnGetBcChainInfo(1)["s_q"], | |
| 1583 | + oLp.fnGetBcChainInfo(1)["s_b"] | |
| 1584 | + ); | |
| 1585 | + aOtherBc.push(_factory.createBcObj( | |
| 1586 | + oLp, "bd", true, 1, | |
| 1587 | + oStartBc.getFcTimeObj(), | |
| 1588 | + _paramObj | |
| 1589 | + )); | |
| 1590 | + aOtherBc.push(_factory.createBcObj( | |
| 1591 | + oLp, "out", true, 1, | |
| 1592 | + oStartBc.getFcTimeObj(), | |
| 1593 | + _paramObj | |
| 1594 | + )); | |
| 1595 | + | |
| 1596 | + oEndBc = oLp.getBc( | |
| 1597 | + oLp.fnGetBcChainInfo(1)["e_q"], | |
| 1598 | + oLp.fnGetBcChainInfo(1)["e_b"] | |
| 1599 | + ); | |
| 1600 | + aOtherBc.push(_factory.createBcObj( | |
| 1601 | + oLp, "in", true, 1, | |
| 1602 | + oEndBc.getArrTimeObj(), | |
| 1603 | + _paramObj | |
| 1604 | + )); | |
| 1605 | + aOtherBc.push(_factory.createBcObj( | |
| 1606 | + oLp, "lc", true, 1, | |
| 1607 | + oEndBc.getArrTimeObj(), | |
| 1608 | + _paramObj | |
| 1609 | + )); | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + } else { | |
| 1613 | + // 2个车次链以上,暂时没有此班型 | |
| 1614 | + } | |
| 1615 | + | |
| 1616 | + oLp.addOtherBcArray(aOtherBc); | |
| 1617 | + } | |
| 1618 | + }, | |
| 1619 | + | |
| 1620 | + /** | |
| 1621 | + * 祛除上标线开头的删除标记的班次。 | |
| 1622 | + */ | |
| 1623 | + fnRemoveDelFirstFlagBc: function() { | |
| 1624 | + var oLp = _internalLpArray[0]; | |
| 1625 | + var aMinBcIndex = oLp.getMinBcObjPosition(); | |
| 1626 | + if (oLp.getBc(aMinBcIndex[0], aMinBcIndex[1]).fnIsDelFlag()) { | |
| 1627 | + oLp.removeBc(aMinBcIndex[0], aMinBcIndex[1]); | |
| 1628 | + } | |
| 1629 | + }, | |
| 1630 | + /** | |
| 1631 | + * 祛除上标线结尾的删除标记的班次。 | |
| 1632 | + */ | |
| 1633 | + fnRemoveDelLastFlagBc: function() { | |
| 1634 | + var oLp = _internalLpArray[0]; | |
| 1635 | + var aMaxBcIndex = oLp.getMaxBcObjPosition(); | |
| 1636 | + if (oLp.getBc(aMaxBcIndex[0], aMaxBcIndex[1]).fnIsDelFlag()) { | |
| 1637 | + oLp.removeBc(aMaxBcIndex[0], aMaxBcIndex[1]); | |
| 1638 | + } | |
| 1639 | + }, | |
| 1640 | + | |
| 1641 | + /** | |
| 1642 | + * 调整路牌班次间隔(核准周转时间,停站时间)。 | |
| 1643 | + * @param iFre int 迭代次数 | |
| 1644 | + */ | |
| 1645 | + fnAdjustLpBcInterval: function(iFre) { | |
| 1646 | + if (iFre > 0) { | |
| 1647 | + for (var i = 0; i < _internalLpArray.length; i++) { | |
| 1648 | + _internalLpArray[i].fnAdjustBcInterval( | |
| 1649 | + this.fnCalcuAverPeakStopTime(), | |
| 1650 | + this.fnCalcuAverTroughStopTime(), | |
| 1651 | + _paramObj); | |
| 1652 | + } | |
| 1653 | + | |
| 1654 | + this.fnAdjustLpBcInterval(iFre - 1); | |
| 1655 | + } | |
| 1656 | + }, | |
| 1657 | + | |
| 1658 | + /** | |
| 1659 | + * 调整班次间隔。 | |
| 1660 | + * @param bIsUp 是否上行 | |
| 1661 | + * @param oStartTime 开始时间对象 | |
| 1662 | + * @param iFre 迭代次数 | |
| 1663 | + */ | |
| 1664 | + fnAdjustBcInterval2_: function(bIsUp, oStartTime, iFre) { | |
| 1665 | + if (iFre > 0) { | |
| 1666 | + var aBc = _fnGetBcList2(bIsUp, oStartTime); // 指定方向的班次列表 | |
| 1667 | + aBc.sort(function(o1, o2) { | |
| 1668 | + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) { | |
| 1669 | + return -1; | |
| 1670 | + } else { | |
| 1671 | + return 1; | |
| 1672 | + } | |
| 1673 | + }); | |
| 1674 | + var i; | |
| 1675 | + var j; | |
| 1676 | + | |
| 1677 | + var iBcCountOfGroup = 3; // 3个班次取一次计算 | |
| 1678 | + var aBcOfGroup; // 3个班次列表 | |
| 1679 | + var aBcIntervalOfGroup; // 班次间隔列表,如:3个班次,2个间隔 | |
| 1680 | + | |
| 1681 | + for (i = 0; i <= aBc.length - iBcCountOfGroup; i++) { | |
| 1682 | + aBcOfGroup = []; | |
| 1683 | + aBcIntervalOfGroup = []; | |
| 1684 | + for (j = i; j < i + iBcCountOfGroup; j++) { | |
| 1685 | + aBcOfGroup.push(aBc[j]); | |
| 1686 | + } | |
| 1687 | + | |
| 1688 | + for (j = 0; j < aBcOfGroup.length; j++) { | |
| 1689 | + if (j < aBcOfGroup.length - 1) { | |
| 1690 | + aBcIntervalOfGroup.push(aBcOfGroup[j + 1].getFcTimeObj().diff( | |
| 1691 | + aBcOfGroup[j].getFcTimeObj(), "m")); | |
| 1692 | + } | |
| 1693 | + } | |
| 1694 | + | |
| 1695 | + if (aBcIntervalOfGroup[0] < 19) { | |
| 1696 | + aBcOfGroup[1].addMinuteToFcsj(1); | |
| 1697 | + } else if (aBcIntervalOfGroup[0] > 20) { | |
| 1698 | + aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 1699 | + } else { | |
| 1700 | + if (Math.abs(aBcIntervalOfGroup[0] - aBcIntervalOfGroup[1]) <= 1) { | |
| 1701 | + //continue; | |
| 1702 | + } else if (aBcIntervalOfGroup[0] > aBcIntervalOfGroup[1]) { | |
| 1703 | + aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 1704 | + } else { | |
| 1705 | + aBcOfGroup[1].addMinuteToFcsj(1); | |
| 1706 | + } | |
| 1707 | + } | |
| 1708 | + | |
| 1709 | + } | |
| 1710 | + | |
| 1711 | + this.fnAdjustBcInterval2(bIsUp, oStartTime, iFre - 1); | |
| 1712 | + } | |
| 1713 | + }, | |
| 1714 | + | |
| 1715 | + /** | |
| 1716 | + * 调整班次间隔。 | |
| 1717 | + * @param boolean isUp 是否上行 | |
| 1718 | + * @param oStartTime 开始时间对象 | |
| 1719 | + * @param fre int 迭代次数 | |
| 1720 | + */ | |
| 1721 | + fnAdjustBcInterval: function(isUp, oStartTime, fre) { | |
| 1722 | + if (fre > 0) { | |
| 1723 | + var aBc = !oStartTime ? _fnGetBcList(isUp) : _fnGetBcList2(isUp, oStartTime); // 指定方向的班次列表 | |
| 1724 | + | |
| 1725 | + aBc.sort(function(o1, o2) { | |
| 1726 | + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) { | |
| 1727 | + return -1; | |
| 1728 | + } else { | |
| 1729 | + return 1; | |
| 1730 | + } | |
| 1731 | + }); | |
| 1732 | + | |
| 1733 | + var i; | |
| 1734 | + var j; | |
| 1735 | + | |
| 1736 | + var iBcCountOfGroup = 3; // 3个班次取一次计算 | |
| 1737 | + var aBcOfGroup; // 3个班次列表 | |
| 1738 | + var aBcIntervalOfGroup; // 班次间隔列表,如:3个班次,2个间隔 | |
| 1739 | + var oBcFcTime; // 班次发车时间 | |
| 1740 | + | |
| 1741 | + for (i = 0; i <= aBc.length - iBcCountOfGroup; i++) { | |
| 1742 | + aBcOfGroup = []; | |
| 1743 | + aBcIntervalOfGroup = []; | |
| 1744 | + for (j = i; j < i + iBcCountOfGroup; j++) { | |
| 1745 | + aBcOfGroup.push(aBc[j]); | |
| 1746 | + } | |
| 1747 | + | |
| 1748 | + for (j = 0; j < aBcOfGroup.length; j++) { | |
| 1749 | + if (j < aBcOfGroup.length - 1) { | |
| 1750 | + aBcIntervalOfGroup.push(aBcOfGroup[j + 1].getFcTimeObj().diff( | |
| 1751 | + aBcOfGroup[j].getFcTimeObj(), "m")); | |
| 1752 | + } | |
| 1753 | + } | |
| 1754 | + | |
| 1755 | + // 判定规则 | |
| 1756 | + oBcFcTime = aBcOfGroup[1].getFcTimeObj(); | |
| 1757 | + | |
| 1758 | + // 第一个班次发车时间不动,根据间隔,调整中间一个班次 | |
| 1759 | + // 如果3个班次2个间隔时间差1分钟,不调整 | |
| 1760 | + // 如果第一个间隔大,调整第二个班次往前1分钟 | |
| 1761 | + // 如果第二个间隔大,调整第二个班次往后1分钟 | |
| 1762 | + | |
| 1763 | + if (_paramObj.isTroughBc(oBcFcTime) && | |
| 1764 | + aBcIntervalOfGroup[0] > _paramObj.getTroughMaxFcjx()) { | |
| 1765 | + aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 1766 | + } | |
| 1767 | + | |
| 1768 | + //else if (_paramObj.isMPeakBc(oBcFcTime) && | |
| 1769 | + // aBcIntervalOfGroup[0] < _paramObj.getMPeakMinFcjx()) { | |
| 1770 | + // aBcOfGroup[1].addMinuteToFcsj(1); | |
| 1771 | + //} else if (_paramObj.isMPeakBc(oBcFcTime) && | |
| 1772 | + // aBcIntervalOfGroup[0] > _paramObj.getMPeakMaxFcjx()) { | |
| 1773 | + // aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 1774 | + //} else if (_paramObj.isEPeakBc(oBcFcTime) && | |
| 1775 | + // aBcIntervalOfGroup[0] < _paramObj.getEPeakMinFcjx()) { | |
| 1776 | + // aBcOfGroup[1].addMinuteToFcsj(1); | |
| 1777 | + //} else if (_paramObj.isEPeakBc(oBcFcTime) && | |
| 1778 | + // aBcIntervalOfGroup[0] > _paramObj.getEPeakMaxFcjx()) { | |
| 1779 | + // aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 1780 | + //} | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + else { | |
| 1784 | + if (Math.abs(aBcIntervalOfGroup[0] - aBcIntervalOfGroup[1]) <= 1) { | |
| 1785 | + //continue; | |
| 1786 | + } else if (aBcIntervalOfGroup[0] > aBcIntervalOfGroup[1]) { | |
| 1787 | + aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 1788 | + } else { | |
| 1789 | + aBcOfGroup[1].addMinuteToFcsj(1); | |
| 1790 | + } | |
| 1791 | + } | |
| 1792 | + | |
| 1793 | + //if (Math.abs(aBcIntervalOfGroup[0] - aBcIntervalOfGroup[1]) <= 1) { | |
| 1794 | + // //continue; | |
| 1795 | + //} else if (aBcIntervalOfGroup[0] > aBcIntervalOfGroup[1]) { | |
| 1796 | + // aBcOfGroup[1].addMinuteToFcsj(-1); | |
| 1797 | + //} else { | |
| 1798 | + // aBcOfGroup[1].addMinuteToFcsj(1); | |
| 1799 | + //} | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + } | |
| 1803 | + | |
| 1804 | + this.fnAdjustBcInterval(isUp, oStartTime, fre - 1); | |
| 1805 | + } | |
| 1806 | + | |
| 1807 | + }, | |
| 1808 | + | |
| 1809 | + /** | |
| 1810 | + * 调整班次间隔(平均间隔)。 | |
| 1811 | + * @param bIsUp 是否上行 | |
| 1812 | + * @param oStartTime 开始时间对象 | |
| 1813 | + */ | |
| 1814 | + fnAdjustBcInterval2_avg: function(bIsUp, oStartTime) { | |
| 1815 | + var aBc = !oStartTime ? _fnGetBcList(bIsUp) : _fnGetBcList2(bIsUp, oStartTime); // 指定方向的班次列表 | |
| 1816 | + aBc.sort(function(o1, o2) { | |
| 1817 | + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) { | |
| 1818 | + return -1; | |
| 1819 | + } else { | |
| 1820 | + return 1; | |
| 1821 | + } | |
| 1822 | + }); | |
| 1823 | + | |
| 1824 | + var j; | |
| 1825 | + var iCount = aBc.length - 1; | |
| 1826 | + var iC1 = Math.floor(aBc[aBc.length - 1].getFcTimeObj().diff(aBc[0].getFcTimeObj(), "m") / iCount); | |
| 1827 | + var iC2 = aBc[aBc.length - 1].getFcTimeObj().diff(aBc[0].getFcTimeObj(), "m") % iCount; | |
| 1828 | + var iTempTime; | |
| 1829 | + | |
| 1830 | + for (j = 0; j < iCount - iC2; j++) { | |
| 1831 | + iTempTime = aBc[j + 1].getFcTimeObj().diff(aBc[j].getFcTimeObj(), "m"); | |
| 1832 | + aBc[j + 1].addMinuteToFcsj(iC1 - iTempTime); | |
| 1833 | + } | |
| 1834 | + for (j = 0; j < iC2; j++) { | |
| 1835 | + iTempTime = aBc[iCount - iC2 + j + 1].getFcTimeObj().diff(aBc[iCount - iC2 + j].getFcTimeObj(), "m"); | |
| 1836 | + aBc[iCount - iC2 + j + 1].addMinuteToFcsj(iC1 + 1 - iTempTime); | |
| 1837 | + } | |
| 1838 | + | |
| 1839 | + }, | |
| 1840 | + | |
| 1841 | + /** | |
| 1842 | + * 计算高峰平均停站时间。 | |
| 1843 | + */ | |
| 1844 | + fnCalcuAverPeakStopTime: function() { | |
| 1845 | + var i; | |
| 1846 | + var j; | |
| 1847 | + var aBc; | |
| 1848 | + var iBcCount = 0; | |
| 1849 | + var iSum = 0; | |
| 1850 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 1851 | + aBc = _internalLpArray[i].getBcArray(); | |
| 1852 | + | |
| 1853 | + for (j = 0; j < aBc.length; j++) { | |
| 1854 | + if (!_paramObj.isTroughBc(aBc[j].getArrTimeObj())) { | |
| 1855 | + iBcCount ++; | |
| 1856 | + iSum += aBc[j].getStopTime(); | |
| 1857 | + } | |
| 1858 | + } | |
| 1859 | + } | |
| 1860 | + | |
| 1861 | + return Math.floor(iSum / iBcCount); | |
| 1862 | + }, | |
| 1863 | + | |
| 1864 | + /** | |
| 1865 | + * 计算低谷平均停站时间。 | |
| 1866 | + */ | |
| 1867 | + fnCalcuAverTroughStopTime: function() { | |
| 1868 | + var i; | |
| 1869 | + var j; | |
| 1870 | + var aBc; | |
| 1871 | + var iBcCount = 0; | |
| 1872 | + var iSum = 0; | |
| 1873 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 1874 | + aBc = _internalLpArray[i].getBcArray(); | |
| 1875 | + for (j = 0; j < aBc.length; j++) { | |
| 1876 | + if (_paramObj.isTroughBc(aBc[j].getArrTimeObj())) { | |
| 1877 | + iBcCount ++; | |
| 1878 | + iSum += aBc[j].getStopTime(); | |
| 1879 | + } | |
| 1880 | + } | |
| 1881 | + } | |
| 1882 | + | |
| 1883 | + return Math.floor(iSum / iBcCount); | |
| 1884 | + }, | |
| 1885 | + | |
| 1886 | + //------------- 其他方法 -------------// | |
| 1887 | + /** | |
| 1888 | + * 返回内部路牌数据列表。 | |
| 1889 | + * @returns {Array} | |
| 1890 | + */ | |
| 1891 | + fnGetLpArray: function() { | |
| 1892 | + return _internalLpArray; | |
| 1893 | + }, | |
| 1894 | + | |
| 1895 | + /** | |
| 1896 | + * 内部数据转化成显示用的班次数组。 | |
| 1897 | + */ | |
| 1898 | + fnToGanttBcArray: function() { | |
| 1899 | + var aAllBc = []; | |
| 1900 | + var aLpBc = []; | |
| 1901 | + var aEatBc = []; | |
| 1902 | + var oLp; | |
| 1903 | + var i; | |
| 1904 | + var j; | |
| 1905 | + | |
| 1906 | + for (i = 0; i < _internalLpArray.length; i++) { | |
| 1907 | + oLp = _internalLpArray[i]; | |
| 1908 | + aLpBc = []; | |
| 1909 | + aLpBc = aLpBc.concat(oLp.getOtherBcArray(), oLp.getBcArray()); | |
| 1910 | + | |
| 1911 | + aEatBc = []; | |
| 1912 | + // 根据班次的吃饭时间添加吃饭班次 | |
| 1913 | + for (j = 0; j < aLpBc.length; j++) { | |
| 1914 | + if (aLpBc[j].fnGetEatTime() > 0) { | |
| 1915 | + aEatBc.push(_factory.createBcObj( | |
| 1916 | + oLp, | |
| 1917 | + "cf", | |
| 1918 | + !aLpBc[j].isUp(), // 和上一个班次方向相反 | |
| 1919 | + 1, | |
| 1920 | + _paramObj.addMinute(aLpBc[j].getArrTimeObj(), aLpBc[j].getStopTime()), // 使用上一个班次的到达时间作为开始时间 | |
| 1921 | + _paramObj | |
| 1922 | + )); | |
| 1923 | + } | |
| 1924 | + } | |
| 1925 | + aLpBc = aLpBc.concat(aEatBc); | |
| 1926 | + | |
| 1927 | + // 按照发车时间排序 | |
| 1928 | + aLpBc.sort(function(o1, o2) { | |
| 1929 | + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) { | |
| 1930 | + return -1; | |
| 1931 | + } else { | |
| 1932 | + return 1; | |
| 1933 | + } | |
| 1934 | + }); | |
| 1935 | + | |
| 1936 | + // 重新赋值fcno | |
| 1937 | + for (j = 0; j < aLpBc.length; j++) { | |
| 1938 | + aLpBc[j].fnSetFcno(j + 1); | |
| 1939 | + } | |
| 1940 | + | |
| 1941 | + aAllBc = aAllBc.concat(aLpBc); | |
| 1942 | + } | |
| 1943 | + | |
| 1944 | + var aGanttBc = []; | |
| 1945 | + for (i = 0; i < aAllBc.length; i++) { | |
| 1946 | + aGanttBc.push(aAllBc[i].toGanttBcObj()); | |
| 1947 | + } | |
| 1948 | + | |
| 1949 | + return aGanttBc; | |
| 1950 | + } | |
| 1951 | + | |
| 1952 | + }; | |
| 1953 | + | |
| 1949 | 1954 | }; |
| 1950 | 1955 | \ No newline at end of file | ... | ... |