From 5c9991be21f57781573f04961ec511ac2938ea3d Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 08 四月 2025 15:27:08 +0800
Subject: [PATCH] '功能完善'

---
 FloatTrade/CSettingDlg.cpp |  565 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 542 insertions(+), 23 deletions(-)

diff --git a/FloatTrade/CSettingDlg.cpp b/FloatTrade/CSettingDlg.cpp
index 4d2ddee..43dbbe5 100644
--- a/FloatTrade/CSettingDlg.cpp
+++ b/FloatTrade/CSettingDlg.cpp
@@ -8,6 +8,7 @@
 #include "../common/StringUtil.h"
 #include "../common/NetworkApi.h"
 #include "../common/JsonUtil.h"
+#include "../common/TimeUtil.h"
 #include "ConfigUtil.h"
 #include <iostream>
 #include <string>
@@ -15,6 +16,11 @@
 #include <regex>
 #include <iconv.h>
 #include <thread>
+#include "CCBBuyDlg.h"
+
+#include "win32_screen_shots.h"
+#include "ThsCodeOCR.h"
+
 using namespace std;
 
 // CSettingDlg 瀵硅瘽妗�
@@ -46,6 +52,10 @@
 	ON_BN_CLICKED(btn_sure_network, &CSettingDlg::OnBnClickedsurenetwork)
 	ON_BN_CLICKED(btn_radical_buy_block_count_sure, &CSettingDlg::OnBnClickedradicalbuyblockcountsure)
 	ON_BN_CLICKED(btn_sure_trade_params_setting, &CSettingDlg::OnBnClickedsuretradeparamssetting)
+	ON_BN_CLICKED(btn_sure_ocr, &CSettingDlg::OnBnClickedsureocr)
+	ON_BN_CLICKED(btn_sure_ocr_test, &CSettingDlg::OnBnClickedsureocrtest)
+	ON_BN_CLICKED(IDC_BUTTON_BUY_CB, &CSettingDlg::OnBnClickedButtonBuyCb)
+	ON_BN_CLICKED(IDC_BUTTON1, &CSettingDlg::OnBnClickedButton1)
 END_MESSAGE_MAP()
 
 
@@ -82,6 +92,18 @@
 
 	ConfigUtil::setVolumesSetting(volumeList);
 	ConfigUtil::setThsAutoRefreshTimeSpace(stoi(StringUtil::cstring2String(refreshSpace)));
+
+	// 鑾峰彇涔板叆/鍗栧嚭榛樿閲戦
+	CString buyMoney, sellMoney;
+
+	((CEdit*)GetDlgItem(IDC_EDIT_DEFAULT_BUY_MONEY))->GetWindowTextW(buyMoney);
+	((CEdit*)GetDlgItem(IDC_EDIT_DEFAULT_SELL_MONEY))->GetWindowTextW(sellMoney);
+	if (buyMoney.IsEmpty() || sellMoney.IsEmpty()) {
+		AfxMessageBox(L"璇疯缃粯璁や拱鍏�/鍗栧嚭閲戦");
+		return;
+	}
+	ConfigUtil::setBuyMoney(stoi(StringUtil::cstring2String( buyMoney).c_str()));
+	ConfigUtil::setSellMoney(stoi(StringUtil::cstring2String(sellMoney).c_str()));
 	AfxMessageBox(L"淇濆瓨鎴愬姛", MB_ICONINFORMATION);
 }
 
@@ -102,23 +124,27 @@
 				auto normal = data["normal"].GetArray();;
 				auto radical = data["radical"].GetArray();
 				auto moneys_enum = data["moneys"].GetArray();
+				auto default_buy_money = data["default_buy_money"].GetInt();
+
+
 				settings.normalCount = normal[0].GetInt();
 				settings.radicalCount = radical[0].GetInt();
+				settings.defaultBuyMoney = default_buy_money;
 				auto money_list = normal[1].GetArray();
 				for (int i = 0; i < money_list.Size(); i++) {
 					auto item = money_list[i].GetArray();
-					settings.normalMoneyList.push_back(TimeMoney({ CString(item[0].GetString()),item[1].GetInt(), item[2].GetInt() }));
+					settings.normalMoneyList.push_back(TimeMoney({ CString(item[0].GetString()),item[1].GetInt(), item[2].GetInt(), item[3].GetInt() }));
 				}
 
 				money_list = radical[1].GetArray();
 				for (int i = 0; i < money_list.Size(); i++) {
 					auto item = money_list[i].GetArray();
-					settings.radicalMoneyList.push_back(TimeMoney({ CString(item[0].GetString()),item[1].GetInt(), item[2].GetInt() }));
+					settings.radicalMoneyList.push_back(TimeMoney({ CString(item[0].GetString()),item[1].GetInt(), item[2].GetInt(), item[3].GetInt() }));
 				}
 
 
