瀏覽代碼

close camel @configuration, use test mode

xsr 8 月之前
父節點
當前提交
b0db224eca

+ 0 - 268
src/main/java/com/gct/tools/etlcamelhuge/controller/BaseDataController.java

@@ -1,268 +0,0 @@
1
-package com.gct.tools.etlcamelhuge.controller;
2
-
3
-import com.alibaba.fastjson.JSONObject;
4
-import com.gct.tools.etlcamelhuge.entity.BaseDataBody;
5
-import io.swagger.annotations.Api;
6
-import io.swagger.annotations.ApiOperation;
7
-import org.omg.CORBA.IRObject;
8
-import org.springframework.jdbc.core.JdbcTemplate;
9
-import org.springframework.web.bind.annotation.PostMapping;
10
-import org.springframework.web.bind.annotation.RequestBody;
11
-import org.springframework.web.bind.annotation.RequestMapping;
12
-import org.springframework.web.bind.annotation.RestController;
13
-
14
-import javax.annotation.Resource;
15
-import javax.sql.DataSource;
16
-import java.math.BigDecimal;
17
-import java.util.ArrayList;
18
-import java.util.List;
19
-import java.util.Map;
20
-import java.util.stream.Collectors;
21
-
22
-/**
23
- * class name: BaseDataController
24
- *
25
- * @author gxt
26
- * @version 1.0
27
- * @since 2021/8/30 下午3:51 周一
28
- */
29
-@RestController
30
-@RequestMapping("/BaseData")
31
-@Api(value = "BaseDataController", description = "基础数据操作controller")
32
-public class BaseDataController {
33
-
34
-    private JdbcTemplate jdbcTemplate;
35
-    @Resource(name = "oracle")
36
-    DataSource oracleDataSource;
37
-
38
-    @Resource(name = "centralbase")
39
-    DataSource baseDataSource;
40
-
41
-    @Resource(name = "gtsj")
42
-    DataSource gtsjDataSource;
43
-
44
-    @PostMapping("/saveDataToStatusDaily")
45
-    @ApiOperation("从 A2 获取 数据插入到 centrlBase-StatusDaily 中,只需要传入查询时间")
46
-    public JSONObject saveDataToStatusDaily(@RequestBody BaseDataBody baseDataBody) {
47
-        JSONObject jsonObject = new JSONObject();
48
-        int insertCount = 0;
49
-        int updateDYMCount = 0;
50
-        int updateCMDCount = 0;
51
-        int updateOLiNozzleCount = 0;
52
-        try {
53
-            jdbcTemplate = new JdbcTemplate(oracleDataSource);
54
-            String date = baseDataBody.getDate();
55
-            String sql = "select  distinct jh,rq,cyfs,yz,hysx , yysx ,tysx,bs,dym from DBA01 where rq  = to_date('" + date + "','yyyy-MM-dd') and qyrq is not null ";
56
-            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
57
-            for (Map<String, Object> map : list) {
58
-                if (map.get("YZ") == null) map.put("YZ", "0.0");
59
-                if (map.get("HYSX") == null) map.put("HYSX", "0.0");
60
-                if (map.get("YYSX") == null) map.put("YYSX", "0.0");
61
-                if (map.get("TYSX") == null) map.put("TYSX", "0.0");
62
-                if (map.get("BS") == null) map.put("BS", "0.0");
63
-                sql = "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) " +
64
-                        "values (?,?,?,?,?,?,?,?)";
65
-                insertCount = insertBaseDataSourceOfStatusDaily(sql, map);
66
-                sql = "select  distinct jh , rq , dym from DBA01 where  (jh,rq) in (SELECT  jh,max(rq) rq  FROM DBA01 WHERE dym is not null and rq<=to_date('"+date+"','yyyy-MM-dd') group by jh)";
67
-                List<Map<String, Object>> dymIsNotNUllList = selectA2DataOfNotIsNullDYMOrBJ(sql);
68
-                for (Map<String, Object> stringObjectMap : dymIsNotNUllList) {
69
-                    sql = "update centralbase.cb_pc_pro_wellbore_status_daily set start_pump_liq_level = '" + stringObjectMap.get("DYM") + "' where well_id = '" + stringObjectMap.get("JH") + "' and prod_date::date  = '" + stringObjectMap.get("RQ") + "' ";
70
-                    updateDYMCount = updateBaseDataSourceOfStatusDaily(sql) + updateDYMCount;
71
-                }
72
-                sql = "select well_id,prod_date,start_pump_liq_level,pump_depth from centralbase.cb_pc_pro_wellbore_status_daily where prod_date = '" + map.get("RQ") + "' ";
73
-                List<Map<String, Object>> CMDDataList = selectBaseDataSourceStatusDaily(sql);
74
-                for (Map<String, Object> stringObjectMap : CMDDataList) {
75
-                    stringObjectMap.put("submergence_depth", null);
76
-                    if (stringObjectMap.get("start_pump_liq_level") != null && stringObjectMap.get("pump_depth") != null) {
77
-                        double cmd = Double.valueOf(stringObjectMap.get("pump_depth").toString()) - Double.valueOf(stringObjectMap.get("start_pump_liq_level").toString()) / 10;
78
-                        BigDecimal bd = new BigDecimal(cmd);
79
-                        double cmd1 = bd.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
80
-                        stringObjectMap.put("submergence_depth", cmd1);
81
-                    }
82
-                    //修改为batch 执行,用一个list 接受,在执行那个batchUpdate
83
-                    sql = " update centralbase.cb_pc_pro_wellbore_status_daily set submergence_depth = '" + stringObjectMap.get("submergence_depth") + "' where well_id = '" + stringObjectMap.get("well_id") + "' and prod_date  = '" + stringObjectMap.get("prod_date") + "' ";
84
-                    updateCMDCount = updateBaseDataSourceOfStatusDaily(sql) + updateCMDCount;
85
-                }
86
-                sql = "select distinct jh , rq , bj from DBA01 where  (jh,rq) in (SELECT  jh,max(rq) rq  FROM DBA01 WHERE bj is not null and rq<= to_date('"+date+"','yyyy-MM-dd') group by jh)";
87
-                List<Map<String, Object>> oilNozzleList = selectA2DataOfNotIsNullDYMOrBJ(sql);
88
-                for (Map<String, Object> stringObjectMap : oilNozzleList) {
89
-                    sql = " update centralbase.cb_pc_pro_wellbore_status_daily set oil_nozzle = '" + stringObjectMap.get("BJ") + "' where well_id ='" + stringObjectMap.get("JH") + "' and prod_date='" + stringObjectMap.get("RQ") + "' ";
90
-                    updateOLiNozzleCount = updateBaseDataSourceOfStatusDaily(sql) + updateOLiNozzleCount;
91
-                }
92
-                insertCount++;
93
-            }
94
-        } catch (Exception e) {
95
-            e.printStackTrace();
96
-            jsonObject.put("error", e.getMessage());
97
-        } finally {
98
-            jsonObject.put("插入条数", insertCount);
99
-            jsonObject.put("修改DYM条数", updateDYMCount);
100
-            jsonObject.put("修改CMD条数", updateCMDCount);
101
-            jsonObject.put("修改OliNozzle条数", updateOLiNozzleCount);
102
-        }
103
-        return jsonObject;
104
-    }
105
-
106
-
107
-    public int insertBaseDataSourceOfStatusDaily(String sql, Map<String, Object> map) {
108
-        jdbcTemplate = new JdbcTemplate(baseDataSource);
109
-        if (map.isEmpty()) return 0;
110
-        return jdbcTemplate.update(sql, map.get("JH"), map.get("RQ"), map.get("CYFS"), map.get("YZ"), map.get("HYSX"), map.get("YYSX"), map.get("BS"), map.get("DYM"));
111
-    }
112
-
113
-    public List<Map<String, Object>> selectA2DataOfNotIsNullDYMOrBJ(String sql) {
114
-        jdbcTemplate = new JdbcTemplate(oracleDataSource);
115
-        return jdbcTemplate.queryForList(sql);
116
-    }
117
-
118
-    public List<Map<String, Object>> selectBaseDataSourceStatusDaily(String sql) {
119
-        jdbcTemplate = new JdbcTemplate(baseDataSource);
120
-        return jdbcTemplate.queryForList(sql);
121
-    }
122
-
123
-    public int updateBaseDataSourceOfStatusDaily(String sql) {
124
-        jdbcTemplate = new JdbcTemplate(baseDataSource);
125
-        return jdbcTemplate.update(sql);
126
-    }
127
-
128
-
129
-    @PostMapping("/saveDataToVolDaily")
130
-    @ApiOperation("从 A2 获取 数据插入到 centrlBase-VolDaily 中,只需要传入查询时间")
131
-    public JSONObject saveVolDaily(@RequestBody BaseDataBody baseDataBody) {
132
-        JSONObject jsonObject = new JSONObject();
133
-        int insertCount = 0;
134
-        int updateLiqOliDailyCount = 0;
135
-        try {
136
-            jdbcTemplate = new JdbcTemplate(oracleDataSource);
137
-            String date = baseDataBody.getDate();
138
-            String sql = " select distinct  jh,rq,scsj, rcyl1,rcyl,rcql,hs, bz,sccw from DBA01 where rq  = to_date('" + date + "','yyyy-MM-dd') and qyrq is not null ";
139
-            List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
140
-            for (Map<String, Object> map : list) {
141
-                if (map.get("SCSJ") == null) map.put("SCSJ", "0.0");
142
-                if (map.get("RCYL1") == null) map.put("RCYL1", "0.0");
143
-                if (map.get("RCYL") == null) map.put("RCYL", "0.0");
144
-                if (map.get("RCQL") == null) map.put("RCQL", "0.0");
145
-                if (map.get("HS") == null) map.put("HS", "0.0");
146
-                if (map.get("BZ") == null) map.put("BZ", "");
147
-                if (map.get("SCCW") == null) map.put("SCCW", "");
148
-                map.put("RCSL", -1);
149
-                map.put("QYB", -1);
150
-                map.put("SQB", -1);
151
-                if (map.get("RCQL") != null && map.get("RCYL") != null && !map.get("RCYL").equals("0.0") && map.get("RCYL") != "0.0") {
152
-                    double qyb = Double.valueOf(map.get("RCQL").toString()) / Double.valueOf(map.get("RCYL").toString());
153
-                    if (!Double.isNaN(qyb) && !Double.isInfinite(qyb)) {
154
-                        BigDecimal bd = new BigDecimal(qyb);
155
-                        double d1 = bd.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
156
-                        map.put("QYB", d1);
157
-                    }
158
-                }
159
-                if (map.get("RCYL1") != null && map.get("HS") != null && !map.get("HS").equals("0.0") && map.get("HS") != "0.0") {
160
-                    double rcsl = (Double.valueOf(map.get("RCYL1").toString()) * Double.valueOf(map.get("HS").toString())) / 100;
161
-                    if (!Double.isNaN(rcsl) && !Double.isInfinite(rcsl)) {
162
-                        BigDecimal bd = new BigDecimal(rcsl);
163
-                        double d1 = bd.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
164
-                        map.put("RCSL", d1);
165
-                    }
166
-                }
167
-                if (map.get("RCQL") != null && map.get("RCSL") != null && !map.get("RCQL").equals("0.0") && map.get("RCQL") != "0.0") {
168
-                    double sqb = Double.valueOf(map.get("RCSL").toString()) / Double.valueOf(map.get("RCQL").toString());
169
-                    if (!Double.isNaN(sqb) && !Double.isInfinite(sqb)) {
170
-                        BigDecimal bd = new BigDecimal(sqb);
171
-                        double d1 = bd.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
172
-                        map.put("SQB", d1);
173
-                    }
174
-                }
175
-                if (!map.containsKey("SMD")) {
176
-                    map.put("SMD", 1);
177
-                }
178
-                if (!map.containsKey("YMD")) {
179
-                    map.put("YMD", 0.85);
180
-                }
181
-                sql = "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) " +
182
-                        "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
183
-                insertCount = insertBaseDataVolDaily(sql, map) + insertCount;
184
-                sql = "select distinct  jh,rq,scsj, rcyl1,rcyl,rcql,hs, bz,sccw from DBA01 where rq  = to_date('" + date + "','yyyy-MM-dd') and qyrq is not null ";
185
-                updateLiqOliDailyCount = updateBaseDataVolDaily(sql) + updateLiqOliDailyCount;
186
-            }
187
-
188
-        } catch (Exception e) {
189
-            jsonObject.put("error", e.getMessage());
190
-        } finally {
191
-            jsonObject.put("插入条数", insertCount);
192
-            jsonObject.put("修改liqOliDaily条数", updateLiqOliDailyCount);
193
-        }
194
-        return jsonObject;
195
-    }
196
-
197
-    public int insertBaseDataVolDaily(String sql, Map<String, Object> map) {
198
-        jdbcTemplate = new JdbcTemplate(baseDataSource);
199
-        if (map.isEmpty()) return 0;
200
-        return jdbcTemplate.update(sql, map.get("JH"), map.get("RQ"), map.get("SCSJ"), map.get("RCYL1"), map.get("RCYL"), map.get("RCQL"), map.get("HS"), map.get("BZ"), map.get("QYB"), map.get("RCSL"), map.get("SQB"), map.get("SMD"), map.get("YMD"), map.get("SCCW"));
201
-    }
202
-
203
-    public int updateBaseDataVolDaily(String sql) {
204
-        jdbcTemplate = new JdbcTemplate(baseDataSource);
205
-        return jdbcTemplate.update(sql);
206
-    }
207
-
208
-    @PostMapping("/getNeedRunTimeData")
209
-    @ApiOperation("查询天安的数据库 只需要传过来 需要查询的sql 就行")
210
-    public JSONObject getNeedRunTimeData(@RequestBody BaseDataBody baseDataBody){
211
-        JSONObject jsonObject = new JSONObject();
212
-        jdbcTemplate = new JdbcTemplate(gtsjDataSource);
213
-        try{
214
-            long st = System.currentTimeMillis();
215
-            List<Map<String, Object>> list = jdbcTemplate.queryForList(baseDataBody.getSql());
216
-            jsonObject.put("cost",(System.currentTimeMillis()-st)+" ms");
217
-            jsonObject.put("RunTimedata",list);
218
-        }catch (Exception e){
219
-            jsonObject.put("error",e.getMessage());
220
-        }
221
-         return jsonObject;
222
-    }
223
-
224
-    @PostMapping("/getNeedA2Data")
225
-    @ApiOperation("查询A2数据库 只需要传过来 需要查询的sql 就行")
226
-    public JSONObject getNeedA2Data(@RequestBody BaseDataBody baseDataBody){
227
-        JSONObject jsonObject = new JSONObject();
228
-        jdbcTemplate = new JdbcTemplate(oracleDataSource);
229
-        try{
230
-            List<Map<String, Object>> list = jdbcTemplate.queryForList(baseDataBody.getSql());
231
-            jsonObject.put("A2data",list);
232
-        }catch (Exception e){
233
-            jsonObject.put("error",e.getMessage());
234
-        }
235
-        return jsonObject;
236
-    }
237
-
238
-    @PostMapping("/getA2WellSorceData")
239
-    @ApiOperation("查询A2数据库 并且和 wellSource 做对比 只填写需要查询A2Data 的时间就行")
240
-    public JSONObject getA2WellSorceData(@RequestBody BaseDataBody baseDataBody){
241
-        JSONObject jsonObject = new JSONObject();
242
-        jdbcTemplate = new JdbcTemplate(oracleDataSource);
243
-        try{
244
-            String sql = "select  distinct jh  from DBA01 where rq  = to_date('"+baseDataBody.getDate()+"','yyyy-MM-dd') and qyrq is not null ";
245
-            List<Map<String, Object>>  A2DataList = jdbcTemplate.queryForList(sql);
246
-            List<Map<String, Object>>  wellSourceList = getWellSource();
247
-            Object collect = A2DataList.stream().filter(item -> !wellSourceList.contains(item)).collect(Collectors.toList());
248
-            Object collect1 = wellSourceList.stream().filter(item -> !A2DataList.contains(item)).collect(Collectors.toList());
249
-            jsonObject.put("wellSource 中不存在 A2 的井号为",collect);
250
-            jsonObject.put("A2 中不存在 wellSource 的井号为",collect1);
251
-        }catch (Exception e){
252
-            jsonObject.put("error",e.getMessage());
253
-        }
254
-        return jsonObject;
255
-    }
256
-
257
-    public List<Map<String, Object>>  getWellSource(){
258
-        List<Map<String, Object>>  list = new ArrayList<>();
259
-        try{
260
-            jdbcTemplate = new JdbcTemplate(baseDataSource);
261
-            String sql = " select distinct well_id from centralbase.cb_cd_well_source ";
262
-            list = jdbcTemplate.queryForList(sql);
263
-        }catch (Exception e){
264
-            e.printStackTrace();
265
-        }
266
-        return list;
267
-    }
268
-}

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

