|
@@ -37,19 +37,8 @@ class TemperatureEnvironmentAnalyst(AnalystWithGoodBadLimitPoint):
|
|
|
turbrineInfos = self.common.getTurbineInfos(
|
|
|
conf.dataContract.dataFilter.powerFarmID, turbineCodes, self.turbineInfo)
|
|
|
|
|
|
- groupedOfTurbineModel = turbrineInfos.groupby(Field_MillTypeCode)
|
|
|
-
|
|
|
- returnDatas = []
|
|
|
- for turbineModelCode, group in groupedOfTurbineModel:
|
|
|
- currTurbineCodes = group[Field_CodeOfTurbine].unique().tolist()
|
|
|
- currTurbineModeInfo = self.common.getTurbineModelByCode(
|
|
|
- turbineModelCode, self.turbineModelInfo)
|
|
|
- currDataFrameOfTurbines = dataFrameOfTurbines[dataFrameOfTurbines[Field_CodeOfTurbine].isin(
|
|
|
- currTurbineCodes)]
|
|
|
- returnData= self.draw(mergeData, outputAnalysisDir, conf,currTurbineModeInfo)
|
|
|
- returnDatas.append(returnData)
|
|
|
-
|
|
|
- returnResult = pd.concat(returnDatas, ignore_index=True)
|
|
|
+ returnResult= self.draw(mergeData, outputAnalysisDir, conf,turbrineInfos)
|
|
|
+
|
|
|
return returnResult
|
|
|
# return self.draw(mergeData, outputAnalysisDir, conf)
|
|
|
|
|
@@ -132,7 +121,7 @@ class TemperatureEnvironmentAnalyst(AnalystWithGoodBadLimitPoint):
|
|
|
row=1, col=1
|
|
|
)
|
|
|
fig1.update_layout(
|
|
|
- title={'text': f'温度偏差-{turbineModelInfo[Field_MachineTypeCode]}', 'x': 0.5},
|
|
|
+ title={'text': f'温度偏差', 'x': 0.5},
|
|
|
xaxis_title='机组名称',
|
|
|
yaxis_title='温度偏差',
|
|
|
shapes=[
|
|
@@ -144,6 +133,30 @@ class TemperatureEnvironmentAnalyst(AnalystWithGoodBadLimitPoint):
|
|
|
xaxis=dict(tickangle=-45) # 设置x轴刻度旋转角度为45度
|
|
|
)
|
|
|
|
|
|
+ # 确保从 Series 中提取的是具体的值
|
|
|
+ engineTypeCode = turbineModelInfo.get(Field_MillTypeCode, "")
|
|
|
+ if isinstance(engineTypeCode, pd.Series):
|
|
|
+ engineTypeCode = engineTypeCode.iloc[0]
|
|
|
+
|
|
|
+ engineTypeName = turbineModelInfo.get(Field_MachineTypeCode, "")
|
|
|
+ if isinstance(engineTypeName, pd.Series):
|
|
|
+ engineTypeName = engineTypeName.iloc[0]
|
|
|
+ # 构建最终的JSON对象
|
|
|
+ json_output = {
|
|
|
+ "analysisTypeCode": "风电机组环境温度传感器分析",
|
|
|
+ "engineCode": engineTypeCode,
|
|
|
+ "engineTypeName": engineTypeName,
|
|
|
+ "xaixs": "机组名称",
|
|
|
+ "yaixs": "温度偏差",
|
|
|
+ "data": [{
|
|
|
+ "engineName": "", # Field_NameOfTurbine
|
|
|
+ "engineCode": "", # Field_CodeOfTurbine
|
|
|
+ "title": f'温度偏差',
|
|
|
+ "xData": res[Field_NameOfTurbine].tolist(),
|
|
|
+ "yData": res[self.fieldTemperatureDiff].tolist(),
|
|
|
+ }]
|
|
|
+ }
|
|
|
+
|
|
|
result_rows = []
|
|
|
# 保存图像
|
|
|
pngFileName = '{}环境温差Bias.png'.format(
|
|
@@ -152,18 +165,27 @@ class TemperatureEnvironmentAnalyst(AnalystWithGoodBadLimitPoint):
|
|
|
fig1.write_image(pngFilePath, scale=3)
|
|
|
|
|
|
# 保存HTML
|
|
|
- htmlFileName = '{}环境温差Bias.html'.format(
|
|
|
+ # htmlFileName = '{}环境温差Bias.html'.format(
|
|
|
+ # self.powerFarmInfo[Field_PowerFarmName].iloc[0])
|
|
|
+ # htmlFilePath = os.path.join(outputAnalysisDir, htmlFileName)
|
|
|
+ # fig1.write_html(htmlFilePath)
|
|
|
+
|
|
|
+ # 将JSON对象保存到文件
|
|
|
+ jsonFileName = '{}环境温差Bias.json'.format(
|
|
|
self.powerFarmInfo[Field_PowerFarmName].iloc[0])
|
|
|
- htmlFilePath = os.path.join(outputAnalysisDir, htmlFileName)
|
|
|
- fig1.write_html(htmlFilePath)
|
|
|
+ output_json_path = os.path.join(outputAnalysisDir, jsonFileName)
|
|
|
+ with open(output_json_path, 'w', encoding='utf-8') as f:
|
|
|
+ import json
|
|
|
+ json.dump(json_output, f, ensure_ascii=False, indent=4)
|
|
|
|
|
|
+ # 如果需要返回DataFrame,可以包含文件路径
|
|
|
result_rows.append({
|
|
|
Field_Return_TypeAnalyst: self.typeAnalyst(),
|
|
|
Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
|
|
|
Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
|
|
|
Field_CodeOfTurbine: Const_Output_Total,
|
|
|
- Field_Return_FilePath: pngFilePath,
|
|
|
- Field_Return_IsSaveDatabase: False
|
|
|
+ Field_Return_FilePath: output_json_path,
|
|
|
+ Field_Return_IsSaveDatabase: True
|
|
|
})
|
|
|
|
|
|
result_rows.append({
|
|
@@ -171,10 +193,19 @@ class TemperatureEnvironmentAnalyst(AnalystWithGoodBadLimitPoint):
|
|
|
Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
|
|
|
Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
|
|
|
Field_CodeOfTurbine: Const_Output_Total,
|
|
|
- Field_Return_FilePath: htmlFilePath,
|
|
|
- Field_Return_IsSaveDatabase: True
|
|
|
+ Field_Return_FilePath: pngFilePath,
|
|
|
+ Field_Return_IsSaveDatabase: False
|
|
|
})
|
|
|
|
|
|
+ # result_rows.append({
|
|
|
+ # Field_Return_TypeAnalyst: self.typeAnalyst(),
|
|
|
+ # Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
|
|
|
+ # Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
|
|
|
+ # Field_CodeOfTurbine: Const_Output_Total,
|
|
|
+ # Field_Return_FilePath: htmlFilePath,
|
|
|
+ # Field_Return_IsSaveDatabase: True
|
|
|
+ # })
|
|
|
+
|
|
|
# 环境温度中位数条形图
|
|
|
fig2 = make_subplots(rows=1, cols=1)
|
|
|
fig2.add_trace(
|
|
@@ -183,12 +214,37 @@ class TemperatureEnvironmentAnalyst(AnalystWithGoodBadLimitPoint):
|
|
|
row=1, col=1
|
|
|
)
|
|
|
fig2.update_layout(
|
|
|
- title={'text': f'平均温度-{turbineModelInfo[Field_MachineTypeCode]}', 'x': 0.5},
|
|
|
+ title={'text': f'平均温度', 'x': 0.5},
|
|
|
xaxis_title='机组名称',
|
|
|
yaxis_title=' 温度',
|
|
|
xaxis=dict(tickangle=-45) # 为x轴也设置旋转角度
|
|
|
)
|
|
|
|
|
|
+ # 确保从 Series 中提取的是具体的值
|
|
|
+ engineTypeCode = turbineModelInfo.get(Field_MillTypeCode, "")
|
|
|
+ if isinstance(engineTypeCode, pd.Series):
|
|
|
+ engineTypeCode = engineTypeCode.iloc[0]
|
|
|
+
|
|
|
+ engineTypeName = turbineModelInfo.get(Field_MachineTypeCode, "")
|
|
|
+ if isinstance(engineTypeName, pd.Series):
|
|
|
+ engineTypeName = engineTypeName.iloc[0]
|
|
|
+ # 构建最终的JSON对象
|
|
|
+ json_output = {
|
|
|
+ "analysisTypeCode": "风电机组环境温度传感器分析",
|
|
|
+ "engineCode": engineTypeCode,
|
|
|
+ "engineTypeName": engineTypeName,
|
|
|
+ "xaixs": "机组名称",
|
|
|
+ "yaixs": "温度",
|
|
|
+ "data": [{
|
|
|
+ "engineName": "", # Field_NameOfTurbine
|
|
|
+ "engineCode": "", # Field_CodeOfTurbine
|
|
|
+ "title": f'平均温度',
|
|
|
+ "xData": res[Field_NameOfTurbine].tolist(),
|
|
|
+ "yData": res['当前机组温度'].tolist(),
|
|
|
+ }]
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
# 保存图像
|
|
|
pngFileName = '{}环境温度中位数.png'.format(
|
|
|
self.powerFarmInfo[Field_PowerFarmName].iloc[0])
|
|
@@ -196,18 +252,27 @@ class TemperatureEnvironmentAnalyst(AnalystWithGoodBadLimitPoint):
|
|
|
fig2.write_image(pngFilePath, scale=3)
|
|
|
|
|
|
# 保存HTML
|
|
|
- htmlFileName = '{}环境温度中位数.html'.format(
|
|
|
+ # htmlFileName = '{}环境温度中位数.html'.format(
|
|
|
+ # self.powerFarmInfo[Field_PowerFarmName].iloc[0])
|
|
|
+ # htmlFilePath = os.path.join(outputAnalysisDir, htmlFileName)
|
|
|
+ # fig2.write_html(htmlFilePath)
|
|
|
+
|
|
|
+ # 将JSON对象保存到文件
|
|
|
+ jsonFileName = '{}环境温度中位数.json'.format(
|
|
|
self.powerFarmInfo[Field_PowerFarmName].iloc[0])
|
|
|
- htmlFilePath = os.path.join(outputAnalysisDir, htmlFileName)
|
|
|
- fig2.write_html(htmlFilePath)
|
|
|
+ output_json_path = os.path.join(outputAnalysisDir, jsonFileName)
|
|
|
+ with open(output_json_path, 'w', encoding='utf-8') as f:
|
|
|
+ import json
|
|
|
+ json.dump(json_output, f, ensure_ascii=False, indent=4)
|
|
|
|
|
|
+ # 如果需要返回DataFrame,可以包含文件路径
|
|
|
result_rows.append({
|
|
|
Field_Return_TypeAnalyst: self.typeAnalyst(),
|
|
|
Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
|
|
|
Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
|
|
|
Field_CodeOfTurbine: Const_Output_Total,
|
|
|
- Field_Return_FilePath: pngFilePath,
|
|
|
- Field_Return_IsSaveDatabase: False
|
|
|
+ Field_Return_FilePath: output_json_path,
|
|
|
+ Field_Return_IsSaveDatabase: True
|
|
|
})
|
|
|
|
|
|
result_rows.append({
|
|
@@ -215,10 +280,19 @@ class TemperatureEnvironmentAnalyst(AnalystWithGoodBadLimitPoint):
|
|
|
Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
|
|
|
Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
|
|
|
Field_CodeOfTurbine: Const_Output_Total,
|
|
|
- Field_Return_FilePath: htmlFilePath,
|
|
|
- Field_Return_IsSaveDatabase: True
|
|
|
+ Field_Return_FilePath: pngFilePath,
|
|
|
+ Field_Return_IsSaveDatabase: False
|
|
|
})
|
|
|
|
|
|
+ # result_rows.append({
|
|
|
+ # Field_Return_TypeAnalyst: self.typeAnalyst(),
|
|
|
+ # Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
|
|
|
+ # Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
|
|
|
+ # Field_CodeOfTurbine: Const_Output_Total,
|
|
|
+ # Field_Return_FilePath: htmlFilePath,
|
|
|
+ # Field_Return_IsSaveDatabase: True
|
|
|
+ # })
|
|
|
+
|
|
|
result_df = pd.DataFrame(result_rows)
|
|
|
|
|
|
return result_df
|