|
@@ -52,114 +52,6 @@ public class CamelJDBCConfiguration {
|
52
|
52
|
@Override
|
53
|
53
|
public void configure() throws Exception {
|
54
|
54
|
|
55
|
|
- /*RouteDefinition OrgAndWellSource= (RouteDefinition) from("timer:insert-OrgAndWellSource?period=86400000")
|
56
|
|
- .routeId("insert-OrgAndWellSource")
|
57
|
|
- .setHeader("date", constant(getDate()+" 00:00:00"))
|
58
|
|
- .process(exchange -> {
|
59
|
|
- org = 0;
|
60
|
|
- orgIdPreList = new HashMap<>();
|
61
|
|
- })
|
62
|
|
- .setBody(simple("select max(org_id) from centralbase.cb_pc_organization"))
|
63
|
|
- .to("jdbc:centralbase")
|
64
|
|
- .process(exchange -> {
|
65
|
|
- HashMap body = exchange.getIn().getBody(HashMap.class);
|
66
|
|
- if (body == null || StringUtils.isEmpty(body.get("max"))) org = 0;
|
67
|
|
- else
|
68
|
|
- org = Integer.valueOf(body.get("max").toString());
|
69
|
|
- })
|
70
|
|
- .setBody(simple("select org_id_pre,org_id from centralbase.cb_pc_organization"))
|
71
|
|
- .to("jdbc:centralbase")
|
72
|
|
- .split(body()).process(exchange -> {
|
73
|
|
- HashMap body = exchange.getIn().getBody(HashMap.class);
|
74
|
|
- orgIdPreList.put(body.get("org_id_pre"),body.get("org_id"));
|
75
|
|
- }).end();
|
76
|
|
- setMyBody(OrgAndWellSource)
|
77
|
|
- .setBody(simple("select distinct WELL_ID,cydmc,zyq,zk,qyrq,sccw,qk,REMARKS from DBA01 where PROD_DATE=to_date('${header.date}','yyyy-mm-dd hh24:mi:ss') and WELL_ID ='${header.well_id}'"))
|
78
|
|
- .to("jdbc:oracle")
|
79
|
|
- .transform()
|
80
|
|
- .body((result) -> {
|
81
|
|
- organization = new TreeSet<>();
|
82
|
|
- return result;
|
83
|
|
- })
|
84
|
|
- .step("1")
|
85
|
|
- .split(body()).process(exchange -> {
|
86
|
|
- Message in = exchange.getIn();
|
87
|
|
- HashMap<String, Object> aRow = in.getBody(HashMap.class);
|
88
|
|
- if (StringUtils.isEmpty(aRow.get("qyrq"))){
|
89
|
|
- aRow.put("QYRQ","2021-01-01 00:00:00");
|
90
|
|
- }
|
91
|
|
- if (!aRow.containsKey("JM")) aRow.put("JM",aRow.get("WELL_ID"));
|
92
|
|
- String org_level3 = aRow.get("ZYQ") + "@" + aRow.get("CYDMC") + "@" + aRow.get("ZK");
|
93
|
|
- String org_level2 = aRow.get("ZYQ") + "@" + aRow.get("CYDMC");
|
94
|
|
- String org_level1 = aRow.get("ZYQ").toString();
|
95
|
|
- aRow.put("station_id", org_level3);
|
96
|
|
- orgID = org;
|
97
|
|
- if ((!orgIdPreList.containsKey(org_level1)) || (!orgIdPreList.containsKey(org_level2)) || (!orgIdPreList.containsKey(org_level3))) {
|
98
|
|
- if (organization.add(org_level1)) {
|
99
|
|
- if (!orgIDs.containsKey(org_level1)) orgIDs.put(org_level1,++orgID);
|
100
|
|
- }
|
101
|
|
- if (organization.add(org_level2)) {
|
102
|
|
- if (!orgIDs.containsKey(org_level2)) orgIDs.put(org_level2,++orgID);
|
103
|
|
- }
|
104
|
|
- if (organization.add(org_level3)) {
|
105
|
|
- if (!orgIDs.containsKey(org_level3)) orgIDs.put(org_level3,++orgID);
|
106
|
|
- }
|
107
|
|
- }
|
108
|
|
- if(orgIdPreList.get(org_level3) !=null){
|
109
|
|
- aRow.put("org_id",orgIdPreList.get(org_level3));
|
110
|
|
- return;
|
111
|
|
- }
|
112
|
|
- if(orgIDs.get(org_level3) !=null){
|
113
|
|
- aRow.put("org_id",orgIDs.get(org_level3));
|
114
|
|
- }
|
115
|
|
- })
|
116
|
|
- .setBody(simple("insert into centralbase.cb_cd_well_source (well_id,well_common_name,spud_date,org_id,station_id,station_name,completion_name,PRODUCING_AREA_name,remarks) " +
|
117
|
|
- "select '${body[WELL_ID]}','${body[JM]}','${body[QYRQ]}'::timestamp,'${body[org_id]}','${body[station_id]}','${body[ZK]}','${body[SCCW]}','${body[QK]}','${body[REMARKS]}' " +
|
118
|
|
- "where NOT EXISTS ( SELECT * FROM centralbase.cb_cd_well_source WHERE well_id = '${body[WELL_ID]}' )"))
|
119
|
|
- .to("jdbc:centralbase")
|
120
|
|
- .end()
|
121
|
|
- .transform().body((re) -> {
|
122
|
|
- List<Map<String, Object>> rows = new ArrayList<>();
|
123
|
|
- for (String s : organization) {
|
124
|
|
- Map<String, Object> row = new HashMap<>();
|
125
|
|
- String[] orgs = s.split("@");
|
126
|
|
- row.put("org_id_pre", s);
|
127
|
|
- switch (orgs.length) {
|
128
|
|
- case 1:
|
129
|
|
- row.put("org_name", orgs[0]);
|
130
|
|
- row.put("org_level", 1);
|
131
|
|
- row.put("org_parent", "0");
|
132
|
|
- break;
|
133
|
|
- case 2:
|
134
|
|
- row.put("org_name", orgs[1]);
|
135
|
|
- row.put("org_level", 2);
|
136
|
|
- row.put("org_parent", orgIDs.get(orgs[0]).toString());
|
137
|
|
- break;
|
138
|
|
- case 3:
|
139
|
|
- row.put("org_name", orgs[2]);
|
140
|
|
- row.put("org_level", 3);
|
141
|
|
- row.put("org_parent", orgIDs.get(orgs[0] + "@" + orgs[1]).toString());
|
142
|
|
- break;
|
143
|
|
- }
|
144
|
|
- if (!orgIdPreList.containsKey(s)) {
|
145
|
|
- org++;
|
146
|
|
- row.put("org_code", org);
|
147
|
|
- row.put("org_id", "" + org);
|
148
|
|
- orgIdPreList.put(s, row.get("org_id"));
|
149
|
|
- rows.add(row);
|
150
|
|
- }
|
151
|
|
- }
|
152
|
|
- return rows;
|
153
|
|
- }).split(body())
|
154
|
|
- .setBody(simple("insert into centralbase.cb_pc_organization(org_id,org_code,org_name,org_level,parent_id,org_id_pre)" +
|
155
|
|
- "select '${body[org_id]}','${body[org_code]}','${body[org_name]}','${body[org_level]}','${body[org_parent]}','${body[org_id_pre]}' " +
|
156
|
|
- "where NOT EXISTS ( SELECT * FROM centralbase.cb_pc_organization WHERE org_id = '${body[org_id]}')"))
|
157
|
|
- .doTry()
|
158
|
|
- .to("jdbc:centralbase")
|
159
|
|
- .doCatch(Exception.class)
|
160
|
|
- .log("${header.date}"+" routeId:insert-OrgAndWellSource-> centralbase.cb_pc_organization insert data failed")
|
161
|
|
- .end();*/
|
162
|
|
-
|
163
|
55
|
from("timer:update-wellControl?period=3600000")
|
164
|
56
|
.routeId("update-wellControl")
|
165
|
57
|
.setBody(simple("select scc.well_id,wo.well_common_name,op.org_id from centralbase.sys_access_well_control scc\n" +
|
|
@@ -244,10 +136,11 @@ public class CamelJDBCConfiguration {
|
244
|
136
|
});
|
245
|
137
|
setSysControlBody(statusDailyDYM)
|
246
|
138
|
.setBody(simple("select distinct WELL_ID , PROD_DATE , DYNAMIC_LIQ_LEVEL " +
|
247
|
|
- "from ZY_DXGW.PC_PRO_COM_DAILY " +
|
248
|
|
- "where (WELL_ID,PROD_DATE) in" +
|
249
|
|
- " (SELECT WELL_ID,max(PROD_DATE) PROD_DATE FROM ZY_DXGW.PC_PRO_COM_DAILY" +
|
250
|
|
- " WHERE DYNAMIC_LIQ_LEVEL is not null and WELL_ID='${header.well_id}' group by WELL_ID)"))
|
|
139
|
+ " from ZY_DXGW.PC_PRO_COM_DAILY " +
|
|
140
|
+ " where (WELL_ID,PROD_DATE) in " +
|
|
141
|
+ " (SELECT WELL_ID, max(PROD_DATE) PROD_DATE FROM ZY_DXGW.PC_PRO_COM_DAILY " +
|
|
142
|
+ " where PROD_DATE > TO_DATE('2024-01-01','yyyy-MM-dd') " +
|
|
143
|
+ "and WELL_ID='${header.well_id}' and DYNAMIC_LIQ_LEVEL is not null group by WELL_ID)"))
|
251
|
144
|
.to("jdbc:oracle")
|
252
|
145
|
.split(body())
|
253
|
146
|
.setBody(simple("update centralbase.cb_pc_pro_wellbore_status_daily set start_pump_liq_level = '${body[DYNAMIC_LIQ_LEVEL]}' " +
|
|
@@ -266,18 +159,16 @@ public class CamelJDBCConfiguration {
|
266
|
159
|
});
|
267
|
160
|
setSysControlBody(statusDailyBS)
|
268
|
161
|
.setBody(simple("select distinct WELL_ID , PROD_DATE , PUMP_DEPTH " +
|
269
|
|
- "from ZY_DXGW.PC_PRO_COM_DAILY " +
|
270
|
|
- "where (WELL_ID,PROD_DATE) in" +
|
271
|
|
- " (SELECT WELL_ID,max(PROD_DATE) PROD_DATE FROM ZY_DXGW.PC_PRO_COM_DAILY" +
|
272
|
|
- " WHERE PUMP_DEPTH is not null and WELL_ID='${header.well_id}' group by WELL_ID)"))
|
|
162
|
+ " from ZY_DXGW.PC_PRO_COM_DAILY " +
|
|
163
|
+ " where (WELL_ID,PROD_DATE) in " +
|
|
164
|
+ " (SELECT WELL_ID, max(PROD_DATE) PROD_DATE FROM ZY_DXGW.PC_PRO_COM_DAILY " +
|
|
165
|
+ " where PROD_DATE > TO_DATE('2024-01-01','yyyy-MM-dd') " +
|
|
166
|
+ "and WELL_ID='${header.well_id}' and PUMP_DEPTH is not null group by WELL_ID)"))
|
273
|
167
|
.to("jdbc:oracle")
|
274
|
168
|
.split(body())
|
275
|
169
|
.setBody(simple("update centralbase.cb_pc_pro_wellbore_status_daily set pump_depth = '${body[PUMP_DEPTH]}' " +
|
276
|
170
|
"where well_id = '${header.well_id}' and prod_date::date = '${header.date}' "))
|
277
|
|
- .doTry()
|
278
|
171
|
.to("jdbc:centralbase")
|
279
|
|
- .doCatch(Exception.class)
|
280
|
|
- .log("${header.date}" + " routeId:update-statusDaily-BS -> centralbase.cb_pc_pro_wellbore_status_daily update data failed")
|
281
|
172
|
.end();
|
282
|
173
|
|
283
|
174
|
RouteDefinition statusDailyBJ = from("timer:mytimer-update-statusDaily-BJ?period=10800000")
|
|
@@ -288,10 +179,11 @@ public class CamelJDBCConfiguration {
|
288
|
179
|
});
|
289
|
180
|
setSysControlBody(statusDailyBJ)
|
290
|
181
|
.setBody(simple("select distinct WELL_ID , PROD_DATE , PUMP_DIAMETER " +
|
291
|
|
- "from ZY_DXGW.PC_PRO_COM_DAILY " +
|
292
|
|
- "where (WELL_ID,PROD_DATE) in" +
|
293
|
|
- " (SELECT WELL_ID,max(PROD_DATE) PROD_DATE FROM ZY_DXGW.PC_PRO_COM_DAILY" +
|
294
|
|
- " WHERE PUMP_DIAMETER is not null and WELL_ID='${header.well_id}' group by WELL_ID)"))
|
|
182
|
+ " from ZY_DXGW.PC_PRO_COM_DAILY " +
|
|
183
|
+ " where (WELL_ID,PROD_DATE) in " +
|
|
184
|
+ " (SELECT WELL_ID, max(PROD_DATE) PROD_DATE FROM ZY_DXGW.PC_PRO_COM_DAILY " +
|
|
185
|
+ " where PROD_DATE > TO_DATE('2024-01-01','yyyy-MM-dd') " +
|
|
186
|
+ "and WELL_ID='${header.well_id}' and PUMP_DIAMETER is not null group by WELL_ID)"))
|
295
|
187
|
.to("jdbc:oracle")
|
296
|
188
|
.split(body())
|
297
|
189
|
.setBody(simple("update centralbase.cb_pc_pro_wellbore_status_daily set oil_nozzle = '${body[PUMP_DIAMETER]}' " +
|
|
@@ -314,7 +206,7 @@ public class CamelJDBCConfiguration {
|
314
|
206
|
.split(body()).process(exchange -> {
|
315
|
207
|
Message in = exchange.getIn();
|
316
|
208
|
HashMap<String, Object> aRow = in.getBody(HashMap.class);
|
317
|
|
- aRow.put("submergence_depth", null);
|
|
209
|
+ aRow.put("submergence_depth", 0);
|
318
|
210
|
if (aRow.get("start_pump_liq_level") != null && aRow.get("pump_depth") != null) {
|
319
|
211
|
double cmd = Double.parseDouble(aRow.get("pump_depth").toString()) - Double.parseDouble(aRow.get("start_pump_liq_level").toString()) / 10;
|
320
|
212
|
BigDecimal bd = new BigDecimal(cmd);
|
|
@@ -326,7 +218,7 @@ public class CamelJDBCConfiguration {
|
326
|
218
|
.doTry()
|
327
|
219
|
.to("jdbc:centralbase")
|
328
|
220
|
.doCatch(Exception.class)
|
329
|
|
- .log("${header.date}" + " routeId:update-statusDaily-submergenceDepth -> centralbase.cb_pc_pro_wellbore_status_daily update data failed")
|
|
221
|
+// .log("${header.date}" + " routeId:update-statusDaily-submergenceDepth -> centralbase.cb_pc_pro_wellbore_status_daily update data failed")
|
330
|
222
|
.end();
|
331
|
223
|
|
332
|
224
|
|