diff --git a/apps/iot/src/endpoint/iot_jinzhi_endpoint.erl b/apps/iot/src/endpoint/iot_jinzhi_endpoint.erl index 276c7a4..df1f5e4 100644 --- a/apps/iot/src/endpoint/iot_jinzhi_endpoint.erl +++ b/apps/iot/src/endpoint/iot_jinzhi_endpoint.erl @@ -185,9 +185,19 @@ format_events(LocationCode, DynamicLocationCode, EventType, #{<<"event_code">> : end, Attachments0), % <<"occurrenceTime">> => <<"2023-06-10 12:00:00">>, - + % TODO delete + FakeLocationCodes = application:get_env(iot, fake_location_codes, []), + LocationCode1 = case length(FakeLocationCodes) > 0 of + true -> + Len = length(FakeLocationCodes), + RandomIndex = rand:uniform(Len), + lists:nth(RandomIndex, FakeLocationCodes); + false -> + LocationCode + end, DeviceInfo = #{ - <<"location">> => LocationCode, + % <<"location">> => LocationCode, + <<"location">> => LocationCode1, <<"category">> => EventCode, <<"description">> => Description, <<"occurrenceTime">> => Datetime, diff --git a/apps/iot/src/iot_watchdog.erl b/apps/iot/src/iot_watchdog.erl index 3f6b500..66112c9 100644 --- a/apps/iot/src/iot_watchdog.erl +++ b/apps/iot/src/iot_watchdog.erl @@ -169,7 +169,7 @@ handle_info({timeout, _, warn_ticker}, State = #state{warn_buf = WarnBuf, url = case length(WarnBuf) > 0 of true -> Warn0 = hd(WarnBuf), - Warn = iolist_to_binary([Warn0, <<"(累计: ">>, length(WarnBuf), <<")">>]), + Warn = iolist_to_binary([Warn0, <<"(累计: ">>, integer_to_binary(length(WarnBuf)), <<")">>]), Body = format_warn(Warn, Users, PriKey), case catch do_post(Url, Body) of {ok, Resp} -> diff --git a/config/sys-prod.config b/config/sys-prod.config index 7ec9e42..d625e23 100644 --- a/config/sys-prod.config +++ b/config/sys-prod.config @@ -14,6 +14,10 @@ %% 数据的最大缓存量 {device_cache_size, 200}, + {fake_location_codes, [ + "0517105041011073100004" + ]}, + {watchdog, [ {pri_key, "jinzhi_watchdog_pri.key"}, {url, "http://172.30.37.242:8080/hqtaskcenterapp/sys/taskCenter/taskReceive/sendNotice.do"},