4e8f87b3f5b8abfb4d5b4decL297">297
306
|
|
|
298
|
307
|
@logit
|
|
299
|
308
|
def upload_temperature(request):
|
|
300
|
|
- request.POST = request.POST or json.loads(request.body)
|
|
301
|
|
- macid = request.POST.get('mac', '')
|
|
302
|
|
- name = request.POST.get('name', '')
|
|
303
|
|
- sex = request.POST.get('gender', 0)
|
|
304
|
|
- birth_stamp = request.POST.get('birthday', 0)
|
|
305
|
|
- age = request.POST.get('age', 0)
|
|
306
|
|
- phone = request.POST.get('mobile', '')
|
|
307
|
|
- start_stamp = request.POST.get('startTime', 0)
|
|
308
|
|
- end_stamp = request.POST.get('endTime', 0)
|
|
309
|
|
- temperature = round(float(request.POST.get('maxTempValue', 0)), 2)
|
|
310
|
|
-
|
|
311
|
|
- try:
|
|
312
|
|
- eqpt = ThermometerEquipmentInfo.objects.get(macid=macid, status=True)
|
|
313
|
|
- except ThermometerEquipmentInfo.DoesNotExist:
|
|
314
|
|
- ThermometerMeasureLogInfo.objects.create(macid=macid, name=name, sex=sex, birth_stamp=birth_stamp, phone=phone, start_stamp=start_stamp, end_stamp=end_stamp, temperature=temperature, upload_temperature_info=request.POST, status=False)
|
|
315
|
|
- return response(ThermometerEquipmentStatusCode.THERMOMETER_EQUIPMENT_NOT_FOUND)
|
|
316
|
|
-
|
|
317
|
|
- try:
|
|
318
|
|
- point = IsolationPointInfo.objects.get(point_id=eqpt.point_id, status=True)
|
|
319
|
|
- except IsolationPointInfo.DoesNotExist:
|
|
320
|
|
- return response(IsolationPointStatusCode.ISOLATIONPOINT_NOT_FOUND)
|
|
321
|
|
-
|
|
322
|
|
- point_measure_ymd = tc.local_string(format='%Y-%m-%d')
|
|
323
|
|
- point_measure_window = point.current_measure_window
|
|
324
|
|
-
|
|
325
|
|
- eqpt.name = name
|
|
326
|
|
- eqpt.sex = sex
|
|
327
|
|
- eqpt.birth_stamp = birth_stamp
|
|
328
|
|
- eqpt.age = stamp2age(birth_stamp)
|
|
329
|
|
- eqpt.phone = phone
|
|
330
|
|
- eqpt.last_submit_at = tc.utc_datetime()
|
|
331
|
|
- eqpt.save()
|
|
332
|
|
-
|
|
333
|
|
- ThermometerMeasureLogInfo.objects.create(point_id=eqpt.point_id, macid=macid, name=name, sex=sex, birth_stamp=birth_stamp, phone=phone, start_stamp=start_stamp, end_stamp=end_stamp, temperature=temperature, upload_temperature_info=request.POST)
|
|
334
|
|
-
|
|
335
|
|
- if point_measure_window:
|
|
336
|
|
- measure_info, _ = ThermometerMeasureInfo.objects.get_or_create(point_id=eqpt.point_id, point_measure_ymd=point_measure_ymd, point_measure_window=point_measure_window, macid=macid, defaults={
|
|
337
|
|
- 'temperature': temperature,
|
|
338
|
|
- })
|
|
339
|
|
- if temperature > measure_info.temperature:
|
|
340
|
|
- measure_info.temperature = temperature
|
|
341
|
|
- measure_info.save()
|
|
|
309
|
+ # request.POST = request.POST or json.loads(request.body)
|
|
|
310
|
+ # macid = request.POST.get('mac', '')
|
|
|
311
|
+ # name = request.POST.get('name', '')
|
|
|
312
|
+ # sex = request.POST.get('gender', 0)
|
|
|
313
|
+ # birth_stamp = request.POST.get('birthday', 0)
|
|
|
314
|
+ # age = request.POST.get('age', 0)
|
|
|
315
|
+ # phone = request.POST.get('mobile', '')
|
|
|
316
|
+ # start_stamp = request.POST.get('startTime', 0)
|
|
|
317
|
+ # end_stamp = request.POST.get('endTime', 0)
|
|
|
318
|
+ # temperature = round(float(request.POST.get('maxTempValue', 0)), 2)
|
|
|
319
|
+ #
|
|
|
320
|
+ # try:
|
|
|
321
|
+ # eqpt = ThermometerEquipmentInfo.objects.get(macid=macid, status=True)
|
|
|
322
|
+ # except ThermometerEquipmentInfo.DoesNotExist:
|
|
|
323
|
+ # ThermometerMeasureLogInfo.objects.create(macid=macid, name=name, sex=sex, birth_stamp=birth_stamp, phone=phone, start_stamp=start_stamp, end_stamp=end_stamp, temperature=temperature, upload_temperature_info=request.POST, status=False)
|
|
|
324
|
+ # return response(ThermometerEquipmentStatusCode.THERMOMETER_EQUIPMENT_NOT_FOUND)
|
|
|
325
|
+ #
|
|
|
326
|
+ # try:
|
|
|
327
|
+ # point = IsolationPointInfo.objects.get(point_id=eqpt.point_id, status=True)
|
|
|
328
|
+ # except IsolationPointInfo.DoesNotExist:
|
|
|
329
|
+ # return response(IsolationPointStatusCode.ISOLATIONPOINT_NOT_FOUND)
|
|
|
330
|
+ #
|
|
|
331
|
+ # point_measure_ymd = tc.local_string(format='%Y-%m-%d')
|
|
|
332
|
+ # point_measure_window = point.current_measure_window
|
|
|
333
|
+ #
|
|
|
334
|
+ # eqpt.name = name
|
|
|
335
|
+ # eqpt.sex = sex
|
|
|
336
|
+ # eqpt.birth_stamp = birth_stamp
|
|
|
337
|
+ # eqpt.age = stamp2age(birth_stamp)
|
|
|
338
|
+ # eqpt.phone = phone
|
|
|
339
|
+ # eqpt.last_submit_at = tc.utc_datetime()
|
|
|
340
|
+ # eqpt.save()
|
|
|
341
|
+ #
|
|
|
342
|
+ # ThermometerMeasureLogInfo.objects.create(point_id=eqpt.point_id, macid=macid, name=name, sex=sex, birth_stamp=birth_stamp, phone=phone, start_stamp=start_stamp, end_stamp=end_stamp, temperature=temperature, upload_temperature_info=request.POST)
|
|
|
343
|
+ #
|
|
|
344
|
+ # if point_measure_window:
|
|
|
345
|
+ # measure_info, _ = ThermometerMeasureInfo.objects.get_or_create(point_id=eqpt.point_id, point_measure_ymd=point_measure_ymd, point_measure_window=point_measure_window, macid=macid, defaults={
|
|
|
346
|
+ # 'temperature': temperature,
|
|
|
347
|
+ # })
|
|
|
348
|
+ # if temperature > measure_info.temperature:
|
|
|
349
|
+ # measure_info.temperature = temperature
|
|
|
350
|
+ # measure_info.save()
|
|
342
|
351
|
|
|
343
|
352
|
return response()
|
|
344
|
353
|
|
|
|
|
@@ -416,6 +425,7 @@ def mqtt_upload_temperature(payload):
|
|
416
|
425
|
if ipui:
|
|
417
|
426
|
ipui.observed_ymds = list(set(ipui.observed_ymds + [point_measure_ymd]))
|
|
418
|
427
|
ipui.observed_days = len(ipui.observed_ymds)
|
|
|
428
|
+ ipui.last_submit_at = tc.utc_datetime()
|
|
419
|
429
|
ipui.save()
|
|
420
|
430
|
|
|
421
|
431
|
set_screen_info(point.point_id, get_screen_data(point))
|
|
|
|
@@ -57,8 +57,8 @@ def get_point_info(request):
|
|
57
|
57
|
|
|
58
|
58
|
@logit
|
|
59
|
59
|
def get_point_fields(request):
|
|
60
|
|
- user_id = request.POST.get('user_id', '')
|
|
61
|
60
|
point_id = request.POST.get('point_id', '')
|
|
|
61
|
+ user_id = request.POST.get('user_id', '')
|
|
62
|
62
|
|
|
63
|
63
|
try:
|
|
64
|
64
|
point = IsolationPointInfo.objects.get(point_id=point_id, status=True)
|
|
|
|
@@ -66,15 +66,14 @@ def get_point_fields(request):
|
|
66
|
66
|
return response(IsolationPointStatusCode.ISOLATIONPOINT_NOT_FOUND)
|
|
67
|
67
|
|
|
68
|
68
|
try:
|
|
69
|
|
- user_info = IsolationPointUserInfo.objects.get(user_id=user_id, point_id=point_id, status=True)
|
|
70
|
|
- user_info = user_info.fields
|
|
|
69
|
+ ipui = IsolationPointUserInfo.objects.get(user_id=user_id, point_id=point_id, status=True)
|
|
71
|
70
|
except IsolationPointUserInfo.DoesNotExist:
|
|
72
|
|
- user_info = []
|
|
|
71
|
+ ipui = None
|
|
73
|
72
|
|
|
74
|
73
|
return response(data={
|
|
75
|
74
|
'point_name': point.point_name,
|
|
76
|
75
|
'fields': point.point_fields,
|
|
77
|
|
- 'user_info': user_info,
|
|
|
76
|
+ 'user_info': ipui.fields if ipui else [],
|
|
78
|
77
|
})
|
|
79
|
78
|
|
|
80
|
79
|
|
|
|
|
@@ -16,11 +16,11 @@ class IsolationPointInfoAdmin(admin.ModelAdmin):
|
|
16
|
16
|
|
|
17
|
17
|
|
|
18
|
18
|
class IsolationPointUserInfoAdmin(admin.ModelAdmin):
|
|
19
|
|
- list_display = ('point_id', 'user_id', 'fields', 'observed_days', 'leave_at', 'status', 'updated_at', 'created_at')
|
|
|
19
|
+ list_display = ('point_id', 'user_id', 'fields', 'observed_days', 'last_submit_at', 'leave_at', 'status', 'updated_at', 'created_at')
|
|
20
|
20
|
|
|
21
|
21
|
|
|
22
|
22
|
class ThermometerEquipmentInfoAdmin(ReadOnlyModelAdmin, admin.ModelAdmin):
|
|
23
|
|
- list_display = ('eqpt_id', 'point_id', 'macid', 'sn', 'active_status', 'active_at', 'ipui_pk', 'name', 'sex', 'birth_stamp', 'age', 'phone', 'remark', 'last_submit_at', 'eqpt_register_status', 'eqpt_register_result', 'status', 'updated_at', 'created_at')
|
|
|
23
|
+ list_display = ('eqpt_id', 'point_id', 'macid', 'sn', 'active_status', 'active_at', 'ipui_pk', 'name', 'sex', 'birth_stamp', 'age', 'phone', 'status', 'updated_at', 'created_at')
|
|
24
|
24
|
list_filter = ('point_id', 'status')
|
|
25
|
25
|
|
|
26
|
26
|
|
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+# Generated by Django 3.2.6 on 2021-08-17 09:27
|
|
|
2
|
+
|
|
|
3
|
+from django.db import migrations, models
|
|
|
4
|
+import jsonfield.fields
|
|
|
5
|
+
|
|
|
6
|
+
|
|
|
7
|
+class Migration(migrations.Migration):
|
|
|
8
|
+
|
|
|
9
|
+ dependencies = [
|
|
|
10
|
+ ('equipment', '0011_isolationpointuserinfo_observed_ymds'),
|
|
|
11
|
+ ]
|
|
|
12
|
+
|
|
|
13
|
+ operations = [
|
|
|
14
|
+ migrations.AddField(
|
|
|
15
|
+ model_name='isolationpointuserinfo',
|
|
|
16
|
+ name='last_submit_at',
|
|
|
17
|
+ field=models.DateTimeField(blank=True, help_text='上一次上报时间', null=True, verbose_name='last_submit_at'),
|
|
|
18
|
+ ),
|
|
|
19
|
+ migrations.AddField(
|
|
|
20
|
+ model_name='isolationpointuserinfo',
|
|
|
21
|
+ name='remarks',
|
|
|
22
|
+ field=jsonfield.fields.JSONField(blank=True, default=[], help_text='备注', null=True, verbose_name='remarks'),
|
|
|
23
|
+ ),
|
|
|
24
|
+ migrations.AlterField(
|
|
|
25
|
+ model_name='isolationpointuserinfo',
|
|
|
26
|
+ name='remark',
|
|
|
27
|
+ field=models.CharField(blank=True, help_text='备注', max_length=255, null=True, verbose_name='remark'),
|
|
|
28
|
+ ),
|
|
|
29
|
+ ]
|
|
|
|
@@ -144,9 +144,12 @@ class IsolationPointUserInfo(BaseModelMixin):
|
|
144
|
144
|
|
|
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
|
+
|
|
|
148
|
+ last_submit_at = models.DateTimeField(_('last_submit_at'), blank=True, null=True, help_text='上一次上报时间')
|
|
147
|
149
|
leave_at = models.DateTimeField(_('leave_at'), blank=True, null=True, help_text='离开时间')
|
|
148
|
150
|
|
|
149
|
|
- remark = JSONField(_('remark'), default=[], blank=True, null=True, help_text='备注')
|
|
|
151
|
+ remark = models.CharField(_('remark'), max_length=255, blank=True, null=True, help_text='备注')
|
|
|
152
|
+ remarks = JSONField(_('remarks'), default=[], blank=True, null=True, help_text='备注')
|
|
150
|
153
|
|
|
151
|
154
|
class Meta:
|
|
152
|
155
|
verbose_name = _('隔离点用户录入信息')
|
|
|
|
@@ -162,9 +165,13 @@ class IsolationPointUserInfo(BaseModelMixin):
|
|
162
|
165
|
@property
|
|
163
|
166
|
def data(self):
|
|
164
|
167
|
return {
|
|
|
168
|
+ 'pk': self.pk,
|
|
165
|
169
|
'point_id': self.point_id,
|
|
166
|
170
|
'user_id': self.user_id,
|
|
167
|
171
|
'fields': self.fields,
|
|
|
172
|
+ 'observed_days': self.observed_days,
|
|
|
173
|
+ 'last_submit_at': tc.local_string(utc_dt=self.last_submit_at, format='%m-%d %H:%M') if self.last_submit_at else '',
|
|
|
174
|
+ 'remark': self.remark,
|
|
168
|
175
|
}
|
|
169
|
176
|
|
|
170
|
177
|
|
|
|
|
@@ -241,7 +248,7 @@ class ThermometerEquipmentInfo(BaseModelMixin):
|
|
241
|
248
|
'age': self.age or '',
|
|
242
|
249
|
'phone': self.phone or '',
|
|
243
|
250
|
'remark': self.remark or '',
|
|
244
|
|
- 'last_submit_at': tc.local_string(utc_dt=self.last_submit_at),
|
|
|
251
|
+ 'last_submit_at': tc.local_string(utc_dt=self.last_submit_at) if self.last_submit_at else '',
|
|
245
|
252
|
'eqpt_register_status': self.eqpt_register_status,
|
|
246
|
253
|
'eqpt_register_status_str': dict(self.REGISTER_STATUE_TUPLE).get(self.eqpt_register_status, ''),
|
|
247
|
254
|
'eqpt_register_result': self.eqpt_register_result,
|
|
|
|
@@ -254,7 +261,7 @@ class ThermometerEquipmentInfo(BaseModelMixin):
|
|
254
|
261
|
'point_id': self.point_id,
|
|
255
|
262
|
'macid': self.macid,
|
|
256
|
263
|
'remark': self.remark,
|
|
257
|
|
- 'last_submit_at': tc.local_string(utc_dt=self.last_submit_at, format='%m-%d %H:%M'),
|
|
|
264
|
+ 'last_submit_at': tc.local_string(utc_dt=self.last_submit_at, format='%m-%d %H:%M') if self.last_submit_at else '',
|
|
258
|
265
|
}
|
|
259
|
266
|
|
|
260
|
267
|
|