Commit 4d6144bf591c5ccc541039b4daac667b5a628285

Authored by 徐烜
1 parent 67754b96

时刻表v2.7.6

1、修改分班路牌数确定规则,[连班路牌小于2,则5休2之外的车辆数则为连班车辆数],[总分班路牌数小于加班路牌数,则忽略其他分班路牌数]
2、生成时刻表时,需要选择站点路由版本,和导入时刻表一致,后台导出逻辑里使用StationRouteService查找站点路由名字
3、修正导出生成的时刻表的格式,最后的几个班次为进场,到场,离场
4、修正导出生成的时刻表的格式,每个路牌的统计小时分钟使用冒号分割,不用中文
5、修改PoiUtils,CellType为String时,需要添加 [xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("@"));]
src/main/java/com/bsth/service/schedule/datatools/TTInfoDetailDataToolsImpl.java
1 1 package com.bsth.service.schedule.datatools;
2 2  
3 3 import com.bsth.entity.Station;
  4 +import com.bsth.entity.StationRoute;
  5 +import com.bsth.service.StationRouteService;
4 6 import com.bsth.service.StationService;
5 7 import com.bsth.service.schedule.exception.ScheduleException;
6 8 import com.bsth.service.schedule.utils.*;
... ... @@ -18,6 +20,8 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
18 20 import org.apache.poi.xssf.usermodel.XSSFSheet;
19 21 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
20 22 import org.joda.time.DateTime;
  23 +import org.joda.time.LocalTime;
  24 +import org.joda.time.format.DateTimeFormat;
21 25 import org.slf4j.Logger;
22 26 import org.slf4j.LoggerFactory;
23 27 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -42,9 +46,8 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
42 46 /** 日志记录器 */
43 47 private final static Logger LOGGER = LoggerFactory.getLogger(TTInfoDetailDataToolsImpl.class);
44 48  
45   - // TODO:之后改了
46 49 @Autowired
47   - private StationService stationService;
  50 + private StationRouteService stationRouteService;
48 51  
49 52 @Autowired
50 53 @Qualifier(value = "dataToolsServiceImpl")
... ... @@ -441,8 +444,8 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
441 444  
442 445 // 构造表头
443 446 PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short)0, "路牌", new Color(0x96b9d7));
444   - Station station1 = stationService.findById(lpObjList.get(0).getStationRouteId1());
445   - Station station2 = stationService.findById(lpObjList.get(1).getStationRouteId2());
  447 + StationRoute station1 = stationRouteService.findById(lpObjList.get(0).getStationRouteId1());
  448 + StationRoute station2 = stationRouteService.findById(lpObjList.get(1).getStationRouteId2());
446 449 for (int i = 0; i < groupCount; i++) {
447 450 PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (i * 2 + 1),
448 451 station1.getStationName(), new Color(0x96b9d7));
... ... @@ -553,8 +556,8 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
553 556  
554 557 // 构造表头,添加一个进场,添加一个出场
555 558 PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short)0, "路牌", new Color(0x96b9d7));
556   - Station station1 = stationService.findById(lpObjList.get(0).getStationRouteId1());
557   - Station station2 = stationService.findById(lpObjList.get(1).getStationRouteId2());
  559 + StationRoute station1 = stationRouteService.findById(lpObjList.get(0).getStationRouteId1());
  560 + StationRoute station2 = stationRouteService.findById(lpObjList.get(1).getStationRouteId2());
558 561 PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (1),
559 562 "报到", new Color(0x96b9d7));
560 563 PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (2),
... ... @@ -565,23 +568,28 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
565 568 PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (i * 2 + 2),
566 569 station2.getStationName(), new Color(0x96b9d7));
567 570 }
  571 +
  572 + // 最后一个进场需要变成三个班次
  573 + // 1个分班进场班次,1个到场班次,1个离场班次
568 574 PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 3),
569   - "进场", new Color(0x96b9d7));
  575 + station2.getStationName(), new Color(0x96b9d7));
570 576 PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 4),
  577 + "到场", new Color(0x96b9d7));
  578 + PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 5),
571 579 "离场", new Color(0x96b9d7));
572 580  
573 581 // 路牌统计字段
574   - PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 5),
575   - "总公里", new Color(0x96b9d7));
576 582 PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 6),
577   - "营业公里", new Color(0x96b9d7));
  583 + "公里", new Color(0x96b9d7));
