Newer
Older
casic-metering / casic-metering-dao / src / main / resources / mapper / MeterStaffMapper.xml
xiezhuangzhuang on 29 Nov 2022 2 KB 计量人员相关接口开发
<?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.casic.missiles.mapper.MeterStaffMapper">

    <select id="selectStaffList" resultType="com.casic.missiles.model.MeterStaff" parameterType="com.casic.missiles.dto.meter.MeterStaffRequest">
        select t2.* from (SELECT
            t.id,
            t.`NAME`,
            t.staff_no,
            t.sex,
            (select `NAME` from sys_dict where id = t.education) as education,
            (select `NAME` from sys_dict where id = t.technology_job) as technology_job,
            (select `NAME` from sys_dict where id = t.administration_job) as administration_job,
            (select `FULL_NAME` from sys_dept where id = t.dept_id) as dept_id,
            (select `id` from sys_dept where id = t.dept_id) as did,
            (select `certificate_no` from meter_certificate where staff_id = t.id ORDER BY create_time limit 1) as verifier_certificate_no,
            DATE_FORMAT((select `valid_date` from meter_certificate where staff_id = t.id ORDER BY create_time limit 1),'%Y-%m-%d') as certificate_date,
            t.major,
            t.technology_exam
        FROM
            meter_staff t) t2
        <where>
            <if test="request.staffNo != null  and request.staffNo != ''">
                and t2.staff_no like CONCAT('%',#{request.staffNo},'%')
            </if>
            <if test="request.name != null  and request.name != ''">
                and t2.`NAME` like concat('%', #{request.name}, '%')
            </if>
            <if test="request.deptId != null  and  request.deptId != ''">
                and t2.did = #{request.deptId}
            </if>
            <if test="request.major != null  and request.major != ''">
                and t2.major like concat('%', #{request.major}, '%')
            </if>
            <if test="request.verifierCertificateNo != null  and request.verifierCertificateNo != ''">
                and t2.verifier_certificate_no like concat('%', #{request.verifierCertificateNo}, '%')
            </if>
        </where>
    </select>

    <update id="deleteStaff">
        UPDATE meter_staff SET `is_del` = 1 WHERE `id` = #{id}
    </update>

    <select id="getMaxNo" resultType="long">
        SELECT IFNULL(max(RIGHT(staff_no, 12)), 0) from meter_staff
    </select>
</mapper>