add key
This commit is contained in:
parent
f4aa27065a
commit
1a49c4628b
@ -15,7 +15,7 @@
|
||||
%% API
|
||||
-export([start_link/0]).
|
||||
-export([get_pid/0, forward/3, get_stat/0]).
|
||||
-export([parse_json_file/0, export/0]).
|
||||
-export([parse_json_file/0, export/0, export_n/1]).
|
||||
|
||||
%% gen_statem callbacks
|
||||
-export([init/1, handle_event/4, terminate/3, code_change/4, callback_mode/0]).
|
||||
@ -52,6 +52,18 @@ export() ->
|
||||
end
|
||||
end || Line <- Lines].
|
||||
|
||||
export_n(N) when N > 0 ->
|
||||
Lines0 = parse_json_file(),
|
||||
Lines = lists:sublist(Lines0, 1, N),
|
||||
[begin
|
||||
case catch jiffy:decode(Line, [return_maps]) of
|
||||
M when is_map(M) ->
|
||||
export0(M);
|
||||
Error ->
|
||||
lager:notice("invalid data: ~p, error: ~p", [Line, Error])
|
||||
end
|
||||
end || Line <- Lines].
|
||||
|
||||
export0(Fields0 = #{<<"device_uuid">> := DeviceUUID, <<"timestamp">> := Timestamp}) ->
|
||||
Fields = lists:foldl(fun(Key, M) -> maps:remove(Key, M) end, Fields0, [<<"device_uuid">>]),
|
||||
%% 查找终端设备对应的点位信息
|
||||
@ -237,6 +249,7 @@ do_post(PostmanPid, #north_data{id = Id, location_code = LocationCode, fields =
|
||||
<<"version">> => <<"1.0">>,
|
||||
<<"location_code">> => LocationCode,
|
||||
<<"ts">> => Timestamp,
|
||||
<<"repair">> => true,
|
||||
<<"properties">> => Fields
|
||||
},
|
||||
try
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user