hd_real_name/target/classes/mappers/attendanceMachine/AttendanceMachineMapper.xml

110 lines
5.1 KiB
XML
Raw Normal View History

2025-03-17 15:01:27 +08:00
<?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.bonus.gzrn.rnbmw.attendanceMachine.dao.AttendanceMachineDao">
<select id="getAttendanceMachineList"
resultType="com.bonus.gzrn.rnbmw.attendanceMachine.entity.AttendanceMachineBean">
select bam.id, bamr.id as relationProId, bam.attendance_machine_name, bam.attendance_machine_id, bp.name as proName,
cu.username as createUserName, bu.username as bindingUserName, uu.username as unbindingUserName
from bm_attendance_machine bam
left join bm_attendance_machine_pro_relation bamr on bamr.attendance_machine_id = bam.id and bamr.is_active = 1
left join bm_project bp on bp.id = bamr.pro_id
left join sys_user cu on cu.id = bam.create_user_id
left join sys_user bu on bu.id = bamr.binding_user_id
left join sys_user uu on uu.id = bamr.unbinding_user_id
where bam.is_active = 1
<if test="params.proName != null and params.proName != ''">
and bp.name like concat('%',#{params.proName},'%')
</if>
<if test="params.status != null and params.status != ''">
<if test='params.status == "在用"'>
and bamr.pro_id is not null
</if>
<if test='params.status == "空闲"'>
and bamr.pro_id is null
</if>
</if>
<if test="offset != null and offset >= 0 and limit != null and limit >= 0">
limit #{offset}, #{limit}
</if>
</select>
<select id="getAttendanceMachineListCount" resultType="java.lang.Integer">
select count(bam.id) from bm_attendance_machine bam
left join bm_attendance_machine_pro_relation bamr on bamr.attendance_machine_id = bam.id and bamr.is_active = 1
left join bm_project bp on bp.id = bamr.pro_id
left join sys_user cu on cu.id = bam.create_user_id
left join sys_user bu on bu.id = bamr.binding_user_id
left join sys_user uu on uu.id = bamr.unbinding_user_id
where bam.is_active = 1
<if test="params.proId != null and params.proId != ''">
and bamr.pro_id = #{params.proId}
</if>
<if test="params.status != null and params.status != ''">
<if test='params.status == "在用"'>
and bamr.pro_id is not null
</if>
<if test='params.status == "空闲"'>
and bamr.pro_id is null
</if>
</if>
</select>
<insert id="addAttendanceMachine" useGeneratedKeys="true" keyProperty = "id" keyColumn="id">
insert into bm_attendance_machine(attendance_machine_id, attendance_machine_name, create_user_id)
select #{attendanceMachineId}, #{attendanceMachineName}, #{createUserId} from dual
where NOT EXISTS (SELECT attendance_machine_id FROM bm_attendance_machine WHERE
attendance_machine_id = #{attendanceMachineId} and is_active = 1)
</insert>
<insert id="addAttendanceMachinePro">
insert into bm_attendance_machine_pro_relation(attendance_machine_id, pro_id, binding_user_id)
values (#{id}, #{proId}, #{bindingUserId})
</insert>
<update id="updateAttendanceMachine">
update bm_attendance_machine_pro_relation set unbinding_user_id = #{unbindingUserId},
is_active = 0 where id = #{relationProId}
</update>
<update id="updatePersonJobStatus">
update bm_attendance_machine_push_history set is_job = 0 where attendance_machine_id = #{attendanceMachineId}
</update>
<insert id="insertAttendanceMachineJobPush">
insert into bm_attendance_machine_push(id_number, attendance_machine_id, operate)
values (#{idNumber}, #{attendanceMachineId}, #{operate});
</insert>
<insert id="insertAttendanceMachinePush">
insert into bm_attendance_machine_push(id_number, face_base64, face_path, attendance_machine_id, operate)
values (#{idNumber}, #{faceImg}, #{facePhoto}, #{attendanceMachineId}, #{operate});
replace into bm_attendance_machine_push_history(id_number, attendance_machine_id) values
(#{idNumber}, #{attendanceMachineId})
</insert>
<select id="selectAttendanceMachinePushList"
resultType="com.bonus.gzrn.rnbmw.PersonComprehensive.entity.PersonComprehensiveBean">
select bamp.id_number as idNumber, bw.name, operate, face_base64 as faceImg from bm_attendance_machine bam
left join bm_attendance_machine_push bamp on bamp.attendance_machine_id = bam.id and is_push = 0
left join bm_worker bw on bw.id_number = bamp.id_number
where bam.is_active = 1 and bam.attendance_machine_id = #{sn}
</select>
<select id="selectBasePersonList" resultType="com.bonus.gzrn.rnbmw.PersonComprehensive.entity.PersonComprehensiveBean">
select bw.id_number as idNumber, bwp.PHOTO_PATH as facePhoto,
bwp.FACE_FEATURES as faceFeatureByte from bm_worker bw
left join bm_worker_record bwr on bwr.id_number = bw.id_number and bwr.is_active = 1
left join bm_worker_photo bwp on bwp.ID_NUMBER = bw.id_number and bwp.PHOTO_TYPE = 3
where bw.IS_ACTIVE = 1 and bwr.ein_status = 1 and bwr.project_id = #{proId}
and bwp.PHOTO_PATH is not null
</select>
<select id="selectBasePersonPushList" resultType="com.bonus.gzrn.rnbmw.PersonComprehensive.entity.PersonComprehensiveBean">
select id_number as idNumber, attendance_machine_id as attendanceMachineId from bm_attendance_machine_push_history
where is_job = 0 and attendance_machine_id = #{id}
</select>
</mapper>