TrsNameResultsMapper.xml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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="com.ruoyi.project.mapper.TrsNameResultsMapper">
  6. <resultMap type="TrsNameResults" id="TrsNameResultsResult">
  7. <result property="id" column="id" />
  8. <result property="sitename" column="sitename" />
  9. <result property="sitetag" column="sitetag" />
  10. <result property="page" column="page" />
  11. <result property="wrongWord" column="wrong_word" />
  12. <result property="country" column="country" />
  13. <result property="dutyAll" column="duty_all" />
  14. <result property="dutyShort" column="duty_short" />
  15. <result property="sort" column="sort" />
  16. <result property="context" column="context" />
  17. <result property="time" column="time" />
  18. <result property="scantime" column="scantime" />
  19. <result property="status" column="status" />
  20. <result property="version" column="version" />
  21. <result property="datakey" column="datakey" />
  22. <result property="allcontext" column="allcontext" />
  23. </resultMap>
  24. <sql id="selectTrsNameResultsVo">
  25. select id, sitename,sitetag, page, wrong_word, country, duty_all, duty_short, sort, context, time,scantime, status,allcontext from trs_name_results
  26. </sql>
  27. <select id="selectId" parameterType="String" resultType="Long">
  28. select id from trs_name_results where datakey = #{datakey}
  29. </select>
  30. <select id="selectTrsNameResultsList" parameterType="TrsNameResults" resultMap="TrsNameResultsResult">
  31. <include refid="selectTrsNameResultsVo"/>
  32. <where>
  33. <if test="sitename != null and sitename != ''"> and sitename = #{sitename}</if>
  34. <if test="sitetag != null and sitetag != ''"> and sitetag = #{sitetag}</if>
  35. <if test="page != null and page != ''"> and page like concat('%', #{page}, '%')</if>
  36. <if test="wrongWord != null and wrongWord != ''"> and wrong_word like concat('%', #{wrongWord}, '%')</if>
  37. <if test="country != null and country != ''"> and country like concat('%', #{country}, '%')</if>
  38. <if test="dutyAll != null and dutyAll != ''"> and duty_all like concat('%', #{dutyAll}, '%')</if>
  39. <if test="dutyShort != null and dutyShort != ''"> and duty_short like concat('%', #{dutyShort}, '%')</if>
  40. <if test="sort != null and sort != ''"> and sort = #{sort}</if>
  41. <if test="context != null and context != ''"> and context like concat('%', #{context}, '%')</if>
  42. <if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and time between #{params.beginTime} and #{params.endTime}</if>
  43. <if test="status != null and status != ''"> and status = #{status}</if>
  44. <if test="version != null and version != ''"> and version = #{version}</if>
  45. <if test="datakey != null and datakey != ''"> and datakey = #{datakey}</if>
  46. </where>
  47. order by time desc
  48. </select>
  49. <select id="selectTrsNameResultsById" parameterType="Long" resultMap="TrsNameResultsResult">
  50. <include refid="selectTrsNameResultsVo"/>
  51. where id = #{id}
  52. </select>
  53. <insert id="insertTrsNameResults" parameterType="TrsNameResults" useGeneratedKeys="true" keyProperty="id">
  54. insert into trs_name_results
  55. <trim prefix="(" suffix=")" suffixOverrides=",">
  56. <if test="sitename != null">sitename,</if>
  57. <if test="sitetag != null">sitetag,</if>
  58. <if test="page != null">page,</if>
  59. <if test="wrongWord != null">wrong_word,</if>
  60. <if test="country != null">country,</if>
  61. <if test="dutyAll != null">duty_all,</if>
  62. <if test="dutyShort != null">duty_short,</if>
  63. <if test="sort != null">sort,</if>
  64. <if test="context != null">context,</if>
  65. <if test="time != null">time,</if>
  66. <if test="scantime != null">scantime,</if>
  67. <if test="status != null">status,</if>
  68. <if test="version != null">version,</if>
  69. <if test="datakey != null">datakey,</if>
  70. <if test="allcontext != null">allcontext,</if>
  71. </trim>
  72. <trim prefix="values (" suffix=")" suffixOverrides=",">
  73. <if test="sitename != null">#{sitename},</if>
  74. <if test="sitetag != null">#{sitetag},</if>
  75. <if test="page != null">#{page},</if>
  76. <if test="wrongWord != null">#{wrongWord},</if>
  77. <if test="country != null">#{country},</if>
  78. <if test="dutyAll != null">#{dutyAll},</if>
  79. <if test="dutyShort != null">#{dutyShort},</if>
  80. <if test="sort != null">#{sort},</if>
  81. <if test="context != null">#{context},</if>
  82. <if test="time != null">#{time},</if>
  83. <if test="scantime != null">#{scantime},</if>
  84. <if test="status != null">#{status},</if>
  85. <if test="version != null">#{version},</if>
  86. <if test="datakey != null">#{datakey},</if>
  87. <if test="allcontext != null">#{allcontext},</if>
  88. </trim>
  89. </insert>
  90. <update id="updateTrsNameResults" parameterType="TrsNameResults">
  91. update trs_name_results
  92. <trim prefix="SET" suffixOverrides=",">
  93. <if test="sitename != null">sitename = #{sitename},</if>
  94. <if test="sitetag != null">sitetag = #{sitetag},</if>
  95. <if test="page != null">page = #{page},</if>
  96. <if test="wrongWord != null">wrong_word = #{wrongWord},</if>
  97. <if test="country != null">country = #{country},</if>
  98. <if test="dutyAll != null">duty_all = #{dutyAll},</if>
  99. <if test="dutyShort != null">duty_short = #{dutyShort},</if>
  100. <if test="sort != null">sort = #{sort},</if>
  101. <if test="context != null">context = #{context},</if>
  102. <if test="time != null">time = #{time},</if>
  103. <if test="scantime != null">scantime = #{scantime},</if>
  104. <if test="status != null">status = #{status},</if>
  105. <if test="version != null">version = #{version},</if>
  106. <if test="datakey != null">datakey = #{datakey},</if>
  107. <if test="allcontext != null">allcontext = #{allcontext},</if>
  108. </trim>
  109. where id = #{id}
  110. </update>
  111. <delete id="deleteTrsNameResultsById" parameterType="Long">
  112. delete from trs_name_results where id = #{id}
  113. </delete>
  114. <delete id="deleteTrsNameResultsByIds" parameterType="String">
  115. delete from trs_name_results where id in
  116. <foreach item="id" collection="array" open="(" separator="," close=")">
  117. #{id}
  118. </foreach>
  119. </delete>
  120. <select id="getStatistics" parameterType="TrsNameResults" resultType="java.util.Map">
  121. SELECT
  122. /* 第一组:总体统计 */
  123. COUNT(DISTINCT datakey) AS errorWordCount,
  124. SUM(CASE WHEN status = '已处理' THEN 1 ELSE 0 END) AS processedCount,
  125. SUM(CASE WHEN status = '不必处理' THEN 1 ELSE 0 END) AS noNeedProcessCount,
  126. /* 第二组:严重性错误(errorGrade=1) */
  127. 0 AS errorWordCount2,
  128. 0 AS processedCount2,
  129. 0 AS noNeedProcessCount2,
  130. /* 第三组:一般性错误(errorGrade=2) */
  131. 0 AS errorWordCount3,
  132. 0 AS processedCount3,
  133. 0 AS noNeedProcessCount3
  134. FROM trs_name_results
  135. <where>
  136. <if test="sitename != null and sitename != ''"> and sitename = #{sitename}</if>
  137. <if test="sitetag != null and sitetag != ''"> and sitetag = #{sitetag}</if>
  138. <if test="page != null and page != ''"> and page = #{page}</if>
  139. <if test="wrongWord != null and wrongWord != ''"> and wrong_word = #{wrongWord}</if>
  140. <if test="country != null and country != ''"> and country = #{country}</if>
  141. <if test="dutyAll != null and dutyAll != ''"> and duty_all = #{dutyAll}</if>
  142. <if test="dutyShort != null and dutyShort != ''"> and duty_short = #{dutyShort}</if>
  143. <if test="sort != null and sort != ''"> and sort = #{sort}</if>
  144. <if test="context != null and context != ''"> and context like concat('%', #{context}, '%')</if>
  145. <if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and time between #{params.beginTime} and #{params.endTime}</if>
  146. <if test="status != null and status != ''"> and status = #{status}</if>
  147. <if test="version != null and version != ''"> and version = #{version}</if>
  148. <if test="datakey != null and datakey != ''"> and datakey = #{datakey}</if>
  149. </where>
  150. </select>
  151. </mapper>