Commit 4308e58a7004b89c279592cd01195d7864104388
1 parent
e1ecfac0
1、修改ktr从classpath中以流的方式加载
Showing
11 changed files
with
190 additions
and
40 deletions
src/main/java/com/bsth/service/schedule/datatools/CarConfigInfoDataToolsImpl.java
| @@ -11,7 +11,6 @@ import org.slf4j.Logger; | @@ -11,7 +11,6 @@ import org.slf4j.Logger; | ||
| 11 | import org.slf4j.LoggerFactory; | 11 | import org.slf4j.LoggerFactory; |
| 12 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | import org.springframework.beans.factory.annotation.Qualifier; | 13 | import org.springframework.beans.factory.annotation.Qualifier; |
| 14 | -import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| 15 | import org.springframework.stereotype.Service; | 14 | import org.springframework.stereotype.Service; |
| 16 | 15 | ||
| 17 | import java.io.File; | 16 | import java.io.File; |
| @@ -90,8 +89,9 @@ public class CarConfigInfoDataToolsImpl implements DataToolsService { | @@ -90,8 +89,9 @@ public class CarConfigInfoDataToolsImpl implements DataToolsService { | ||
| 90 | File ktrFile = new File(this.getClass().getResource( | 89 | File ktrFile = new File(this.getClass().getResource( |
| 91 | dataToolsProperties.getCarsconfigDatainputktr()).toURI()); | 90 | dataToolsProperties.getCarsconfigDatainputktr()).toURI()); |
| 92 | 91 | ||
| 93 | - // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径 | 92 | + // 通用参数,转换文件路径,转换文件类路径,excel输入文件路径,错误输出文件路径 |
| 94 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); | 93 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); |
| 94 | + ktrParms.put("trans_class_path", dataToolsProperties.getCarsconfigDatainputktr()); | ||
| 95 | ktrParms.put("filepath", file.getAbsolutePath()); | 95 | ktrParms.put("filepath", file.getAbsolutePath()); |
| 96 | ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); | 96 | ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); |
| 97 | 97 | ||
| @@ -120,8 +120,9 @@ public class CarConfigInfoDataToolsImpl implements DataToolsService { | @@ -120,8 +120,9 @@ public class CarConfigInfoDataToolsImpl implements DataToolsService { | ||
| 120 | File ktrFile = new File(this.getClass().getResource( | 120 | File ktrFile = new File(this.getClass().getResource( |
| 121 | dataToolsProperties.getCarsconfigDataoutputktr()).toURI()); | 121 | dataToolsProperties.getCarsconfigDataoutputktr()).toURI()); |
| 122 | 122 | ||
| 123 | - // 通用参数,转换文件路径,excel输出文件名 | 123 | + // 通用参数,转换文件路径,转换文件类路径,excel输出文件名 |
| 124 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); | 124 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); |
| 125 | + ktrParms.put("trans_class_path", dataToolsProperties.getCarsconfigDataoutputktr()); | ||
| 125 | ktrParms.put("filename", "车辆配置信息_download-"); | 126 | ktrParms.put("filename", "车辆配置信息_download-"); |
| 126 | 127 | ||
| 127 | ktrParms.putAll(params); | 128 | ktrParms.putAll(params); |
src/main/java/com/bsth/service/schedule/datatools/CarsDataToolsImpl.java
| @@ -9,7 +9,6 @@ import org.slf4j.Logger; | @@ -9,7 +9,6 @@ import org.slf4j.Logger; | ||
| 9 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | import org.springframework.beans.factory.annotation.Qualifier; | 11 | import org.springframework.beans.factory.annotation.Qualifier; |
| 12 | -import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| 13 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
| 14 | 13 | ||
| 15 | import java.io.File; | 14 | import java.io.File; |
| @@ -88,8 +87,9 @@ public class CarsDataToolsImpl implements DataToolsService { | @@ -88,8 +87,9 @@ public class CarsDataToolsImpl implements DataToolsService { | ||
| 88 | File ktrFile = new File(this.getClass().getResource( | 87 | File ktrFile = new File(this.getClass().getResource( |
| 89 | dataToolsProperties.getCarsDatainputktr()).toURI()); | 88 | dataToolsProperties.getCarsDatainputktr()).toURI()); |
| 90 | 89 | ||
| 91 | - // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径 | 90 | + // 通用参数,转换文件路径,转换文件类路径,excel输入文件路径,错误输出文件路径 |
| 92 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); | 91 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); |
| 92 | + ktrParms.put("trans_class_path", dataToolsProperties.getCarsDatainputktr()); | ||
| 93 | ktrParms.put("filepath", file.getAbsolutePath()); | 93 | ktrParms.put("filepath", file.getAbsolutePath()); |
| 94 | ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); | 94 | ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); |
| 95 | 95 | ||
| @@ -116,8 +116,9 @@ public class CarsDataToolsImpl implements DataToolsService { | @@ -116,8 +116,9 @@ public class CarsDataToolsImpl implements DataToolsService { | ||
| 116 | File ktrFile = new File(this.getClass().getResource( | 116 | File ktrFile = new File(this.getClass().getResource( |
| 117 | dataToolsProperties.getCarsDataoutputktr()).toURI()); | 117 | dataToolsProperties.getCarsDataoutputktr()).toURI()); |
| 118 | 118 | ||
| 119 | - // 通用参数,转换文件路径,excel输出文件名 | 119 | + // 通用参数,转换文件路径,转换文件类路径,excel输出文件名 |
| 120 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); | 120 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); |
| 121 | + ktrParms.put("trans_class_path", dataToolsProperties.getCarsDataoutputktr()); | ||
| 121 | ktrParms.put("filename", "车辆基础信息_download-"); | 122 | ktrParms.put("filename", "车辆基础信息_download-"); |
| 122 | 123 | ||
| 123 | ktrParms.putAll(params); | 124 | ktrParms.putAll(params); |
src/main/java/com/bsth/service/schedule/datatools/EmployeeConfigInfoDataToolsImpl.java
| @@ -9,7 +9,6 @@ import org.slf4j.Logger; | @@ -9,7 +9,6 @@ import org.slf4j.Logger; | ||
| 9 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | import org.springframework.beans.factory.annotation.Qualifier; | 11 | import org.springframework.beans.factory.annotation.Qualifier; |
| 12 | -import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| 13 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
| 14 | 13 | ||
| 15 | import java.io.File; | 14 | import java.io.File; |
| @@ -88,8 +87,9 @@ public class EmployeeConfigInfoDataToolsImpl implements DataToolsService { | @@ -88,8 +87,9 @@ public class EmployeeConfigInfoDataToolsImpl implements DataToolsService { | ||
| 88 | File ktrFile = new File(this.getClass().getResource( | 87 | File ktrFile = new File(this.getClass().getResource( |
| 89 | dataToolsProperties.getEmployeesconfigDatainputktr()).toURI()); | 88 | dataToolsProperties.getEmployeesconfigDatainputktr()).toURI()); |
| 90 | 89 | ||
| 91 | - // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径 | 90 | + // 通用参数,转换文件路径,转换文件类路径,excel输入文件路径,错误输出文件路径 |
| 92 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); | 91 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); |
| 92 | + ktrParms.put("trans_class_path", dataToolsProperties.getEmployeesconfigDatainputktr()); | ||
| 93 | ktrParms.put("filepath", file.getAbsolutePath()); | 93 | ktrParms.put("filepath", file.getAbsolutePath()); |
| 94 | ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); | 94 | ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); |
| 95 | 95 | ||
| @@ -118,8 +118,9 @@ public class EmployeeConfigInfoDataToolsImpl implements DataToolsService { | @@ -118,8 +118,9 @@ public class EmployeeConfigInfoDataToolsImpl implements DataToolsService { | ||
| 118 | File ktrFile = new File(this.getClass().getResource( | 118 | File ktrFile = new File(this.getClass().getResource( |
| 119 | dataToolsProperties.getEmployeesconfigDataoutputktr()).toURI()); | 119 | dataToolsProperties.getEmployeesconfigDataoutputktr()).toURI()); |
| 120 | 120 | ||
| 121 | - // 通用参数,转换文件路径,excel输出文件名 | 121 | + // 通用参数,转换文件路径,转换文件类路径,excel输出文件名 |
| 122 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); | 122 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); |
| 123 | + ktrParms.put("trans_class_path", dataToolsProperties.getEmployeesconfigDataoutputktr()); | ||
| 123 | ktrParms.put("filename", "人员配置信息_download-"); | 124 | ktrParms.put("filename", "人员配置信息_download-"); |
| 124 | 125 | ||
| 125 | ktrParms.putAll(params); | 126 | ktrParms.putAll(params); |
src/main/java/com/bsth/service/schedule/datatools/EmployeeDataToolsImpl.java
| @@ -9,7 +9,6 @@ import org.slf4j.Logger; | @@ -9,7 +9,6 @@ import org.slf4j.Logger; | ||
| 9 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | import org.springframework.beans.factory.annotation.Qualifier; | 11 | import org.springframework.beans.factory.annotation.Qualifier; |
| 12 | -import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| 13 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
| 14 | 13 | ||
| 15 | import java.io.File; | 14 | import java.io.File; |
| @@ -88,8 +87,9 @@ public class EmployeeDataToolsImpl implements DataToolsService { | @@ -88,8 +87,9 @@ public class EmployeeDataToolsImpl implements DataToolsService { | ||
| 88 | File ktrFile = new File(this.getClass().getResource( | 87 | File ktrFile = new File(this.getClass().getResource( |
| 89 | dataToolsProperties.getEmployeesDatainputktr()).toURI()); | 88 | dataToolsProperties.getEmployeesDatainputktr()).toURI()); |
| 90 | 89 | ||
| 91 | - // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径 | 90 | + // 通用参数,转换文件路径,转换文件类路径,excel输入文件路径,错误输出文件路径 |
| 92 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); | 91 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); |
| 92 | + ktrParms.put("trans_class_path", dataToolsProperties.getEmployeesDatainputktr()); | ||
| 93 | ktrParms.put("filepath", file.getAbsolutePath()); | 93 | ktrParms.put("filepath", file.getAbsolutePath()); |
| 94 | ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); | 94 | ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); |
| 95 | 95 | ||
| @@ -116,8 +116,9 @@ public class EmployeeDataToolsImpl implements DataToolsService { | @@ -116,8 +116,9 @@ public class EmployeeDataToolsImpl implements DataToolsService { | ||
| 116 | File ktrFile = new File(this.getClass().getResource( | 116 | File ktrFile = new File(this.getClass().getResource( |
| 117 | dataToolsProperties.getEmployeesDataoutputktr()).toURI()); | 117 | dataToolsProperties.getEmployeesDataoutputktr()).toURI()); |
| 118 | 118 | ||
| 119 | - // 通用参数,转换文件路径,excel输出文件名 | 119 | + // 通用参数,转换文件路径,转换文件类路径,excel输出文件名 |
| 120 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); | 120 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); |
| 121 | + ktrParms.put("trans_class_path", dataToolsProperties.getEmployeesDataoutputktr()); | ||
| 121 | ktrParms.put("filename", "人员基础信息_download-"); | 122 | ktrParms.put("filename", "人员基础信息_download-"); |
| 122 | 123 | ||
| 123 | ktrParms.putAll(params); | 124 | ktrParms.putAll(params); |
src/main/java/com/bsth/service/schedule/datatools/GuideboardInfoDataToolsImpl.java
| @@ -9,7 +9,6 @@ import org.slf4j.Logger; | @@ -9,7 +9,6 @@ import org.slf4j.Logger; | ||
| 9 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | import org.springframework.beans.factory.annotation.Qualifier; | 11 | import org.springframework.beans.factory.annotation.Qualifier; |
| 12 | -import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| 13 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
| 14 | 13 | ||
| 15 | import java.io.File; | 14 | import java.io.File; |
| @@ -88,8 +87,9 @@ public class GuideboardInfoDataToolsImpl implements DataToolsService { | @@ -88,8 +87,9 @@ public class GuideboardInfoDataToolsImpl implements DataToolsService { | ||
| 88 | File ktrFile = new File(this.getClass().getResource( | 87 | File ktrFile = new File(this.getClass().getResource( |
| 89 | dataToolsProperties.getGuideboardsDatainputktr()).toURI()); | 88 | dataToolsProperties.getGuideboardsDatainputktr()).toURI()); |
| 90 | 89 | ||
| 91 | - // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径 | 90 | + // 通用参数,转换文件路径,转换文件类路径,excel输入文件路径,错误输出文件路径 |
| 92 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); | 91 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); |
| 92 | + ktrParms.put("trans_class_path", dataToolsProperties.getGuideboardsDatainputktr()); | ||
| 93 | ktrParms.put("filepath", file.getAbsolutePath()); | 93 | ktrParms.put("filepath", file.getAbsolutePath()); |
| 94 | ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); | 94 | ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); |
| 95 | 95 | ||
| @@ -118,8 +118,9 @@ public class GuideboardInfoDataToolsImpl implements DataToolsService { | @@ -118,8 +118,9 @@ public class GuideboardInfoDataToolsImpl implements DataToolsService { | ||
| 118 | File ktrFile = new File(this.getClass().getResource( | 118 | File ktrFile = new File(this.getClass().getResource( |
| 119 | dataToolsProperties.getGuideboardsDataoutputktr()).toURI()); | 119 | dataToolsProperties.getGuideboardsDataoutputktr()).toURI()); |
| 120 | 120 | ||
| 121 | - // 通用参数,转换文件路径,excel输出文件名 | 121 | + // 通用参数,转换文件路径,转换文件类路径,excel输出文件名 |
| 122 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); | 122 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); |
| 123 | + ktrParms.put("trans_class_path", dataToolsProperties.getGuideboardsDataoutputktr()); | ||
| 123 | ktrParms.put("filename", "路牌信息_download-"); | 124 | ktrParms.put("filename", "路牌信息_download-"); |
| 124 | 125 | ||
| 125 | ktrParms.putAll(params); | 126 | ktrParms.putAll(params); |
src/main/java/com/bsth/service/schedule/datatools/ScheduleRule1FlatDataToolsImpl.java
| @@ -9,7 +9,6 @@ import org.slf4j.Logger; | @@ -9,7 +9,6 @@ import org.slf4j.Logger; | ||
| 9 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | import org.springframework.beans.factory.annotation.Qualifier; | 11 | import org.springframework.beans.factory.annotation.Qualifier; |
| 12 | -import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| 13 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
| 14 | 13 | ||
| 15 | import java.io.File; | 14 | import java.io.File; |
| @@ -88,8 +87,9 @@ public class ScheduleRule1FlatDataToolsImpl implements DataToolsService { | @@ -88,8 +87,9 @@ public class ScheduleRule1FlatDataToolsImpl implements DataToolsService { | ||
| 88 | File ktrFile = new File(this.getClass().getResource( | 87 | File ktrFile = new File(this.getClass().getResource( |
| 89 | dataToolsProperties.getScheduleruleDatainputktr()).toURI()); | 88 | dataToolsProperties.getScheduleruleDatainputktr()).toURI()); |
| 90 | 89 | ||
| 91 | - // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径 | 90 | + // 通用参数,转换文件路径,转换文件类路径,excel输入文件路径,错误输出文件路径 |
| 92 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); | 91 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); |
| 92 | + ktrParms.put("trans_class_path", dataToolsProperties.getScheduleruleDatainputktr()); | ||
| 93 | ktrParms.put("filepath", file.getAbsolutePath()); | 93 | ktrParms.put("filepath", file.getAbsolutePath()); |
| 94 | ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); | 94 | ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); |
| 95 | 95 | ||
| @@ -118,8 +118,9 @@ public class ScheduleRule1FlatDataToolsImpl implements DataToolsService { | @@ -118,8 +118,9 @@ public class ScheduleRule1FlatDataToolsImpl implements DataToolsService { | ||
| 118 | File ktrFile = new File(this.getClass().getResource( | 118 | File ktrFile = new File(this.getClass().getResource( |
| 119 | dataToolsProperties.getScheduleruleOutput()).toURI()); | 119 | dataToolsProperties.getScheduleruleOutput()).toURI()); |
| 120 | 120 | ||
| 121 | - // 通用参数,转换文件路径,excel输出文件名 | 121 | + // 通用参数,转换文件路径,转换文件类路径,excel输出文件名 |
| 122 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); | 122 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); |
| 123 | + ktrParms.put("trans_class_path", dataToolsProperties.getScheduleruleOutput()); | ||
| 123 | ktrParms.put("filename", "排版规则信息_download-"); | 124 | ktrParms.put("filename", "排版规则信息_download-"); |
| 124 | 125 | ||
| 125 | ktrParms.putAll(params); | 126 | ktrParms.putAll(params); |
src/main/java/com/bsth/service/schedule/datatools/TTInfoDetailDataToolsImpl.java
| @@ -24,11 +24,12 @@ import org.slf4j.LoggerFactory; | @@ -24,11 +24,12 @@ import org.slf4j.LoggerFactory; | ||
| 24 | import org.springframework.beans.factory.annotation.Autowired; | 24 | import org.springframework.beans.factory.annotation.Autowired; |
| 25 | import org.springframework.beans.factory.annotation.Qualifier; | 25 | import org.springframework.beans.factory.annotation.Qualifier; |
| 26 | import org.springframework.stereotype.Service; | 26 | import org.springframework.stereotype.Service; |
| 27 | +import org.springframework.util.StreamUtils; | ||
| 27 | 28 | ||
| 28 | import java.awt.*; | 29 | import java.awt.*; |
| 29 | -import java.io.File; | ||
| 30 | -import java.io.PrintWriter; | ||
| 31 | -import java.io.StringWriter; | 30 | +import java.io.*; |
| 31 | +import java.nio.file.Files; | ||
| 32 | +import java.nio.file.Paths; | ||
| 32 | import java.util.*; | 33 | import java.util.*; |
| 33 | import java.util.List; | 34 | import java.util.List; |
| 34 | 35 | ||
| @@ -237,6 +238,7 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | @@ -237,6 +238,7 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | ||
| 237 | 238 | ||
| 238 | @Override | 239 | @Override |
| 239 | public DataToolsFile exportData(Map<String, Object> params) throws ScheduleException { | 240 | public DataToolsFile exportData(Map<String, Object> params) throws ScheduleException { |
| 241 | + File template_ktr_temp_file = null; | ||
| 240 | try { | 242 | try { |
| 241 | LOGGER.info("//---------------- 导出时刻表明细 start... ----------------//"); | 243 | LOGGER.info("//---------------- 导出时刻表明细 start... ----------------//"); |
| 242 | 244 | ||
| @@ -247,12 +249,31 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | @@ -247,12 +249,31 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | ||
| 247 | File ktrFile2 = new File(this.getClass().getResource( | 249 | File ktrFile2 = new File(this.getClass().getResource( |
| 248 | dataToolsProperties.getTtinfodetailOutput()).toURI()); | 250 | dataToolsProperties.getTtinfodetailOutput()).toURI()); |
| 249 | 251 | ||
| 250 | - // 通用参数,转换文件路径,excel输出文件名 | 252 | + // 通用参数,转换文件路径,转换文件类路径,excel输出文件名 |
| 251 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); | 253 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); |
| 254 | + ktrParms.put("trans_class_path", dataToolsProperties.getTtinfodetailMetaoutput()); | ||
| 252 | ktrParms.put("filename", String.format("时刻表_(id=%s)_download-", String.valueOf(params.get("ttinfoid")))); | 255 | ktrParms.put("filename", String.format("时刻表_(id=%s)_download-", String.valueOf(params.get("ttinfoid")))); |
| 253 | 256 | ||
| 257 | + //---------------------- 计算template ktr(以下)-------------------// | ||
| 258 | + /** | ||
| 259 | + * trans_class_path 指定的ktr内部使用了 ETL Metadata Injection 步骤,内部的模版ktr必须是一个外部文件路径,无法是流 | ||
| 260 | + * 所以这里从类路径获取模版ktr流,生成一个临时ktr保存到临时目录,传递给 injectktrfile 变量 | ||
| 261 | + */ | ||
| 262 | + InputStream template_ktr_input_stream = this.getClass().getResourceAsStream( | ||
| 263 | + dataToolsProperties.getTtinfodetailOutput()); | ||
| 264 | + template_ktr_temp_file = Files.createTempFile( | ||
| 265 | + Paths.get(dataToolsProperties.getTransTempdir()), | ||
| 266 | + "ttInfoDetailEditTemplate_ktr_" + new DateTime().toString("yyyyMMddHHmmss"), | ||
| 267 | + ".ktr").toFile(); | ||
| 268 | + FileOutputStream template_ktr_output_stream = new FileOutputStream(template_ktr_temp_file); | ||
| 269 | + | ||
| 270 | + StreamUtils.copy(template_ktr_input_stream, template_ktr_output_stream); | ||
| 271 | + | ||
| 272 | + //---------------------- 计算template ktr(以上)-------------------// | ||
| 273 | + | ||
| 254 | // 附加参数 | 274 | // 附加参数 |
| 255 | - ktrParms.put("injectktrfile", ktrFile2.getAbsolutePath()); // 注入元数据的ktr文件 | 275 | +// ktrParms.put("injectktrfile", ktrFile2.getAbsolutePath()); // 注入元数据的ktr文件 |
| 276 | + ktrParms.put("injectktrfile", template_ktr_temp_file.getAbsolutePath()); // 注入元数据的ktr文件 | ||
| 256 | ktrParms.put("ttinfoid", String.valueOf(params.get("ttinfoid"))); | 277 | ktrParms.put("ttinfoid", String.valueOf(params.get("ttinfoid"))); |
| 257 | 278 | ||
| 258 | DataToolsFile file = dataToolsService.exportData(ktrParms); | 279 | DataToolsFile file = dataToolsService.exportData(ktrParms); |
| @@ -312,6 +333,10 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | @@ -312,6 +333,10 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | ||
| 312 | LOGGER.info(sw.toString()); | 333 | LOGGER.info(sw.toString()); |
| 313 | 334 | ||
| 314 | throw new ScheduleException(exp.getMessage()); | 335 | throw new ScheduleException(exp.getMessage()); |
| 336 | + } finally { | ||
| 337 | + if (template_ktr_temp_file != null && template_ktr_temp_file.exists()) { | ||
| 338 | + template_ktr_temp_file.delete(); | ||
| 339 | + } | ||
| 315 | } | 340 | } |
| 316 | } | 341 | } |
| 317 | 342 | ||
| @@ -325,8 +350,9 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | @@ -325,8 +350,9 @@ public class TTInfoDetailDataToolsImpl implements DataToolsService, TTInfoDetail | ||
| 325 | File ktrFile = new File(this.getClass().getResource( | 350 | File ktrFile = new File(this.getClass().getResource( |
| 326 | dataToolsProperties.getTtinfodetailForeditktr()).toURI()); | 351 | dataToolsProperties.getTtinfodetailForeditktr()).toURI()); |
| 327 | 352 | ||
| 328 | - // 通用参数,转换文件路径,excel输出文件名,错误输出文件路径 | 353 | + // 通用参数,转换文件路径,转换文件类路径,excel输出文件名,错误输出文件路径 |
| 329 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); | 354 | ktrParms.put("transpath", ktrFile.getAbsolutePath()); |
| 355 | + ktrParms.put("trans_class_path", dataToolsProperties.getTtinfodetailForeditktr()); | ||
| 330 | ktrParms.put("filename", "todo"); | 356 | ktrParms.put("filename", "todo"); |
| 331 | 357 | ||
| 332 | // 附加参数 | 358 | // 附加参数 |
src/main/java/com/bsth/service/schedule/timetable/strategy/impl/TimetableExcelDataImportStrategyImpl.java
| @@ -11,10 +11,16 @@ import jxl.write.WritableSheet; | @@ -11,10 +11,16 @@ import jxl.write.WritableSheet; | ||
| 11 | import jxl.write.WritableWorkbook; | 11 | import jxl.write.WritableWorkbook; |
| 12 | import org.apache.commons.lang3.StringUtils; | 12 | import org.apache.commons.lang3.StringUtils; |
| 13 | import org.apache.poi.ss.usermodel.Sheet; | 13 | import org.apache.poi.ss.usermodel.Sheet; |
| 14 | +import org.joda.time.DateTime; | ||
| 14 | import org.slf4j.Logger; | 15 | import org.slf4j.Logger; |
| 15 | import org.slf4j.LoggerFactory; | 16 | import org.slf4j.LoggerFactory; |
| 17 | +import org.springframework.util.StreamUtils; | ||
| 16 | 18 | ||
| 17 | import java.io.File; | 19 | import java.io.File; |
| 20 | +import java.io.FileOutputStream; | ||
| 21 | +import java.io.InputStream; | ||
| 22 | +import java.nio.file.Files; | ||
| 23 | +import java.nio.file.Paths; | ||
| 18 | import java.util.ArrayList; | 24 | import java.util.ArrayList; |
| 19 | import java.util.List; | 25 | import java.util.List; |
| 20 | import java.util.Map; | 26 | import java.util.Map; |
| @@ -145,35 +151,83 @@ public class TimetableExcelDataImportStrategyImpl implements TimetableExcelDataI | @@ -145,35 +151,83 @@ public class TimetableExcelDataImportStrategyImpl implements TimetableExcelDataI | ||
| 145 | } | 151 | } |
| 146 | 152 | ||
| 147 | // 3-3、计算ktr路径相关参数 | 153 | // 3-3、计算ktr路径相关参数 |
| 154 | + File template_ktr_temp_file = null; | ||
| 148 | try { | 155 | try { |
| 149 | // 元数据ktr | 156 | // 元数据ktr |
| 150 | File mktrFile = new File(this.getClass().getResource( | 157 | File mktrFile = new File(this.getClass().getResource( |
| 151 | dataToolsProperties.getTtinfodetailMetadatainputktr()).toURI()); | 158 | dataToolsProperties.getTtinfodetailMetadatainputktr()).toURI()); |
| 152 | ktrParams.put("transpath", mktrFile.getAbsolutePath()); | 159 | ktrParams.put("transpath", mktrFile.getAbsolutePath()); |
| 160 | + ktrParams.put("trans_class_path", dataToolsProperties.getTtinfodetailMetadatainputktr()); | ||
| 153 | 161 | ||
| 154 | // 实际数据ktr | 162 | // 实际数据ktr |
| 155 | if (timetableExcelFormatType == TimetableExcelFormatType.Normal) { | 163 | if (timetableExcelFormatType == TimetableExcelFormatType.Normal) { |
| 156 | - File normal_ktrFile = new File(this.getClass().getResource( | ||
| 157 | - dataToolsProperties.getTtinfodetailDatainputktr2version()).toURI()); | ||
| 158 | - ktrParams.put("injectktrfile", normal_ktrFile.getAbsolutePath()); | 164 | +// File normal_ktrFile = new File(this.getClass().getResource( |
| 165 | +// dataToolsProperties.getTtinfodetailDatainputktr2version()).toURI()); | ||
| 166 | +// ktrParams.put("injectktrfile", normal_ktrFile.getAbsolutePath()); | ||
| 167 | + template_ktr_temp_file = generateTemplateKtrFile( | ||
| 168 | + "ttInfo_input_normal_template_ktr_", | ||
| 169 | + ".ktr", | ||
| 170 | + dataToolsProperties.getTtinfodetailDatainputktr2version(), | ||
| 171 | + dataToolsProperties.getTransTempdir() | ||
| 172 | + ); | ||
| 173 | + ktrParams.put("injectktrfile", template_ktr_temp_file.getAbsolutePath()); | ||
| 159 | } else if (timetableExcelFormatType == TimetableExcelFormatType.NormalWithGs) { | 174 | } else if (timetableExcelFormatType == TimetableExcelFormatType.NormalWithGs) { |
| 160 | - File noramlwithgs_ktrFile = new File(this.getClass().getResource( | ||
| 161 | - dataToolsProperties.getTtinfodetailDatainputktr2normalwithgs()).toURI()); | ||
| 162 | - ktrParams.put("injectktrfile", noramlwithgs_ktrFile.getAbsolutePath()); | 175 | +// File noramlwithgs_ktrFile = new File(this.getClass().getResource( |
| 176 | +// dataToolsProperties.getTtinfodetailDatainputktr2normalwithgs()).toURI()); | ||
| 177 | +// ktrParams.put("injectktrfile", noramlwithgs_ktrFile.getAbsolutePath()); | ||
| 178 | + template_ktr_temp_file = generateTemplateKtrFile( | ||
| 179 | + "ttInfo_input_noramlwithgs_template_ktr_", | ||
| 180 | + ".ktr", | ||
| 181 | + dataToolsProperties.getTtinfodetailDatainputktr2normalwithgs(), | ||
| 182 | + dataToolsProperties.getTransTempdir() | ||
| 183 | + ); | ||
| 184 | + ktrParams.put("injectktrfile", template_ktr_temp_file.getAbsolutePath()); | ||
| 163 | } else if (timetableExcelFormatType == TimetableExcelFormatType.Dynamic) { | 185 | } else if (timetableExcelFormatType == TimetableExcelFormatType.Dynamic) { |
| 164 | - File dynamic_ktrFile = new File(this.getClass().getResource( | ||
| 165 | - dataToolsProperties.getTtinfodetailDatainputktr2version2()).toURI()); | ||
| 166 | - ktrParams.put("injectktrfile", dynamic_ktrFile.getAbsolutePath()); | 186 | +// File dynamic_ktrFile = new File(this.getClass().getResource( |
| 187 | +// dataToolsProperties.getTtinfodetailDatainputktr2version2()).toURI()); | ||
| 188 | +// ktrParams.put("injectktrfile", dynamic_ktrFile.getAbsolutePath()); | ||
| 189 | + template_ktr_temp_file = generateTemplateKtrFile( | ||
| 190 | + "ttInfo_input_dynamic_template_ktr_", | ||
| 191 | + ".ktr", | ||
| 192 | + dataToolsProperties.getTtinfodetailDatainputktr2version2(), | ||
| 193 | + dataToolsProperties.getTransTempdir() | ||
| 194 | + ); | ||
| 195 | + ktrParams.put("injectktrfile", template_ktr_temp_file.getAbsolutePath()); | ||
| 167 | } else { | 196 | } else { |
| 168 | throw new ScheduleException("未知的TimetableExcelFormatType格式[" + timetableExcelFormatType + "]"); | 197 | throw new ScheduleException("未知的TimetableExcelFormatType格式[" + timetableExcelFormatType + "]"); |
| 169 | } | 198 | } |
| 170 | 199 | ||
| 200 | + // 3-4、执行ktr | ||
| 201 | + dataToolsService.importData(fileCal, ktrParams); | ||
| 202 | + | ||
| 171 | } catch (Exception exp) { | 203 | } catch (Exception exp) { |
| 172 | exp.printStackTrace(); | 204 | exp.printStackTrace(); |
| 173 | throw new ScheduleException("导入时刻表异常!"); | 205 | throw new ScheduleException("导入时刻表异常!"); |
| 206 | + } finally { | ||
| 207 | + if (template_ktr_temp_file != null && template_ktr_temp_file.exists()) { | ||
| 208 | + template_ktr_temp_file.delete(); | ||
| 209 | + } | ||
| 174 | } | 210 | } |
| 175 | 211 | ||
| 176 | - // 3-4、执行ktr | ||
| 177 | - dataToolsService.importData(fileCal, ktrParams); | 212 | + } |
| 213 | + | ||
| 214 | + /** | ||
| 215 | + * trans_class_path 指定的ktr内部使用了 ETL Metadata Injection 步骤,内部的模版ktr必须是一个外部文件路径,无法是流 | ||
| 216 | + * 所以这里从类路径获取模版ktr流,生成一个临时ktr保存到临时目录,传递给 injectktrfile 变量 | ||
| 217 | + */ | ||
| 218 | + private File generateTemplateKtrFile( | ||
| 219 | + String filePrefix, String fileSuffix, | ||
| 220 | + String fileClassPath, String fileDir) throws Exception { | ||
| 221 | + InputStream template_ktr_input_stream = this.getClass().getResourceAsStream(fileClassPath); | ||
| 222 | + File template_ktr_temp_file = Files.createTempFile( | ||
| 223 | + Paths.get(fileDir), | ||
| 224 | + filePrefix + new DateTime().toString("yyyyMMddHHmmss"), | ||
| 225 | + fileSuffix).toFile(); | ||
| 226 | + FileOutputStream template_ktr_output_stream = new FileOutputStream(template_ktr_temp_file); | ||
| 227 | + | ||
| 228 | + StreamUtils.copy(template_ktr_input_stream, template_ktr_output_stream); | ||
| 229 | + | ||
| 230 | + return template_ktr_temp_file; | ||
| 231 | + | ||
| 178 | } | 232 | } |
| 179 | } | 233 | } |
src/main/java/com/bsth/service/schedule/timetable/strategy/impl/TimetableExcelWithPlanInfoExportStrategyImpl.java
| @@ -9,10 +9,16 @@ import jxl.write.Label; | @@ -9,10 +9,16 @@ import jxl.write.Label; | ||
| 9 | import jxl.write.WritableSheet; | 9 | import jxl.write.WritableSheet; |
| 10 | import jxl.write.WritableWorkbook; | 10 | import jxl.write.WritableWorkbook; |
| 11 | import org.apache.poi.ss.usermodel.Row; | 11 | import org.apache.poi.ss.usermodel.Row; |
| 12 | +import org.joda.time.DateTime; | ||
| 12 | import org.slf4j.Logger; | 13 | import org.slf4j.Logger; |
| 13 | import org.slf4j.LoggerFactory; | 14 | import org.slf4j.LoggerFactory; |
| 15 | +import org.springframework.util.StreamUtils; | ||
| 14 | 16 | ||
| 15 | import java.io.File; | 17 | import java.io.File; |
| 18 | +import java.io.FileOutputStream; | ||
| 19 | +import java.io.InputStream; | ||
| 20 | +import java.nio.file.Files; | ||
| 21 | +import java.nio.file.Paths; | ||
| 16 | import java.time.ZoneId; | 22 | import java.time.ZoneId; |
| 17 | import java.time.format.DateTimeFormatter; | 23 | import java.time.format.DateTimeFormatter; |
| 18 | import java.util.*; | 24 | import java.util.*; |
| @@ -33,6 +39,8 @@ public class TimetableExcelWithPlanInfoExportStrategyImpl implements TimetableEx | @@ -33,6 +39,8 @@ public class TimetableExcelWithPlanInfoExportStrategyImpl implements TimetableEx | ||
| 33 | 39 | ||
| 34 | LOG.info("---------------- 开始导出线路=[{}],日期=[{}]排班时刻信息... --------------", xl.getName(), scheduleDate); | 40 | LOG.info("---------------- 开始导出线路=[{}],日期=[{}]排班时刻信息... --------------", xl.getName(), scheduleDate); |
| 35 | 41 | ||
| 42 | + File template_ktr_temp_file = null; | ||
| 43 | + | ||
| 36 | try { | 44 | try { |
| 37 | // ---------- 1-1、创建ktr参数 --------- // | 45 | // ---------- 1-1、创建ktr参数 --------- // |
| 38 | Map<String, Object> ktrParams = new HashMap<>(); | 46 | Map<String, Object> ktrParams = new HashMap<>(); |
| @@ -43,12 +51,33 @@ public class TimetableExcelWithPlanInfoExportStrategyImpl implements TimetableEx | @@ -43,12 +51,33 @@ public class TimetableExcelWithPlanInfoExportStrategyImpl implements TimetableEx | ||
| 43 | File ktrFile = new File(this.getClass().getResource( | 51 | File ktrFile = new File(this.getClass().getResource( |
| 44 | dataToolsProperties.getTtinfodetailPlaninfoOutput()).toURI()); | 52 | dataToolsProperties.getTtinfodetailPlaninfoOutput()).toURI()); |
| 45 | 53 | ||
| 46 | - // 通用参数,转换文件路径,excel输出文件名 | 54 | + // 通用参数,转换文件路径,转换文件类路径,excel输出文件名 |
| 47 | ktrParams.put("transpath", ktrMetaFile.getAbsolutePath()); | 55 | ktrParams.put("transpath", ktrMetaFile.getAbsolutePath()); |
| 56 | + ktrParams.put("trans_class_path", dataToolsProperties.getTtinfodetailPlaninfoMetaoutput()); | ||
| 48 | ktrParams.put("filename", "排班时刻表导出数据temp"); | 57 | ktrParams.put("filename", "排班时刻表导出数据temp"); |
| 58 | + | ||
| 59 | + //---------------------- 计算template ktr(以下)-------------------// | ||
| 60 | + /** | ||
| 61 | + * trans_class_path 指定的ktr内部使用了 ETL Metadata Injection 步骤,内部的模版ktr必须是一个外部文件路径,无法是流 | ||
| 62 | + * 所以这里从类路径获取模版ktr流,生成一个临时ktr保存到临时目录,传递给 injectktrfile 变量 | ||
| 63 | + */ | ||
| 64 | + InputStream template_ktr_input_stream = this.getClass().getResourceAsStream( | ||
| 65 | + dataToolsProperties.getTtinfodetailPlaninfoOutput()); | ||
| 66 | + template_ktr_temp_file = Files.createTempFile( | ||
| 67 | + Paths.get(dataToolsProperties.getTransTempdir()), | ||
| 68 | + "planInfoOutputTemplate_ktr_" + new DateTime().toString("yyyyMMddHHmmss"), | ||
| 69 | + ".ktr").toFile(); | ||
| 70 | + FileOutputStream template_ktr_output_stream = new FileOutputStream(template_ktr_temp_file); | ||
| 71 | + | ||
| 72 | + StreamUtils.copy(template_ktr_input_stream, template_ktr_output_stream); | ||
| 73 | + | ||
| 74 | + //---------------------- 计算template ktr(以上)-------------------// | ||
| 75 | + | ||
| 76 | + | ||
| 49 | // ktr附加命名参数 | 77 | // ktr附加命名参数 |
| 78 | +// ktrParams.put("injectktrfile", ktrFile.getAbsolutePath()); // 注入元数据的ktr文件 | ||
| 79 | + ktrParams.put("injectktrfile", template_ktr_temp_file.getAbsolutePath()); // 注入元数据的ktr文件 | ||
| 50 | ktrParams.put("xlid", xl.getId()); // 线路Id | 80 | ktrParams.put("xlid", xl.getId()); // 线路Id |
| 51 | - ktrParams.put("injectktrfile", ktrFile.getAbsolutePath()); // 注入元数据的ktr文件 | ||
| 52 | ktrParams.put("sdate", scheduleDate.toInstant() | 81 | ktrParams.put("sdate", scheduleDate.toInstant() |
| 53 | .atZone(ZoneId.systemDefault()).toLocalDate() | 82 | .atZone(ZoneId.systemDefault()).toLocalDate() |
| 54 | .format(DateTimeFormatter.ISO_DATE)); // 排班日期 | 83 | .format(DateTimeFormatter.ISO_DATE)); // 排班日期 |
| @@ -106,6 +135,10 @@ public class TimetableExcelWithPlanInfoExportStrategyImpl implements TimetableEx | @@ -106,6 +135,10 @@ public class TimetableExcelWithPlanInfoExportStrategyImpl implements TimetableEx | ||
| 106 | } catch (Exception exp) { | 135 | } catch (Exception exp) { |
| 107 | LOG.error("---------------- 导出线路=[{}],日期=[{}]排班时刻信息失败! --------------", xl.getName(), scheduleDate); | 136 | LOG.error("---------------- 导出线路=[{}],日期=[{}]排班时刻信息失败! --------------", xl.getName(), scheduleDate); |
| 108 | throw new ScheduleException(exp); | 137 | throw new ScheduleException(exp); |
| 138 | + } finally { | ||
| 139 | + if (template_ktr_temp_file != null && template_ktr_temp_file.exists()) { | ||
| 140 | + template_ktr_temp_file.delete(); | ||
| 141 | + } | ||
| 109 | } | 142 | } |
| 110 | 143 | ||
| 111 | } | 144 | } |
src/main/java/com/bsth/service/schedule/timetable/strategy/impl/TimetableExcelWithPlanInfoViewStrategyImpl.java
| @@ -40,8 +40,9 @@ public class TimetableExcelWithPlanInfoViewStrategyImpl implements TimetableExce | @@ -40,8 +40,9 @@ public class TimetableExcelWithPlanInfoViewStrategyImpl implements TimetableExce | ||
| 40 | File ktrFile = new File(this.getClass().getResource( | 40 | File ktrFile = new File(this.getClass().getResource( |
| 41 | dataToolsProperties.getTtinfodetailPlaninfoOutputEdit()).toURI()); | 41 | dataToolsProperties.getTtinfodetailPlaninfoOutputEdit()).toURI()); |
| 42 | 42 | ||
| 43 | - // 通用参数,转换文件路径,excel输出文件名 | 43 | + // 通用参数,转换文件路径,转换文件类路径,excel输出文件名 |
| 44 | ktrParams.put("transpath", ktrFile.getAbsolutePath()); | 44 | ktrParams.put("transpath", ktrFile.getAbsolutePath()); |
| 45 | + ktrParams.put("trans_class_path", dataToolsProperties.getTtinfodetailPlaninfoOutputEdit()); | ||
| 45 | ktrParams.put("filename", "排班时刻表导出edit数据"); | 46 | ktrParams.put("filename", "排班时刻表导出edit数据"); |
| 46 | // ktr附加命名参数 | 47 | // ktr附加命名参数 |
| 47 | ktrParams.put("xlid", xl.getId()); // 线路Id | 48 | ktrParams.put("xlid", xl.getId()); // 线路Id |
src/main/java/com/bsth/service/schedule/utils/DataToolsServiceImpl.java
| @@ -157,6 +157,12 @@ public class DataToolsServiceImpl implements DataToolsService { | @@ -157,6 +157,12 @@ public class DataToolsServiceImpl implements DataToolsService { | ||
| 157 | "没有指定transpath参数值,无法确定ktr转换文件!"); | 157 | "没有指定transpath参数值,无法确定ktr转换文件!"); |
| 158 | } | 158 | } |
| 159 | File ktrFile = new File(transpath); | 159 | File ktrFile = new File(transpath); |
| 160 | + | ||
| 161 | + String transClassPath = String.valueOf(params.get("trans_class_path")); | ||
| 162 | + if ("null".equals(transClassPath)) { | ||
| 163 | + throw new Exception("没有指定 trans_class_path 参数值,无法确定ktr转换文件!"); | ||
| 164 | + } | ||
| 165 | + | ||
| 160 | // 设置文件路径,错误输出文件路径参数 | 166 | // 设置文件路径,错误输出文件路径参数 |
| 161 | params.put("filepath", file.getAbsolutePath()); | 167 | params.put("filepath", file.getAbsolutePath()); |
| 162 | params.put("erroroutputdir", dataToolsProperties.getTransErrordir()); | 168 | params.put("erroroutputdir", dataToolsProperties.getTransErrordir()); |
| @@ -164,7 +170,16 @@ public class DataToolsServiceImpl implements DataToolsService { | @@ -164,7 +170,16 @@ public class DataToolsServiceImpl implements DataToolsService { | ||
| 164 | // 2、使用kettle运行封装数据导入逻辑的ktr转换文件 | 170 | // 2、使用kettle运行封装数据导入逻辑的ktr转换文件 |
| 165 | // 2.1、初始化kettle(组件初始化已经做了) | 171 | // 2.1、初始化kettle(组件初始化已经做了) |
| 166 | // 2.2、创建转换元数据,转换 | 172 | // 2.2、创建转换元数据,转换 |
| 167 | - TransMeta transMeta = new TransMeta(ktrFile.getAbsolutePath()); | 173 | +// TransMeta transMeta = new TransMeta(ktrFile.getAbsolutePath()); |
| 174 | + | ||
| 175 | + // 使用流方式载入ktr | ||
| 176 | + TransMeta transMeta = new TransMeta( | ||
| 177 | + this.getClass().getResourceAsStream(transClassPath), | ||
| 178 | + null, | ||
| 179 | + true, | ||
| 180 | + null, | ||
| 181 | + null); | ||
| 182 | + | ||
| 168 | Trans trans = new Trans(transMeta); | 183 | Trans trans = new Trans(transMeta); |
| 169 | // 2.3、设定命名参数,用于指定数据文件,注意每个ktr必须都有以下指定的命名参数 | 184 | // 2.3、设定命名参数,用于指定数据文件,注意每个ktr必须都有以下指定的命名参数 |
| 170 | for (String key : params.keySet()) { | 185 | for (String key : params.keySet()) { |
| @@ -225,6 +240,12 @@ public class DataToolsServiceImpl implements DataToolsService { | @@ -225,6 +240,12 @@ public class DataToolsServiceImpl implements DataToolsService { | ||
| 225 | "没有指定transpath参数值,无法确定ktr转换文件!"); | 240 | "没有指定transpath参数值,无法确定ktr转换文件!"); |
| 226 | } | 241 | } |
| 227 | File ktrFile = new File(transpath); | 242 | File ktrFile = new File(transpath); |
| 243 | + | ||
| 244 | + String transClassPath = String.valueOf(params.get("trans_class_path")); | ||
| 245 | + if ("null".equals(transClassPath)) { | ||
| 246 | + throw new Exception("没有指定 trans_class_path 参数值,无法确定ktr转换文件!"); | ||
| 247 | + } | ||
| 248 | + | ||
| 228 | // 设置文件路径参数 | 249 | // 设置文件路径参数 |
| 229 | String filepath = dataToolsProperties.getFileoutputDir() + | 250 | String filepath = dataToolsProperties.getFileoutputDir() + |
| 230 | File.separator + | 251 | File.separator + |
| @@ -238,7 +259,16 @@ public class DataToolsServiceImpl implements DataToolsService { | @@ -238,7 +259,16 @@ public class DataToolsServiceImpl implements DataToolsService { | ||
| 238 | // 2、使用kettle运行封装数据导入逻辑的ktr转换文件 | 259 | // 2、使用kettle运行封装数据导入逻辑的ktr转换文件 |
| 239 | // 2.1、初始化kettle(组件初始化已经做了) | 260 | // 2.1、初始化kettle(组件初始化已经做了) |
| 240 | // 2.2、创建转换元数据,转换 | 261 | // 2.2、创建转换元数据,转换 |
| 241 | - TransMeta transMeta = new TransMeta(ktrFile.getAbsolutePath()); | 262 | +// TransMeta transMeta = new TransMeta(ktrFile.getAbsolutePath()); |
| 263 | + | ||
| 264 | + // 使用流方式载入ktr | ||
| 265 | + TransMeta transMeta = new TransMeta( | ||
| 266 | + this.getClass().getResourceAsStream(transClassPath), | ||
| 267 | + null, | ||
| 268 | + true, | ||
| 269 | + null, | ||
| 270 | + null); | ||
| 271 | + | ||
| 242 | Trans trans = new Trans(transMeta); | 272 | Trans trans = new Trans(transMeta); |
| 243 | // 2.3、设定命名参数,用于指定数据文件,注意每个ktr必须都有以下指定的命名参数 | 273 | // 2.3、设定命名参数,用于指定数据文件,注意每个ktr必须都有以下指定的命名参数 |
| 244 | for (String key : params.keySet()) { | 274 | for (String key : params.keySet()) { |