Browse Source

modify BJ update logic

gxt 3 years ago
parent
commit
bc94985eb5

+ 2 - 3
src/main/java/com/gct/tools/etlcamelhuge/controller/BaseDataController.java

@@ -77,11 +77,10 @@ public class BaseDataController {
77 77
                     sql = " update centralbase.cb_pc_pro_wellbore_status_daily set submergence_depth = '" + stringObjectMap.get("submergence_depth") + "' where well_id = '" + stringObjectMap.get("well_id") + "' and prod_date  = '" + stringObjectMap.get("prod_date") + "' ";
78 78
                     updateCMDCount = updateBaseDataSourceOfStatusDaily(sql) + updateCMDCount;
79 79
                 }
80
-                sql = " select distinct rn.well_id,cb.prod_date,rn.pump_diameter  from centralbase.cb_temp_well_mech_runtime rn ,centralbase.cb_pc_pro_wellbore_status_daily cb where cb.well_id = rn.well_id " +
81
-                        " and cb.prod_date = '" + date + "'  ";
80
+                sql = " SELECT  distinct jh,max(rq),bj FROM DBA01 WHERE dym is not null group by jh,dym ";
82 81
                 List<Map<String, Object>> oilNozzleList = selectBaseDataSourceStatusDaily(sql);
83 82
                 for (Map<String, Object> stringObjectMap : oilNozzleList) {
84
-                    sql = " update centralbase.cb_pc_pro_wellbore_status_daily set oil_nozzle = '" + stringObjectMap.get("pump_diameter") + "' where well_id ='" + stringObjectMap.get("well_id") + "' and prod_date='" + stringObjectMap.get("prod_date") + "' ";
83
+                    sql = " update centralbase.cb_pc_pro_wellbore_status_daily set oil_nozzle = '" + stringObjectMap.get("BJ") + "' where well_id ='" + stringObjectMap.get("JH") + "' and prod_date='" + stringObjectMap.get("RQ") + "' ";
85 84
                     updateOLiNozzleCount = updateBaseDataSourceOfStatusDaily(sql) + updateOLiNozzleCount;
86 85
                 }
87 86
                 insertCount++;

+ 31 - 31
src/main/java/com/gct/tools/etlcamelhuge/routeconfig/CamelJDBCCofRealTimeConfiguration.java

