【调度系统】广东民航医疗快线调度系统源代码
wzp
2024-12-05 8a09f655eace34e9c90bbfc711eedb7a69e4e068
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!--#include virtual="/inc/odbc.asp"-->
<%
'接口信息(系统提示)
corpid="wx248505bfbab6d0c1"
corpsecret="lGTkJljHoaRjBbDGkmrrlS9VFGkN-9Ha7FQ2nObSY9s"
 
access_token=GetAccess_token()
 
 
'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=wx248505bfbab6d0c1&corpsecret=2MCilqWYC0FWjOQ894sbb-s7Lb5sVH4HHuJgOsd9l1k
'{"access_token":"2qs5HAae2cno2I4_WkFwTyMMbpI0k1q0IP74qNH4f9o52Lpmebnl5aJRkeiruCA5OPfNzA2X-6vpBqPPIoeIKA","expires_in":7200}
'appUrl="http://tvadmin.v.com.cn/ECERP/aa.asp"
 
'Post方法
Function PostBody(appUrl,args1)
Set PBrs = Server.CreateObject("ADODB.Recordset")
 
    Set https = Server.CreateObject("Msxml2.ServerXMLHTTP") 
    
    'Set https = Server.CreateObject("MSXML2.XMLHTTP") 
    With https 
    .Open "Post", appUrl, False
    .setRequestHeader "Content-Type","application/x-www-form-urlencoded"
    .Send args1
    PostBody = .ResponseBody
    End With 
    PostBody = BytesToBstr(PostBody,"utf-8")
    Set https = Nothing 
End Function
 
'Get方法
Function GetBody(appUrl,Origin)
Set https = Server.CreateObject("Msxml2.ServerXMLHTTP") 
 
With https 
.Open "GET", appUrl&"?"&Origin, False
.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
.Send ""
GetBody = .ResponseBody
End With 
GetBody = BytesToBstr(GetBody,"utf-8")
Set https = Nothing 
End Function
 
'获取access_token
Function GetAccess_token()
access_tokenID=8056    '对应数据库ID 
corpid="wx248505bfbab6d0c1"
corpsecret="lGTkJljHoaRjBbDGkmrrlS9VFGkN-9Ha7FQ2nObSY9s"
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select vtext,vMono from dictionary where id="&access_tokenID
rs.open sql,objConn,1,1
access_token=rs("vtext")
access_token_time=cdate(rs("vMono"))
rs.close()
If DateDiff("s",access_token_time,now())>0 then
    '获取新的access_token
    url="https://qyapi.weixin.qq.com/cgi-bin/gettoken"  '//定义要获取源代码的网址,一般是通过变量传递过来
    Origin="corpid="&corpid&"&corpsecret="&corpsecret
    HTMLCODE= GetBody(url,Origin)
    'Response.Write HTMLCODE
    str="["&HTMLCODE&"]"
    set obj = getjson(str)
    access_token    = obj.get(0).access_token
    expires_in        = obj.get(0).expires_in
    'access_token=replace(replace(HTMLCODE,"{""access_token"":""",""),""",""expires_in"":7200}","")    
    access_token_time=DateAdd("s",500,now())
    '写入数据库
    sql="update dictionary set vtext='"&access_token&"',vMono='"&access_token_time&"' where id="&access_tokenID
 
    objConn.Execute sql
End if 
GetAccess_token = access_token
End Function
 
'返回结果写入数据库
Private Function API_JsonSql(method,HTMLCODE,reserve)
    sql="Insert into API_Json (method,Json,reserve) values ('"&method&"','"&HTMLCODE&"','"&reserve&"')"
    objConn.Execute sql
    Set rs = Server.CreateObject("ADODB.Recordset")
    sql="select id from API_Json where method='"&method&"' and is_Json=0 order by id desc"
    rs.open sql,objConn,1,1
    if not rs.Eof then
    JsonID=rs("id")
    else
    JsonID=""
    end if    
    rs.close()
    API_JsonSql=JsonID
End Function
 
Function BytesToBstr(body,Cset) '飘易:转换GB2312
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText 
objstream.Close
set objstream = nothing
End Function
 
 
Private Function BuildRequestMysign(sParaSort)
    '获得签名结果
    key               = AppSecret
    sign_type       = "MD5"
    'sParaSort="{""appkey"":"""&appKey&""",""sessionkey"":"""&sessionKey&""","&sParaSort&"}"
    input_charset="utf-8"
    BuildRequestMysign = Md5Sign(sParaSort,key,input_charset)
End Function
 
'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-1-1 0:0:0", ToUnixTime)        
End Function
 
'输入参数
'method="gy.erp.vip.get"
'args1="""method"":"""&method&""",""page_no"":""1"",""page_size"":""10"",""name"":""李欣"""
 
 
'签名
'key               = secret
 
'sign_type       = "MD5"
'sParaSort="{""appkey"":"""&appKey&""",""sessionkey"":"""&sessionKey&""","&args1&"}"
'input_charset="utf-8"
'sign1 = UCase(BuildRequestMysign(sParaSort))
'sign1 = UCase(md5(key&sParaSort&key))    
 
 
'Response.Write "{""access_token"":""sV2v8S3qm9jeEyUUSD166ftctmvzbH9bZANj42bI1mMMnh1JNRpuCxWuKo-KATyhfmOZI181i1U7PH0ZeU1rXVZUoFJRNnUkp0RPYrbLdAw"",""expires_in"":7200}"
%>
 
<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>