以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 组装共通品合并加工 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=103081) |
-- 作者:zhangning -- 发布时间:2017/6/30 11:07:00 -- 组装共通品合并加工 老师,您好! 在表《加工用制品构成》中有各个组装品的构成,如图: 在《月度加工整体安排》中会对组装品作出安排计划安排,如在7月要生产明峰长床3台,短床2台, 调度安排是2台长床和1台短床 一个批次,调度号是1707排3,1台长床和1台短床1个批次,调度号是1707排4, 在《加工排产》表中,如下图: 输入组装品名和制单号(一个调度号对应一个制单号),按下“导入加工品”按钮后,会将在《加工用制品构成》里 所要用到的单品导入进来, 现在出现了一个问题,如出现有共通品的情况,共通品需要合并加工: 例如:在1707排3调度号中,我先导入了长床的构成,后又导入了短床的构成, 接下来希望将粗体字中的共通品进行合并,代码需要写在“合并共通品”命令里, 希望达到的效果是: 在同一个”调度“号中,①只留下最先出现的“部品ID",后出现的删掉行, ②”最终良品数“加在一起 请老师帮帮忙,谢谢! |
-- 作者:有点甜 -- 发布时间:2017/6/30 11:19:00 -- 剔除重复值,参考
Dim idx As String = "-1," If count > 1 Then Tables("表A").filter = "_Identify not in (" & idx.trim(",") & ")" \'DataTables("表A").deletefor("_Identify not in (" & idx.trim(",") & ")")
|
-- 作者:有点甜 -- 发布时间:2017/6/30 11:21:00 -- 看懂2楼代码,如果要合计良品数,微调代码即可。
具体问题,做个小例子上来测试。 |
-- 作者:zhangning -- 发布时间:2017/6/30 13:01:00 -- 谢谢老师,因水平有限,看不懂2楼代码,还需好好学学, 能否麻烦老师帮改改,谢谢!
|
-- 作者:zhangning -- 发布时间:2017/6/30 13:01:00 -- 开发者 qdkf |
-- 作者:有点甜 -- 发布时间:2017/6/30 14:55:00 -- 类似代码
Dim idx As String = "-1," If count > 1 Then count = 0 If count > 1 Then Tables("加工排产").filter = "_Identify not in (" & idx.trim(",") & ")" |
-- 作者:zhangning -- 发布时间:2017/7/3 9:32:00 -- 老师,如要先判断一下“调度”内容是否一致, 内容一致,再找出重复的,合并,最后删除, 请问老师,粗体的判断代码怎么写呢? |
-- 作者:有点甜 -- 发布时间:2017/7/3 9:48:00 -- Dim t As Table = Tables("加工排产") Dim dic As new Dictionary(of String, String) For i As Integer = 0 To t.Rows.count - 1 Step 2 Dim r1 As Row = t.Rows(i) Dim r2 As Row = t.Rows(i+1) Dim key As String = r1("部品id") & "|" & r1("调度") If dic.ContainsKey(key) = False Then dic.Add(key, r1("_Identify") & "," & r2("_Identify")) End If Next Dim idxs As String = "" For Each key As String In dic.Keys idxs &= dic(key) & "," Next \'msgbox(idxs) t.filter = "_Identify in (" & idxs.trim(",") & ")" [此贴子已经被作者于2017/7/3 9:48:30编辑过]
|
-- 作者:zhangning -- 发布时间:2017/7/3 13:46:00 -- 如果要合计良品数,微调代码即可 粗体不会,不知道怎么调,能不能麻烦老师帮写写,麻烦老师了!
|
-- 作者:有点甜 -- 发布时间:2017/7/3 14:08:00 -- Dim t As Table = Tables("加工排产") Dim dic As new Dictionary(of String, String) For i As Integer = 0 To t.Rows.count - 1 Step 2 Dim r1 As Row = t.Rows(i) Dim r2 As Row = t.Rows(i+1) Dim key As String = r1("部品id") & "|" & r1("调度") If dic.ContainsKey(key) = False Then dic.Add(key, r1("_Identify") & "," & r2("_Identify")) r1("良品数") = t.compute("sum(良品数)", "部品id = \'" & r1("部品id") & "\' and 调度 = \'" & r1("调度") & "\'") End If Next Dim idxs As String = "" For Each key As String In dic.Keys idxs &= dic(key) & "," Next \'msgbox(idxs) t.filter = "_Identify in (" & idxs.trim(",") & ")" |