| | |
| | | #include "../common/NetworkApi.h" |
| | | #include <map> |
| | | #include "../common/JsonUtil.h" |
| | | #include "../common/TimeUtil.h" |
| | | |
| | | |
| | | std::list<CodeInfo> MonitorDlg::l2CodesList; |
| | | std::list<CodeInfo> MonitorDlg::l2PositionCodesList; |
| | | list<TradeDelegateRecord> MonitorDlg::delegateList; |
| | | list<TradeDealRecord> MonitorDlg::dealList; |
| | | bool MonitorDlg::kill; |
| | |
| | | Sleep(2000); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | void MonitorDlg::requestL2PositionCodeList(MonitorDlg* dlg) |
| | | { |
| | | |
| | | |
| | | while (TRUE) { |
| | | if (kill) { |
| | | break; |
| | | } |
| | | try { |
| | | SubscriptCodesResult result = NetworkApi::get_huaxin_position_subscript_codes(); |
| | | dlg->labelL2PositionSubscriptCodesUpdateTime.SetWindowTextW(result.updateTime); |
| | | if (result.codeInfos.size() > 0) { |
| | | //将原来的数据映射为map |
| | | |
| | | dlg->listL2PositionCodes.SetRedraw(false); |
| | | |
| | | // 先删除/增加多余的行,然后修改行中内容 |
| | | int add_line_count = result.codeInfos.size() - l2PositionCodesList.size(); |
| | | if (add_line_count > 0) { |
| | | //增加行 |
| | | int start_index = l2PositionCodesList.size(); |
| | | for (int i = 0; i < add_line_count; i++) { |
| | | dlg->listL2PositionCodes.InsertItem(start_index + i, L""); |
| | | } |
| | | } |
| | | else if (add_line_count < 0) { |
| | | int start_index = l2PositionCodesList.size() - 1; |
| | | //删除行 |
| | | for (int i = 0; i > add_line_count; i--) { |
| | | dlg->listL2PositionCodes.DeleteItem(start_index + i); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //更改数据 |
| | | int index = -1; |
| | | bool hasChanged = FALSE; |
| | | for (list<CodeInfo>::iterator el = result.codeInfos.begin(); el != result.codeInfos.end(); ++el) { |
| | | CodeInfo r = *el; |
| | | index++; |
| | | // 如果原数据的主键和本行主键一致就不用修改 |
| | | if (l2PositionCodesList.size() > index) { |
| | | list<CodeInfo>::iterator or = l2PositionCodesList.begin(); |
| | | std::advance(or , index); |
| | | if (r.code == (*or ).code) { |
| | | continue; |
| | | } |
| | | } |
| | | hasChanged = TRUE; |
| | | CString desc = CString(r.code); |
| | | desc.Append(L"("); |
| | | desc.Append(r.name); |
| | | desc.Append(L")"); |
| | | dlg->listL2PositionCodes.SetItemText(index, 0, desc); |
| | | |
| | | } |
| | | if (hasChanged || add_line_count != 0) { |
| | | l2PositionCodesList.clear(); |
| | | for (list<CodeInfo>::iterator el = result.codeInfos.begin(); el != result.codeInfos.end(); ++el) { |
| | | CodeInfo r = *el; |
| | | l2PositionCodesList.push_back(r); |
| | | } |
| | | } |
| | | dlg->listL2PositionCodes.SetRedraw(true); |
| | | } |
| | | |
| | | } |
| | | |
| | | catch (...) { |
| | | |
| | | |
| | | } |
| | | // 每1s请求一次 |
| | | Sleep(2000); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | CString kplInfo; |
| | | auto kplObject = data[L"kpl"].GetObjectW(); |
| | | if (kplObject.HasMember(L"limit_up")) { |
| | | CString limit_up_time = data[L"kpl"][L"limit_up"].GetArray()[0].GetString(); |
| | | kplInfo.Append(L"涨停列表-"); |
| | | kplInfo.Append(L"【"); |
| | | kplInfo.Append(data[L"kpl"][L"limit_up"].GetArray()[0].GetString()); |
| | | kplInfo.Append(limit_up_time); |
| | | kplInfo.Append(L"】"); |
| | | kplInfo.Append(L"【"); |
| | | kplInfo.Append(CString(std::to_string(data[L"kpl"][L"limit_up"].GetArray()[1].GetInt()).c_str())); |
| | | kplInfo.Append(L"】"); |
| | | |
| | | kplInfo.Append(L"\t"); |
| | | |
| | | string now_time_str = TimeUtil::getNowTime(); |
| | | |
| | | if (TimeUtil::trade_time_sub(now_time_str,StringUtil::cstring2String( limit_up_time))>60) { |
| | | dlg->labelColors[IDC_STATIC_KPL_DATA] = RGB(255, 0, 0); |
| | | } |
| | | else { |
| | | dlg->labelColors[IDC_STATIC_KPL_DATA] = RGB(0, 0, 0); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (kplObject.HasMember(L"jingxuan_rank")) { |
| | |
| | | DDX_Control(pDX, IDC_STATIC_L2_SUBSCRIPT_CODES_UPDATE_TIME, labelL2SubscriptCodesUpdateTime); |
| | | DDX_Control(pDX, IDC_EDIT1, editLog); |
| | | DDX_Control(pDX, IDC_STATIC_L2_LISTEN_ACTIVE, labelL2ListenData); |
| | | DDX_Control(pDX, IDC_LIST_L2_POSITION_CODES, listL2PositionCodes); |
| | | DDX_Control(pDX, IDC_STATIC_L2_POSITION_SUBSCRIPT_CODES_UPDATE_TIME2, labelL2PositionSubscriptCodesUpdateTime); |
| | | } |
| | | |
| | | |
| | |
| | | ON_BN_CLICKED(IDC_BUTTON_REDIS_TEST, &MonitorDlg::OnBnClickedButtonRedisTest) |
| | | ON_BN_CLICKED(IDC_BUTTON_SYNC_SHSZ_CODES, &MonitorDlg::OnBnClickedButtonSyncShszCodes) |
| | | ON_BN_CLICKED(IDC_BUTTON_SAVE_RUNNING_DATA, &MonitorDlg::OnBnClickedButtonSaveRunningData) |
| | | ON_BN_CLICKED(IDC_BUTTON_REPAIRE_TASK, &MonitorDlg::OnBnClickedButtonRepaireTask) |
| | | END_MESSAGE_MAP() |
| | | |
| | | |
| | |
| | | logStartIndex = 1; |
| | | |
| | | l2RefreshThread = std::thread(requestL2CodeList, this); |
| | | l2PositionRefreshThread = std::thread(requestL2PositionCodeList, this); |
| | | delegateRefreshThread = std::thread(requestDelegateList, this); |
| | | dealRefreshThread = std::thread(requestDealList, this); |
| | | autoRefreshThread = std::thread(autoRefresh, this); |
| | |
| | | |
| | | //启动 |
| | | l2RefreshThread.detach(); |
| | | l2PositionRefreshThread.detach(); |
| | | delegateRefreshThread.detach(); |
| | | dealRefreshThread.detach(); |
| | | autoRefreshThread.detach(); |
| | | systemLogThread.detach(); |
| | | l2ListenActiveThread.detach(); |
| | | |
| | | kplDataWarning = FALSE; |
| | | |
| | | |
| | | return TRUE; // return TRUE unless you set the focus to a control |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | void MonitorDlg::OnBnClickedButtonRepaireTask() |
| | | { |
| | | string result = NetworkApi::repaire_task(); |
| | | auto doc = JsonUtil::parseUTF16(result); |
| | | if (doc.IsObject()) { |
| | | if (doc[L"code"].GetInt() == 0) { |
| | | MessageBox(L"修复完成!", L"提示"); |
| | | } |
| | | else { |
| | | AfxMessageBox(doc[L"msg"].GetString()); |
| | | } |
| | | } |
| | | else { |
| | | AfxMessageBox(L"网络请求出错"); |
| | | } |
| | | |
| | | } |