<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
|
<%Session.CodePage=65001%>
|
<!--#include file="JsonPost_3010011.gds"-->
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<%
|
'创建成员 Https请求方式: POST
|
Set rs = Server.CreateObject("ADODB.Recordset")
|
|
appUrl="https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata?access_token="&access_token
|
userid = trim(Request("userid"))
|
starttime = trim(Request("starttime"))
|
endtime = trim(Request("endtime"))
|
If starttime="" Then
|
If userid<>"" Then useridSql=" where userid='"&userid&"'"
|
sql="select top 1 checkin_time from OA_CheckinData"&useridSql&" order by checkin_time desc"
|
rs.open sql,objConn,1,1
|
if not rs.Eof then
|
starttime = rs("checkin_time")
|
Else
|
starttime = date()-day(date()-1) '当月第一天
|
end if
|
rs.close()
|
End If
|
If endtime="" Then endtime=Now()
|
starttime=ToUnixTime(starttime,+8)+1
|
endtime=ToUnixTime(endtime,+8)
|
|
If userid="" Then
|
sql="select top 100 OA_weixinUserID from dbo.OA_User where OA_DepartmentID in (select vID from dictionary where vtitle='OA_Department' and vType=150) and OA_execLevel in (0,1)"
|
rs.open sql,objConn,1,1
|
do while not rs.Eof
|
OA_weixinUserID = rs("OA_weixinUserID")
|
useridlist=useridlist&""","""&OA_weixinUserID
|
rs.movenext
|
loop
|
rs.close()
|
If useridlist<>"" Then useridlist=Mid(useridlist,4)
|
Else
|
useridlist=userid
|
End If
|
|
args1="{"
|
args1=args1&"""opencheckindatatype"": 3"
|
args1=args1&",""starttime"": "&starttime
|
args1=args1&",""endtime"": "&endtime
|
args1=args1&",""useridlist"":["""&useridlist&"""]"
|
args1=args1&"}"
|
'Response.Write args1&"<br>"
|
'Response.End
|
HTMLCODE= PostBody(appUrl,args1)
|
|
'Response.Write HTMLCODE&"<br><br>"
|
'Response.End
|
If HTMLCODE<>"" Then
|
%>
|
<script language="JScript" runat="Server">
|
function toObject(json) {
|
eval("var o=" + json);
|
return o;
|
}
|
function toArray(s){
|
var dic = Server.CreateObject("Scripting.Dictionary")
|
eval("var a=" + json);
|
for(var i=0;i<a.length;i++){
|
var obj = Server.CreateObject("Scripting.Dictionary")
|
for(x in a[i]) obj.Add(x,a[i][x])
|
dic.Add(i, obj);
|
}
|
return dic
|
}
|
</script>
|
<script language="jscript" runat="server">
|
Array.prototype.get = function(i)
|
{
|
return this[i];
|
};
|
function getjson(str){
|
try{
|
eval("var jsonStr = (" + str + ")");
|
}catch(ex){
|
var jsonStr = null;
|
}
|
return jsonStr;
|
}
|
</script>
|
<%
|
str=HTMLCODE
|
dim obj
|
set obj = getjson(str)
|
errmsg = obj.errmsg
|
If errmsg="ok" Then
|
for v=0 to obj.checkindata.length-1
|
userid = obj.checkindata.get(v).userid '用户id
|
groupname = obj.checkindata.get(v).groupname '打卡规则名称
|
checkin_type = obj.checkindata.get(v).checkin_type '打卡类型。字符串,目前有:上班打卡,下班打卡,外出打卡
|
exception_type = obj.checkindata.get(v).exception_type '异常类型,字符串,包括:时间异常,地点异常,未打卡,wifi异常,非常用设备。如果有多个异常,以分号间隔
|
checkin_time = FromUnixTime(obj.checkindata.get(v).checkin_time, +8) '打卡时间。Unix时间戳
|
location_title = obj.checkindata.get(v).location_title '打卡地点title
|
location_detail = obj.checkindata.get(v).location_detail'打卡地点详情
|
wifiname = obj.checkindata.get(v).wifiname '打卡wifi名称
|
notes = obj.checkindata.get(v).notes '打卡备注
|
wifimac = obj.checkindata.get(v).wifimac '打卡的MAC地址/bssid
|
'mediaids = obj.checkindata.get(v).mediaids '打卡的附件media_id,可使用media/get获取附件
|
lat = obj.checkindata.get(v).lat '位置打卡地点纬度,是实际纬度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准
|
lng = obj.checkindata.get(v).lng '位置打卡地点经度,是实际经度的1000000倍,与腾讯地图一致采用GCJ-02坐标系统标准
|
'deviceid = obj.checkindata.get(v).deviceid '打卡设备id
|
'sch_checkin_time= obj.checkindata.get(v).sch_checkin_time'标准打卡时间,指此次打卡时间对应的标准上班时间或标准下班时间
|
'groupid = obj.checkindata.get(v).groupid '规则id,表示打卡记录所属规则的id
|
'schedule_id = obj.checkindata.get(v).schedule_id '班次id,表示打卡记录所属规则中,所属班次的id
|
'timeline_id = obj.checkindata.get(v).timeline_id '时段id,表示打卡记录所属规则中,某一班次中的某一时段的id,如上下班时间为9:00-12:00、13:00-18:00的班次中,9:00-12:00为其中一组时段
|
'Response.Write userid&"<br>"
|
'Response.Write checkin_type &" "& exception_type&"<br>"
|
'Response.Write location_detail&"<br><br>"
|
sql="Insert into OA_CheckinData (userid,groupname,checkin_type,exception_type,checkin_time,location_title,location_detail,wifiname,notes,wifimac,mediaids,lat,lng,deviceid,sch_checkin_time,groupid,schedule_id,timeline_id) values ('"&userid&"','"&groupname&"','"&checkin_type&"','"&exception_type&"','"&checkin_time&"','"&location_title&"','"&location_detail&"','"&wifiname&"','"¬es&"','"&wifimac&"','"&mediaids&"','"&lat&"','"&lng&"','"&deviceid&"','"&sch_checkin_time&"','"&groupid&"','"&schedule_id&"','"&timeline_id&"')"
|
objConn.Execute sql
|
Next
|
End If
|
'Response.Write errmsg&"<br><br>"
|
End If
|
'Response.End
|
Response.Write errmsg
|
|
'把标准时间转换为UNIX时间戳
|
Function ToUnixTime(strTime, intTimeZone)
|
If IsEmpty(strTime) or Not IsDate(strTime) Then strTime = Now
|
If IsEmpty(intTimeZone) or Not isNumeric(intTimeZone) Then intTimeZone = 0
|
ToUnixTime = DateAdd("h",-intTimeZone,strTime)
|
ToUnixTime = DateDiff("s","1970-01-01 00:00:00", ToUnixTime)
|
End Function
|
'把UNIX时间戳转换为标准时间
|
Function FromUnixTime(intTime, intTimeZone)
|
If IsEmpty(intTime) or Not IsNumeric(intTime) Then
|
FromUnixTime = Now()
|
Exit Function
|
End If
|
If IsEmpty(intTime) or Not IsNumeric(intTimeZone) Then intTimeZone = 0
|
FromUnixTime = DateAdd("s", intTime, "1970-01-01 00:00:00")
|
FromUnixTime = DateAdd("h", intTimeZone, FromUnixTime)
|
End Function
|
%>
|