0627更新

main
zcwBit 4 months ago
parent 82148397e0
commit 4fb94a2726

@ -16,6 +16,7 @@ import qtawesome as qta
from datetime import datetime from datetime import datetime
import random import random
import json import json
import time
from model.ProcedureModel.ProcedureProcessor import StepTableModel from model.ProcedureModel.ProcedureProcessor import StepTableModel
from utils.DBModels.ProcedureModel import DatabaseManager from utils.DBModels.ProcedureModel import DatabaseManager
@ -449,7 +450,7 @@ class StepExecutor(QWidget):
if result is None: if result is None:
print(f"警告:步骤 {stepInfo['stepId']} 返回了None结果设置为False") print(f"警告:步骤 {stepInfo['stepId']} 返回了None结果设置为False")
result = '未检测到关键字' result = '执行失败,未检测到关键字'
executionTime = datetime.now().strftime("%Y-%m-%d %H:%M:%S") executionTime = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
stepResult = { stepResult = {
@ -630,10 +631,19 @@ class StepExecutor(QWidget):
return False return False
def performWaitOperation(self, stepId, description, keyword): def performWaitOperation(self, stepId, description, keyword):
"""执行等待操作""" """执行等待操作,等待时间取自描述字段中的数字(秒)"""
print(f"执行等待操作 (步骤 {stepId}): {description}") print(f"执行等待操作 (步骤 {stepId}): {description}")
# 这里可以添加具体的等待操作逻辑 import re, time
return '执行成功' # 只提取描述中的数字(支持小数),不再匹配"等待"字样
match = re.search(r'([0-9]+(?:\.[0-9]+)?)', description)
if match:
seconds = float(match.group(1))
print(f" 等待 {seconds} 秒...")
time.sleep(seconds)
return '执行成功'
else:
print(" 未检测到等待时间")
return '未检测到等待时间'
def performDeltaTOperation(self, stepId, description, keyword): def performDeltaTOperation(self, stepId, description, keyword):
"""执行接收操作""" """执行接收操作"""
@ -842,8 +852,8 @@ class StepExecutor(QWidget):
if step.get('executed', False): if step.get('executed', False):
rowCells[2].text = step.get('time', '').strftime("%Y-%m-%d %H:%M:%S") if step.get('time') else '' rowCells[2].text = step.get('time', '').strftime("%Y-%m-%d %H:%M:%S") if step.get('time') else ''
result = step.get('result', False) result = step.get('result', False)
rowCells[3].text = "✓ 成功" if result else "✗ 失败" rowCells[3].text = "✓ 成功" if '失败' not in result else "✗ 失败"
rowCells[4].text = "正常执行" if result else "执行失败" rowCells[4].text = result
if result: if result:
rowCells[3].paragraphs[0].runs[0].font.color.rgb = RGBColor(0, 176, 80) rowCells[3].paragraphs[0].runs[0].font.color.rgb = RGBColor(0, 176, 80)

@ -134,13 +134,11 @@ class StepTableModel(QAbstractTableModel):
return step['time'].strftime("%Y-%m-%d %H:%M:%S") if step['time'] else '' return step['time'].strftime("%Y-%m-%d %H:%M:%S") if step['time'] else ''
elif col == 3: elif col == 3:
# print(step['result']) # print(step['result'])
if not step['result']: if step['executed']:
return ' ' if '失败' in step['result']:
if '失败' in step['result']: return ''
return '' else:
if step['result'] == '未检测到关键字': return ''
return ''
return ''
elif col == 4: elif col == 4:
# print(step['result']) # print(step['result'])
return step['result'] return step['result']
@ -149,10 +147,10 @@ class StepTableModel(QAbstractTableModel):
elif role == Qt.BackgroundRole: elif role == Qt.BackgroundRole:
if step['executed']: if step['executed']:
if step['result']: if '失败' in step['result']:
return QBrush(QColor(144, 238, 144))
else:
return QBrush(QColor(255, 182, 193)) return QBrush(QColor(255, 182, 193))
else:
return QBrush(QColor(144, 238, 144))
elif step['isMain']: elif step['isMain']:
return QBrush(QColor(220, 220, 220)) return QBrush(QColor(220, 220, 220))

Loading…
Cancel
Save