Newer
Older
casic-metering / casic-metering-dao / src / main / resources / mapper / MeterStaffMapper.xml
xiezhuangzhuang on 29 Nov 2022 4 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 where t.is_del = 0) 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>
    <select id="selectStaffInfo" resultType="com.casic.missiles.model.MeterStaff" parameterType="String">
        SELECT
            t.id,
            t.id_card,
            t.account,
            t.`NAME`,
            t.staff_no,
            t.sex,
            t.birthday,
            t.certificate_company,
            t.verifier_certificate_no,
            t.certificate_date,
            t.work_date,
            t.main_examiner,
            t.special_operator,
            (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,
			t.remark
        FROM
            meter_staff t where t.id =#{id}
    </select>
    <update id="updateStaffInfo" parameterType="com.casic.missiles.model.MeterStaff">
        UPDATE meter_staff
        SET `name` = #{meterStaff.name},
            `id_card` = #{meterStaff.idCard},
            `account` = #{meterStaff.account},
            `staff_no` = #{meterStaff.staffNo},
            `birthday` = DATE_FORMAT(#{meterStaff.birthday},'%Y-%m-%d %H:%i:%S'),
            `education` = #{meterStaff.education},
            `technology_job` = #{meterStaff.technologyJob},
            `administration_job` = #{meterStaff.administrationJob},
            `dept_id` = #{meterStaff.deptId},
            `major` = #{meterStaff.major},
            `certificate_company` = #{meterStaff.certificateCompany},
            `verifier_certificate_no` = #{meterStaff.verifierCertificateNo},
            `certificate_date` = DATE_FORMAT(#{meterStaff.certificateDate},'%Y-%m-%d %H:%i:%S'),
            `work_date` = DATE_FORMAT(#{meterStaff.workDate},'%Y-%m-%d %H:%i:%S'),
            `technology_exam` = #{meterStaff.technologyExam},
            `main_examiner` = #{meterStaff.mainExaminer},
            `special_operator` = #{meterStaff.specialOperator},
            `remark` = #{meterStaff.remark},
            `update_time` =  DATE_FORMAT(#{meterStaff.updateTime},'%Y-%m-%d %H:%i:%S')
        WHERE
            `id` = #{meterStaff.id}
    </update>

    <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>