-				int moneys[] = { combo_normal_buy_money_1 ,combo_normal_buy_money_2 ,combo_normal_buy_money_3,combo_radical_buy_money_1 ,combo_radical_buy_money_2 ,combo_radical_buy_money_3 };
-				for (int i = 0; i < 6; i++) {
+				int moneys[] = { combo_normal_buy_money_1 ,combo_normal_buy_money_2 ,combo_normal_buy_money_3,combo_radical_buy_money_1 ,combo_radical_buy_money_2 ,combo_radical_buy_money_3, combo_default_buy_money };
+				for (int i = 0; i < 7; i++) {
 					CComboBox* box = (CComboBox*)GetDlgItem(moneys[i]);
 					for (int i = 0; i < moneys_enum.Size(); i++) {
 						box->AddString(to_wstring(moneys_enum[i].GetInt()).c_str());
@@ -153,25 +179,46 @@
 
 	}
 
+	((CEdit*)GetDlgItem(IDC_EDIT_DEFAULT_BUY_MONEY))->SetWindowTextW(to_wstring(ConfigUtil::getBuyMoney()).c_str());
+	((CEdit*)GetDlgItem(IDC_EDIT_DEFAULT_SELL_MONEY))->SetWindowTextW(to_wstring(ConfigUtil::getSellMoney()).c_str());
+
 	try {
-	
+
 		requestRadicalBuyBlockCount();
 	}
 	catch (...) {
-	
-	
+
+
 	}
 
 
 	comboTradeMode.Clear();
 	comboTradeMode.AddString(L"涔版墍鏈�");
 	comboTradeMode.AddString(L"鍙拱鎯充拱");
+	comboTradeMode.AddString(L"鍙拱杈ㄨ瘑搴�");
 
-	std::thread t1(requestTradeMode, this);
+	std::thread t1(requestTradeParamsSettings, this);
 	t1.detach();
 
+	// 璁剧疆鎴浘鍙傛暟
+	int ids[] = { IDC_EDIT_OCR_WINDOW_PARAMS_TOP, IDC_EDIT_OCR_WINDOW_PARAMS_WIDTH, IDC_EDIT_OCR_WINDOW_PARAMS_HEIGHT, IDC_EDIT_OCR_WINDOW_PARAMS_SCALE };
+	// 璁剧疆榛樿鍙傛暟
+	((CEdit*)GetDlgItem(ids[0]))->SetWindowTextW(L"10");
+	((CEdit*)GetDlgItem(ids[1]))->SetWindowTextW(L"300");
+	((CEdit*)GetDlgItem(ids[2]))->SetWindowTextW(L"50");
+	((CEdit*)GetDlgItem(ids[3]))->SetWindowTextW(L"1");
 
-
+	try {
+		OCRWindowParams params = ConfigUtil::getOCRWindowParams();
+		((CEdit*)GetDlgItem(ids[0]))->SetWindowTextW(to_wstring(params.top).c_str());
+		((CEdit*)GetDlgItem(ids[1]))->SetWindowTextW(to_wstring(params.width).c_str());
+		((CEdit*)GetDlgItem(ids[2]))->SetWindowTextW(to_wstring(params.height).c_str());
+		((CEdit*)GetDlgItem(ids[3]))->SetWindowTextW(CString( StringUtil::to_string(params.scale).c_str()));
+	}
+	catch (...) {
+	
+	
+	}
 
 	return TRUE;  // return TRUE unless you set the focus to a control
 				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
@@ -194,6 +241,7 @@
 			writer.String(StringUtil::cstring2String(timeMoney.time).c_str());
 			writer.Int(timeMoney.money);
 			writer.Int(timeMoney.count);
+			writer.Int(timeMoney.defaultCount);
 			writer.EndArray();
 		}
 
@@ -210,12 +258,13 @@
 			writer1.String(StringUtil::cstring2String(timeMoney.time).c_str());
 			writer1.Int(timeMoney.money);
 			writer1.Int(timeMoney.count);
+			writer1.Int(timeMoney.defaultCount);
 			writer1.EndArray();
 		}
 
 		writer1.EndArray();
 		const char* radicalMoneyJson = buf1.GetString();
