WorkTaskRecordMapper.xml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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.dayou.mapper.WorkTaskRecordMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.dayou.entity.WorkTaskRecord">
  6. <result column="id" property="id" />
  7. <result column="created" property="created" />
  8. <result column="modified" property="modified" />
  9. <result column="deleted" property="deleted" />
  10. <result column="instance_id" property="instanceId" />
  11. <result column="task_id" property="taskId" />
  12. <result column="handler_id" property="handlerId" />
  13. <result column="finished" property="finished" />
  14. <result column="finish_time" property="finishTime" />
  15. </resultMap>
  16. <!-- 通用查询结果列 -->
  17. <sql id="Base_Column_List">
  18. id,
  19. created,
  20. modified,
  21. deleted,
  22. instance_id, task_id, handler_id, finished, finish_time
  23. </sql>
  24. <update id="finishOpening">
  25. UPDATE work_task_record
  26. SET finished = 1,
  27. finish_time = now()
  28. WHERE
  29. instance_id = #{id}
  30. AND task_id = (
  31. SELECT
  32. wnt.id
  33. FROM
  34. `work_node_task` wnt
  35. LEFT JOIN work_node wn ON wn.id = wnt.node_id
  36. WHERE
  37. task_type = "OPENING"
  38. AND wnt.version = "LATEST"
  39. AND wn.flow_id = #{flowId}
  40. AND wnt.deleted = 0
  41. )
  42. AND deleted = 0
  43. </update>
  44. <select id="instanceNodeTasks" parameterType="java.lang.Long" resultType="com.dayou.dto.WorkNodeInstanceTaskDTO">
  45. SELECT
  46. wtr.id AS recordId,
  47. wtr.finished,
  48. wtr.handler_id,
  49. wnt.task_type,
  50. wnt.handler_permission,
  51. wnt.business_handle
  52. FROM
  53. work_task_record wtr
  54. LEFT JOIN work_node_task wnt ON wnt.id = wtr.task_id
  55. WHERE
  56. wtr.instance_id = #{instanceNodeId}
  57. AND wtr.deleted = 0
  58. </select>
  59. <select id="getNotBusinessHandleTaskId" parameterType="java.lang.Long" resultType="java.lang.Long">
  60. SELECT
  61. wtr.id
  62. FROM
  63. work_task_record wtr
  64. LEFT JOIN work_flow_node_instance wfni ON wtr.instance_id = wfni.id
  65. LEFT JOIN work_node_task wnt ON wtr.task_id = wnt.id
  66. WHERE
  67. wfni.id = #{instanceNodeId}
  68. AND wnt.deleted = 0
  69. AND wfni.deleted = 0
  70. AND wtr.deleted = 0
  71. AND wtr.finished = 0
  72. AND wnt.business_handle = 0
  73. </select>
  74. <select id="getInstanceTask" parameterType="java.lang.Long" resultType="com.dayou.vo.WorkTaskRecordVO">
  75. SELECT
  76. wtr.id,
  77. wfni.id AS instanceId,
  78. t.id AS taskId,
  79. u.name as handler,
  80. (case wtr.finished when 1 then '已完成' else '未完成' end) as finished,
  81. wtr.finish_time,
  82. t.description AS taskName,
  83. wfni.state AS nodeState
  84. FROM
  85. work_task_record wtr
  86. left join user u on u.id = wtr.handler_id
  87. LEFT JOIN work_node_task t ON t.id = wtr.task_id
  88. LEFT JOIN work_flow_node_instance wfni ON wfni.id = wtr.instance_id
  89. where wtr.instance_id = #{instanceId} and wtr.deleted = 0 and t.deleted = 0 and wfni.deleted = 0
  90. </select>
  91. <select id="taskTodoPage" parameterType="com.dayou.vo.TaskTodoVO" resultType="com.dayou.vo.TaskTodoVO">
  92. SELECT
  93. wfni.id,
  94. wtr.id as taskId,
  95. wfni.id AS currentNodeId,
  96. wfni.business_sub_id,
  97. wfni.business_sub_id as statementNo,
  98. wfni.business_min_id as reportNo,
  99. wfni.business_id,
  100. m.name as orderName,
  101. m.order_id,
  102. m.financial,
  103. m.allot_type,
  104. u1.name as clientManager,
  105. u2.name as principal,
  106. d.name as departmentName,
  107. m.business_object_type,
  108. wfni.name AS nodeName,
  109. wfni.code as nodeCode,
  110. u.name AS handler,
  111. wnt.description AS taskName,
  112. wtr.handler_id,
  113. wtr.finished as taskFinished,
  114. m.created,
  115. m.id as majorId,
  116. (select name from major_production where deleted = 0 and major_id = m.id and report_no= ifnull(wfni.business_min_id,wfni.business_sub_id)) as productionName
  117. FROM
  118. work_task_record wtr
  119. LEFT JOIN work_node_task wnt ON wnt.id = wtr.task_id
  120. inner JOIN (
  121. SELECT
  122. wn.NAME,
  123. wn.CODE,
  124. wfni.id,
  125. wfni.business_id ,
  126. wfni.business_sub_id,
  127. wfni.business_min_id,
  128. wfni.state
  129. FROM
  130. work_flow_node_instance wfni
  131. LEFT JOIN work_node wn ON wn.id = wfni.node_id
  132. WHERE
  133. wfni.business_type = 'MAJOR_BUSINESS'
  134. AND wfni.state = 'PENDING'
  135. AND wfni.deleted = 0
  136. AND wn.deleted = 0
  137. ) wfni ON wtr.instance_id = wfni.id
  138. LEFT JOIN major m ON m.id = wfni.business_id
  139. LEFT JOIN user u ON u.id = wtr.handler_id
  140. left join user u1 on u1.id = m.client_manager_id
  141. left join user u2 on u2.id = m.principal_id
  142. left join department d on d.id = m.department_id
  143. WHERE
  144. wtr.handler_id =#{todoVO.handlerId}
  145. AND u.deleted = 0
  146. AND wnt.deleted = 0
  147. AND wtr.deleted = 0
  148. <if test="keyword!=null and keyword!='' ">
  149. and(
  150. m.name like concat ('%',#{keyword},'%')
  151. or m.order_id like concat('%',#{keyword},'%')
  152. or wfni.business_sub_id like concat('%',#{keyword},'%')
  153. or u1.name like concat ('%',#{keyword},'%')
  154. or u2.name like concat ('%',#{keyword},'%')
  155. or m.business_object_type like concat ('%',#{keyword},'%')
  156. or u.name like concat ('%',#{keyword},'%')
  157. or wfni.name like concat('%',#{keyword},'%')
  158. )
  159. </if>
  160. <if test="todoVO!=null and todoVO.nodeName!=null and todoVO.nodeName!='' ">
  161. and wfni.name = #{todoVO.nodeName}
  162. </if>
  163. <if test="todoVO!=null and todoVO.startDate!=null and todoVO.startDate!=''">
  164. and m.created &gt;= #{todoVO.startDate}
  165. </if>
  166. <if test="todoVO!=null and todoVO.endDate!=null and todoVO.endDate!=''">
  167. and m.created &lt;= #{todoVO.endDate}
  168. </if>
  169. ORDER BY
  170. wtr.created DESC
  171. </select>
  172. <select id="majorTaskDonePage" parameterType="com.dayou.vo.MajorTaskDoneVO" resultType="com.dayou.vo.MajorTaskDoneVO">
  173. SELECT
  174. wf.id,
  175. u.name AS handler,
  176. wf.handler_id,
  177. wf.state,
  178. wf.handing_time as handingTimeLong,
  179. wf.comments,
  180. wf.business_type,
  181. m.id AS majorId,
  182. m.order_id,
  183. m.name AS majorName,
  184. wn.name AS nodeName,
  185. wf.created as finishTime,
  186. ifnull(wf.business_min_id,wf.business_sub_id) as reportNo,
  187. wfni.state as instanceState,
  188. wfni.id as instanceId,
  189. (select name from major_production where deleted = 0 and report_no= (ifnull(wf.business_min_id,wf.business_sub_id))) as productionName
  190. FROM
  191. (
  192. ( SELECT * FROM work_flow_log WHERE handler_id = #{todoVO.handlerId} ) wf
  193. LEFT JOIN ( SELECT id, node_id, business_id ,state FROM work_flow_node_instance ) wfni ON wf.instance_id = wfni.id
  194. LEFT JOIN ( SELECT id, NAME FROM work_node WHERE deleted = 0 ) wn ON wn.id = wfni.node_id
  195. LEFT JOIN ( SELECT id, order_id, NAME FROM major WHERE deleted = 0 ) m ON m.id = wf.business_id
  196. LEFT JOIN user u ON u.id = wf.handler_id
  197. )
  198. <where>
  199. <if test="keyword!=null and keyword!='' ">
  200. and (
  201. m.name like concat ('%',#{keyword},'%')
  202. or m.order_id like concat('%',#{keyword},'%')
  203. or wf.business_sub_id like concat('%',#{keyword},'%')
  204. )
  205. </if>
  206. <if test="todoVO!=null and todoVO.nodeName!=null and todoVO.nodeName!='' ">
  207. and wn.name = #{todoVO.nodeName}
  208. </if>
  209. <if test="todoVO!=null and todoVO.state!=null and todoVO.state!='' ">
  210. and wf.state = #{todoVO.state}
  211. </if>
  212. <if test="todoVO!=null and todoVO.startDate!=null and todoVO.startDate!=''">
  213. and wf.created &gt;= #{todoVO.startDate}
  214. </if>
  215. <if test="todoVO!=null and todoVO.endDate!=null and todoVO.endDate!=''">
  216. and wf.created &lt;= #{todoVO.endDate}
  217. </if>
  218. </where>
  219. ORDER BY
  220. wf.created DESC
  221. </select>
  222. <update id="batchFinishTask" parameterType="java.util.List">
  223. update work_task_record set finished = 1 ,finish_time = now() where id in (
  224. <foreach collection="ids" index="index" separator="," item="item">
  225. #{item}
  226. </foreach>
  227. )
  228. </update>
  229. </mapper>