Files
guoju0808/ry-api/ruoyi-business/src/main/resources/mapper/business/BizProjectPlanMapper.xml
T
2026-08-26 23:14:46 +08:00

133 lines
8.6 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.ruoyi.business.mapper.BizProjectPlanMapper">
<resultMap type="BizProjectPlan" id="BizProjectPlanResult">
<id property="planId" column="plan_id" />
<result property="planName" column="plan_name" />
<result property="planDirection" column="plan_direction" />
<result property="planDirectionId" column="plan_direction_id" />
<result property="planDirectionTitle" column="plan_direction_title" />
<result property="planCategory" column="plan_category" />
<result property="projectForm" column="project_form" />
<result property="designFileUrl" column="design_file_url" />
<result property="subjectDirection" column="subject_direction" />
<result property="status" column="status" />
<result property="isSettled" column="is_settled" />
<result property="projectNo" column="project_no" />
<result property="projectName" column="project_name" />
<result property="remark" column="remark" />
<result property="auditOpinion" column="audit_opinion" />
<result property="auditBy" column="audit_by" />
<result property="auditTime" column="audit_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" />
<result property="isDeleted" column="is_deleted" />
</resultMap>
<sql id="selectFields">
select p.plan_id, p.plan_name, p.plan_direction, p.plan_direction_id,
s.title as plan_direction_title,
p.plan_category, p.project_form, p.design_file_url, p.subject_direction, p.status, p.is_settled,
p.project_no, p.remark, p.audit_opinion, p.audit_by, p.audit_time, p.submitter_id,
COALESCE(bp.name, u.user_name) as submitter_name,
proj.project_name as project_name,
p.create_by, p.create_time, p.update_by, p.update_time, p.is_deleted
from biz_project_plan p
left join biz_special_plan s on s.id = p.plan_direction_id
left join sys_user u on u.user_id = p.submitter_id
left join biz_person bp on bp.user_id = u.user_id
left join biz_project proj on proj.project_no = p.project_no and proj.is_deleted = 0
</sql>
<select id="selectByPrimaryKey" resultMap="BizProjectPlanResult" parameterType="String">
<include refid="selectFields"/>
where p.plan_id = #{planId} and p.is_deleted = 0
</select>
<select id="selectList" resultMap="BizProjectPlanResult" parameterType="BizProjectPlan">
<include refid="selectFields"/>
<where>
p.is_deleted = 0
<if test="planName != null and planName != ''"> and p.plan_name like concat('%', #{planName}, '%')</if>
<if test="planDirectionId != null"> and p.plan_direction_id = #{planDirectionId}</if>
<if test="planCategory != null and planCategory != ''"> and p.plan_category = #{planCategory}</if>
<if test="projectForm != null and projectForm != ''"> and p.project_form = #{projectForm}</if>
<if test="submitterId != null"> and p.submitter_id = #{submitterId}</if>
<choose>
<!-- 选了具体状态: 等值匹配 -->
<when test="status != null and status != ''"> and p.status = #{status}</when>
<!-- 未选: 不加 status 过滤, 由前端按角色决定默认值 (经理侧默认查 1/2/3, 医生侧默认查全部含 0) -->
</choose>
<if test="remark != null and remark != ''"> and p.remark like concat('%', #{remark}, '%')</if>
</where>
order by p.plan_id desc
</select>
<insert id="insert" parameterType="BizProjectPlan">
insert into biz_project_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="planId != null and planId != ''">plan_id,</if>
<if test="planName != null and planName != ''">plan_name,</if>
<if test="planDirection != null and planDirection != ''">plan_direction,</if>
<if test="planDirectionId != null">plan_direction_id,</if>
<if test="planCategory != null and planCategory != ''">plan_category,</if>
<if test="projectForm != null and projectForm != ''">project_form,</if>
<if test="designFileUrl != null and designFileUrl != ''">design_file_url,</if>
<if test="subjectDirection != null and subjectDirection != ''">subject_direction,</if>
<if test="status != null">status,</if>
<if test="isSettled != null and isSettled != ''">is_settled,</if>
<if test="projectNo != null and projectNo != ''">project_no,</if>
<if test="remark != null">remark,</if>
<if test="submitterId != null">submitter_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="planId != null and planId != ''">#{planId},</if>
<if test="planName != null and planName != ''">#{planName},</if>
<if test="planDirection != null and planDirection != ''">#{planDirection},</if>
<if test="planDirectionId != null">#{planDirectionId},</if>
<if test="planCategory != null and planCategory != ''">#{planCategory},</if>
<if test="projectForm != null and projectForm != ''">#{projectForm},</if>
<if test="designFileUrl != null and designFileUrl != ''">#{designFileUrl},</if>
<if test="subjectDirection != null and subjectDirection != ''">#{subjectDirection},</if>
<if test="status != null">#{status},</if>
<if test="isSettled != null and isSettled != ''">#{isSettled},</if>
<if test="projectNo != null and projectNo != ''">#{projectNo},</if>
<if test="remark != null">#{remark},</if>
<if test="submitterId != null">#{submitterId},</if>
</trim>
</insert>
<update id="updateByPrimaryKey" parameterType="BizProjectPlan">
update biz_project_plan
<trim prefix="SET" suffixOverrides=",">
<if test="planName != null and planName != ''">plan_name = #{planName},</if>
<if test="planDirection != null and planDirection != ''">plan_direction = #{planDirection},</if>
<if test="planDirectionId != null">plan_direction_id = #{planDirectionId},</if>
<if test="planCategory != null and planCategory != ''">plan_category = #{planCategory},</if>
<if test="projectForm != null and projectForm != ''">project_form = #{projectForm},</if>
<if test="designFileUrl != null and designFileUrl != ''">design_file_url = #{designFileUrl},</if>
<if test="subjectDirection != null and subjectDirection != ''">subject_direction = #{subjectDirection},</if>
<if test="isSettled != null and isSettled != ''">is_settled = #{isSettled},</if>
<if test="projectNo != null and projectNo != ''">project_no = #{projectNo},</if>
<if test="auditOpinion != null and auditOpinion != ''">audit_opinion = #{auditOpinion},</if>
<if test="auditBy != null and auditBy != ''">audit_by = #{auditBy},</if>
<if test="auditTime != null and auditTime != ''">audit_time = #{auditTime},</if>
<if test="status != null">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="submitterId != null">submitter_id = #{submitterId},</if>
</trim>
where plan_id = #{planId}
</update>
<delete id="deleteByPrimaryKey" parameterType="String">
delete from biz_project_plan where plan_id = #{planId}
</delete>
<delete id="deleteByPrimaryKeys" parameterType="String">
delete from biz_project_plan where plan_id in
<foreach collection="planIds" item="planId" open="(" separator="," close=")">
#{planId}
</foreach>
</delete>
<!-- 软删除: 项目级联删除时按 projectNo 置 is_deleted=1 (biz_project_plan 用 project_no 关联项目) -->
<update id="softDeleteByProjectNo" parameterType="String">
update biz_project_plan set is_deleted = 1 where project_no = #{projectNo}
</update>
</mapper>