|
@@ -17,6 +17,7 @@ import java.lang.reflect.InvocationTargetException;
|
17
|
17
|
import java.time.LocalDate;
|
18
|
18
|
import java.time.format.DateTimeFormatter;
|
19
|
19
|
import java.util.*;
|
|
20
|
+import java.util.concurrent.atomic.AtomicInteger;
|
20
|
21
|
|
21
|
22
|
@RunWith(SpringRunner.class)
|
22
|
23
|
@SpringBootTest(classes = EtlCamelHugeApplication.class)
|
|
@@ -48,7 +49,9 @@ class EtlCamelHugeApplicationTests {
|
48
|
49
|
|
49
|
50
|
Map<String, Map<String, Object>> parentObjMap = new HashMap<>();
|
50
|
51
|
Map<String, Map<String, Object>> orgIdMap = new HashMap<>();
|
|
52
|
+ AtomicInteger a = new AtomicInteger(1);
|
51
|
53
|
results.forEach(rowMap -> {
|
|
54
|
+ rowMap.put("org_id_map_int",a.getAndIncrement());
|
52
|
55
|
orgIdMap.put(rowMap.get("ORG_ID").toString(), rowMap);
|
53
|
56
|
});
|
54
|
57
|
results.forEach(rowMap -> {
|
|
@@ -72,12 +75,15 @@ class EtlCamelHugeApplicationTests {
|
72
|
75
|
|
73
|
76
|
String sqlInsertOrg = String.format("insert into centralbase.cb_pc_organization(" +
|
74
|
77
|
"org_id,org_name,org_code,org_level,parent_id,org_id_pre) " +
|
75
|
|
- "values('%s','%s','%s','%s','%s','%s')", rowMap.get("ORG_ID"), rowMap.get("ORG_NAME"), rowMap.get("ORG_CODE"), rowMap.get("ORG_LEVEL")
|
76
|
|
- , rowMap.get("PARENT_ID"), orgIdPreStr);
|
|
78
|
+ "values('%s','%s','%s','%s','%s','%s')", rowMap.get("org_id_map_int"), rowMap.get("ORG_NAME"), rowMap.get("ORG_CODE"),
|
|
79
|
+ orgIdPreStr.split("@").length
|
|
80
|
+ , Objects.nonNull(orgIdMap.get(rowMap.get("PARENT_ID").toString()))?orgIdMap.get(rowMap.get("PARENT_ID").toString()).get("org_id_map_int"):"0"
|
|
81
|
+ , orgIdPreStr);
|
77
|
82
|
// System.out.println(sqlInsertOrg);
|
78
|
|
-// centralbaseTemplate.execute(sqlInsertOrg); //excute finish, unused
|
|
83
|
+ centralbaseTemplate.execute(sqlInsertOrg); //excute finish, unused
|
79
|
84
|
});
|
80
|
85
|
|
|
86
|
+ if(a.get()>1)return;
|
81
|
87
|
//excute wellsource
|
82
|
88
|
sql = String.format("select WELL_ID,well_common_name,org_id from " +
|
83
|
89
|
"zy_dxgw.pc_dev_well_attr_info where well_purpose_name='采油井'");
|
|
@@ -87,11 +93,13 @@ class EtlCamelHugeApplicationTests {
|
87
|
93
|
String wellCommonName = rowMap.get("WELL_COMMON_NAME").toString();
|
88
|
94
|
String wellLegalName = rowMap.get("WELL_COMMON_NAME").toString();
|
89
|
95
|
String orgId = rowMap.get("ORG_ID").toString();
|
|
96
|
+ String orgIdMapInt = orgIdMap.get(orgId).get("org_id_map_int").toString();
|
90
|
97
|
String stationId = orgIdMap.get(orgId).get("ORG_ID_PRE").toString();
|
91
|
|
- String sqlInsertWellSource = String.format("insert into centralbase.cb_pc_well_source(well_id,well_common_name," +
|
|
98
|
+ String sqlInsertWellSource = String.format("insert into centralbase.cb_cd_well_source(well_id,well_common_name," +
|
92
|
99
|
"well_legal_name,org_id,station_id) values('%s','%s','%s','%s','%s')",
|
93
|
|
- wellId, wellCommonName, wellLegalName, orgId, stationId);
|
94
|
|
- System.out.println(sqlInsertWellSource);
|
|
100
|
+ wellId, wellCommonName, wellLegalName, orgIdMapInt, stationId);
|
|
101
|
+// System.out.println(sqlInsertWellSource);
|
|
102
|
+ centralbaseTemplate.execute(sqlInsertWellSource);
|
95
|
103
|
});
|
96
|
104
|
|
97
|
105
|
}
|