test_erp.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # generate_locations.py
  2. import os
  3. import django
  4. import sys
  5. def setup_django():
  6. # 使用原始字符串处理Windows路径
  7. project_path = "D:/Document/code/vue/greater_wms"
  8. sys.path.append(project_path)
  9. # 根据实际目录名设置(注意下划线)
  10. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'greaterwms.settings')
  11. django.setup()
  12. def main():
  13. try:
  14. # 从正确的应用导入模型
  15. from erp.views import AccessToken ,ProductionInboundAuditSync,PurchaseInboundAuditSync,OtherInboundAuditSync,OtherOutboundAuditSync,ProductionOutboundAuditSync,PurchaseInboundSaveSync,SaleOutboundSaveSync
  16. from erp.models import InboundBill
  17. from warehouse.models import baseset
  18. token = AccessToken.get_current_token()
  19. print('【1】token:',token)
  20. # 所有审核操作统一入口
  21. # inbound_bill = InboundBill.objects.filter(billId=2210144887247006720).first()
  22. inbound_bill = InboundBill.objects.filter(billId=2210170242427054080).first()
  23. print(f"ERP单号: {inbound_bill.number}")
  24. if not inbound_bill:
  25. print("❌ 未找到ERP单据")
  26. return
  27. # ProductionInboundAuditsync = ProductionInboundAuditSync(inbound_bill,[])
  28. # success = ProductionInboundAuditsync.execute_sync()
  29. # 审核采购入库单
  30. PurchaseInboundAuditsync = PurchaseInboundAuditSync(inbound_bill,[])
  31. success = PurchaseInboundAuditsync.execute_sync()
  32. # # 审核其它入库单
  33. # OtherInboundAuditsync = OtherInboundAuditSync(inbound_bill,[])
  34. # success = OtherInboundAuditsync.execute_sync()
  35. # # 审核其它出库单
  36. # OtherOutboundAuditsync = OtherOutboundAuditSync(inbound_bill,[])
  37. # success = OtherOutboundAuditsync.execute_sync()
  38. # # 审核生产出库单
  39. # ProductionOutboundAuditsync = ProductionOutboundAuditSync(inbound_bill,[])
  40. # success = ProductionOutboundAuditsync.execute_sync()
  41. # # 保存采购入库单
  42. # PurchaseInboundSavesync = PurchaseInboundSaveSync(inbound_bill,[])
  43. # success = PurchaseInboundSavesync.execute_sync()
  44. # # 保存销售出库单
  45. # SaleOutboundSavesync = SaleOutboundSaveSync(inbound_bill,[])
  46. # success = SaleOutboundSavesync.execute_sync()
  47. print("✅ 方法生成成功!")
  48. except Exception as e:
  49. print(f"❌ 生成失败:{str(e)}")
  50. import traceback
  51. traceback.print_exc()
  52. if __name__ == "__main__":
  53. setup_django()
  54. main()