WorkTaskRecordMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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) limit 1) as productionName,
  117. cc1.name AS cClienteleName,
  118. cc2.name AS cClienteleSubName,
  119. cl1.name AS cClienteleContactName,
  120. cl1.mobile AS cMobile,
  121. wtr.created as taskCreated
  122. FROM
  123. work_task_record wtr
  124. LEFT JOIN work_node_task wnt ON wnt.id = wtr.task_id
  125. inner JOIN (
  126. SELECT
  127. wn.name,
  128. wn.CODE,
  129. wfni.id,
  130. wfni.business_id ,
  131. wfni.business_sub_id,
  132. wfni.business_min_id,
  133. wfni.state
  134. FROM
  135. work_flow_node_instance wfni
  136. LEFT JOIN work_node wn ON wn.id = wfni.node_id
  137. WHERE
  138. wfni.business_type = 'MAJOR_BUSINESS'
  139. AND wfni.state = 'PENDING'
  140. AND wfni.deleted = 0
  141. AND wn.deleted = 0
  142. ) wfni ON wtr.instance_id = wfni.id
  143. LEFT JOIN major m ON m.id = wfni.business_id
  144. LEFT JOIN user u ON u.id = wtr.handler_id
  145. left join user u1 on u1.id = m.client_manager_id
  146. left join user u2 on u2.id = m.principal_id
  147. left join department d on d.id = m.department_id
  148. LEFT JOIN customer_company cc1 ON cc1.id = m.clientele_id
  149. LEFT JOIN customer_company cc2 ON cc2.id = m.clientele_sub_id
  150. LEFT JOIN customer_linkman cl1 ON cl1.id = m.clientele_contact_id
  151. WHERE
  152. wtr.handler_id =#{todoVO.handlerId}
  153. AND u.deleted = 0
  154. AND wnt.deleted = 0
  155. AND wtr.deleted = 0
  156. <if test="keyword!=null and keyword!='' ">
  157. and(
  158. m.name like concat ('%',#{keyword},'%')
  159. or m.order_id like concat('%',#{keyword},'%')
  160. or wfni.business_sub_id like concat('%',#{keyword},'%')
  161. or u1.name like concat ('%',#{keyword},'%')
  162. or u2.name like concat ('%',#{keyword},'%')
  163. or m.business_object_type like concat ('%',#{keyword},'%')
  164. or u.name like concat ('%',#{keyword},'%')
  165. or wfni.name like concat('%',#{keyword},'%')
  166. )
  167. </if>
  168. <if test="todoVO!=null and todoVO.nodeName!=null and todoVO.nodeName!='' ">
  169. and wfni.name = #{todoVO.nodeName}
  170. </if>
  171. <if test="todoVO!=null and todoVO.startDate!=null and todoVO.startDate!=''">
  172. and m.created &gt;= #{todoVO.startDate}
  173. </if>
  174. <if test="todoVO!=null and todoVO.endDate!=null and todoVO.endDate!=''">
  175. and m.created &lt;= #{todoVO.endDate}
  176. </if>
  177. <if test="todoVO != null and todoVO.getNodeIsBookbindingStamp">
  178. AND (wfni.code = 'STATEMENT_BOOKBINDING_STAMP' OR wfni.code = 'REPORT_BOOKBINDING_STAMP' OR wfni.code = 'LETTER_BOOKBINDING_STAMP')
  179. </if>
  180. <if test="todoVO != null and todoVO.getNodeIsRecheckArchiving">
  181. AND wfni.code = 'RECHECK_ARCHIVING'
  182. </if>
  183. <if test="todoVO != null and todoVO.getNodeIsCheckArchiving">
  184. AND wfni.code = 'CHECK_ARCHIVING'
  185. </if>
  186. ORDER BY wtr.created DESC
  187. </select>
  188. <select id="majorTaskDonePage" parameterType="com.dayou.vo.MajorTaskDoneVO" resultType="com.dayou.vo.MajorTaskDoneVO">
  189. SELECT
  190. wf.id,
  191. u.name AS handler,
  192. wf.handler_id,
  193. (case wf.state when 'PASS' then '提交' when 'REVERSE' then '退回' when 'TERMINATE' then '终止' else '-' end) as state,
  194. wf.handing_time as handingTimeLong,
  195. wf.comments,
  196. wf.business_type,
  197. m.id AS majorId,
  198. m.order_id,
  199. m.name AS majorName,
  200. wn.name AS nodeName,
  201. wf.created as finishTime,
  202. wf.business_sub_id as statementNo,
  203. ifnull(wf.business_min_id,wf.business_sub_id) as reportNo,
  204. wfni.state as instanceState,
  205. wfni.id as instanceId,
  206. (select name from major_production where deleted = 0 and report_no= (ifnull(wf.business_min_id,wf.business_sub_id))) as productionName,
  207. (select production from major_production where deleted = 0 and report_no= (ifnull(wf.business_min_id,wf.business_sub_id))) as productionType
  208. FROM
  209. (
  210. ( SELECT * FROM work_flow_log WHERE handler_id = #{todoVO.handlerId} and business_type='MAJOR_BUSINESS' ) wf
  211. LEFT JOIN ( SELECT id, node_id, business_id ,state FROM work_flow_node_instance ) wfni ON wf.instance_id = wfni.id
  212. LEFT JOIN ( SELECT id, name FROM work_node WHERE deleted = 0 ) wn ON wn.id = wfni.node_id
  213. LEFT JOIN ( SELECT id, order_id, name FROM major WHERE deleted = 0 ) m ON m.id = wf.business_id
  214. LEFT JOIN user u ON u.id = wf.handler_id
  215. )
  216. <where>
  217. <if test="keyword!=null and keyword!='' ">
  218. and (
  219. m.name like concat ('%',#{keyword},'%')
  220. or m.order_id like concat('%',#{keyword},'%')
  221. or wf.business_sub_id like concat('%',#{keyword},'%')
  222. )
  223. </if>
  224. <if test="todoVO!=null and todoVO.nodeName!=null and todoVO.nodeName!='' ">
  225. and wn.name = #{todoVO.nodeName}
  226. </if>
  227. <if test="todoVO!=null and todoVO.state!=null and todoVO.state!='' ">
  228. and wf.state = #{todoVO.state}
  229. </if>
  230. <if test="todoVO!=null and todoVO.startDate!=null and todoVO.startDate!=''">
  231. and wf.created &gt;= #{todoVO.startDate}
  232. </if>
  233. <if test="todoVO!=null and todoVO.endDate!=null and todoVO.endDate!=''">
  234. and wf.created &lt;= #{todoVO.endDate}
  235. </if>
  236. </where>
  237. ORDER BY
  238. wf.created DESC
  239. </select>
  240. <update id="batchFinishTask" parameterType="java.util.List">
  241. update work_task_record set finished = 1 ,finish_time = now() where id in (
  242. <foreach collection="ids" index="index" separator="," item="item">
  243. #{item}
  244. </foreach>
  245. )
  246. </update>
  247. <select id="personalTodoPage" parameterType="com.dayou.vo.TaskTodoVO" resultType="com.dayou.vo.PersonalTodoVO">
  248. SELECT
  249. wfni.id,
  250. wtr.id AS taskId,
  251. wfni.id AS currentNodeId,
  252. wfni.business_id,
  253. p.location,
  254. p.order_id,
  255. u1.name AS clientManager,
  256. wfni.name AS nodeName,
  257. wfni.code AS nodeCode,
  258. u.name AS handlerName,
  259. wtr.handler_id,
  260. wtr.finished AS taskFinished,
  261. p.created,
  262. cc.name AS clientName,
  263. cc1.name AS clientSubName,
  264. p.agent,
  265. cl.name AS contactName,
  266. cl.mobile AS contactTel,
  267. p.bailorA,
  268. p.bailorB,
  269. p.bailorA_tel,
  270. p.bailorB_tel,
  271. u2.name AS outwardStaffName,
  272. u3.name AS inwardStaffName,
  273. u4.name AS pricingStaffName,
  274. wfni.created AS nodeCreated,
  275. pt.acreage,
  276. pt.amount,
  277. pt.price,
  278. pt.is_online,
  279. c.comments
  280. FROM
  281. work_task_record wtr
  282. LEFT JOIN work_node_task wnt ON wnt.id = wtr.task_id
  283. INNER JOIN (
  284. SELECT
  285. wn.name,
  286. wn.CODE,
  287. wfni.id,
  288. wfni.business_id,
  289. wfni.state,
  290. wfni.created
  291. FROM
  292. work_flow_node_instance wfni
  293. LEFT JOIN work_node wn ON wn.id = wfni.node_id
  294. WHERE
  295. wfni.business_type = 'PERSONAL_BUSINESS'
  296. AND wfni.state = 'PENDING'
  297. AND wfni.deleted = 0
  298. AND wn.deleted = 0
  299. ) wfni ON wtr.instance_id = wfni.id
  300. LEFT JOIN personal p ON p.id = wfni.business_id
  301. LEFT JOIN customer_company cc ON cc.id = p.clientele_id
  302. LEFT JOIN customer_company cc1 ON cc1.id = p.clientele_sub_id
  303. LEFT JOIN customer_linkman cl ON cl.id = p.clientele_contact_id
  304. LEFT JOIN user u ON u.id = wtr.handler_id
  305. LEFT JOIN user u1 ON u1.id = p.client_manager_id
  306. LEFT JOIN user u2 ON u2.id = p.outward_staff
  307. LEFT JOIN user u3 ON u3.id = p.inward_staff
  308. LEFT JOIN user u4 ON u4.id = p.pricing_staff
  309. LEFT JOIN personal_target pt ON pt.personal_id = p.id
  310. left join (
  311. select business_id,comments from work_flow_log where concat(business_id,created) in (
  312. select concat(business_id,max(created)) from work_flow_log where business_type = 'PERSONAL_BUSINESS' and comments is not null group BY business_id
  313. )
  314. ) c on c.business_id = p.id
  315. WHERE
  316. wtr.handler_id = #{personal.handlerId}
  317. AND u.deleted = 0
  318. AND wnt.deleted = 0
  319. AND wtr.deleted = 0
  320. <if test="keyword!=null and keyword!='' ">
  321. and (
  322. p.location like concat ('%',#{keyword},'%')
  323. or p.order_id like concat('%',#{keyword},'%')
  324. or p.agent like concat('%',#{keyword},'%')
  325. or p.bailorA like concat('%',#{keyword},'%')
  326. or p.bailorB like concat('%',#{keyword},'%')
  327. or cc.name like concat('%',#{keyword},'%')
  328. or cc1.name like concat('%',#{keyword},'%')
  329. or cl.name like concat('%',#{keyword},'%')
  330. or p.bailorA_tel like concat('%',#{keyword},'%')
  331. or p.bailorB_tel like concat('%',#{keyword},'%')
  332. )
  333. </if>
  334. <if test="personal!=null and personal.startDate!=null and personal.startDate!=''">
  335. and p.created &gt;= #{personal.startDate}
  336. </if>
  337. <if test="personal!=null and personal.endDate!=null and personal.endDate!=''">
  338. and p.created &lt;= #{personal.endDate}
  339. </if>
  340. <if test="personal!=null and personal.nodeCode!=null and personal.nodeCode!=''">
  341. and wfni.code = #{personal.nodeCode}
  342. </if>
  343. <if test="personal!=null and personal.clientName!=null and personal.clientName!=''">
  344. and cc.name like concat('%',#{personal.clientName},'%')
  345. </if>
  346. <if test="personal!=null and personal.clientSubName!=null and personal.clientSubName!=''">
  347. and cc1.name like concat('%',#{personal.clientSubName},'%')
  348. </if>
  349. <if test="personal!=null and personal.clientManager!=null and personal.clientManager!='' ">
  350. and u1.name like concat('%',#{personal.clientManager},'%')
  351. </if>
  352. <if test="personal!=null and personal.outwardStaffName!=null and personal.outwardStaffName!='' ">
  353. and u2.name like concat('%',#{personal.outwardStaffName},'%')
  354. </if>
  355. <if test="personal!=null and personal.inwardStaffName!=null and personal.inwardStaffName!='' ">
  356. and u3.name like concat('%',#{personal.inwardStaffName},'%')
  357. </if>
  358. <if test="personal!=null and personal.pricingStaffName!=null and personal.pricingStaffName!='' ">
  359. and u4.name like concat('%',#{personal.pricingStaffName},'%')
  360. </if>
  361. <if test="personal!=null and personal.handlerName!=null and personal.handlerName!='' ">
  362. and u.name like concat('%',#{personal.handlerName},'%')
  363. </if>
  364. <if test="personal != null and personal.getNodeIsBookbindingStamp">
  365. AND (wfni.code = 'STATEMENT_BOOKBINDING_STAMP' OR wfni.code = 'REPORT_BOOKBINDING_STAMP' OR wfni.code = 'LETTER_BOOKBINDING_STAMP')
  366. </if>
  367. order by wfni.created DESC
  368. </select>
  369. <select id="personalTaskDonePage" parameterType="com.dayou.vo.PersonalTaskDoneVO" resultType="com.dayou.vo.PersonalTaskDoneVO">
  370. SELECT
  371. wf.id,
  372. u.name AS handler,
  373. wf.handler_id,
  374. (case wf.state when 'PASS' then '提交' when 'REVERSE' then '退回' when 'TERMINATE' then '终止' else '-' end) as state,
  375. wf.handing_time as handingTimeLong,
  376. wf.comments,
  377. wf.business_type,
  378. p.id AS personalId,
  379. p.order_id,
  380. p.location,
  381. p.clientName,
  382. p.clientSubName,
  383. p.bailorA,
  384. p.bailorB,
  385. wn.name AS nodeName,
  386. wf.created as finishTime,
  387. ifnull(wf.business_min_id,wf.business_sub_id) as reportNo,
  388. wfni.state as instanceState,
  389. wfni.id as instanceId
  390. FROM
  391. (
  392. ( SELECT * FROM work_flow_log WHERE handler_id = #{todoVO.handlerId} and business_type='PERSONAL_BUSINESS' ) wf
  393. LEFT JOIN ( SELECT id, node_id, business_id ,state FROM work_flow_node_instance ) wfni ON wf.instance_id = wfni.id
  394. LEFT JOIN ( SELECT id, name FROM work_node WHERE deleted = 0 ) wn ON wn.id = wfni.node_id
  395. LEFT JOIN ( SELECT p.id, p.order_id, p.location,cc.name as clientName,cc1.name as clientSubName,p.bailorA,p.bailorB FROM personal p left join customer_company cc on cc.id =
  396. p.clientele_id left join customer_company cc1 on cc1.id = p.clientele_sub_id
  397. WHERE p.deleted = 0) p ON p.id = wf.business_id
  398. LEFT JOIN user u ON u.id = wf.handler_id
  399. )
  400. <where>
  401. <if test="keyword!=null and keyword!='' ">
  402. and (
  403. p.location like concat ('%',#{keyword},'%')
  404. or p.order_id like concat('%',#{keyword},'%')
  405. or p.clientName like concat('%',#{keyword},'%')
  406. or p.clientSubName like concat('%',#{keyword},'%')
  407. or p.bailoraTel like concat('%',#{keyword},'%')
  408. or p.bailorbTel like concat('%',#{keyword},'%')
  409. )
  410. </if>
  411. <if test="todoVO!=null and todoVO.nodeName!=null and todoVO.nodeName!='' ">
  412. and wn.name = #{todoVO.nodeName}
  413. </if>
  414. <if test="todoVO!=null and todoVO.state!=null and todoVO.state!='' ">
  415. and wf.state = #{todoVO.state}
  416. </if>
  417. <if test="todoVO!=null and todoVO.startDate!=null and todoVO.startDate!=''">
  418. and wf.created &gt;= #{todoVO.startDate}
  419. </if>
  420. <if test="todoVO!=null and todoVO.endDate!=null and todoVO.endDate!=''">
  421. and wf.created &lt;= #{todoVO.endDate}
  422. </if>
  423. </where>
  424. ORDER BY
  425. wf.created DESC
  426. </select>
  427. <select id="majorTodoSimpleList" parameterType="java.lang.Long" resultType="com.dayou.vo.TaskTodoVO">
  428. SELECT
  429. wfni.id,
  430. wtr.id as taskId,
  431. wfni.id AS currentNodeId,
  432. wfni.business_sub_id as statementNo,
  433. wfni.business_min_id as reportNo,
  434. wfni.business_id,
  435. m.name as orderName,
  436. m.order_id,
  437. wfni.name AS nodeName,
  438. wfni.code as nodeCode,
  439. wfni.created as instanceCreated
  440. FROM
  441. work_task_record wtr
  442. inner JOIN (
  443. SELECT
  444. wn.name,
  445. wn.CODE,
  446. wfni.id,
  447. wfni.business_id ,
  448. wfni.business_sub_id,
  449. wfni.business_min_id,
  450. wfni.state,
  451. wfni.created
  452. FROM
  453. work_flow_node_instance wfni
  454. LEFT JOIN work_node wn ON wn.id = wfni.node_id
  455. WHERE
  456. wfni.business_type = 'MAJOR_BUSINESS'
  457. AND wfni.state = 'PENDING'
  458. AND wfni.deleted = 0
  459. AND wn.deleted = 0
  460. ) wfni ON wtr.instance_id = wfni.id
  461. LEFT JOIN major m ON m.id = wfni.business_id
  462. WHERE
  463. wtr.handler_id = #{handlerId}
  464. AND wtr.deleted = 0
  465. order by wfni.created limit 8
  466. </select>
  467. <select id="personalTodoSimpleList" parameterType="java.lang.Long" resultType="com.dayou.vo.PersonalTodoVO">
  468. SELECT
  469. wfni.id,
  470. wtr.id AS taskId,
  471. wfni.id AS currentNodeId,
  472. wfni.business_id,
  473. p.location,
  474. p.order_id,
  475. wfni.name AS nodeName,
  476. wfni.code AS nodeCode,
  477. wfni.created as instanceCreated
  478. FROM
  479. work_task_record wtr
  480. LEFT JOIN work_node_task wnt ON wnt.id = wtr.task_id
  481. INNER JOIN (
  482. SELECT
  483. wn.name,
  484. wn.CODE,
  485. wfni.id,
  486. wfni.business_id,
  487. wfni.state,
  488. wfni.created
  489. FROM
  490. work_flow_node_instance wfni
  491. LEFT JOIN work_node wn ON wn.id = wfni.node_id
  492. WHERE
  493. wfni.business_type = 'PERSONAL_BUSINESS'
  494. AND wfni.state = 'PENDING'
  495. AND wfni.deleted = 0
  496. AND wn.deleted = 0
  497. ) wfni ON wtr.instance_id = wfni.id
  498. LEFT JOIN personal p ON p.id = wfni.business_id
  499. WHERE
  500. wtr.handler_id = #{handlerId}
  501. AND wnt.deleted = 0
  502. AND wtr.deleted = 0
  503. order by wfni.created desc limit 8
  504. </select>
  505. <select id="getTodoTotalNum" parameterType="java.lang.Long" resultType="com.dayou.vo.BusinessTodoNum">
  506. SELECT
  507. wfni.business_type,
  508. count( wfni.id ) AS totalNum
  509. FROM
  510. work_task_record wtr
  511. INNER JOIN ( SELECT wfni.business_type, wfni.id FROM work_flow_node_instance wfni WHERE wfni.state = 'PENDING' AND wfni.deleted = 0 ) wfni ON wtr.instance_id = wfni.id
  512. WHERE
  513. wtr.handler_id = #{handlerId}
  514. AND wtr.deleted = 0
  515. GROUP BY
  516. wfni.business_type
  517. </select>
  518. <!--获取资产业务已办列表-->
  519. <select id="getAssetsTaskDoneList" resultType="com.dayou.vo.AssetsTaskDoneVO">
  520. SELECT DISTINCT
  521. (@i := @i + 1) AS id,
  522. instance.recordId,
  523. log.id AS logId,
  524. user.name AS handlerName,
  525. log.handler_id,
  526. (case log.state
  527. when 'PASS' then '提交'
  528. when 'REVERSE' then '退回'
  529. when 'TERMINATE' then '终止'
  530. else '-' end) AS state,
  531. log.handing_time AS handingTimeLong,
  532. log.comments,
  533. log.business_type,
  534. assets.id AS assetsId,
  535. assets.order_id AS orderId,
  536. assets.name AS assetsName,
  537. node.name AS nodeName,
  538. node.code AS nodeCode,
  539. log.created AS finishTime,
  540. instance.business_sub_id AS statementNo,
  541. (SELECT assets_name FROM assets_production WHERE assets_production.production_no = instance.business_sub_id) AS
  542. statementName,
  543. (SELECT assets_name FROM assets_production WHERE assets_production.production_no = instance.business_min_id limit 1) AS
  544. reportName,
  545. instance.business_min_id AS reportNo,
  546. instance.state AS instanceState,
  547. instance.id AS instanceId,
  548. instance.created AS startDate
  549. FROM
  550. (SELECT @i := 0) AS sort,
  551. work_flow_log AS log
  552. LEFT JOIN (SELECT work_flow_node_instance.id, node_id, business_id, state, business_sub_id,
  553. business_min_id,work_task_record.created,work_task_record.id AS recordId
  554. FROM work_flow_node_instance,work_task_record
  555. WHERE state = 'FINISHED'
  556. AND work_flow_node_instance.id = work_task_record.instance_id
  557. AND work_flow_node_instance.deleted = 0) AS instance ON log.instance_id = instance.id
  558. LEFT JOIN (SELECT id, name, code FROM work_node WHERE deleted = 0) AS node ON node.id = instance.node_id
  559. LEFT JOIN (SELECT id, order_id, name, department_id FROM assets WHERE deleted = 0) AS assets ON assets.id = log.business_id
  560. LEFT JOIN user ON user.id = log.handler_id
  561. <if test="assetsSelectDTO != null and assetsSelectDTO.selectByDepartment">
  562. INNER JOIN (
  563. SELECT DISTINCT
  564. department.id,
  565. department.parent_id,
  566. user.id AS userId
  567. FROM
  568. user,
  569. post,
  570. department,
  571. user_post ,
  572. work_task_record AS record
  573. WHERE
  574. user.id = user_post.user_id
  575. AND user_post.post_id = post.id
  576. AND post.department_id = department.id
  577. AND user_post.deleted = 0
  578. ) AS department ON (department.id IN
  579. <foreach collection="assetsSelectDTO.departmentIdList" index="index" item="item" open="(" separator=","
  580. close=")">
  581. #{item}
  582. </foreach>
  583. )
  584. AND department.userId = log.handler_id
  585. </if>
  586. WHERE instance.id IS NOT NULL
  587. AND log.business_type = 'ASSET_BUSINESS'
  588. <if test="assetsSelectDTO != null and assetsSelectDTO.handlerId != null">
  589. AND handler_id = #{assetsSelectDTO.handlerId}
  590. </if>
  591. <if test="assetsSelectDTO != null and assetsSelectDTO.keyWord != null and assetsSelectDTO.keyWord != '' ">
  592. AND (
  593. assets.order_id LIKE CONCAT('%',#{assetsSelectDTO.keyWord},'%') OR
  594. assets.name LIKE CONCAT('%',#{assetsSelectDTO.keyWord},'%') OR
  595. instance.business_sub_id LIKE CONCAT('%',#{assetsSelectDTO.keyWord},'%') OR
  596. instance.business_min_id LIKE CONCAT('%',#{assetsSelectDTO.keyWord},'%')
  597. )
  598. </if>
  599. <if test="assetsSelectDTO != null and assetsSelectDTO.nodeCode != null">
  600. AND node.code = #{assetsSelectDTO.nodeCode}
  601. </if>
  602. <if test="assetsSelectDTO != null and assetsSelectDTO.departmentId">
  603. AND assets.department_id = #{assetsSelectDTO.departmentId}
  604. </if>
  605. ORDER BY log.created DESC
  606. </select>
  607. <update id="batchFinishTaskByInstanceId" parameterType="java.util.List">
  608. update work_task_record set finished = 1 , finish_time = now() where instance_id in (
  609. <foreach collection="list" index="index" item="item" separator="," >
  610. #{item}
  611. </foreach>
  612. )
  613. </update>
  614. </mapper>