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);
return strtime_now;
}
void get_current_date( int day)
tm *get_current_date( )
{
time_t t = time(NULL);
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;
imonth = tm_info->tm_mon + 1;
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)
{

View File

@ -650,7 +650,7 @@ extern int CheckFileVersion(int argc, char** argv);
*/
extern std::string GetCurrentTime();
extern void get_current_date( int day) ;
extern tm *get_current_date() ;
/**
* @brief
* @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());
// 初始化日志记录,日志缓存区,记录数,未使用,后期,命令启动
log_init(SOFTWARE_RUN_LOG, 1380, 160 * 1024 * 2);
log_init(SOFTWARE_RUN_LOG, 1380, 200 * 1024 * 2);
LOG_INFO("####CIDNSOFT start####\n");
// 查看版本信息

View File

@ -212,19 +212,18 @@ void CheckThread()
std::string data = jd.JsonCmd_07();
data_publish(data.c_str(), GlobalConfig::Topic_G.mPubStatus.c_str());
HardStatus = 0;
if (GlobalConfig::day == 0)
{
get_current_date(GlobalConfig::day);
}else{
int day = 0;
get_current_date(day);
if(GlobalConfig::day != day){
LOG_INFO("global = %d ,day = %d\n",GlobalConfig::day,day);
sql_ctl->CalculateData();
}
int hour = 0;
struct tm *tm_info = get_current_date();
hour = tm_info->tm_hour;
print_info("hour = %d\n",hour);
int statistics = readIntValue( "config", "statistics",(char*)GlobalConfig::Config_G.c_str());
if(statistics == 0 && hour > 13 ){
writeIntValue("config", "statistics",1,(char*)GlobalConfig::Config_G.c_str());
sql_ctl->CalculateData();
}else if(statistics == 1 && hour < 13){
writeIntValue("config", "statistics",0,(char*)GlobalConfig::Config_G.c_str());
}
}
if(mqttresend == 1800){
mqttresend = 0;