add(派单任务刷新)、modify(派单任务和管片任务详情界面)
This commit is contained in:
@ -11,7 +11,9 @@ from service.msg_recorder import MessageRecorder
|
||||
|
||||
from service.opcua_ui_client import OpcuaUiClient
|
||||
from service.artifact_query_thread import ArtifactInfoQueryThread # 管片任务查询
|
||||
from busisness.models import ArtifactInfoModel
|
||||
from service.pdrecord_query_thread import PDRecordQueryThread # 派单任务查询
|
||||
from busisness.models import ArtifactInfoModel
|
||||
from busisness.models import PDRecordModel
|
||||
from typing import List
|
||||
|
||||
|
||||
@ -42,8 +44,8 @@ class MainController:
|
||||
self.__connectSignals()
|
||||
|
||||
def showMainWindow(self):
|
||||
# self.main_window.showFullScreen()
|
||||
self.main_window.show()
|
||||
self.main_window.showFullScreen()
|
||||
# self.main_window.show()
|
||||
|
||||
def _initSubControllers(self):
|
||||
# 右侧视频显示控制模块
|
||||
@ -158,34 +160,18 @@ class MainController:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
def convert_to_ampm(self, time_str: str) -> str:
|
||||
"""时间格式转换: 转换为AM/PM形式"""
|
||||
from datetime import datetime
|
||||
time_formats = [
|
||||
"%Y-%m-%d %H:%M:%S",
|
||||
"%Y-%m-%d %H:%M:%S.%f"
|
||||
]
|
||||
for fmt in time_formats:
|
||||
try:
|
||||
dt = datetime.strptime(time_str, fmt)
|
||||
return dt.strftime("%I:%M%p")
|
||||
except ValueError:
|
||||
continue
|
||||
return "--:--"
|
||||
|
||||
def onUpdateUiByArtifactInfo(self, artifact_list:List[ArtifactInfoModel]):
|
||||
for index, artifact in enumerate(artifact_list, 1):
|
||||
if artifact.MouldCode:
|
||||
self.main_window.segment_task_widget.set_task_id(f"task{index}", artifact.MouldCode) # 模具号
|
||||
if artifact.BetonVolume:
|
||||
self.main_window.segment_task_widget.set_task_volume(f"task{index}", artifact.BetonVolume) # 浇筑方量
|
||||
if artifact.BeginTime:
|
||||
time_str = self.convert_to_ampm(artifact.BeginTime)
|
||||
self.main_window.segment_task_widget.set_task_time(f"task{index}", time_str) # 开始时间
|
||||
self.main_window.SetSegmentTaskDetails(f"task{index}", artifact) # 更新管片任务详情
|
||||
# 更新管片任务
|
||||
self.main_window.update_segment_tasks(artifact_list)
|
||||
# 将opc服务中的 segment_tasks的值复原为 0,以便下次触发管片更新
|
||||
self.opc_client.write_value_by_name("segment_tasks", 0)
|
||||
|
||||
def onUpdateUiByPDRecord(self, pdrecord_list:List[PDRecordModel]):
|
||||
# 更新派单任务
|
||||
self.main_window.update_dispatch_tasks(pdrecord_list)
|
||||
# 将opc服务中的 dispatch_tasks的值复原为 0,以便下次触发派单更新
|
||||
self.opc_client.write_value_by_name("dispatch_tasks", 0)
|
||||
|
||||
# ======================== OPCUA值更新界面方法 ======================
|
||||
def _update_upper_weight(self, val):
|
||||
# 更新上料斗重量
|
||||
@ -224,18 +210,31 @@ class MainController:
|
||||
def _update_segment_tasks(self, val):
|
||||
if val: # 需要更新管片任务
|
||||
"""更新左侧的管片任务"""
|
||||
if hasattr(self, "query_thread") and self.query_thread.isRunning():
|
||||
if hasattr(self, "segment_query_thread") and self.segment_query_thread.isRunning():
|
||||
return
|
||||
# 1. 管片信息查询线程
|
||||
self.query_thread = ArtifactInfoQueryThread()
|
||||
self.segment_query_thread = ArtifactInfoQueryThread()
|
||||
# 2. 主线程更新管片任务UI
|
||||
self.query_thread.query_finished.connect(self.onUpdateUiByArtifactInfo)
|
||||
self.segment_query_thread.query_finished.connect(self.onUpdateUiByArtifactInfo)
|
||||
# 3. 查询管片信息错误
|
||||
self.query_thread.query_error.connect(self.onQueryArtifactInfoError)
|
||||
self.query_thread.start()
|
||||
self.segment_query_thread.query_error.connect(self.onQueryInfoError)
|
||||
self.segment_query_thread.start()
|
||||
|
||||
def onQueryArtifactInfoError(self, error_msg:str):
|
||||
# 查询管片信息失败预警
|
||||
def _update_dispatch_tasks(self, val):
|
||||
if val: # 需要更新派单任务
|
||||
"""更新右侧的派单任务"""
|
||||
if hasattr(self, "dispatch_query_thread") and self.dispatch_query_thread.isRunning():
|
||||
return
|
||||
# 1. 派单信息查询线程
|
||||
self.dispatch_query_thread = PDRecordQueryThread()
|
||||
# 2. 主线程更新派单任务UI
|
||||
self.dispatch_query_thread.query_finished.connect(self.onUpdateUiByPDRecord)
|
||||
# 3. 查询派单信息错误
|
||||
self.dispatch_query_thread.query_error.connect(self.onQueryInfoError)
|
||||
self.dispatch_query_thread.start()
|
||||
|
||||
def onQueryInfoError(self, error_msg:str):
|
||||
# 查询信息失败预警
|
||||
self.msg_recorder.warning_record(error_msg)
|
||||
|
||||
def _update_vibration_frequency(self, val):
|
||||
|
||||
Reference in New Issue
Block a user