增加测试代码

This commit is contained in:
anlicheng 2024-09-11 15:51:43 +08:00
parent dcd23dd6da
commit ce7ad8a22c
3 changed files with 17 additions and 3 deletions

View File

@ -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,

View File

@ -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} ->

View File

@ -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"},