3.2.5 beta4 重新优化每日统计逻辑
This commit is contained in:
parent
3f541a08df
commit
4d3ffb4b99
@ -514,14 +514,17 @@ std::string GetCurrentTime()
|
|||||||
std::string strtime_now = std::string((char*)time_now);
|
std::string strtime_now = std::string((char*)time_now);
|
||||||
return strtime_now;
|
return strtime_now;
|
||||||
}
|
}
|
||||||
void get_current_date( int day)
|
tm *get_current_date( )
|
||||||
{
|
{
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
struct tm *tm_info = localtime(&t);
|
struct tm *tm_info = localtime(&t);
|
||||||
int iyear;int imonth;
|
int iyear = 0;int imonth = 0;int day = 0;int hour = 0;
|
||||||
iyear = tm_info->tm_year + 1900;
|
iyear = tm_info->tm_year + 1900;
|
||||||
imonth = tm_info->tm_mon + 1;
|
imonth = tm_info->tm_mon + 1;
|
||||||
day = tm_info->tm_mday;
|
day = tm_info->tm_mday;
|
||||||
|
hour = tm_info->tm_hour;
|
||||||
|
print_info("year = %d,month = %d,day = %d\n",iyear,imonth,day);
|
||||||
|
return tm_info;
|
||||||
}
|
}
|
||||||
int system_custom(const char *cmd, char *buf)
|
int system_custom(const char *cmd, char *buf)
|
||||||
{
|
{
|
||||||
|
@ -650,7 +650,7 @@ extern int CheckFileVersion(int argc, char** argv);
|
|||||||
*/
|
*/
|
||||||
extern std::string GetCurrentTime();
|
extern std::string GetCurrentTime();
|
||||||
|
|
||||||
extern void get_current_date( int day) ;
|
extern tm *get_current_date() ;
|
||||||
/**
|
/**
|
||||||
* @brief 和系统交互函数
|
* @brief 和系统交互函数
|
||||||
* @param cmd 要发出的系统命令 例:ls
|
* @param cmd 要发出的系统命令 例:ls
|
||||||
|
2
main.cpp
2
main.cpp
@ -29,7 +29,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
printf(" Firmware compile time:%s %s,version %s\n", __DATE__, __TIME__,GlobalConfig::Version.c_str());
|
printf(" Firmware compile time:%s %s,version %s\n", __DATE__, __TIME__,GlobalConfig::Version.c_str());
|
||||||
// 初始化日志记录,日志缓存区,记录数,未使用,后期,命令启动
|
// 初始化日志记录,日志缓存区,记录数,未使用,后期,命令启动
|
||||||
log_init(SOFTWARE_RUN_LOG, 1380, 160 * 1024 * 2);
|
log_init(SOFTWARE_RUN_LOG, 1380, 200 * 1024 * 2);
|
||||||
LOG_INFO("####CIDNSOFT start####\n");
|
LOG_INFO("####CIDNSOFT start####\n");
|
||||||
|
|
||||||
// 查看版本信息
|
// 查看版本信息
|
||||||
|
@ -212,18 +212,17 @@ void CheckThread()
|
|||||||
std::string data = jd.JsonCmd_07();
|
std::string data = jd.JsonCmd_07();
|
||||||
data_publish(data.c_str(), GlobalConfig::Topic_G.mPubStatus.c_str());
|
data_publish(data.c_str(), GlobalConfig::Topic_G.mPubStatus.c_str());
|
||||||
HardStatus = 0;
|
HardStatus = 0;
|
||||||
if (GlobalConfig::day == 0)
|
int hour = 0;
|
||||||
{
|
struct tm *tm_info = get_current_date();
|
||||||
get_current_date(GlobalConfig::day);
|
hour = tm_info->tm_hour;
|
||||||
}else{
|
print_info("hour = %d\n",hour);
|
||||||
int day = 0;
|
int statistics = readIntValue( "config", "statistics",(char*)GlobalConfig::Config_G.c_str());
|
||||||
get_current_date(day);
|
if(statistics == 0 && hour > 13 ){
|
||||||
if(GlobalConfig::day != day){
|
writeIntValue("config", "statistics",1,(char*)GlobalConfig::Config_G.c_str());
|
||||||
LOG_INFO("global = %d ,day = %d\n",GlobalConfig::day,day);
|
|
||||||
sql_ctl->CalculateData();
|
sql_ctl->CalculateData();
|
||||||
|
}else if(statistics == 1 && hour < 13){
|
||||||
|
writeIntValue("config", "statistics",0,(char*)GlobalConfig::Config_G.c_str());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if(mqttresend == 1800){
|
if(mqttresend == 1800){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user