Python物流运输管理系统源代码,基于Django实现,实现了运单录入、发车出库、到货签收、客户签收等基本功能,含测试账号。拥有较为完善的报表功能和财务管理功能。可以通过后台界面对各个用户进行权限管理。
程序运行截图




核心代码

"""
Django settings for PPWuLiu project.Generated by 'django-admin startproject' using Django 3.1.2.For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""import os
from pathlib import Pathfrom django.contrib.messages import constants# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent# 创建日志的路径
LOG_PATH = os.path.join(BASE_DIR, "logs")
if not os.path.isdir(LOG_PATH):if os.path.isfile(LOG_PATH):os.remove(LOG_PATH)os.makedirs(LOG_PATH)# 启用Django Debug Toolbar
ENABLE_DJANGO_TOOLBAR = False# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv("DJANGO_TMS_SECRET_KEY")
#SECRET_KEY = os.environ["SECRET_KEY"]
PBKDF2_ITERATIONS = 3# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = TrueALLOWED_HOSTS = []# Application definitionINSTALLED_APPS = [# 'channels','django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles',# 'rest_framework',# 'django_filters','wuliu.apps.WuliuConfig','utils',
]
if DEBUG:try:import django_extensionsINSTALLED_APPS.append('django_extensions')# print SQL queries in shell_plusSHELL_PLUS_PRINT_SQL = Trueexcept ImportError:passMIDDLEWARE = ['django.middleware.security.SecurityMiddleware','django.contrib.sessions.middleware.SessionMiddleware','django.middleware.common.CommonMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware',
]# Pyinstrument, 暂时不用, 因为Django Debug Toolbar更好用更强大
# if DEBUG:
#     try:
#         import pyinstrument
#         MIDDLEWARE.append('pyinstrument.middleware.ProfilerMiddleware')
#     except ImportError:
#         pass# Django Debug Toolbar
if ENABLE_DJANGO_TOOLBAR:# debug_toolbar依赖于django.contrib.staticfilesif DEBUG and 'django.contrib.staticfiles' in INSTALLED_APPS:try:import debug_toolbarINSTALLED_APPS.append('debug_toolbar')MIDDLEWARE.append('debug_toolbar.middleware.DebugToolbarMiddleware')# Internal IPsINTERNAL_IPS = ['127.0.0.1',]except ImportError:passROOT_URLCONF = 'PPWuLiu.urls'TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates','DIRS': [],'APP_DIRS': True,'OPTIONS': {'context_processors': ['django.template.context_processors.debug','django.template.context_processors.request','django.contrib.auth.context_processors.auth','django.contrib.messages.context_processors.messages','wuliu.processor.pros'],},},
]WSGI_APPLICATION = 'PPWuLiu.wsgi.application'# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databasesDATABASES = {'default': {'ENGINE': 'django.db.backends.mysql','NAME': os.getenv("DJANGO_TMS_MYSQL_DATABASE_NAME"),'USER': os.getenv("DJANGO_TMS_MYSQL_USER"),'PASSWORD': os.getenv("DJANGO_TMS_MYSQL_PASSWORD"),'HOST': os.getenv("DJANGO_TMS_MYSQL_HOST"),'PORT': os.getenv("DJANGO_TMS_MYSQL_PORT"),}
}# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validatorsAUTH_PASSWORD_VALIDATORS = [{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',},{'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',},{'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',},{'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',},
]# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/LANGUAGE_CODE = 'zh-hans'TIME_ZONE = 'Asia/Shanghai'USE_I18N = TrueUSE_L10N = TrueUSE_TZ = True# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/STATIC_URL = '/static/'STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")
]# CustomCACHES = {'default': {# 基于本地内存的缓存'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',}
}# 关闭浏览器使会话立即过期
SESSION_EXPIRE_AT_BROWSER_CLOSE = TrueMESSAGE_TAGS = {constants.ERROR: "danger",
}LOGGING = {'version': 1,'disable_existing_loggers': False,'filters': {'require_debug_false': {'()': 'django.utils.log.RequireDebugFalse',},'require_debug_true': {'()': 'django.utils.log.RequireDebugTrue',},},'handlers': {'console': {'level': 'INFO','filters': ['require_debug_true'],'class': 'logging.StreamHandler',},# Unused'file': {'level': 'INFO','class': 'logging.FileHandler','filename': '%s/log.txt' % LOG_PATH,'encoding': 'utf-8',},'request_exceptions': {'level': 'INFO','class': 'logging.FileHandler','filename': '%s/request_exceptions.txt' % LOG_PATH,'encoding': 'utf-8',},'mail_admins': {'level': 'ERROR','filters': ['require_debug_false'],'class': 'django.utils.log.AdminEmailHandler'}},'loggers': {'django': {'handlers': ['console', 'mail_admins'],'level': 'INFO',},'wuliu.apps': {'handlers': ['request_exceptions'],'level': 'INFO','propagate': True,},'utils.common.expire_lru_cache': {'handlers': ['console'],'level': 'INFO','propagate': True,},},
}'''
# channels相关配置, 暂时不用
ASGI_APPLICATION = "PPWuLiu.asgi.application"
CHANNEL_LAYERS = {'default': {'BACKEND': 'channels_redis.core.RedisChannelLayer','CONFIG': {'hosts': [('127.0.0.1', 6379)],},},
}
'''

commn.py

from functools import wrapsfrom django.shortcuts import redirect
from django.http import Http404, HttpResponseForbidden
from django.utils import timezonefrom .models import (User, Waybill, TransportOut, DepartmentPayment, CargoPricePayment, Permission, PermissionGroup,_get_global_settings,
)
from utils.common import ExpireLruCache, model_to_dict_expire_lru_cache_three_hours = ExpireLruCache(expire_time=timezone.timedelta(hours=3))
expire_lru_cache_one_minute = ExpireLruCache(expire_time=timezone.timedelta(minutes=1))get_global_settings = expire_lru_cache_three_hours(_get_global_settings)@expire_lru_cache_one_minute
def _get_logged_user_by_id(user_id: int) -> User:""" 根据用户名返回用户模型对象 """return User.objects.get(id=user_id)def get_logged_user(request) -> User:""" 获取已登录的用户对象 """return _get_logged_user_by_id(request.session["user"]["id"])def get_logged_user_type(request) -> User.Types:""" 获取已登录的用户的用户类型 """return get_logged_user(request).get_type@expire_lru_cache_one_minute
def _get_user_permissions(user: User) -> set:""" 获取用户拥有的权限, 注意该方法返回的是集合而不是QuerySet """return set(user.permission.all().values_list("name", flat=True))def is_logged_user_has_perm(request, perm_name: str) -> bool:""" 检查已登录用户是否具有perm_name权限:return: True或False"""if not perm_name:return Truereturn perm_name in _get_user_permissions(get_logged_user(request))def is_logged_user_is_goods_yard(request) -> bool:""" 判断已登录的用户是否属于货场 """return get_logged_user_type(request) == User.Types.GoodsYarddef _gen_permission_tree_list(root_pg_=PermissionGroup.objects.get(father__isnull=True)) -> list:""" 根据所有的权限组和权限的层级结构生成列表, 用于前端渲染 """tree_list = []for pg in PermissionGroup.objects.filter(father=root_pg_):tree_list.append({"id": pg.id, "name": pg.name, "print_name": pg.print_name, "children": _gen_permission_tree_list(pg)})for p in Permission.objects.filter(father=root_pg_):tree_list.append({"id": p.id, "name": p.name, "print_name": p.print_name,})return tree_listPERMISSION_TREE_LIST = _gen_permission_tree_list()def login_required(raise_404=False):""" 自定义装饰器, 用于装饰路由方法若用户未登录, 则跳转到登录页面raise_404为True时, 则跳转到404页面"""def _login_required(func):@wraps(func)def login_check(request, *args, **kwargs):if not request.session.get("user"):if raise_404:raise Http404return redirect("wuliu:login")return func(request, *args, **kwargs)return login_checkreturn _login_requireddef check_permission(perm_name: str):""" 自定义装饰器, 用于在请求前检查用户是否具有perm_name权限若无perm_name权限则跳转至403页面"""def _check_permission(func):@wraps(func)def perm_check(request, *args, **kwargs):if perm_name and not is_logged_user_has_perm(request, perm_name):return HttpResponseForbidden()return func(request, *args, **kwargs)return perm_checkreturn _check_permissiondef check_administrator(func):""" 自定义装饰器, 用于在请求前检查用户是否为管理员若不是管理员则跳转至403页面"""@wraps(func)def admin_check(request, *args, **kwargs):if not get_logged_user(request).administrator:return HttpResponseForbidden()return func(request, *args, **kwargs)return admin_checkdef waybill_to_dict(waybill_obj: Waybill) -> dict:""" 将Waybill对象转为字典 """waybill_dic = model_to_dict_(waybill_obj)waybill_dic["id_"] = waybill_obj.get_full_idwaybill_dic["fee_type_id"] = waybill_dic["fee_type"]waybill_dic["fee_type"] = waybill_obj.get_fee_type_display()waybill_dic["status_id"] = waybill_dic["status"]waybill_dic["status"] = waybill_obj.get_status_display()if waybill_obj.return_waybill is not None:waybill_dic["return_waybill"] = waybill_to_dict(waybill_obj.return_waybill)else:waybill_dic["return_waybill"] = Nonereturn waybill_dicdef transport_out_to_dict(transport_out_obj: TransportOut) -> dict:""" 将TransportOut对象转为字典 """to_dic = model_to_dict_(transport_out_obj)to_dic["id_"] = transport_out_obj.get_full_idto_dic["status_id"] = to_dic["status"]to_dic["status"] = transport_out_obj.get_status_display()to_dic.update(transport_out_obj.gen_waybills_info())return to_dicdef department_payment_to_dict(department_payment_obj: DepartmentPayment) -> dict:""" 将DepartmentPayment对象转为字典 """dp_dic = model_to_dict_(department_payment_obj)dp_dic["id_"] = department_payment_obj.get_full_iddp_dic["status_id"] = dp_dic["status"]dp_dic["status"] = department_payment_obj.get_status_display()total_fee_dic = department_payment_obj.gen_total_fee()dp_dic["total_fee_now"] = total_fee_dic["fee_now"]dp_dic["total_fee_sign_for"] = total_fee_dic["fee_sign_for"]dp_dic["total_cargo_price"] = total_fee_dic["cargo_price"]dp_dic["final_total_fee"] = sum(total_fee_dic.values())return dp_dicdef cargo_price_payment_to_dict(cargo_price_payment_obj: CargoPricePayment) -> dict:""" 将CargoPricePayment对象转为字典 """cpp_dic = model_to_dict_(cargo_price_payment_obj)cpp_dic["id_"] = cargo_price_payment_obj.get_full_idcpp_dic["status_id"] = cpp_dic["status"]cpp_dic["status"] = cargo_price_payment_obj.get_status_display()total_fee_dic = cargo_price_payment_obj.gen_total_fee()cpp_dic["total_cargo_price"] = total_fee_dic["cargo_price"]cpp_dic["total_deduction_fee"] = total_fee_dic["deduction_fee"]cpp_dic["total_cargo_handling_fee"] = total_fee_dic["cargo_handling_fee"]cpp_dic["final_fee"] = (total_fee_dic["cargo_price"] - total_fee_dic["deduction_fee"] - total_fee_dic["cargo_handling_fee"])return cpp_dic

测试数据账号密码如下:

#用户名 密码 用户类型
#csshd 666666 收货点
#csfgs 666666 分公司(到货点)#kj_1 666666 会计(财务部)
#zxg_1 666666 货物装卸工1(货台)
#zxg_2 666666 货物装卸工2(货台)
#pzqqt 88888888 管理员

完整Python物流运输管理系统源代码下载地址:物流运输管理系统

Python物流运输管理系统源代码,基于Django实现,实现了运单录入、发车出库、到货签收、客户签收等基本功能,含测试账号相关推荐

  1. python车辆定位调度管理系统,基于django+twisted

    通过给车辆安装gps定位器,实现车辆的监控管理 软件架构 软件架构说明 主要框架 python: django twisted 数据库:postgresql 前端:layui 进程守护:supervi ...

  2. Python版超市管理系统源代码,基于django+mysql

    Python版超市管理系统源代码,基于django+mysql 安装步骤 1.在mysql中创建名为demo_django_supermarket的数据库,修改config/setting.py中数据 ...

  3. 订单信息修改java模型图,java毕业设计_springboot框架的物流运输管理系统订单管理...

    这是一个基于java的毕业设计项目,毕设课题为springboot框架的物流运输管理系统订单管理, 是一个采用b/s结构的javaweb项目, 开发工具eclipsei/eclipse, 项目框架js ...

  4. java-php-python-springboot智能物流运输管理系统登录计算机毕业设计

    java-php-python-springboot智能物流运输管理系统登录计算机毕业设计 java-php-python-springboot智能物流运输管理系统登录计算机毕业设计 本源码技术栈: ...

  5. TMS物流运输管理系统、智慧物流、智能运输、运单管理、预开单、补录运单、提货管理、库存管理、签收管理、短驳管理、车辆配载、送货管理、回单管理、退货管理、中转管理、承运商、路由、车线、司机、油卡、车辆

    TMS物流运输管理系统.智慧物流.智能运输.运单管理.预开单.补录运单.提货管理.库存管理.签收管理.短驳管理.车辆配载.送货管理.回单管理.退货管理.中转管理.承运商.路由.车线.司机.油卡.车辆, ...

  6. 集装箱RFID物流运输管理系统应用

    经过近几年的发展,RFID技术已经被广泛用于生产.物流.交通.运输.医疗.防伪.跟踪.设备和资产管理等需要收集和处理数据的应用领域,被认为是条形码标签的未来替代品. 将RFID技术应用于集装箱物流运输 ...

  7. 大型物流运输管理系统源码 TMS源码

    大型物流运输管理系统源码 TMS是一套适用于物流公司的物流运输管理系统,涵盖物流公司内部从订单->提货->运单->配车->点到->预约->签收->回单-> ...

  8. javaweb仓库管理系统的实现,基于ssm+mysql实现的WMS进销存出库入库系统

    javaweb仓库管理系统的实现,基于ssm+mysql实现的WMS进销存出库入库系统 感兴趣的朋友可以家 3060912346 主要技术 SpringBoot\SSM(两个版本都有) HTML.jQ ...

  9. python实现宿舍管理系统_基于PYTHON微信小程序的病历管理系统的设计与实现

    好程序设计擅长JAVA(SSM,SSH,SPRINGBOOT).PYTHON(DJANGO/FLASK).THINKPHP.C#.安卓.微信小程序.MYSQL.SQLSERVER等,欢迎咨询 今天记录 ...

  10. Python版名片管理系统源代码

    Python版名片管理系统,功能: 新增名片(记录用户的姓名,电话,QQ,邮箱): 显示所有名片: 查询名片: 查询成功后可以修改,删除名片 运行截图: cards_main.py :程序的入口,完整 ...

最新文章

  1. 线上直播丨KDD 2021预训练Workshop,谷歌MSRA等5位顶尖研究者参与研讨
  2. 一文带你重温去年最难忘的10个数据泄露事件
  3. 杭电2063--过山车(二分匹配)
  4. Redis命令——哈希(Hash)
  5. Thrift架构~thrift中间语言的认识(只有它什么都不是,它才有可能什么都是)
  6. Qt中的模态对话框和非模态对话框
  7. matlab graphic,Matlab图形系统,Matlab Graphic System,音标,读音,翻译,英文例句,英语词典...
  8. 三、比特币白皮书:一种点对点的电子现金系统
  9. [*转*] 开发B2C电子商务系统(ASP.NET)--多年前的老文章
  10. xbox360fsd更新游戏封面_Steam推出了新版游戏库,界面更为简洁
  11. 地理类国际顶级期刊汇总
  12. 理光m2554进入维修_理光DX2432C,基士得耶6201供墨检测代码,看完马上解决代码故障...
  13. 数据库新手常犯的5个错误
  14. 浏览器渲染机制面试_面试 09-01.浏览器渲染机制
  15. xmta温度控制仪说明书_XMT温度控制仪说明书
  16. php架构师都会有什么面试题,PHP架构师面试题目和答案
  17. 马尔可夫和切比雪夫不等式的证明
  18. 电影文件的合并与分割
  19. tilemap 导入unity_Unity2019基础教程:TileMap搭建像素画场景关卡
  20. python学习笔记3

热门文章

  1. ipv6如何测试服务器已经是ipv6协议,怎么测试域名是否支持ipv6
  2. Druid SQL和Security在美团点评的实践
  3. 货币战争悲壮的英雄:帕潘德里欧
  4. 如何在Photoshop里抠头发丝
  5. python检测按键按下_如何检测按键是否被按下?
  6. 轻量应用服务器腾讯云,腾讯云轻量应用服务器 ECS云服务器使用对比
  7. OLAP系统核心技术点,每一点都值得单独收藏
  8. 用流量扫码总显示无法连接服务器,手机有流量但无法连接网络?手机数据网络不能访问互联网...
  9. 如何用C#做一个类似于桌面插件的程序(转)
  10. python3 录屏