Ver código fonte

开始编写入库,库位分配规则

flower_mr 1 mês atrás
pai
commit
89d5cbcacb

+ 0 - 0
bin/__init__.py


+ 3 - 0
bin/admin.py

@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.

+ 6 - 0
bin/apps.py

@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class BinConfig(AppConfig):
+    default_auto_field = 'django.db.models.BigAutoField'
+    name = 'bin'

+ 0 - 0
bin/migrations/__init__.py


+ 3 - 0
bin/models.py

@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.

+ 3 - 0
bin/tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 3 - 0
bin/views.py

@@ -0,0 +1,3 @@
+from django.shortcuts import render
+
+# Create your views here.

BIN
container/__pycache__/models.cpython-38.pyc


BIN
container/__pycache__/views.cpython-38.pyc


+ 19 - 0
container/migrations/0002_containerwcsmodel_tasknumber.py

@@ -0,0 +1,19 @@
+# Generated by Django 4.1.2 on 2025-04-15 10:20
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('container', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='containerwcsmodel',
+            name='tasknumber',
+            field=models.IntegerField(default=123456, verbose_name='任务号'),
+            preserve_default=False,
+        ),
+    ]

BIN
container/migrations/__pycache__/0002_containerwcsmodel_tasknumber.cpython-38.pyc


+ 2 - 0
container/models.py

@@ -86,6 +86,7 @@ class ContainerWCSModel(models.Model):
     taskid = models.CharField(max_length=50, verbose_name='任务ID')
     month = models.IntegerField(verbose_name='月份')
     tasktype = models.CharField(max_length=50, verbose_name='任务类型')
+    tasknumber = models.IntegerField(verbose_name='任务号')
     container = models.CharField(max_length=50, verbose_name='托盘号')
     current_location = models.CharField(max_length=50, verbose_name='当前库位')
     target_location = models.CharField(max_length=50, verbose_name='目标库位')
@@ -109,6 +110,7 @@ class ContainerWCSModel(models.Model):
             'target_location': self.target_location,
             'tasktype': self.tasktype,
             'taskid': self.taskid,
+            'taskNumber': self.tasknumber,
             'message': self.message,
             'container': self.container,
             'status': self.status

+ 2 - 0
container/views.py

@@ -268,6 +268,8 @@ class ContainerWCSViewSet(viewsets.ModelViewSet):
 
         data_tosave['taskid'] = f"inbound-{data_tosave['month']}-{new_id}"
         logger.info(f"生成入库任务: {data_tosave['taskid']}")
+        # 每月生成唯一递增的 taskNumber
+        data_tosave['tasknumber'] = f"{data_tosave['month']}{new_id}"
         ContainerWCSModel.objects.create(**data_tosave)
 
     @transaction.atomic

BIN
db.sqlite3


+ 2 - 0
logs/error.log

@@ -2258,3 +2258,5 @@ Traceback (most recent call last):
   File "d:\language\python38\lib\site-packages\django\middleware\common.py", line 88, in get_full_path_with_slash
     raise RuntimeError(
 RuntimeError: You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SLASH set. Django can't redirect to the slash URL while maintaining POST data. Change your form to point to 192.168.18.69:8008/container/container_wcs/ (note the trailing slash), or set APPEND_SLASH=False in your Django settings.
+[2025-04-15 10:20:36,698][django.request.log_response():241] [ERROR] Internal Server Error: /container/container_wcs/
+[2025-04-15 10:20:59,725][django.request.log_response():241] [ERROR] Internal Server Error: /container/container_wcs/

+ 2 - 0
logs/server.log

@@ -2480,3 +2480,5 @@ RuntimeError: You called this URL via POST, but the URL doesn't end in a slash a
 [2025-04-15 01:07:18,450][django.request.log_response():241] [WARNING] Not Found: /cyclecount/qtyrecorviewset/
 [2025-04-15 01:07:45,911][django.request.log_response():241] [WARNING] Not Found: /stock/list/
 [2025-04-15 01:07:48,094][django.request.log_response():241] [WARNING] Not Found: /cyclecount/manualcyclecount/
+[2025-04-15 10:20:36,698][django.request.log_response():241] [ERROR] Internal Server Error: /container/container_wcs/
+[2025-04-15 10:20:59,725][django.request.log_response():241] [ERROR] Internal Server Error: /container/container_wcs/