【调度系统】广东民航医疗快线调度系统源代码
wzp
2024-12-05 9dc0d99742f5526321e1b5fdb0dec10e6725415e
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<% @LANGUAGE="VBSCRIPT" CODEPAGE="65001" %> 
<% Session.CodePage=65001 %> 
<% Response.charset = "utf-8" %>
<!--#include virtual="/inc/odbc.asp"-->
<!--#include virtual="/inc/function.asp"-->
<!--#include virtual="/inc/core.asp"-->
<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>
<%
Set rs = Server.CreateObject("ADODB.Recordset")
Set rsDt = Server.CreateObject("ADODB.Recordset")
 
ServiceOrdID    = trim(request("ServiceOrdID"))
StartAddress    = trim(request("StartAddress"))
EndAddress        = trim(request("EndAddress"))
ServiceBranch    = trim(request("ServiceBranch"))
 
If ServiceOrdID<>"" Then
    sql="select ServiceOrdClass,ServiceOrdTraStreet,ServiceOrdTraVia,ServiceOrdTraEnd from ServiceOrder where ServiceOrdID="&ServiceOrdID
    rs.open Sql,objConn,1,1
    If not rs.Eof Then
        ServiceBranch    = rs("ServiceOrdClass")
        StartAddress    = trim(rs("ServiceOrdTraStreet"))
        If rs("ServiceOrdTraVia")<>"" Then StartAddress=rs("ServiceOrdTraVia")
        EndAddress        = trim(rs("ServiceOrdTraEnd"))
    End If
    rs.close()
End If
 
If ServiceBranch="" Then ServiceBranch="BF"
errcode=0
OrderPrice=0
StartAddress_lat=0
StartAddress_lng=0
EndAddress_lat=0
EndAddress_lng=0
 
If StartAddress="" Then
    errcode=40020
    errmsg="invalid StartAddress"
ElseIf EndAddress="" Then
    errcode=40021
    errmsg="invalid EndAddress"
End If
 
'出发地坐标
If InStr(StartAddress,",")>1 And errcode=0 Then
    StartAddressSP=SPLIT(StartAddress,",")
    If UBOUND(StartAddressSP)=1 Then
        If IsNumeric(StartAddressSP(0)) And IsNumeric(StartAddressSP(1)) Then
            StartAddress_lat=StartAddressSP(0)
            StartAddress_lng=StartAddressSP(1)
        End If
    End If
End If
If StartAddress_lat=0 And errcode=0 Then
    sql="select HopsProvince+HopsCity+HopsArea+HospAddress from HospData where HospName='"&StartAddress&"'"
    rs.open Sql,objConn,1,1
    If not rs.Eof Then
        StartAddress=rs(0)
    End If
    rs.close()
    appUrl="http://api.map.baidu.com/geocoder/v2/"
    args1="address="&StartAddress&"&output=json&ak=rGQBbHKGjAtVQy23OckafQkC6nNlaGmi"
    HTMLCODE= GetBody(appUrl,args1)
    'Response.Write HTMLCODE
    'Response.End
    json    = HTMLCODE
    str=json
    set obj = getjson(str)
    status        = obj.status
    If status=0 Then
        StartAddress_lat        = obj.result.location.lat
        StartAddress_lng        = obj.result.location.lng
    End if
End If
 
'目的地坐标
If InStr(EndAddress,",")>1 And errcode=0 Then
    EndAddressSP=SPLIT(EndAddress,",")
    If UBOUND(EndAddressSP)=1 Then
        If IsNumeric(EndAddressSP(0)) And IsNumeric(EndAddressSP(1)) Then
            EndAddress_lat=EndAddressSP(0)
            EndAddress_lng=EndAddressSP(1)
        End If
    End If
