From c7ec5e7a2762eb9cd2c9d2a23fc1de4677161a30 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期二, 11 二月 2025 10:14:08 +0800
Subject: [PATCH] 完善参数
---
models/accessRegularity.go | 29 ++++++++++++++++++++++-------
1 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/models/accessRegularity.go b/models/accessRegularity.go
index 5d1b59b..301ac5d 100644
--- a/models/accessRegularity.go
+++ b/models/accessRegularity.go
@@ -174,10 +174,16 @@
return ""
}
-func countValidDays(records []*service.ESRecordInfo, startHour, endHort int, direction string) int {
+func countValidDays(records []*service.ESRecordInfo, startHour, endHour int, direction string) int {
layout := "2006-01-02 15:04:05" // 鏃堕棿鏍煎紡
lastDirectionMap := make(map[string]string) // 璁板綍鏈�鍚庝竴鏉� Direction
lastTimeMap := make(map[string]time.Time) // 璁板綍鏈�鍚庝竴鏉℃椂闂�
+
+ // 鍒ゆ柇鏄惁璺ㄥぉ
+ var isCrossDay bool
+ if endHour < startHour {
+ isCrossDay = true
+ }
for _, record := range records {
// 瑙f瀽鏃堕棿
@@ -191,13 +197,22 @@
hour := t.Hour()
var key string
- // 鍒ゆ柇鏃堕棿鑼冨洿锛屽苟褰掑睘鍒版煇涓�澶�
- if hour >= startHour { // 21:00-23:59 褰掑睘褰撳ぉ
- key = t.Format("2006-01-02")
- } else if hour < endHort { // 00:00-02:59 褰掑睘鍓嶄竴澶�
- key = t.AddDate(0, 0, -1).Format("2006-01-02")
+ if !isCrossDay {
+ // 鍒ゆ柇鏃堕棿鑼冨洿锛屽苟褰掑睘鍒版煇涓�澶�
+ if hour >= startHour && hour < endHour {
+ key = t.Format("2006-01-02")
+ } else {
+ continue // 涓嶅湪缁熻鑼冨洿鍐�
+ }
} else {
- continue // 涓嶅湪缁熻鑼冨洿鍐�
+ // 鍒ゆ柇鏃堕棿鑼冨洿锛屽苟褰掑睘鍒版煇涓�澶�
+ if hour >= startHour { // 21:00-23:59 褰掑睘褰撳ぉ
+ key = t.Format("2006-01-02")
+ } else if hour < endHour { // 00:00-02:59 褰掑睘鍓嶄竴澶�
+ key = t.AddDate(0, 0, -1).Format("2006-01-02")
+ } else {
+ continue // 涓嶅湪缁熻鑼冨洿鍐�
+ }
}
// 璁板綍璇ユ椂闂存鍐呯殑鏈�鍚庝竴鏉℃暟鎹�
--
Gitblit v1.8.0