|
@@ -1,68 +0,0 @@
|
1
|
|
-package com.gct.tools.etlcamelhuge.routeconfig;
|
2
|
|
-
|
3
|
|
-import com.alibaba.fastjson.JSON;
|
4
|
|
-import org.apache.camel.Message;
|
5
|
|
-import org.apache.camel.builder.RouteBuilder;
|
6
|
|
-import org.apache.camel.model.ExpressionNode;
|
7
|
|
-import org.apache.camel.model.ProcessorDefinition;
|
8
|
|
-import org.apache.camel.model.RouteDefinition;
|
9
|
|
-import org.springframework.beans.factory.annotation.Value;
|
10
|
|
-import org.springframework.context.annotation.Bean;
|
11
|
|
-import org.springframework.context.annotation.Configuration;
|
12
|
|
-import org.springframework.util.StringUtils;
|
13
|
|
-
|
14
|
|
-import java.math.BigDecimal;
|
15
|
|
-import java.sql.Timestamp;
|
16
|
|
-import java.time.Instant;
|
17
|
|
-import java.time.LocalDateTime;
|
18
|
|
-import java.time.ZoneId;
|
19
|
|
-import java.time.ZoneOffset;
|
20
|
|
-import java.time.format.DateTimeFormatter;
|
21
|
|
-import java.util.*;
|
22
|
|
-
|
23
|
|
-/**
|
24
|
|
- * class name: CamelJDBCConfiguration
|
25
|
|
- *
|
26
|
|
- * @author lloyd
|
27
|
|
- * @version 1.0
|
28
|
|
- * @since 2021/4/14 下午3:16
|
29
|
|
- */
|
30
|
|
-@Configuration
|
31
|
|
-public class CamelInsertA2Configuration {
|
32
|
|
-
|
33
|
|
- @Value("${insertA2.cron}")
|
34
|
|
- private String cron;
|
35
|
|
-
|
36
|
|
-
|
37
|
|
- @Bean
|
38
|
|
- public RouteBuilder routeBuilderWithInsertA2() {
|
39
|
|
- return new RouteBuilder() {
|
40
|
|
- @Override
|
41
|
|
- public void configure() throws Exception {
|
42
|
|
- from("quartz:tab?cron="+cron)
|
43
|
|
- .routeId("update-test")
|
44
|
|
- .process(exchange -> {
|
45
|
|
- Message in = exchange.getIn();
|
46
|
|
- in.setHeader("date",getDate());
|
47
|
|
- })
|
48
|
|
- .setBody(simple("select well_id,prod_date,liq_prod_daily from aoid.aoid_daily_yield where prod_date='${header.date}' "))
|
49
|
|
- .to("jdbc:aoid")
|
50
|
|
- .split(body()).process(exchange -> {
|
51
|
|
- Message in = exchange.getIn();
|
52
|
|
- HashMap<String, Object> aRow = in.getBody(HashMap.class);
|
53
|
|
- //aRow.putIfAbsent("liq_prod_daily", null);
|
54
|
|
- Timestamp timestamp = (Timestamp) aRow.get("prod_date");
|
55
|
|
- Instant instant = Instant.ofEpochMilli(timestamp.getTime());
|
56
|
|
- LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
57
|
|
- aRow.put("prod_date",localDateTime.plusDays(1).toLocalDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
|
58
|
|
- })
|
59
|
|
- .setBody(simple(" insert into DMS_DBA01_RCYL (JH, RQ, RCYL) values('${body[well_id]}', to_date(to_char('${body[prod_date]}'),'yyyy-MM-dd'),'${body[liq_prod_daily]}') "))
|
60
|
|
- .to("jdbc:insertA2")
|
61
|
|
- .end();
|
62
|
|
- };
|
63
|
|
- };
|
64
|
|
- }
|
65
|
|
- private String getDate(){
|
66
|
|
- return LocalDateTime.now().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
67
|
|
- }
|
68
|
|
-}
|