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