Bladeren bron

1、删除所有表中无用的status字段,有date日期字段即可,不用重复字段;
2、新增查询订单sn总数、sn实际数量、抄写成功数量、上报成功数量函数;
3、新增删除指定订单号所有表数据函数;

Jeff 5 jaren geleden
bovenliggende
commit
bac637d678

+ 123 - 95
scbc.tools/scbc.tools/DataImpl.cpp

@@ -23,32 +23,36 @@ PRIMARY KEY (bid ASC));"
 #define _INSERT_MID_TABLE_ "INSERT INTO mid(bid, number, pid, ctype, version, purl, psize, pmd5)VALUES\
 (%s, %s, %s, %s, %s, %s, %s, %s);"
 
-// KeyCopy表;
+// Key表;
 #define _CREATE_KEYS_TABLE_ \
 	"CREATE TABLE keys \
-(pid  INTEGER NOT NULL,\
+(bid  TEXT(16) NOT NULL,\
 sn  TEXT(32) PRIMARY KEY NOT NULL,\
+pid  INTEGER NOT NULL,\
 keys  TEXT NOT NULL,\
 copy_date  DATETIME DEFAULT '',\
-report_date  DATETIME DEFAULT '',\
-copy_status  INTEGER NOT NULL DEFAULT 0,\
-report_status  INTEGER NOT NULL DEFAULT 0);"
-#define _SELECT_KEYS_TABLE_ "SELECT pid, sn, keys, copy_date, report_date, copy_status, report_status FROM keys"
+report_date  DATETIME DEFAULT '');"
+#define _SELECT_KEYS_TABLE_ "SELECT bid, pid, sn, keys, copy_date, report_date FROM keys"
 
 // Log表;
 #define _CREATE_LOG_TABLE_ \
 	"CREATE TABLE log \
-(type  TEXT(32) NOT NULL,\
-sn  TEXT NOT NULL,\
+(bid  TEXT(16) NOT NULL,\
+type  TEXT(32) NOT NULL,\
+sn  TEXT(32) NOT NULL,\
 content  TEXT NOT NULL,\
 gdate  DATETIME DEFAULT current_timestamp,\
 report_date  DATETIME DEFAULT '',\
-report_status  INTEGER NOT NULL DEFAULT 0,\
 PRIMARY KEY (type, sn));"
-#define _SELECT_LOG_TABLE_ "SELECT type, sn, content, gdate, report_status FROM log"
+#define _SELECT_LOG_TABLE_ "SELECT type, bid, sn, content, gdate, report_date FROM log"
 
+#define _SELECT_BID_INFO__ \
+"select mid.number as tc, \
+count(keys.bid) as ac,\
+count(case when keys.copy_date <> '' then '抄写成功' end) as cc,\
+count(case when keys.report_date <> '' and keys.copy_date <> '' then '上报成功' end) as rc \
+from mid inner join keys on mid.bid = keys.bid where mid.bid = '%s';"
 
-//#define FREE_MSG if ( m_pszErrmsg ) { printf(m_pszErrmsg);sqlite3_free(m_pszErrmsg); m_pszErrmsg = NULL;}
 #define FREE_MSG if ( psqlite_error )  \
 	printf("%s\n",psqlite_error),\
 	sqlite3_free(psqlite_error),\
@@ -138,7 +142,7 @@ BOOL CDataImpl::QueryTable(std::string table)
 {
 	if ( table.size() == 0 )
 	{
-		//Global::WriteTextLog(_T("ExecteSQL:执行语句空!"));
+		//Global::WriteTextLog(_T("QueryTable:表名空!"));
 		return FALSE;
 	}
 
@@ -155,7 +159,7 @@ BOOL CDataImpl::QueryTable(std::string table)
 	int sqlite_error = sqlite3_get_table(m_psqlite3, szSql, &pazResult, &nRow, &nCol, &psqlite_error);
 	if ( sqlite_error != SQLITE_OK)
 	{
-		//Global::WriteTextLog(_T("QueryContactsType:%s"), m_pszErrmsg);
+		//Global::WriteTextLog(_T("QueryTable:%s"), psqlite_error);
 		FREE_MSG;
 		return FALSE;
 	}
@@ -183,7 +187,7 @@ INT CDataImpl::QueryMidInfo(std::string order, STMid &data)
 	int sqlite_error = sqlite3_get_table(m_psqlite3, strSql.c_str(), &pazResult, &nRow, &nCol, &psqlite_error);
 	if ( sqlite_error != SQLITE_OK)
 	{
-		//Global::WriteTextLog(_T("QueryContactsType:%s"), m_pszErrmsg);
+		//Global::WriteTextLog(_T("QueryMidInfo:%s"), psqlite_error);
 		FREE_MSG;
 		return -1;
 	}
@@ -225,6 +229,7 @@ INT CDataImpl::QueryMidInfo(std::string order, STMid &data)
 	return nRow;
 }
 
