| 
				
			 | 
			
			
				@@ -11,41 +11,41 @@ import org.apache.camel.Message; 
			 | 
		
	
		
			
			| 
				
					11
				
			 | 
			
				
					11
				
			 | 
			
			
				 import org.apache.camel.builder.RouteBuilder; 
			 | 
		
	
		
			
			| 
				
					12
				
			 | 
			
				
					12
				
			 | 
			
			
				 import org.apache.camel.model.dataformat.JsonLibrary; 
			 | 
		
	
		
			
			| 
				
					13
				
			 | 
			
				
					13
				
			 | 
			
			
				 import org.springframework.context.annotation.Configuration; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					14
				
			 | 
			
			
				+import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
			| 
				
					14
				
			 | 
			
				
					15
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					16
				
			 | 
			
			
				+import javax.annotation.Resource; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					17
				
			 | 
			
			
				+import javax.sql.DataSource; 
			 | 
		
	
		
			
			| 
				
					15
				
			 | 
			
				
					18
				
			 | 
			
			
				 import java.io.*; 
			 | 
		
	
		
			
			| 
				
					16
				
			 | 
			
				
					19
				
			 | 
			
			
				 import java.math.BigDecimal; 
			 | 
		
	
		
			
			| 
				
					17
				
			 | 
			
				
					20
				
			 | 
			
			
				 import java.net.HttpURLConnection; 
			 | 
		
	
		
			
			| 
				
					18
				
			 | 
			
				
					21
				
			 | 
			
			
				 import java.net.URL; 
			 | 
		
	
		
			
			| 
				
					19
				
			 | 
			
				
					22
				
			 | 
			
			
				 import java.net.URLEncoder; 
			 | 
		
	
		
			
			| 
				
					20
				
			 | 
			
				
					23
				
			 | 
			
			
				 import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
			| 
				
					21
				
			 | 
			
				
			 | 
			
			
				-import java.util.ArrayList; 
			 | 
		
	
		
			
			| 
				
					22
				
			 | 
			
				
			 | 
			
			
				-import java.util.Date; 
			 | 
		
	
		
			
			| 
				
					23
				
			 | 
			
				
			 | 
			
			
				-import java.util.HashMap; 
			 | 
		
	
		
			
			| 
				
					24
				
			 | 
			
				
			 | 
			
			
				-import java.util.List; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					24
				
			 | 
			
			
				+import java.util.*; 
			 | 
		
	
		
			
			| 
				
					25
				
			 | 
			
				
					25
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
					26
				
			 | 
			
				
					26
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
					27
				
			 | 
			
				
					27
				
			 | 
			
			
				 @Configuration 
			 | 
		
	
		
			
			| 
				
					28
				
			 | 
			
				
					28
				
			 | 
			
			
				 public class CamelRestConfiguration extends RouteBuilder { 
			 | 
		
	
		
			
			| 
				
					29
				
			 | 
			
				
					29
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
					30
				
			 | 
			
				
					30
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					31
				
			 | 
			
			
				+    private static Map<String, String> accessWellMap = new HashMap(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					32
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
					31
				
			 | 
			
				
					33
				
			 | 
			
			
				     public String gtTransUtil(String gtdata)//处理示功图 
			 | 
		
	
		
			
			| 
				
					32
				
			 | 
			
				
					34
				
			 | 
			
			
				     { 
			 | 
		
	
		
			
			| 
				
					33
				
			 | 
			
				
					35
				
			 | 
			
			
				         String gt = ""; 
			 | 
		
	
		
			
			| 
				
					34
				
			 | 
			
				
			 | 
			
			
				-        if (gtdata == null){ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					36
				
			 | 
			
			
				+        if (gtdata == null) { 
			 | 
		
	
		
			
			| 
				
					35
				
			 | 
			
				
					37
				
			 | 
			
			
				             gtdata = ""; 
			 | 
		
	
		
			
			| 
				
					36
				
			 | 
			
				
					38
				
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				
					37
				
			 | 
			
				
					39
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
					38
				
			 | 
			
				
					40
				
			 | 
			
			
				         Double[][] doubles = null; 
			 | 
		
	
		
			
			| 
				
					39
				
			 | 
			
				
			 | 
			
			
				-        int len = gtdata.length()/8; 
			 | 
		
	
		
			
			| 
				
					40
				
			 | 
			
				
			 | 
			
			
				-        if(!gtdata.equals("")) 
			 | 
		
	
		
			
			| 
				
					41
				
			 | 
			
				
			 | 
			
			
				-        { 
			 | 
		
	
		
			
			| 
				
					42
				
			 | 
			
				
			 | 
			
			
				-            for(int i=0;i<len;i++) 
			 | 
		
	
		
			
			| 
				
					43
				
			 | 
			
				
			 | 
			
			
				-            { 
			 | 
		
	
		
			
			| 
				
					44
				
			 | 
			
				
			 | 
			
			
				-                gt += String.valueOf(Double.parseDouble(gtdata.substring(i*8, i*8+3))/100)+ ","; 
			 | 
		
	
		
			
			| 
				
					45
				
			 | 
			
				
			 | 
			
			
				-                if (i ==len-1){ 
			 | 
		
	
		
			
			| 
				
					46
				
			 | 
			
				
			 | 
			
			
				-                    gt += String.valueOf(Double.parseDouble(gtdata.substring(i*8+3, i*8+8))/100); 
			 | 
		
	
		
			
			| 
				
					47
				
			 | 
			
				
			 | 
			
			
				-                }else { 
			 | 
		
	
		
			
			| 
				
					48
				
			 | 
			
				
			 | 
			
			
				-                    gt += String.valueOf(Double.parseDouble(gtdata.substring(i*8+3, i*8+8))/100)+","; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					41
				
			 | 
			
			
				+        int len = gtdata.length() / 8; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					42
				
			 | 
			
			
				+        if (!gtdata.equals("")) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					43
				
			 | 
			
			
				+            for (int i = 0; i < len; i++) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					44
				
			 | 
			
			
				+                gt += String.valueOf(Double.parseDouble(gtdata.substring(i * 8, i * 8 + 3)) / 100) + ","; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					45
				
			 | 
			
			
				+                if (i == len - 1) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					46
				
			 | 
			
			
				+                    gt += String.valueOf(Double.parseDouble(gtdata.substring(i * 8 + 3, i * 8 + 8)) / 100); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					47
				
			 | 
			
			
				+                } else { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					48
				
			 | 
			
			
				+                    gt += String.valueOf(Double.parseDouble(gtdata.substring(i * 8 + 3, i * 8 + 8)) / 100) + ","; 
			 | 
		
	
		
			
			| 
				
					49
				
			 | 
			
				
					49
				
			 | 
			
			
				                 } 
			 | 
		
	
		
			
			| 
				
					50
				
			 | 
			
				
					50
				
			 | 
			
			
				             } 
			 | 
		
	
		
			
			| 
				
					51
				
			 | 
			
				
					51
				
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -60,14 +60,57 @@ public class CamelRestConfiguration extends RouteBuilder { 
			 | 
		
	
		
			
			| 
				
					60
				
			 | 
			
				
					60
				
			 | 
			
			
				         String string = SGTUtil.encodeToString(doubles); 
			 | 
		
	
		
			
			| 
				
					61
				
			 | 
			
				
					61
				
			 | 
			
			
				         return string; 
			 | 
		
	
		
			
			| 
				
					62
				
			 | 
			
				
					62
				
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				
					63
				
			 | 
			
				
			 | 
			
			
				-    public static String getDate() 
			 | 
		
	
		
			
			| 
				
					64
				
			 | 
			
				
			 | 
			
			
				-    { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					63
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					64
				
			 | 
			
			
				+    public String getDate() { 
			 | 
		
	
		
			
			| 
				
					65
				
			 | 
			
				
					65
				
			 | 
			
			
				         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 
			 | 
		
	
		
			
			| 
				
					66
				
			 | 
			
				
					66
				
			 | 
			
			
				         String date = df.format(new java.util.Date());// new Date()为获取当前系统时间 
			 | 
		
	
		
			
			| 
				
					67
				
			 | 
			
				
					67
				
			 | 
			
			
				         return date; 
			 | 
		
	
		
			
			| 
				
					68
				
			 | 
			
				
					68
				
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				
					69
				
			 | 
			
				
					69
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
					70
				
			 | 
			
				
			 | 
			
			
				-    public String loadPhdDate( String well_id) throws Exception { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					70
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					71
				
			 | 
			
			
				+    public void getCurrentTimeParams(String wellId, String wellName,String date) throws Exception { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					72
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					73
				
			 | 
			
			
				+        Map<String, Double> map = new HashMap<>(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					74
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					75
				
			 | 
			
			
				+        String ACurrent = "/upData/A相电流"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					76
				
			 | 
			
			
				+        String BCurrent = "/upData/B相电流"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					77
				
			 | 
			
			
				+        String CCurrent = "/upData/C相电流"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					78
				
			 | 
			
			
				+        String APress = "/upData/A相电压"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					79
				
			 | 
			
			
				+        String BPress = "/upData/B相电压"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					80
				
			 | 
			
			
				+        String CPress = "/upData/C相电压"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					81
				
			 | 
			
			
				+        String noTotalPower = "/upData/总无功功率"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					82
				
			 | 
			
			
				+        String totalPower = "/upData/总有功功率"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					83
				
			 | 
			
			
				+        String casePress = "/upData/套压"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					84
				
			 | 
			
			
				+        String oilPress = "/upData/油压"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					85
				
			 | 
			
			
				+        System.out.println("开始 :wellId: " + wellId +"wellName:" + wellName + "date"+ date + "sysdate" + new Date()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					86
				
			 | 
			
			
				+        map.put("ACurrent", Double.valueOf("".equals(getParams(wellId + ACurrent)) ? "0" : getParams(wellId + ACurrent))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					87
				
			 | 
			
			
				+        map.put("BCurrent", Double.valueOf("".equals(getParams(wellId + BCurrent)) ? "0" : getParams(wellId + BCurrent))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					88
				
			 | 
			
			
				+        map.put("CCurrent", Double.valueOf("".equals(getParams(wellId + CCurrent)) ? "0" : getParams(wellId + CCurrent))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					89
				
			 | 
			
			
				+        map.put("APress", Double.valueOf("".equals(getParams(wellId + APress)) ? "0" : getParams(wellId + APress))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					90
				
			 | 
			
			
				+        map.put("BPress", Double.valueOf("".equals(getParams(wellId + BPress)) ? "0" : getParams(wellId + BPress))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					91
				
			 | 
			
			
				+        map.put("CPress", Double.valueOf("".equals(getParams(wellId + CPress)) ? "0" : getParams(wellId + CPress))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					92
				
			 | 
			
			
				+        map.put("noTotalPower", Double.valueOf("".equals(getParams(wellId + noTotalPower)) ? "0" : getParams(wellId + noTotalPower))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					93
				
			 | 
			
			
				+        map.put("totalPower", Double.valueOf("".equals(getParams(wellId + totalPower)) ? "0" : getParams(wellId + totalPower))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					94
				
			 | 
			
			
				+        map.put("casePress", Double.valueOf("".equals(getParams(wellId + casePress)) ? "0" : getParams(wellId + casePress))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					95
				
			 | 
			
			
				+        map.put("oilPress", Double.valueOf("".equals(getParams(wellId + oilPress)) ? "0" : getParams(wellId + oilPress))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					96
				
			 | 
			
			
				+        System.out.println("over"); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					97
				
			 | 
			
			
				+        insertCurrentTimeParams(map, wellName,date); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					98
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					99
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					100
				
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					101
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					102
				
			 | 
			
			
				+    public void insertCurrentTimeParams(Map<String, Double> map, String wellName,String date) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					103
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					104
				
			 | 
			
			
				+        JdbcTemplate jdbcTemplate = new JdbcTemplate(baseDataSource); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					105
				
			 | 
			
			
				+        String sql = "INSERT INTO centralbase.cb_pc_current_time_params (well_name, prod_date,a_current, b_current, c_current, a_press, b_press, c_press, no_total_power, total_power, case_press, oil_press) " + 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					106
				
			 | 
			
			
				+                "VALUES ('" + wellName + "','" + date + "'," + (map.get("ACurrent") == 0 ? null : map.get("ACurrent")) + "," + (map.get("BCurrent") == 0 ? null : map.get("BCurrent")) + "," + (map.get("CCurrent") == 0 ? null : map.get("CCurrent")) + "," + (map.get("APress") == 0 ? null : map.get("APress")) + "," + (map.get("BPress") == 0 ? null : map.get("BPress")) + "," 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					107
				
			 | 
			
			
				+                + (map.get("CPress") == 0 ? null : map.get("CPress")) + "," + (map.get("noTotalPower") == 0 ? null : map.get("noTotalPower")) + "," + (map.get("totalPower") == 0 ? null : map.get("totalPower")) + "," + (map.get("casePress") == 0 ? null : map.get("casePress")) + "," + (map.get("oilPress") == 0 ? null : map.get("oilPress")) + ")  ON CONFLICT (well_name,prod_date)  DO NOTHING;"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					108
				
			 | 
			
			
				+        if (accessWellMap.get(wellName) != null) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					109
				
			 | 
			
			
				+            jdbcTemplate.update(sql); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					110
				
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					111
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					112
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					113
				
			 | 
			
			
				+    public String getParams(String param) throws Exception { 
			 | 
		
	
		
			
			| 
				
					71
				
			 | 
			
				
					114
				
			 | 
			
			
				         URL restURL = new URL("http://11.72.128.71/api-service/tsdb/getLast?appKey=MOsEWVl8S0"); 
			 | 
		
	
		
			
			| 
				
					72
				
			 | 
			
				
					115
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
					73
				
			 | 
			
				
					116
				
			 | 
			
			
				         //此处的urlConnection对象实际上是根据URL的请求协议(此处是http) 生成的URLConnection类 的子类HttpURLConnection 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -83,7 +126,59 @@ public class CamelRestConfiguration extends RouteBuilder { 
			 | 
		
	
		
			
			| 
				
					83
				
			 | 
			
				
					126
				
			 | 
			
			
				         conn.setAllowUserInteraction(false); 
			 | 
		
	
		
			
			| 
				
					84
				
			 | 
			
				
					127
				
			 | 
			
			
				         DataOutputStream out = new DataOutputStream(conn 
			 | 
		
	
		
			
			| 
				
					85
				
			 | 
			
				
					128
				
			 | 
			
			
				                 .getOutputStream()); 
			 | 
		
	
		
			
			| 
				
					86
				
			 | 
			
				
			 | 
			
			
				-        String content = "id="+URLEncoder.encode(well_id+"/upData/电流平衡率", "UTF-8"); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					129
				
			 | 
			
			
				+        String content = "id=" + URLEncoder.encode(param, "UTF-8"); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					130
				
			 | 
			
			
				+        out.writeBytes(content); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					131
				
			 | 
			
			
				+        out.flush(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					132
				
			 | 
			
			
				+        out.close(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					133
				
			 | 
			
			
				+        PrintStream ps = new PrintStream(conn.getOutputStream()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					134
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					135
				
			 | 
			
			
				+        ps.close(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					136
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					137
				
			 | 
			
			
				+        InputStream is = null; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					138
				
			 | 
			
			
				+        if (conn.getResponseCode() == 200) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					139
				
			 | 
			
			
				+            is = conn.getInputStream(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					140
				
			 | 
			
			
				+        } else { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					141
				
			 | 
			
			
				+            is = conn.getErrorStream(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					142
				
			 | 
			
			
				+        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					143
				
			 | 
			
			
				+        BufferedReader bReader = new BufferedReader(new InputStreamReader(is, "UTF-8")); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					144
				
			 | 
			
			
				+        String line; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					145
				
			 | 
			
			
				+        StringBuilder resultStr = new StringBuilder(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					146
				
			 | 
			
			
				+        while (null != (line = bReader.readLine())) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					147
				
			 | 
			
			
				+            resultStr.append(line); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					148
				
			 | 
			
			
				+        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					149
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					150
				
			 | 
			
			
				+        String value = ""; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					151
				
			 | 
			
			
				+        JSONObject json = null; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					152
				
			 | 
			
			
				+        try { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					153
				
			 | 
			
			
				+            json = JSONObject.parseObject(resultStr.toString()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					154
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					155
				
			 | 
			
			
				+            if (json.size() > 0) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					156
				
			 | 
			
			
				+                value = json.get("value").toString(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					157
				
			 | 
			
			
				+            } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					158
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					159
				
			 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					160
				
			 | 
			
			
				+        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					161
				
			 | 
			
			
				+        return value; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					162
				
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					163
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					164
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					165
				
			 | 
			
			
				+    public String loadPhdDate(String well_id) throws Exception { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					166
				
			 | 
			
			
				+        URL restURL = new URL("http://11.72.128.71/api-service/tsdb/getLast?appKey=MOsEWVl8S0"); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					167
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					168
				
			 | 
			
			
				+        //此处的urlConnection对象实际上是根据URL的请求协议(此处是http) 生成的URLConnection类 的子类HttpURLConnection 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					169
				
			 | 
			
			
				+        HttpURLConnection conn = (HttpURLConnection) restURL.openConnection(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					170
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					171
				
			 | 
			
			
				+        //请求方式 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					172
				
			 | 
			
			
				+        conn.setRequestMethod("POST"); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					173
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					174
				
			 | 
			
			
				+        //设置是否从httpUrlConnection读入,默认情况下是true; httpUrlConnection.setDoInput(true); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					175
				
			 | 
			
			
				+        conn.setDoOutput(true); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					176
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					177
				
			 | 
			
			
				+        //allowUserInteraction 如果为 true,则在允许用户交互(例如弹出一个验证对话框)的上下文中对此 URL 进行检查。 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					178
				
			 | 
			
			
				+        conn.setAllowUserInteraction(false); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					179
				
			 | 
			
			
				+        DataOutputStream out = new DataOutputStream(conn 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					180
				
			 | 
			
			
				+                .getOutputStream()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					181
				
			 | 
			
			
				+        String content = "id=" + URLEncoder.encode(well_id + "/upData/电流平衡率", "UTF-8"); 
			 | 
		
	
		
			
			| 
				
					87
				
			 | 
			
				
					182
				
			 | 
			
			
				         out.writeBytes(content); 
			 | 
		
	
		
			
			| 
				
					88
				
			 | 
			
				
					183
				
			 | 
			
			
				         out.flush(); 
			 | 
		
	
		
			
			| 
				
					89
				
			 | 
			
				
					184
				
			 | 
			
			
				         out.close(); 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -115,12 +210,34 @@ public class CamelRestConfiguration extends RouteBuilder { 
			 | 
		
	
		
			
			| 
				
					115
				
			 | 
			
				
					210
				
			 | 
			
			
				             } 
			 | 
		
	
		
			
			| 
				
					116
				
			 | 
			
				
					211
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
					117
				
			 | 
			
				
					212
				
			 | 
			
			
				         } catch (Exception e) { 
			 | 
		
	
		
			
			| 
				
					118
				
			 | 
			
				
			 | 
			
			
				-            System.out.println(resultStr); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					213
				
			 | 
			
			
				+            e.printStackTrace(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					214
				
			 | 
			
			
				+//            System.out.println(resultStr); 
			 | 
		
	
		
			
			| 
				
					119
				
			 | 
			
				
					215
				
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				
					120
				
			 | 
			
				
					216
				
			 | 
			
			
				 //        System.out.println(value); 
			 | 
		
	
		
			
			| 
				
					121
				
			 | 
			
				
					217
				
			 | 
			
			
				         return value; 
			 | 
		
	
		
			
			| 
				
					122
				
			 | 
			
				
					218
				
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				
					123
				
			 | 
			
				
					219
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					220
				
			 | 
			
			
				+    @Resource(name = "centralbase") 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					221
				
			 | 
			
			
				+    DataSource baseDataSource; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					222
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					223
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					224
				
			 | 
			
			
				+    public void insertData(ZDJG_WELL z) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					225
				
			 | 
			
			
				+        JdbcTemplate jdbcTemplate = new JdbcTemplate(baseDataSource); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					226
				
			 | 
			
			
				+        String sql = "INSERT INTO centralbase.collection_time_error (well_id, prod_date,rut_time, stroke_length, stroke_frequency, susp_max_load, susp_min_load, sgt, error_log) " + 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					227
				
			 | 
			
			
				+                "VALUES ('" + z.getWell_common_name() + "','" + z.getProd_date() + "','" + z.getBz() + "','" + z.getStroke() + "','" + z.getFrequence() + "','" + z.getSxzh() + "','" + z.getXxzh() + "','" + z.getZd_init_sgt() + "','" + z.getErrorInfo() + "')  ON CONFLICT (well_id,prod_date)  DO NOTHING;"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					228
				
			 | 
			
			
				+        jdbcTemplate.update(sql); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					229
				
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					230
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					231
				
			 | 
			
			
				+    public void getAccessWell() { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					232
				
			 | 
			
			
				+        JdbcTemplate jdbcTemplate = new JdbcTemplate(baseDataSource); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					233
				
			 | 
			
			
				+        String sql = "SELECT well_id wellid FROM centralbase.sys_access_well_control where access_status = '1' and error_id = '1' "; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					234
				
			 | 
			
			
				+        List<String> accessWells = jdbcTemplate.queryForList(sql, String.class); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					235
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					236
				
			 | 
			
			
				+        accessWells.forEach(x -> { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					237
				
			 | 
			
			
				+            accessWellMap.put(x, x); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					238
				
			 | 
			
			
				+        }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					239
				
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					240
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
					124
				
			 | 
			
				
					241
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
					125
				
			 | 
			
				
					242
				
			 | 
			
			
				     public ZDJG_WELL loadGtDataNew(String param, String well_id, String sysDate) throws Exception { 
			 | 
		
	
		
			
			| 
				
					126
				
			 | 
			
				
					243
				
			 | 
			
			
				 //        String date = getDate(); 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -242,12 +359,12 @@ public class CamelRestConfiguration extends RouteBuilder { 
			 | 
		
	
		
			
			| 
				
					242
				
			 | 
			
				
					359
				
			 | 
			
			
				         ps.close(); 
			 | 
		
	
		
			
			| 
				
					243
				
			 | 
			
				
					360
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
					244
				
			 | 
			
				
					361
				
			 | 
			
			
				         InputStream is = null; 
			 | 
		
	
		
			
			| 
				
					245
				
			 | 
			
				
			 | 
			
			
				-        if (conn.getResponseCode() == 200){ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					362
				
			 | 
			
			
				+        if (conn.getResponseCode() == 200) { 
			 | 
		
	
		
			
			| 
				
					246
				
			 | 
			
				
					363
				
			 | 
			
			
				             is = conn.getInputStream(); 
			 | 
		
	
		
			
			| 
				
					247
				
			 | 
			
				
			 | 
			
			
				-        }else { 
			 | 
		
	
		
			
			| 
				
					248
				
			 | 
			
				
			 | 
			
			
				-            is= conn.getErrorStream(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					364
				
			 | 
			
			
				+        } else { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					365
				
			 | 
			
			
				+            is = conn.getErrorStream(); 
			 | 
		
	
		
			
			| 
				
					249
				
			 | 
			
				
					366
				
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				
					250
				
			 | 
			
				
			 | 
			
			
				-        BufferedReader bReader = new BufferedReader(new InputStreamReader(is,"UTF-8")); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					367
				
			 | 
			
			
				+        BufferedReader bReader = new BufferedReader(new InputStreamReader(is, "UTF-8")); 
			 | 
		
	
		
			
			| 
				
					251
				
			 | 
			
				
					368
				
			 | 
			
			
				         String line, resultStr = ""; 
			 | 
		
	
		
			
			| 
				
					252
				
			 | 
			
				
					369
				
			 | 
			
			
				         while (null != (line = bReader.readLine())) { 
			 | 
		
	
		
			
			| 
				
					253
				
			 | 
			
				
					370
				
			 | 
			
			
				             resultStr += line; 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -258,56 +375,75 @@ public class CamelRestConfiguration extends RouteBuilder { 
			 | 
		
	
		
			
			| 
				
					258
				
			 | 
			
				
					375
				
			 | 
			
			
				         try { 
			 | 
		
	
		
			
			| 
				
					259
				
			 | 
			
				
					376
				
			 | 
			
			
				             json = JSONObject.parseObject(resultStr); 
			 | 
		
	
		
			
			| 
				
					260
				
			 | 
			
				
					377
				
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
					261
				
			 | 
			
				
			 | 
			
			
				-            if(json.size()>0){ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					378
				
			 | 
			
			
				+            if (json.size() > 0) { 
			 | 
		
	
		
			
			| 
				
					262
				
			 | 
			
				
					379
				
			 | 
			
			
				                 String value = json.get("value").toString(); 
			 | 
		
	
		
			
			| 
				
					263
				
			 | 
			
				
					380
				
			 | 
			
			
				                 String time = json.get("time").toString(); 
			 | 
		
	
		
			
			| 
				
					264
				
			 | 
			
				
			 | 
			
			
				-                time= time.replace("Z", " UTC"); //2019-06-27T16:00:00.000 UTC 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					381
				
			 | 
			
			
				+                time = time.replace("Z", " UTC"); //2019-06-27T16:00:00.000 UTC 
			 | 
		
	
		
			
			| 
				
					265
				
			 | 
			
				
					382
				
			 | 
			
			
				                 SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z");//转换时区格式 
			 | 
		
	
		
			
			| 
				
					266
				
			 | 
			
				
			 | 
			
			
				-                Date cjDate = format1 .parse(time) ; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					383
				
			 | 
			
			
				+                Date cjDate = format1.parse(time); 
			 | 
		
	
		
			
			| 
				
					267
				
			 | 
			
				
					384
				
			 | 
			
			
				                 SimpleDateFormat fomat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
			 | 
		
	
		
			
			| 
				
					268
				
			 | 
			
				
					385
				
			 | 
			
			
				                 SimpleDateFormat fomat3 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); 
			 | 
		
	
		
			
			| 
				
					269
				
			 | 
			
				
					386
				
			 | 
			
			
				                 String mydate = fomat2.format(cjDate); 
			 | 
		
	
		
			
			| 
				
					270
				
			 | 
			
				
			 | 
			
			
				-                JSONObject json2= JSONObject.parseObject(value); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					387
				
			 | 
			
			
				+                JSONObject json2 = JSONObject.parseObject(value); 
			 | 
		
	
		
			
			| 
				
					271
				
			 | 
			
				
					388
				
			 | 
			
			
				                 String bool = json2.getString("state").toString(); 
			 | 
		
	
		
			
			| 
				
					272
				
			 | 
			
				
			 | 
			
			
				-                z.setIs_device_close(bool.equals("true")? "在线": "不在线"); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					389
				
			 | 
			
			
				+                z.setIs_device_close(bool.equals("true") ? "在线" : "不在线"); 
			 | 
		
	
		
			
			| 
				
					273
				
			 | 
			
				
					390
				
			 | 
			
			
				                 z.setIs_well_close("关井"); 
			 | 
		
	
		
			
			| 
				
					274
				
			 | 
			
				
			 | 
			
			
				-                if (!bool.equals("false")){ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					391
				
			 | 
			
			
				+                if (!bool.equals("false")) { 
			 | 
		
	
		
			
			| 
				
					275
				
			 | 
			
				
					392
				
			 | 
			
			
				                     String data = json2.get("data").toString(); 
			 | 
		
	
		
			
			| 
				
					276
				
			 | 
			
				
					393
				
			 | 
			
			
				                     JSONObject jsonObject = JSONObject.parseObject(data); 
			 | 
		
	
		
			
			| 
				
					277
				
			 | 
			
				
					394
				
			 | 
			
			
				 //                    String offset = jsonObject.getString("offset"); 
			 | 
		
	
		
			
			| 
				
					278
				
			 | 
			
				
					395
				
			 | 
			
			
				                     String jh = well_id.replace(" ", ""); 
			 | 
		
	
		
			
			| 
				
					279
				
			 | 
			
				
					396
				
			 | 
			
			
				                     z.setWell_common_name(jh); 
			 | 
		
	
		
			
			| 
				
					280
				
			 | 
			
				
			 | 
			
			
				-                    String gtsj = TransUtil.tranSGT(jsonObject.getString("offset"),jsonObject.getString("load")); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					397
				
			 | 
			
			
				+                    String gtsj = TransUtil.tranSGT(jsonObject.getString("offset"), jsonObject.getString("load")); 
			 | 
		
	
		
			
			| 
				
					281
				
			 | 
			
				
					398
				
			 | 
			
			
				                     Date timeRtu = null; 
			 | 
		
	
		
			
			| 
				
					282
				
			 | 
			
				
			 | 
			
			
				-                    String  rtutime = jsonObject.getString("time"); 
			 | 
		
	
		
			
			| 
				
					283
				
			 | 
			
				
			 | 
			
			
				-                    timeRtu = fomat3.parse("0000-00-00 00:".equals(rtutime)? "2021-04-10 10:10": rtutime); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					399
				
			 | 
			
			
				+                    String rtutime = jsonObject.getString("time"); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					400
				
			 | 
			
			
				+                    timeRtu = fomat3.parse("0000-00-00 00:".equals(rtutime) ? "2021-04-10 10:10" : rtutime); 
			 | 
		
	
		
			
			| 
				
					284
				
			 | 
			
				
					401
				
			 | 
			
			
				                     Date yunpingtai = fomat2.parse(mydate); 
			 | 
		
	
		
			
			| 
				
					285
				
			 | 
			
				
					402
				
			 | 
			
			
				                     long time1 = timeRtu.getTime(); 
			 | 
		
	
		
			
			| 
				
					286
				
			 | 
			
				
					403
				
			 | 
			
			
				                     long time2 = yunpingtai.getTime(); 
			 | 
		
	
		
			
			| 
				
					287
				
			 | 
			
				
					404
				
			 | 
			
			
				                     Date date = new Date(); 
			 | 
		
	
		
			
			| 
				
					288
				
			 | 
			
				
					405
				
			 | 
			
			
				                     long time3 = date.getTime(); 
			 | 
		
	
		
			
			| 
				
					289
				
			 | 
			
				
			 | 
			
			
				-                    int hours1 = (int) ((time3 - time2) / (1000 * 60 * 60)); 
			 | 
		
	
		
			
			| 
				
					290
				
			 | 
			
				
			 | 
			
			
				-                    int hours = (int) ((time2 - time1) / (1000 * 60 * 60)); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					406
				
			 | 
			
			
				+                    int hours1 = Math.abs((int) ((time3 - time2) / (1000 * 60 * 60))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					407
				
			 | 
			
			
				+                    int hours = Math.abs((int) ((time2 - time1) / (1000 * 60 * 60))); 
			 | 
		
	
		
			
			| 
				
					291
				
			 | 
			
				
					408
				
			 | 
			
			
				                     //云平台和采集时间相差要小于4小时 
			 | 
		
	
		
			
			| 
				
					292
				
			 | 
			
				
			 | 
			
			
				-                    if (hours <4 && !"".equals(gtsj) && hours1< 4 ){ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					409
				
			 | 
			
			
				+                    if (hours < 4 && !"".equals(gtsj) && hours1 < 4) { 
			 | 
		
	
		
			
			| 
				
					293
				
			 | 
			
				
					410
				
			 | 
			
			
				                         z.setZd_init_sgt(gtsj);//位移载荷点 
			 | 
		
	
		
			
			| 
				
					294
				
			 | 
			
				
			 | 
			
			
				-//                        z.setProd_date(mydate); 
			 | 
		
	
		
			
			| 
				
					295
				
			 | 
			
				
			 | 
			
			
				-//                        z.setSys_date(sysDate); 
			 | 
		
	
		
			
			| 
				
					296
				
			 | 
			
				
			 | 
			
			
				-//                        z.setIs_well_close(Double.valueOf(jsonObject.getString("minCurrent")) > 0 ? "开井": "关井"); 
			 | 
		
	
		
			
			| 
				
					297
				
			 | 
			
				
			 | 
			
			
				-//                        z.setPressure(0); 
			 | 
		
	
		
			
			| 
				
					298
				
			 | 
			
				
			 | 
			
			
				-                        if (jsonObject.getString("strokeFrequency") != null){ 
			 | 
		
	
		
			
			| 
				
					299
				
			 | 
			
				
			 | 
			
			
				-                            z.setStroke(CALUtil.round((Double.valueOf(jsonObject.getString("strokeFrequency"))) * 100) / 100);//冲程,但GTSB_2的冲程是CC字段 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					411
				
			 | 
			
			
				+// 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					412
				
			 | 
			
			
				+                        if (jsonObject.getString("strokeFrequency") != null) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					413
				
			 | 
			
			
				+                            z.setStroke(CALUtil.round((Double.valueOf(jsonObject.getString("stroke"))) * 100) / 100);//冲程,但GTSB_2的冲程是CC字段 
			 | 
		
	
		
			
			| 
				
					300
				
			 | 
			
				
					414
				
			 | 
			
			
				                         } 
			 | 
		
	
		
			
			| 
				
					301
				
			 | 
			
				
			 | 
			
			
				-                        if (jsonObject.getString("stroke") != null){ 
			 | 
		
	
		
			
			| 
				
					302
				
			 | 
			
				
			 | 
			
			
				-                            z.setFrequence(CALUtil.round((Double.valueOf(jsonObject.getString("stroke"))) * 100) / 100);//冲次,但GTSB_2的冲次是PJXC字段 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					415
				
			 | 
			
			
				+                        if (jsonObject.getString("stroke") != null) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					416
				
			 | 
			
			
				+                            z.setFrequence(CALUtil.round((Double.valueOf(jsonObject.getString("strokeFrequency"))) * 100) / 100);//冲次,但GTSB_2的冲次是PJXC字段 
			 | 
		
	
		
			
			| 
				
					303
				
			 | 
			
				
					417
				
			 | 
			
			
				                         } 
			 | 
		
	
		
			
			| 
				
					304
				
			 | 
			
				
					418
				
			 | 
			
			
				                         z.setSxzh(Double.parseDouble(jsonObject.getString("maxLoad")));//最大载荷 
			 | 
		
	
		
			
			| 
				
					305
				
			 | 
			
				
					419
				
			 | 
			
			
				                         z.setXxzh(Double.parseDouble(jsonObject.getString("minLoad")));//最小载荷 
			 | 
		
	
		
			
			| 
				
					306
				
			 | 
			
				
					420
				
			 | 
			
			
				                         z.setWell_common_name(well_id); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					421
				
			 | 
			
			
				+                    } else { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					422
				
			 | 
			
			
				+                        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					423
				
			 | 
			
			
				+                        String dateNow = df.format(new java.util.Date()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					424
				
			 | 
			
			
				+                        ZDJG_WELL well = new ZDJG_WELL(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					425
				
			 | 
			
			
				+                        well.setZd_init_sgt(gtsj);//位移载荷点 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					426
				
			 | 
			
			
				+// 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					427
				
			 | 
			
			
				+                        if (jsonObject.getString("strokeFrequency") != null) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					428
				
			 | 
			
			
				+                            well.setStroke(CALUtil.round((Double.valueOf(jsonObject.getString("stroke"))) * 100) / 100);//冲程,但GTSB_2的冲程是CC字段 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					429
				
			 | 
			
			
				+                        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					430
				
			 | 
			
			
				+                        if (jsonObject.getString("stroke") != null) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					431
				
			 | 
			
			
				+                            well.setFrequence(CALUtil.round((Double.valueOf(jsonObject.getString("strokeFrequency"))) * 100) / 100);//冲次,但GTSB_2的冲次是PJXC字段 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					432
				
			 | 
			
			
				+                        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					433
				
			 | 
			
			
				+                        well.setProd_date(dateNow); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					434
				
			 | 
			
			
				+                        well.setBz(rtutime); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					435
				
			 | 
			
			
				+                        well.setSxzh(Double.parseDouble(jsonObject.getString("maxLoad")));//最大载荷 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					436
				
			 | 
			
			
				+                        well.setXxzh(Double.parseDouble(jsonObject.getString("minLoad")));//最小载荷 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					437
				
			 | 
			
			
				+                        well.setWell_common_name(well_id); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					438
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					439
				
			 | 
			
			
				+                        well.setErrorInfo("采集时间错误"); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					440
				
			 | 
			
			
				+                        if (accessWellMap.get(well.getWell_common_name()) != null) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					441
				
			 | 
			
			
				+                            insertData(well); 
			 | 
		
	
		
			
			| 
				
					307
				
			 | 
			
				
					442
				
			 | 
			
			
				                     } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					443
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
					308
				
			 | 
			
				
					444
				
			 | 
			
			
				                 } 
			 | 
		
	
		
			
			| 
				
					309
				
			 | 
			
				
					445
				
			 | 
			
			
				             } 
			 | 
		
	
		
			
			| 
				
					310
				
			 | 
			
				
			 | 
			
			
				-        }catch (Exception e){ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					446
				
			 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
			| 
				
					311
				
			 | 
			
				
					447
				
			 | 
			
			
				 //            System.out.println(resultStr); 
			 | 
		
	
		
			
			| 
				
					312
				
			 | 
			
				
					448
				
			 | 
			
			
				         } 
			 | 
		
	
		
			
			| 
				
					313
				
			 | 
			
				
					449
				
			 | 
			
			
				         bReader.close(); 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -316,46 +452,50 @@ public class CamelRestConfiguration extends RouteBuilder { 
			 | 
		
	
		
			
			| 
				
					316
				
			 | 
			
				
					452
				
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				
					317
				
			 | 
			
				
					453
				
			 | 
			
			
				     @Override 
			 | 
		
	
		
			
			| 
				
					318
				
			 | 
			
				
					454
				
			 | 
			
			
				     public synchronized void configure() throws Exception { 
			 | 
		
	
		
			
			| 
				
					319
				
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				
					320
				
			 | 
			
				
			 | 
			
			
				-          restConfiguration() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					455
				
			 | 
			
			
				+        String date = getDate(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					456
				
			 | 
			
			
				+        getAccessWell(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					457
				
			 | 
			
			
				+        JSONObject body = new JSONObject(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					458
				
			 | 
			
			
				+        Map<String,String> map = new HashMap<>(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					459
				
			 | 
			
			
				+        restConfiguration() 
			 | 
		
	
		
			
			| 
				
					321
				
			 | 
			
				
					460
				
			 | 
			
			
				                 .component("servlet") 
			 | 
		
	
		
			
			| 
				
					322
				
			 | 
			
				
					461
				
			 | 
			
			
				                 .host("11.72.128.71"); 
			 | 
		
	
		
			
			| 
				
					323
				
			 | 
			
				
					462
				
			 | 
			
			
				         from("timer:mytimer?period=3600000") 
			 | 
		
	
		
			
			| 
				
					324
				
			 | 
			
				
			 | 
			
			
				-                .setBody(simple("select  *  from centralbase.cb_cd_well_source")) 
			 | 
		
	
		
			
			| 
				
					325
				
			 | 
			
				
			 | 
			
			
				-                .to("jdbc:centralbase") 
			 | 
		
	
		
			
			| 
				
					326
				
			 | 
			
				
			 | 
			
			
				-//                .to("rest:post:/api-service/device/query?appKey=MOsEWVl8S0&type=simple&pageSize=8000&page=1") 
			 | 
		
	
		
			
			| 
				
					327
				
			 | 
			
				
			 | 
			
			
				-//                .unmarshal().json(JsonLibrary.Jackson) 
			 | 
		
	
		
			
			| 
				
					328
				
			 | 
			
				
			 | 
			
			
				-//                .split(body()).process( 
			 | 
		
	
		
			
			| 
				
					329
				
			 | 
			
				
			 | 
			
			
				-//                exchange -> { 
			 | 
		
	
		
			
			| 
				
					330
				
			 | 
			
				
			 | 
			
			
				-//                    Message in = exchange.getIn(); 
			 | 
		
	
		
			
			| 
				
					331
				
			 | 
			
				
			 | 
			
			
				-//                    HashMap<String, Object> aRow = in.getBody(HashMap.class); 
			 | 
		
	
		
			
			| 
				
					332
				
			 | 
			
				
			 | 
			
			
				-//                    in.setHeader("id",aRow.get("data")); 
			 | 
		
	
		
			
			| 
				
					333
				
			 | 
			
				
			 | 
			
			
				-//                    in.setHeader("date", getDate()); 
			 | 
		
	
		
			
			| 
				
					334
				
			 | 
			
				
			 | 
			
			
				-//                }) 
			 | 
		
	
		
			
			| 
				
					335
				
			 | 
			
				
			 | 
			
			
				-// 
			 | 
		
	
		
			
			| 
				
					336
				
			 | 
			
				
			 | 
			
			
				-//                .setBody(simple("${in.header.id}")) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					463
				
			 | 
			
			
				+                .setBody(simple(body.toJSONString())) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					464
				
			 | 
			
			
				+                .to("rest:post:/api-service/device/query?appKey=MOsEWVl8S0&type=simple&pageSize=8000&page=1") 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					465
				
			 | 
			
			
				+                .unmarshal().json(JsonLibrary.Jackson) 
			 | 
		
	
		
			
			| 
				
					337
				
			 | 
			
				
					466
				
			 | 
			
			
				                 .split(body()).process( 
			 | 
		
	
		
			
			| 
				
					338
				
			 | 
			
				
			 | 
			
			
				-                exchange -> { 
			 | 
		
	
		
			
			| 
				
					339
				
			 | 
			
				
			 | 
			
			
				-                    Message in = exchange.getIn(); 
			 | 
		
	
		
			
			| 
				
					340
				
			 | 
			
				
			 | 
			
			
				-                    HashMap<String, Object> aRow = in.getBody(HashMap.class); 
			 | 
		
	
		
			
			| 
				
					341
				
			 | 
			
				
			 | 
			
			
				-                    if (aRow.get("typeName").toString().indexOf("油井")> 0){ 
			 | 
		
	
		
			
			| 
				
					342
				
			 | 
			
				
			 | 
			
			
				-//                        Double phd = "".equals(loadPhdDate(aRow.get("id").toString())) ?  0 : Double.valueOf(loadPhdDate(aRow.get("id").toString()) ); 
			 | 
		
	
		
			
			| 
				
					343
				
			 | 
			
				
			 | 
			
			
				-//                        ZDJG_WELL zdjg_well = loadGtDataNew(aRow.get("id")+"/analyse/功图数据", aRow.get("code").toString(), "2021-08-17"); 
			 | 
		
	
		
			
			| 
				
					344
				
			 | 
			
				
			 | 
			
			
				-                        ZDJG_WELL zdjg_well = loadGtDataNew("", aRow.get("well_id").toString(), ""); 
			 | 
		
	
		
			
			| 
				
					345
				
			 | 
			
				
			 | 
			
			
				-                        aRow.put("sgt",zdjg_well.getZd_init_sgt() );//null 
			 | 
		
	
		
			
			| 
				
					346
				
			 | 
			
				
			 | 
			
			
				-                        aRow.put("susp_max_load",zdjg_well.getSxzh());//最大载荷 
			 | 
		
	
		
			
			| 
				
					347
				
			 | 
			
				
			 | 
			
			
				-                        aRow.put("susp_min_load",zdjg_well.getXxzh());//最小载荷 
			 | 
		
	
		
			
			| 
				
					348
				
			 | 
			
				
			 | 
			
			
				-                        aRow.put("stroke",zdjg_well.getStroke()); 
			 | 
		
	
		
			
			| 
				
					349
				
			 | 
			
				
			 | 
			
			
				-                        aRow.put("frequency",zdjg_well.getFrequence()); 
			 | 
		
	
		
			
			| 
				
					350
				
			 | 
			
				
			 | 
			
			
				-                        aRow.put("dyna_create_time",zdjg_well.getProd_date()); 
			 | 
		
	
		
			
			| 
				
					351
				
			 | 
			
				
			 | 
			
			
				-                        aRow.put("well_name",aRow.get("code")); 
			 | 
		
	
		
			
			| 
				
					352
				
			 | 
			
				
			 | 
			
			
				-                        aRow.put("phd",""); 
			 | 
		
	
		
			
			| 
				
					353
				
			 | 
			
				
			 | 
			
			
				-                    } 
			 | 
		
	
		
			
			| 
				
					354
				
			 | 
			
				
			 | 
			
			
				-                }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					467
				
			 | 
			
			
				+                        exchange -> { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					468
				
			 | 
			
			
				+                            Message in = exchange.getIn(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					469
				
			 | 
			
			
				+                            HashMap<String, Object> aRow = in.getBody(HashMap.class); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					470
				
			 | 
			
			
				+                            in.setHeader("id", aRow.get("data")); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					471
				
			 | 
			
			
				+                            in.setHeader("date", getDate()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					472
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					473
				
			 | 
			
			
				+                            map.put("date",in.getHeader("date").toString()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					474
				
			 | 
			
			
				+                        }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					475
				
			 | 
			
			
				+                .setBody(simple("${in.header.id}")) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					476
				
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					477
				
			 | 
			
			
				+                .split(body()).process( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					478
				
			 | 
			
			
				+                        exchange -> { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					479
				
			 | 
			
			
				+                            Message in = exchange.getIn(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					480
				
			 | 
			
			
				+                            HashMap<String, Object> aRow = in.getBody(HashMap.class); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					481
				
			 | 
			
			
				+                            if (aRow.get("typeName") != null && aRow.get("typeName").toString().indexOf("油井") > 0) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					482
				
			 | 
			
			
				+                                getCurrentTimeParams(aRow.get("id").toString(), aRow.get("code").toString(),map.get("date")); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					483
				
			 | 
			
			
				+                                Double phd = "".equals(loadPhdDate(aRow.get("id").toString())) ? 0 : Double.valueOf(loadPhdDate(aRow.get("id").toString())); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					484
				
			 | 
			
			
				+                                ZDJG_WELL zdjg_well = loadGtData(aRow.get("id") + "/analyse/功图数据", aRow.get("code").toString(), "2021-08-17"); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					485
				
			 | 
			
			
				+                                aRow.put("sgt", zdjg_well.getZd_init_sgt());//null 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					486
				
			 | 
			
			
				+                                aRow.put("susp_max_load", zdjg_well.getSxzh());//最大载荷 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					487
				
			 | 
			
			
				+                                aRow.put("susp_min_load", zdjg_well.getXxzh());//最小载荷 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					488
				
			 | 
			
			
				+                                aRow.put("stroke", zdjg_well.getStroke()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					489
				
			 | 
			
			
				+                                aRow.put("frequency", zdjg_well.getFrequence()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					490
				
			 | 
			
			
				+                                aRow.put("dyna_create_time", zdjg_well.getProd_date()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					491
				
			 | 
			
			
				+                                aRow.put("well_name", zdjg_well.getStroke() == 0 || zdjg_well.getSxzh() == 0 ? "No01" : aRow.get("code")); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					492
				
			 | 
			
			
				+                                aRow.put("phd", phd == null ? 0 : phd); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					493
				
			 | 
			
			
				+                            } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					494
				
			 | 
			
			
				+                        }) 
			 | 
		
	
		
			
			| 
				
					355
				
			 | 
			
				
					495
				
			 | 
			
			
				 //                .log("${body[phd]}"+ "sql" + "${body[well_name]}") 
			 | 
		
	
		
			
			| 
				
					356
				
			 | 
			
				
					496
				
			 | 
			
			
				                 .doTry() 
			 | 
		
	
		
			
			| 
				
					357
				
			 | 
			
				
					497
				
			 | 
			
			
				                 .setBody(simple("insert into centralbase.cb_temp_well_mech_runtime(well_id,prod_date,stroke_length,stroke_frequency,susp_max_load,susp_min_load,sgt,elec_pump_current_b) " + 
			 | 
		
	
		
			
			| 
				
					358
				
			 | 
			
				
			 | 
			
			
				-                        "values( '${body[well_name]}','${in.header.date}','${body[stroke]}','${body[frequency]}','${body[susp_max_load]}','${body[susp_min_load]}','${body[sgt]}','${body[phd]}')  " )) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				
					498
				
			 | 
			
			
				+                        "values( '${body[well_name]}','${in.header.date}','${body[stroke]}','${body[frequency]}','${body[susp_max_load]}','${body[susp_min_load]}','${body[sgt]}','${body[phd]}')  ")) 
			 | 
		
	
		
			
			| 
				
					359
				
			 | 
			
				
					499
				
			 | 
			
			
				 //                        "where NOT EXISTS (SELECT * FROM centralbase.cb_temp_well_mech_runtime WHERE well_id = '${body[well_name]}' and  prod_date = '${in.header.date}' )")) 
			 | 
		
	
		
			
			| 
				
					360
				
			 | 
			
				
					500
				
			 | 
			
			
				                 .to("jdbc:centralbase") 
			 | 
		
	
		
			
			| 
				
					361
				
			 | 
			
				
					501
				
			 | 
			
			
				                 .doCatch(Exception.class) 
			 |