|
@@ -9,6 +9,8 @@
|
|
|
import datetime
|
|
|
import time
|
|
|
|
|
|
+from django.db.models import Value, CharField
|
|
|
+
|
|
|
from Model.models import EquipmentInfoMonday, EquipmentInfoTuesday, EquipmentInfoWednesday, EquipmentInfoThursday, \
|
|
|
EquipmentInfoFriday, EquipmentInfoSaturday, EquipmentInfoSunday
|
|
|
from Object.utils import LocalDateTimeUtil
|
|
@@ -38,19 +40,19 @@ class EquipmentInfoService:
|
|
|
week = val
|
|
|
equipment_info = None
|
|
|
if week == 1:
|
|
|
- equipment_info = EquipmentInfoMonday.objects.all()
|
|
|
+ equipment_info = EquipmentInfoMonday.objects.all().annotate(tab_val=Value('1', output_field=CharField()))
|
|
|
elif week == 2:
|
|
|
- equipment_info = EquipmentInfoTuesday.objects.all()
|
|
|
+ equipment_info = EquipmentInfoTuesday.objects.all().annotate(tab_val=Value('2', output_field=CharField()))
|
|
|
elif week == 3:
|
|
|
- equipment_info = EquipmentInfoWednesday.objects.all()
|
|
|
+ equipment_info = EquipmentInfoWednesday.objects.all().annotate(tab_val=Value('3', output_field=CharField()))
|
|
|
elif week == 4:
|
|
|
- equipment_info = EquipmentInfoThursday.objects.all()
|
|
|
+ equipment_info = EquipmentInfoThursday.objects.all().annotate(tab_val=Value('4', output_field=CharField()))
|
|
|
elif week == 5:
|
|
|
- equipment_info = EquipmentInfoFriday.objects.all()
|
|
|
+ equipment_info = EquipmentInfoFriday.objects.all().annotate(tab_val=Value('5', output_field=CharField()))
|
|
|
elif week == 6:
|
|
|
- equipment_info = EquipmentInfoSaturday.objects.all()
|
|
|
+ equipment_info = EquipmentInfoSaturday.objects.all().annotate(tab_val=Value('6', output_field=CharField()))
|
|
|
elif week == 7:
|
|
|
- equipment_info = EquipmentInfoSunday.objects.all()
|
|
|
+ equipment_info = EquipmentInfoSunday.objects.all().annotate(tab_val=Value('7', output_field=CharField()))
|
|
|
return equipment_info
|
|
|
|
|
|
@classmethod
|
|
@@ -189,14 +191,16 @@ class EquipmentInfoService:
|
|
|
equipment_info_qs = equipment_info_qs.values('id', 'device_uid', 'device_nick_name', 'channel', 'event_type',
|
|
|
'status', 'alarm',
|
|
|
'event_time', 'receive_time', 'is_st', 'add_time',
|
|
|
- 'storage_location', 'border_coords')
|
|
|
+ 'storage_location', 'border_coords', 'tab_val')
|
|
|
|
|
|
equipment_info_qs = equipment_info_qs.order_by('-event_time')
|
|
|
qs_page = equipment_info_qs[(page - 1) * size:page * size]
|
|
|
if qs_page and len(qs_page) > 0:
|
|
|
for item in qs_page:
|
|
|
- event_time = item['event_time']
|
|
|
- item['id'] = int(str(event_time) + str(item['id']))
|
|
|
+ # 星期表值
|
|
|
+ tab_val = item['tab_val']
|
|
|
+ # id = 星期表值+id
|
|
|
+ item['id'] = int(tab_val + str(item['id']))
|
|
|
item['devUid'] = item['device_uid']
|
|
|
item['devNickName'] = item['device_nick_name']
|
|
|
item['Channel'] = item['channel']
|
|
@@ -213,4 +217,5 @@ class EquipmentInfoService:
|
|
|
item.pop('receive_time')
|
|
|
item.pop('add_time')
|
|
|
item.pop('border_coords')
|
|
|
+ item.pop('tab_val')
|
|
|
return qs_page
|