xusirui před 1 rokem
rodič
revize
cb81d2f804

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

@@ -25,7 +25,7 @@ public class MyTest {
25 25
 
26 26
     @Test
27 27
     public void test() {
28
-        loadBaseDataService.loadCdWellSource();
28
+        loadBaseDataService.loadWorkDiagramData();
29 29
 //        cbPcProWellboreVolDailyMapper.selectList(new QueryWrapper<>());
30 30
     }
31 31
 

+ 6 - 1
src/main/java/com/gct/tool/feign/DataBankClient.java

@@ -16,7 +16,12 @@ public interface DataBankClient {
16 16
     /*
17 17
     http://tlmdatabank.tlm.pcep.cloud/api/dde/
18 18
      */
19
-    @PostMapping(value = "governdataservice/struct/OP_PRO_COMPLETION_VOL_DAILY/query")
19
+    @PostMapping(value = "governdataservice/struct/OP_PROD_WELL_PROD_DAILY/query")
20 20
     JSONObject getVolDailyData(@RequestBody Map query, @RequestParam int page,@RequestParam int size,@RequestParam String identity);
21 21
 
22
+    @PostMapping(value = "subjectdataservice/X_OP_PRO_WELL_VOL_DAILY")
23
+    JSONObject getStatusDailyData(@RequestBody Map query, @RequestParam int page,@RequestParam int size,@RequestParam String identity);
24
+
25
+
26
+
22 27
 }

+ 16 - 0
src/main/java/com/gct/tool/feign/WorkDiagramClient.java

@@ -0,0 +1,16 @@
1
+package com.gct.tool.feign;
2
+
3
+import com.alibaba.fastjson.JSONObject;
4
+import org.springframework.cloud.openfeign.FeignClient;
5
+import org.springframework.web.bind.annotation.PostMapping;
6
+import org.springframework.web.bind.annotation.RequestBody;
7
+import org.springframework.web.bind.annotation.RequestParam;
8
+
9
+import java.util.Map;
10
+
11
+@FeignClient(url = "10.79.1.252:9101/itl_tycjpt/dataBySql", name = "work-diagram-client")
12
+public interface WorkDiagramClient {
13
+
14
+    @PostMapping(value = "/getDataBySqlQuery")
15
+    String getWorkDiagramData(@RequestParam String sqlstring);
16
+}

+ 1 - 21
src/main/java/com/gct/tool/mapper/centralbase/CbCdWellSourceMapper.java

@@ -3,7 +3,7 @@ package com.gct.tool.mapper.centralbase;
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
-import com.gct.centralbase.entity.CbCdWellSource;
6
+import com.gct.tool.entity.centralbase.CbCdWellSource;
7 7
 import org.apache.ibatis.annotations.Mapper;
8 8
 import org.apache.ibatis.annotations.Param;
9 9
 
@@ -21,25 +21,5 @@ import java.util.Map;
21 21
 @Mapper
22 22
 public interface CbCdWellSourceMapper extends BaseMapper<CbCdWellSource> {
23 23
 
24
-    List<CbCdWellSource> selectWellSourceList(@Param("orgIds") List<String> orgIds);
25
-
26
-    List<CbCdWellSource> getjhAll();
27
-    List<CbCdWellSource> getjhAllByorgid(@Param("orgid") String orgid);
28
-    Page<Map<String,Object>> getAllWellSourceList(@Param("page") IPage<Map<String,Object>> page, @Param("sql") String sql);
29
-
30
-    /**
31
-     * 根据井号查询稠油井信息
32
-     * @param wellName
33
-     * @return
34
-     */
35
-    CbCdWellSource getByWellId_Heavy(@Param("wellName") String wellName);
36
-
37
-
38
-
39
-    //查询所有井用于分析误差率
40
-    List<CbCdWellSource> getjhAllYieldError();
41
-
42
-    List<CbCdWellSource> getjhAllConent();
43
-
44 24
 
45 25
 }

+ 2 - 49
src/main/java/com/gct/tool/mapper/centralbase/CbCdWellSourceMapper.xml

@@ -1,11 +1,9 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
-<mapper namespace="com.gct.centralbase.mapper.CbCdWellSourceMapper">
4
-
5
-    <cache flushInterval="60000" size="5096"/>
3
+<mapper namespace="com.gct.tool.mapper.centralbase.CbCdWellSourceMapper">
6 4
 
7 5
     <!-- 通用查询映射结果 -->
8
-    <resultMap id="BaseResultMap" type="com.gct.centralbase.entity.CbCdWellSource">
6
+    <resultMap id="BaseResultMap" type="com.gct.tool.entity.centralbase.CbCdWellSource">
9 7
         <result column="well_id" property="wellId"/>
10 8
         <result column="well_common_name" property="wellCommonName"/>
11 9
         <result column="well_legal_name" property="wellLegalName"/>
@@ -36,51 +34,6 @@
36 34
     </resultMap>
37 35
 
38 36
 
39
-    <select id="selectWellSourceList" resultType="com.gct.centralbase.entity.CbCdWellSource">
40
-        select "u"."well_common_name" from "centralbase"."cb_cd_well_source" "u"
41
-        -- LEFT JOIN sys_user_role r ON u.id = r.user_id
42
-        -- left join sys_user_dept d on u.id = d.user_id
43
-        <where>
44
-            <if test="orgIds != null  and orgIds != ''">
45
-                and "u"."org_id" in
46
-                <foreach collection="orgIds" item="org_id" index="index" open="(" close=")" separator=",">
47
-                    #{org_id}
48
-                </foreach>
49
-            </if>
50
-        </where>
51
-    </select>
52
-    <select id="getAllWellSourceList" resultType="java.util.Map">
53
-        ${sql}
54
-    </select>
55
-
56
-    <select id="getjhAll" resultType="com.gct.centralbase.entity.CbCdWellSource">
57
-        select * from centralbase.cb_cd_well_source where (station_id
58
-         like '%红浅%' or station_id like '%六采%' or station_id like '%五采%' or station_id like '%特采%' )
59
-    </select>
60
-
61
-    <select id="getjhAllByorgid" resultType="com.gct.centralbase.entity.CbCdWellSource">
62
-        select * from centralbase.cb_cd_well_source where org_id =#{orgid}
63
-    </select>
64
-
65
-    <select id="getByWellId_Heavy" resultType="com.gct.centralbase.entity.CbCdWellSource">
66
-        select * from centralbase.cb_cd_well_source where well_id =#{wellName} and (station_id
67
-         like '%红浅%' or station_id like '%六采%' or station_id like '%五采%' or station_id like '%特采%' )
68
-    </select>
69
-
70
-
71
-    <select id="getjhAllYieldError" resultType="com.gct.centralbase.entity.CbCdWellSource">
72
-        select * from centralbase.cb_cd_well_source where (station_id
73
-         like '%一采%' or station_id like '%二采%' or station_id like '%三采%')
74
-    </select>
75
-
76
-
77
-    <select id="getjhAllConent" resultType="com.gct.centralbase.entity.CbCdWellSource">
78
-        select * from centralbase.cb_cd_well_source
79
-    </select>
80
-
81
-
82
-
83
-
84 37
 
