:art: chg_sta

huangqimin001 %!s(int64=3) %!d(string=hace) años
padre
commit
1465ac4662

+ 18 - 0
account/migrations/0005_alter_administratorinfo_point_name.py

@@ -0,0 +1,18 @@
1
+# Generated by Django 3.2.6 on 2021-08-17 15:33
2
+
3
+from django.db import migrations, models
4
+
5
+
6
+class Migration(migrations.Migration):
7
+
8
+    dependencies = [
9
+        ('account', '0004_auto_20210816_2148'),
10
+    ]
11
+
12
+    operations = [
13
+        migrations.AlterField(
14
+            model_name='administratorinfo',
15
+            name='point_name',
16
+            field=models.CharField(blank=True, db_index=True, help_text='隔离点名称', max_length=255, null=True, verbose_name='point_name'),
17
+        ),
18
+    ]

+ 1 - 0
api/eqpt_views.py

@@ -343,6 +343,7 @@ def mqtt_upload_temperature(payload):
343 343
         ).aggregate(Max('temperature')).get('temperature__max') or 0
344 344
         ipui.observed_ymds = list(set(ipui.observed_ymds + [tc.local_string(format='%Y-%m-%d')]))
345 345
         ipui.observed_days = len(ipui.observed_ymds)
346
+        ipui.chg_sta = chg_sta
346 347
         ipui.temperature = temperature__max
347 348
         ipui.last_submit_at = tc.utc_datetime()
348 349
         ipui.save()

+ 18 - 0
equipment/migrations/0016_isolationpointuserinfo_chg_sta.py

@@ -0,0 +1,18 @@
1
+# Generated by Django 3.2.6 on 2021-08-17 15:33
2
+
3
+from django.db import migrations, models
4
+
5
+
6
+class Migration(migrations.Migration):
7
+
8
+    dependencies = [
9
+        ('equipment', '0015_auto_20210817_1907'),
10
+    ]
11
+
12
+    operations = [
13
+        migrations.AddField(
14
+            model_name='isolationpointuserinfo',
15
+            name='chg_sta',
16
+            field=models.BooleanField(default=True, help_text='充电状态,true 充电,false 未充电', verbose_name='chg_sta'),
17
+        ),
18
+    ]

+ 5 - 3
equipment/models.py

@@ -82,6 +82,7 @@ class IsolationPointInfo(BaseModelMixin):
82 82
 class IsolationPointUserInfo(BaseModelMixin):
83 83
     HAS_NOT_UPLOAD = '未上报'
84 84
     HAS_YET_UPLOAD = '已上报'
85
+    CHG_STA_CHARGING = ' 充电中'
85 86
 
86 87
     point_id = models.CharField(_('point_id'), max_length=32, blank=True, null=True, help_text='隔离点唯一标识', db_index=True)
87 88
 
@@ -92,6 +93,7 @@ class IsolationPointUserInfo(BaseModelMixin):
92 93
     observed_ymds = JSONField(_('observed_ymds'), default=[], blank=True, null=True, help_text='已测温日期')
93 94
     observed_days = models.IntegerField(_('observed_days'), default=0, help_text='已测温天数')
94 95
 
96
+    chg_sta = models.BooleanField(_(u'chg_sta'), default=True, help_text='充电状态,true 充电,false 未充电')
95 97
     temperature = models.FloatField(_('temperature'), default=0, help_text='用户体温')
96 98
     last_submit_at = models.DateTimeField(_('last_submit_at'), blank=True, null=True, help_text='上一次上报时间')
97 99
     leave_at = models.DateTimeField(_('leave_at'), blank=True, null=True, help_text='离开时间')
@@ -112,9 +114,9 @@ class IsolationPointUserInfo(BaseModelMixin):
112 114
 
113 115
     @property
114 116
     def temperature_has_upload(self):
115
-        if not self.last_submit_at:
116
-            return IsolationPointUserInfo.HAS_NOT_UPLOAD
117
-        if self.last_submit_at > tc.utc_datetime(hours=-1):
117
+        if self.chg_sta:
118
+            return IsolationPointUserInfo.CHG_STA_CHARGING
119
+        if self.last_submit_at and self.last_submit_at > tc.utc_datetime(hours=-1):
118 120
             return IsolationPointUserInfo.HAS_YET_UPLOAD
119 121
         return IsolationPointUserInfo.HAS_NOT_UPLOAD
120 122