Browse Source

修改序列号排查接口查询不同工位扫码记录

zhangdongming 1 year ago
parent
commit
088ae73bee
1 changed files with 16 additions and 3 deletions
  1. 16 3
      Controller/UserDevice/SerialNumberCheckController.py

+ 16 - 3
Controller/UserDevice/SerialNumberCheckController.py

@@ -61,13 +61,14 @@ class SerialNumberView(View):
         p_type = int(request_dict.get('type', 0))
         p_type = int(request_dict.get('type', 0))
         n_time = int(time.time())
         n_time = int(time.time())
         try:
         try:
-            dict_type = {'1': '三乡总装', '2': '三乡包装', '3': '三乡返工', '4': '三乡管理', '5': '珠海包装', '6': '珠海管理'}
+            dict_type = {'1': '三乡总装', '2': '三乡包装', '3': '三乡返工', '4': '三乡管理', '5': '珠海翻新', '6': '珠海管理'}
             first_serial = serial_no[:6]
             first_serial = serial_no[:6]
             # 查询当前工位是否扫过序列号
             # 查询当前工位是否扫过序列号
             first_serial_qs = SerialNumberCheckLog.objects.filter(serial_number=first_serial)
             first_serial_qs = SerialNumberCheckLog.objects.filter(serial_number=first_serial)
-            # 工位类型,1:三乡总装,2:三乡包装,3:三乡返工,4:三乡管理,5:珠海包装
+            # 工位类型,1:三乡总装,2:三乡包装,3:三乡返工,4:三乡管理,5:珠海翻新,6:珠海管理
             if p_type == 4 or p_type == 6:
             if p_type == 4 or p_type == 6:
-                first_serial_qs = first_serial_qs.filter(type=5) if p_type == 6 else first_serial_qs.exclude(type=5)
+                first_serial_qs = first_serial_qs.filter(type__in=[2, 5]) if p_type == 6 \
+                    else first_serial_qs.exclude(type=5)
                 first_serial_qs = first_serial_qs.order_by('type', '-created_time')
                 first_serial_qs = first_serial_qs.order_by('type', '-created_time')
                 if not first_serial_qs.exists():
                 if not first_serial_qs.exists():
                     return response.json(173)
                     return response.json(173)
@@ -98,6 +99,18 @@ class SerialNumberView(View):
                 params = {'serial_number': first_serial, 'created_time': n_time,
                 params = {'serial_number': first_serial, 'created_time': n_time,
                           'full_serial_number': serial_no, 'type': p_type, 'phone_model': phone_model}
                           'full_serial_number': serial_no, 'type': p_type, 'phone_model': phone_model}
                 SerialNumberCheckLog.objects.create(**params)
                 SerialNumberCheckLog.objects.create(**params)
+                # 珠海翻新查询三乡包装扫码记录超过2次则提示异常
+                if p_type == 5:
+                    s_qs = SerialNumberCheckLog.objects.filter(serial_number=first_serial, type=2)
+                    if s_qs.count() >= 2:
+                        # 返回当前序列号数据结构
+                        log_dict = {'fullSerialNumber': s_qs[0].full_serial_number,
+                                    'count': s_qs[0].count, 'type': s_qs[0].type,
+                                    'createdTime': s_qs[0].created_time,
+                                    'stationName': dict_type[str(s_qs[0].type)],
+                                    'phoneModel': s_qs[0].phone_model}
+                        result = {'logs': [log_dict]}
+                        return response.json(174, result)
                 return response.json(0)
                 return response.json(0)
         except Exception as e:
         except Exception as e:
             LOGGER.error('APP扫码工具保存日志异常:errLine:{}, errMsg:{}'
             LOGGER.error('APP扫码工具保存日志异常:errLine:{}, errMsg:{}'