Browse Source

客流统计增加通道号、修改获取时间戳接口

zhangdongming 1 year ago
parent
commit
2a70aab7e1

+ 11 - 9
Controller/AlgorithmShop/AlgorithmShopController.py

@@ -80,17 +80,18 @@ class AlgorithmShopView(View):
             if not uid:
                 return response.json(444)
 
-            d_time = request_dict.get('deviceTime')
-            enter_count = request_dict.get('enterCount')
-            tz_value = request_dict.get('timeZone')
-            exit_count = request_dict.get('exitCount')
+            d_time = request_dict.get('deviceTime')  # 设备上报时间的
+            enter_count = request_dict.get('enterCount')  # 进 统计
+            tz_value = request_dict.get('timeZone')  # 时区
+            exit_count = request_dict.get('exitCount')  # 出 统计
+            channel = int(request_dict.get('channel', '1'))  # 设备通道号
 
             if not all([sign, enter_count, exit_count, tz_value]):
                 return response.json(444)
             enter_count = int(enter_count)
             exit_count = int(exit_count)
             redis = RedisObject(5)
-            key = f'ASJ:PASSENGER:FLOW:{uid}:{d_time}'
+            key = f'ASJ:PASSENGER:FLOW:{uid}:{channel}:{d_time}'
 
             # 检查Redis中是否已存在相同key的数据
             r_data = redis.get_data(key)
@@ -102,19 +103,20 @@ class AlgorithmShopView(View):
                 'uid': uid,
                 'updated_time': now_time,
                 'created_time': now_time,
-                'device_time': int(d_time)
+                'device_time': int(d_time),
+                'channel': channel
             }
 
             tz = TimeZone.get_value(int(tz_value))
             date_time = LocalDateTimeUtil.time_format_date(int(d_time), tz)
             data['statistical_time'] = datetime.strptime(date_time, '%Y-%m-%d %H:%M:%S')
 
-            LOGGER.info(f'uid{uid}-DeviceTime:{d_time},tz:{tz},结果:{date_time}')
+            LOGGER.info(f'uid{uid},channel:{channel},DeviceTime:{d_time},tz:{tz},结果:{date_time}')
             passenger_flow_list = []
-            data['count'] = enter_count
+            data['count'] = enter_count  # 进
             data['type'] = 1
             passenger_flow_list.append(DeviceAlgorithmPassengerFlow(**data))
-            data['count'] = exit_count
+            data['count'] = exit_count  # 出
             data['type'] = 2
             passenger_flow_list.append(DeviceAlgorithmPassengerFlow(**data))
             DeviceAlgorithmPassengerFlow.objects.bulk_create(passenger_flow_list)

+ 1 - 1
Controller/UnicomCombo/UnicomComboController.py

@@ -71,7 +71,7 @@ class UnicomComboView(View):
             return self.update_device_card_type(request_dict, response)
         elif operation == 'xxx-sign':  # 获取签名用于测试
             return self.get_test_sign(request_dict, response)
-        elif operation == 'gettimestamp':
+        elif operation == 'getTimestamp':
             return self.get_test_sign(request_dict, response)
         elif operation == 'getSimBySerialNumber':
             return self.get_sim_by_serial_number(request_dict, response)

+ 1 - 0
Model/models.py

@@ -3530,6 +3530,7 @@ class DeviceAlgorithmPassengerFlow(models.Model):
     count = models.IntegerField(default=0, verbose_name='当前时段统计数量')
     statistical_time = models.DateTimeField(blank=True, null=True, verbose_name=u'统计日期时间')
     device_time = models.IntegerField(default=0, verbose_name='设备上报时间戳')
+    channel = models.IntegerField(default=1, blank=True, verbose_name=u'设备通道')
     updated_time = models.IntegerField(default=0, verbose_name='更新时间')
     created_time = models.IntegerField(default=0, verbose_name='创建时间')