瀏覽代碼

1、修复查询数据库时,null字段赋值报错的问题,使用ifnull(f,v)将null转化为v;
2、测试用例;

Jeff 5 年之前
父節點
當前提交
b1322d7237
共有 3 個文件被更改,包括 20 次插入11 次删除
  1. 1 1
      scbc.tools/scbc.tools/DataImpl.cpp
  2. 1 1
      scbc.tools/scbc.tools/SDK.cpp
  3. 18 9
      scbc.tools/test/test.cpp

+ 1 - 1
scbc.tools/scbc.tools/DataImpl.cpp

@@ -47,7 +47,7 @@ PRIMARY KEY (type, sn));"
 #define _SELECT_LOG_TABLE_ "SELECT type, bid, sn, content, gdate, report_date FROM log"
 
 #define _SELECT_BID_INFO__ \
-"select mid.number as tc, \
+	"select ifnull(mid.number,0) 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 \

+ 1 - 1
scbc.tools/scbc.tools/SDK.cpp

@@ -171,7 +171,7 @@ int CSDK::UpdateKeyReportStatus(std::string sn)
 }
 
 int CSDK::ReportKeyCopyResults(std::string sn)
-{//http://test.admin.ota.qhmoka.com/IDManage/reportlist.do
+{
 	if ( sn.size() == 0 )
 		return -1;
 

+ 18 - 9
scbc.tools/test/test.cpp

@@ -28,13 +28,15 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
 	}
 	else
 	{
+		std::string bid = "DXM1900259";
 		// 1、查询订单是否已下载成功;
-		int nRet = QueryMidInfo("IDL144240G");
+		int nRet = QueryMidInfo(bid.c_str());
 		printf("QueryMidInfo:%d\n", nRet);
 		if ( nRet != 2 )
 		{
+			printf("订单未下载成功,开始下载\n");
 			// 未下载成功,开始后台下载;
-			nRet = DownloadMidData("IDL144240G");
+			nRet = DownloadMidData(bid.c_str());
 			printf("DownloadMidData:%d\n", nRet);
 			if ( nRet == 0 )
 			{
@@ -43,30 +45,37 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
 				exit(0);
 			}
 		}
+		else
+			printf("订单已下载\n");
 
 		// 2、等待下载成功;
 		while ( nRet != 2 )
 		{
-			nRet = QueryMidInfo("IDL144240G");
+			nRet = QueryMidInfo(bid.c_str());
 			printf("QueryMidInfo:%d\n", nRet);
+			if ( nRet == 2 )
+			{
+				printf("查询订单已下载成功\n");
+			}
 			Sleep(1000);
 		}
 
+		std::string sn = "TEST-TONY-5588";
 		// 3、获取指定sn的keys,用于抄写key;
 		SNKeys keys;
-		nRet = QueryKeyInfo("TEST-3311-8811", keys);
+		nRet = QueryKeyInfo(sn.c_str(), keys);
 		printf("QueryKeyInfo:%d\n", nRet);
 
 		// 4、抄写成功后,保存抄写结果;
-		nRet = UpdateKeyCopyStatus("TEST-3311-8811");
+		nRet = UpdateKeyCopyStatus(sn.c_str());
 		printf("UpdateKeyCopyStatus:%d\n", nRet);
 
 		// 5、单个sn抄写结果上报;
-		nRet = ReportKeyCopyResults("TEST-3311-8811");
+		nRet = ReportKeyCopyResults(sn.c_str());
 		printf("ReportKeyCopyResults:%d, %s\n", nRet, nRet == 1 ? "上报成功" : "上报失败");
 		if ( nRet == -8 )
 		{
-			nRet = UpdateKeyReportStatus("TEST-3311-8811");
+			nRet = UpdateKeyReportStatus(sn.c_str());
 			printf("UpdateKeyReportStatus:%d\n", nRet);
 		}
 
@@ -76,11 +85,11 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
 
 		// 7、查询应下载sn数量、实际下载sn数据、抄写成功sn数量、上报成功sn数量;
 		BidInfo binfo;
-		nRet = QueryBidInfo("IDL144240G", binfo);
+		nRet = QueryBidInfo(bid.c_str(), binfo);
 		printf("QueryBidInfo:%d\n", nRet, nRet == 1 ? "查询成功": "查询失败");
 
 		// 8、删除批次相关表数据(全部表数量)
-		nRet = RemoveBidData("IDL144240G");
+		nRet = RemoveBidData(bid.c_str());
 		printf("RemoveBidData:%d\n", nRet);
 	}