test.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. // test.cpp : 定义控制台应用程序的入口点。
  2. //
  3. #include "stdafx.h"
  4. #include "test.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #endif
  8. // 唯一的应用程序对象
  9. CWinApp theApp;
  10. using namespace std;
  11. int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
  12. {
  13. int nRetCode = 0;
  14. // 初始化 MFC 并在失败时显示错误
  15. if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
  16. {
  17. // TODO: 更改错误代码以符合您的需要
  18. _tprintf(_T("错误: MFC 初始化失败\n"));
  19. nRetCode = 1;
  20. }
  21. else
  22. {
  23. std::string bid = "DXM1900259";
  24. // 0、初始化环境;
  25. if ( !ScbcInit(bid.c_str()) )
  26. {
  27. printf("初始化失败\n");
  28. return -1;
  29. }
  30. // 测试1千次;
  31. int i = 1000;
  32. while(i--){
  33. printf("\n\n******************No.%ld******************\n", i);
  34. // 1、查询订单是否已下载成功;
  35. int nRet = QueryMidInfo(bid.c_str());
  36. printf("QueryMidInfo:%d\n", nRet);
  37. if ( nRet != 2 )
  38. {
  39. printf("订单未下载成功,开始下载\n");
  40. // 未下载成功,开始后台下载;
  41. nRet = DownloadMidData(bid.c_str());
  42. printf("DownloadMidData:%d\n", nRet);
  43. if ( nRet == 0 )
  44. {
  45. printf("该批次未导入系统,无法下载,程序退出\n");
  46. continue;
  47. }
  48. }
  49. else
  50. printf("订单已下载\n");
  51. // 2、等待下载成功;
  52. while ( nRet != 2 )
  53. {
  54. nRet = QueryMidInfo(bid.c_str());
  55. printf("QueryMidInfo:%d\n", nRet);
  56. if ( nRet == 2 )
  57. {
  58. printf("查询订单已下载成功\n");
  59. }
  60. Sleep(1000);
  61. }
  62. std::string sn = "TEST-TONY-5588";
  63. // 3、获取指定sn的keys,用于抄写key;
  64. SNKeys keys;
  65. nRet = QueryKeyInfo(sn.c_str(), keys);
  66. printf("QueryKeyInfo:%d\n", nRet);
  67. // 4、抄写成功后,保存抄写结果;
  68. if ( true )
  69. {
  70. nRet = UpdateKeyCopyStatus(sn.c_str());
  71. printf("UpdateKeyCopyStatus:%d\n", nRet);
  72. }
  73. //Sleep(6000);
  74. // 5、单个sn抄写结果上报;
  75. nRet = ReportKeyCopyResults(sn.c_str());
  76. printf("ReportKeyCopyResults:%d, %s\n", nRet, nRet == 1 ? "上报成功" : "上报失败");
  77. if ( nRet == -8 )
  78. {
  79. nRet = UpdateKeyReportStatus(sn.c_str());
  80. printf("UpdateKeyReportStatus:%d\n", nRet);
  81. }
  82. // 6、1000个sn抄写结果上报;
  83. while((nRet = BatchReportKeyCopyResults()) == 1)
  84. printf("BatchReportKeyCopyResults:%d, %s\n", nRet, nRet == 1 ? "上报成功" : "上报失败");
  85. // 7、查询应下载sn数量、实际下载sn数据、抄写成功sn数量、上报成功sn数量;
  86. BidInfo binfo;
  87. nRet = QueryBidInfo(bid.c_str(), binfo);
  88. printf("QueryBidInfo:%d\n", nRet, nRet == 1 ? "查询成功": "查询失败");
  89. printf("15秒后,开始删除订单信息\n");
  90. Sleep(15000);
  91. // 8、删除批次相关表数据(全部表数量)
  92. nRet = RemoveBidData(bid.c_str());
  93. printf("RemoveBidData:%d\n", nRet);
  94. printf("删除订单信息成功\n");
  95. }
  96. }
  97. system("pause");
  98. return nRetCode;
  99. }