| | |
| | | |
| | | public: |
| | | |
| | | static Json::Value toJson(std::list<TradeData> dataList) { |
| | | static Json::Value toJson(std::list<TradeData*> dataList) { |
| | | Json::Value root; |
| | | |
| | | std::list<TradeData>::iterator ele; |
| | | std::list<TradeData*>::iterator ele; |
| | | int index = 0; |
| | | for (ele = dataList.begin();ele != dataList.end();ele++) { |
| | | Json::Value item; |
| | | item["time"] = (*ele).time; |
| | | item["price"] = (*ele).price; |
| | | item["num"] = (*ele).num; |
| | | item["limitPrice"] = (*ele).limitPrice; |
| | | item["operateType"] = (*ele).operateType; |
| | | item["cancelTime"] = (*ele).cancelTime; |
| | | item["cancelTimeUnit"] = (*ele).cancelTimeUnit; |
| | | item["time"] = (*ele)->time; |
| | | item["price"] = (*ele)->price; |
| | | item["num"] = (*ele)->num; |
| | | item["limitPrice"] = (*ele)->limitPrice; |
| | | item["operateType"] = (*ele)->operateType; |
| | | item["cancelTime"] = (*ele)->cancelTime; |
| | | item["cancelTimeUnit"] = (*ele)->cancelTimeUnit; |
| | | root[index++] = item; |
| | | } |
| | | return root; |
| | |
| | | std::unique_ptr<Json::StreamWriter> jsonWriter(writerBuilder.newStreamWriter()); |
| | | jsonWriter->write(json, &os); |
| | | string jsonStr = os.str(); |
| | | //释放资源 |
| | | jsonWriter.reset(); |
| | | return jsonStr; |
| | | } |
| | | |
| | | static std::string loadL2Data(int clientID, int channel, string code, long captureTime, long processTime, std::list<TradeData> dataList) { |
| | | static std::string loadL2Data(int clientID, int channel, string code, long captureTime, long processTime, std::list<TradeData*> dataList) { |
| | | Json::Value data; |
| | | data["channel"] = channel; |
| | | data["code"] = code; |
| | |
| | | root["data"] = data; |
| | | return toJsonStr(root); |
| | | } |
| | | // ocr识别 |
| | | static std::string loadOcrData(int client,cv::Mat mat,string key) { |
| | | Json::Value data; |
| | | Json::Value array; |
| | | int len = mat.rows * mat.cols; |
| | | for (int i = 0; i < len; i++) { |
| | | Json::Value d; |
| | | d[0] = mat.data[i]; |
| | | array[i] = d; |
| | | } |
| | | data["data"] = array; |
| | | data["width"] = mat.cols; |
| | | data["height"] = mat.rows; |
| | | data["key"] = key; |
| | | Json::Value root; |
| | | root["data"] = data; |
| | | root["type"] = 100; |
| | | return toJsonStr(root); |
| | | } |
| | | |
| | | static std::string toJson(ClientEnvState state) { |
| | | Json::Value root; |