End If
If EndAddress_lat=0 And errcode=0 Then
    sql="select HopsProvince+HopsCity+HopsArea+HospAddress from HospData where HospName='"&EndAddress&"'"
    rs.open Sql,objConn,1,1
    If not rs.Eof Then
        EndAddress=rs(0)
    End If
    rs.close()
    appUrl="http://api.map.baidu.com/geocoder/v2/"
    args1="address="&EndAddress&"&output=json&ak=rGQBbHKGjAtVQy23OckafQkC6nNlaGmi"
    HTMLCODE= GetBody(appUrl,args1)
    'Response.Write HTMLCODE
    'Response.End
    json    = HTMLCODE
    str=json
    set obj = getjson(str)
    status        = obj.status
    If status=0 Then
        EndAddress_lat        = obj.result.location.lat
        EndAddress_lng        = obj.result.location.lng
    End If
End If
 
 
If (StartAddress_lat<>0 And EndAddress_lat<>0) And errcode=0 Then
    '机构参数
    sql="select * from IntroducerUnitData where ServiceBranch='"&ServiceBranch&"' and UnitState<>0 order by UnitID desc"
    rs.open sql,objConn,1,1
    If Not rs.eof Then
        UnitID        = rs("UnitID")
        ServiceBranch    = rs("ServiceBranch")
        ServiceMinPrice    = rs("ServiceMinPrice")
        ServiceUnitPrice= rs("ServiceUnitPrice")
        ServiceLong        = rs("ServiceLong")
        ServiceAddress_lat=rs("ServiceAddress_lat")
        ServiceAddress_lng=rs("ServiceAddress_lng")
    Else
        errcode=40024
        errmsg="invalid ServiceBranch"
    End If
    rs.close()
 
    '计算所属地区
    sql="select (cast((6378137.0*ACOS(SIN("&ServiceAddress_lat&"/180*PI())*SIN(cast("&StartAddress_lat&" as decimal(15,10))/180*PI())+COS("&ServiceAddress_lat&"/180*PI())*COS(cast("&StartAddress_lat&" as decimal(15,10))/180*PI())*COS(("&ServiceAddress_lng&"-cast("&StartAddress_lng&" as decimal(15,10)))/180*PI()))) as decimal(15,0))),(cast((6378137.0*ACOS(SIN("&ServiceAddress_lat&"/180*PI())*SIN(cast("&EndAddress_lat&" as decimal(15,10))/180*PI())+COS("&ServiceAddress_lat&"/180*PI())*COS(cast("&EndAddress_lat&" as decimal(15,10))/180*PI())*COS(("&ServiceAddress_lng&"-cast("&EndAddress_lng&" as decimal(15,10)))/180*PI()))) as decimal(15,0)))"
    rs.open Sql,objConn,1,1
    StartDistance=clng(rs(0))
    EndDistance=clng(rs(1))
    rs.close()
    If StartDistance<EndDistance Then
        Region_lat=StartAddress_lat
        Region_lng=StartAddress_lng
    Else
        Region_lat=EndAddress_lat
        Region_lng=EndAddress_lng
    End If
 
            
 
    '路线规划距离(公里)
    TraDistance=0
    appUrl="http://api.map.baidu.com/direction/v2/driving"
    args1="origin="&StartAddress_lat&","&StartAddress_lng&"&destination="&EndAddress_lat&","&EndAddress_lng&"&ak=rGQBbHKGjAtVQy23OckafQkC6nNlaGmi"
    HTMLCODE= GetBody(appUrl,args1)
    json    = HTMLCODE
    str=json
    set obj = getjson(str)
    status        = obj.status
    If status=0 Then
        str=json
        str=right(str,len(str)-instr(str,"[")+1)
        str=left(str,InstrRev(str,"]"))
        set obj = getjson(str)
        for i=0 to obj.length-1
            TraDistance        = obj.get(i).distance            '行程距离(米)
        Next
    End If
    If TraDistance>1000 And IsNumeric(TraDistance) Then
        TraDistance=CInt(TraDistance/1000)
    ElseIf TraDistance>0 And IsNumeric(TraDistance) Then
        TraDistance=1
    End If
    
    
 
    '费用计算
    IRPrice=0
    If errcode=0 Then
        '距离报价
        OrderPrice=TraDistance*ServiceUnitPrice
        If OrderPrice<ServiceMinPrice Then OrderPrice=ServiceMinPrice
        
        '地区基础费用
        If TraDistance<ServiceLong Then
            appUrl="http://api.map.baidu.com/geocoder/v2/"
            args1="location="&Region_lat&","&Region_lng&"&output=json&latest_admin=1&ak=rGQBbHKGjAtVQy23OckafQkC6nNlaGmi"
            HTMLCODE= GetBody(appUrl,args1)
            json    = HTMLCODE
            str=json
            set obj = getjson(str)
            status        = obj.status
            If status=0 Then
                StartProvince    = obj.result.addressComponent.province
                StartCity    = obj.result.addressComponent.city
                StartArea    = obj.result.addressComponent.district
            End If
            If StartProvince<>"" And StartCity<>"" And StartArea<>"" And IRPrice=0 Then
                sql="select IRPrice from IntroducerRegion where IRState=1 and IRUnitID="&UnitID&" and (IRProvince='"&StartProvince&"' and IRCity='"&StartCity&"' and IRArea='"&StartArea&"')"
                rs.open sql,objConn,1,1
                If Not rs.eof Then
                    IRPrice=rs("IRPrice")
                End If
                rs.close()
            End If
            If StartProvince<>"" And StartCity<>"" And IRPrice=0 Then
                sql="select IRPrice from IntroducerRegion where IRState=1 and IRUnitID="&UnitID&" and (IRProvince='"&StartProvince&"' and IRCity='"&StartCity&"' and IRArea='')"
                rs.open sql,objConn,1,1
                If Not rs.eof Then
                    IRPrice=rs("IRPrice")
                End If
                rs.close()
            End If
            If StartProvince<>"" And IRPrice=0 Then
                sql="select IRPrice from IntroducerRegion where IRState=1 and IRUnitID="&UnitID&" and (IRProvince='"&StartProvince&"' and IRCity='' and IRArea='')"
                rs.open sql,objConn,1,1
                If Not rs.eof Then
                    IRPrice=rs("IRPrice")
                End If
                rs.close()
            End If
            If IRPrice=0 Then
                sql="select IRPrice from IntroducerRegion where IRState=1 and IRUnitID="&UnitID&" and (IRProvince='其它')"
                rs.open sql,objConn,1,1
                If Not rs.eof Then
                    IRPrice=rs("IRPrice")
                End If
                rs.close()
            End If
            OrderPrice=OrderPrice+IRPrice
            addressComponent=StartProvince
            If StartCity<>"" Then addressComponent=addressComponent&"-"&StartCity
            If StartArea<>"" Then addressComponent=addressComponent&"-"&StartArea
        Else
            addressComponent="长途"
        End If
    End If
    
    webJson="{""APPID"":"""&APPID&""",""method"":"""&method&""",""result"":1,""OrderPrice"":"""&OrderPrice&""",""TraDistance"":"""&TraDistance&""",""addressComponent"":"""&addressComponent&""",""StartAddress"":"""&StartAddress&""",""EndAddress"":"""&EndAddress&""",""origin"":"""&StartAddress_lat&","&StartAddress_lng&""",""destination"":"""&EndAddress_lat&","&EndAddress_lng&"""}"
    
Else
    errcode=40022
    errmsg="invalid Address"
End If
 
 
If Left(errcode,1)="4" Or webJson="" Then
    If errcode="" Then
        errcode=-1
        errmsg="error"
    End If
    webJson="{""APPID"":"""&APPID&""",""method"":"""&method&""",""result"":2,""errcode"":"&errcode&",""errmsg"":"""&errmsg&"""}"
    'Call OA_Running(UnitID,webJson)
Else
    OkJson="{""APPID"":"""&APPID&""",""method"":"""&method&""",""result"":1,""Running"":"""&sParaRunning&"""}"
    'Call OA_Running(UnitID,OkJson)
End If
 
Response.Write webJson
Response.End
%>