From 60d5ccb13d7936a1dd7c4b9fe78fb26eb7a3c764 Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Fri, 12 Jul 2024 17:02:38 +0800 Subject: [PATCH] fix period --- apps/iot/src/iot_api.erl | 2 +- apps/iot/src/iot_event_period_settings.erl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/iot/src/iot_api.erl b/apps/iot/src/iot_api.erl index f00fd34..4d92f02 100644 --- a/apps/iot/src/iot_api.erl +++ b/apps/iot/src/iot_api.erl @@ -48,7 +48,7 @@ ai_event(Id) when is_integer(Id) -> get_event_period_settings() -> Token = iot_util:md5(<>), {ok, Url0} = application:get_env(iot, api_url), - Url = Url0 ++ "/api/v1/eventPeriodSettings", + Url = Url0 ++ "/api/v1/alertPeriod", Headers = [ {<<"content-type">>, <<"application/json">>} diff --git a/apps/iot/src/iot_event_period_settings.erl b/apps/iot/src/iot_event_period_settings.erl index 159b15b..37f4881 100644 --- a/apps/iot/src/iot_event_period_settings.erl +++ b/apps/iot/src/iot_event_period_settings.erl @@ -135,15 +135,15 @@ code_change(_OldVsn, State = #state{}, _Extra) -> -spec settings(tuple()) -> no_return(). settings({ok, Resp}) when is_binary(Resp) -> case catch jiffy:decode(Resp, [return_maps]) of - Settings when is_map(Settings) -> - lists:foreach(fun({GroupKey, Throttle}) -> + #{<<"code">> := 200, <<"data">> := Settings} when is_list(Settings) -> + lists:foreach(fun(#{<<"event_code">> := GroupKey, <<"time_period">> := Throttle}) -> case is_integer(Throttle) andalso Throttle > 0 of true -> ets:insert(?TAB_NAME, #period{group_key = GroupKey, throttle = Throttle}); false -> ok end - end, maps:to_list(Settings)); + end, Settings); Error -> lager:debug("[iot_event_period_settings] get event_period_settings from api get error: ~p", [Error]) end;