@@ -78,35 +78,7 @@ public class CamelJDBCCofRealTimeConfiguration  {
78 78
         return new RouteBuilder() {
79 79
             @Override
80 80
             public void configure() throws Exception {
81
-                from("timer:mytimer-insert-mechDaily?period=3600000")
82
-                        .routeId("insert-mech_daily")
83
-                        .setHeader("date", constant(getDate()))
84
-                        .setBody(simple("select distinct jh,rq,dym,jy,ly,bj,bs,bx,zs,cc,cs,blx,dl from DBA01 where rq  = to_date('${header.date}','yyyy-MM-dd') and qyrq is not null  "))
85
-                        .to("jdbc:oracle")
86
-                        .split(body()).process(exchange -> {
87
-                    Message in = exchange.getIn();
88
-                    HashMap<String, Object> aRow = in.getBody(HashMap.class);
89
-                    if (aRow.get("JY") == null) aRow.put("JY", "0.0");
90
-                    if (aRow.get("LY") == null) aRow.put("LY", "0.0");
91
-                    if (aRow.get("BJ") == null) aRow.put("BJ", "0.0");
92
-                    if (aRow.get("BS") == null) aRow.put("BS", "0.0");
93
-                    if (aRow.get("BX") == null) aRow.put("BX", "0.0");
94
-                    if (aRow.get("ZS") == null) aRow.put("ZS", "0.0");
95
-                    if (aRow.get("CC") == null) aRow.put("CC", "0.0");
96
-                    if (aRow.get("CS") == null) aRow.put("CS", "0.0");
97
-                    if (aRow.get("BLX") == null) aRow.put("BLX", "");
98
-                    if (aRow.get("DL") == null) aRow.put("DL", "0.0");
99
-                })
100
-                        .setBody(simple("insert into centralbase.cb_temp_well_mech_daily(well_id,prod_date,static_pressure,flow_pres,pump_diameter,pump_depth,pump_efficiency,rotate_frequency,stroke_length,stroke_frequency,pump_type,elec_frequency) " +
101
-                                "select '${body[JH]}','${body[RQ]}','${body[JY]}','${body[LY]}','${body[BJ]}','${body[BS]}','${body[BX]}','${body[ZS]}','${body[CC]}','${body[CS]}','${body[BLX]}','${body[DL]}' " +
102
-                                "where NOT EXISTS ( SELECT * FROM centralbase.cb_temp_well_mech_daily WHERE well_id = '${body[JH]}' and  prod_date = '${body[RQ]}' )"))
103
-                        .doTry()
104
-                        .to("jdbc:centralbase")
105
-                        .doCatch(Exception.class)
106
-                        .log("${header.date}"+" routeId:insert-mech_daily ->  centralbase.cb_temp_well_mech_daily insert data failed")
107
-                        .end();
108
-
109
-                from("timer:mytimer-update-runTime?period=3600000")
81
+                /*from("timer:mytimer-update-runTime?period=3600000")
110 82
                         .routeId("update-runTime")
111 83
                         .setHeader("date", constant(getDate() + " 00:00:00"))
112 84
                         .setBody(simple("SELECT  distinct jh,max(rq),bj FROM DBA01 WHERE dym is not null group by jh,bj"))
@@ -121,7 +93,7 @@ public class CamelJDBCCofRealTimeConfiguration  {
121 93
                         .to("jdbc:centralbase")
122 94
                         .doCatch(Exception.class)
123 95
                         .log("${header.date}"+" routeId:update-runTime -> centralbase.cb_temp_well_mech_runtime update data failed")
124
-                        .end();
96
+                        .end();*/
125 97
 
126 98
                 from("timer:mytimer-insert-runtimeAndSendToMQ?period=3600000")
127 99
                         .routeId("insert-runtimeAndSendToMQ")
@@ -189,7 +161,7 @@ public class CamelJDBCCofRealTimeConfiguration  {
189 161
                         .log("${header.date}"+" routeId:insert-runtimeAndSendToMQ ->  centralbase.cb_temp_well_mech_runtime insert data failed ${body}")
190 162
                         .end();
191 163
 
192
-               from("timer:mytimer-update-avg-mech_daily?period=3600000")
164
+               from("timer:mytimer-update-avg-mech_daily?period=1800000")
193 165
                         .routeId("update-avg-mech_daily")
194 166
                         .setHeader("date", constant(getDate()))
195 167
                         .setBody(simple("select well_id,avg(stroke_length) stroke_length  ,avg(stroke_frequency) stroke_frequency from centralbase.cb_temp_well_mech_runtime where prod_date::date='${header.date}' group by well_id"))
@@ -214,6 +186,34 @@ public class CamelJDBCCofRealTimeConfiguration  {
214 186
                         .doCatch(Exception.class)
215 187
                         .log("${header.date}"+" routeId:update-avg-mech_daily ->  centralbase.cb_temp_well_mech_daily update data failed")
216 188
                         .end();
189
+
190
+                from("timer:mytimer-insert-mechDaily?period=3600000")
191
+                        .routeId("insert-mech_daily")
192
+                        .setHeader("date", constant(getDate()))
193
+                        .setBody(simple("select distinct jh,rq,dym,jy,ly,bj,bs,bx,zs,cc,cs,blx,dl from DBA01 where rq  = to_date('${header.date}','yyyy-MM-dd') and qyrq is not null  "))
194
+                        .to("jdbc:oracle")
195
+                        .split(body()).process(exchange -> {
196
+                            Message in = exchange.getIn();
197
+                            HashMap<String, Object> aRow = in.getBody(HashMap.class);
198
+                            if (aRow.get("JY") == null) aRow.put("JY", "0.0");
199
+                            if (aRow.get("LY") == null) aRow.put("LY", "0.0");
200
+                            if (aRow.get("BJ") == null) aRow.put("BJ", "0.0");
201
+                            if (aRow.get("BS") == null) aRow.put("BS", "0.0");
202
+                            if (aRow.get("BX") == null) aRow.put("BX", "0.0");
203
+                            if (aRow.get("ZS") == null) aRow.put("ZS", "0.0");
204
+                            if (aRow.get("CC") == null) aRow.put("CC", "0.0");
205
+                            if (aRow.get("CS") == null) aRow.put("CS", "0.0");
206
+                            if (aRow.get("BLX") == null) aRow.put("BLX", "");
207
+                            if (aRow.get("DL") == null) aRow.put("DL", "0.0");
208
+                        })
209
+                        .setBody(simple("insert into centralbase.cb_temp_well_mech_daily(well_id,prod_date,static_pressure,flow_pres,pump_diameter,pump_depth,pump_efficiency,rotate_frequency,stroke_length,stroke_frequency,pump_type,elec_frequency) " +
210
+                                "select '${body[JH]}','${body[RQ]}','${body[JY]}','${body[LY]}','${body[BJ]}','${body[BS]}','${body[BX]}','${body[ZS]}','${body[CC]}','${body[CS]}','${body[BLX]}','${body[DL]}' " +
211
+                                "where NOT EXISTS ( SELECT * FROM centralbase.cb_temp_well_mech_daily WHERE well_id = '${body[JH]}' and  prod_date = '${body[RQ]}' )"))
212
+                        .doTry()
213
+                        .to("jdbc:centralbase")
214
+                        .doCatch(Exception.class)
215
+                        .log("${header.date}"+" routeId:insert-mech_daily ->  centralbase.cb_temp_well_mech_daily insert data failed")
216
+                        .end();
217 217
             };
218 218
         };
219 219
     }

+ 18 - 5
src/main/java/com/gct/tools/etlcamelhuge/routeconfig/CamelJDBCConfiguration.java

@@ -172,7 +172,7 @@ public class CamelJDBCConfiguration {
172 172
                         .end();
173 173
 
174 174
 
175
-                from("timer:mytimer-update-statusDaily-DYM?period=3600000")
175
+                from("timer:mytimer-update-statusDaily-DYM?period=1800000")
176 176
                         .routeId("update-statusDaily-DYM")
177 177
                         .setHeader("date", constant(getDate() + " 00:00:00"))
178 178
                         .setBody(simple("SELECT  distinct jh,max(rq),dym FROM DBA01 WHERE dym is not null group by jh,dym"))
@@ -185,7 +185,20 @@ public class CamelJDBCConfiguration {
185 185
                         .log("${header.date}"+" routeId:update-statusDaily-DYM ->  centralbase.cb_pc_pro_wellbore_status_daily update data failed")
186 186
                         .end();
187 187
 
188
-                from("timer:mytimer-update-statusDaily-submergenceDepth?period=3600000")
188
+                from("timer:mytimer-update-statusDaily-BJ?period=1800000")
189
+                        .routeId("update-statusDaily-DYM")
190
+                        .setHeader("date", constant(getDate() + " 00:00:00"))
191
+                        .setBody(simple("SELECT  distinct jh,max(rq),bj FROM DBA01 WHERE dym is not null group by jh,dym"))
192
+                        .to("jdbc:oracle")
193
+                        .split(body())
194
+                        .setBody(simple("update centralbase.cb_pc_pro_wellbore_status_daily set oil_nozzle = '${body[BJ]}' where well_id = '${body[JH]}' and prod_date::date  = '${header.date}' "))
195
+                        .doTry()
196
+                        .to("jdbc:centralbase")
197
+                        .doCatch(Exception.class)
198
+                        .log("${header.date}"+" routeId:update-statusDaily-DYM ->  centralbase.cb_pc_pro_wellbore_status_daily update data failed")
199
+                        .end();
200
+
201
+                from("timer:mytimer-update-statusDaily-submergenceDepth?period=1800000")
189 202
                         .routeId("update-statusDaily-submergenceDepth")
190 203
                         .setHeader("date", constant(getDate() + " 00:00:00"))
191 204
                         .setBody(simple("select well_id,prod_date,start_pump_liq_level,pump_depth from centralbase.cb_pc_pro_wellbore_status_daily where prod_date = '${header.date}' "))
@@ -209,7 +222,7 @@ public class CamelJDBCConfiguration {
209 222
                         .end();
210 223
 
211 224
 
212
-                from("timer:mytimer-update-statusDaily-oil_nozzle?period=3600000")
225
+              /*  from("timer:mytimer-update-statusDaily-oil_nozzle?period=1800000")
213 226
                         .routeId("update-statusDaily-oil_nozzle")
214 227
                         .setHeader("date", constant(getDate() + " 00:00:00"))
215 228
                         .setBody(simple("select distinct rn.well_id,cb.prod_date,rn.pump_diameter  from centralbase.cb_temp_well_mech_runtime rn ,centralbase.cb_pc_pro_wellbore_status_daily cb where cb.well_id = rn.well_id " +
@@ -225,7 +238,7 @@ public class CamelJDBCConfiguration {
225 238
                         .to("jdbc:centralbase")
226 239
                         .doCatch(Exception.class)
227 240
                         .log("${header.date}"+" routeId:update-statusDaily-oil_nozzle ->  centralbase.cb_pc_pro_wellbore_status_daily update data failed")
228
-                        .end();
241
+                        .end();*/
229 242
 
230 243
 
231 244
 
@@ -292,7 +305,7 @@ public class CamelJDBCConfiguration {
292 305
                         .to("jdbc:centralbase")
293 306
                         .end();
294 307
 
295
-                from("timer:mytimer-update-volDaily-liq_prod_daily?period=3600000")
308
+                from("timer:mytimer-update-volDaily-liq_prod_daily?period=1800000")
296 309
                         .routeId("update-volDaily-liq_prod_daily")
297 310
                         .setHeader("date", constant(getDate()))
298 311
                         .setBody(simple("select distinct  jh,rq,scsj, rcyl1,rcyl,rcql,hs, bz from DBA01 where rq  = to_date('${header.date}','yyyy-MM-dd') and qyrq is not null "))