From 954ead41d9391bca28a3cc4f9592f73f25b3bbc8 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 02 一月 2023 17:55:06 +0800
Subject: [PATCH] '完善批量设置代码'

---
 ConsoleApplication/CurrentPriceCapture.cpp |   33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/ConsoleApplication/CurrentPriceCapture.cpp b/ConsoleApplication/CurrentPriceCapture.cpp
index 6cc9143..a81e928 100644
--- a/ConsoleApplication/CurrentPriceCapture.cpp
+++ b/ConsoleApplication/CurrentPriceCapture.cpp
@@ -325,16 +325,33 @@
 			int y = wrect.top + 50;
 			PostMessage(win, WM_MOUSEWHEEL, 0, MAKEWORD(x, y));
 			Sleep(1000);
-			cv::Mat oimg = CaptureUtil::capture(win);
-			list<CurrentPriceData> codes = capture(oimg,openCLExcuter);
-			for (list<CurrentPriceData>::iterator ele = codes.begin();ele != codes.end();ele++) {
-				string code = (*ele).code;
-				if (codesSet.count(code) == 0&&stof((*ele).price)>0) {
-					codesSet.insert(code);
-					flist.push_back(*ele);
+			
+			int re_try_count = 0;
+			while (re_try_count < 3) {
+				int invalid_price_count = 0;
+				re_try_count++;
+				cv::Mat oimg = CaptureUtil::capture(win);
+				list<CurrentPriceData> codes = capture(oimg, openCLExcuter);
+				for (list<CurrentPriceData>::iterator ele = codes.begin(); ele != codes.end(); ele++) {
+					string code = (*ele).code;
+					if (codesSet.count(code) == 0 && stof((*ele).price) > 0) {
+						codesSet.insert(code);
+						flist.push_back(*ele);
+					}
+					else if (stof((*ele).price) <= 0) {
+						// 获取的价格无效
+						invalid_price_count++;
+					}
+				}
+				codes.clear();
+				if (invalid_price_count <= 1) {
+					// 无效价格代码数量小于1个就退出
+					break;
+				}
+				else {
+					Sleep(500);
 				}
 			}
-			codes.clear();
 			Sleep(50);
 	}
 	return flist;

--
Gitblit v1.8.0