mirror of
https://gitee.com/dgiiot/dgiot.git
synced 2024-11-30 03:07:40 +08:00
feat: add push other
This commit is contained in:
parent
a0b30e6533
commit
4072982a70
@ -46,7 +46,6 @@
|
||||
%% @description 备注
|
||||
%% 已实现 get post 的适配工作
|
||||
get({'before', '*', Args}) ->
|
||||
%% io:format("~s ~p Data: ~p ~n", [?FILE, ?LINE, Data]),
|
||||
NewData = maps:fold(fun(K, V, Acc) ->
|
||||
case V of
|
||||
undefined -> Acc;
|
||||
@ -226,8 +225,8 @@ format_multilayer(Object) ->
|
||||
[<<"">>] ->
|
||||
Acc;
|
||||
_ ->
|
||||
NewV = format_value(V),
|
||||
NewK = format_value(K),
|
||||
NewV = dgiot_bamis:format_multilayer(V),
|
||||
Acc#{NewK => NewV}
|
||||
end;
|
||||
(K, V, Acc) when is_list(V) ->
|
||||
@ -235,7 +234,7 @@ format_multilayer(Object) ->
|
||||
NewV =
|
||||
lists:foldl(fun
|
||||
(V1, Acc1) when is_map(V1) ->
|
||||
Fv = format_multilayer(V1),
|
||||
Fv = dgiot_bamis:format_multilayer(V1),
|
||||
case length(maps:values(Fv)) > 0 of
|
||||
true ->
|
||||
Acc1 ++ [Fv];
|
||||
@ -280,6 +279,25 @@ format_value(#{<<"regex">> := V}) ->
|
||||
#{<<"$regex">> => V};
|
||||
format_value(#{<<"in">> := V}) ->
|
||||
#{<<"$in">> => V};
|
||||
format_value(#{<<"or">> := V}) ->
|
||||
#{<<"$or">> => V};
|
||||
format_value(#{<<"and">> := V}) ->
|
||||
#{<<"$and">> => V};
|
||||
|
||||
format_value(<<"gt">>) ->
|
||||
<<"$gt">>;
|
||||
format_value(<<"gte">>) ->
|
||||
<<"$gte">>;
|
||||
format_value(<<"lt">>) ->
|
||||
<<"$lt">>;
|
||||
format_value(<<"lte">>) ->
|
||||
<<"$lte">>;
|
||||
format_value(<<"ne">>) ->
|
||||
<<"$ne">>;
|
||||
format_value(<<"regex">>) ->
|
||||
<<"$regex">>;
|
||||
format_value(<<"in">>) ->
|
||||
<<"$in">>;
|
||||
format_value(<<"or">>) ->
|
||||
<<"$or">>;
|
||||
format_value(<<"and">>) ->
|
||||
|
@ -34,6 +34,7 @@
|
||||
update_notification/2,
|
||||
create_maintenance/2,
|
||||
send_maintenance/1,
|
||||
send_other/1,
|
||||
get_operations/0,
|
||||
send_message_to3D/3,
|
||||
triggeralarm/2,
|
||||
@ -201,7 +202,7 @@ add_notification(<<"start_", Ruleid/binary>>, DeviceId, Payload) ->
|
||||
NotificationId = dgiot_parse_id:get_notificationid(Ruleid),
|
||||
dgiot_data:insert(?NOTIFICATION, {DeviceId, Ruleid}, {start, dgiot_datetime:now_secs(), NotificationId}),
|
||||
Content = save_notification(Ruleid, DeviceId, Payload, NotificationId),
|
||||
%% io:format("~s ~p Content = ~p.~n", [?FILE, ?LINE, Content]),
|
||||
dgiot_umeng:send_other(Content),
|
||||
dgiot_umeng:send_maintenance(Content#{<<"notificationid">> => NotificationId}),
|
||||
dgiot_umeng:send_msg(Content),
|
||||
dgiot_umeng:sendSubscribe(Content)
|
||||
@ -623,6 +624,53 @@ sendSubscribe(_O) ->
|
||||
%% io:format("~s ~p _O = ~p.~n", [?FILE, ?LINE, _O]),
|
||||
pass.
|
||||
|
||||
%% 推送第三方
|
||||
send_other(#{<<"send_alarm_status">> := <<"start">>, <<"_deviceid">> := DeviceId, <<"_viewid">> := ViewId, <<"dgiot_alarmvalue">> := Alarmvalue}) ->
|
||||
case dgiot_parse:get_object(<<"View">>, ViewId) of
|
||||
{ok, #{<<"meta">> := #{<<"otherpush">> := #{<<"ispush">> := <<"true">>, <<"type">> := <<"mqtt">>, <<"topic">> := Topic, <<"level">> := Level, <<"description">> := Description}}}} ->
|
||||
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,
|
||||
<<"status">> => <<"在线"/utf8>>,
|
||||
<<"content">> => Description,
|
||||
<<"time">> => Timestamp,
|
||||
<<"level">> => Level,
|
||||
<<"data">> => #{
|
||||
<<"id">> => Number,
|
||||
<<"deviceid">> => DeviceId,
|
||||
<<"devicename">> => DeviceName,
|
||||
<<"productid">> => ProductId,
|
||||
<<"productname">> => ProductName,
|
||||
<<"value">> => Alarmvalue,
|
||||
<<"type">> => <<"warn">>,
|
||||
<<"description">> => <<Description/binary, ";触发值:"/utf8, BinAlarmvalue/binary>>
|
||||
}
|
||||
},
|
||||
dgiot_mqtt:publish(DeviceId, <<"bridge/", Topic/binary>>, jsx:encode(Data)),
|
||||
dgiot_mqtt:publish(DeviceId, Topic, jsx:encode(Data));
|
||||
_ ->
|
||||
pass
|
||||
end;
|
||||
_O ->
|
||||
pass
|
||||
end;
|
||||
|
||||
send_other(_O) ->
|
||||
pass.
|
||||
|
||||
%% 触发 告警工单创建
|
||||
send_maintenance(#{<<"send_alarm_status">> := <<"start">>, <<"notificationid">> := NotificationId, <<"_deviceid">> := DeviceId, <<"devaddr">> := Devaddr, <<"_viewid">> := ViewId, <<"_productid">> := ProductId}) ->
|
||||
case dgiot_parse:get_object(<<"View">>, ViewId) of
|
||||
|
Loading…
Reference in New Issue
Block a user