master
IoTcat 5 years ago
parent 1f3f1a2a89
commit 3d4e662a8e
  1. 6
      lib/ovo.h
  2. 95
      src/main.cpp
  3. 37
      src/park.h

@ -469,8 +469,9 @@ namespace ovo{
return _data.size();
}
private:
map<string, string> _data;
private:
ovo::String S;
/* string to string */
inline string toStr(const string& from) const{
@ -729,6 +730,9 @@ namespace ovo{
std::vector<std::vector<string>> v;
std::vector<ovo::data> o;
d.classify();
if(!d.size()) return this->getSQL(tableName);
indexList = this->_getTableIndex(tableName);

@ -11,7 +11,86 @@ using namespace std;
int main(int argc, char const *argv[])
{
FeeTable t;
Park p;
if(!p.isExist()){
ovo::math m;
std::vector<std::map<string, int>> ParkIniInfo;
std::map<string, int> t_map;
for(int i = 0; i < 100; i ++){
t_map["Car"] = m.rand(0, 600);
t_map["Bicycle"] = m.rand(0, 600);
t_map["Airplane"] = m.rand(0, 600);
t_map["Ship"] = m.rand(0, 600);
ParkIniInfo.push_back(t_map);
}
p.ini(ParkIniInfo);
std::map<string, std::vector<int>> feeTable;
std::vector<int> fee;
for(int i = 0; i < 24; i ++){
fee.push_back(m.rand(0, 60));
}
feeTable["Car"] = fee;
for(int i = 0; i < 24; i ++){
fee[i] = m.rand(0, 60);
}
feeTable["Bicycle"] = fee;
for(int i = 0; i < 24; i ++){
fee[i] = m.rand(0, 60);
}
feeTable["Airplane"] = fee;
for(int i = 0; i < 24; i ++){
fee[i] = m.rand(0, 60);
}
feeTable["Ship"] = fee;
p.updateFeeTable(feeTable);
}
ovo::data d;
d["date"] = "2019-05-24";
cout <<p.getLog(d).size();
//cout << p.getLog()
while(1){
string input = "";
while(cin >> input){
if(input == "getPlots"){
for(auto i : p.getPlotsID()){
cout << p.getPlot(i).showAll() << endl;
}
}
if(input == "getPlotsNum"){
cout << p.getPlotsID().size() << endl;
}
input = "";
}
}
// FeeTable t;
/*
std::vector<string> v;
@ -20,7 +99,8 @@ int main(int argc, char const *argv[])
t.setTypes(v);
*/
*//*
std::map<string, std::vector<int>> mm;
std::vector<int> vv;
@ -38,7 +118,7 @@ int main(int argc, char const *argv[])
//cout << t.getFee("car", "0", "10000");
//cout << t.showAll();
*/
/*
Plot p("eeeee", 3, "222");
@ -51,7 +131,7 @@ int main(int argc, char const *argv[])
*/
/*
Park p;
@ -84,12 +164,12 @@ int main(int argc, char const *argv[])
//cout << p._feeTable.showAll();
//cout << p._d.showAll();
//
//*/
/*
string kk = "";
if(!p.newCar("110", "Cars", p.getPlotsID("Cars", false)[0], kk))cout << kk;
int t = time(NULL);*/
int t = time(NULL);
string s = "Cars";
//cout << endl<<p.getPlotsID("Cars", false).size();
@ -103,10 +183,11 @@ int main(int argc, char const *argv[])
cout << " " << time(NULL) - t;
//p.delCar("110");
cout << p.getPlotByCar("110").showAll();
*/
for(auto i : p.getLogByDate("2019-05-23")){
cout << i.showAll();
}
*/
return 0;
}

@ -695,6 +695,27 @@ public:
}
std::vector<std::map<string, string>> getLog(std::map<string, string> Filter){
ovo::data d;
std::vector<ovo::data> v;
std::vector<std::map<string, string>> o;
for(auto i : Filter){
d[i.first] = d[i.second];
}
v = db.getSQL(this->_d["log"], d);
for(auto i : v){
o.push_back(i._data);
}
return o;
}
std::vector<ovo::data> getLog(ovo::data FilterData){
return db.getSQL(this->_d["log"], FilterData);
@ -720,6 +741,14 @@ public:
return db.getSQL(this->_d["log"], d);
}
std::vector<ovo::data> getLogByType(const string& type, const string& date){
ovo::data d;
d["type"] = type;
d["date"] = date;
return db.getSQL(this->_d["log"], d);
}
std::vector<ovo::data> getLogByLevel(const int& level){
ovo::data d;
@ -727,6 +756,14 @@ public:
return db.getSQL(this->_d["log"], d);
}
std::vector<ovo::data> getLogByLevel(const int& level, const string& date){
ovo::data d;
d["level"] = to_string(level);
d["date"] = date;
return db.getSQL(this->_d["log"], d);
}
std::vector<ovo::data> getLogByFee(const int& fee){
ovo::data d;

Loading…
Cancel
Save