Foxtable(狐表)用户栏目专家坐堂 → [求助]用丰桥开放平台的快递API接入方案怎么搞


  共有4927人关注过本帖树形打印复制链接

主题:[求助]用丰桥开放平台的快递API接入方案怎么搞

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/5/19 17:47:00 [显示全部帖子]


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/5/19 22:44:00 [显示全部帖子]

1、拷贝这个xml存放到你表C第一列去

 

<Request service = "OrderService" lang = "zh-CN" >
<Head>CS_IcziI</Head>
<Body>
  <Order
 orderid="SFKD-20160219000019"
 j_company="深圳宝龙达信息技术股份有限公司"
 j_c
 j_tel="15323233432"
 j_mobile="15322234342"
 j_province="广东省"
 j_city="深圳市"
 j_county="南山区"
 j_address="广东省深圳市南山区西丽镇塘朗同富裕工业城7栋"
 d_c d_tel="15023434543"
 d_mobile="15423456545"
 d_province="广东省"
 d_city="深圳市"
 d_county="南山区"
 d_address="科技园软件产业基地"
 express_type="1"
 pay_method="1"
 custid="7551234567"
 parcel_quantity="1"
 is_docall="0"
 sendstarttime=""
 order_source="宝龙达"
 remark="电子产品 笔记本+显卡"
        is_unified_waybill_no="1">
</Order>
</Body>
</Request>

 

2、执行下面代码测试

 

Dim hc As New HttpClient("http://bsp-oisp.sf-express.com/bsp-oisp/sfexpressService")
Dim xml As String = Tables("表C").Rows(1)("第一列")
Dim checkWord As String = "tgz8Lx54wfQkii9E3dWlIJ1v91zYbBUO"

Dim str As String = xml & checkWord
Dim md5 As new System.Security.Cryptography.MD5CryptoServiceProvider
Dim bs() As Byte = md5.ComputeHash(system.Text.Encoding.UTF8.GetBytes(str))
Dim verifyCode As String = Convert.ToBase64String(bs)
hc.FormData.Add("xml",xml)
hc.FormData.Add("verifyCode",verifyCode)

Dim ret As String = hc.getData()
msgbox(ret)


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/5/27 10:07:00 [显示全部帖子]

 

文件【 Newtonsoft.Json.dll】不需要引用,foxtable自身就自带了。

 

c#代码转换成vb.net,可以参考 http://converter.telerik.com/

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/5/27 16:37:00 [显示全部帖子]

全局代码,编写代码

 

Class TestCallWaybillPrinter

public Shared Sub WayBillPrinterTools()
Dim url7 As String = "http://localhost:4040/sf/waybill/print?type=V2.0.FM_poster_100mm150mm&output=noAlertPrint"
Dim url8 As String = "http://localhost:4040/sf/waybill/print?type=V2.0.FM_poster_100mm150mm&output=print"
Dim url9 As String = "http://localhost:4040/sf/waybill/print?type=V2.0.FM_poster_100mm150mm&output=image"
Dim url10 As String = "http://localhost:4040/sf/waybill/print?type=V3.0.FM_poster_100mm210mm&output=noAlertPrint"
Dim url11 As String = "http://localhost:4040/sf/waybill/print?type=V3.0.FM_poster_100mm210mm&output=print"
Dim url12 As String = "http://localhost:4040/sf/waybill/print?type=V3.0.FM_poster_100mm210mm&output=image"
Dim reqURL As String = url12
Dim jsonParam As String = AssemblyParameters(True)
Console.WriteLine("param :" & jsonParam)
Console.ReadKey(True)
Dim notTopLogo As Boolean = True

If reqURL.Contains("V2.0") AndAlso notTopLogo Then
    reqURL = reqURL.Replace("V2.0", "V2.1")
End If

If reqURL.Contains("V3.0") AndAlso notTopLogo Then
    reqURL = reqURL.Replace("V3.0", "V3.1")
End If

Dim result As String = postJson(reqURL, jsonParam)
Console.WriteLine("最终msg:" & result)
Console.ReadKey(True)

If result.Contains(""",""") Then
    Dim arr As String() = result.Split(""",""")
   
    For i As Integer = 0 To arr.Length - 1
        generateImage(arr(i).ToString(), "D:\qiaoWaybill201811102-" & i & ".jpg")
    Next
Else
    generateImage(result, "D:\qiaoWaybill201811102-1.jpg")
End If

Console.WriteLine("结束")
Console.ReadKey(True)
End Sub

