|
@@ -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)
|