|
@@ -49,44 +49,47 @@ public class GtController {
|
49
|
49
|
List<String> wellList = gtBody.getWellList().stream().map(x->x.toString()).collect(Collectors.toList());
|
50
|
50
|
JSONObject jsonObject = new JSONObject();
|
51
|
51
|
jdbcTemplate = new JdbcTemplate(dataSource);
|
52
|
|
- int curPage = 0;
|
53
|
|
- int pageSize = 5000;
|
54
|
52
|
int sumData = 0;
|
55
|
53
|
try {
|
56
|
|
- for (int i = 0; i < wellList.size(); i++) {
|
|
54
|
+ if (wellList.isEmpty() || wellList.size()==0 ){
|
57
|
55
|
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);
|
|
56
|
+ " where ti.well_id = so.well_id and ti.prod_date between '%s' and '%s' " ,startDate,endDate);
|
|
57
|
+ sumData = sendDataToMQ(sql);
|
|
58
|
+ }else {
|
|
59
|
+ for (int i = 0; i < wellList.size(); i++) {
|
|
60
|
+ 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 " +
|
|
61
|
+ " 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);
|
|
62
|
+ sumData = sendDataToMQ(sql);
|
75
|
63
|
}
|
76
|
|
- /* sumData += list.size();
|
77
|
|
- if (list.size()< pageSize){
|
78
|
|
- break;
|
79
|
|
- }
|
80
|
|
- curPage ++ ;*/
|
81
|
64
|
}
|
82
|
|
-
|
83
|
65
|
}catch (Exception e){
|
84
|
66
|
e.printStackTrace();
|
85
|
67
|
jsonObject.put("error",e.getMessage());
|
86
|
68
|
}finally {
|
87
|
|
- jsonObject.put("sumData",sumData);
|
|
69
|
+ jsonObject.put("发送数据为sumData",sumData);
|
88
|
70
|
}
|
89
|
|
- return jsonObject;
|
|
71
|
+ return jsonObject;
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+ public int sendDataToMQ(String sql){
|
|
75
|
+ int sumData = 0;
|
|
76
|
+ List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
77
|
+ for (Map<String, Object> map : list) {
|
|
78
|
+ String wellName = map.get("well_common_name").toString();
|
|
79
|
+ String wellId = map.get("well_id").toString();
|
|
80
|
+ String orgId = map.get("org_id").toString();
|
|
81
|
+ String prodDate = map.get("prod_date").toString().substring(0, 19);
|
|
82
|
+ Double strokeLength = Double.valueOf(map.get("stroke_length").toString());
|
|
83
|
+ Double strokeFrequency = Double.valueOf(map.get("stroke_frequency").toString());
|
|
84
|
+ String sgt = map.get("sgt").toString();
|
|
85
|
+ if (sgt == null || sgt.length() == 0) {
|
|
86
|
+ sgt = "0,0,0,0,0,0,0,0,0,0";
|
|
87
|
+ }
|
|
88
|
+ DiagnoseMsg diagnoseMsg = new DiagnoseMsg(wellId, wellName, orgId, prodDate, sgt, LocalDateTime.now().toString(), strokeLength, strokeFrequency);
|
|
89
|
+ //producer.send((MessageBody) diagnoseMsg);
|
|
90
|
+ sumData++;
|
|
91
|
+ }
|
|
92
|
+ return sumData;
|
90
|
93
|
}
|
91
|
94
|
|
92
|
95
|
/* @GetMapping("/getGTSJ")
|