-		NetworkApi::set_buy_money_and_count(settings.normalCount, string(normalMoneyJson), settings.radicalCount, string(radicalMoneyJson));
+		NetworkApi::set_buy_money_and_count(settings.normalCount, string(normalMoneyJson), settings.radicalCount, string(radicalMoneyJson), settings.defaultBuyMoney);
 		MessageBox(L"璁剧疆鎴愬姛", L"鎻愮ず");
 	}
 	catch (CString st) {
@@ -231,10 +280,12 @@
 	int normal_times[] = { edit_normal_buy_money_time_1 ,edit_normal_buy_money_time_2 ,edit_normal_buy_money_time_3 };
 	int normal_moneys[] = { combo_normal_buy_money_1 ,combo_normal_buy_money_2 ,combo_normal_buy_money_3 };
 	int normal_counts[] = { edit_normal_buy_count_1 ,edit_normal_buy_count_2 ,edit_normal_buy_count_3 };
+	int default_normal_counts[] = { edit_normal_buy_default_count_1 ,edit_normal_buy_default_count_2 ,edit_normal_buy_default_count_3 };
 
 	int radical_times[] = { edit_radical_buy_money_time_1 ,edit_radical_buy_money_time_2 ,edit_radical_buy_money_time_3 };
 	int radical_moneys[] = { combo_radical_buy_money_1 ,combo_radical_buy_money_2 ,combo_radical_buy_money_3 };
 	int radical_counts[] = { edit_radical_buy_count_1 ,edit_radical_buy_count_2 ,edit_radical_buy_count_3 };
+	int default_radical_counts[] = { edit_radical_buy_default_count_1 ,edit_radical_buy_default_count_2 ,edit_radical_buy_default_count_3 };
 
 
 	CString normalCount;
@@ -263,6 +314,7 @@
 		CString time;
 		CString money;
 		CString count;
+		CString defaultCount;
 		((CEdit*)GetDlgItem(normal_times[i]))->GetWindowTextW(time);
 
 		CComboBox* moneyCombo = ((CComboBox*)GetDlgItem(normal_moneys[i]));
@@ -271,6 +323,7 @@
 		}
 		((CEdit*)GetDlgItem(normal_counts[i]))->GetWindowTextW(count);
 
+		((CEdit*)GetDlgItem(default_normal_counts[i]))->GetWindowTextW(defaultCount);
 
 		if (!time.IsEmpty() && !money.IsEmpty() && !count.IsEmpty()) {
 			if (!validTime(time)) {
@@ -282,7 +335,10 @@
 			if (!StringUtil::isNumber(StringUtil::cstring2String(count))) {
 				throw CString(L"鏈�澶т拱鍏ユ暟閲忔牸寮忛敊璇�(蹇呴』涓烘鏁存暟)");
 			}
-			settings.normalMoneyList.push_back(TimeMoney({ time,stoi(StringUtil::cstring2String(money).c_str()),stoi(StringUtil::cstring2String(count).c_str()) }));
+			if (!StringUtil::isNumber(StringUtil::cstring2String(defaultCount))) {
+				throw CString(L"榛樿閲戦涔板叆鏁伴噺鏍煎紡閿欒(蹇呴』涓烘鏁存暟)");
+			}
+			settings.normalMoneyList.push_back(TimeMoney({ time,stoi(StringUtil::cstring2String(money).c_str()),stoi(StringUtil::cstring2String(count).c_str()),stoi(StringUtil::cstring2String(defaultCount).c_str()) }));
 		}
 	}
 
@@ -292,6 +348,7 @@
 		CString time;
 		CString money;
 		CString count;
+		CString defaultCount;
 		((CEdit*)GetDlgItem(radical_times[i]))->GetWindowTextW(time);
 		CComboBox* moneyCombo = ((CComboBox*)GetDlgItem(radical_moneys[i]));
 		if (moneyCombo->GetCurSel() >= 0) {
@@ -299,6 +356,8 @@
 		}
 
 		((CEdit*)GetDlgItem(radical_counts[i]))->GetWindowTextW(count);
+
+		((CEdit*)GetDlgItem(default_radical_counts[i]))->GetWindowTextW(defaultCount);
 
 
 		if (!time.IsEmpty() && !money.IsEmpty() && !count.IsEmpty()) {
@@ -311,9 +370,22 @@
 			if (!StringUtil::isNumber(StringUtil::cstring2String(count))) {
 				throw CString(L"鏈�澶т拱鍏ユ暟閲忔牸寮忛敊璇�(蹇呴』涓烘鏁存暟)");
 			}
-			settings.radicalMoneyList.push_back(TimeMoney({ time,stoi(StringUtil::cstring2String(money).c_str()),stoi(StringUtil::cstring2String(count).c_str()) }));
+
+			if (!StringUtil::isNumber(StringUtil::cstring2String(defaultCount))) {
+				throw CString(L"榛樿閲戦涔板叆鏁伴噺鏍煎紡閿欒(蹇呴』涓烘鏁存暟)");
+			}
+
+			settings.radicalMoneyList.push_back(TimeMoney({ time,stoi(StringUtil::cstring2String(money).c_str()),stoi(StringUtil::cstring2String(count).c_str()),stoi(StringUtil::cstring2String(defaultCount).c_str()) }));
 		}
 	}
+	CString default_buy_money;
+	CComboBox* moneyCombo = ((CComboBox*)GetDlgItem(combo_default_buy_money));
+	if (moneyCombo->GetCurSel() >= 0) {
+		moneyCombo->GetLBText(moneyCombo->GetCurSel(), default_buy_money);
+	}
+
+	settings.defaultBuyMoney = stoi(StringUtil::cstring2String(default_buy_money).c_str());
+
 	return settings;
 }
 
