From 334b16b4abb4cbe3d1d4e4f211efd6f4468ae09f Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 19 九月 2025 15:12:52 +0800
Subject: [PATCH] 1.ControlJob和ProcessJob的中断操作,强制结批增加字符串描述原因,方便生产跟踪。

---
 SourceCode/Bond/Servo/CControlJobDlg.cpp |  162 +++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 143 insertions(+), 19 deletions(-)

diff --git a/SourceCode/Bond/Servo/CControlJobDlg.cpp b/SourceCode/Bond/Servo/CControlJobDlg.cpp
index 77311e8..d388c2c 100644
--- a/SourceCode/Bond/Servo/CControlJobDlg.cpp
+++ b/SourceCode/Bond/Servo/CControlJobDlg.cpp
@@ -14,7 +14,7 @@
 CControlJobDlg::CControlJobDlg(CWnd* pParent /*=nullptr*/)
 	: CDialogEx(IDD_DIALOG_CONTROL_JOB, pParent)
 {
-
+    m_pControlJob = nullptr;
 }
 
 CControlJobDlg::~CControlJobDlg()
@@ -29,40 +29,164 @@
 
 
 BEGIN_MESSAGE_MAP(CControlJobDlg, CDialogEx)
+    ON_WM_SIZE()
+    ON_BN_CLICKED(IDC_BUTTON_COMPLETION_BATH, &CControlJobDlg::OnBnClickedButtonCompletionBath)
 END_MESSAGE_MAP()
 
 
+void CControlJobDlg::SetControlJob(SERVO::CControlJob* pControlJob)
+{
+    m_pControlJob = pControlJob;
+}
+
 // CControlJobDlg 娑堟伅澶勭悊绋嬪簭
-
-
 BOOL CControlJobDlg::OnInitDialog()
 {
 	CDialogEx::OnInitDialog();
 
+
+    // label瀛椾綋
+    LOGFONT lf{};
+    GetFont()->GetLogFont(&lf);
+    lf.lfHeight = -20;
+    lf.lfWeight = FW_BOLD;
+    _tcscpy_s(lf.lfFaceName, _T("Arial"));
+    m_fontNoJob.CreateFontIndirect(&lf);
+    GetDlgItem(IDC_LABEL_NO_JOB)->SetFont(&m_fontNoJob);
+
+
+    // 鍒楄〃鎺т欢
     HIMAGELIST imageList = ImageList_Create(24, 24, ILC_COLOR24, 1, 1);
     ListView_SetImageList(m_listCtrl.GetSafeHwnd(), imageList, LVSIL_SMALL);
-
-    // m_list 宸茬粡鏄璇濇涓婄殑 CExpandableListCtrl 鎴愬憳锛堟嫋鎺т欢鏀圭被锛�
     m_listCtrl.ModifyStyle(0, LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS);
-    m_listCtrl.InsertColumn(0, _T("鍚嶇О"), LVCFMT_LEFT, 260);
-    m_listCtrl.InsertColumn(1, _T("鐘舵��"), LVCFMT_LEFT, 120);
-    m_listCtrl.InsertColumn(2, _T("鎻忚堪"), LVCFMT_LEFT, 260);
+    m_listCtrl.InsertColumn(0, _T("ID"), LVCFMT_LEFT, 180);
+    m_listCtrl.InsertColumn(1, _T("绫诲瀷"), LVCFMT_LEFT, 120);
+    m_listCtrl.InsertColumn(2, _T("鐘舵��"), LVCFMT_LEFT, 120);
+    m_listCtrl.InsertColumn(3, _T("閰嶆柟"), LVCFMT_LEFT, 120);
+    m_listCtrl.InsertColumn(4, _T("Port / Carrier / Slot"), LVCFMT_LEFT, 180);
+    m_listCtrl.InsertColumn(5, _T("鎻忚堪"), LVCFMT_LEFT, 220);
 
-    auto* root1 = m_listCtrl.InsertRoot({ _T("EFEM"), _T("Ready"), _T("Front End Module") });
-    m_listCtrl.InsertChild(root1, { _T("Slot #1"), _T("OK"), _T("150mm wafer") });
-    m_listCtrl.InsertChild(root1, { _T("Slot #2"), _T("Empty"), _T("") });
 
-    auto* root2 = m_listCtrl.InsertRoot({ _T("Bonder"), _T("Run"), _T("G1+G2 Process") });
-    auto* ch21 = m_listCtrl.InsertChild(root2, { _T("Job A"), _T("Proc"), _T("Step 1") });
-    m_listCtrl.InsertChild(ch21, { _T("SubStep A1"), _T("Done"), _T("Align") });
-    m_listCtrl.InsertChild(ch21, { _T("SubStep A2"), _T("Run"),  _T("Bond") });
+    // 鎺т欢鐘舵��
+    Resize();
 
-    // 鍒濆璁╅《灞傚睍寮�
-    root1->expanded = true;
-    root2->expanded = true;
+    // 濡傛灉m_pControlJob涓虹┖锛屽彇master鐨�
+    auto* cj = m_pControlJob;
+    if (cj == nullptr) {
+        cj = theApp.m_model.getMaster().getControlJob();
+    }
 
-    m_listCtrl.RebuildVisible();
+    ShowGroup1(cj == nullptr);
+    ShowGroup2(cj != nullptr);
+    GetDlgItem(IDC_BUTTON_COMPLETION_BATH)->EnableWindow(cj != nullptr);
+    LoadData(cj);
 
 	return TRUE;  // return TRUE unless you set the focus to a control
 				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
 }