+// 主要返回keys,用于抄写;
 INT CDataImpl::QueryKeyInfo(std::string sn, STKeys &data)
 {
 	if ( m_psqlite3 == NULL )
@@ -242,31 +247,19 @@ INT CDataImpl::QueryKeyInfo(std::string sn, STKeys &data)
 	int sqlite_error = sqlite3_get_table(m_psqlite3, strSql.c_str(), &pazResult, &nRow, &nCol, &psqlite_error);
 	if ( sqlite_error != SQLITE_OK)
 	{
-		//Global::WriteTextLog(_T("QueryContactsInfo:%s"), m_pszErrmsg);
+		//Global::WriteTextLog(_T("QueryKeyInfo:%s"), psqlite_error);
 		FREE_MSG;
 		return -1;
 	}
 
 	if ( nRow == 1)
 	{
-#ifndef USE_UTF8
-		data.pid = pazResult[nCol+0];
-		data.sn = pazResult[nCol+1];
-		data.keys = pazResult[nCol+2];
-		data.copy_date = pazResult[nCol+3];
-		data.report_date = pazResult[nCol+4];
-		data.copy_status = pazResult[nCol+5];
-		data.report_status = pazResult[nCol+6];
-#else
-		// 由Native for SQLite3插入的数据,都是utf8格式;
-		data.pid = pazResult[nCol+0];
-		data.sn = CharEncoding::UTF82ASCII(pazResult[nCol+1]);
-		data.keys = CharEncoding::UTF82ASCII(pazResult[nCol+2]);
-		data.copy_date = CharEncoding::UTF82ASCII(pazResult[nCol+3]);
-		data.report_date = CharEncoding::UTF82ASCII(pazResult[nCol+4]);
-		data.copy_status = pazResult[nCol+5];
-		data.report_status = pazResult[nCol+6];
-#endif
+		data.bid = pazResult[nCol+0];
+		data.pid = pazResult[nCol+1];
+		data.sn = pazResult[nCol+2];
+		data.keys = pazResult[nCol+3];
+		data.copy_date = pazResult[nCol+4];
+		data.report_date = pazResult[nCol+5];
 	}
 
 	sqlite3_free_table(pazResult);
@@ -284,11 +277,11 @@ INT CDataImpl::QueryUnReportKeyInfo(std::vector<STKeys> &vtdata)
 
 	char** pazResult = NULL;
 	char* psqlite_error = NULL;
-	std::string strSql = "SELECT sn,copy_date FROM keys WHERE copy_date <> '' and report_status in(0,-1)";
+	std::string strSql = "SELECT sn,copy_date FROM keys WHERE copy_date <> '' and report_date = ''";
 	int sqlite_error = sqlite3_get_table(m_psqlite3, strSql.c_str(), &pazResult, &nRow, &nCol, &psqlite_error);
 	if ( sqlite_error != SQLITE_OK)
 	{
-		//Global::WriteTextLog(_T("QueryContactsInfo:%s"), m_pszErrmsg);
+		//Global::WriteTextLog(_T("QueryUnReportKeyInfo:%s"), psqlite_error);
 		FREE_MSG;
 		return -1;
 	}
@@ -319,7 +312,7 @@ INT CDataImpl::QueryLogInfo(std::string sn, STLog &data)
 	int sqlite_error = sqlite3_get_table(m_psqlite3, _SELECT_LOG_TABLE_, &pazResult, &nRow, &nCol, &psqlite_error);
 	if ( sqlite_error != SQLITE_OK)
 	{
-		//Global::WriteTextLog(_T("QueryTaskInfo:%s"), m_pszErrmsg);
+		//Global::WriteTextLog(_T("QueryLogInfo:%s"), psqlite_error);
 		FREE_MSG;
 		return -1;
 	}
@@ -328,17 +321,19 @@ INT CDataImpl::QueryLogInfo(std::string sn, STLog &data)
 	{
 #ifndef USE_UTF8
 		data.type = pazResult[nCol+0];
-		data.sn = pazResult[nCol+1];
-		data.content = pazResult[nCol+2];
-		data.gdate = pazResult[nCol+3];
-		data.report_status = pazResult[nCol+4];
+		data.bid = pazResult[nCol+1];
+		data.sn = pazResult[nCol+2];
+		data.content = pazResult[nCol+3];
+		data.gdate = pazResult[nCol+4];
+		data.report_date = pazResult[nCol+5];
 #else
 		// 由Native for SQLite3插入的数据,都是utf8格式;
 		data.type = CharEncoding::UTF82ASCII(pazResult[nCol+0]);
-		data.sn = CharEncoding::UTF82ASCII(pazResult[nCol+1]);
-		data.content = CharEncoding::UTF82ASCII(pazResult[nCol+2]);
-		data.gdate = pazResult[nCol+3];
-		data.report_status = pazResult[nCol+4];
+		data.bid = CharEncoding::UTF82ASCII(pazResult[nCol+1]);
+		data.sn = CharEncoding::UTF82ASCII(pazResult[nCol+2]);
+		data.content = CharEncoding::UTF82ASCII(pazResult[nCol+3]);
+		data.gdate = pazResult[nCol+4];
+		data.report_date = pazResult[nCol+5];
 #endif
 	}
 
@@ -357,11 +352,11 @@ INT CDataImpl::QueryUnReportLogInfo(std::vector<STLog> &vtdata)
 
 	char** pazResult = NULL;
 	char* psqlite_error = NULL;
-	std::string strSql = "SELECT type, sn, content, gdate FROM log WHERE report_status in(0,-1)";
+	std::string strSql = "SELECT type, bid, sn, content, gdate FROM log WHERE report_date = ''";
 	int sqlite_error = sqlite3_get_table(m_psqlite3, strSql.c_str(), &pazResult, &nRow, &nCol, &psqlite_error);
 	if ( sqlite_error != SQLITE_OK)
 	{
-		//Global::WriteTextLog(_T("QueryContactsInfo:%s"), m_pszErrmsg);
+		//Global::WriteTextLog(_T("QueryUnReportLogInfo:%s"), psqlite_error);
 		FREE_MSG;
 		return -1;
 	}
@@ -371,9 +366,43 @@ INT CDataImpl::QueryUnReportLogInfo(std::vector<STLog> &vtdata)
 	for(int i = 1; i <= nRow; i++, it++)
 	{
 		it->type = pazResult[i*nCol+0];
-		it->sn= pazResult[i*nCol+1];
-		it->content= pazResult[i*nCol+2];
-		it->gdate= pazResult[i*nCol+3];
+		it->bid= pazResult[i*nCol+1];
+		it->sn= pazResult[i*nCol+2];
+		it->content= pazResult[i*nCol+3];
+		it->gdate= pazResult[i*nCol+4];
+	}
+
+	sqlite3_free_table(pazResult);
+
+	return nRow;
+}
+
+INT CDataImpl::QueryBidInfo(std::string order, BidInfo& binfo)
+{
+	if ( m_psqlite3 == NULL )
+		return -1;
+
+	INT nRow = 0;
+	INT nCol = 0;
+
+	char** pazResult = NULL;
+	char* psqlite_error = NULL;
+	TCHAR szSQL[1024] = {0};
+	_stprintf_s(szSQL, _SELECT_BID_INFO__, order.c_str());
+	int sqlite_error = sqlite3_get_table(m_psqlite3, szSQL, &pazResult, &nRow, &nCol, &psqlite_error);
+	if ( sqlite_error != SQLITE_OK)
+	{
+		//Global::WriteTextLog(_T("QueryUnReportLogInfo:%s"), psqlite_error);
+		FREE_MSG;
+		return -1;
+	}
+
+	if ( nRow == 1 )
+	{
+		binfo.tcount = pazResult[nCol+0];
+		binfo.sn_count = pazResult[nCol+1];
+		binfo.copy_count = pazResult[nCol+2];
+		binfo.report_count = pazResult[nCol+3];
 	}
 
 	sqlite3_free_table(pazResult);
@@ -408,7 +437,7 @@ INT CDataImpl::InsertMidInfo(STMid &data)
 	int sqlite_error = sqlite3_exec(m_psqlite3, strInsert.c_str(), NULL, 0, &psqlite_error);
 	if(SQLITE_OK != sqlite_error)
 	{
-		//Global::WriteTextLog(_T("InsertContactsType:%s"), psqlite_error);
+		//Global::WriteTextLog(_T("InsertMidInfo:%s"), psqlite_error);
 		FREE_MSG;
 	}
 
@@ -421,7 +450,9 @@ INT CDataImpl::InsertKeyInfo(STKeys &data)
 	if(m_psqlite3 == NULL)
 		return -1;
 
-	std::string strInsert = "INSERT INTO keys(pid, sn, keys) VALUES ('";
+	std::string strInsert = "INSERT INTO keys(bid, pid, sn, keys) VALUES ('";
+	strInsert.append(data.bid);
+	strInsert.append("','");
 	strInsert.append(data.pid);
 	strInsert.append("','");
 	strInsert.append(data.sn);
@@ -432,7 +463,7 @@ INT CDataImpl::InsertKeyInfo(STKeys &data)
 	int sqlite_error = sqlite3_exec(m_psqlite3, strInsert.c_str(), NULL, 0, &psqlite_error);
 	if(SQLITE_OK != sqlite_error)
 	{
-		//Global::WriteTextLog(_T("InsertContactsInfo:%s"), psqlite_error);
+		//Global::WriteTextLog(_T("InsertKeyInfo:%s"), psqlite_error);
 		FREE_MSG;
 	}
 
@@ -444,22 +475,22 @@ INT CDataImpl::InsertLogInfo(STLog &data)
 	if(m_psqlite3 == NULL)
 		return -1;
 
-	std::string strInsert = "INSERT INTO log(type, sn, content, report_date, report_status) VALUES ('";
+	std::string strInsert = "INSERT INTO log(type, bid, sn, content, report_date) VALUES ('";
 	strInsert.append(data.type);
 	strInsert.append("','");
+	strInsert.append(data.bid);
+	strInsert.append("','");
 	strInsert.append(data.sn);
 	strInsert.append("','");
 	strInsert.append(data.content);
 	strInsert.append("','");
 	strInsert.append(data.report_date);
-	strInsert.append("','");
-	strInsert.append(data.report_status);
 	strInsert.append("');");
 	char* psqlite_error = NULL;
 	int sqlite_error = sqlite3_exec(m_psqlite3, strInsert.c_str(), NULL, 0, &psqlite_error);
 	if(SQLITE_OK != sqlite_error)
 	{
-		//Global::WriteTextLog(_T("InsertContactsInfo:%s"), psqlite_error);
+		//Global::WriteTextLog(_T("InsertLogInfo:%s"), psqlite_error);
 		FREE_MSG;
 	}
 
@@ -480,16 +511,17 @@ INT CDataImpl::BatchInsertKeyInfo(std::vector<STKeys> &vtdata)
 	}
 
 	sqlite3_stmt *stmt;