@@ -325,11 +397,11 @@
 	auto doc = JsonUtil::parseUTF16(result);
 	if (doc.IsObject()) {
 		if (doc[L"code"].GetInt() == 0) {
-		 auto array =	doc[L"data"].GetArray();
-		 for (int i = 0; i < array.Size(); i++) {
-			auto item =  array[i].GetArray();
-			mList.push_back(RadicalBuyBlockInfo({ item[0].GetString(),item[1].GetInt()}));
-		 }
+			auto array = doc[L"data"].GetArray();
+			for (int i = 0; i < array.Size(); i++) {
+				auto item = array[i].GetArray();
+				mList.push_back(RadicalBuyBlockInfo({ item[0].GetString(),item[1].GetInt() }));
+			}
 		}
 	}
 	int block_ids[] = { IDC_EDIT_RADICAL_BUY_BLOCK_1, IDC_EDIT_RADICAL_BUY_BLOCK_2, IDC_EDIT_RADICAL_BUY_BLOCK_3, IDC_EDIT_RADICAL_BUY_BLOCK_4 };
@@ -352,10 +424,13 @@
 	int normal_times[] = { edit_normal_buy_money_time_1 ,edit_normal_buy_money_time_2 ,edit_normal_buy_money_time_3 };
 	int normal_moneys[] = { combo_normal_buy_money_1 ,combo_normal_buy_money_2 ,combo_normal_buy_money_3 };
 	int normal_counts[] = { edit_normal_buy_count_1 ,edit_normal_buy_count_2 ,edit_normal_buy_count_3 };
+	int default_normal_counts[] = { edit_normal_buy_default_count_1 ,edit_normal_buy_default_count_2 ,edit_normal_buy_default_count_3 };
 
 	int radical_times[] = { edit_radical_buy_money_time_1 ,edit_radical_buy_money_time_2 ,edit_radical_buy_money_time_3 };
 	int radical_moneys[] = { combo_radical_buy_money_1 ,combo_radical_buy_money_2 ,combo_radical_buy_money_3 };
 	int radical_counts[] = { edit_radical_buy_count_1 ,edit_radical_buy_count_2 ,edit_radical_buy_count_3 };
+	int default_radical_counts[] = { edit_radical_buy_default_count_1 ,edit_radical_buy_default_count_2 ,edit_radical_buy_default_count_3 };
+
 	editNormalBuyCount.SetWindowTextW(to_wstring(setting.normalCount).c_str());
 	editRadicalBuyCount.SetWindowTextW(to_wstring(setting.radicalCount).c_str());
 	int index = 0;
@@ -374,6 +449,9 @@
 			}
 		}
 		((CEdit*)GetDlgItem(normal_counts[index]))->SetWindowTextW(to_wstring(timeMoney.count).c_str());
+
+		((CEdit*)GetDlgItem(default_normal_counts[index]))->SetWindowTextW(to_wstring(timeMoney.defaultCount).c_str());
+
 		index++;
 	}
 
@@ -393,19 +471,137 @@
 			}
 		}
 		((CEdit*)GetDlgItem(radical_counts[index]))->SetWindowTextW(to_wstring(timeMoney.count).c_str());
+
+		((CEdit*)GetDlgItem(default_radical_counts[index]))->SetWindowTextW(to_wstring(timeMoney.defaultCount).c_str());
+
 		index++;
+	}
+
+	// 璁剧疆榛樿涔板叆閲戦
+	CComboBox* box = (CComboBox*)GetDlgItem(combo_default_buy_money);
+	int nCount = box->GetCount();
+	for (int i = 0; i < nCount; i++)
+	{
+		CString strItem;
+		box->GetLBText(i, strItem);
+		if (stoi(StringUtil::cstring2String(strItem).c_str()) == setting.defaultBuyMoney) {
+			box->SetCurSel(i);
+			break;
+		}
 	}
 }
 