+
+void CControlJobDlg::OnSize(UINT nType, int cx, int cy)
+{
+    CDialogEx::OnSize(nType, cx, cy);
+    if (GetDlgItem(IDC_LIST1) == nullptr) return;
+    Resize();
+}
+
+void CControlJobDlg::Resize()
+{
+    CRect rcClient, rcItem;
+    CWnd* pItem;
+
+    GetClientRect(rcClient);
+
+
+    // 鍏抽棴鎸夐挳
+    int y = rcClient.bottom - 12;
+    pItem = GetDlgItem(IDCANCEL);
+    pItem->GetClientRect(&rcItem);
+    pItem->MoveWindow(rcClient.right - 12 - rcItem.Width(),
+        y - rcItem.Height(),
+        rcItem.Width(), rcItem.Height());
+    y -= rcItem.Height();
+    y -= 12;
+
+
+    // 绾�
+    pItem = GetDlgItem(IDC_LINE1);
+    pItem->MoveWindow(12, y, rcClient.Width() - 24, 2);
+    y -= 2;
+
+
+    // Label
+    pItem = GetDlgItem(IDC_LABEL_NO_JOB);
+    pItem->GetClientRect(&rcItem);
+    pItem->MoveWindow((rcClient.Width() - rcItem.Width()) / 2,
+        (y - rcItem.Height()) / 2,
+        rcItem.Width(), rcItem.Height());
+
+
+    // ListCtrl
+    pItem = GetDlgItem(IDC_LIST1);
+    pItem->MoveWindow(12, 12, rcClient.Width() - 24, y - 12);
+}
+
+void CControlJobDlg::ShowGroup1(BOOL bShow)
+{
+    GetDlgItem(IDC_LABEL_NO_JOB)->ShowWindow(bShow ? SW_SHOW : SW_HIDE);
+    GetDlgItem(IDC_LINE1)->ShowWindow(bShow ? SW_SHOW : SW_HIDE);
+}
+
+void CControlJobDlg::ShowGroup2(BOOL bShow)
+{
+    GetDlgItem(IDC_LIST1)->ShowWindow(bShow ? SW_SHOW : SW_HIDE);
+}
+
+void CControlJobDlg::LoadData(SERVO::CControlJob* pControlJob)
+{
+    m_listCtrl.ClearTree();
+    if (pControlJob == nullptr) return;
+
+    auto* root1 = m_listCtrl.InsertRoot({ pControlJob->id().c_str(), _T("ControlJob"),
+            pControlJob->getStateText().c_str(), _T(""), _T(""), pControlJob->failReason().c_str()});
+    auto pjs = pControlJob->getPjs();
+    for (auto pj : pjs) {
+        auto* root2 = m_listCtrl.InsertChild(root1, {pj->id().c_str(),  _T("ProcessJob"),
+                pj->getStateText().c_str(), pj->recipeSpec().c_str(), _T(""), pj->failReason().c_str()});
+        auto cs = pj->carriers();
+        for (auto c : cs) {
+            for (auto g : c.contexts) {
+                SERVO::CGlass* pGlass = (SERVO::CGlass*)g;
+                if (pGlass != nullptr) {
+                    int port, slot;
+                    pGlass->getOrginPort(port, slot);
+                    std::string carrier = c.carrierId + " / Port" + std::to_string(port + 1) + " / Slot" + std::to_string(slot + 1);
+                    m_listCtrl.InsertChild(root2, { pGlass->getID().c_str(), _T("Glass"),
+                        pGlass->getStateText().c_str(), _T(""), carrier.c_str(), _T("") });
+                }
+                else {
+                    m_listCtrl.InsertChild(root2, { "Null", _T("Glass"), _T(""), _T(""), c.carrierId.c_str(), _T("") });
+                }
+            }
+        }
+        root2->expanded = true;
+    }
+    root1->expanded = true;
+    m_listCtrl.RebuildVisible();
+}
+
+void CControlJobDlg::OnBnClickedButtonCompletionBath()
+{
+    if (theApp.m_model.getMaster().completeControlJob("娴嬭瘯鎵嬪姩缁撴壒")) {
+        AfxMessageBox("缁撴壒瀹屾垚");
+    }
+
+    auto* cj = m_pControlJob;
+    if (cj == nullptr) {
+        cj = theApp.m_model.getMaster().getControlJob();
+    }
+
+    ShowGroup1(cj == nullptr);
+    ShowGroup2(cj != nullptr);
+    GetDlgItem(IDC_BUTTON_COMPLETION_BATH)->EnableWindow(cj != nullptr);
+    LoadData(cj);
+}

--
Gitblit v1.9.3