From 415ad67bb66ca2d99fb21a8eeb32f942ad2cd7b0 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期一, 09 二月 2026 13:32:42 +0800
Subject: [PATCH] 1.修改为tab页的展示形式

---
 SourceCode/Bond/Servo/CPageGlassList.cpp |  283 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 273 insertions(+), 10 deletions(-)

diff --git a/SourceCode/Bond/Servo/CPageGlassList.cpp b/SourceCode/Bond/Servo/CPageGlassList.cpp
index 801a337..3fbf607 100644
--- a/SourceCode/Bond/Servo/CPageGlassList.cpp
+++ b/SourceCode/Bond/Servo/CPageGlassList.cpp
@@ -24,6 +24,86 @@
 static const COLORREF kWipParentBk = RGB(201, 228, 180); // 鍩虹缁�
 static const COLORREF kWipChildBk = RGB(221, 241, 208); // 鏇存祬涓�鐐�
 
+namespace {
+	CString FormatPathTime(ULONGLONG ts)
+	{
+		if (ts == 0) return _T("");
+		return CString(CToolUnits::timeToString2(ts).c_str());
+	}
+
+	void BuildPathRowsFromGlass(SERVO::CGlass& glass, std::vector<CProcessDataListDlg::PathRow>& rows)
+	{
+		rows.clear();
+		SERVO::CPath* pHead = glass.getPath();
+		if (pHead == nullptr) return;
+
+		SERVO::CPath* p = pHead->getHeadPath();
+		int step = 1;
+		while (p != nullptr) {
+			CProcessDataListDlg::PathRow r;
+			r.step.Format(_T("%d"), step++);
+			std::string eqName = SERVO::CServoUtilsTool::getEqUnitName(
+				(int)p->getEqID(), (int)p->getUnit(), (int)p->getSlot());
+			if (eqName.empty()) {
+				CString tmp;
+				tmp.Format(_T("Eq:%u Unit:%u Slot:%u"), p->getEqID(), p->getUnit(), p->getSlot());
+				r.chamber = tmp;
+			}
+			else {
+				r.chamber = eqName.c_str();
+			}
+			r.enterTime = FormatPathTime(p->getInTime());
+			r.leaveTime = FormatPathTime(p->getOutTime());
+			r.isArmStep = (p->getEqID() == EQ_ID_ARM
+				|| p->getEqID() == EQ_ID_ARM_TRAY1
+				|| p->getEqID() == EQ_ID_ARM_TRAY2);
+			rows.push_back(r);
+			p = p->getNext();
+		}
+	}
+
+	void ParseNameValuePairs(const CString& text, std::vector<std::pair<CString, CString>>& outRows)
+	{
+		outRows.clear();
+		int idx = 0;
+		CString token;
+		while (AfxExtractSubString(token, text, idx, ',')) {
+			++idx;
+			const int pos = token.Find(_T(':'));
+			if (pos < 0) continue;
+			CString name = token.Left(pos);
+			CString value = token.Mid(pos + 1);
+			name.Trim();
+			value.Trim();
+			if (!name.IsEmpty()) {
+				outRows.emplace_back(name, value);
+			}
+		}
+	}
+
+	void BuildBasicRowsFromList(CListCtrl& list, int row, std::vector<std::pair<CString, CString>>& rows)
+	{
+		rows.clear();
+		CHeaderCtrl* pHdr = list.GetHeaderCtrl();
+		const int colCount = pHdr ? pHdr->GetItemCount() : 0;
+		for (int col = 1; col < colCount; ++col) {
+			if (col == 11 || col == 12) continue; // 杩欎袱鍒楀崟鐙綔涓哄叾浠栭〉
+			TCHAR buf[256] = { 0 };
+			LVCOLUMN lvc = {};
+			lvc.mask = LVCF_TEXT;
+			lvc.pszText = buf;
+			lvc.cchTextMax = _countof(buf);
+			CString header;
+			if (list.GetColumn(col, &lvc)) header = lvc.pszText;
+			header.Trim();
+			if (header.IsEmpty()) continue;
+
+			CString val = list.GetItemText(row, col);
+			rows.emplace_back(header, val);
+		}
+	}
+}
+
 // ===== 鏀惧湪 CPageGlassList.cpp 椤堕儴鐨勫尶鍚嶅伐鍏凤紙鏂囦欢鍐呴潤鎬侊級 =====
 // 鎶婂綋鍓嶁�滃凡灞曞紑鈥濈殑鐖惰锛岀敤瀹冧滑鐨� classId锛堢4鍒楁枃鏈級鍋� key 璁板綍涓嬫潵
 static std::unordered_set<std::string> SnapshotExpandedKeys(CExpandableListCtrl& lv) {
@@ -479,6 +559,7 @@
     ON_BN_CLICKED(IDC_BUTTON_PREV_PAGE, &CPageGlassList::OnBnClickedButtonPrevPage)
     ON_BN_CLICKED(IDC_BUTTON_NEXT_PAGE, &CPageGlassList::OnBnClickedButtonNextPage)
     ON_NOTIFY(ELCN_SHOWFULLTEXT, IDC_LIST_ALARM, &CPageGlassList::OnShowFullText)
+    ON_NOTIFY(NM_DBLCLK, IDC_LIST_ALARM, &CPageGlassList::OnNMDblclkListAlarm)
     ON_BN_CLICKED(IDC_BUTTON_EXPORT_ROW, &CPageGlassList::OnBnClickedButtonExportRow)
 END_MESSAGE_MAP()
 
@@ -1088,9 +1169,10 @@
 {
     CDialogEx::OnInitDialog();
 
-    // 瀹氭椂鍣細1=鍒濆鍖栬闃咃紝2=鍛ㄦ湡鍒锋柊锛堝彧澧為噺锛�
+    // 瀹氭椂鍣細1=鍒濆鍖栬闃咃紝2=鍛ㄦ湡鍒锋柊锛堝彧澧為噺锛夛紝3=寤惰繜鍔犺浇棣栧睆鏁版嵁
     SetTimer(1, 3000, nullptr);
     SetTimer(2, 2000, nullptr);
+    SetTimer(3, 10, nullptr);
 
     // 涓嬫媺妗嗘帶浠�
     InitStatusCombo();
@@ -1140,7 +1222,6 @@
     m_listCtrl.SetPopupFullTextColumns({ 11, 12 });
 
     Resize();
-    OnBnClickedButtonSearch(); // 瑙﹀彂涓�娆℃煡璇笌棣栧睆濉厖
 
     return TRUE;  // return TRUE unless you set the focus to a control
 }
@@ -1200,6 +1281,10 @@
     else if (nIDEvent == 2) {
         UpdateWipData();  // 鍙仛澧為噺锛屼笉閲嶅缓
     }
+    else if (nIDEvent == 3) {
+        KillTimer(3);
+        OnBnClickedButtonSearch(); // 寤惰繜棣栧睆鏌ヨ锛岄伩鍏嶅崱浣� OnInitDialog
+    }
 
     CDialogEx::OnTimer(nIDEvent);
 }
