1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import os
- import django
- import sys
- def setup_django():
-
- project_path = "D:/Document/code/vue/greater_wms"
- sys.path.append(project_path)
-
-
- os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'greaterwms.settings')
- django.setup()
- def main():
- try:
-
- from bin.views import LocationAllocation
-
- container_code = "12345"
- print(f"开始生成库位,托盘编码:{container_code}")
-
-
-
-
- allocator = LocationAllocation()
- number=allocator.get_pallet_count_by_batch(container_code)
- if number is None:
- print("❌ 该批次下无托盘,请检查托盘编码")
- return
- print(f"该批次下托盘总数:{number}")
-
- location_type = allocator.get_location_type(number)
- if not location_type:
- print("❌ 库位类型获取失败,请检查托盘数量")
- return
- print(f"库位类型:{location_type}")
-
-
- batch_status = allocator.get_batch_status(container_code)
- if not batch_status:
- print("❌ 批次状态获取失败,请检查批次号")
- return
- print(f"批次状态:{batch_status}")
- batch = allocator.get_batch(container_code)
- if not batch:
- print("❌ 批次获取失败,请检查托盘编码")
- return
- print(f"批次信息:{batch}")
- location_list_cnumber = allocator.get_location_by_status(container_code, 'in2', 1)
- if not location_list_cnumber:
- print("❌ 通用库位获取失败,请检查托盘编码")
- return
- print(f"库位列表:{location_list_cnumber}")
- updata_location_container_link = allocator.updata_location_container_link(location_list_cnumber.location_code, container_code)
- if not updata_location_container_link:
- print("❌ 库位和托盘的关联关系更新失败,请检查托盘编码")
- return
- print(f"库位和托盘的关联关系更新成功!")
- location_list = allocator.get_location_by_type(location_type, 'in2', 1)
- if not location_list:
- print("❌ 第一次库位获取失败,请检查库位类型")
- return
- print(f"库位列表:{location_list}")
- location_list_cnumber = allocator.get_location_by_type_remainder(batch, 1)
- if not location_list_cnumber:
- print("❌ 剩余库位获取失败,请检查托盘编码")
- return
- print(f"库位列表:{location_list_cnumber}")
- print("✅ 方法生成成功!")
-
- except Exception as e:
- print(f"❌ 生成失败:{str(e)}")
- import traceback
- traceback.print_exc()
- if __name__ == "__main__":
- setup_django()
- main()
|