AssessMapper.xml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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.zhyc.xps.lylc.mapper.AssessMapper">
  4. <resultMap id="AssessDtoMap" type="com.zhyc.xps.lylc.dto.AssessDto">
  5. <result column="oc_id" property="ocId" jdbcType="BIGINT" />
  6. <result column="story_id" property="storyId" jdbcType="BIGINT" />
  7. <result column="target_id" property="targetId" jdbcType="BIGINT" />
  8. <result column="target_title" property="targetTitle" jdbcType="VARCHAR" />
  9. <result column="target_code" property="targetCode" jdbcType="VARCHAR" />
  10. <result column="item_id" property="itemId" jdbcType="BIGINT" />
  11. <result column="item_title" property="itemTitle" jdbcType="VARCHAR" />
  12. <result column="item_code" property="itemCode" jdbcType="VARCHAR" />
  13. <result column="point_id" property="pointId" jdbcType="BIGINT" />
  14. <result column="point_content" property="pointContent" jdbcType="VARCHAR" />
  15. <result column="point_code" property="pointCode" jdbcType="VARCHAR" />
  16. <result column="point_score" property="pointScore" jdbcType="FLOAT" />
  17. <result column="record_id" property="recordId" jdbcType="BIGINT" />
  18. <result column="year" property="year" jdbcType="BIGINT" />
  19. <result column="month" property="month" jdbcType="BIGINT" />
  20. <result column="hos_score" property="hosScore" jdbcType="FLOAT" />
  21. <result column="nhc_score" property="nhcScore" jdbcType="FLOAT" />
  22. <result column="is_assessed" property="isAssessed" jdbcType="BIGINT" />
  23. <result column="assess_time" property="assessTime" jdbcType="DATE" />
  24. <result column="remark" property="remark" jdbcType="VARCHAR" />
  25. <result column="sort_no" property="sortNo" jdbcType="BIGINT" />
  26. </resultMap>
  27. <!-- 通用查询结果列 -->
  28. <sql id="AssessDto_Cols">
  29. A.story_id,
  30. B.story_title,
  31. A.target_id,
  32. C.target_title,
  33. A.item_id,
  34. D.item_title,
  35. D.item_code,
  36. A.point_id,
  37. A.point_code,
  38. A.point_content,
  39. A.point_score,
  40. A.score_criterion,
  41. E.record_id,
  42. E.year,
  43. E.month,
  44. IFNULL(E.hos_score, 0) AS hos_score,
  45. IFNULL(CASE WHEN E.hos_score >= 0 THEN 1 ELSE 0 END, 0) AS is_assessed,
  46. E.assess_time
  47. </sql>
  48. <!--列表查询-->
  49. <select id="getByList" parameterType="java.util.Map" resultMap="AssessDtoMap" >
  50. SELECT
  51. <include refid="AssessDto_Cols"/>
  52. FROM assess_story_target_item_point AS A
  53. LEFT JOIN assess_story AS B ON (A.story_id = B.story_id)
  54. LEFT JOIN assess_story_target AS C ON (A.story_id = C.story_id AND A.target_id = C.target_id)
  55. LEFT JOIN assess_story_target_item AS D ON (A.story_id = D.story_id AND A.target_id = D.target_id AND A.item_id = D.item_id)
  56. LEFT JOIN (
  57. SELECT
  58. M.oc_id,
  59. M.story_id,
  60. M.target_id,
  61. M.item_id,
  62. M.point_id,
  63. M.year,
  64. M.month,
  65. M.record_id,
  66. M.hos_score,
  67. R.assess_time
  68. FROM hos_assess_month_record AS M
  69. LEFT JOIN hos_assess_record AS R ON (M.oc_id = R.oc_id
  70. AND M.story_id = R.story_id
  71. AND M.target_id = R.target_id
  72. AND M.item_id = R.item_id
  73. AND M.point_id = R.point_id
  74. AND M.record_id = R.record_id)
  75. WHERE M.oc_id = #{ocId ,jdbcType=BIGINT}
  76. AND M.year = #{year ,jdbcType=BIGINT}
  77. AND M.month = #{month ,jdbcType=BIGINT}
  78. AND M.story_id = #{storyId ,jdbcType=BIGINT}
  79. GROUP BY M.oc_id, M.story_id, M.target_id, M.item_id, M.point_id
  80. ) AS E ON (A.story_id= E.story_id AND A.target_id = E.target_id AND A.item_id= E.item_id AND A.point_id=E.point_id)
  81. WHERE A.deleted_flag = 0
  82. AND A.story_id = #{storyId ,jdbcType=BIGINT}
  83. <if test="targetId != null">
  84. AND A.target_id = #{targetId ,jdbcType=BIGINT}
  85. </if>
  86. <if test="itemId != null">
  87. AND A.item_id = #{itemId ,jdbcType=BIGINT}
  88. </if>
  89. ORDER BY A.story_id, A.target_id, A.item_id, D.sort_no
  90. </select>
  91. <!--列表查询-->
  92. <select id="getById" resultMap="AssessDtoMap" >
  93. SELECT
  94. <include refid="AssessDto_Cols"/>
  95. FROM assess_story_target_item_point AS A
  96. LEFT JOIN assess_story AS B ON (A.story_id = B.story_id)
  97. LEFT JOIN assess_story_target AS C ON (A.story_id = C.story_id AND A.target_id = C.target_id)
  98. LEFT JOIN assess_story_target_item AS D ON (A.story_id = D.story_id AND A.target_id = D.target_id AND A.item_id = D.item_id)
  99. LEFT JOIN (
  100. SELECT
  101. M.oc_id,
  102. M.story_id,
  103. M.target_id,
  104. M.item_id,
  105. M.point_id,
  106. M.year AS year,
  107. M.month AS month,
  108. M.record_id,
  109. M.hos_score,
  110. R.assess_time
  111. FROM hos_assess_month_record AS M
  112. LEFT JOIN hos_assess_record AS R ON (M.oc_id = R.oc_id
  113. AND M.story_id = R.story_id
  114. AND M.target_id = R.target_id
  115. AND M.item_id = R.item_id
  116. AND M.point_id = R.point_id
  117. AND M.record_id = R.record_id)
  118. WHERE M.oc_id = #{ocId ,jdbcType=BIGINT}
  119. AND M.year = #{year ,jdbcType=BIGINT}
  120. AND M.month = #{month ,jdbcType=BIGINT}
  121. GROUP BY M.oc_id, M.story_id, M.target_id, M.item_id, M.point_id
  122. ) AS E ON (A.story_id= E.story_id AND A.target_id = E.target_id AND A.item_id= E.item_id AND A.point_id=E.point_id)
  123. WHERE A.deleted_flag = 0
  124. <if test="storyId != null">
  125. AND A.story_id = #{storyId ,jdbcType=BIGINT}
  126. </if>
  127. <if test="targetId != null">
  128. AND A.target_id = #{targetId ,jdbcType=BIGINT}
  129. </if>
  130. <if test="itemId != null">
  131. AND A.item_id = #{itemId ,jdbcType=BIGINT}
  132. </if>
  133. <if test="pointId != null">
  134. AND A.point_id = #{pointId ,jdbcType=BIGINT}
  135. </if>
  136. </select>
  137. <!--列表查询-->
  138. <select id="getImprovingByList" parameterType="java.util.Map" resultMap="AssessDtoMap" >
  139. SELECT
  140. A.story_id,
  141. A.target_id,
  142. B.target_title,
  143. A.item_id,
  144. C.item_title,
  145. C.item_code,
  146. A.point_id,
  147. D.point_code,
  148. D.point_content,
  149. D.score_criterion,
  150. A.record_id,
  151. A.year,
  152. A.month,
  153. D.point_score,
  154. A.hos_score
  155. FROM hos_assess_month_record AS A
  156. LEFT JOIN assess_story_target AS B on (A.story_id=B.story_id AND A.target_id=B.target_id)
  157. LEFT join assess_story_target_item AS C on (A.story_id=C.story_id AND A.target_id=C.target_id AND A.item_id=C.item_id)
  158. LEFT join assess_story_target_item_point AS D on (A.story_id=D.story_id AND A.target_id=D.target_id AND A.item_id=D.item_id AND A.point_id= D.point_id)
  159. WHERE A.deleted_flag = 0
  160. <if test="year != null">
  161. AND A.year = #{year ,jdbcType=BIGINT}
  162. </if>
  163. <if test="month != null">
  164. AND A.month = #{month ,jdbcType=BIGINT}
  165. </if>
  166. <if test="ocId != null">
  167. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  168. </if>
  169. <if test="storyId != null">
  170. AND A.story_id = #{storyId ,jdbcType=BIGINT}
  171. </if>
  172. <if test="targetId != null">
  173. AND A.target_id = #{targetId ,jdbcType=BIGINT}
  174. </if>
  175. <if test="itemId != null">
  176. AND A.item_id = #{itemId ,jdbcType=BIGINT}
  177. </if>
  178. AND D.point_score * 0.60 > A.hos_score
  179. ORDER BY A.story_id, A.target_id, A.item_id, A.hos_score DESC
  180. </select>
  181. </mapper>