xsr il y a 2 ans
Parent
commit
3a78ec0428

+ 1 - 1
pom.xml

@@ -11,7 +11,7 @@
11 11
     <modelVersion>4.0.0</modelVersion>
12 12
 
13 13
     <groupId>com.gct.tool</groupId>
14
-    <artifactId>data-analyse-tool</artifactId>
14
+    <artifactId>data-download-tool</artifactId>
15 15
     <version>0.0.1-SNAPSHOT</version>
16 16
     <name>data_analyse_tool</name>
17 17
     <description>数据分析工具</description>

+ 1 - 1
src/main/Test/MyTest.java

@@ -29,7 +29,7 @@ public class MyTest {
29 29
     @Test
30 30
     public void test() {
31 31
 //        aoidDailyYieldServicel.list(new QueryWrapper<AoidDailyYield>().eq("prod_date::date",LocalDate.parse("2022-09-27")));
32
-        dataAnalyseService.produceLiqAnalyse();
32
+//        dataAnalyseService.produceLiqAnalyse();
33 33
 
34 34
     }
35 35
 }

+ 38 - 0
src/main/java/com/gct/tool/entity/excel/SingleGtData.java

@@ -0,0 +1,38 @@
1
+package com.gct.tool.entity.excel;
2
+
3
+import com.alibaba.excel.annotation.ExcelProperty;
4
+import lombok.AllArgsConstructor;
5
+import lombok.Data;
6
+import lombok.NoArgsConstructor;
7
+
8
+import java.time.LocalDateTime;
9
+
10
+/**
11
+ * @author xusirui 2022/11/3
12
+ */
13
+@Data
14
+@AllArgsConstructor
15
+@NoArgsConstructor
16
+public class SingleGtData {
17
+
18
+    @ExcelProperty("井号")
19
+    public String wellId;
20
+
21
+    @ExcelProperty("生产日期")
22
+    public String prodDate;
23
+
24
+    @ExcelProperty("最大载荷")
25
+    public Double maxLoad;
26
+
27
+    @ExcelProperty("最小载荷")
28
+    public Double minLoad;
29
+
30
+    @ExcelProperty("功图")
31
+    public String workDiagram;
32
+
33
+    @ExcelProperty("功图面积")
34
+    public Double workDiagramArea;
35
+
36
+    @ExcelProperty("分析结果")
37
+    public String analyseResult;
38
+}

+ 76 - 287
src/main/java/com/gct/tool/service/impl/DataAnalyseService.java

@@ -3,34 +3,32 @@ package com.gct.tool.service.impl;
3 3
 import com.alibaba.excel.EasyExcel;
4 4
 import com.alibaba.excel.ExcelWriter;
5 5
 import com.alibaba.excel.write.metadata.WriteSheet;
6
-import com.baomidou.mybatisplus.core.conditions.interfaces.Func;
7 6
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
8 7
 import com.gct.common.util.SGTUtil;
9
-import com.gct.tool.entity.aoid.AoidDailyYield;
10 8
 import com.gct.tool.entity.aoid.AoidSinglegtYield;
11 9
 import com.gct.tool.entity.excel.LiqAnalyseData;
10
+import com.gct.tool.entity.excel.SingleGtData;
12 11
 import com.gct.tool.service.aoid.AoidDailyYieldService;
13 12
 import com.gct.tool.service.aoid.AoidSinglegtYieldService;
14 13
 import com.gct.tool.service.centralbase.CbCdWellSourceService;
15
-import io.swagger.models.auth.In;
16
-import org.apache.commons.lang.StringUtils;
17
-import org.apache.poi.util.StringUtil;
18 14
 import org.springframework.beans.factory.annotation.Autowired;
19 15
 import org.springframework.beans.factory.annotation.Value;
20 16
 import org.springframework.boot.ApplicationArguments;
21 17
 import org.springframework.boot.ApplicationRunner;
