Browse Source

add wellsource struct

xsr 1 year ago
parent
commit
04768f6a11

+ 3 - 5
src/main/java/com/gct/tool/entity/centralbase/CbTempWellMechRuntime.java

@@ -2,11 +2,6 @@ package com.gct.tool.entity.centralbase;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.TableName;
4 4
 import com.baomidou.mybatisplus.extension.activerecord.Model;
5
-
6
-import java.lang.reflect.Field;
7
-import java.time.LocalDateTime;
8
-import java.io.Serializable;
9
-
10 5
 import com.fasterxml.jackson.annotation.JsonFormat;
11 6
 import io.swagger.annotations.ApiModel;
12 7
 import io.swagger.annotations.ApiModelProperty;
@@ -14,6 +9,9 @@ import lombok.Data;
14 9
 import lombok.EqualsAndHashCode;
15 10
 import lombok.experimental.Accessors;
16 11
 
12
+import java.io.Serializable;
13
+import java.time.LocalDateTime;
14
+
17 15
 /**
18 16
  * <p>
19 17
  * 机采数据 runtime

+ 29 - 0
src/main/java/com/gct/tool/mapper/centralbase/CbTempWellMechRuntimeMapper.java

@@ -0,0 +1,29 @@
1
+package com.gct.tool.mapper.centralbase;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.gct.centralbase.entity.CbTempWellMechRuntime;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.time.LocalDateTime;
9
+import java.util.List;
10
+
11
+/**
12
+ * <p>
13
+ * 机采数据 runtime Mapper 接口
14
+ * </p>
15
+ *
16
+ * @author wsy
17
+ * @since 2021-01-19
18
+ */
19
+@Mapper
20
+public interface CbTempWellMechRuntimeMapper extends BaseMapper<CbTempWellMechRuntime> {
21
+
22
+
23
+    List getErrorData(@Param("localDateTime") LocalDateTime localDateTime);
24
+
25
+    List getErrorDataInfo(@Param("prodDate") LocalDateTime prodDate);
26
+
27
+    void createTableWithCbRunTime(@Param("startDate") String startDate,@Param("endDate") String endDate);
28
+    void testRuntime(@Param("p1") String p1,@Param("p2") String p2);
29
+}

+ 75 - 0
src/main/java/com/gct/tool/mapper/centralbase/CbTempWellMechRuntimeMapper.xml

