Sfoglia il codice sorgente

修改文件格式

chenhongyan1989 1 mese fa
parent
commit
4083d306ad
2 ha cambiato i file con 12 aggiunte e 12 eliminazioni
  1. 8 10
      app/routers/cms.py
  2. 4 2
      app/routers/temperature.py

+ 8 - 10
app/routers/cms.py

@@ -9,17 +9,17 @@ from app.services.CMSAnalyst import CMSAnalyst
 
 router = APIRouter()
 
-@router.post("/analysis/{analysisType}")
-async def analyze(analysisType: str, input_data:CmsAnalysisInput):
 
+@router.post("/analysis/{analysisType}")
+async def analyze(analysisType: str, input_data: CmsAnalysisInput):
     analysis_map = {
-        #包络谱分析
+        # 包络谱分析
         "envelope": "envelope_spectrum",
-        #频域分析
+        # 频域分析
         "frequency": "frequency_domain",
-        #时域分析
+        # 时域分析
         "time": "time_domain",
-        #趋势分析
+        # 趋势分析
         "trend": "trend_analysis"
     }
 
@@ -42,11 +42,9 @@ async def analyze(analysisType: str, input_data:CmsAnalysisInput):
         else:
             # 处理其他情况,例如其他数据类型
             func_res = {'type': analysisType, 'data': str(func_res)}
-            #对象转化为字符串形式
-        return json.dumps(func_res,ensure_ascii=False)
+            # 对象转化为字符串形式
+        return json.dumps(func_res, ensure_ascii=False)
         # return JSONResponse(content=func_res)#返回json格式
     except Exception as e:
         logger.error(f"analyze is bad {traceback.format_exc()}")
         return {"message": "error", "detail": str(e)}
-
-

+ 4 - 2
app/routers/temperature.py

@@ -7,6 +7,7 @@ from app.services.MSET_Temp import MSET_Temp
 
 router = APIRouter()
 
+
 @router.post("/temperature/threshold")
 async def route_threshold(input_data: TemperatureThresholdInput):
     """
@@ -51,7 +52,7 @@ async def route_threshold(input_data: TemperatureThresholdInput):
 
         total = len(records)
         start = (input_data.pageNo - 1) * input_data.pageSize
-        end   = start + input_data.pageSize
+        end = start + input_data.pageSize
         paginated = records[start:end]
 
         return {
@@ -73,6 +74,7 @@ async def route_threshold(input_data: TemperatureThresholdInput):
             }
         )
 
+
 # SPRT趋势分析
 @router.post("/SPRT/trend")
 async def route_trend(input_data: TemperatureInput):
@@ -112,7 +114,7 @@ async def route_trend(input_data: TemperatureInput):
         return {
             "data": {
                 "type": "SPRT_trend",
-                **result.get("data", {})    # 四个通道的数据或空对象
+                **result.get("data", {})  # 四个通道的数据或空对象
             },
             "code": 200,
             "message": "success"