@@ -1,218 +0,0 @@
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.ArrayList;
21
-import java.util.Arrays;
22
-import java.util.List;
23
-import java.util.Map;
24
-import java.util.stream.Collectors;
25
-
26
-/**
27
- * class name: GtController
28
- *
29
- * @author gxt
30
- * @version 1.0
31
- * @since 2021/8/26 下午2:50 周四
32
- */
33
-@RestController
34
-@RequestMapping("/GTData")
35
-@Api(value = "GtController",description = "功图数据操作controller")
36
-public class GtController {
37
-
38
-    private JdbcTemplate jdbcTemplate;
39
-    @Resource(name = "centralbase")
40
-    DataSource dataSource;
41
-
42
-    @Resource(name = "gtsj")
43
-    DataSource dataSourceOfGTSJ;
44
-
45
-    @Resource(name = "diagnoseMessageProducer")
46
-    private MessageProducer producer;
47
-
48
-    @PostMapping("/sendGTSJ")
49
-    @ApiOperation(value = "从 RunTime 数据表查询数据并且发送功图数据到 MQ 中")
50
-    public JSONObject sendGTSJ(@RequestBody GTBody gtBody){
51
-        String startDate = gtBody.getStartDate();
52
-        String endDate = gtBody.getEndDate();
53
-        List<String> wellList = (List<String>) gtBody.getWellList().stream().map(x->x.toString()).collect(Collectors.toList());
54
-        JSONObject jsonObject = new JSONObject();
55
-        jdbcTemplate = new JdbcTemplate(dataSource);
56
-        long sumData = 0;
57
-        try {
58
-                if (wellList.isEmpty()){
59
-                    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 " +
60
-                            " where ti.well_id = so.well_id  and ti.prod_date between '%s' and '%s' " ,startDate,endDate);
61
-                    sumData = sendDataToMQ(sql);
62
-                }else {
63
-                    for (String s : wellList) {
64
-                        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 " +
65
-                                " where ti.well_id = so.well_id and ti.well_id = '%s' and ti.prod_date between '%s' and '%s' ", s, startDate, endDate);
66
-                        sumData = sendDataToMQ(sql);
67
-                    }
68
-                }
69
-        }catch (Exception e){
70
-            e.printStackTrace();
71
-            jsonObject.put("error",e.getMessage());
72
-        }finally {
73
-            jsonObject.put("发送数据为sumData",sumData);
74
-        }
75
-        return  jsonObject;
76
-    }
77
-
78
-    public long sendDataToMQ(String sql){
79
-        int sumData = 0;
80
-        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
81
-        for (Map<String, Object> map : list) {
82
-            String wellName = map.get("well_common_name").toString();
83
-            String wellId = map.get("well_id").toString();
84
-            String orgId = map.get("org_id").toString();
85
-            String prodDate = map.get("prod_date").toString().substring(0, 19);
86
-            Double strokeLength = Double.valueOf(map.get("stroke_length").toString());
87
-            Double strokeFrequency = Double.valueOf(map.get("stroke_frequency").toString());
88
-            String sgt = map.get("sgt").toString();
89
-            if (sgt == null || sgt.length() == 0) {
90
-                sgt = "0,0,0,0,0,0,0,0,0,0";
91
-            }
92
-            DiagnoseMsg diagnoseMsg = new DiagnoseMsg(wellId, wellName, orgId, prodDate, sgt, LocalDateTime.now().toString(), strokeLength, strokeFrequency);
93
-            producer.send((MessageBody) diagnoseMsg);
94
-            sumData++;
95
-        }
96
-        return sumData;
97
-    }
98
-
99
-    @GetMapping("/getGTSJ")
100
-    @ApiOperation(value = "从实时的机采数据生产的表中获取数据放入到 Runtime 表中")
101
-    public JSONObject getGTSJ(@RequestBody GTBody gtBody){
102
-        String startDate = gtBody.getStartDate();
103
-        JSONArray wellList = gtBody.getWellList();
104
-        JSONObject jsonObject = new JSONObject();
105
-        jdbcTemplate = new JdbcTemplate(dataSourceOfGTSJ);
106
-        int curPage = 0;
107
-        int pageSize = 5000;
108
-        int sumData = 0;
109
-        try {
110
-            if (wellList.isEmpty() || wellList.size() ==0 ){
111
-                while (true){
112
-                    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'  limit %d offset %d ", startDate,curPage,pageSize);
113
-                    List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
114
-                    sql = String.format("select count(1) from public.pc_fd_pumpjack_dyna_dia_t where   dyna_create_time > '%s' ", startDate );
115
-                    Integer count = jdbcTemplate.queryForObject(sql, Integer.class);
116
-                    int pageNum = (count % pageSize ==0 ) ?(count / pageSize) : (count/pageSize)+1;
117
-                    insertDataToRunTime(list);
118
-                    sumData += list.size();
119
-                    curPage ++;
120
-                    if (curPage>pageNum) break;
121
-                }
122
-            }else {
123
-              for (int i = 0; i < wellList.size(); i++) {
124
-                  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'  limit %d offset %d ", startDate, wellList.get(i),curPage,pageSize);
125
-                  List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
126
-                  insertDataToRunTime(list);
127
-                  sumData += list.size();
128
-                  if (list.size()< pageSize){
129
-                      break;
130
-                  }
131
-                  curPage ++ ;
132
-              }
133
-            }
134
-        }catch (Exception e){
135
-            jsonObject.put("error",e.getMessage());
136
-        }finally {
137
-            jsonObject.put("sumData",sumData);
138
-        }
139
-        return    jsonObject;
140
-}
141
-    public void insertDataToRunTime(List<Map<String, Object>> list){
142
-        for (Map<String, Object> map : list) {
143
-            String prod_date = map.get("dyna_create_time").toString().split("\\+")[0];
144
-            map.put("dyna_create_time", prod_date);
145
-            if (map.get("displacement") != null && !map.get("displacement").equals("") && map.get("disp_load") != null && !map.get("disp_load").equals("")) {
146
-                String[] displacements = map.get("displacement").toString().split(";");//10 四舍五入
147
-                String[] disp_loads = map.get("disp_load").toString().split(";");
148
-                Double susp_max_load = max(disp_loads);
149
-                Double susp_min_load = min(disp_loads);
150
-                String sgt = "";
151
-                for (int y = 0; y < displacements.length; y++) {
152
-                    sgt = sgt + displacements[y] + "," + disp_loads[y] + ",";
153
-                }
154
-                String[] s = sgt.split(",");
155
-                String w = "";
156
-                for (int x = 0; x < s.length; x++) {
157
-                    w += new BigDecimal(Math.round(Double.parseDouble(s[x]) * 100)).stripTrailingZeros().toPlainString() + ",";
158
-                }
159
-                Double[][] doubles = SGTUtil.encodeToDoubleArray(w);
160
-                map.put("sgt", SGTUtil.encodeToString(doubles));
161
-                map.put("susp_max_load",susp_max_load);
162
-                map.put("susp_min_load",susp_min_load);
163
-            }
164
-            if ((map.get("displacement") == null || map.get("displacement").equals("")) && (map.get("disp_load") != null && !map.get("disp_load").equals(""))){
165
-                String disp_load = map.get("disp_load").toString().replaceAll(";", ",");
166
-                Double[][] doubles = SGTUtil.encodeToDoubleArray(disp_load);
167
-                map.put("sgt", SGTUtil.encodeToString(doubles));
168
-                String[] split = disp_load.split(",");
169
-                List<String> listLoad = new ArrayList<>();
170
-                for (int i = 0; i < split.length; i++) {
171
-                    if (i%2 != 0){
172
-                        BigDecimal bigDecimal = new  BigDecimal(split[i]).divide(new BigDecimal("100.0"));
173
-                        listLoad.add(bigDecimal.toString());
174
-                    }
175
-                }
176
-                String[] loads = listLoad.toArray(new String[0]);
177
-                Double susp_max_load = max(loads);
178
-                Double susp_min_load = min(loads);
179
-                map.put("susp_max_load",susp_max_load);
180
-                map.put("susp_min_load",susp_min_load);
181
-            }
182
-            if (map.get("stroke") == null) map.put("stroke", "0.0");
183
-            if (map.get("frequency") == null) map.put("frequency", "0.0");
184
-            if (map.get("susp_max_load") == null) map.put("susp_max_load", "0.0");
185
-            if (map.get("susp_min_load") == null) map.put("susp_min_load", "0.0");
186
-            if (map.get("frequency") != null){
187
-                BigDecimal bd=new BigDecimal(map.get("frequency").toString());
188
-                double frequency=bd.setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue();
189
-                map.put("frequency",frequency);
190
-            }
191
-            if (map.get("stroke") != null){
192
-                double stroke1 = Double.parseDouble(map.get("stroke").toString());
193
-                BigDecimal bd=new BigDecimal(stroke1);
194
-                double stroke=bd.setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue();
195
-                map.put("stroke",stroke);
196
-            }
197
-            jdbcTemplate = new JdbcTemplate(dataSource);
198
-            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) " +
199
-                    "values (?,?,?,?,?,?,?)",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"));
200
-        }
201
-   }
202
-
203
-    public Double min(String[] strings){
204
-        double[] doubles = new double[strings.length];
205
-        for (int i = 0; i < strings.length; i++) {
206
-            doubles[i] = Double.parseDouble(strings[i]);
207
-        }
208
-        return Arrays.stream(doubles).min().getAsDouble();
209
-    }
210
-    //获取最大载荷
211
-    public Double max(String[] strings){
212
-        double[] doubles = new double[strings.length];
213
-        for (int i = 0; i < strings.length; i++) {
214
-            doubles[i] = Double.parseDouble(strings[i]);
215
-        }
216
-        return Arrays.stream(doubles).max().getAsDouble();
217
-    }
218
-}

