我这种查询方式还没有发现重复的在线记录,最新版本20240325 int i,yhsl,count,j; string sql,yhbh,userIds,uid,relauserid,relauserids; uid = get_user_id() get_online_user(); yhsl = db_row_count() userIds=""; for(i=0;i<yhsl;i++); { db_go_row(i) yhbh = db_res(0) if(userIds=="") { userIds="'"+yhbh+"'"; } else { userIds=userIds+",'"+yhbh+"'"; } }; if(is_super_user() == '1') //限定超级用户 { sql="select p.unit_id as 组织架构,a.user_id as 用户账号,a.user_name as 用户名称,a.ip as 登录电脑名,a.ip as 登录IP,a.machine_id as 登录电脑机器标识,"; sql=sql+"substring(a.login_time,0,9) as 登录日期,substring(a.login_time,9,15) as 登录时刻,p.note_info as 用户备注 from mup_login_log as a,mup_user p"; sql=sql+" where login_time = (select max(login_time) from mup_login_log as b where b.user_id = a.user_id) and p.user_id = a.user_id and a.user_id in("+ userIds +")"; db_run_query_thr(sql) count = db_row_count() for(j=0;j<count;j++); { db_go_row(j) db_add_field('登录电脑名') db_set_value_ext('登录电脑名',str_get_sub(db_res(3),0,str_pos(db_res(3)," "))) db_add_field('登录IP') db_set_value_ext('登录IP',str_get_sub(db_res(4),str_pos(db_res(4)," ")+1,strlen(db_res(4))-str_pos(db_res(4)," "))) db_add_field('登录日期') db_set_value_ext('登录日期', fmt_date(db_res(6),"yyyy年mm月dd日")) db_add_field('登录时刻') db_set_value_ext('登录时刻', fmt_date(db_res(7),"hh:mi:ss")) db_map("mup_unit","组织架构","组织架构"); }; db_show('【在线用户】登录信息') }; |