ToClientMapper.xml 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="org.dromara.system.mapper.app.ToClientMapper">
  6. <select id="selectScoreSheetMetadata" resultType="org.dromara.system.domain.vo.ScoreSheetVo">
  7. SELECT
  8. e.event_name as eventName,
  9. p.score_rule as scoreRule,
  10. p.project_name as projectName,
  11. p.project_type as projectType,
  12. p.classification as classification,
  13. p.gender as gender,
  14. p.rg_name as rgName,
  15. p.game_stage as gameStage,
  16. p.game_round as gameRound,
  17. DATE_FORMAT(p.start_time, '%Y-%m-%d %H:%i:%s') as startTime,
  18. (SELECT GROUP_CONCAT(name SEPARATOR ',') FROM game_referee WHERE del_flag = '0'
  19. AND event_id = p.event_id
  20. AND (JSON_CONTAINS(p.referee_group, JSON_ARRAY(referee_id))
  21. OR JSON_CONTAINS(p.referee_group, JSON_ARRAY(CAST(referee_id AS CHAR))))
  22. ) as refereeName,
  23. p.timing_format as timingFormat,
  24. (SELECT config_value FROM game_event_config WHERE event_id = p.event_id
  25. AND config_key = 'event_tip' AND del_flag = '0' LIMIT 1) as eventTip,
  26. IFNULL((SELECT COUNT(*) FROM game_athlete a WHERE a.event_id = p.event_id AND a.del_flag = '0'
  27. AND (JSON_CONTAINS(a.project_value, JSON_ARRAY(p.project_id))
  28. OR JSON_CONTAINS(a.project_value, JSON_ARRAY(CAST(p.project_id AS CHAR)))))
  29. , 0) as totalParticipants,
  30. IFNULL((SELECT COUNT(*)
  31. FROM game_score s
  32. JOIN game_athlete a ON s.athlete_id = a.athlete_id AND a.del_flag = '0'
  33. WHERE s.project_id = p.project_id AND s.del_flag = '0'
  34. AND ((p.classification = '0' AND s.individual_performance > 0) OR (p.classification = '1' AND s.team_performance > 0))
  35. )
  36. , 0) as finishedParticipants
  37. FROM game_event_project p
  38. JOIN game_event e ON p.event_id = e.event_id
  39. WHERE p.event_id = #{eventId} AND p.project_id = #{projectId} AND p.del_flag = '0'
  40. </select>
  41. <select id="selectScoreSheetItems" resultType="org.dromara.system.domain.vo.ScoreSheetItemVo">
  42. SELECT
  43. a.athlete_id as athleteId,
  44. a.team_id as teamId,
  45. a.athlete_code as athleteCode,
  46. a.name as name,
  47. t.team_name as teamName,
  48. a.track_index as trackIndex,
  49. s.score_id as scoreId,
  50. CASE
  51. WHEN p.classification = '0' THEN s.individual_performance
  52. ELSE s.team_performance
  53. END as score,
  54. s.fault_a as faultA,
  55. s.fault_b as faultB
  56. FROM game_athlete a
  57. LEFT JOIN game_team t ON a.team_id = t.team_id AND t.del_flag = '0'
  58. CROSS JOIN game_event_project p ON p.project_id = #{projectId}
  59. LEFT JOIN game_score s ON a.athlete_id = s.athlete_id AND s.project_id = #{projectId} AND s.del_flag = '0'
  60. WHERE a.event_id = #{eventId}
  61. AND a.del_flag = '0'
  62. AND (JSON_CONTAINS(a.project_value, JSON_ARRAY(#{projectId}))
  63. OR JSON_CONTAINS(a.project_value, JSON_ARRAY(CAST(#{projectId} AS CHAR))))
  64. ORDER BY a.track_index ASC, a.athlete_code ASC
  65. </select>
  66. <select id="selectScorePreviewList" resultType="org.dromara.system.domain.vo.ScorePreviewVo">
  67. SELECT
  68. s.score_id as scoreId,
  69. s.athlete_id as athleteId,
  70. s.team_id as teamId,
  71. a.athlete_code as athleteCode,
  72. a.name as name,
  73. t.team_name as teamName,
  74. CASE
  75. WHEN p.classification = '0' THEN CAST(s.individual_performance AS CHAR)
  76. ELSE CAST(s.team_performance AS CHAR)
  77. END as score,
  78. s.score_point as scorePoint,
  79. s.score_rank as scoreRank
  80. FROM game_score s
  81. LEFT JOIN game_athlete a ON s.athlete_id = a.athlete_id AND a.del_flag = '0'
  82. LEFT JOIN game_team t ON s.team_id = t.team_id AND t.del_flag = '0'
  83. JOIN game_event_project p ON s.project_id = p.project_id
  84. WHERE s.project_id = #{projectId} AND s.del_flag = '0'
  85. ORDER BY s.score_rank ASC, s.score_id DESC
  86. </select>
  87. </mapper>