From 25f94726888e19d6efed7b393217d9f56a0ca767 Mon Sep 17 00:00:00 2001 From: chenshijun <chenshijun@aiotlink.com> Date: 星期五, 15 三月 2019 18:44:46 +0800 Subject: [PATCH] Merge branch 'yw.1.2.fixbug' of ssh://192.168.1.226:29418/development/c++ into yw.1.2.fixbug --- QiaoJiaSystem/DataManagerServer/http_configserver.cpp | 35 ++++++++++------- QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.cpp | 29 ++++++++++++++ QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.h | 1 3 files changed, 51 insertions(+), 14 deletions(-) diff --git a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp index 64595d9..68b7b32 100644 --- a/QiaoJiaSystem/DataManagerServer/http_configserver.cpp +++ b/QiaoJiaSystem/DataManagerServer/http_configserver.cpp @@ -292,10 +292,10 @@ elem["n_duration"] = iter->n_duration; elem["str_brand"] = iter->str_brand.toStdString(); elem["str_reserved"] = iter->str_reserved.toStdString(); - cout << elem.toStyledString() << endl; + DBG(elem.toStyledString()); value.append(elem); } - cout << value.toStyledString() << endl; + DBG(value.toStyledString()); // std::string out = value.toStyledString(); std::string out = value.size() > 0 ? value.toStyledString() : "[]"; @@ -696,7 +696,7 @@ } dev_rec.str_storage_dev_id = QString::fromLatin1((const char *) serialnumber);//鑾峰彇纾佺洏闃靛垪鐨勮澶噄d - std::cout << dev_rec.str_storage_dev_id.toStdString() << std::endl; + DBG(dev_rec.str_storage_dev_id.toStdString()); ret = db_c.updateDeviceTable(dev_rec); } else { return "{\"ret_status\": \"浼犺緭閿欒锛岃妫�鏌ワ紒\"}"; @@ -743,7 +743,7 @@ std::string str_result; std::string str_tmp; for (int i = 0; i < lvecUsefulChans.size(); i++) { - std::cout << lvecUsefulChans.at(i) << std::endl; + DBG(lvecUsefulChans.at(i)); str_tmp = std::to_string(lvecUsefulChans.at(i)); str_result += str_tmp; str_result += ","; @@ -888,17 +888,17 @@ } } - cout << elem.toStyledString() << endl; + DBG(elem.toStyledString()); value.append(elem); } for (std::vector<int>::iterator it1 = chns.begin(); it1 != chns.end(); it1++) { chn_unused["n_chn"] = *it1; - cout << "*it1" << *it1 << endl; + DBG("*it1" << *it1); value.append(chn_unused); } - cout << value.toStyledString() << endl; + DBG(value.toStyledString()); // std::string out = value.toStyledString(); std::string out = value.size() > 0 ? value.toStyledString() : "[]"; return out; @@ -1026,12 +1026,12 @@ // elem["str_det_thr"] = rec_sdk.str_det_thr.toStdString(); // elem["str_cmp_thr"] = rec_sdk.str_cmp_thr.toStdString(); - cout << elem.toStyledString() << endl; + DBG(elem.toStyledString()); value.append(elem); } - cout << value.toStyledString() << endl; + DBG(value.toStyledString()); std::string out = value.size() > 0 ? value.toStyledString() : "[]"; return out; } @@ -1447,7 +1447,7 @@ "sed -i '/tracker_server=/d' ./WebFDSClient.conf && sed -i '/\\\"host:port\\\"/atracker_server=" + \ value["web_pic_ip"].asString() + ":" + std::to_string(value["web_pic_port"].asInt()) + \ "' ./WebFDSClient.conf";// - std::cout << "cmd_web:" << cmd_web << std::endl; + DBG("cmd_web:" << cmd_web); system(cmd_web.c_str()); //#todo fastDfsClient @@ -1456,7 +1456,7 @@ "sed -i '/tracker_server=/d' ./fastDfsClient.conf && sed -i '/\\\"host:port\\\"/atracker_server=" + \ value["es_pic_ip"].asString() + ":" + std::to_string(value["es_pic_port"].asInt()) + \ "' ./fastDfsClient.conf"; - std::cout << "cmd_es:" << cmd_es << std::endl; + DBG("cmd_es:" << cmd_es); system(cmd_es.c_str()); //#todo config @@ -1611,7 +1611,7 @@ // system("sed -i 's/address .*$/address 192.168.1.111/g' test"); std::string cmd_ip = "sed -i 's/address .*$/address " + ip_addr + "/g' /etc/network/interfaces"; - std::cout << "cmd_ip:" << cmd_ip << std::endl; + DBG("cmd_ip:" << cmd_ip); system(cmd_ip.c_str()); //淇敼config.json @@ -2834,7 +2834,7 @@ appConfig.setStringProperty("DEV_ID", dev_id); appConfig.save(); - //std::cout<<dev_id<<std::endl; + return true; } @@ -3338,6 +3338,8 @@ } std::string devHttpServer_c::getSnapshot(std::string ip, unsigned int port, std::string content, PResponse &response) { + DBG("ip:" << ip << "; port:" << port); + DBG("content: " << content); Json::Reader reader; Json::Value value; @@ -3406,7 +3408,12 @@ fdfsClient.rwLock.unlock(); Json::Value result; result["imgUrl"] = strImgUrl; - db_c.updateCamDevSnapshot(QString::fromStdString(rtsp_ip), QString::fromStdString(strImgUrl)); + if (value.isMember("id")) { + db_c.updateCamDevSnapshotbyID(value["id"].asString().c_str(), QString::fromStdString(strImgUrl)); + } + else{ + db_c.updateCamDevSnapshot(QString::fromStdString(rtsp_ip), QString::fromStdString(strImgUrl)); + } return result.toStyledString(); diff --git a/QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.cpp b/QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.cpp index f1a6d89..cba8280 100644 --- a/QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.cpp +++ b/QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.cpp @@ -455,6 +455,35 @@ } } +bool LDBTool::updateCamDevSnapshotbyID(const QString &strID, const QString &imgUrl) { + QMutexLocker mutexLocker(&m_mutexVisit);//TODO + QSqlTableModel pModel(NULL, m_db); + pModel.setTable("cam_dev"); + pModel.setFilter( + QObject::tr("cam_dev_id = '%1'").arg(strID)); + pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange + pModel.select(); + + QSqlRecord rec = pModel.record(0); + rec.setValue("reserved", imgUrl); + + int rowCount = pModel.rowCount(); + if (rowCount > 0) { + pModel.setRecord(0, rec);//TODO + } + + m_db.transaction();//寮�濮嬩簨鍔℃搷浣� + + if (pModel.submitAll()) { + m_db.commit();//鎻愪氦 + return true; + } else { + m_db.rollback();//鍥炴粴 + ERR("updateCamDevSnapshot err ,Database Error: " << pModel.lastError().text().toStdString()); + return false; + } +} + bool LDBTool::updateCamDevSnapshot(const QString &strIp, const QString &imgUrl) { QMutexLocker mutexLocker(&m_mutexVisit);//TODO QSqlTableModel pModel(NULL, m_db); diff --git a/QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.h b/QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.h index eb53d1c..159e448 100644 --- a/QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.h +++ b/QiaoJiaSystem/VideoServer/QiaoJia/DB/LDBTool.h @@ -54,6 +54,7 @@ int searchCamDevNumber(void); bool searchCamDevByCamId(QString strCamId); bool updateCamDevSnapshot(const QString& strIp ,const QString& imgUrl); + bool updateCamDevSnapshotbyID(const QString &strID, const QString &imgUrl); //load_file_info bool insertLoadFileTable(Record_Load_File_info loadfileRec); -- Gitblit v1.8.0