GZMachinesWeb/resources/mybatis/wf/TaskRecordMapper.xml

361 lines
11 KiB
XML

<?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.bonus.wf.dao.TaskRecordDao" >
<resultMap id="taskRecord" type="com.bonus.wf.beans.TaskRecordBean">
<id property="id" column="id" />
<result property="processId" column="processId"/>
<result property="companyId" column="companyId"/>
<result property="processName" column="processName"/>
<result property="definitionId" column="definitionId"/>
<result property="definitionName" column="definitionName"/>
<result property="operationTime" column="operationTime"/>
<result property="operationUserId" column="operationId"/>
<result property="operationUserName" column="operationName"/>
<result property="checkerId" column="checkerId"/>
<result property="checkerName" column="checkerName"/>
<result property="definitionId" column="definitionId"/>
<result property="creatorName" column="creatorName"/>
<result property="isExamine2" column="isExamine2"/>
<result property="isApproval2" column="isApproval2"/>
<result property="responer2" column="responer2"/>
<result property="responer8" column="responer8"/>
<result property="responer11" column="responer11"/>
<result property="checkStatus12" column="checkStatus12"/>
<result property="isExamine12" column="isExamine12"/>
<result property="isApproval12" column="isApproval12"/>
<result property="checker12" column="checker12"/>
<result property="responer12" column="responer12"/>
<result property="responer18" column="responer18"/>
<result property="responer19" column="responer19"/>
<result property="responer20" column="responer20"/>
<result property="responer21" column="responer21"/>
<result property="responer22" column="responer22"/>
<result property="responer23" column="responer23"/>
<result property="responer24" column="responer24"/>
<result property="responer25" column="responer25"/>
<result property="number" column="number"/>
<result property="unitName" column="unitName"/>
<result property="projectName" column="projectName"/>
<result property="isFinish" column="isFinish"/>
</resultMap>
<select id="findAll" parameterType="com.bonus.wf.beans.TaskRecordBean" resultMap="taskRecord">
SELECT wtr.ID,wtr.DEFINITION_ID as definitionId,wtd.`NAME` as definishtionName,wtr.PROCESS_ID as processId,
wpd.`NAME` as processName,wtr.OPERATION_USER as operationUserId,pu.`NAME` as operationUserName,
wtr.OPERATION_TIME as operationTime,wtr.IS_FINISH as isFinish,wtr.REMARK
FROM wf_task_record wtr,wf_task_definition wtd,wf_process_record wpr,
wf_process_definition wpd,pm_user pu
WHERE wtr.DEFINITION_ID = wtd.ID AND wtr.PROCESS_ID = wpr.ID
AND wpr.PROCESS_ID = wpd.ID AND wtr.OPERATION_USER = pu.ID
AND wtr.IS_ACTIVE = 1
</select>
<select id="findUnFinishContent" parameterType="com.bonus.wf.beans.TaskRecordBean" resultMap="taskRecord">
(
SELECT
wtr.id AS id,
CASE
WHEN wtr.DEFINITION_ID IN (1,2,8) THEN wtr.NUMBER
WHEN wtr.DEFINITION_ID IN (5,11) THEN wtr1.NUMBER
END AS number,
wpd.NAME AS processName,
wtd.NAME AS definitionName,
pu.NAME AS creatorName,
DATE_FORMAT(wtr.OPERATION_TIME, '%Y-%m-%d') AS operationTime,
wtr.DEFINITION_ID AS definitionId,
CASE
WHEN wtr.DEFINITION_ID = 11 THEN wtr1.IS_FINISH
ELSE wtr.IS_FINISH
END AS isFinish,
'TASK' AS source
FROM
wf_task_record wtr
LEFT JOIN wf_task_record wtr1 ON wtr1.ID = wtr.SUP_ID
LEFT JOIN pm_user pu ON pu.id = wtr.OPERATION_USER
LEFT JOIN wf_task_definition wtd ON wtd.ID = wtr.DEFINITION_ID
LEFT JOIN wf_process_definition wpd ON wpd.id = wtr.PROCESS_ID
WHERE
wtr.DEFINITION_ID IN (1, 2, 5, 8, 11)
AND (
(wtr.DEFINITION_ID = 11 AND wtr1.IS_FINISH = #{param.isFinish})
OR (wtr.DEFINITION_ID != 11 AND wtr.IS_FINISH = #{param.isFinish})
)
AND wtr.IS_ACTIVE = 1
<if test="param.operationUserId != null and param.operationUserId != ''">
AND wtr.OPERATION_USER = #{param.operationUserId}
</if>
<if test="param.keyWord != null and param.keyWord != ''">
AND (
wpd.NAME LIKE CONCAT('%', #{param.keyWord}, '%')
OR wtd.NAME LIKE CONCAT('%', #{param.keyWord}, '%')
OR pu.NAME LIKE CONCAT('%', #{param.keyWord}, '%')
)
</if>
)
UNION ALL
(
SELECT
cpa.id AS id,
cpa.code AS number,
'用车计划' AS processName,
'用车申请' AS definitionName,
pu.NAME AS creatorName,
DATE_FORMAT(cpa.create_time, '%Y-%m-%d') AS operationTime,
NULL AS definitionId,
NULL AS isFinish,
'PLAN' AS source
FROM
car_plan_apply cpa
LEFT JOIN pm_user pu ON pu.id = cpa.creator
WHERE
cpa.status = '1'
<if test="param.operationUserId == '14'">
AND cpa.status_type = '3'
</if>
<if test="param.operationUserId in ('57','29','55','56','67')">
AND cpa.status_type = '4'
</if>
<if test="!(param.operationUserId == null
or param.operationUserId == ''
or param.operationUserId == '14'
or param.operationUserId in ('57','29','55','56','67'))">
AND 1 = 0
</if>
<if test="param.keyWord != null and param.keyWord != ''">
AND pu.NAME LIKE CONCAT('%', #{param.keyWord}, '%')
</if>
)
UNION ALL
(
SELECT
cpa.id AS id,
cpa.code AS number,
'派车计划' AS processName,
CASE cpo.type
WHEN 1 THEN '车辆派车'
WHEN 2 THEN '吊车派车'
ELSE '派车'
END AS definitionName,
pu.NAME AS creatorName,
DATE_FORMAT(cpo.create_time, '%Y-%m-%d') AS operationTime,
NULL AS definitionId,
cpo.status AS isFinish,
'OUT' AS source
FROM
car_plan_out cpo
LEFT JOIN pm_user pu ON pu.id = cpo.creator
LEFT JOIN car_plan_apply cpa ON cpo.apply_id = cpa.id
WHERE
1 = 1
<if test="param.operationUserId in ('57','29','55','56','67')">
AND cpo.status = '0'
</if>
<if test="param.operationUserId in ('49','50')">
AND cpo.status = '1'
</if>
<if test="!(param.operationUserId == null
or param.operationUserId == ''
or param.operationUserId in ('49','50')
or param.operationUserId in ('57','29','55','56','67'))">
AND 1 = 0
</if>
<if test="param.keyWord != null and param.keyWord != ''">
AND pu.NAME LIKE CONCAT('%', #{param.keyWord}, '%')
</if>
)
ORDER BY id DESC
</select>
<select id="find" parameterType="com.bonus.wf.beans.TaskRecordBean" resultMap="taskRecord">
SELECT wtr.ID,wtr.DEFINITION_ID as definitionId,wtd.`NAME` as definishtionName,wtr.PROCESS_ID as processId,
wpd.`NAME` as processName,wtr.OPERATION_USER as operationUserId,pu.`NAME` as operationUserName,
wtr.OPERATION_TIME as operationTime,wtr.IS_FINISH as isFinish,wtr.REMARK
FROM wf_task_record wtr,wf_task_definition wtd,wf_process_record wpr,
wf_process_definition wpd,pm_user pu
WHERE wtr.DEFINITION_ID = wtd.ID AND wtr.PROCESS_ID = wpr.ID
AND wpr.PROCESS_ID = wpd.ID AND wtr.OPERATION_USER = pu.ID
AND wtr.IS_ACTIVE = 1
where wtr.ID = #{id}
</select>
<select id="findTaskInfo" parameterType="com.bonus.wf.beans.TaskRecordBean" resultMap="taskRecord">
SELECT wtr.ID AS taskId
FROM wf_task_record wtr
LEFT JOIN wf_task_record wtr1 ON wtr1.ID = wtr.SUP_ID
LEFT JOIN wf_new_check wnc ON wnc.TASK_ID = wtr.ID
WHERE wtr.SUP_ID = #{taskId} AND wtr.DEFINITION_ID = #{definitionId}
</select>
<select id="findRepairTask" parameterType="com.bonus.wf.beans.TaskRecordBean" resultMap="taskRecord">
SELECT wtr.ID as taskId
FROM wf_task_record wtr
WHERE wtr.SUP_ID = #{taskId} AND wtr.DEFINITION_ID = #{definitionId} and wtr.IS_FINISH = 0
</select>
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
insert into wf_task_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="definitionId != null">
DEFINITION_ID,
</if>
<if test="processId != null">
PROCESS_ID,
</if>
<if test="operationUserId != null">
OPERATION_USER,
</if>
<if test="operationTime != null">
OPERATION_TIME,
</if>
<if test="number != null">
NUMBER,
</if>
<if test="isSplit != null">
IS_SPLIT,
</if>
<if test="isFinish != null">
IS_FINISH,
</if>
<if test="leasePerson != null">
LEASE_PERSON,
</if>
<if test="phone != null">
PHONE,
</if>
<if test="remark != null">
REMARK,
</if>
<if test="taskId != null">
SUP_ID,
</if>
<if test="subcontractors != null">
SUBCONTRACTORS_ID,
</if>
<if test="companyId != null">
org_id,
</if>
IS_ACTIVE,PLAN_OUT_ID
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="definitionId != null">
#{definitionId},
</if>
<if test="processId != null">
#{processId},
</if>
<if test="operationUserId != null">
#{operationUserId},
</if>
<if test="operationTime != null">
#{operationTime},
</if>
<if test="number != null">
#{number},
</if>
<if test="isFinish != null">
#{isFinish},
</if>
<if test="isSplit != null">
#{isSplit},
</if>
<if test="leasePerson != null">
#{leasePerson},
</if>
<if test="phone != null">
#{phone},
</if>
<if test="remark != null">
#{remark},
</if>
<if test="taskId != null">
#{taskId},
</if>
<if test="subcontractors != null">
#{subcontractors},
</if>
<if test="companyId != null">
#{companyId},
</if>
1,#{planOutId}
</trim>
</insert>
<select id="findNumber" parameterType="com.bonus.wf.beans.TaskRecordBean" resultType="java.lang.String">
SELECT COUNT(*) FROM wf_task_record wtr
WHERE wtr.OPERATION_TIME LIKE CONCAT("%",#{operationTime},"%")
AND wtr.DEFINITION_ID = #{definitionId}
</select>
<delete id="delete" parameterType="com.bonus.wf.beans.TaskRecordBean">
delete from wf_task_record where id = #{id}
</delete>
<update id="update" parameterType="com.bonus.wf.beans.TaskRecordBean">
update wf_task_record
<set>
<if test="definitionId != null">
DEFINITION_ID = #{definitionId},
</if>
<if test="processId != null">
PROCESS_ID = #{processId},
</if>
<if test="operationUserId !=null">
OPERATION_USER = #{operationUserId},
</if>
<if test="operationTime !=null">
OPERATION_TIME = #{operationTime},
</if>
<if test="number !=null">
NUMBER = #{number},
</if>
<if test="isFinish !=null">
IS_FINISH = #{isFinish},
</if>
<if test="isSplit !=null">
IS_SPLIT = #{isSplit},
</if>
<if test="companyId !=null">
ORG_ID = #{companyId},
</if>
<if test="remark != null">
REMARK = #{remark},
</if>
</set>
where id = #{id}
</update>
<insert id="addTaskAgreement" parameterType="com.bonus.wf.beans.TaskRecordBean">
insert into wf_agreement_task(TASK_ID,AGREEMENT_ID)
values(#{taskId},#{agreementId})
</insert>
<delete id="deleteBatch" parameterType="java.util.List">
DELETE FROM wf_process_record WHERE id in(
<foreach item="o" collection="list" open="" separator=","
close="">
#{o.id}
</foreach>
)
</delete>
<select id="checkTask" parameterType="java.lang.String" resultMap="taskRecord">
SELECT wtr.ID AS taskId,number
FROM wf_task_record wtr
WHERE wtr.SUP_ID = #{taskId} AND wtr.DEFINITION_ID = 20 AND wtr.IS_SPLIT = 0
</select>
</mapper>