1、定义一个分店的统计函数TJ
dim FDName as string = args(0)
dim CMon as integer = asrgs(1)
Dim cmd As New SQLCommand
cmd.C onnection Name =
"数据源名称"
cmd.CommandText = "SEL ECT 销量表.分店号, 销量表.销售月份, Sum(销量表.数量) AS 销量合计 " & _
" FROM {销量表} where 分店名称 = '" & FDName & "' and 销售月份 = " & CMon " & _
" GROUP BY 销量表.分店号 ,销量表.销售月份 "
Dim dt As DataTable = cmd.ExecuteReader()
cmd.CommandText = "SEL ECT * from {目标中间表} where [_Identify] is null"
dim XX as datable = cmd.ExecuteReader(true)
dim f As New
Filler
f.SourceTable = dt
f.DataTable = XX
f.Fill() '填充数据
xx.save
2、 统计分店(N个分店)的销量
dim CM as integer = 202103
for each dr as datarow in datatables("分店名册").datarows
Functions.AsyncExecute("TJ",dr("分店名称"),CM)
‘如果一个个分店按顺序计算就是 functions.Execute("TJ",dr("分店名称"),CM),但考虑到分店多、数据量大的时候,可能效率比较低,所以才想着开多个线程去计算
next
是这么个用法?
只是借用这个例子来整个方法,实际的业务比这个复杂一些,每个月、每个店要统计的数据明细可能会达到百万行,然后统计的结果会在5万行左右
[此贴子已经被作者于2021/3/16 21:12:30编辑过]