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, dic1.dict_label as craft_type_name,dic2.dict_label as craft_post_name,pma.att_device, 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 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 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' insert into pro_mobile_attendance_data user_id, project_id, cfg_id, in_out, longitude, latitude, att_date, att_img, att_device, work_area_id, is_del, remark, state, create_by, create_time, update_by, update_time, #{userId}, #{projectId}, #{cfgId}, #{inOut}, #{longitude}, #{latitude}, #{attDate}, #{attImg}, #{attDevice}, #{isDel}, #{workAreaId}, #{remark}, #{state}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, update pro_mobile_attendance_data user_id = #{userId}, project_id = #{projectId}, cfg_id = #{cfgId}, in_out = #{inOut}, longitude = #{longitude}, latitude = #{latitude}, att_date = #{attDate}, att_img = #{attImg}, att_device = #{attDevice}, is_del = #{isDel}, remark = #{remark}, state = #{state}, create_by = #{createBy}, create_time = #{createTime}, update_by = #{updateBy}, update_time = #{updateTime}, where id = #{id} delete from pro_mobile_attendance_data where id = #{id} delete from pro_mobile_attendance_data where id in #{id}