22
-import org.springframework.context.ApplicationListener;
18
+import org.springframework.core.io.ClassPathResource;
23 19
 import org.springframework.stereotype.Service;
24 20
 
21
+import java.io.BufferedReader;
25 22
 import java.io.File;
26 23
 import java.io.IOException;
24
+import java.io.InputStreamReader;
27 25
 import java.time.LocalDate;
28
-import java.time.LocalDateTime;
29 26
 import java.time.format.DateTimeFormatter;
30
-import java.util.*;
31
-import java.util.function.Function;
27
+import java.util.ArrayList;
28
+import java.util.Arrays;
29
+import java.util.Comparator;
30
+import java.util.List;
32 31
 import java.util.stream.Collectors;
33
-import java.util.stream.Stream;
34 32
 
35 33
 /**
36 34
  * @author xusirui 2022/9/28
@@ -38,12 +36,15 @@ import java.util.stream.Stream;
38 36
 @Service
39 37
 public class DataAnalyseService implements ApplicationRunner {
40 38
 
41
-    @Value("${produce-date}")
42
-    String produceDate;
43
-
44 39
     @Value("${gt-total}")
45 40
     Integer gtTotal;
46 41
 
42
+    @Value("${begin-date}")
43
+    String beginDate;
44
+
45
+    @Value("${end-date}")
46
+    String endDate;
47
+
47 48
     @Autowired
48 49
     AoidDailyYieldService aoidDailyYieldService;
49 50
 
@@ -62,295 +63,83 @@ public class DataAnalyseService implements ApplicationRunner {
62 63
         if (!file.exists()) file.mkdirs();
63 64
     }
64 65
 
65
-    public void produceLiqAnalyse() {
66
-        String fileName = excelFileBasePath + "liqAnalyse-" + produceDate + ".xlsx";
67
-        File file = new File(fileName);
68
-        if (!file.exists()) {
69
-            try {
70
-                file.createNewFile();
71
-            } catch (IOException e) {
72
-                e.printStackTrace();
73
-            }
66
+    public void produceLiqAnalyseTotal(){
67
+        for(LocalDate date = LocalDate.parse(beginDate);date.isBefore(LocalDate.parse(endDate));date = date.plusMonths(1)){
68
+            produceLiqAnalyseMonth(date);
74 69
         }
75
-
76
-        Map<String, List<String>> wellByWorkArea = cbCdWellSourceService.divideWellByWorkArea();
77
-        HashMap<String, List<String>> copyMap = new HashMap<>();
78
-        copyMap.put("第一采油作业区",wellByWorkArea.get("第一采油作业区"));
79
-        copyMap.put("第二采油作业区",wellByWorkArea.get("第二采油作业区"));
80
-        copyMap.put("第三采油作业区",wellByWorkArea.get("第三采油作业区"));
81
-        wellByWorkArea = copyMap;
82
-
83
-        ExcelWriter excelWriter = EasyExcel.write(fileName, LiqAnalyseData.class).build();
84
-
85
-        wellByWorkArea.forEach((workArea, wellIdList) -> {
86
-            WriteSheet writeSheet = EasyExcel.writerSheet(workArea).build();
87
-
88
-            List<LiqAnalyseData> liqAnalyseDataList = aoidDailyYieldService.list(new QueryWrapper<AoidDailyYield>()
89
-                    .eq("prod_date::date", LocalDate.parse(produceDate))
90
-                    .in("well_id", wellIdList)).stream().map(aoidDailyYield -> {
91
-                LiqAnalyseData liqAnalyseData = new LiqAnalyseData();
92
-                liqAnalyseData.setLiqProd(aoidDailyYield.getLiqProdDaily());
93
-                liqAnalyseData.setLiqProd2(aoidDailyYield.getA2LiqProdDaily());
94
-                liqAnalyseData.setWellId(aoidDailyYield.getWellId());
95
-                liqAnalyseData.setProdDate(aoidDailyYield.getProdDate().format(formatter));
96
-                if (!Objects.isNull(aoidDailyYield.getLiqProdDaily()) && !Objects.isNull(aoidDailyYield.getA2LiqProdDaily())) {
97
-                    if (aoidDailyYield.getA2LiqProdDaily() > 1e-6)
98
-                        liqAnalyseData.setErrorRate(Math.abs(aoidDailyYield.getLiqProdDaily() - aoidDailyYield.getA2LiqProdDaily()) / aoidDailyYield.getA2LiqProdDaily());
99
-                    else liqAnalyseData.setErrorRate(100.0);
100
-                }
101
-                liqAnalyseData.setAoidDailyYield(aoidDailyYield);
102
-                return liqAnalyseData;
103
-            }).filter(liqAnalyseData -> Objects.nonNull(liqAnalyseData.getErrorRate()) && liqAnalyseData.getLiqProd() < 200)
104
-                    .collect(Collectors.toList());
105
-
106
-            liqAnalyseDataList.sort(Comparator.comparingDouble(LiqAnalyseData::getErrorRate));
107
-            // init
108
-            liqAnalyseDataList.forEach(liqAnalyseData -> {
109
-                liqAnalyseData.setAnalyseResult("");
110
-                List<AoidSinglegtYield> aoidSinglegtYieldList = aoidSinglegtYieldService.list(new QueryWrapper<AoidSinglegtYield>()
111
-                        .eq("well_id", liqAnalyseData.getWellId())
112
-                        .between("prod_date", LocalDate.parse(produceDate).minusDays(1).atTime(16, 0, 0),
113
-                                LocalDate.parse(produceDate).atTime(16, 0, 0)));
114
-                liqAnalyseData.setAoidSinglegtYieldList(aoidSinglegtYieldList);
115
-            });
116
-        /*    liqAnalyseDataList.forEach(liqAnalyseData ->
117
-                    liqAnalyseData.setAnalyseResult(liqAnalyseData.analyseResult + judgeIntermittenceOpen(liqAnalyseData.wellId)));
118
-            liqAnalyseDataList.forEach(liqAnalyseData ->
119
-                    liqAnalyseData.setAnalyseResult(liqAnalyseData.analyseResult + judgeRatioUndulate(liqAnalyseData.wellId)));*/
120
-            liqAnalyseDataList.forEach(liqAnalyseData ->
121
-                    liqAnalyseData.setAnalyseResult(liqAnalyseData.analyseResult + judgeZhcAndRcy(liqAnalyseData)));
122
-
123
-            liqAnalyseDataList.forEach(this::calTheoryLiq);
124
-            System.out.println("calculate theory liq success");
125
-            liqAnalyseDataList.forEach(this::calLoadDifferenceVariance);
126
-            System.out.println("calculate load difference variance success");
127
-            liqAnalyseDataList.forEach(this::calYxccVariance);
128
-            System.out.println("calculate effect stroke variance success");
129
-            liqAnalyseDataList.forEach(this::calTheoryLoadDiff);
130
-            System.out.println("calculate theory load difference success");
131
-            excelWriter.write(liqAnalyseDataList, writeSheet);
132
-        });
133
-        excelWriter.finish();
134 70
     }
