xsr 8 månader sedan
förälder
incheckning
3953d4756d

+ 184 - 125
src/main/java/com/gct/tools/etlcamelhuge/routeconfig/CamelJDBCConfiguration.java

@@ -7,8 +7,6 @@ import org.apache.camel.model.ExpressionNode;
7 7
 import org.apache.camel.model.ProcessorDefinition;
8 8
 import org.apache.camel.model.RouteDefinition;
9 9
 import org.springframework.context.annotation.Bean;
10
-import org.springframework.context.annotation.Configuration;
11
-import org.springframework.util.StringUtils;
12 10
 
13 11
 import java.math.BigDecimal;
14 12
 import java.math.RoundingMode;
@@ -27,30 +25,32 @@ import java.util.*;
27 25
 public class CamelJDBCConfiguration {
28 26
 
29 27
 
30
-    public String getDate(){
31
-        return  LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
28
+    public String getDate() {
29
+        return LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
32 30
     }
31
+
33 32
     @Bean
34 33
     public RouteBuilder routeBuilderWithOracle1() {
35 34
         return new RouteBuilder() {
36 35
             private SortedSet<String> organization;
37
-            private Map<String, Integer>  orgIDs = new HashMap<>();
36
+            private Map<String, Integer> orgIDs = new HashMap<>();
38 37
             private int orgID;
39 38
             private Map<Object, Object> orgIdPreList;
40 39
             private Integer org;
41 40
 
42
-            public ProcessorDefinition<ExpressionNode> setMyBody(RouteDefinition route){
43
-             return  route.setBody(simple("select well_id from centralbase.sys_access_well_control  where  access_status='1'  "))
41
+            public ProcessorDefinition<ExpressionNode> setSysControlBody(RouteDefinition route) {
42
+                return route.setBody(simple("select well_id from centralbase.sys_access_well_control  where  access_status='1'  "))
44 43
                         .to("jdbc:centralbase")
45 44
                         .split(body()).process(exchange -> {
46 45
                             HashMap body = exchange.getIn().getBody(HashMap.class);
47
-                            exchange.getIn().setHeader("well_id",body.get("well_id"));
46
+                            exchange.getIn().setHeader("well_id", body.get("well_id"));
48 47
                         });
49 48
             }
49
+
50 50
             @Override
51 51
             public void configure() throws Exception {
52 52
 
53
-                RouteDefinition OrgAndWellSource= (RouteDefinition) from("timer:insert-OrgAndWellSource?period=86400000")
53
+                /*RouteDefinition OrgAndWellSource= (RouteDefinition) from("timer:insert-OrgAndWellSource?period=86400000")
54 54
                         .routeId("insert-OrgAndWellSource")
55 55
                         .setHeader("date", constant(getDate()+" 00:00:00"))
56 56
                         .process(exchange -> {
@@ -156,7 +156,7 @@ public class CamelJDBCConfiguration {
156 156
                   .to("jdbc:centralbase")
157 157
                   .doCatch(Exception.class)
158 158
                   .log("${header.date}"+" routeId:insert-OrgAndWellSource->  centralbase.cb_pc_organization insert data failed")
159
-                  .end();
159
+                  .end();*/
160 160
 
161 161
                 from("timer:update-wellControl?period=3600000")
162 162
                         .routeId("update-wellControl")
@@ -173,17 +173,17 @@ public class CamelJDBCConfiguration {
173 173
                             String yesterday = LocalDateTime.now().minusDays(1).format(df);
174 174
                             body.put("yesterday", yesterday);
175 175
                             if (body.get("well_common_name") == null || body.get("well_common_name").equals("")) {
176
-                                body.put("remarks","暂无井信息");
177
-                                body.put("error_id",0);
178
-                                body.put("updateTime",format);
179
-                            }else if (body.get("org_id") == null || body.get("org_id").equals("")){
180
-                                body.put("remarks","暂无机构信息");
181
-                                body.put("error_id",0);
182
-                                body.put("updateTime",format);
183
-                            }else {
184
-                                body.put("remarks","");
185
-                                body.put("error_id",1);
186
-                                body.put("updateTime",format);
176
+                                body.put("remarks", "暂无井信息");
177
+                                body.put("error_id", 0);
178
+                                body.put("updateTime", format);
179
+                            } else if (body.get("org_id") == null || body.get("org_id").equals("")) {
180
+                                body.put("remarks", "暂无机构信息");
181
+                                body.put("error_id", 0);
182
+                                body.put("updateTime", format);
183
+                            } else {
184
+                                body.put("remarks", "");
185
+                                body.put("error_id", 1);
186
+                                body.put("updateTime", format);
187 187
                             }
188 188
 
189 189
                         })
@@ -196,139 +196,198 @@ public class CamelJDBCConfiguration {
196 196
                         .to("jdbc:centralbase")
197 197
                         .end();
198 198
 
199
-
200
-                RouteDefinition statusDaily= from("timer:mytimer-insert-statusDaily?period=10800000")
199
+                RouteDefinition statusDaily = from("timer:mytimer-insert-statusDaily?period=10800000")
201 200
                         .routeId("insert-statusDaily")
202 201
                         .process(exchange -> {
203 202
                             Message in = exchange.getIn();
204
-                            in.setHeader("date",getDate());
203
+                            in.setHeader("date", getDate());
205 204
                         });
206
-                         setMyBody(statusDaily)
207
-                        .setBody(simple("select  distinct jh,rq,cyfs,yz,hysx ,bj, yysx ,tysx,bs,dym from DBA01 where rq  = to_date('${header.date}','yyyy-MM-dd') and jh='${header.well_id}' and qyrq is not null "))
205
+                setSysControlBody(statusDaily)
206
+                        .setBody(simple("select  distinct WELL_ID,PROD_DATE,OIL_PRODUCTION_METHOD ,BACK_PRES,MAX_TUBING_PRES,MIN_TUBING_PRES,CASING_PRES" +
207
+                                " from ZY_DXGW.PC_PRO_COM_DAILY " +
208
+                                "where prod_date  = to_date('${header.date}','yyyy-MM-dd') and well_id ='${header.well_id}'"))
208 209
                         .to("jdbc:oracle")
209 210
                         .split(body()).process(exchange -> {
210
-                    Message in = exchange.getIn();
211
-                    HashMap<String, Object> aRow = in.getBody(HashMap.class);
212
-                    if (aRow.get("YZ") == null) aRow.put("YZ", "0.0");
213
-                    if (aRow.get("BJ") == null) aRow.put("BJ", "0.0");
214
-                    if (aRow.get("HYSX") == null) aRow.put("HYSX", "0.0");
215
-                    if (aRow.get("YYSX") == null) aRow.put("YYSX", "0.0");
216
-                    if (aRow.get("TYSX") == null) aRow.put("TYSX", "0.0");
217
-                    if (aRow.get("BS") == null) aRow.put("BS", "0.0");
218
-                })
219
-                        .setBody(simple("insert into centralbase.cb_pc_pro_wellbore_status_daily(well_id,prod_date,oil_prod_method,oil_nozzle,back_pres,tubing_pres,casing_pres,pump_depth) " +
220
-                                "select '${body[JH]}','${body[RQ]}','${body[CYFS]}','${body[BJ]}','${body[HYSX]}','${body[YYSX]}','${body[TYSX]}','${body[BS]}' " +
221
-                                "where NOT EXISTS ( SELECT * FROM centralbase.cb_pc_pro_wellbore_status_daily WHERE well_id = '${body[JH]}' and  prod_date = '${body[RQ]}')"))
211
+                            Message in = exchange.getIn();
212
+                            HashMap<String, Object> aRow = in.getBody(HashMap.class);
213
+                            aRow.putIfAbsent("OIL_NOZZLE", "0.0");
214
+                            aRow.putIfAbsent("BACK_PRES", "0.0");
215
+                            if (aRow.get("MAX_TUBING_PRES") == null || aRow.get("MIN_TUBING_PRES") == null)
216
+                                aRow.put("TUBING_PRES", "0.0");
217
+                            else {
218
+                                aRow.put("TUBING_PRES", String.format("%.2f",(Double.parseDouble(aRow.get("MAX_TUBING_PRES").toString())
219
+                                        + Double.parseDouble(aRow.get("MIN_TUBING_PRES").toString())) / 2));
220
+                            }
221
+                            aRow.putIfAbsent("CASING_PRES", "0.0");
222
+                            aRow.putIfAbsent("PUMP_DEPTH", "0.0");
223
+                        })
224
+                        .setBody(simple("insert into centralbase.cb_pc_pro_wellbore_status_daily(well_id,prod_date,oil_prod_method,back_pres,tubing_pres,casing_pres) " +
225
+                                "select '${body[WELL_ID]}','${body[PROD_DATE]}','${body[OIL_PRODUCTION_METHOD]}'," +
226
+                                "'${body[BACK_PRES]}','${body[TUBING_PRES]}','${body[CASING_PRES]}'" +
227
+                                "where NOT EXISTS ( SELECT * FROM centralbase.cb_pc_pro_wellbore_status_daily " +
228
+                                "      WHERE well_id = '${body[WELL_ID]}' and  prod_date = '${body[PROD_DATE]}')"))
222 229
                         .doTry()
223 230
                         .to("jdbc:centralbase")
224 231
                         .doCatch(Exception.class)
225
-                        .log("${header.date}"+" routeId:insert-statusDaily ->  centralbase.cb_pc_pro_wellbore_status_daily insert data failed")
232
+                        .log("${header.date}" + " routeId:insert-statusDaily ->  centralbase.cb_pc_pro_wellbore_status_daily insert data failed")
226 233
                         .end();
227 234
 
228
-
235
+                // BS BJ DYM find before data
229 236
                 RouteDefinition statusDailyDYM = from("timer:mytimer-update-statusDaily-DYM?period=10800000")
230 237
                         .routeId("update-statusDaily-DYM")
231 238
                         .process(exchange -> {
232 239
                             Message in = exchange.getIn();
233
-                            in.setHeader("date",getDate());
240
+                            in.setHeader("date", getDate());
234 241
                         });
235
-                         setMyBody(statusDailyDYM)
236
-                        .setBody(simple("select distinct jh , csrq , ymsd from ZD_YTGSCX.DCA002_ZD where  (jh,csrq) in (SELECT  jh,max(csrq) csrq  FROM ZD_YTGSCX.DCA002_ZD WHERE ymsd is not null and jh='${header.well_id}' group by jh)"))
242
+                setSysControlBody(statusDailyDYM)
243
+                        .setBody(simple("select distinct WELL_ID , PROD_DATE , DYNAMIC_LIQ_LEVEL " +
244
+                                "from ZY_DXGW.PC_PRO_COM_DAILY " +
245
+                                "where  (WELL_ID,PROD_DATE) in" +
246
+                                " (SELECT  WELL_ID,max(PROD_DATE) PROD_DATE  FROM ZY_DXGW.PC_PRO_COM_DAILY" +
247
+                                "    WHERE DYNAMIC_LIQ_LEVEL is not null and WELL_ID='${header.well_id}' group by WELL_ID)"))
237 248
                         .to("jdbc:oracle")
238 249
                         .split(body())
239
-                        .setBody(simple("update centralbase.cb_pc_pro_wellbore_status_daily set start_pump_liq_level = '${body[YMSD]}'  where well_id = '${body[JH]}' and prod_date::date  = '${header.date}' "))
250
+                        .setBody(simple("update centralbase.cb_pc_pro_wellbore_status_daily set start_pump_liq_level = '${body[DYNAMIC_LIQ_LEVEL]}'  " +
251
+                                "where well_id = '${header.well_id}' and prod_date::date  = '${header.date}' "))
240 252
                         .doTry()
241 253
                         .to("jdbc:centralbase")
242 254
                         .doCatch(Exception.class)
243
-                        .log("${header.date}"+" routeId:update-statusDaily-DYM ->  centralbase.cb_pc_pro_wellbore_status_daily update data failed")
255
+                        .log("${header.date}" + " routeId:update-statusDaily-DYM ->  centralbase.cb_pc_pro_wellbore_status_daily update data failed")
244 256
                         .end();
257
+
258
+                RouteDefinition statusDailyBS = from("timer:mytimer-update-statusDaily-BS?period=10800000")
259
+                        .routeId("update-statusDaily-BS")
260
+                        .process(exchange -> {
261
+                            Message in = exchange.getIn();
262
+                            in.setHeader("date", getDate());
263
+                        });
264
+                setSysControlBody(statusDailyBS)
265
+                        .setBody(simple("select distinct WELL_ID , PROD_DATE , PUMP_DEPTH " +
266
+                                "from ZY_DXGW.PC_PRO_COM_DAILY " +
267
+                                "where  (WELL_ID,PROD_DATE) in" +
268
+                                " (SELECT  WELL_ID,max(PROD_DATE) PROD_DATE  FROM ZY_DXGW.PC_PRO_COM_DAILY" +
269
+                                "    WHERE PUMP_DEPTH is not null and WELL_ID='${header.well_id}' group by WELL_ID)"))
270
+                        .to("jdbc:oracle")
271
+                        .split(body())
272
+                        .setBody(simple("update centralbase.cb_pc_pro_wellbore_status_daily set pump_depth = '${body[PUMP_DEPTH]}'  " +
273
+                                "where well_id = '${header.well_id}' and prod_date::date  = '${header.date}' "))
274
+                        .doTry()
275
+                        .to("jdbc:centralbase")
276
+                        .doCatch(Exception.class)
277
+                        .log("${header.date}" + " routeId:update-statusDaily-BS ->  centralbase.cb_pc_pro_wellbore_status_daily update data failed")
278
+                        .end();
279
+
280
+                RouteDefinition statusDailyBJ = from("timer:mytimer-update-statusDaily-BJ?period=10800000")
281
+                        .routeId("update-statusDaily-BJ")
282
+                        .process(exchange -> {
283
+                            Message in = exchange.getIn();
284
+                            in.setHeader("date", getDate());
285
+                        });
286
+                setSysControlBody(statusDailyBJ)
287
+                        .setBody(simple("select distinct WELL_ID , PROD_DATE , PUMP_DIAMETER " +
288
+                                "from ZY_DXGW.PC_PRO_COM_DAILY " +
289
+                                "where  (WELL_ID,PROD_DATE) in" +
290
+                                " (SELECT  WELL_ID,max(PROD_DATE) PROD_DATE  FROM ZY_DXGW.PC_PRO_COM_DAILY" +
291
+                                "    WHERE PUMP_DIAMETER is not null and WELL_ID='${header.well_id}' group by WELL_ID)"))
292
+                        .to("jdbc:oracle")
293
+                        .split(body())
294
+                        .setBody(simple("update centralbase.cb_pc_pro_wellbore_status_daily set oil_nozzle = '${body[PUMP_DIAMETER]}'  " +
295
+                                "where well_id = '${header.well_id}' and prod_date::date  = '${header.date}' "))
296
+                        .doTry()
297
+                        .to("jdbc:centralbase")
298
+                        .doCatch(Exception.class)
299
+                        .log("${header.date}" + " routeId:update-statusDaily-BJ ->  centralbase.cb_pc_pro_wellbore_status_daily update data failed")
300
+                        .end();
301
+
245 302
                 RouteDefinition submergenceDepth = from("timer:mytimer-update-statusDaily-submergenceDepth?period=10800000")
246 303
                         .routeId("update-statusDaily-submergenceDepth")
247 304
                         .process(exchange -> {
248 305
                             Message in = exchange.getIn();
249
-                            in.setHeader("date",getDate()+" 00:00:00");
306
+                            in.setHeader("date", getDate() + " 00:00:00");
250 307
                         });
251
-                         setMyBody(submergenceDepth)
308
+                setSysControlBody(submergenceDepth)
252 309
                         .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}' and well_id='${header.well_id}' "))
253 310
                         .to("jdbc:centralbase")
254 311
                         .split(body()).process(exchange -> {
255 312
                             Message in = exchange.getIn();
256 313
                             HashMap<String, Object> aRow = in.getBody(HashMap.class);
257
-                            aRow.put("submergence_depth",null);
258
-                            if (aRow.get("start_pump_liq_level")!=null && aRow.get("pump_depth")!=null){
259
-                                double cmd= Double.parseDouble(aRow.get("pump_depth").toString())-Double.parseDouble(aRow.get("start_pump_liq_level").toString())/10;
260
-                                BigDecimal bd=new BigDecimal(cmd);
261
-                                double cmd1=bd.setScale(1, RoundingMode.HALF_UP).doubleValue();
262
-                                aRow.put("submergence_depth",cmd1);
314
+                            aRow.put("submergence_depth", null);
315
+                            if (aRow.get("start_pump_liq_level") != null && aRow.get("pump_depth") != null) {
316
+                                double cmd = Double.parseDouble(aRow.get("pump_depth").toString()) - Double.parseDouble(aRow.get("start_pump_liq_level").toString()) / 10;
317
+                                BigDecimal bd = new BigDecimal(cmd);
318
+                                double cmd1 = bd.setScale(1, RoundingMode.HALF_UP).doubleValue();
319
+                                aRow.put("submergence_depth", cmd1);
263 320
                             }
264
-                })
321
+                        })
265 322
                         .setBody(simple("update centralbase.cb_pc_pro_wellbore_status_daily set submergence_depth = '${body[submergence_depth]}' where well_id = '${body[well_id]}' and prod_date  = '${body[prod_date]}'"))
266 323
                         .doTry()
267 324
                         .to("jdbc:centralbase")
268 325
                         .doCatch(Exception.class)
269
-                        .log("${header.date}"+" routeId:update-statusDaily-submergenceDepth ->  centralbase.cb_pc_pro_wellbore_status_daily update data failed")
326
+                        .log("${header.date}" + " routeId:update-statusDaily-submergenceDepth ->  centralbase.cb_pc_pro_wellbore_status_daily update data failed")
270 327
                         .end();
271 328
 
329
+
330
+
272 331
                 RouteDefinition volDaily = from("timer:mytimer-insert-volDaily?period=10800000")
273 332
                         .routeId("insert-volDaily")
274 333
                         .process(exchange -> {
275 334
                             Message in = exchange.getIn();
276
-                            in.setHeader("date",getDate());
335
+                            in.setHeader("date", getDate());
277 336
                         });
278
-                         setMyBody(volDaily)
337
+                setSysControlBody(volDaily)
279 338
                         .setBody(simple("select distinct  jh,rq,scsj, rcyl1,rcyl,rcql,hs, bz,sccw from DBA01 where rq  = to_date('${header.date}','yyyy-MM-dd') and jh ='${header.well_id}' and qyrq is not null "))
280 339
                         .to("jdbc:oracle")
281 340
                         .split(body()).process(exchange -> {
282
-                    Message in = exchange.getIn();
283
-                    HashMap<String, Object> aRow = in.getBody(HashMap.class);
284
-                    if (aRow.get("SCSJ") == null) aRow.put("SCSJ", "0.0");
285
-                    if (aRow.get("RCYL1") == null) aRow.put("RCYL1", "0.0");
286
-                    if (aRow.get("RCYL") == null) aRow.put("RCYL", "0.0");
287
-                    if (aRow.get("RCQL") == null) aRow.put("RCQL", "0.0");
288
-                    if (aRow.get("HS") == null) aRow.put("HS", "0.0");
289
-                    if (aRow.get("BZ") == null) aRow.put("BZ", "");
290
-                    if (aRow.get("SCCW") == null) aRow.put("SCCW", "");
291
-                    aRow.put("RCSL",-1);
292
-                    aRow.put("QYB",-1);
293
-                    aRow.put("SQB",-1);
294
-                    if (aRow.get("RCQL")!=null && aRow.get("RCYL")!=null && !aRow.get("RCYL").equals("0.0") && aRow.get("RCYL") != "0.0"){
295
-                        double qyb = Double.valueOf(aRow.get("RCQL").toString()) / Double.valueOf(aRow.get("RCYL").toString());
296
-                        if (!Double.isNaN(qyb) && !Double.isInfinite(qyb)){
297
-                            BigDecimal bd=new BigDecimal(qyb);
298
-                            double d1=bd.setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue();
299
-                            aRow.put("QYB",d1);
300
-                        }
301
-                    }
302
-                    if (aRow.get("RCYL1")!=null && aRow.get("HS") != null && !aRow.get("HS").equals("0.0") && aRow.get("HS") != "0.0"){
303
-                        double rcsl = (Double.valueOf(aRow.get("RCYL1").toString()) * Double.valueOf(aRow.get("HS").toString()))/100;
304
-                        if (!Double.isNaN(rcsl) && !Double.isInfinite(rcsl)) {
305
-                            BigDecimal bd = new BigDecimal(rcsl);
306
-                            double d1 = bd.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
307
-                            aRow.put("RCSL", d1);
308
-                        }
309
-                    }
310
-                    if (aRow.get("RCQL") != null && aRow.get("RCSL") != null && !aRow.get("RCQL").equals("0.0") && aRow.get("RCQL") != "0.0" ){
311
-                        double sqb = Double.valueOf(aRow.get("RCSL").toString()) / Double.valueOf(aRow.get("RCQL").toString());
312
-                        if (!Double.isNaN(sqb) && !Double.isInfinite(sqb)) {
313
-                            BigDecimal bd = new BigDecimal(sqb);
314
-                            double d1 = bd.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
315
-                            aRow.put("SQB", d1);
316
-                        }
317
-                    }
318
-                    if (!aRow.containsKey("SMD")){
319
-                        aRow.put("SMD",1);
320
-                    }
321
-                    if (!aRow.containsKey("YMD")){
322
-                        aRow.put("YMD",0.85);
323
-                    }
324
-                })
341
+                            Message in = exchange.getIn();
342
+                            HashMap<String, Object> aRow = in.getBody(HashMap.class);
343
+                            if (aRow.get("SCSJ") == null) aRow.put("SCSJ", "0.0");
344
+                            if (aRow.get("RCYL1") == null) aRow.put("RCYL1", "0.0");
345
+                            if (aRow.get("RCYL") == null) aRow.put("RCYL", "0.0");
346
+                            if (aRow.get("RCQL") == null) aRow.put("RCQL", "0.0");
347
+                            if (aRow.get("HS") == null) aRow.put("HS", "0.0");
348
+                            if (aRow.get("BZ") == null) aRow.put("BZ", "");
349
+                            if (aRow.get("SCCW") == null) aRow.put("SCCW", "");
350
+                            aRow.put("RCSL", -1);
351
+                            aRow.put("QYB", -1);
352
+                            aRow.put("SQB", -1);
353
+                            if (aRow.get("RCQL") != null && aRow.get("RCYL") != null && !aRow.get("RCYL").equals("0.0") && aRow.get("RCYL") != "0.0") {
354
+                                double qyb = Double.valueOf(aRow.get("RCQL").toString()) / Double.valueOf(aRow.get("RCYL").toString());
355
+                                if (!Double.isNaN(qyb) && !Double.isInfinite(qyb)) {
356
+                                    BigDecimal bd = new BigDecimal(qyb);
357
+                                    double d1 = bd.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
358
+                                    aRow.put("QYB", d1);
359
+                                }
360
+                            }
361
+                            if (aRow.get("RCYL1") != null && aRow.get("HS") != null && !aRow.get("HS").equals("0.0") && aRow.get("HS") != "0.0") {
362
+                                double rcsl = (Double.valueOf(aRow.get("RCYL1").toString()) * Double.valueOf(aRow.get("HS").toString())) / 100;
363
+                                if (!Double.isNaN(rcsl) && !Double.isInfinite(rcsl)) {
364
+                                    BigDecimal bd = new BigDecimal(rcsl);
365
+                                    double d1 = bd.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
366
+                                    aRow.put("RCSL", d1);
367
+                                }
368
+                            }
369
+                            if (aRow.get("RCQL") != null && aRow.get("RCSL") != null && !aRow.get("RCQL").equals("0.0") && aRow.get("RCQL") != "0.0") {
370
+                                double sqb = Double.valueOf(aRow.get("RCSL").toString()) / Double.valueOf(aRow.get("RCQL").toString());
371
+                                if (!Double.isNaN(sqb) && !Double.isInfinite(sqb)) {
372
+                                    BigDecimal bd = new BigDecimal(sqb);
373
+                                    double d1 = bd.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
374
+                                    aRow.put("SQB", d1);
375
+                                }
376
+                            }
377
+                            if (!aRow.containsKey("SMD")) {
378
+                                aRow.put("SMD", 1);
379
+                            }
380
+                            if (!aRow.containsKey("YMD")) {
381
+                                aRow.put("YMD", 0.85);
382
+                            }
383
+                        })
325 384
                         .setBody(simple("insert into centralbase.cb_pc_pro_wellbore_vol_daily(well_id,prod_date,prod_time,liq_prod_daily,oil_prod_daily,gas_prod_daily,water_cut,remarks,gas_oil_ratio,water_prod_daily,water_gas_ratio,surface_crude_water_density,surface_crude_oil_density,stim_content) " +
326 385
                                 "select '${body[JH]}','${body[RQ]}','${body[SCSJ]}','${body[RCYL1]}','${body[RCYL]}','${body[RCQL]}','${body[HS]}','${body[BZ]}','${body[QYB]}','${body[RCSL]}','${body[SQB]}','${body[SMD]}','${body[YMD]}' ,'${body[SCCW]}'" +
327 386
                                 "where NOT EXISTS ( SELECT * FROM centralbase.cb_pc_pro_wellbore_vol_daily WHERE well_id = '${body[JH]}' and  prod_date = '${body[RQ]}' )"))
