|
@@ -46,18 +46,23 @@ class OutputProcessor:
|
|
|
directory = f"output/{powerFarmID}/{dataBatchNum}"
|
|
|
shutil.rmtree(directory)
|
|
|
|
|
|
- def analysisState(self, session: Session, batchNO: str, analysisState: int, errorState: int = ErrorState.NotErr.value, errorCode: str = None, errorInfo: str = None, timestamp: datetime = datetime.now(timezone.utc)+timedelta(hours=8), analysisProgress: float = 0):
|
|
|
+ def analysisState(self, session: Session, batchNO: str, analysisState: int, errorState: int = ErrorState.NotErr.value, errorCode: str = None, errorInfo: str = None, timestamp: datetime = datetime.now(timezone.utc)+timedelta(hours=8), analysisProgress: float = 0,analysis_finish_time: datetime = None):
|
|
|
"""
|
|
|
写处理状态 至主表 analysis_result
|
|
|
写总图(多机组一张图表)上传文件 至子表 analysis_general_file
|
|
|
写单机组图(单机组一张图表)上传文件 至子表 analysis_diagram_relation
|
|
|
"""
|
|
|
- sql = text(f"INSERT INTO analysis_result(batch_code, analysis_state, err_state, err_code, err_info, create_time,analysis_progress) \
|
|
|
- VALUES(:batch_code, :analysis_state, :err_state,:err_code, :err_info, :create_time,:analysis_progress) \
|
|
|
+ sql = text(f"INSERT INTO analysis_result(batch_code, analysis_state, err_state, err_code, err_info, create_time, analysis_progress, analysis_finish_time, update_time) \
|
|
|
+ VALUES(:batch_code, :analysis_state, :err_state, :err_code, :err_info, :create_time, :analysis_progress, :analysis_finish_time, :update_time) \
|
|
|
ON DUPLICATE KEY \
|
|
|
UPDATE \
|
|
|
- analysis_state=VALUES(analysis_state),err_state=VALUES(err_state),err_code=VALUES(err_code), \
|
|
|
- err_info=VALUES(err_info),update_time=VALUES(update_time),analysis_progress=VALUES(analysis_progress);")
|
|
|
+ analysis_state=VALUES(analysis_state), \
|
|
|
+ err_state=VALUES(err_state), \
|
|
|
+ err_code=VALUES(err_code), \
|
|
|
+ err_info=VALUES(err_info), \
|
|
|
+ update_time=VALUES(update_time), \
|
|
|
+ analysis_progress=VALUES(analysis_progress), \
|
|
|
+ analysis_finish_time=VALUES(analysis_finish_time);")
|
|
|
|
|
|
params = {
|
|
|
"batch_code": None if self.common.isNone(batchNO) else batchNO,
|
|
@@ -67,7 +72,8 @@ class OutputProcessor:
|
|
|
"err_info": None if self.common.isNone(errorInfo) else errorInfo,
|
|
|
"create_time": timestamp,
|
|
|
"update_time": timestamp,
|
|
|
- "analysis_progress": analysisProgress
|
|
|
+ "analysis_progress": analysisProgress,
|
|
|
+ "analysis_finish_time":analysis_finish_time if analysis_finish_time is not None else None
|
|
|
}
|
|
|
|
|
|
session.execute(sql, params)
|
|
@@ -154,12 +160,19 @@ class OutputProcessor:
|
|
|
foundationDB = GetBusinessFoundationDbUtil()
|
|
|
|
|
|
with foundationDB.session_scope() as session:
|
|
|
+ # 第一次调用,设置进度为50%
|
|
|
self.analysisState(session, self.dataBatchNum, AnalysisState.Analyzed.value,
|
|
|
- ErrorState.NotErr.value, None, None, timestamp, 100)
|
|
|
+ ErrorState.NotErr.value, None, None, timestamp, 50)
|
|
|
self.analysisResultForTotal(
|
|
|
session, returnDataFrame, timestamp)
|
|
|
self.analysisResultForTurbine(
|
|
|
session, returnDataFrame, timestamp)
|
|
|
+ # 获取分析完成的时间
|
|
|
+ finish_time = datetime.now(timezone.utc) + timedelta(hours=8)
|
|
|
+
|
|
|
+ # 第二次调用:更新分析状态为已完成,进度为100%,并记录完成时间
|
|
|
+ self.analysisState(session, self.dataBatchNum, AnalysisState.Analyzed.value,
|
|
|
+ ErrorState.NotErr.value, None, None, timestamp, 100, analysis_finish_time=finish_time)
|
|
|
|
|
|
self.removeLocalFiles(powerFarmID, dataBatchNum)
|
|
|
except Exception as e:
|