Files
hzdyjs/backend/ruoyi-modules/ruoyi-cw/src/main/resources/mapper/CwProjectApprovalProcessMapper.xml
T
2025-09-07 14:58:44 +08:00

113 lines
5.7 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="org.dromara.cw.mapper.CwProjectApprovalProcessMapper">
<resultMap type="org.dromara.cw.domain.vo.CwProjectApprovalProcessVo" id="CwProjectApprovalProcessResult">
<result property="id" column="id" />
<result property="applicationId" column="application_id" />
<result property="applicationNo" column="application_no" />
<result property="processName" column="process_name" />
<result property="processStatus" column="process_status" />
<result property="totalNodes" column="total_nodes" />
<result property="currentNode" column="current_node" />
<result property="startTime" column="start_time" />
<result property="endTime" column="end_time" />
<result property="submitterId" column="submitter_id" />
<result property="submitterName" column="submitter_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectCwProjectApprovalProcessVo">
select
p.id, p.application_id, p.application_no, p.process_name, p.process_status,
p.total_nodes, p.current_node, p.start_time, p.end_time,
p.submitter_id, p.submitter_name,
p.create_by, p.create_time, p.update_by, p.update_time,
a.project_name,
u.nick_name as submitter_nick_name
from cw_project_approval_process p
left join cw_project_application a on p.application_id = a.id
left join sys_user u on p.submitter_id = u.user_id
</sql>
<select id="selectProcessList" parameterType="org.dromara.cw.domain.CwProjectApprovalProcess" resultMap="CwProjectApprovalProcessResult">
<include refid="selectCwProjectApprovalProcessVo"/>
<where>
p.deleted = 0
<if test="applicationId != null"> and p.application_id = #{applicationId}</if>
<if test="applicationNo != null and applicationNo != ''"> and p.application_no like concat('%', #{applicationNo}, '%')</if>
<if test="processName != null and processName != ''"> and p.process_name like concat('%', #{processName}, '%')</if>
<if test="processStatus != null and processStatus != ''"> and p.process_status = #{processStatus}</if>
<if test="submitterId != null"> and p.submitter_id = #{submitterId}</if>
<if test="submitterName != null and submitterName != ''"> and p.submitter_name like concat('%', #{submitterName}, '%')</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != ''"> and p.create_time &gt;= #{params.beginCreateTime}</if>
<if test="params.endCreateTime != null and params.endCreateTime != ''"> and p.create_time &lt;= #{params.endCreateTime}</if>
<if test="params.beginStartTime != null and params.beginStartTime != ''"> and p.start_time &gt;= #{params.beginStartTime}</if>
<if test="params.endStartTime != null and params.endStartTime != ''"> and p.start_time &lt;= #{params.endStartTime}</if>
</where>
order by p.create_time desc
</select>
<select id="selectByApplicationId" resultMap="CwProjectApprovalProcessResult">
<include refid="selectCwProjectApprovalProcessVo"/>
where p.application_id = #{applicationId} and p.deleted = 0
</select>
<select id="selectByApplicationNo" resultMap="CwProjectApprovalProcessResult">
<include refid="selectCwProjectApprovalProcessVo"/>
where p.application_no = #{applicationNo} and p.deleted = 0
</select>
<select id="selectMyProcesses" resultMap="CwProjectApprovalProcessResult">
<include refid="selectCwProjectApprovalProcessVo"/>
where p.submitter_id = #{submitterId} and p.deleted = 0
order by p.create_time desc
</select>
<select id="selectRunningProcesses" resultMap="CwProjectApprovalProcessResult">
<include refid="selectCwProjectApprovalProcessVo"/>
where p.process_status = 'running' and p.deleted = 0
order by p.start_time
</select>
<select id="selectOvertimeProcesses" resultMap="CwProjectApprovalProcessResult">
<include refid="selectCwProjectApprovalProcessVo"/>
where p.process_status = 'running'
and p.start_time &lt; date_sub(now(), interval #{hours} hour)
and p.deleted = 0
order by p.start_time
</select>
<select id="selectProcessStatistics" resultType="map">
select
p.process_status as status,
count(*) as count
from cw_project_approval_process p
where p.deleted = 0
<if test="submitterId != null"> and p.submitter_id = #{submitterId}</if>
group by p.process_status
order by count desc
</select>
<update id="updateCurrentNode">
update cw_project_approval_process
set current_node = #{currentNode}, update_by = #{updateBy}, update_time = now()
where id = #{id} and deleted = 0
</update>
<update id="updateProcessStatus">
update cw_project_approval_process
set process_status = #{status},
end_time = case when #{status} in ('completed', 'terminated') then now() else end_time end,
update_by = #{updateBy},
update_time = now()
where id = #{id} and deleted = 0
</update>
</mapper>