328 387
                         .doTry()
329 388
                         .to("jdbc:centralbase")
330 389
                         .doCatch(Exception.class)
331
-                        .log("${header.date}"+" routeId:insert-volDaily ->  centralbase.cb_pc_pro_wellbore_vol_daily insert data failed")
390
+                        .log("${header.date}" + " routeId:insert-volDaily ->  centralbase.cb_pc_pro_wellbore_vol_daily insert data failed")
332 391
                         .endDoTry()
333 392
                         .setBody(simple("update centralbase.cb_pc_pro_wellbore_vol_daily set  water_prod_daily =null where water_prod_daily = -1 and prod_date = '${header.date}' "))
334 393
                         .to("jdbc:centralbase")
@@ -342,9 +401,9 @@ public class CamelJDBCConfiguration {
342 401
                         .routeId("update-volDaily-liq_prod_daily")
343 402
                         .process(exchange -> {
344 403
                             Message in = exchange.getIn();
345
-                            in.setHeader("date",getDate());
404
+                            in.setHeader("date", getDate());
346 405
                         });
347
-                         setMyBody(volDailyLiqProdDaily)
406
+                setSysControlBody(volDailyLiqProdDaily)
348 407
                         .setBody(simple("select distinct  jh,rq,scsj, rcyl1,rcyl,rcql,hs, bz from DBA01 where rq  = to_date('${header.date}','yyyy-MM-dd')and jh ='${header.well_id}' and qyrq is not null "))
349 408
                         .to("jdbc:oracle")
350 409
                         .split(body()).process(exchange -> {
@@ -356,26 +415,26 @@ public class CamelJDBCConfiguration {
356 415
                             if (aRow.get("RCQL") == null) aRow.put("RCQL", "0.0");
357 416
                             if (aRow.get("HS") == null) aRow.put("HS", "0.0");
358 417
                             if (aRow.get("BZ") == null) aRow.put("BZ", "");
359
-                            aRow.put("RCSL",-1);
360
-                            aRow.put("QYB",-1);
361
-                            aRow.put("SQB",-1);
362
-                            if (aRow.get("RCQL")!=null && aRow.get("RCYL")!=null && !aRow.get("RCYL").equals("0.0") && aRow.get("RCYL") != "0.0"){
418
+                            aRow.put("RCSL", -1);
419
+                            aRow.put("QYB", -1);
420
+                            aRow.put("SQB", -1);
421
+                            if (aRow.get("RCQL") != null && aRow.get("RCYL") != null && !aRow.get("RCYL").equals("0.0") && aRow.get("RCYL") != "0.0") {
363 422
                                 double qyb = Double.valueOf(aRow.get("RCQL").toString()) / Double.valueOf(aRow.get("RCYL").toString());
364
-                                if (!Double.isNaN(qyb) && !Double.isInfinite(qyb)){
365
-                                    BigDecimal bd=new BigDecimal(qyb);
366
-                                    double d1=bd.setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue();
367
-                                    aRow.put("QYB",d1);
423
+                                if (!Double.isNaN(qyb) && !Double.isInfinite(qyb)) {
424
+                                    BigDecimal bd = new BigDecimal(qyb);
425
+                                    double d1 = bd.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
426
+                                    aRow.put("QYB", d1);
368 427
                                 }
369 428
                             }
370
-                            if (aRow.get("RCYL1")!=null && aRow.get("HS") != null && !aRow.get("HS").equals("0.0") && aRow.get("HS") != "0.0"){
371
-                                double rcsl = (Double.valueOf(aRow.get("RCYL1").toString()) * Double.valueOf(aRow.get("HS").toString()))/100;
429
+                            if (aRow.get("RCYL1") != null && aRow.get("HS") != null && !aRow.get("HS").equals("0.0") && aRow.get("HS") != "0.0") {
430
+                                double rcsl = (Double.valueOf(aRow.get("RCYL1").toString()) * Double.valueOf(aRow.get("HS").toString())) / 100;
372 431
                                 if (!Double.isNaN(rcsl) && !Double.isInfinite(rcsl)) {
373 432
                                     BigDecimal bd = new BigDecimal(rcsl);
374 433
                                     double d1 = bd.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
375 434
                                     aRow.put("RCSL", d1);
376 435
                                 }
377 436
                             }
378
-                            if (aRow.get("RCQL") != null && aRow.get("RCSL") != null && !aRow.get("RCQL").equals("0.0") && aRow.get("RCQL") != "0.0" ){
437
+                            if (aRow.get("RCQL") != null && aRow.get("RCSL") != null && !aRow.get("RCQL").equals("0.0") && aRow.get("RCQL") != "0.0") {
379 438
                                 double sqb = Double.valueOf(aRow.get("RCSL").toString()) / Double.valueOf(aRow.get("RCQL").toString());
380 439
                                 if (!Double.isNaN(sqb) && !Double.isInfinite(sqb)) {
381 440
                                     BigDecimal bd = new BigDecimal(sqb);
@@ -383,11 +442,11 @@ public class CamelJDBCConfiguration {
383 442
                                     aRow.put("SQB", d1);
384 443
                                 }
385 444
                             }
386
-                            if (!aRow.containsKey("SMD")){
387
-                                aRow.put("SMD",1);
445
+                            if (!aRow.containsKey("SMD")) {
446
+                                aRow.put("SMD", 1);
388 447
                             }
389
-                            if (!aRow.containsKey("YMD")){
390
-                                aRow.put("YMD",0.85);
448
+                            if (!aRow.containsKey("YMD")) {
449
+                                aRow.put("YMD", 0.85);
391 450
                             }
392 451
                         })
393 452
                         .setBody(simple("update centralbase.cb_pc_pro_wellbore_vol_daily set prod_time = '${body[SCSJ]}' ,liq_prod_daily='${body[RCYL1]}' ,oil_prod_daily ='${body[RCYL]}' ,gas_prod_daily ='${body[RCQL]}' ,water_cut='${body[HS]}' ,remarks='${body[BZ]}' ,gas_oil_ratio='${body[QYB]}' ,water_prod_daily='${body[RCSL]}' ,water_gas_ratio='${body[SQB]}',surface_crude_water_density='${body[SMD]}',surface_crude_oil_density= '${body[YMD]}' " +
@@ -395,16 +454,16 @@ public class CamelJDBCConfiguration {
395 454
                         .doTry()
396 455
                         .to("jdbc:centralbase")
397 456
                         .doCatch(Exception.class)
398
-                        .log("${header.date}"+" routeId:update-volDaily-liq_prod_daily ->  centralbase.cb_pc_pro_wellbore_vol_daily update data failed")
457
+                        .log("${header.date}" + " routeId:update-volDaily-liq_prod_daily ->  centralbase.cb_pc_pro_wellbore_vol_daily update data failed")
399 458
                         .end();
400 459
 
401 460
                 RouteDefinition runTime = from("timer:mytimer-update-runTime-strokeAndFrequency?period=10800000")
402 461
                         .routeId("update-runTime-strokeAndFrequency")
403 462
                         .process(exchange -> {
404 463
                             Message in = exchange.getIn();
405
-                            in.setHeader("date",getDate());
464
+                            in.setHeader("date", getDate());
406 465
                         });
407
-                        setMyBody(runTime)
466
+                setSysControlBody(runTime)
408 467
                         .setBody(simple("select distinct  jh,rq,cc,cs from DBA01 where rq  = to_date('${header.date}','yyyy-MM-dd')and jh ='${header.well_id}' and qyrq is not null "))
409 468
                         .to("jdbc:oracle")
410 469
                         .split(body())
@@ -414,12 +473,12 @@ public class CamelJDBCConfiguration {
414 473
                         .doTry()
415 474
                         .to("jdbc:centralbase")
416 475
                         .doCatch(Exception.class)
417
-                        .log("${header.date}"+" routeId:update-runTime-strokeAndFrequency ->  centralbase.cb_temp_well_mech_runtime update data failed")
476
+                        .log("${header.date}" + " routeId:update-runTime-strokeAndFrequency ->  centralbase.cb_temp_well_mech_runtime update data failed")
418 477
                         .end();
419
-            };
420
-        };
421
-
478
+            }
422 479
 
480
+            ;
481
+        };
423 482
 
424 483
 
425 484
     }