Переглянути джерело

完成Log界面查询显示

JeffWang 3 роки тому
батько
коміт
e437a27245

+ 86 - 66
Source/OGCAssistTool/OGCAssistTool/DataImpl.cpp

@@ -213,7 +213,7 @@ INT CDataImpl::InsertSN(std::string strOrder, std::string strLine, std::string s
 		return -1;
 
 	char szValue[16] = {0};
-	std::string strInsert = "INSERT INTO DebugSN(OrderID, Line, SN, TestTime, ElapsedTime, TestResult, DEAvgValue, Outcome) VALUES ('";
+	std::string strInsert = "INSERT INTO DebugSN(OrderID, Line, SN, TestTime, ElapsedTime, TestResult, DEAvgValue, DEValue, Outcome) VALUES ('";
 	strInsert.append(strOrder);
 	strInsert.append("','");
 	strInsert.append(strLine);
@@ -234,6 +234,10 @@ INT CDataImpl::InsertSN(std::string strOrder, std::string strLine, std::string s
 	strInsert.append("','");
 	strInsert.append(szValue);
 
+	_gcvt_s(szValue, dDeltaEValue, 3);
+	strInsert.append("','");
+	strInsert.append(szValue);
+
 	strInsert.append("','");
 	strInsert.append(strDetails);
 	strInsert.append("');");
@@ -382,7 +386,9 @@ INT CDataImpl::QuerySNData(std::string strSN, TB_SN &sn_data)
 		sn_data.nTestResult = atoi(pazResult[nCol+5]);
 		sn_data.strDeltaAVGEValue = pazResult[nCol+6];
 		sn_data.dDeltaAVGEValue = atof(pazResult[nCol+6]);
-		sn_data.strDetails = pazResult[nCol+7];
+		sn_data.strDeltaEValue = pazResult[nCol+7];
+		sn_data.dDeltaEValue = atof(pazResult[nCol+7]);
+		sn_data.strDetails = pazResult[nCol+8];
 #else
 		// 由Native for SQLite3插入的数据,都是utf8格式;
 		sn_data.strOrder = CharEncoding::UTF82ASCII(pazResult[nCol+0]);
@@ -395,7 +401,9 @@ INT CDataImpl::QuerySNData(std::string strSN, TB_SN &sn_data)
 		sn_data.nTestResult = atoi(pazResult[nCol+5]);
 		sn_data.strDeltaAVGEValue = CharEncoding::UTF82ASCII(pazResult[nCol+6]);
 		sn_data.dDeltaAVGEValue = atof(pazResult[nCol+6]);
-		sn_data.strDetails = CharEncoding::UTF82ASCII(pazResult[nCol+7]);
+		sn_data.strDeltaEValue = CharEncoding::UTF82ASCII(pazResult[nCol+7]);
+		sn_data.dDeltaEValue = atof(pazResult[nCol+7]);
+		sn_data.strDetails = CharEncoding::UTF82ASCII(pazResult[nCol+8]);
 #endif
 	}
 
@@ -431,30 +439,34 @@ INT CDataImpl::QuerySNData(std::string strOrder, std::vector<TB_SN> &vtSNdata)
 	for(int i = 1; i <= nRow; i++, it++)
 	{
 #ifndef USE_UTF8
-		it->strOrder = pazResult[nCol+0];
-		it->strSN = pazResult[nCol+1];
-		it->strLine = pazResult[nCol+2];
-		it->strTestTime = pazResult[nCol+3];
-		it->strElapsed = pazResult[nCol+4];
+		it->strOrder = pazResult[i*nCol+0];
+		it->strSN = pazResult[i*nCol+1];
+		it->strLine = pazResult[i*nCol+2];
+		it->strTestTime = pazResult[i*nCol+3];
+		it->strElapsed = pazResult[i*nCol+4];
 		it->nElapsed = atoi(it->strElapsed.c_str());
-		it->strTestResult = pazResult[nCol+5];
-		it->nTestResult = atoi(pazResult[nCol+5]);
-		it->strDeltaAVGEValue = pazResult[nCol+6];
-		it->dDeltaAVGEValue = atof(pazResult[nCol+6]);
-		it->strDetails = pazResult[nCol+7];
+		it->strTestResult = pazResult[i*nCol+5];
+		it->nTestResult = atoi(pazResult[i*nCol+5]);
+		it->strDeltaAVGEValue = pazResult[i*nCol+6];
+		it->dDeltaAVGEValue = atof(pazResult[i*nCol+6]);
+		it->strDeltaEValue = pazResult[i*nCol+7];
+		it->dDeltaEValue = atof(pazResult[i*nCol+7]);
+		it->strDetails = pazResult[i*nCol+8];
 #else
 		// 由Native for SQLite3插入的数据,都是utf8格式;
-		it->strOrder = CharEncoding::UTF82ASCII(pazResult[nCol+0]);
-		it->strSN = CharEncoding::UTF82ASCII(pazResult[nCol+1]);
-		it->strLine = CharEncoding::UTF82ASCII(pazResult[nCol+2]);
-		it->strTestTime = CharEncoding::UTF82ASCII(pazResult[nCol+3]);
-		it->strElapsed = CharEncoding::UTF82ASCII(pazResult[nCol+4]);
-		it->nElapsed = atoi(pazResult[nCol+4]);
-		it->strTestResult = CharEncoding::UTF82ASCII(pazResult[nCol+5]);
-		it->nTestResult = atoi(pazResult[nCol+5]);
-		it->strDeltaAVGEValue = CharEncoding::UTF82ASCII(pazResult[nCol+6]);
-		it->dDeltaAVGEValue = atof(pazResult[nCol+6]);
-		it->strDetails = CharEncoding::UTF82ASCII(pazResult[nCol+7]);
+		it->strOrder = CharEncoding::UTF82ASCII(pazResult[i*nCol+0]);
+		it->strSN = CharEncoding::UTF82ASCII(pazResult[i*nCol+1]);
+		it->strLine = CharEncoding::UTF82ASCII(pazResult[i*nCol+2]);
+		it->strTestTime = CharEncoding::UTF82ASCII(pazResult[i*nCol+3]);
+		it->strElapsed = CharEncoding::UTF82ASCII(pazResult[i*nCol+4]);
+		it->nElapsed = atoi(pazResult[i*nCol+4]);
+		it->strTestResult = CharEncoding::UTF82ASCII(pazResult[i*nCol+5]);
+		it->nTestResult = atoi(pazResult[i*nCol+5]);
+		it->strDeltaAVGEValue = CharEncoding::UTF82ASCII(pazResult[i*nCol+6]);
+		it->dDeltaAVGEValue = atof(pazResult[i*nCol+6]);
+		it->strDeltaEValue = CharEncoding::UTF82ASCII(pazResult[i*nCol+7]);
+		it->dDeltaEValue = atof(pazResult[i*nCol+7]);
+		it->strDetails = CharEncoding::UTF82ASCII(pazResult[i*nCol+8]);
 #endif
 	}
 
@@ -492,30 +504,34 @@ INT CDataImpl::QuerySNData(std::vector<TB_SN> &vtSNData, std::string strBeginTim
 	for(int i = 1; i <= nRow; i++, it++)
 	{
 #ifndef USE_UTF8
-		it->strOrder = pazResult[nCol+0];
-		it->strSN = pazResult[nCol+1];
-		it->strLine = pazResult[nCol+2];
-		it->strTestTime = pazResult[nCol+3];
-		it->strElapsed = pazResult[nCol+4];
+		it->strOrder = pazResult[i*nCol+0];
+		it->strSN = pazResult[i*nCol+1];
+		it->strLine = pazResult[i*nCol+2];
+		it->strTestTime = pazResult[i*nCol+3];
+		it->strElapsed = pazResult[i*nCol+4];
 		it->nElapsed = atoi(it->strElapsed.c_str());
-		it->strTestResult = pazResult[nCol+5];
-		it->nTestResult = atoi(pazResult[nCol+5]);
-		it->strDeltaAVGEValue = pazResult[nCol+6];
-		it->dDeltaAVGEValue = atof(pazResult[nCol+6]);
-		it->strDetails = pazResult[nCol+7];
+		it->strTestResult = pazResult[i*nCol+5];
+		it->nTestResult = atoi(pazResult[i*nCol+5]);
+		it->strDeltaAVGEValue = pazResult[i*nCol+6];
+		it->dDeltaAVGEValue = atof(pazResult[i*nCol+6]);
+		it->strDeltaEValue = pazResult[i*nCol+7];
+		it->dDeltaEValue = atof(pazResult[i*nCol+7]);
+		it->strDetails = pazResult[i*nCol+8];
 #else
 		// 由Native for SQLite3插入的数据,都是utf8格式;
-		it->strOrder = CharEncoding::UTF82ASCII(pazResult[nCol+0]);
-		it->strSN = CharEncoding::UTF82ASCII(pazResult[nCol+1]);
-		it->strLine = CharEncoding::UTF82ASCII(pazResult[nCol+2]);
-		it->strTestTime = CharEncoding::UTF82ASCII(pazResult[nCol+3]);
-		it->strElapsed = CharEncoding::UTF82ASCII(pazResult[nCol+4]);
-		it->nElapsed = atoi(pazResult[nCol+4]);
-		it->strTestResult = CharEncoding::UTF82ASCII(pazResult[nCol+5]);
-		it->nTestResult = atoi(pazResult[nCol+5]);
-		it->strDeltaAVGEValue = CharEncoding::UTF82ASCII(pazResult[nCol+6]);
-		it->dDeltaAVGEValue = atof(pazResult[nCol+6]);
-		it->strDetails = CharEncoding::UTF82ASCII(pazResult[nCol+7]);
+		it->strOrder = CharEncoding::UTF82ASCII(pazResult[i*nCol+0]);
+		it->strSN = CharEncoding::UTF82ASCII(pazResult[i*nCol+1]);
+		it->strLine = CharEncoding::UTF82ASCII(pazResult[i*nCol+2]);
+		it->strTestTime = CharEncoding::UTF82ASCII(pazResult[i*nCol+3]);
+		it->strElapsed = CharEncoding::UTF82ASCII(pazResult[i*nCol+4]);
+		it->nElapsed = atoi(pazResult[i*nCol+4]);
+		it->strTestResult = CharEncoding::UTF82ASCII(pazResult[i*nCol+5]);
+		it->nTestResult = atoi(pazResult[i*nCol+5]);
+		it->strDeltaAVGEValue = CharEncoding::UTF82ASCII(pazResult[i*nCol+6]);
+		it->dDeltaAVGEValue = atof(pazResult[i*nCol+6]);
+		it->strDeltaEValue = CharEncoding::UTF82ASCII(pazResult[i*nCol+7]);
+		it->dDeltaEValue = atof(pazResult[i*nCol+7]);
+		it->strDetails = CharEncoding::UTF82ASCII(pazResult[i*nCol+8]);
 #endif
 	}
 
@@ -554,30 +570,34 @@ INT CDataImpl::QuerySNData(std::vector<TB_SN> &vtSNData, std::string strWhere)
 	for(int i = 1; i <= nRow; i++, it++)
 	{
 #ifndef USE_UTF8
-		it->strOrder = pazResult[nCol+0];
-		it->strSN = pazResult[nCol+1];
-		it->strLine = pazResult[nCol+2];
-		it->strTestTime = pazResult[nCol+3];
-		it->strElapsed = pazResult[nCol+4];
+		it->strOrder = pazResult[i*nCol+0];
+		it->strSN = pazResult[i*nCol+1];
+		it->strLine = pazResult[i*nCol+2];
+		it->strTestTime = pazResult[i*nCol+3];
+		it->strElapsed = pazResult[i*nCol+4];
 		it->nElapsed = atoi(it->strElapsed.c_str());
-		it->strTestResult = pazResult[nCol+5];
-		it->nTestResult = atoi(pazResult[nCol+5]);
-		it->strDeltaAVGEValue = pazResult[nCol+6];
-		it->dDeltaAVGEValue = atof(pazResult[nCol+6]);
-		it->strDetails = pazResult[nCol+7];
+		it->strTestResult = pazResult[i*nCol+5];
+		it->nTestResult = atoi(pazResult[i*nCol+5]);
+		it->strDeltaAVGEValue = pazResult[i*nCol+6];
+		it->dDeltaAVGEValue = atof(pazResult[i*nCol+6]);
+		it->strDeltaEValue = pazResult[i*nCol+7];
+		it->dDeltaEValue = atof(pazResult[i*nCol+7]);
+		it->strDetails = pazResult[i*nCol+8];
 #else
 		// 由Native for SQLite3插入的数据,都是utf8格式;
-		it->strOrder = CharEncoding::UTF82ASCII(pazResult[nCol+0]);
-		it->strSN = CharEncoding::UTF82ASCII(pazResult[nCol+1]);
-		it->strLine = CharEncoding::UTF82ASCII(pazResult[nCol+2]);
-		it->strTestTime = CharEncoding::UTF82ASCII(pazResult[nCol+3]);
-		it->strElapsed = CharEncoding::UTF82ASCII(pazResult[nCol+4]);
-		it->nElapsed = atoi(pazResult[nCol+4]);
-		it->strTestResult = CharEncoding::UTF82ASCII(pazResult[nCol+5]);
-		it->nTestResult = atoi(pazResult[nCol+5]);
-		it->strDeltaAVGEValue = CharEncoding::UTF82ASCII(pazResult[nCol+6]);
-		it->dDeltaAVGEValue = atof(pazResult[nCol+6]);
-		it->strDetails = CharEncoding::UTF82ASCII(pazResult[nCol+7]);
+		it->strOrder = CharEncoding::UTF82ASCII(pazResult[i*nCol+0]);
+		it->strSN = CharEncoding::UTF82ASCII(pazResult[i*nCol+1]);
+		it->strLine = CharEncoding::UTF82ASCII(pazResult[i*nCol+2]);
+		it->strTestTime = CharEncoding::UTF82ASCII(pazResult[i*nCol+3]);
+		it->strElapsed = CharEncoding::UTF82ASCII(pazResult[i*nCol+4]);
+		it->nElapsed = atoi(pazResult[i*nCol+4]);
+		it->strTestResult = CharEncoding::UTF82ASCII(pazResult[i*nCol+5]);
+		it->nTestResult = atoi(pazResult[i*nCol+5]);
+		it->strDeltaAVGEValue = CharEncoding::UTF82ASCII(pazResult[i*nCol+6]);
+		it->dDeltaAVGEValue = atof(pazResult[i*nCol+6]);
+		it->strDeltaEValue = CharEncoding::UTF82ASCII(pazResult[i*nCol+7]);
+		it->dDeltaEValue = atof(pazResult[i*nCol+7]);
+		it->strDetails = CharEncoding::UTF82ASCII(pazResult[i*nCol+8]);
 #endif
 	}
 

+ 41 - 6
Source/OGCAssistTool/OGCAssistTool/PageLog.cpp

@@ -31,6 +31,7 @@ void CPageLog::DoDataExchange(CDataExchange* pDX)
 BEGIN_MESSAGE_MAP(CPageLog, CDialogEx)
 	ON_WM_CTLCOLOR()
 	ON_BN_CLICKED(BTN_QUERY, &CPageLog::OnBnClickedQuery)
+	ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST1, &CPageLog::OnNMCustomdrawList1)
 END_MESSAGE_MAP()
 
 
@@ -57,6 +58,7 @@ BOOL CPageLog::OnInitDialog()
 		_T("SN,90"),
 		_T("调试时间,190"),
 		_T("调试耗时,90"),
+		_T("调试结果,90"),
 		_T("▲E实际值,90"),
 		_T("▲E标准值,90"),
 		_T("32组RGB▲E值,300"),
@@ -137,7 +139,10 @@ void CPageLog::OnBnClickedQuery()
 	{
 		CString strOrder;
 		GetDlgItemText(EDIT_BATCH_NUM, strOrder);
-		strWhere.append(" OrderID='");
+		if ( strWhere.size() )
+			strWhere.append(" and OrderID='");
+		else
+			strWhere.append(" OrderID='");
 		strWhere.append(CharEncoding::UNICODE2ASCII((LPWCH)strOrder.GetString()));
 		strWhere.append("'");
 	}
@@ -146,7 +151,10 @@ void CPageLog::OnBnClickedQuery()
 	{
 		CString strSN;
 		GetDlgItemText(EDIT_SN, strSN);
-		strWhere.append(" SN='");
+		if ( strWhere.size() )
+			strWhere.append(" and SN='");
+		else
+			strWhere.append(" SN='");
 		strWhere.append(CharEncoding::UNICODE2ASCII((LPWCH)strSN.GetString()));
 		strWhere.append("'");
 	}
@@ -159,7 +167,10 @@ void CPageLog::OnBnClickedQuery()
 			int nCurSel = pCb->GetCurSel();
 			if ( nCurSel != CB_ERR )
 			{
-				strWhere.append("TestResult='");
+				if ( strWhere.size() )
+					strWhere.append(" and TestResult='");
+				else
+					strWhere.append(" TestResult='");
 				strWhere.append(nCurSel ? "1" : "0");
 				strWhere.append("'");
 			}
@@ -167,7 +178,7 @@ void CPageLog::OnBnClickedQuery()
 	}
 
 	std::vector<TB_SN> vtSNData;
