微调代码,加入部分剩余产品处理机制;

This commit is contained in:
Saturneric 2021-04-19 20:56:56 +08:00
parent 8d7ffe6904
commit c1a8cdedcd
2 changed files with 26 additions and 6 deletions

View File

@ -93,9 +93,9 @@ class Process:
def set_product_time(self, pdt_time: int): def set_product_time(self, pdt_time: int):
self.pdt_time: int = pdt_time self.pdt_time: int = pdt_time
def add_res_need(self, rcs_attrs, amount): def add_res_need(self, rcs_attr: str, amount: int):
self.res_needs.append({ self.res_needs.append({
"rcs_attrs": rcs_attrs, "rcs_attr": rcs_attr,
"amount": amount "amount": amount
}) })

View File

@ -4,6 +4,7 @@ import csv
from typing import List, Dict from typing import List, Dict
from datetime import datetime from datetime import datetime
import time import time
import math
import dataset_importer import dataset_importer
@ -59,10 +60,13 @@ def products_processor(runtime_products: List[runtime.RuntimeProduct]):
processes_list: List[runtime.RuntimeProcess] = [] processes_list: List[runtime.RuntimeProcess] = []
production_times: int = 0 production_times: int = 0
for process in runtime_product.product.processes: for process in runtime_product.product.processes:
runtime_process: runtime.RuntimeProcess = \ # 执行工序的次数
runtime.RuntimeProcess(runtime_product, process) process_number = math.ceil(float(runtime_product.amount) / float(process.max_quantity))
production_times += runtime_process.process.pdt_time for i in range(process_number):
processes_list.append(runtime_process) runtime_process: runtime.RuntimeProcess = \
runtime.RuntimeProcess(runtime_product, process)
production_times += runtime_process.process.pdt_time
processes_list.append(runtime_process)
runtime_product.set_delay(production_times) runtime_product.set_delay(production_times)
runtime_products_processes_list.append({"runtimeProduct": runtime_product, "runtimeProcess": processes_list}) runtime_products_processes_list.append({"runtimeProduct": runtime_product, "runtimeProcess": processes_list})
@ -72,11 +76,27 @@ def products_processor(runtime_products: List[runtime.RuntimeProduct]):
key=lambda dict_item: key=lambda dict_item:
(dict_item["runtimeProduct"].ddl, dict_item["runtimeProduct"].delay)) (dict_item["runtimeProduct"].ddl, dict_item["runtimeProduct"].delay))
# 输出检查
for item in runtime_products_processes_list: for item in runtime_products_processes_list:
for runtime_process in item["runtimeProcess"]: for runtime_process in item["runtimeProcess"]:
runtime_product: runtime.RuntimeProduct = item["runtimeProduct"] runtime_product: runtime.RuntimeProduct = item["runtimeProduct"]
print(runtime_product.product.product_id, runtime_product.delay, runtime_process.process.pcs_id) print(runtime_product.product.product_id, runtime_product.delay, runtime_process.process.pcs_id)
return runtime_products_processes_list
# def resource_processor(resources: List[model.Resource], runtime_products_processes_list: List[Dict[str, any]]):
# resource_pool = runtime.RuntimeResourcePool(resources)
#
# for item in runtime_products_processes_list:
# ifalloc = True
# for runtime_process in item["runtimeProcess"]:
# runtime_process: runtime.RuntimeProcess = runtime_process
# for resource_item in runtime_process.process.res_needs:
# resource_item['']
# runtime_resource_need = runtime.RuntimeResourceNeed(runtime_process.process)
# if resource_pool.alloc_resource():
if __name__ == "__main__": if __name__ == "__main__":
m_orders, m_products, m_processes, m_resources = dataset_importer.import_dataset() m_orders, m_products, m_processes, m_resources = dataset_importer.import_dataset()