@@ -0,0 +1,75 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
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.CbTempWellMechRuntimeMapper">
4
+
5
+    <cache flushInterval="6000000" size="5096"/>
6
+
7
+    <!-- 通用查询映射结果 -->
8
+    <resultMap id="BaseResultMap" type="com.gct.centralbase.entity.CbTempWellMechRuntime">
9
+        <result column="well_id" property="wellId" />
10
+        <result column="prod_date" property="prodDate" />
11
+        <result column="theo_discharge" property="theoDischarge" />
12
+        <result column="indi_diagram_interp_code" property="indiDiagramInterpCode" />
13
+        <result column="dynamic_liq_level" property="dynamicLiqLevel" />
14
+        <result column="static_liq_lev" property="staticLiqLev" />
15
+        <result column="static_pressure" property="staticPressure" />
16
+        <result column="flow_pres" property="flowPres" />
17
+        <result column="pump_diameter" property="pumpDiameter" />
18
+        <result column="pump_depth" property="pumpDepth" />
19
+        <result column="pump_efficiency" property="pumpEfficiency" />
20
+        <result column="rotate_frequency" property="rotateFrequency" />
21
+        <result column="stroke_length" property="strokeLength" />
22
+        <result column="stroke_frequency" property="strokeFrequency" />
23
+        <result column="susp_max_load" property="suspMaxLoad" />
24
+        <result column="susp_min_load" property="suspMinLoad" />
25
+        <result column="pump_tag_discharge" property="pumpTagDischarge" />
26
+        <result column="rep_pressure_gradient_flow" property="repPressureGradientFlow" />
27
+        <result column="pump_type" property="pumpType" />
28
+        <result column="electromotor_power" property="electromotorPower" />
29
+        <result column="elec_frequency" property="elecFrequency" />
30
+        <result column="diagram_interp_code_time" property="diagramInterpCodeTime" />
31
+        <result column="sgt" property="sgt" />
32
+        <result column="elec_pump_current_a" property="elecPumpCurrentA" />
33
+        <result column="elec_pump_current_b" property="elecPumpCurrentB" />
34
+        <result column="elec_pump_current_c" property="elecPumpCurrentC" />
35
+        <result column="dgt" property="dgt" />
36
+    </resultMap>
37
+    <select id="getErrorData" resultType="java.util.Map">
38
+        delete from  centralbase.cb_runtime_error where prod_date::date =#{localDateTime};
39
+        insert into centralbase.cb_runtime_error
40
+        select t3.org_name org,prod_date,sum(frequencyzero) frequencyzero , sum(frequencynull) frequencynull ,sum(frequencylit) frequencylit ,sum(frequencyok) frequencyok,
41
+               sum(strokezero) strokezero,sum(strokenull) strokenull,sum(strokelit) strokelit,sum(strokeok) strokeok,
42
+               sum(sgtnullstr) sgtnullstr,sum(sgtnull) sgtnull,sum(sgtok) sgtok from (
43
+        select rn.well_id,#{localDateTime}::date prod_date,
44
+        sum(case when rn.stroke_frequency=0 then 1 else 0 end ) frequencyzero ,
45
+        sum(case when rn.stroke_frequency is null  then 1 else 0 end ) frequencynull,
46
+        sum(case when rn.stroke_frequency >12 or rn.stroke_frequency &lt; 0 then 1 else 0 end ) frequencylit,
47
+        sum(case when rn.stroke_frequency &lt;12 and rn.stroke_frequency > 0 then 1 else 0 end ) frequencyok,
48
+        sum(case when rn.stroke_length = 0  then 1 else 0 end ) strokezero,
49
+        sum(case when rn.stroke_length is null then 1 else 0 end ) strokenull,
50
+        sum(case when rn.stroke_length >12 or rn.stroke_length &lt; 0 then 1 else 0 end ) strokelit,
51
+        sum(case when rn.stroke_length &lt; 12 and rn.stroke_length > 0 then 1 else 0 end ) strokeok,
52
+        sum(case when rn.sgt ='' then 1 else 0 end ) sgtnullstr,
53
+        sum(case when rn.sgt is null then 1 else 0 end ) sgtnull,
54
+        sum(case when rn.sgt !='' and sgt is not null  then 1 else 0 end ) sgtok
55
+        from centralbase.cb_temp_well_mech_runtime rn
56
+        where  rn.prod_date::date=#{localDateTime} group by rn.well_id
57
+        ) dat
58
+        left join centralbase.cb_cd_well_source t0 on dat.well_id=t0.well_id
59
+        left join centralbase.cb_pc_organization t1 on t0.org_id=t1.org_id
60
+        left join centralbase.cb_pc_organization t2 on t1.parent_id=t2.org_id
61
+        left join centralbase.cb_pc_organization t3 on t2.parent_id=t3.org_id
62
+        group by t3.org_name,prod_date
63
+    </select>
64
+    <select id="getErrorDataInfo" resultType="java.util.Map">
65
+        select * from centralbase.cb_runtime_error where prod_date::date =#{prodDate} and org_name !=''
66
+    </select>
67
+
68
+    <select id="createTableWithCbRunTime">
69
+        select centralbase.timingCrateTableRunTime(#{endDate},#{startDate});
70
+    </select>
71
+    <select id="testRuntime">
72
+        SELECT  count(1) FROM centralbase.cb_temp_well_mech_runtime
73
+        WHERE prod_date = #{p1}
74
+    </select>
75
+</mapper>