Bläddra i källkod

fit: 当前值(不包含adjust) == 0时, 清除对过滤次数的校正

gaoyagang 1 år sedan
förälder
incheckning
d6bdf903e5
1 ändrade filer med 8 tillägg och 1 borttagningar
  1. 8 1
      app/cmd/events/internal/logic/handler/handler.go

+ 8 - 1
app/cmd/events/internal/logic/handler/handler.go

@@ -61,7 +61,7 @@ func (h *EventHandler) adjustFilterCycle(message []byte) error {
 
 	// 获得一个时间窗口中的许可, 如果获得失败, 则说明事件重复, 不处理  600的是因为 超滤膜反洗时间不会超过600秒
 	if h.canExec(entInfo.ProjectId, entInfo.DeviceCode, "adjustFilterCycle", "", 600*time.Second) == false {
-		fmt.Printf("adjustFilterCycle 不可重复执行\n")
+		//fmt.Printf("adjustFilterCycle 不可重复执行\n")
 		return nil
 	}
 
@@ -104,6 +104,13 @@ func (h *EventHandler) adjustFilterCycle(message []byte) error {
 	// 通过上面的判断, 得知自控系统的filterCycle值阻塞了, 需要调整
 	adjustValue, err := filterCycleItem.IncreAdjust(86400 * time.Second)
 	fmt.Printf("projectId: %d, item: %s, adjustValue: %d\n", entInfo.ProjectId, filterCycleItem.Item, adjustValue)
+
+	// 判断是否清除adjust的值
+	// 如果当前值(不包含adjust) == 0时, 清除
+	if filterCycle-adjustValue <= 0 {
+		filterCycleItem.ClearAdjust()
+		fmt.Printf("projectId: %d, item: %s, adjustValue clear\n", entInfo.ProjectId, filterCycleItem.Item)
+	}
 	//key := fmt.Sprintf("events:adjust:%d:%s:%s:%s", entInfo.ProjectId, entInfo.DeviceCode, "filter_cycle", "")
 	//h.svcCtx.Cache.Incr(context.Background(), key)
 	//h.svcCtx.Cache.Expire(context.Background(), key, 86400*time.Second)