Browse Source

井筒全息快照查询优化

da-xian 1 month ago
parent
commit
ee76336d9b
1 changed files with 75 additions and 73 deletions
  1. 75 73
      src/main/resources/mapping/cquery/WellInfoCQuery.xml

+ 75 - 73
src/main/resources/mapping/cquery/WellInfoCQuery.xml

@@ -3,87 +3,90 @@
 <mapper namespace="com.bowintek.smartsearch.mapper.cquery.WellInfoCQuery">
 
     <select id="getWellInfo" resultType="java.util.HashMap">
-        select
+        SELECT
             well.*,
-            TO_CHAR(well.create_date , 'YYYY-MM-dd') create_date_fmt,
-            TO_CHAR(well.update_date , 'YYYY-MM-dd') update_date_fmt,
-            TO_CHAR(well.spud_date , 'YYYY-MM-dd') spud_date_fmt,TO_CHAR(well.end_drilling_date , 'YYYY-MM-dd') end_drilling_date_fmt,
-               fact_daily.fluid_prod_daily,
-               fact_daily.oil_prod_daily,
-               fact_daily.water_cut,
-               fact_daily.oil_prod_cum,
-               TO_CHAR(fact_intr.start_prod_date , 'YYYY-MM-dd') start_prod_date,
-               fact_intr.prod_horizon,
-               TO_CHAR(fact_intr.recent_testing_date , 'YYYY-MM-dd') recent_testing_date,
-               fact_intr.recent_testing_name,
-               fact_intr.construction_description,
-               TO_CHAR(fact_intr.recent_prod_date , 'YYYY-MM-dd') recent_prod_date,
-               fact_intr.oil_nozzle,
-               fact_intr.tubing_pres,
-               fact_intr.casing_pres,
-               fact_intr.start_pump_liq_level,
-               str.well_production_sections,
-               str.t74_top_depth,
-               str.ko_azimuth,
-               str.ko_horizontal_dislocation,
-               str.azimuth_angle,
-               str.well_coordinates_x,
-               str.well_coordinates_y,
+            TO_CHAR( well.create_date, 'YYYY-MM-dd' ) create_date_fmt,
+            TO_CHAR( well.update_date, 'YYYY-MM-dd' ) update_date_fmt,
+            TO_CHAR( well.spud_date, 'YYYY-MM-dd' ) spud_date_fmt,
+            TO_CHAR( well.end_drilling_date, 'YYYY-MM-dd' ) end_drilling_date_fmt,
+            fact_daily.fluid_prod_daily,
+            fact_daily.oil_prod_daily,
+            fact_daily.water_cut,
+            fact_daily.oil_prod_cum,
+            TO_CHAR( fact_intr.start_prod_date, 'YYYY-MM-dd' ) start_prod_date,
+            fact_intr.prod_horizon,
+            TO_CHAR( fact_intr.recent_testing_date, 'YYYY-MM-dd' ) recent_testing_date,
+            fact_intr.recent_testing_name,
+            fact_intr.construction_description,
+            TO_CHAR( fact_intr.recent_prod_date, 'YYYY-MM-dd' ) recent_prod_date,
+            fact_intr.oil_nozzle,
+            fact_intr.tubing_pres,
+            fact_intr.casing_pres,
+            fact_intr.start_pump_liq_level,
+            str.well_production_sections,
+            str.t74_top_depth,
+            str.ko_azimuth,
+            str.ko_horizontal_dislocation,
+            str.azimuth_angle,
+            str.well_coordinates_x,
+            str.well_coordinates_y,
             intr.well_state
-        from by_dwr.fact_dwr_well_basic_information well
-                 left join by_dwr.fact_dwr_well_structure str on well.well_id = str.well_id
-            left join  by_dwr.fact_dwr_well_history_introduction intr on well.well_id=intr.well_id
-                 left join (
-            select daily.*
-            from by_dwr.fact_dwr_pc_pro_well_vol_d daily
-                     inner join(
-                select well_id, max(prod_date) prod_date from by_dwr.fact_dwr_pc_pro_well_vol_d group by well_id
-            ) maxdaily on daily.well_id = maxdaily.well_id and daily.prod_date = maxdaily.prod_date
-        ) fact_daily on well.well_id = fact_daily.well_id
-                 left join (
-            select intr.*
-            from by_dwr.fact_dwr_well_history_introduction intr
-                     inner join(
-                select well_id, max(start_prod_date) start_prod_date
-                from by_dwr.fact_dwr_well_history_introduction
-                group by well_id
-            ) maxintr on intr.well_id = maxintr.well_id and intr.start_prod_date = maxintr.start_prod_date
-        ) fact_intr on well.well_id = fact_intr.well_id
+        FROM
+            by_dwr.fact_dwr_well_basic_information well
+                LEFT JOIN by_dwr.fact_dwr_well_structure str ON well.well_id = str.well_id
+                LEFT JOIN by_dwr.fact_dwr_well_history_introduction intr ON well.well_id = intr.well_id
+                LEFT JOIN by_dwr.fact_dwr_pc_pro_well_vol_d_d fact_daily ON well.well_id = fact_daily.well_id
+                LEFT JOIN (
+                SELECT
+                    intr.*
+                FROM
+                    by_dwr.fact_dwr_well_history_introduction intr
+                        INNER JOIN ( SELECT well_id, MAX ( start_prod_date ) start_prod_date FROM by_dwr.fact_dwr_well_history_introduction GROUP BY well_id ) maxintr ON intr.well_id = maxintr.well_id
+                        AND intr.start_prod_date = maxintr.start_prod_date
+            ) fact_intr ON well.well_id = fact_intr.well_id
         where well.well_id = #{well_id}
     </select>
     <select id="getWellInfoList" parameterType="com.bowintek.smartsearch.vo.query.WellInfoParams"
             resultType="java.util.HashMap">
