Files
zhxg_java/srs-comprehensive/src/main/resources/mapper/comprehensive/CphGoodApplyMapper.xml

948 lines
49 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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.srs.comprehensive.mapper.CphGoodApplyMapper">
<resultMap type="CphGoodApply" id="CphGoodApplyResult">
<result property="id" column="id" />
<result property="stuNo" column="stu_no" />
<result property="zzmm" column="zzmm" />
<result property="bornTime" column="born_time" />
<result property="typeCode" column="type_code" />
<result property="classPost" column="class_post" />
<result property="bankCard" column="bank_card" />
<result property="bankAddr" column="bank_addr" />
<result property="goodHis" column="good_his" />
<result property="mainHis" column="main_his" />
<result property="courseScore" column="course_score" />
<result property="applyStatus" column="apply_status" />
<result property="applyTime" column="apply_time" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<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="material" column="material" />
<result property="classtwoSure" column="classtwo_sure" />
<result property="youthPercent" column="youth_percent" />
</resultMap>
<sql id="selectCphGoodApplyVo">
select id, stu_no, zzmm, born_time, type_code, class_post,material,classtwo_sure,youth_percent, bank_card, bank_addr,
good_his, main_his, course_score, apply_status, apply_time, status, del_flag, create_by, create_time,
update_by, update_time from cph_good_apply
</sql>
<select id="selectCphGoodApplyList" parameterType="CphGoodApply" resultMap="CphGoodApplyResult">
<include refid="selectCphGoodApplyVo"/>
<where>
<if test="stuNo != null and stuNo != ''"> and stu_no = #{stuNo}</if>
<if test="zzmm != null and zzmm != ''"> and zzmm = #{zzmm}</if>
<if test="bornTime != null and bornTime != ''"> and born_time = #{bornTime}</if>
<if test="typeCode != null and typeCode != ''"> and type_code = #{typeCode}</if>
<if test="classPost != null and classPost != ''"> and class_post = #{classPost}</if>
<if test="bankCard != null and bankCard != ''"> and bank_card = #{bankCard}</if>
<if test="bankAddr != null and bankAddr != ''"> and bank_addr = #{bankAddr}</if>
<if test="goodHis != null and goodHis != ''"> and good_his = #{goodHis}</if>
<if test="mainHis != null and mainHis != ''"> and main_his = #{mainHis}</if>
<if test="courseScore != null and courseScore != ''"> and course_score = #{courseScore}</if>
<if test="applyStatus != null and applyStatus != ''"> and apply_status = #{applyStatus}</if>
<if test="applyTime != null "> and apply_time = #{applyTime}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="material != null and material != ''"> and material = #{material}</if>
<if test="classtwoSure != null and classtwoSure != ''"> and classtwo_sure = #{classtwoSure}</if>
<if test="youthPercent != null and youthPercent != ''"> and youth_percent = #{youthPercent}</if>
</where>
</select>
<select id="listTermByYear" resultType="CphTerm" parameterType="Long">
SELECT * from cph_term
where stu_year_id = #{id}
</select>
<select id="listOwnScoreClassRank" resultType="com.srs.comprehensive.domain.Vo.CphClassRankScore">
select t2.* ,sc.class_name,
(select count(1) from srs_student where `status` = '01' and class_id = sc.class_id) as class_count,
(select count(1) from srs_student as f1
left join srs_class as f2 on f1.class_id = f2.class_id
where f1.`status` = '01' and f2.major_id = sc.major_id and f2.grade_id = sc.grade_id) as major_count
from
(select t1.* from (
select a.stu_no,a.stu_year_id,b.stu_year_name,a.stu_score,a.cph_score,a.sport_score,
RANK() OVER(PARTITION BY c.class_id,a.stu_year_id,d.grade_id ORDER BY a.cph_score DESC ) as cph_class_rank,
RANK() OVER(PARTITION BY c.class_id,a.stu_year_id,d.grade_id ORDER BY a.stu_score DESC ) as stu_class_rank,
RANK() OVER(PARTITION BY d.major_id,a.stu_year_id,d.grade_id ORDER BY a.stu_score DESC ) as stu_major_rank
from cph_total_score as a
left join srs_stu_year as b on a.stu_year_id = b.id
left join srs_student as c on a.stu_no = c.stu_no
left join srs_class as d on c.class_id = d.class_id
)as t1
where t1.stu_no = #{stuNo} and t1.stu_year_id in (
select id from srs_stu_year as b where b.`status` = 1
)
)as t2
left join srs_student as ss on t2.stu_no = ss.stu_no
left join srs_class as sc on ss.class_id = sc.class_id
</select>
<select id="listOwnYearCourseScore" resultType="CphCourseNameScore">
select a.cj as course_score,b.course_name,c.term_name,d.stu_year_name,a.is_pass,sci.exam_method,a.fzlx
from cph_stu_score_middle as a
left join srs_course_info as b on a.kcdm = b.course_no
left join cph_term as c on a.xqdm = c.term_code
left join srs_stu_year as d on c.stu_year_id = d.id
left join srs_course_info as sci on sci.course_no=a.kcdm
where a.stu_no = #{stuNo}
ORDER BY c.term_name
</select>
<select id="countOwnPass" resultType="CphCoursePassCount">
select count(a.is_pass) as course_count,sum(case when a.is_pass='true' then 1 else 0 end ) as pass_count,
sum(case when a.is_pass='false' then 1 else 0 end ) as unpass_count , b.stu_year_name
from cph_stu_score_middle as a
left join srs_stu_year as b on a.xndm = b.xndm
where a.stu_no = #{stuNo}
GROUP BY b.id
</select>
<select id="countOwnIam" resultType="CphIamSitCount">
select d.stu_year_name,
count(1) as iam_count,
sum(case when c.max_score > 0 then 1 else 0 end ) as add_count,
sum(case when c.max_score &lt; 0 then 1 else 0 end ) as minus_count
from cph_iam as a
left join srs_student as b on a.to_add = b.stu_id
left join cph_rules as c on a.rule_id = c.rule_id
left join srs_stu_year as d on a.stu_year_id = d.id
where b.stu_no = #{stuNo} and a.audit_status = 6
GROUP BY a.stu_year_id
</select>
<select id="getOwnPassCountByCode" resultType="CphCoursePassCount">
select count(a.is_pass) as course_count,sum(case when a.is_pass='1' then 1 else 0 end ) as pass_count,
sum(case when a.is_pass='0' then 1 else 0 end ) as unpass_count , b.stu_year_name
from cph_stu_score_middle as a
left join srs_stu_year as b on a.xndm = b.xndm
where a.stu_no = #{stuNo} and a.xndm = (select t2.xndm from cph_own_good_type as t1
left join srs_stu_year as t2 on t1.stu_year_id = t2.id where t1.type_code = #{code})
GROUP BY b.id
</select>
<select id="getOwnIamCountByCode" resultType="CphIamSitCount">
select d.stu_year_name,
count(1) as iam_count,
sum(case when c.max_score > 0 then 1 else 0 end ) as add_count,
sum(case when c.max_score &lt; 0 then 1 else 0 end ) as minus_count
from cph_iam as a
left join srs_student as b on a.to_add = b.stu_id
left join cph_rules as c on a.rule_id = c.rule_id
left join srs_stu_year as d on a.stu_year_id = d.id
where b.stu_no = #{stuNo} and a.audit_status = 6
and a.stu_year_id = (select stu_year_id from cph_own_good_type as t where t.type_code = #{code})
GROUP BY a.stu_year_id
</select>
<select id="listOwnXyjxjApply" resultType="com.srs.comprehensive.domain.Vo.CphGoodApplyVo">
select a.* ,b.type_name,c.fdy_comment,c.dept_comment,c.final_comment
from cph_good_apply as a
left join cph_own_good_type as b on a.type_code = b.type_code
left join cph_good_audit as c on a.id = c.apply_id
where a.stu_no = #{stuNo} and b.parent_code = "XYJXJ"
ORDER BY create_time DESC
</select>
<select id="listFdyAudit" resultType="CphGoodAuditFdyVo" parameterType="CphSearch">
select c.stu_no,c.`name` as stu_name,d.class_name,b.apply_status,f.type_name,a.*
from cph_good_audit as a
left join cph_good_apply as b on a.apply_id = b.id
left join srs_student as c on b.stu_no = c.stu_no
left join srs_class as d on c.class_id = d.class_id
left join cph_teacher as e on d.teacher_id = e.teacher_id
left join cph_own_good_type as f on b.type_code = f.type_code
<where>
e.employee_id = #{tNo}
<if test="status != null and status != ''"> and b.apply_status = #{status}</if>
<if test="code != null and code != ''"> and f.type_code like concat('%', #{code}, '%')</if>
<if test="stuNo != null and stuNo != ''"> and c.stu_no = #{stuNo}</if>
<if test="stuName != null and stuName != ''"> and c.`name` = #{stuName}</if>
</where>
ORDER BY fdy_status asc,id desc
</select>
<select id="listXwAudit" resultType="CphGoodAuditFdyVo" parameterType="CphSearch">
select b.apply_status,c.stu_no,c.`name` as stu_name,d.class_name,f.type_name,a.*,e.major_id,e.major_name,e.major_type_name,
d.class_name
from cph_good_audit as a
left join cph_good_apply as b on a.apply_id = b.id
left join srs_student as c on b.stu_no = c.stu_no
left join srs_class as d on c.class_id = d.class_id
left join cph_own_good_type as f on b.type_code = f.type_code
left join srs_majors as e on d.major_id = e.major_id
<where>
<if test="deptId != null and deptId != ''"> and e.college_id = #{deptId}</if>
<if test="majorId != null and majorId != ''"> and d.major_id = #{majorId}</if>
<if test="classId != null and classId != ''"> and c.class_id = #{classId}</if>
<if test="status != null and status != ''"> and b.apply_status = #{status}</if>
<if test="stuNo != null and stuNo != ''"> and c.stu_no = #{stuNo}</if>
<if test="stuName != null and stuName != ''"> and c.`name` = #{stuName}</if>
<if test="code != null and code != ''"> and f.type_code like concat('%', #{code}, '%')</if>
</where>
ORDER BY id desc
</select>
<select id="importYxbg" resultType="CphGoodApplyVo" parameterType="CphSearch">
select d.stu_year_name,e.class_name,a.stu_no,b.`name` as stu_name,c.type_name,NOW() as import_time,f.major_type_name,
f.major_name,g.dept_name,
case
when a.apply_status = 1 then '已提交待辅导员审核'
when a.apply_status = 6 then '学工审核通过'
when a.apply_status = 10 then '驳回'
when a.apply_status = 12 then '作废'
when a.apply_status = 11 then '拒绝'
when a.apply_status = 2 then '辅导员审核通过'
when a.apply_status = 3 then '学院审核通过'
else '无状态' end as apply_status,
h.`name` as teacherName
from cph_good_apply as a
left join srs_student as b on a.stu_no = b.stu_no
left join cph_own_good_type as c on a.type_code = c.type_code
left join srs_stu_year as d on c.stu_year_id = d.id
left join srs_class as e on b.class_id = e.class_id
left join srs_majors as f on e.major_id = f.major_id
left join sys_dept as g on f.college_id = g.dept_id
left join cph_teacher as h on e.teacher_id = h.teacher_id
<where>
c.type_code like "%YXXSGB%" and a.apply_status not in (14)
<if test="stuYearId != null and stuYearId != ''"> and d.id = #{stuYearId}</if>
<if test="deptId != null and deptId != ''"> and g.dept_id = #{deptId}</if>
<if test="majorId != null and majorId != ''"> and f.major_id = #{majorId}</if>
<if test="classId != null and classId != ''"> and e.class_id = #{classId}</if>
<if test="tNo != null and tNo != ''"> and h.employee_id = #{tNo}</if>
</where>
</select>
<select id="importShxs" resultType="CphGoodApplyVo" parameterType="CphSearch">
select d.stu_year_name,e.class_name,a.stu_no,b.`name` as stu_name,c.type_name,NOW() as import_time,f.major_type_name,
f.major_name,g.dept_name,
case
when a.apply_status = 1 then '已提交待辅导员审核'
when a.apply_status = 6 then '学工审核通过'
when a.apply_status = 10 then '驳回'
when a.apply_status = 11 then '拒绝'
when a.apply_status = 12 then '作废'
when a.apply_status = 2 then '辅导员审核通过'
when a.apply_status = 3 then '学院审核通过'
else '无状态' end as apply_status,
h.`name` as teacherName
from cph_good_apply as a
left join srs_student as b on a.stu_no = b.stu_no
left join cph_own_good_type as c on a.type_code = c.type_code
left join srs_stu_year as d on c.stu_year_id = d.id
left join srs_class as e on b.class_id = e.class_id
left join srs_majors as f on e.major_id = f.major_id
left join sys_dept as g on f.college_id = g.dept_id
left join cph_teacher as h on e.teacher_id = h.teacher_id
<where>
c.type_code like "%SHXS%" and a.apply_status not in (14)
<if test="stuYearId != null and stuYearId != ''"> and d.id = #{stuYearId}</if>
<if test="deptId != null and deptId != ''"> and g.dept_id = #{deptId}</if>
<if test="majorId != null and majorId != ''"> and f.major_id = #{majorId}</if>
<if test="classId != null and classId != ''"> and e.class_id = #{classId}</if>
<if test="tNo != null and tNo != ''"> and h.employee_id = #{tNo}</if>
</where>
</select>
<select id="importXyjxj" resultType="CphGoodApplyVo" parameterType="CphSearch">
select d.stu_year_name,e.class_name,a.stu_no,b.`name` as stu_name,c.type_name,a.bank_card,a.bank_addr,NOW() as import_time,f.major_type_name,
f.major_name,g.dept_name,
case
when a.apply_status = 1 then '已提交待辅导员审核'
when a.apply_status = 6 then '学工审核通过'
when a.apply_status = 10 then '驳回'
when a.apply_status = 11 then '拒绝'
when a.apply_status = 12 then '作废'
when a.apply_status = 2 then '辅导员审核通过'
when a.apply_status = 3 then '学院审核通过'
else '无状态' end as apply_status,
h.`name` as teacherName
from cph_good_apply as a
left join srs_student as b on a.stu_no = b.stu_no
left join cph_own_good_type as c on a.type_code = c.type_code
left join srs_stu_year as d on c.stu_year_id = d.id
left join srs_class as e on b.class_id = e.class_id
left join srs_majors as f on e.major_id = f.major_id
left join sys_dept as g on f.college_id = g.dept_id
left join cph_teacher as h on e.teacher_id = h.teacher_id
<where>
c.parent_code = "XYJXJ" and a.apply_status not in (14)
<if test="stuYearId != null and stuYearId != ''"> and d.id = #{stuYearId}</if>
<if test="deptId != null and deptId != ''"> and g.dept_id = #{deptId}</if>
<if test="majorId != null and majorId != ''"> and f.major_id = #{majorId}</if>
<if test="classId != null and classId != ''"> and e.class_id = #{classId}</if>
<if test="tNo != null and tNo != ''"> and h.employee_id = #{tNo}</if>
</where>
</select>
<select id="listXyjxjCanType" resultType="com.srs.comprehensive.domain.Vo.CphGoodTypeCode">
select concat(b.stu_year_name,a.type_name) as type_name , a.type_code,a.stu_year_id
from cph_own_good_type as a
left join srs_stu_year as b on a.stu_year_id = b.id
where a.parent_code = 'XYJXJ' and enable_status = 1 and start_status = 1
</select>
<select id="selectByOnlyCodeStuNo" resultType="CphGoodApply">
SELECT a.*
from cph_good_apply as a
left join cph_own_good_type as b on a.type_code = b.type_code
where a.stu_no = #{stuNo} and b.only_code = #{code} and a.apply_status not in (11,12,14)
</select>
<select id="lookDetail" parameterType="Long" resultType="CphGoodApplyVo">
select a.*,b.fdy_comment,b.fdy_time,f.nick_name as fdy_no_name,b.fdy_status,
b.dept_comment,b.dept_time,g.nick_name as dept_no_name,b.dept_status,
b.final_comment,b.final_time,h.nick_name as final_no_name,b.final_status,
c.type_name,d.`name` as stuName,e.class_name,b.id as audit_id
from cph_good_apply as a
left join cph_good_audit as b on a.id = b.apply_id
left join cph_own_good_type as c on a.type_code = c.type_code
left join srs_student as d on a.stu_no = d.stu_no
left join srs_class as e on d.class_id = e.class_id
left join sys_user as f on b.fdy_no = f.user_name
left join sys_user as g on b.dept_no = g.user_name
left join sys_user as h on b.final_no = h.user_name
where a.id = #{id}
</select>
<select id="selectCphGoodApplyById" parameterType="Long" resultMap="CphGoodApplyResult">
<include refid="selectCphGoodApplyVo"/>
where id = #{id}
</select>
<select id="getGrades" resultType="java.util.Map" parameterType="CphGoodApply">
SELECT cph_good_apply.id as applyId,cph_good_apply.stu_no as stuNo,cph_good_apply.zzmm,cph_good_apply.born_time as bornTime
,cph_good_apply.type_code as typeCode,cph_good_apply.class_post as classPost,
cph_good_apply.good_his as goodHis,cph_good_apply.main_his as mainHis
,cph_good_apply.material,cph_good_apply.apply_status as applyStatus,cph_good_apply.apply_time as applyTime,
cph_good_audit.*,cph_own_good_type.type_name as typeName,cph_own_good_type.stu_year_id as stuYearId
,cph_good_audit.fdy_comment as fdyComment,cph_good_audit.dept_comment as deptComment,cph_good_audit.final_comment as finalComment
,cph_good_apply.classtwo_sure as classtwoSure,cph_good_apply.youth_percent as youthPercent
from cph_good_apply
LEFT JOIN cph_good_audit ON cph_good_apply.id = cph_good_audit.apply_id
left join cph_own_good_type on cph_good_apply.type_code=cph_own_good_type.type_code
where stu_no = #{stuNo}
and cph_good_apply.type_code like '%SHXS%'
order by cph_good_apply.id desc
</select>
<select id="getMyApply" resultType="com.srs.comprehensive.domain.Vo.ApplyYxgbVo">
select cpa.id, cpa.zzmm,cpa.class_post,stu_no, cpa.type_code, type_name, stu_year_name, apply_time,cpa.youth_percent,cpa.classtwo_sure,cpa.good_his,cpa.main_his, cpa.apply_status AS `status`,fdy_comment,dept_comment,final_comment
from cph_good_apply cpa
left join cph_good_audit cga on cpa.id = cga.apply_id
left join cph_own_good_type cogt on cpa.type_code = cogt.type_code
left join srs_stu_year ssy on cogt.stu_year_id = ssy.id
where stu_no = #{username}
and cpa.type_code like '%YXXSGB%'
order by cpa.id desc
</select>
<select id="getOwnRankByCode" parameterType="CphSearch" resultType="CphClassRankScore">
select t2.* ,sc.class_name,
(select count(1) from srs_student where `status` = '01' and class_id = sc.class_id) as class_count,
(select count(1) from srs_student as f1
left join srs_class as f2 on f1.class_id = f2.class_id
where f1.`status` = '01' and f2.major_id = sc.major_id and f2.grade_id = sc.grade_id) as major_count
from
(select t1.* from (
select a.stu_no,a.stu_year_id,b.stu_year_name,a.stu_score,a.cph_score,a.sport_score,
RANK() OVER(PARTITION BY c.class_id,a.stu_year_id,d.grade_id ORDER BY a.cph_score DESC ) as cph_class_rank,
RANK() OVER(PARTITION BY c.class_id,a.stu_year_id,d.grade_id ORDER BY a.stu_score DESC ) as stu_class_rank,
RANK() OVER(PARTITION BY d.major_id,a.stu_year_id,d.grade_id ORDER BY a.stu_score DESC ) as stu_major_rank
from cph_total_score as a
left join srs_stu_year as b on a.stu_year_id = b.id
left join srs_student as c on a.stu_no = c.stu_no
left join srs_class as d on c.class_id = d.class_id
)as t1
where t1.stu_no = #{stuNo}
and t1.stu_year_id = (
select stu_year_id from cph_own_good_type where type_code = #{code}
))as t2
left join srs_student as ss on t2.stu_no = ss.stu_no
left join srs_class as sc on ss.class_id = sc.class_id
</select>
<insert id="insertCphGoodApply" parameterType="CphGoodApply" useGeneratedKeys="true" keyProperty="id">
insert into cph_good_apply
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="stuNo != null">stu_no,</if>
<if test="zzmm != null">zzmm,</if>
<if test="bornTime != null">born_time,</if>
<if test="typeCode != null">type_code,</if>
<if test="classPost != null">class_post,</if>
<if test="bankCard != null">bank_card,</if>
<if test="bankAddr != null">bank_addr,</if>
<if test="goodHis != null">good_his,</if>
<if test="mainHis != null">main_his,</if>
<if test="courseScore != null">course_score,</if>
<if test="applyStatus != null">apply_status,</if>
<if test="applyTime != null">apply_time,</if>
<if test="status != null">status,</if>
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="material != null">material,</if>
<if test="classtwoSure != null">classtwo_sure,</if>
<if test="youthPercent != null">youth_percent,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stuNo != null">#{stuNo},</if>
<if test="zzmm != null">#{zzmm},</if>
<if test="bornTime != null">#{bornTime},</if>
<if test="typeCode != null">#{typeCode},</if>
<if test="classPost != null">#{classPost},</if>
<if test="bankCard != null">#{bankCard},</if>
<if test="bankAddr != null">#{bankAddr},</if>
<if test="goodHis != null">#{goodHis},</if>
<if test="mainHis != null">#{mainHis},</if>
<if test="courseScore != null">#{courseScore},</if>
<if test="applyStatus != null">#{applyStatus},</if>
<if test="applyTime != null">#{applyTime},</if>
<if test="status != null">#{status},</if>
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="material != null">#{material},</if>
<if test="classtwoSure != null">#{classtwoSure},</if>
<if test="youthPercent != null">#{youthPercent},</if>
</trim>
</insert>
<update id="updateCphGoodApply" parameterType="CphGoodApply">
update cph_good_apply
<trim prefix="SET" suffixOverrides=",">
<if test="stuNo != null">stu_no = #{stuNo},</if>
<if test="zzmm != null">zzmm = #{zzmm},</if>
<if test="bornTime != null">born_time = #{bornTime},</if>
<if test="typeCode != null">type_code = #{typeCode},</if>
<if test="classPost != null">class_post = #{classPost},</if>
<if test="bankCard != null">bank_card = #{bankCard},</if>
<if test="bankAddr != null">bank_addr = #{bankAddr},</if>
<if test="goodHis != null">good_his = #{goodHis},</if>
<if test="mainHis != null">main_his = #{mainHis},</if>
<if test="courseScore != null">course_score = #{courseScore},</if>
<if test="applyStatus != null">apply_status = #{applyStatus},</if>
<if test="applyTime != null">apply_time = #{applyTime},</if>
<if test="status != null">status = #{status},</if>
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</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>
<if test="material != null">material = #{material},</if>
<if test="classtwoSure != null">classtwo_sure = #{classtwoSure},</if>
<if test="youthPercent != null">youth_percent = #{youthPercent},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCphGoodApplyById" parameterType="Long">
delete from cph_good_apply where id = #{id}
</delete>
<delete id="deleteCphGoodApplyByIds" parameterType="String">
delete from cph_good_apply where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="countJwcUnDo" resultType="String">
select concat('good-',count(a.id)) as `all`
from cph_good_apply as a
where a.apply_status = 3
union
select concat('lake-',count(a.id)) as `all`
from cph_lake_apply as a
where a.apply_status = 3
union
select concat('biye-',count(a.id)) as `all`
from cph_biye_apply as a
where a.apply_status = 3
union
select concat('dms-',count(a.id)) as `all`
from dms_manage_application as a
where a.`status` = 2
union
select concat('kn-',count(a.id)) as `all`
from srs_knrd_apply as a
where a.`step` = 4
union
select concat('zx-',count(a.id)) as `all`
from srs_zxj_apply as a
where a.`step` = 3
<!-- 知无涯 教务困难资助-->
union
select concat('knzz-',count(a.id)) as `all`
from knzz_tufa_apply as a
where a.apply_status = 3
/*宁博 6、困难资助-国家励志奖学金-学工审核代办*/
union
select concat('knzzgl-',count(a.id)) as `all`
from knzz_gl_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 3
-- 陈冠元 困难资助-自治区人民政府奖学金-学工审核代办
union
select concat('knzzzzq-',count(a.id)) as `all`
from knzz_zzq_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 3
-- 邵政文-(日常事务-学生证补办-辅导员审核-学工审核)
union
select concat('xszb-',count(a.id)) as `all`
from rt_stu_id_reissue as a
where a.inspection_progress = 1
-- 邵政文-(日常事务-在校证明申请-辅导员审核-学工审核)
union
select concat('zxzm-',count(a.id)) as `all`
from rt_stu_at_school as a
where a.xgstatus = 0 or a.xgstatus is null
/*庞世斌 4、学生奖惩-先进班集体-学工审核代办*/
union
select concat('xjbjt-',count(a.id)) as `all`
from cph_new_good_class_apply as a
WHERE a.apply_status = 3
<!-- 知无涯 "中职升高职" 学校终审 -->
union
select concat('zsg-',count(a.id)) as `all`
from knzz_zsg_apply as a
where a.apply_status = 3
</select>
<select id="countStuUnDo" resultType="String" parameterType="String">
select concat('good-',count(a.id)) as `all`
from cph_good_apply as a
where a.apply_status = 6 and a.stu_no = #{stuNo}
union
select concat('lake-',count(a.id)) as `all`
from cph_lake_apply as a
where a.apply_status = 6 and a.stu_no = #{stuNo}
union
select concat('biye-',count(a.id)) as `all`
from cph_biye_apply as a
where a.apply_status = 6 and a.stu_no = #{stuNo}
union
select concat('dms-',count(a.id)) as `all`
from dms_manage_application as a
where a.`status` = 3 and a.stu_no = #{stuNo}
union
select concat('kn-',count(a.id)) as `all`
from srs_knrd_apply as a
where a.`step` = 5 and a.xh = #{stuNo}
union
select concat('zx-',count(a.id)) as `all`
from srs_zxj_apply as a
where a.`step` = 4 and a.xh = #{stuNo}
<!-- 知无涯 学生困难资助申请驳回-->
union
select concat('knzz-',count(a.id)) as `all`
from knzz_tufa_apply as a
where a.apply_status = 6 and a.stu_no = #{stuNo}
</select>
<select id="countXwUnDo" resultType="String" parameterType="Long">
select concat('good-',count(a.id)) as `all`
from cph_good_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 2 and b.dept_id = #{id}
union
select concat('lake-',count(a.id)) as `all`
from cph_lake_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 2 and b.dept_id = #{id}
union
select concat('biye-',count(a.id)) as `all`
from cph_biye_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 2 and b.dept_id = #{id}
union
select concat('dms-',count(a.id)) as `all`
from dms_manage_application as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.`status` = 1 and b.dept_id = #{id}
union
select concat('kn-',count(a.id)) as `all`
from srs_knrd_apply as a
left join view_stu_info as b on a.xh = b.stu_no
where a.`step` = 3 and b.dept_id = #{id}
and
EXISTS(
SELECT m.* FROM sys_role r
LEFT JOIN sys_role_menu rm on r.role_id = rm.role_id
LEFT JOIN sys_menu m on rm.menu_id = m.menu_id
where r.role_key ='stumanger' and m.component = 'poverty/povertyapply/xw'
)
union
select concat('zx-',count(a.id)) as `all`
from srs_zxj_apply as a
left join view_stu_info as b on a.xh = b.stu_no
where a.`step` = 2 and b.dept_id = #{id}
and
EXISTS(
SELECT m.* FROM sys_role r
LEFT JOIN sys_role_menu rm on r.role_id = rm.role_id
LEFT JOIN sys_menu m on rm.menu_id = m.menu_id
where r.role_key ='stumanger' and m.component = 'poverty/xw'
)
<!-- 知无涯 学务困难资助 -->
union
select concat('knzz-',count(a.id)) as `all`
from knzz_tufa_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 2 and b.dept_id = #{id}
/*宁博 6、困难资助-国家励志奖学金-学务审核代办*/
union
select concat('knzzgl-',count(a.id)) as `all`
from knzz_gl_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 2 and b.dept_id = #{id}
-- 陈冠元 困难资助-自治区人民政府奖学金-学校审核代办
union
select concat('knzzzzq-',count(a.id)) as `all`
from knzz_zzq_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 2 and b.dept_id = #{id}
/*庞世斌 4、学生奖惩-先进班集体-学务审核代办*/
union
select concat('xjbjt-',count(a.id)) as `all`
from cph_new_good_class_apply as a
left join srs_class as c on a.class_id = c.class_id
left join srs_majors as e on c.major_id = e.major_id
left join sys_dept as f on e.college_id = f.dept_id
WHERE a.apply_status = 2 and f.dept_id = #{id}
<!-- 知无涯"中职升高职" 学务审核 -->
union
select concat('zsg-',count(a.id)) as `all`
from knzz_zsg_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 2 and b.dept_id = #{id}
<!-- 知无涯"铺导员综合绩效" (第1步学务初审) -->
union
select concat('jx-',count(a.id)) as `all`
from sys_performance as a
left join sys_user as b on a.credit_pass = b.user_name
where a.xwstatus IS NULL and b.dept_id = #{id}
# 宁博-辅导员管理--成果绩效----(第1步学务初审)
union
select concat('cg-',count(a.check_id)) as `all`
from sys_teacher_achievementcheck as a
left join sys_user as b on a.teacher_id = b.user_name
where a.check_status = 1 and b.dept_id = #{id}
-- 陈冠元 辅导员业绩考核-学务审核待办
union
select concat('yj-',count(a.id)) as `all`
from sys_teacher_kpi_filling as a
left join sys_user as b on a.job_number = b.user_name
where a.role_audit = 1 and b.dept_id = #{id}
</select>
<select id="countFdyUnDo" resultType="String" parameterType="String">
select concat('good-',count(a.id)) as `all`
from cph_good_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 1 and b.t_no = #{tNo}
union
select concat('lake-',count(a.id)) as `all`
from cph_lake_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 1 and b.t_no = #{tNo}
union
select concat('biye-',count(a.id)) as `all`
from cph_biye_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 1 and b.t_no = #{tNo}
union
select concat('dms-',count(a.id)) as `all`
from dms_manage_application as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.`status` = 0 and b.t_no = #{tNo}
union
select concat('kn-',count(a.id)) as `all`
from srs_knrd_apply as a
left join view_stu_info as b on a.xh = b.stu_no
where a.`step` = 2 and b.t_no = #{tNo}
union
select concat('zx-',count(a.id)) as `all`
from srs_zxj_apply as a
left join view_stu_info as b on a.xh = b.stu_no
where a.`step` = 1 and b.t_no = #{tNo}
union
select concat('qgzxgw-',count(a.id)) as `all`
from qgzx_stu_post as a
left join qgzx_post as b on a.post_id = b.id
left join sys_dept as c on b.dept_code = c.dept_code
left join view_stu_info as d on a.stu_no = d.stu_no
where b.zdls_no = #{tNo} and a.apply_status = '1'
union
select concat('qgzxgzjl-',count(a.id)) as `all`
from qgzx_stu_post as a
left join qgzx_post as b on a.post_id = b.id
left join sys_dept as c on b.dept_code = c.dept_code
left join view_stu_info as d on a.stu_no = d.stu_no
where b.zdls_no = #{tNo} and a.apply_status = '1'
<!-- 知无涯 辅导员困难资助-->
union
select concat('knzz-',count(a.id)) as `all`
from knzz_tufa_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 1 and b.t_no = #{tNo}
<!-- 知无涯 统计待审核的离校申请 -->
union
select concat('leave-',count(a.return_school_id)) as `all`
from sur_itinerary as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.leave_status = 1 and b.t_no = #{tNo}
/*宁博 10、假期去向-学生返校-辅导员审核代办*/
union
select concat('return-',count(a.return_school_id)) as `all`
from sur_itinerary as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.status = '1' and b.t_no = #{tNo}
/*宁博 6、困难资助-国家励志奖学金-辅导员审核代办*/
union
select concat('knzzgl-',count(a.id)) as `all`
from knzz_gl_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 1 and b.t_no = #{tNo}
-- 陈冠元 困难资助-自治区人民政府奖学金-辅导员审核代办
union
select concat('knzzzzq-',count(a.id)) as `all`
from knzz_zzq_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 1 and b.t_no = #{tNo}
-- 邵政文-(日常事务-学生证补办-辅导员审核-学工审核)
union
select concat('xszb-',count(a.id)) as `all`
from rt_stu_id_reissue as a
left join view_stu_info as b on a.stu_no = b.stu_no
where b.t_no = #{tNo} and a.inspection_progress = 0
-- 邵政文-(日常事务-在校证明申请-辅导员审核-学工审核)
union
select concat('zxzm-',count(a.id)) as `all`
from rt_stu_at_school as a
left join view_stu_info as d on a.student_id = d.stu_no
where d.t_no = #{tNo} and (a.status = 0 or a.status is null)
/* 庞世斌 学生奖惩-先进班集体-辅导员审核代办*/
union
select concat('xjbjt-',count(a.id)) as `all`
from cph_new_good_class_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
WHERE b.t_no = #{tNo} and a.apply_status = 1
/*庞世斌 3、综合素质-综合素质申请审核代办*/
union
select concat('zhsz-',count(a.id)) as `all`
from cph_audit_details a
left join view_stu_info as b on a.submitter_id = b.stu_id
WHERE status_code = 1 and t_no=#{tNo}
<!-- 知无涯"中职升高职" 辅导员审核 -->
union
select concat('zsg-',count(a.id)) as `all`
from knzz_zsg_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 1 and b.t_no = #{tNo}
<!--知无涯 "铺导员综合绩效" 待办 (第3步科室复核 和 第4步学工处长终审) -->
union
select concat('jx-',count(a.id)) as `all`
from sys_performance as a
where (a.shstatus IS NOT NULL and a.ksstatus IS NULL) -- 科室复核待办
or (a.ksstatus IS NOT NULL and a.xgstatus IS NULL) -- 学工处长待办
-- 邵政文-(宿舍管理-住宿费用-辅导员确认待办)
union
select concat('zsfy-',count(a.id)) as `all`
from view_dms_record as a
left join dms_new_record as b on a.stu_year_id = b.id
left join view_stu_info as d on a.stu_no = d.stu_no
where d.t_no = #{tNo} and a.apply_status = 1
</select>
<select id="countBiyeYearDept" resultType="CphBiyeApplyVo">
select count(a.id) as major_count,c.stu_year_name,b.dept_name
from cph_biye_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
left join srs_stu_year as c on a.stu_year_id = c.id
where a.apply_status = 6
GROUP BY b.dept_id,c.id
</select>
<select id="countSjUnDo" resultType="String" parameterType="Long">
select concat('sj-',count(a.application_id)) as `all`
from rt_stu_disciplinary_application as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.penalty_status=3 and b.dept_id = #{id}
and
EXISTS(
SELECT m.* FROM sys_role r
LEFT JOIN sys_role_menu rm on r.role_id = rm.role_id
LEFT JOIN sys_menu m on rm.menu_id = m.menu_id
where r.role_key ='Junior_college_leader'
)
<!-- 知无涯 书记困难资助-->
union
select concat('knzz-',count(a.id)) as `all`
from knzz_tufa_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.apply_status = 1 and b.dept_id = #{id}
<!-- 知无涯"书记综合绩效" 待办 (第2步书记审核) -->
union
select concat('jx-',count(a.id)) as `all`
from sys_performance as a
left join sys_user as b on a.credit_pass = b.user_name
where a.xwstatus IS NOT NULL and a.shstatus IS NULL and b.dept_id = #{id}
# 宁博-辅导员管理--成果绩效----待办 (第2步书记审核)
union
select concat('cg-',count(a.check_id)) as `all`
from sys_teacher_achievementcheck as a
left join sys_user as b on a.teacher_id = b.user_name
where a.check_status = 2 and b.dept_id = #{id}
-- 陈冠元 辅导员业绩考核-学院书记待办
union
select concat('yj-',count(a.id)) as `all`
from sys_teacher_kpi_filling as a
left join sys_user as b on a.job_number = b.user_name
where a.role_audit = 2 and b.dept_id = #{id}
</select>
<!--
========================================================================================================================
开发与维护文档 (Development & Maintenance Document)
========================================================================================================================
最后更新: 2025-08-19
负责人: 知无涯
模块概述:
本 XML 文件是整个学工系统的核心组件之一,其主要功能是为系统首页(工作台)提供各个角色的“待办事项”数量统计。
它并非传统的CRUD映射文件而是通过一系列复杂的 `UNION` 查询,从不同的业务表中汇总统计数据。
核心设计模式:
1. 角色分离:文件通过不同的 `<select>` 标签id 以 `count...UnDo` 命名)来为不同的系统角色提供独立的待办统计逻辑。
2. 联合查询UNION每个角色的待办数量都是通过 `UNION` 连接多个 `SELECT COUNT(...)` 语句来实现的。
3. 键值对格式:每个 `SELECT` 语句都使用 `CONCAT('prefix-', COUNT(...))` 的格式返回一个字符串,例如 'jx-5'。
- 'prefix-' (例如 'jx-')这是待办事项的唯一标识符Key
- COUNT(...) (例如 5)这是该事项的待办数量Value
前端会根据这个 'prefix' 来匹配并更新界面上对应待办事项的数量。
角色与待办事项详解:
1. <select id="countJwcUnDo"> - 学工/校级管理员 (Jwc)
- 职责:负责各项业务的最终审批环节。
- 数据范围:全校范围,无部门或个人过滤。
- 包含待办项:
- `good-`, `lake-`, `biye-`: 评优/毕业生状态为3 (待校级审核)。
- `dms-`: 宿舍状态为2 (待校级审核)。
- `kn-`, `zx-`: 困难认定/助学金,进入最终步骤。
- `knzz-`, `knzzgl-`, `knzzzzq-`: 各类困难资助状态为3 (待校级终审)。
- `xszb-`, `zxzm-`: 学生证补办/在校证明,进入校级审核环节。
- `xjbjt-`: 先进班集体状态为3 (待校级审核)。
- `zsg-`: 中职升高职状态为3 (待校级终审)。
2. <select id="countXwUnDo"> - 学务/院系管理员 (Xw)
- 职责:负责各项业务的院系级审批(第二级)。
- 数据范围按当前登录用户的院系ID (`dept_id`) 过滤。
- 包含待办项:
- 常规业务 (`good-`, `biye-`, `dms-`, `kn-`, `zx-`等):状态均为流程的第二步。
- `zsg-`: 中职升高职状态为2 (待院系审核)。
- `jx-`: 辅导员综合绩效,状态为 `xwstatus IS NULL` (流程第一步)。
3. <select id="countSjUnDo"> - 书记/院系领导 (Sj)
- 职责:负责院系内的特殊和高级别审批。
- 数据范围按当前登录用户的院系ID (`dept_id`) 过滤。
- 包含待办项:
- `sj-`: 学生违纪处分状态为3。
- `knzz-`: 困难资助状态为1 (可代办辅导员的待办)。
- `jx-`: 辅导员综合绩效,状态为 `xwstatus IS NOT NULL and shstatus IS NULL` (流程第二步)。
4. <select id="countFdyUnDo"> - 辅导员/指导老师 (Fdy)
- 职责:这是一个综合性角色,处理多项职责的待办。
- 数据范围:主要按辅导员/教师工号 (`t_no`) 过滤。
- 包含待办项:
- 常规初审 (`good-`, `biye-`, `dms-`, `kn-`, `zx-`等):状态均为流程的第一步。
- 勤工助学 (`qgzxgw-`, `qgzxgzjl-`): 作为“指导老师”,按 `zdls_no` 过滤。
- `zsg-`: 中职升高职状态为1 (流程第一步)。
- `jx-`: 辅导员综合绩效,这是一个特例。此处的待办是为内嵌在此角色中的“科室复核”和“学工处长”岗准备的,
查询条件是 `(shstatus IS NOT NULL and ksstatus IS NULL) or (ksstatus IS NOT NULL and xgstatus IS NULL)`
它聚合了绩效审批的第三步和第四步。
5. <select id="countStuUnDo"> - 学生 (Stu)
- 职责:处理被驳回或需要本人操作的申请。
- 数据范围:按当前登录学生的学号 (`stuNo`) 过滤。
- 包含待办项:主要是各项业务被驳回的状态,例如 `apply_status = 6`。
如何新增一个待办事项 (示例:为辅导员添加“新增奖学金”待办)
1. **确定角色和审批环节**
- 角色:辅导员。
- 环节:初审。
- 因此,我们需要修改 `<select id="countFdyUnDo">`。
2. **确定业务逻辑**
- 业务表:`new_scholarship_apply`。
- 状态字段:`status`。
- 待办状态值:`1` (代表“待初审”)。
- 过滤方式:按辅导员教师工号 `t_no` 过滤。
3. **选择一个唯一的前缀 (Prefix)**
- 我们选择 `xsjxj-` (“新式奖学金”的拼音首字母)。
4. **编写并添加SQL代码**
- 在 `<select id="countFdyUnDo">` 的最后一个 `union` 之后,添加以下代码块:
```xml
union
select concat('xsjxj-',count(a.id)) as `all`
from new_scholarship_apply as a
left join view_stu_info as b on a.stu_no = b.stu_no
where a.status = 1 and b.t_no = #{tNo}
```
5. **同步更新前端代码**
- 在前端定义辅导员 `taskList` 的地方,添加一个新的对象:
```javascript
{
label: "辅导员·新增奖学金审核",
name: "xsjxj", // 必须与后端的 'xsjxj-' 匹配
value: 0,
url: "/scholarship/new/fdy-audit" // 跳转到对应的审核页面
}
```
注意事项与最佳实践:
- **保持一致性**新增业务时尽量遵循现有的状态码约定如1=待初审, 2=待院审, 3=待校审, 6=驳回)。
- **注释是关键**:添加任何新的 `union` 查询时,请务必在前面加上清晰的注释,说明其业务目的和开发者。
- **前端同步**:后端添加的任何新前缀,都必须在前端有对应的 `name` 才能显示出来。
- **性能考虑**`UNION` 的性能开销会随着子查询的增多而增加。虽然目前性能良好,但未来应避免无限制地增加。
- **逻辑严谨**:在编写 `WHERE` 条件时,要特别注意审批链的流转,确保上级审批的待办条件正确承接了下级的“已通过”状态。
========================================================================================================================
-->
</mapper>