ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 387|回复: 12

生产管理排产

[复制链接]

TA的精华主题

TA的得分主题

发表于 2024-10-11 18:10 | 显示全部楼层 |阅读模式
本人小白一枚,请老师帮我解决一下各个分表的起始日期和结束日期的逻辑计算,谢谢


补充内容 (2024-11-19 12:27):
最新的附件详见12楼,请好心的老师帮我完善一下吧

项目占位计划B版.zip

59.83 KB, 下载次数: 28

TA的精华主题

TA的得分主题

 楼主| 发表于 2024-10-12 08:29 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
自己顶一下

TA的精华主题

TA的得分主题

 楼主| 发表于 2024-10-13 15:28 | 显示全部楼层

TA的精华主题

TA的得分主题

 楼主| 发表于 2024-10-14 12:25 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
顶4

TA的精华主题

TA的得分主题

 楼主| 发表于 2024-10-21 13:07 | 显示全部楼层
完蛋啦,这是没人会做了鸭,还是我没有描述清楚哦

TA的精华主题

TA的得分主题

发表于 2024-10-24 14:51 | 显示全部楼层
我觉得你没表达清楚. 另外, 我觉得做排产不要管理工序, 只要管理工数, 安排工序的事情交给班长去做. 看看我做的周计划排程: https://club.excelhome.net/thread-1644060-1-1.html

TA的精华主题

TA的得分主题

 楼主| 发表于 2024-10-24 14:59 | 显示全部楼层

  1. Sub ProductionSchedulingRevised()
  2. '项目占位计划B版2024-10-22-3,虽然能进行排产,我不知道怎么写设备占位的代码。请哪位老师帮忙添加一下吧,谢谢了
  3. 但没有把设备占位考虑进来,未达到我的使用要求。
  4. Dim lastRow As Long
  5. Dim ws As Worksheet
  6. Set ws = ThisWorkbook.Sheets("排产清单")
  7. lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
  8. Dim orderNumbers As Object
  9. Set orderNumbers = CreateObject("Scripting.Dictionary")
  10. Dim i As Long
  11. For i = 2 To lastRow
  12. Dim orderNumber As String
  13. orderNumber = ws.Cells(i, 1).Value
  14. If Not orderNumbers.Exists(orderNumber) Then
  15. orderNumbers.Add orderNumber, i
  16. End If
  17. Next i
  18. Dim currentDate As Date
  19. currentDate = Date
  20. Dim equipmentUsage As Object
  21. Set equipmentUsage = CreateObject("Scripting.Dictionary")
  22. Dim processedRows As Object
  23. Set processedRows = CreateObject("Scripting.Dictionary")
  24. For Each orderKey In orderNumbers.Keys
  25. Dim firstProcessRow As Long
  26. firstProcessRow = orderNumbers(orderKey)
  27. If Not processedRows.Exists(firstProcessRow) Then
  28. ws.Cells(firstProcessRow, 10).Value = currentDate
  29. Dim duration As Long
  30. duration = ws.Cells(firstProcessRow, 11).Value
  31. ws.Cells(firstProcessRow, 12).Value = currentDate + duration
  32. processedRows.Add firstProcessRow, True
  33. End If
  34. Dim currentRow As Long
  35. currentRow = firstProcessRow
  36. Do While True
  37. Dim nextProcessRow As Long
  38. nextProcessRow = FindNextProcessRow(ws, currentRow)
  39. If nextProcessRow = 0 Then Exit Do
  40. Dim equipment As String
  41. equipment = ws.Cells(nextProcessRow, 9).Value
  42. If IsEquipmentAvailableForPriorityRevised(ws, equipment, ws.Cells(nextProcessRow, 10).Value, ws.Cells(nextProcessRow, 13).Value, equipmentUsage) Then
  43. ws.Cells(nextProcessRow, 10).Value = ws.Cells(currentRow, 12).Value
  44. duration = ws.Cells(nextProcessRow, 11).Value
  45. ws.Cells(nextProcessRow, 12).Value = ws.Cells(nextProcessRow, 10).Value + duration
  46. processedRows.Add nextProcessRow, True
  47. currentRow = nextProcessRow
  48. Else
  49. currentRow = WaitForEquipmentAvailability(ws, currentRow, equipment, equipmentUsage)
  50. End If
  51. Loop
  52. Next orderKey
  53. End Sub
  54. Function FindNextProcessRow(ws As Worksheet, startRow As Long) As Long
  55. Dim i As Long
  56. For i = startRow + 1 To ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
  57. If ws.Cells(i, 1).Value = ws.Cells(startRow, 1).Value And ws.Cells(i, 6).Value = ws.Cells(startRow, 6).Value + 10 Then
  58. FindNextProcessRow = i
  59. Exit Function
  60. End If
  61. Next i
  62. FindNextProcessRow = 0
  63. End Function
  64. Function IsEquipmentAvailableForPriorityRevised(ws As Worksheet, equipment As String, startDate As Date, priority As Long, equipmentUsage As Object) As Boolean
  65. If equipmentUsage.Exists(equipment) Then
  66. Dim lastUsedDate As Date
  67. lastUsedDate = equipmentUsage(equipment)
  68. Dim i As Long
  69. For i = 2 To ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
  70. If ws.Cells(i, 9).Value = equipment And ws.Cells(i, 10).Value > startDate And ws.Cells(i, 13).Value <= priority Then
  71. If ws.Cells(i, 10).Value < lastUsedDate Then
  72. IsEquipmentAvailableForPriorityRevised = False
  73. Else
  74. IsEquipmentAvailableForPriorityRevised = True
  75. End If
  76. Exit Function
  77. End If
  78. Next i
  79. Else
  80. IsEquipmentAvailableForPriorityRevised = True
  81. End If
  82. End Function
  83. Function WaitForEquipmentAvailability(ws As Worksheet, currentRow As Long, equipment As String, equipmentUsage As Object) As Long
  84. Dim endDate As Date
  85. endDate = ws.Cells(currentRow, 12).Value
  86. Dim nextAvailableRow As Long
  87. Do
  88. nextAvailableRow = FindNextAvailableTimeForPriorityRevised(ws, currentRow, equipment)
  89. If nextAvailableRow = 0 Then
  90. ' Wait until equipment is available
  91. DoEvents
  92. Else
  93. Dim newStartDate As Date
  94. newStartDate = ws.Cells(nextAvailableRow, 10).Value
  95. If IsEquipmentAvailableForPriorityRevised(ws, equipment, newStartDate, ws.Cells(nextAvailableRow, 13).Value, equipmentUsage) Then
  96. Exit Do
  97. Else
  98. currentRow = nextAvailableRow
  99. End If
  100. End If
  101. Loop
  102. WaitForEquipmentAvailability = nextAvailableRow
  103. End Function
  104. Function FindNextAvailableTimeForPriorityRevised(ws As Worksheet, currentRow As Long, equipment As String) As Long
  105. Dim endDate As Date
  106. endDate = ws.Cells(currentRow, 12).Value
  107. Dim i As Long
  108. For i = currentRow + 1 To ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
  109. If ws.Cells(i, 9).Value = equipment And ws.Cells(i, 9).Value > endDate Then
  110. FindNextAvailableTimeForPriorityRevised = i
  111. Exit Function
  112. End If
  113. Next i
  114. FindNextAvailableTimeForPriorityRevised = currentRow
  115. End Function
