TaskMapper.xml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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.hssx.pcbms.mapper.TaskMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.hssx.pcbms.entity.Task">
  6. <id column="id" property="id" />
  7. <result column="name" property="name" />
  8. <result column="code" property="code" />
  9. <result column="plan_time" property="planTime" />
  10. <result column="work_load" property="workLoad" />
  11. <result column="recipient_id" property="recipientId" />
  12. <result column="payer" property="payer" />
  13. <result column="payee" property="payee" />
  14. <result column="fee" property="fee" />
  15. <result column="tag_id" property="tagId" />
  16. <result column="delay_time" property="delayTime" />
  17. <result column="state" property="state" />
  18. <result column="publish_id" property="publishId" />
  19. <result column="content" property="content" />
  20. <result column="indate" property="indate" />
  21. </resultMap>
  22. <resultMap id="BaseResultMapVO" type="com.hssx.pcbms.entity.vo.TaskDTO">
  23. <id column="id" property="id" />
  24. <result column="name" property="name" />
  25. <result column="code" property="code" />
  26. <result column="plan_time" property="planTime" />
  27. <result column="work_load" property="workLoad" />
  28. <result column="recipient_id" property="recipientId" />
  29. <result column="payer" property="payer" />
  30. <result column="payee" property="payee" />
  31. <result column="fee" property="fee" />
  32. <result column="tag_id" property="tagId" />
  33. <result column="delay_time" property="delayTime" />
  34. <result column="state" property="state" />
  35. <result column="publish_id" property="publishId" />
  36. <result column="publishName" property="publisherName" />
  37. <result column="tagname" property="tagName" />
  38. <result column="recipient" property="recipientName" />
  39. <result column="pHedaPic" property="publisherHedaPic" />
  40. <result column="rHedaPic" property="recipientHedaPic" />
  41. <result column="content" property="content" />
  42. <result column="indate" property="indate" />
  43. <collection property="participantsVOS" select="selectPaticaterByTaskId" column="id"
  44. ofType="com.hssx.pcbms.entity.vo.TaskParticipantsVO"/>
  45. </resultMap>
  46. <!-- 通用查询结果列 -->
  47. <sql id="Base_Column_List">
  48. id, name, code, plan_time, work_load, recipient_id, payer, payee, fee, tag_id, delay_time, state, publish_id,content
  49. </sql>
  50. <select id="selectListByCondition" resultMap="BaseResultMapVO">
  51. select
  52. t.id, t.name, t.code, t.plan_time, t.work_load, t.recipient_id,t.content,t.indate,
  53. t.payer, t.payee, t.fee, t.tag_id, t.delay_time, t.state, t.publish_id,
  54. u.name publishName,tt.name tagname,ru.name recipient,t.content,u.head_url pHedaPic,ru.head_url rHedaPic
  55. from
  56. task t
  57. left join user u
  58. on t.publish_id = u.id
  59. left join task_tags tt
  60. on tt.id = t.tag_id
  61. left join user ru
  62. on t.recipient_id = ru.id
  63. <where>
  64. t.state !=8
  65. <if test="taskVO.keyName != null and taskVO.keyName != ''">
  66. and t.name like concat('%',#{taskVO.keyName},'%')
  67. </if>
  68. <if test="taskVO.startTime != null and taskVO.startTime != ''and taskVO.endTime != null and taskVO.endTime != ''">
  69. and t.plan_time between #{taskVO.startTime} and #{taskVO.endTime}
  70. </if>
  71. <if test="taskVO.uid != null">
  72. and t.publish_id =#{taskVO.uid}
  73. </if>
  74. <if test="taskVO.tagId != null and taskVO.tagId != ''">
  75. and t.tag_id = #{taskVO.tagId}
  76. </if>
  77. <if test="taskVO.state != null">
  78. and t.state = #{taskVO.state}
  79. </if>
  80. </where>
  81. order by t.indate desc
  82. </select>
  83. <select id="selectListByTaskIds" resultMap="BaseResultMapVO">
  84. select
  85. t.id, t.name, t.code, t.plan_time, t.work_load, t.recipient_id,t.content,t.indate,
  86. t.payer, t.payee, t.fee, t.tag_id, t.delay_time, t.state, t.publish_id,
  87. u.name publishName,tt.name tagname,ru.name recipient,u.head_url pHedaPic,ru.head_url rHedaPic
  88. from
  89. task t
  90. left join user u
  91. on t.publish_id = u.id
  92. left join task_tags tt
  93. on tt.id = t.tag_id
  94. left join user ru
  95. on t.recipient_id = ru.id
  96. <where>
  97. <foreach collection="list" separator="," close=")" item="item" open="t.id in (" index="index">
  98. #{item}
  99. </foreach>
  100. and t.state !=8
  101. <if test="taskVO.keyName != null and taskVO.keyName != ''">
  102. and t.name like concat('%',#{taskVO.keyName},'%')
  103. </if>
  104. <if test="taskVO.startTime != null and taskVO.startTime != ''and taskVO.endTime != null and taskVO.endTime != ''">
  105. and t.plan_time between #{taskVO.startTime} and #{taskVO.endTime}
  106. </if>
  107. <if test="taskVO.tagId != null and taskVO.tagId != ''">
  108. and t.tag_id = #{taskVO.tagId}
  109. </if>
  110. <if test="taskVO.state != null">
  111. and t.state = #{taskVO.state}
  112. </if>
  113. </where>
  114. order by t.indate desc
  115. </select>
  116. <resultMap id="PaticaterMapVO" type="com.hssx.pcbms.entity.vo.TaskParticipantsVO">
  117. <id column="id" property="id" />
  118. <result column="user_id" property="userId" />
  119. <result column="task_id" property="taskId" />
  120. <result column="head_pic" property="headPic"/>
  121. <result column="name" property="userName"/>
  122. </resultMap>
  123. <select id="selectPaticaterByTaskId" resultMap="PaticaterMapVO">
  124. select tp.id, tp.user_id, tp.task_id,u.name
  125. from task_participants tp
  126. left join user u
  127. on tp.user_id = u.id
  128. where tp.task_id = #{id}
  129. </select>
  130. <select id="getDetailById" resultMap="BaseResultMapVO">
  131. select
  132. t.id, t.name, t.code, t.plan_time, t.work_load, t.recipient_id,t.indate,
  133. t.payer, t.payee, t.fee, t.tag_id, t.delay_time, t.state, t.publish_id,
  134. u.name publishName,tt.name tagname,ru.name recipient,t.content,u.head_url pHedaPic,ru.head_url rHedaPic
  135. from
  136. task t
  137. left join user u
  138. on t.publish_id = u.id
  139. left join task_tags tt
  140. on tt.id = t.tag_id
  141. left join user ru
  142. on t.recipient_id = ru.id
  143. <where>
  144. t.id = #{taskVO.id}
  145. </where>
  146. </select>
  147. </mapper>