@@ -17,6 +17,7 @@ from equipment.models import (IsolationPointInfo, IsolationPointUserInfo, Thermo |
||
| 17 | 17 |
ThermometerMeasureInfo, ThermometerMeasureLogInfo) |
| 18 | 18 |
from utils.age import stamp2age |
| 19 | 19 |
from utils.error.errno_utils import IsolationPointStatusCode, ThermometerEquipmentStatusCode |
| 20 |
+from utils.redis.rscreen import get_screen_info, set_screen_info |
|
| 20 | 21 |
|
| 21 | 22 |
|
| 22 | 23 |
@logit |
@@ -174,16 +175,14 @@ def eqpt_result(request): |
||
| 174 | 175 |
}) |
| 175 | 176 |
|
| 176 | 177 |
|
| 177 |
-@logit |
|
| 178 |
-def screen_eqpt_result(request): |
|
| 179 |
- point_id = request.POST.get('point_id', '')
|
|
| 180 |
- |
|
| 181 |
- try: |
|
| 182 |
- point = IsolationPointInfo.objects.get(point_id=point_id, status=True) |
|
| 183 |
- except IsolationPointInfo.DoesNotExist: |
|
| 184 |
- return response(IsolationPointStatusCode.ISOLATIONPOINT_NOT_FOUND) |
|
| 178 |
+def get_screen_data(point=None, point_id=None): |
|
| 179 |
+ if not point: |
|
| 180 |
+ try: |
|
| 181 |
+ point = IsolationPointInfo.objects.get(point_id=point_id, status=True) |
|
| 182 |
+ except IsolationPointInfo.DoesNotExist: |
|
| 183 |
+ return {}
|
|
| 185 | 184 |
|
| 186 |
- eqpts = ThermometerEquipmentInfo.objects.filter(point_id=point_id, active_status=ThermometerEquipmentInfo.ONLINE, status=True) |
|
| 185 |
+ eqpts = ThermometerEquipmentInfo.objects.filter(point_id=point.point_id, active_status=ThermometerEquipmentInfo.ONLINE, status=True) |
|
| 187 | 186 |
macids = eqpts.values_list('macid', flat=True)
|
| 188 | 187 |
|
| 189 | 188 |
logs = ThermometerMeasureInfo.objects.filter( |
@@ -195,7 +194,7 @@ def screen_eqpt_result(request): |
||
| 195 | 194 |
).values('macid', 'temperature')
|
| 196 | 195 |
logs = {log.get('macid'): log.get('temperature') for log in logs}
|
| 197 | 196 |
|
| 198 |
- infos = IsolationPointUserInfo.objects.filter(point_id=point_id, status=True).values('pk', 'fields')
|
|
| 197 |
+ infos = IsolationPointUserInfo.objects.filter(point_id=point.point_id, status=True).values('pk', 'fields')
|
|
| 199 | 198 |
infos = {info.get('pk'): info.get('fields') for info in infos}
|
| 200 | 199 |
|
| 201 | 200 |
total_active_eqpt_num = eqpts.count() |
@@ -234,14 +233,34 @@ def screen_eqpt_result(request): |
||
| 234 | 233 |
'observed_days': 1, |
| 235 | 234 |
} for eqpt in eqpts] |
| 236 | 235 |
|
| 237 |
- return response(data={
|
|
| 236 |
+ return {
|
|
| 238 | 237 |
'eqpts': eqpts, |
| 239 | 238 |
'reminds': reminds, |
| 240 | 239 |
'total_active_eqpt_num': total_active_eqpt_num, |
| 241 | 240 |
'has_upload_temperature_num': has_upload_temperature_num, |
| 242 | 241 |
'not_upload_temperature_num': total_active_eqpt_num - has_upload_temperature_num, |
| 243 | 242 |
'fever_num': fever_num, |
| 244 |
- }) |
|
| 243 |
+ 'update_time': tc.local_string(), |
|
| 244 |
+ } |
|
| 245 |
+ |
|
| 246 |
+ |
|
| 247 |
+@logit |
|
| 248 |
+def screen_eqpt_result(request): |
|
| 249 |
+ point_id = request.POST.get('point_id', '')
|
|
| 250 |
+ |
|
| 251 |
+ screen_info = get_screen_info(point_id) |
|
| 252 |
+ |
|
| 253 |
+ if screen_info: |
|
| 254 |
+ return response(data=screen_info) |
|
| 255 |
+ |
|
| 256 |
+ try: |
|
| 257 |
+ point = IsolationPointInfo.objects.get(point_id=point_id, status=True) |
|
| 258 |
+ except IsolationPointInfo.DoesNotExist: |
|
| 259 |
+ return response(IsolationPointStatusCode.ISOLATIONPOINT_NOT_FOUND) |
|
| 260 |
+ |
|
| 261 |
+ screen_data = get_screen_data(point) |
|
| 262 |
+ |
|
| 263 |
+ return response(data=screen_data) |
|
| 245 | 264 |
|
| 246 | 265 |
|
| 247 | 266 |
@logit |
@@ -355,3 +374,5 @@ def mqtt_upload_temperature(payload): |
||
| 355 | 374 |
if temperature > measure_info.temperature: |
| 356 | 375 |
measure_info.temperature = temperature |
| 357 | 376 |
measure_info.save() |
| 377 |
+ |
|
| 378 |
+ set_screen_info(point.point_id, get_screen_data(point)) |
@@ -2,3 +2,4 @@ |
||
| 2 | 2 |
|
| 3 | 3 |
HY_QRCODE_URL_HASH = 'twjc:qrcode:url:hash' # scene:qrcode_url |
| 4 | 4 |
TWJC_POINT_INFO = 'twjc:point:info:%s' # uuid:point_id |
| 5 |
+TWJC_SCREEN_INFO = 'twjc:screen:info:%s' # point_id:screen_info |
@@ -0,0 +1,12 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+ |
|
| 3 |
+from utils.redis.connect import r |
|
| 4 |
+from utils.redis.rkeys import TWJC_SCREEN_INFO |
|
| 5 |
+ |
|
| 6 |
+ |
|
| 7 |
+def set_screen_info(point_id, screen_info): |
|
| 8 |
+ r.setjson(TWJC_SCREEN_INFO % point_id, screen_info) |
|
| 9 |
+ |
|
| 10 |
+ |
|
| 11 |
+def get_screen_info(point_id): |
|
| 12 |
+ return r.getjson(TWJC_SCREEN_INFO % point_id) |