WorkTaskRecordMapper.xml 9.4 KB

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