-        select
-        well.well_id, well.well_common_name, well_purpose, well.well_type,  well.end_drilling_date, well.budgeted_md, well.completion_formation,
-        well.completion_method, well.org_id_a1, well.org_id_a2,  well.org_name_a2,well.project_id, well.project_name,
-        TO_CHAR(well.spud_date , 'YYYY-MM-dd') spud_date,TO_CHAR(well.end_drilling_date , 'YYYY-MM-dd') end_drilling_date,TO_CHAR(well.completion_date , 'YYYY-MM-dd') completion_date,
-        station.name  org_name_a1,
-        TO_CHAR(fact_daily.oil_prod_begin_date , 'YYYY-MM-dd') oil_prod_begin_date,
-        TO_CHAR(fact_daily.oil_prod_recent_date , 'YYYY-MM-dd') oil_prod_recent_date,
-        fact_daily.current_state,fact_daily.water_cut,fact_daily.oil_prod_cum/10000 oil_prod_year,
-        fact_daily.gas_prod_cum/100000000 gas_prod_year,
-        fact_daily.inj_vol_cum/10000 water_prod_year,
-        fact_mon.oil_prod_mon,fact_mon.gas_prod_mon/10000 gas_prod_mon,fact_mon.inj_vol_mon water_prod_mon,
+        SELECT
+        well.well_id,
+        well.well_common_name,
+        well_purpose,
+        well.well_type,
+        well.end_drilling_date,
+        well.budgeted_md,
+        well.completion_formation,
+        well.completion_method,
+        well.org_id_a1,
+        well.org_id_a2,
+        well.org_name_a2,
+        well.project_id,
+        well.project_name,
+        TO_CHAR( well.spud_date, 'YYYY-MM-dd' ) spud_date,
+        TO_CHAR( well.end_drilling_date, 'YYYY-MM-dd' ) end_drilling_date,
+        TO_CHAR( well.completion_date, 'YYYY-MM-dd' ) completion_date,
+        station.NAME org_name_a1,
+        TO_CHAR( fact_daily.oil_prod_begin_date, 'YYYY-MM-dd' ) oil_prod_begin_date,
+        TO_CHAR( fact_daily.oil_prod_recent_date, 'YYYY-MM-dd' ) oil_prod_recent_date,
+        fact_daily.current_state,
+        fact_daily.water_cut,
+        fact_daily.oil_prod_cum / 10000 oil_prod_year,
+        fact_daily.gas_prod_cum / 100000000 gas_prod_year,
+        fact_daily.inj_vol_cum / 10000 water_prod_year,
+        fact_mon.oil_prod_mon,
+        fact_mon.gas_prod_mon / 10000 gas_prod_mon,
+        fact_mon.inj_vol_mon water_prod_mon,
         well_stt.well_coordinates_x x,
         well_stt.well_coordinates_y y,
         intr.well_state
-        from by_dwr.fact_dwr_well_basic_information well
-        left join  by_dwr.fact_dwr_well_history_introduction intr on well.well_id=intr.well_id
-        left join (
-        select daily.* from by_dwr.fact_dwr_pc_pro_well_vol_d daily
-        inner join(
-        select well_id, max(prod_date) prod_date from by_dwr.fact_dwr_pc_pro_well_vol_d group by well_id
-        ) maxdaily on daily.well_id=maxdaily.well_id and daily.prod_date=maxdaily.prod_date
-        )fact_daily on well.well_id= fact_daily.well_id
-        left join (
-        select mon.* from by_dwr.fact_dwr_pc_pro_well_vol_m mon
-        inner join(
-        select well_id, max(prod_date) prod_date from by_dwr.fact_dwr_pc_pro_well_vol_m group by well_id
-        ) maxmon on mon.well_id=maxmon.well_id and mon.prod_date=maxmon.prod_date
-        )fact_mon on well.well_id= fact_mon.well_id
-        left join by_dwr.fact_dwr_well_structure well_stt on well.well_id = well_stt.well_id
-        left join by_dim.v_plant_site_station station on well.org_id_a1=station.id
-        where 1=1
+        FROM
+        by_dwr.fact_dwr_well_basic_information well
+        LEFT JOIN by_dwr.fact_dwr_well_history_introduction intr ON well.well_id = intr.well_id
+        LEFT JOIN by_dwr.fact_dwr_pc_pro_well_vol_d_d fact_daily ON well.well_id = fact_daily.well_id
+        LEFT JOIN by_dwr.fact_dwr_pc_pro_well_vol_m_m fact_mon ON well.well_id = fact_mon.well_id
+        LEFT JOIN by_dwr.fact_dwr_well_structure well_stt ON well.well_id = well_stt.well_id
+        LEFT JOIN by_dim.v_plant_site_station station ON well.org_id_a1 = station.ID
+        WHERE 1 = 1
         <if test="well_common_name!='' and well_common_name!=null">
             and well.well_common_name like Concat('%',#{well_common_name},'%')
         </if>
@@ -140,7 +143,6 @@
                 #{unitId}
             </foreach>
         </if>
-        order by well.well_common_name
     </select>
 
     <select id="getWellMapList" parameterType="com.bowintek.smartsearch.vo.query.WellInfoParams"