-	const char* sql = "INSERT INTO keys(pid, sn, keys) VALUES (?,?,?)";
+	const char* sql = "INSERT INTO keys(bid, pid, sn, keys) VALUES (?,?,?,?)";
 	sqlite3_prepare_v2(m_psqlite3, sql, strlen(sql), &stmt, 0);
 
 	std::vector<STKeys>::iterator it = vtdata.begin();
 	for ( int i = 0; it != vtdata.end(); it++, i++ )
 	{
 		sqlite3_reset(stmt);  
-		sqlite3_bind_text(stmt, 1, it->pid.c_str(), it->pid.size(), SQLITE_STATIC);  
-		sqlite3_bind_text(stmt, 2, it->sn.c_str(), it->sn.size(), SQLITE_STATIC);  
-		sqlite3_bind_text(stmt, 3, it->keys.c_str(), it->keys.size(), SQLITE_STATIC);   
+		sqlite3_bind_text(stmt, 1, it->bid.c_str(), it->bid.size(), SQLITE_STATIC);  
+		sqlite3_bind_text(stmt, 2, it->pid.c_str(), it->pid.size(), SQLITE_STATIC);  
+		sqlite3_bind_text(stmt, 3, it->sn.c_str(), it->sn.size(), SQLITE_STATIC);  
+		sqlite3_bind_text(stmt, 4, it->keys.c_str(), it->keys.size(), SQLITE_STATIC);   
 		sqlite3_step(stmt);  
 	}
 
