|
|
@@ -106,8 +106,8 @@ BOOL CMonitorObjectMng::LoadMoMap()
|
|
|
if (imei[0x00] != 0x00) simei << imei << '.' << idx;
|
|
|
|
|
|
string momp = smomp.str();
|
|
|
- m_mapMoMpZZJNO[momp] = zzj_no;
|
|
|
- m_mapMoMpZZJEPOS[momp] = (DAOCHA_POSITION)epos;
|
|
|
+ //m_mapMoMpZZJNO[momp] = zzj_no;
|
|
|
+ //m_mapMoMpZZJEPOS[momp][0] = (DAOCHA_POSITION)epos;
|
|
|
m_mapMoMpImeiIdx[momp] = simei.str();
|
|
|
if (imei[0x00] != 0x00) m_mapImeiIdxMoMp[simei.str()] = smomp.str();
|
|
|
|
|
|
@@ -130,9 +130,11 @@ BOOL CMonitorObjectMng::LoadMoMap()
|
|
|
it->zzjno = zzj_no;
|
|
|
it->mo = mo;
|
|
|
it->mp = mp;
|
|
|
+ it->mapPos[time(0)] = (DAOCHA_POSITION)epos;;
|
|
|
if (!it->imei.empty())
|
|
|
it->pDeivce = CDeviceMng::Instance()->Insert(imei);
|
|
|
}
|
|
|
+ /*
|
|
|
{
|
|
|
auto& it = m_mapMoMpName[momp];
|
|
|
if (it.size() == 0)
|
|
|
@@ -188,9 +190,10 @@ BOOL CMonitorObjectMng::LoadMoMap()
|
|
|
it.push_back(direct2);
|
|
|
}
|
|
|
}
|
|
|
+ */
|
|
|
}
|
|
|
|
|
|
- return m_mapMoMpImeiIdx.size() + 1;
|
|
|
+ return m_mapMoMpInfo.size() + 1;
|
|
|
}
|
|
|
|
|
|
void CMonitorObjectMng::GetChild(std::list<CMonitorObject*>& lst, CMonitorObject* parent)
|
|
|
@@ -219,7 +222,7 @@ void CMonitorObjectMng::GetChild(std::list<CMonitorObject*>& lst, CMonitorObject
|
|
|
pObject->type = "mo.mp";
|
|
|
pObject->up = parent->id;
|
|
|
pObject->parent = parent;
|
|
|
- pObject->eqpno = m_mapMoMpZZJNO[pObject->id];
|
|
|
+ pObject->eqpno = m_mapMoMpInfo[pObject->id]->zzjno;
|
|
|
parent->m_lstMo.push_back(pObject);
|
|
|
}
|
|
|
}
|
|
|
@@ -420,45 +423,66 @@ bool CMonitorObjectMng::GetStationNameByMomP(const std::string& mo, const std::s
|
|
|
|
|
|
bool CMonitorObjectMng::GetNameByMoMp(const std::string& momp, std::string& name1, std::string& name2, std::string& name3)
|
|
|
{
|
|
|
- auto& it = m_mapMoMpName.find(momp);
|
|
|
- if (it == m_mapMoMpName.end()) return false;
|
|
|
- if (it->second.size() < 3) return false;
|
|
|
- name1 = it->second[0];
|
|
|
- name2 = it->second[1];
|
|
|
- name3 = it->second[2];
|
|
|
- return true;
|
|
|
+ //auto& it = m_mapMoMpName.find(momp);
|
|
|
+ //if (it == m_mapMoMpName.end()) return false;
|
|
|
+ //if (it->second.size() < 3) return false;
|
|
|
+ //name1 = it->second[0];
|
|
|
+ //name2 = it->second[1];
|
|
|
+ //name3 = it->second[2];
|
|
|
+ //return true;
|
|
|
+
|
|
|
+ auto it = GetMoMpInfo(momp);
|
|
|
+ if (it)
|
|
|
+ {
|
|
|
+ name1 = it->name1;
|
|
|
+ name2 = it->name2;
|
|
|
+ name3 = it->name3;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
bool CMonitorObjectMng::GetNameByMoMp(const std::string& momp, std::string& name1, std::string& name2, std::string& name3, std::string& out_name, std::string& in_name)
|
|
|
{
|
|
|
- auto& it = m_mapMoMpName.find(momp);
|
|
|
- if (it == m_mapMoMpName.end()) return false;
|
|
|
- if (it->second.size() < 5) return false;
|
|
|
- name1 = it->second[0];
|
|
|
- name2 = it->second[1];
|
|
|
- name3 = it->second[2];
|
|
|
- out_name = it->second[3];
|
|
|
- in_name = it->second[4];
|
|
|
- return true;
|
|
|
+ //auto& it = m_mapMoMpName.find(momp);
|
|
|
+ //if (it == m_mapMoMpName.end()) return false;
|
|
|
+ //if (it->second.size() < 5) return false;
|
|
|
+ //name1 = it->second[0];
|
|
|
+ //name2 = it->second[1];
|
|
|
+ //name3 = it->second[2];
|
|
|
+ //out_name = it->second[3];
|
|
|
+ //in_name = it->second[4];
|
|
|
+
|
|
|
+ auto it = GetMoMpInfo(momp);
|
|
|
+ if (it)
|
|
|
+ {
|
|
|
+ name1 = it->name1;
|
|
|
+ name2 = it->name2;
|
|
|
+ name3 = it->name3;
|
|
|
+ out_name = it->out_name;
|
|
|
+ in_name = it->in_name;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
void CMonitorObjectMng::SetNameByMoMp(const std::string& momp, std::string& name1, std::string& name2, std::string& name3)
|
|
|
{
|
|
|
- auto& it = m_mapMoMpName.find(momp);
|
|
|
- if (it == m_mapMoMpName.end())
|
|
|
- {
|
|
|
- std::vector<string> vct;
|
|
|
- vct.push_back(name1);
|
|
|
- vct.push_back(name2);
|
|
|
- vct.push_back(name3);
|
|
|
- m_mapMoMpName[momp] = vct;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- it->second[0] = name1;
|
|
|
- it->second[1] = name2;
|
|
|
- it->second[2] = name3;
|
|
|
- }
|
|
|
+ //auto& it = m_mapMoMpName.find(momp);
|
|
|
+ //if (it == m_mapMoMpName.end())
|
|
|
+ //{
|
|
|
+ // std::vector<string> vct;
|
|
|
+ // vct.push_back(name1);
|
|
|
+ // vct.push_back(name2);
|
|
|
+ // vct.push_back(name3);
|
|
|
+ // m_mapMoMpName[momp] = vct;
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // it->second[0] = name1;
|
|
|
+ // it->second[1] = name2;
|
|
|
+ // it->second[2] = name3;
|
|
|
+ //}
|
|
|
|
|
|
{
|
|
|
auto it = GetMoMpInfo(momp);
|
|
|
@@ -469,7 +493,7 @@ void CMonitorObjectMng::SetNameByMoMp(const std::string& momp, std::string& name
|
|
|
it->name3 = name3;
|
|
|
it->name1utf = ANSItoUTF8(name1);
|
|
|
it->name2utf = ANSItoUTF8(name2);
|
|
|
- it->name3 = ANSItoUTF8(name3);
|
|
|
+ it->name3utf = ANSItoUTF8(name3);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -485,19 +509,19 @@ bool CMonitorObjectMng::GetDirectByMoMp(const std::string& momp, std::string& ou
|
|
|
|
|
|
void CMonitorObjectMng::SetDirectByMoMp(const std::string& momp, std::string& direct1, std::string& direct2)
|
|
|
{
|
|
|
- auto& it = m_mapMoMpDirect.find(momp);
|
|
|
- if (it == m_mapMoMpDirect.end())
|
|
|
- {
|
|
|
- std::vector<string> vct;
|
|
|
- vct.push_back(direct1);
|
|
|
- vct.push_back(direct2);
|
|
|
- m_mapMoMpDirect[momp] = vct;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- it->second[0] = direct1;
|
|
|
- it->second[1] = direct2;
|
|
|
- }
|
|
|
+ //auto& it = m_mapMoMpDirect.find(momp);
|
|
|
+ //if (it == m_mapMoMpDirect.end())
|
|
|
+ //{
|
|
|
+ // std::vector<string> vct;
|
|
|
+ // vct.push_back(direct1);
|
|
|
+ // vct.push_back(direct2);
|
|
|
+ // m_mapMoMpDirect[momp] = vct;
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // it->second[0] = direct1;
|
|
|
+ // it->second[1] = direct2;
|
|
|
+ //}
|
|
|
|
|
|
{
|
|
|
auto it = GetMoMpInfo(momp);
|
|
|
@@ -653,38 +677,36 @@ void CMonitorObjectMng::GeneralMoPack(CMonitorObject* pObject, yyjson_mut_doc* d
|
|
|
|
|
|
uint32_t CMonitorObjectMng::GeneralMpPack(uint8_t** pack, int* len)
|
|
|
{
|
|
|
- if (m_mapMoMpName.size() == 0) return 0;
|
|
|
+ if (m_mapMoMpInfo.size() == 0) return 0;
|
|
|
|
|
|
auto doc = yyjson_mut_doc_new(nullptr);
|
|
|
auto root = yyjson_mut_arr(doc);
|
|
|
yyjson_mut_doc_set_root(doc, root);
|
|
|
|
|
|
- for (const auto& it : m_mapMoMpName)
|
|
|
+ for (const auto& it : m_mapMoMpInfo)
|
|
|
{
|
|
|
auto ss = it.second;
|
|
|
- if (ss.size() == 5)
|
|
|
- {
|
|
|
- auto obj = yyjson_mut_obj(doc);
|
|
|
- yyjson_mut_arr_add_val(root, obj);
|
|
|
-
|
|
|
- string mo, mp, momp = it.first;
|
|
|
- spiltByPoint(momp, mo, mp);
|
|
|
- string station, mompname;
|
|
|
- CMonitorObjectMng::Instance()->GetStationNameByMomP(momp, station, mompname);
|
|
|
- string mo_name, mp_name;
|
|
|
- spiltByPoint(mompname, mo_name, mp_name);
|
|
|
-
|
|
|
- yyjson_mut_obj_add_strcpy(doc, obj, "station", station.c_str());
|
|
|
- yyjson_mut_obj_add_strcpy(doc, obj, "mo_name", mo_name.c_str());
|
|
|
- yyjson_mut_obj_add_strcpy(doc, obj, "mp_name", mp_name.c_str());
|
|
|
- yyjson_mut_obj_add_strcpy(doc, obj, "mo", mo.c_str());
|
|
|
- yyjson_mut_obj_add_strcpy(doc, obj, "mp", mp.c_str());
|
|
|
- yyjson_mut_obj_add_strcpy(doc, obj, "name1", ss[0].c_str());
|
|
|
- yyjson_mut_obj_add_strcpy(doc, obj, "name2", ss[1].c_str());
|
|
|
- yyjson_mut_obj_add_strcpy(doc, obj, "name3", ss[2].c_str());
|
|
|
- yyjson_mut_obj_add_strcpy(doc, obj, "direct1", ss[3].c_str());
|
|
|
- yyjson_mut_obj_add_strcpy(doc, obj, "direct2", ss[4].c_str());
|
|
|
- }
|
|
|
+
|
|
|
+ auto obj = yyjson_mut_obj(doc);
|
|
|
+ yyjson_mut_arr_add_val(root, obj);
|
|
|
+
|
|
|
+ string mo, mp, momp = it.first;
|
|
|
+ spiltByPoint(momp, mo, mp);
|
|
|
+ string station, mompname;
|
|
|
+ CMonitorObjectMng::Instance()->GetStationNameByMomP(momp, station, mompname);
|
|
|
+ string mo_name, mp_name;
|
|
|
+ spiltByPoint(mompname, mo_name, mp_name);
|
|
|
+
|
|
|
+ yyjson_mut_obj_add_strcpy(doc, obj, "station", station.c_str());
|
|
|
+ yyjson_mut_obj_add_strcpy(doc, obj, "mo_name", mo_name.c_str());
|
|
|
+ yyjson_mut_obj_add_strcpy(doc, obj, "mp_name", mp_name.c_str());
|
|
|
+ yyjson_mut_obj_add_strcpy(doc, obj, "mo", mo.c_str());
|
|
|
+ yyjson_mut_obj_add_strcpy(doc, obj, "mp", mp.c_str());
|
|
|
+ yyjson_mut_obj_add_strcpy(doc, obj, "name1", ss->name1.c_str());
|
|
|
+ yyjson_mut_obj_add_strcpy(doc, obj, "name2", ss->name2.c_str());
|
|
|
+ yyjson_mut_obj_add_strcpy(doc, obj, "name3", ss->name3.c_str());
|
|
|
+ yyjson_mut_obj_add_strcpy(doc, obj, "direct1", ss->out_name.c_str());
|
|
|
+ yyjson_mut_obj_add_strcpy(doc, obj, "direct2", ss->in_name.c_str());
|
|
|
}
|
|
|
|
|
|
size_t json_len;
|
|
|
@@ -708,7 +730,12 @@ void CMonitorObjectMng::UpdateZZJEPOS(const string& momp, DAOCHA_POSITION epos)
|
|
|
auto ret = CDBConnectPool::Instance()->DBExecuteSQL(sql);
|
|
|
if (ret)
|
|
|
{
|
|
|
- m_mapMoMpZZJEPOS[momp] = epos;
|
|
|
+ auto lstEPOS = m_mapMoMpInfo[momp];
|
|
|
+ lstEPOS->mapPos[time(0)] = (DAOCHA_POSITION)epos;
|
|
|
+ if (lstEPOS->mapPos.size() > 10)
|
|
|
+ {
|
|
|
+ lstEPOS->mapPos.erase(lstEPOS->mapPos.begin());
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -716,4 +743,22 @@ void CMonitorObjectMng::UpdateZZJEPOS(const string& momp, DAOCHA_POSITION epos)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//删除ZZJ历史记录,保留最新的一个
|
|
|
+void CMonitorObjectMng::ClearZZJHistroyEPOS(time_t t)
|
|
|
+{
|
|
|
+ for (auto& item : m_mapMoMpInfo)
|
|
|
+ {
|
|
|
+ //auto& epos = m_mapMoMpZZJEPOS[momp];
|
|
|
+ auto& epos = item.second->mapPos;
|
|
|
+
|
|
|
+ for (auto it = epos.begin(); it != (--epos.end());)
|
|
|
+ {
|
|
|
+ if (it->first <= t)
|
|
|
+ it = epos.erase(it);
|
|
|
+ else
|
|
|
+ it++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
CMonitorObjectMng CMonitorObjectMng::obj;
|