Commit 754616cc9241c3fc518d9d63bae4dbf4daff3db4
1 parent
14e3a310
时刻表v2.7.16
1、导出时刻表加入新的sheet,保存使用的参数数据 2、解决添加吃饭班次加错方向的问题,主要修改fnGetQBcIndexWithFcTimeFromGroupArray方法的班次判定逻辑
Showing
6 changed files
with
1518 additions
and
1403 deletions
src/main/java/com/bsth/service/schedule/datatools/TTInfoDetailDataToolsImpl.java
| ... | ... | @@ -691,6 +691,44 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail |
| 691 | 691 | sheet.autoSizeColumn(groupCount * 2 + 10); |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | + private void createParameterInfoSheet( | |
| 695 | + org.apache.poi.ss.usermodel.Workbook wb, | |
| 696 | + DTInfos dtInfos, ExcelPoiOperator excelPoiOperator) { | |
| 697 | + org.apache.poi.ss.usermodel.Sheet sheet = excelPoiOperator.createWorkBookSheet(wb, "时刻表信息_参数"); | |
| 698 | + | |
| 699 | + //---------------------- 参数对象信息 -----------------------// | |
| 700 | + List<ParameterInfo> parameterInfoList = dtInfos.getParameterInfoList(); | |
| 701 | + | |
| 702 | + int _s = parameterInfoList.size() / 2; | |
| 703 | + int _y = parameterInfoList.size() % 2; | |
| 704 | + // 1行2个参数对象值,1个参数对象对应2列,1列描述,1列值 | |
| 705 | + int rowCount = _s + (_y == 0 ? 0 : 1); | |
| 706 | + | |
| 707 | + for (int i = 0; i < rowCount; i++) { | |
| 708 | + Row row = excelPoiOperator.createSheetRow(sheet, i); | |
| 709 | + for (int j = 0; j < 4; j++) { | |
| 710 | + excelPoiOperator.createStringCell(wb, row, (short) j, ""); | |
| 711 | + } | |
| 712 | + } | |
| 713 | + | |
| 714 | + for (int i = 0; i < parameterInfoList.size(); i++) { | |
| 715 | + int row = i / 2; | |
| 716 | + int col1 = (i % 2) == 0 ? 0 : 2; | |
| 717 | + int col2 = (i % 2) == 0 ? 1 : 3; | |
| 718 | + | |
| 719 | + ParameterInfo parameterInfo = parameterInfoList.get(i); | |
| 720 | + | |
| 721 | + sheet.getRow(row).getCell(col1).setCellValue(parameterInfo.getParamItem()); | |
| 722 | + sheet.getRow(row).getCell(col2).setCellValue(parameterInfo.getParamValue()); | |
| 723 | + } | |
| 724 | + | |
| 725 | + sheet.autoSizeColumn(0); | |
| 726 | + sheet.autoSizeColumn(1); | |
| 727 | + sheet.autoSizeColumn(2); | |
| 728 | + sheet.autoSizeColumn(3); | |
| 729 | + | |
| 730 | + } | |
| 731 | + | |
| 694 | 732 | @Override |
| 695 | 733 | public DataToolsFile exportDynamicTTinfo(DTInfos dtInfos, DataToolsFileType type) throws ScheduleException { |
| 696 | 734 | try { |
| ... | ... | @@ -707,6 +745,7 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail |
| 707 | 745 | org.apache.poi.ss.usermodel.Workbook wb = excelPoiOperator.createWorkBook(); |
| 708 | 746 | this.createDynamicTTinfoSheet(wb, dtInfos, excelPoiOperator); |
| 709 | 747 | this.createDynamicTTinfoStatSheet(wb, dtInfos, excelPoiOperator); |
| 748 | + this.createParameterInfoSheet(wb, dtInfos, excelPoiOperator); | |
| 710 | 749 | |
| 711 | 750 | // wb内存写入文件 |
| 712 | 751 | String filepath = dataToolsProperties.getFileoutputDir() + | ... | ... |
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.bsth.service.schedule.utils.DataToolsFileType; | |
| 6 | -import com.fasterxml.jackson.annotation.JsonCreator; | |
| 7 | -import com.fasterxml.jackson.annotation.JsonValue; | |
| 8 | - | |
| 9 | -import java.util.List; | |
| 10 | - | |
| 11 | -/** | |
| 12 | - * 动态时刻表数据。 | |
| 13 | - */ | |
| 14 | -public interface TTinfoDetailDynamicData { | |
| 15 | - | |
| 16 | - //---------------------- 生成时刻表用对象(以下) ---------------------// | |
| 17 | - public static enum BcType { // 班次类型枚举 | |
| 18 | - IN("in"), // 进场 | |
| 19 | - OUT("out"), // 出场 | |
| 20 | - BD("bd"), // 早例保 | |
| 21 | - LC("lc"), // 晚例保 | |
| 22 | - NORMAL("normal"); // 正常 | |
| 23 | - private String flag; | |
| 24 | - | |
| 25 | - @JsonCreator | |
| 26 | - private BcType(String flag) { | |
| 27 | - this.flag = flag; | |
| 28 | - } | |
| 29 | - | |
| 30 | - @JsonValue | |
| 31 | - public String getFlag() { | |
| 32 | - return flag; | |
| 33 | - } | |
| 34 | - | |
| 35 | - public void setFlag(String flag) { | |
| 36 | - this.flag = flag; | |
| 37 | - } | |
| 38 | - } | |
| 39 | - | |
| 40 | - public static class BcObj { // 班次对象 | |
| 41 | - /** 班次时间 */ | |
| 42 | - private Integer bcsj; | |
| 43 | - /** 停站时间 */ | |
| 44 | - private Integer ssj; | |
| 45 | - /** 吃饭时间 */ | |
| 46 | - private Integer eatsj; | |
| 47 | - | |
| 48 | - /** 停车场id */ | |
| 49 | - private Integer tccid; | |
| 50 | - /** 起点站id */ | |
| 51 | - private Integer qdzid; | |
| 52 | - /** 终点站id */ | |
| 53 | - private Integer zdzid; | |
| 54 | - | |
| 55 | - /** 是否上行 */ | |
| 56 | - private Boolean isUp; | |
| 57 | - | |
| 58 | - /** 是否分班 */ | |
| 59 | - private Boolean isFb; | |
| 60 | - | |
| 61 | - /** 班次类型 */ | |
| 62 | - private BcType bcType; | |
| 63 | - /** 发车时刻 */ | |
| 64 | - private String fcsj; | |
| 65 | - /** 用于统计的发车时间描述(把进出场,保养,吃饭时间写在一起) */ | |
| 66 | - private String fcsjDesc; | |
| 67 | - | |
| 68 | - /** 第几圈(从1开始) */ | |
| 69 | - private Integer groupNo; | |
| 70 | - /** 圈里第几个班次(1或者2) */ | |
| 71 | - private Integer groupBcNo; | |
| 72 | - | |
| 73 | - public Integer getBcsj() { | |
| 74 | - return bcsj; | |
| 75 | - } | |
| 76 | - | |
| 77 | - public void setBcsj(Integer bcsj) { | |
| 78 | - this.bcsj = bcsj; | |
| 79 | - } | |
| 80 | - | |
| 81 | - public Integer getSsj() { | |
| 82 | - return ssj; | |
| 83 | - } | |
| 84 | - | |
| 85 | - public void setSsj(Integer ssj) { | |
| 86 | - this.ssj = ssj; | |
| 87 | - } | |
| 88 | - | |
| 89 | - public Integer getEatsj() { | |
| 90 | - return eatsj; | |
| 91 | - } | |
| 92 | - | |
| 93 | - public void setEatsj(Integer eatsj) { | |
| 94 | - this.eatsj = eatsj; | |
| 95 | - } | |
| 96 | - | |
| 97 | - public Integer getTccid() { | |
| 98 | - return tccid; | |
| 99 | - } | |
| 100 | - | |
| 101 | - public void setTccid(Integer tccid) { | |
| 102 | - this.tccid = tccid; | |
| 103 | - } | |
| 104 | - | |
| 105 | - public Integer getQdzid() { | |
| 106 | - return qdzid; | |
| 107 | - } | |
| 108 | - | |
| 109 | - public void setQdzid(Integer qdzid) { | |
| 110 | - this.qdzid = qdzid; | |
| 111 | - } | |
| 112 | - | |
| 113 | - public Integer getZdzid() { | |
| 114 | - return zdzid; | |
| 115 | - } | |
| 116 | - | |
| 117 | - public void setZdzid(Integer zdzid) { | |
| 118 | - this.zdzid = zdzid; | |
| 119 | - } | |
| 120 | - | |
| 121 | - public BcType getBcType() { | |
| 122 | - return bcType; | |
| 123 | - } | |
| 124 | - | |
| 125 | - public void setBcType(BcType bcType) { | |
| 126 | - this.bcType = bcType; | |
| 127 | - } | |
| 128 | - | |
| 129 | - public String getFcsj() { | |
| 130 | - return fcsj; | |
| 131 | - } | |
| 132 | - | |
| 133 | - public void setFcsj(String fcsj) { | |
| 134 | - this.fcsj = fcsj; | |
| 135 | - } | |
| 136 | - | |
| 137 | - public Boolean getIsUp() { | |
| 138 | - return isUp; | |
| 139 | - } | |
| 140 | - | |
| 141 | - public void setIsUp(Boolean isUp) { | |
| 142 | - this.isUp = isUp; | |
| 143 | - } | |
| 144 | - | |
| 145 | - public Integer getGroupNo() { | |
| 146 | - return groupNo; | |
| 147 | - } | |
| 148 | - | |
| 149 | - public void setGroupNo(Integer groupNo) { | |
| 150 | - this.groupNo = groupNo; | |
| 151 | - } | |
| 152 | - | |
| 153 | - public Integer getGroupBcNo() { | |
| 154 | - return groupBcNo; | |
| 155 | - } | |
| 156 | - | |
| 157 | - public void setGroupBcNo(Integer groupBcNo) { | |
| 158 | - this.groupBcNo = groupBcNo; | |
| 159 | - } | |
| 160 | - | |
| 161 | - public String getFcsjDesc() { | |
| 162 | - return fcsjDesc; | |
| 163 | - } | |
| 164 | - | |
| 165 | - public void setFcsjDesc(String fcsjDesc) { | |
| 166 | - this.fcsjDesc = fcsjDesc; | |
| 167 | - } | |
| 168 | - | |
| 169 | - public Boolean getIsFb() { | |
| 170 | - return isFb; | |
| 171 | - } | |
| 172 | - | |
| 173 | - public void setIsFb(Boolean fb) { | |
| 174 | - isFb = fb; | |
| 175 | - } | |
| 176 | - } | |
| 177 | - | |
| 178 | - public static class LpObj { // 路牌对象 | |
| 179 | - /** 路牌名字 */ | |
| 180 | - private String lpname; | |
| 181 | - /** 每圈的第一个班次是否上行 */ | |
| 182 | - private Boolean isUp; | |
| 183 | - | |
| 184 | - /** 第一个班次起点站路由id */ | |
| 185 | - private Integer stationRouteId1; | |
| 186 | - /** 第二个班次起点站路由id */ | |
| 187 | - private Integer stationRouteId2; | |
| 188 | - | |
| 189 | - /** 班次列表 */ | |
| 190 | - private List<BcObj> bcObjList; | |
| 191 | - /** 总圈数 */ | |
| 192 | - private Integer groupCount; | |
| 193 | - | |
| 194 | - //---------------- 路牌统计 ---------------// | |
| 195 | - /** 总里程 */ | |
| 196 | - private Double zlc; | |
| 197 | - /** 营运里程 */ | |
| 198 | - private Double yylc; | |
| 199 | - /** 空驶里程 */ | |
| 200 | - private Double kslc; | |
| 201 | - /** 总工时 */ | |
| 202 | - private Double zgs; | |
| 203 | - /** 总班次 */ | |
| 204 | - private Integer zbc; | |
| 205 | - /** 营运工时 */ | |
| 206 | - private Double yygs; | |
| 207 | - /** 营运班次 */ | |
| 208 | - private Integer yybc; | |
| 209 | - | |
| 210 | - public String getLpname() { | |
| 211 | - return lpname; | |
| 212 | - } | |
| 213 | - | |
| 214 | - public void setLpname(String lpname) { | |
| 215 | - this.lpname = lpname; | |
| 216 | - } | |
| 217 | - | |
| 218 | - public Boolean getIsUp() { | |
| 219 | - return isUp; | |
| 220 | - } | |
| 221 | - | |
| 222 | - public void setIsUp(Boolean isUp) { | |
| 223 | - this.isUp = isUp; | |
| 224 | - } | |
| 225 | - | |
| 226 | - public List<BcObj> getBcObjList() { | |
| 227 | - return bcObjList; | |
| 228 | - } | |
| 229 | - | |
| 230 | - public void setBcObjList(List<BcObj> bcObjList) { | |
| 231 | - this.bcObjList = bcObjList; | |
| 232 | - } | |
| 233 | - | |
| 234 | - public Integer getGroupCount() { | |
| 235 | - return groupCount; | |
| 236 | - } | |
| 237 | - | |
| 238 | - public void setGroupCount(Integer groupCount) { | |
| 239 | - this.groupCount = groupCount; | |
| 240 | - } | |
| 241 | - | |
| 242 | - public Integer getStationRouteId1() { | |
| 243 | - return stationRouteId1; | |
| 244 | - } | |
| 245 | - | |
| 246 | - public void setStationRouteId1(Integer stationRouteId1) { | |
| 247 | - this.stationRouteId1 = stationRouteId1; | |
| 248 | - } | |
| 249 | - | |
| 250 | - public Integer getStationRouteId2() { | |
| 251 | - return stationRouteId2; | |
| 252 | - } | |
| 253 | - | |
| 254 | - public void setStationRouteId2(Integer stationRouteId2) { | |
| 255 | - this.stationRouteId2 = stationRouteId2; | |
| 256 | - } | |
| 257 | - | |
| 258 | - public Boolean getUp() { | |
| 259 | - return isUp; | |
| 260 | - } | |
| 261 | - | |
| 262 | - public void setUp(Boolean up) { | |
| 263 | - isUp = up; | |
| 264 | - } | |
| 265 | - | |
| 266 | - public Double getZlc() { | |
| 267 | - return zlc; | |
| 268 | - } | |
| 269 | - | |
| 270 | - public void setZlc(Double zlc) { | |
| 271 | - this.zlc = zlc; | |
| 272 | - } | |
| 273 | - | |
| 274 | - public Double getYylc() { | |
| 275 | - return yylc; | |
| 276 | - } | |
| 277 | - | |
| 278 | - public void setYylc(Double yylc) { | |
| 279 | - this.yylc = yylc; | |
| 280 | - } | |
| 281 | - | |
| 282 | - public Double getKslc() { | |
| 283 | - return kslc; | |
| 284 | - } | |
| 285 | - | |
| 286 | - public void setKslc(Double kslc) { | |
| 287 | - this.kslc = kslc; | |
| 288 | - } | |
| 289 | - | |
| 290 | - public Double getZgs() { | |
| 291 | - return zgs; | |
| 292 | - } | |
| 293 | - | |
| 294 | - public void setZgs(Double zgs) { | |
| 295 | - this.zgs = zgs; | |
| 296 | - } | |
| 297 | - | |
| 298 | - public Integer getZbc() { | |
| 299 | - return zbc; | |
| 300 | - } | |
| 301 | - | |
| 302 | - public void setZbc(Integer zbc) { | |
| 303 | - this.zbc = zbc; | |
| 304 | - } | |
| 305 | - | |
| 306 | - public Double getYygs() { | |
| 307 | - return yygs; | |
| 308 | - } | |
| 309 | - | |
| 310 | - public void setYygs(Double yygs) { | |
| 311 | - this.yygs = yygs; | |
| 312 | - } | |
| 313 | - | |
| 314 | - public Integer getYybc() { | |
| 315 | - return yybc; | |
| 316 | - } | |
| 317 | - | |
| 318 | - public void setYybc(Integer yybc) { | |
| 319 | - this.yybc = yybc; | |
| 320 | - } | |
| 321 | - | |
| 322 | - } | |
| 323 | - | |
| 324 | - public static class StatInfo { // 统计数据对象 | |
| 325 | - /** 统计项目 */ | |
| 326 | - private String statItem; | |
| 327 | - /** 统计值 */ | |
| 328 | - private Double statValue; | |
| 329 | - | |
| 330 | - public String getStatItem() { | |
| 331 | - return statItem; | |
| 332 | - } | |
| 333 | - | |
| 334 | - public void setStatItem(String statItem) { | |
| 335 | - this.statItem = statItem; | |
| 336 | - } | |
| 337 | - | |
| 338 | - public Double getStatValue() { | |
| 339 | - return statValue; | |
| 340 | - } | |
| 341 | - | |
| 342 | - public void setStatValue(Double statValue) { | |
| 343 | - this.statValue = statValue; | |
| 344 | - } | |
| 345 | - } | |
| 346 | - | |
| 347 | - public static class DTInfos { // 所有数据信息 | |
| 348 | - /** 路牌班次数据列表 */ | |
| 349 | - private List<LpObj> lpObjList; | |
| 350 | - /** 统计数据列表 */ | |
| 351 | - private List<StatInfo> statInfoList; | |
| 352 | - | |
| 353 | - public List<LpObj> getLpObjList() { | |
| 354 | - return lpObjList; | |
| 355 | - } | |
| 356 | - | |
| 357 | - public void setLpObjList(List<LpObj> lpObjList) { | |
| 358 | - this.lpObjList = lpObjList; | |
| 359 | - } | |
| 360 | - | |
| 361 | - public List<StatInfo> getStatInfoList() { | |
| 362 | - return statInfoList; | |
| 363 | - } | |
| 364 | - | |
| 365 | - public void setStatInfoList(List<StatInfo> statInfoList) { | |
| 366 | - this.statInfoList = statInfoList; | |
| 367 | - } | |
| 368 | - } | |
| 369 | - | |
| 370 | - //---------------------- 生成时刻表用对象(以上) ---------------------// | |
| 371 | - | |
| 372 | - /** | |
| 373 | - * 导出动态时刻表数据。 | |
| 374 | - * @param dtInfos | |
| 375 | - * @return | |
| 376 | - * @throws ScheduleException | |
| 377 | - */ | |
| 378 | - public DataToolsFile exportDynamicTTinfo(DTInfos dtInfos, DataToolsFileType type) throws ScheduleException; | |
| 379 | -} | |
| 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.bsth.service.schedule.utils.DataToolsFileType; | |
| 6 | +import com.fasterxml.jackson.annotation.JsonCreator; | |
| 7 | +import com.fasterxml.jackson.annotation.JsonValue; | |
| 8 | + | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 动态时刻表数据。 | |
| 13 | + */ | |
| 14 | +public interface TTinfoDetailDynamicData { | |
| 15 | + | |
| 16 | + //---------------------- 生成时刻表用对象(以下) ---------------------// | |
| 17 | + enum BcType { // 班次类型枚举 | |
| 18 | + IN("in"), // 进场 | |
| 19 | + OUT("out"), // 出场 | |
| 20 | + BD("bd"), // 早例保 | |
| 21 | + LC("lc"), // 晚例保 | |
| 22 | + NORMAL("normal"); // 正常 | |
| 23 | + private String flag; | |
| 24 | + | |
| 25 | + @JsonCreator | |
| 26 | + private BcType(String flag) { | |
| 27 | + this.flag = flag; | |
| 28 | + } | |
| 29 | + | |
| 30 | + @JsonValue | |
| 31 | + public String getFlag() { | |
| 32 | + return flag; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public void setFlag(String flag) { | |
| 36 | + this.flag = flag; | |
| 37 | + } | |
| 38 | + } | |
| 39 | + | |
| 40 | + class BcObj { // 班次对象 | |
| 41 | + /** 班次时间 */ | |
| 42 | + private Integer bcsj; | |
| 43 | + /** 停站时间 */ | |
| 44 | + private Integer ssj; | |
| 45 | + /** 吃饭时间 */ | |
| 46 | + private Integer eatsj; | |
| 47 | + | |
| 48 | + /** 停车场id */ | |
| 49 | + private Integer tccid; | |
| 50 | + /** 起点站id */ | |
| 51 | + private Integer qdzid; | |
| 52 | + /** 终点站id */ | |
| 53 | + private Integer zdzid; | |
| 54 | + | |
| 55 | + /** 是否上行 */ | |
| 56 | + private Boolean isUp; | |
| 57 | + | |
| 58 | + /** 是否分班 */ | |
| 59 | + private Boolean isFb; | |
| 60 | + | |
| 61 | + /** 班次类型 */ | |
| 62 | + private BcType bcType; | |
| 63 | + /** 发车时刻 */ | |
| 64 | + private String fcsj; | |
| 65 | + /** 用于统计的发车时间描述(把进出场,保养,吃饭时间写在一起) */ | |
| 66 | + private String fcsjDesc; | |
| 67 | + | |
| 68 | + /** 第几圈(从1开始) */ | |
| 69 | + private Integer groupNo; | |
| 70 | + /** 圈里第几个班次(1或者2) */ | |
| 71 | + private Integer groupBcNo; | |
| 72 | + | |
| 73 | + public Integer getBcsj() { | |
| 74 | + return bcsj; | |
| 75 | + } | |
| 76 | + | |
| 77 | + public void setBcsj(Integer bcsj) { | |
| 78 | + this.bcsj = bcsj; | |
| 79 | + } | |
| 80 | + | |
| 81 | + public Integer getSsj() { | |
| 82 | + return ssj; | |
| 83 | + } | |
| 84 | + | |
| 85 | + public void setSsj(Integer ssj) { | |
| 86 | + this.ssj = ssj; | |
| 87 | + } | |
| 88 | + | |
| 89 | + public Integer getEatsj() { | |
| 90 | + return eatsj; | |
| 91 | + } | |
| 92 | + | |
| 93 | + public void setEatsj(Integer eatsj) { | |
| 94 | + this.eatsj = eatsj; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public Integer getTccid() { | |
| 98 | + return tccid; | |
| 99 | + } | |
| 100 | + | |
| 101 | + public void setTccid(Integer tccid) { | |
| 102 | + this.tccid = tccid; | |
| 103 | + } | |
| 104 | + | |
| 105 | + public Integer getQdzid() { | |
| 106 | + return qdzid; | |
| 107 | + } | |
| 108 | + | |
| 109 | + public void setQdzid(Integer qdzid) { | |
| 110 | + this.qdzid = qdzid; | |
| 111 | + } | |
| 112 | + | |
| 113 | + public Integer getZdzid() { | |
| 114 | + return zdzid; | |
| 115 | + } | |
| 116 | + | |
| 117 | + public void setZdzid(Integer zdzid) { | |
| 118 | + this.zdzid = zdzid; | |
| 119 | + } | |
| 120 | + | |
| 121 | + public BcType getBcType() { | |
| 122 | + return bcType; | |
| 123 | + } | |
| 124 | + | |
| 125 | + public void setBcType(BcType bcType) { | |
| 126 | + this.bcType = bcType; | |
| 127 | + } | |
| 128 | + | |
| 129 | + public String getFcsj() { | |
| 130 | + return fcsj; | |
| 131 | + } | |
| 132 | + | |
| 133 | + public void setFcsj(String fcsj) { | |
| 134 | + this.fcsj = fcsj; | |
| 135 | + } | |
| 136 | + | |
| 137 | + public Boolean getIsUp() { | |
| 138 | + return isUp; | |
| 139 | + } | |
| 140 | + | |
| 141 | + public void setIsUp(Boolean isUp) { | |
| 142 | + this.isUp = isUp; | |
| 143 | + } | |
| 144 | + | |
| 145 | + public Integer getGroupNo() { | |
| 146 | + return groupNo; | |
| 147 | + } | |
| 148 | + | |
| 149 | + public void setGroupNo(Integer groupNo) { | |
| 150 | + this.groupNo = groupNo; | |
| 151 | + } | |
| 152 | + | |
| 153 | + public Integer getGroupBcNo() { | |
| 154 | + return groupBcNo; | |
| 155 | + } | |
| 156 | + | |
| 157 | + public void setGroupBcNo(Integer groupBcNo) { | |
| 158 | + this.groupBcNo = groupBcNo; | |
| 159 | + } | |
| 160 | + | |
| 161 | + public String getFcsjDesc() { | |
| 162 | + return fcsjDesc; | |
| 163 | + } | |
| 164 | + | |
| 165 | + public void setFcsjDesc(String fcsjDesc) { | |
| 166 | + this.fcsjDesc = fcsjDesc; | |
| 167 | + } | |
| 168 | + | |
| 169 | + public Boolean getIsFb() { | |
| 170 | + return isFb; | |
| 171 | + } | |
| 172 | + | |
| 173 | + public void setIsFb(Boolean fb) { | |
| 174 | + isFb = fb; | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + class LpObj { // 路牌对象 | |
| 179 | + /** 路牌名字 */ | |
| 180 | + private String lpname; | |
| 181 | + /** 每圈的第一个班次是否上行 */ | |
| 182 | + private Boolean isUp; | |
| 183 | + | |
| 184 | + /** 第一个班次起点站路由id */ | |
| 185 | + private Integer stationRouteId1; | |
| 186 | + /** 第二个班次起点站路由id */ | |
| 187 | + private Integer stationRouteId2; | |
| 188 | + | |
| 189 | + /** 班次列表 */ | |
| 190 | + private List<BcObj> bcObjList; | |
| 191 | + /** 总圈数 */ | |
| 192 | + private Integer groupCount; | |
| 193 | + | |
| 194 | + //---------------- 路牌统计 ---------------// | |
| 195 | + /** 总里程 */ | |
| 196 | + private Double zlc; | |
| 197 | + /** 营运里程 */ | |
| 198 | + private Double yylc; | |
| 199 | + /** 空驶里程 */ | |
| 200 | + private Double kslc; | |
| 201 | + /** 总工时 */ | |
| 202 | + private Double zgs; | |
| 203 | + /** 总班次 */ | |
| 204 | + private Integer zbc; | |
| 205 | + /** 营运工时 */ | |
| 206 | + private Double yygs; | |
| 207 | + /** 营运班次 */ | |
| 208 | + private Integer yybc; | |
| 209 | + | |
| 210 | + public String getLpname() { | |
| 211 | + return lpname; | |
| 212 | + } | |
| 213 | + | |
| 214 | + public void setLpname(String lpname) { | |
| 215 | + this.lpname = lpname; | |
| 216 | + } | |
| 217 | + | |
| 218 | + public Boolean getIsUp() { | |
| 219 | + return isUp; | |
| 220 | + } | |
| 221 | + | |
| 222 | + public void setIsUp(Boolean isUp) { | |
| 223 | + this.isUp = isUp; | |
| 224 | + } | |
| 225 | + | |
| 226 | + public List<BcObj> getBcObjList() { | |
| 227 | + return bcObjList; | |
| 228 | + } | |
| 229 | + | |
| 230 | + public void setBcObjList(List<BcObj> bcObjList) { | |
| 231 | + this.bcObjList = bcObjList; | |
| 232 | + } | |
| 233 | + | |
| 234 | + public Integer getGroupCount() { | |
| 235 | + return groupCount; | |
| 236 | + } | |
| 237 | + | |
| 238 | + public void setGroupCount(Integer groupCount) { | |
| 239 | + this.groupCount = groupCount; | |
| 240 | + } | |
| 241 | + | |
| 242 | + public Integer getStationRouteId1() { | |
| 243 | + return stationRouteId1; | |
| 244 | + } | |
| 245 | + | |
| 246 | + public void setStationRouteId1(Integer stationRouteId1) { | |
| 247 | + this.stationRouteId1 = stationRouteId1; | |
| 248 | + } | |
| 249 | + | |
| 250 | + public Integer getStationRouteId2() { | |
| 251 | + return stationRouteId2; | |
| 252 | + } | |
| 253 | + | |
| 254 | + public void setStationRouteId2(Integer stationRouteId2) { | |
| 255 | + this.stationRouteId2 = stationRouteId2; | |
| 256 | + } | |
| 257 | + | |
| 258 | + public Boolean getUp() { | |
| 259 | + return isUp; | |
| 260 | + } | |
| 261 | + | |
| 262 | + public void setUp(Boolean up) { | |
| 263 | + isUp = up; | |
| 264 | + } | |
| 265 | + | |
| 266 | + public Double getZlc() { | |
| 267 | + return zlc; | |
| 268 | + } | |
| 269 | + | |
| 270 | + public void setZlc(Double zlc) { | |
| 271 | + this.zlc = zlc; | |
| 272 | + } | |
| 273 | + | |
| 274 | + public Double getYylc() { | |
| 275 | + return yylc; | |
| 276 | + } | |
| 277 | + | |
| 278 | + public void setYylc(Double yylc) { | |
| 279 | + this.yylc = yylc; | |
| 280 | + } | |
| 281 | + | |
| 282 | + public Double getKslc() { | |
| 283 | + return kslc; | |
| 284 | + } | |
| 285 | + | |
| 286 | + public void setKslc(Double kslc) { | |
| 287 | + this.kslc = kslc; | |
| 288 | + } | |
| 289 | + | |
| 290 | + public Double getZgs() { | |
| 291 | + return zgs; | |
| 292 | + } | |
| 293 | + | |
| 294 | + public void setZgs(Double zgs) { | |
| 295 | + this.zgs = zgs; | |
| 296 | + } | |
| 297 | + | |
| 298 | + public Integer getZbc() { | |
| 299 | + return zbc; | |
| 300 | + } | |
| 301 | + | |
| 302 | + public void setZbc(Integer zbc) { | |
| 303 | + this.zbc = zbc; | |
| 304 | + } | |
| 305 | + | |
| 306 | + public Double getYygs() { | |
| 307 | + return yygs; | |
| 308 | + } | |
| 309 | + | |
| 310 | + public void setYygs(Double yygs) { | |
| 311 | + this.yygs = yygs; | |
| 312 | + } | |
| 313 | + | |
| 314 | + public Integer getYybc() { | |
| 315 | + return yybc; | |
| 316 | + } | |
| 317 | + | |
| 318 | + public void setYybc(Integer yybc) { | |
| 319 | + this.yybc = yybc; | |
| 320 | + } | |
| 321 | + | |
| 322 | + } | |
| 323 | + | |
| 324 | + class StatInfo { // 统计数据对象 | |
| 325 | + /** 统计项目 */ | |
| 326 | + private String statItem; | |
| 327 | + /** 统计值 */ | |
| 328 | + private Double statValue; | |
| 329 | + | |
| 330 | + public String getStatItem() { | |
| 331 | + return statItem; | |
| 332 | + } | |
| 333 | + | |
| 334 | + public void setStatItem(String statItem) { | |
| 335 | + this.statItem = statItem; | |
| 336 | + } | |
| 337 | + | |
| 338 | + public Double getStatValue() { | |
| 339 | + return statValue; | |
| 340 | + } | |
| 341 | + | |
| 342 | + public void setStatValue(Double statValue) { | |
| 343 | + this.statValue = statValue; | |
| 344 | + } | |
| 345 | + } | |
| 346 | + | |
| 347 | + class ParameterInfo { // 生成参数对象 | |
| 348 | + /** 参数项目名称 */ | |
| 349 | + private String paramItem; | |
| 350 | + /** 参数项目值 */ | |
| 351 | + private String paramValue; | |
| 352 | + | |
| 353 | + public String getParamItem() { | |
| 354 | + return paramItem; | |
| 355 | + } | |
| 356 | + | |
| 357 | + public void setParamItem(String paramItem) { | |
| 358 | + this.paramItem = paramItem; | |
| 359 | + } | |
| 360 | + | |
| 361 | + public String getParamValue() { | |
| 362 | + return paramValue; | |
| 363 | + } | |
| 364 | + | |
| 365 | + public void setParamValue(String paramValue) { | |
| 366 | + this.paramValue = paramValue; | |
| 367 | + } | |
| 368 | + } | |
| 369 | + | |
| 370 | + class DTInfos { // 所有数据信息 | |
| 371 | + /** 路牌班次数据列表 */ | |
| 372 | + private List<LpObj> lpObjList; | |
| 373 | + /** 统计数据列表 */ | |
| 374 | + private List<StatInfo> statInfoList; | |
| 375 | + /** 参数对象信息 */ | |
| 376 | + private List<ParameterInfo> parameterInfoList; | |
| 377 | + | |
| 378 | + public List<LpObj> getLpObjList() { | |
| 379 | + return lpObjList; | |
| 380 | + } | |
| 381 | + | |
| 382 | + public void setLpObjList(List<LpObj> lpObjList) { | |
| 383 | + this.lpObjList = lpObjList; | |
| 384 | + } | |
| 385 | + | |
| 386 | + public List<StatInfo> getStatInfoList() { | |
| 387 | + return statInfoList; | |
| 388 | + } | |
| 389 | + | |
| 390 | + public void setStatInfoList(List<StatInfo> statInfoList) { | |
| 391 | + this.statInfoList = statInfoList; | |
| 392 | + } | |
| 393 | + | |
| 394 | + public List<ParameterInfo> getParameterInfoList() { | |
| 395 | + return parameterInfoList; | |
| 396 | + } | |
| 397 | + | |
| 398 | + public void setParameterInfoList(List<ParameterInfo> parameterInfoList) { | |
| 399 | + this.parameterInfoList = parameterInfoList; | |
| 400 | + } | |
| 401 | + } | |
| 402 | + | |
| 403 | + //---------------------- 生成时刻表用对象(以上) ---------------------// | |
| 404 | + | |
| 405 | + /** | |
| 406 | + * 导出动态时刻表数据。 | |
| 407 | + * @param dtInfos | |
| 408 | + * @return | |
| 409 | + * @throws ScheduleException | |
| 410 | + */ | |
| 411 | + DataToolsFile exportDynamicTTinfo(DTInfos dtInfos, DataToolsFileType type) throws ScheduleException; | |
| 412 | +} | ... | ... |
src/main/resources/static/pages/base/timesmodel/js/v2/ParameterObj.js
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalLpObj.js
| 1 | -/** | |
| 2 | - * 内部路牌对象。 | |
| 3 | - * @constructor | |
| 4 | - */ | |
| 5 | -var InternalLpObj = function( | |
| 6 | - orilpObj, // 原始路牌对象 | |
| 7 | - qCount, // 总共多少圈 | |
| 8 | - isUp // 圈是以上行开始还是下行开始 | |
| 9 | -) { | |
| 10 | - // TODO:原始路牌对象(这个路牌是对接外部gantt图像,以后有机会改了) | |
| 11 | - this._$$_orign_lp_obj = orilpObj; | |
| 12 | - | |
| 13 | - this._$_isUp = isUp; | |
| 14 | - | |
| 15 | - // 路牌的圈数,注意每个路牌的圈数都是一致的, | |
| 16 | - // 但并不是每一圈都有值 | |
| 17 | - // 第1圈从上标线开始 | |
| 18 | - // 第0圈表示中标线的第一个班次组成的半圈 | |
| 19 | - // 有多少圈根据最终迭代的结果来看 | |
| 20 | - this._$_qCount = qCount; | |
| 21 | - // 保存的是 InternalGroupBcObj 对象 | |
| 22 | - this._$_groupBcArray = new Array(qCount); | |
| 23 | - | |
| 24 | - var i; | |
| 25 | - for (i = 0; i < this._$_qCount; i++) { | |
| 26 | - this._$_groupBcArray[i] = new InternalGroupObj( | |
| 27 | - this, this._$_isUp, undefined, undefined); | |
| 28 | - } | |
| 29 | - | |
| 30 | - // 距离上一个路牌的最小发车间隔时间 | |
| 31 | - // 用于纵向添加班次的时候使用 | |
| 32 | - // 默认第一个路牌为0 | |
| 33 | - this._$_minVerticalIntervalTime = 0; | |
| 34 | - | |
| 35 | - // 详细记录每圈每个方向上的发车间隔时间 | |
| 36 | - // 第一维度表示圈数,第二维度表示第一个方向,第二个方向 | |
| 37 | - // 第一个方向是否上行由 _$_isUp 决定 | |
| 38 | - // 这里的间隔表示下一个路牌上的班次距离本路牌的班次发车时间间隔 | |
| 39 | - // 如果当前是最后一个路牌,表示第一个路牌的下一圈同方向班次距离本班次的间隔 | |
| 40 | - this._$_aVerticalIntervalTime = new Array(this._$_qCount); | |
| 41 | - for (i = 0; i < this._$_aVerticalIntervalTime.length; i++) { | |
| 42 | - this._$_aVerticalIntervalTime[i] = new Array(2); | |
| 43 | - } | |
| 44 | - | |
| 45 | - // 班型的相关变量 | |
| 46 | - this._$_bx_isLb = false; // 是否连班 | |
| 47 | - this._$_bx_isfb = false; // 是否分班 | |
| 48 | - this._$_bx_isfb_5_2 = false; // 是否5休2分班 | |
| 49 | - this._$_bx_desc; // 班型描述(默认为路牌编号) | |
| 50 | - | |
| 51 | - // 其他班次(进出场,例包,吃饭等),TODO:以后再拆 | |
| 52 | - this._$_other_bc_array = []; | |
| 53 | - | |
| 54 | - // TODO: | |
| 55 | - | |
| 56 | -}; | |
| 57 | - | |
| 58 | -//------------------- get/set 方法 -------------------// | |
| 59 | - | |
| 60 | -InternalLpObj.prototype.getOtherBcArray = function() { | |
| 61 | - return this._$_other_bc_array; | |
| 62 | -}; | |
| 63 | -InternalLpObj.prototype.addOtherBcArray = function(ba) { | |
| 64 | - this._$_other_bc_array = this._$_other_bc_array.concat(ba); | |
| 65 | -}; | |
| 66 | - | |
| 67 | -/** | |
| 68 | - * 获取圈 | |
| 69 | - * @param qIndex 圈index | |
| 70 | - */ | |
| 71 | -InternalLpObj.prototype.getGroup = function(qIndex) { | |
| 72 | - return this._$_groupBcArray[qIndex]; | |
| 73 | -}; | |
| 74 | - | |
| 75 | -/** | |
| 76 | - * 获取路牌圈数。 | |
| 77 | - * @returns {*} | |
| 78 | - */ | |
| 79 | -InternalLpObj.prototype.fnGetGroupCount = function() { | |
| 80 | - return this._$_qCount; | |
| 81 | -}; | |
| 82 | - | |
| 83 | -/** | |
| 84 | - * 是否上行。 | |
| 85 | - * @returns boolean | |
| 86 | - */ | |
| 87 | -InternalLpObj.prototype.isUp = function() { | |
| 88 | - return this._$_isUp; | |
| 89 | -}; | |
| 90 | - | |
| 91 | -/** | |
| 92 | - * 获取班次。 | |
| 93 | - * @param qIndex 第几圈 | |
| 94 | - * @param bcIndex 第几个班次 | |
| 95 | - */ | |
| 96 | -InternalLpObj.prototype.getBc = function(qIndex, bcIndex) { | |
| 97 | - var group = this._$_groupBcArray[qIndex]; | |
| 98 | - var bc; | |
| 99 | - if (bcIndex == 0) { | |
| 100 | - bc = group.getBc1(); | |
| 101 | - } else if (bcIndex == 1) { | |
| 102 | - bc = group.getBc2(); | |
| 103 | - } | |
| 104 | - return bc; | |
| 105 | -}; | |
| 106 | - | |
| 107 | -/** | |
| 108 | - * 在具体位置设置班次。 | |
| 109 | - * @param qIndex 第几圈 | |
| 110 | - * @param bcIndex 第几个班次 | |
| 111 | - * @param bc 班次对象 | |
| 112 | - */ | |
| 113 | -InternalLpObj.prototype.setBc = function(qIndex, bcIndex, bc) { | |
| 114 | - var group = this._$_groupBcArray[qIndex]; | |
| 115 | - if (bcIndex == 0) { | |
| 116 | - group.setBc1(bc); | |
| 117 | - bc.setGroup(group); | |
| 118 | - } else if (bcIndex == 1) { | |
| 119 | - group.setBc2(bc); | |
| 120 | - bc.setGroup(group); | |
| 121 | - } | |
| 122 | -}; | |
| 123 | - | |
| 124 | -/** | |
| 125 | - * 设置原始路牌对象。 | |
| 126 | - * @param lpObj 原始路牌对象 | |
| 127 | - */ | |
| 128 | -InternalLpObj.prototype.setLp = function(lpObj) { | |
| 129 | - this._$$_orign_lp_obj = lpObj; | |
| 130 | - var i; | |
| 131 | - var group; | |
| 132 | - for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 133 | - group = this._$_groupBcArray[i]; | |
| 134 | - if (group) { | |
| 135 | - group.setLp(this); // 圈和班次保存都是 InternalLpObj 对象 | |
| 136 | - } | |
| 137 | - } | |
| 138 | -}; | |
| 139 | - | |
| 140 | -InternalLpObj.prototype.getLpNo = function() { | |
| 141 | - return this._$$_orign_lp_obj.lpNo; | |
| 142 | -}; | |
| 143 | -InternalLpObj.prototype.getLpName = function() { | |
| 144 | - return this._$$_orign_lp_obj.lpName; | |
| 145 | -}; | |
| 146 | -InternalLpObj.prototype.setBxFb5_2 = function(fb) { | |
| 147 | - this._$_bx_isfb_5_2 = fb; | |
| 148 | -}; | |
| 149 | -InternalLpObj.prototype.isBxFb5_2 = function() { | |
| 150 | - return this._$_bx_isfb_5_2; | |
| 151 | -}; | |
| 152 | -InternalLpObj.prototype.setBxLb = function(lb) { | |
| 153 | - this._$_bx_isLb = lb; | |
| 154 | -}; | |
| 155 | -InternalLpObj.prototype.isBxLb = function() { | |
| 156 | - return this._$_bx_isLb; | |
| 157 | -}; | |
| 158 | - | |
| 159 | -InternalLpObj.prototype.setBxFb = function(fb) { | |
| 160 | - this._$_bx_isfb = fb; | |
| 161 | -}; | |
| 162 | -InternalLpObj.prototype.isBxFb = function() { | |
| 163 | - return this._$_bx_isfb; | |
| 164 | -}; | |
| 165 | - | |
| 166 | -/** | |
| 167 | - * 设置路牌的班型描述(最终是设置班次的路牌名字)。 | |
| 168 | - * @param desc 描述 | |
| 169 | - */ | |
| 170 | -InternalLpObj.prototype.setBxDesc = function(desc) { | |
| 171 | - // 最终原始路牌的名字 | |
| 172 | - this._$$_orign_lp_obj.lpName = desc + "_" + this._$$_orign_lp_obj.lpNo; | |
| 173 | - // 内部对象的班型描述 | |
| 174 | - this._$_bx_desc = desc; | |
| 175 | -}; | |
| 176 | -/** | |
| 177 | - * 获取版型描述 | |
| 178 | - * @returns string | |
| 179 | - */ | |
| 180 | -InternalLpObj.prototype.getBxDesc = function() { | |
| 181 | - return this._$_bx_desc; | |
| 182 | -}; | |
| 183 | - | |
| 184 | -/** | |
| 185 | - * 设置纵向最小发车间隔时间。 | |
| 186 | - * @param v | |
| 187 | - */ | |
| 188 | -InternalLpObj.prototype.setVerticalMinIntervalTime = function(v) { | |
| 189 | - // 第一个路牌,都为0 | |
| 190 | - this._$_minVerticalIntervalTime = v; | |
| 191 | -}; | |
| 192 | -/** | |
| 193 | - * 获取纵向最小发车间隔时间。 | |
| 194 | - * @returns {number|*} | |
| 195 | - */ | |
| 196 | -InternalLpObj.prototype.getVerticalMinIntervalTime = function() { | |
| 197 | - return this._$_minVerticalIntervalTime; | |
| 198 | -}; | |
| 199 | - | |
| 200 | -/** | |
| 201 | - * 设置纵向发车间隔。 | |
| 202 | - * @param iQindex 圈index | |
| 203 | - * @param iBindex 班次index | |
| 204 | - * @param iTime 间隔时间 | |
| 205 | - */ | |
| 206 | -InternalLpObj.prototype.fnSetVerticalIntervalTime = function(iQindex, iBindex, iTime) { | |
| 207 | - this._$_aVerticalIntervalTime[iQindex][iBindex] = iTime; | |
| 208 | -}; | |
| 209 | - | |
| 210 | -/** | |
| 211 | - * 返回纵向发车间隔。 | |
| 212 | - * @param iQindex 圈index | |
| 213 | - * @param iBindex 班次index | |
| 214 | - */ | |
| 215 | -InternalLpObj.prototype.fnGetVerticalIntervalTime = function(iQindex, iBindex) { | |
| 216 | - return this._$_aVerticalIntervalTime[iQindex][iBindex]; | |
| 217 | -}; | |
| 218 | - | |
| 219 | -//-------------------- 班次操作方法(查询,统计,删除) -----------------------// | |
| 220 | - | |
| 221 | -/** | |
| 222 | - * 返回总共班次数。 | |
| 223 | - */ | |
| 224 | -InternalLpObj.prototype.getBcCount = function() { | |
| 225 | - var i; | |
| 226 | - var group; | |
| 227 | - var bccount = 0; | |
| 228 | - for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 229 | - group = this._$_groupBcArray[i]; | |
| 230 | - if (group) { | |
| 231 | - if (group.getBc1()) { | |
| 232 | - bccount += 1; | |
| 233 | - } | |
| 234 | - if (group.getBc2()) { | |
| 235 | - bccount += 1; | |
| 236 | - } | |
| 237 | - } | |
| 238 | - } | |
| 239 | - | |
| 240 | - return bccount; | |
| 241 | -}; | |
| 242 | - | |
| 243 | -/** | |
| 244 | - * 返回班次列表,过滤空的班次,将所有存在的班次连成连续的对象数组返回。 | |
| 245 | - * @returns arrays (InternalBcObj) | |
| 246 | - */ | |
| 247 | -InternalLpObj.prototype.getBcArray = function() { | |
| 248 | - var bcArray = []; | |
| 249 | - var i; | |
| 250 | - var group; | |
| 251 | - for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 252 | - group = this._$_groupBcArray[i]; | |
| 253 | - if (group) { | |
| 254 | - group.getBc1() ? bcArray.push(group.getBc1()) : ""; | |
| 255 | - group.getBc2() ? bcArray.push(group.getBc2()) : ""; | |
| 256 | - } | |
| 257 | - } | |
| 258 | - | |
| 259 | - return bcArray; | |
| 260 | -}; | |
| 261 | - | |
| 262 | -/** | |
| 263 | - * 获取最小(最早)班次对象。 | |
| 264 | - * @returns [{圈index},{班次index}] | |
| 265 | - */ | |
| 266 | -InternalLpObj.prototype.getMinBcObjPosition = function() { | |
| 267 | - var i; | |
| 268 | - var bIndex = []; | |
| 269 | - for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 270 | - if (this._$_groupBcArray[i].getBc1()) { | |
| 271 | - bIndex.push(i); | |
| 272 | - bIndex.push(0); | |
| 273 | - break; | |
| 274 | - } | |
| 275 | - if (this._$_groupBcArray[i].getBc2()) { | |
| 276 | - bIndex.push(i); | |
| 277 | - bIndex.push(1); | |
| 278 | - break; | |
| 279 | - } | |
| 280 | - } | |
| 281 | - return bIndex; | |
| 282 | -}; | |
| 283 | - | |
| 284 | -/** | |
| 285 | - * 获取最大(最晚)班次对象。 | |
| 286 | - * @returns [{圈index},{班次index}] | |
| 287 | - */ | |
| 288 | -InternalLpObj.prototype.getMaxBcObjPosition = function() { | |
| 289 | - var i; | |
| 290 | - var bIndex = []; | |
| 291 | - for (i = this._$_groupBcArray.length - 1; i >= 0; i--) { | |
| 292 | - if (this._$_groupBcArray[i].getBc2()) { | |
| 293 | - bIndex.push(i); | |
| 294 | - bIndex.push(1); | |
| 295 | - break; | |
| 296 | - } | |
| 297 | - if (this._$_groupBcArray[i].getBc1()) { | |
| 298 | - bIndex.push(i); | |
| 299 | - bIndex.push(0); | |
| 300 | - break; | |
| 301 | - } | |
| 302 | - } | |
| 303 | - return bIndex; | |
| 304 | -}; | |
| 305 | - | |
| 306 | -InternalLpObj.prototype.getMinBcObj = function() { | |
| 307 | - var i; | |
| 308 | - var bcObj; | |
| 309 | - for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 310 | - bcObj = this._$_groupBcArray[i].getBc1(); | |
| 311 | - if (bcObj) { | |
| 312 | - break; | |
| 313 | - } | |
| 314 | - bcObj = this._$_groupBcArray[i].getBc2(); | |
| 315 | - if (bcObj) { | |
| 316 | - break; | |
| 317 | - } | |
| 318 | - } | |
| 319 | - return bcObj; | |
| 320 | -}; | |
| 321 | -InternalLpObj.prototype.getMaxBcObj = function() { | |
| 322 | - var i; | |
| 323 | - var bcObj; | |
| 324 | - for (i = this._$_groupBcArray.length - 1; i >= 0; i--) { | |
| 325 | - bcObj = this._$_groupBcArray[i].getBc2(); | |
| 326 | - if (bcObj) { | |
| 327 | - break; | |
| 328 | - } | |
| 329 | - bcObj = this._$_groupBcArray[i].getBc1(); | |
| 330 | - if (bcObj) { | |
| 331 | - break; | |
| 332 | - } | |
| 333 | - } | |
| 334 | - return bcObj; | |
| 335 | -}; | |
| 336 | - | |
| 337 | -/** | |
| 338 | - * 获取车次链信息。 | |
| 339 | - * @param num 第几个车次链 | |
| 340 | - * @returns object {s_q: {开始圈索引},s_b : {开始班次索引},e_q : {结束圈索引},e_b : {结束班次索引}, bcount : {班次数}} | |
| 341 | - */ | |
| 342 | -InternalLpObj.prototype.fnGetBcChainInfo = function(num) { | |
| 343 | - // 计算总的车次链信息 | |
| 344 | - var aChainInfo = []; | |
| 345 | - var oChainInfo; | |
| 346 | - var aBcIndex = this.getMinBcObjPosition(); | |
| 347 | - var oBc; | |
| 348 | - var iQIndex; | |
| 349 | - var iBcIndex; | |
| 350 | - var i; | |
| 351 | - var bFlag; | |
| 352 | - | |
| 353 | - var iBcount = 0; | |
| 354 | - | |
| 355 | - if (aBcIndex.length == 2) { | |
| 356 | - iBcount = 1; | |
| 357 | - oChainInfo = {s_q : aBcIndex[0], s_b : aBcIndex[1], e_q : aBcIndex[0], e_b : aBcIndex[1], bcount: 1}; | |
| 358 | - aChainInfo.push(oChainInfo); | |
| 359 | - bFlag = true; | |
| 360 | - | |
| 361 | - // 下一个班次的索引 | |
| 362 | - iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1; | |
| 363 | - iBcIndex = aBcIndex[1] == 0 ? 1 : 0; | |
| 364 | - | |
| 365 | - for (i = iQIndex; i < this._$_qCount; i++) { | |
| 366 | - while (iBcIndex <= 1) { | |
| 367 | - oBc = this.getBc(i, iBcIndex); | |
| 368 | - if (!oBc) { | |
| 369 | - if (bFlag) { | |
| 370 | - // 车次链结尾是这个班次的前一个班次 | |
| 371 | - oChainInfo.e_q = iBcIndex == 0 ? i - 1 : i; | |
| 372 | - oChainInfo.e_b = iBcIndex == 0 ? 1 : 0; | |
| 373 | - oChainInfo.bcount = iBcount; | |
| 374 | - } | |
| 375 | - | |
| 376 | - bFlag = false; | |
| 377 | - } else { | |
| 378 | - if (bFlag) { | |
| 379 | - iBcount ++; | |
| 380 | - oChainInfo.bcount = iBcount; | |
| 381 | - } else { | |
| 382 | - // 下一个车次链开始 | |
| 383 | - iBcount = 1; | |
| 384 | - oChainInfo = {s_q : i, s_b : iBcIndex, e_q : i, e_b : iBcIndex, bcount: 1}; | |
| 385 | - aChainInfo.push(oChainInfo); | |
| 386 | - bFlag = true; | |
| 387 | - } | |
| 388 | - } | |
| 389 | - | |
| 390 | - | |
| 391 | - iBcIndex ++; | |
| 392 | - } | |
| 393 | - iBcIndex = 0; | |
| 394 | - } | |
| 395 | - | |
| 396 | - } | |
| 397 | - | |
| 398 | - return aChainInfo[num]; | |
| 399 | -}; | |
| 400 | - | |
| 401 | -/** | |
| 402 | - * 获取车次链的个数。 | |
| 403 | - * @returns int | |
| 404 | - */ | |
| 405 | -InternalLpObj.prototype.fnGetBcChainCount = function() { | |
| 406 | - var iChainCount = 0; | |
| 407 | - var aBcIndex = this.getMinBcObjPosition(); | |
| 408 | - | |
| 409 | - var oBc; | |
| 410 | - var iQIndex; | |
| 411 | - var iBcIndex; | |
| 412 | - var i; | |
| 413 | - var bFlag; | |
| 414 | - | |
| 415 | - if (aBcIndex.length == 2) { | |
| 416 | - iChainCount = 1; | |
| 417 | - bFlag = true; | |
| 418 | - | |
| 419 | - // 下一个班次的索引 | |
| 420 | - iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1; | |
| 421 | - iBcIndex = aBcIndex[1] == 0 ? 1 : 0; | |
| 422 | - | |
| 423 | - for (i = iQIndex; i < this._$_qCount; i++) { | |
| 424 | - while (iBcIndex <= 1) { | |
| 425 | - oBc = this.getBc(i, iBcIndex); | |
| 426 | - if (!oBc) { | |
| 427 | - bFlag = false; | |
| 428 | - } else { | |
| 429 | - if (bFlag) { | |
| 430 | - | |
| 431 | - } else { | |
| 432 | - iChainCount ++; | |
| 433 | - bFlag = true; | |
| 434 | - } | |
| 435 | - } | |
| 436 | - | |
| 437 | - | |
| 438 | - iBcIndex ++; | |
| 439 | - } | |
| 440 | - iBcIndex = 0; | |
| 441 | - } | |
| 442 | - | |
| 443 | - } | |
| 444 | - | |
| 445 | - | |
| 446 | - return iChainCount; | |
| 447 | -}; | |
| 448 | - | |
| 449 | -/** | |
| 450 | - * 在具体位置移除班次。 | |
| 451 | - * @param qIndex 第几圈 | |
| 452 | - * @param bcIndex 第几个班次 | |
| 453 | - */ | |
| 454 | -InternalLpObj.prototype.removeBc = function(qIndex, bcIndex) { | |
| 455 | - var group = this._$_groupBcArray[qIndex]; | |
| 456 | - if (bcIndex == 0) { | |
| 457 | - group.removeBc1(); | |
| 458 | - } else if (bcIndex == 1) { | |
| 459 | - group.removeBc2(); | |
| 460 | - } | |
| 461 | -}; | |
| 462 | - | |
| 463 | -/** | |
| 464 | - * 使用指定时间匹配返回离之最近的第几圈第几个班次, | |
| 465 | - * 使用时间差的绝度值,比较,取最小的 | |
| 466 | - * 如果有两个一样的时间差,取比fctime大的时间 | |
| 467 | - * @param fctime moment 比较用时间 | |
| 468 | - * @param groupArray 圈数组 | |
| 469 | - * @param hasUp boolean 计算上行班次 | |
| 470 | - * @param hasDown boolean 计算下行班次 | |
| 471 | - * @returns [{第几圈},{第几个班次}] | |
| 472 | - */ | |
| 473 | -InternalLpObj.prototype.fnGetQBcIndexWithFcTimeFromGroupArray = function( | |
| 474 | - fctime, groupArray, hasUp, hasDown | |
| 475 | -) { | |
| 476 | - var i; | |
| 477 | - var timediff; // 时间差取绝对值 | |
| 478 | - var qIndex; | |
| 479 | - var bcIndex; | |
| 480 | - | |
| 481 | - var group; | |
| 482 | - var bc1time; | |
| 483 | - var bc2time; | |
| 484 | - | |
| 485 | - var tempdiff; | |
| 486 | - | |
| 487 | - console.log("比较时间=" + fctime.format("HH:mm")); | |
| 488 | - | |
| 489 | - var oBc; | |
| 490 | - | |
| 491 | - for (i = 0; i < this._$_qCount; i++) { | |
| 492 | - group = groupArray[i]; | |
| 493 | - if (group) { | |
| 494 | - oBc = group.getBc1(); | |
| 495 | - if (oBc != undefined && (oBc.isUp() == hasUp || oBc.isUp() == hasDown)) { | |
| 496 | - bc1time = group.getBc1().getFcTimeObj(); | |
| 497 | - console.log("bc1time=" + bc1time.format("HH:mm") + " tempdiff=" + tempdiff); | |
| 498 | - tempdiff = Math.abs(bc1time.diff(fctime)); | |
| 499 | - | |
| 500 | - if (!timediff) { | |
| 501 | - timediff = Math.abs(tempdiff); | |
| 502 | - qIndex = i; | |
| 503 | - bcIndex = 0; | |
| 504 | - } else { | |
| 505 | - if (tempdiff < timediff) { | |
| 506 | - timediff = tempdiff; | |
| 507 | - qIndex = i; | |
| 508 | - bcIndex = 0; | |
| 509 | - } if (Math.abs(tempdiff) == timediff) { | |
| 510 | - if (bc1time.isAfter(fctime)) { | |
| 511 | - timediff = tempdiff; | |
| 512 | - qIndex = i; | |
| 513 | - bcIndex = 0; | |
| 514 | - } | |
| 515 | - | |
| 516 | - } | |
| 517 | - } | |
| 518 | - } | |
| 519 | - | |
| 520 | - oBc = group.getBc2(); | |
| 521 | - if (oBc != undefined && (oBc.isUp() == hasUp || oBc.isUp() == hasDown)) { | |
| 522 | - bc2time = group.getBc2().getFcTimeObj(); | |
| 523 | - console.log("bc2time=" + bc2time.format("HH:mm") + " tempdiff=" + tempdiff); | |
| 524 | - tempdiff = Math.abs(bc2time.diff(fctime)); | |
| 525 | - | |
| 526 | - if (!timediff) { | |
| 527 | - timediff = Math.abs(tempdiff); | |
| 528 | - qIndex = i; | |
| 529 | - bcIndex = 1; | |
| 530 | - } else { | |
| 531 | - if (tempdiff < timediff) { | |
| 532 | - timediff = tempdiff; | |
| 533 | - qIndex = i; | |
| 534 | - bcIndex = 1; | |
| 535 | - } if (Math.abs(tempdiff) == timediff) { | |
| 536 | - if (bc2time.isBefore(fctime)) { | |
| 537 | - timediff = tempdiff; | |
| 538 | - qIndex = i; | |
| 539 | - bcIndex = 1; | |
| 540 | - } | |
| 541 | - | |
| 542 | - } | |
| 543 | - } | |
| 544 | - } | |
| 545 | - } | |
| 546 | - } | |
| 547 | - | |
| 548 | - console.log("中标线对应数组索引=" + qIndex); | |
| 549 | - | |
| 550 | - var rst = []; | |
| 551 | - rst.push(qIndex); | |
| 552 | - rst.push(bcIndex); | |
| 553 | - | |
| 554 | - return rst; | |
| 555 | -}; | |
| 556 | - | |
| 557 | -/** | |
| 558 | - * 使用指定时间匹配返回离之最近的第几圈第几个班次, | |
| 559 | - * 使用时间差的绝度值,比较,取最小的 | |
| 560 | - * 如果有两个一样的时间差,取比fctime大的时间 | |
| 561 | - * @param fctime moment 比较用时间 | |
| 562 | - * @param hasUp boolean 计算上行班次 | |
| 563 | - * @param hasDown boolean 计算下行班次 | |
| 564 | - * @returns [{第几圈},{第几个班次}] | |
| 565 | - */ | |
| 566 | -InternalLpObj.prototype.getQBcIndexWithFcTime = function( | |
| 567 | - fctime, hasUp, hasDown | |
| 568 | -) { | |
| 569 | - return this.fnGetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray, hasUp, hasDown); | |
| 570 | -}; | |
| 571 | - | |
| 572 | -//---------------------- 内部数据初始化方法(不同于构造函数)---------------------// | |
| 573 | - | |
| 574 | -/** | |
| 575 | - * 从指定开始时间到结束时间创建不间断班次(连班),并初始化路牌 | |
| 576 | - * 注意,之前有班次会删除后再创建。 | |
| 577 | - * @param startTime 开始时间 | |
| 578 | - * @param endTime 结束时间 | |
| 579 | - * @param isUp 第一个班次是上行还是下行 | |
| 580 | - * @param fromQ 从第几圈开始加入 | |
| 581 | - * @param paramObj 参数对象 | |
| 582 | - * @param factory 工厂对象 | |
| 583 | - */ | |
| 584 | -InternalLpObj.prototype.initDataFromTimeToTime = function( | |
| 585 | - startTime, | |
| 586 | - endTime, | |
| 587 | - isUp, | |
| 588 | - fromQ, | |
| 589 | - paramObj, | |
| 590 | - factory) { | |
| 591 | - | |
| 592 | - var bcData = []; // 班次数组 | |
| 593 | - var bcObj; | |
| 594 | - var kssj = startTime; | |
| 595 | - var fcno = 1; // 发车顺序号 | |
| 596 | - var bcCount = 1; // 班次数 | |
| 597 | - do { | |
| 598 | - bcObj = factory.createBcObj( | |
| 599 | - this, "normal", isUp, fcno, kssj, paramObj); // this就是所属路牌对象 | |
| 600 | - bcData.push(bcObj); | |
| 601 | - | |
| 602 | - kssj = paramObj.addMinute(kssj, bcObj.getBcTime() + bcObj.getStopTime()); | |
| 603 | - fcno ++; | |
| 604 | - bcCount ++; | |
| 605 | - isUp = !isUp; | |
| 606 | - } while(kssj.isBefore(endTime)); | |
| 607 | - bcCount--; | |
| 608 | - | |
| 609 | - //console.log("last -1;" + bcData[bcCount -2].getFcTimeObj().format("HH:mm")); | |
| 610 | - //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm")); | |
| 611 | - //console.log("endtime: " + endTime.format("HH:mm")); | |
| 612 | - | |
| 613 | - //if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) { | |
| 614 | - // // 如果最后一个班次的到达时间超过结束时间,也要去除 | |
| 615 | - // bcData.splice(bcCount - 1, 1); | |
| 616 | - //} | |
| 617 | - | |
| 618 | - this._initDataFromLbBcArray(bcData, fromQ); | |
| 619 | - | |
| 620 | -}; | |
| 621 | - | |
| 622 | -/** | |
| 623 | - * 使用连班的班次数组初始化路牌(相应的圈会被覆盖)。 | |
| 624 | - * @param bcArray 连班班次数组 | |
| 625 | - * @param fromQ 从第几圈开始加入 | |
| 626 | - */ | |
| 627 | -InternalLpObj.prototype._initDataFromLbBcArray = function( | |
| 628 | - bcArray, | |
| 629 | - fromQ | |
| 630 | -) { | |
| 631 | - var _bc1Obj; | |
| 632 | - var _bc2Obj; | |
| 633 | - var _qObj; | |
| 634 | - | |
| 635 | - // 第一班次是上行还是下行 | |
| 636 | - var isUp = bcArray[0].isUp(); | |
| 637 | - | |
| 638 | - if (bcArray.length > 0 && fromQ < this._$_qCount) { | |
| 639 | - // 构造圈数 | |
| 640 | - if (isUp != this._$_isUp) { | |
| 641 | - // 如果方向不一致,意味着第一个班次是半圈 | |
| 642 | - // 加半圈,并加在bc2上 | |
| 643 | - _bc2Obj = bcArray.slice(0, 1)[0]; | |
| 644 | - _qObj = new InternalGroupObj( | |
| 645 | - this, | |
| 646 | - this._$_isUp, | |
| 647 | - undefined, | |
| 648 | - _bc2Obj | |
| 649 | - ); | |
| 650 | - _bc2Obj.setGroup(_qObj); | |
| 651 | - this._$_groupBcArray[fromQ] = _qObj; | |
| 652 | - | |
| 653 | - bcArray.splice(0, 1); | |
| 654 | - fromQ ++; | |
| 655 | - } | |
| 656 | - | |
| 657 | - var qCount1 = Math.floor(bcArray.length / 2); // 需要添加多少圈 | |
| 658 | - var qCount2 = bcArray.length % 2; // 最后是否有半圈 | |
| 659 | - | |
| 660 | - while (fromQ < this._$_qCount) { | |
| 661 | - if (qCount1 > 0) { | |
| 662 | - _bc1Obj = bcArray.slice(0, 1)[0]; | |
| 663 | - _bc2Obj = bcArray.slice(1, 2)[0]; | |
| 664 | - _qObj = new InternalGroupObj( | |
| 665 | - this, | |
| 666 | - this._$_isUp, | |
| 667 | - _bc1Obj, | |
| 668 | - _bc2Obj | |
| 669 | - ); | |
| 670 | - _bc1Obj.setGroup(_qObj); | |
| 671 | - _bc2Obj.setGroup(_qObj); | |
| 672 | - this._$_groupBcArray[fromQ] = _qObj; | |
| 673 | - | |
| 674 | - bcArray.splice(0, 2); | |
| 675 | - qCount1 --; | |
| 676 | - } else if (qCount2 > 0) { | |
| 677 | - // 加半圈,并加在bc1上 | |
| 678 | - _bc1Obj = bcArray.slice(0, 1)[0]; | |
| 679 | - _qObj = new InternalGroupObj( | |
| 680 | - this, | |
| 681 | - this._$_isUp, | |
| 682 | - _bc1Obj, | |
| 683 | - undefined | |
| 684 | - ); | |
| 685 | - _bc1Obj.setGroup(_qObj); | |
| 686 | - this._$_groupBcArray[fromQ] = _qObj; | |
| 687 | - | |
| 688 | - bcArray.splice(0, 1); | |
| 689 | - qCount2 --; | |
| 690 | - } else { | |
| 691 | - break; | |
| 692 | - } | |
| 693 | - | |
| 694 | - fromQ ++; | |
| 695 | - } | |
| 696 | - } | |
| 697 | -}; | |
| 698 | - | |
| 699 | -//-------------------------- 其他方法 ----------------------------// | |
| 700 | - | |
| 701 | -/** | |
| 702 | - * 从指定位置的班次开始,往后所有的班次修正发车时间 | |
| 703 | - * @param groupIndex | |
| 704 | - * @param bcIndex | |
| 705 | - * @param time | |
| 706 | - */ | |
| 707 | -InternalLpObj.prototype.fnAddMinuteToBcFcsj = function(groupIndex, bcIndex, time) { | |
| 708 | - var i; | |
| 709 | - var oCurBc; | |
| 710 | - | |
| 711 | - // 修正之前班次的停站时间 | |
| 712 | - //oCurBc = this.getBc( | |
| 713 | - // bcIndex == 0 ? groupIndex - 1 : groupIndex, | |
| 714 | - // bcIndex == 1 ? 0 : 1 | |
| 715 | - //); | |
| 716 | - //if (oCurBc) { | |
| 717 | - // oCurBc.setStopTime(oCurBc.getStopTime() + time); | |
| 718 | - //} | |
| 719 | - | |
| 720 | - | |
| 721 | - for (i = groupIndex; i < this._$_qCount; i++) { | |
| 722 | - if (bcIndex == 0) { | |
| 723 | - oCurBc = this.getBc(i, 0); | |
| 724 | - if (oCurBc) { | |
| 725 | - oCurBc.addMinuteToFcsj(time); | |
| 726 | - } | |
| 727 | - oCurBc = this.getBc(i, 1); | |
| 728 | - if (oCurBc) { | |
| 729 | - oCurBc.addMinuteToFcsj(time); | |
| 730 | - } | |
| 731 | - | |
| 732 | - } else { | |
| 733 | - oCurBc = this.getBc(i, 1); | |
| 734 | - if (oCurBc) { | |
| 735 | - oCurBc.addMinuteToFcsj(time); | |
| 736 | - } | |
| 737 | - | |
| 738 | - } | |
| 739 | - | |
| 740 | - bcIndex = 0; | |
| 741 | - } | |
| 742 | -}; | |
| 743 | - | |
| 744 | -/** | |
| 745 | - * 在指定位置添加一个吃饭班次。 | |
| 746 | - * 注1:吃饭班次不是普通班次,不记录进圈,记录进_$_other_bc_array | |
| 747 | - * 注2:添加吃饭班次时,会修改之前班次的停战时间,所以导致之后的班次的停战都会发生变化 | |
| 748 | - * @param groupIndex | |
| 749 | - * @param bcIndex | |
| 750 | - * @param factory | |
| 751 | - * @param paramObj | |
| 752 | - * @returns int 相差时间(吃饭时间距离和停站时间相差值) | |
| 753 | - */ | |
| 754 | -InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, paramObj) { | |
| 755 | - var oPreBc; | |
| 756 | - var oEatBc; | |
| 757 | - var iBcModifyTime; | |
| 758 | - oPreBc = this.getBc( // 前一个邻接班次 | |
| 759 | - bcIndex == 0 ? groupIndex - 1 : groupIndex, | |
| 760 | - bcIndex == 1 ? 0 : 1); | |
| 761 | - if (oPreBc) { // 存在前一个班次 | |
| 762 | - oEatBc = factory.createBcObj( | |
| 763 | - this, | |
| 764 | - "cf", | |
| 765 | - !oPreBc.isUp(), // 和上一个班次方向相反 | |
| 766 | - 1, | |
| 767 | - paramObj.addMinute(oPreBc.getArrTimeObj(), oPreBc.getStopTime()), // 使用上一个班次的到达时间作为开始时间 | |
| 768 | - paramObj | |
| 769 | - ); | |
| 770 | - | |
| 771 | - //iBcModifyTime = oEatBc.getBcTime() - oPreBc.getStopTime(); // 后续班次要调整的时间 | |
| 772 | - | |
| 773 | - // 修正之后的班次发车时间 | |
| 774 | - // 注意:之后那个班次发车时间就是吃饭班次的到达时间 | |
| 775 | - iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m"); | |
| 776 | - this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime); | |
| 777 | - | |
| 778 | - oPreBc.setStopTime(0); // 不重置停站时间 | |
| 779 | - oPreBc.fnSetEatTime(oEatBc.getBcTime()); | |
| 780 | - | |
| 781 | - //this._$_other_bc_array.push(oEatBc); | |
| 782 | - | |
| 783 | - return iBcModifyTime; | |
| 784 | - } else { | |
| 785 | - return false; | |
| 786 | - } | |
| 787 | - | |
| 788 | -}; | |
| 789 | - | |
| 790 | -/** | |
| 791 | - * 调整路牌的班次,通过调整停站时间,或者班次发车时间,不能让班次的到达时间和下一个班次的发车时间重叠。 | |
| 792 | - * @param iPeakAverStopTime 高峰平均停站时间 | |
| 793 | - * @param iTroughAverStopTime 低谷平均停站时间 | |
| 794 | - * @param oParam 参数对象 | |
| 795 | - */ | |
| 796 | -InternalLpObj.prototype.fnAdjustBcInterval = function(iPeakAverStopTime, iTroughAverStopTime, oParam) { | |
| 797 | - // 获取车次链个数 | |
| 798 | - var iBcChainCount = this.fnGetBcChainCount(); | |
| 799 | - | |
| 800 | - var i; | |
| 801 | - var j; | |
| 802 | - var oBcIndex; | |
| 803 | - var iQIndex; | |
| 804 | - var iBcIndex; | |
| 805 | - var iBcCount; | |
| 806 | - var oBc; | |
| 807 | - var oNextBc; | |
| 808 | - | |
| 809 | - var iBcStopTime; | |
| 810 | - | |
| 811 | - for (i = 0; i < iBcChainCount; i++) { | |
| 812 | - oBcIndex = this.fnGetBcChainInfo(i); | |
| 813 | - iQIndex = oBcIndex["s_q"]; | |
| 814 | - iBcIndex = oBcIndex["s_b"]; | |
| 815 | - iBcCount = oBcIndex["bcount"]; | |
| 816 | - | |
| 817 | - for (j = 0; j < iBcCount - 1; j++) { | |
| 818 | - oBc = this.getBc(iQIndex, iBcIndex); | |
| 819 | - oNextBc = this.getBc( | |
| 820 | - iBcIndex == 0 ? iQIndex : iQIndex + 1, | |
| 821 | - iBcIndex == 0 ? 1 : 0); | |
| 822 | - | |
| 823 | - if (oNextBc.fnIsFirstBc()) { // 如果同一路牌连续2个方向首站班次,都不做处理 | |
| 824 | - continue; | |
| 825 | - } | |
| 826 | - | |
| 827 | - // 不改变当前班次的行驶时间,修正停站时间和下一个班次的发车时间 | |
| 828 | - iBcStopTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m"); | |
| 829 | - if (iBcStopTime < 0) { | |
| 830 | - // 当前班次使用最小停站时间 | |
| 831 | - oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp())); | |
| 832 | - oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime); | |
| 833 | - | |
| 834 | - } else { | |
| 835 | - if (iBcStopTime == oBc.getStopTime() + oBc.fnGetEatTime()) { | |
| 836 | - // 停站时间一致,没有问题 | |
| 837 | - | |
| 838 | - | |
| 839 | - } else { | |
| 840 | - // TODO:当前班次使用最小停站时间 | |
| 841 | - oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp())); | |
| 842 | - oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime); | |
| 843 | - | |
| 844 | - } | |
| 845 | - } | |
| 846 | - | |
| 847 | - iBcIndex = iBcIndex == 0 ? 1 : 0; | |
| 848 | - iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex; | |
| 849 | - } | |
| 850 | - | |
| 851 | - this.getBc(iQIndex, iBcIndex).setStopTime(0); | |
| 852 | - } | |
| 853 | - | |
| 854 | - | |
| 855 | -}; | |
| 856 | - | |
| 857 | -/** | |
| 858 | - * 返回指定班次的上一个班次。 | |
| 859 | - * @param oBc {moment} 指定班次 | |
| 860 | - * @returns {object} 上一个班次,如果没有,返回false | |
| 861 | - */ | |
| 862 | -InternalLpObj.prototype.getPreBc = function(oBc) { | |
| 863 | - // 获取车次链个数 | |
| 864 | - var iBcChainCount = this.fnGetBcChainCount(); | |
| 865 | - | |
| 866 | - var i; | |
| 867 | - var j; | |
| 868 | - var oBcIndex; | |
| 869 | - var iQIndex; | |
| 870 | - var iBcIndex; | |
| 871 | - var iBcCount; | |
| 872 | - var _oPreBc; | |
| 873 | - var _bFindCurrentBc = false; | |
| 874 | - | |
| 875 | - for (i = 0; i < iBcChainCount; i++) { | |
| 876 | - oBcIndex = this.fnGetBcChainInfo(i); | |
| 877 | - iQIndex = oBcIndex["s_q"]; | |
| 878 | - iBcIndex = oBcIndex["s_b"]; | |
| 879 | - iBcCount = oBcIndex["bcount"]; | |
| 880 | - | |
| 881 | - for (j = 0; j < iBcCount - 1; j++) { | |
| 882 | - if (oBc.getFcTimeObj().format("HH:mm") == | |
| 883 | - this.getBc(iQIndex, iBcIndex).getFcTimeObj().format("HH:mm")) { | |
| 884 | - _bFindCurrentBc = true; | |
| 885 | - break; | |
| 886 | - } | |
| 887 | - | |
| 888 | - // 进入到下一圈 | |
| 889 | - iBcIndex = iBcIndex == 0 ? 1 : 0; | |
| 890 | - iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex; | |
| 891 | - } | |
| 892 | - | |
| 893 | - if (_bFindCurrentBc) { | |
| 894 | - if (iQIndex == oBcIndex["s_q"] && iBcIndex == oBcIndex["s_q"]) { // 第一个班次 | |
| 895 | - break; | |
| 896 | - } else { | |
| 897 | - _oPreBc = this.getBc( | |
| 898 | - iBcIndex == 0 ? iQIndex - 1 : iQIndex, | |
| 899 | - iBcIndex == 0 ? 1 : 0); | |
| 900 | - } | |
| 901 | - } | |
| 902 | - | |
| 903 | - } | |
| 904 | - | |
| 905 | - return _oPreBc || false; | |
| 906 | - | |
| 907 | -}; | |
| 908 | - | |
| 909 | -/** | |
| 910 | - * 通过修改layover时间,修正班次的发车,到达时间。 | |
| 911 | - * 如果layover时间不符合范围要求,修改成平均时间。 | |
| 912 | - * @param oParam {ParameterObj} 参数对象 | |
| 913 | - */ | |
| 914 | -InternalLpObj.prototype.fnAdjustBcTime_layover = function(oParam) { | |
| 915 | - // 获取车次链个数(连班路牌1个,分班路牌2个) | |
| 916 | - var iBlockCount = this.fnGetBcChainCount(); | |
| 917 | - | |
| 918 | - var i; | |
| 919 | - var j; | |
| 920 | - var aTrip; // 每个block关联的trip列表 | |
| 921 | - var trip; // 当前班次 | |
| 922 | - var nextTrip; // 下一个班次 | |
| 923 | - var layOverTime; | |
| 924 | - var aLayOverTimeRange; | |
| 925 | - | |
| 926 | - var oBcIndex; | |
| 927 | - var iQIndex; // block开始第几圈缩影 | |
| 928 | - var iBcIndex; // block开始第几个班次 | |
| 929 | - var iBcCount; // block的trip数目 | |
| 930 | - | |
| 931 | - | |
| 932 | - for (i = 0; i < iBlockCount; i++) { | |
| 933 | - // 获取block关联的trip列表 | |
| 934 | - oBcIndex = this.fnGetBcChainInfo(i); | |
| 935 | - iQIndex = oBcIndex["s_q"]; | |
| 936 | - iBcIndex = oBcIndex["s_b"]; | |
| 937 | - iBcCount = oBcIndex["bcount"]; | |
| 938 | - | |
| 939 | - aTrip = []; | |
| 940 | - for (j = 0; j < iBcCount; j++) { | |
| 941 | - aTrip.push(this.getBc(iQIndex, iBcIndex)); | |
| 942 | - iBcIndex = iBcIndex == 0 ? 1 : 0; | |
| 943 | - iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex; | |
| 944 | - } | |
| 945 | - | |
| 946 | - if (aTrip.length < 2) { | |
| 947 | - // 两个trip一起处理,只有1个trip的block不处理 | |
| 948 | - continue; | |
| 949 | - } | |
| 950 | - // 迭代block,处理trip的发车,到达,停站时间 | |
| 951 | - for (j = 0; j < aTrip.length - 1; j++) { | |
| 952 | - trip = aTrip[j]; | |
| 953 | - nextTrip = aTrip[j + 1]; | |
| 954 | - | |
| 955 | - if (trip.fnIsFirstBc() && nextTrip.fnIsFirstBc()) { | |
| 956 | - // 如果两个方向的首班车都在一个block上 | |
| 957 | - // 则停站时间不考虑范围,直接发车时间-到达时间 | |
| 958 | - layOverTime = nextTrip.getFcTimeObj().diff(trip.getArrTimeObj(), "m"); | |
| 959 | - trip.setStopTime(layOverTime); | |
| 960 | - continue; | |
| 961 | - } | |
| 962 | - | |
| 963 | - //------------- 吃饭班次处理 -----------// | |
| 964 | - // 获取当前trip的layover的范围 | |
| 965 | - aLayOverTimeRange = oParam.calcuTripLayoverTimeRange( | |
| 966 | - trip.getArrTimeObj(), trip.isUp(), trip.getBcTime() | |
| 967 | - ); | |
| 968 | - // 重新计算当前班次layover时间 | |
| 969 | - layOverTime = nextTrip.getFcTimeObj().diff(trip.getArrTimeObj(), "m"); | |
| 970 | - if (trip.fnGetEatTime() > 0) { | |
| 971 | - // 如果当前班次layover是要吃饭的 | |
| 972 | - // 则停站时间没有,变成吃饭时间 | |
| 973 | - trip.setStopTime(0); | |
| 974 | - // 修改下一个班次的发车时间,到达时间 | |
| 975 | - nextTrip.setFcTimeObj(oParam.addMinute( | |
| 976 | - trip.getArrTimeObj(), | |
| 977 | - trip.fnGetEatTime()) | |
| 978 | - ); | |
| 979 | - nextTrip.setBcTime(oParam.calcuTravelTime(nextTrip.getFcTimeObj(), nextTrip.isUp())); | |
| 980 | - nextTrip.setArrTimeObj(oParam.addMinute(nextTrip.getFcTimeObj(), nextTrip.getBcTime())); | |
| 981 | - continue; | |
| 982 | - } | |
| 983 | - | |
| 984 | - //------------- 正常班次处理 -----------// | |
| 985 | - if (layOverTime < aLayOverTimeRange[0] || layOverTime > aLayOverTimeRange[1]) { | |
| 986 | - // 如果layover时间在范围之外,使用平均值 | |
| 987 | - layOverTime = oParam.fnCalcuFixedStopNumber( | |
| 988 | - trip.getArrTimeObj(), | |
| 989 | - trip.isUp(), | |
| 990 | - oParam.calcuTravelTime( | |
| 991 | - trip.getFcTimeObj(), | |
| 992 | - trip.isUp()) | |
| 993 | - ); | |
| 994 | - | |
| 995 | - trip.setStopTime(layOverTime); | |
| 996 | - nextTrip.setFcTimeObj(oParam.addMinute( | |
| 997 | - trip.getArrTimeObj(), | |
| 998 | - trip.getStopTime()) | |
| 999 | - ); | |
| 1000 | - nextTrip.setBcTime(oParam.calcuTravelTime(nextTrip.getFcTimeObj(), nextTrip.isUp())); | |
| 1001 | - nextTrip.setArrTimeObj(oParam.addMinute(nextTrip.getFcTimeObj(), nextTrip.getBcTime())); | |
| 1002 | - } | |
| 1003 | - } | |
| 1004 | - // 最后一个trip的layover时间为0 | |
| 1005 | - aTrip[j].setStopTime(0); | |
| 1006 | - | |
| 1007 | - } | |
| 1008 | -}; | |
| 1009 | - | |
| 1010 | -// TODO | |
| 1011 | - | |
| 1012 | -/** | |
| 1013 | - * | |
| 1014 | - * | |
| 1015 | - */ | |
| 1016 | -InternalLpObj.prototype.calcuLpBx = function() { | |
| 1017 | - | |
| 1018 | -}; | |
| 1019 | - | |
| 1 | +/** | |
| 2 | + * 内部路牌对象。 | |
| 3 | + * @constructor | |
| 4 | + */ | |
| 5 | +var InternalLpObj = function( | |
| 6 | + orilpObj, // 原始路牌对象 | |
| 7 | + qCount, // 总共多少圈 | |
| 8 | + isUp // 圈是以上行开始还是下行开始 | |
| 9 | +) { | |
| 10 | + // TODO:原始路牌对象(这个路牌是对接外部gantt图像,以后有机会改了) | |
| 11 | + this._$$_orign_lp_obj = orilpObj; | |
| 12 | + | |
| 13 | + this._$_isUp = isUp; | |
| 14 | + | |
| 15 | + // 路牌的圈数,注意每个路牌的圈数都是一致的, | |
| 16 | + // 但并不是每一圈都有值 | |
| 17 | + // 第1圈从上标线开始 | |
| 18 | + // 第0圈表示中标线的第一个班次组成的半圈 | |
| 19 | + // 有多少圈根据最终迭代的结果来看 | |
| 20 | + this._$_qCount = qCount; | |
| 21 | + // 保存的是 InternalGroupBcObj 对象 | |
| 22 | + this._$_groupBcArray = new Array(qCount); | |
| 23 | + | |
| 24 | + var i; | |
| 25 | + for (i = 0; i < this._$_qCount; i++) { | |
| 26 | + this._$_groupBcArray[i] = new InternalGroupObj( | |
| 27 | + this, this._$_isUp, undefined, undefined); | |
| 28 | + } | |
| 29 | + | |
| 30 | + // 距离上一个路牌的最小发车间隔时间 | |
| 31 | + // 用于纵向添加班次的时候使用 | |
| 32 | + // 默认第一个路牌为0 | |
| 33 | + this._$_minVerticalIntervalTime = 0; | |
| 34 | + | |
| 35 | + // 详细记录每圈每个方向上的发车间隔时间 | |
| 36 | + // 第一维度表示圈数,第二维度表示第一个方向,第二个方向 | |
| 37 | + // 第一个方向是否上行由 _$_isUp 决定 | |
| 38 | + // 这里的间隔表示下一个路牌上的班次距离本路牌的班次发车时间间隔 | |
| 39 | + // 如果当前是最后一个路牌,表示第一个路牌的下一圈同方向班次距离本班次的间隔 | |
| 40 | + this._$_aVerticalIntervalTime = new Array(this._$_qCount); | |
| 41 | + for (i = 0; i < this._$_aVerticalIntervalTime.length; i++) { | |
| 42 | + this._$_aVerticalIntervalTime[i] = new Array(2); | |
| 43 | + } | |
| 44 | + | |
| 45 | + // 班型的相关变量 | |
| 46 | + this._$_bx_isLb = false; // 是否连班 | |
| 47 | + this._$_bx_isfb = false; // 是否分班 | |
| 48 | + this._$_bx_isfb_5_2 = false; // 是否5休2分班 | |
| 49 | + this._$_bx_desc; // 班型描述(默认为路牌编号) | |
| 50 | + | |
| 51 | + // 其他班次(进出场,例包,吃饭等),TODO:以后再拆 | |
| 52 | + this._$_other_bc_array = []; | |
| 53 | + | |
| 54 | + // TODO: | |
| 55 | + | |
| 56 | +}; | |
| 57 | + | |
| 58 | +//------------------- get/set 方法 -------------------// | |
| 59 | + | |
| 60 | +InternalLpObj.prototype.getOtherBcArray = function() { | |
| 61 | + return this._$_other_bc_array; | |
| 62 | +}; | |
| 63 | +InternalLpObj.prototype.addOtherBcArray = function(ba) { | |
| 64 | + this._$_other_bc_array = this._$_other_bc_array.concat(ba); | |
| 65 | +}; | |
| 66 | + | |
| 67 | +/** | |
| 68 | + * 获取圈 | |
| 69 | + * @param qIndex 圈index | |
| 70 | + */ | |
| 71 | +InternalLpObj.prototype.getGroup = function(qIndex) { | |
| 72 | + return this._$_groupBcArray[qIndex]; | |
| 73 | +}; | |
| 74 | + | |
| 75 | +/** | |
| 76 | + * 获取路牌圈数。 | |
| 77 | + * @returns {*} | |
| 78 | + */ | |
| 79 | +InternalLpObj.prototype.fnGetGroupCount = function() { | |
| 80 | + return this._$_qCount; | |
| 81 | +}; | |
| 82 | + | |
| 83 | +/** | |
| 84 | + * 是否上行。 | |
| 85 | + * @returns boolean | |
| 86 | + */ | |
| 87 | +InternalLpObj.prototype.isUp = function() { | |
| 88 | + return this._$_isUp; | |
| 89 | +}; | |
| 90 | + | |
| 91 | +/** | |
| 92 | + * 获取班次。 | |
| 93 | + * @param qIndex 第几圈 | |
| 94 | + * @param bcIndex 第几个班次 | |
| 95 | + */ | |
| 96 | +InternalLpObj.prototype.getBc = function(qIndex, bcIndex) { | |
| 97 | + var group = this._$_groupBcArray[qIndex]; | |
| 98 | + var bc; | |
| 99 | + if (bcIndex == 0) { | |
| 100 | + bc = group.getBc1(); | |
| 101 | + } else if (bcIndex == 1) { | |
| 102 | + bc = group.getBc2(); | |
| 103 | + } | |
| 104 | + return bc; | |
| 105 | +}; | |
| 106 | + | |
| 107 | +/** | |
| 108 | + * 在具体位置设置班次。 | |
| 109 | + * @param qIndex 第几圈 | |
| 110 | + * @param bcIndex 第几个班次 | |
| 111 | + * @param bc 班次对象 | |
| 112 | + */ | |
| 113 | +InternalLpObj.prototype.setBc = function(qIndex, bcIndex, bc) { | |
| 114 | + var group = this._$_groupBcArray[qIndex]; | |
| 115 | + if (bcIndex == 0) { | |
| 116 | + group.setBc1(bc); | |
| 117 | + bc.setGroup(group); | |
| 118 | + } else if (bcIndex == 1) { | |
| 119 | + group.setBc2(bc); | |
| 120 | + bc.setGroup(group); | |
| 121 | + } | |
| 122 | +}; | |
| 123 | + | |
| 124 | +/** | |
| 125 | + * 设置原始路牌对象。 | |
| 126 | + * @param lpObj 原始路牌对象 | |
| 127 | + */ | |
| 128 | +InternalLpObj.prototype.setLp = function(lpObj) { | |
| 129 | + this._$$_orign_lp_obj = lpObj; | |
| 130 | + var i; | |
| 131 | + var group; | |
| 132 | + for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 133 | + group = this._$_groupBcArray[i]; | |
| 134 | + if (group) { | |
| 135 | + group.setLp(this); // 圈和班次保存都是 InternalLpObj 对象 | |
| 136 | + } | |
| 137 | + } | |
| 138 | +}; | |
| 139 | + | |
| 140 | +InternalLpObj.prototype.getLpNo = function() { | |
| 141 | + return this._$$_orign_lp_obj.lpNo; | |
| 142 | +}; | |
| 143 | +InternalLpObj.prototype.getLpName = function() { | |
| 144 | + return this._$$_orign_lp_obj.lpName; | |
| 145 | +}; | |
| 146 | +InternalLpObj.prototype.setBxFb5_2 = function(fb) { | |
| 147 | + this._$_bx_isfb_5_2 = fb; | |
| 148 | +}; | |
| 149 | +InternalLpObj.prototype.isBxFb5_2 = function() { | |
| 150 | + return this._$_bx_isfb_5_2; | |
| 151 | +}; | |
| 152 | +InternalLpObj.prototype.setBxLb = function(lb) { | |
| 153 | + this._$_bx_isLb = lb; | |
| 154 | +}; | |
| 155 | +InternalLpObj.prototype.isBxLb = function() { | |
| 156 | + return this._$_bx_isLb; | |
| 157 | +}; | |
| 158 | + | |
| 159 | +InternalLpObj.prototype.setBxFb = function(fb) { | |
| 160 | + this._$_bx_isfb = fb; | |
| 161 | +}; | |
| 162 | +InternalLpObj.prototype.isBxFb = function() { | |
| 163 | + return this._$_bx_isfb; | |
| 164 | +}; | |
| 165 | + | |
| 166 | +/** | |
| 167 | + * 设置路牌的班型描述(最终是设置班次的路牌名字)。 | |
| 168 | + * @param desc 描述 | |
| 169 | + */ | |
| 170 | +InternalLpObj.prototype.setBxDesc = function(desc) { | |
| 171 | + // 最终原始路牌的名字 | |
| 172 | + this._$$_orign_lp_obj.lpName = desc + "_" + this._$$_orign_lp_obj.lpNo; | |
| 173 | + // 内部对象的班型描述 | |
| 174 | + this._$_bx_desc = desc; | |
| 175 | +}; | |
| 176 | +/** | |
| 177 | + * 获取版型描述 | |
| 178 | + * @returns string | |
| 179 | + */ | |
| 180 | +InternalLpObj.prototype.getBxDesc = function() { | |
| 181 | + return this._$_bx_desc; | |
| 182 | +}; | |
| 183 | + | |
| 184 | +/** | |
| 185 | + * 设置纵向最小发车间隔时间。 | |
| 186 | + * @param v | |
| 187 | + */ | |
| 188 | +InternalLpObj.prototype.setVerticalMinIntervalTime = function(v) { | |
| 189 | + // 第一个路牌,都为0 | |
| 190 | + this._$_minVerticalIntervalTime = v; | |
| 191 | +}; | |
| 192 | +/** | |
| 193 | + * 获取纵向最小发车间隔时间。 | |
| 194 | + * @returns {number|*} | |
| 195 | + */ | |
| 196 | +InternalLpObj.prototype.getVerticalMinIntervalTime = function() { | |
| 197 | + return this._$_minVerticalIntervalTime; | |
| 198 | +}; | |
| 199 | + | |
| 200 | +/** | |
| 201 | + * 设置纵向发车间隔。 | |
| 202 | + * @param iQindex 圈index | |
| 203 | + * @param iBindex 班次index | |
| 204 | + * @param iTime 间隔时间 | |
| 205 | + */ | |
| 206 | +InternalLpObj.prototype.fnSetVerticalIntervalTime = function(iQindex, iBindex, iTime) { | |
| 207 | + this._$_aVerticalIntervalTime[iQindex][iBindex] = iTime; | |
| 208 | +}; | |
| 209 | + | |
| 210 | +/** | |
| 211 | + * 返回纵向发车间隔。 | |
| 212 | + * @param iQindex 圈index | |
| 213 | + * @param iBindex 班次index | |
| 214 | + */ | |
| 215 | +InternalLpObj.prototype.fnGetVerticalIntervalTime = function(iQindex, iBindex) { | |
| 216 | + return this._$_aVerticalIntervalTime[iQindex][iBindex]; | |
| 217 | +}; | |
| 218 | + | |
| 219 | +//-------------------- 班次操作方法(查询,统计,删除) -----------------------// | |
| 220 | + | |
| 221 | +/** | |
| 222 | + * 返回总共班次数。 | |
| 223 | + */ | |
| 224 | +InternalLpObj.prototype.getBcCount = function() { | |
| 225 | + var i; | |
| 226 | + var group; | |
| 227 | + var bccount = 0; | |
| 228 | + for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 229 | + group = this._$_groupBcArray[i]; | |
| 230 | + if (group) { | |
| 231 | + if (group.getBc1()) { | |
| 232 | + bccount += 1; | |
| 233 | + } | |
| 234 | + if (group.getBc2()) { | |
| 235 | + bccount += 1; | |
| 236 | + } | |
| 237 | + } | |
| 238 | + } | |
| 239 | + | |
| 240 | + return bccount; | |
| 241 | +}; | |
| 242 | + | |
| 243 | +/** | |
| 244 | + * 返回班次列表,过滤空的班次,将所有存在的班次连成连续的对象数组返回。 | |
| 245 | + * @returns arrays (InternalBcObj) | |
| 246 | + */ | |
| 247 | +InternalLpObj.prototype.getBcArray = function() { | |
| 248 | + var bcArray = []; | |
| 249 | + var i; | |
| 250 | + var group; | |
| 251 | + for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 252 | + group = this._$_groupBcArray[i]; | |
| 253 | + if (group) { | |
| 254 | + group.getBc1() ? bcArray.push(group.getBc1()) : ""; | |
| 255 | + group.getBc2() ? bcArray.push(group.getBc2()) : ""; | |
| 256 | + } | |
| 257 | + } | |
| 258 | + | |
| 259 | + return bcArray; | |
| 260 | +}; | |
| 261 | + | |
| 262 | +/** | |
| 263 | + * 获取最小(最早)班次对象。 | |
| 264 | + * @returns [{圈index},{班次index}] | |
| 265 | + */ | |
| 266 | +InternalLpObj.prototype.getMinBcObjPosition = function() { | |
| 267 | + var i; | |
| 268 | + var bIndex = []; | |
| 269 | + for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 270 | + if (this._$_groupBcArray[i].getBc1()) { | |
| 271 | + bIndex.push(i); | |
| 272 | + bIndex.push(0); | |
| 273 | + break; | |
| 274 | + } | |
| 275 | + if (this._$_groupBcArray[i].getBc2()) { | |
| 276 | + bIndex.push(i); | |
| 277 | + bIndex.push(1); | |
| 278 | + break; | |
| 279 | + } | |
| 280 | + } | |
| 281 | + return bIndex; | |
| 282 | +}; | |
| 283 | + | |
| 284 | +/** | |
| 285 | + * 获取最大(最晚)班次对象。 | |
| 286 | + * @returns [{圈index},{班次index}] | |
| 287 | + */ | |
| 288 | +InternalLpObj.prototype.getMaxBcObjPosition = function() { | |
| 289 | + var i; | |
| 290 | + var bIndex = []; | |
| 291 | + for (i = this._$_groupBcArray.length - 1; i >= 0; i--) { | |
| 292 | + if (this._$_groupBcArray[i].getBc2()) { | |
| 293 | + bIndex.push(i); | |
| 294 | + bIndex.push(1); | |
| 295 | + break; | |
| 296 | + } | |
| 297 | + if (this._$_groupBcArray[i].getBc1()) { | |
| 298 | + bIndex.push(i); | |
| 299 | + bIndex.push(0); | |
| 300 | + break; | |
| 301 | + } | |
| 302 | + } | |
| 303 | + return bIndex; | |
| 304 | +}; | |
| 305 | + | |
| 306 | +InternalLpObj.prototype.getMinBcObj = function() { | |
| 307 | + var i; | |
| 308 | + var bcObj; | |
| 309 | + for (i = 0; i < this._$_groupBcArray.length; i++) { | |
| 310 | + bcObj = this._$_groupBcArray[i].getBc1(); | |
| 311 | + if (bcObj) { | |
| 312 | + break; | |
| 313 | + } | |
| 314 | + bcObj = this._$_groupBcArray[i].getBc2(); | |
| 315 | + if (bcObj) { | |
| 316 | + break; | |
| 317 | + } | |
| 318 | + } | |
| 319 | + return bcObj; | |
| 320 | +}; | |
| 321 | +InternalLpObj.prototype.getMaxBcObj = function() { | |
| 322 | + var i; | |
| 323 | + var bcObj; | |
| 324 | + for (i = this._$_groupBcArray.length - 1; i >= 0; i--) { | |
| 325 | + bcObj = this._$_groupBcArray[i].getBc2(); | |
| 326 | + if (bcObj) { | |
| 327 | + break; | |
| 328 | + } | |
| 329 | + bcObj = this._$_groupBcArray[i].getBc1(); | |
| 330 | + if (bcObj) { | |
| 331 | + break; | |
| 332 | + } | |
| 333 | + } | |
| 334 | + return bcObj; | |
| 335 | +}; | |
| 336 | + | |
| 337 | +/** | |
| 338 | + * 获取车次链信息。 | |
| 339 | + * @param num 第几个车次链 | |
| 340 | + * @returns object {s_q: {开始圈索引},s_b : {开始班次索引},e_q : {结束圈索引},e_b : {结束班次索引}, bcount : {班次数}} | |
| 341 | + */ | |
| 342 | +InternalLpObj.prototype.fnGetBcChainInfo = function(num) { | |
| 343 | + // 计算总的车次链信息 | |
| 344 | + var aChainInfo = []; | |
| 345 | + var oChainInfo; | |
| 346 | + var aBcIndex = this.getMinBcObjPosition(); | |
| 347 | + var oBc; | |
| 348 | + var iQIndex; | |
| 349 | + var iBcIndex; | |
| 350 | + var i; | |
| 351 | + var bFlag; | |
| 352 | + | |
| 353 | + var iBcount = 0; | |
| 354 | + | |
| 355 | + if (aBcIndex.length == 2) { | |
| 356 | + iBcount = 1; | |
| 357 | + oChainInfo = {s_q : aBcIndex[0], s_b : aBcIndex[1], e_q : aBcIndex[0], e_b : aBcIndex[1], bcount: 1}; | |
| 358 | + aChainInfo.push(oChainInfo); | |
| 359 | + bFlag = true; | |
| 360 | + | |
| 361 | + // 下一个班次的索引 | |
| 362 | + iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1; | |
| 363 | + iBcIndex = aBcIndex[1] == 0 ? 1 : 0; | |
| 364 | + | |
| 365 | + for (i = iQIndex; i < this._$_qCount; i++) { | |
| 366 | + while (iBcIndex <= 1) { | |
| 367 | + oBc = this.getBc(i, iBcIndex); | |
| 368 | + if (!oBc) { | |
| 369 | + if (bFlag) { | |
| 370 | + // 车次链结尾是这个班次的前一个班次 | |
| 371 | + oChainInfo.e_q = iBcIndex == 0 ? i - 1 : i; | |
| 372 | + oChainInfo.e_b = iBcIndex == 0 ? 1 : 0; | |
| 373 | + oChainInfo.bcount = iBcount; | |
| 374 | + } | |
| 375 | + | |
| 376 | + bFlag = false; | |
| 377 | + } else { | |
| 378 | + if (bFlag) { | |
| 379 | + iBcount ++; | |
| 380 | + oChainInfo.bcount = iBcount; | |
| 381 | + } else { | |
| 382 | + // 下一个车次链开始 | |
| 383 | + iBcount = 1; | |
| 384 | + oChainInfo = {s_q : i, s_b : iBcIndex, e_q : i, e_b : iBcIndex, bcount: 1}; | |
| 385 | + aChainInfo.push(oChainInfo); | |
| 386 | + bFlag = true; | |
| 387 | + } | |
| 388 | + } | |
| 389 | + | |
| 390 | + | |
| 391 | + iBcIndex ++; | |
| 392 | + } | |
| 393 | + iBcIndex = 0; | |
| 394 | + } | |
| 395 | + | |
| 396 | + } | |
| 397 | + | |
| 398 | + return aChainInfo[num]; | |
| 399 | +}; | |
| 400 | + | |
| 401 | +/** | |
| 402 | + * 获取车次链的个数。 | |
| 403 | + * @returns int | |
| 404 | + */ | |
| 405 | +InternalLpObj.prototype.fnGetBcChainCount = function() { | |
| 406 | + var iChainCount = 0; | |
| 407 | + var aBcIndex = this.getMinBcObjPosition(); | |
| 408 | + | |
| 409 | + var oBc; | |
| 410 | + var iQIndex; | |
| 411 | + var iBcIndex; | |
| 412 | + var i; | |
| 413 | + var bFlag; | |
| 414 | + | |
| 415 | + if (aBcIndex.length == 2) { | |
| 416 | + iChainCount = 1; | |
| 417 | + bFlag = true; | |
| 418 | + | |
| 419 | + // 下一个班次的索引 | |
| 420 | + iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1; | |
| 421 | + iBcIndex = aBcIndex[1] == 0 ? 1 : 0; | |
| 422 | + | |
| 423 | + for (i = iQIndex; i < this._$_qCount; i++) { | |
| 424 | + while (iBcIndex <= 1) { | |
| 425 | + oBc = this.getBc(i, iBcIndex); | |
| 426 | + if (!oBc) { | |
| 427 | + bFlag = false; | |
| 428 | + } else { | |
| 429 | + if (bFlag) { | |
| 430 | + | |
| 431 | + } else { | |
| 432 | + iChainCount ++; | |
| 433 | + bFlag = true; | |
| 434 | + } | |
| 435 | + } | |
| 436 | + | |
| 437 | + | |
| 438 | + iBcIndex ++; | |
| 439 | + } | |
| 440 | + iBcIndex = 0; | |
| 441 | + } | |
| 442 | + | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + return iChainCount; | |
| 447 | +}; | |
| 448 | + | |
| 449 | +/** | |
| 450 | + * 在具体位置移除班次。 | |
| 451 | + * @param qIndex 第几圈 | |
| 452 | + * @param bcIndex 第几个班次 | |
| 453 | + */ | |
| 454 | +InternalLpObj.prototype.removeBc = function(qIndex, bcIndex) { | |
| 455 | + var group = this._$_groupBcArray[qIndex]; | |
| 456 | + if (bcIndex == 0) { | |
| 457 | + group.removeBc1(); | |
| 458 | + } else if (bcIndex == 1) { | |
| 459 | + group.removeBc2(); | |
| 460 | + } | |
| 461 | +}; | |
| 462 | + | |
| 463 | +/** | |
| 464 | + * 使用指定时间匹配返回离之最近的第几圈第几个班次, | |
| 465 | + * 使用时间差的绝度值,比较,取最小的 | |
| 466 | + * 如果有两个一样的时间差,取比fctime大的时间 | |
| 467 | + * @param fctime moment 比较用时间 | |
| 468 | + * @param groupArray 圈数组 | |
| 469 | + * @param hasUp boolean 计算上行班次 | |
| 470 | + * @param hasDown boolean 计算下行班次 | |
| 471 | + * @returns [{第几圈},{第几个班次}] | |
| 472 | + */ | |
| 473 | +InternalLpObj.prototype.fnGetQBcIndexWithFcTimeFromGroupArray = function( | |
| 474 | + fctime, groupArray, hasUp, hasDown | |
| 475 | +) { | |
| 476 | + var i; | |
| 477 | + var timediff; // 时间差取绝对值 | |
| 478 | + var qIndex; | |
| 479 | + var bcIndex; | |
| 480 | + | |
| 481 | + var group; | |
| 482 | + var bc1time; | |
| 483 | + var bc2time; | |
| 484 | + | |
| 485 | + var tempdiff; | |
| 486 | + | |
| 487 | + console.log("比较时间=" + fctime.format("HH:mm")); | |
| 488 | + | |
| 489 | + var oBc; | |
| 490 | + | |
| 491 | + for (i = 0; i < this._$_qCount; i++) { | |
| 492 | + group = groupArray[i]; | |
| 493 | + if (group) { | |
| 494 | + oBc = group.getBc1(); | |
| 495 | + | |
| 496 | + if (oBc != undefined && ((hasUp && hasDown) || (hasUp && (oBc.isUp() == hasUp)) || (hasDown && (!oBc.isUp() == hasDown)))) { | |
| 497 | + bc1time = group.getBc1().getFcTimeObj(); | |
| 498 | + console.log("bc1time=" + bc1time.format("HH:mm") + " tempdiff=" + tempdiff); | |
| 499 | + tempdiff = Math.abs(bc1time.diff(fctime)); | |
| 500 | + | |
| 501 | + if (!timediff) { | |
| 502 | + timediff = Math.abs(tempdiff); | |
| 503 | + qIndex = i; | |
| 504 | + bcIndex = 0; | |
| 505 | + } else { | |
| 506 | + if (tempdiff < timediff) { | |
| 507 | + timediff = tempdiff; | |
| 508 | + qIndex = i; | |
| 509 | + bcIndex = 0; | |
| 510 | + } if (Math.abs(tempdiff) == timediff) { | |
| 511 | + if (bc1time.isAfter(fctime)) { | |
| 512 | + timediff = tempdiff; | |
| 513 | + qIndex = i; | |
| 514 | + bcIndex = 0; | |
| 515 | + } | |
| 516 | + | |
| 517 | + } | |
| 518 | + } | |
| 519 | + } | |
| 520 | + | |
| 521 | + oBc = group.getBc2(); | |
| 522 | + if (oBc != undefined && ((hasUp && hasDown) || (hasUp && (oBc.isUp() == hasUp)) || (hasDown && (!oBc.isUp() == hasDown)))) { | |
| 523 | + bc2time = group.getBc2().getFcTimeObj(); | |
| 524 | + console.log("bc2time=" + bc2time.format("HH:mm") + " tempdiff=" + tempdiff); | |
| 525 | + tempdiff = Math.abs(bc2time.diff(fctime)); | |
| 526 | + | |
| 527 | + if (!timediff) { | |
| 528 | + timediff = Math.abs(tempdiff); | |
| 529 | + qIndex = i; | |
| 530 | + bcIndex = 1; | |
| 531 | + } else { | |
| 532 | + if (tempdiff < timediff) { | |
| 533 | + timediff = tempdiff; | |
| 534 | + qIndex = i; | |
| 535 | + bcIndex = 1; | |
| 536 | + } if (Math.abs(tempdiff) == timediff) { | |
| 537 | + if (bc2time.isBefore(fctime)) { | |
| 538 | + timediff = tempdiff; | |
| 539 | + qIndex = i; | |
| 540 | + bcIndex = 1; | |
| 541 | + } | |
| 542 | + | |
| 543 | + } | |
| 544 | + } | |
| 545 | + } | |
| 546 | + } | |
| 547 | + } | |
| 548 | + | |
| 549 | + console.log("中标线对应数组索引=" + qIndex); | |
| 550 | + | |
| 551 | + var rst = []; | |
| 552 | + rst.push(qIndex); | |
| 553 | + rst.push(bcIndex); | |
| 554 | + | |
| 555 | + return rst; | |
| 556 | +}; | |
| 557 | + | |
| 558 | +/** | |
| 559 | + * 使用指定时间匹配返回离之最近的第几圈第几个班次, | |
| 560 | + * 使用时间差的绝度值,比较,取最小的 | |
| 561 | + * 如果有两个一样的时间差,取比fctime大的时间 | |
| 562 | + * @param fctime moment 比较用时间 | |
| 563 | + * @param hasUp boolean 计算上行班次 | |
| 564 | + * @param hasDown boolean 计算下行班次 | |
| 565 | + * @returns [{第几圈},{第几个班次}] | |
| 566 | + */ | |
| 567 | +InternalLpObj.prototype.getQBcIndexWithFcTime = function( | |
| 568 | + fctime, hasUp, hasDown | |
| 569 | +) { | |
| 570 | + return this.fnGetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray, hasUp, hasDown); | |
| 571 | +}; | |
| 572 | + | |
| 573 | +//---------------------- 内部数据初始化方法(不同于构造函数)---------------------// | |
| 574 | + | |
| 575 | +/** | |
| 576 | + * 从指定开始时间到结束时间创建不间断班次(连班),并初始化路牌 | |
| 577 | + * 注意,之前有班次会删除后再创建。 | |
| 578 | + * @param startTime 开始时间 | |
| 579 | + * @param endTime 结束时间 | |
| 580 | + * @param isUp 第一个班次是上行还是下行 | |
| 581 | + * @param fromQ 从第几圈开始加入 | |
| 582 | + * @param paramObj 参数对象 | |
| 583 | + * @param factory 工厂对象 | |
| 584 | + */ | |
| 585 | +InternalLpObj.prototype.initDataFromTimeToTime = function( | |
| 586 | + startTime, | |
| 587 | + endTime, | |
| 588 | + isUp, | |
| 589 | + fromQ, | |
| 590 | + paramObj, | |
| 591 | + factory) { | |
| 592 | + | |
| 593 | + var bcData = []; // 班次数组 | |
| 594 | + var bcObj; | |
| 595 | + var kssj = startTime; | |
| 596 | + var fcno = 1; // 发车顺序号 | |
| 597 | + var bcCount = 1; // 班次数 | |
| 598 | + do { | |
| 599 | + bcObj = factory.createBcObj( | |
| 600 | + this, "normal", isUp, fcno, kssj, paramObj); // this就是所属路牌对象 | |
| 601 | + bcData.push(bcObj); | |
| 602 | + | |
| 603 | + kssj = paramObj.addMinute(kssj, bcObj.getBcTime() + bcObj.getStopTime()); | |
| 604 | + fcno ++; | |
| 605 | + bcCount ++; | |
| 606 | + isUp = !isUp; | |
| 607 | + } while(kssj.isBefore(endTime)); | |
| 608 | + bcCount--; | |
| 609 | + | |
| 610 | + //console.log("last -1;" + bcData[bcCount -2].getFcTimeObj().format("HH:mm")); | |
| 611 | + //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm")); | |
| 612 | + //console.log("endtime: " + endTime.format("HH:mm")); | |
| 613 | + | |
| 614 | + //if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) { | |
| 615 | + // // 如果最后一个班次的到达时间超过结束时间,也要去除 | |
| 616 | + // bcData.splice(bcCount - 1, 1); | |
| 617 | + //} | |
| 618 | + | |
| 619 | + this._initDataFromLbBcArray(bcData, fromQ); | |
| 620 | + | |
| 621 | +}; | |
| 622 | + | |
| 623 | +/** | |
| 624 | + * 使用连班的班次数组初始化路牌(相应的圈会被覆盖)。 | |
| 625 | + * @param bcArray 连班班次数组 | |
| 626 | + * @param fromQ 从第几圈开始加入 | |
| 627 | + */ | |
| 628 | +InternalLpObj.prototype._initDataFromLbBcArray = function( | |
| 629 | + bcArray, | |
| 630 | + fromQ | |
| 631 | +) { | |
| 632 | + var _bc1Obj; | |
| 633 | + var _bc2Obj; | |
| 634 | + var _qObj; | |
| 635 | + | |
| 636 | + // 第一班次是上行还是下行 | |
| 637 | + var isUp = bcArray[0].isUp(); | |
| 638 | + | |
| 639 | + if (bcArray.length > 0 && fromQ < this._$_qCount) { | |
| 640 | + // 构造圈数 | |
| 641 | + if (isUp != this._$_isUp) { | |
| 642 | + // 如果方向不一致,意味着第一个班次是半圈 | |
| 643 | + // 加半圈,并加在bc2上 | |
| 644 | + _bc2Obj = bcArray.slice(0, 1)[0]; | |
| 645 | + _qObj = new InternalGroupObj( | |
| 646 | + this, | |
| 647 | + this._$_isUp, | |
| 648 | + undefined, | |
| 649 | + _bc2Obj | |
| 650 | + ); | |
| 651 | + _bc2Obj.setGroup(_qObj); | |
| 652 | + this._$_groupBcArray[fromQ] = _qObj; | |
| 653 | + | |
| 654 | + bcArray.splice(0, 1); | |
| 655 | + fromQ ++; | |
| 656 | + } | |
| 657 | + | |
| 658 | + var qCount1 = Math.floor(bcArray.length / 2); // 需要添加多少圈 | |
| 659 | + var qCount2 = bcArray.length % 2; // 最后是否有半圈 | |
| 660 | + | |
| 661 | + while (fromQ < this._$_qCount) { | |
| 662 | + if (qCount1 > 0) { | |
| 663 | + _bc1Obj = bcArray.slice(0, 1)[0]; | |
| 664 | + _bc2Obj = bcArray.slice(1, 2)[0]; | |
| 665 | + _qObj = new InternalGroupObj( | |
| 666 | + this, | |
| 667 | + this._$_isUp, | |
| 668 | + _bc1Obj, | |
| 669 | + _bc2Obj | |
| 670 | + ); | |
| 671 | + _bc1Obj.setGroup(_qObj); | |
| 672 | + _bc2Obj.setGroup(_qObj); | |
| 673 | + this._$_groupBcArray[fromQ] = _qObj; | |
| 674 | + | |
| 675 | + bcArray.splice(0, 2); | |
| 676 | + qCount1 --; | |
| 677 | + } else if (qCount2 > 0) { | |
| 678 | + // 加半圈,并加在bc1上 | |
| 679 | + _bc1Obj = bcArray.slice(0, 1)[0]; | |
| 680 | + _qObj = new InternalGroupObj( | |
| 681 | + this, | |
| 682 | + this._$_isUp, | |
| 683 | + _bc1Obj, | |
| 684 | + undefined | |
| 685 | + ); | |
| 686 | + _bc1Obj.setGroup(_qObj); | |
| 687 | + this._$_groupBcArray[fromQ] = _qObj; | |
| 688 | + | |
| 689 | + bcArray.splice(0, 1); | |
| 690 | + qCount2 --; | |
| 691 | + } else { | |
| 692 | + break; | |
| 693 | + } | |
| 694 | + | |
| 695 | + fromQ ++; | |
| 696 | + } | |
| 697 | + } | |
| 698 | +}; | |
| 699 | + | |
| 700 | +//-------------------------- 其他方法 ----------------------------// | |
| 701 | + | |
| 702 | +/** | |
| 703 | + * 从指定位置的班次开始,往后所有的班次修正发车时间 | |
| 704 | + * @param groupIndex | |
| 705 | + * @param bcIndex | |
| 706 | + * @param time | |
| 707 | + */ | |
| 708 | +InternalLpObj.prototype.fnAddMinuteToBcFcsj = function(groupIndex, bcIndex, time) { | |
| 709 | + var i; | |
| 710 | + var oCurBc; | |
| 711 | + | |
| 712 | + // 修正之前班次的停站时间 | |
| 713 | + //oCurBc = this.getBc( | |
| 714 | + // bcIndex == 0 ? groupIndex - 1 : groupIndex, | |
| 715 | + // bcIndex == 1 ? 0 : 1 | |
| 716 | + //); | |
| 717 | + //if (oCurBc) { | |
| 718 | + // oCurBc.setStopTime(oCurBc.getStopTime() + time); | |
| 719 | + //} | |
| 720 | + | |
| 721 | + | |
| 722 | + for (i = groupIndex; i < this._$_qCount; i++) { | |
| 723 | + if (bcIndex == 0) { | |
| 724 | + oCurBc = this.getBc(i, 0); | |
| 725 | + if (oCurBc) { | |
| 726 | + oCurBc.addMinuteToFcsj(time); | |
| 727 | + } | |
| 728 | + oCurBc = this.getBc(i, 1); | |
| 729 | + if (oCurBc) { | |
| 730 | + oCurBc.addMinuteToFcsj(time); | |
| 731 | + } | |
| 732 | + | |
| 733 | + } else { | |
| 734 | + oCurBc = this.getBc(i, 1); | |
| 735 | + if (oCurBc) { | |
| 736 | + oCurBc.addMinuteToFcsj(time); | |
| 737 | + } | |
| 738 | + | |
| 739 | + } | |
| 740 | + | |
| 741 | + bcIndex = 0; | |
| 742 | + } | |
| 743 | +}; | |
| 744 | + | |
| 745 | +/** | |
| 746 | + * 在指定位置添加一个吃饭班次。 | |
| 747 | + * 注1:吃饭班次不是普通班次,不记录进圈,记录进_$_other_bc_array | |
| 748 | + * 注2:添加吃饭班次时,会修改之前班次的停战时间,所以导致之后的班次的停战都会发生变化 | |
| 749 | + * @param groupIndex | |
| 750 | + * @param bcIndex | |
| 751 | + * @param factory | |
| 752 | + * @param paramObj | |
| 753 | + * @returns int 相差时间(吃饭时间距离和停站时间相差值) | |
| 754 | + */ | |
| 755 | +InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, paramObj) { | |
| 756 | + var oPreBc; | |
| 757 | + var oEatBc; | |
| 758 | + var iBcModifyTime; | |
| 759 | + | |
| 760 | + if (!this.getBc(groupIndex, bcIndex)) { // | |
| 761 | + return 0; | |
| 762 | + } | |
| 763 | + | |
| 764 | + oPreBc = this.getBc( // 前一个邻接班次 | |
| 765 | + bcIndex == 0 ? groupIndex - 1 : groupIndex, | |
| 766 | + bcIndex == 1 ? 0 : 1); | |
| 767 | + if (oPreBc) { // 存在前一个班次 | |
| 768 | + oEatBc = factory.createBcObj( | |
| 769 | + this, | |
| 770 | + "cf", | |
| 771 | + !oPreBc.isUp(), // 和上一个班次方向相反 | |
| 772 | + 1, | |
| 773 | + paramObj.addMinute(oPreBc.getArrTimeObj(), oPreBc.getStopTime()), // 使用上一个班次的到达时间作为开始时间 | |
| 774 | + paramObj | |
| 775 | + ); | |
| 776 | + | |
| 777 | + //iBcModifyTime = oEatBc.getBcTime() - oPreBc.getStopTime(); // 后续班次要调整的时间 | |
| 778 | + | |
| 779 | + // 修正之后的班次发车时间 | |
| 780 | + // 注意:之后那个班次发车时间就是吃饭班次的到达时间 | |
| 781 | + iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m"); | |
| 782 | + this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime); | |
| 783 | + | |
| 784 | + oPreBc.setStopTime(0); // 不重置停站时间 | |
| 785 | + oPreBc.fnSetEatTime(oEatBc.getBcTime()); | |
| 786 | + | |
| 787 | + //this._$_other_bc_array.push(oEatBc); | |
| 788 | + | |
| 789 | + return iBcModifyTime; | |
| 790 | + } else { | |
| 791 | + return false; | |
| 792 | + } | |
| 793 | + | |
| 794 | +}; | |
| 795 | + | |
| 796 | +/** | |
| 797 | + * 调整路牌的班次,通过调整停站时间,或者班次发车时间,不能让班次的到达时间和下一个班次的发车时间重叠。 | |
| 798 | + * @param iPeakAverStopTime 高峰平均停站时间 | |
| 799 | + * @param iTroughAverStopTime 低谷平均停站时间 | |
| 800 | + * @param oParam 参数对象 | |
| 801 | + */ | |
| 802 | +InternalLpObj.prototype.fnAdjustBcInterval = function(iPeakAverStopTime, iTroughAverStopTime, oParam) { | |
| 803 | + // 获取车次链个数 | |
| 804 | + var iBcChainCount = this.fnGetBcChainCount(); | |
| 805 | + | |
| 806 | + var i; | |
| 807 | + var j; | |
| 808 | + var oBcIndex; | |
| 809 | + var iQIndex; | |
| 810 | + var iBcIndex; | |
| 811 | + var iBcCount; | |
| 812 | + var oBc; | |
| 813 | + var oNextBc; | |
| 814 | + | |
| 815 | + var iBcStopTime; | |
| 816 | + | |
| 817 | + for (i = 0; i < iBcChainCount; i++) { | |
| 818 | + oBcIndex = this.fnGetBcChainInfo(i); | |
| 819 | + iQIndex = oBcIndex["s_q"]; | |
| 820 | + iBcIndex = oBcIndex["s_b"]; | |
| 821 | + iBcCount = oBcIndex["bcount"]; | |
| 822 | + | |
| 823 | + for (j = 0; j < iBcCount - 1; j++) { | |
| 824 | + oBc = this.getBc(iQIndex, iBcIndex); | |
| 825 | + oNextBc = this.getBc( | |
| 826 | + iBcIndex == 0 ? iQIndex : iQIndex + 1, | |
| 827 | + iBcIndex == 0 ? 1 : 0); | |
| 828 | + | |
| 829 | + if (oNextBc.fnIsFirstBc()) { // 如果同一路牌连续2个方向首站班次,都不做处理 | |
| 830 | + continue; | |
| 831 | + } | |
| 832 | + | |
| 833 | + // 不改变当前班次的行驶时间,修正停站时间和下一个班次的发车时间 | |
| 834 | + iBcStopTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m"); | |
| 835 | + if (iBcStopTime < 0) { | |
| 836 | + // 当前班次使用最小停站时间 | |
| 837 | + oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp())); | |
| 838 | + oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime); | |
| 839 | + | |
| 840 | + } else { | |
| 841 | + if (iBcStopTime == oBc.getStopTime() + oBc.fnGetEatTime()) { | |
| 842 | + // 停站时间一致,没有问题 | |
| 843 | + | |
| 844 | + | |
| 845 | + } else { | |
| 846 | + // TODO:当前班次使用最小停站时间 | |
| 847 | + oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp())); | |
| 848 | + oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime); | |
| 849 | + | |
| 850 | + } | |
| 851 | + } | |
| 852 | + | |
| 853 | + iBcIndex = iBcIndex == 0 ? 1 : 0; | |
| 854 | + iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex; | |
| 855 | + } | |
| 856 | + | |
| 857 | + this.getBc(iQIndex, iBcIndex).setStopTime(0); | |
| 858 | + } | |
| 859 | + | |
| 860 | + | |
| 861 | +}; | |
| 862 | + | |
| 863 | +/** | |
| 864 | + * 返回指定班次的上一个班次。 | |
| 865 | + * @param oBc {moment} 指定班次 | |
| 866 | + * @returns {object} 上一个班次,如果没有,返回false | |
| 867 | + */ | |
| 868 | +InternalLpObj.prototype.getPreBc = function(oBc) { | |
| 869 | + // 获取车次链个数 | |
| 870 | + var iBcChainCount = this.fnGetBcChainCount(); | |
| 871 | + | |
| 872 | + var i; | |
| 873 | + var j; | |
| 874 | + var oBcIndex; | |
| 875 | + var iQIndex; | |
| 876 | + var iBcIndex; | |
| 877 | + var iBcCount; | |
| 878 | + var _oPreBc; | |
| 879 | + var _bFindCurrentBc = false; | |
| 880 | + | |
| 881 | + for (i = 0; i < iBcChainCount; i++) { | |
| 882 | + oBcIndex = this.fnGetBcChainInfo(i); | |
| 883 | + iQIndex = oBcIndex["s_q"]; | |
| 884 | + iBcIndex = oBcIndex["s_b"]; | |
| 885 | + iBcCount = oBcIndex["bcount"]; | |
| 886 | + | |
| 887 | + for (j = 0; j < iBcCount - 1; j++) { | |
| 888 | + if (oBc.getFcTimeObj().format("HH:mm") == | |
| 889 | + this.getBc(iQIndex, iBcIndex).getFcTimeObj().format("HH:mm")) { | |
| 890 | + _bFindCurrentBc = true; | |
| 891 | + break; | |
| 892 | + } | |
| 893 | + | |
| 894 | + // 进入到下一圈 | |
| 895 | + iBcIndex = iBcIndex == 0 ? 1 : 0; | |
| 896 | + iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex; | |
| 897 | + } | |
| 898 | + | |
| 899 | + if (_bFindCurrentBc) { | |
| 900 | + if (iQIndex == oBcIndex["s_q"] && iBcIndex == oBcIndex["s_q"]) { // 第一个班次 | |
| 901 | + break; | |
| 902 | + } else { | |
| 903 | + _oPreBc = this.getBc( | |
| 904 | + iBcIndex == 0 ? iQIndex - 1 : iQIndex, | |
| 905 | + iBcIndex == 0 ? 1 : 0); | |
| 906 | + } | |
| 907 | + } | |
| 908 | + | |
| 909 | + } | |
| 910 | + | |
| 911 | + return _oPreBc || false; | |
| 912 | + | |
| 913 | +}; | |
| 914 | + | |
| 915 | +/** | |
| 916 | + * 通过修改layover时间,修正班次的发车,到达时间。 | |
| 917 | + * 如果layover时间不符合范围要求,修改成平均时间。 | |
| 918 | + * @param oParam {ParameterObj} 参数对象 | |
| 919 | + */ | |
| 920 | +InternalLpObj.prototype.fnAdjustBcTime_layover = function(oParam) { | |
| 921 | + // 获取车次链个数(连班路牌1个,分班路牌2个) | |
| 922 | + var iBlockCount = this.fnGetBcChainCount(); | |
| 923 | + | |
| 924 | + var i; | |
| 925 | + var j; | |
| 926 | + var aTrip; // 每个block关联的trip列表 | |
| 927 | + var trip; // 当前班次 | |
| 928 | + var nextTrip; // 下一个班次 | |
| 929 | + var layOverTime; | |
| 930 | + var aLayOverTimeRange; | |
| 931 | + | |
| 932 | + var oBcIndex; | |
| 933 | + var iQIndex; // block开始第几圈缩影 | |
| 934 | + var iBcIndex; // block开始第几个班次 | |
| 935 | + var iBcCount; // block的trip数目 | |
| 936 | + | |
| 937 | + | |
| 938 | + for (i = 0; i < iBlockCount; i++) { | |
| 939 | + // 获取block关联的trip列表 | |
| 940 | + oBcIndex = this.fnGetBcChainInfo(i); | |
| 941 | + iQIndex = oBcIndex["s_q"]; | |
| 942 | + iBcIndex = oBcIndex["s_b"]; | |
| 943 | + iBcCount = oBcIndex["bcount"]; | |
| 944 | + | |
| 945 | + aTrip = []; | |
| 946 | + for (j = 0; j < iBcCount; j++) { | |
| 947 | + aTrip.push(this.getBc(iQIndex, iBcIndex)); | |
| 948 | + iBcIndex = iBcIndex == 0 ? 1 : 0; | |
| 949 | + iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex; | |
| 950 | + } | |
| 951 | + | |
| 952 | + if (aTrip.length < 2) { | |
| 953 | + // 两个trip一起处理,只有1个trip的block不处理 | |
| 954 | + continue; | |
| 955 | + } | |
| 956 | + // 迭代block,处理trip的发车,到达,停站时间 | |
| 957 | + for (j = 0; j < aTrip.length - 1; j++) { | |
| 958 | + trip = aTrip[j]; | |
| 959 | + nextTrip = aTrip[j + 1]; | |
| 960 | + | |
| 961 | + if (trip.fnIsFirstBc() && nextTrip.fnIsFirstBc()) { | |
| 962 | + // 如果两个方向的首班车都在一个block上 | |
| 963 | + // 则停站时间不考虑范围,直接发车时间-到达时间 | |
| 964 | + layOverTime = nextTrip.getFcTimeObj().diff(trip.getArrTimeObj(), "m"); | |
| 965 | + trip.setStopTime(layOverTime); | |
| 966 | + continue; | |
| 967 | + } | |
| 968 | + | |
| 969 | + //------------- 吃饭班次处理 -----------// | |
| 970 | + // 获取当前trip的layover的范围 | |
| 971 | + aLayOverTimeRange = oParam.calcuTripLayoverTimeRange( | |
| 972 | + trip.getArrTimeObj(), trip.isUp(), trip.getBcTime() | |
| 973 | + ); | |
| 974 | + // 重新计算当前班次layover时间 | |
| 975 | + layOverTime = nextTrip.getFcTimeObj().diff(trip.getArrTimeObj(), "m"); | |
| 976 | + if (trip.fnGetEatTime() > 0) { | |
| 977 | + // 如果当前班次layover是要吃饭的 | |
| 978 | + // 则停站时间没有,变成吃饭时间 | |
| 979 | + trip.setStopTime(0); | |
| 980 | + // 修改下一个班次的发车时间,到达时间 | |
| 981 | + nextTrip.setFcTimeObj(oParam.addMinute( | |
| 982 | + trip.getArrTimeObj(), | |
| 983 | + trip.fnGetEatTime()) | |
| 984 | + ); | |
| 985 | + nextTrip.setBcTime(oParam.calcuTravelTime(nextTrip.getFcTimeObj(), nextTrip.isUp())); | |
| 986 | + nextTrip.setArrTimeObj(oParam.addMinute(nextTrip.getFcTimeObj(), nextTrip.getBcTime())); | |
| 987 | + continue; | |
| 988 | + } | |
| 989 | + | |
| 990 | + //------------- 正常班次处理 -----------// | |
| 991 | + if (layOverTime < aLayOverTimeRange[0] || layOverTime > aLayOverTimeRange[1]) { | |
| 992 | + // 如果layover时间在范围之外,使用平均值 | |
| 993 | + layOverTime = oParam.fnCalcuFixedStopNumber( | |
| 994 | + trip.getArrTimeObj(), | |
| 995 | + trip.isUp(), | |
| 996 | + oParam.calcuTravelTime( | |
| 997 | + trip.getFcTimeObj(), | |
| 998 | + trip.isUp()) | |
| 999 | + ); | |
| 1000 | + | |
| 1001 | + trip.setStopTime(layOverTime); | |
| 1002 | + nextTrip.setFcTimeObj(oParam.addMinute( | |
| 1003 | + trip.getArrTimeObj(), | |
| 1004 | + trip.getStopTime()) | |
| 1005 | + ); | |
| 1006 | + nextTrip.setBcTime(oParam.calcuTravelTime(nextTrip.getFcTimeObj(), nextTrip.isUp())); | |
| 1007 | + nextTrip.setArrTimeObj(oParam.addMinute(nextTrip.getFcTimeObj(), nextTrip.getBcTime())); | |
| 1008 | + } | |
| 1009 | + } | |
| 1010 | + // 最后一个trip的layover时间为0 | |
| 1011 | + aTrip[j].setStopTime(0); | |
| 1012 | + | |
| 1013 | + } | |
| 1014 | +}; | |
| 1015 | + | |
| 1016 | +// TODO | |
| 1017 | + | |
| 1018 | +/** | |
| 1019 | + * | |
| 1020 | + * | |
| 1021 | + */ | |
| 1022 | +InternalLpObj.prototype.calcuLpBx = function() { | |
| 1023 | + | |
| 1024 | +}; | |
| 1025 | + | |
| 1026 | + | ... | ... |
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalScheduleObj.js
| ... | ... | @@ -1398,7 +1398,7 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { |
| 1398 | 1398 | var iDEQIndex = aDEIndex[0]; |
| 1399 | 1399 | var iDEBIndex = aDEIndex[1]; |
| 1400 | 1400 | |
| 1401 | - // 注意,本模型只有连班才有吃饭 | |
| 1401 | + // TODO:注意,本模型只有连班才有吃饭 | |
| 1402 | 1402 | |
| 1403 | 1403 | var i; |
| 1404 | 1404 | var oLp; |
| ... | ... | @@ -1415,7 +1415,6 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) { |
| 1415 | 1415 | var j; |
| 1416 | 1416 | for (i = 0; i < aLbIndex.length; i++) { |
| 1417 | 1417 | oLp = _internalLpArray[aLbIndex[i]]; |
| 1418 | - | |
| 1419 | 1418 | // 午饭 |
| 1420 | 1419 | iLTime = oLp.fnAddEatBc(iLEQIndex, iLEBIndex, _factory, _paramObj); |
| 1421 | 1420 | // 晚饭 | ... | ... |
src/main/resources/static/pages/base/timesmodel/js/v2/main_v2.js
| ... | ... | @@ -747,6 +747,41 @@ var Main_v2 = function() { |
| 747 | 747 | |
| 748 | 748 | }; |
| 749 | 749 | |
| 750 | + var __funCalcuExportData_paramInfoList = function() { | |
| 751 | + return [ | |
| 752 | + {'paramItem' : '上行首班时间', 'paramValue' : _paramObj.getUpFirstDTimeObj().format("HH:mm")}, | |
| 753 | + {'paramItem' : '上行末班时间', 'paramValue' : _paramObj.getUpLastDtimeObj().format("HH:mm")}, | |
| 754 | + {'paramItem' : '下行首班时间', 'paramValue' : _paramObj.getDownFirstDTimeObj().format("HH:mm")}, | |
| 755 | + {'paramItem' : '下行末班时间', 'paramValue' : _paramObj.getDownLastDTimeObj().format("HH:mm")}, | |
| 756 | + {'paramItem' : '早高峰开始时间', 'paramValue' : _paramObj.getMPeakStartTimeObj().format("HH:mm")}, | |
| 757 | + {'paramItem' : '早高峰结束时间', 'paramValue' : _paramObj.getMPeakEndTimeObj().format("HH:mm")}, | |
| 758 | + {'paramItem' : '晚高峰开始时间', 'paramValue' : _paramObj.getEPeakStartTimeObj().format("HH:mm")}, | |
| 759 | + {'paramItem' : '晚高峰结束时间', 'paramValue' : _paramObj.getEPeakEndTimeObj().format("HH:mm")}, | |
| 760 | + {'paramItem' : '上行进场时间', 'paramValue' : _paramObj.getUpInTime()}, | |
| 761 | + {'paramItem' : '上行出场时间', 'paramValue' : _paramObj.getUpOutTime()}, | |
| 762 | + {'paramItem' : '下行进场时间', 'paramValue' : _paramObj.getDownInTime()}, | |
| 763 | + {'paramItem' : '下行出场时间', 'paramValue' : _paramObj.getDownOutTime()}, | |
| 764 | + {'paramItem' : '早高峰上行时间', 'paramValue' : _paramObj.getUpMPeakTime()}, | |
| 765 | + {'paramItem' : '早高峰下行时间', 'paramValue' : _paramObj.getDownMPeakTime()}, | |
| 766 | + {'paramItem' : '晚高峰上行时间', 'paramValue' : _paramObj.getUpEPeakTime()}, | |
| 767 | + {'paramItem' : '晚高峰下行时间', 'paramValue' : _paramObj.getDownEPeakTime()}, | |
| 768 | + {'paramItem' : '低谷上行时间', 'paramValue' : _paramObj.getUpTroughTime()}, | |
| 769 | + {'paramItem' : '低谷下行时间', 'paramValue' : _paramObj.getDownTroughTime()}, | |
| 770 | + {'paramItem' : '线路规划类型', 'paramValue' : "双向"}, | |
| 771 | + {'paramItem' : '吃饭地点', 'paramValue' : _paramObj.fnIsEat() ? (_paramObj.fnIsBothEat() ? "上下行" : (_paramObj.fnIsUpEat() ? "上行" : "下行")) : "不吃饭"}, | |
| 772 | + {'paramItem' : '早晚例行保养', 'paramValue' : _paramObj.getLbTime()}, | |
| 773 | + {'paramItem' : '停车场', 'paramValue' : _paramObj.getTccId()}, | |
| 774 | + {'paramItem' : '工作餐午餐时间', 'paramValue' : _paramObj.fnGetLunchTime()}, | |
| 775 | + {'paramItem' : '工作餐晚餐时间', 'paramValue' : _paramObj.fnGetDinnerTime()}, | |
| 776 | + {'paramItem' : '早高峰发车间隔', 'paramValue' : "[" + _paramObj.getMPeakMinFcjx() + "," + _paramObj.getMPeakMaxFcjx() + "]"}, | |
| 777 | + {'paramItem' : '晚高峰发车间隔', 'paramValue' : "[" + _paramObj.getEPeakMinFcjx() + "," + _paramObj.getEPeakMaxFcjx() + "]"}, | |
| 778 | + {'paramItem' : '低谷发车间隔', 'paramValue' : "[" + _paramObj.getTroughMinFcjx() + "," + _paramObj.getTroughMaxFcjx() + "]"}, | |
| 779 | + {'paramItem' : '建议加班路牌数', 'paramValue' : _paramObj.getJBLpes()}, | |
| 780 | + {'paramItem' : '停站类型', 'paramValue' : _paramObj.isTwoWayStop() ? "双向停站" : (_paramObj.isUpOneWayStop() ? "上行主站" : "下行主站") }, | |
| 781 | + {'paramItem' : '建议高峰配车数', 'paramValue' : _paramObj.getAdvicePeakClzs()} | |
| 782 | + ] | |
| 783 | + }; | |
| 784 | + | |
| 750 | 785 | return { |
| 751 | 786 | /** |
| 752 | 787 | * 工厂对象,创建不同的对象。 |
| ... | ... | @@ -829,7 +864,8 @@ var Main_v2 = function() { |
| 829 | 864 | $('.exportAddXls').on('click', function() { |
| 830 | 865 | var aInfos = { |
| 831 | 866 | "lpObjList": _funCalcuExportData_lpObjList(aInternalLpObj), // 路牌班次信息列表 |
| 832 | - "statInfoList": _funCalcuExportData_statInfoList(aInternalLpObj) // 统计项目列表 | |
| 867 | + "statInfoList": _funCalcuExportData_statInfoList(aInternalLpObj), // 统计项目列表 | |
| 868 | + "parameterInfoList" : __funCalcuExportData_paramInfoList() // 参数对象 | |
| 833 | 869 | }; |
| 834 | 870 | |
| 835 | 871 | console.log(aInfos); |
| ... | ... | @@ -862,7 +898,8 @@ var Main_v2 = function() { |
| 862 | 898 | $('.exportAddXlsx').on('click', function() { |
| 863 | 899 | var aInfos = { |
| 864 | 900 | "lpObjList": _funCalcuExportData_lpObjList(aInternalLpObj), // 路牌班次信息列表 |
| 865 | - "statInfoList": _funCalcuExportData_statInfoList(aInternalLpObj) // 统计项目列表 | |
| 901 | + "statInfoList": _funCalcuExportData_statInfoList(aInternalLpObj), // 统计项目列表 | |
| 902 | + "parameterInfoList" : __funCalcuExportData_paramInfoList() // 参数对象 | |
| 866 | 903 | }; |
| 867 | 904 | |
| 868 | 905 | console.log(aInfos); | ... | ... |