From 29f9008039e21f377d968ee67cb26d3cf8363809 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 11 九月 2025 15:37:54 +0800
Subject: [PATCH] 1.修复数据库类联G1和Buddy的问题;
---
SourceCode/Bond/Servo/CPageGlassList.cpp | 183 +++++++++++++++++++++++++++------------------
1 files changed, 108 insertions(+), 75 deletions(-)
diff --git a/SourceCode/Bond/Servo/CPageGlassList.cpp b/SourceCode/Bond/Servo/CPageGlassList.cpp
index 62a83f6..fdbdcd4 100644
--- a/SourceCode/Bond/Servo/CPageGlassList.cpp
+++ b/SourceCode/Bond/Servo/CPageGlassList.cpp
@@ -520,10 +520,10 @@
{
m_rebuilding = true;
- // 鏀惧湪浠讳綍娓呯┖/閲嶅缓鍔ㄤ綔涔嬪墠锛�
+ // 鏀惧湪浠讳綍娓呯┖/閲嶅缓鍔ㄤ綔涔嬪墠锛氳褰曞睍寮�鐨勭埗鑺傜偣 key锛圕lassID锛�
auto expandedKeys = SnapshotExpandedKeys(m_listCtrl);
- // 鈥斺�� 鍙屼繚闄╋細鍏堟竻鎺夊彲瑙侀」锛屽啀娓呮爲缁撴瀯 鈥斺��
+ // 鈥斺�� 鍙屼繚闄╋細鍏堟竻鎺夊彲瑙侀」锛屽啀娓呮爲缁撴瀯 鈥斺��
m_listCtrl.SetRedraw(FALSE);
m_listCtrl.DeleteAllItems();
m_listCtrl.SetRedraw(TRUE);
@@ -532,7 +532,7 @@
m_listCtrl.ClearTree();
const int colCount = m_listCtrl.GetHeaderCtrl() ? m_listCtrl.GetHeaderCtrl()->GetItemCount() : 0;
- if (colCount <= 0) return;
+ if (colCount <= 0) { m_rebuilding = false; return; }
// ==================== 1) WIP锛氫粎绗� 1 椤垫瀯寤猴紝涓旀斁鍦ㄦ渶椤堕儴 ====================
if (m_nCurPage == 1) {
@@ -551,9 +551,11 @@
SERVO::CGlass* b = g->getBuddy();
if (b) {
+ // 鎸変綘鐨勭害瀹氾細g 鏄埗锛宐uddy 鏄瓙
SERVO::CGlass* parent = g;
SERVO::CGlass* child = b;
+ // parent
std::vector<CString> pcols(colCount);
pcols[1] = _T("");
pcols[2] = std::to_string(parent->getCassetteSequenceNo()).c_str();
@@ -572,6 +574,7 @@
MaybeRestoreExpandByKey(nParent, expandedKeys);
m_listCtrl.SetNodeColor(nParent, kWipText, kWipParentBk); // 鐖讹細鍩虹缁�
+ // child
std::vector<CString> ccols(colCount);
ccols[1] = _T("");
ccols[2] = std::to_string(child->getCassetteSequenceNo()).c_str();
@@ -615,7 +618,7 @@
for (auto* item : tempGlasses) item->release();
}
- // ==================== 2) DB 褰撳墠椤碉紙鏃犺绗嚑椤甸兘鏋勫缓锛涙帓鍦� WIP 涔嬪悗锛� ====================
+ // ==================== 2) DB 褰撳墠椤碉紙涓ら樁娈垫瀯寤猴紝澶勭悊鍗曞悜 buddy锛� ====================
#if USE_FAKE_DB_DEMO
auto page = _make_page_fake(m_filters, PAGE_SIZE, PAGE_SIZE * (m_nCurPage - 1));
#else
@@ -623,99 +626,128 @@
auto page = db.queryPaged(m_filters, PAGE_SIZE, PAGE_SIZE * (m_nCurPage - 1));
#endif
+ // 寤虹储寮曪細classId -> index
std::unordered_map<std::string, size_t> idxById;
idxById.reserve(page.items.size());
- for (size_t i = 0; i < page.items.size(); ++i) idxById[page.items[i].classId] = i;
+ for (size_t i = 0; i < page.items.size(); ++i) {
+ idxById[page.items[i].classId] = i;
+ }
- std::unordered_set<std::string> usedDb;
+ // 宸叉秷璐癸紙宸叉彃鍏ヤ负鐖舵垨瀛愶級
+ std::unordered_set<std::string> consumed;
int zebra = 0;
+ auto zebraBk = [&](int z) -> COLORREF {
+ return (z % 2 == 0) ? RGB(255, 255, 255) : RGB(235, 235, 235);
+ };
+ // -------- Phase 1: 鍏堝鐞嗏�滄湁 buddyId 鐨勮褰曗�濓紙鑳介厤灏遍厤锛涘崟鍚戜篃閰嶏級 ----------
for (size_t i = 0; i < page.items.size(); ++i) {
const auto& r = page.items[i];
- if (usedDb.count(r.classId)) continue;
+ if (consumed.count(r.classId)) continue;
+ if (r.buddyId.empty()) continue;
- COLORREF bk = (zebra % 2 == 0) ? RGB(255, 255, 255) : RGB(235, 235, 235);
- bool paired = false;
+ COLORREF bk = zebraBk(zebra);
- if (!r.buddyId.empty()) {
- auto it = idxById.find(r.buddyId);
- if (it != idxById.end()) {
- const auto& br = page.items[it->second];
- if (!usedDb.count(br.classId)) {
- bool rIsParent = (r.classId <= br.classId);
- const auto& parentRec = rIsParent ? r : br;
- const auto& childRec = rIsParent ? br : r;
+ auto it = idxById.find(r.buddyId);
+ if (it != idxById.end()) {
+ const auto& br = page.items[it->second];
+ if (!consumed.count(br.classId)) {
+ // 鈥斺�� 浠モ�滄湁 buddyId 鐨勮繖鏉� r鈥濅负鐖讹紝buddy 浣滀负瀛愶紙鍗曞悜涔熻兘閰嶏級鈥斺��
+ std::vector<CString> pcols(colCount);
+ pcols[1] = std::to_string(r.id).c_str();
+ pcols[2] = std::to_string(r.cassetteSeqNo).c_str();
+ pcols[3] = std::to_string(r.jobSeqNo).c_str();
+ pcols[4] = r.classId.c_str();
+ pcols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)r.materialType).c_str();
+ pcols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)r.state).c_str();
+ pcols[7] = r.tStart.c_str();
+ pcols[8] = r.tEnd.c_str();
+ pcols[9] = r.buddyId.c_str();
+ pcols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)r.aoiResult).c_str();
+ pcols[11] = r.path.c_str();
+ pcols[12] = r.params.c_str();
- std::vector<CString> pcols(colCount);
- pcols[1] = std::to_string(parentRec.id).c_str(); pcols[2] = std::to_string(parentRec.cassetteSeqNo).c_str();
- pcols[3] = std::to_string(parentRec.jobSeqNo).c_str(); pcols[4] = parentRec.classId.c_str();
- pcols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)parentRec.materialType).c_str();
- pcols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)parentRec.state).c_str();
- pcols[7] = parentRec.tStart.c_str(); pcols[8] = parentRec.tEnd.c_str(); pcols[9] = parentRec.buddyId.c_str();
- pcols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)parentRec.aoiResult).c_str();
- pcols[11] = parentRec.path.c_str(); pcols[12] = parentRec.params.c_str();
+ auto* nParent = m_listCtrl.InsertRoot(pcols);
+ MaybeRestoreExpandByKey(nParent, expandedKeys);
+ m_listCtrl.SetNodeColor(nParent, RGB(0, 0, 0), bk);
- auto* nParent = m_listCtrl.InsertRoot(pcols);
- MaybeRestoreExpandByKey(nParent, expandedKeys);
- m_listCtrl.SetNodeColor(nParent, RGB(0, 0, 0), bk);
+ std::vector<CString> ccols(colCount);
+ ccols[1] = std::to_string(br.id).c_str();
+ ccols[2] = std::to_string(br.cassetteSeqNo).c_str();
+ ccols[3] = std::to_string(br.jobSeqNo).c_str();
+ ccols[4] = br.classId.c_str();
+ ccols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)br.materialType).c_str();
+ ccols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)br.state).c_str();
+ ccols[7] = br.tStart.c_str();
+ ccols[8] = br.tEnd.c_str();
+ ccols[9] = br.buddyId.c_str();
+ ccols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)br.aoiResult).c_str();
+ ccols[11] = br.path.c_str();
+ ccols[12] = br.params.c_str();
- std::vector<CString> ccols(colCount);
- ccols[1] = std::to_string(childRec.id).c_str(); ccols[2] = std::to_string(childRec.cassetteSeqNo).c_str();
- ccols[3] = std::to_string(childRec.jobSeqNo).c_str(); ccols[4] = childRec.classId.c_str();
- ccols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)childRec.materialType).c_str();
- ccols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)childRec.state).c_str();
- ccols[7] = childRec.tStart.c_str(); ccols[8] = childRec.tEnd.c_str(); ccols[9] = childRec.buddyId.c_str();
- ccols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)childRec.aoiResult).c_str();
- ccols[11] = childRec.path.c_str(); ccols[12] = childRec.params.c_str();
+ auto* nChild = m_listCtrl.InsertChild(nParent, ccols);
+ m_listCtrl.SetNodeColor(nChild, RGB(0, 0, 0), bk);
- auto* nChild = m_listCtrl.InsertChild(nParent, ccols);
- m_listCtrl.SetNodeColor(nChild, RGB(0, 0, 0), bk);
-
- usedDb.insert(parentRec.classId);
- usedDb.insert(childRec.classId);
- paired = true;
- }
+ consumed.insert(r.classId);
+ consumed.insert(br.classId);
+ ++zebra;
+ continue;
}
}
- if (!paired && !r.buddyId.empty()) {
- std::vector<CString> pcols(colCount);
- pcols[1] = std::to_string(r.id).c_str(); pcols[2] = std::to_string(r.cassetteSeqNo).c_str();
- pcols[3] = std::to_string(r.jobSeqNo).c_str(); pcols[4] = r.classId.c_str();
- pcols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)r.materialType).c_str();
- pcols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)r.state).c_str();
- pcols[7] = r.tStart.c_str(); pcols[8] = r.tEnd.c_str(); pcols[9] = r.buddyId.c_str();
- pcols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)r.aoiResult).c_str();
- pcols[11] = r.path.c_str(); pcols[12] = r.params.c_str();
+ // 鍚岄〉娌℃壘鍒� buddy锛堟垨宸茶娑堣垂锛夆啋 鎻掑崰浣嶅瓙琛�
+ std::vector<CString> pcols(colCount);
+ pcols[1] = std::to_string(r.id).c_str();
+ pcols[2] = std::to_string(r.cassetteSeqNo).c_str();
+ pcols[3] = std::to_string(r.jobSeqNo).c_str();
+ pcols[4] = r.classId.c_str();
+ pcols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)r.materialType).c_str();
+ pcols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)r.state).c_str();
+ pcols[7] = r.tStart.c_str();
+ pcols[8] = r.tEnd.c_str();
+ pcols[9] = r.buddyId.c_str();
+ pcols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)r.aoiResult).c_str();
+ pcols[11] = r.path.c_str();
+ pcols[12] = r.params.c_str();
- auto* nParent = m_listCtrl.InsertRoot(pcols);
- MaybeRestoreExpandByKey(nParent, expandedKeys);
- m_listCtrl.SetNodeColor(nParent, RGB(0, 0, 0), bk);
+ auto* nParent = m_listCtrl.InsertRoot(pcols);
+ MaybeRestoreExpandByKey(nParent, expandedKeys);
+ m_listCtrl.SetNodeColor(nParent, RGB(0, 0, 0), bk);
- std::vector<CString> ccols(colCount);
- ccols[4] = r.buddyId.c_str(); // 鍗犱綅瀛愯锛氭樉绀� buddy 鐨� classId
- auto* nChild = m_listCtrl.InsertChild(nParent, ccols);
- m_listCtrl.SetNodeColor(nChild, RGB(0, 0, 0), bk);
+ std::vector<CString> ccols(colCount); // 鍗犱綅鍙啓 ClassID
+ ccols[4] = r.buddyId.c_str();
+ auto* nChild = m_listCtrl.InsertChild(nParent, ccols);
+ m_listCtrl.SetNodeColor(nChild, RGB(0, 0, 0), bk);
- usedDb.insert(r.classId);
- paired = true;
- }
+ consumed.insert(r.classId);
+ ++zebra;
+ }
- if (!paired) {
- std::vector<CString> cols(colCount);
- cols[1] = std::to_string(r.id).c_str(); cols[2] = std::to_string(r.cassetteSeqNo).c_str();
- cols[3] = std::to_string(r.jobSeqNo).c_str(); cols[4] = r.classId.c_str();
- cols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)r.materialType).c_str();
- cols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)r.state).c_str();
- cols[7] = r.tStart.c_str(); cols[8] = r.tEnd.c_str(); cols[9] = r.buddyId.c_str();
- cols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)r.aoiResult).c_str();
- cols[11] = r.path.c_str(); cols[12] = r.params.c_str();
+ // -------- Phase 2: 鍓╀綑鏈秷璐圭殑锛屼綔涓衡�滃崟鏉℃牴琛屸�� ----------
+ for (size_t i = 0; i < page.items.size(); ++i) {
+ const auto& r = page.items[i];
+ if (consumed.count(r.classId)) continue;
- auto* n = m_listCtrl.InsertRoot(cols);
- m_listCtrl.SetNodeColor(n, RGB(0, 0, 0), bk);
- usedDb.insert(r.classId);
- }
+ COLORREF bk = zebraBk(zebra);
+ std::vector<CString> cols(colCount);
+ cols[1] = std::to_string(r.id).c_str();
+ cols[2] = std::to_string(r.cassetteSeqNo).c_str();
+ cols[3] = std::to_string(r.jobSeqNo).c_str();
+ cols[4] = r.classId.c_str();
+ cols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)r.materialType).c_str();
+ cols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)r.state).c_str();
+ cols[7] = r.tStart.c_str();
+ cols[8] = r.tEnd.c_str();
+ cols[9] = r.buddyId.c_str();
+ cols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)r.aoiResult).c_str();
+ cols[11] = r.path.c_str();
+ cols[12] = r.params.c_str();
+
+ auto* n = m_listCtrl.InsertRoot(cols);
+ m_listCtrl.SetNodeColor(n, RGB(0, 0, 0), bk);
+
+ consumed.insert(r.classId);
++zebra;
}
@@ -728,6 +760,7 @@
m_rebuilding = false;
}
+
void CPageGlassList::UpdatePageControls()
{
CString strPage;
--
Gitblit v1.9.3