lijian 2 years ago
parent
commit
31de7c3e8b

+ 9 - 8
src/main/java/com/gct/tools/etlcamelhuge/routeconfig/CamelRestConfiguration.java

@@ -67,7 +67,7 @@ public class CamelRestConfiguration extends RouteBuilder {
67
     }
67
     }
68
 
68
 
69
 
69
 
70
-    public void getCurrentTimeParams(String wellId, String wellName) throws Exception {
70
+    public void getCurrentTimeParams(String wellId, String wellName,String date) throws Exception {
71
 
71
 
72
         Map<String, Double> map = new HashMap<>();
72
         Map<String, Double> map = new HashMap<>();
73
 
73
 
@@ -92,17 +92,16 @@ public class CamelRestConfiguration extends RouteBuilder {
92
         map.put("totalPower", Double.valueOf("".equals(getParams(wellId + totalPower)) ? "0" : getParams(wellId + totalPower)));
92
         map.put("totalPower", Double.valueOf("".equals(getParams(wellId + totalPower)) ? "0" : getParams(wellId + totalPower)));
93
         map.put("casePress", Double.valueOf("".equals(getParams(wellId + casePress)) ? "0" : getParams(wellId + casePress)));
93
         map.put("casePress", Double.valueOf("".equals(getParams(wellId + casePress)) ? "0" : getParams(wellId + casePress)));
94
         map.put("oilPress", Double.valueOf("".equals(getParams(wellId + oilPress)) ? "0" : getParams(wellId + oilPress)));
94
         map.put("oilPress", Double.valueOf("".equals(getParams(wellId + oilPress)) ? "0" : getParams(wellId + oilPress)));
95
-        insertCurrentTimeParams(map, wellName);
95
+        insertCurrentTimeParams(map, wellName,date);
96
 
96
 
97
 
97
 
98
     }
98
     }
99
 
99
 
100
-    public void insertCurrentTimeParams(Map<String, Double> map, String wellName) {
101
-        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
102
-        String dateNow = df.format(new java.util.Date());
100
+    public void insertCurrentTimeParams(Map<String, Double> map, String wellName,String date) {
101
+
103
         JdbcTemplate jdbcTemplate = new JdbcTemplate(baseDataSource);
102
         JdbcTemplate jdbcTemplate = new JdbcTemplate(baseDataSource);
104
         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) " +
103
         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) " +
105
-                "VALUES ('" + wellName + "','" + dateNow + "'," + (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")) + ","
104
+                "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")) + ","
106
                 + (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;";
105
                 + (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;";
107
         if (accessWellMap.get(wellName) != null)
106
         if (accessWellMap.get(wellName) != null)
108
             jdbcTemplate.update(sql);
107
             jdbcTemplate.update(sql);
@@ -361,7 +360,7 @@ public class CamelRestConfiguration extends RouteBuilder {
361
 
360
 
362
         getAccessWell();
361
         getAccessWell();
363
         JSONObject body = new JSONObject();
362
         JSONObject body = new JSONObject();
364
-
363
+        Map<String,String> map = new HashMap<>();
365
         restConfiguration()
364
         restConfiguration()
366
                 .component("servlet")
365
                 .component("servlet")
367
                 .host("11.72.128.71");
366
                 .host("11.72.128.71");
@@ -375,6 +374,8 @@ public class CamelRestConfiguration extends RouteBuilder {
375
                             HashMap<String, Object> aRow = in.getBody(HashMap.class);
374
                             HashMap<String, Object> aRow = in.getBody(HashMap.class);
376
                             in.setHeader("id", aRow.get("data"));
375
                             in.setHeader("id", aRow.get("data"));
377
                             in.setHeader("date", getDate());
376
                             in.setHeader("date", getDate());
377
+
378
+                            map.put("date",in.getHeader("date").toString());
378
                         })
379
                         })
379
                 .setBody(simple("${in.header.id}"))
380
                 .setBody(simple("${in.header.id}"))
380
 
381
 
@@ -383,7 +384,7 @@ public class CamelRestConfiguration extends RouteBuilder {
383
                             Message in = exchange.getIn();
384
                             Message in = exchange.getIn();
384
                             HashMap<String, Object> aRow = in.getBody(HashMap.class);
385
                             HashMap<String, Object> aRow = in.getBody(HashMap.class);
385
                             if (aRow.get("typeName").toString().indexOf("油井") > 0) {
386
                             if (aRow.get("typeName").toString().indexOf("油井") > 0) {
386
-                                getCurrentTimeParams(aRow.get("id").toString(), aRow.get("code").toString());
387
+                                getCurrentTimeParams(aRow.get("id").toString(), aRow.get("code").toString(),map.get("date"));
387
                                 Double phd = "".equals(loadPhdDate(aRow.get("id").toString())) ? 0 : Double.valueOf(loadPhdDate(aRow.get("id").toString()));
388
                                 Double phd = "".equals(loadPhdDate(aRow.get("id").toString())) ? 0 : Double.valueOf(loadPhdDate(aRow.get("id").toString()));
388
                                 ZDJG_WELL zdjg_well = loadGtData(aRow.get("id") + "/analyse/功图数据", aRow.get("code").toString(), "2021-08-17");
389
                                 ZDJG_WELL zdjg_well = loadGtData(aRow.get("id") + "/analyse/功图数据", aRow.get("code").toString(), "2021-08-17");
389
                                 aRow.put("sgt", zdjg_well.getZd_init_sgt());//null
390
                                 aRow.put("sgt", zdjg_well.getZd_init_sgt());//null