135 71
 
136
-    public void calTheoryLiq(LiqAnalyseData liqAnalyseData) {
137
-        Double dailyLiq = liqAnalyseData.getAoidDailyYield().getLiqProdDaily();
138
-        if (Objects.isNull(dailyLiq)) {
139
-            return;
140
-        }
141
-        double deltaLiq = 1000;
142
-        for (AoidSinglegtYield aoidSinglegtYield : liqAnalyseData.getAoidSinglegtYieldList()) {
143
-            Double singleLiq = aoidSinglegtYield.getLiqProdDaily();
144
-            if (Objects.nonNull(singleLiq)) {
145
-                if (Math.abs(singleLiq - dailyLiq) < deltaLiq) {
146
-                    deltaLiq = Math.abs(singleLiq - dailyLiq);
147
-                    Double bj = aoidSinglegtYield.getBj();
148
-                    Double yxcc = aoidSinglegtYield.getYxcc();
149
-                    Double cc = aoidSinglegtYield.getFrequence();
150
-                    liqAnalyseData.setTheoryLiqProd(get2EffectMath(1440 * Math.PI * bj * bj / 4 * yxcc * cc / 1e6));
151
-                }
152
-            }
153
-        }
154
-    }
155
-
156
-    public void calTheoryLoadDiff(LiqAnalyseData liqAnalyseData){
157
-        double maxTheoryLoadDiff = 0;
158
-        double minTheoryLoadDiff = 999;
159
-        for (AoidSinglegtYield aoidSinglegtYield : liqAnalyseData.getAoidSinglegtYieldList()) {
160
-            if (aoidSinglegtYield.getSgtIsLegal()!=1)continue;
161
-            Double[][] sgt = SGTUtil.encodeToDoubleArray(aoidSinglegtYield.getSgt());
162
-            Double[] maxStroke = Arrays.stream(sgt).max(Comparator.comparingDouble(x -> x[0])).get();
163
-            double theoryLoadDiff = 0;
164
-            for (double i=0;i<maxStroke[0];i+=0.02){
165
-                double l = i;
166
-                double r = l+0.02;
167
-                List<Double[]> list = Arrays.stream(sgt).filter(x -> l <= x[0] && x[0] < r).collect(Collectors.toList());
168
-                if (list.isEmpty())continue;
169
-                Double maxLoad = list.stream().max(Comparator.comparingDouble(x -> x[1])).get()[1];
170
-                Double minLoad = list.stream().min(Comparator.comparingDouble(x -> x[1])).get()[1];
171
-                theoryLoadDiff = Math.max(theoryLoadDiff,maxLoad-minLoad);
72
+    public List<String> readWellIds(){
73
+        try{
74
+            ClassPathResource resource = new ClassPathResource("wellIds.txt");
75
+            BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()));
76
+            String wellId;
77
+            List<String> wellIds = new ArrayList<>();
78
+            while ((wellId = br.readLine())!=null){
79
+                wellIds.add(wellId);
172 80
             }
173
-            maxTheoryLoadDiff = Math.max(maxTheoryLoadDiff,theoryLoadDiff);
174
-            minTheoryLoadDiff = Math.min(maxTheoryLoadDiff,theoryLoadDiff);
175
-        }
176
-        liqAnalyseData.setMaxTheoryLoadDiff(maxTheoryLoadDiff);
177
-        liqAnalyseData.setMinTheoryLoadDiff(minTheoryLoadDiff);
178
-    }
179
-
180
-    public void calYxccVariance(LiqAnalyseData liqAnalyseData){
181
-        List<Double> yxccs = liqAnalyseData.getAoidSinglegtYieldList()
182
-                .stream()
183
-                .map(AoidSinglegtYield::getYxcc)
184
-                .filter(Objects::nonNull)
185
-                .collect(Collectors.toList());
186
-        Double maxYxcc = 0d;
187
-        for (int i = 0; i < yxccs.size(); i++) {
188
-            if (yxccs.get(i)>maxYxcc)maxYxcc = yxccs.get(i);
81
+            return wellIds;
82
+        }catch (Exception e){
83
+            e.printStackTrace();
189 84
         }
190
-        if (maxYxcc==0)return;
191
-        for (int i = 0; i < yxccs.size(); i++) {
192
-            yxccs.set(i,yxccs.get(i)/maxYxcc*10);
193
-        }
194
-        Double aveYxcc = 0d;
195
-        for (int i = 0; i < yxccs.size(); i++) {
196
-            aveYxcc += yxccs.get(i);
197
-        }
198
-        aveYxcc/=yxccs.size();
199
-        double variance = 0d;
200
-        for (int i = 0; i < yxccs.size(); i++) {
201
-            variance+=(yxccs.get(i)-aveYxcc)*(yxccs.get(i)-aveYxcc);
202
-        }
203
-        variance/=yxccs.size();
204
-        liqAnalyseData.setEffectStrokeVariance(variance);
85
+        return new ArrayList<>();
205 86
     }
206 87
 
207
-    public void calLoadDifferenceVariance(LiqAnalyseData liqAnalyseData) {
208
-        List<Double> loadDiffs = liqAnalyseData.getAoidSinglegtYieldList()
209
-                .stream()
210
-                .map(aoidSinglegtYield -> {
211
-                    if (aoidSinglegtYield.getSgtIsLegal() == 0) return 0d;
212
-                    double[][] sgt = SGTUtil.encodeToUseArray(aoidSinglegtYield.getSgt());
213
-                    double[] maxLoadP = Arrays.stream(sgt).max(Comparator.comparingDouble(x -> x[1])).get();
214
-                    double[] minLoadP = Arrays.stream(sgt).min(Comparator.comparingDouble(x -> x[1])).get();
215
-                    return maxLoadP[1] - minLoadP[1];
216
-                }).collect(Collectors.toList());
217
-        if (loadDiffs.isEmpty()) return;
218
-        Double maxloadDiff = 0d;
219
-        for (int i = 0; i < loadDiffs.size(); i++) {
220
-            if (loadDiffs.get(i) > maxloadDiff) maxloadDiff = loadDiffs.get(i);
221
-        }
222
-        if (maxloadDiff == 0) return;
223
-        liqAnalyseData.setMaxLoadDiff(maxloadDiff);
224
-        liqAnalyseData.setPumpDepth(liqAnalyseData.getAoidDailyYield().getBs());
225
-        liqAnalyseData.setSubmergenceDegree(liqAnalyseData.getAoidDailyYield().getCmd());
226
-        for (int i = 0; i < loadDiffs.size(); i++) {
227
-            loadDiffs.set(i, loadDiffs.get(i) / maxloadDiff * 10);
228
-        }
229
-        Double aveLoadDiff = 0d;
230
-        for (int i = 0; i < loadDiffs.size(); i++) {
231
-            aveLoadDiff += loadDiffs.get(i);
232
-        }
233
-        aveLoadDiff /= loadDiffs.size();
234
-        double variance = 0;
235
-        for (int i = 0; i < loadDiffs.size(); i++) {
236
-            variance += (loadDiffs.get(i) - aveLoadDiff) * (loadDiffs.get(i) - aveLoadDiff);
237
-        }
238
-        variance /= loadDiffs.size();
239
-        liqAnalyseData.setLoadDifferenceVariance(get2EffectMath(variance));
240
-    }
241
-
242
-    private <T> List<T> getNonNullList(List<AoidSinglegtYield> list, Function<? super AoidSinglegtYield, T> getFun) {
243
-        return list.stream().map(getFun).filter(Objects::nonNull).collect(Collectors.toList());
244
-    }
245
-
246
-    private Double get2EffectMath(Double num) {
247
-        return Double.parseDouble(String.format("%.2f", num));
248
-    }
249
-
250
-    public String judgeIntermittenceOpen(String wellId) {
251
-
252
-        List<AoidSinglegtYield> list = aoidSinglegtYieldService.list(new QueryWrapper<AoidSinglegtYield>()
253
-                .eq("well_id", wellId)
254
-                .between("prod_date", LocalDate.parse(produceDate).minusDays(7).atTime(23, 59, 59),
255
-                        LocalDate.parse(produceDate).atTime(23, 59, 59)));
256
-        Map<LocalDate, Integer> map = new TreeMap<>((date1, date2) -> {
257
-            if (date1.isBefore(date2)) return -1;
258
-            if (date1.isAfter(date2)) return 1;
259
-            return 0;
260
-        });
261
-        list.forEach(aoidSinglegtYield -> {
262
-            LocalDate date = aoidSinglegtYield.getProdDate().toLocalDate();
263
-            map.putIfAbsent(date, 0);
264
-            if (aoidSinglegtYield.getStroke() != 0 && !StringUtils.isBlank(aoidSinglegtYield.getSgt())) {
265
-                map.put(date, map.get(date) + 1);
266
-            }
267
-        });
268
-        Integer[] counts = map.entrySet().stream().map(entry -> entry.getValue()).collect(Collectors.toList()).toArray(new Integer[]{});
269
-        for (int i = 0; i < counts.length; i++) {
270
-            if (counts[i] < gtTotal) counts[i] = 1;
271
-            else counts[i] = 0;
272
-            if (i >= 2 && counts[i] + counts[i - 1] + counts[i - 2] == 3) return "间开;";
273
-        }
274
-        return "";
275
-    }
276
-
277
-    public String judgeRatioUndulate(String wellId) {
278
-        List<AoidSinglegtYield> list = aoidSinglegtYieldService.list(new QueryWrapper<AoidSinglegtYield>()
279
-                .eq("well_id", wellId)
280
-                .eq("prod_date::date", LocalDate.parse(produceDate)));
281
-        String ans = "";
282
-        for (int i = 0; i < list.size(); i++) {
283
-            AoidSinglegtYield aoidSinglegtYield = list.get(i);
284
-
285
-            if (aoidSinglegtYield.getBdxs() > 2 || aoidSinglegtYield.getBdxs() < 0.1) {
286
-                ans += "标定系数异常;";
287
-                break;
88
+    public void produceLiqAnalyseMonth(LocalDate beginDate) {
89
+        String fileName = excelFileBasePath + "功图数据-" + beginDate.format(DateTimeFormatter.ofPattern("yyyy-MM")) + ".xlsx";
90
+        File file = new File(fileName);
91
+        if (!file.exists()) {
92
+            try {
93
+                file.createNewFile();
94
+            } catch (IOException e) {
95
+                e.printStackTrace();
288 96
             }
289 97
         }
290
-
291
-        List<Double> bdxss = list.stream().map(AoidSinglegtYield::getBdxs).filter(Objects::nonNull).collect(Collectors.toList());
292
-        if (bdxss.isEmpty()) ans += "标定系数缺失";
293
-        else {
294
-            Double maxBdxs = bdxss.stream().max(Double::compare).get();
295
-            Double minBdxs = bdxss.stream().min(Double::compare).get();
296
-            if (maxBdxs - minBdxs > 0.1) ans += "标定系数变化;";
297
-        }
298
-
299
-        List<Double> yxccs = list.stream().map(AoidSinglegtYield::getYxcc).filter(Objects::nonNull).collect(Collectors.toList());
300
-        if (yxccs.isEmpty()) {
301
-            ans += "部分有效冲程无法计算;";
302
-        } else {
303
-            Double maxYxcc = yxccs.stream().max(Double::compare).get();
304
-            Double minYxcc = yxccs.stream().min(Double::compare).get();
305
-            if (maxYxcc - minYxcc > maxYxcc * 0.5) ans += "供液不稳;";
306
-        }
307
-
308
-        return ans;
309
-    }
310
-
311
-    public String judgeZhcAndRcy(LiqAnalyseData liqAnalyseData) {
312
-        String ans = "";
313
-        List<AoidSinglegtYield> list = liqAnalyseData.getAoidSinglegtYieldList();
314
-
315
-        List<Double> loadDiffs = liqAnalyseData.getAoidSinglegtYieldList()
316
-                .stream()
317
-                .map(aoidSinglegtYield -> {
318
-                    if (aoidSinglegtYield.getSgtIsLegal() == 0) return 0d;
319
-                    double[][] sgt = SGTUtil.encodeToUseArray(aoidSinglegtYield.getSgt());
320
-                    double[] maxLoadP = Arrays.stream(sgt).max(Comparator.comparingDouble(x -> x[1])).get();
321
-                    double[] minLoadP = Arrays.stream(sgt).min(Comparator.comparingDouble(x -> x[1])).get();
322
-                    return maxLoadP[1] - minLoadP[1];
323
-                }).collect(Collectors.toList());
324
-        if (loadDiffs.isEmpty()) ans += "载荷差缺失";
325
-        else {
326
-            Double maxLoadDiff = loadDiffs.stream().max(Double::compare).get();
327
-            Double minLoadDiff = loadDiffs.stream().min(Double::compare).get();
328
-
329
-            if (maxLoadDiff * 0.6 > minLoadDiff && maxLoadDiff - minLoadDiff > 4) ans += "载荷差波动超过40%;";
330
-            else if (maxLoadDiff * 0.7 > minLoadDiff && maxLoadDiff - minLoadDiff > 3) ans += "载荷差波动超过30%;";
331
-            else if (maxLoadDiff * 0.8 > minLoadDiff && maxLoadDiff - minLoadDiff > 2) ans += "载荷差波动超过20%;";
332
-        }
333
-
334
-        List<Double> liqProds = list.stream().map(AoidSinglegtYield::getLiqProdDaily).filter(Objects::nonNull).collect(Collectors.toList());
335
-        if (loadDiffs.isEmpty()) ans += "液量缺失";
336
-        else {
337
-            Double maxSingleRcl = liqProds.stream().max(Double::compare).get();
338
-            Double minSingleRcl = liqProds.stream().min(Double::compare).get();
339
-
340
-            if (maxSingleRcl * 0.6 > minSingleRcl && maxSingleRcl - minSingleRcl > 1.2) ans += "单张功图液量波动超过40%;";
341
-            else if (maxSingleRcl * 0.7 > minSingleRcl && maxSingleRcl - minSingleRcl > 0.9) ans += "单张功图液量波动超过30%;";
342
-            else if (maxSingleRcl * 0.8 > minSingleRcl && maxSingleRcl - minSingleRcl > 0.6) ans += "单张功图液量波动超过20%;";
343
-            else if (maxSingleRcl * 0.9 > minSingleRcl && maxSingleRcl - minSingleRcl > 0.3) ans += "单张功图液量波动超过10%;";
98
+        ExcelWriter excelWriter = EasyExcel.write(fileName, SingleGtData.class).build();
99
+        List<String> wellIds = readWellIds();
100
+        for (LocalDate date = beginDate;date.isBefore(beginDate.plusMonths(1));date = date.plusDays(1)){
101
+            System.out.println(date.format(DateTimeFormatter.ISO_LOCAL_DATE));
102
+            final LocalDate produceDate = date;
103
+                WriteSheet writeSheet = EasyExcel.writerSheet("第二采油作业区").build();
104
+                List<SingleGtData> singleGtDatas = aoidSinglegtYieldService.list(new QueryWrapper<AoidSinglegtYield>()
105
+                        .eq("prod_date::date", produceDate)
106
+                        .in("well_id",wellIds))
107
+                        .stream()
108
+                        .filter(aoidSinglegtYield -> aoidSinglegtYield.getSgtIsLegal() == 1)
109
+                        .map(aoidSinglegtYield -> {
110
+                            SingleGtData singleGtData = new SingleGtData();
111
+                            singleGtData.setProdDate(aoidSinglegtYield.getProdDate().format(formatter));
112
+                            singleGtData.setWorkDiagram(aoidSinglegtYield.getSgt());
113
+                            double[][] sgt = SGTUtil.encodeToUseArray(aoidSinglegtYield.getSgt());
114
+                            double[] maxLoadP = Arrays.stream(sgt).max(Comparator.comparingDouble(x -> x[1])).get();
115
+                            double[] minLoadP = Arrays.stream(sgt).min(Comparator.comparingDouble(x -> x[1])).get();
116
+                            singleGtData.setMaxLoad(maxLoadP[1]);
117
+                            singleGtData.setMinLoad(minLoadP[1]);
118
+                            singleGtData.setWellId(aoidSinglegtYield.getWellId());
119
+                            singleGtData.setAnalyseResult(aoidSinglegtYield.getEczdjg());
120
+                            double s = 0;
121
+                            for (int i = 0; i < sgt.length / 2 - 1; i++) {
122
+                                double h = Math.abs(sgt[i][0] - sgt[i + 1][0]);
123
+                                double Si = (sgt[i][1] + sgt[i + 1][1]) * h / 2.0;
124
+                                s += Si;
125
+                            }
126
+                            for (int i = sgt.length / 2 - 1; i < sgt.length - 1; i++) {
127
+                                double h = Math.abs(sgt[i][0] - sgt[i + 1][0]);
128
+                                double Si = (sgt[i][1] + sgt[i + 1][1]) * h / 2.0;
129
+                                s -= Si;
130
+                            }
131
+                            singleGtData.setWorkDiagramArea(s);
132
+                            return singleGtData;
133
+                        }).collect(Collectors.toList());
134
+                excelWriter.write(singleGtDatas, writeSheet);
344 135
         }
345
-
346
-
347
-        return ans;
136
+        excelWriter.finish();
348 137
     }
349 138
 
350 139
 
351 140
     @Override
352 141
     public void run(ApplicationArguments args) throws Exception {
353
-        produceLiqAnalyse();
142
+        produceLiqAnalyseTotal();
354 143
         System.exit(0);
355 144
     }
356 145
 }

+ 3 - 2
src/main/resources/application-dev.yml

@@ -55,5 +55,6 @@ swagger:
55 55
     key-name: token
56 56
   enabled: true
57 57
 
58
-produce-date: 2022-09-27
59
-gt-total: 48
58
+gt-total: 48
59
+begin-date: 2022-05-01
60
+end-date: 2022-11-01

+ 3 - 2
src/main/resources/application-pro.yml

@@ -55,5 +55,6 @@ swagger:
55 55
     key-name: token
56 56
   enabled: true
57 57
 
58
-produce-date: 2022-10-25
59
-gt-total: 24
58
+gt-total: 24
59
+begin-date: 2022-05-01
60
+end-date: 2022-11-01

+ 100 - 0
src/main/resources/wellIds.txt

@@ -0,0 +1,100 @@
1
+0004
2
+0010
3
+0016A
4
+0023
5
+00251
6
+00252
7
+0028
8
+0030
9
+0031
10
+0035
11
+0036
12
+0037
13
+0039
14
+0041
15
+00453
16
+0047
17
+0051
18
+0055
19
+0059
20
+0064
21
+0068
22
+0070
23
+0073
24
+0079
25
+0083
26
+0084
27
+0089
28
+0090
29
+0095
30
+0207
31
+0208
32
+0209
33
+0211
34
+0213
35
+0218
36
+0605
37
+0608
38
+0616
39
+0617
40
+0706
41
+0708
42
+0709
43
+0781
44
+0912
45
+0913
46
+0914
47
+7601
48
+7603
49
+7608
50
+CH0405
51
+CH0507
52
+CH0509
53
+CH21008
54
+CH21076
55
+CH21077
56
+CH35001
57
+CH35004
58
+CH35014
59
+CH35015
60
+CH35026
61
+CH35027
62
+CH3505
63
+CH3507
64
+CH3508
65
+CH3516
66
+CH7209
67
+CH7244
68
+CHD35007
69
+h0113
70
+h0115
71
+h0117
72
+h0118
73
+h0120
74
+h0124
75
+h0126
76
+h0127
77
+h0128
78
+h0131
79
+h0133
80
+h0143
81
+h0145
82
+h0155
83
+h0156
84
+h0161
85
+h0164
86
+h0169
87
+h0174
88
+h0203
89
+h0225
90
+h0226
91
+h0229
92
+h0239
93
+h0542
94
+h0546
95
+h0549
96
+h0552
97
+h0554
98
+h0558
99
+h0559
100
+h0570