This commit is contained in:
dawnwinterLiu 2024-03-21 14:23:33 +08:00
parent e5b511f2ae
commit 32a742f10d
3 changed files with 52 additions and 9 deletions

1
.gitignore vendored
View File

@ -98,6 +98,7 @@ apps/dgiot_demo/
apps/dgiot_jingmao/ apps/dgiot_jingmao/
apps/dgiot_atom/ apps/dgiot_atom/
apps/dgiot_12184/ apps/dgiot_12184/
apps/dgiot_rtsp2ws/
node_modules/ node_modules/
package-lock.json package-lock.json
erlang_ls.config erlang_ls.config

View File

@ -997,15 +997,20 @@ get_port(Socket) ->
%%[global, {capture, all_but_first, binary}]) %%[global, {capture, all_but_first, binary}])
ping_all() -> ping_all() ->
lists:map(fun({A, B, C, _D}) -> lists:map(
Cmd = "for /l %i in (1,1,255) do ping -n 1 -w 50 " fun({A, B, C, _D}) ->
++ to_list(A) ++ "." lists:map(
++ to_list(B) ++ "." fun(N) ->
++ to_list(C) ++ "." Cmd =
++ "%i", case os:type() of
os:cmd(Cmd) {unix, linux} ->
end, "ping -c 1 -w 50 " ++ to_list(A) ++ "." ++ to_list(B) ++ "." ++ to_list(C) ++ "." ++ dgiot_utils:to_list(N);
get_ifaddrs()). _ ->
"ping -n 1 -w 50 " ++ to_list(A) ++ "." ++ to_list(B) ++ "." ++ to_list(C) ++ "." ++ dgiot_utils:to_list(N)
end,
os:cmd(Cmd)
end, lists:seq(1, 255))
end, get_ifaddrs()).
get_ifaddrs() -> get_ifaddrs() ->
case inet:getifaddrs() of case inet:getifaddrs() of

View File

@ -40,6 +40,7 @@
triggeralarm/2, triggeralarm/2,
send_msg/1, send_msg/1,
sendSubscribe/1, sendSubscribe/1,
send_dashboard/1,
get_defultmessage/1, get_defultmessage/1,
replace_miniparam/10 replace_miniparam/10
]). ]).
@ -203,6 +204,7 @@ add_notification(<<"start_", Ruleid/binary>>, DeviceId, Payload) ->
NotificationId = dgiot_parse_id:get_notificationid(Ruleid), NotificationId = dgiot_parse_id:get_notificationid(Ruleid),
dgiot_data:insert(?NOTIFICATION, {DeviceId, Ruleid}, {start, dgiot_datetime:now_secs(), NotificationId}), dgiot_data:insert(?NOTIFICATION, {DeviceId, Ruleid}, {start, dgiot_datetime:now_secs(), NotificationId}),
Content = save_notification(Ruleid, DeviceId, Payload, NotificationId), Content = save_notification(Ruleid, DeviceId, Payload, NotificationId),
dgiot_umeng:send_dashboard(Content),
dgiot_umeng:send_other(Content), dgiot_umeng:send_other(Content),
dgiot_umeng:send_maintenance(Content#{<<"notificationid">> => NotificationId}), dgiot_umeng:send_maintenance(Content#{<<"notificationid">> => NotificationId}),
dgiot_umeng:send_msg(Content), dgiot_umeng:send_msg(Content),
@ -625,6 +627,41 @@ sendSubscribe(_O) ->
%% io:format("~s ~p _O = ~p.~n", [?FILE, ?LINE, _O]), %% io:format("~s ~p _O = ~p.~n", [?FILE, ?LINE, _O]),
pass. pass.
%%
send_dashboard(#{<<"_deviceid">> := DeviceId, <<"dgiot_alarmvalue">> := Alarmvalue} = Args) ->
case dgiot_parse:get_object(<<"Device">>, DeviceId) of
{ok, #{<<"name">> := DeviceName, <<"product">> := #{<<"objectId">> := ProductId}}} ->
ProductName =
case dgiot_parse:get_object(<<"Product">>, ProductId) of
{ok, #{<<"name">> := Name1}} ->
Name1;
_ ->
<<>>
end,
<<Number:10/binary, _/binary>> = dgiot_utils:random(),
Timestamp = dgiot_datetime:format(dgiot_datetime:to_localtime(dgiot_datetime:now_secs()), <<"YY-MM-DD HH:NN:SS">>),
%% BinAlarmvalue = dgiot_utils:to_binary(Alarmvalue),
Data = #{
<<"id">> => Number,
<<"deviceid">> => DeviceId,
<<"devicename">> => DeviceName,
<<"productid">> => ProductId,
<<"productname">> => ProductName,
<<"value">> => Alarmvalue,
<<"time">> => Timestamp,
<<"level">> => 1,
<<"type">> => <<"warn">>,
<<"description">> => maps:get(<<"description">>, Args, <<>>)
},
Pubtopic = <<"$dg/user/dashboard/notification/report">>,
dgiot_mqtt:publish(DeviceId, Pubtopic, dgiot_json:encode(Data));
_ ->
pass
end;
send_dashboard(_O) ->
pass.
%% %%
send_other(#{<<"send_alarm_status">> := <<"start">>, <<"_deviceid">> := DeviceId, <<"_viewid">> := ViewId, <<"dgiot_alarmvalue">> := Alarmvalue}) -> send_other(#{<<"send_alarm_status">> := <<"start">>, <<"_deviceid">> := DeviceId, <<"_viewid">> := ViewId, <<"dgiot_alarmvalue">> := Alarmvalue}) ->
case dgiot_parse:get_object(<<"View">>, ViewId) of case dgiot_parse:get_object(<<"View">>, ViewId) of