Commit 80c9d172cfd7caa8a7081169b347ee2aa1974ce5

Authored by 徐烜
1 parent 65efc647

浦东调度车辆信息同步etl更新

车辆库命名参数url由程序传入,修改配置文件和相关代码
1、修改datatools下的config-*.properties所有配置文件,添加car_interface参数
2、修改DataToolsProperties.java设定car_interface属性
3、修改VehicleDataSyncTaskThread.java设置ktr命名参数url
4、修改VehicleDataSyncTaskThread.java,内部判断车辆自编号参数,时间范围参数的有效性和优先级,具体程序中和ktr中都有说明
src/main/java/com/bsth/service/schedule/datasync/VehicleDataSyncTaskServiceImpl.java
... ... @@ -230,7 +230,7 @@ public class VehicleDataSyncTaskServiceImpl extends BServiceImpl<VehicleDataSync
230 230 try {
231 231 Path rootPath = VehicleDataSyncTaskThread.getLogbackFilePath();
232 232 Path logFilePath = Paths.get(rootPath.toString(), "datasync", "vehicle", fileName);
233   - return logFilePath.toFile();
  233 + file = logFilePath.toFile();
234 234 } catch (Exception exp) {
235 235 exp.printStackTrace();
236 236 }
... ...
src/main/java/com/bsth/service/schedule/datasync/task/VehicleDataSyncTaskThread.java
... ... @@ -3,6 +3,7 @@ package com.bsth.service.schedule.datasync.task;
3 3 import ch.qos.logback.classic.LoggerContext;
4 4 import ch.qos.logback.core.FileAppender;
5 5 import com.bsth.entity.schedule.datasync.VehicleDataSyncTask;
  6 +import com.bsth.service.schedule.exception.ScheduleException;
6 7 import com.bsth.service.schedule.utils.DataToolsProperties;
7 8 import com.bsth.service.schedule.utils.DataToolsServiceImpl;
8 9 import lombok.AllArgsConstructor;
... ... @@ -27,6 +28,7 @@ import java.io.PrintWriter;
27 28 import java.io.StringWriter;
28 29 import java.nio.file.Path;
29 30 import java.nio.file.Paths;
  31 +import java.util.Date;
30 32 import java.util.HashMap;
31 33 import java.util.Map;
32 34 import java.util.concurrent.CountDownLatch;
... ... @@ -74,11 +76,24 @@ public class VehicleDataSyncTaskThread implements Runnable {
74 76 dataToolsProperties.getVehicleDatasyncktr()).toURI());
75 77 // 2、创建命名参数
76 78 Map<String, String> ktrNamedParams = new HashMap<>();
77   - ktrNamedParams.put("paramClzbh", vehicleDataSyncTask.getParamClzbh());
78   - ktrNamedParams.put("paramFrom", vehicleDataSyncTask.getParamFrom() == null ?
79   - null : DateFormatUtils.format(vehicleDataSyncTask.getParamFrom(), "yyyy-MM-dd") + " 00:00:00");
80   - ktrNamedParams.put("paramTo", vehicleDataSyncTask.getParamTo() == null ?
81   - null : DateFormatUtils.format(vehicleDataSyncTask.getParamTo(), "yyyy-MM-dd") + " 23:59:59");
  79 + // 2-1、车辆库车辆信息url参数
  80 + ktrNamedParams.put("url", this.dataToolsProperties.getCarsInterface());
  81 + // 2-2、验证自编号参数,时间参数
  82 + String paramClzbh = vehicleDataSyncTask.getParamClzbh();
  83 + Date paramFrom = vehicleDataSyncTask.getParamFrom();
  84 + Date paramTo = vehicleDataSyncTask.getParamTo();
  85 + if (StringUtils.isNotBlank(paramClzbh)) { // 有车辆自编号参数先判断(优先级最高)
  86 + ktrNamedParams.put("paramClzbh", paramClzbh);
  87 + ktrNamedParams.put("paramFrom", null);
  88 + ktrNamedParams.put("paramTo", null);
  89 + } else if (paramFrom != null && paramTo != null) { // 其次是时间参数
  90 + ktrNamedParams.put("paramClzbh", null);
  91 + ktrNamedParams.put("paramFrom", DateFormatUtils.format(paramFrom, "yyyy-MM-dd") + " 00:00:00");
  92 + ktrNamedParams.put("paramTo", DateFormatUtils.format(paramTo, "yyyy-MM-dd") + " 23:59:59");
  93 + } else {
  94 + throw new ScheduleException("车辆信息同步参数异常,车辆参数为空,时间参数为空或部分为空!");
  95 + }
  96 + // 2-3、其他参数
