Explorar el Código

开放平台接口

lmstack hace 2 años
padre
commit
180ba47ba6
Se han modificado 1 ficheros con 40 adiciones y 0 borrados
  1. 40 0
      LIB/BACKEND/OPENAPI/OpenApi.py

+ 40 - 0
LIB/BACKEND/OPENAPI/OpenApi.py

@@ -0,0 +1,40 @@
+'''
+数据预处理类
+
+'''
+__author__ = 'lmstack'
+
+import pandas as pd
+
+import requests
+import json
+
+class OpenApi:
+    def __init__(self):
+        pass
+
+    # def data_split(self, dfin, drive_interval_threshold=120, charge_interval_threshold=300, 
+    #                            drive_stand_threshold=120, charge_stand_threshold=300,
+    #                            default_time_threshold = 300, drive_time_threshold=300, charge_time_threshold=300, 
+    #                            stand_time_threshold = 1800):
+    #     '''
+    #     数据分段函数,会调用_data_split_by_status和_data_split_by_time函数。
+    #     其中_data_split_by_status 将数据分为charge、drive、stand、和none段;
+    #     _data_split_by_time 将每个段内的数据,根据时间跳变继续分段。
+
+    #     '''
+    def get_device_fault(self, start_time="", end_time=""):
+        # start_time = "2021-12-30 00:00:00"
+        # end_time = "2021-12-31 00:00:00"
+        url = 'http://open.li-ai.com.cn/admin/v1/deviceFault'
+        headers = {'Content-Type':"application/json; charset=utf-8","token":"2A26DD0ADE53456D928562A17131A3B5"}
+        data = {}
+        if start_time != "":
+            data['startTime'] = start_time
+        if end_time != "":
+            data['endTime'] = end_time
+        response = requests.post(url,  json=data, headers=headers)
+        df = pd.DataFrame(columns=['sn', 'imei','faultTime', 'updateTime', 'overTime', 'faultStatus', 'questionType', 'questionTypeText', 'childProblem','childProblemText'])
+        for d in json.loads(response.text)["data"]:
+            df = df.append(d, ignore_index=True)
+        return df