Foxtable(狐表)用户栏目专家坐堂 → [求助] BOM延长展开


  共有3476人关注过本帖树形打印复制链接

主题:[求助] BOM延长展开

帅哥哟,离线,有人找我吗?
sanny
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:799 积分:5921 威望:0 精华:0 注册:2018/11/3 8:24:00
[求助] BOM延长展开  发帖心情 Post By:2019/7/12 22:52:00 [显示全部帖子]

 

[此贴子已经被作者于2019/10/7 10:54:08编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
sanny
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:799 积分:5921 威望:0 精华:0 注册:2018/11/3 8:24:00
  发帖心情 Post By:2019/7/12 22:54:00 [显示全部帖子]

需得到demandafterstock 列的值,根据列MssingQty的数量

 回到顶部
帅哥哟,离线,有人找我吗?
sanny
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:799 积分:5921 威望:0 精华:0 注册:2018/11/3 8:24:00
  发帖心情 Post By: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


 回到顶部
帅哥哟,离线,有人找我吗?
sanny
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:799 积分:5921 威望:0 精华:0 注册:2018/11/3 8:24:00
  发帖心情 Post By:2019/7/13 9:57:00 [显示全部帖子]

 

[此贴子已经被作者于2019/10/7 10:54:24编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
sanny
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:799 积分:5921 威望:0 精华:0 注册:2018/11/3 8:24:00
  发帖心情 Post By: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


 回到顶部
帅哥哟,离线,有人找我吗?
sanny
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:799 积分:5921 威望:0 精华:0 注册:2018/11/3 8:24:00
  发帖心情 Post By:2019/7/13 12:35:00 [显示全部帖子]

 

[此贴子已经被作者于2019/10/7 10:54:43编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
sanny
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:799 积分:5921 威望:0 精华:0 注册:2018/11/3 8:24:00
  发帖心情 Post By:2019/7/13 15:51:00 [显示全部帖子]

 

[此贴子已经被作者于2019/10/7 10:55:01编辑过]

 回到顶部