123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- # generate_locations.py
- import os
- import django
- import sys
- # fun:get_pallet_count_by_batch: 根据托盘码查询批次下托盘总数
- # fun:get_location_type: 根据托盘数目获取库位类型
- # fun:updata_location_container_link: 更新库位和托盘的关联关系
- # fun:get_batch_status: 获取批次状态
- # fun:get_batch: 获取批次
- # fun:get_location_list_remainder: 获取可用库位的c_number列表
- # fun:get_min_list_index: 获取最小的库位
- # fun:get_location_by_type_remainder: 根据库位类型获取库位
- # fun:get_location_by_type: 第一次入库,根据库位类型获取库位
- # fun:get_location_by_status: 根据库位状态获取库位
- def setup_django():
- # 使用原始字符串处理Windows路径
- project_path = "E:/code/greater_wms"
- sys.path.append(project_path)
-
- # 根据实际目录名设置
- os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'greaterwms.settings')
- django.setup()
- def main():
- from container.views import OutTaskViewSet
- testtask = OutTaskViewSet()
- # count =testtask.get_batch_count_by_boundlist("2")
- # if not count:
- # print("❌ 批次下没有可用的库位,请检查批次号")
- # return
- # print(f"[1]批次下可用的库位数:{count}")
- # location_demand = testtask.generate_location_by_demand(count)
- # if not location_demand:
- # print("❌ 库位需求生成失败,请检查托盘编码")
- # return
- # print(f"[2]库位需求:{location_demand}")
- # for demand_id, demand_qty in count.items():
- # print (f"需求{demand_id}的库位数:{demand_qty}")
- # container_list = testtask.get_location_by_status_and_batch(1,demand_id)
- # if not container_list:
- # print("❌ 库位获取失败,请检查托盘编码")
- # return
- # print(f"[2]库位:{container_list}")
- # # container_list是dict
- # container_id_list = container_list.keys()
- # print(f"[3]库位id列表:{container_id_list}")
- # print("✅ 方法生成成功!")
- # container_order = testtask.get_order_by_batch(container_id_list)
- # if not container_order:
- # print("❌ 订单获取失败,请检查托盘编码")
- # return
- # print(f"[4]订单:{container_order}")
- # # 根据container_order(dict)的值进行排序
- # sorted_order = sorted(
- # container_order.values(),
- # key=lambda x: (
- # int(x['location_type'][-1]), # 提取T后的数字并转为整数
- # -x['location_c_number'] # 按location_c_number降序
- # )
- # )
- # print(f"[5]排序后的订单:{sorted_order}")
- if __name__ == "__main__":
- setup_django()
- main()
|