-	if ( GLOBAL::g_db.QuerySNData(vtSNData, strWhere) > 0 )
+	if ( GLOBAL::g_db.QuerySNData(vtSNData, strWhere) != -1 )
 	{
 		UpdateList(vtSNData);
 	}
@@ -186,7 +197,8 @@ void CPageLog::UpdateList(std::vector<TB_SN> &vtSNData)
 		arryString.Add(CharEncoding::ASCII2UNICODE(it->strSN.c_str()));
 		arryString.Add(CharEncoding::ASCII2UNICODE(it->strTestTime.c_str()));
 		arryString.Add(CharEncoding::ASCII2UNICODE(it->strElapsed.c_str()));
-		arryString.Add(CharEncoding::ASCII2UNICODE(it->strDeltaEValue.c_str()));
+		arryString.Add(it->strTestResult == "1" ? _T("PASS") : _T("FAIL"));
+		arryString.Add(CharEncoding::ASCII2UNICODE(it->strDeltaAVGEValue.c_str()));
 		arryString.Add(CharEncoding::ASCII2UNICODE(it->strDeltaEValue.c_str()));
 		arryString.Add(CharEncoding::ASCII2UNICODE(it->strDetails.c_str()));
 
@@ -195,4 +207,27 @@ void CPageLog::UpdateList(std::vector<TB_SN> &vtSNData)
 	}
 	//m_ctrlList.m_AryList.SetSize(vtRGB.size(), 1);
 	m_ctrlList.SetItemCountEx(vtSNData.size());
