HyWorkTaskMapper.xml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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.fs.qw.mapper.HyWorkTaskMapper">
  6. <resultMap type="QwWorkTask" id="HyWorkTaskResult">
  7. <result property="id" column="id" />
  8. <result property="extId" column="ext_id" />
  9. <result property="qwUserId" column="qw_user_id" />
  10. <result property="type" column="type" />
  11. <result property="status" column="status" />
  12. <result property="remark" column="remark" />
  13. <result property="score" column="score" />
  14. <result property="sopId" column="sop_id" />
  15. <result property="companyId" column="company_id" />
  16. <result property="companyUserId" column="company_user_id" />
  17. <result property="createTime" column="create_time" />
  18. <result property="updateTime" column="update_time" />
  19. <result property="title" column="title" />
  20. </resultMap>
  21. <sql id="selectHyWorkTaskVo">
  22. select id, ext_id, qw_user_id, type,title, status, remark, score, sop_id, company_id, company_user_id, create_time, update_time from hy_work_task
  23. </sql>
  24. <select id="selectHyWorkTaskList" parameterType="QwWorkTask" resultMap="HyWorkTaskResult">
  25. <include refid="selectHyWorkTaskVo"/>
  26. <where>
  27. <if test="extId != null "> and ext_id = #{extId}</if>
  28. <if test="qwUserId != null "> and qw_user_id = #{qwUserId}</if>
  29. <if test="type != null "> and type = #{type}</if>
  30. <if test="status != null "> and status = #{status}</if>
  31. <if test="score != null "> and score = #{score}</if>
  32. <if test="sopId != null and sopId != ''"> and sop_id = #{sopId}</if>
  33. <if test="companyId != null "> and company_id = #{companyId}</if>
  34. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  35. </where>
  36. </select>
  37. <select id="selectHyWorkTaskById" parameterType="Long" resultMap="HyWorkTaskResult">
  38. <include refid="selectHyWorkTaskVo"/>
  39. where id = #{id}
  40. </select>
  41. <select id="selectHyWorkTaskListVONew" resultType="com.fs.qw.vo.QwWorkTaskListVO">
  42. SELECT t.*
  43. FROM hy_work_task t
  44. INNER JOIN (
  45. SELECT t_inner.id
  46. FROM qw_work_task t_inner
  47. <where>
  48. DATE(t_inner.create_time) = CURDATE()
  49. <if test="extId != null "> and t_inner.ext_id = #{extId}</if>
  50. <if test="qwUserId != null "> and t_inner.qw_user_id = #{qwUserId}</if>
  51. <if test="type != null "> and t_inner.type = #{type}</if>
  52. <if test="status != null "> and t_inner.status = #{status}</if>
  53. <if test="score != null "> and t_inner.score = #{score}</if>
  54. <if test="sopId != null and sopId != ''"> and t_inner.sop_id = #{sopId}</if>
  55. <if test="companyId != null "> and t_inner.company_id = #{companyId}</if>
  56. <if test="companyUserId != null "> and t_inner.company_user_id = #{companyUserId}</if>
  57. </where>
  58. ORDER BY t_inner.score DESC, t_inner.id DESC
  59. LIMIT ${(pageNum-1)*pageSize}, ${pageSize}
  60. ) AS filtered_ids ON t.id = filtered_ids.id
  61. ORDER BY t.score DESC, t.id DESC
  62. </select>
  63. <select id="selectHyWorkTaskListByMap" resultType="com.fs.qw.domain.QwWorkTask">
  64. select
  65. qwt.*
  66. from hy_work_task qwt
  67. where qwt.qw_user_id = #{params.qwUserId}
  68. and date(qwt.create_time) = #{params.date}
  69. and qwt.company_id = #{params.companyId}
  70. and qwt.company_user_id = #{params.companyUserId}
  71. and qwt.status = 0
  72. </select>
  73. <select id="selectHyWorkTaskListVONewCount" resultType="java.lang.Long">
  74. select count(1) from hy_work_task t
  75. <where>
  76. DATE(t.create_time) = CURDATE()
  77. <if test="extId != null "> and t.ext_id = #{extId}</if>
  78. <if test="qwUserId != null "> and t.qw_user_id = #{qwUserId}</if>
  79. <if test="type != null "> and t.type = #{type}</if>
  80. <if test="status != null "> and t.status = #{status}</if>
  81. <if test="score != null "> and t.score = #{score}</if>
  82. <if test="sopId != null and sopId != ''"> and t.sop_id = #{sopId}</if>
  83. <if test="companyId != null "> and t.company_id = #{companyId}</if>
  84. <if test="companyUserId != null "> and t.company_user_id = #{companyUserId}</if>
  85. </where>
  86. order by t.score desc,t.id desc
  87. </select>
  88. <insert id="insertHyWorkTask" parameterType="QwWorkTask" useGeneratedKeys="true" keyProperty="id">
  89. insert into hy_work_task
  90. <trim prefix="(" suffix=")" suffixOverrides=",">
  91. <if test="extId != null">ext_id,</if>
  92. <if test="qwUserId != null">qw_user_id,</if>
  93. <if test="type != null">type,</if>
  94. <if test="status != null">status,</if>
  95. <if test="remark != null">remark,</if>
  96. <if test="score != null">score,</if>
  97. <if test="sopId != null">sop_id,</if>
  98. <if test="companyId != null">company_id,</if>
  99. <if test="companyUserId != null">company_user_id,</if>
  100. <if test="createTime != null">create_time,</if>
  101. <if test="updateTime != null">update_time,</if>
  102. <if test="title != null">title,</if>
  103. </trim>
  104. <trim prefix="values (" suffix=")" suffixOverrides=",">
  105. <if test="extId != null">#{extId},</if>
  106. <if test="qwUserId != null">#{qwUserId},</if>
  107. <if test="type != null">#{type},</if>
  108. <if test="status != null">#{status},</if>
  109. <if test="remark != null">#{remark},</if>
  110. <if test="score != null">#{score},</if>
  111. <if test="sopId != null">#{sopId},</if>
  112. <if test="companyId != null">#{companyId},</if>
  113. <if test="companyUserId != null">#{companyUserId},</if>
  114. <if test="createTime != null">#{createTime},</if>
  115. <if test="updateTime != null">#{updateTime},</if>
  116. <if test="title != null">#{title},</if>
  117. </trim>
  118. </insert>
  119. <update id="updateHyWorkTask" parameterType="QwWorkTask">
  120. update hy_work_task
  121. <trim prefix="SET" suffixOverrides=",">
  122. <if test="extId != null">ext_id = #{extId},</if>
  123. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  124. <if test="type != null">type = #{type},</if>
  125. <if test="status != null">status = #{status},</if>
  126. <if test="remark != null">remark = #{remark},</if>
  127. <if test="score != null">score = #{score},</if>
  128. <if test="sopId != null">sop_id = #{sopId},</if>
  129. <if test="companyId != null">company_id = #{companyId},</if>
  130. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  131. <if test="createTime != null">create_time = #{createTime},</if>
  132. <if test="updateTime != null">update_time = #{updateTime},</if>
  133. <if test="title != null">title = #{title},</if>
  134. </trim>
  135. where id = #{id}
  136. </update>
  137. <insert id="insertQwWorkTaskBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
  138. INSERT INTO hy_work_task (
  139. ext_id,
  140. qw_user_id,
  141. status,
  142. type,
  143. title,
  144. remark,
  145. score,
  146. sop_id,
  147. company_id,
  148. company_user_id,
  149. create_time,
  150. update_time
  151. )
  152. VALUES
  153. <foreach collection="qwWorkTasks" item="log" separator=",">
  154. (
  155. #{log.extId},
  156. #{log.qwUserId},
  157. #{log.status},
  158. #{log.type},
  159. #{log.title},
  160. #{log.remark},
  161. #{log.score},
  162. #{log.sopId},
  163. #{log.companyId},
  164. #{log.companyUserId},
  165. #{log.createTime},
  166. #{log.updateTime}
  167. )
  168. </foreach>
  169. </insert>
  170. <delete id="deleteHyWorkTaskById" parameterType="Long">
  171. delete from hy_work_task where id = #{id}
  172. </delete>
  173. <delete id="deleteHyWorkTaskByIds" parameterType="String">
  174. delete from hy_work_task where id in
  175. <foreach item="id" collection="array" open="(" separator="," close=")">
  176. #{id}
  177. </foreach>
  178. </delete>
  179. </mapper>