| 
				
			 | 
			
			
				@@ -2,6 +2,7 @@ package com.gct.tools.etlcamelhuge; 
			 | 
		
	
		
			
			| 
				
					2
				
			 | 
			
				
					2
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
					3
				
			 | 
			
				
					3
				
			 | 
			
			
				 import com.gct.tools.etlcamelhuge.routeconfig.CamelJDBCConfiguration; 
			 | 
		
	
		
			
			| 
				
					4
				
			 | 
			
				
					4
				
			 | 
			
			
				 import lombok.Data; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					5
				
			 | 
			
			
				+import org.json.JSONObject; 
			 | 
		
	
		
			
			| 
				
					5
				
			 | 
			
				
					6
				
			 | 
			
			
				 import org.junit.jupiter.api.Test; 
			 | 
		
	
		
			
			| 
				
					6
				
			 | 
			
				
					7
				
			 | 
			
			
				 import org.junit.runner.RunWith; 
			 | 
		
	
		
			
			| 
				
					7
				
			 | 
			
				
					8
				
			 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -15,10 +16,7 @@ import java.lang.reflect.Array; 
			 | 
		
	
		
			
			| 
				
					15
				
			 | 
			
				
					16
				
			 | 
			
			
				 import java.lang.reflect.InvocationTargetException; 
			 | 
		
	
		
			
			| 
				
					16
				
			 | 
			
				
					17
				
			 | 
			
			
				 import java.time.LocalDate; 
			 | 
		
	
		
			
			| 
				
					17
				
			 | 
			
				
					18
				
			 | 
			
			
				 import java.time.format.DateTimeFormatter; 
			 | 
		
	
		
			
			| 
				
					18
				
			 | 
			
				
			 | 
			
			
				-import java.util.ArrayList; 
			 | 
		
	
		
			
			| 
				
					19
				
			 | 
			
				
			 | 
			
			
				-import java.util.Arrays; 
			 | 
		
	
		
			
			| 
				
					20
				
			 | 
			
				
			 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
			| 
				
					21
				
			 | 
			
				
			 | 
			
			
				-import java.util.Map; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					19
				
			 | 
			
			
				+import java.util.*; 
			 | 
		
	
		
			
			| 
				
					22
				
			 | 
			
				
					20
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
					23
				
			 | 
			
				
					21
				
			 | 
			
			
				 @RunWith(SpringRunner.class) 
			 | 
		
	
		
			
			| 
				
					24
				
			 | 
			
				
					22
				
			 | 
			
			
				 @SpringBootTest 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -27,6 +25,9 @@ class EtlCamelHugeApplicationTests { 
			 | 
		
	
		
			
			| 
				
					27
				
			 | 
			
				
					25
				
			 | 
			
			
				     @Resource(name = "oracle") 
			 | 
		
	
		
			
			| 
				
					28
				
			 | 
			
				
					26
				
			 | 
			
			
				     DataSource oracle; 
			 | 
		
	
		
			
			| 
				
					29
				
			 | 
			
				
					27
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					28
				
			 | 
			
			
				+    @Resource(name="centralbase") 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					29
				
			 | 
			
			
				+    DataSource centralbase; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					30
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
					30
				
			 | 
			
				
					31
				
			 | 
			
			
				     @Test 
			 | 
		
	
		
			
			| 
				
					31
				
			 | 
			
				
					32
				
			 | 
			
			
				     public void testOracle(){ 
			 | 
		
	
		
			
			| 
				
					32
				
			 | 
			
				
					33
				
			 | 
			
			
				         JdbcTemplate template = new JdbcTemplate(oracle); 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -38,4 +39,40 @@ class EtlCamelHugeApplicationTests { 
			 | 
		
	
		
			
			| 
				
					38
				
			 | 
			
				
					39
				
			 | 
			
			
				         }); 
			 | 
		
	
		
			
			| 
				
					39
				
			 | 
			
				
					40
				
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				
					40
				
			 | 
			
				
					41
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					42
				
			 | 
			
			
				+    @Test 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					43
				
			 | 
			
			
				+    public void orgCreate(){ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					44
				
			 | 
			
			
				+        JdbcTemplate oracleTemplate = new JdbcTemplate(oracle); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					45
				
			 | 
			
			
				+        final JdbcTemplate centralbaseTemplate = new JdbcTemplate(centralbase); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					46
				
			 | 
			
			
				+        String sql = String.format("select * from zy_dxgw.V_PC_ORGANIZATION_T where CANTON = '重油公司'"); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					47
				
			 | 
			
			
				+        List<Map<String, Object>> results = oracleTemplate.queryForList(sql); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					48
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					49
				
			 | 
			
			
				+        Map<String,Map<String,Object>> parentObjMap = new HashMap<>(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					50
				
			 | 
			
			
				+        Map<String, Map<String,Object>> orgIdMap = new HashMap<>(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					51
				
			 | 
			
			
				+        results.forEach(rowMap->{ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					52
				
			 | 
			
			
				+            orgIdMap.put(rowMap.get("ORG_ID").toString(),rowMap); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					53
				
			 | 
			
			
				+        }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					54
				
			 | 
			
			
				+        results.forEach(rowMap->{ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					55
				
			 | 
			
			
				+            parentObjMap.put(rowMap.get("ORG_ID").toString(),orgIdMap.get(rowMap.get("PARENT_ID"))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					56
				
			 | 
			
			
				+        }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					57
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					58
				
			 | 
			
			
				+        results.forEach(rowMap->{ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					59
				
			 | 
			
			
				+            Stack<String> orgPreStack = new Stack<>(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					60
				
			 | 
			
			
				+            Map<String,Object> parentObj = null; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					61
				
			 | 
			
			
				+            while((parentObj=parentObjMap.get(rowMap.get("PARENT_ID").toString()))!=null){ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					62
				
			 | 
			
			
				+                orgPreStack.push(parentObj.get("ORG_NAME").toString()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					63
				
			 | 
			
			
				+            } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					64
				
			 | 
			
			
				+            StringBuilder orgIdPre = new StringBuilder(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					65
				
			 | 
			
			
				+            while (!orgPreStack.isEmpty()){ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					66
				
			 | 
			
			
				+                orgIdPre.append("@").append(orgPreStack.pop()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					67
				
			 | 
			
			
				+            } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					68
				
			 | 
			
			
				+            String orgIdPreStr = orgIdPre.delete(0, 1).toString(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					69
				
			 | 
			
			
				+            String sqlInsertOrg = String.format("insert into centralbase.cb_pc_organization(" + 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					70
				
			 | 
			
			
				+                    "org_id,org_name,org_code,org_level,parent_id,org_id_pre) " + 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					71
				
			 | 
			
			
				+                    "values(%s,%s,%s,%s,%s,%s)",rowMap.get("ORG_ID"),rowMap.get("ORG_NAME"),rowMap.get("ORG_CODE"),rowMap.get("ORG_LEVEL") 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					72
				
			 | 
			
			
				+                    ,rowMap.get("PARENT_ID"),orgIdPreStr); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					73
				
			 | 
			
			
				+            System.out.println(sqlInsertOrg); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					74
				
			 | 
			
			
				+//            centralbaseTemplate.execute(sqlInsertOrg); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					75
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					76
				
			 | 
			
			
				+        }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					77
				
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
					41
				
			 | 
			
				
					78
				
			 | 
			
			
				 } 
			 |