我的数据表共有三个:1、一个是员工实时扫码表,清单条码编码,员工姓名和工序实时扫码基础数据,2、qqddb ,是客户产品信息数据表。3、实时工序表是计算表,这个表的数据都是来源于前两个表。重量和件数都是来源于ddqdb。员工姓名、用时、工序名称等都来源于扫码表,“清单条码编码”是三个表的共同标识。我的问题涉及了“实时计算表”的两个分劈计算,1、是实际耗时的计算。就是同一个人同时开工扫码多个清单条码,要根据开工时间和bs将工序耗时,按照重量、件数比例等进行工序耗时分劈成实际耗时。2、同一清单,同一工序的工作,只有一个重量和件数,如果多人做同一工序,或一个人多次扫同一个工序同一条码,要按照实际耗时比重再分劈每个工序的“数量和件数”。老师麻烦您给我解决上述两个计算的两个问题:1、是计算速度问题,2 是第一个计算有的实际耗时不计算,内容为空。
Dim Result As DialogResult
Result = MessageBox.Show("您是从头计算所有数据(y),还是接着上次计算(n)?","提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
DataTables("车间扫码表").LoadFilter = ""
DataTables("车间扫码表").Load
For Each dr As DataRow In DataTables("车间扫码表").DataRows
If dr("jsf") IsNot Nothing Then
dr("jsf") = Nothing
End If
Next
\' MessageBox.Show("从头算大约需要12分钟...")
\'如果从头计算还要清空表
DataTables("实时工序计算表").deletefor("")
DataTables("实时工序明细表").deletefor("")
End If
\'\'1、加载表
DataTables("车间扫码表").LoadFilter = ""
DataTables("车间扫码表").Load
Tables("ddqdb").Sort = "清单条码编码"
Dim fr As DataRow
fr = DataTables("车间扫码表").DataRows(0)
DataTables("ddqdb").LoadFilter = "[清单条码编码]>=\'" & fr("清单条码编码") & "\'"
DataTables("ddqdb").Load
DataTables("车间扫码表").LoadFilter = "[jsf] is null"
DataTables("车间扫码表").Load
\'2、将车间扫描表逐行镜像写入实时工序计算表
Dim Cols1() As String = {"日期", "清单条码编码", "ygdm", "员工姓名", "gxdm", "工序名称", "开工时间", "结束时间", "工序耗时", "jsbm1", "bs" }
Dim Cols2() As String = {"日期", "清单条码编码", "ygdm", "员工姓名", "gxdm", "工序名称", "开工时间", "结束时间", "工序耗时", "jsbm1", "bs" }
For Each dr1 As DataRow In DataTables("车间扫码表").DataRows
dr1("jsf") = "√"
Dim dr2 As DataRow = DataTables("实时工序计算表").AddNew()
For i As Integer = 0 To Cols1.Length - 1
dr2(Cols2(i)) = dr1(Cols1(i))
Next
Next
\'\'3、工序填入顺序号
For Each er As DataRow In DataTables("实时工序计算表").DataRows
Dim gm As String = er("gxdm")
Dim tm As String = er("清单条码编码")
Dim br As DataRow = DataTables("gxdmb").find("gxdm=\'" & gm & "\'")
If br IsNot Nothing Then
er("顺序号") = br("顺序号")
End If
Dim ur As DataRow = DataTables("ddqdb").find("清单条码编码=\'" & tm & "\'")
If ur IsNot Nothing Then
If ur("结算单位") = "重量" Then
er("重量") = ur("重量") \'填入重量
Else If ur("结算单位") = "数量" Then
er("件数") = ur("件每台") * ur("台数")
End If
End If
Next
\'\'以下是’bs\'数组
\'\'依据bs长度的计算实际耗时方法:长度l=18时,为一个人同时扫多个条码,这样工序耗时按重量劈开就是实际耗时。
Dim drs As List(Of DataRow)
Dim Nas As New List(Of String) \'bs长度18
Dim Nbs As New List(Of String) \'bs长度6
Dim Ncs As New List(Of String) \'bs长度12
Dim l As Integer
Dim Arys As List(Of String())
Arys = DataTables("实时工序计算表").GetValues("bs|开工时间")
For Each Ary As String() In Arys
Dim zzl As Double = DataTables("实时工序计算表").sqlCompute("sum(重量)", "bs=\'" & Ary(0) & "\'and 开工时间 = #" & Ary(1) & "#")
drs = DataTables("实时工序计算表").Select("[bs]=\'" & Ary(0) & "\'and 开工时间 = #" & Ary(1) & "#")
For Each dr As DataRow In drs
If dr IsNot Nothing Then
Dim gxhs As Double = dr("工序耗时")
Dim dzl As Double = dr("重量")
Dim sjhs As Double = Round2((dzl * gxhs / zzl), 2)
If sjhs <> 0 Then
MessageBox.Show(dzl & "/" & sjhs & "/" & dr("bs"))
dr("实际耗时") = Round2((dzl * gxhs / zzl), 2)
Else
MessageBox.Show(ary(1))
end if
End if
Next
Next
MainTable = Tables("实时工序计算表")
Forms("实时工序优速计算").close