2025-09-03 15:36:22 +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.yanzhu.manage.mapper.ProMobileAttendanceDataMapper" >
<resultMap type= "ProMobileAttendanceData" id= "ProMobileAttendanceDataResult" >
<result property= "id" column= "id" />
<result property= "userId" column= "user_id" />
<result property= "projectId" column= "project_id" />
<result property= "cfgId" column= "cfg_id" />
<result property= "inOut" column= "in_out" />
<result property= "longitude" column= "longitude" />
<result property= "latitude" column= "latitude" />
<result property= "attDate" column= "att_date" />
<result property= "attImg" column= "att_img" />
<result property= "isDel" column= "is_del" />
<result property= "remark" column= "remark" />
<result property= "state" column= "state" />
<result property= "createBy" column= "create_by" />
<result property= "createTime" column= "create_time" />
<result property= "updateBy" column= "update_by" />
<result property= "updateTime" column= "update_time" />
2025-09-17 15:44:26 +08:00
<result property= "userName" column= "user_name" />
<result property= "userPhone" column= "user_phone" />
<result property= "subDeptName" column= "sub_dept_name" />
<result property= "subDeptGroupName" column= "sub_dept_group_name" />
<result property= "craftTypeName" column= "craft_type_name" />
<result property= "craftPostName" column= "craft_post_name" />
<result property= "userPost" column= "user_post" />
<result property= "userSex" column= "user_sex" />
2025-09-18 16:48:12 +08:00
<result property= "attDevice" column= "att_device" />
2025-12-29 16:00:21 +08:00
<result property= "workAreaId" column= "wa.work_area_id" />
2025-09-03 15:36:22 +08:00
</resultMap>
<sql id= "selectProMobileAttendanceDataVo" >
2025-09-17 15:44:26 +08:00
select pma.id, pma.user_id, pma.project_id, pma.cfg_id, pma.in_out, pma.longitude, pma.latitude, pma.att_date, pma.att_img, pma.is_del,
pma.remark, pma.state, pma.create_by, pma.create_time, pma.update_by, pma.update_time,
2025-09-18 16:48:12 +08:00
dic1.dict_label as craft_type_name,dic2.dict_label as craft_post_name,pma.att_device,
2025-09-17 15:44:26 +08:00
psu.user_name, psu.user_phone,psu.sub_dept_name,psu.sub_dept_group_name,psu.user_post,psu.user_sex
from pro_mobile_attendance_data pma
2025-09-25 16:33:09 +08:00
left join (
SELECT t.* FROM pro_project_info_subdepts_users t
INNER JOIN (SELECT user_id, MAX(CONCAT(IFNULL(update_time, DATE('2099-12-31')), create_time)) AS max_time_key FROM pro_project_info_subdepts_users GROUP BY user_id) t_max ON t.user_id = t_max.user_id
AND CONCAT(IFNULL(t.update_time, DATE('2099-12-31')), t.create_time) = t_max.max_time_key
) psu ON pma.user_id = psu.user_id
2025-09-17 15:44:26 +08:00
left join sys_dict_data dic1 on psu.`craft_type`=dic1.`dict_value` and dic1.`dict_type`='pro_craft_type'
left join sys_dict_data dic2 on psu.`craft_post`=dic2.`dict_value` and dic2.`dict_type`='pro_craft_post'
2025-09-03 15:36:22 +08:00
</sql>
<select id= "selectProMobileAttendanceDataList" parameterType= "ProMobileAttendanceData" resultMap= "ProMobileAttendanceDataResult" >
<include refid= "selectProMobileAttendanceDataVo" />
<where >
2025-09-17 15:44:26 +08:00
<if test= "userId != null " > and pma.user_id = #{userId}</if>
<if test= "projectId != null " > and pma.project_id = #{projectId}</if>
<if test= "cfgId != null " > and pma.cfg_id = #{cfgId}</if>
<if test= "inOut != null and inOut != ''" > and pma.in_out = #{inOut}</if>
<if test= "longitude != null " > and pma.longitude = #{longitude}</if>
<if test= "latitude != null " > and pma.latitude = #{latitude}</if>
<if test= "attDate != null " > and pma.att_date = #{attDate}</if>
<if test= "attImg != null and attImg != ''" > and pma.att_img = #{attImg}</if>
<if test= "isDel != null " > and pma.is_del = #{isDel}</if>
<if test= "state != null " > and pma.state = #{state}</if>
2025-12-29 18:03:22 +08:00
<if test= "workAreaId != null " > and wa.work_area_id = #{workAreaId}</if>
2025-09-17 15:44:26 +08:00
<if test= "userName!=null and userName!=''" > and psu.user_name like concat('%', #{userName}, '%')</if>
<if test= "userPhone!=null and userPhone!=''" > and psu.user_phone like concat('%', #{userPhone}, '%')</if>
<if test= "startDate!=null" > and date(pma.att_date) > = date(#{startDate})</if>
<if test= "endDate!=null" > and date(pma.att_date) < = date(#{endDate})</if>
2025-09-03 15:36:22 +08:00
</where>
2025-09-18 16:48:12 +08:00
order by pma.att_date desc,pma.id desc
2025-09-03 15:36:22 +08:00
</select>
<select id= "selectProMobileAttendanceDataById" parameterType= "Long" resultMap= "ProMobileAttendanceDataResult" >
<include refid= "selectProMobileAttendanceDataVo" />
2025-09-17 15:44:26 +08:00
where pma.id = #{id}
2025-09-03 15:36:22 +08:00
</select>
<insert id= "insertProMobileAttendanceData" parameterType= "ProMobileAttendanceData" useGeneratedKeys= "true" keyProperty= "id" >
insert into pro_mobile_attendance_data
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "userId != null" > user_id,</if>
<if test= "projectId != null" > project_id,</if>
<if test= "cfgId != null" > cfg_id,</if>
<if test= "inOut != null" > in_out,</if>
<if test= "longitude != null" > longitude,</if>
<if test= "latitude != null" > latitude,</if>
<if test= "attDate != null" > att_date,</if>
<if test= "attImg != null" > att_img,</if>
2025-09-18 16:48:12 +08:00
<if test= "attDevice != null" > att_device,</if>
2025-12-29 16:00:21 +08:00
<if test= "workAreaId != null" > work_area_id,</if>
2025-09-03 15:36:22 +08:00
<if test= "isDel != null" > is_del,</if>
<if test= "remark != null" > remark,</if>
<if test= "state != null" > state,</if>
<if test= "createBy != null" > create_by,</if>
<if test= "createTime != null" > create_time,</if>
<if test= "updateBy != null" > update_by,</if>
<if test= "updateTime != null" > update_time,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "userId != null" > #{userId},</if>
<if test= "projectId != null" > #{projectId},</if>
<if test= "cfgId != null" > #{cfgId},</if>
<if test= "inOut != null" > #{inOut},</if>
<if test= "longitude != null" > #{longitude},</if>
<if test= "latitude != null" > #{latitude},</if>
<if test= "attDate != null" > #{attDate},</if>
<if test= "attImg != null" > #{attImg},</if>
2025-09-18 16:48:12 +08:00
<if test= "attDevice != null" > #{attDevice},</if>
2025-09-03 15:36:22 +08:00
<if test= "isDel != null" > #{isDel},</if>
2025-12-29 16:00:21 +08:00
<if test= "workAreaId != null" > #{workAreaId},</if>
2025-09-03 15:36:22 +08:00
<if test= "remark != null" > #{remark},</if>
<if test= "state != null" > #{state},</if>
<if test= "createBy != null" > #{createBy},</if>
<if test= "createTime != null" > #{createTime},</if>
<if test= "updateBy != null" > #{updateBy},</if>
<if test= "updateTime != null" > #{updateTime},</if>
</trim>
</insert>
<update id= "updateProMobileAttendanceData" parameterType= "ProMobileAttendanceData" >
update pro_mobile_attendance_data
<trim prefix= "SET" suffixOverrides= "," >
<if test= "userId != null" > user_id = #{userId},</if>
<if test= "projectId != null" > project_id = #{projectId},</if>
<if test= "cfgId != null" > cfg_id = #{cfgId},</if>
<if test= "inOut != null" > in_out = #{inOut},</if>
<if test= "longitude != null" > longitude = #{longitude},</if>
<if test= "latitude != null" > latitude = #{latitude},</if>
<if test= "attDate != null" > att_date = #{attDate},</if>
<if test= "attImg != null" > att_img = #{attImg},</if>
2025-09-18 16:48:12 +08:00
<if test= "attDevice != null" > att_device = #{attDevice},</if>
2025-09-03 15:36:22 +08:00
<if test= "isDel != null" > is_del = #{isDel},</if>
<if test= "remark != null" > remark = #{remark},</if>
<if test= "state != null" > state = #{state},</if>
<if test= "createBy != null" > create_by = #{createBy},</if>
<if test= "createTime != null" > create_time = #{createTime},</if>
<if test= "updateBy != null" > update_by = #{updateBy},</if>
<if test= "updateTime != null" > update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id= "deleteProMobileAttendanceDataById" parameterType= "Long" >
delete from pro_mobile_attendance_data where id = #{id}
</delete>
<delete id= "deleteProMobileAttendanceDataByIds" parameterType= "String" >
delete from pro_mobile_attendance_data where id in
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
</mapper>