578 584 PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 7),
579   - "空驶公里", new Color(0x96b9d7));
  585 + "营业公里", new Color(0x96b9d7));
580 586 PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 8),
581   - "总工时", new Color(0x96b9d7));
  587 + "空驶公里", new Color(0x96b9d7));
582 588 PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 9),
583   - "营业工时", new Color(0x96b9d7));
  589 + "工时", new Color(0x96b9d7));
584 590 PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 10),
  591 + "营业工时", new Color(0x96b9d7));
  592 + PoiUtils.createStringXSSFCell(wb, lpHeadRow, (short) (groupCount * 2 + 11),
585 593 "营运班次", new Color(0x96b9d7));
586 594  
587 595 // 构建每个路牌的班次数据
... ... @@ -598,6 +606,7 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
598 606  
599 607 PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (groupCount * 2 + 3));
600 608 PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (groupCount * 2 + 4));
  609 + PoiUtils.createBlankXSSFCell(wb, lpRow, (short) (groupCount * 2 + 5));
601 610  
602 611 for (BcObj bcObj : lpObj.getBcObjList()) {
603 612 if (bcObj.getBcType() == BcType.NORMAL) {
... ... @@ -626,7 +635,7 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
626 635 } else if (bcObj.getBcType() == BcType.IN) {
627 636 if (bcObj.getGroupNo() == -2) {
628 637 Cell cell = lpRow.getCell((short) (groupCount * 2 + 3));
629   - cell.setCellValue(bcObj.getFcsj());
  638 + cell.setCellValue(bcObj.getFcsj() + "X");
630 639 } else if (bcObj.getGroupNo() > 0) { //分班进场
631 640 Cell cell = lpRow.getCell((short) (bcObj.getGroupNo() * 2 + bcObj.getGroupBcNo() + 3));
632 641 // 停驶用 ※
... ... @@ -635,22 +644,27 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
635 644  
636 645 } else if (bcObj.getBcType() == BcType.LC) {
637 646 if (bcObj.getGroupNo() == -2) {
  647 + // 这个是到场,准备离场班次
638 648 Cell cell = lpRow.getCell((short) (groupCount * 2 + 4));
639 649 cell.setCellValue(bcObj.getFcsj());
  650 + // 加10分钟表示真正离场时间
  651 + cell = lpRow.getCell((short) (groupCount * 2 + 5));
  652 + LocalTime localTime = LocalTime.parse(bcObj.getFcsj(), DateTimeFormat.forPattern("HH:mm"));
  653 + cell.setCellValue(localTime.plusMinutes(10).toString(DateTimeFormat.forPattern("HH:mm")));
640 654 }
641 655  
642 656 }
643 657 }
644 658  
645 659 // 路牌统计字段
646   - PoiUtils.createDoubleXSSFCell(wb, lpRow, (short) (groupCount * 2 + 5), lpObj.getZlc());
647   - PoiUtils.createDoubleXSSFCell(wb, lpRow, (short) (groupCount * 2 + 6), lpObj.getYylc());
648   - PoiUtils.createDoubleXSSFCell(wb, lpRow, (short) (groupCount * 2 + 7), lpObj.getKslc());
649   - PoiUtils.createStringXSSFCell(wb, lpRow, (short) (groupCount * 2 + 8),
650   - String.format("%d小时%d分钟", (int) (lpObj.getZgs() / 60), (int) (lpObj.getZgs() % 60)));
  660 + PoiUtils.createDoubleXSSFCell(wb, lpRow, (short) (groupCount * 2 + 6), lpObj.getZlc());
  661 + PoiUtils.createDoubleXSSFCell(wb, lpRow, (short) (groupCount * 2 + 7), lpObj.getYylc());
  662 + PoiUtils.createDoubleXSSFCell(wb, lpRow, (short) (groupCount * 2 + 8), lpObj.getKslc());
651 663 PoiUtils.createStringXSSFCell(wb, lpRow, (short) (groupCount * 2 + 9),
652   - String.format("%d小时%d分钟", (int) (lpObj.getYygs() / 60), (int) (lpObj.getYygs() % 60)));
653   - PoiUtils.createIntegerXSSFCell(wb, lpRow, (short) (groupCount * 2 + 10), lpObj.getYybc());
  664 + String.format("%d%s%d", (int) (lpObj.getZgs() / 60), ":", (int) (lpObj.getZgs() % 60)));
  665 + PoiUtils.createStringXSSFCell(wb, lpRow, (short) (groupCount * 2 + 10),
  666 + String.format("%d%s%d", (int) (lpObj.getYygs() / 60), ":", (int) (lpObj.getYygs() % 60)));
  667 + PoiUtils.createIntegerXSSFCell(wb, lpRow, (short) (groupCount * 2 + 11), lpObj.getYybc());
