派生自 development/c++

chenshijun
2019-03-19 9c1dbad3fcf04c4c797437531031cfaefe28bfcf
QiaoJiaSystem/FaceSearchServer/FaceDBCompareServer.cpp
@@ -191,44 +191,62 @@
        m_rwLock.wrlock();
        if (t_json["\"syncTpye\""].type() == Json::nullValue) {
            //            同步库/特征是base64
//            #todo sqlite search data from file
            auto str_tab = t_json["\"tableName\""].asString();
            m_tableName = str_tab.substr(1, str_tab.length() - 2);//.append("_fea");
            string tet = "./syncDBClient ";
            string str_json = writer.write(t_json);
            tet.append("\"" + str_json.substr(0, str_json.length() - 1) + "\" ");
            INFO(tet);
            system(tet.c_str());
//            string tet = "./syncDBClient ";
//            string str_json = writer.write(t_json);
//            tet.append("\"" + str_json.substr(0, str_json.length() - 1) + "\" ");
//            INFO(tet);
//            system(tet.c_str());
            dataMap.clear();
            try {
                // init
                BISTL::BiMapFeaData biMapFeaData(m_tableName);
                auto mymap = biMapFeaData.getMap();
                auto size = mymap->size();
                //#todo
                for (auto it = mymap->begin(); it != mymap->end(); it++) {
                    string str_uuid(it->second.m_id.data());
                    string ft(it->second.m_feature.data());
                    string imgUrl(it->second.m_imgUrl.data());
                    string strIdCard(it->second.m_idcard.data());
//                BISTL::BiMapFeaData biMapFeaData(m_tableName);
//                auto mymap = biMapFeaData.getMap();
                auto mymap = m_erlangDbTool->loadFaceFeaData(m_tableName);
                for (auto &item : mymap) {
                    auto &it = item.second;
                    string str2;
                    str2 = base64.Decode(ft.data(), ft.length());
                    str2 = base64.Decode(it.feature.data(), it.feature.size());
                    std::vector<unsigned char> t_fea;
                    t_fea.resize(str2.size());
                    memcpy(t_fea.data(), str2.data(), str2.size());
                    auto &test = dataMap[str_uuid];
                    test.uuid = str_uuid;
                    auto &test = dataMap[it.id];
                    test.uuid = it.id;
                    test.features.push_back(t_fea);
                    test.faceUrl = imgUrl;
                    test.idcard = strIdCard;
                    test.faceUrl = it.img;
                    test.idcard = it.idcard;
                    test.enabled = it.enable;
                    test.monLevel = it.monLevel;
                }
//                //#todo
//                for (auto it = mymap->begin(); it != mymap->end(); it++) {
//                    string str_uuid(it->second.m_id.data());
//                    string ft(it->second.m_feature.data());
//                    string imgUrl(it->second.m_imgUrl.data());
//                    string strIdCard(it->second.m_idcard.data());
//                    string str2;
//                    str2 = base64.Decode(ft.data(), ft.length());
//                    std::vector<unsigned char> t_fea;
//                    t_fea.resize(str2.size());
//                    memcpy(t_fea.data(), str2.data(), str2.size());
//                    auto &test = dataMap[str_uuid];
//                    test.uuid = str_uuid;
//                    test.features.push_back(t_fea);
//                    test.faceUrl = imgUrl;
//                    test.idcard = strIdCard;
//                }
            } catch (const std::exception &e) {
                printf("Exception:%s\n", e.what());
                BISTL::shared_memory_object::remove(m_tableName.c_str());
//                BISTL::shared_memory_object::remove(m_tableName.c_str());
            }
            BISTL::shared_memory_object::remove(m_tableName.c_str());
            appPref.setIntData(m_tableName, 1);
            DBG(m_tableName << " size is " << dataMap.size());
//            BISTL::shared_memory_object::remove(m_tableName.c_str());
        } else {
            //#todo get sqlite3 data
            m_tableName = t_json["tableName"].asCString();