|
@@ -8,6 +8,7 @@ import com.gct.common.core.result.Result;
|
8
|
8
|
import com.gct.common.util.DateTimeUtil;
|
9
|
9
|
import com.gct.common.util.StringUtil;
|
10
|
10
|
import com.gct.edge.actuator.algorithm.CalIntegral;
|
|
11
|
+import com.gct.edge.actuator.entity.Date2;
|
11
|
12
|
import com.gct.edge.actuator.entity.YieldRealTime;
|
12
|
13
|
import com.gct.edge.actuator.mapper.YieldRealTimeMapper;
|
13
|
14
|
import com.gct.edge.actuator.service.ServicePlusImpl;
|
|
@@ -17,11 +18,15 @@ import com.gct.edge.base.entity.TableNameEnum;
|
17
|
18
|
import org.springframework.beans.factory.annotation.Autowired;
|
18
|
19
|
import org.springframework.stereotype.Service;
|
19
|
20
|
|
|
21
|
+import javax.jws.Oneway;
|
20
|
22
|
import java.io.IOException;
|
21
|
23
|
import java.io.InputStream;
|
|
24
|
+import java.time.Duration;
|
22
|
25
|
import java.time.LocalDateTime;
|
23
|
26
|
import java.time.ZoneOffset;
|
24
|
27
|
import java.time.format.DateTimeFormatter;
|
|
28
|
+import java.util.ArrayList;
|
|
29
|
+import java.util.Collections;
|
25
|
30
|
import java.util.List;
|
26
|
31
|
import java.util.Objects;
|
27
|
32
|
import java.util.UUID;
|
|
@@ -95,36 +100,65 @@ public class YieldServiceImpl extends ServicePlusImpl<YieldRealTimeMapper, Yield
|
95
|
100
|
@Override
|
96
|
101
|
public Result getWellIdsByNew(String moduleKey, String startDate) {
|
97
|
102
|
|
98
|
|
- LocalDateTime start = DateTimeUtil.formatDateTime(startDate +" 00:00:00");
|
99
|
|
- LocalDateTime end = DateTimeUtil.formatDateTime(startDate +" 23:59:59");
|
|
103
|
+ LocalDateTime start = DateTimeUtil.formatDateTime(startDate + " 00:00:00");
|
|
104
|
+ LocalDateTime end = DateTimeUtil.formatDateTime(startDate + " 23:59:59");
|
100
|
105
|
|
101
|
106
|
QueryWrapper<YieldRealTime> queryWrapper = new QueryWrapper<>();
|
102
|
|
- queryWrapper.eq("module_key",moduleKey);
|
103
|
|
- queryWrapper.gt("pro_time",start);
|
104
|
|
- queryWrapper.lt("pro_time",end);
|
105
|
|
- return Result.ok( baseMapper.selectList(queryWrapper));
|
|
107
|
+ queryWrapper.eq("module_key", moduleKey);
|
|
108
|
+ queryWrapper.gt("pro_time", start);
|
|
109
|
+ queryWrapper.lt("pro_time", end);
|
|
110
|
+ return Result.ok(baseMapper.selectList(queryWrapper));
|
106
|
111
|
|
107
|
112
|
}
|
108
|
113
|
|
|
114
|
+ @Override
|
|
115
|
+ public List<YieldRealTime> getRealYieldWithDilution(String moduleKey, String wellId, String date, int dilutionVal) {
|
|
116
|
+ int interval = 24 * 60;
|
|
117
|
+ if (dilutionVal <= 0 || dilutionVal >= interval) return getYieldRealTimeInfoByWellId(moduleKey, wellId, date);
|
|
118
|
+ LocalDateTime start = DateTimeUtil.formatDateTime(date + " 00:00:00");
|
|
119
|
+ LocalDateTime end = DateTimeUtil.formatDateTime(date + " 23:59:59");
|
|
120
|
+ interval = interval / dilutionVal;
|
|
121
|
+ ArrayList<LocalDateTime[]> dateList = new ArrayList<>();
|
|
122
|
+ while (Duration.between(start.plusMinutes(interval), end).getSeconds() > 0) {
|
|
123
|
+ dateList.add(new LocalDateTime[]{start, start.plusMinutes(interval)});
|
|
124
|
+ start = start.plusMinutes(interval);
|
|
125
|
+ }
|
|
126
|
+ //最多只能补一个,够数了就不用补
|
|
127
|
+ if (dateList.size() < dilutionVal)
|
|
128
|
+ dateList.add(new LocalDateTime[]{start, end});
|
|
129
|
+
|
|
130
|
+ List<YieldRealTime> lis = new ArrayList<>();
|
|
131
|
+ for (LocalDateTime[] item : dateList) {
|
|
132
|
+ LambdaQueryWrapper<YieldRealTime> wrapper = new LambdaQueryWrapper<YieldRealTime>()
|
|
133
|
+ .eq(YieldRealTime::getModuleKey, moduleKey)
|
|
134
|
+ .eq(YieldRealTime::getWellId, wellId)
|
|
135
|
+ .between(YieldRealTime::getProTime, item[0], item[1])
|
|
136
|
+ .last(" limit 1 ");
|
|
137
|
+ YieldRealTime one = yieldRealTimeMapper.selectOne(wrapper);
|
|
138
|
+ if (Objects.nonNull(one)) lis.add(one);
|
|
139
|
+ }
|
|
140
|
+
|
|
141
|
+ return lis;
|
|
142
|
+ }
|
109
|
143
|
|
110
|
144
|
@Override
|
111
|
145
|
public List<YieldRealTime> getYieldRealTimeInfoByWellId(String moduleKey, String wellId, String startdate) {
|
112
|
146
|
|
113
|
|
- LocalDateTime start = DateTimeUtil.formatDateTime(startdate +" 00:00:00");
|
114
|
|
- LocalDateTime end = DateTimeUtil.formatDateTime(startdate +" 23:59:59");
|
|
147
|
+ LocalDateTime start = DateTimeUtil.formatDateTime(startdate + " 00:00:00");
|
|
148
|
+ LocalDateTime end = DateTimeUtil.formatDateTime(startdate + " 23:59:59");
|
115
|
149
|
|
116
|
150
|
LambdaQueryWrapper<YieldRealTime> queryWrapper = new LambdaQueryWrapper<YieldRealTime>()
|
117
|
|
- .eq(YieldRealTime::getModuleKey,moduleKey)
|
118
|
|
- .between(YieldRealTime::getProTime,start,end)
|
119
|
|
- .eq(YieldRealTime::getWellId,wellId)
|
|
151
|
+ .eq(YieldRealTime::getModuleKey, moduleKey)
|
|
152
|
+ .between(YieldRealTime::getProTime, start, end)
|
|
153
|
+ .eq(YieldRealTime::getWellId, wellId)
|
120
|
154
|
.orderByAsc(YieldRealTime::getProTime);
|
121
|
155
|
List<YieldRealTime> maps = yieldRealTimeMapper.selectList(queryWrapper);
|
122
|
156
|
|
123
|
157
|
return maps;
|
124
|
158
|
}
|
125
|
159
|
|
126
|
|
- private Double makeEffectiveMath(Double num,int effect){
|
127
|
|
- return Math.ceil(num*Math.pow(10,effect))/(int)Math.pow(10,effect);
|
|
160
|
+ private Double makeEffectiveMath(Double num, int effect) {
|
|
161
|
+ return Math.ceil(num * Math.pow(10, effect)) / (int) Math.pow(10, effect);
|
128
|
162
|
}
|
129
|
163
|
|
130
|
164
|
@Override
|
|
@@ -132,23 +166,23 @@ public class YieldServiceImpl extends ServicePlusImpl<YieldRealTimeMapper, Yield
|
132
|
166
|
YieldRealTime yieldRealTime = baseMapper.selectOne(new QueryWrapper<YieldRealTime>()
|
133
|
167
|
.eq("module_key", moduleKey)
|
134
|
168
|
.eq("well_id", wellId)
|
135
|
|
- .between("pro_time", DateTimeUtil.formatDate(prodTime).atTime(0,0,0),
|
136
|
|
- DateTimeUtil.formatDate(prodTime).atTime(23,59,59)
|
|
169
|
+ .between("pro_time", DateTimeUtil.formatDate(prodTime).atTime(0, 0, 0),
|
|
170
|
+ DateTimeUtil.formatDate(prodTime).atTime(23, 59, 59)
|
137
|
171
|
)
|
138
|
172
|
.orderByDesc("pro_time")
|
139
|
173
|
.last("limit 1")
|
140
|
174
|
);
|
141
|
175
|
JSONArray ja = new JSONArray();
|
142
|
176
|
if (!Objects.isNull(yieldRealTime)) {
|
143
|
|
- ja.add(infoObj("冲程:", makeEffectiveMath(yieldRealTime.getStroke(),2)+" m","冲次:", makeEffectiveMath(yieldRealTime.getFrequence(),2)));
|
144
|
|
- ja.add(infoObj("泵深:", makeEffectiveMath(yieldRealTime.getPumpDepth(),1)+" m","泵径:", makeEffectiveMath(yieldRealTime.getPumpDiameter(),1)+" mm"));
|
145
|
|
- ja.add(infoObj("动液面:", makeEffectiveMath((yieldRealTime.getPumpDepth() - yieldRealTime.getSubmergence()),1)+" m","含水率:", makeEffectiveMath(yieldRealTime.getMoistureContent(),1) + " %"));
|
146
|
|
- ja.add(infoObj("沉没度:", makeEffectiveMath(yieldRealTime.getSubmergence(),1)+" m","气液比:", makeEffectiveMath(yieldRealTime.getGasLiqRatio(),1)));
|
|
177
|
+ ja.add(infoObj("冲程:", makeEffectiveMath(yieldRealTime.getStroke(), 2) + " m", "冲次:", makeEffectiveMath(yieldRealTime.getFrequence(), 2)));
|
|
178
|
+ ja.add(infoObj("泵深:", makeEffectiveMath(yieldRealTime.getPumpDepth(), 1) + " m", "泵径:", makeEffectiveMath(yieldRealTime.getPumpDiameter(), 1) + " mm"));
|
|
179
|
+ ja.add(infoObj("动液面:", makeEffectiveMath((yieldRealTime.getPumpDepth() - yieldRealTime.getSubmergence()), 1) + " m", "含水率:", makeEffectiveMath(yieldRealTime.getMoistureContent(), 1) + " %"));
|
|
180
|
+ ja.add(infoObj("沉没度:", makeEffectiveMath(yieldRealTime.getSubmergence(), 1) + " m", "气液比:", makeEffectiveMath(yieldRealTime.getGasLiqRatio(), 1)));
|
147
|
181
|
}
|
148
|
182
|
return ja;
|
149
|
183
|
}
|
150
|
184
|
|
151
|
|
- private JSONObject infoObj(String name, Object val,String name2,Object val2) {
|
|
185
|
+ private JSONObject infoObj(String name, Object val, String name2, Object val2) {
|
152
|
186
|
JSONObject obj = new JSONObject();
|
153
|
187
|
obj.put("name", name);
|
154
|
188
|
obj.put("value", val);
|
|
@@ -158,7 +192,7 @@ public class YieldServiceImpl extends ServicePlusImpl<YieldRealTimeMapper, Yield
|
158
|
192
|
}
|
159
|
193
|
|
160
|
194
|
@Override
|
161
|
|
- public Result getYieldResultDisperse(String moduleKey,String wellId, String beginDateTime, String endDateTime, Integer total) {
|
|
195
|
+ public Result getYieldResultDisperse(String moduleKey, String wellId, String beginDateTime, String endDateTime, Integer total) {
|
162
|
196
|
YieldRealTime yieldRealTime = baseMapper.selectOne(new QueryWrapper<YieldRealTime>()
|
163
|
197
|
.eq("module_key", moduleKey)
|
164
|
198
|
.eq("well_id", wellId)
|