StatusBar.Message1= "正在从服务器下载数据请稍后:"
StatusBar.ProgressBar.Visible =True
Dim st As New Date(1970,1,1,8,0,0)
Dim t1 As Integer = CInt((Date.Today.AddDays(-30) - st).TotalSeconds()) '时间戳
Dim t2 As Integer = CInt((Date.Now - st).TotalSeconds()) '时间戳
Dim ur As String = "https://qyapi.weixin.qq.com/cgi-bin/corp/getapprovaldata?access_token={0}"
Dim hc As new HttpClient(Cexp(ur,Functions.Execute("GetQYAccessToken2")))
Dim jo As New JObject
jo("starttime") = t1 '' "1492617600"
jo("endtime") = t2 ''"1539392688"
hc.Content = jo.Tostring()
jo = JObject.Parse(hc.GetData)
Dim json As String = jo("data").ToString()
Dim ja As JArray = Jarray.Parse(json)
StatusBar.ProgressBar.Maximum = ja.Count + 30
StatusBar.ProgressBar.Minimum = 30
Dim bhs As String = "'',"
For i As Integer = 0 To ja.Count - 1
bhs &= "'" & ja(i)("sp_num").ToString() & "',"
Next
Dim fdr = DataTables("报价申请").SQLFind("审批编号 in (" & bhs.trim(",") & ")")
If fdr Is Nothing Then
msgbox("全部编号都有了")
End If
For i As Integer = 0 To ja.Count - 1
StatusBar.ProgressBar.value += 1
Dim dr As DataRow
dr = DataTables("报价申请").SQLFind("审批编号= '" & ja(i)("sp_num").ToString() & "'")
If dr Is Nothing Then
If ja(i)("spname").ToString() ="木作报价申请" Then
Dim r As Row =Tables("报价申请").AddNew()
r("单据类型") =ja(i)("spname").ToString()
r("审批状态") = ja(i)("sp_status").ToString()
r("审批人") = ja(i)("approval_name").ToString().Replace("""","").Replace("[","").Replace("]","")
r("抄送人") = ja(i)("notify_name").ToString().Replace("""","").Replace("[","").Replace("]","")
r("审批编号") = ja(i)("sp_num").ToString()
r("申请部门") = ja(i)("apply_org").ToString() '申请部门
r("申请人") = ja(i)("apply_name").ToString() '申请人
'r("单元房号") = ja(i)("单元房号").ToString()
'r("客户电话") = ja(i)("客户电话").ToString()
' r("sh") = 1
Dim d = st.AddSeconds(ja(i)("apply_time").ToString())
r("申请时间") = d '''''ja(i)("apply_time").ToString() 时间戳 申请时间
Dim jsona As String = ja(i)("comm")("apply_data").ToString()
Dim joa As JObject = JObject.Parse(jsona)
For Each it As object In joa
If it.value("value") IsNot Nothing Then
'r(it.value("title").ToString()) = CompressJSon(it.value("value")).Trim("[","]").Replace("""","")
'MessageBox.Show(CompressJSon(it.value("value")).Trim("[","]").Replace("""",""))
If it.value("title").ToString() = "客户名称" Then
r("客户名称") = CompressJSon(it.value("value")).Trim("[","]").Replace("""","")
ElseIf it.value("title").ToString() ="客户电话" Then
r("客户电话") = CompressJSon(it.value("value")).Trim("[","]").Replace("""","")
ElseIf it.value("title").ToString() ="楼盘" Then
r("楼盘") = CompressJSon(it.value("value")).Trim("[","]").Replace("""","")
ElseIf it.value("title").ToString() ="单元房号" Then
r("单元房号") = CompressJSon(it.value("value")).Trim("[","]").Replace("""","")
ElseIf it.value("title").ToString() ="推荐系列" Then
r("推荐系列") = CompressJSon(it.value("value")).Trim("[","]").Replace("""","")
ElseIf it.value("title").ToString() ="预算金额" Then
r("预算价格") = CompressJSon(it.value("value")).Trim("[","]").Replace("""","")
ElseIf it.value("title").ToString() ="漆面要求" Then
r("漆面要求") = CompressJSon(it.value("value")).Trim("[","]").Replace("""","")
ElseIf it.value("title").ToString() ="基材要求" Then
r("基材要求") = CompressJSon(it.value("value")).Trim("[","]").Replace("""","")
ElseIf it.value("title").ToString() ="已收资料" Then
r("已收资料") = CompressJSon(it.value("value")).Trim("[","]").Replace("""","")
ElseIf it.value("title").ToString() ="客户来源" Then
r("客户来源") = CompressJSon(it.value("value")).Trim("[","]").Replace("""","")
ElseIf it.value("title").ToString() ="计划时间" Then
r("计划时间") = CompressJSon(it.value("value")).Trim("[","]").Replace("""","")
'ElseIf it.value("title").ToString() ="基材要求" Then
'r("基材要求") = CompressJSon(it.value("value")).Trim("[","]").Replace("""","")
'ElseIf it.value("title").ToString() ="计划时间" Then
'If CompressJSon(it.value("value")).Trim("[","]").Replace("""","") IsNot Nothing Then
'r("计划时间") = Format(st.AddSeconds( CompressJSon(it.value("value")).Trim("[","]").Replace("""","")/1000 ),"yyyyMMddhhmmss")
'End If
' ElseIf it.value("title").ToString() ="出车用途" Then
' r("ccyt") = CompressJSon(it.value("value")).Trim("[","]").Replace("""","")
' ElseIf it.value("title").ToString() ="接送方式" Then
' r("jsfs") = CompressJSon(it.value("value")).Trim("[","]").Replace("""","")
End If
Application.DoEvents
End If
Next
'''
r.save
End If
End If
Next
StatusBar.Reset()