-void CSettingDlg::requestTradeMode(CSettingDlg* context)
+void CSettingDlg::requestTradeParamsSettings(CSettingDlg* context)
 {
 	try {
 		int mode = NetworkApi::get_buy_mode();
 		context->comboTradeMode.SetCurSel(mode);
 	}
 	catch (...) {
-	
-	
+
+	}
+
+	try {
+		string result = NetworkApi::get_place_order_settings();
+		auto root = JsonUtil::parseUTF8(result);
+		if (root.IsObject()) {
+			if (root["code"].GetInt() == 0) {
+				auto data = root["data"].GetObject();
+				auto radical_buy = data["radical_buy"].GetObject();
+				auto prices = radical_buy["price"].GetArray();
+				auto zyltgb = radical_buy["zyltgb"].GetArray();
+				auto market_strong = radical_buy["top_block_count_by_market_strong"].GetArray();
+				auto special_codes_rank = radical_buy["special_codes_max_block_in_rank"].GetInt();
+				auto ignore_block_in_market_strong = radical_buy["ignore_block_in_money_market_strong"].GetInt();
+                // 涔伴灏�    
+				auto buy_first_limit_up = radical_buy["buy_first_limit_up"].GetInt();
+
+				((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MIN))->SetWindowTextW(to_wstring(prices[0].GetInt()).c_str());
+				((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MAX))->SetWindowTextW(to_wstring(prices[1].GetInt()).c_str());
+
+				((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MIN))->SetWindowTextW(to_wstring(zyltgb[0][0].GetArray()[0].GetInt()).c_str());
+				((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MAX))->SetWindowTextW(to_wstring(zyltgb[0][0].GetArray()[1].GetInt()).c_str());
+				((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MIN_1))->SetWindowTextW(to_wstring(zyltgb[0][1].GetArray()[0].GetInt()).c_str());
+				((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MAX_1))->SetWindowTextW(to_wstring(zyltgb[0][1].GetArray()[1].GetInt()).c_str());
+
+
+
+				((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MIN2))->SetWindowTextW(to_wstring(zyltgb[1][0].GetArray()[0].GetInt()).c_str());
+				((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MAX2))->SetWindowTextW(to_wstring(zyltgb[1][0].GetArray()[1].GetInt()).c_str());
+				((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MIN_2))->SetWindowTextW(to_wstring(zyltgb[1][1].GetArray()[0].GetInt()).c_str());
+				((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MAX_2))->SetWindowTextW(to_wstring(zyltgb[1][1].GetArray()[1].GetInt()).c_str());
+
+				((CEdit*)context->GetDlgItem(IDC_EDIT_IGNORE_BLOCK_IN_MARKET_STRONG))->SetWindowTextW(to_wstring(ignore_block_in_market_strong).c_str());
+
+				if (market_strong.Size() > 0) {
+					((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_1))->SetWindowTextW(to_wstring(market_strong[0][0].GetInt()).c_str());
+					((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_1))->SetWindowTextW(to_wstring(market_strong[0][1].GetInt()).c_str());
+					((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_1))->SetWindowTextW(to_wstring(market_strong[0][2].GetInt()).c_str());
+				}
+				if (market_strong.Size() > 1) {
+					((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_2))->SetWindowTextW(to_wstring(market_strong[1][0].GetInt()).c_str());
+					((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_2))->SetWindowTextW(to_wstring(market_strong[1][1].GetInt()).c_str());
+					((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_2))->SetWindowTextW(to_wstring(market_strong[1][2].GetInt()).c_str());
+				}
+
+				if (market_strong.Size() > 2) {
+					((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_3))->SetWindowTextW(to_wstring(market_strong[2][0].GetInt()).c_str());
+					((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_3))->SetWindowTextW(to_wstring(market_strong[2][1].GetInt()).c_str());
+					((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_3))->SetWindowTextW(to_wstring(market_strong[2][2].GetInt()).c_str());
+				}
+
+				if (market_strong.Size() > 3) {
+					((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_4))->SetWindowTextW(to_wstring(market_strong[3][0].GetInt()).c_str());
+					((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_4))->SetWindowTextW(to_wstring(market_strong[3][1].GetInt()).c_str());
+					((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_4))->SetWindowTextW(to_wstring(market_strong[3][2].GetInt()).c_str());
+				}
+				if (market_strong.Size() > 4) {
+					((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_5))->SetWindowTextW(to_wstring(market_strong[4][0].GetInt()).c_str());
+					((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_5))->SetWindowTextW(to_wstring(market_strong[4][1].GetInt()).c_str());
+					((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_5))->SetWindowTextW(to_wstring(market_strong[4][2].GetInt()).c_str());
+				}
+
+				((CEdit*)context->GetDlgItem(IDC_EDIT_RADICAL_BUY_SPECIAL_BLOCK_IN_RANK))->SetWindowTextW(to_wstring(special_codes_rank).c_str());
+
+				if (buy_first_limit_up > 0) {
+					((CButton*)context->GetDlgItem(IDC_CHECK_BUY_FIRST_LIMIT_UP))->SetCheck(true);
+				}
+				else {
+					((CButton*)context->GetDlgItem(IDC_CHECK_BUY_FIRST_LIMIT_UP))->SetCheck(false);
+				}
+
+				
+
+
+			}
+
+		}
+
+
+	}
+	catch (...) {
+	}
+
+	try {
+	  string result =	NetworkApi::get_buy_open_limit_up_codes();
+	  auto root = JsonUtil::parseUTF8(result);
+	  if (root.IsObject()) {
+		  if (root["code"].GetInt() == 0) {
+			  auto data = root["data"].GetArray();
+			  CString codes;
+			  for (int i = 0; i < data.Size(); i++) {
+				 string code =  data[i].GetString();
+				 codes.Append(CString(code.c_str()));
+				 if (i < data.Size() - 1) {
+					 codes.Append(L",");
+				 }
+			  }
+			  ((CEdit*)context->GetDlgItem(IDC_EDIT_BUY_OPEN_LIMIT_UP_CODES))->SetWindowTextW(codes);
+		  }
+
+	  }
+	}
+	catch (...) {
 	}
 
 
@@ -440,7 +636,7 @@
 				}
 				mList.push_back(RadicalBuyBlockInfo({ block , stoi(StringUtil::cstring2String(count)) }));
 			}
