完善逻辑;

This commit is contained in:
Saturneric 2021-04-19 03:56:21 +08:00
parent 0d414c0318
commit 4a045d650b
2 changed files with 15 additions and 7 deletions

View File

@ -7,12 +7,13 @@ class RuntimeProduct:
def __init__(self, product, amount):
self.ddl: datetime = datetime.today()
self.start: datetime = datetime.today()
self.product: model.Product = product
self.amount: int = amount
def set_ddl(self, ddl: datetime):
def set_ddl_start(self, ddl: datetime, start: datetime):
self.ddl = ddl
pass
self.start = start
class ProductLine:
@ -71,4 +72,5 @@ class RuntimeProcess:
def __init__(self, runtime_product: RuntimeProduct, process: model.Process):
self.runtime_product = runtime_product
self.process = process
self.start_ddl = self.runtime_product.ddl - timedelta(minutes=process.pdt_time)
self.ddl = runtime_product.ddl
self.delay = self.runtime_product.ddl - timedelta(minutes=process.pdt_time)

View File

@ -15,7 +15,7 @@ def orders_processor(orders: Dict[str, model.Order]) -> List[runtime.RuntimeProd
for sorted_order in sorted_orders_list:
for item in sorted_order.products:
runtime_product = runtime.RuntimeProduct(item["product"], item["amount"])
runtime_product.set_ddl(sorted_order.latest_end_time)
runtime_product.set_ddl_start(sorted_order.latest_end_time, sorted_order.earliest_start_time)
products_lines.add_runtime_product(runtime_product)
runtime_product = products_lines.pop_runtime_product()
@ -41,7 +41,7 @@ def search_semi_products(floor, produce_tree, produce_list, runtime_product):
for item in runtime_product.product.semi_products:
runtime_semi_product = runtime.RuntimeProduct(item["semi_product"], item["amount"])
runtime_semi_product.set_ddl(runtime_product.ddl)
runtime_semi_product.set_ddl_start(runtime_product.ddl, runtime_product.start)
# print("C", runtime_semi_product.product.product_id, runtime_semi_product.ddl)
@ -60,7 +60,13 @@ def products_processor(runtime_products: List[runtime.RuntimeProduct]):
processes_list.append(runtime_process)
processes_list = sorted(processes_list, key=lambda rt_pcs: (rt_pcs.ddl, rt_pcs.delay))
for runtime_process in processes_list:
print(runtime_process.process.pcs_id, runtime_process.delay)
if __name__ == "__main__":
orders, products, processes, resources = dataset_importer.import_dataset()
orders_processor(orders)
m_orders, m_products, m_processes, m_resources = dataset_importer.import_dataset()
produce_list = orders_processor(m_orders)
products_processor(produce_list)