Private Shared Function AssemblyParameters(ByVal isFengMi As Boolean) As String
Dim waybillDtoList As IList(Of WaybillDto) = New List(Of WaybillDto)()
Dim dto As WaybillDto = New WaybillDto()
dto.appId = "SLKJ2019"
dto.appKey = "FBIqMkZjzxbsZgo7jTpeq7PD8CVzLT4Q"
dto.mailNo = "755123457777"
dto.consignerProvince = "广东省"
dto.consignerCity = "深圳市"
dto.consignerCounty = "南山区"
dto.consignerAddress = "学府路软件产业基地2B12楼5200708号"
dto.consignerCompany = "神一样的科技"
dto.consignerMobile = "15893799999"
dto.consignerName = "风一样的旭哥"
dto.consignerShipperCode = "518052"
dto.consignerTel = "0755-33123456"
dto.deliverProvince = "浙江省"
dto.deliverCity = "杭州市"
dto.deliverCounty = "拱墅区"
dto.deliverCompany = "神罗科技集团有限公司"
dto.deliverAddress = "舟山东路708号古墩路北(玉泉花园旁)百花苑西区7-2-201室"
dto.deliverName = "艾丽斯"
dto.deliverMobile = "15881234567"
dto.deliverShipperCode = "310000"
dto.deliverTel = "0571-26508888"
dto.destCode = "755"
dto.zipCode = "571"
dto.expressType = 1
dto.codValue = "999.9"
dto.insureValue = "501"
dto.monthAccount = "7550385912"
dto.orderNo = ""
dto.payMethod = 1
dto.childRemark = "子单号备注"
dto.mainRemark = "这是主运单的备注"
dto.returnTrackingRemark = "迁回单备注"
dto.encryptCustName = True
dto.encryptMobile = True
Dim rlsInfoDtoList As System.Collections.ArrayList = New System.Collections.ArrayList
Dim rlsMain As RlsInfoDto = New RlsInfoDto()
rlsMain.abFlag = "A"
rlsMain.codingMapping = "F33"
rlsMain.codingMappingOut = "1A"
rlsMain.destRouteLabel = "755WE-571A3"
rlsMain.destTeamCode = "012345678"
rlsMain.printIcon = "11110000"
rlsMain.proCode = "T4"
rlsMain.qrcode = "MMM={'k1':'755WE','k2':'021WT','k3':'','k4':'T4','k5':'755123456789','k6':''}"
rlsMain.sourceTransferCode = "021WTF"
rlsMain.waybillNo = "755123456789"
rlsMain.xbFlag = "XB"
rlsInfoDtoList.Add(rlsMain)

If dto.returnTrackingNo IsNot Nothing Then
    Dim rlsBack As RlsInfoDto = New RlsInfoDto()
    rlsBack.waybillNo = dto.returnTrackingNo
    rlsBack.destRouteLabel = "021WTF"
    rlsBack.printIcon = "11110000"
    rlsBack.proCode = "T4"
    rlsBack.abFlag = "A"
    rlsBack.xbFlag = "XB"
    rlsBack.codingMapping = "1A"
    rlsBack.codingMappingOut = "F33"
    rlsBack.destTeamCode = "87654321"
    rlsBack.sourceTransferCode = "755WE-571A3"
    rlsBack.qrcode = "MMM={'k1':'21WT','k2':'755WE','k3':'','k4':'T4','k5':'443123456789','k6':''}"
    rlsInfoDtoList.Add(rlsBack)
End If

Dim cargo As CargoInfoDto = New CargoInfoDto()
cargo.cargo = "苹果7S"
cargo.cargoCount = 2
cargo.cargoUnit = "件"
cargo.sku = "00015645"
cargo.remark = "手机贵重物品 小心轻放"
Dim cargo2 As CargoInfoDto = New CargoInfoDto()
cargo2.cargo = "苹果macbook pro"
cargo2.cargoCount = 10
cargo2.cargoUnit = "件"
cargo2.sku = "00015646"
cargo2.remark = "笔记本贵重物品 小心轻放"
Dim cargoInfoList As System.Collections.ArrayList = New System.Collections.ArrayList
cargoInfoList.Add(cargo2)
cargoInfoList.Add(cargo)
dto.cargoInfoDtoList = cargoInfoList
dto.rlsInfoDtoList = rlsInfoDtoList

If isFengMi Then
    dto.rlsInfoDtoList = rlsInfoDtoList
End If

waybillDtoList.Add(dto)
Return Newtonsoft.Json.JsonConvert.SerializeObject(waybillDtoList)
End Function

Private Shared Function postJson(ByVal reqURL As String, ByVal jsonParm As String) As String
Dim httpResult As String = ""

Try
    Dim req As System.Net.HttpWebRequest = CType(System.Net.WebRequest.Create(reqURL), System.Net.HttpWebRequest)
    req.ContentType = "application/json;charset=utf-8"
    req.Method = "POST"
    req.Timeout = 20000
    Dim bs As Byte() = System.Text.Encoding.UTF8.GetBytes(jsonParm)
   
    Using reqStream As io.Stream = req.GetRequestStream()
    reqStream.Write(bs, 0, bs.Length)
End Using

Using response As System.Net.HttpWebResponse = CType(req.GetResponse(), System.Net.HttpWebResponse)

Using sr As io.StreamReader = New io.StreamReader(response.GetResponseStream(), Encoding.[Default])
httpResult = sr.ReadToEnd().ToString()
End Using
End Using

If httpResult.Contains("[") Then
    httpResult = httpResult.Substring(httpResult.IndexOf("[") + 1, httpResult.IndexOf("]") - httpResult.IndexOf("[") - 1)
End If

