HosStatisMapper.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.hos.mapper.HosStatisMapper">
  5. <resultMap id="StoryMonthScoreCounterResultMap" type="com.zhyc.xps.hos.vo.StoryMonthScoreCounterVo">
  6. <result column="story_id" property="storyId" jdbcType="BIGINT" />
  7. <result column="year" property="year" jdbcType="BIGINT" />
  8. <result column="m1" property="m1" jdbcType="FLOAT" />
  9. <result column="m2" property="m2" jdbcType="FLOAT" />
  10. <result column="m3" property="m3" jdbcType="FLOAT" />
  11. <result column="m4" property="m4" jdbcType="FLOAT" />
  12. <result column="m5" property="m5" jdbcType="FLOAT" />
  13. <result column="m6" property="m6" jdbcType="FLOAT" />
  14. <result column="m7" property="m7" jdbcType="FLOAT" />
  15. <result column="m8" property="m8" jdbcType="FLOAT" />
  16. <result column="m9" property="m9" jdbcType="FLOAT" />
  17. <result column="m10" property="m10" jdbcType="FLOAT" />
  18. <result column="m11" property="m11" jdbcType="FLOAT" />
  19. <result column="m12" property="m12" jdbcType="FLOAT" />
  20. </resultMap>
  21. <select id="monthScoreCounterByList" resultMap="StoryMonthScoreCounterResultMap">
  22. SELECT
  23. R.story_id,
  24. R.year,
  25. SUM(CASE R.month WHEN 1 THEN R.hos_score else 0 end) AS m1,
  26. SUM(CASE R.month WHEN 2 THEN R.hos_score else 0 end) AS m2,
  27. SUM(CASE R.month WHEN 3 THEN R.hos_score else 0 end) AS m3,
  28. SUM(CASE R.month WHEN 4 THEN R.hos_score else 0 end) AS m4,
  29. SUM(CASE R.month WHEN 5 THEN R.hos_score else 0 end) AS m5,
  30. SUM(CASE R.month WHEN 6 THEN R.hos_score else 0 end) AS m6,
  31. SUM(CASE R.month WHEN 7 THEN R.hos_score else 0 end) AS m7,
  32. SUM(CASE R.month WHEN 8 THEN R.hos_score else 0 end) AS m8,
  33. SUM(CASE R.month WHEN 9 THEN R.hos_score else 0 end) AS m9,
  34. SUM(CASE R.month WHEN 10 THEN R.hos_score else 0 end) AS m10,
  35. SUM(CASE R.month WHEN 11 THEN R.hos_score else 0 end) AS m11,
  36. SUM(CASE R.month WHEN 12 THEN R.hos_score else 0 end) AS m12
  37. FROM hos_assess_month_record AS R
  38. WHERE R.deleted_flag = 0
  39. AND R.oc_id = #{ocId}
  40. AND R.year = #{year}
  41. Group By R.story_id, R.year
  42. </select>
  43. <select id="monthScoreCounterById" parameterType="java.util.Map" resultType="com.zhyc.xps.hos.vo.StoryMonthScoreCounterVo">
  44. SELECT
  45. R.story_id,
  46. R.year,
  47. SUM(CASE R.month WHEN 1 THEN R.hos_score else 0 end) AS m1,
  48. SUM(CASE R.month WHEN 2 THEN R.hos_score else 0 end) AS m2,
  49. SUM(CASE R.month WHEN 3 THEN R.hos_score else 0 end) AS m3,
  50. SUM(CASE R.month WHEN 4 THEN R.hos_score else 0 end) AS m4,
  51. SUM(CASE R.month WHEN 5 THEN R.hos_score else 0 end) AS m5,
  52. SUM(CASE R.month WHEN 6 THEN R.hos_score else 0 end) AS m6,
  53. SUM(CASE R.month WHEN 7 THEN R.hos_score else 0 end) AS m7,
  54. SUM(CASE R.month WHEN 8 THEN R.hos_score else 0 end) AS m8,
  55. SUM(CASE R.month WHEN 9 THEN R.hos_score else 0 end) AS m9,
  56. SUM(CASE R.month WHEN 10 THEN R.hos_score else 0 end) AS m10,
  57. SUM(CASE R.month WHEN 11 THEN R.hos_score else 0 end) AS m11,
  58. SUM(CASE R.month WHEN 12 THEN R.hos_score else 0 end) AS m12
  59. FROM hos_assess_month_record AS R
  60. WHERE R.deleted_flag = 0
  61. AND R.oc_id = #{ocId}
  62. AND R.year = #{year}
  63. AND R.story_id = #{storyId}
  64. Group By R.story_id, R.year
  65. </select>
  66. <resultMap id="StoryMonthScoreResultMap" type="com.zhyc.xps.hos.vo.StoryMonthScoreVo">
  67. <result column="story_id" property="storyId" jdbcType="BIGINT" />
  68. <result column="year" property="year" jdbcType="BIGINT" />
  69. <result column="month" property="month" jdbcType="BIGINT" />
  70. <result column="nhc_score" property="nhcScore" jdbcType="FLOAT" />
  71. <result column="hos_score" property="hosScore" jdbcType="FLOAT" />
  72. </resultMap>
  73. <select id="monthScoreByList" resultMap="StoryMonthScoreResultMap">
  74. SELECT
  75. R.story_id,
  76. R.year,
  77. R.month,
  78. ROUND(SUM(R.hos_score), 1) AS hos_score,
  79. ROUND(SUM(R.nhc_score), 1) AS nhc_score
  80. FROM hos_assess_month_record AS R
  81. WHERE R.deleted_flag = 0
  82. <if test="ocId != null">
  83. AND R.oc_id = #{ocId}
  84. </if>
  85. <if test="year != null">
  86. AND R.year = #{year}
  87. </if>
  88. <if test="month != null">
  89. AND R.month = #{month}
  90. </if>
  91. <if test="storyId != null">
  92. AND R.story_id = #{storyId}
  93. </if>
  94. GROUP BY R.story_id, R.year, R.month
  95. </select>
  96. <select id="monthScoreById" parameterType="java.util.Map" resultMap="StoryMonthScoreResultMap">
  97. SELECT
  98. R.story_id,
  99. R.year,
  100. R.month,
  101. ROUND(SUM(R.hos_score),1) AS hos_score,
  102. ROUND(SUM(R.nhc_score),1) AS nhc_score
  103. FROM hos_assess_month_record AS R
  104. WHERE R.deleted_flag = 0
  105. AND R.oc_id = #{ocId}
  106. AND R.year = #{year}
  107. AND R.month = #{month}
  108. AND R.story_id = #{storyId}
  109. GROUP BY R.story_id, R.year, R.month
  110. </select>
  111. </mapper>