以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  统计效率的问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=185201)

--  作者:wsjawm
--  发布时间:2023/2/9 21:26:00
--  统计效率的问题
新建了一个数据表,然后用手工编码写了个统计代码,但是统计的效率好低,统计20行数据要用时10秒,但用foxtable自带的统计工具却可以秒开,不知道哪里出问题了,求解。
Dim dr As DataRow = Args(0)
Dim dt As DataTable = DataTables("生产过程进度追溯表")
dr("投料数量") = dt.SQLCompute("Sum(投料数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("入库数量") = dt.SQLCompute("Sum(入库数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("报废数量") = dt.SQLCompute("Sum(报废数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("粗车") = dt.SQLCompute("Sum(粗车完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("割圈") = dt.SQLCompute("Sum(割圈完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("镗孔") = dt.SQLCompute("Sum(镗孔完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("铰孔") = dt.SQLCompute("Sum(铰孔完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("半精车") = dt.SQLCompute("Sum(半精车完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("精车I") = dt.SQLCompute("Sum(精车I完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("精车II") = dt.SQLCompute("Sum(精车II完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("光刀") = dt.SQLCompute("Sum(光刀完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("滚道淬") = dt.SQLCompute("Sum(滚道淬火完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("车圆弧") = dt.SQLCompute("Sum(车圆弧完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("齿加工") = dt.SQLCompute("Sum(齿加工完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("齿倒角") = dt.SQLCompute("Sum(齿轮倒角完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("齿淬火") = dt.SQLCompute("Sum(齿轮淬火完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("整形") = dt.SQLCompute("Sum(整形完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("孔加工") = dt.SQLCompute("Sum(孔加工完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("打油眼") = dt.SQLCompute("Sum(打油眼完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("油眼攻丝") = dt.SQLCompute("Sum(油眼攻丝完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("打堵头眼") = dt.SQLCompute("Sum(打堵头眼完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("堵头攻丝") = dt.SQLCompute("Sum(堵头眼攻丝完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("车磨") = dt.SQLCompute("Sum(车磨完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("装配") = dt.SQLCompute("Sum(装配完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("清洗") = dt.SQLCompute("Sum(清洗完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("打标") = dt.SQLCompute("Sum(打标完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("打标牌") = dt.SQLCompute("Sum(打标牌完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("喷漆") = dt.SQLCompute("Sum(喷漆完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")
dr("包装") = dt.SQLCompute("Sum(包装完成数量)", "备用2 = \'" & dr("销售计划号") & "\'")

--  作者:有点蓝
--  发布时间:2023/2/9 22:00:00
--  
就应该使用统计工具呀:http://www.foxtable.com/webhelp/topics/1623.htm
Dim dr As DataRow = Args(0)
Dim g As New GroupTableBuilder("统计表1"DataTables("生产过程进度追溯表"))
g.FromServer = True
g.Groups.AddDef("
备用2")
g.Totals.AddDef("
投料数量")
g.Totals.AddDef("
入库数量")
……
g.filter = "备用2 = \'" & dr("销售计划号") & "\'"
dim dt as datatable = g.Build(true)
dim dr2 as datarow = dt.datarows(0)
dr("投料数量") = dr2("投料数量")
dr("入库数量") = dr2("入库数量")
……