WellInfoCQuery.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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.bowintek.practice.mapper.cquery.WellInfoCQuery">
  4. <select id="getWellInfo" resultType="java.util.HashMap">
  5. select
  6. well.*,
  7. TO_CHAR(well.create_date , 'YYYY-MM-dd') create_date_fmt,
  8. TO_CHAR(well.update_date , 'YYYY-MM-dd') update_date_fmt,
  9. TO_CHAR(well.spud_date , 'YYYY-MM-dd') spud_date_fmt,TO_CHAR(well.end_drilling_date , 'YYYY-MM-dd') end_drilling_date_fmt,
  10. fact_daily.fluid_prod_daily,
  11. fact_daily.oil_prod_daily,
  12. fact_daily.water_cut,
  13. fact_daily.oil_prod_cum,
  14. TO_CHAR(fact_intr.start_prod_date , 'YYYY-MM-dd') start_prod_date,
  15. fact_intr.prod_horizon,
  16. TO_CHAR(fact_intr.recent_testing_date , 'YYYY-MM-dd') recent_testing_date,
  17. fact_intr.recent_testing_name,
  18. fact_intr.construction_description,
  19. TO_CHAR(fact_intr.recent_prod_date , 'YYYY-MM-dd') recent_prod_date,
  20. fact_intr.oil_nozzle,
  21. fact_intr.tubing_pres,
  22. fact_intr.casing_pres,
  23. fact_intr.start_pump_liq_level,
  24. str.well_production_sections,
  25. str.t74_top_depth,
  26. str.ko_azimuth,
  27. str.ko_horizontal_dislocation,
  28. str.azimuth_angle,
  29. str.well_coordinates_x,
  30. str.well_coordinates_y,
  31. intr.well_state
  32. from by_dwr.fact_dwr_well_basic_information well
  33. left join by_dwr.fact_dwr_well_structure str on well.well_id = str.well_id
  34. left join by_dwr.fact_dwr_well_history_introduction intr on well.well_id=intr.well_id
  35. left join (
  36. select daily.*
  37. from by_dwr.fact_dwr_pc_pro_well_vol_d daily
  38. inner join(
  39. select well_id, max(prod_date) prod_date from by_dwr.fact_dwr_pc_pro_well_vol_d group by well_id
  40. ) maxdaily on daily.well_id = maxdaily.well_id and daily.prod_date = maxdaily.prod_date
  41. ) fact_daily on well.well_id = fact_daily.well_id
  42. left join (
  43. select intr.*
  44. from by_dwr.fact_dwr_well_history_introduction intr
  45. inner join(
  46. select well_id, max(start_prod_date) start_prod_date
  47. from by_dwr.fact_dwr_well_history_introduction
  48. group by well_id
  49. ) maxintr on intr.well_id = maxintr.well_id and intr.start_prod_date = maxintr.start_prod_date
  50. ) fact_intr on well.well_id = fact_intr.well_id
  51. where well.well_id = #{well_id}
  52. </select>
  53. <select id="getWellInfoList" parameterType="com.bowintek.practice.vo.query.WellInfoParams"
  54. resultType="java.util.HashMap">
  55. select
  56. well.well_id, well.well_common_name, well_purpose, well.well_type, well.end_drilling_date, well.budgeted_md, well.completion_formation,
  57. well.completion_method, well.org_id_a1, well.org_id_a2, well.org_name_a2,well.project_id, well.project_name,
  58. 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,
  59. station.name org_name_a1,
  60. TO_CHAR(fact_daily.oil_prod_begin_date , 'YYYY-MM-dd') oil_prod_begin_date,
  61. TO_CHAR(fact_daily.oil_prod_recent_date , 'YYYY-MM-dd') oil_prod_recent_date,
  62. fact_daily.current_state,fact_daily.water_cut,fact_daily.oil_prod_cum oil_prod_year,
  63. fact_daily.gas_prod_cum gas_prod_year,
  64. fact_daily.inj_vol_cum water_prod_year,
  65. fact_mon.oil_prod_mon,fact_mon.gas_prod_mon,fact_mon.inj_vol_mon water_prod_mon,
  66. well_stt.well_coordinates_x x,
  67. well_stt.well_coordinates_y y,
  68. intr.well_state
  69. from by_dwr.fact_dwr_well_basic_information well
  70. left join by_dwr.fact_dwr_well_history_introduction intr on well.well_id=intr.well_id
  71. left join (
  72. select daily.* from by_dwr.fact_dwr_pc_pro_well_vol_d daily
  73. inner join(
  74. select well_id, max(prod_date) prod_date from by_dwr.fact_dwr_pc_pro_well_vol_d group by well_id
  75. ) maxdaily on daily.well_id=maxdaily.well_id and daily.prod_date=maxdaily.prod_date
  76. )fact_daily on well.well_id= fact_daily.well_id
  77. left join (
  78. select mon.* from by_dwr.fact_dwr_pc_pro_well_vol_m mon
  79. inner join(
  80. select well_id, max(prod_date) prod_date from by_dwr.fact_dwr_pc_pro_well_vol_m group by well_id
  81. ) maxmon on mon.well_id=maxmon.well_id and mon.prod_date=maxmon.prod_date
  82. )fact_mon on well.well_id= fact_mon.well_id
  83. left join by_dwr.fact_dwr_well_structure well_stt on well.well_id = well_stt.well_id
  84. left join by_dim.v_plant_site_station station on well.org_id_a1=station.id
  85. where 1=1
  86. <if test="well_common_name!='' and well_common_name!=null">
  87. and well.well_common_name like Concat('%',#{well_common_name},'%')
  88. </if>
  89. <if test="well_id!='' and well_id!=null">
  90. and well.well_id like Concat('%',#{well_id},'%')
  91. </if>
  92. <if test="well_type!='' and well_type!=null">
  93. and well.well_type like Concat('%',#{well_type},'%')
  94. </if>
  95. <if test="well_purpose!='' and well_purpose!=null">
  96. and well.well_purpose like Concat('%',#{well_purpose},'%')
  97. </if>
  98. <if test="spud_date_begin!='' and spud_date_begin!=null">
  99. and well.spud_date <![CDATA[ >= ]]> CAST(#{spud_date_begin} AS DATE)
  100. </if>
  101. <if test="spud_date_end!='' and spud_date_end!=null">
  102. and well.spud_date <![CDATA[ < ]]> (CAST(#{spud_date_end} AS DATE) + INTERVAL '1 day')
  103. </if>
  104. <if test="completion_date_begin!='' and completion_date_begin!=null">
  105. and well.completion_date <![CDATA[ >= ]]> CAST(#{completion_date_begin} AS DATE)
  106. </if>
  107. <if test="completion_date_end!='' and completion_date_end!=null">
  108. and well.completion_date <![CDATA[ < ]]> (CAST(#{completion_date_end} AS DATE) + INTERVAL '1 day')
  109. </if>
  110. <if test="oil_prod_begin_date_begin!='' and oil_prod_begin_date_begin!=null">
  111. and fact_daily.oil_prod_begin_date <![CDATA[ >= ]]> CAST(#{oil_prod_begin_date_begin} AS DATE)
  112. </if>
  113. <if test="oil_prod_begin_date_end!='' and oil_prod_begin_date_end!=null">
  114. and fact_daily.oil_prod_begin_date <![CDATA[ < ]]> (CAST(#{oil_prod_begin_date_end} AS DATE) + INTERVAL '1
  115. day')
  116. </if>
  117. <if test="oil_prod_recent_date_begin!='' and oil_prod_recent_date_begin!=null">
  118. and fact_daily.oil_prod_recent_date <![CDATA[ >= ]]> CAST(#{oil_prod_recent_date_begin} AS DATE)
  119. </if>
  120. <if test="oil_prod_recent_date_end!='' and oil_prod_recent_date_end!=null">
  121. and fact_daily.oil_prod_recent_date <![CDATA[ < ]]> (CAST(#{oil_prod_recent_date_end} AS DATE) + INTERVAL
  122. '1 day')
  123. </if>
  124. <if test="org_id_a1!='' and org_id_a1!=null">
  125. and well.org_id_a1 =#{org_id_a1}
  126. </if>
  127. <if test="project_id!='' and project_id!=null">
  128. and well.project_id =#{project_id}
  129. </if>
  130. <if test="orgList!=null and orgList.size>0">
  131. and well.org_id_a1 in
  132. <foreach collection="orgList" item="orgId" index="index" open="(" close=")" separator=",">
  133. #{orgId}
  134. </foreach>
  135. </if>
  136. <if test="unitList!=null and unitList.size>0">
  137. and well.project_id in
  138. <foreach collection="unitList" item="unitId" index="index" open="(" close=")" separator=",">
  139. #{unitId}
  140. </foreach>
  141. </if>
  142. order by well.well_common_name
  143. </select>
  144. <select id="getWellMapList" parameterType="com.bowintek.practice.vo.query.WellInfoParams"
  145. resultType="java.util.HashMap">
  146. SELECT well.well_id,
  147. well.well_common_name,
  148. well.geo_description,
  149. structure.well_coordinates_x x,
  150. structure.well_coordinates_y y
  151. FROM by_dwr.fact_dwr_well_basic_information well
  152. inner join by_dwr.fact_dwr_well_structure structure on well.well_id = structure.well_id
  153. where 1=1
  154. <if test="well_common_name!='' and well_common_name!=null">
  155. and well.well_common_name like Concat('%',#{well_common_name},'%')
  156. </if>
  157. <if test="well_id!='' and well_id!=null">
  158. and well.well_id like Concat('%',#{well_id},'%')
  159. </if>
  160. <if test="well_type!='' and well_type!=null">
  161. and well.well_type like Concat('%',#{well_type},'%')
  162. </if>
  163. <if test="spud_date_begin!='' and spud_date_begin!=null">
  164. and well.spud_date <![CDATA[ >= ]]> CAST(#{spud_date_begin} AS DATE)
  165. </if>
  166. <if test="spud_date_end!='' and spud_date_end!=null">
  167. and well.spud_date <![CDATA[ < ]]> (CAST(#{spud_date_end} AS DATE) + INTERVAL '1 day')
  168. </if>
  169. <if test="completion_date_begin!='' and completion_date_begin!=null">
  170. and well.completion_date <![CDATA[ >= ]]> CAST(#{completion_date_begin} AS DATE)
  171. </if>
  172. <if test="completion_date_end!='' and completion_date_end!=null">
  173. and well.completion_date <![CDATA[ < ]]> (CAST(#{completion_date_end} AS DATE) + INTERVAL '1 day')
  174. </if>
  175. <if test="org_id_a1!='' and org_id_a1!=null">
  176. and well.org_id_a1 =#{org_id_a1}
  177. </if>
  178. <if test="project_id!='' and project_id!=null">
  179. and well.project_id =#{project_id}
  180. </if>
  181. order by well.well_common_name
  182. </select>
  183. <select id="selectBoreholeInterList" resultType="java.util.HashMap">
  184. select
  185. bi.interp_borehole_id,
  186. bi.interp_id,
  187. bi.well_id,
  188. bi.wellbore_id,
  189. bi.zone_id,
  190. bi.zone_no,
  191. bi.borehole_inter_type,
  192. bi.start_depth,
  193. bi.end_depth,
  194. bi.thickness,
  195. bi.lithology_class,
  196. bi.spontaneous_potential,
  197. bi.sp_gamma_radiant_intensity,
  198. bi.well_diameter,
  199. bi.formation_volume_density,
  200. bi.sonic_differential_time,
  201. bi.compensated_neutron,
  202. bi.laterolog_shallow,
  203. bi.laterolog_deep,
  204. bi.laterolog_flushed_zone,
  205. bi.density_porosity,
  206. bi.sonic_porosity,
  207. bi.neutron_porosity,
  208. bi.effective_porosity,
  209. bi.total_porosity,
  210. bi.permeability,
  211. bi.oil_gas_saturation,
  212. bi.irreducible_water_saturation,
  213. bi.shale_content,
  214. bi.sandy_content,
  215. bi.lime_content,
  216. bi.dolomitic_content,
  217. bi.carbonate_content,
  218. bi.idx_type,
  219. case when bi.interpretation_result like 'c%' then ''
  220. else bi.interpretation_result
  221. end interpretation_result,
  222. bi.start_tvd,
  223. bi.end_tvd,
  224. bi.tvd_thickness,
  225. bi.remarks,
  226. TO_CHAR(bi.create_date , 'YYYY-MM-dd') create_date,
  227. bi.create_user_id,
  228. bi.create_app_id,
  229. TO_CHAR(bi.update_date , 'YYYY-MM-dd') update_date,
  230. bi.update_user_id,
  231. bi.check_date,
  232. bi.check_user_id,
  233. bi.unify_task_id,
  234. bi.source
  235. from by_dwr.fact_dwr_wl_ach_borehole_inter bi
  236. where bi.well_id = 'HBe6JDZ9rt'
  237. order by zone_no asc
  238. </select>
  239. <select id="selectTestHistoryList" resultType="java.util.HashMap">
  240. select *
  241. from by_dm.dws_dm_test_history th
  242. where th.well_id = #{well_id}
  243. order by testing_date desc
  244. limit 100
  245. </select>
  246. <select id="selectTestHistorySummary" resultType="java.util.HashMap">
  247. select testing_name, count(1) as testing_num
  248. from by_dm.dws_dm_test_history th
  249. where th.well_id = #{well_id}
  250. group by th.testing_name
  251. </select>
  252. <select id="getLastTestHistory" resultType="java.util.HashMap">
  253. select *
  254. from by_dm.dws_dm_test_history th
  255. where th.well_id = #{well_id}
  256. order by th.testing_date desc limit 1
  257. </select>
  258. <select id="selectAnalyticalAssaysList" resultType="java.util.HashMap">
  259. select *
  260. from by_dm.dws_dm_analytical_assays_new aa
  261. where aa.well_id = #{well_id}
  262. order by item_code
  263. limit 100
  264. </select>
  265. <select id="selectAnalyticalAssaysSummary" resultType="java.util.HashMap">
  266. SELECT item_code,
  267. SUM(CASE WHEN item_code = '井裸眼井基本解释成果' THEN 1 ELSE 0 END) AS 井裸眼井基本解释成果,
  268. SUM(CASE WHEN item_code = '岩石力学参数解释成果' THEN 1 ELSE 0 END) AS 岩石力学参数解释成果,
  269. SUM(CASE WHEN item_code = '储层孔隙结构评价' THEN 1 ELSE 0 END) AS 储层孔隙结构评价,
  270. SUM(CASE WHEN item_code = '裂缝型地层测井解释成果' THEN 1 ELSE 0 END) AS 裂缝型地层测井解释成果,
  271. SUM(CASE WHEN item_code = '煤层气测井解释成果' THEN 1 ELSE 0 END) AS 煤层气测井解释成果,
  272. SUM(CASE WHEN item_code = '录井综合解释' THEN 1 ELSE 0 END) AS 录井综合解释,
  273. SUM(CASE WHEN item_code = '气测解释' THEN 1 ELSE 0 END) AS 气测解释,
  274. SUM(CASE WHEN item_code = '定量荧光解释' THEN 1 ELSE 0 END) AS 定量荧光解释
  275. FROM by_dm.dws_dm_analytical_assays_new
  276. where well_id = #{well_id}
  277. GROUP BY item_code;
  278. </select>
  279. <select id="selectHistoryAssignmentList" resultType="java.util.HashMap">
  280. select well_common_name, well_id, wellbore_id, event_id, test_id, TO_CHAR(start_time , 'YYYY-MM-dd') start_time,TO_CHAR(end_time , 'YYYY-MM-dd') end_time , constr_description, remarks, well_production_sections, formation_name, top_md, btm_md, thickness, layer_no,
  281. working_type, test_processes_name, worksummary, construct_no, work_team, pump_depth
  282. from by_dwr.fact_dwr_brief_history_assignment ha
  283. where ha.well_id = #{well_id}
  284. order by start_time desc
  285. </select>
  286. <select id="selectHistoryAssignmentSummary" resultType="java.util.HashMap">
  287. select test_processes_name, count(1) as testing_num
  288. from by_dwr.fact_dwr_brief_history_assignment bha
  289. where bha.well_id = #{well_id}
  290. group by bha.test_processes_name
  291. </select>
  292. <select id="getLastHistoryAssignment" resultType="java.util.HashMap">
  293. select
  294. well_common_name, well_id, wellbore_id, event_id, test_id, TO_CHAR(start_time , 'YYYY-MM-dd') start_time,TO_CHAR(end_time , 'YYYY-MM-dd') end_time , constr_description, remarks, well_production_sections, formation_name, top_md, btm_md, thickness, layer_no,
  295. working_type, test_processes_name, worksummary, construct_no, work_team, pump_depth
  296. from by_dwr.fact_dwr_brief_history_assignment bha
  297. where bha.well_id = #{well_id}
  298. order by bha.start_time desc limit 1
  299. </select>
  300. <select id="selectDataIndexList" resultType="java.util.HashMap">
  301. select di.*,well.well_id
  302. from by_dwr.fact_dwr_well_data_index di
  303. inner join by_dwr.fact_dwr_well_basic_information well on di.well_common_name=well.well_common_name
  304. where well.well_id = #{well_id}
  305. </select>
  306. <select id="selectDimProjectTypeList" resultType="java.util.HashMap">
  307. select name as title,value_id as key
  308. from BY_DIM.dim_project_type
  309. where is_effect = 1
  310. </select>
  311. <select id="selectConstructUnitList" resultType="java.util.HashMap">
  312. select lv.*,
  313. desc1.name as project_name_1,
  314. desc2.name as project_name_2,
  315. desc3.name as project_name_3,
  316. desc4.name as project_name_4,
  317. desc5.name as project_name_5
  318. from BY_DIM.dim_construct_unit_level lv
  319. left join BY_DIM.dim_construct_unit_desc desc1 on lv.project_id_1 = desc1.id
  320. left join BY_DIM.dim_construct_unit_desc desc2 on lv.project_id_2 = desc2.id
  321. left join BY_DIM.dim_construct_unit_desc desc3 on lv.project_id_3 = desc3.id
  322. left join BY_DIM.dim_construct_unit_desc desc4 on lv.project_id_4 = desc4.id
  323. left join BY_DIM.dim_construct_unit_desc desc5 on lv.project_id_5 = desc5.id
  324. where lv.is_effect = 1
  325. </select>
  326. <select id="selectOilgasUnitList" resultType="java.util.HashMap">
  327. select lv.*, desc1.name as project_name_1,
  328. desc2.name as project_name_2,
  329. desc3.name as project_name_3,
  330. desc4.name as project_name_4,
  331. desc5.name as project_name_5,
  332. desc6.name as project_name_6,
  333. desc7.name as project_name_7
  334. from BY_DIM.dim_oilgas_unit_level lv
  335. left join BY_DIM.dim_oilgas_unit_desc desc1 on lv.project_id_1 = desc1.id
  336. left join BY_DIM.dim_oilgas_unit_desc desc2 on lv.project_id_2 = desc2.id
  337. left join BY_DIM.dim_oilgas_unit_desc desc3 on lv.project_id_3 = desc3.id
  338. left join BY_DIM.dim_oilgas_unit_desc desc4 on lv.project_id_4 = desc4.id
  339. left join BY_DIM.dim_oilgas_unit_desc desc5 on lv.project_id_5 = desc5.id
  340. left join BY_DIM.dim_oilgas_unit_desc desc6 on lv.project_id_6 = desc6.id
  341. left join BY_DIM.dim_oilgas_unit_desc desc7 on lv.project_id_7 = desc7.id
  342. where lv.is_effect = 1
  343. </select>
  344. </mapper>