admin
2024-05-17 58ba0cf05fc97b0f424abfbe838ef0f3665bc2f9
功能修改
5个文件已修改
144 ■■■■■ 已修改文件
Monitor/Monitor.aps 补丁 | 查看 | 原始文档 | blame | 历史
Monitor/Monitor.rc 补丁 | 查看 | 原始文档 | blame | 历史
Monitor/MonitorDlg.cpp 121 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Monitor/MonitorDlg.h 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Monitor/resource.h 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Monitor/Monitor.aps
Binary files differ
Monitor/Monitor.rc
Binary files differ
Monitor/MonitorDlg.cpp
@@ -8,9 +8,11 @@
#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;
@@ -133,6 +135,86 @@
        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);
    }
}
@@ -412,15 +494,26 @@
                    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")) {
@@ -712,6 +805,8 @@
    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);
}
@@ -728,6 +823,7 @@
    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()
@@ -809,6 +905,7 @@
    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);
@@ -817,11 +914,14 @@
    //启动
    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
@@ -956,3 +1056,22 @@
    }
}
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"网络请求出错");
    }
}
Monitor/MonitorDlg.h
@@ -40,21 +40,29 @@
    DECLARE_DYNAMIC(MonitorDlg)
private:
    //开盘啦数据警告
    bool kplDataWarning;
    const int MAX_LOG_LINES = 100;
    map<int,COLORREF> labelColors;
    static bool kill;
    static std::list<CodeInfo> l2CodesList;
    static std::list<CodeInfo> l2PositionCodesList;
    static list<TradeDelegateRecord> delegateList;
    static list<TradeDealRecord> dealList;
    static void requestL2CodeList(MonitorDlg* dlg);
    static void requestL2PositionCodeList(MonitorDlg* dlg);
    static void requestDelegateList(MonitorDlg* dlg);
    static void requestDealList(MonitorDlg* dlg);
    static void autoRefresh(MonitorDlg* dlg);
    static void requestSystemLog(MonitorDlg* dlg);
    static void requestL2ListenActiveCount(MonitorDlg* dlg);
    
    std::thread l2RefreshThread;
    std::thread l2PositionRefreshThread;
    std::thread delegateRefreshThread;
    std::thread dealRefreshThread;
    std::thread autoRefreshThread;
@@ -114,4 +122,7 @@
    CEdit editLog;
    CStatic labelL2ListenData;
    afx_msg void OnBnClickedButtonSaveRunningData();
    CListCtrl listL2PositionCodes;
    CStatic labelL2PositionSubscriptCodesUpdateTime;
    afx_msg void OnBnClickedButtonRepaireTask();
};
Monitor/resource.h
@@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 供 Monitor.rc 使用
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 供 Monitor.rc 使用
//
#define IDR_MAINFRAME                   128
#define IDD_MONITOR                     139
@@ -20,6 +20,9 @@
#define IDC_STATIC_L2_SUBSCRIPT_CODES_UPDATE_TIME 1013
#define IDC_EDIT1                       1014
#define IDC_STATIC_L2_LISTEN_ACTIVE     1015
#define IDC_LIST_L2_POSITION_CODES      1017
#define IDC_STATIC_L2_SUBSCRIPT_CODES_UPDATE_TIME2 1018
#define IDC_STATIC_L2_POSITION_SUBSCRIPT_CODES_UPDATE_TIME2 1018
#define IDC_BUTTON_REFRESH_DELEGATE     1038
#define IDC_BUTTON_REFRESH_DEAL         1039
#define IDC_BUTTON_REFRESH_POSITION     1040
@@ -30,8 +33,9 @@
#define IDC_BUTTON_INIT_DATA            1044
#define IDC_BUTTON_REDIS_TEST           1045
#define IDC_BUTTON_SYNC_SHSZ_CODES      1046
#define IDC_BUTTON_SYNC_SHSZ_CODES2     1047
#define IDC_BUTTON_SAVE_RUNNING_DATA    1047
#define IDC_BUTTON_SAVE_RUNNING_DATA2   1048
#define IDC_BUTTON_REPAIRE_TASK         1048
// Next default values for new objects
//