Commit 6c33dbf29755b2f5360d091688d7da9146af59fd

Authored by 徐烜
2 parents 6dc5bdaa ed9bb7ee

PSM-12

Too many changes to show.

To preserve performance only 9 of 38 files are displayed.

src/main/java/com/bsth/controller/BaseController.java
@@ -9,6 +9,7 @@ import org.springframework.data.domain.Page; @@ -9,6 +9,7 @@ import org.springframework.data.domain.Page;
9 import org.springframework.data.domain.PageRequest; 9 import org.springframework.data.domain.PageRequest;
10 import org.springframework.data.domain.Sort; 10 import org.springframework.data.domain.Sort;
11 import org.springframework.data.domain.Sort.Direction; 11 import org.springframework.data.domain.Sort.Direction;
  12 +import org.springframework.util.CollectionUtils;
12 import org.springframework.web.bind.annotation.PathVariable; 13 import org.springframework.web.bind.annotation.PathVariable;
13 import org.springframework.web.bind.annotation.RequestMapping; 14 import org.springframework.web.bind.annotation.RequestMapping;
14 import org.springframework.web.bind.annotation.RequestMethod; 15 import org.springframework.web.bind.annotation.RequestMethod;
@@ -167,11 +168,24 @@ public class BaseController<T, ID extends Serializable> { @@ -167,11 +168,24 @@ public class BaseController<T, ID extends Serializable> {
167 */ 168 */
168 @RequestMapping(value = "/dataExport", method = RequestMethod.GET) 169 @RequestMapping(value = "/dataExport", method = RequestMethod.GET)
169 public void dataExport(HttpServletResponse response) throws Exception { 170 public void dataExport(HttpServletResponse response) throws Exception {
  171 + dataExport(response, null);
  172 + }
  173 +
  174 + @RequestMapping(value = "/dataExportExt", method = RequestMethod.GET)
  175 + public void dataExport(HttpServletResponse response, @RequestParam Map<String, Object> param) throws Exception {
170 // 1、使用ktr转换获取输出文件 176 // 1、使用ktr转换获取输出文件
171 File ktrfile = new File(this.getClass().getResource(getDataExportKtrClasspath()).toURI()); 177 File ktrfile = new File(this.getClass().getResource(getDataExportKtrClasspath()).toURI());
172 - File outputfile = dataImportExportService.fileDataOutput(  
173 - getDataExportFilename(),  
174 - ktrfile); 178 + File outputfile = null;
  179 + if (!CollectionUtils.isEmpty(param)) {
  180 + outputfile = dataImportExportService.fileDataOutput(
  181 + getDataExportFilename(),
  182 + ktrfile,
  183 + param);
  184 + } else {
  185 + outputfile = dataImportExportService.fileDataOutput(
  186 + getDataExportFilename(),
  187 + ktrfile);
  188 + }
175 189
176 System.out.println(outputfile.getName()); 190 System.out.println(outputfile.getName());
177 String filePath = outputfile.getAbsolutePath(); 191 String filePath = outputfile.getAbsolutePath();
src/main/java/com/bsth/controller/schedule/TTInfoDetailController.java
@@ -14,6 +14,7 @@ import com.bsth.service.StationRouteService; @@ -14,6 +14,7 @@ import com.bsth.service.StationRouteService;
14 import com.bsth.service.schedule.GuideboardInfoService; 14 import com.bsth.service.schedule.GuideboardInfoService;
15 import com.bsth.service.schedule.TTInfoDetailService; 15 import com.bsth.service.schedule.TTInfoDetailService;
16 import com.bsth.service.schedule.utils.DataImportExportService; 16 import com.bsth.service.schedule.utils.DataImportExportService;
  17 +import com.bsth.service.schedule.utils.DataToolsProperties;
17 import jxl.Cell; 18 import jxl.Cell;
18 import jxl.Sheet; 19 import jxl.Sheet;
19 import jxl.Workbook; 20 import jxl.Workbook;
@@ -26,6 +27,7 @@ import org.springframework.util.CollectionUtils; @@ -26,6 +27,7 @@ import org.springframework.util.CollectionUtils;
26 import org.springframework.web.bind.annotation.*; 27 import org.springframework.web.bind.annotation.*;
27 import org.springframework.web.multipart.MultipartFile; 28 import org.springframework.web.multipart.MultipartFile;
28 29
  30 +import javax.servlet.http.HttpServletResponse;
29 import java.io.File; 31 import java.io.File;
30 import java.util.*; 32 import java.util.*;
31 import java.util.regex.Matcher; 33 import java.util.regex.Matcher;
@@ -51,6 +53,8 @@ public class TTInfoDetailController extends BaseController&lt;TTInfoDetail, Long&gt; { @@ -51,6 +53,8 @@ public class TTInfoDetailController extends BaseController&lt;TTInfoDetail, Long&gt; {
51 private StationRouteService stationRouteService; 53 private StationRouteService stationRouteService;
52 @Autowired 54 @Autowired
53 private GuideboardInfoService guideboardInfoService; 55 private GuideboardInfoService guideboardInfoService;
  56 + @Autowired
  57 + private DataToolsProperties dataToolsProperties;
54 58
55 59
56 public static class ExcelFileOutput { 60 public static class ExcelFileOutput {
@@ -126,11 +130,15 @@ public class TTInfoDetailController extends BaseController&lt;TTInfoDetail, Long&gt; { @@ -126,11 +130,15 @@ public class TTInfoDetailController extends BaseController&lt;TTInfoDetail, Long&gt; {
126 Cell[] cells = sheet.getRow(0); // 获取第一行数据列 130 Cell[] cells = sheet.getRow(0); // 获取第一行数据列
127 for (int i = 0; i < cells.length; i++) { 131 for (int i = 0; i < cells.length; i++) {
128 String cell_con = cells[i].getContents(); 132 String cell_con = cells[i].getContents();
  133 +
129 if (StringUtils.isEmpty(cell_con)) { 134 if (StringUtils.isEmpty(cell_con)) {
130 rtn.put("status", ResponseCode.ERROR); 135 rtn.put("status", ResponseCode.ERROR);
131 rtn.put("msg", String.format("第1行,第%d列数据不能为空", i + 1)); 136 rtn.put("msg", String.format("第1行,第%d列数据不能为空", i + 1));
132 return rtn; 137 return rtn;
133 } else { 138 } else {
  139 + // 正则表达式去除数字
  140 + cell_con = cell_con.replaceAll("[\\d+]", "");
  141 +
134 if (i == 0) { // 第一列必须是路牌2个字 142 if (i == 0) { // 第一列必须是路牌2个字
135 if (!"路牌".equals(cell_con.trim())) { 143 if (!"路牌".equals(cell_con.trim())) {
136 rtn.put("status", ResponseCode.ERROR); 144 rtn.put("status", ResponseCode.ERROR);
@@ -457,4 +465,25 @@ public class TTInfoDetailController extends BaseController&lt;TTInfoDetail, Long&gt; { @@ -457,4 +465,25 @@ public class TTInfoDetailController extends BaseController&lt;TTInfoDetail, Long&gt; {
457 public List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId) { 465 public List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId) {
458 return ttInfoDetailRepository.findBcdetails(xlId, ttinfoId, lpId); 466 return ttInfoDetailRepository.findBcdetails(xlId, ttinfoId, lpId);
459 } 467 }
  468 +
  469 + @Override
  470 + public void dataExport(HttpServletResponse response, @RequestParam Map<String, Object> param) throws Exception {
  471 + // 获取injectktr
  472 + File ktrFile2 = new File(this.getClass().getResource(
  473 + dataToolsProperties.getTtinfodetailOutput()).toURI());
  474 + param.put("injectktrfile", ktrFile2.getAbsolutePath());
  475 + param.put("ttinfoid", param.get("ttinfoid"));
  476 +
  477 + super.dataExport(response, param);
  478 + }
  479 +
  480 + @Override
  481 + protected String getDataExportKtrClasspath() {
  482 + return dataToolsProperties.getTtinfodetailMetaoutput();
  483 + }
  484 +
  485 + @Override
  486 + protected String getDataExportFilename() {
  487 + return "时刻表";
  488 + }
460 } 489 }
src/main/java/com/bsth/data/arrival/ArrivalData_GPS.java
@@ -50,8 +50,8 @@ public class ArrivalData_GPS implements CommandLineRunner{ @@ -50,8 +50,8 @@ public class ArrivalData_GPS implements CommandLineRunner{
50 50
51 @Override 51 @Override
52 public void run(String... arg0) throws Exception { 52 public void run(String... arg0) throws Exception {
53 - logger.info("ArrivalData_GPS,100,10 @11-10");  
54 - //Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 100, 10, TimeUnit.SECONDS); 53 + logger.info("ArrivalData_GPS,30,10");
  54 + //Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 40, 10, TimeUnit.SECONDS);
55 } 55 }
56 56
57 @Component 57 @Component
src/main/java/com/bsth/service/realcontrol/dto/ScheduleExecRate.java
1 -package com.bsth.service.realcontrol.dto;  
2 -  
3 -/**  
4 - * 班次执行率DTO  
5 - * Created by panzhao on 2016/11/14.  
6 - */  
7 -public class ScheduleExecRate {  
8 -  
9 - private long id;  
10 - private String dfsj;  
11 - private String fcsjActual;  
12 - private String zdsj;  
13 - private String zdsjActual;  
14 - private int status;  
15 - private String lineCode;  
16 -  
17 - public long getId() {  
18 - return id;  
19 - }  
20 -  
21 - public void setId(long id) {  
22 - this.id = id;  
23 - }  
24 -  
25 - public String getDfsj() {  
26 - return dfsj;  
27 - }  
28 -  
29 - public void setDfsj(String dfsj) {  
30 - this.dfsj = dfsj;  
31 - }  
32 -  
33 - public String getFcsjActual() {  
34 - return fcsjActual;  
35 - }  
36 -  
37 - public void setFcsjActual(String fcsjActual) {  
38 - this.fcsjActual = fcsjActual;  
39 - }  
40 -  
41 - public String getZdsj() {  
42 - return zdsj;  
43 - }  
44 -  
45 - public void setZdsj(String zdsj) {  
46 - this.zdsj = zdsj;  
47 - }  
48 -  
49 - public String getZdsjActual() {  
50 - return zdsjActual;  
51 - }  
52 -  
53 - public void setZdsjActual(String zdsjActual) {  
54 - this.zdsjActual = zdsjActual;  
55 - }  
56 -  
57 - public int getStatus() {  
58 - return status;  
59 - }  
60 -  
61 - public void setStatus(int status) {  
62 - this.status = status;  
63 - }  
64 -  
65 - public String getLineCode() {  
66 - return lineCode;  
67 - }  
68 -  
69 - public void setLineCode(String lineCode) {  
70 - this.lineCode = lineCode;  
71 - }  
72 -} 1 +package com.bsth.service.realcontrol.dto;
  2 +
  3 +/**
  4 + * 班次执行率DTO
  5 + * Created by panzhao on 2016/11/14.
  6 + */
  7 +public class ScheduleExecRate {
  8 +
  9 + private long id;
  10 + private String dfsj;
  11 + private String fcsjActual;
  12 + private String zdsj;
  13 + private String zdsjActual;
  14 + private int status;
  15 + private String lineCode;
  16 +
  17 + public long getId() {
  18 + return id;
  19 + }
  20 +
  21 + public void setId(long id) {
  22 + this.id = id;
  23 + }
  24 +
  25 + public String getDfsj() {
  26 + return dfsj;
  27 + }
  28 +
  29 + public void setDfsj(String dfsj) {
  30 + this.dfsj = dfsj;
  31 + }
  32 +
  33 + public String getFcsjActual() {
  34 + return fcsjActual;
  35 + }
  36 +
  37 + public void setFcsjActual(String fcsjActual) {
  38 + this.fcsjActual = fcsjActual;
  39 + }
  40 +
  41 + public String getZdsj() {
  42 + return zdsj;
  43 + }
  44 +
  45 + public void setZdsj(String zdsj) {
  46 + this.zdsj = zdsj;
  47 + }
  48 +
  49 + public String getZdsjActual() {
  50 + return zdsjActual;
  51 + }
  52 +
  53 + public void setZdsjActual(String zdsjActual) {
  54 + this.zdsjActual = zdsjActual;
  55 + }
  56 +
  57 + public int getStatus() {
  58 + return status;
  59 + }
  60 +
  61 + public void setStatus(int status) {
  62 + this.status = status;
  63 + }
  64 +
  65 + public String getLineCode() {
  66 + return lineCode;
  67 + }
  68 +
  69 + public void setLineCode(String lineCode) {
  70 + this.lineCode = lineCode;
  71 + }
  72 +}
src/main/java/com/bsth/service/schedule/utils/DataImportExportService.java
@@ -3,6 +3,7 @@ package com.bsth.service.schedule.utils; @@ -3,6 +3,7 @@ package com.bsth.service.schedule.utils;
3 import org.springframework.web.multipart.MultipartFile; 3 import org.springframework.web.multipart.MultipartFile;
4 4
5 import java.io.File; 5 import java.io.File;
  6 +import java.util.Map;
6 7
7 /** 8 /**
8 * 数据导入导出服务。 9 * 数据导入导出服务。
@@ -32,4 +33,7 @@ public interface DataImportExportService { @@ -32,4 +33,7 @@ public interface DataImportExportService {
32 * @throws Exception 33 * @throws Exception
33 */ 34 */
34 File fileDataOutput(String fileName, File ktrFile) throws Exception; 35 File fileDataOutput(String fileName, File ktrFile) throws Exception;
  36 +
  37 +
  38 + File fileDataOutput(String fileName, File ktrFile, Map<String, Object> param) throws Exception;
35 } 39 }
src/main/java/com/bsth/service/schedule/utils/DataImportExportServiceImpl.java
@@ -10,6 +10,7 @@ import org.springframework.beans.factory.InitializingBean; @@ -10,6 +10,7 @@ import org.springframework.beans.factory.InitializingBean;
10 import org.springframework.beans.factory.annotation.Autowired; 10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.boot.context.properties.EnableConfigurationProperties; 11 import org.springframework.boot.context.properties.EnableConfigurationProperties;
12 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
  13 +import org.springframework.util.CollectionUtils;
13 import org.springframework.web.multipart.MultipartFile; 14 import org.springframework.web.multipart.MultipartFile;
14 15
15 import java.io.File; 16 import java.io.File;
@@ -111,6 +112,11 @@ public class DataImportExportServiceImpl implements DataImportExportService, Ini @@ -111,6 +112,11 @@ public class DataImportExportServiceImpl implements DataImportExportService, Ini
111 112
112 @Override 113 @Override
113 public File fileDataOutput(String fileName, File ktrFile) throws Exception { 114 public File fileDataOutput(String fileName, File ktrFile) throws Exception {
  115 + return fileDataOutput(fileName, ktrFile, null);
  116 + }
  117 +
  118 + @Override
  119 + public File fileDataOutput(String fileName, File ktrFile, Map<String, Object> param) throws Exception {
114 // 初始化转换,元数据,转换对象 120 // 初始化转换,元数据,转换对象
115 TransMeta transMeta = new TransMeta(ktrFile.getAbsolutePath()); 121 TransMeta transMeta = new TransMeta(ktrFile.getAbsolutePath());
116 Trans trans = new Trans(transMeta); 122 Trans trans = new Trans(transMeta);
@@ -120,6 +126,14 @@ public class DataImportExportServiceImpl implements DataImportExportService, Ini @@ -120,6 +126,14 @@ public class DataImportExportServiceImpl implements DataImportExportService, Ini
120 fileName + 126 fileName +
121 new DateTime().toString("yyyyMMddHHmmss") + ".xls"; 127 new DateTime().toString("yyyyMMddHHmmss") + ".xls";
122 trans.setParameterValue("filepath", filepath); 128 trans.setParameterValue("filepath", filepath);
  129 +
  130 + // 添加其他参数
  131 + if (!CollectionUtils.isEmpty(param)) {
  132 + for (String key : param.keySet()) {
  133 + trans.setParameterValue(key, String.valueOf(param.get(key)));
  134 + }
  135 + }
  136 +
123 // 执行转换 137 // 执行转换
124 trans.execute(null); 138 trans.execute(null);
125 // 等待转换结束 139 // 等待转换结束
src/main/java/com/bsth/service/schedule/utils/DataToolsProperties.java
@@ -83,6 +83,10 @@ public class DataToolsProperties { @@ -83,6 +83,10 @@ public class DataToolsProperties {
83 /** 人员信息导出ktr转换 */ 83 /** 人员信息导出ktr转换 */
84 @NotNull 84 @NotNull
85 private String employeesDataoutputktr; 85 private String employeesDataoutputktr;
  86 + /** 时刻表导出元数据ktr转换 */
  87 + private String ttinfodetailMetaoutput;
  88 + /** 时刻表导出数据ktr转换 */
  89 + private String ttinfodetailOutput;
86 90
87 // TODO: 91 // TODO:
88 92
@@ -253,4 +257,20 @@ public class DataToolsProperties { @@ -253,4 +257,20 @@ public class DataToolsProperties {
253 public void setKvarsDbdname(String kvarsDbdname) { 257 public void setKvarsDbdname(String kvarsDbdname) {
254 this.kvarsDbdname = kvarsDbdname; 258 this.kvarsDbdname = kvarsDbdname;
255 } 259 }
  260 +
  261 + public String getTtinfodetailMetaoutput() {
  262 + return ttinfodetailMetaoutput;
  263 + }
  264 +
  265 + public void setTtinfodetailMetaoutput(String ttinfodetailMetaoutput) {
  266 + this.ttinfodetailMetaoutput = ttinfodetailMetaoutput;
  267 + }
  268 +
  269 + public String getTtinfodetailOutput() {
  270 + return ttinfodetailOutput;
  271 + }
  272 +
  273 + public void setTtinfodetailOutput(String ttinfodetailOutput) {
  274 + this.ttinfodetailOutput = ttinfodetailOutput;
  275 + }
256 } 276 }
src/main/resources/datatools/config-dev.properties
@@ -48,13 +48,19 @@ datatools.employeesconfig_datainputktr=/datatools/ktrs/employeesConfigDataInput. @@ -48,13 +48,19 @@ datatools.employeesconfig_datainputktr=/datatools/ktrs/employeesConfigDataInput.
48 48
49 # 4、数据导出配置信息 49 # 4、数据导出配置信息
50 # 导出数据文件目录配置(根据不同的环境需要修正) 50 # 导出数据文件目录配置(根据不同的环境需要修正)
51 -datatools.fileoutput_dir=/Users/xu/resource/project/bsth_control_u_d_files 51 +datatools.fileoutput_dir=/Users/xu/resource/project_code/runtime_temp/bsth_control_u_d_files
52 52
53 ##---------------------------- 导出数据ktr -----------------------------## 53 ##---------------------------- 导出数据ktr -----------------------------##
54 # 车辆信息导出ktr转换 54 # 车辆信息导出ktr转换
55 datatools.cars_dataoutputktr=/datatools/ktrs/carsDataOutput.ktr 55 datatools.cars_dataoutputktr=/datatools/ktrs/carsDataOutput.ktr
56 # 人员信息导出ktr转换 56 # 人员信息导出ktr转换
57 datatools.employees_dataoutputktr=/datatools/ktrs/employeesDataOutput.ktr 57 datatools.employees_dataoutputktr=/datatools/ktrs/employeesDataOutput.ktr
  58 +# 时刻表导出元数据ktr转换
  59 +datatools.ttinfodetail_metaoutput=/datatools/ktrs/ttinfodetailDataOutputMetaData.ktr
  60 +# 时刻表导出数据ktr转换
  61 +datatools.ttinfodetail_output=/datatools/ktrs/ttinfodetailDataOutput.ktr
  62 +
  63 +
58 64
59 # TODO: 65 # TODO:
60 66
src/main/resources/datatools/config-prod.properties
@@ -56,5 +56,9 @@ datatools.fileoutput_dir=/opt/bsth_control_u_d_files @@ -56,5 +56,9 @@ datatools.fileoutput_dir=/opt/bsth_control_u_d_files
56 datatools.cars_dataoutputktr=/datatools/ktrs/carsDataOutput.ktr 56 datatools.cars_dataoutputktr=/datatools/ktrs/carsDataOutput.ktr
57 # 人员信息导出ktr转换 57 # 人员信息导出ktr转换
58 datatools.employees_dataoutputktr=/datatools/ktrs/employeesDataOutput.ktr 58 datatools.employees_dataoutputktr=/datatools/ktrs/employeesDataOutput.ktr
  59 +# 时刻表导出元数据ktr转换
  60 +datatools.ttinfodetail_metaoutput=/datatools/ktrs/ttinfodetailDataOutputMetaData.ktr
  61 +# 时刻表导出数据ktr转换
  62 +datatools.ttinfodetail_output=/datatools/ktrs/ttinfodetailDataOutput.ktr
59 63
60 # TODO: 64 # TODO:
61 \ No newline at end of file 65 \ No newline at end of file