前端评价得分筛选 q.managerScore 之前透传到后端但 mapper 没读, 形同虚设。
在 selectList 加 <if test="managerScore != null">and manager_score = #{managerScore}</if>,
跟 INSERT/UPDATE 同款 BigDecimal null check 风格 (无需 != '')。
EXPLAIN 验证: 12 行数据走 PRIMARY Backward scan, 命中 1 行 manager_score=5。
309 lines
21 KiB
XML
309 lines
21 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.BizProjectMapper">
|
|
<resultMap type="BizProject" id="BizProjectResult">
|
|
<id property="projectId" column="project_id" />
|
|
<result property="projectNo" column="project_no" />
|
|
<result property="projectName" column="project_name" />
|
|
<result property="totalSessions" column="total_sessions" />
|
|
<result property="assignedSessions" column="assigned_sessions" />
|
|
<result property="assignedAmount" column="assigned_amount" />
|
|
<result property="doneSessions" column="done_sessions" />
|
|
<result property="todoSessions" column="todo_sessions" />
|
|
<result property="totalAmount" column="total_amount" />
|
|
<result property="availableAmount" column="available_amount" />
|
|
<result property="paidLaborAmount" column="paid_labor_amount" />
|
|
<result property="paidMeetingAmount" column="paid_meeting_amount" />
|
|
<result property="managerScore" column="manager_score" />
|
|
<result property="sponsorScore" column="sponsor_score" />
|
|
<result property="sponsorAdminUserName" column="sponsor_admin_user_name" />
|
|
<result property="sponsorAdminUserId" column="sponsor_admin_user_id" />
|
|
<result property="leadUserId" column="lead_user_id" />
|
|
<result property="leadUserName" column="lead_user_name" />
|
|
<result property="isBidProject" column="is_bid_project" />
|
|
<result property="sponsorOrgName" column="sponsor_org_name" />
|
|
<result property="execOrgNames" column="exec_org_names" />
|
|
<result property="projectForm" column="project_form" />
|
|
<result property="isFinished" column="is_finished" />
|
|
<result property="isSettled" column="is_settled" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createUserId" column="create_user_id" />
|
|
<result property="createUserName" column="create_user_name" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="manageFee" column="manage_fee" />
|
|
<result property="startTime" column="start_time" />
|
|
<result property="endTime" column="end_time" />
|
|
<result property="submitDeadlineDays" column="submit_deadline_days" />
|
|
<result property="supportContractUrl" column="support_contract_url" />
|
|
<result property="executeContractUrl" column="execute_contract_url" />
|
|
<result property="invitationUrl" column="invitation_url" />
|
|
<result property="supportLetterUrl" column="support_letter_url" />
|
|
<result property="publishUrl" column="publish_url" />
|
|
</resultMap>
|
|
<sql id="selectFields">
|
|
select p.project_id, p.project_no, p.project_name, p.total_sessions, p.done_sessions, p.todo_sessions, p.total_amount, p.available_amount, p.paid_labor_amount, p.paid_meeting_amount, p.manager_score, p.sponsor_score, p.sponsor_admin_user_name, p.project_form, p.is_finished, p.is_settled, p.sponsor_admin_user_id, p.lead_user_id, p.is_bid_project, p.create_by, p.create_user_id, p.create_time, p.update_by, p.update_time, p.manage_fee, p.start_time, p.end_time, p.submit_deadline_days, p.support_contract_url, p.execute_contract_url, p.invitation_url, p.support_letter_url, p.publish_url,
|
|
o.org_name as sponsor_org_name,
|
|
lu.user_name as lead_user_name,
|
|
bp.name as create_user_name,
|
|
(select group_concat(distinct o2.org_name separator ',')
|
|
from biz_project_assign bpa
|
|
join biz_org o2 on o2.org_id = bpa.execution_unit_id and o2.org_type = 'executor'
|
|
where bpa.project_id = p.project_id) as exec_org_names
|
|
from biz_project p
|
|
left join biz_org o on o.user_id = p.sponsor_admin_user_id and o.org_type = 'sponsor'
|
|
left join sys_user lu on lu.user_id = p.lead_user_id
|
|
left join biz_person bp on bp.user_id = p.create_user_id
|
|
</sql>
|
|
|
|
<!-- sponsor 端专属查询: 与 selectFields 等价 (sponsor 评分改走 biz_project_rating 子表, 这里只查项目本体) -->
|
|
<sql id="selectFieldsForSponsor">
|
|
select p.project_id, p.project_no, p.project_name, p.total_sessions, p.done_sessions, p.todo_sessions,
|
|
p.total_amount, p.available_amount, p.paid_labor_amount, p.paid_meeting_amount,
|
|
p.manager_score, p.sponsor_score, p.sponsor_admin_user_name, p.project_form, p.is_finished, p.is_settled,
|
|
p.sponsor_admin_user_id, p.lead_user_id, p.is_bid_project,
|
|
p.create_by, p.create_user_id, p.create_time, p.update_by, p.update_time, p.manage_fee,
|
|
p.start_time, p.end_time, p.submit_deadline_days,
|
|
p.support_contract_url, p.execute_contract_url, p.invitation_url, p.support_letter_url,
|
|
p.publish_url,
|
|
o.org_name as sponsor_org_name,
|
|
lu.user_name as lead_user_name,
|
|
bp.name as create_user_name,
|
|
(select group_concat(distinct o2.org_name separator ',')
|
|
from biz_project_assign bpa
|
|
join biz_org o2 on o2.org_id = bpa.execution_unit_id and o2.org_type = 'executor'
|
|
where bpa.project_id = p.project_id) as exec_org_names
|
|
from biz_project p
|
|
left join biz_org o on o.user_id = p.sponsor_admin_user_id and o.org_type = 'sponsor'
|
|
left join sys_user lu on lu.user_id = p.lead_user_id
|
|
left join biz_person bp on bp.user_id = p.create_user_id
|
|
</sql>
|
|
<select id="selectByPrimaryKey" resultMap="BizProjectResult" parameterType="Long">
|
|
<include refid="selectFields"/>
|
|
where project_id = #{projectId}
|
|
</select>
|
|
<!-- sponsor 专属列表 (走 params.projectIds + LEFT JOIN 当前 login 用户评分) -->
|
|
<select id="selectSponsorList" resultMap="BizProjectResult" parameterType="BizProject">
|
|
<include refid="selectFieldsForSponsor"/>
|
|
<where>
|
|
<if test="params.projectIds != null and params.projectIds.size() > 0">
|
|
and p.project_id in
|
|
<foreach collection="params.projectIds" item="id" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="params.sponsorAdminUserId != null">and p.sponsor_admin_user_id = #{params.sponsorAdminUserId}</if>
|
|
<if test="projectNo != null and projectNo != ''">and p.project_no like concat('%', #{projectNo}, '%')</if>
|
|
<if test="projectName != null and projectName != ''">and p.project_name like concat('%', #{projectName}, '%')</if>
|
|
<if test="startTime != null">and p.start_time >= #{startTime}</if>
|
|
<if test="endTime != null">and p.end_time <= #{endTime}</if>
|
|
<if test="isFinished != null and isFinished != ''">and p.is_finished = #{isFinished}</if>
|
|
</where>
|
|
order by p.project_id desc
|
|
</select>
|
|
|
|
<!--
|
|
executor 专属列表: 只查 biz_project_assign 里分给当前用户的项目
|
|
匹配规则 (任一):
|
|
1) a.exec_user_id = 当前 user_id (子账号直接被指派)
|
|
2) a.execution_unit_id = 当前 user_id 对应的 executor biz_org.org_id (主账号整公司被指派)
|
|
注: executor 角色无评分/聚合分需求, 复用 selectFields (含 sponsor_score / manager_score)
|
|
-->
|
|
<select id="selectExecutorList" resultMap="BizProjectResult" parameterType="BizProject">
|
|
select distinct p.project_id, p.project_no, p.project_name, p.total_sessions, p.done_sessions, p.todo_sessions, p.total_amount, p.available_amount, p.paid_labor_amount, p.paid_meeting_amount, p.manager_score, p.sponsor_score, p.sponsor_admin_user_name, p.project_form, p.is_finished, p.is_settled, p.sponsor_admin_user_id, p.lead_user_id, p.is_bid_project, p.create_by, p.create_user_id, p.create_time, p.update_by, p.update_time, p.manage_fee, p.start_time, p.end_time, p.submit_deadline_days, p.support_contract_url, p.execute_contract_url, p.invitation_url, p.support_letter_url, p.publish_url,
|
|
o.org_name as sponsor_org_name,
|
|
lu.user_name as lead_user_name,
|
|
bp.name as create_user_name,
|
|
(select group_concat(distinct o2.org_name separator ',')
|
|
from biz_project_assign bpa2
|
|
join biz_org o2 on o2.org_id = bpa2.execution_unit_id and o2.org_type = 'executor'
|
|
where bpa2.project_id = p.project_id) as exec_org_names,
|
|
(select coalesce(sum(bpa3.sessions), 0)
|
|
from biz_project_assign bpa3
|
|
where bpa3.project_id = p.project_id
|
|
and (bpa3.exec_user_id = #{params.executorUserId}
|
|
or bpa3.execution_unit_id = (select org_id from biz_org where user_id = #{params.executorUserId} and org_type = 'executor'))) as assigned_sessions,
|
|
(select coalesce(sum(bpa4.amount), 0)
|
|
from biz_project_assign bpa4
|
|
where bpa4.project_id = p.project_id
|
|
and (bpa4.exec_user_id = #{params.executorUserId}
|
|
or bpa4.execution_unit_id = (select org_id from biz_org where user_id = #{params.executorUserId} and org_type = 'executor'))) as assigned_amount
|
|
from biz_project p
|
|
join biz_project_assign a on a.project_id = p.project_id
|
|
left join biz_org o on o.user_id = p.sponsor_admin_user_id and o.org_type = 'sponsor'
|
|
left join sys_user lu on lu.user_id = p.lead_user_id
|
|
left join biz_person bp on bp.user_id = p.create_user_id
|
|
<where>
|
|
(a.exec_user_id = #{params.executorUserId}
|
|
or a.execution_unit_id = (select org_id from biz_org where user_id = #{params.executorUserId} and org_type = 'executor'))
|
|
<if test="projectNo != null and projectNo != ''">and p.project_no like concat('%', #{projectNo}, '%')</if>
|
|
<if test="projectName != null and projectName != ''">and p.project_name like concat('%', #{projectName}, '%')</if>
|
|
<if test="startTime != null">and p.start_time >= #{startTime}</if>
|
|
<if test="endTime != null">and p.end_time <= #{endTime}</if>
|
|
<if test="isFinished != null and isFinished != ''">and p.is_finished = #{isFinished}</if>
|
|
</where>
|
|
order by p.project_id desc
|
|
</select>
|
|
|
|
<select id="selectList" resultMap="BizProjectResult" parameterType="BizProject">
|
|
<include refid="selectFields"/>
|
|
<where>
|
|
<if test="params.projectIds != null and params.projectIds.size() > 0">
|
|
and project_id in
|
|
<foreach collection="params.projectIds" item="id" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="params.projectNos != null and params.projectNos.size() > 0">
|
|
and project_no in
|
|
<foreach collection="params.projectNos" item="no" open="(" separator="," close=")">
|
|
#{no}
|
|
</foreach>
|
|
</if>
|
|
<if test="projectNo != null and projectNo != ''">and project_no like concat('%', #{projectNo}, '%')</if>
|
|
<if test="projectName != null and projectName != ''">and project_name like concat('%', #{projectName}, '%')</if>
|
|
<if test="projectForm != null and projectForm != ''">and project_form = #{projectForm}</if>
|
|
<if test="sponsorAdminUserIds != null and sponsorAdminUserIds.size() > 0">
|
|
and sponsor_admin_user_id in
|
|
<foreach collection="sponsorAdminUserIds" item="id" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
<if test="execAdminUserIds != null and execAdminUserIds.size() > 0">
|
|
and exists (
|
|
select 1 from biz_project_assign bpa
|
|
where bpa.project_id = project_id
|
|
and bpa.exec_user_id in
|
|
<foreach collection="execAdminUserIds" item="id" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
)
|
|
</if>
|
|
<if test="isFinished != null and isFinished != ''">and is_finished = #{isFinished}</if>
|
|
<if test="isSettled != null and isSettled != ''">and is_settled = #{isSettled}</if>
|
|
<if test="managerScore != null">and manager_score = #{managerScore}</if>
|
|
</where>
|
|
order by project_id desc
|
|
</select>
|
|
<insert id="insert" parameterType="BizProject">
|
|
insert into biz_project
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="projectId != null and projectId != ''">project_id,</if>
|
|
<if test="projectNo != null and projectNo != ''">project_no,</if>
|
|
<if test="projectName != null and projectName != ''">project_name,</if>
|
|
<if test="totalSessions != null">total_sessions,</if>
|
|
<if test="doneSessions != null">done_sessions,</if>
|
|
<if test="todoSessions != null">todo_sessions,</if>
|
|
<if test="totalAmount != null">total_amount,</if>
|
|
<if test="availableAmount != null">available_amount,</if>
|
|
<if test="paidLaborAmount != null">paid_labor_amount,</if>
|
|
<if test="paidMeetingAmount != null">paid_meeting_amount,</if>
|
|
<if test="managerScore != null">manager_score,</if>
|
|
<if test="sponsorScore != null">sponsor_score,</if>
|
|
<if test="sponsorAdminUserName != null and sponsorAdminUserName != ''">sponsor_admin_user_name,</if>
|
|
<if test="projectForm != null and projectForm != ''">project_form,</if>
|
|
<if test="isFinished != null and isFinished != ''">is_finished,</if>
|
|
<if test="isSettled != null and isSettled != ''">is_settled,</if>
|
|
<if test="sponsorAdminUserId != null">sponsor_admin_user_id,</if>
|
|
<if test="leadUserId != null">lead_user_id,</if>
|
|
<if test="isBidProject != null and isBidProject != ''">is_bid_project,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="createUserId != null">create_user_id,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="manageFee != null">manage_fee,</if>
|
|
<if test="startTime != null">start_time,</if>
|
|
<if test="endTime != null">end_time,</if>
|
|
<if test="submitDeadlineDays != null">submit_deadline_days,</if>
|
|
<if test="supportContractUrl != null and supportContractUrl != ''">support_contract_url,</if>
|
|
<if test="executeContractUrl != null and executeContractUrl != ''">execute_contract_url,</if>
|
|
<if test="invitationUrl != null and invitationUrl != ''">invitation_url,</if>
|
|
<if test="supportLetterUrl != null and supportLetterUrl != ''">support_letter_url,</if>
|
|
<if test="publishUrl != null and publishUrl != ''">publish_url,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="projectId != null and projectId != ''">#{projectId},</if>
|
|
<if test="projectNo != null and projectNo != ''">#{projectNo},</if>
|
|
<if test="projectName != null and projectName != ''">#{projectName},</if>
|
|
<if test="totalSessions != null">#{totalSessions},</if>
|
|
<if test="doneSessions != null">#{doneSessions},</if>
|
|
<if test="todoSessions != null">#{todoSessions},</if>
|
|
<if test="totalAmount != null">#{totalAmount},</if>
|
|
<if test="availableAmount != null">#{availableAmount},</if>
|
|
<if test="paidLaborAmount != null">#{paidLaborAmount},</if>
|
|
<if test="paidMeetingAmount != null">#{paidMeetingAmount},</if>
|
|
<if test="managerScore != null">#{managerScore},</if>
|
|
<if test="sponsorScore != null">#{sponsorScore},</if>
|
|
<if test="sponsorAdminUserName != null and sponsorAdminUserName != ''">#{sponsorAdminUserName},</if>
|
|
<if test="projectForm != null and projectForm != ''">#{projectForm},</if>
|
|
<if test="isFinished != null and isFinished != ''">#{isFinished},</if>
|
|
<if test="isSettled != null and isSettled != ''">#{isSettled},</if>
|
|
<if test="sponsorAdminUserId != null">#{sponsorAdminUserId},</if>
|
|
<if test="leadUserId != null">#{leadUserId},</if>
|
|
<if test="isBidProject != null and isBidProject != ''">#{isBidProject},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="createUserId != null">#{createUserId},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="manageFee != null">#{manageFee},</if>
|
|
<if test="startTime != null">#{startTime},</if>
|
|
<if test="endTime != null">#{endTime},</if>
|
|
<if test="submitDeadlineDays != null">#{submitDeadlineDays},</if>
|
|
<if test="supportContractUrl != null and supportContractUrl != ''">#{supportContractUrl},</if>
|
|
<if test="executeContractUrl != null and executeContractUrl != ''">#{executeContractUrl},</if>
|
|
<if test="invitationUrl != null and invitationUrl != ''">#{invitationUrl},</if>
|
|
<if test="supportLetterUrl != null and supportLetterUrl != ''">#{supportLetterUrl},</if>
|
|
<if test="publishUrl != null and publishUrl != ''">#{publishUrl},</if>
|
|
</trim>
|
|
</insert>
|
|
<update id="updateByPrimaryKey" parameterType="BizProject">
|
|
update biz_project
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="manageFee != null and manageFee != ''">manage_fee = #{manageFee},</if>
|
|
<if test="startTime != null">start_time = #{startTime},</if>
|
|
<if test="endTime != null">end_time = #{endTime},</if>
|
|
<if test="submitDeadlineDays != null and submitDeadlineDays != ''">submit_deadline_days = #{submitDeadlineDays},</if>
|
|
<if test="supportContractUrl != null and supportContractUrl != ''">support_contract_url = #{supportContractUrl},</if>
|
|
<if test="executeContractUrl != null and executeContractUrl != ''">execute_contract_url = #{executeContractUrl},</if>
|
|
<if test="invitationUrl != null and invitationUrl != ''">invitation_url = #{invitationUrl},</if>
|
|
<if test="supportLetterUrl != null and supportLetterUrl != ''">support_letter_url = #{supportLetterUrl},</if>
|
|
<if test="publishUrl != null and publishUrl != ''">publish_url = #{publishUrl},</if>
|
|
<if test="projectNo != null and projectNo != ''">project_no = #{projectNo},</if>
|
|
<if test="projectName != null and projectName != ''">project_name = #{projectName},</if>
|
|
<if test="totalSessions != null">total_sessions = #{totalSessions},</if>
|
|
<if test="doneSessions != null">done_sessions = #{doneSessions},</if>
|
|
<if test="todoSessions != null">todo_sessions = #{todoSessions},</if>
|
|
<if test="totalAmount != null">total_amount = #{totalAmount},</if>
|
|
<if test="availableAmount != null">available_amount = #{availableAmount},</if>
|
|
<if test="paidLaborAmount != null">paid_labor_amount = #{paidLaborAmount},</if>
|
|
<if test="paidMeetingAmount != null">paid_meeting_amount = #{paidMeetingAmount},</if>
|
|
<if test="managerScore != null">manager_score = #{managerScore},</if>
|
|
<if test="sponsorScore != null">sponsor_score = #{sponsorScore},</if>
|
|
<if test="sponsorAdminUserName != null and sponsorAdminUserName != ''">sponsor_admin_user_name = #{sponsorAdminUserName},</if>
|
|
<if test="projectForm != null and projectForm != ''">project_form = #{projectForm},</if>
|
|
<if test="isFinished != null and isFinished != ''">is_finished = #{isFinished},</if>
|
|
<if test="isSettled != null and isSettled != ''">is_settled = #{isSettled},</if>
|
|
<if test="sponsorAdminUserId != null">sponsor_admin_user_id = #{sponsorAdminUserId},</if>
|
|
<if test="leadUserId != null">lead_user_id = #{leadUserId},</if>
|
|
<if test="isBidProject != null and isBidProject != ''">is_bid_project = #{isBidProject},</if>
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
<if test="createUserId != null">create_user_id = #{createUserId},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
</trim>
|
|
where project_id = #{projectId}
|
|
</update>
|
|
<delete id="deleteByPrimaryKey" parameterType="Long">
|
|
delete from biz_project where project_id = #{projectId}
|
|
</delete>
|
|
<delete id="deleteByPrimaryKeys" parameterType="Long">
|
|
delete from biz_project where project_id in
|
|
<foreach collection="projectIds" item="projectId" open="(" separator="," close=")">
|
|
#{projectId}
|
|
</foreach>
|
|
</delete>
|
|
</mapper> |