diff --git a/apps/enp/serializers.py b/apps/enp/serializers.py index 496923f5..787c55ce 100644 --- a/apps/enp/serializers.py +++ b/apps/enp/serializers.py @@ -36,7 +36,8 @@ class Drain2Serializer(CustomModelSerializer): now = datetime.now() today = str(now)[:10]+' 00:00:00' today_last = str(now)[:10]+' 23:59:59' - odata = equips.values('id', 'name', 'type') + odata = equips.values('id', 'name', 'type', + 'is_online', 'running_state') eids = [f"'{e['id']}'" for e in odata] eids_str = ','.join(eids) sql_str = f''' @@ -94,10 +95,10 @@ GROUP BY for i in odata: i.update(data.get(i['id'], { "avg_tsp": None, - "total_duration_online": None, - "total_duration_run": None, - "total_duration_standby": None, - "last_running_state": None, + "total_duration_online": 0, + "total_duration_run": 0, + "total_duration_standby": 0, + "last_running_state": 50, })) return odata