nes-num-old">
414
|
+ # if temperature > measure_info.temperature:
|
|
|
415
|
+ # measure_info.temperature = temperature
|
|
|
416
|
+ # measure_info.save()
|
|
|
417
|
+ #
|
|
|
418
|
+ # set_old_temperature(eqpt.point_id, macid, temperature)
|
|
|
419
|
+ #
|
|
|
420
|
+ # try:
|
|
|
421
|
+ # ipui = IsolationPointUserInfo.objects.get(pk=eqpt.ipui_pk)
|
|
|
422
|
+ # except IsolationPointUserInfo.DoesNotExist:
|
|
|
423
|
+ # ipui = None
|
|
|
424
|
+ # if ipui:
|
|
|
425
|
+ # ipui.observed_ymds = list(set(ipui.observed_ymds + [point_measure_ymd]))
|
|
|
426
|
+ # ipui.observed_days = len(ipui.observed_ymds)
|
|
|
427
|
+ # ipui.last_submit_at = tc.utc_datetime()
|
|
|
428
|
+ # ipui.save()
|
|
420
|
429
|
|
|
421
|
|
- try:
|
|
422
|
|
- ipui = IsolationPointUserInfo.objects.get(pk=eqpt.ipui_pk)
|
|
423
|
|
- except IsolationPointUserInfo.DoesNotExist:
|
|
424
|
|
- ipui = None
|
|
425
|
|
- if ipui:
|
|
426
|
|
- ipui.observed_ymds = list(set(ipui.observed_ymds + [point_measure_ymd]))
|
|
427
|
|
- ipui.observed_days = len(ipui.observed_ymds)
|
|
428
|
|
- ipui.last_submit_at = tc.utc_datetime()
|
|
429
|
|
- ipui.save()
|
|
|
430
|
+ try:
|
|
|
431
|
+ ipui = IsolationPointUserInfo.objects.get(pk=eqpt.ipui_pk)
|
|
|
432
|
+ except IsolationPointUserInfo.DoesNotExist:
|
|
|
433
|
+ ipui = None
|
|
|
434
|
+ if ipui:
|
|
|
435
|
+ temperature__max = ThermometerMeasureLogInfo.objects.filter(point_id=eqpt.point_id, macid=macid).aggregate(Max('temperature')).get('temperature__max') or 0
|
|
|
436
|
+ ipui.observed_ymds = list(set(ipui.observed_ymds + [tc.local_string(format='%Y-%m-%d')]))
|
|
|
437
|
+ ipui.observed_days = len(ipui.observed_ymds)
|
|
|
438
|
+ ipui.temperature = temperature__max
|
|
|
439
|
+ ipui.last_submit_at = tc.utc_datetime()
|
|
|
440
|
+ ipui.save()
|
|
430
|
441
|
|
|
431
|
442
|
set_screen_info(point.point_id, get_screen_data(point))
|
|
|
|
@@ -16,7 +16,7 @@ class IsolationPointInfoAdmin(admin.ModelAdmin):
|
|
16
|
16
|
|
|
17
|
17
|
|
|
18
|
18
|
class IsolationPointUserInfoAdmin(admin.ModelAdmin):
|
|
19
|
|
- list_display = ('point_id', 'user_id', 'fields', 'observed_days', 'last_submit_at', 'leave_at', 'status', 'updated_at', 'created_at')
|
|
|
19
|
+ list_display = ('point_id', 'user_id', 'fields', 'observed_days', 'temperature', 'last_submit_at', 'leave_at', 'status', 'updated_at', 'created_at')
|
|
20
|
20
|
|
|
21
|
21
|
|
|
22
|
22
|
class ThermometerEquipmentInfoAdmin(ReadOnlyModelAdmin, admin.ModelAdmin):
|
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+# Generated by Django 3.2.6 on 2021-08-17 09:56
|
|
|
2
|
+
|
|
|
3
|
+from django.db import migrations, models
|
|
|
4
|
+
|
|
|
5
|
+
|
|
|
6
|
+class Migration(migrations.Migration):
|
|
|
7
|
+
|
|
|
8
|
+ dependencies = [
|
|
|
9
|
+ ('equipment', '0012_auto_20210817_1727'),
|
|
|
10
|
+ ]
|
|
|
11
|
+
|
|
|
12
|
+ operations = [
|
|
|
13
|
+ migrations.AddField(
|
|
|
14
|
+ model_name='isolationpointuserinfo',
|
|
|
15
|
+ name='temperature',
|
|
|
16
|
+ field=models.FloatField(default=0, help_text='用户体温', verbose_name='temperature'),
|
|
|
17
|
+ ),
|
|
|
18
|
+ ]
|
|
|
|
@@ -145,6 +145,7 @@ class IsolationPointUserInfo(BaseModelMixin):
|
|
145
|
145
|
observed_ymds = JSONField(_('observed_ymds'), default=[], blank=True, null=True, help_text='已测温日期')
|
|
146
|
146
|
observed_days = models.IntegerField(_('observed_days'), default=0, help_text='已测温天数')
|
|
147
|
147
|
|
|
|
148
|
+ temperature = models.FloatField(_('temperature'), default=0, help_text='用户体温')
|
|
148
|
149
|
last_submit_at = models.DateTimeField(_('last_submit_at'), blank=True, null=True, help_text='上一次上报时间')
|
|
149
|
150
|
leave_at = models.DateTimeField(_('leave_at'), blank=True, null=True, help_text='离开时间')
|
|
150
|
151
|
|
|
|
|
@@ -163,6 +164,14 @@ class IsolationPointUserInfo(BaseModelMixin):
|
|
163
|
164
|
return self.pk
|
|
164
|
165
|
|
|
165
|
166
|
@property
|
|
|
167
|
+ def temperature_has_upload(self):
|
|
|
168
|
+ if not self.last_submit_at:
|
|
|
169
|
+ return '未上报'
|
|
|
170
|
+ if self.last_submit_at > tc.utc_datetime(hours=-1):
|
|
|
171
|
+ return '已上报'
|
|
|
172
|
+ return '未上报'
|
|
|
173
|
+
|
|
|
174
|
+ @property
|
|
166
|
175
|
def data(self):
|
|
167
|
176
|
return {
|
|
168
|
177
|
'pk': self.pk,
|
|
|
|
@@ -170,6 +179,8 @@ class IsolationPointUserInfo(BaseModelMixin):
|
|
170
|
179
|
'user_id': self.user_id,
|
|
171
|
180
|
'fields': self.fields,
|
|
172
|
181
|
'observed_days': self.observed_days,
|
|
|
182
|
+ 'temperature_has_upload': self.temperature_has_upload,
|
|
|
183
|
+ 'temperature': self.temperature,
|
|
173
|
184
|
'last_submit_at': tc.local_string(utc_dt=self.last_submit_at, format='%m-%d %H:%M') if self.last_submit_at else '',
|
|
174
|
185
|
'remark': self.remark,
|
|
175
|
186
|
}
|