Ver código fonte

添加数据库表操作接口。

JeffWang 2 anos atrás
pai
commit
77a3c662e4

+ 91 - 1
Source/OGCAssistTool/OGCAssistTool/MESdb.cpp

@@ -420,11 +420,101 @@ bool CMESdb::Scan(TString TVSN, TString LineCode, TString PcProcessCode, TString
 
 bool CMESdb::UploadTestData(TString strSN, TString strResult, TString strDateTime)
 {
+	try
+	{
+		CString strSql;
+		//strSql.Format(_T("insert into aaaa(SN,Result,UpdateTime) values ('%s','%s','%s')"), strSN.c_str(), strResult.c_str(), strDateTime.c_str());
+		strSql.Format(_T("insert into aaaa(SN,Result,UpdateTime) values ('%s','%s',GETDATE())"), strSN.c_str(), strResult.c_str());
+
+		m_pConnection3->CursorLocation = adUseClient;
+		m_pConnection3->Execute(_bstr_t(strSql), NULL, adExecuteNoRecords);
+
+		return true;
+	}
+	catch (_com_error &e)
+	{
+		_bstr_t bstrSource(e.Source());
+		_bstr_t bstrDescription(e.Description());
+		//WriteTextLog(_T("%s,%d =>%08lx,%s,%s,%s"), __FUNCTIONW__, __LINE__, e.Error(), e.ErrorMessage(), (TCHAR*)bstrSource, (TCHAR*)bstrDescription);
+	}
+
 	return false;
 }
 
-bool CMESdb::GetDeltaEInfo(TString strBatch, TString &strDeltaEType, TString &strDeltaValue)
+bool CMESdb::GetWhiteid(TString strBom, TString &Whiteid)
+{
+	try
+	{
+		CString strSql;
+		_RecordsetPtr rsData;
+		rsData.CreateInstance(__uuidof(Recordset));
+		strSql.Format(_T("select whiteid,remark from CPCWHITE where bom ='%s'"), strBom.c_str());
+		HRESULT hr = rsData->Open(_variant_t(strSql), _variant_t((IDispatch*)m_pConnection3, true), adOpenDynamic, adLockPessimistic, adCmdText);
+
+		if (SUCCEEDED(hr))
+		{			
+			if (rsData->EndOfFile == VARIANT_FALSE)
+			{
+				Whiteid = rsData->GetCollect(_T("whiteid")).bstrVal;
+			}
+
+			rsData->Close();
+		}
+
+		return Whiteid.size() > 0 ? true : false;
+	}
+	catch (_com_error &e)
+	{
+		_bstr_t bstrSource(e.Source());
+		_bstr_t bstrDescription(e.Description());
+		//WriteTextLog(_T("%s,%d =>%08lx,%s,%s,%s"), __FUNCTIONW__, __LINE__, e.Error(), e.ErrorMessage(), (TCHAR*)bstrSource, (TCHAR*)bstrDescription);
+	}
+
+	return false;
+}
+
+bool CMESdb::GetWhiteValue(TString strWhiteid, TString strWhiteName,TString &strValue)
 {
+	try
+	{
+		CString strSql;
+		_RecordsetPtr rsData;
+		rsData.CreateInstance(__uuidof(Recordset));
+		strSql.Format(_T("select propvalue from CPCWHITELINE where whiteid ='%s' and propname='%s'"), strWhiteid.c_str(), strWhiteName.c_str());
+		HRESULT hr = rsData->Open(_variant_t(strSql), _variant_t((IDispatch*)m_pConnection3, true), adOpenDynamic, adLockPessimistic, adCmdText);
 
+		if (SUCCEEDED(hr))
+		{			
+			if (rsData->EndOfFile == VARIANT_FALSE)
+			{
+				strValue = rsData->GetCollect(_T("propvalue")).bstrVal;
+			}
+
+			rsData->Close();
+		}
+
+		return strValue.size() > 0 ? true : false;
+	}
+	catch (_com_error &e)
+	{
+		_bstr_t bstrSource(e.Source());
+		_bstr_t bstrDescription(e.Description());
+		//WriteTextLog(_T("%s,%d =>%08lx,%s,%s,%s"), __FUNCTIONW__, __LINE__, e.Error(), e.ErrorMessage(), (TCHAR*)bstrSource, (TCHAR*)bstrDescription);
+	}
+
+	return false;
+}
+
+bool CMESdb::GetDeltaEInfo(TString strBatch, TString &strDeltaEType, TString &strDeltaValue)
+{
+	// 1、通过BOM查询whiteid
+	TString strWhiteid;
+	if ( GetWhiteid(strBatch, strWhiteid) )
+	{
+		// 2、通过whiteid查询白平衡参数
+		if ( GetWhiteValue(strWhiteid, _T("DeltaE_Test_Standard"), strDeltaEType) && GetWhiteValue(strWhiteid, _T("DeltaE_Test_Target"), strDeltaValue) )
+			return true;
+	}
+	
 	return false;
 }

+ 2 - 0
Source/OGCAssistTool/OGCAssistTool/MESdb.h

@@ -85,6 +85,8 @@ public:
 		TString &ErroMsg);       //返回错误描述
 	// 上传测试数据;
 	bool UploadTestData(TString strSN, TString strResult, TString strDateTime);
+	bool GetWhiteid(TString strBom, TString &Whiteid);
+	bool GetWhiteValue(TString strWhiteid, TString strWhiteName,TString &strValue);
 	// 获取DeltaE数据;
 	bool GetDeltaEInfo(TString strBatch, TString &strDeltaEType, TString &strDeltaValue);
 };