mirror of
https://gitee.com/dgiiot/dgiot.git
synced 2024-12-02 12:18:30 +08:00
"feat: 同步设备最后离线时间"
This commit is contained in:
parent
f185cf68fc
commit
4030ef921d
@ -263,7 +263,7 @@ sync_parse(OffLine) ->
|
||||
Now = dgiot_datetime:now_secs(),
|
||||
case V of
|
||||
{[Acl, _, Last, IsEnable, ProductId, Devaddr, DeviceSecret, Node, Longitude, Latitude]} when (Now - Last) < 0 ->
|
||||
case dgiot_parse:update_object(<<"Device">>, DeviceId, #{<<"status">> => <<"ONLINE">>, <<"isEnable">> => IsEnable}) of
|
||||
case dgiot_parse:update_object(<<"Device">>, DeviceId, #{<<"status">> => <<"ONLINE">>, <<"isEnable">> => IsEnable, <<"lastOnlineTime">> => Last}) of
|
||||
{ok, _R} ->
|
||||
insert_mnesia(DeviceId, Acl, true, Last, IsEnable, ProductId, Devaddr, DeviceSecret, Node, Longitude, Latitude);
|
||||
_ ->
|
||||
@ -271,7 +271,7 @@ sync_parse(OffLine) ->
|
||||
end,
|
||||
timer:sleep(50);
|
||||
{[Acl, true, Last, IsEnable, ProductId, Devaddr, DeviceSecret, Node, Longitude, Latitude]} when (Now - Last) > OffLine ->
|
||||
case dgiot_parse:update_object(<<"Device">>, DeviceId, #{<<"status">> => <<"OFFLINE">>, <<"isEnable">> => IsEnable}) of
|
||||
case dgiot_parse:update_object(<<"Device">>, DeviceId, #{<<"status">> => <<"OFFLINE">>, <<"isEnable">> => IsEnable, <<"lastOnlineTime">> => Last}) of
|
||||
{ok, _R} ->
|
||||
insert_mnesia(DeviceId, Acl, false, Last, IsEnable, ProductId, Devaddr, DeviceSecret, Node, Longitude, Latitude);
|
||||
_ ->
|
||||
@ -279,7 +279,7 @@ sync_parse(OffLine) ->
|
||||
end,
|
||||
timer:sleep(50);
|
||||
{[Acl, false, Last, IsEnable, ProductId, Devaddr, DeviceSecret, Node, Longitude, Latitude]} when (Now - Last) < OffLine ->
|
||||
case dgiot_parse:update_object(<<"Device">>, DeviceId, #{<<"status">> => <<"ONLINE">>, <<"isEnable">> => IsEnable}) of
|
||||
case dgiot_parse:update_object(<<"Device">>, DeviceId, #{<<"status">> => <<"ONLINE">>, <<"isEnable">> => IsEnable, <<"lastOnlineTime">> => Last}) of
|
||||
{ok, _R} ->
|
||||
insert_mnesia(DeviceId, Acl, true, Last, IsEnable, ProductId, Devaddr, DeviceSecret, Node, Longitude, Latitude);
|
||||
_ ->
|
||||
|
Loading…
Reference in New Issue
Block a user