Dim dic As new Dictionary(of String,Integer)
DataTables("生产计划下达_刀具明细").DataRows.Clear()
For Each dr1 As DataRow In DataTables("生产计划下达_生产排产分配表").DataRows
For Each dr2 As DataRow In DataTables("BOM基础数据").sqlSelect("[成品编码] = '" & dr1("成品编码") & "' And [加工工序] = '" & dr1("加工工序") & "' And [加工内容] = '" & dr1("加工内容") & "' and [使用设备] = '" & dr1("使用设备") & "' and 材料类型 = '刀具类' and 使用状态 = '使用中'")
Dim nm As String = dr1("生产批次") & "|" & dr2("使用设备") & "|" & dr2("加工工序") & "|" & dr2("刀柄型号") & "|" & dr2("加工内容") & "|" & dr2("材料编码") & "|" & dr2("材料描述") & "|" & dr1("毛坯产地") & "|" & dr1("成品编码") & "|" & dr1("成品描述")
Dim vl As Integer = dr2("用量")
output.show(dic.keys.count)
If dic.ContainsKey(nm) = False
dic.Add(nm,vl)
Else
dic(nm) = dic(nm) + 1
End If
Next
Next
For Each key As String In dic.keys
Dim dr As DataRow = DataTables("生产计划下达_刀具明细").AddNew()
Dim ary = key.split("|")
dr("使用设备") = ary(1)
dr("加工工序") = ary(2)
dr("刀柄型号") = ary(3)
dr("加工内容") = ary(4)
dr("生产批次") = ary(0)
dr("材料编码") = ary(5)
dr("材料描述") = ary(6)
dr("计划需求") = dic(key)
dr("毛坯产地") = ary(7)
dr("成品编码") = ary(8)
dr("成品描述") = ary(9)
Next