@@ -1229,6 +1314,8 @@
 
 void CPageGlassList::OnBnClickedButtonSearch()
 {
+    CWaitCursor wait; // 鏄剧ず绛夊緟鍏夋爣锛屾彁绀烘鍦ㄥ姞杞�
+
     // 鑾峰彇鍏抽敭瀛楄緭鍏ユ鍐呭
     CString strKeyword;
     GetDlgItemText(IDC_EDIT_KEYWORD, strKeyword);
@@ -1572,15 +1659,191 @@
 {
     auto* p = reinterpret_cast<NMC_ELC_SHOWFULLTEXT*>(pNMHDR);
 
-    // 瀵硅瘽妗嗘樉绀哄伐鑹哄弬鏁�
-    if (p->iSubItem == 12) {
-        CProcessDataListDlg dlg;
-        dlg.setRawText(p->text);
-        dlg.DoModal();
-    }
-    else {
+	if (p->iSubItem != 11 && p->iSubItem != 12) {
         AfxMessageBox(p->text);
+        *pResult = 0;
+        return;
     }
+
+    const int row = p->iItem;
+    std::vector<std::pair<CString, CString>> basicRows;
+    std::vector<std::pair<CString, CString>> processRows;
+    std::vector<CProcessDataListDlg::PathRow> pathRows;
+    bool pathOk = false;
+
+    BuildBasicRowsFromList(m_listCtrl, row, basicRows);
+
+    CString paramsText = m_listCtrl.GetItemText(row, 12);
+    ParseNameValuePairs(paramsText, processRows);
+
+    CString strId = m_listCtrl.GetItemText(row, 1); // DB id锛學IP涓虹┖
+    if (!strId.IsEmpty()) {
+        try {
+            auto rec = GlassLogDb::Instance().queryById(_ttoi64(strId));
+            if (rec.has_value() && !rec->pretty.empty()) {
+                SERVO::CGlass tempGlass;
+                if (GlassJson::FromString(rec->pretty, tempGlass)) {
+                    BuildPathRowsFromGlass(tempGlass, pathRows);
+                    pathOk = !pathRows.empty();
+                }
+            }
+        }
+        catch (...) {
+            pathOk = false;
+        }
+    }
+
+    if (!pathOk) {
+        CString cls = m_listCtrl.GetItemText(row, 4); // Class ID
+#ifdef _UNICODE
+        std::string classId = CT2A(cls);
+#else
+        std::string classId = cls.GetString();
+#endif
+        if (!classId.empty()) {
+            std::vector<SERVO::CGlass*> wipGlasses;
+            theApp.m_model.m_master.getWipGlasses(wipGlasses);
+            std::vector<SERVO::CGlass*> tempRetain = wipGlasses;
+            SERVO::CGlass* found = nullptr;
+            for (auto* g : wipGlasses) {
+                if (g == nullptr) continue;
+                if (g->getID() == classId) { found = g; break; }
+                SERVO::CGlass* b = g->getBuddy();
+                if (b != nullptr && b->getID() == classId) { found = b; break; }
+            }
+            if (found != nullptr) {
+                BuildPathRowsFromGlass(*found, pathRows);
+                pathOk = !pathRows.empty();
+            }
+            for (auto* item : tempRetain) {
+                if (item != nullptr) item->release();
+            }
+        }
+    }
+
+    if (!pathOk) {
+        CString pathText = m_listCtrl.GetItemText(row, 11);
+        if (!pathText.IsEmpty()) {
+            int cur = 0;
+            CString token = pathText.Tokenize(_T("->"), cur);
+            int step = 1;
+            while (!token.IsEmpty()) {
+                token.Trim();
+                if (!token.IsEmpty()) {
+                    CProcessDataListDlg::PathRow r;
+                    r.step.Format(_T("%d"), step++);
+                    r.chamber = token;
+                    r.enterTime = _T("");
+                    r.leaveTime = _T("");
+                    CString upper = token;
+                    upper.MakeUpper();
+                    r.isArmStep = (upper.Find(_T("ARM")) >= 0 || upper.Find(_T("TRAY")) >= 0);
+                    pathRows.push_back(r);
+                }
+                token = pathText.Tokenize(_T("->"), cur);
+            }
+        }
+    }
+
+    CProcessDataListDlg dlg;
+    dlg.setUnifiedData(basicRows, pathRows, processRows);
+    dlg.setInitialTab((p->iSubItem == 11) ? 1 : 2);
+    dlg.DoModal();
+
+    *pResult = 0;
+}
+
+void CPageGlassList::OnNMDblclkListAlarm(NMHDR* pNMHDR, LRESULT* pResult)
+{
+    LPNMITEMACTIVATE pItem = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
+    if (pItem == nullptr || pItem->iItem < 0) {
+        *pResult = 0;
+        return;
+    }
+
+    const int row = pItem->iItem;
+    std::vector<std::pair<CString, CString>> basicRows;
+    std::vector<std::pair<CString, CString>> processRows;
+    std::vector<CProcessDataListDlg::PathRow> pathRows;
+    bool pathOk = false;
+
+    BuildBasicRowsFromList(m_listCtrl, row, basicRows);
+
+    CString paramsText = m_listCtrl.GetItemText(row, 12);
+    ParseNameValuePairs(paramsText, processRows);
+
+    CString strId = m_listCtrl.GetItemText(row, 1); // DB id锛學IP涓虹┖
+    if (!strId.IsEmpty()) {
+        try {
+            auto rec = GlassLogDb::Instance().queryById(_ttoi64(strId));
+            if (rec.has_value() && !rec->pretty.empty()) {
+                SERVO::CGlass tempGlass;
+                if (GlassJson::FromString(rec->pretty, tempGlass)) {
+                    BuildPathRowsFromGlass(tempGlass, pathRows);
+                    pathOk = !pathRows.empty();
+                }
+            }
+        }
+        catch (...) {
+            pathOk = false;
+        }
+    }
+
+    if (!pathOk) {
+        CString cls = m_listCtrl.GetItemText(row, 4); // Class ID
+#ifdef _UNICODE
+        std::string classId = CT2A(cls);
+#else
+        std::string classId = cls.GetString();
+#endif
+        if (!classId.empty()) {
+            std::vector<SERVO::CGlass*> wipGlasses;
+            theApp.m_model.m_master.getWipGlasses(wipGlasses);
+            std::vector<SERVO::CGlass*> tempRetain = wipGlasses;
+            SERVO::CGlass* found = nullptr;
+            for (auto* g : wipGlasses) {
+                if (g == nullptr) continue;
+                if (g->getID() == classId) { found = g; break; }
+                SERVO::CGlass* b = g->getBuddy();
+                if (b != nullptr && b->getID() == classId) { found = b; break; }
+            }
+            if (found != nullptr) {
+                BuildPathRowsFromGlass(*found, pathRows);
+                pathOk = !pathRows.empty();
+            }
+            for (auto* item : tempRetain) {
+                if (item != nullptr) item->release();
+            }
+        }
+    }
+
+    if (!pathOk) {
+        CString pathText = m_listCtrl.GetItemText(row, 11);
+        if (!pathText.IsEmpty()) {
+            int cur = 0;
+            CString token = pathText.Tokenize(_T("->"), cur);
+            int step = 1;
+            while (!token.IsEmpty()) {
+                token.Trim();
+                if (!token.IsEmpty()) {
+                    CProcessDataListDlg::PathRow r;
+                    r.step.Format(_T("%d"), step++);
+                    r.chamber = token;
+                    r.enterTime = _T("");
+                    r.leaveTime = _T("");
+                    CString upper = token;
+                    upper.MakeUpper();
+                    r.isArmStep = (upper.Find(_T("ARM")) >= 0 || upper.Find(_T("TRAY")) >= 0);
+                    pathRows.push_back(r);
+                }
+                token = pathText.Tokenize(_T("->"), cur);
+            }
+        }
+    }
+
+    CProcessDataListDlg dlg;
+    dlg.setUnifiedData(basicRows, pathRows, processRows);
+    dlg.DoModal();
 
     *pResult = 0;
 }
@@ -2059,4 +2322,4 @@
     double randomNoise = (rand() % 100 - 50) / 100.0 * variation * 0.3;  // 闅忔満鍣0
     
     return baseValue + timeTrend + randomNoise;
-}
\ No newline at end of file
+}

--
Gitblit v1.9.3