|
@@ -8,15 +8,14 @@ import org.apache.camel.Message;
|
8
|
8
|
import org.apache.camel.builder.RouteBuilder;
|
9
|
9
|
import org.springframework.context.annotation.Bean;
|
10
|
10
|
import org.springframework.context.annotation.Configuration;
|
|
11
|
+import org.springframework.util.StringUtils;
|
11
|
12
|
|
12
|
13
|
import javax.annotation.Resource;
|
13
|
14
|
import java.math.BigDecimal;
|
|
15
|
+import java.math.RoundingMode;
|
14
|
16
|
import java.time.LocalDateTime;
|
15
|
17
|
import java.time.format.DateTimeFormatter;
|
16
|
|
-import java.util.ArrayList;
|
17
|
|
-import java.util.Arrays;
|
18
|
|
-import java.util.HashMap;
|
19
|
|
-import java.util.List;
|
|
18
|
+import java.util.*;
|
20
|
19
|
|
21
|
20
|
/**
|
22
|
21
|
* class name: CamelJDBCCofRealTimeConfiguration.java
|
|
@@ -93,7 +92,7 @@ public class CamelJDBCCofRealTimeConfiguration {
|
93
|
92
|
String prod_date = aRow.get("dyna_create_time").toString().split("\\+")[0];
|
94
|
93
|
aRow.put("dyna_create_time", prod_date);
|
95
|
94
|
aRow.put("sgt", "");
|
96
|
|
- if (aRow.get("displacement") != null && !aRow.get("displacement").equals("") && aRow.get("disp_load") != null && !aRow.get("disp_load").equals("")) {
|
|
95
|
+ if (!StringUtils.isEmpty(aRow.get("displacement")) && !StringUtils.isEmpty(aRow.get("disp_load"))) {
|
97
|
96
|
String[] displacements = aRow.get("displacement").toString().split(";");//10 四舍五入
|
98
|
97
|
String[] disp_loads = aRow.get("disp_load").toString().split(";");
|
99
|
98
|
Double susp_max_load = max(disp_loads);
|
|
@@ -113,7 +112,7 @@ public class CamelJDBCCofRealTimeConfiguration {
|
113
|
112
|
aRow.put("susp_min_load",susp_min_load);
|
114
|
113
|
}
|
115
|
114
|
//对于位移没有数据,所有数据都在载荷中的特殊数据做特别处理
|
116
|
|
- else if ((aRow.get("displacement") == null || aRow.get("displacement").equals("")) && (aRow.get("disp_load") != null && !aRow.get("disp_load").equals(""))){
|
|
115
|
+ else if (StringUtils.isEmpty(aRow.get("displacement")) && !StringUtils.isEmpty(aRow.get("disp_load"))){
|
117
|
116
|
String disp_load = aRow.get("disp_load").toString().replaceAll(";", ",");
|
118
|
117
|
Double[][] doubles = SGTUtil.encodeToDoubleArray(disp_load);
|
119
|
118
|
aRow.put("sgt", SGTUtil.encodeToString(doubles));
|
|
@@ -131,19 +130,19 @@ public class CamelJDBCCofRealTimeConfiguration {
|
131
|
130
|
aRow.put("susp_max_load",susp_max_load);
|
132
|
131
|
aRow.put("susp_min_load",susp_min_load);
|
133
|
132
|
}
|
134
|
|
- if (aRow.get("stroke") == null) aRow.put("stroke", "0.0");
|
135
|
|
- if (aRow.get("frequency") == null) aRow.put("frequency", "0.0");
|
136
|
|
- if (aRow.get("susp_max_load") == null) aRow.put("susp_max_load", "0.0");
|
137
|
|
- if (aRow.get("susp_min_load") == null) aRow.put("susp_min_load", "0.0");
|
138
|
|
- if (aRow.get("frequency") != null){
|
|
133
|
+ aRow.putIfAbsent("stroke", "0.0");
|
|
134
|
+ aRow.putIfAbsent("frequency", "0.0");
|
|
135
|
+ aRow.putIfAbsent("susp_max_load", "0.0");
|
|
136
|
+ aRow.putIfAbsent("susp_min_load", "0.0");
|
|
137
|
+ if (!StringUtils.isEmpty(aRow.get("frequency"))){
|
139
|
138
|
BigDecimal bd=new BigDecimal(aRow.get("frequency").toString());
|
140
|
|
- double frequency=bd.setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
139
|
+ double frequency=bd.setScale(1, RoundingMode.HALF_UP).doubleValue();
|
141
|
140
|
aRow.put("frequency",frequency);
|
142
|
141
|
}
|
143
|
|
- if (aRow.get("stroke") != null){
|
|
142
|
+ if (!StringUtils.isEmpty(aRow.get("stroke"))){
|
144
|
143
|
double stroke1 = Double.parseDouble(aRow.get("stroke").toString());
|
145
|
144
|
BigDecimal bd=new BigDecimal(stroke1);
|
146
|
|
- double stroke=bd.setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
145
|
+ double stroke=bd.setScale(1, RoundingMode.HALF_UP).doubleValue();
|
147
|
146
|
aRow.put("stroke",stroke);
|
148
|
147
|
}
|
149
|
148
|
String wellName =aRow.get("well_name").toString();
|