复制代码

项目占位计划B版2024-10-22-3.zip

30.16 KB, 下载次数: 11

TA的精华主题

TA的得分主题

 楼主| 发表于 2024-10-24 15:07 | 显示全部楼层
13825719951 发表于 2024-10-24 14:51
我觉得你没表达清楚. 另外, 我觉得做排产不要管理工序, 只要管理工数, 安排工序的事情交给班长去做. 看看我 ...

因为要生产的件太多了,而且每个件的工序必需要一步一步的干,我们要做全盘的规划,如果要一个工序一个工序去抠设备的占位的话,根本就搞不完,而且手工排产出来的还有可能会有错误,所以我就想把数据往表里面一丢,全由系统去进行排产

TA的精华主题

TA的得分主题

发表于 2024-10-24 15:12 | 显示全部楼层
人生の取引 发表于 2024-10-24 15:07
因为要生产的件太多了,而且每个件的工序必需要一步一步的干,我们要做全盘的规划,如果要一个工序一个工 ...

好吧, 我再看一下你的表各.

TA的精华主题

TA的得分主题

 楼主| 发表于 2024-10-24 15:24 | 显示全部楼层
13825719951 发表于 2024-10-24 15:12
好吧, 我再看一下你的表各.

好的,谢谢你,我刚刚也看了一下您发链接,不适用我们重型行业的生产模式,我们这个行业是单件多工序,无法使用流水线作业方式
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-11-21 16:38 , Processed in 0.033131 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表