| | |
| | | and subject_name = #{subjectName} |
| | | <if test="id != null ">and id != #{id}</if> |
| | | </select> |
| | | <select id="selectCountCategory" resultType="com.gkhy.exam.pay.dto.rep.NonCategoryCount"> |
| | | SELECT |
| | | cc.id, |
| | | sot.name as subject_name, |
| | | cc.amount, |
| | | cc.category_type, |
| | | COUNT( cps.`name` ) num |
| | | FROM |
| | | non_coal_category cc |
| | | LEFT JOIN sys_operate_type sot on cc.operate_type_id = sot.id |
| | | LEFT JOIN non_coal_pay_category cpc ON cc.id = cpc.category_id |
| | | LEFT JOIN non_coal_pay cp ON cpc.non_coal_pay_id = cp.id |
| | | LEFT JOIN non_coal_pay_student cps ON cp.id = cps.non_coal_pay_id |
| | | WHERE cc.category_type = 2 and cc.del_flag = 0 and cps.del_flag =0 and cp.del_flag = 0 and cps.pay_status = 1 |
| | | <if test="year!=null and year !=''"> |
| | | and cp.year =#{year} |
| | | </if> |
| | | <if test="quarter != null"> |
| | | and cp.quarter = #{quarter} |
| | | </if> |
| | | <if test="districtCode!=null and districtCode!=''"> |
| | | and cc.district_code =#{districtCode} |
| | | </if> |
| | | <if test="deptId!=null"> |
| | | and cp.dept_id =#{deptId} |
| | | </if> |
| | | GROUP BY |
| | | cc.id |
| | | </select> |
| | | <select id="selectCountTheory" resultType="com.gkhy.exam.pay.dto.rep.CateGoryTheory"> |
| | | WITH filtered_data AS ( |
| | | SELECT |
| | | cp.id AS pay_id, |
| | | cp.pay_type, |
| | | cpc.category_id AS category_id |
| | | FROM |
| | | non_coal_pay cp |
| | | LEFT JOIN non_coal_pay_category cpc ON cp.id = cpc.non_coal_pay_id |
| | | LEFT JOIN non_coal_category cc ON cpc.category_id = cc.id |
| | | WHERE |
| | | cc.category_type = 1 |
| | | AND cp.del_flag = 0 |
| | | <if test="year !=null and year!=''"> |
| | | and cp.year = #{year} |
| | | </if> |
| | | <if test="quarter!=null"> |
| | | and cp.quarter = #{quarter} |
| | | </if> |
| | | <if test="districtCode !=null and districtCode !=''"> |
| | | and cp.district_code = #{districtCode} |
| | | </if> |
| | | <if test="deptId!=null"> |
| | | and cp.dept_id =#{deptId} |
| | | </if> |
| | | ), |
| | | pay_type_data AS ( |
| | | SELECT |
| | | CASE |
| | | WHEN fd.pay_type IN (1, 3) THEN '初训理论' |
| | | ELSE '复训理论' |
| | | END AS pay_type_name, |
| | | cps.id AS student_id, |
| | | cc.amount |
| | | FROM |
| | | filtered_data fd |
| | | LEFT JOIN non_coal_pay_student cps ON fd.pay_id = cps.non_coal_pay_id |
| | | LEFT JOIN non_coal_category cc ON fd.category_id = cc.id |
| | | WHERE |
| | | cps.del_flag = 0 and cps.pay_status =1 |
| | | ) |
| | | SELECT |
| | | pay_type_name, |
| | | COUNT(student_id) AS num, |
| | | MAX(amount) AS amount |
| | | FROM |
| | | pay_type_data |
| | | GROUP BY |
| | | pay_type_name |
| | | </select> |
| | | |
| | | <update id="deleteNonCoalCategoryById" parameterType="Long"> |
| | | update non_coal_category |