If httpResult.StartsWith("""") Then
    httpResult = httpResult.Substring(1, httpResult.Length - 1)
End If

If httpResult.EndsWith("""") Then
    httpResult = httpResult.Substring(0, httpResult.Length - 1)
End If

httpResult = httpResult.Replace("\n", "")
Catch ex As Exception
    Return ex.Message
End Try

Return httpResult
End Function

Public Shared Function generateImage(ByVal imgStr As String, ByVal imgFilePath As String) As Boolean
If imgStr Is Nothing Then Return False

Try
    Dim bytes As Byte() = Convert.FromBase64String(imgStr)
    Dim x As Integer = 256
    Dim a As Byte = CByte(x)
   
    For i As Integer = 0 To bytes.Length - 1
       
        If bytes(i) < 0 Then
            bytes(i) += a
        End If
    Next
   
    Using fs As io.FileStream = New io.FileStream(imgFilePath, io.FileMode.OpenOrCreate, io.FileAccess.Write)
    fs.Write(bytes, 0, bytes.Length)
    fs.Close()
End Using

Catch e As Exception
    Return False
End Try

Return True
End Function
End Class

Class CargoInfoDto
Public cargo As String
Public parcelQuantity As Integer
Public cargoCount As Integer
Public cargoUnit As String
Public cargoWeight As Double
Public cargoAmount As Double
Public cargoTotalWeight As Double
Public remark As String
Public sku As String
End Class

Class RlsInfoDto
Public abFlag As String
Public codingMapping As String
Public codingMappingOut As String
Public destRouteLabel As String
Public destTeamCode As String
Public printIcon As String
Public proCode As String
Public qrcode As String
Public sourceTransferCode As String
Public waybillNo As String
Public xbFlag As String
End Class

Class WaybillDto
Public mailNo As String
Public expressType As Integer
Public payMethod As Integer
Public returnTrackingNo As String
Public monthAccount As String
Public orderNo As String
Public zipCode As String
Public destCode As String
Public payArea As String
Public deliverCompany As String
Public deliverName As String
Public deliverMobile As String
Public deliverTel As String
Public deliverProvince As String
Public deliverCity As String
Public deliverCounty As String
Public deliverAddress As String
Public deliverShipperCode As String
Public consignerCompany As String
Public consignerName As String
Public consignerMobile As String
Public consignerTel As String
Public consignerProvince As String
Public consignerCity As String
Public consignerCounty As String
Public consignerAddress As String
Public consignerShipperCode As String
Public logo As String
Public sftelLogo As String
Public topLogo As String
Public topsftelLogo As String
Public appId As String
Public appKey As String
Public electric As String
Public cargoInfoDtoList As System.Collections.ArrayList
Public rlsInfoDtoList As System.Collections.ArrayList
Public insureValue As String
Public codValue As String
Public codMonthAccount As String
Public mainRemark As String
Public returnTrackingRemark As String
Public childRemark As String
Public custLogo As String
Public insureFee As String
Public encryptCustName As Boolean
Public encryptMobile As Boolean
End Class

 

调用代码

 

TestCallWaybillPrinter.WayBillPrinterTools

[此贴子已经被作者于2019/5/27 16:41:16编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/5/27 17:39:00 [显示全部帖子]

 

Console.WriteLine("param :" & jsonParam)
Console.ReadKey(True)

 

改成

 

msgbox(jsonParam)

 

-----------其余的,类似 Console 的,都改成msgbox

 

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/5/27 18:18:00 [显示全部帖子]

以下是引用km007在2019/5/27 17:52:00的发言:
甜版,现在改了后,仅是弹窗显示,但是输出打印呢?

 

不是生成对应的文件了吗?认认真真看懂代码。看懂帮助文件。

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/6/3 8:39:00 [显示全部帖子]

把模板保存在表格里,或者txt文件里,然后读取进来,如

 

<Order 
orderid=[orderid]
j_company=[j_company]


 

得到模板以后,替换值,如

 

str = str.Replace("[orderid]", "123").replace("[j_company]", "abc")

[此贴子已经被作者于2019/6/3 8:39:10编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/6/3 11:24:00 [显示全部帖子]

比如

 

<Request service = "OrderService" lang = "zh-CN" >
<Head>CS_IcziI</Head>
<Body>
  <Order
 orderid="SFKD-20160219000019"
 j_company="深圳宝龙达信息技术股份有限公司"
 j_c
 j_tel="15323233432"
 j_mobile="15322234342"
 j_province="广东省"
 j_city="深圳市"
 j_county="南山区"
 j_address="广东省深圳市南山区西丽镇塘朗同富裕工业城7栋"
 d_c d_tel="15023434543"
 d_mobile="15423456545"
 d_province="广东省"
 d_city="深圳市"
 d_county="南山区"
 d_address="科技园软件产业基地"
 express_type="1"
 pay_method="1"
 custid="7551234567"
 parcel_quantity="1"
 is_docall="0"
 sendstarttime=""
 order_source="宝龙达"
 remark="电子产品 笔记本+显卡"
        is_unified_waybill_no="1">

 

<AddedService name="COD"></AddedService>

<Cargo name='手机'></Cargo>    


</Order>

</Body>
</Request>


 回到顶部