@@ -540,7 +572,7 @@ BOOL CDataImpl::UpdateMidInfo(STMid &data)
 	int sqlite_error = sqlite3_exec(m_psqlite3, strInsert.c_str(), NULL, 0, &psqlite_error);
 	if(SQLITE_OK != sqlite_error)
 	{
-		//Global::WriteTextLog(_T("UpdateContactsType:%s"), psqlite_error);
+		//Global::WriteTextLog(_T("UpdateMidInfo:%s"), psqlite_error);
 		FREE_MSG;
 		return FALSE;
 	}
@@ -576,7 +608,7 @@ BOOL CDataImpl::UpdateDownloadStatus(std::string order, int status, std::string
 	int sqlite_error = sqlite3_exec(m_psqlite3, strInsert.c_str(), NULL, 0, &psqlite_error);
 	if(SQLITE_OK != sqlite_error)
 	{
-		//Global::WriteTextLog(_T("UpdateContactsType:%s"), psqlite_error);
+		//Global::WriteTextLog(_T("UpdateDownloadStatus:%s"), psqlite_error);
 		FREE_MSG;
 		return FALSE;
 	}
@@ -584,20 +616,13 @@ BOOL CDataImpl::UpdateDownloadStatus(std::string order, int status, std::string
 	return TRUE;
 }
 
-BOOL CDataImpl::UpdateKeyCopyStatus(std::string sn, int status)
+// 抄写成功状态;
+BOOL CDataImpl::UpdateKeyCopyStatus(std::string sn)
 {
 	if(m_psqlite3 == NULL)
 		return FALSE;
 
-	// 只记录抄写成功;
-	if ( status != 1)
-		return FALSE;
-
-	char szStatus[10] = {0};
-	_itoa_s(status, szStatus, 10);
-	std::string strInsert = "UPDATE keys SET copy_status = '";
-	strInsert.append(szStatus);
-	strInsert.append("', copy_date=current_timestamp");
+	std::string strInsert = "UPDATE keys SET copy_date=current_timestamp";
 	strInsert.append(" WHERE sn ='");
 	strInsert.append(sn);
 	strInsert.append("';");
@@ -606,7 +631,7 @@ BOOL CDataImpl::UpdateKeyCopyStatus(std::string sn, int status)
 	int sqlite_error = sqlite3_exec(m_psqlite3, strInsert.c_str(), NULL, 0, &psqlite_error);
 	if(SQLITE_OK != sqlite_error)
 	{
-		//Global::WriteTextLog(_T("UpdateContactsInfo:%s"), psqlite_error);
+		//Global::WriteTextLog(_T("UpdateKeyCopyStatus:%s"), psqlite_error);
 		FREE_MSG;
 		return FALSE;
 	}
@@ -614,20 +639,12 @@ BOOL CDataImpl::UpdateKeyCopyStatus(std::string sn, int status)
 	return TRUE;
 }
 
-BOOL CDataImpl::UpdateKeyReportStatus(std::string sn, int status)
+BOOL CDataImpl::UpdateKeyReportStatus(std::string sn)
 {
 	if(m_psqlite3 == NULL)
 		return FALSE;
 
-	// 只记录抄写成功;
-	if ( status != 1)
-		return FALSE;
-
-	char szStatus[10] = {0};
-	_itoa_s(status, szStatus, 10);
-	std::string strInsert = "UPDATE keys SET report_status = '";
-	strInsert.append(szStatus);
-	strInsert.append("', report_date=current_timestamp");
+	std::string strInsert = "UPDATE keys SET report_date=current_timestamp";
 	strInsert.append(" WHERE sn ='");
 	strInsert.append(sn);
 	strInsert.append("' and copy_date <> '';");
@@ -636,7 +653,7 @@ BOOL CDataImpl::UpdateKeyReportStatus(std::string sn, int status)
 	int sqlite_error = sqlite3_exec(m_psqlite3, strInsert.c_str(), NULL, 0, &psqlite_error);
 	if(SQLITE_OK != sqlite_error)
 	{
-		//Global::WriteTextLog(_T("UpdateContactsInfo:%s"), psqlite_error);
+		//Global::WriteTextLog(_T("UpdateKeyReportStatus:%s"), psqlite_error);
 		FREE_MSG;
 		return FALSE;
 	}
@@ -644,20 +661,12 @@ BOOL CDataImpl::UpdateKeyReportStatus(std::string sn, int status)
 	return TRUE;
 }
 
-BOOL CDataImpl::UpdateLogReportStatus(std::string sn, std::string type, int status)
+BOOL CDataImpl::UpdateLogReportStatus(std::string sn, std::string type)
 {
 	if(m_psqlite3 == NULL)
 		return FALSE;
 
-	// 只记录抄写成功;
-	if ( status != 1)
-		return FALSE;
-
-	char szStatus[10] = {0};
-	_itoa_s(status, szStatus, 10);
-	std::string strInsert = "UPDATE log SET report_status = '";
-	strInsert.append(szStatus);
-	strInsert.append("', report_date=current_timestamp");
+	std::string strInsert = "UPDATE log SET report_date=current_timestamp";
 	strInsert.append(" WHERE sn ='");
 	strInsert.append(sn);
 	strInsert.append("' and type ='");
@@ -668,7 +677,26 @@ BOOL CDataImpl::UpdateLogReportStatus(std::string sn, std::string type, int stat
 	int sqlite_error = sqlite3_exec(m_psqlite3, strInsert.c_str(), NULL, 0, &psqlite_error);
 	if(SQLITE_OK != sqlite_error)
 	{
-		//Global::WriteTextLog(_T("UpdateContactsInfo:%s"), psqlite_error);
+		//Global::WriteTextLog(_T("UpdateLogReportStatus:%s"), psqlite_error);
+		FREE_MSG;
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+BOOL CDataImpl::RemoveBidData(std::string order)
+{
+	if(m_psqlite3 == NULL)
+		return FALSE;
+
+	TCHAR szSQL[1024] = {0};
+	_stprintf_s(szSQL, "delete from mid where bid = '%s'; delete from keys where bid = '%s'; delete from log where bid = '%s'", order.c_str(), order.c_str(), order.c_str());
+	char* psqlite_error = NULL;
+	int sqlite_error = sqlite3_exec(m_psqlite3, szSQL, NULL, 0, &psqlite_error);
+	if(SQLITE_OK != sqlite_error)
+	{
+		//Global::WriteTextLog(_T("UpdateLogReportStatus:%s"), psqlite_error);
 		FREE_MSG;
 		return FALSE;
 	}

+ 8 - 3
scbc.tools/scbc.tools/DataImpl.h

@@ -84,6 +84,8 @@ public:
 	INT QueryUnReportKeyInfo(std::vector<STKeys> &vtdata);
 	INT QueryLogInfo(std::string sn, STLog &data);
 	INT QueryUnReportLogInfo(std::vector<STLog> &vtdata);
+	// 查询订单抄写成功数量,成功上报数量,抄写总数;
+	INT QueryBidInfo(std::string order, BidInfo &binfo);
 
 	// 插入mid信息;
 	INT InsertMidInfo(STMid &data);
@@ -100,11 +102,14 @@ public:
 	// 更新下载状态;(成功时,更新完成时间)
 	BOOL UpdateDownloadStatus(std::string order, int status, std::string des = "" /*失败描述*/);
 	// 更新抄写状态;
-	BOOL UpdateKeyCopyStatus(std::string sn, int status);
+	BOOL UpdateKeyCopyStatus(std::string sn);
 	// 更新上报状态;
-	BOOL UpdateKeyReportStatus(std::string sn, int status);
+	BOOL UpdateKeyReportStatus(std::string sn);
 	// 更新日志上报状态;
-	BOOL UpdateLogReportStatus(std::string sn, std::string type, int status);
+	BOOL UpdateLogReportStatus(std::string sn, std::string type);
+
+	// 删除订单所有数据;
+	BOOL RemoveBidData(std::string order);
 };
 
 #endif

+ 9 - 8
scbc.tools/scbc.tools/SDK.cpp

@@ -138,7 +138,7 @@ int CSDK::QueryKeyInfo(std::string sn, STKeys &keys)
 	return -4;
 }
 
-int CSDK::UpdateKeyCopyStatus(std::string sn, int status )
+int CSDK::UpdateKeyCopyStatus(std::string sn )
 {
 	if ( sn.size() == 0 )
 		return -1;
@@ -148,13 +148,13 @@ int CSDK::UpdateKeyCopyStatus(std::string sn, int status )
 		return -2;
 
 	BOOL bRet = FALSE;
-	// 更新抄写成功状态:1,失败-1;
-	bRet = db.UpdateKeyCopyStatus(sn.c_str(), status);	
+	// 更新抄写成功状态;
+	bRet = db.UpdateKeyCopyStatus(sn.c_str());	
 	
 	return bRet == TRUE ? 1 : 0;
 }
 
-int CSDK::UpdateKeyReportStatus(std::string sn, int status)
+int CSDK::UpdateKeyReportStatus(std::string sn)
 {
 	if ( sn.size() == 0 )
 		return -1;
@@ -165,7 +165,7 @@ int CSDK::UpdateKeyReportStatus(std::string sn, int status)
 
 	BOOL bRet = FALSE;
 	// 更新抄写成功状态:1,失败-1;
-	bRet = db.UpdateKeyReportStatus(sn.c_str(), status);
+	bRet = db.UpdateKeyReportStatus(sn.c_str());
 	
 	return bRet == TRUE ? 1 : 0;
 }
@@ -217,7 +217,7 @@ bool CSDK::CheckDownload(std::string file, STMid& mid)
 	{
 		// 文件下载成功,批量插入数据库;
 		std::vector<STKeys> vtKeys;
-		ParserKey(file, vtKeys, mid.pid);
+		ParserKey(file, vtKeys, mid);
 		if ( vtKeys.size() )
 		{
 			CDataImpl db;
@@ -340,7 +340,7 @@ int CSDK::ReportDownloadStatus(std::string order)
 	return -1;
 }
 
-void CSDK::ParserKey(std::string file, std::vector<STKeys> &vtKyes, std::string pid)
+void CSDK::ParserKey(std::string file, std::vector<STKeys> &vtKyes, STMid &mid)
 {
 	// 读取文件;
 	FILE* pf = NULL;
@@ -373,7 +373,8 @@ void CSDK::ParserKey(std::string file, std::vector<STKeys> &vtKyes, std::string
 		if ( pItem )
 		{
 			STKeys key;
-			key.pid = pid;
+			key.bid = mid.order;
+			key.pid = mid.pid;
 			// 序列号;
 			key.sn = cJSON_GetObjectItem(pItem, _T("sn")) ? cJSON_GetObjectItem(pItem, _T("sn"))->valuestring : "";
 			cJSON *pJsonKeys = cJSON_GetObjectItem(pItem, _T("key"));

+ 3 - 3
scbc.tools/scbc.tools/SDK.h

@@ -16,13 +16,13 @@ public:
 	int QueryMidInfo(std::string order);
 	int DownloadMidData(std::string order);
 	int QueryKeyInfo(std::string sn, STKeys &keys);
-	int UpdateKeyCopyStatus(std::string sn, int status = 1 );
-	int UpdateKeyReportStatus(std::string sn, int status = 1);
+	int UpdateKeyCopyStatus(std::string sn );
+	int UpdateKeyReportStatus(std::string sn);
 	int ReportKeyCopyResults(std::string sn = "");
 
 	int GetMidInfo(std::string order, STMid &mid);
 	static int ReportDownloadStatus(std::string order);
-	static void ParserKey(std::string file, std::vector<STKeys> &vtKyes, std::string pid);
+	static void ParserKey(std::string file, std::vector<STKeys> &vtKyes, STMid& mid);
 	static bool ParserSNKey(std::string json, SNKeys &snKey);
 private:
 	static std::list<STMid> m_vtMidTask;

+ 40 - 15
scbc.tools/scbc.tools/TableInfo.h

@@ -16,8 +16,8 @@ typedef struct	__ST_MID__
 	std::string		status;							// 下载状态:0=未下载,1=完成,-1=下载失败;
 	std::string		start_date;						// 下载开始时间;
 	std::string		finish_date;					// 下载完成时间;
-	std::string		dsize;							// 已下载大小;
-	std::string		file;							// 文件路径;
+	//std::string		dsize;							// 已下载大小;
+	//std::string		file;							// 文件路径;
 	std::string		des;							// 状态描述:下载失败原因;
 
 	__ST_MID__& operator=(const __ST_MID__& that)
@@ -34,8 +34,8 @@ typedef struct	__ST_MID__
 			status = that.status;
 			start_date = that.start_date;
 			finish_date = that.finish_date;
-			dsize = that.dsize;
-			file = that.file;
+			//dsize = that.dsize;
+			//file = that.file;
 			des = that.des;
 		}
 
@@ -48,23 +48,40 @@ typedef struct	__ST_MID__
 typedef struct __ST_KEYS__
 {
 	std::string		sn;								// sn;
+	std::string		bid;							// 订单号;
 	std::string		keys;							// key包Json字符串;
 	std::string		pid;							// project id;
 	std::string		copy_date;						// 抄写成功时间;
-	std::string		report_date;					// 上报时间;
-	std::string		copy_status;					// 抄写状态:0=未抄写、-1=抄写成失败、1=抄写成功;
-	std::string		report_status;					// 上报状态:0=未上报、1=上报成功、-1=上报失败;
+	std::string		report_date;					// 上报成功时间;
+	//std::string		copy_status;					// 抄写状态:0=未抄写、-1=抄写成失败、1=抄写成功;
+	//std::string		report_status;					// 上报状态:0=未上报、1=上报成功、-1=上报失败;
+
+	__ST_KEYS__& operator=(const __ST_KEYS__& that)
+	{
+		if ( this != &that )
+		{
+			sn = that.sn;
+			bid = that.bid;
+			keys = that.keys;
+			pid = that.pid;
+			copy_date = that.copy_date;
+			report_date = that.report_date;
+		}
+
+		return *this;
+	}
 }STKeys, *pSTKeys;
 
 // 日志表;
 typedef struct __ST_LOG__
 {
 	std::string		type;							// 日志类型;
-	std::string		sn;								// 关联的sn;		
+	std::string		sn;								// 关联的sn;	
+	std::string		bid;							// 订单号;
 	std::string		content;						// 日志内容;
 	std::string		gdate;							// 日志生成时间;
-	std::string		report_date;					// 日志上报时间;
-	std::string		report_status;					// 上报状态:0=未上报、1=上报成功、-1=上报失败;
+	std::string		report_date;					// 日志上报成功时间;
+	//std::string		report_status;					// 上报状态:0=未上报、1=上报成功、-1=上报失败;
 }STLog, *pSTLog;
 
 // 抄写表;
@@ -73,11 +90,19 @@ typedef struct __SN_KEYS__
 	int				pid;							// project id;
 	std::string		did;							// device id;
 	std::string		mac;							// mac地址;
-	std::string		hdcp;							// ;
-	std::string		hdcp22;							// ;
-	std::string		widi;							// ;
-	std::string		widevine;						// ;
+	std::string		hdcp;							// hdcp;
+	std::string		hdcp22;							// hdcp22;
+	std::string		widi;							// widi;
+	std::string		widevine;						// widevine;
 	std::string		esn;							// neflix esn;
-	std::string		cikey;							// ;
+	std::string		cikey;							// cikey;
 }SNKeys, *pSNKeys;
+
+typedef struct __BID_INFO__
+{
+	std::string tcount;								// 总sn数量;
+	std::string sn_count;							// 实际sn数量;
+	std::string copy_count;							// 成功抄写数量;
+	std::string report_count;						// 成功上报数量;
+}BidInfo, *pBidInfo;
 #endif

+ 8 - 13
scbc.tools/scbc.tools/scbc.tools.cpp

@@ -23,8 +23,8 @@ void TEST_Download()
 {
 	printf("开始压测下载……\n");
 	TCHAR szDir[MAX_PATH] = {0};
-	_stprintf_s(szDir, _T("E:\\bin\\%s.exe"), "SunloginClient");
-	for (int i = 0; i < 30000; i++)
+	_stprintf_s(szDir, _T("%s%s.exe"), Global::g_szCurModuleDir, "SunloginClient");
+	for (int i = 0; i < 300000; i++)
 	{
 		CCurlClient curl;
 		curl.Initialize();
@@ -56,7 +56,6 @@ void TEST_InsertMidInfo()
 			mid.order = szdata;
 			mid.ctype = szdata;
 			mid.version = "V8-SCBC098-LV1096";
-			mid.dsize = "100";
 			mid.number = "1000";
 			mid.pid = "102";
 			mid.pmd5 = "dfeqadfadfer546489er4adf";
@@ -67,9 +66,8 @@ void TEST_InsertMidInfo()
 		for ( int i = 0; i < 100; i++)
 		{
 			_itoa_s(i, szdata, 10);
-			db.UpdateKeyCopyStatus(szdata, 1);
 			if ( i%2 )
-				db.UpdateKeyReportStatus(szdata, 1);
+				db.UpdateKeyReportStatus(szdata);
 		}
 	}
 }
@@ -134,17 +132,14 @@ void TEST_InertLog()
 			log.type = "1";
 			log.content = "测试内容:东方丽景散热地觚单位 加菲软糖加工厂饮用水";
 			if ( i%2 )
-				log.report_status = "1";
-			else
-				log.report_status = "0";
-			log.report_date = "";
+				log.report_date = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S").GetString();
 			db.InsertLogInfo(log);
 		}
 		db.TransactionCommit();
 
 		std::vector<STLog> vtLog;
 		db.QueryUnReportLogInfo(vtLog);
-		db.UpdateLogReportStatus("0", "1", 1);
+		db.UpdateLogReportStatus("0", "1");
 	}
 }
 
@@ -239,9 +234,9 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
 	{
 		std::string md5 = GetFileMD5("D:\\bin\\scbc.tools\\scbc.tools.pdb");
 		// TODO: 在此处为应用程序的行为编写代码。
-		Sleep(10000);
-		TEST_Download();
-		//TEST_GetMidInfo();
+		//Sleep(10000);
+		//TEST_Download();
+		TEST_GetMidInfo();
 		/*
 		TEST_InsertMidInfo();
 		TEST_QueryMidInfo();