Pārlūkot izejas kodu

优化产品出货制作方案代码

zhangdongming 1 dienu atpakaļ
vecāks
revīzija
917a3e21e8
2 mainītis faili ar 26 papildinājumiem un 8 dzēšanām
  1. 22 8
      AdminController/ProductsSchemeManageController.py
  2. 4 0
      Model/models.py

+ 22 - 8
AdminController/ProductsSchemeManageController.py

@@ -174,6 +174,7 @@ class ProductsSchemeManageView(View):
                 'storage_code': storage_code,  # 使用生成的编码
                 'order_number': request_dict.get('orderNumber', ''),
                 'device_type': device_type,
+                'product_model': int(request_dict.get('productModel', 0)),
                 'flash': request_dict.get('flash', ''),
                 'ddr': request_dict.get('ddr', ''),
                 'main_controller': request_dict.get('mainController', ''),
@@ -185,6 +186,9 @@ class ProductsSchemeManageView(View):
                 'customer_code': request_dict.get('customerCode', ''),
                 'phy': request_dict.get('phy', ''),
                 'remark': request_dict.get('remark', ''),
+                'sku': request_dict.get('sku', ''),
+                'scheme_code': request_dict.get('schemeCode', ''),
+                'hw_version':request_dict.get('hwVersion', ''),
                 'created_time': int(time.time()),
                 'updated_time': int(time.time()),
                 'created_by': user_id,
@@ -221,13 +225,18 @@ class ProductsSchemeManageView(View):
         'orderQuantity': 'order_quantity',
         'customerCode': 'customer_code',
         'phy': 'phy',
-        'remark': 'remark'
+        'remark': 'remark',
+        'sku': 'sku',
+        'schemeCode': 'scheme_code',
+        'productModel': 'product_model',
+        'hwVersion':'hw_version'
     }
 
     # 需要类型转换的字段配置(字段名: 转换函数)
     FIELD_CONVERTERS = {
         'deviceType': int,
-        'orderQuantity': int
+        'orderQuantity': int,
+        'productModel': int
     }
 
     @transaction.atomic
@@ -338,8 +347,8 @@ class ProductsSchemeManageView(View):
         """方案对象序列化(优化点:集中管理序列化逻辑)"""
         # 定义需要包含在str_schema中的字段
         schema_fields = [
-            'flash', 'main_controller', 'wifi', 'four_g',
-            'sensor', 'ddr', 'ad', 'phy'
+            'order_number','hw_version', 'main_controller', 'sensor', 'ad', 'wifi', 'four_g',
+            'flash', 'ddr', 'phy'
         ]
 
         # 获取字段值,过滤掉空值
@@ -366,6 +375,10 @@ class ProductsSchemeManageView(View):
             'phy': scheme.phy,
             'remark': scheme.remark,
             'strSchema': str_schema,
+            'productModel': scheme.product_model,
+            'sku': scheme.sku,
+            'schemeCode': scheme.scheme_code,
+            'hwVersion': scheme.hw_version,
             'createdTime': scheme.created_time,
             'createdBy': scheme.created_by
         }
@@ -388,13 +401,14 @@ class ProductsSchemeManageView(View):
             qr_data = json.dumps({
                 "sc": scheme.storage_code,
                 "t": 'NVR' if scheme.device_type == 1 else 'IPC',
-                "f": scheme.flash,
-                "ddr": scheme.ddr,
+                "hw": scheme.hw_version,
                 "mc": scheme.main_controller,
+                "s": scheme.sensor,
+                "ad": scheme.ad,
                 "wifi": scheme.wifi,
                 "mode4G": scheme.four_g,
-                "ad": scheme.ad,
-                "s": scheme.sensor,
+                "f": scheme.flash,
+                "ddr": scheme.ddr,
                 'uc': scheme.customer_code,
                 'phy': scheme.phy,
                 "num": scheme.order_quantity,

+ 4 - 0
Model/models.py

@@ -5697,6 +5697,7 @@ class ProductsScheme(models.Model):
     storage_code = models.CharField(max_length=50, unique=True, verbose_name='入库编码')
     # 1是NVR 2是IPC
     device_type = models.SmallIntegerField(default=0, verbose_name='设备大类')
+    product_model = models.SmallIntegerField(default=0, verbose_name='产品型号')
     flash = models.CharField(max_length=50, verbose_name='闪存', blank=True)
     ddr = models.CharField(max_length=50, verbose_name='DDR', blank=True)
     main_controller = models.CharField(max_length=50, verbose_name='主控', blank=True)
@@ -5708,6 +5709,9 @@ class ProductsScheme(models.Model):
     customer_code = models.CharField(max_length=100, verbose_name='客户代码', blank=True)
     phy = models.CharField(max_length=100, verbose_name='物理层器件', blank=True)
     remark = models.TextField(blank=True, verbose_name="备注")
+    sku = models.CharField(max_length=50, verbose_name='128', blank=True)
+    scheme_code = models.CharField(max_length=50, verbose_name='方案代码', blank=True)
+    hw_version = models.CharField(max_length=50, verbose_name='硬件版本号', blank=True)
     created_time = models.IntegerField(default=0, verbose_name='创建时间')
     created_by = models.CharField(max_length=64, verbose_name='创建人')
     updated_time = models.IntegerField(default=0, verbose_name='更新时间')