SatisfyStatisMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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.SatisfyStatisMapper">
  5. <resultMap id="GroupResultMap" type="com.zhyc.xps.hos.vo.SatisfyGroupVo">
  6. <result column="group_id" property="groupId" jdbcType="BIGINT" />
  7. <result column="group_name" property="groupName" jdbcType="VARCHAR" />
  8. <result column="record_qty" property="recordQty" jdbcType="BIGINT" />
  9. <result column="target_qty" property="targetQty" jdbcType="BIGINT" />
  10. <result column="score" property="score" jdbcType="FLOAT" />
  11. </resultMap>
  12. <select id="groupByList" resultMap="GroupResultMap">
  13. SELECT
  14. A.target_group_id AS group_id,
  15. D.group_name,
  16. COUNT(A.record_id) AS record_qty,
  17. COUNT(distinct(A.target_id)) AS target_qty,
  18. ROUND(AVG(A.score)*20, 1) AS score
  19. FROM checklist_record AS A
  20. LEFT JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
  21. LEFT JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
  22. LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.target_group_id = D.group_id)
  23. <where>
  24. <if test="ocId != null">
  25. AND A.oc_id = #{ocId}
  26. </if>
  27. <if test="checklistId != null">
  28. AND A.checklist_id = #{checklistId}
  29. </if>
  30. <if test="targetType != null">
  31. AND B.target_type = #{targetType}
  32. </if>
  33. <if test="checklistCatId != null">
  34. AND B.checklist_cat_id = #{checklistCatId}
  35. </if>
  36. <if test="year != null">
  37. AND YEAR(A.record_time) = #{year}
  38. </if>
  39. <if test="month != null">
  40. AND MONTH(A.record_time) = #{month}
  41. </if>
  42. <if test="recordTime != null">
  43. AND DATE_FORMAT(A.record_time,'%Y-%m-%d') = #{recordTime}
  44. </if>
  45. <if test="nodeLeft != null and nodeRight != null">
  46. <![CDATA[
  47. AND C.node_left >= #{nodeLeft, jdbcType=BIGINT}
  48. AND C.node_right <= #{nodeRight, jdbcType=BIGINT}
  49. ]]>
  50. </if>
  51. </where>
  52. GROUP BY A.target_group_id
  53. </select>
  54. <resultMap id="GroupYearResultMap" type="com.zhyc.xps.hos.vo.SatisfyGroupYearVo">
  55. <result column="group_id" property="groupId" jdbcType="BIGINT" />
  56. <result column="group_name" property="groupName" jdbcType="VARCHAR" />
  57. <result column="year" property="year" jdbcType="INTEGER" />
  58. <result column="record_qty" property="recordQty" jdbcType="BIGINT" />
  59. <result column="target_qty" property="targetQty" jdbcType="BIGINT" />
  60. <result column="score" property="score" jdbcType="FLOAT" />
  61. </resultMap>
  62. <select id="groupYearByList" resultMap="GroupYearResultMap">
  63. SELECT
  64. A.target_group_id AS group_id,
  65. D.group_name,
  66. YEAR(A.record_time) AS year,
  67. COUNT(A.record_id) AS record_qty,
  68. COUNT(distinct(A.target_id)) AS target_qty,
  69. ROUND(AVG(A.score)*20, 1) AS score
  70. FROM checklist_record AS A
  71. LEFT JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
  72. LEFT JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
  73. LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.target_group_id = D.group_id)
  74. <where>
  75. <if test="ocId != null">
  76. AND A.oc_id = #{ocId}
  77. </if>
  78. <if test="checklistId != null">
  79. AND A.checklist_id = #{checklistId}
  80. </if>
  81. <if test="targetType != null">
  82. AND B.target_type = #{targetType}
  83. </if>
  84. <if test="checklistCatId != null">
  85. AND B.checklist_cat_id = #{checklistCatId}
  86. </if>
  87. <if test="year != null">
  88. AND YEAR(A.record_time) = #{year}
  89. </if>
  90. <if test="month != null">
  91. AND MONTH(A.record_time) = #{month}
  92. </if>
  93. <if test="recordTime != null">
  94. AND DATE_FORMAT(A.record_time,'%Y-%m-%d') = #{recordTime}
  95. </if>
  96. <if test="nodeLeft != null and nodeRight != null">
  97. <![CDATA[
  98. AND D.node_left >= #{nodeLeft, jdbcType=BIGINT}
  99. AND D.node_right <= #{nodeRight, jdbcType=BIGINT}
  100. ]]>
  101. </if>
  102. </where>
  103. GROUP BY YEAR(A.record_time), A.target_group_id
  104. ORDER BY group_id, year
  105. </select>
  106. <select id="groupMonthScoreCounterById" resultType="com.zhyc.xps.hos.vo.SatisfyGroupMonthScoreCounterVo">
  107. SELECT
  108. A.target_group_id AS group_id,
  109. D.group_name,
  110. YEAR(A.record_time) AS year,
  111. CASE MONTH(A.record_time) when 1 then ROUND(AVG(A.score)*20, 1) else 0 end AS m1,
  112. CASE MONTH(A.record_time) when 2 then ROUND(AVG(A.score)*20, 1) else 0 end AS m2,
  113. CASE MONTH(A.record_time) when 3 then ROUND(AVG(A.score)*20, 1) else 0 end AS m3,
  114. CASE MONTH(A.record_time) when 4 then ROUND(AVG(A.score)*20, 1) else 0 end AS m4,
  115. CASE MONTH(A.record_time) when 5 then ROUND(AVG(A.score)*20, 1) else 0 end AS m5,
  116. CASE MONTH(A.record_time) when 6 then ROUND(AVG(A.score)*20, 1) else 0 end AS m6,
  117. CASE MONTH(A.record_time) when 7 then ROUND(AVG(A.score)*20, 1) else 0 end AS m7,
  118. CASE MONTH(A.record_time) when 8 then ROUND(AVG(A.score)*20, 1) else 0 end AS m8,
  119. CASE MONTH(A.record_time) when 9 then ROUND(AVG(A.score)*20, 1) else 0 end AS m9,
  120. CASE MONTH(A.record_time) when 10 then ROUND(AVG(A.score)*20, 1) else 0 end AS m10,
  121. CASE MONTH(A.record_time) when 11 then ROUND(AVG(A.score)*20, 1) else 0 end AS m11,
  122. CASE MONTH(A.record_time) when 12 then ROUND(AVG(A.score)*20, 1) else 0 end AS m12
  123. FROM checklist_record AS A
  124. LEFT JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
  125. LEFT JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
  126. LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.target_group_id = D.group_id)
  127. <where>
  128. <if test="ocId != null">
  129. AND A.oc_id = #{ocId}
  130. </if>
  131. <if test="checklistId != null">
  132. AND A.checklist_id = #{checklistId}
  133. </if>
  134. <if test="targetType != null">
  135. AND B.target_type = #{targetType}
  136. </if>
  137. <if test="checklistCatId != null">
  138. AND B.checklist_cat_id = #{checklistCatId}
  139. </if>
  140. <if test="year != null">
  141. AND YEAR(A.record_time) = #{year}
  142. </if>
  143. <if test="nodeLeft != null and nodeRight != null">
  144. <![CDATA[
  145. AND C.node_left >= #{nodeLeft, jdbcType=BIGINT}
  146. AND C.node_right <= #{nodeRight, jdbcType=BIGINT}
  147. ]]>
  148. </if>
  149. </where>
  150. </select>
  151. <resultMap id="GroupMonthResultMap" type="com.zhyc.xps.hos.vo.SatisfyGroupMonthVo">
  152. <result column="group_id" property="groupId" jdbcType="BIGINT" />
  153. <result column="group_name" property="groupName" jdbcType="VARCHAR" />
  154. <result column="year" property="year" jdbcType="BIGINT" />
  155. <result column="month" property="month" jdbcType="BIGINT" />
  156. <result column="record_qty" property="recordQty" jdbcType="BIGINT" />
  157. <result column="target_qty" property="targetQty" jdbcType="BIGINT" />
  158. <result column="score" property="score" jdbcType="FLOAT" />
  159. </resultMap>
  160. <select id="groupMonthByList" parameterType="java.util.Map" resultMap="GroupMonthResultMap" >
  161. SELECT
  162. D.group_id,
  163. D.group_name,
  164. YEAR(A.record_time) AS year,
  165. Month(A.record_time) AS month,
  166. COUNT(A.record_id) AS record_qty,
  167. COUNT(distinct(A.target_id)) AS target_qty,
  168. ROUND(AVG(A.score)*20, 1) AS score
  169. FROM checklist_record AS A
  170. JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
  171. JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
  172. JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.target_group_id = D.group_id)
  173. <where>
  174. <if test="ocId != null">
  175. AND A.oc_id = #{ocId}
  176. </if>
  177. <if test="checklistCatId != null">
  178. AND B.checklist_cat_id=#{checklistCatId}
  179. </if>
  180. <if test="recordTime != null">
  181. AND DATE_FORMAT(A.record_time,'%Y-%m-%d') = #{recordTime}
  182. </if>
  183. <if test="year != null">
  184. AND YEAR(A.record_time) = #{year}
  185. </if>
  186. <if test="month != null">
  187. AND MONTH(A.record_time) = #{month}
  188. </if>
  189. <if test="nodeLeft != null and nodeRight != null">
  190. <![CDATA[
  191. AND D.node_left >= #{nodeLeft, jdbcType=BIGINT}
  192. AND D.node_right <= #{nodeRight, jdbcType=BIGINT}
  193. ]]>
  194. </if>
  195. </where>
  196. GROUP BY D.group_id, YEAR(A.record_time), Month(A.record_time)
  197. </select>
  198. <resultMap id="GroupChecklistMonthResultMap" type="com.zhyc.xps.hos.vo.SatisfyGroupChecklistMonthVo">
  199. <result column="group_id" property="groupId" jdbcType="BIGINT" />
  200. <result column="group_name" property="groupName" jdbcType="VARCHAR" />
  201. <result column="year" property="year" jdbcType="BIGINT" />
  202. <result column="month" property="month" jdbcType="BIGINT" />
  203. <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
  204. <result column="checklist_title" property="checklistTitle" jdbcType="VARCHAR" />
  205. <result column="record_qty" property="recordQty" jdbcType="BIGINT" />
  206. <result column="target_qty" property="targetQty" jdbcType="BIGINT" />
  207. <result column="score" property="score" jdbcType="FLOAT" />
  208. </resultMap>
  209. <select id="groupChecklistMonthByList" parameterType="java.util.Map" resultMap="GroupChecklistMonthResultMap" >
  210. SELECT
  211. D.group_id,
  212. D.group_name,
  213. YEAR(A.record_time) AS year,
  214. Month(A.record_time) AS month,
  215. C.target_type,
  216. A.checklist_id,
  217. B.checklist_title,
  218. COUNT(A.record_id) AS record_qty,
  219. COUNT(distinct(A.target_id)) AS target_qty,
  220. ROUND(AVG(A.score)*20, 1) AS score
  221. FROM checklist_record AS A
  222. JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
  223. JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
  224. JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.target_group_id = D.group_id)
  225. <where>
  226. <if test="ocId != null">
  227. AND A.oc_id = #{ocId}
  228. </if>
  229. <if test="checklistCatId != null">
  230. AND B.checklist_cat_id=#{checklistCatId}
  231. </if>
  232. <if test="recordTime != null">
  233. AND DATE_FORMAT(A.record_time,'%Y-%m-%d') = #{recordTime}
  234. </if>
  235. <if test="year != null">
  236. AND YEAR(A.record_time) = #{year}
  237. </if>
  238. <if test="month != null">
  239. AND MONTH(A.record_time) = #{month}
  240. </if>
  241. <if test="nodeLeft != null and nodeRight != null">
  242. <![CDATA[
  243. AND D.node_left >= #{nodeLeft, jdbcType=BIGINT}
  244. AND D.node_right <= #{nodeRight, jdbcType=BIGINT}
  245. ]]>
  246. </if>
  247. </where>
  248. GROUP BY A.checklist_id
  249. </select>
  250. <resultMap id="GroupChecklistMonthScoreCounterResultMap" type="com.zhyc.xps.hos.vo.SatisfyGroupChecklistMonthScoreCounterVo">
  251. <result column="group_id" property="groupId" jdbcType="BIGINT" />
  252. <result column="group_title" property="groupName" jdbcType="VARCHAR" />
  253. <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
  254. <result column="checklist_title" property="checklistTitle" jdbcType="VARCHAR" />
  255. <result column="year" property="year" jdbcType="BIGINT" />
  256. <result column="m1" property="m1" jdbcType="FLOAT" />
  257. <result column="m2" property="m2" jdbcType="FLOAT" />
  258. <result column="m3" property="m3" jdbcType="FLOAT" />
  259. <result column="m4" property="m4" jdbcType="FLOAT" />
  260. <result column="m5" property="m5" jdbcType="FLOAT" />
  261. <result column="m6" property="m6" jdbcType="FLOAT" />
  262. <result column="m7" property="m7" jdbcType="FLOAT" />
  263. <result column="m8" property="m8" jdbcType="FLOAT" />
  264. <result column="m9" property="m9" jdbcType="FLOAT" />
  265. <result column="m10" property="m10" jdbcType="FLOAT" />
  266. <result column="m11" property="m11" jdbcType="FLOAT" />
  267. <result column="m12" property="m12" jdbcType="FLOAT" />
  268. </resultMap>
  269. <select id="groupChecklistMonthScoreCounterByList" resultMap="GroupChecklistMonthScoreCounterResultMap">
  270. SELECT
  271. D.group_id,
  272. D.group_name,
  273. C.target_type,
  274. A.checklist_id,
  275. B.checklist_title,
  276. YEAR(A.record_time) AS year,
  277. CASE MONTH(A.record_time) when 1 then ROUND(AVG(A.score)*20, 1) else 0 end AS m1,
  278. CASE MONTH(A.record_time) when 2 then ROUND(AVG(A.score)*20, 1) else 0 end AS m2,
  279. CASE MONTH(A.record_time) when 3 then ROUND(AVG(A.score)*20, 1) else 0 end AS m3,
  280. CASE MONTH(A.record_time) when 4 then ROUND(AVG(A.score)*20, 1) else 0 end AS m4,
  281. CASE MONTH(A.record_time) when 5 then ROUND(AVG(A.score)*20, 1) else 0 end AS m5,
  282. CASE MONTH(A.record_time) when 6 then ROUND(AVG(A.score)*20, 1) else 0 end AS m6,
  283. CASE MONTH(A.record_time) when 7 then ROUND(AVG(A.score)*20, 1) else 0 end AS m7,
  284. CASE MONTH(A.record_time) when 8 then ROUND(AVG(A.score)*20, 1) else 0 end AS m8,
  285. CASE MONTH(A.record_time) when 9 then ROUND(AVG(A.score)*20, 1) else 0 end AS m9,
  286. CASE MONTH(A.record_time) when 10 then ROUND(AVG(A.score)*20, 1) else 0 end AS m10,
  287. CASE MONTH(A.record_time) when 11 then ROUND(AVG(A.score)*20, 1) else 0 end AS m11,
  288. CASE MONTH(A.record_time) when 12 then ROUND(AVG(A.score)*20, 1) else 0 end AS m12
  289. FROM checklist_record AS A
  290. LEFT JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
  291. LEFT JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
  292. LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.target_group_id = D.group_id)
  293. <where>
  294. <if test="ocId != null">
  295. AND A.oc_id = #{ocId}
  296. </if>
  297. <if test="checklistId != null">
  298. AND A.checklist_id = #{checklistId}
  299. </if>
  300. <if test="targetType != null">
  301. AND B.target_type = #{targetType}
  302. </if>
  303. <if test="checklistCatId != null">
  304. AND B.checklist_cat_id = #{checklistCatId}
  305. </if>
  306. <if test="year != null">
  307. AND YEAR(A.record_time) = #{year}
  308. </if>
  309. <if test="nodeLeft != null and nodeRight != null">
  310. <![CDATA[
  311. AND C.node_left >= #{nodeLeft, jdbcType=BIGINT}
  312. AND C.node_right <= #{nodeRight, jdbcType=BIGINT}
  313. ]]>
  314. </if>
  315. </where>
  316. </select>
  317. <resultMap id="DoctorSatisfyResultMap" type="com.zhyc.xps.hos.vo.SatisfyDoctorVo">
  318. <result column="doctor_id" property="doctorId" jdbcType="BIGINT" />
  319. <result column="doctor_name" property="doctorName" jdbcType="VARCHAR" />
  320. <result column="record_qty" property="recordQty" jdbcType="BIGINT" />
  321. <result column="score" property="score" jdbcType="FLOAT" />
  322. </resultMap>
  323. <select id="doctorByList" resultMap="DoctorSatisfyResultMap">
  324. SELECT
  325. D.doctor_id,
  326. D.doctor_name,
  327. COUNT(A.record_id) AS record_qty,
  328. ROUND(AVG(A.score)*20, 1) AS score
  329. FROM checklist_record AS A
  330. JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
  331. JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
  332. JOIN hos_doctor AS D ON (A.oc_id = D.oc_id AND A.target_id = D.doctor_id)
  333. JOIN s_group AS E ON (D.oc_id = E.oc_id AND D.group_id = E.group_id)
  334. <where>
  335. <if test="ocId != null">
  336. AND A.oc_id = #{ocId}
  337. </if>
  338. <if test="targetType != null">
  339. AND C.target_type = #{targetType}
  340. </if>
  341. <if test="year != null">
  342. AND YEAR(A.record_time) = #{year}
  343. </if>
  344. <if test="month != null">
  345. AND MONTH(A.record_time) = #{month}
  346. </if>
  347. <if test="recordTime != null">
  348. AND DATE_FORMAT(A.record_time,'%Y-%m-%d') = #{recordTime}
  349. </if>
  350. <if test="nodeLeft != null and nodeRight != null">
  351. <![CDATA[
  352. AND E.node_left >= #{nodeLeft, jdbcType=BIGINT}
  353. AND E.node_right <= #{nodeRight, jdbcType=BIGINT}
  354. ]]>
  355. </if>
  356. </where>
  357. GROUP BY D.doctor_id
  358. </select>
  359. <resultMap id="GridResultMap" type="com.zhyc.xps.hos.vo.SatisfyGridVo">
  360. <result column="grid_id" property="gridId" jdbcType="BIGINT" />
  361. <result column="grid_title" property="gridTitle" jdbcType="VARCHAR" />
  362. <result column="record_qty" property="recordQty" jdbcType="BIGINT" />
  363. <result column="score" property="score" jdbcType="FLOAT" />
  364. </resultMap>
  365. <select id="gridByList" resultMap="GridResultMap">
  366. SELECT
  367. D.grid_id,
  368. D.grid_title,
  369. COUNT(A.record_id) AS record_qty,
  370. ROUND(AVG(A.score)*20, 1) AS score
  371. FROM checklist_record AS A
  372. JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
  373. JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
  374. JOIN ent_grid AS D ON (A.oc_id = D.oc_id AND A.target_id = D.grid_id)
  375. JOIN s_group AS E ON (D.oc_id = E.oc_id AND D.group_id = E.group_id)
  376. <where>
  377. <if test="ocId != null">
  378. AND A.oc_id = #{ocId}
  379. </if>
  380. <if test="checklistId != null">
  381. AND A.checklist_id = #{checklistId}
  382. </if>
  383. <if test="targetType != null">
  384. AND C.target_type = #{targetType}
  385. </if>
  386. <if test="checklistCatId != null">
  387. AND B.checklist_cat_id = #{checklistCatId}
  388. </if>
  389. <if test="year != null">
  390. AND YEAR(A.record_time) = #{year}
  391. </if>
  392. <if test="month != null">
  393. AND MONTH(A.record_time) = #{month}
  394. </if>
  395. <if test="recordTime != null">
  396. AND DATE_FORMAT(A.record_time,'%Y-%m-%d') = #{recordTime}
  397. </if>
  398. <if test="nodeLeft != null and nodeRight != null">
  399. <![CDATA[
  400. AND E.node_left >= #{nodeLeft, jdbcType=BIGINT}
  401. AND E.node_right <= #{nodeRight, jdbcType=BIGINT}
  402. ]]>
  403. </if>
  404. </where>
  405. GROUP BY D.grid_id
  406. </select>
  407. <resultMap id="GroupChecklistDayResultMap" type="com.zhyc.xps.hos.vo.SatisfyGroupChecklistDayVo">
  408. <result column="group_id" property="groupId" jdbcType="BIGINT" />
  409. <result column="group_name" property="groupName" jdbcType="VARCHAR" />
  410. <result column="year" property="year" jdbcType="BIGINT" />
  411. <result column="month" property="month" jdbcType="BIGINT" />
  412. <result column="day" property="day" jdbcType="BIGINT" />
  413. <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
  414. <result column="checklist_title" property="checklistTitle" jdbcType="BIGINT" />
  415. <result column="record_qty" property="recordQty" jdbcType="BIGINT" />
  416. <result column="target_qty" property="targetQty" jdbcType="BIGINT" />
  417. <result column="score" property="score" jdbcType="FLOAT" />
  418. </resultMap>
  419. <select id="groupChecklistDayByList" resultMap="GroupChecklistDayResultMap">
  420. SELECT
  421. D.group_id,
  422. D.group_name,
  423. A.checklist_id,
  424. B.checklist_title,
  425. YEAR(A.record_time) AS year,
  426. MONTH(A.record_time) AS month,
  427. DAY(A.record_time) AS day,
  428. COUNT(A.record_id) AS record_qty,
  429. COUNT(distinct(A.target_id)) AS target_qty,
  430. ROUND(AVG(A.score)*20, 1) AS score
  431. FROM checklist_record AS A
  432. JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
  433. JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
  434. JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.target_group_id = D.group_id)
  435. <where>
  436. <if test="ocId != null">
  437. AND A.oc_id = #{ocId}
  438. </if>
  439. <if test="checklistId != null">
  440. AND A.checklist_id = #{checklistId}
  441. </if>
  442. <if test="targetType != null">
  443. AND B.target_type = #{targetType}
  444. </if>
  445. <if test="checklistCatId != null">
  446. AND B.checklist_cat_id = #{checklistCatId}
  447. </if>
  448. <if test="year != null">
  449. AND YEAR(A.record_time) = #{year}
  450. </if>
  451. <if test="month != null">
  452. AND MONTH(A.record_time) = #{month}
  453. </if>
  454. <if test="nodeLeft != null and nodeRight != null">
  455. <![CDATA[
  456. AND D.node_left >= #{nodeLeft, jdbcType=BIGINT}
  457. AND D.node_right <= #{nodeRight, jdbcType=BIGINT}
  458. ]]>
  459. </if>
  460. </where>
  461. GROUP BY D.group_id, A.checklist_id, DAY(A.record_time)
  462. ORDER BY day
  463. </select>
  464. </mapper>