fake data
This commit is contained in:
parent
49a73ad88f
commit
6c9f8549d0
@ -93,16 +93,11 @@ handle_call(_Request, _From, State = #state{}) ->
|
|||||||
{noreply, NewState :: #state{}, timeout() | hibernate} |
|
{noreply, NewState :: #state{}, timeout() | hibernate} |
|
||||||
{stop, Reason :: term(), NewState :: #state{}}).
|
{stop, Reason :: term(), NewState :: #state{}}).
|
||||||
handle_cast({forward, LocationCode, DynamicLocationCode, EventType, Params}, State = #state{id = Id, timer_map = TimerMap, pri_key = PriKey, url = Url}) ->
|
handle_cast({forward, LocationCode, DynamicLocationCode, EventType, Params}, State = #state{id = Id, timer_map = TimerMap, pri_key = PriKey, url = Url}) ->
|
||||||
try
|
ReqBody = format_event(LocationCode, DynamicLocationCode, EventType, Params, PriKey),
|
||||||
ReqBody = format_event(LocationCode, DynamicLocationCode, EventType, Params, PriKey),
|
catch do_post(Url, Id, ReqBody),
|
||||||
catch do_post(Url, Id, ReqBody),
|
TimerRef = erlang:start_timer(?RETRY_INTERVAL, self(), {repost_ticker, Id, ReqBody}),
|
||||||
TimerRef = erlang:start_timer(?RETRY_INTERVAL, self(), {repost_ticker, Id, ReqBody}),
|
|
||||||
|
|
||||||
{noreply, State#state{id = Id + 1, timer_map = maps:put(Id, TimerRef, TimerMap)}}
|
{noreply, State#state{id = Id + 1, timer_map = maps:put(Id, TimerRef, TimerMap)}}.
|
||||||
catch _:Err:Stack ->
|
|
||||||
lager:notice("[iot_jinzhi_endpoint] format_event get error: ~p, stack: ~p", [Err, Stack]),
|
|
||||||
{noreply, State}
|
|
||||||
end.
|
|
||||||
|
|
||||||
%% @private
|
%% @private
|
||||||
%% @doc Handling all non call/cast messages
|
%% @doc Handling all non call/cast messages
|
||||||
@ -190,20 +185,9 @@ format_event(LocationCode, DynamicLocationCode, EventType, #{<<"event_code">> :=
|
|||||||
end, Attachments0),
|
end, Attachments0),
|
||||||
|
|
||||||
% <<"occurrenceTime">> => <<"2023-06-10 12:00:00">>,
|
% <<"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),
|
|
||||||
Code = lists:nth(RandomIndex, FakeLocationCodes),
|
|
||||||
list_to_binary(Code);
|
|
||||||
false ->
|
|
||||||
LocationCode
|
|
||||||
end,
|
|
||||||
DeviceInfo = #{
|
DeviceInfo = #{
|
||||||
% <<"location">> => LocationCode,
|
% <<"location">> => LocationCode,
|
||||||
<<"location">> => LocationCode1,
|
<<"location">> => fake_location_code(EventCode, LocationCode),
|
||||||
<<"category">> => EventCode,
|
<<"category">> => EventCode,
|
||||||
<<"description">> => Description,
|
<<"description">> => Description,
|
||||||
<<"occurrenceTime">> => Datetime,
|
<<"occurrenceTime">> => Datetime,
|
||||||
@ -277,4 +261,10 @@ serialize0([{K, V}|T], Target) ->
|
|||||||
<<$[, V0/binary, $]>>
|
<<$[, V0/binary, $]>>
|
||||||
end,
|
end,
|
||||||
Item = <<$", K/binary, $", $:, V1/binary>>,
|
Item = <<$", K/binary, $", $:, V1/binary>>,
|
||||||
serialize0(T, [Item|Target]).
|
serialize0(T, [Item|Target]).
|
||||||
|
|
||||||
|
|
||||||
|
fake_location_code(EventCode, LocationCode) when is_binary(EventCode), is_binary(LocationCode) ->
|
||||||
|
% TODO delete
|
||||||
|
FakeLocationCodes = application:get_env(iot, fake_location_codes, []),
|
||||||
|
proplists:get_value(EventCode, FakeLocationCodes, LocationCode).
|
||||||
@ -15,7 +15,11 @@
|
|||||||
{device_cache_size, 200},
|
{device_cache_size, 200},
|
||||||
|
|
||||||
{fake_location_codes, [
|
{fake_location_codes, [
|
||||||
"0508103010001050300001"
|
{<<"23103">>, <<"0508103010001050300001">>},
|
||||||
|
{<<"20407">>, <<"0512104030001050400003">>},
|
||||||
|
{<<"10404">>, <<"0507106030001050600003">>},
|
||||||
|
{<<"22503">>, <<"0500000000001022700537">>},
|
||||||
|
{<<"23104">>, <<"0500000000001022700538">>}
|
||||||
]},
|
]},
|
||||||
|
|
||||||
{watchdog, [
|
{watchdog, [
|
||||||
|
|||||||
15
docs/jinzhi.md
Normal file
15
docs/jinzhi.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# 事件分类
|
||||||
|
|
||||||
|
```text
|
||||||
|
23103 鼠类监测 event_code:
|
||||||
|
20407 异物占道 event_code:
|
||||||
|
10404 垃圾溢满 event_code:
|
||||||
|
22503 后厨非标着装 event_code:
|
||||||
|
23104 动火离人 event_code:
|
||||||
|
```
|
||||||
|
|
||||||
|
1、鼠类检测 0508103010001050300001 朴苑餐厅
|
||||||
|
2、异物占道 0512104030001050400003 行政楼B楼
|
||||||
|
3、垃圾溢满 0507106030001050600003 朴苑3舍
|
||||||
|
4、后厨非标着装 0500000000001022700537 监控摄像头532(诚苑餐厅 北侧)
|
||||||
|
5、动火离人 0500000000001022700538 监控摄像头533(诚苑餐厅 北侧)
|
||||||
@ -1,9 +0,0 @@
|
|||||||
# 事件分类
|
|
||||||
|
|
||||||
```text
|
|
||||||
23103 鼠类监测
|
|
||||||
20407 异物占道
|
|
||||||
10404 垃圾溢满
|
|
||||||
22503 后厨非标着装
|
|
||||||
23104 动火离人
|
|
||||||
```
|
|
||||||
Loading…
x
Reference in New Issue
Block a user