3.2.5 beta4 重新优化每日统计逻辑

This commit is contained in:
zhangsheng 2024-09-26 13:41:57 +08:00
parent 3f541a08df
commit 4d3ffb4b99
5 changed files with 18 additions and 16 deletions

BIN
Cidn-SH

Binary file not shown.

View File

@ -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)
{ {

View File

@ -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

View File

@ -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");
// 查看版本信息 // 查看版本信息

View File

@ -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){