Browse Source

0827-稳定版

gxt 3 years ago
parent
commit
ac504f2bcc

+ 24 - 0
pom.xml

@@ -41,6 +41,26 @@
41 41
             <groupId>org.postgresql</groupId>
42 42
             <artifactId>postgresql</artifactId>
43 43
         </dependency>
44
+        <!--<dependency>
45
+            <groupId>com.spring4all</groupId>
46
+            <artifactId>swagger-spring-boot-starter</artifactId>
47
+            <version>1.9.1.RELEASE</version>
48
+        </dependency>-->
49
+        <dependency>
50
+            <groupId>io.springfox</groupId>
51
+            <artifactId>springfox-swagger2</artifactId>
52
+            <version>2.9.0</version>
53
+        </dependency>
54
+        <dependency>
55
+            <groupId>io.springfox</groupId>
56
+            <artifactId>springfox-swagger-ui</artifactId>
57
+            <version>2.9.0</version>
58
+        </dependency>
59
+        <dependency>
60
+            <groupId>com.google.guava</groupId>
61
+            <artifactId>guava</artifactId>
62
+            <version>27.1-jre</version>
63
+        </dependency>
44 64
         <dependency>
45 65
             <groupId>com.gct.common.util</groupId>
46 66
             <artifactId>common-util</artifactId>
@@ -55,6 +75,10 @@
55 75
             <groupId>org.springframework.boot</groupId>
56 76
             <artifactId>spring-boot-starter-jdbc</artifactId>
57 77
         </dependency>
78
+        <dependency>
79
+            <groupId>org.springframework.boot</groupId>
80
+            <artifactId>spring-boot-starter-web</artifactId>
81
+        </dependency>
58 82
         <!-- <dependency>
59 83
              <groupId>com.zaxxer</groupId>
60 84
              <artifactId>HikariCP</artifactId>

+ 8 - 8
settings.xml

@@ -52,7 +52,7 @@ under the License.
52 52
      | Default: ${user.home}/.m2/repository
53 53
     <localRepository>/path/to/local/repo</localRepository>
54 54
     -->
55
-    <localRepository>D:/repository</localRepository>
55
+    <!--  <localRepository>/home/gxt/.m2/repository</localRepository>-->
56 56
 
57 57
     <!-- interactiveMode
58 58
      | This will determine whether maven prompts you when it needs input. If set to false,
@@ -178,7 +178,7 @@ under the License.
178 178
         <mirror>
179 179
             <id>nexus</id>
180 180
             <name>maven-public</name>
181
-            <url>http://114.115.206.163:3000/repository/maven-public/</url>
181
+            <url>http://114.115.206.163:8081/repository/maven-public/</url>
182 182
             <mirrorOf>*</mirrorOf>
183 183
         </mirror>
184 184
 
@@ -212,7 +212,7 @@ under the License.
212 212
          | or the command line, profiles have to have an ID that is unique.
213 213
          |
214 214
          | An encouraged best practice for profile identification is to use a consistent naming convention
215
-         | for profiles, such as 'env-dev', 'env-test1.json', 'env-production', 'user-jdcasey', 'user-brett', etc.
215
+         | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
216 216
          | This will make it more intuitive to understand what the set of introduced profiles is attempting
217 217
          | to accomplish, particularly when you only have a list of profile id's for debug.
218 218
          |
@@ -244,7 +244,7 @@ under the License.
244 244
                 <repository>
245 245
                     <id>nexus</id>
246 246
                     <name>Nexus Repository</name>
247
-                    <url>http://114.115.206.163:3000/repository/maven-public/</url>
247
+                    <url>http://114.115.206.163:8081/repository/maven-public/</url>
248 248
                     <releases>
249 249
                         <enabled>true</enabled>
250 250
                     </releases>
@@ -253,7 +253,7 @@ under the License.
253 253
                 <repository>
254 254
                     <id>central</id>
255 255
                     <name>Nexus Central Repository</name>
256
-                    <url>http://114.115.206.163:3000/repository/maven-central/</url>
256
+                    <url>http://114.115.206.163:8081/repository/maven-central/</url>
257 257
                     <releases>
258 258
                         <enabled>true</enabled>
259 259
                     </releases>
@@ -265,7 +265,7 @@ under the License.
265 265
                 <repository>
266 266
                     <id>release</id>
267 267
                     <name>Nexus Release Repository</name>
268
-                    <url>http://114.115.206.163:3000/repository/maven-releases/</url>
268
+                    <url>http://114.115.206.163:8081/repository/maven-releases/</url>
269 269
                     <releases>