654 668  
655 669 }
656 670  
... ... @@ -670,6 +684,7 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail
670 684 sheet.autoSizeColumn(groupCount * 2 + 8);
671 685 sheet.autoSizeColumn(groupCount * 2 + 9);
672 686 sheet.autoSizeColumn(groupCount * 2 + 10);
  687 + sheet.autoSizeColumn(groupCount * 2 + 11);
673 688 }
674 689  
675 690 @Override
... ...
src/main/java/com/bsth/service/schedule/utils/PoiUtils.java
... ... @@ -58,7 +58,7 @@ public class PoiUtils {
58 58 public static XSSFCell createStringXSSFCell(
59 59 XSSFWorkbook xssfWorkbook, XSSFRow xssfRow, short column, String value,
60 60 Color backgroundColor) {
61   - return createXSSFCell(
  61 + XSSFCell xssfCell = createXSSFCell(
62 62 xssfWorkbook, xssfRow, column,
63 63 value, XSSFCell.CELL_TYPE_STRING,
64 64 HorizontalAlignment.CENTER, VerticalAlignment.CENTER,
... ... @@ -66,11 +66,14 @@ public class PoiUtils {
66 66 (short) 13, new Color(0x2765A7), "宋体",
67 67 backgroundColor, FillPatternType.SOLID_FOREGROUND
68 68 );
  69 + DataFormat dataFormat = xssfWorkbook.createDataFormat();
  70 + xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("@"));
  71 + return xssfCell;
69 72 }
70 73  
71 74 public static XSSFCell createStringXSSFCell(
72 75 XSSFWorkbook xssfWorkbook, XSSFRow xssfRow, short column, String value) {
73   - return createXSSFCell(
  76 + XSSFCell xssfCell = createXSSFCell(
74 77 xssfWorkbook, xssfRow, column,
75 78 value, XSSFCell.CELL_TYPE_STRING,
76 79 HorizontalAlignment.CENTER, VerticalAlignment.CENTER,
... ... @@ -78,6 +81,9 @@ public class PoiUtils {
78 81 (short) 13, new Color(0x2765A7), "宋体",
79 82 new Color(0xffffff), FillPatternType.SOLID_FOREGROUND
80 83 );
  84 + DataFormat dataFormat = xssfWorkbook.createDataFormat();
  85 + xssfCell.getCellStyle().setDataFormat(dataFormat.getFormat("@"));
  86 + return xssfCell;
81 87 }
82 88  
83 89 public static XSSFCell createDoubleXSSFCell(
... ... @@ -150,8 +156,9 @@ public class PoiUtils {
150 156  
151 157 // 设定值
152 158 if (valueType == XSSFCell.CELL_TYPE_STRING) {
153   - cell.setCellValue(creationHelper.createRichTextString(
154   - WorkbookUtil.createSafeSheetName(String.valueOf(value))));
  159 +// cell.setCellValue(creationHelper.createRichTextString(
  160 +// WorkbookUtil.createSafeSheetName(String.valueOf(value))));
  161 + cell.setCellValue(creationHelper.createRichTextString(String.valueOf(value)));
155 162 } else if (valueType == XSSFCell.CELL_TYPE_NUMERIC) {
156 163 if (value instanceof Date) { // 日期
157 164 cellStyle.setDataFormat(creationHelper.createDataFormat().getFormat("yyyy-mm-dd"));
... ...
src/main/resources/static/pages/base/timesmodel/add.html
... ... @@ -120,7 +120,21 @@
120 120 </div>
121 121 </div>
122 122 <!-- 线路名称 (* 必填项) END -->
123   - </div>
  123 +
  124 + </div>
  125 +
  126 + <div class="form-group">
  127 + <!-- 线路版本 -->
  128 + <div class="col-md-6">
  129 + <label class="control-label col-md-5">
  130 + <span class="required"> * </span> 站点路由版本&nbsp;:
  131 + </label>
  132 + <div class="col-md-6">
  133 + <select name="lineVersion" class="form-control input-medium" id="lineVersionSelect"></select>
  134 + </div>
  135 + </div>
  136 + </div>
  137 +
124 138 <!-- 表单分组组件 form-group END -->
125 139 </div>
126 140 <!-- 获取参数 -->
... ... @@ -132,10 +146,10 @@
132 146 <div class="col-md-9">
133 147 <div class="icheck-list">
134 148 <label >
135   - <input type="radio" class="icheck" name="baseRes" value=1 checked> 班型/人次/车辆
  149 + <input type="radio" class="icheck" name="baseRes" value=1> 班型/人次/车辆
136 150 </label>
137 151 <label>
138   - <input type="radio" class="icheck" name="baseRes" value=2> 发车间隔分析
  152 + <input type="radio" class="icheck" name="baseRes" value=2 checked> 发车间隔分析
139 153 </label>
140 154 <label>
141 155 <input type="radio" class="icheck" name="baseRes" value=0> 客流大数据分析
... ...
src/main/resources/static/pages/base/timesmodel/js/add-form-reload.js
... ... @@ -201,6 +201,25 @@
201 201 $get('/tic_ec/' + skbId ,null, function(d){
202 202 if(d.status=='SUCCESS') {
203 203 $("#lineSelect").select2("val", d.data.xl.id + '_' + d.data.xl.lineCode + '_' + d.data.xl.name);
  204 +
  205 + // 获取线路版本信息
  206 + $get('/tic_ec/stationroute/' + d.data.xl.id, null, function(rs){
  207 + // 构造select2内容
  208 + var iSelVersion = 0;
  209 + var aOption = [];
  210 + aOption.push('<option value="">请选择...</option><optgroup label="线路版本">');
  211 + $.each(rs.data, function(i, g) {
  212 + aOption.push('<option value="'+ g.version + '">' + g.desc + '</option>');
  213 + if (i == 0) {
  214 + iSelVersion = g.version;
  215 + }
  216 + });
  217 + aOption.push('</optgroup>');
  218 + $('#lineVersionSelect').html(aOption.join("")).select2();
  219 + if (iSelVersion > 0) {
  220 + $("#lineVersionSelect").select2("val", iSelVersion);
  221 + }
  222 + });
204 223 }
205 224 });
206 225 }
... ...
src/main/resources/static/pages/base/timesmodel/js/add-form-wizard.js
... ... @@ -395,10 +395,26 @@ var SKBFormWizard = function() {
395 395 // 返回参数详情模版.
396 396 return cb && cb ({'forminput':template(tempName,{map:map}),'datadisplay': template(tempName +'config',{map:null})});
397 397 }else if (n==2) {
398   - return cb && cb({
  398 + // 更具站点路由版本获取起点终点站
  399 + var iversion = $('#lineVersionSelect').val();
  400 + $get('/stationroute/all',{'line.id_eq':lineId,'destroy_eq':0, 'versions_eq': iversion},function(result) {
  401 + $.each(result, function(i, d) {
  402 + if (d.stationMark == 'B' && d.directions == 0) {
  403 + // alert(d.stationName);
  404 + map.line.startStationName = d.stationName;
  405 + } else if (d.stationMark == 'E' && d.directions == 0) {
  406 + // alert(d.stationName);
  407 + map.line.endStationName = d.stationName;
  408 + }
  409 + });
  410 +
  411 +
  412 + return cb && cb({
399 413 'forminput': template(tempName, {map: map}),
400 414 'datadisplay': template(tempName + '_config', {map: null})
401 415 });
  416 + });
  417 +
402 418 }
403 419 });
404 420 }
... ... @@ -476,6 +492,7 @@ var SKBFormWizard = function() {
476 492 rules : {
477 493 'skbName' : {required : true,},// 时刻表名称,必填项.
478 494 'lineName' : {required : true,},// 线路名称,必填项.
  495 + 'lineVersion': {required: true}, // 站点路由版本,必填项,
479 496 // 'krl' : {isBaseRes : true,number : true,digits : true,},// 客容量,当选择为客流方式时必填项、整数
480 497 'startStationFirstTime' : {required : true}, // 起始站首班时间,必填项.
481 498 'startStationEndTime' : {required : true}, // 起始站末班时间 ,必填项.
... ... @@ -598,20 +615,20 @@ var SKBFormWizard = function() {
598 615 var argus = form.serializeJSON();
599 616 console.log(argus);
600 617 // 获取站点路由.
601   - $get('/stationroute/all',{'line.id_eq':argus.lineName.split('_')[0],'destroy_eq':0},function(result) {
  618 + $get('/stationroute/all',{'line.id_eq':argus.lineName.split('_')[0],'destroy_eq':0, 'versions_eq': argus.lineVersion},function(result) {
602 619 // 判断.
603 620 if(result) {
604 621 // 定义上行起点站,上行终点站,下行起点站,下行终点站.
605 622 var upB ='',upE='',downB='',downE='';
606 623 for(var r = 0 ; r<result.length;r++) {
607 624 if(result[r].directions==0 && result[r].stationMark =='B')
608   - upB = result[r].station.id;
  625 + upB = result[r].id;
609 626 if(result[r].directions==0 && result[r].stationMark =='E')
610   - upE = result[r].station.id;
  627 + upE = result[r].id;
611 628 if(result[r].directions==1 && result[r].stationMark =='B')
612   - downB = result[r].station.id;
  629 + downB = result[r].id;
613 630 if(result[r].directions==1 && result[r].stationMark =='E')
614   - downE = result[r].station.id;
  631 + downE = result[r].id;
615 632 }
616 633 argus.up_s = upB + '_' + upE;
617 634 argus.down_s = downB + '_' + downE;
... ... @@ -628,7 +645,7 @@ var SKBFormWizard = function() {
628 645 $get('/tidc/all',{'ttinfo.id_eq':parseInt(argus.skbName)},function(data) {
629 646 if(data.status=='SUCCESS' && data.data.length>0) {
630 647 argus.istidc = 1;
631   - layer.confirm('系统已存在该时刻表【'+
  648 + layer.confirm('系统已存在该时刻表【'+
632 649 $("#skbNameSelect").select2("data")[0].text +
633 650 '】明细,是否使用已有数据渲染模型?', {
634 651 btn: ['确定并使用','取消并继续'] //按钮
... ... @@ -648,7 +665,7 @@ var SKBFormWizard = function() {
648 665 layer.msg('系统不存在该线路的上、下行起终点站!');
649 666 }
650 667 });
651   -
  668 +
652 669 // 表单提交.
653 670 function submit(p,argus) {
654 671 var baseRes2 = $('#submit_argus_form input[name="baseRes"]:checked').val();// 获取参数方式值.
... ...
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalScheduleObj.js
... ... @@ -354,13 +354,18 @@ var InternalScheduleObj = function(paramObj, lpArray, factory) {
354 354 alert("总配车数小于低谷最小配车");
355 355 throw "总配车数小于低谷最小配车";
356 356 }
  357 +
357 358 if (iDgminpc < 2) {
358   - alert("连班路牌小于2,办不到啊");
359   - throw "连班路牌小于2,办不到啊";
  359 + // alert("连班路牌小于2,办不到啊");
  360 + // throw "连班路牌小于2,办不到啊";
  361 + console.log("连班路牌小于2,则5休2之外的车辆数则为连班车辆数");
  362 + iDgminpc = iCls - i_5_2_lpes;
360 363 }
361 364 if (iCls - iDgminpc < i_5_2_lpes) {
362   - alert("总分班路牌数小于加班路牌数");
363   - throw "总分班路牌数小于加班路牌数";
  365 + // alert("总分班路牌数小于加班路牌数");
  366 + // throw "总分班路牌数小于加班路牌数";
  367 + console.log("总分班路牌数小于加班路牌数,则忽略其他分班路牌数");
  368 + iDgminpc = iCls - i_5_2_lpes;
364 369 }
365 370  
366 371 //// 修正连班路牌数,班次间隔大于20的,加1,直至班次间隔小于20
... ...