| | |
| | | //#include "HcRecord.h" |
| | | #include <time.h> |
| | | #include <dirent.h> |
| | | |
| | | using namespace std; |
| | | |
| | | devHttpServer_c::devHttpServer_c() |
| | |
| | | Json::Reader reader; |
| | | Json::Value value; |
| | | |
| | | if (reader.parse(content, value)) |
| | | { |
| | | if (reader.parse(content, value)) { |
| | | std::string devId = value["videoNum"].asString(); |
| | | std::string picDate = value["picDate"].asString(); |
| | | qint64 sub; |
| | | std::string path=getVideoPathByTime(picDate,devId,sub); |
| | | if (path.empty()) |
| | | { |
| | | if (path.empty()) { |
| | | |
| | | return "{\"ret_status\":\"内容有误,请检查!\"}"; |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | std::string result = "{\"file_path\":\"" + path + "\"}"; |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | return "{\"ret_status\":\"传输错误,请检查!\"}"; |
| | | } |
| | | } |
| | |
| | | return true; |
| | | } |
| | | |
| | | std::string devHttpServer_c::getVideoPathByTime(const std::string& time,const std::string& camId,qint64& sub) |
| | | { |
| | | std::string devHttpServer_c::getVideoPathByTime(const std::string &time, const std::string &camId, qint64 &sub) { |
| | | std::string t_FilePath = appConfig.getStringProperty("cutPath"); |
| | | |
| | | bool find=false;; |
| | |
| | | DBG("t_FilePath" << t_FilePath); |
| | | DBG("vec.size()" << vec.size()); |
| | | int size=vec.size(); |
| | | for(int i=0;i<size;++i) |
| | | { |
| | | qint64 t1=QDateTime::fromString(QString::fromStdString(vec[i]), "yyyy-MM-dd hh:mm:ss:zzz").toMSecsSinceEpoch(); |
| | | if(i+1<size) |
| | | { |
| | | qint64 t2=QDateTime::fromString(QString::fromStdString(vec[i+1]), "yyyy-MM-dd hh:mm:ss:zzz").toMSecsSinceEpoch(); |
| | | if(t>=t1 && t<t2) |
| | | { |
| | | for (int i = 0; i < size; ++i) { |
| | | qint64 t1 = QDateTime::fromString(QString::fromStdString(vec[i]), |
| | | "yyyy-MM-dd hh:mm:ss:zzz").toMSecsSinceEpoch(); |
| | | if (i + 1 < size) { |
| | | qint64 t2 = QDateTime::fromString(QString::fromStdString(vec[i + 1]), |
| | | "yyyy-MM-dd hh:mm:ss:zzz").toMSecsSinceEpoch(); |
| | | if (t >= t1 && t < t2) { |
| | | DBG("path="<<vec[i]); |
| | | t_FilePath+=vec[i]+".mp4"; |
| | | sub=t-t1; |
| | |
| | | break; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | sub=t-t1; |
| | | if(t>=t1 && sub<=3000) |
| | | { |
| | | if (t >= t1 && sub <= 3000) { |
| | | DBG("path="<<vec[i]); |
| | | t_FilePath+=vec[i]+".mp4"; |
| | | find=true; |
| | |
| | | |
| | | } |
| | | DBG("sub="<<sub); |
| | | if(!find) |
| | | { |
| | | if (!find) { |
| | | t_FilePath=""; |
| | | } |
| | | return t_FilePath; |
| | | |
| | | } |
| | | std::vector<std::string> devHttpServer_c::forEachFile(const std::string &dir_name) |
| | | { |
| | | |
| | | std::vector<std::string> devHttpServer_c::forEachFile(const std::string &dir_name) { |
| | | std::vector<std::string> v; |
| | | auto dir = opendir(dir_name.data()); |
| | | struct dirent *ent; |
| | |
| | | while ((ent = readdir(dir)) != NULL) { |
| | | std::string filename = std::string(ent->d_name); |
| | | std::string temp; |
| | | if(filename!="."&&filename!="..") |
| | | { |
| | | if (filename != "." && filename != "..") { |
| | | |
| | | temp = filename.substr(0, filename.rfind('.')); |
| | | v.push_back(temp); |
| | |
| | | } else { |
| | | str_result = "[]"; |
| | | } |
| | | erlangDbTool->sendMessage(); |
| | | return str_result; |
| | | } else { |
| | | response->write(SimpleWeb::StatusCode::server_error_not_implemented, "{\"error\":\"传输错误,请检查!\"}"); |
| | |
| | | str_res = "{\"result\":\"-1\",\"msg\":\"error\",\"existDataBase\":[]}"; |
| | | ERR(ex.what()); |
| | | } |
| | | erlangDbTool->sendMessage(); |
| | | return str_res; |
| | | } else { |
| | | response->write(SimpleWeb::StatusCode::server_error_not_implemented, "{\"error\":\"传输错误,请检查!\"}"); |