85 38
 </mapper>
86 39
 

+ 114 - 10
src/main/java/com/gct/tool/service/LoadBaseDataService.java

@@ -1,22 +1,34 @@
1 1
 package com.gct.tool.service;
2 2
 
3
+import com.alibaba.fastjson.JSON;
3 4
 import com.alibaba.fastjson.JSONArray;
4 5
 import com.alibaba.fastjson.JSONObject;
6
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
7
+import com.gct.tool.entity.centralbase.CbCdWellSource;
8
+import com.gct.tool.entity.centralbase.CbPcProWellboreVolDaily;
5 9
 import com.gct.tool.entity.sql.QueryBody;
6 10
 import com.gct.tool.feign.DataBankClient;
7 11
 import com.gct.tool.feign.DataBankTokenClient;
12
+import com.gct.tool.feign.WorkDiagramClient;
13
+import com.gct.tool.mapper.centralbase.CbCdWellSourceMapper;
14
+import com.gct.tool.mapper.centralbase.CbPcProWellboreVolDailyMapper;
8 15
 import lombok.extern.slf4j.Slf4j;
16
+import org.mockito.internal.util.StringUtil;
9 17
 import org.springframework.beans.factory.annotation.Autowired;
10 18
 import org.springframework.stereotype.Service;
19
+import org.springframework.util.StringUtils;
11 20
 
