Skip to content

Commit

Permalink
feat: 迁移脚本 && 字段修å�值重复
Browse files Browse the repository at this point in the history
  • Loading branch information
h7ml committed Jul 21, 2021
1 parent 558816b commit 1d69ba7
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 11 deletions.
55 changes: 48 additions & 7 deletions apps/dgiot_device/src/device2.erl
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,54 @@
-export([updata_data/0]).
-include_lib("dgiot/include/logger.hrl").


%%% @description 设备数据字段迁移
updata_data() ->
Success = fun(Page) -> io:format("~p ~n", [Page])
%% ?LOG(error, "~p", [Page])
%% dgiot_parse:update_object(<<"Device">>, DeviceId, #{})
end,
Success = fun(Page) -> io:format("~p ~n", [Page]) end,
Info = fun(Page) ->
case Page of
[#{<<"basedata">> := Basedata, <<"objectId">> := ObjectId, <<"devaddr">> := Devaddr}] ->
case Basedata of
#{<<"basicdata">> := BasisData} ->
PowerOnCtrl = maps:get(<<"PowerOnCtrl">>, BasisData, 0),
PubCtrl = maps:get(<<"PubCtrl">>, BasisData, 1),
PubFreq = maps:get(<<"PubFreq">>, BasisData, 20),
ParaGet = maps:get(<<"ParaGet">>, BasisData, 1),
FOTA = maps:get(<<"FOTA">>, BasisData, 0),
AgreementRelease = maps:get(<<"AgreementRelease">>, BasisData, 0),
PowerOffDelay = maps:get(<<"PowerOffDelay">>, BasisData, 48),
ExpirationTime = maps:get(<<"expirationTime">>, Basedata, 0),
CtrlSerialNo = maps:get(<<"CtrlSerialNo">>, BasisData, 0),
MDSerialNo = maps:get(<<"MDSerialNo">>, BasisData, 0),
CtrSoftVersion = maps:get(<<"CtrSoftVersion">>, BasisData, 0),
ProtocolVersion = maps:get(<<"ProtocolVersion">>, BasisData, 0),
PartAddr = maps:get(<<"partAddr">>, BasisData, 0),
MDSoftVersion = maps:get(<<"MDSoftVersion">>, BasisData, 0),
SIMSerialNo = maps:get(<<"SIMSerialNo">>, BasisData, 0),
dgiot_parse:update_object(<<"Device">>, ObjectId, #{<<"profile">> => #{
<<"PowerOnCtrl">> => PowerOnCtrl,
<<"PubCtrl">> => PubCtrl,
<<"PubFreq">> => PubFreq,
<<"ParaGet">> => ParaGet,
<<"FOTA">> => FOTA,
<<"AgreementRelease">> => AgreementRelease,
<<"PowerOffDelay">> => PowerOffDelay
}, <<"form">> => #{
<<"Devaddr">> => Devaddr,
<<"ExpirationTime">> => ExpirationTime,
<<"CtrlSerialNo">> => CtrlSerialNo,
<<"MDSerialNo">> => MDSerialNo,
<<"CtrSoftVersion">> => CtrSoftVersion,
<<"ProtocolVersion">> => ProtocolVersion,
<<"PartAddr">> => PartAddr,
<<"MDSoftVersion">> => MDSoftVersion,
<<"SIMSerialNo">> => SIMSerialNo
}});
_ ->
pass
end;
R -> io:format("~p ~n", [R])
end
end,

Query = #{<<"where">> => #{}},
dgiot_parse_loader:start(<<"Device">>, Query, 0, 100, 20000, Success),
dgiot_parse_loader:start(<<"Device">>, Query, 0, 1, 2000, Info),
ok.
6 changes: 3 additions & 3 deletions apps/dgiot_http/src/umeng/dgiot_umeng.erl
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ add_notification(Ruleid, DevAddr, Payload) ->
<<"role:", Name/binary>> ->
RoleId = dgiot_parse:get_roleid(Name),
UserIds = dgiot_parse:get_userids(RoleId),
lists:foldl(fun(X, Acc1) ->
lists:foldl(fun(Y, Acc1) ->
Acc1 ++ [#{
<<"method">> => <<"post">>,
<<"path">> => <<"/classes/Notification">>,
<<"body">> => #{
<<"ACL">> => #{
X => #{
Y => #{
<<"read">> => true,
<<"write">> => true
}
Expand All @@ -215,7 +215,7 @@ add_notification(Ruleid, DevAddr, Payload) ->
<<"user">> => #{
<<"__type">> => <<"Pointer">>,
<<"className">> => <<"_User">>,
<<"objectId">> => X
<<"objectId">> => Y
}
}
}]
Expand Down
2 changes: 1 addition & 1 deletion apps/dgiot_parse/etc/dgiot_parse.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ parse.delete_field = ACL,objectId,updatedAt,createdAt
##--------------------------------------------------------------------
## parse config
##--------------------------------------------------------------------
parse.parse_server = http://prod.iotn2n.com:1337
parse.parse_server = http://132.232.119.105:1337
parse.parse_path = /parse/
parse.parse_appid = 1uqZbbdd_JMyQ45YLsUzYezMRPerMa80
parse.parse_master_key = PADbN7p973quWLngikp6XvrDbL97u_vM
Expand Down

0 comments on commit 1d69ba7

Please sign in to comment.