-			
+
 		}
 
 
@@ -458,7 +654,7 @@
 		const char* json = buf.GetString();
 		// 璁剧疆鏁版嵁
 		NetworkApi::set_radical_buy_block_count(StringUtil::base64_encode(json));
-		MessageBox(L"璁剧疆鎴愬姛",L"鎻愮ず");
+		MessageBox(L"璁剧疆鎴愬姛", L"鎻愮ず");
 	}
 	catch (CString msg) {
 		AfxMessageBox(msg);
@@ -476,9 +672,332 @@
 	int mode = comboTradeMode.GetCurSel();
 	try {
 		NetworkApi::set_buy_mode(mode);
-		MessageBox(L"璁剧疆鎴愬姛",L"鎻愮ず");
+		// 浠锋牸涓庡彧鏈夋祦閫氬競鍊�
+		CString minPrice, maxPrice, minZyltgb, maxZyltgb, minZyltgbPrice, maxZyltgbPrice, minZyltgb2, maxZyltgb2, minZyltgbPrice2, maxZyltgbPrice2;
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MIN))->GetWindowText(minPrice);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MAX))->GetWindowText(maxPrice);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MIN))->GetWindowText(minZyltgb);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MAX))->GetWindowText(maxZyltgb);
+
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MIN_1))->GetWindowText(minZyltgbPrice);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MAX_1))->GetWindowText(maxZyltgbPrice);
+
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MIN2))->GetWindowText(minZyltgb2);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_ZYLTGB_MAX2))->GetWindowText(maxZyltgb2);
+
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MIN_2))->GetWindowText(minZyltgbPrice2);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_PRICE_MAX_2))->GetWindowText(maxZyltgbPrice2);
+
+		if (!StringUtil::isNumber(StringUtil::cstring2String(minPrice)) || !StringUtil::isNumber(StringUtil::cstring2String(maxPrice))) {
+			throw wstring(L"浠锋牸蹇呴』涓烘暣鏁�");
+		}
+
+		if (!StringUtil::isNumber(StringUtil::cstring2String(minZyltgb)) || !StringUtil::isNumber(StringUtil::cstring2String(maxZyltgb))) {
+			throw wstring(L"鑷敱娴侀�氬競鍊煎繀椤讳负鏁存暟");
+		}
+
+		// 甯傚満寮哄害涓庤鲸璇嗗害
+		CString strong_min_1, strong_max_1, strong_block_in_max_1,
+			strong_min_2, strong_max_2, strong_block_in_max_2,
+			strong_min_3, strong_max_3, strong_block_in_max_3,
+			strong_min_4, strong_max_4, strong_block_in_max_4,
+			strong_min_5, strong_max_5, strong_block_in_max_5;
+		CString special_codes_rank, ignore_block_in_market_strong;
+
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_1))->GetWindowText(strong_min_1);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_1))->GetWindowText(strong_max_1);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_1))->GetWindowText(strong_block_in_max_1);
+
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_2))->GetWindowText(strong_min_2);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_2))->GetWindowText(strong_max_2);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_2))->GetWindowText(strong_block_in_max_2);
+
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_3))->GetWindowText(strong_min_3);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_3))->GetWindowText(strong_max_3);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_3))->GetWindowText(strong_block_in_max_3);
+
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_4))->GetWindowText(strong_min_4);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_4))->GetWindowText(strong_max_4);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_4))->GetWindowText(strong_block_in_max_4);
+
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MIN_5))->GetWindowText(strong_min_5);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_MARKET_STRONG_MAX_5))->GetWindowText(strong_max_5);
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_BLOCK_IN_RANK_5))->GetWindowText(strong_block_in_max_5);
+
+		((CEdit*)GetDlgItem(IDC_EDIT_RADICAL_BUY_SPECIAL_BLOCK_IN_RANK))->GetWindowText(special_codes_rank);
+
+		((CEdit*)GetDlgItem(IDC_EDIT_IGNORE_BLOCK_IN_MARKET_STRONG))->GetWindowText(ignore_block_in_market_strong);
+
+		bool can_buy_first_limit_up = ((CButton*)GetDlgItem(IDC_CHECK_BUY_FIRST_LIMIT_UP))->GetCheck();
+
+
+
+		rapidjson::StringBuffer buf;
+		rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buf);
+		writer.StartObject();
+		writer.Key("price");
+		writer.StartArray();
+		writer.Int(stoi(StringUtil::cstring2String(minPrice)));
+		writer.Int(stoi(StringUtil::cstring2String(maxPrice)));
+		writer.EndArray();
+
+		writer.Key("zyltgb");
+		writer.StartArray();
+
+		writer.StartArray();
+		writer.StartArray();
+		writer.Int(stoi(StringUtil::cstring2String(minZyltgb)));
+		writer.Int(stoi(StringUtil::cstring2String(maxZyltgb)));
+		writer.EndArray();
+		writer.StartArray();
+		writer.Int(stoi(StringUtil::cstring2String(minZyltgbPrice)));
+		writer.Int(stoi(StringUtil::cstring2String(maxZyltgbPrice)));
+		writer.EndArray();
+		writer.EndArray();
+
+
+		writer.StartArray();
+		writer.StartArray();
+		writer.Int(stoi(StringUtil::cstring2String(minZyltgb2)));
+		writer.Int(stoi(StringUtil::cstring2String(maxZyltgb2)));
+		writer.EndArray();
+		writer.StartArray();
+		writer.Int(stoi(StringUtil::cstring2String(minZyltgbPrice2)));
+		writer.Int(stoi(StringUtil::cstring2String(maxZyltgbPrice2)));
+		writer.EndArray();
+		writer.EndArray();
+
+
+		writer.EndArray();
+
+
+		writer.Key("top_block_count_by_market_strong");
+		writer.StartArray();
+
+		if (!strong_min_1.IsEmpty() && !strong_max_1.IsEmpty() && !strong_block_in_max_1.IsEmpty()) {
+			writer.StartArray();
+			writer.Int(stoi(StringUtil::cstring2String(strong_min_1)));
+			writer.Int(stoi(StringUtil::cstring2String(strong_max_1)));
+			writer.Int(stoi(StringUtil::cstring2String(strong_block_in_max_1)));
+			writer.EndArray();
+		}
+
+		if (!strong_min_2.IsEmpty() && !strong_max_2.IsEmpty() && !strong_block_in_max_2.IsEmpty()) {
+			writer.StartArray();
+			writer.Int(stoi(StringUtil::cstring2String(strong_min_2)));
+			writer.Int(stoi(StringUtil::cstring2String(strong_max_2)));
+			writer.Int(stoi(StringUtil::cstring2String(strong_block_in_max_2)));
+			writer.EndArray();
+		}
+
+
+		if (!strong_min_3.IsEmpty() && !strong_max_3.IsEmpty() && !strong_block_in_max_3.IsEmpty()) {
+			writer.StartArray();
+			writer.Int(stoi(StringUtil::cstring2String(strong_min_3)));
+			writer.Int(stoi(StringUtil::cstring2String(strong_max_3)));
+			writer.Int(stoi(StringUtil::cstring2String(strong_block_in_max_3)));
+			writer.EndArray();
+		}
+
+
+		if (!strong_min_4.IsEmpty() && !strong_max_4.IsEmpty() && !strong_block_in_max_4.IsEmpty()) {
+			writer.StartArray();
+			writer.Int(stoi(StringUtil::cstring2String(strong_min_4)));
+			writer.Int(stoi(StringUtil::cstring2String(strong_max_4)));
+			writer.Int(stoi(StringUtil::cstring2String(strong_block_in_max_4)));
+			writer.EndArray();
+		}
+
+
+		if (!strong_min_5.IsEmpty() && !strong_max_5.IsEmpty() && !strong_block_in_max_5.IsEmpty()) {
+			writer.StartArray();
+			writer.Int(stoi(StringUtil::cstring2String(strong_min_5)));
+			writer.Int(stoi(StringUtil::cstring2String(strong_max_5)));
+			writer.Int(stoi(StringUtil::cstring2String(strong_block_in_max_5)));
+			writer.EndArray();
+		}
+		
+
+
+
+		writer.EndArray();
+
+		writer.Key("special_codes_max_block_in_rank");
+		writer.Int(stoi(StringUtil::cstring2String(special_codes_rank)));
+
+
+		writer.Key("ignore_block_in_money_market_strong");
+		writer.Int(stoi(StringUtil::cstring2String(ignore_block_in_market_strong)));
+
+		writer.Key("buy_first_limit_up");
+		writer.Int(can_buy_first_limit_up?1:0);
+
+
+		writer.EndObject();
+
+		const char* radicalJson = buf.GetString();
+		auto result = NetworkApi::set_place_order_settings(radicalJson);
+		auto doc = JsonUtil::parseUTF16(result);
+		if (!doc.IsObject()) {
+			throw wstring(L"缃戠粶璇锋眰閿欒");
+		}
+		if (doc[L"code"].GetInt() != 0) {
+			throw  wstring(doc[L"msg"].GetString());
+		}
+
+	
 	}
 	catch (wstring msg) {
 		AfxMessageBox(msg.c_str());
 	}
