Ver código fonte

解决scada数据完整度 实现时间粒度值获取问题

zhouyang.xie 2 meses atrás
pai
commit
079be7d42a

+ 1 - 0
.gitignore

@@ -46,3 +46,4 @@ codegen/
 
 **/*.egg-info/
 **/__pycache__/
+**/*venv/

+ 24 - 0
.vscode/launch.json

@@ -0,0 +1,24 @@
+{
+    // Use IntelliSense to learn about possible attributes.
+    // Hover to view descriptions of existing attributes.
+    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "name": "Python: Remote Attach",  // 远程调试
+            "type":"debugpy",
+            "request": "attach",
+            "connect": {
+                "host": "localhost",
+                "port": 5678
+            },
+            "pathMappings": [
+                {
+                    "localRoot": "${workspaceFolder}",
+                    "remoteRoot": "."
+                }
+            ],
+            "justMyCode": false
+        }
+        ]
+    }

+ 17 - 0
README.md

@@ -70,6 +70,7 @@ WTOAAM
     kaleido==0.1.0.post1
     plotly==5.19.0
     plotly-express==0.4.1
+    pip install kaleido==0.1.0.post1 plotly==5.19.0 plotly-express==0.4.1
 
 # 更新加载文件夹模块命令:
 1、安装build包:pip insatall build
@@ -80,17 +81,33 @@ WTOAAM
 # 获取python程序依赖包
 
 **务必确保:python程序所依赖的python site-packages路径(其下的包均为对应程序版本的“”最新依赖)、用户权限,以确定应该使用的pip工具**
+pip install pip-tools pipreqs pipdeptree
+pipdeptree 当前虚拟环境中所有安装的包以及它们的依赖关系树, 在源代码目录执行命令:pipdeptree
+pipreqs   如果你的虚拟环境尚未安装任何依赖,pipreqs 将会扫描源代码并将依赖写入 requirements.txt。你可以根据 pipreqs 输出的 requirements.txt 文件,手动安装所需的依赖包。在源代码目录执行命令(其中 点为当前目录): pipreqs . --force --ignore <path_to_non_python_files>
+手动安装依赖:pip install -r requirements.txt
+
 
 ## 方案一
 此方案 验证成功
 执行如下命令:
 
+**Linux**
+
 ```shell
 sudo /usr/local/python3.9/bin/pip3.9 freeze | grep -vE 'repositoryZN|dataAnalysisBehavior|dataAnalysisBusiness|dataContract|dataAnalysisService' > requirements.txt
 
 sudo /usr/local/python3.9/bin/pip3.9 download -r requirements.txt -d download
 ``` 
 
+**windows**
+
+```shell
+pip freeze | Select-String -NotMatch 'repositoryZN|dataAnalysisBehavior|dataAnalysisBusiness|dataContract|dataAnalysisService' | Set-Content requirements.txt
+
+pip download -r requirements.txt -d download
+```
+
+
 ## 方案二
 此方案 验证未成功 ,保留以供继续研究
 1. pip install pip-tools pipreqs pipdeptree

+ 1 - 1
dataAnalysisBehavior/behavior/baseAnalyst.py

@@ -49,7 +49,7 @@ class BaseAnalyst(ABC):
         self.turbineInfo = turbineInfo
 
         # 加载数据转换信息
-        self.dataTransfer = dataTransfer
+        # self.dataTransfer = dataTransfer
 
         # 加载机型信息
         self.turbineModelInfo = turbineModelInfo

+ 2 - 9
dataAnalysisBusiness/algorithm/dataProcessor.py

@@ -236,15 +236,8 @@ class DataProcessor:
                                                   AnalysisState.Analyzed.value, ErrorState.Err.value, code, message)
             except Exception as e1:
                 # 使用 traceback 模块获取完整的异常信息
-                error_message = ''.join(traceback.format_exception(
-                    etype=type(e1), value=e1, tb=e1.__traceback__))
+                error_message = ''.join(traceback.format_exception(e1))
                 # 记录异常信息
                 self.logger.error(f"捕获到异常: {error_message}")
-            finally:
-                # 使用 traceback 模块获取完整的异常信息
-                error_message = ''.join(traceback.format_exception(
-                    etype=type(e), value=e, tb=e.__traceback__))
-                # 记录异常信息
-                self.logger.error(f"捕获到异常: {error_message}")
-
+            
         return DataFrameOutput

+ 3 - 2
dataAnalysisService/service/serviceOfDataAnalysis.py

@@ -30,7 +30,7 @@ def buildDynamicInstance(modulePath, className, conf: Contract,logger:Logger,dbU
     instance.powerFarmInfo=powerFarmInfo
     instance.turbineInfo=turbineInfo
     instance.turbineModelInfo=turbineModelInfo
-    instance.dataTransfer=dataTransfer
+    # instance.dataTransfer=dataTransfer
     instance.weatherStationInfo=weatherStationInfo
     instance.dataFrameContractOfTurbine=dataFrameContractOfTurbine
     
@@ -79,6 +79,7 @@ class ServiceOfDataAnalysis:
 
         # if self.dataTransfer.empty:
         #     raise CustomError(106)
+        self.dataTransfer:pd.DataFrame=None
 
         # 加载机型信息
         self.turbineModelInfo:pd.DataFrame= dal.loadTurbineModelInfos(
@@ -130,7 +131,7 @@ class ServiceOfDataAnalysis:
         process.weatherStationInfo = self.weatherStationInfo
         # 加载所有新能源场站,及所属风电机组机型的合同功率曲线
         process.dataFrameContractOfTurbine = self.dataFrameContractOfTurbine
-        process.dataTransfer=self.dataTransfer
+        # process.dataTransfer=self.dataTransfer
 
         for analyst in analysts:
             process.attach(analyst)

+ 3 - 11
wtoaamapi/apps/viewDemo/viewDataAnalysis.py

@@ -54,9 +54,7 @@ class DataAnalysis(ViewSet):
                 dataAnalysisService = ServiceOfDataAnalysis(logger, databasesUtil, minioClient, conf)
             except Exception as exception:
                 # 使用 traceback 模块获取完整的异常信息
-                error_message = ''.join(traceback.format_exception(
-                    etype=type(exception), value=exception, tb=exception.__traceback__))
-                self.logger.error(f"捕获到异常: {error_message}")
+                error_message =''.join(traceback.format_exception(exception))
                 code = exception.code
                 message = exception.message
                 with foundationDB.session_scope() as session:
@@ -92,15 +90,9 @@ class DataAnalysis(ViewSet):
                                                   AnalysisState.Analyzed.value, ErrorState.Err.value, code, message)
             except Exception as e1:
                 # 使用 traceback 模块获取完整的异常信息
-                error_message = ''.join(traceback.format_exception(
-                    etype=type(e1), value=e1, tb=e1.__traceback__))
+                error_message = ''.join(traceback.format_exception(e1))
                 # 记录异常信息
                 self.logger.error(f"捕获到异常: {error_message}")
-            finally:
-                # 使用 traceback 模块获取完整的异常信息
-                error_message = ''.join(traceback.format_exception(
-                    etype=type(e), value=e, tb=e.__traceback__))
-                # 记录异常信息
-                logger.error(f"捕获到异常: {error_message}")
+            
             # 返回包含错误信息的 HTTP 响应,状态码设为 500(内部服务器错误)
             return HttpResponse(f"内部服务器错误: {error_message}", status=500)