Dim b As New GroupTableBuilder("统计表1",DataTables("JKH荒料"))
Dim dt1 As fxDataSource
'Dim b As New SQLGroupTableBuilder("统计表1","JKH荒料")
b.ConnectionName = "Foxtable-SQL"
b.Filter = "[中文品名] Is Not Null"
b.Groups.AddDef("中文品名") '根据产品分组
'b.Totals.AddDef("荒料编号",AggregateEnum.Count,"累计已发运_颗数")
b.Groups.AddDef("计价单位","已发运_累计_计价单位")
b.Totals.AddDef("码单体积","已发运_累计_码单体积(M3)")
b.Totals.AddDef("码单重量","已发运_累计_码单重(T)")
b.Totals.AddDef("采购货值外币","已发运_累计_采购货值(外币)")
b.Totals.AddDef("采购成本含税","已发运_累计_货物含税总成本(RMB)")
'b.Build
dt1 = b.BuildDataSource()
Dim b2 As New GroupTableBuilder("统计表2",DataTables("JKH荒料"))
Dim dt2 As fxDataSource
'Dim b2 As New SQLGroupTableBuilder("统计表2","JKH荒料")
b2.ConnectionName = "Foxtable-SQL"
b2.Filter = "[荒料状态] = '在途' And [中文品名] Is Not Null"
b2.Groups.AddDef("中文品名") '根据产品分组
'b2.Totals.AddDef("荒料编号",AggregateEnum.Count,"在途_颗数")
b2.Totals.AddDef("码单体积","已发运_在途_码单体积(M3)")
b2.Totals.AddDef("码单重量","已发运_在途_码单重(T)")
b2.Totals.AddDef("实时采购成本合计","已发运_在途_总成本(RMB)")
'b2.Build
dt2 = b2.BuildDataSource()
Dim b3 As New GroupTableBuilder("统计表2",DataTables("JKH荒料"))
Dim dt3 As fxDataSource
'Dim b2 As New SQLGroupTableBuilder("统计表2","JKH荒料")
b3.ConnectionName = "Foxtable-SQL"
b3.Filter = "[荒料状态] = '已到港未入库' And [中文品名] Is Not Null"
b3.Groups.AddDef("中文品名") '根据产品分组
'b3.Totals.AddDef("荒料编号",AggregateEnum.Count,"已到港未入库_颗数")
b3.Totals.AddDef("码单体积","已发运_已到港未入库_码单体积(M3)")
b3.Totals.AddDef("码单重量","已发运_已到港未入库_码单重(T)")
b3.Totals.AddDef("实时采购成本合计","已发运_已到港未入库_总成本(RMB)")
'b2.Build
dt3 = b3.BuildDataSource()
Dim b4 As New GroupTableBuilder("统计表3",DataTables("JKH荒料"))
Dim dt4 As fxDataSource
'Dim b4 As New SQLGroupTableBuilder("统计表3","JKH荒料")
b4.ConnectionName = "Foxtable-SQL"
b4.Filter = "[荒料状态] = '在库未出库' And [中文品名] Is Not Null"
b4.Groups.AddDef("中文品名") '根据产品分组
'b4.Totals.AddDef("荒料编号",AggregateEnum.Count,"荒料在库_颗数")
b4.Totals.AddDef("码单体积","已发运_荒料在库_码单体积(M3)")
b4.Totals.AddDef("码单重量","已发运_荒料在库_码单重(T)")
'b4.Totals.AddDef("平均采购单价含税",AggregateEnum.Average,"荒料在库_平均采购单价(以含税成本计)")
b4.Totals.AddDef("实时采购成本合计","已发运_荒料在库_总成本(RMB)")
'b4.Build
dt4 = b4.BuildDataSource()
Dim b5 As New GroupTableBuilder("统计表4",DataTables("JKH荒料"))
Dim dt5 As fxDataSource
b5.Filter = "[荒料状态] = '销售出库' And [中文品名] Is Not Null"
b5.Groups.AddDef("中文品名") '根据产品分组
'b5.Totals.AddDef("库存天数",AggregateEnum.Average,"荒料销售_库存平均周期(天数)")
'b5.Totals.AddDef("销售日期",AggregateEnum.Count,"荒料销售_颗数")
b5.Totals.AddDef("荒料销售数量",AggregateEnum.Sum,"已发运_荒料销售_荒料销售数量")
b5.Totals.AddDef("荒料销售单价",AggregateEnum.Average,"已发运_荒料销售_荒料平均单价")
b5.Totals.AddDef("荒料销售金额",AggregateEnum.Sum,"已发运_荒料销售_厦门公司销售金额(RMB)")
b5.Totals.AddDef("荒料销售毛利",AggregateEnum.Sum,"已发运_荒料销售_厦门公司销售毛利(RMB)")
b5.Totals.AddDef("荒料销售毛利率不扣息",AggregateEnum.Average,"已发运_荒料销售_厦门公司毛利率(不扣息)")
b5.Totals.AddDef("采购成本不含税",AggregateEnum.Sum,"已发运_荒料销售_合计成本不含税(RMB)")
b5.Totals.AddDef("最终客户销售金额",AggregateEnum.Sum,"已发运_荒料销售_最终合计销售额(RMB)")
b5.Totals.AddDef("合计荒料销售毛利",AggregateEnum.Sum,"已发运_荒料销售_最终合计毛利(RMB)")
'b5.Totals.AddDef("合计荒料销售毛利率",AggregateEnum.Average,"已发运_荒料销售_最终毛利率不扣息取均值")
dt5 = b5.BuildDataSource()
Dim b7 As New GroupTableBuilder("统计表7",DataTables("JKH排载清关"))
Dim dt7 As fxDataSource
'Dim b As New SQLGroupTableBuilder("统计表1","JKH荒料")
b7.Filter = "[启运日] Is Null And [中文品名] Is Not Null"
b7.Groups.AddDef("中文品名") '根据产品分组
b7.Groups.AddDef("币种","未发运_币种") '根据产品分组
b7.Totals.AddDef("实际发运FOB金额","未发运_货值(外币)")
b7.Totals.AddDef("实际发运体积","未发运_体积(M3)")
'b.Build
dt7 = b7.BuildDataSource()
Dim b8 As New GroupTableBuilder("统计表8",DataTables("JKH荒料"))
Dim dt8 As fxDataSource
b8.Filter = "[荒料状态] = '加工出库' And ([加工成品总面积] = 0 or [加工成品总面积] Is Null) And [中文品名] Is Not Null"
b8.Groups.AddDef("中文品名") '根据产品分组
'b6.Totals.AddDef("荒料编号",AggregateEnum.Count,"加工大板_颗数")
b8.Totals.AddDef("码单体积","已发运_大板未成品_码单体积(M3)")
b8.Totals.AddDef("码单重量","已发运_大板未成品_码单重(T)")
'b8.Totals.AddDef("已销售总面积","已发运_加工大板销售_大板销售面积")
b8.Totals.AddDef("实时采购成本合计","已发运_大板未成品_总成本(RMB)")
dt8 = b8.BuildDataSource()
Dim b9 As New GroupTableBuilder("统计表9",DataTables("加工大板"))
Dim dt9 As fxDataSource
b9.Filter = "([大板状态] = '未成品' And [中文品名] Is Not Null) or ([大板状态] = '在库未出库' And [中文品名] Is Not Null)"
b9.Groups.AddDef("中文品名") '根据产品分组
'b6.Totals.AddDef("荒料编号",AggregateEnum.Count,"加工大板_颗数")
b9.Totals.AddDef("面积","已发运_大板在库_大板在库面积")
b9.Totals.AddDef("每片采购加工成本不含税","已发运_大板在库_采购加工成本不含税(RMB)")
dt9 = b9.BuildDataSource()
Dim b10 As New GroupTableBuilder("统计表10",DataTables("JKH荒料"))
Dim dt10 As fxDataSource
b10.Filter = "[荒料状态] = '加工出库' And [中文品名] Is Not Null"
b10.Groups.AddDef("中文品名") '根据产品分组
'b6.Totals.AddDef("荒料编号",AggregateEnum.Count,"加工大板_颗数")
b10.Totals.AddDef("已销售总面积","已发运_加工大板销售_大板销售面积")
b10.Totals.AddDef("该荒料大板销售总金额","已发运_加工大板销售_已销售总额")
b10.Totals.AddDef("该荒料大板销售总毛利","已发运_加工大板销售_已销售毛利")
b10.Totals.AddDef("该荒料大板销售毛利率",AggregateEnum.Average,"已发运_加工大板销售_销售平均毛利率")
dt10 = b10.BuildDataSource()
dt7.Combine("中文品名",dt1,"中文品名")
dt7.Combine("中文品名",dt2,"中文品名")
dt7.Combine("中文品名",dt3,"中文品名")
dt7.Combine("中文品名",dt4,"中文品名")
dt7.Combine("中文品名",dt5,"中文品名")
dt7.Combine("中文品名",dt8,"中文品名")
dt7.Combine("中文品名",dt9,"中文品名")
dt7.Combine("中文品名",dt10,"中文品名")
Tables("报表-各品种经营情况_Table1").DataSource = dt7
With DataTables("报表-各品种经营情况_Table1").DataCols '用表达式列计算
.Add("已发运_荒料销售_最终毛利率",Gettype(Double),"1 - 1.17 * [已发运_荒料销售_合计成本不含税(RMB)] / [已发运_荒料销售_最终合计销售额(RMB)]")
End With
With Tables("报表-各品种经营情况_Table1")
'.Cols("已发运_荒料销售_最终毛利率不扣息取均").Visible = False
.Cols("已发运_荒料销售_最终毛利率").Move(26)
End With