+
+	try {
+		CString st;
+		((CEdit *)GetDlgItem(IDC_EDIT_BUY_OPEN_LIMIT_UP_CODES))->GetWindowText(st);
+		string codes = StringUtil::cstring2String(st);
+		std::stringstream ss(codes);
+		std::string token;
+		list<string> tokens;
+
+		// 浣跨敤 std::stringstream 鍒嗛殧瀛楃涓�
+		while (std::getline(ss, token, ',')) {
+			tokens.push_back(token);
+		}
+		string result = NetworkApi::set_buy_open_limit_up_codes(tokens);
+		auto doc = JsonUtil::parseUTF16(result);
+		if (!doc.IsObject()) {
+			throw wstring(L"缃戠粶璇锋眰閿欒");
+		}
+		if (doc[L"code"].GetInt() != 0) {
+			throw  wstring(doc[L"msg"].GetString());
+		}
+
+		MessageBox(L"璁剧疆鎴愬姛", L"鎻愮ず");
+	
+	}
+	catch (wstring msg) {
+		AfxMessageBox(msg.c_str());
+	}
+
+
+
+
+	
+
+
+}
+
+
+void CSettingDlg::OnBnClickedsureocr()
+{
+	int ids[] = { IDC_EDIT_OCR_WINDOW_PARAMS_TOP, IDC_EDIT_OCR_WINDOW_PARAMS_WIDTH, IDC_EDIT_OCR_WINDOW_PARAMS_HEIGHT, IDC_EDIT_OCR_WINDOW_PARAMS_SCALE };
+
+	CString top, width, height, scale;
+	((CEdit*)GetDlgItem(ids[0]))->GetWindowTextW(top);
+	((CEdit*)GetDlgItem(ids[1]))->GetWindowTextW(width);
+	((CEdit*)GetDlgItem(ids[2]))->GetWindowTextW(height);
+	((CEdit*)GetDlgItem(ids[3]))->GetWindowTextW(scale);
+
+
+
+
+
+
+
+
+	try {
+		if (!StringUtil::isNumber(StringUtil::cstring2String(top))) {
+			throw CString(L"涓婅竟璺濇牸寮忛敊璇�");
+		}
+
+		if (!StringUtil::isNumber(StringUtil::cstring2String(width))) {
+			throw CString(L"瀹藉害鏍煎紡閿欒");
+		}
+
+		if (!StringUtil::isNumber(StringUtil::cstring2String(height))) {
+			throw CString(L"楂樺害鏍煎紡閿欒");
+		}
+
+		if (scale.IsEmpty()) {
+			throw CString(L"璇峰~鍐欑缉鏀炬瘮");
+		}
+
+		OCRWindowParams params;
+		params.top = stoi(StringUtil::cstring2String(top));
+		params.width = stoi(StringUtil::cstring2String(width));
+		params.height = stoi(StringUtil::cstring2String(height));
+		params.scale = stof(StringUtil::cstring2String(scale));
+		ConfigUtil::setOCRWindowParams(params);
+		MessageBox(L"淇濆瓨鎴愬姛", L"鎻愮ず");
+	}
+	catch (CString st) {
+		AfxMessageBox(st);
+	}
+
+
+	catch (...) {
+		AfxMessageBox(L"淇濆瓨澶辫触");
+	}
+}
+
+
+void CSettingDlg::OnBnClickedsureocrtest()
+{
+	
+
+	try {
+
+		RECT rect;
+		cv::Mat mat = ThsCodeOCR::capture(ConfigUtil::getOCRWindowParams());
+
+		cv::imwrite("D:/test_origin.jpg", mat);
+
+		mat = ThsCodeOCR::splitForCodeImg(mat);
+
+		cv::imwrite("D:/test.jpg", mat);
+		string code;
+	
+		ThsCodeOCR *ocr =	new ThsCodeOCR();
+		auto start_time = GetTickCount64();
+		for (int i = 0; i < 10; i++) {
+			code = ocr->ocrCode();
+			cout << code << endl;
+		}
+
+		int subTime = GetTickCount64() - start_time;
+		CString msg;
+		msg.Append(CString(code.c_str()));
+		msg.Append(L"锛氳�楁椂");
+		msg.Append(to_wstring(subTime).c_str());
+		msg.Append(L"ms");
+		delete ocr;
+		MessageBox(msg, L"璇嗗埆缁撴灉");
+
+	/*	cv::Mat mat = cv::imread("D:/test_origin_1.jpg", cv::IMREAD_GRAYSCALE);
+		mat = ThsCodeOCR::splitForCodeImg(mat);
+		ThsCodeOCR* ocr = new ThsCodeOCR();
+		string code = ocr->ocrCode(mat);
+		MessageBox(CString(code.c_str()), L"璇嗗埆缁撴灉");*/
+
+	}
+	catch (string st) {
+		AfxMessageBox(CString(st.c_str()));
+	}
+	catch (...) {
+		AfxMessageBox(L"鍙戠敓鍏朵粬閿欒");
+	}
+}
+
+
+void CSettingDlg::OnBnClickedButtonBuyCb()
+{
+	// 鎵撳紑鍙浆鍊轰拱鍏�
+	CCBBuyDlg dlg;
+	INT_PTR nResponse = dlg.DoModal();
+}
+
+
+void CSettingDlg::OnBnClickedButton1()
+{
+	NetworkApi::test_place_order("002387");
 }

--
Gitblit v1.8.0