From 48ab1f71c5a005e6f64109a9d9a3b3598a1b2f60 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期四, 03 四月 2025 16:45:55 +0800
Subject: [PATCH] 1. 修复生产履历界面的列表的第一列显示异常问题
---
SourceCode/Bond/Servo/ProductionLogDlg.cpp | 68 +++++++++++++++++----------------
SourceCode/Bond/Servo/ProductionLogDlg.h | 1
2 files changed, 35 insertions(+), 34 deletions(-)
diff --git a/SourceCode/Bond/Servo/ProductionLogDlg.cpp b/SourceCode/Bond/Servo/ProductionLogDlg.cpp
index 5dbadc8..52dbb7e 100644
--- a/SourceCode/Bond/Servo/ProductionLogDlg.cpp
+++ b/SourceCode/Bond/Servo/ProductionLogDlg.cpp
@@ -78,13 +78,6 @@
m_listCtrl.MoveWindow(12, 58, rcClient.Width() - 24, rcClient.Height() - 64);
}
-void CProductionLogDlg::LoadAlarms()
-{
- // 鍒锋柊鍘嗗彶鎶ヨ鏁版嵁
- m_nCurPage = 1;
- UpdatePageData();
-}
-
void CProductionLogDlg::UpdatePageData()
{
// 鏍规嵁杩囨护鏉′欢鍔犺浇鏁版嵁锛堟敮鎸佸垎椤点�佹ā绯婃煡璇€�佹椂闂磋寖鍥达級
@@ -140,20 +133,28 @@
void CProductionLogDlg::InsertStepData(CListCtrl* pListCtrl, const ProductionStep& step)
{
- int nRow = pListCtrl->GetItemCount();
- CString str;
+ if (pListCtrl == nullptr || pListCtrl->m_hWnd == nullptr) {
+ return;
+ }
- str.Format(_T("%d"), step.nStepId); pListCtrl->InsertItem(nRow, str);
- pListCtrl->SetItemText(nRow, 1, step.strProductId.c_str());
- pListCtrl->SetItemText(nRow, 2, step.strBatchNo.c_str());
- str.Format(_T("%d"), step.nDeviceId); pListCtrl->SetItemText(nRow, 3, str);
- pListCtrl->SetItemText(nRow, 4, step.strOperator.c_str());
- pListCtrl->SetItemText(nRow, 5, step.strStartTime.c_str());
- pListCtrl->SetItemText(nRow, 6, step.strEndTime.c_str());
- str.Format(_T("%d"), step.nYield); pListCtrl->SetItemText(nRow, 7, str);
- str.Format(_T("%d"), step.nGoodCount); pListCtrl->SetItemText(nRow, 8, str);
- str.Format(_T("%d"), step.nBadCount); pListCtrl->SetItemText(nRow, 9, str);
- pListCtrl->SetItemText(nRow, 10, step.strStatus.c_str());
+ int nRowCount = pListCtrl->GetItemCount();
+ if (nRowCount >= PAGE_SIZE) {
+ pListCtrl->DeleteItem(nRowCount - 1);
+ }
+
+ CString str;
+ int nNewItem = pListCtrl->InsertItem(0, _T(""));
+ str.Format(_T("%d"), step.nStepId); pListCtrl->SetItemText(nNewItem, 1, str);
+ pListCtrl->SetItemText(nNewItem, 2, step.strProductId.c_str());
+ pListCtrl->SetItemText(nNewItem, 3, step.strBatchNo.c_str());
+ str.Format(_T("%d"), step.nDeviceId); pListCtrl->SetItemText(nNewItem, 4, str);
+ pListCtrl->SetItemText(nNewItem, 5, step.strOperator.c_str());
+ pListCtrl->SetItemText(nNewItem, 6, step.strStartTime.c_str());
+ pListCtrl->SetItemText(nNewItem, 7, step.strEndTime.c_str());
+ str.Format(_T("%d"), step.nYield); pListCtrl->SetItemText(nNewItem, 8, str);
+ str.Format(_T("%d"), step.nGoodCount); pListCtrl->SetItemText(nNewItem, 9, str);
+ str.Format(_T("%d"), step.nBadCount); pListCtrl->SetItemText(nNewItem, 10, str);
+ pListCtrl->SetItemText(nNewItem, 11, step.strStatus.c_str());
}
std::string CProductionLogDlg::getCurrentTimeString()
@@ -211,8 +212,8 @@
// 璇诲彇鍒楀閰嶇疆
CString strIniFile, strItem;
strIniFile.Format(_T("%s\\configuration.ini"), (LPCTSTR)theApp.m_strAppDir);
- int width[11] = { 60, 100, 100, 70, 100, 140, 140, 60, 60, 60, 80 };
- for (int i = 0; i < 11; ++i) {
+ int width[12] = { 0, 60, 100, 100, 70, 100, 140, 140, 60, 60, 60, 80 };
+ for (int i = 0; i < 12; ++i) {
strItem.Format(_T("Col_%d_Width"), i);
width[i] = GetPrivateProfileInt("ProductionListCtrl", strItem, width[i], strIniFile);
}
@@ -226,17 +227,18 @@
HIMAGELIST imageList = ImageList_Create(24, 24, ILC_COLOR24, 1, 1);
ListView_SetImageList(pListCtrl->GetSafeHwnd(), imageList, LVSIL_SMALL);
- pListCtrl->InsertColumn(0, _T("姝ラID"), LVCFMT_LEFT, width[0]);
- pListCtrl->InsertColumn(1, _T("浜у搧ID"), LVCFMT_LEFT, width[1]);
- pListCtrl->InsertColumn(2, _T("鎵规鍙�"), LVCFMT_LEFT, width[2]);
- pListCtrl->InsertColumn(3, _T("璁惧ID"), LVCFMT_LEFT, width[3]);
- pListCtrl->InsertColumn(4, _T("鎿嶄綔鍛�"), LVCFMT_LEFT, width[4]);
- pListCtrl->InsertColumn(5, _T("寮�濮嬫椂闂�"), LVCFMT_LEFT, width[5]);
- pListCtrl->InsertColumn(6, _T("缁撴潫鏃堕棿"), LVCFMT_LEFT, width[6]);
- pListCtrl->InsertColumn(7, _T("浜ч噺"), LVCFMT_LEFT, width[7]);
- pListCtrl->InsertColumn(8, _T("鑹搧鏁�"), LVCFMT_LEFT, width[8]);
- pListCtrl->InsertColumn(9, _T("涓嶈壇鍝佹暟"), LVCFMT_LEFT, width[9]);
- pListCtrl->InsertColumn(10, _T("鐘舵��"), LVCFMT_LEFT, width[10]);
+ pListCtrl->InsertColumn(0, _T(""), LVCFMT_RIGHT, width[0]);
+ pListCtrl->InsertColumn(1, _T("姝ラID"), LVCFMT_LEFT, width[1]);
+ pListCtrl->InsertColumn(2, _T("浜у搧ID"), LVCFMT_LEFT, width[2]);
+ pListCtrl->InsertColumn(3, _T("鎵规鍙�"), LVCFMT_LEFT, width[3]);
+ pListCtrl->InsertColumn(4, _T("璁惧ID"), LVCFMT_LEFT, width[4]);
+ pListCtrl->InsertColumn(5, _T("鎿嶄綔鍛�"), LVCFMT_LEFT, width[5]);
+ pListCtrl->InsertColumn(6, _T("寮�濮嬫椂闂�"), LVCFMT_LEFT, width[6]);
+ pListCtrl->InsertColumn(7, _T("缁撴潫鏃堕棿"), LVCFMT_LEFT, width[7]);
+ pListCtrl->InsertColumn(8, _T("浜ч噺"), LVCFMT_LEFT, width[8]);
+ pListCtrl->InsertColumn(9, _T("鑹搧鏁�"), LVCFMT_LEFT, width[9]);
+ pListCtrl->InsertColumn(10, _T("涓嶈壇鍝佹暟"), LVCFMT_LEFT, width[10]);
+ pListCtrl->InsertColumn(11, _T("鐘舵��"), LVCFMT_LEFT, width[11]);
// 鍒濆鍖栧垎椤垫暟鎹�
int totalRecords = ProductionLogManager::getInstance().getTotalStepCount(
diff --git a/SourceCode/Bond/Servo/ProductionLogDlg.h b/SourceCode/Bond/Servo/ProductionLogDlg.h
index 44f8d03..f9ff622 100644
--- a/SourceCode/Bond/Servo/ProductionLogDlg.h
+++ b/SourceCode/Bond/Servo/ProductionLogDlg.h
@@ -17,7 +17,6 @@
private:
void InitRxWindow();
void Resize();
- void LoadAlarms();
void UpdatePageData();
void UpdatePageControls();
void FillDataToListCtrl(CListCtrl* pListCtrl, const std::vector<ProductionStep>& vecSteps);
--
Gitblit v1.9.3