调整大屏显示状态,温度不正常时不显示温度

FFIB vor 3 Jahren
Ursprung
Commit
bd02e54f05
2 geänderte Dateien mit 39 neuen Zeilen und 8 gelöschten Zeilen
  1. 19 8
      api/eqpt_views.py
  2. 20 0
      equipment/models.py

+ 19 - 8
api/eqpt_views.py

@@ -190,14 +190,14 @@ def get_screen_data(point=None, point_id=None):
190 190
     ipuis = {ipui.get('pk'): {
191 191
         'fields': ipui.get('fields', []),
192 192
         'observed_days': ipui.get('observed_days', 0),
193
-        'temperature_has_upload': ipui.get('temperature_has_upload', ''),
193
+        'user_status': ipui.get('user_status', ''),
194 194
         'temperature': ipui.get('temperature', 0),
195 195
         'last_submit_at': ipui.get('last_submit_at', ''),
196 196
         'remark': ipui.get('remark', ''),
197 197
     } for ipui in ipuis}
198 198
 
199 199
     eqpts = [{**eqpt.screen_data, **{
200
-        'has_upload': ipuis.get(eqpt.ipui_pk, {}).get('temperature_has_upload', ''),
200
+        'user_status': ipuis.get(eqpt.ipui_pk, {}).get('user_status', ''),
201 201
         'temperature': ipuis.get(eqpt.ipui_pk, {}).get('temperature', 0),
202 202
         'observed_days': ipuis.get(eqpt.ipui_pk, {}).get('observed_days', 0),
203 203
         'last_submit_at': ipuis.get(eqpt.ipui_pk, {}).get('last_submit_at', ''),
@@ -217,15 +217,18 @@ def get_screen_data(point=None, point_id=None):
217 217
         'phone': eqpt.get('phone', ''),
218 218
         'sex': eqpt.get('sex', ''),
219 219
         'age': eqpt.get('age', ''),
220
-        'status': eqpt.get('has_upload'),
220
+        'status': eqpt.get('user_status'),
221 221
         'last_report_time': eqpt.get('last_submit_at', ''),
222 222
         'temperature': eqpt.get('temperature', 0),
223 223
         'observed_days': eqpt.get('observed_days', 0),
224 224
     } for eqpt in eqpts]
225 225
 
226
-    # 排序:发烧 > 未上报 > 充电中 > 时间
226
+    # 排序:发烧 > 未联网 > 关机 > 未佩戴 > 充电中 > 时间
227 227
     eqpts_fever = []
228
-    eqpts_not_upload = []
228
+    # eqpts_not_upload = []
229
+    eqpts_not_connected = []
230
+    eqpts_shutdown = []
231
+    eqpts_not_worn = []
229 232
     eqpts_chg = []
230 233
     eqpts_other = []
231 234
     for eqpt in eqpts:
@@ -233,15 +236,23 @@ def get_screen_data(point=None, point_id=None):
233 236
         temperature = eqpt.get('temperature')
234 237
         if temperature > settings.FEVER_TEMPERATURE:
235 238
             eqpts_fever.append(eqpt)
236
-        elif status == IsolationPointUserInfo.HAS_NOT_UPLOAD and temperature <= settings.FEVER_TEMPERATURE:
237
-            eqpts_not_upload.append(eqpt)
239
+        elif status == IsolationPointUserInfo.HAS_NOT_CONNECTED:
240
+            eqpt['temperature'] = '-'
241
+            eqpts_not_connected.append(eqpt)
242
+        elif status == IsolationPointUserInfo.HAS_SHUTDOWN:
243
+            eqpt['temperature'] = '-'
244
+            eqpts_shutdown.append(eqpt)
245
+        elif status == IsolationPointUserInfo.HAS_NOT_WORN:
246
+            eqpt['temperature'] = '-'
247
+            eqpts_not_worn.append(eqpt)
238 248
         elif status == IsolationPointUserInfo.CHG_STA_CHARGING:
249
+            eqpt['temperature'] = '-'
239 250
             eqpts_chg.append(eqpt)
240 251
         else:
241 252
             eqpts_other.append(eqpt)
242 253
 
243 254
     return {
244
-        'eqpts': eqpts_fever + eqpts_not_upload + eqpts_chg + eqpts_other,
255
+        'eqpts': eqpts_fever + eqpts_not_connected + eqpts_shutdown + eqpts_not_worn + eqpts_chg + eqpts_other,
245 256
         'reminds': reminds,
246 257
         'total_active_eqpt_num': total_active_eqpt_num,
247 258
         'has_upload_temperature_num': has_upload_temperature_num,

+ 20 - 0
equipment/models.py

@@ -81,6 +81,9 @@ class IsolationPointInfo(BaseModelMixin):
81 81
 
82 82
 class IsolationPointUserInfo(BaseModelMixin):
83 83
     HAS_NOT_UPLOAD = '未上报'
84
+    HAS_NOT_CONNECTED = '未联网'
85
+    HAS_NOT_WORN = '未佩戴'
86
+    HAS_SHUTDOWN = '关机'
84 87
     HAS_YET_UPLOAD = '已上报'
85 88
     CHG_STA_CHARGING = '充电中'
86 89
 
@@ -120,9 +123,25 @@ class IsolationPointUserInfo(BaseModelMixin):
120 123
             return IsolationPointUserInfo.CHG_STA_CHARGING
121 124
         if self.last_submit_at and self.last_submit_at > tc.utc_datetime(hours=-1):
122 125
             return IsolationPointUserInfo.HAS_YET_UPLOAD
126
+        
123 127
         return IsolationPointUserInfo.HAS_NOT_UPLOAD
124 128
 
125 129
     @property
130
+    def user_status(self):
131
+        has_upload = self.last_submit_at and self.last_submit_at > tc.utc_datetime(hours=-1)
132
+        if has_upload and self.chg_sta:
133
+            return IsolationPointUserInfo.CHG_STA_CHARGING
134
+        if has_upload and self.temperature >= 35:
135
+            return IsolationPointUserInfo.HAS_YET_UPLOAD
136
+        if has_upload and self.temperature < 35:
137
+            return IsolationPointUserInfo.HAS_NOT_WORN
138
+        if not has_upload and (self.chg_sta or self.temperature > 0):
139
+            return IsolationPointUserInfo.HAS_SHUTDOWN
140
+        
141
+        return IsolationPointUserInfo.HAS_NOT_CONNECTED
142
+
143
+
144
+    @property
126 145
     def data(self):
127 146
         return {
128 147
             'pk': self.pk,
@@ -131,6 +150,7 @@ class IsolationPointUserInfo(BaseModelMixin):
131 150
             'fields': self.fields,
132 151
             'observed_days': self.observed_days,
133 152
             'temperature_has_upload': self.temperature_has_upload,
153
+            'user_status': self.user_status,
134 154
             'temperature': self.temperature,
135 155
             'last_submit_at': tc.local_string(utc_dt=self.last_submit_at, format='%m-%d %H:%M') if self.last_submit_at else '',
136 156
             'remark': self.remark or '',