12
-import java.sql.SQLOutput;
21
+import java.time.LocalDateTime;
22
+import java.time.format.DateTimeFormatter;
13 23
 import java.util.*;
24
+import java.util.stream.Collectors;
14 25
 
15 26
 @Service
16 27
 @Slf4j
17 28
 public class LoadBaseDataService {
18 29
 
19
-    final String identity = "CDF03A45C9BF4D9B85155364FAAEE08C14D85F6D51774A59GMXF6MBQG4ZDOKZXL4YF6KZSGEZGEKZWMBQTMKZVL43WCYJVG4XWCMLDGUXT22DKO43TAZ3CMYXXEL3AMFWWWN3ROFXGEZZSONYDAMBTGEYTKLRVGEZTONZXFYXTAMBSF4YDAMQ";
30
+    final String governDataServiceIdentity = "CDF03A45C9BF4D9B85155364FAAEE08C14D85F6D51774A59GMXF6MBQG4ZDOKZXL4YF6KZSGEZGEKZWMBQTMKZVL43WCYJVG4XWCMLDGUXT22DKO43TAZ3CMYXXEL3AMFWWWN3ROFXGEZZSONYDAMBTGEYTKLRVGEZTONZXFYXTAMBSF4YDAMQ";
31
+    final String sharedDataServiceIdentity = "77ACF8C095A94D3CA3474B9561FEA62D352F67FAE44AF04CMA2TGLZPMJPTGKZUF4XTIKZSGRRDGK27MIZGAKZOF5RDGNZTGBQS4YRWF4XT2NDFGZ2DCNLIFYYXEY3XMBVG4NRSNR4DGZTEMRWTAMBTGEZC4MBQGUXTONZXFYXTAMBSF4YDAMQ";
20 32
 
21 33
     @Autowired
22 34
     BaseResourceService baseResourceService;
@@ -26,12 +38,22 @@ public class LoadBaseDataService {
26 38
     @Autowired
27 39
     DataBankTokenClient tokenClient;
28 40
 
29
-    private void printMap(Object o,boolean isPrintNull,Set<String>filterSet){
30
-        ((Map)o).forEach((k,v)->{
31
-            if ((isPrintNull || Objects.nonNull(v))&&(Objects.isNull(filterSet)|| filterSet.contains(k)))
32
-                System.out.printf("%s:%s\n",k,v);
41
+    @Autowired
42
+    WorkDiagramClient workDiagramClient;
43
+
44
+    @Autowired
45
+    CbCdWellSourceMapper cbCdWellSourceMapper;
46
+
47
+    @Autowired
48
+    CbPcProWellboreVolDailyMapper cbPcProWellboreVolDailyMapper;
49
+
50
+    private void printMap(Object o, boolean isPrintNull, Set<String> filterSet) {
51
+        ((Map) o).forEach((k, v) -> {
52
+            if ((isPrintNull || Objects.nonNull(v)) && (Objects.isNull(filterSet) || filterSet.contains(k)))
53
+                System.out.printf("%s:%s\n", k, v);
33 54
         });
34 55
     }
56
+
35 57
     /**
36 58
      * @return
37 59
      */
@@ -43,24 +65,106 @@ public class LoadBaseDataService {
43 65
         wellIds.forEach(wellId -> {
44 66
             QueryBody queryBody = new QueryBody();
45 67
             queryBody.select("TL").eq("WELL_LEGAL_NAME", wellId);
46
-            JSONObject object = dataBankClient.getCdWellData(queryBody.toJsonMap(), 0, 10, identity);
68
+            JSONObject object = dataBankClient.getCdWellData(queryBody.toJsonMap(), 0, 10, governDataServiceIdentity);
47 69
             System.out.println(object);
48 70
             JSONArray array = object.getJSONObject("resultData").getJSONArray("content");
49 71
 //            ((Map) array.get(0)).forEach((k,v)-> System.out.printf(k+","));
50 72
             System.out.println("");
51 73
             array.forEach(o -> {
52
-                printMap(o,false,null);
74
+                printMap(o, false, null);
53 75
 //                System.out.printf("%s,%s\n",((Map) o).get("WELL_LEGAL_NAME"),((Map) o).get("WELL_ID"));
54 76
             });
55 77
         });
56 78
     }
57 79
 
58
-    public void loadVolDailyData(){
80
+    public void loadVolDailyData() {
81
+        List<CbCdWellSource> cbCdWellSources = cbCdWellSourceMapper.selectList(new QueryWrapper<>());
82
+        cbCdWellSources.forEach(cbCdWellSource -> {
83
+            QueryBody queryBody = new QueryBody();
84
+            String dateStr = LocalDateTime.now().minusDays(3).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
85
+            queryBody.select("TL").eq("WELL_ID", cbCdWellSource.getWellId()).gt("PROD_DATE", dateStr);
86
+            JSONObject object = dataBankClient.getVolDailyData(queryBody.toJsonMap(), 0, 5, governDataServiceIdentity);
87
+            JSONArray array = object.getJSONObject("resultData").getJSONArray("content");
88
+            for (int i = 0; i < array.size(); i++) {
89
+                JSONObject volDailyJson = array.getJSONObject(i);
90
+                CbPcProWellboreVolDaily volDaily = volDailyJson.toJavaObject(CbPcProWellboreVolDaily.class);
91
+                volDaily.setWaterCut(volDailyJson.getDouble("WATER_CUT_RATIO"));
92
+                QueryWrapper<CbPcProWellboreVolDaily> wrapper = new QueryWrapper<CbPcProWellboreVolDaily>()
93
+                        .eq("well_id", volDaily.getWellId())
94
+                        .eq("prod_date", volDaily.getProdDate());
95
+                if (Objects.isNull(cbPcProWellboreVolDailyMapper.selectOne(wrapper))) {
96
+                    cbPcProWellboreVolDailyMapper.insert(volDaily);
97
+                } else {
98
+                    cbPcProWellboreVolDailyMapper.update(volDaily, wrapper);
99
+                }
100
+            }
59 101
 
102
+        });
60 103
     }
61 104
 
62
-    public void loadStatusDailyData(){
105
+    public void loadStatusDailyData() {
106
+        List<CbCdWellSource> cbCdWellSources = cbCdWellSourceMapper.selectList(new QueryWrapper<>());
107
+        cbCdWellSources = cbCdWellSources.subList(0, 1);
108
+        cbCdWellSources.forEach(cbCdWellSource -> {
109
+            QueryBody queryBody = new QueryBody();
110
+            String dateStr = LocalDateTime.now().minusDays(365).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
111
+            queryBody.select("TL").eq("WELL_ID", cbCdWellSource.getWellId());
112
+//            queryBody.select("TL");
113
+            JSONObject object = dataBankClient.getStatusDailyData(queryBody.toJsonMap(), 0, 500, sharedDataServiceIdentity);
114
+            JSONArray array = object.getJSONObject("resultData").getJSONArray("content");
115
+            HashSet<String> filterSet = new HashSet<>();
116
+            filterSet.add("OIL_NOZZLE");
117
+            filterSet.add("START_PUMP_DEPTH");
118
+            filterSet.add("START_PUMP_LIQ_LEVEL");
119
+            filterSet.add("END_PUMP_DEPTH");
120
+            filterSet.add("END_PUMP_LIQ_LEVEL");
121
+            array.forEach(o -> printMap(o, true, null));
122
+//            for (int i = 0; i < array.size(); i++) {
123
+//                JSONObject volDailyJson = array.getJSONObject(i);
124
+//                CbPcProWellboreVolDaily volDaily = volDailyJson.toJavaObject(CbPcProWellboreVolDaily.class);
125
+//                volDaily.setWaterCut(volDailyJson.getDouble("WATER_CUT_RATIO"));
126
+//                QueryWrapper<CbPcProWellboreVolDaily> wrapper = new QueryWrapper<CbPcProWellboreVolDaily>()
127
+//                        .eq("well_id", volDaily.getWellId())
128
+//                        .eq("prod_date", volDaily.getProdDate());
129
+//                if (Objects.isNull( cbPcProWellboreVolDailyMapper.selectOne(wrapper))){
130
+//                    cbPcProWellboreVolDailyMapper.insert(volDaily);
131
+//                } else {
132
+//                    cbPcProWellboreVolDailyMapper.update(volDaily,wrapper);
133
+//                }
134
+//            }
135
+        });
136
+    }
63 137
 
138
+    private JSONArray executeRemoteSql(String sqlString){
139
+        System.out.println(sqlString);
140
+        String res = workDiagramClient.getWorkDiagramData(sqlString);
141
+        res=res.replace("\\","");
142
+        res=res.substring(1,res.length()-1);
143
+        JSONObject selectMaxTimeJson = JSONObject.parseObject(res);
144
+        return selectMaxTimeJson.getJSONArray("dataList");
64 145
     }
65 146
 
147
+    public void loadWorkDiagramData(){
148
+        List<CbCdWellSource> cbCdWellSources = cbCdWellSourceMapper.selectList(new QueryWrapper<>());
149
+        cbCdWellSources = cbCdWellSources.subList(0, 1);
150
+        cbCdWellSources.forEach(cbCdWellSource -> {
151
+            String selectNearlyWorkDiagramSqlStr = String.format(
152
+                            "select * from PC_FD_PUMPJACK_DYNA_DIA_T@A11gxk where DYNA_CREATE_TIME =  " +
153
+                            "(select max(DYNA_CREATE_TIME) from PC_FD_PUMPJACK_DYNA_DIA_T@A11gxk where WELL_COMMON_NAME = '%s')" +
154
+                            "and WELL_COMMON_NAME = '%s'",
155
+                    cbCdWellSource.getWellLegalName(),cbCdWellSource.getWellLegalName());
156
+            JSONObject nearlyWorkDiagram = executeRemoteSql(selectNearlyWorkDiagramSqlStr).getJSONObject(0);
157
+            String displacement = nearlyWorkDiagram.getString("DISPLACEMENT");
158
+            String load = nearlyWorkDiagram.getString("DISP_LOAD");
159
+            List<Double[]> sgt = new ArrayList<>();
160
+            List<Double> dispacementList = Arrays.stream(displacement.split(";")).map(Double::parseDouble).collect(Collectors.toList());
161
+            List<Double> loadList = Arrays.stream(load.split(";")).map(Double::parseDouble).collect(Collectors.toList());
162
+            for (int i=0;i<Math.min(dispacementList.size(),loadList.size());i++){
163
+                sgt.add(new Double[]{dispacementList.get(i),loadList.get(i)});
164
+            }
165
+            Double stroke = Double.parseDouble(nearlyWorkDiagram.getString("STROKE"));
166
+            Double frequency = Double.parseDouble(nearlyWorkDiagram.getString("FREQUENCY"));
167
+
168
+        });
169
+    }
66 170
 }