mirror of
https://gitee.com/dgiiot/dgiot.git
synced 2024-11-30 03:07:40 +08:00
feat: triggeralarm
This commit is contained in:
parent
8aab84bd9c
commit
d233e93557
@ -334,7 +334,7 @@ do_request(post_operations, Args, #{<<"sessionToken">> := _SessionToken}, _Req)
|
||||
%% 请求:POST /iotapi/post_triggeralarm
|
||||
do_request(post_triggeralarm, #{<<"deviceid">> := DeviceId} = Args, #{<<"sessionToken">> := _SessionToken}, _Req) ->
|
||||
%% dgiot_mqtt:publish(<<"">>, <<"">>, jsx:decode(Args)),
|
||||
dgiot_umeng:triggeralarm(DeviceId),
|
||||
dgiot_umeng:triggeralarm(DeviceId, maps:get(<<"content">>, Args, <<>>)),
|
||||
{ok, #{<<"msg">> => <<"trigger successfully">>, <<"data">> => Args}};
|
||||
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
send_maintenance/1,
|
||||
get_operations/0,
|
||||
send_message_to3D/3,
|
||||
triggeralarm/1,
|
||||
triggeralarm/2,
|
||||
send_msg/1,
|
||||
sendSubscribe/1,
|
||||
get_defultmessage/1,
|
||||
@ -500,20 +500,17 @@ get_operations() ->
|
||||
}
|
||||
}.
|
||||
|
||||
triggeralarm(DeviceId) ->
|
||||
triggeralarm(DeviceId, Content) ->
|
||||
case dgiot_parse:get_object(<<"Device">>, DeviceId) of
|
||||
{ok, #{<<"name">> := DeviceName, <<"product">> := #{<<"objectId">> := ProductId}, <<"detail">> := Detail}} ->
|
||||
{ProductName, Lev, Type, Content} =
|
||||
{ok, #{<<"name">> := DeviceName, <<"product">> := #{<<"objectId">> := ProductId}}} ->
|
||||
{ProductName, Lev, Type} =
|
||||
case dgiot_parse:get_object(<<"Product">>, ProductId) of
|
||||
{ok, #{<<"name">> := <<"检票闸机"/utf8>>}} ->
|
||||
Desc = maps:get(<<"desc">>, Detail, <<"通过人数超过阈值,请到现场处理"/utf8>>),
|
||||
{<<"检票闸机"/utf8>>, <<"二级"/utf8>>, <<"告警工单"/utf8>>, <<DeviceName/binary, Desc/binary>>};
|
||||
{<<"检票闸机"/utf8>>, <<"二级"/utf8>>, <<"告警工单"/utf8>>};
|
||||
{ok, #{<<"name">> := <<"车闸机"/utf8>>}} ->
|
||||
Desc = maps:get(<<"desc">>, Detail, <<"当前车闸机无法自动抬起,请检查该设备"/utf8>>),
|
||||
{<<"车闸机"/utf8>>, <<"二级"/utf8>>, <<"告警工单"/utf8>>, <<DeviceName/binary, Desc/binary>>};
|
||||
{<<"车闸机"/utf8>>, <<"二级"/utf8>>, <<"告警工单"/utf8>>};
|
||||
{ok, #{<<"name">> := Name1}} ->
|
||||
Desc = maps:get(<<"desc">>, Detail, <<"发生火灾,请赶往A区查看"/utf8>>),
|
||||
{Name1, <<"一级"/utf8>>, <<"报警工单"/utf8>>, <<DeviceName/binary, Desc/binary>>}
|
||||
{Name1, <<"一级"/utf8>>, <<"报警工单"/utf8>>}
|
||||
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">>),
|
||||
|
@ -231,11 +231,11 @@ get_objectid(Class, Map) ->
|
||||
<<"Device">> ->
|
||||
Product = case maps:get(<<"product">>, Map) of
|
||||
#{<<"objectId">> := ProductId} ->
|
||||
ProductId;
|
||||
dgiot_utils:to_binary(ProductId);
|
||||
ProductId1 ->
|
||||
ProductId1
|
||||
dgiot_utils:to_binary(ProductId1)
|
||||
end,
|
||||
DevAddr = maps:get(<<"devaddr">>, Map, <<"">>),
|
||||
DevAddr = dgiot_utils:to_binary(maps:get(<<"devaddr">>, Map, <<>>)),
|
||||
<<Did:10/binary, _/binary>> = dgiot_utils:to_md5(<<"Device", Product/binary, DevAddr/binary>>),
|
||||
Map#{
|
||||
<<"objectId">> => Did
|
||||
|
Loading…
Reference in New Issue
Block a user