-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathassessUtil.cpp
More file actions
80 lines (70 loc) · 1.85 KB
/
assessUtil.cpp
File metadata and controls
80 lines (70 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "assessUtil.h"
LogUtil* LogUtil::_pInstance = new LogUtil();
AssessUtil* AssessUtil::_pInstance = new AssessUtil();
AssessUtil::AssessUtil()
{
Init();
}
AssessUtil* AssessUtil::GetInstance(){
if(_pInstance == NULL)
{
_pInstance = new AssessUtil();
}
}
bool AssessUtil::Init()
{
LOG4CPLUS_INFO(LogUtil::GetInstance()->GetLogger()
,"AssessUtil Init");
widCountMap.clear();
return true;
}
bool AssessUtil::IntervalAssess(const string &startTime,const string &endTime)
{
widCountMap.clear();
map<int,int>::iterator iter;
string query = "select * from tagstatus where time >= '";
query += startTime + "'";
query += " and time < '";
query += endTime + "'";
vector<TagStatus> tagStatusList;
if(DbUtil::GetInstance()->DbQueryTagStatus(query,tagStatusList))
{
LOG4CPLUS_ERROR(LogUtil::GetInstance()->GetLogger()
,"DbQueryTagStatus fail"<<query);
return false;
}
for(unsigned int i=0;i<tagStatusList.size();i++)
{
string widList = tagStatusList[i].widList;
long sid = tagStatusList[i].sid;
vector<string> widV;
if(!StrUtil::GetInstance()->Split(widList,",",widV))
{
LOG4CPLUS_ERROR(LogUtil::GetInstance()->GetLogger()
,"Split Error"<<i);
return false;
}
for(unsigned int j=0;j<widV.size();j++)
{
int wid = atoi(widV[j].c_str());
iter = widCountMap.find(wid);
if(iter == widCountMap.end())
widCountMap[wid] = 1;
else
widCountMap[wid] += 1;
}
}
return true;
}
map<int,int> *AssessUtil::GetWidCountMap()
{
return &widCountMap;
}
void AssessUtil::Test()
{
}
AssessUtil::~AssessUtil()
{
if(_pInstance)
delete _pInstance;
}