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 72
         Map<String, Double> map = new HashMap<>();
73 73
 
@@ -92,17 +92,16 @@ public class CamelRestConfiguration extends RouteBuilder {
92 92
         map.put("totalPower", Double.valueOf("".equals(getParams(wellId + totalPower)) ? "0" : getParams(wellId + totalPower)));
93 93
         map.put("casePress", Double.valueOf("".equals(getParams(wellId + casePress)) ? "0" : getParams(wellId + casePress)));
94 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 102
         JdbcTemplate jdbcTemplate = new JdbcTemplate(baseDataSource);
104 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 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 106
         if (accessWellMap.get(wellName) != null)
108 107
             jdbcTemplate.update(sql);
@@ -361,7 +360,7 @@ public class CamelRestConfiguration extends RouteBuilder {
361 360
 
362 361
         getAccessWell();
363 362
         JSONObject body = new JSONObject();
364
-
363
+        Map<String,String> map = new HashMap<>();
365 364
         restConfiguration()
366 365
                 .component("servlet")
367 366
                 .host("11.72.128.71");
@@ -375,6 +374,8 @@ public class CamelRestConfiguration extends RouteBuilder {
375 374
                             HashMap<String, Object> aRow = in.getBody(HashMap.class);
376 375
                             in.setHeader("id", aRow.get("data"));
377 376
                             in.setHeader("date", getDate());
377
+
378
+                            map.put("date",in.getHeader("date").toString());
378 379
                         })
379 380
                 .setBody(simple("${in.header.id}"))
380 381
 
@@ -383,7 +384,7 @@ public class CamelRestConfiguration extends RouteBuilder {
383 384
                             Message in = exchange.getIn();
384 385
                             HashMap<String, Object> aRow = in.getBody(HashMap.class);
385 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 388
                                 Double phd = "".equals(loadPhdDate(aRow.get("id").toString())) ? 0 : Double.valueOf(loadPhdDate(aRow.get("id").toString()));
388 389
                                 ZDJG_WELL zdjg_well = loadGtData(aRow.get("id") + "/analyse/功图数据", aRow.get("code").toString(), "2021-08-17");
389 390
                                 aRow.put("sgt", zdjg_well.getZd_init_sgt());//null