<?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.meter.MeterStaffMapper">
<insert id="addStaffList" parameterType="java.util.List">
INSERT INTO meter_staff (
`id`,
`name`,
`id_card`,
`account`,
`staff_no`,
`sex`,
`birthday`,
`education`,
`technology_job`,
`administration_job`,
`dept_id`,
`major`,
`work_date`,
`technology_exam`,
`main_examiner`,
`special_operator`,
`remark`
)
VALUES
<foreach collection ="list" item="bean" separator =",">
(#{bean.id}, #{bean.name}, #{bean.idCard}, #{bean.account}, #{bean.staffNo}
, #{bean.sex}, STR_TO_DATE(#{bean.birthday},'%Y-%m-%d'), #{bean.education}, #{bean.technologyJob}
, #{bean.administrationJob}, #{bean.deptId}, #{bean.major}, STR_TO_DATE(#{bean.workDate},'%Y-%m-%d'), #{bean.technologyExam}
, #{bean.mainExaminer}, #{bean.specialOperator}, #{bean.remark}
)
</foreach >
</insert>
<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,
t.education,
t.technology_job,
t.administration_job,
t.dept_id,
(select `certificate_no` from meter_certificate where staff_id = t.id ORDER BY create_time limit 1) as verifier_certificate_no,
(select `valid_date` from meter_certificate where staff_id = t.id ORDER BY create_time limit 1) 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.dept_id = #{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,
t.education,
t.technology_job,
t.administration_job,
t.dept_id,
(select `certificate_no` from meter_certificate where staff_id = t.id ORDER BY create_time limit 1) as verifier_certificate_no,
(select `valid_date` from meter_certificate where staff_id = t.id ORDER BY create_time limit 1) as certificate_date,
t.major,
t.technology_exam,
t.remark,
t.minio_file_name
FROM
meter_staff t where t.id =#{id}
</select>
<select id="meterStaffStatistic" resultType="com.casic.missiles.dto.meter.MeterWorkbenchResponse">
SELECT
DATE_FORMAT( work_date, '%Y-%m' ) AS `date`,
COUNT( 1 ) AS `count`
FROM
meter_staff
WHERE
is_del = 0
and DATE_FORMAT( work_date, '%Y-%m' ) >= #{startTime}
and DATE_FORMAT( work_date, '%Y-%m' ) <= #{endTime}
GROUP BY
DATE_FORMAT( work_date, '%Y-%m' )
ORDER BY
DATE_FORMAT( work_date, '%Y-%m' )
</select>
<select id="getMaxNo" resultType="java.lang.Long">
SELECT IFNULL(max(RIGHT(staff_no, 12)), 0) from meter_staff
</select>
</mapper>