From 689283efb275e3f1ba049aad8e361bd014a1af53 Mon Sep 17 00:00:00 2001 From: pans <pansen626@sina.com> Date: 星期四, 24 一月 2019 18:33:31 +0800 Subject: [PATCH] fix bug --- QiaoJiaSystem/DataManagerServer/http_configserver.cpp | 71 ++++++++++++++++++++++------------- 1 files changed, 45 insertions(+), 26 deletions(-) diff --git a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp index 9db378a..db1f481 100644 --- a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp +++ b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp @@ -1863,8 +1863,12 @@ std::string EndTime = value["EndTime"].asString(); std::string UploadFlag = value["IsSync"].asString(); + UploadFlag = UploadFlag.empty() ? "0" : UploadFlag; std::string CmpThreshold = value["threshold"].asString(); + CmpThreshold = CmpThreshold.empty() ? "60" : CmpThreshold; std::string Enabled = value["enabled"].asString(); + Enabled = Enabled.empty() ? "1" : Enabled; + bool ret = false; FieldValues fieldValues; fieldValues.insert(std::make_pair("uuid", Uuid)); @@ -1991,10 +1995,10 @@ subJson.append("\"bwType\":\"" + item.second.bwType + "\","); //#todo modify subJson.append("\"start_time\":\"" + item.second.startTime + "\","); - subJson.append("\"end_time\":\"" + item.second.endTime + "\""); + subJson.append("\"end_time\":\"" + item.second.endTime + "\","); - subJson.append("\"IsSync\":\"" + item.second.uploadFlag + "\""); - subJson.append("\"threshold\":\"" + item.second.cmpThreshold + "\""); + subJson.append("\"IsSync\":\"" + item.second.uploadFlag + "\","); + subJson.append("\"threshold\":\"" + item.second.cmpThreshold + "\","); subJson.append("\"enabled\":\"" + item.second.enabled + "\""); subJson.append("},"); json.append(subJson); @@ -2037,9 +2041,9 @@ subJson.append("\"tableType\":\"" + item.tableType + "\","); subJson.append("\"bwType\":\"" + item.bwType + "\","); subJson.append("\"start_time\":\"" + item.startTime + "\","); - subJson.append("\"end_time\":\"" + item.endTime + "\""); - subJson.append("\"IsSync\":\"" + item.uploadFlag + "\""); - subJson.append("\"threshold\":\"" + item.cmpThreshold + "\""); + subJson.append("\"end_time\":\"" + item.endTime + "\","); + subJson.append("\"IsSync\":\"" + item.uploadFlag + "\","); + subJson.append("\"threshold\":\"" + item.cmpThreshold + "\","); subJson.append("\"enabled\":\"" + item.enabled + "\""); subJson.append("},"); json.append(subJson); @@ -2079,6 +2083,7 @@ std::string idcard = value["idcard"].asString(); std::string strUUID = value["uuid"].asString(); std::string UploadFlag = value["IsSync"].asString(); +// #todo cv::Mat image; if (img_url.size() > 0) { @@ -2129,13 +2134,15 @@ } for (auto &item : faceResults) { + //#todo 鍘婚噸 + feature_base64 = base64.Encode(item.feature.data(), item.feature.size()); int x = item.left; int y = item.top; int w = item.width; int h = item.height; cv::Rect t_rect = {x, y, w, h}; - auto t_image = image(CvUtil::zoomRect(t_rect, 1.5, 1.5) & cv::Rect(0, 0, image.cols, image.rows)).clone(); + auto t_image = image(CvUtil::zoomRect(t_rect, 2, 2) & cv::Rect(0, 0, image.cols, image.rows)).clone(); std::vector<uchar> buffer; cvutil.cvMat2Buffer(t_image, buffer); img_url = "http://"; @@ -2159,16 +2166,16 @@ // std::string uuid = ""; bool ret_addPerson = false; + FieldValues fieldValues; + AddFaceData addFaceData; if (TableName.find("lt_") == 0) { - FieldValues fieldValues; - AddFaceData addFaceData; - addFaceData.feature.resize(faceResults[0].feature.size()); - memcpy(addFaceData.feature.data(), faceResults[0].feature.data(), faceResults[0].feature.size()); //#todo uuid have value is update if (strUUID.size() <= 0) { - // get Person id + addFaceData.feature.resize(faceResults[0].feature.size()); + memcpy(addFaceData.feature.data(), faceResults[0].feature.data(), faceResults[0].feature.size()); + // get Person id strUUID = AppUtil::getPersonId(m_batch, m_SerialNumber); addFaceData.uuid = strUUID; addFaceData.faceUrl = img_url; @@ -2184,14 +2191,22 @@ fieldValues.insert(std::make_pair("uuid", strUUID)); fieldValues.insert(std::make_pair("idCard", idcard)); - m_SqliteFaceEncap.updateFace(TableName, addFaceData, fieldValues); + ret_addPerson = m_SqliteFaceEncap.updateFace(TableName, addFaceData, fieldValues); } } else { - //#todo update data - // get Person id - strUUID = strUUID.size() > 0 ? strUUID : AppUtil::getPersonId(m_batch, m_SerialNumber); - ret_addPerson = erlangDbTool->addPerson(strUUID, TableName, feature_base64, img_url, idcard); + + if (strUUID.size() <= 0) { + strUUID = strUUID.size() > 0 ? strUUID : AppUtil::getPersonId(m_batch, m_SerialNumber); + ret_addPerson = erlangDbTool->addPerson(strUUID, TableName, feature_base64, img_url, idcard); + } else { + addFaceData.uuid = strUUID; + addFaceData.faceUrl = img_url; + fieldValues.insert(std::make_pair("uuid", strUUID)); + fieldValues.insert(std::make_pair("idCard", idcard)); +// #todo update + ret_addPerson = erlangDbTool->updatePerson(TableName, addFaceData, fieldValues); + } } if (ret_addPerson && strUUID.size() > 0) { @@ -2203,7 +2218,17 @@ if (UploadFlag == "1") { // #todo db queue upload to server - std::thread sendPerson(uploadPersonToServer, this, strUUID, img_url, idcard, feature_base64); + + std::string str_serUrl; + if (1) { + str_serUrl = GET_STR_CONFIG("uploadPersonUrl"); +// string sendUrl = "192.168.1.203:3697/addPerson/uploadToTemporary"; + } else { + str_serUrl = GET_STR_CONFIG("uploadPersonUrl"); +// string sendUrl = "192.168.1.203:3697/addPerson/uploadToTemporary"; + } + std::thread sendPerson(uploadPersonToServer, this, str_serUrl, strUUID, img_url, idcard, + feature_base64); sendPerson.detach(); } @@ -3105,9 +3130,8 @@ } } -void devHttpServer_c::uploadPersonToServer(devHttpServer_c *t_ptrThis, std::string parm_uuid, std::string parm_img_url, - std::string parm_idcard, - std::string parm_fea) { +void devHttpServer_c::uploadPersonToServer(devHttpServer_c *t_ptrThis, std::string sendUrl, std::string parm_uuid, + std::string parm_img_url, std::string parm_idcard, std::string parm_fea) { HttpRequestWithCrul m_requestWithCrul; Json::Value perInfos; Json::Value perInfo; @@ -3124,12 +3148,7 @@ perInfo["cardId"] = parm_idcard;//鍥剧墖鎻忚堪 perInfos.append(perInfo); - std::string str_serIp = GET_STR_CONFIG("mainServerIp"); - std::string str_serPort = GET_STR_CONFIG("mainServerPort"); -// string sendUrl = "192.168.1.203:3697/addPerson/uploadToTemporary"; - string sendUrl = str_serIp; - sendUrl.append(":").append(str_serPort).append("/addPerson/uploadToTemporary"); string postParams = perInfos.toStyledString(); string str_addRes; -- Gitblit v1.8.0