|
|
@@ -60,14 +60,17 @@ func canTakePhoto() bool {
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
- days := int(today.Sub(lastDate).Hours() / 24)
|
|
|
- if days < mcu.CfgParams.TakePhotoIntervalDays {
|
|
|
+ lastUTC := time.Date(lastDate.Year(), lastDate.Month(), lastDate.Day(), 0, 0, 0, 0, time.UTC)
|
|
|
+ todayUTC := time.Date(today.Year(), today.Month(), today.Day(), 0, 0, 0, 0, time.UTC)
|
|
|
+ days := int(todayUTC.Sub(lastUTC) / (24 * time.Hour))
|
|
|
+
|
|
|
+ allowed := days == 0 || days >= mcu.CfgParams.TakePhotoIntervalDays
|
|
|
+ if !allowed {
|
|
|
baseapp.Logger.Infof("[%s] 未达到拍照间隔天数要求, 上次拍照日期: %s, 已间隔: %d天, 间隔要求: %d天, 忽略本次拍照请求",
|
|
|
MODULE_NAME, lastDate.Format("2006-01-02"), days, mcu.CfgParams.TakePhotoIntervalDays)
|
|
|
- return false
|
|
|
}
|
|
|
|
|
|
- return true
|
|
|
+ return allowed
|
|
|
}
|
|
|
|
|
|
func (r *MQTTReporter) takePhotoAndUpToFtp() (string, error) {
|