FactWellCQuery.xml 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.FactWellCQuery">
  4. <select id="getDayGroupList" resultType="com.bowintek.practice.vo.FactWell.FactWellGroupList">
  5. SELECT t.well_id,
  6. t.prod_time_str time_str,
  7. SUM(t.gas_prod_daily) gas,
  8. SUM(t.oil_prod_daily) oil,
  9. SUM(t.fluid_prod_daily) fluid,
  10. SUM(t.water_prod_daily) water,
  11. SUM(t.water_cut) watercut
  12. FROM ( SELECT wd.well_id,
  13. TO_CHAR(wd.prod_date , 'YYYY-MM-DD') prod_time_str,
  14. COALESCE(wd.gas_prod_daily, 0) gas_prod_daily,
  15. COALESCE(wd.oil_prod_daily, 0) oil_prod_daily,
  16. COALESCE(wd.fluid_prod_daily, 0) fluid_prod_daily,
  17. COALESCE(wd.water_prod_daily, 0) water_prod_daily,
  18. COALESCE(wd.water_cut, 0) water_cut
  19. FROM by_dwr.fact_dwr_pc_pro_well_vol_d wd
  20. WHERE wd.prod_date <![CDATA[ >= ]]> to_date(#{startDay},'YYYY-MM-DD')
  21. and wd.prod_date <![CDATA[ <= ]]> to_date(#{endDay},'YYYY-MM-DD')
  22. <if test="wellId!='' and wellId!=null">
  23. and wd.well_id=#{wellId}
  24. </if>
  25. ) t
  26. GROUP BY t.well_id, t.prod_time_str
  27. </select>
  28. <select id="getMonthGroupList" resultType="com.bowintek.practice.vo.FactWell.FactWellGroupList">
  29. SELECT t.well_id,
  30. t.prod_time_str time_str,
  31. MAX(t.gas_prod_mon) gas,
  32. MAX(t.oil_prod_mon) oil,
  33. MAX(t.water_prod_mon) water,
  34. MAX(t.fluid_prod_mon) fluid,
  35. 0 watercut
  36. FROM ( SELECT wm.well_id,
  37. TO_CHAR(wm.prod_date , 'YYYY年MM月') prod_time_str,
  38. COALESCE(wm.gas_prod_cum, 0) gas_prod_mon,
  39. COALESCE(wm.oil_prod_cum, 0) oil_prod_mon,
  40. COALESCE(wm.water_prod_cum, 0) water_prod_mon,
  41. COALESCE(wm.liquid_prod_cum, 0) fluid_prod_mon
  42. FROM by_dwr.fact_dwr_pc_pro_well_vol_d wm
  43. WHERE wm.prod_date is not null
  44. and wm.prod_date <![CDATA[ >= ]]> to_date(#{startDay},'YYYY-MM-DD')
  45. and wm.prod_date <![CDATA[ <= ]]> to_date(#{endDay},'YYYY-MM-DD')
  46. and wm.well_id=#{wellId}
  47. ) t
  48. GROUP BY t.well_id, t.prod_time_str
  49. </select>
  50. <select id="getYearGroupList" resultType="com.bowintek.practice.vo.FactWell.FactWellGroupList">
  51. SELECT t.well_id,
  52. t.prod_time_str time_str,
  53. SUM(t.gas_prod_mon) gas,
  54. SUM(t.oil_prod_mon) oil,
  55. SUM(t.water_prod_mon) water,
  56. SUM(t.fluid_prod_mon) fluid,
  57. 0 watercut
  58. FROM ( SELECT wm.well_id,
  59. SUBSTRING(prod_date, 1, 4) prod_time_str,
  60. COALESCE(wm.gas_prod_mon, 0) gas_prod_mon,
  61. COALESCE(wm.oil_prod_mon, 0) oil_prod_mon,
  62. COALESCE(wm.water_prod_mon, 0) water_prod_mon,
  63. COALESCE(wm.fluid_prod_mon, 0) fluid_prod_mon
  64. FROM by_dwr.fact_dwr_pc_pro_well_vol_m wm
  65. WHERE wm.prod_date is not null
  66. and to_date(CONCAT(wm.prod_date,'-01'), 'YYYY-MM-DD') <![CDATA[ >= ]]> to_date(#{startDay},'YYYY-MM-DD')
  67. and to_date(CONCAT(wm.prod_date,'-01'), 'YYYY-MM-DD') <![CDATA[ <= ]]> to_date(#{endDay},'YYYY-MM-DD')
  68. <if test="wellId!='' and wellId!=null">
  69. and wm.well_id=#{wellId}
  70. </if>
  71. ) t
  72. GROUP BY t.well_id, t.prod_time_str
  73. </select>
  74. </mapper>