|
@@ -6,8 +6,11 @@ import org.junit.jupiter.api.Test;
|
6
|
6
|
import org.junit.runner.RunWith;
|
7
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
8
|
8
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
9
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
9
|
10
|
import org.springframework.test.context.junit4.SpringRunner;
|
10
|
11
|
|
|
12
|
+import javax.annotation.Resource;
|
|
13
|
+import javax.sql.DataSource;
|
11
|
14
|
import java.lang.reflect.Array;
|
12
|
15
|
import java.lang.reflect.InvocationTargetException;
|
13
|
16
|
import java.time.LocalDate;
|
|
@@ -15,150 +18,24 @@ import java.time.format.DateTimeFormatter;
|
15
|
18
|
import java.util.ArrayList;
|
16
|
19
|
import java.util.Arrays;
|
17
|
20
|
import java.util.List;
|
|
21
|
+import java.util.Map;
|
18
|
22
|
|
19
|
23
|
@RunWith(SpringRunner.class)
|
20
|
24
|
@SpringBootTest
|
21
|
25
|
class EtlCamelHugeApplicationTests {
|
22
|
26
|
|
23
|
|
- /* @Autowired
|
24
|
|
- RouteBuilder routeBuilder;*/
|
|
27
|
+ @Resource(name = "oracle")
|
|
28
|
+ DataSource oracle;
|
25
|
29
|
|
26
|
30
|
@Test
|
27
|
|
- public void contextLoads() {
|
|
31
|
+ public void testOracle(){
|
|
32
|
+ JdbcTemplate template = new JdbcTemplate(oracle);
|
|
33
|
+ String sql = String.format("select WELL_ID,well_common_name,org_id from " +
|
|
34
|
+ "zy_dxgw.pc_dev_well_attr_info where well_purpose_name='采油井'");
|
|
35
|
+ List<Map<String, Object>> maps = template.queryForList(sql);
|
|
36
|
+ maps.get(0).forEach((k,v)->{
|
|
37
|
+ System.out.printf("k: %s, v: %s\n",k,v);
|
|
38
|
+ });
|
28
|
39
|
}
|
29
|
40
|
|
30
|
|
- @Test
|
31
|
|
- public void test1() {
|
32
|
|
- Double[] num = {8.0, 6.0, 3.0, 2.0};
|
33
|
|
- List<Double> lis = new java.util.ArrayList<>(Arrays.asList(num));
|
34
|
|
- lis.add(0.9);
|
35
|
|
- System.out.println("1___________" + lis);
|
36
|
|
- List<Double> lis1 = new java.util.ArrayList<Double>(Arrays.asList(lis.subList(lis.size() / 2 - 1, lis.size()).toArray(new Double[]{})));
|
37
|
|
- List<Double> lis2 = new java.util.ArrayList<Double>(Arrays.asList(lis.subList(0, lis.size() / 2 - 1).toArray(new Double[]{})));
|
38
|
|
-
|
39
|
|
- double x = lis.get(0).doubleValue();
|
40
|
|
- System.out.println("2___________" + lis1);
|
41
|
|
-
|
42
|
|
- lis.add(lis.get(0));
|
43
|
|
- System.out.println("3___________" + lis);
|
44
|
|
- lis1.add(lis.get(0));
|
45
|
|
- lis2.add(9.8);
|
46
|
|
- System.out.println("4___________" + lis1);
|
47
|
|
- System.out.println("___________" + lis2);
|
48
|
|
- }
|
49
|
|
-
|
50
|
|
- @Test
|
51
|
|
- public void test2() {
|
52
|
|
- List<Double[]> p1 = new ArrayList<>();
|
53
|
|
- Double[] num0 = {8.0, 6.0};
|
54
|
|
- Double[] num1 = {0.0, 5.0};
|
55
|
|
- Double[] num2 = {6.0, 7.0};
|
56
|
|
-
|
57
|
|
- p1.add(num0);
|
58
|
|
- p1.add(num1);
|
59
|
|
- p1.add(num2);
|
60
|
|
- System.out.println(p1.toArray(new Double[p1.size()][]));
|
61
|
|
- System.out.println("p1====================" + p1);
|
62
|
|
-
|
63
|
|
- Double[][] a = new Double[][]{};
|
64
|
|
- System.out.println(a.getClass());
|
65
|
|
- List<Double[]> p_p1 = p1.subList(0, p1.size() / 2);
|
66
|
|
- System.out.println(p_p1);
|
67
|
|
-
|
68
|
|
- p_p1.add(num0);
|
69
|
|
- System.out.println(p_p1);
|
70
|
|
- System.out.println("p1====================" + p1);
|
71
|
|
- if (false) {
|
72
|
|
- List<Double> lis = new java.util.ArrayList<>(Arrays.asList(num0));
|
73
|
|
- lis.add(0.9);
|
74
|
|
- System.out.println("1___________" + lis);
|
75
|
|
- List<Double> lis1 = new java.util.ArrayList<Double>(Arrays.asList(lis.subList(lis.size() / 2 - 1, lis.size()).toArray(new Double[]{})));
|
76
|
|
- List<Double> lis2 = new java.util.ArrayList<Double>(Arrays.asList(lis.subList(0, lis.size() / 2 - 1).toArray(new Double[]{})));
|
77
|
|
-
|
78
|
|
- double x = lis.get(0).doubleValue();
|
79
|
|
- System.out.println("2___________" + lis1);
|
80
|
|
-
|
81
|
|
- lis.add(lis.get(0));
|
82
|
|
- System.out.println("3___________" + lis);
|
83
|
|
- lis1.add(lis.get(0));
|
84
|
|
- lis2.add(9.8);
|
85
|
|
- System.out.println("4___________" + lis1);
|
86
|
|
- System.out.println("___________" + lis2);
|
87
|
|
- }
|
88
|
|
- }
|
89
|
|
-
|
90
|
|
- @Data
|
91
|
|
- class te {
|
92
|
|
- private double m;
|
93
|
|
-
|
94
|
|
- // @Cons
|
95
|
|
- public te(double m) {
|
96
|
|
- this.m = m;
|
97
|
|
- }
|
98
|
|
- }
|
99
|
|
-
|
100
|
|
- @Test
|
101
|
|
- public void test3() {
|
102
|
|
-
|
103
|
|
- te s = new te(0.9);
|
104
|
|
- System.out.println(s);
|
105
|
|
- System.out.println(s.getClass());
|
106
|
|
- try {
|
107
|
|
- Class<?> clazz = Class.forName("com.gct.tools.etlcamelhuge.EtlCamelHugeApplicationTests$te");
|
108
|
|
- te t = (te) clazz.getConstructor(double.class).newInstance(9.0);
|
109
|
|
-
|
110
|
|
- System.out.println(t);
|
111
|
|
-
|
112
|
|
- } catch (NoSuchMethodException e) {
|
113
|
|
- e.printStackTrace();
|
114
|
|
- } catch (InvocationTargetException e) {
|
115
|
|
- e.printStackTrace();
|
116
|
|
- } catch (InstantiationException e) {
|
117
|
|
- e.printStackTrace();
|
118
|
|
- } catch (IllegalAccessException e) {
|
119
|
|
- e.printStackTrace();
|
120
|
|
- } catch (ClassNotFoundException e) {
|
121
|
|
- e.printStackTrace();
|
122
|
|
- }
|
123
|
|
-
|
124
|
|
- ArrayList<Double> a1 = new ArrayList<Double>();
|
125
|
|
-
|
126
|
|
- a1.add(0.9);
|
127
|
|
- a1.add(0.8);
|
128
|
|
- Double[] objects = a1.toArray(new Double[]{});
|
129
|
|
-
|
130
|
|
- for (int i = 0; i < objects.length; i++) {
|
131
|
|
- System.out.println(objects[i]);
|
132
|
|
- }
|
133
|
|
-
|
134
|
|
- }
|
135
|
|
-
|
136
|
|
- private <T> T[][] transfer(List<List<T>> source, Class<T> tClass) {
|
137
|
|
-
|
138
|
|
- List<T[]> l1 = new ArrayList<>();
|
139
|
|
- for (List<T> ts : source) {
|
140
|
|
- T[] t = (T[]) Array.newInstance(tClass, ts.size());
|
141
|
|
- for (int i = 0; i < ts.size(); i++) {
|
142
|
|
- t[i] = ts.get(i);
|
143
|
|
- }
|
144
|
|
-
|
145
|
|
- l1.add(t);
|
146
|
|
- }
|
147
|
|
- T[][] ts = l1.toArray((T[][]) Array.newInstance(tClass, source.size()));
|
148
|
|
- return ts;
|
149
|
|
-
|
150
|
|
- }
|
151
|
|
-
|
152
|
|
- @Autowired
|
153
|
|
- CamelJDBCConfiguration camelJDBCConfiguration;
|
154
|
|
- @Test
|
155
|
|
- public void test10() {
|
156
|
|
-
|
157
|
|
- }
|
158
|
|
-
|
159
|
|
- public static void main(String args[]) throws Exception {
|
160
|
|
- System.out.println(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
161
|
|
- }
|
162
|
|
-
|
163
|
|
-
|
164
|
41
|
}
|