270 270
                         <enabled>true</enabled>
271 271
                     </releases>
@@ -277,7 +277,7 @@ under the License.
277 277
                 <repository>
278 278
                     <id>snapshots</id>
279 279
                     <name>Nexus Snapshots Repository</name>
280
-                    <url>http://114.115.206.163:3000/repository/maven-snapshots/</url>
280
+                    <url>http://114.115.206.163:8081/repository/maven-snapshots/</url>
281 281
                     <releases>
282 282
                         <enabled>true</enabled>
283 283
                     </releases>
@@ -291,7 +291,7 @@ under the License.
291 291
                 <pluginRepository>
292 292
                     <id>plugins</id>
293 293
                     <name>Nexus Plugin Repositories</name>
294
-                    <url>http://114.115.206.163:3000/repository/maven-public/</url>
294
+                    <url>http://114.115.206.163:8081/repository/maven-public/</url>
295 295
                 </pluginRepository>
296 296
             </pluginRepositories>
297 297
         </profile>

+ 3 - 4
src/main/java/com/gct/tools/etlcamelhuge/EtlCamelHugeApplication.java

@@ -1,13 +1,12 @@
1 1
 package com.gct.tools.etlcamelhuge;
2 2
 
3
-import org.apache.camel.component.servlet.CamelHttpTransportServlet;
3
+
4 4
 import org.springframework.boot.SpringApplication;
5
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
6 5
 import org.springframework.boot.autoconfigure.SpringBootApplication;
7
-import org.springframework.boot.web.servlet.ServletRegistrationBean;
8
-import org.springframework.context.annotation.Bean;
6
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
9 7
 
10 8
 @SpringBootApplication
