以文本方式查看主题
- Foxtable(狐表) (http://foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2)
---- [求助] BOM延长展开 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=137700)
|
-- 作者:sanny
-- 发布时间:2019/7/12 22:52:00
-- [求助] BOM延长展开
[此贴子已经被作者于2019/10/7 10:54:08编辑过]
|
-- 作者:sanny
-- 发布时间:2019/7/12 22:54:00
--
需得到demandafterstock 列的值,根据列MssingQty的数量
|
-- 作者:有点蓝
-- 发布时间:2019/7/13 8:46:00
--
我对BOM管理这块业务不熟。不如直接使用文字描述一下过程,比如第一行,数据从哪取,每个列的数据是怎么计算的,把每个步骤和计算公式列出来。同样第二行的数据从哪里取,stock、qc、missing qty......等等列是怎么计算的,一直到第九行,每一行的计算步骤用文字描述一下
|
-- 作者:sanny
-- 发布时间:2019/7/13 9:28:00
--
蓝老师,列stock 和Qc的值已经取出来了,如下程序。现在是要取列 demandafterstock 的值,这个值取自列 MissingQty * BOM用量。谢谢。
内函数
Dim pn As String = args(0) Dim qty As String = args(1) Dim idx As Integer = args(5)
Dim dic1 = vars("dic1") Dim dic2 = vars("dic2")
For Each dr As DataRow In DataTables("BOM").Select("FNumber=\'" & pn & "\'") Dim ndr As DataRow = DataTables("物料需求").AddNew ndr("PartNo") = dr("PN") ndr("Date") = args(3) ndr("批号") = args(4) ndr("OrderDemand") = dr("FQty") * qty ndr("层次") = "第" & idx & "层"
Dim flag = args(5) If args.length < 6 OrElse args(5) = True Then Dim aa As Integer If args.length = 7 Then aa = args(6) * dr("FQty") End If If dic1.ContainsKey(ndr("PartNo")) Then If dic1(ndr("PartNo")) >= ndr("OrderDemand")-aa Then ndr("Stock") = ndr("OrderDemand")-aa dic1(ndr("PartNo")) -= ndr("Stock") flag = False ElseIf dic1(ndr("PartNo")) > 0 Then ndr("Stock") = dic1(ndr("PartNo")) dic1(ndr("PartNo")) -= ndr("Stock") End If
If flag = True Then If dic2.ContainsKey(ndr("PartNo")) Then Dim qty1 = ndr("OrderDemand") - ndr("stock") If qty1 > 0 Then If dic2(ndr("PartNo")) >= qty1 Then ndr("QC") = qty1 dic2(ndr("PartNo")) -= ndr("QC") ElseIf dic2(ndr("PartNo")) > 0 Then ndr("QC") = dic2(ndr("PartNo")) dic2(ndr("PartNo")) -= ndr("QC") End If End If End If End If
End If End If
Functions.Execute("sumChild",dr("PN"),ndr("OrderDemand"), args(2), args(3), args(4),idx+1) Next
按钮:
DataTables("物料需求").datarows.clear
Dim dic1 As new Dictionary(of String, Double) For Each dr As DataRow In DataTables("库存表").Select("part is not null") dic1.add(dr("part"), dr("qty")) Next vars("dic1") = dic1
Dim dic2 As new Dictionary(of String, Double) For Each dr As DataRow In DataTables("待检产品").Select("part is not null") dic2.add(dr("part"), dr("qty")) Next vars("dic2") = dic2
For Each Ary As String() In DataTables("OrderList").GetValues("PartNo|ETD|批号","PartNo is not null") Dim dr As DataRow = DataTables("物料需求").AddNew dr("PartNo") = ary(0) If ary(1) > "" dr("Date") = cdate(ary(1)) End If dr("批号") = ary(2) Dim qty As Integer = DataTables("OrderList").Compute("sum(Qty)","PartNo=\'" & ary(0) & "\' And " & IIf(ary(1) > "","ETD=\'" & ary(1) & "\'","ETD is null") & " and 批号 =\'" & ary(2) & "\'") dr("OrderDemand") = qty
Dim drr As DataRow = DataTables("BOM").find("Fnumber =" &"\'"& dr("PartNo")&"\'") If drr IsNot Nothing dr("层次") = "父层" Else dr("层次") = "单件出货" End If
Dim flag As Boolean = True If dic1.ContainsKey(dr("PartNo")) Then If dic1(dr("PartNo")) >= qty Then dr("Stock") = qty dic1(dr("PartNo")) -= dr("Stock") flag = False ElseIf dic1(dr("PartNo")) > 0 Then dr("Stock") = dic1(dr("PartNo")) dic1(dr("PartNo")) -= dr("Stock") End If End If
If dic2.ContainsKey(dr("PartNo")) Then If dic2(dr("PartNo")) >= qty Then dr("QC") = qty dic2(dr("PartNo")) -= dr("QC") ElseIf dic2(dr("PartNo")) > 0 Then dr("QC") = dic2(dr("PartNo")) dic2(dr("PartNo")) -= dr("QC") End If End If dr("MissingQty") = dr("Stock")+dr("QC") -dr("OrderDemand") Functions.Execute("sumChild",ary(0),qty, ary(0), dr("Date"),ary(2),1) Next
|
-- 作者:有点蓝
-- 发布时间:2019/7/13 9:37:00
--
MissingQty值从哪里来?BOM用量又是怎么计算的?
|
-- 作者:sanny
-- 发布时间:2019/7/13 9:57:00
--
[此贴子已经被作者于2019/10/7 10:54:24编辑过]
|
-- 作者:有点蓝
-- 发布时间:2019/7/13 10:15:00
--
用文字描述一下BOM中的用量应该怎么计算。如果要递归取所有子层用量的和,这个应该之前给您写过这种递归用法
|
-- 作者:sanny
-- 发布时间:2019/7/13 10:43:00
--
蓝老师, 这是bom展开的代码,如何根据MisssingQty来展开,可以帮忙修改一下吗? 感谢了。
Dim pn As String = args(0) |
Dim qty As String = args(1) |
For Each dr As DataRow In DataTables("BOM").Select("FNumber=\'" & pn & "\'") |
Dim ndr As DataRow = DataTables("物料需求").AddNew |
ndr("PartNo") = dr("PN") |
ndr("Date") = args(3) |
ndr("批号") = args(4) |
ndr("Demand") = dr("FQty") * qty |
Functions.Execute("sumChild",dr("PN"),ndr("Demand"), args(2), args(3), args(4)) |
|
Next |
|
|
DataTables("物料需求").datarows.clear |
For Each Ary As String() In DataTables("OrderList").GetValues("PartNo|ETD|批号","PartNo is not null") |
Dim dr As DataRow = DataTables("物料需求").AddNew |
dr("PartNo") = ary(0) |
dr("Date") = ary(1) |
dr("批号") = ary(2) |
Dim qty As Integer = DataTables("OrderList").Compute("sum(Qty)","PartNo=\'" & ary(0) & "\' And ETD=\'" & ary(1) & "\' and 批号 =\'" & ary(2) & "\'") |
dr("Demand") = qty |
|
|
Functions.Execute("sumChild",ary(0),qty, ary(0), ary(1),ary(2)) |
|
Next |
|
-- 作者:有点蓝
-- 发布时间:2019/7/13 10:54:00
--
我不懂您的业务呀。都搞不清楚MisssingQty和子层是什么关系。
方便使用文字描述一下整个逻辑步骤
|
-- 作者:sanny
-- 发布时间:2019/7/13 12:35:00
--
[此贴子已经被作者于2019/10/7 10:54:43编辑过]
|