123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.dayou.mapper.WorkTaskRecordMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dayou.entity.WorkTaskRecord">
- <result column="id" property="id" />
- <result column="created" property="created" />
- <result column="modified" property="modified" />
- <result column="deleted" property="deleted" />
- <result column="instance_id" property="instanceId" />
- <result column="task_id" property="taskId" />
- <result column="handler_id" property="handlerId" />
- <result column="finished" property="finished" />
- <result column="finish_time" property="finishTime" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id,
- created,
- modified,
- deleted,
- instance_id, task_id, handler_id, finished, finish_time
- </sql>
- <update id="finishOpening">
- UPDATE work_task_record
- SET finished = 1,
- finish_time = now()
- WHERE
- instance_id = #{id}
- AND task_id = (
- SELECT
- wnt.id
- FROM
- `work_node_task` wnt
- LEFT JOIN work_node wn ON wn.id = wnt.node_id
- WHERE
- task_type = "OPENING"
- AND wn.flow_id = #{flowId}
- AND wnt.deleted = 0
- )
- AND deleted = 0
- </update>
- <select id="instanceNodeTasks" parameterType="java.lang.Long" resultType="com.dayou.dto.WorkNodeInstanceTaskDTO">
- SELECT
- wtr.id AS recordId,
- wtr.finished,
- wtr.handler_id,
- wnt.task_type,
- wnt.handler_permission,
- wnt.business_handle
- FROM
- work_task_record wtr
- LEFT JOIN work_node_task wnt ON wnt.id = wtr.task_id
- WHERE
- wtr.instance_id = #{instanceNodeId}
- AND wtr.deleted = 0
- </select>
- <select id="getNotBusinessHandleTaskId" parameterType="java.lang.Long" resultType="java.lang.Long">
- SELECT
- wtr.id
- FROM
- work_task_record wtr
- LEFT JOIN work_flow_node_instance wfni ON wtr.instance_id = wfni.id
- LEFT JOIN work_node_task wnt ON wtr.task_id = wnt.id
- WHERE
- wfni.id = #{instanceNodeId}
- AND wnt.deleted = 0
- AND wfni.deleted = 0
- AND wtr.deleted = 0
- AND wtr.finished = 0
- AND wnt.business_handle = 0
- </select>
- <select id="getInstanceTask" parameterType="java.lang.Long" resultType="com.dayou.vo.WorkTaskRecordVO">
- SELECT
- wtr.id,
- wfni.id AS instanceId,
- t.id AS taskId,
- u.name as handler,
- (case wtr.finished when 1 then '已完成' else '未完成' end) as finished,
- wtr.finish_time,
- t.description AS taskName,
- wfni.state AS nodeState
- FROM
- work_task_record wtr
- left join user u on u.id = wtr.handler_id
- LEFT JOIN work_node_task t ON t.id = wtr.task_id
- LEFT JOIN work_flow_node_instance wfni ON wfni.id = wtr.instance_id
- where wtr.instance_id = #{instanceId} and wtr.deleted = 0 and t.deleted = 0 and wfni.deleted = 0
- </select>
- <select id="taskTodoPage" parameterType="com.dayou.vo.TaskTodoVO" resultType="com.dayou.vo.TaskTodoVO">
- SELECT
- wfni.id,
- wtr.id as taskId,
- wfni.id AS currentNodeId,
- wfni.business_sub_id,
- wfni.business_sub_id as statementNo,
- wfni.business_min_id as reportNo,
- wfni.business_id,
- m.name as orderName,
- m.order_id,
- m.financial,
- m.allot_type,
- u1.name as clientManager,
- u2.name as principal,
- d.name as departmentName,
- m.business_object_type,
- wfni.name AS nodeName,
- wfni.code as nodeCode,
- u.name AS handler,
- wnt.description AS taskName,
- wtr.handler_id,
- wtr.finished as taskFinished,
- m.created,
- m.id as majorId,
- (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
- FROM
- work_task_record wtr
- LEFT JOIN work_node_task wnt ON wnt.id = wtr.task_id
- inner JOIN (
- SELECT
- wn.NAME,
- wn.CODE,
- wfni.id,
- wfni.business_id ,
- wfni.business_sub_id,
- wfni.business_min_id,
- wfni.state
- FROM
- work_flow_node_instance wfni
- LEFT JOIN work_node wn ON wn.id = wfni.node_id
- WHERE
- wfni.business_type = 'MAJOR_BUSINESS'
- AND wfni.state = 'PENDING'
- AND wfni.deleted = 0
- AND wn.deleted = 0
- ) wfni ON wtr.instance_id = wfni.id
- LEFT JOIN major m ON m.id = wfni.business_id
- LEFT JOIN user u ON u.id = wtr.handler_id
- left join user u1 on u1.id = m.client_manager_id
- left join user u2 on u2.id = m.principal_id
- left join department d on d.id = m.department_id
- WHERE
- wtr.handler_id =#{todoVO.handlerId}
- AND u.deleted = 0
- AND wnt.deleted = 0
- AND wtr.deleted = 0
- <if test="keyword!=null and keyword!='' ">
- and(
- m.name like concat ('%',#{keyword},'%')
- or m.order_id like concat('%',#{keyword},'%')
- or wfni.business_sub_id like concat('%',#{keyword},'%')
- or u1.name like concat ('%',#{keyword},'%')
- or u2.name like concat ('%',#{keyword},'%')
- or m.business_object_type like concat ('%',#{keyword},'%')
- or u.name like concat ('%',#{keyword},'%')
- or wfni.name like concat('%',#{keyword},'%')
- )
- </if>
- <if test="todoVO!=null and todoVO.nodeName!=null and todoVO.nodeName!='' ">
- and wfni.name = #{todoVO.nodeName}
- </if>
- <if test="todoVO!=null and todoVO.startDate!=null and todoVO.startDate!=''">
- and m.created >= #{todoVO.startDate}
- </if>
- <if test="todoVO!=null and todoVO.endDate!=null and todoVO.endDate!=''">
- and m.created <= #{todoVO.endDate}
- </if>
- ORDER BY
- wtr.created DESC
- </select>
- <select id="majorTaskDonePage" parameterType="com.dayou.vo.MajorTaskDoneVO" resultType="com.dayou.vo.MajorTaskDoneVO">
- SELECT
- wf.id,
- u.name AS handler,
- wf.handler_id,
- wf.state,
- wf.handing_time as handingTimeLong,
- wf.comments,
- wf.business_type,
- m.id AS majorId,
- m.order_id,
- m.name AS majorName,
- wn.name AS nodeName,
- wf.created as finishTime,
- ifnull(wf.business_min_id,wf.business_sub_id) as reportNo,
- wfni.state as instanceState,
- wfni.id as instanceId,
- (select name from major_production where deleted = 0 and report_no= (ifnull(wf.business_min_id,wf.business_sub_id))) as productionName
- FROM
- (
- ( SELECT * FROM work_flow_log WHERE handler_id = #{todoVO.handlerId} ) wf
- LEFT JOIN ( SELECT id, node_id, business_id ,state FROM work_flow_node_instance ) wfni ON wf.instance_id = wfni.id
- LEFT JOIN ( SELECT id, NAME FROM work_node WHERE deleted = 0 ) wn ON wn.id = wfni.node_id
- LEFT JOIN ( SELECT id, order_id, NAME FROM major WHERE deleted = 0 ) m ON m.id = wf.business_id
- LEFT JOIN user u ON u.id = wf.handler_id
- )
- <where>
- <if test="keyword!=null and keyword!='' ">
- and (
- m.name like concat ('%',#{keyword},'%')
- or m.order_id like concat('%',#{keyword},'%')
- or wf.business_sub_id like concat('%',#{keyword},'%')
- )
- </if>
- <if test="todoVO!=null and todoVO.nodeName!=null and todoVO.nodeName!='' ">
- and wn.name = #{todoVO.nodeName}
- </if>
- <if test="todoVO!=null and todoVO.state!=null and todoVO.state!='' ">
- and wf.state = #{todoVO.state}
- </if>
- <if test="todoVO!=null and todoVO.startDate!=null and todoVO.startDate!=''">
- and wf.created >= #{todoVO.startDate}
- </if>
- <if test="todoVO!=null and todoVO.endDate!=null and todoVO.endDate!=''">
- and wf.created <= #{todoVO.endDate}
- </if>
- </where>
- ORDER BY
- wf.created DESC
- </select>
- <update id="batchFinishTask" parameterType="java.util.List">
- update work_task_record set finished = 1 ,finish_time = now() where id in (
- <foreach collection="ids" index="index" separator="," item="item">
- #{item}
- </foreach>
- )
- </update>
- </mapper>
|