9
+@EnableSwagger2
11 10
 public class EtlCamelHugeApplication {
12 11
     public static void main(String[] args) {
13 12
         SpringApplication.run(EtlCamelHugeApplication.class, args);

+ 2 - 2
src/main/java/com/gct/tools/etlcamelhuge/MQ/DefaultMsgSendFailCallBack.java

@@ -21,7 +21,7 @@ import java.util.logging.Logger;
21 21
 @Slf4j
22 22
 public class DefaultMsgSendFailCallBack {
23 23
 
24
-    public static void accept(MessageBody msg, String logFilePath) {
24
+    public synchronized static void  accept(MessageBody msg, String logFilePath) {
25 25
         String msgJson = msg.toJsonBody();
26 26
         String fileName = logFilePath + "-" + LocalDate.now().format(DateTimeFormatter.ISO_DATE);
27 27
         File file = new File(fileName);
@@ -41,7 +41,6 @@ public class DefaultMsgSendFailCallBack {
41 41
                 return;
42 42
             }
43 43
         }
44
-
45 44
         try {
46 45
             FileHandler fileHandler = new FileHandler(fileName, true);
47 46
             fileHandler.setFormatter(new Formatter() {
@@ -54,6 +53,7 @@ public class DefaultMsgSendFailCallBack {
54 53
             logger.setUseParentHandlers(false);
55 54
             logger.addHandler(fileHandler);
56 55
             logger.info(msgJson + "\n");
56
+
57 57
         } catch (IOException ioException) {
58 58
             log.error("run logger handler failed, cause by:{}", ioException.getMessage());
59 59
         }

+ 4 - 2
src/main/java/com/gct/tools/etlcamelhuge/MQ/DefaultMsgSendSuccessCallBack.java

@@ -4,6 +4,8 @@ import lombok.extern.slf4j.Slf4j;
4 4
 import org.apache.rocketmq.client.producer.SendResult;
5 5
 import org.springframework.stereotype.Component;
6 6
 
7
+import java.util.concurrent.atomic.AtomicInteger;
8
+
7 9
 /**
8 10
  * class name: DiagnoseMsgSendSuccessCallBack
9 11
  *
@@ -14,10 +16,10 @@ import org.springframework.stereotype.Component;
14 16
 @Slf4j
15 17
 @Component("defaultMsgSendSuccessCallBack")
16 18
 public class DefaultMsgSendSuccessCallBack implements SendSuccessCallBack {
17
-    private static int count = 0;
19
+    public static AtomicInteger count =new AtomicInteger(0);
18 20
     @Override
19 21
     public void accept(SendResult sendResult) {
20
-        System.out.println("send = "+count++);
22
+        System.out.println("send success= "+count.incrementAndGet());
21 23
         //log.info("send msg success,msg:{}", sendResult.getMsgId());
22 24
     }
23 25
 }

+ 1 - 0
src/main/java/com/gct/tools/etlcamelhuge/MQ/GCTRocketMQConfiguration.java

@@ -54,6 +54,7 @@ public class GCTRocketMQConfiguration {
54 54
                                                    @Qualifier("defaultMsgSendSuccessCallBack") SendSuccessCallBack successCallBack) {
55 55
         GCTRocketMQProperties one = properties.getOne();
56 56
         return new DiagnoseMessageProducer(buildDefaultMQProducer(one), one, (e, msg) -> {
57
+            System.out.println("send diagnose message failed ++++"+e.getMessage());
57 58
             Logger log = LoggerFactory.getLogger(DiagnoseMessageProducer.class);
58 59
             log.error("send diagnose message failed  cause by:{},stack:{}", e.getMessage(), e.getStackTrace());
59 60
             DefaultMsgSendFailCallBack.accept(msg, one.getLogFilePath());

+ 178 - 0
src/main/java/com/gct/tools/etlcamelhuge/controller/GtController.java

@@ -0,0 +1,178 @@
1
+package com.gct.tools.etlcamelhuge.controller;
2
+
3
+import com.alibaba.fastjson.JSONArray;
4
+import com.alibaba.fastjson.JSONObject;
5
+import com.gct.common.util.SGTUtil;
6
+import com.gct.tools.etlcamelhuge.MQ.MessageBody;
7
+import com.gct.tools.etlcamelhuge.MQ.MessageProducer;
8
+import com.gct.tools.etlcamelhuge.entity.DiagnoseMsg;
9
+import com.gct.tools.etlcamelhuge.entity.GTBody;
10
+import io.swagger.annotations.Api;
11
+import io.swagger.annotations.ApiOperation;
12
+import io.swagger.annotations.ApiParam;
13
+import org.springframework.jdbc.core.JdbcTemplate;
14
+import org.springframework.web.bind.annotation.*;
15
+
16
+import javax.annotation.Resource;
17
+import javax.sql.DataSource;
18
+import java.math.BigDecimal;
19
+import java.time.LocalDateTime;
20
+import java.util.Arrays;
21
+import java.util.List;
22
+import java.util.Map;
23
+import java.util.stream.Collectors;
24
+
25
+/**
26
+ * class name: GtController
27
+ *
28
+ * @author gxt
29
+ * @version 1.0
30
+ * @since 2021/8/26 下午2:50 周四
31
+ */
32
+@RestController
33
+@RequestMapping("/")
34
+@Api(value = "GtController",description = "功图数据操作controller")
35
+public class GtController {
36
+
37
+    private JdbcTemplate jdbcTemplate;
38
+    @Resource(name = "centralbase")
39
+    DataSource dataSource;
40
+
41
+    @Resource(name = "diagnoseMessageProducer")
42
+    private MessageProducer producer;
43
+
44
+    @PostMapping("/sendGTSJ")
45
+    @ApiOperation(value = "从 RunTime 数据表查询数据并且发送功图数据到 MQ 中")
46
+    public JSONObject sendGTSJ(@RequestBody GTBody gtBody){
47
+        String startDate = gtBody.getStartDate();
48
+        String endDate = gtBody.getEndDate();
49
+        List<String> wellList = gtBody.getWellList().stream().map(x->x.toString()).collect(Collectors.toList());
50
+        JSONObject jsonObject = new JSONObject();
51
+        jdbcTemplate = new JdbcTemplate(dataSource);
52
+        int curPage = 0;
53
+        int pageSize = 5000;
54
+        int sumData = 0;
55
+        try {
56
+                for (int i = 0; i < wellList.size(); i++) {
57
+                    String sql = String.format("select so.well_id,so.well_common_name,so.org_id,ti.prod_date,ti.stroke_frequency,ti.stroke_length,ti.sgt from centralbase.cb_temp_well_mech_runtime ti, centralbase.cb_cd_well_source so " +
58
+                            " where ti.well_id = so.well_id and ti.well_id = '%s' and ti.prod_date between '%s' and '%s' ",wellList.get(i) ,startDate,endDate);
59
+                    String countSql = String.format("select count(1) from (%s)",sql);
60
+                    //Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
61
+                    List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
62
+                    for (Map<String, Object> map : list) {
63
+                        String wellName =map.get("well_common_name").toString();
64
+                        String wellId =map.get("well_id").toString();
65
+                        String orgId = map.get("org_id").toString();
66
+                        String prodDate = map.get("prod_date").toString().substring(0,19);
67
+                        Double strokeLength = Double.valueOf(map.get("stroke_length").toString());
68
+                        Double strokeFrequency = Double.valueOf(map.get("stroke_frequency").toString());
69
+                        String sgt = map.get("sgt").toString();
70
+                        if (sgt == null || sgt.length() ==0){
71
+                            sgt = "0,0,0,0,0,0,0,0,0,0";
72
+                        }
73
+                        DiagnoseMsg diagnoseMsg = new DiagnoseMsg(wellId, wellName, orgId, prodDate, sgt, LocalDateTime.now().toString(), strokeLength, strokeFrequency);
74
+                        producer.send((MessageBody) diagnoseMsg);
75
+                    }
76
+                   /* sumData += list.size();
77
+                    if (list.size()< pageSize){
78
+                        break;
79
+                    }
80
+                    curPage ++ ;*/
81
+                }
82
+
83
+        }catch (Exception e){
84
+            e.printStackTrace();
85
+            jsonObject.put("error",e.getMessage());
86
+        }finally {
87
+            jsonObject.put("sumData",sumData);
88
+        }
89
+        return    jsonObject;
90
+    }
91
+
92
+   /* @GetMapping("/getGTSJ")
93
+    @ApiOperation(value = "从实时的机采数据生产的表中获取数据放入到 Runtime 表中")
94
+    public JSONObject getGTSJ(@RequestBody GTBody gtBody){
95
+
96
+        String startDate = gtBody.getStartDate();
97
+        String endDate = gtBody.getEndDate();
98
+        List<String> wellList = gtBody.getWellList();
99
+        JSONObject jsonObject = new JSONObject();
100
+        jdbcTemplate = new JdbcTemplate(dataSource);
101
+        int curPage = 0;
102
+        int pageSize = 5000;
103
+        int sumData = 0;
104
+        try {
105
+            for (int i = 0; i < wellList.size(); i++) {
106
+                String sql = String.format("select distinct well_name,dyna_create_time,check_date,displacement,disp_load,stroke,frequency,susp_max_load,susp_min_load from public.pc_fd_pumpjack_dyna_dia_t where   dyna_create_time > '%s' and well_name = '%s' offset %d limit %d ", startDate, wellList.get(i));
107
+                List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
108
+                for (Map<String, Object> map : list) {
109
+                    String prod_date = map.get("dyna_create_time").toString().split("\\+")[0];
110
+                    map.put("dyna_create_time", prod_date);
111
+                    if (map.get("displacement") != null && !map.get("displacement").equals("") && map.get("disp_load") != null && !map.get("disp_load").equals("")) {
112
+                        String[] displacements = map.get("displacement").toString().split(";");//10 四舍五入
113
+                        String[] disp_loads = map.get("disp_load").toString().split(";");
114
+                        Double susp_max_load = max(disp_loads);
115
+                        Double susp_min_load = min(disp_loads);
116
+                        String sgt = "";
117
+                        for (int i = 0; i < displacements.length; i++) {
118
+                            sgt = sgt + displacements[i] + "," + disp_loads[i] + ",";
119
+                        }
120
+                        String[] s = sgt.split(",");
121
+                        String w = "";
122
+                        for (int i = 0; i < s.length; i++) {
123
+                            w += new BigDecimal(Math.round(Double.parseDouble(s[i]) * 100)).stripTrailingZeros().toPlainString() + ",";
124
+                        }
125
+                        Double[][] doubles = SGTUtil.encodeToDoubleArray(w);
126
+                        map.put("sgt", SGTUtil.encodeToString(doubles));
127
+                        map.put("susp_max_load",susp_max_load);
128
+                        map.put("susp_min_load",susp_min_load);
129
+                    }
130
+                    if (map.get("stroke") == null) map.put("stroke", "0.0");
131
+                    if (map.get("frequency") == null) map.put("frequency", "0.0");
132
+                    if (map.get("susp_max_load") == null) map.put("susp_max_load", "0.0");
133
+                    if (map.get("susp_min_load") == null) map.put("susp_min_load", "0.0");
134
+                    if (map.get("frequency") != null){
135
+                        BigDecimal bd=new BigDecimal(map.get("frequency").toString());
136
+                        double frequency=bd.setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue();
137
+                        map.put("frequency",frequency);
138
+                    }
139
+                    if (map.get("stroke") != null){
140
+                        double stroke1 = Double.parseDouble(map.get("stroke").toString());
141
+                        BigDecimal bd=new BigDecimal(stroke1);
142
+                        double stroke=bd.setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue();
143
+                        map.put("stroke",stroke);
144
+                    }
145
+                    jdbcTemplate.update("insert into centralbase.cb_temp_well_mech_runtime(well_id,prod_date,stroke_length,stroke_frequency,susp_max_load,susp_min_load,sgt) " +
146
+                            "value (?,?,?,?,?,?,?)",map.get("well_name").toString(),map.get("dyna_create_time"),map.get("stroke"),map.get("frequency"),map.get("susp_max_load"),map.get("susp_min_load"),map.get("sgt"));
147
+                }
148
+               *//* sumData += list.size();
149
+                if (list.size()< pageSize){
150
+                    break;
151
+                }
152
+                curPage ++ ;*//*
153
+            }
154
+        }catch (Exception e){
155
+            jsonObject.put("error",e.getMessage());
156
+        }finally {
157
+            jsonObject.put("sumData",sumData);
158
+        }
159
+        return    jsonObject;
160
+         }*/
161
+
162
+
163
+    public Double min(String[] strings){
164
+        double[] doubles = new double[strings.length];
165
+        for (int i = 0; i < strings.length; i++) {
166
+            doubles[i] = Double.parseDouble(strings[i]);
167
+        }
168
+        return Arrays.stream(doubles).min().getAsDouble();
169
+    }
170
+    //获取最大载荷
171
+    public Double max(String[] strings){
172
+        double[] doubles = new double[strings.length];
173
+        for (int i = 0; i < strings.length; i++) {
174
+            doubles[i] = Double.parseDouble(strings[i]);
175
+        }
176
+        return Arrays.stream(doubles).max().getAsDouble();
177
+    }
178
+}

+ 27 - 0
src/main/java/com/gct/tools/etlcamelhuge/entity/GTBody.java

@@ -0,0 +1,27 @@
1
+package com.gct.tools.etlcamelhuge.entity;
2
+
3
+import com.alibaba.fastjson.JSONArray;
4
+import io.swagger.annotations.ApiModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * class name: GTBody
12
+ *
13
+ * @author gxt
14
+ * @version 1.0
15
+ * @since 2021/8/27 下午2:34 周五
16
+ */
17
+@Data
18
+@ApiModel(value = "GTBody", description = "")
19
+public class GTBody {
20
+
21
+    @ApiModelProperty(value = "开始时间")
22
+    public String startDate;
23
+    @ApiModelProperty(value = "结束时间")
24
+    public String endDate;
25
+    @ApiModelProperty(value = "井号集合")
26
+    public JSONArray wellList;
27
+}

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

@@ -2,10 +2,12 @@ package com.gct.tools.etlcamelhuge.routeconfig;
2 2
 
3 3
 import com.alibaba.fastjson.JSONObject;
4 4
 import com.gct.common.util.SGTUtil;
5
+import com.gct.tools.etlcamelhuge.MQ.DefaultMsgSendSuccessCallBack;
5 6
 import com.gct.tools.etlcamelhuge.MQ.MessageBody;
6 7
 import com.gct.tools.etlcamelhuge.MQ.MessageProducer;
7 8
 import com.gct.tools.etlcamelhuge.camelconfig.MyDataSourceConfiguration;
8 9
 import com.gct.tools.etlcamelhuge.entity.DiagnoseMsg;
10
+import lombok.Data;
9 11
 import org.apache.camel.*;
10 12
 import org.apache.camel.builder.RouteBuilder;
11 13
 //import org.apache.rocketmq.common.message.Message;
@@ -24,6 +26,13 @@ import java.time.LocalDateTime;
24 26
 import java.time.format.DateTimeFormatter;
25 27
 import java.util.*;
26 28
 
29
+@Data
30
+class LogMessage{
31
+    String id;
32
+    LocalDateTime date;
33
+    Object data;
34
+    String msg;
35
+}
27 36
 /**
28 37
  * class name: CamelJDBCConfiguration
29 38
  *
@@ -55,16 +64,11 @@ public class CamelJDBCConfiguration /*extends RouteBuilder */ {
55 64
         return  LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
56 65
     }
57 66
 
58
-    private JdbcTemplate jdbcTemplate;
59
-    @Resource(name = "gtsj")
60
-    DataSource dataSource;
61 67
 
62 68
 
69
+    private static Integer sendMsgRunTime=0;
70
+
63 71
 
64
-    public  List list(){
65
-                jdbcTemplate = new JdbcTemplate(dataSource);
66
-     return    jdbcTemplate.queryForList("select distinct well_name,dyna_create_time,check_date,displacement,disp_load,stroke,frequency,susp_max_load,susp_min_load from public.pc_fd_pumpjack_dyna_dia_t where   dyna_create_time > '2021-08-25 17:00:00' offset  0 limit 100");
67
-    }
68 72
 
69 73
     @Resource(name = "diagnoseMessageProducer")
70 74
     private MessageProducer producer;
@@ -173,7 +177,6 @@ public class CamelJDBCConfiguration /*extends RouteBuilder */ {
173 177
                         .setHeader("date", constant(getDate()))
174 178
                         .setBody(simple("select  distinct jh,rq,cyfs,yz,hysx , yysx ,tysx,bs,dym from DBA01 where rq  = to_date('${header.date}','yyyy-MM-dd') and qyrq is not null "))
175 179
                         .to("jdbc:oracle")
176
-                        .log("${header.date}"+" routeId:oracle-2->  select cb_pc_pro_wellbore_status_daily  need data failed")
177 180
                         .split(body()).process(exchange -> {
178 181
                     Message in = exchange.getIn();
179 182
                     HashMap<String, Object> aRow = in.getBody(HashMap.class);
@@ -199,7 +202,6 @@ public class CamelJDBCConfiguration /*extends RouteBuilder */ {
199 202
                         //.setBody(simple("SELECT distinct jh,rq,dym FROM DBA01 WHERE  rq between to_date(TO_CHAR(ADD_MONTHS(SYSDATE,-3),'yyyy-MM-dd'),'yyyy-MM-dd')and to_date(TO_CHAR(SYSDATE,'yyyy-MM-dd'),'yyyy-MM-dd') and dym is not null;"))
200 203
                         .setBody(simple("SELECT  distinct jh,max(rq),dym FROM DBA01 WHERE dym is not null group by jh,dym"))
201 204
                         .to("jdbc:oracle")
202
-                        .log("${header.date}"+" routeId:oracle-5->  select DYM data failed")
203 205
                         .split(body())
204 206
                         .doTry()
205 207
                         .setBody(simple("update centralbase.cb_pc_pro_wellbore_status_daily set start_pump_liq_level = '${body[DYM]}' where well_id = '${body[JH]}' and prod_date::date  = '${header.date}' "))
@@ -214,7 +216,6 @@ public class CamelJDBCConfiguration /*extends RouteBuilder */ {
214 216
                         //.setBody(simple("SELECT  distinct jh,max(rq),dym FROM DBA01 WHERE dym is not null group by jh,dym"))
215 217
                         .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}' "))
216 218
                         .to("jdbc:centralbase")
217
-                        .log("${header.date}"+" routeId:oracle-7-> select  centralbase.cb_pc_pro_wellbore_status_daily need data failed")
218 219
                         .split(body()).process(exchange -> {
219 220
                             Message in = exchange.getIn();
220 221
                             HashMap<String, Object> aRow = in.getBody(HashMap.class);
@@ -238,7 +239,6 @@ public class CamelJDBCConfiguration /*extends RouteBuilder */ {
238 239
                         .setHeader("date", constant(getDate()))
239 240
                         .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 "))
240 241
                         .to("jdbc:oracle")
241
-                        .log("${header.date}"+" routeId:oracle-3->  select centralbase.cb_pc_pro_wellbore_vol_daily need  insert data failed")
242 242
                         .split(body()).process(exchange -> {
243 243
                     Message in = exchange.getIn();
244 244
                     HashMap<String, Object> aRow = in.getBody(HashMap.class);
@@ -305,7 +305,6 @@ public class CamelJDBCConfiguration /*extends RouteBuilder */ {
305 305
                         .setHeader("date", constant(getDate()))
306 306
                         .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 "))
307 307
                         .to("jdbc:oracle")
308
-                        .log("${header.date}"+" routeId:oracle-12-> select  centralbase.cb_pc_pro_wellbore_vol_daily need  update data failed")
309 308
                         .split(body()).process(exchange -> {
310 309
                             Message in = exchange.getIn();
311 310
                             HashMap<String, Object> aRow = in.getBody(HashMap.class);
@@ -362,7 +361,6 @@ public class CamelJDBCConfiguration /*extends RouteBuilder */ {
362 361
                         .setHeader("date", constant(getDate()))
363 362
                         .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  "))
364 363
                         .to("jdbc:oracle")
365
-                        .log("${header.date}"+" routeId:oracle-4-> select  centralbase.cb_temp_well_mech_daily need insert data failed")
366 364
                         .split(body()).process(exchange -> {
367 365
                     Message in = exchange.getIn();
368 366
                     HashMap<String, Object> aRow = in.getBody(HashMap.class);
@@ -391,7 +389,6 @@ public class CamelJDBCConfiguration /*extends RouteBuilder */ {
391 389
                         .setHeader("date", constant(getDate() + " 00:00:00"))
392 390
                         .setBody(simple("SELECT  distinct jh,max(rq),bj FROM DBA01 WHERE dym is not null group by jh,bj"))
393 391
                         .to("jdbc:oracle")
394
-                        .log("${header.date}"+" routeId:oracle-6-> select bj  centralbase.cb_temp_well_mech_runtime need update data failed")
395 392
                         .split(body()).process(exchange -> {
396 393
                             Message in = exchange.getIn();
397 394
                             HashMap<String, Object> aRow = in.getBody(HashMap.class);
@@ -401,6 +398,7 @@ public class CamelJDBCConfiguration /*extends RouteBuilder */ {
401 398
                         .to("jdbc:centralbase")
402 399
                         .log("${header.date}"+" routeId:oracle-6->  centralbase.cb_temp_well_mech_runtime update data failed")
403 400
                         .end();
401
+
404 402
                 from("timer:mytimer8?period=3600000")
405 403
                         .routeId("jdbc-gtsj-?")
406 404
                         .setBody(simple("select max(prod_date) from centralbase.cb_temp_well_mech_runtime "))
@@ -456,7 +454,7 @@ public class CamelJDBCConfiguration /*extends RouteBuilder */ {
456 454
                                 "where NOT EXISTS (SELECT * FROM centralbase.cb_temp_well_mech_runtime WHERE well_id = '${body[well_name]}' and  prod_date = '${body[dyna_create_time]}' )"))
457 455
                         .to("jdbc:centralbase")
458 456
                         .doCatch(Exception.class)
459
-                        .log("${header.date}"+" routeId:jdbc-gtsj-?->  centralbase.cb_temp_well_mech_runtime insert data failed")
457
+                        .log("${header.date}"+" routeId:jdbc-gtsj-?->  centralbase.cb_temp_well_mech_runtime insert data failed ${body}")
460 458
                         .end();
461 459
 
462 460
                   from("timer:mytimer9?period=3600000")
@@ -465,7 +463,6 @@ public class CamelJDBCConfiguration /*extends RouteBuilder */ {
465 463
                         .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\n" +
466 464
                                 "and cb.prod_date = '${header.date}' "))
467 465
                         .to("jdbc:centralbase")//.log("${body}")
468
-                        .log("${header.date}"+" routeId:centralbase-2-> select  pump_diameter centralbase.cb_pc_pro_wellbore_status_daily  data failed")
469 466
                         .split(body()).process(exchange -> {
470 467
                             Message in = exchange.getIn();
471 468
                             HashMap<String, Object> aRow = in.getBody(HashMap.class);
@@ -481,11 +478,8 @@ public class CamelJDBCConfiguration /*extends RouteBuilder */ {
481 478
                from("timer:mytimer10?period=3600000")
482 479
                         .routeId("centralbase-3")
483 480
                         .setHeader("date", constant(getDate()))
484
-                        .doTry()
485 481
                         .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"))
486 482
                         .to("jdbc:centralbase")//.log("${body}")
487
-                        .doCatch(Exception.class)
488
-                        .log("${header.date}"+" routeId:centralbase-3-> select stroke_length  centralbase.cb_temp_well_mech_daily  data failed")
489 483
                         .split(body()).process(exchange -> {
490 484
                     Message in = exchange.getIn();
491 485
                     HashMap<String, Object> aRow = in.getBody(HashMap.class);
@@ -509,8 +503,11 @@ public class CamelJDBCConfiguration /*extends RouteBuilder */ {
509 503
 
510 504
                 from("timer:mytimer11?period=3600000")
511 505
                         .routeId("centralbase-1")
512
-                        .setBody(simple("select so.well_id,so.well_common_name,so.org_id,ti.prod_date,ti.stroke_frequency,ti.stroke_length,ti.sgt from centralbase.cb_temp_well_mech_runtime ti, centralbase.cb_cd_well_source so where ti.well_id = so.well_id and ti.prod_date =(select max(prod_date) from centralbase.cb_temp_well_mech_runtime) "))
513
-                        .to("jdbc:centralbase")
506
+                        .setBody(simple("select so.well_id,so.well_common_name,so.org_id,ti.prod_date,ti.stroke_frequency,ti.stroke_length,ti.sgt from centralbase.cb_temp_well_mech_runtime ti, centralbase.cb_cd_well_source so where ti.well_id = so.well_id and ti.prod_date = (select max(prod_date) from centralbase.cb_temp_well_mech_runtime) "))
507
+                        .to("jdbc:centralbase").process(exchange -> {
508
+                            sendMsgRunTime=0;
509
+                            DefaultMsgSendSuccessCallBack.count.set(0);
510
+                        })
514 511
                         .split(body())
515 512
                         .doTry()
516 513
                         .process(exchange -> {
@@ -527,12 +524,15 @@ public class CamelJDBCConfiguration /*extends RouteBuilder */ {
527 524
                                 sgt = "0,0";
528 525
                             }
529 526
                             DiagnoseMsg diagnoseMsg = new DiagnoseMsg(wellId, wellName, orgId, prodDate, sgt, LocalDateTime.now().toString(), strokeLength, strokeFrequency);
530
-                            producer.send((MessageBody) diagnoseMsg);
527
+                            sendMsgRunTime++;
528
+                            System.out.println("sendMsgRunTime = " + sendMsgRunTime);
529
+                            producer.send(diagnoseMsg);
531 530
                         })
532 531
                         .doCatch(Exception.class)
533 532
                         .log("${header.date}"+" rocketMQ send data failed")
534 533
                         .end();
535 534
 
535
+
536 536
             };
537 537
         };
538 538
 

+ 13 - 7
src/main/resources/application.yml

@@ -107,7 +107,7 @@ management:
107 107
   endpoints:
108 108
     web:
109 109
       exposure:
110
-        include: health, info,camelroutes , camelroutecontroller
110
+        include: '*'
111 111
       cors:
112 112
         allow-credentials: off
113 113
 server:
@@ -116,7 +116,7 @@ server:
116 116
 
117 117
 rocketmq:
118 118
   #rocketmq的路由调度器的地址
119
-  name-server: 10.72.143.2:9876
119
+  name-server: 101.200.219.190:9876
120 120
   producer:
121 121
     # 消息分组
122 122
     group: aoid
@@ -129,12 +129,12 @@ gct:
129 129
     one:
130 130
       topic: diagnose-msg
131 131
       tags: v1
132
-      log-file-path: /home/lloyd/Desktop/log/task.json
132
+      log-file-path: ${user.home}/logs/gct-etl/diagnoseMsgFailed.json
133 133
       producer:
134 134
         group: diagnose
135 135
         access-key: diagnose-msg-v1
136 136
         secret-key: diagnose-msg-v1
137
-      name-server: 10.72.143.2:9876
137
+      name-server: 101.200.219.190:9876
138 138
       consumer:
139 139
         group: diagnose
140 140
         access-key: diagnose-msg-v1
@@ -142,13 +142,19 @@ gct:
142 142
     two:
143 143
       topic: warn-msg
144 144
       tags: v1
145
-      log-file-path: /home/lloyd/Desktop/log/task.json
145
+      log-file-path: ${user.home}/logs/gct-etl/warnMsgFailed.json
146 146
       producer:
147 147
         group: warn
148 148
         access-key: warn-msg-v1
149 149
         secret-key: warn-msg-v1
150
-      name-server: 10.72.143.2:9876
150
+      name-server: 101.200.219.190:9876
151 151
       consumer:
152 152
         group: warn
153 153
         access-key: warn-msg-v1
154
-        secret-key: warn-msg-v1
154
+        secret-key: warn-msg-v1
155
+
156
+# swagger 相关配置
157
+swagger:
158
+  authorization:
159
+    key-name: token
160
+  enabled: true

+ 1 - 0
src/test/java/com/gct/tools/etlcamelhuge/EtlCamelHugeApplicationTests.java

@@ -2,6 +2,7 @@ package com.gct.tools.etlcamelhuge;
2 2
 
3 3
 import com.alibaba.fastjson.JSONArray;
4 4
 import com.alibaba.fastjson.JSONObject;
5
+import com.gct.tools.etlcamelhuge.entity.GTBody;
5 6
 import com.gct.tools.etlcamelhuge.routeconfig.CamelJDBCConfiguration;
6 7
 import io.micrometer.core.instrument.util.IOUtils;
7 8
 import lombok.Data;