82 97 Path fileDir = Paths.get(VehicleDataSyncTaskThread.getLogbackFilePath().toString(), "datasync", "vehicle");
83 98 String filePrefix = String.format(KTR_FILE_PREFIX_PATTERN, MDC.get("taskLogKey"));
84 99 ktrNamedParams.put("file_validate_error", Paths.get(fileDir.toString(),
... ...
src/main/java/com/bsth/service/schedule/utils/DataToolsProperties.java
... ... @@ -125,6 +125,9 @@ public class DataToolsProperties {
125 125 @NotNull
126 126 /** 车辆信息同步 */
127 127 private String vehicleDatasyncktr;
  128 + @NotNull
  129 + /** 浦东车辆库车辆数据接口地址 */
  130 + private String carsInterface;
128 131  
129 132 // TODO:
130 133  
... ... @@ -391,4 +394,12 @@ public class DataToolsProperties {
391 394 public void setVehicleDatasyncktr(String vehicleDatasyncktr) {
392 395 this.vehicleDatasyncktr = vehicleDatasyncktr;
393 396 }
  397 +
  398 + public String getCarsInterface() {
  399 + return carsInterface;
  400 + }
  401 +
  402 + public void setCarsInterface(String carsInterface) {
  403 + this.carsInterface = carsInterface;
  404 + }
394 405 }
... ...
src/main/resources/datatools/config-cloud.properties
... ... @@ -82,4 +82,8 @@ datatools.guideboards_dataoutputktr=/datatools/ktrs/guideboardDataOutput.ktr
82 82 ##--------------------------- 数据同步ktr ------------------------##
83 83 datatools.vehicle_datasyncktr=/datatools/ktrs/vehicleDataSync.ktr
84 84  
  85 +# 车辆库访问url
  86 +datatools.cars_interface=http://180.166.5.82:8076/cars/getCarsInterface
  87 +#datatools.cars_interface=http://192.170.101.132:8076/cars/getCarsInterface
  88 +
85 89 # TODO:
... ...
src/main/resources/datatools/config-dev.properties
... ... @@ -82,6 +82,10 @@ datatools.guideboards_dataoutputktr=/datatools/ktrs/guideboardDataOutput.ktr
82 82 ##--------------------------- 数据同步ktr ------------------------##
83 83 datatools.vehicle_datasyncktr=/datatools/ktrs/vehicleDataSync.ktr
84 84  
  85 +# 车辆库访问url
  86 +datatools.cars_interface=http://180.166.5.82:8076/cars/getCarsInterface
  87 +#datatools.cars_interface=http://192.170.101.132:8076/cars/getCarsInterface
  88 +
85 89 # TODO:
86 90  
87 91  
... ...
src/main/resources/datatools/config-prod.properties
... ... @@ -82,4 +82,8 @@ datatools.guideboards_dataoutputktr=/datatools/ktrs/guideboardDataOutput.ktr
82 82 ##--------------------------- 数据同步ktr ------------------------##
83 83 datatools.vehicle_datasyncktr=/datatools/ktrs/vehicleDataSync.ktr
84 84  
  85 +# 车辆库访问url
  86 +datatools.cars_interface=http://180.166.5.82:8076/cars/getCarsInterface
  87 +#datatools.cars_interface=http://192.170.101.132:8076/cars/getCarsInterface
  88 +
85 89 # TODO:
... ...
src/main/resources/datatools/config-test.properties
... ... @@ -82,4 +82,8 @@ datatools.guideboards_dataoutputktr=/datatools/ktrs/guideboardDataOutput.ktr
82 82 ##--------------------------- 数据同步ktr ------------------------##
83 83 datatools.vehicle_datasyncktr=/datatools/ktrs/vehicleDataSync.ktr
84 84  
  85 +# 车辆库访问url
  86 +datatools.cars_interface=http://180.166.5.82:8076/cars/getCarsInterface
  87 +#datatools.cars_interface=http://192.170.101.132:8076/cars/getCarsInterface
  88 +
85 89 # TODO:
... ...
src/main/resources/datatools/ktrs/vehicleDataSync.ktr
... ... @@ -125,11 +125,11 @@
125 125 </info>
126 126 <notepads>
127 127 <notepad>
128   - <note>1&#x3001;json&#x8f93;&#x5165;step&#x5904;&#x7406;&#x592a;&#x6162;&#xff0c;&#x4f7f;&#x7528;javascript&#x6a21;&#x62df;&#x4ee3;&#x66ff;&#xa;2&#x3001;&#x5f85;&#x5904;&#x7406;&#x6570;&#x636e;xls&#x8f93;&#x51fa;&#x4e2d;&#x5df2;&#x7ecf;&#x5305;&#x542b;&#x4e86;&#x8fdc;&#x7a0b;&#x548c;&#x672c;&#x5730;&#x7684;&#x5bf9;&#x6bd4;&#x8f66;&#x8f86;&#x6570;&#x636e;&#xff08;&#x4e0d;&#x9700;&#x8981;&#x8f93;&#x51fa;&#x6574;&#x4e2a;&#x8f66;&#x8f86;&#x57fa;&#x7840;&#x4fe1;&#x606f;xls&#xff09;&#xff0c;&#xa; &#x5982;&#x679c;&#x4ee5;&#x540e;&#x6dfb;&#x52a0;&#x66f4;&#x591a;&#x7684;&#x66f4;&#x65b0;&#x5b57;&#x6bb5;&#xff0c;&#x8fd9;&#x4e2a;&#x6b65;&#x9aa4;&#x8981;&#x6539;&#x7684;&#xa;3&#x3001;&#x6ce8;&#x610f;&#xff1a;&#x547d;&#x540d;&#x53c2;&#x6570;paramClzbh&#x7684;&#x9ed8;&#x8ba4;&#x503c;&#x4e0d;&#x8981;&#x5199;&#xff0c;&#x5426;&#x5219;&#x5728;&#x8fdb;&#x884c;&#x65f6;&#x95f4;&#x8303;&#x56f4;&#x540c;&#x6b65;&#x7684;&#x65f6;&#x5019;&#x6c38;&#x8fdc;&#x6309;&#x7167;paramClzbh&#x9ed8;&#x8ba4;&#x503c;&#x540c;&#x6b65;&#x4e86;&#xff0c;&#xa; TODO&#xff1a;&#x4e4b;&#x540e;&#x4f1a;&#x8003;&#x8651;&#x4f7f;&#x7528;&#x65b0;&#x7684;&#x547d;&#x540d;&#x53c2;&#x6570;paramType&#x533a;&#x522b;&#x4e0d;&#x540c;&#x7684;&#x540c;&#x6b65;&#x7c7b;&#x578b;</note>
  128 + <note>1&#x3001;json&#x8f93;&#x5165;step&#x5904;&#x7406;&#x592a;&#x6162;&#xff0c;&#x4f7f;&#x7528;javascript&#x6a21;&#x62df;&#x4ee3;&#x66ff;&#xa;2&#x3001;&#x5f85;&#x5904;&#x7406;&#x6570;&#x636e;xls&#x8f93;&#x51fa;&#x4e2d;&#x5df2;&#x7ecf;&#x5305;&#x542b;&#x4e86;&#x8fdc;&#x7a0b;&#x548c;&#x672c;&#x5730;&#x7684;&#x5bf9;&#x6bd4;&#x8f66;&#x8f86;&#x6570;&#x636e;&#xff08;&#x4e0d;&#x9700;&#x8981;&#x8f93;&#x51fa;&#x6574;&#x4e2a;&#x8f66;&#x8f86;&#x57fa;&#x7840;&#x4fe1;&#x606f;xls&#xff09;&#xff0c;&#xa; &#x5982;&#x679c;&#x4ee5;&#x540e;&#x6dfb;&#x52a0;&#x66f4;&#x591a;&#x7684;&#x66f4;&#x65b0;&#x5b57;&#x6bb5;&#xff0c;&#x8fd9;&#x4e2a;&#x6b65;&#x9aa4;&#x8981;&#x6539;&#x7684;&#xa;3&#x3001;&#x6ce8;&#x610f;&#xff1a;&#x547d;&#x540d;&#x53c2;&#x6570;paramClzbh&#x7684;&#x9ed8;&#x8ba4;&#x503c;&#x4e0d;&#x8981;&#x5199;&#xff0c;&#x5426;&#x5219;&#x5728;&#x8fdb;&#x884c;&#x65f6;&#x95f4;&#x8303;&#x56f4;&#x540c;&#x6b65;&#x7684;&#x65f6;&#x5019;&#x6c38;&#x8fdc;&#x6309;&#x7167;paramClzbh&#x9ed8;&#x8ba4;&#x503c;&#x540c;&#x6b65;&#x4e86;&#xff0c;&#xa; TODO&#xff1a;&#x4e4b;&#x540e;&#x4f1a;&#x8003;&#x8651;&#x4f7f;&#x7528;&#x65b0;&#x7684;&#x547d;&#x540d;&#x53c2;&#x6570;paramType&#x533a;&#x522b;&#x4e0d;&#x540c;&#x7684;&#x540c;&#x6b65;&#x7c7b;&#x578b;&#xa;4&#x3001;&#x5df2;&#x7ecf;&#x5728;&#x7a0b;&#x5e8f;&#x4e2d;&#x5224;&#x65ad;&#x53c2;&#x6570;&#x7684;&#x95ee;&#x9898;&#x4e86;&#xff0c;&#x7b2c;3&#x70b9;&#x53ef;&#x4ee5;&#x5ffd;&#x7565;&#x4e86;</note>
129 129 <xloc>463</xloc>
130 130 <yloc>36</yloc>
131   - <width>1246</width>
132   - <heigth>130</heigth>
  131 + <width>649</width>
  132 + <heigth>106</heigth>
133 133 <fontname>YaHei Consolas Hybrid</fontname>
134 134 <fontsize>12</fontsize>
135 135 <fontbold>N</fontbold>
... ... @@ -727,6 +727,30 @@
727 727 </attributes>
728 728 </connection>
729 729 <connection>
  730 + <name>&#x5916;&#x7f51;&#x6768;&#x9ad8;&#x673a;&#x52a1;oracle</name>
  731 + <server>58.247.254.118</server>
  732 + <type>ORACLE</type>
  733 + <access>Native</access>
  734 + <database>orcl</database>
  735 + <port>15211</port>
  736 + <username>ygjw</username>
  737 + <password>Encrypted 2be98afc86aa7f2e4cb79ce10c795a5cd</password>
  738 + <servername/>
  739 + <data_tablespace/>
  740 + <index_tablespace/>
  741 + <attributes>
  742 + <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
  743 + <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
  744 + <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
  745 + <attribute><code>PORT_NUMBER</code><attribute>15211</attribute></attribute>
  746 + <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>N</attribute></attribute>
  747 + <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
  748 + <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
  749 + <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
  750 + <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  751 + </attributes>
  752 + </connection>
  753 + <connection>
730 754 <name>&#x5916;&#x7f51;&#x91d1;&#x9ad8;&#x673a;&#x52a1;oracle</name>
731 755 <server>58.247.254.118</server>
732 756 <type>ORACLE</type>
... ... @@ -914,6 +938,32 @@
914 938 </step>
915 939  
916 940 <step>
  941 + <name>&#x516c;&#x53f8;&#xff0c;&#x5206;&#x516c;&#x53f8;&#x540d;&#x79f0;&#x4ee3;&#x7801;&#x6570;&#x636e;</name>
  942 + <type>TableInput</type>
  943 + <description/>
  944 + <distribute>N</distribute>
  945 + <custom_distribution/>
  946 + <copies>1</copies>
  947 + <partitioning>
  948 + <method>none</method>
  949 + <schema_name/>
  950 + </partitioning>
  951 + <connection>control_jndi</connection>
  952 + <sql>select gs.gsmc as gsmc&#xa;, fgs.fgsmc as fgsmc&#xa;, concat &#x28;gs.gsmc, &#x27;-&#x27;, fgs.fgsmc&#x29; as allmc&#xa;, gs.gsdm as gsdm&#xa;, fgs.fgsdm as fgsdm&#xa;from&#xa;&#x28;select business_name as fgsmc&#xa;, business_code as fgsdm&#xa;, up_code gsdm &#xa;from bsth_c_business &#xa;where up_code in &#x28;&#xa;select business_code from bsth_c_business where up_code &#x3d; &#x27;88&#x27;&#x29;&#xa;&#x29; fgs left join&#xa;&#x28;select business_name as gsmc&#xa;, business_code as gsdm&#xa;from bsth_c_business&#xa;where up_code &#x3d; &#x27;88&#x27;&#xa;&#x29; gs on fgs.gsdm &#x3d; gs.gsdm</sql>
  953 + <limit>0</limit>
  954 + <lookup/>
  955 + <execute_each_row>N</execute_each_row>
  956 + <variables_active>N</variables_active>
  957 + <lazy_conversion_active>N</lazy_conversion_active>
  958 + <cluster_schema/>
  959 + <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
  960 + <xloc>176</xloc>
  961 + <yloc>220</yloc>
  962 + <draw>Y</draw>
  963 + </GUI>
  964 + </step>
  965 +
  966 + <step>
917 967 <name>&#x5199;&#x65e5;&#x5fd7;</name>
918 968 <type>WriteToLog</type>
919 969 <description/>
... ... @@ -3012,32 +3062,6 @@
3012 3062 </GUI>
3013 3063 </step>
3014 3064  
3015   - <step>
3016   - <name>&#x516c;&#x53f8;&#xff0c;&#x5206;&#x516c;&#x53f8;&#x540d;&#x79f0;&#x4ee3;&#x7801;&#x6570;&#x636e;</name>
3017   - <type>TableInput</type>
3018   - <description/>
3019   - <distribute>N</distribute>
3020   - <custom_distribution/>
3021   - <copies>1</copies>
3022   - <partitioning>
3023   - <method>none</method>
3024   - <schema_name/>
3025   - </partitioning>
3026   - <connection>control_jndi</connection>
3027   - <sql>select gs.gsmc as gsmc&#xa;, fgs.fgsmc as fgsmc&#xa;, concat &#x28;gs.gsmc, &#x27;-&#x27;, fgs.fgsmc&#x29; as allmc&#xa;, gs.gsdm as gsdm&#xa;, fgs.fgsdm as fgsdm&#xa;from&#xa;&#x28;select business_name as fgsmc&#xa;, business_code as fgsdm&#xa;, up_code gsdm &#xa;from bsth_c_business &#xa;where up_code in &#x28;&#xa;select business_code from bsth_c_business where up_code &#x3d; &#x27;88&#x27;&#x29;&#xa;&#x29; fgs left join&#xa;&#x28;select business_name as gsmc&#xa;, business_code as gsdm&#xa;from bsth_c_business&#xa;where up_code &#x3d; &#x27;88&#x27;&#xa;&#x29; gs on fgs.gsdm &#x3d; gs.gsdm</sql>
3028   - <limit>0</limit>
3029   - <lookup/>
3030   - <execute_each_row>N</execute_each_row>
3031   - <variables_active>N</variables_active>
3032   - <lazy_conversion_active>N</lazy_conversion_active>
3033   - <cluster_schema/>
3034   - <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
3035   - <xloc>176</xloc>
3036   - <yloc>220</yloc>
3037   - <draw>Y</draw>
3038   - </GUI>
3039   - </step>
3040   -
3041 3065 <step_error_handling>
3042 3066 <error>
3043 3067 <source_step>JavaScript&#x89e3;&#x6790;json&#x751f;&#x6210;&#x6570;&#x636e;</source_step>
... ...