-}
+}
+
+void CPageLog::OnNMCustomdrawList1(NMHDR *pNMHDR, LRESULT *pResult)
+{
+	NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
+	*pResult = 0;
+	if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
+	{
+		*pResult = CDRF_NOTIFYITEMDRAW;
+	}
+	else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
+	{
+		if ( m_ctrlList.m_AryList.ElementAt(pLVCD->nmcd.dwItemSpec).ElementAt(4) == _T("FAIL") )
+		{
+			pLVCD->clrText = RGB(235,10,10);
+		}
+
+		if ( pLVCD->nmcd.dwItemSpec % 2 )
+			pLVCD->clrTextBk = RGB(204,204,204);
+		else 
+			pLVCD->clrTextBk = RGB(190,190,190);
+		*pResult = CDRF_DODEFAULT;
+	}
+}

+ 1 - 0
Source/OGCAssistTool/OGCAssistTool/PageLog.h

@@ -29,4 +29,5 @@ public:
 	CListSortCtrl m_ctrlList;
 	afx_msg void OnBnClickedQuery();
 	void UpdateList(std::vector<TB_SN> &vtSNData);
+	afx_msg void OnNMCustomdrawList1(NMHDR *pNMHDR, LRESULT *pResult);
 };

+ 1 - 1
Source/OGCAssistTool/OGCAssistTool/TableInfo.h

@@ -60,7 +60,7 @@ PRIMARY KEY(SN));"
 
 // ²éѯ±í;
 #define _SELECT_ORDER_ "SELECT OrderID, DEType, DEValue, Mode, CreateTime FROM DebugOrders"
-#define _SELECT_SN_ "SELECT OrderID, SN,Line,TestTime,ElapsedTime,TestResult,DEAvgValue,Outcome FROM DebugSN"
+#define _SELECT_SN_ "SELECT OrderID, SN,Line,TestTime,ElapsedTime,TestResult,DEAvgValue,DEValue,Outcome FROM DebugSN"
 
 // ɾ³ý¼Ç¼;
 #define _DELETE_ORDER_ ""