Commit c4fecbeecc3abd25d0ee0b41cabadec1e9375ce1
1 parent
bec3c4e6
1.线调->轨迹回放加入到离站信息导出功能
Showing
3 changed files
with
69 additions
and
16 deletions
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
| @@ -559,6 +559,22 @@ public class GpsServiceImpl implements GpsService { | @@ -559,6 +559,22 @@ public class GpsServiceImpl implements GpsService { | ||
| 559 | public Map<String, ArrivalEntity> findArrivalByTs(Long st, Long et, List<DeviceChange> dcs) { | 559 | public Map<String, ArrivalEntity> findArrivalByTs(Long st, Long et, List<DeviceChange> dcs) { |
| 560 | Map<String, ArrivalEntity> map = new HashMap<>(); | 560 | Map<String, ArrivalEntity> map = new HashMap<>(); |
| 561 | 561 | ||
| 562 | + List<ArrivalEntity> list = findArrivalListByTs(st, et, dcs); | ||
| 563 | + | ||
| 564 | + String stationName, prefix; | ||
| 565 | + for(ArrivalEntity arr : list){ | ||
| 566 | + prefix = arr.getLineCode() + "_" + arr.getUpDown() + "_"; | ||
| 567 | + stationName = BasicData.getStationNameByCode(arr.getStopNo(), prefix); | ||
| 568 | + | ||
| 569 | + arr.setStopName(stationName); | ||
| 570 | + | ||
| 571 | + // 反转进出状态 | ||
| 572 | + map.put(arr.getDeviceId() + "_" + arr.getTs(), arr); | ||
| 573 | + } | ||
| 574 | + return map; | ||
| 575 | + } | ||
| 576 | + | ||
| 577 | + private List<ArrivalEntity> findArrivalListByTs(Long st, Long et, List<DeviceChange> dcs) { | ||
| 562 | // weeks_year 分区字段 | 578 | // weeks_year 分区字段 |
| 563 | Calendar sCal = Calendar.getInstance(); | 579 | Calendar sCal = Calendar.getInstance(); |
| 564 | sCal.setTime(new Date(st)); | 580 | sCal.setTime(new Date(st)); |
| @@ -591,21 +607,10 @@ public class GpsServiceImpl implements GpsService { | @@ -591,21 +607,10 @@ public class GpsServiceImpl implements GpsService { | ||
| 591 | sql.append(" UNION "); | 607 | sql.append(" UNION "); |
| 592 | } | 608 | } |
| 593 | 609 | ||
| 594 | - logger.info("arrivl sql : " + sql.toString()); | 610 | + logger.info("arrival sql : " + sql.toString()); |
| 595 | JdbcTemplate jdbcTemplate_ms = new JdbcTemplate(DBUtils_MS.getDataSource()); | 611 | JdbcTemplate jdbcTemplate_ms = new JdbcTemplate(DBUtils_MS.getDataSource()); |
| 596 | - List<ArrivalEntity> list = jdbcTemplate_ms.query(sql.toString(), BeanPropertyRowMapper.newInstance(ArrivalEntity.class)); | ||
| 597 | - | ||
| 598 | - String stationName, prefix; | ||
| 599 | - for(ArrivalEntity arr : list){ | ||
| 600 | - prefix = arr.getLineCode() + "_" + arr.getUpDown() + "_"; | ||
| 601 | - stationName = BasicData.getStationNameByCode(arr.getStopNo(), prefix); | ||
| 602 | 612 | ||
| 603 | - arr.setStopName(stationName); | ||
| 604 | - | ||
| 605 | - // 反转进出状态 | ||
| 606 | - map.put(arr.getDeviceId() + "_" + arr.getTs(), arr); | ||
| 607 | - } | ||
| 608 | - return map; | 613 | + return jdbcTemplate_ms.query(sql.toString(), BeanPropertyRowMapper.newInstance(ArrivalEntity.class)); |
| 609 | } | 614 | } |
| 610 | 615 | ||
| 611 | 616 | ||
| @@ -1074,7 +1079,55 @@ public class GpsServiceImpl implements GpsService { | @@ -1074,7 +1079,55 @@ public class GpsServiceImpl implements GpsService { | ||
| 1074 | 1079 | ||
| 1075 | @Override | 1080 | @Override |
| 1076 | public void arrivalExcel(String nbbm, long st, long et, HttpServletResponse resp) { | 1081 | public void arrivalExcel(String nbbm, long st, long et, HttpServletResponse resp) { |
| 1082 | + st = st * 1000; | ||
| 1083 | + et = et * 1000; | ||
| 1084 | + List<DeviceChange> dcs = findDeviceChangeLogs(nbbm, et, st); | ||
| 1085 | + // 查询到离站数据 | ||
| 1086 | + List<ArrivalEntity> list = findArrivalListByTs(st, et, dcs); | ||
| 1077 | 1087 | ||
| 1088 | + //创建excel工作簿 | ||
| 1089 | + Workbook wb = new HSSFWorkbook(); | ||
| 1090 | + Sheet sheet = wb.createSheet("到离站信息"); | ||
| 1091 | + //表头 | ||
| 1092 | + Row row = sheet.createRow(0); | ||
| 1093 | + row.setHeight((short) (1.5 * 256)); | ||
| 1094 | + row.createCell(0).setCellValue("序号"); | ||
| 1095 | + row.createCell(1).setCellValue("车辆"); | ||
| 1096 | + row.createCell(2).setCellValue("牌照号"); | ||
| 1097 | + row.createCell(3).setCellValue("站名"); | ||
| 1098 | + row.createCell(4).setCellValue("时间"); | ||
| 1099 | + row.createCell(5).setCellValue("进/出站"); | ||
| 1100 | + //数据 | ||
| 1101 | + DateTimeFormatter fmtHHmmss = DateTimeFormat.forPattern("HH:mm.ss"), fmt = DateTimeFormat.forPattern("yyyyMMddHHmm"); | ||
| 1102 | + ArrivalEntity arrival; | ||
| 1103 | + String prefix, stationName; | ||
| 1104 | + for(int i = 0; i < list.size(); i ++){ | ||
| 1105 | + arrival = list.get(i); | ||
| 1106 | + prefix = arrival.getLineCode() + "_" + arrival.getUpDown() + "_"; | ||
| 1107 | + stationName = BasicData.getStationNameByCode(arrival.getStopNo(), prefix); | ||
| 1108 | + row = sheet.createRow(i + 1); | ||
| 1109 | + row.createCell(0).setCellValue(i + 1); | ||
| 1110 | + row.createCell(1).setCellValue(nbbm); | ||
| 1111 | + row.createCell(2).setCellValue(BasicData.nbbmCompanyPlateMap.get(nbbm)); | ||
| 1112 | + row.createCell(3).setCellValue(stationName); | ||
| 1113 | + row.createCell(4).setCellValue(fmtHHmmss.print(arrival.getTs())); | ||
| 1114 | + row.createCell(5).setCellValue(arrival.getInOut() == 0 ? "进站" : "出站"); | ||
| 1115 | + } | ||
| 1116 | + | ||
| 1117 | + String filename = nbbm + "到离站数据" + fmt.print(st) + "至" + fmt.print(et) + ".xls"; | ||
| 1118 | + try { | ||
| 1119 | + resp.setContentType("application/x-msdownload"); | ||
| 1120 | + resp.addHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8")); | ||
| 1121 | + | ||
| 1122 | + OutputStream out=resp.getOutputStream(); | ||
| 1123 | + wb.write(out); | ||
| 1124 | + out.flush(); | ||
| 1125 | + out.close(); | ||
| 1126 | + } catch (UnsupportedEncodingException e) { | ||
| 1127 | + logger.error("", e); | ||
| 1128 | + } catch (IOException e) { | ||
| 1129 | + logger.error("", e); | ||
| 1130 | + } | ||
| 1078 | } | 1131 | } |
| 1079 | 1132 | ||
| 1080 | @Override | 1133 | @Override |
src/main/resources/application-dev.properties
| @@ -20,7 +20,7 @@ spring.datasource.control.password= root2jsp | @@ -20,7 +20,7 @@ spring.datasource.control.password= root2jsp | ||
| 20 | spring.datasource.control.type= com.zaxxer.hikari.HikariDataSource | 20 | spring.datasource.control.type= com.zaxxer.hikari.HikariDataSource |
| 21 | #DATASOURCE | 21 | #DATASOURCE |
| 22 | spring.datasource.control.hikari.minimum-idle= 8 | 22 | spring.datasource.control.hikari.minimum-idle= 8 |
| 23 | -spring.datasource.control.hikari.maximum-pool-size= 100 | 23 | +spring.datasource.control.hikari.maximum-pool-size= 16 |
| 24 | #spring.datasource.control.hikari.auto-commit= true | 24 | #spring.datasource.control.hikari.auto-commit= true |
| 25 | spring.datasource.control.hikari.idle-timeout= 60000 | 25 | spring.datasource.control.hikari.idle-timeout= 60000 |
| 26 | #spring.datasource.control.hikari.pool-name= HikariPool | 26 | #spring.datasource.control.hikari.pool-name= HikariPool |
| @@ -38,7 +38,7 @@ spring.datasource.info-publish.password= root2jsp | @@ -38,7 +38,7 @@ spring.datasource.info-publish.password= root2jsp | ||
| 38 | spring.datasource.info-publish.type= com.zaxxer.hikari.HikariDataSource | 38 | spring.datasource.info-publish.type= com.zaxxer.hikari.HikariDataSource |
| 39 | #DATASOURCE | 39 | #DATASOURCE |
| 40 | spring.datasource.info-publish.hikari.minimum-idle= 8 | 40 | spring.datasource.info-publish.hikari.minimum-idle= 8 |
| 41 | -spring.datasource.info-publish.hikari.maximum-pool-size= 100 | 41 | +spring.datasource.info-publish.hikari.maximum-pool-size= 16 |
| 42 | #spring.datasource.info-publish.hikari.auto-commit= true | 42 | #spring.datasource.info-publish.hikari.auto-commit= true |
| 43 | spring.datasource.info-publish.hikari.idle-timeout= 60000 | 43 | spring.datasource.info-publish.hikari.idle-timeout= 60000 |
| 44 | #spring.datasource.info-publish.hikari.pool-name= HikariPool | 44 | #spring.datasource.info-publish.hikari.pool-name= HikariPool |
src/main/resources/static/real_control_v2/mapmonitor/fragments/playback_v3/right.html
| @@ -53,7 +53,7 @@ | @@ -53,7 +53,7 @@ | ||
| 53 | <div class="uk-dropdown uk-dropdown-small"> | 53 | <div class="uk-dropdown uk-dropdown-small"> |
| 54 | <ul class="uk-nav uk-nav-dropdown"> | 54 | <ul class="uk-nav uk-nav-dropdown"> |
| 55 | <li><a class="export-excel-abnormal">导出异常数据</a></li> | 55 | <li><a class="export-excel-abnormal">导出异常数据</a></li> |
| 56 | - <!--<li><a class="export-excel-arrival">导出到离站数据</a></li>--> | 56 | + <li><a class="export-excel-arrival">导出到离站数据</a></li> |
| 57 | </ul> | 57 | </ul> |
| 58 | </div> | 58 | </div> |
| 59 | </div> | 59 | </div> |