+ 2 - 2
src/main/java/com/gct/tools/etlcamelhuge/routeconfig/CamelJDBCCofRealTimeConfiguration.java

@@ -24,7 +24,7 @@ import java.util.*;
24 24
  * @version 1.0
25 25
  * @since 2021/4/14 下午3:16
26 26
  */
27
-@Configuration
27
+//@Configuration
28 28
 public class CamelJDBCCofRealTimeConfiguration  {
29 29
 
30 30
     private static long sendMsgRunTime=0;
@@ -81,7 +81,7 @@ public class CamelJDBCCofRealTimeConfiguration  {
81 81
                             exchange.getIn().setHeader("sgt_last_time",body.get("sgt_last_time"));
82 82
                         })
83 83
                         .setBody(simple("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   well_name='${header.well_id}' and  dyna_create_time >= '${header.sgt_last_time}' limit 50 "))
84
-                        .to("jdbc:gtsj")
84
+                        .to("jdbc:oracle")
85 85
                         .process(exchange -> {
86 86
                             sendMsgRunTime = 0;
87 87
                         })

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

@@ -23,7 +23,7 @@ import java.util.*;
23 23
  * @version 1.0
24 24
  * @since 2021/4/14 下午3:16
25 25
  */
26
-@Configuration
26
+//@Configuration
27 27
 public class CamelJDBCConfiguration {
28 28
 
29 29