提交
This commit is contained in:
1
backend/.gitignore
vendored
1
backend/.gitignore
vendored
@@ -93,7 +93,6 @@ ENV/
|
||||
*.pyc
|
||||
conf/*
|
||||
!conf/env.example.py
|
||||
db.sqlite3
|
||||
media/
|
||||
__pypackages__/
|
||||
package-lock.json
|
||||
|
||||
@@ -28,7 +28,7 @@ from conf.env import *
|
||||
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = "django-insecure--z8%exyzt7e_%i@1+#1mm=%lb5=^fx_57=1@a+_y7bg5-w%)sm"
|
||||
SECRET_KEY = "django-insecure--z8%exyz2sae4e_%i@1+#1mm=%lb5=^fx_57=1@a+_y7bg5-w%)sm"
|
||||
# 初始化plugins插件路径到环境变量中
|
||||
PLUGINS_PATH = os.path.join(BASE_DIR, "plugins")
|
||||
sys.path.insert(0, os.path.join(PLUGINS_PATH))
|
||||
@@ -408,7 +408,8 @@ SHARED_APPS = []
|
||||
# ********** 一键导入插件配置开始 **********
|
||||
# 例如:
|
||||
# from dvadmin_upgrade_center.settings import * # 升级中心
|
||||
from dvadmin3_celery.settings import * # celery 异步任务
|
||||
from code_info.settings import * # celery 异步任务
|
||||
# from dvadmin3_celery.settings import * # celery 异步任务
|
||||
# from dvadmin_third.settings import * # 第三方用户管理
|
||||
# from dvadmin_ak_sk.settings import * # 秘钥管理管理
|
||||
# from dvadmin_tenants.settings import * # 租户管理
|
||||
@@ -416,3 +417,22 @@ from dvadmin3_celery.settings import * # celery 异步任务
|
||||
#from dvadmin_uniapp.settings import *
|
||||
# ...
|
||||
# ********** 一键导入插件配置结束 **********
|
||||
|
||||
|
||||
if locals().get('ENVIRONMENT') != 'local':
|
||||
# 1. 定义统一的迁移文件存放目录(例如:`./all_migrations/`)
|
||||
BASE_MIGRATIONS_DIR = "all_migrations"
|
||||
# 2. 自动生成 MIGRATION_MODULES
|
||||
# 2. 定义需要排除的 App(如 Django 内置 App 或第三方 App)
|
||||
EXCLUDED_APPS = ('django','admin','auth.','contenttypes.','sessions.','psqlextra','rest_framework','drf_yasg',)
|
||||
MIGRATION_MODULES = {}
|
||||
for app in INSTALLED_APPS:
|
||||
if app.startswith(EXCLUDED_APPS):
|
||||
continue
|
||||
# 判断是否存在目录,并在目录下创建一个__init__.py 文件
|
||||
app_migrations_dir = os.path.join(BASE_DIR, BASE_MIGRATIONS_DIR, app.split('.')[-1], 'migrations')
|
||||
if not os.path.exists(app_migrations_dir):
|
||||
os.makedirs(os.path.join(app_migrations_dir))
|
||||
open(os.path.join(BASE_DIR, BASE_MIGRATIONS_DIR, app.split('.')[-1],'migrations', '__init__.py'), 'w').close()
|
||||
MIGRATION_MODULES.update(
|
||||
{app.split('.')[-1]: f"{BASE_MIGRATIONS_DIR}.{app.split('.')[-1]}.migrations"})
|
||||
@@ -1,6 +1,6 @@
|
||||
[
|
||||
{
|
||||
"name": "DVAdmin团队",
|
||||
"name": "总部",
|
||||
"key": "dvadmin",
|
||||
"sort": 1,
|
||||
"owner": "",
|
||||
@@ -11,7 +11,7 @@
|
||||
"children": [
|
||||
{
|
||||
"name": "运营部",
|
||||
"key": "",
|
||||
"key": "zongbu",
|
||||
"sort": 2,
|
||||
"owner": "",
|
||||
"phone": "",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -97,7 +97,7 @@
|
||||
"parent": 1,
|
||||
"title": "网站标题",
|
||||
"key": "site_title",
|
||||
"value": "Dvadmin",
|
||||
"value": "协众防重码",
|
||||
"sort": 1,
|
||||
"status": true,
|
||||
"data_options": null,
|
||||
@@ -111,7 +111,7 @@
|
||||
"parent": 1,
|
||||
"title": "网站名称",
|
||||
"key": "site_name",
|
||||
"value": "企业级后台管理系统",
|
||||
"value": "协众防重码系统",
|
||||
"sort": 1,
|
||||
"status": true,
|
||||
"data_options": null,
|
||||
@@ -158,7 +158,7 @@
|
||||
"parent": 1,
|
||||
"title": "版权信息",
|
||||
"key": "copyright",
|
||||
"value": "2021-2024 django-vue-admin.com 版权所有",
|
||||
"value": "2021-2025 协众防重码系统 版权所有",
|
||||
"sort": 4,
|
||||
"status": true,
|
||||
"data_options": null,
|
||||
@@ -177,7 +177,7 @@
|
||||
"parent": 1,
|
||||
"title": "备案信息",
|
||||
"key": "keep_record",
|
||||
"value": "晋ICP备18005113号-3",
|
||||
"value": "",
|
||||
"sort": 5,
|
||||
"status": true,
|
||||
"data_options": null,
|
||||
@@ -196,7 +196,7 @@
|
||||
"parent": 1,
|
||||
"title": "帮助链接",
|
||||
"key": "help_url",
|
||||
"value": "https://django-vue-admin.com",
|
||||
"value": "#",
|
||||
"sort": 6,
|
||||
"status": true,
|
||||
"data_options": null,
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
"last_name": "",
|
||||
"is_staff": true,
|
||||
"is_active": true,
|
||||
"password": "pbkdf2_sha256$260000$g17x5wlSiW1FZAh1Eudchw$ZeSAqj3Xak0io8v/pmPW0BX9EX5R2zFXDwbbD68oBFk=",
|
||||
"description": "A01",
|
||||
"password": "pbkdf2_sha256$600000$ITjuHRKiVCgPpiuCYxAaEp$aA9LDAfujtdMJRstK9YcBPz9a9MkfFG5Tsq1NviWxy0=",
|
||||
"last_login": null,
|
||||
"is_superuser": true
|
||||
},
|
||||
@@ -34,7 +35,8 @@
|
||||
"last_name": "",
|
||||
"is_staff": true,
|
||||
"is_active": true,
|
||||
"password": "pbkdf2_sha256$260000$g17x5wlSiW1FZAh1Eudchw$ZeSAqj3Xak0io8v/pmPW0BX9EX5R2zFXDwbbD68oBFk=",
|
||||
"description": "A02",
|
||||
"password": "pbkdf2_sha256$600000$ITjuHRKiVCgPpiuCYxAaEp$aA9LDAfujtdMJRstK9YcBPz9a9MkfFG5Tsq1NviWxy0=",
|
||||
"last_login": null,
|
||||
"is_superuser": false
|
||||
},
|
||||
@@ -49,11 +51,12 @@
|
||||
"role": [],
|
||||
"role_key": ["public"],
|
||||
"dept_key": "technology",
|
||||
"description": "A03",
|
||||
"first_name": "",
|
||||
"last_name": "",
|
||||
"is_staff": true,
|
||||
"is_active": true,
|
||||
"password": "pbkdf2_sha256$260000$g17x5wlSiW1FZAh1Eudchw$ZeSAqj3Xak0io8v/pmPW0BX9EX5R2zFXDwbbD68oBFk=",
|
||||
"password": "pbkdf2_sha256$600000$ITjuHRKiVCgPpiuCYxAaEp$aA9LDAfujtdMJRstK9YcBPz9a9MkfFG5Tsq1NviWxy0=",
|
||||
"last_login": null,
|
||||
"is_superuser": false
|
||||
}
|
||||
|
||||
0
backend/plugins/code_info/__init__.py
Normal file
0
backend/plugins/code_info/__init__.py
Normal file
3
backend/plugins/code_info/admin.py
Normal file
3
backend/plugins/code_info/admin.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
6
backend/plugins/code_info/apps.py
Normal file
6
backend/plugins/code_info/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CodeInfoConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'plugins.code_info'
|
||||
0
backend/plugins/code_info/fixtures/__init__.py
Normal file
0
backend/plugins/code_info/fixtures/__init__.py
Normal file
1
backend/plugins/code_info/fixtures/init_dictionary.json
Normal file
1
backend/plugins/code_info/fixtures/init_dictionary.json
Normal file
@@ -0,0 +1 @@
|
||||
[]
|
||||
49
backend/plugins/code_info/fixtures/init_menu.json
Normal file
49
backend/plugins/code_info/fixtures/init_menu.json
Normal file
@@ -0,0 +1,49 @@
|
||||
[ {
|
||||
"name": "扫码信息",
|
||||
"icon": "ele-Bell",
|
||||
"sort": 8,
|
||||
"is_link": false,
|
||||
"is_catalog": true,
|
||||
"web_path": "/releaseInfo",
|
||||
"component": "",
|
||||
"component_name": "",
|
||||
"status": true,
|
||||
"cache": true,
|
||||
"visible": true,
|
||||
"parent": null,
|
||||
"children": [
|
||||
{
|
||||
"name": "扫码数据",
|
||||
"icon": "ele-Bell",
|
||||
"sort": 1,
|
||||
"is_link": false,
|
||||
"is_catalog": false,
|
||||
"web_path": "/scanData",
|
||||
"component": "plugins/scanInfo/src/scanData/index",
|
||||
"component_name": "scanData",
|
||||
"status": true,
|
||||
"cache": false,
|
||||
"visible": true,
|
||||
"children": [],
|
||||
"menu_button": [],
|
||||
"menu_field": []
|
||||
},{
|
||||
"name": "异常扫码记录",
|
||||
"icon": "ele-Bell",
|
||||
"sort": 2,
|
||||
"is_link": false,
|
||||
"is_catalog": false,
|
||||
"web_path": "/scanRecord",
|
||||
"component": "plugins/scanInfo/src/scanRecord/index",
|
||||
"component_name": "scanRecord",
|
||||
"status": true,
|
||||
"cache": false,
|
||||
"visible": true,
|
||||
"children": [],
|
||||
"menu_button": [],
|
||||
"menu_field": []
|
||||
}
|
||||
],
|
||||
"menu_button": [],
|
||||
"menu_field": []
|
||||
}]
|
||||
33
backend/plugins/code_info/fixtures/initialize.py
Normal file
33
backend/plugins/code_info/fixtures/initialize.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# 初始化
|
||||
import os
|
||||
|
||||
import django
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "application.settings")
|
||||
django.setup()
|
||||
|
||||
from dvadmin.system.fixtures.initSerializer import MenuInitSerializer, SystemConfigInitSerializer, \
|
||||
DictionaryInitSerializer
|
||||
|
||||
from dvadmin.utils.core_initialize import CoreInitialize
|
||||
|
||||
|
||||
class Initialize(CoreInitialize):
|
||||
|
||||
def init_menu(self):
|
||||
"""
|
||||
初始化菜单信息
|
||||
"""
|
||||
self.init_base(MenuInitSerializer, unique_fields=['name', 'web_path', 'component', 'component_name'])
|
||||
def init_dictionary(self):
|
||||
"""
|
||||
初始化字典表
|
||||
"""
|
||||
self.init_base(DictionaryInitSerializer, unique_fields=['value', 'parent', ])
|
||||
|
||||
def run(self):
|
||||
self.init_menu()
|
||||
self.init_dictionary()
|
||||
print(22)
|
||||
if __name__ == '__main__':
|
||||
Initialize(app='release_info').run()
|
||||
0
backend/plugins/code_info/migrations/__init__.py
Normal file
0
backend/plugins/code_info/migrations/__init__.py
Normal file
29
backend/plugins/code_info/models.py
Normal file
29
backend/plugins/code_info/models.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from django.db import models
|
||||
|
||||
from django.db import models
|
||||
from dvadmin.utils.models import CoreModel
|
||||
|
||||
table_prefix = "release_info_"
|
||||
|
||||
|
||||
class ScanData(CoreModel):
|
||||
# 产品件号、供应商代码、生产批次、产品序列码、版本号、扫码时间、班次和人员信息
|
||||
code = models.CharField(null=True, blank=True, max_length=255, verbose_name='扫码值', help_text='扫码值')
|
||||
product_code = models.CharField(null=True, blank=True, max_length=255, verbose_name='产品件号', help_text='产品件号')
|
||||
supplier_code = models.CharField(null=True, blank=True, max_length=255, verbose_name='供应商代码', help_text='供应商代码')
|
||||
production_batch = models.CharField(null=True, blank=True, max_length=255, verbose_name='生产批次', help_text='生产批次')
|
||||
product_serial_number = models.CharField(null=True, blank=True, max_length=255, verbose_name='产品序列码', help_text='产品序列码')
|
||||
version_number = models.CharField(null=True, blank=True, max_length=255, verbose_name='版本号', help_text='版本号')
|
||||
shift = models.CharField(null=True, blank=True, max_length=255, verbose_name='班次', help_text='班次')
|
||||
STATUS_EMU = (
|
||||
(0, "重复扫码"),
|
||||
(1, "正常"),
|
||||
(2, "未识别码"),
|
||||
)
|
||||
status = models.IntegerField(default=1, choices=STATUS_EMU, verbose_name='状态', help_text='状态')
|
||||
|
||||
class Meta:
|
||||
db_table = table_prefix + "scan_data"
|
||||
verbose_name = "扫码数据"
|
||||
verbose_name_plural = verbose_name
|
||||
ordering = ('-create_datetime',)
|
||||
22
backend/plugins/code_info/settings.py
Normal file
22
backend/plugins/code_info/settings.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from application import settings
|
||||
|
||||
# ================================================= #
|
||||
# ***************** 插件配置区开始 *******************
|
||||
# ================================================= #
|
||||
# 路由配置
|
||||
plugins_url_patterns = [
|
||||
{"re_path": r'api/code_info/', "include": "code_info.urls"},
|
||||
]
|
||||
# app 配置
|
||||
apps = ['code_info']
|
||||
# 租户模式中,public模式共享app配置
|
||||
tenant_shared_apps = ['code_info']
|
||||
# ================================================= #
|
||||
# ******************* 插件配置区结束 *****************
|
||||
# ================================================= #
|
||||
|
||||
# ********** 赋值到 settings 中 **********
|
||||
settings.INSTALLED_APPS += [app for app in apps if app not in settings.INSTALLED_APPS]
|
||||
settings.TENANT_SHARED_APPS += tenant_shared_apps
|
||||
# ********** 注册路由 **********
|
||||
settings.PLUGINS_URL_PATTERNS += plugins_url_patterns
|
||||
15
backend/plugins/code_info/urls.py
Normal file
15
backend/plugins/code_info/urls.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from django.urls import path
|
||||
from rest_framework import routers
|
||||
|
||||
from plugins.code_info.views.scan_data import ScanDataViewSet
|
||||
from plugins.code_info.views.scan_record import ScanRecordViewSet
|
||||
|
||||
route_url = routers.SimpleRouter()
|
||||
|
||||
route_url.register(r'scan_data', ScanDataViewSet,basename='scan_data')
|
||||
route_url.register(r'scan_record', ScanRecordViewSet)
|
||||
|
||||
urlpatterns = [
|
||||
|
||||
]
|
||||
urlpatterns += route_url.urls
|
||||
0
backend/plugins/code_info/views/__init__.py
Normal file
0
backend/plugins/code_info/views/__init__.py
Normal file
67
backend/plugins/code_info/views/scan_data.py
Normal file
67
backend/plugins/code_info/views/scan_data.py
Normal file
@@ -0,0 +1,67 @@
|
||||
from dvadmin.utils.field_permission import FieldPermissionMixin
|
||||
from dvadmin.utils.serializers import CustomModelSerializer
|
||||
from dvadmin.utils.validator import CustomValidationError
|
||||
from dvadmin.utils.viewset import CustomModelViewSet
|
||||
from plugins.code_info.models import ScanData
|
||||
|
||||
|
||||
class ScanDataSerializer(CustomModelSerializer):
|
||||
"""
|
||||
扫码数据-序列化器
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = ScanData
|
||||
fields = "__all__"
|
||||
read_only_fields = ["id"]
|
||||
|
||||
class CreateScanDataSerializer(CustomModelSerializer):
|
||||
"""
|
||||
扫码数据-序列化器
|
||||
"""
|
||||
|
||||
def create(self, validated_data):
|
||||
code = validated_data.get("code")
|
||||
print(code)
|
||||
code_list = code.split("/")
|
||||
if len(code_list) == 5:
|
||||
validated_data["product_code"] = code_list[0]
|
||||
validated_data["supplier_code"] = code_list[1]
|
||||
validated_data["production_batch"] = code_list[2]
|
||||
validated_data["product_serial_number"] = code_list[3]
|
||||
validated_data["version_number"] = code_list[4]
|
||||
validated_data["shift"] = self.request.user.description
|
||||
instance = super().create(validated_data)
|
||||
# 1.格式错误
|
||||
if len(code_list) != 5:
|
||||
instance.status = 2
|
||||
instance.save()
|
||||
raise CustomValidationError("数据格式错误")
|
||||
# 2.查询数据是否已存在数据库
|
||||
print("ScanData.objects.filter(code=code, status=1)",ScanData.objects.filter(code=code, status=1))
|
||||
if ScanData.objects.filter(code=code, status=1).exclude(id=instance.id).exists():
|
||||
instance.status = 0
|
||||
instance.save()
|
||||
raise CustomValidationError("重复扫码")
|
||||
return instance
|
||||
|
||||
|
||||
class Meta:
|
||||
model = ScanData
|
||||
fields = "__all__"
|
||||
read_only_fields = ["id"]
|
||||
|
||||
|
||||
class ScanDataViewSet(CustomModelViewSet, FieldPermissionMixin):
|
||||
"""
|
||||
扫码数据接口
|
||||
list:查询
|
||||
create:新增
|
||||
update:修改
|
||||
retrieve:单例
|
||||
destroy:删除
|
||||
"""
|
||||
queryset = ScanData.objects.filter(status=1)
|
||||
serializer_class = ScanDataSerializer
|
||||
create_serializer_class = CreateScanDataSerializer
|
||||
extra_filter_class = []
|
||||
29
backend/plugins/code_info/views/scan_record.py
Normal file
29
backend/plugins/code_info/views/scan_record.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from dvadmin.utils.field_permission import FieldPermissionMixin
|
||||
from dvadmin.utils.serializers import CustomModelSerializer
|
||||
from dvadmin.utils.viewset import CustomModelViewSet
|
||||
from plugins.code_info.models import ScanData
|
||||
|
||||
|
||||
class ScanRecordSerializer(CustomModelSerializer):
|
||||
"""
|
||||
扫码数据-序列化器
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = ScanData
|
||||
fields = "__all__"
|
||||
read_only_fields = ["id"]
|
||||
|
||||
|
||||
class ScanRecordViewSet(CustomModelViewSet, FieldPermissionMixin):
|
||||
"""
|
||||
异常扫码数据记录接口
|
||||
list:查询
|
||||
create:新增
|
||||
update:修改
|
||||
retrieve:单例
|
||||
destroy:删除
|
||||
"""
|
||||
queryset = ScanData.objects.exclude(status=1)
|
||||
serializer_class = ScanRecordSerializer
|
||||
extra_filter_class = []
|
||||
@@ -8,8 +8,7 @@ django-restql==0.15.4
|
||||
django-simple-captcha==0.6.0
|
||||
django-timezone-field==7.0
|
||||
djangorestframework_simplejwt==5.4.0
|
||||
drf-yasg==1.21.7
|
||||
mysqlclient==2.2.0
|
||||
drf-yasg==1.21.10
|
||||
pypinyin==0.51.0
|
||||
ua-parser==0.18.0
|
||||
pyparsing==3.1.2
|
||||
|
||||
Reference in New Issue
Block a user