Browse Source

修改日期显示格式

master
zhaohe 2 years ago
parent
commit
0057987fc2
  1. 16
      src/db/db_service.cpp
  2. 6
      src/db/db_service.hpp
  3. 1
      src/main_control_service.cpp
  4. 2
      src/service/disinfection_ctl_service.cpp

16
src/db/db_service.cpp

@ -40,6 +40,7 @@ using namespace nlohmann;
#define FORMULA_DB_STRUCT \ #define FORMULA_DB_STRUCT \
make_table("formulas", /**/ \ make_table("formulas", /**/ \
make_column("id", &Formula::id, primary_key()), /**/ \ make_column("id", &Formula::id, primary_key()), /**/ \
make_column("loglevel", &Formula::loglevel), /**/ \
make_column("formula_id", &Formula::formula_id), /**/ \ make_column("formula_id", &Formula::formula_id), /**/ \
make_column("stoped_gs", &Formula::stoped_gs), /**/ \ make_column("stoped_gs", &Formula::stoped_gs), /**/ \
make_column("continued_gs", &Formula::continued_gs), /**/ \ make_column("continued_gs", &Formula::continued_gs), /**/ \
@ -456,13 +457,14 @@ json DBService::getAllFormulaJson() {
return jret; return jret;
} }
void DBService::addFormula(string formula_id, string stoped_gs, string continued_gs, string stoped_satur, string continued_satur, string stoped_humi,
string continued_humi, string injection_pump_speed) {
void DBService::addFormula(string loglevel, string formula_id, string stoped_gs, string continued_gs, string stoped_satur, string continued_satur,
string stoped_humi, string continued_humi, string injection_pump_speed) {
lock_guard<recursive_mutex> lock(lock_); lock_guard<recursive_mutex> lock(lock_);
auto formulatable = make_storage(FORMULA_DB, FORMULA_DB_STRUCT); auto formulatable = make_storage(FORMULA_DB, FORMULA_DB_STRUCT);
formulatable.sync_schema(); formulatable.sync_schema();
Formula f; Formula f;
f.loglevel = loglevel;
f.formula_id = formula_id; f.formula_id = formula_id;
f.stoped_gs = stoped_gs; f.stoped_gs = stoped_gs;
f.continued_gs = continued_gs; f.continued_gs = continued_gs;
@ -476,10 +478,10 @@ void DBService::addFormula(string formula_id, string stoped_gs, string continued
formulatable.sync_schema(); formulatable.sync_schema();
} }
void DBService::addFormula(string formula_id, int stoped_gs, int continued_gs, int stoped_satur, int continued_satur, int stoped_humi, int continued_humi,
int injection_pump_speed) {
addFormula(formula_id, to_string(stoped_gs), to_string(continued_gs), to_string(stoped_satur), to_string(continued_satur), to_string(stoped_humi),
to_string(continued_humi), to_string(injection_pump_speed));
void DBService::addFormula(string formula_id, int loglevel, int stoped_gs, int continued_gs, int stoped_satur, int continued_satur, int stoped_humi,
int continued_humi, int injection_pump_speed) {
addFormula(formula_id, to_string(loglevel), to_string(stoped_gs), to_string(continued_gs), to_string(stoped_satur), to_string(continued_satur),
to_string(stoped_humi), to_string(continued_humi), to_string(injection_pump_speed));
} }
shared_ptr<db::Formula> DBService::delFormula(int id) { shared_ptr<db::Formula> DBService::delFormula(int id) {
lock_guard<recursive_mutex> lock(lock_); lock_guard<recursive_mutex> lock(lock_);
@ -605,7 +607,7 @@ static string getTime() {
time_t t = ::time(nullptr); time_t t = ::time(nullptr);
struct tm* tmp = localtime_r(&t, &tm); struct tm* tmp = localtime_r(&t, &tm);
return fmt::format("{:0>4}-{:0>2}{:0>2}-{:0>2}:{:0>2}:{:0>2}", tm.tm_year + 1900, //
return fmt::format("{:0>4}-{:0>2}-{:0>2} {:0>2}:{:0>2}:{:0>2}", tm.tm_year + 1900, //
tm.tm_mon + 1, // tm.tm_mon + 1, //
tm.tm_mday, // tm.tm_mday, //
tm.tm_hour, // tm.tm_hour, //

6
src/db/db_service.hpp

@ -79,9 +79,9 @@ struct Setting {
struct Formula { struct Formula {
public: public:
int id; int id;
string loglevel;
string formula_id; string formula_id;
string stoped_gs; string stoped_gs;
string loglevel;
string continued_gs; string continued_gs;
string stoped_satur; string stoped_satur;
string continued_satur; string continued_satur;
@ -149,9 +149,9 @@ class DBService : public enable_shared_from_this<DBService> {
list<shared_ptr<db::Formula>> getAllFormula(); list<shared_ptr<db::Formula>> getAllFormula();
json getAllFormulaJson(); json getAllFormulaJson();
void addFormula(string formula_id, string stoped_gs, string continued_gs, string stoped_satur, string continued_satur, string stoped_humi,
void addFormula(string loglevel, string formula_id, string stoped_gs, string continued_gs, string stoped_satur, string continued_satur, string stoped_humi,
string continued_humi, string injection_pump_speed); string continued_humi, string injection_pump_speed);
void addFormula(string formula_id, int stoped_gs, int continued_gs, int stoped_satur, int continued_satur, int stoped_humi, int continued_humi,
void addFormula(string formula_id, int loglevel, int stoped_gs, int continued_gs, int stoped_satur, int continued_satur, int stoped_humi, int continued_humi,
int injection_pump_speed); int injection_pump_speed);
shared_ptr<db::Formula> delFormula(int id); shared_ptr<db::Formula> delFormula(int id);
shared_ptr<db::Formula> updateFormula(int id, string column, string val); shared_ptr<db::Formula> updateFormula(int id, string column, string val);

1
src/main_control_service.cpp

@ -558,6 +558,7 @@ void MainControlService::processFrontEndMessage_processFormulaCmd(weak_ptr<WebSo
if (cmdstr == "addFormula") { if (cmdstr == "addFormula") {
string formula_id = cmd["formula_id"]; string formula_id = cmd["formula_id"];
m_dbService->addFormula(cmd["formula_id"], // m_dbService->addFormula(cmd["formula_id"], //
jsonGet<int>(cmd["loglevel"]), //
jsonGet<int>(cmd["stoped_gs"]), // jsonGet<int>(cmd["stoped_gs"]), //
jsonGet<int>(cmd["continued_gs"]), // jsonGet<int>(cmd["continued_gs"]), //
jsonGet<int>(cmd["stoped_satur"]), // jsonGet<int>(cmd["stoped_satur"]), //

2
src/service/disinfection_ctl_service.cpp

@ -53,7 +53,7 @@ static string getTime() {
time_t t = time(nullptr); time_t t = time(nullptr);
struct tm* tmp = localtime_r(&t, &tm); struct tm* tmp = localtime_r(&t, &tm);
return fmt::format("{:0>4}-{:0>2}{:0>2}-{:0>2}:{:0>2}:{:0>2}", tm.tm_year + 1900, //
return fmt::format("{:0>4}-{:0>2}-{:0>2} {:0>2}:{:0>2}:{:0>2}", tm.tm_year + 1900, //
tm.tm_mon + 1, // tm.tm_mon + 1, //
tm.tm_mday, // tm.tm_mday, //
tm.tm_hour, // tm.tm_hour, //

Loading…
Cancel
Save