Commit 56cea78e by 李定达

1.调整stld的特殊文件的命名规则识别,香港以周日记作一周的第一天且以第一个周日作为该年的第一周;第一个周日之前的时间不计入本年第几周运算

parent 10ccd2cd
...@@ -169,19 +169,19 @@ bool readStoreID(QString &storeID) ...@@ -169,19 +169,19 @@ bool readStoreID(QString &storeID)
} }
} }
bool copyfiles(QFileInfo fileinfo, QString path, QString day) bool copyfiles(QFileInfo fileinfo, QString path, QString tmpday)
{ {
QFile file(path + day + "/" + fileinfo.fileName()); QFile file(path + tmpday + "/" + fileinfo.fileName());
file.remove(); file.remove();
QDir dir; QDir dir;
dir.mkdir(path + day); dir.mkdir(path + tmpday);
QLOG_DEBUG() << "copy file from : " << fileinfo.absoluteFilePath() << " to " << path + day + "/" + fileinfo.fileName(); QLOG_DEBUG() << "copy file from : " << fileinfo.absoluteFilePath() << " to " << path + tmpday + "/" + fileinfo.fileName();
return QFile::copy(fileinfo.absoluteFilePath(), path + day + "/" + fileinfo.fileName()); return QFile::copy(fileinfo.absoluteFilePath(), path + tmpday + "/" + fileinfo.fileName());
} }
void clearDirForPath(QString path) void clearDirForPath(QString path)
...@@ -228,7 +228,7 @@ void echosuccess(QString filename, QString dats) ...@@ -228,7 +228,7 @@ void echosuccess(QString filename, QString dats)
} }
bool doCopyFileToLocat() bool doCopyFileToLocat(QString tmpday, QString tmpday2, QString weeks)
{ {
QDir dir(DEFALUT_FILEPATH); QDir dir(DEFALUT_FILEPATH);
dir.setFilter(QDir::Files); dir.setFilter(QDir::Files);
...@@ -240,23 +240,23 @@ bool doCopyFileToLocat() ...@@ -240,23 +240,23 @@ bool doCopyFileToLocat()
QFileInfoList list = dir.entryInfoList(); QFileInfoList list = dir.entryInfoList();
if(IsSuccess(stldtmppath + day + "/" + SUCCESS_FILENAME, abday)) if(IsSuccess(stldtmppath + tmpday + "/" + SUCCESS_FILENAME, abday))
{ {
QLOG_WARN() << "find success file : " << stldtmppath + day + "/" + SUCCESS_FILENAME; QLOG_WARN() << "find success file : " << stldtmppath + tmpday + "/" + SUCCESS_FILENAME;
return true; return true;
} }
clearDirForPath(stldtmppath + day + "/"); clearDirForPath(stldtmppath + tmpday + "/");
int copyfilesnum = 0; int copyfilesnum = 0;
foreach (QFileInfo tmp , list) foreach (QFileInfo tmp , list)
{ {
if(tmp.fileName().endsWith(".xml.gz")) if(tmp.fileName().endsWith(".xml.gz") && (tmp.fileName().contains(tmpday2) || tmp.fileName().contains(weeks)))
{ {
QLOG_DEBUG() << "|" << tmp.absoluteFilePath(); QLOG_DEBUG() << "|" << tmp.absoluteFilePath();
if(copyfiles(tmp, stldtmppath, day)) if(copyfiles(tmp, stldtmppath, tmpday))
{ {
++ copyfilesnum; ++ copyfilesnum;
if(tmp.fileName().startsWith("DSOS", Qt::CaseInsensitive)) if(tmp.fileName().startsWith("DSOS", Qt::CaseInsensitive))
...@@ -277,8 +277,66 @@ bool doCopyFileToLocat() ...@@ -277,8 +277,66 @@ bool doCopyFileToLocat()
return ((copyfilesnum >= 3 && flagDSOS && flagSTLD && flagNP6) ? true : false); return ((copyfilesnum >= 3 && flagDSOS && flagSTLD && flagNP6) ? true : false);
} }
int GetWeek(int days, int week)
{
int oneweek = days - week - 1;
if(oneweek < 0)
return 0;
return (oneweek / 7 + 1);
}
//int a[] = {31, 28, 31, 30, 31, 30, 31,31, 30, 31, 30, 31};
//void judge_day(int Year, int Month, int Day, int *result_day)
//{
// int Total = 0;
// int i = 0;
// if( (((Year%400) == 0) || ((Year%4) == 0)) && ((Year %100) != 0))
// {
// a[1] = 29;
// }
// for(i=0;i<Month-1;i++)
// {
// Total += a[i];
// }
// Total += Day;
// *result_day = Total;
//}
void GetWeeks(QDateTime &tmptime2, QString &weeks)
{
// int days = 0;
// int year = tmptime2.toString("YYYY").toInt();
// int mouth = tmptime2.toString("MM").toInt();
// int day = tmptime2.toString("DD").toInt();
// QLOG_DEBUG() << "GetWeeks:year" << year << "GetWeeks:mouth" << mouth << "GetWeeks:day" << day;
// judge_day(year, mouth, day, days);
// tmptime2.date().dayOfWeek();
QLOG_DEBUG() << "day : " << tmptime2.toString("yyyyMMdd");
QLOG_DEBUG() << "days : " << tmptime2.date().dayOfYear() << "week : " << tmptime2.date().dayOfWeek() % 7;
int tmpweeks = GetWeek(tmptime2.date().dayOfYear(), tmptime2.date().dayOfWeek() % 7);
QLOG_INFO() << "get tmp weeks : " << tmpweeks;
weeks = QString::number(tmpweeks) + QString::number(tmptime2.date().dayOfWeek()%7) + tmptime2.toString("yyyy");
QLOG_INFO() << "get weeks : " << weeks;
}
bool CopyFileToLocat() bool CopyFileToLocat()
{ {
bool flag = false;
QFile flagfile(DEFALUT_FLAG_FILENAME); QFile flagfile(DEFALUT_FLAG_FILENAME);
if(!flagfile.exists()) if(!flagfile.exists())
...@@ -287,7 +345,28 @@ bool CopyFileToLocat() ...@@ -287,7 +345,28 @@ bool CopyFileToLocat()
return false; return false;
} }
return doCopyFileToLocat(); QDateTime time = QDateTime::currentDateTime();
for (auto i = 0; i > -30; --i)
{
QDateTime tmptime1 = time.addDays(i);
QDateTime tmptime2 = time.addDays(i - 1);
QString tmppath1 = tmptime1.toString("dd");
QString tmppath2 = tmptime2.toString("YYYYMMdd");
QString weeks;
GetWeeks(tmptime2, weeks);
if(doCopyFileToLocat(tmppath1, tmppath2, weeks))
{
if(i == 0)
flag = true;
}
}
return flag;
} }
bool uploadfile(QString zipfile, QString zipfilename) bool uploadfile(QString zipfile, QString zipfilename)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment