diff --git a/.pnpm-debug.log b/.pnpm-debug.log index 4e4193b3f5..9e26dfeeb6 100644 --- a/.pnpm-debug.log +++ b/.pnpm-debug.log @@ -1,14 +1 @@ -{ - "0 debug pnpm:scope": { - "selected": 1 - }, - "1 error pnpm": { - "code": "ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND", - "err": { - "name": "pnpm", - "message": "No package.json (or package.yaml, or package.json5) was found in \"D:\\msys64\\home\\h7ml\\dgiot\\dgiot\".", - "code": "ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND", - "stack": "pnpm: No package.json (or package.yaml, or package.json5) was found in \"D:\\msys64\\home\\h7ml\\dgiot\\dgiot\".\n at readProjectManifest (D:\\software\\nodejs\\node_global\\node_modules\\pnpm\\dist\\pnpm.cjs:19808:13)\n at async Object.readProjectManifestOnly (D:\\software\\nodejs\\node_global\\node_modules\\pnpm\\dist\\pnpm.cjs:19812:28)\n at async readProjectManifestOnly (D:\\software\\nodejs\\node_global\\node_modules\\pnpm\\dist\\pnpm.cjs:43711:24)\n at async Object.handler (D:\\software\\nodejs\\node_global\\node_modules\\pnpm\\dist\\pnpm.cjs:177889:24)\n at async D:\\software\\nodejs\\node_global\\node_modules\\pnpm\\dist\\pnpm.cjs:182165:21\n at async run (D:\\software\\nodejs\\node_global\\node_modules\\pnpm\\dist\\pnpm.cjs:182139:34)\n at async runPnpm (D:\\software\\nodejs\\node_global\\node_modules\\pnpm\\dist\\pnpm.cjs:182358:5)\n at async D:\\software\\nodejs\\node_global\\node_modules\\pnpm\\dist\\pnpm.cjs:182350:7" - } - } -} \ No newline at end of file +{} \ No newline at end of file diff --git a/apps/dgiot_bridge/src/handler/dgiot_rule_handler.erl b/apps/dgiot_bridge/src/handler/dgiot_rule_handler.erl index b291c04ad2..e0e9ed5b9d 100644 --- a/apps/dgiot_bridge/src/handler/dgiot_rule_handler.erl +++ b/apps/dgiot_bridge/src/handler/dgiot_rule_handler.erl @@ -232,11 +232,11 @@ sql_tpl(Trigger, Condition, Action) -> %% _ -> Acc %% end %% end, <<"">>, Where), - DefaultSql = <<"SELECT", "\r\n", + DefaultSql = <<"SELECT", "\r\n ", SELECT/binary, "\r\n", "FROM ", "\r\n", " \"", FROM/binary, "\"", "\r\n", - "WHERE", "\r\n ", + "WHERE", "\r\n ", WHERE/binary>>, {ok, #{<<"template">> => DefaultSql}}. @@ -470,12 +470,12 @@ generateFrom(Trigger) -> end; <<"trigger/mqtt/event">> -> case Params of - #{<<"productKey">> := ProductId} -> + #{<<"productKey">> := ProductId, <<"mqtt">> := Mqtt, <<"deviceName">> := Devaddr} -> case ProductId of <<"">> -> - <<"$events/", ProductId/binary>>; + <<"$events/", Mqtt/binary, "/", ProductId/binary, "/", Devaddr/binary>>; _ -> - <<"$events/", "test/#">> + <<"$events/", Mqtt/binary, "/", ProductId/binary, "/", Devaddr/binary, "/#">> end; _ -> <<"$dg/user/", "test/#">> @@ -486,13 +486,56 @@ generateFrom(Trigger) -> <<"$dg/user/", "test/#">> end. -generateSelect(_Condition, _Trigger, _FROM) -> - <<"SELECT">>. +generateSelect(_Condition, Trigger, _FROM) -> +%% Trigger: [ +%% { +%% label: '设备属性触发', +%% value: 'trigger/product/property', +%% }, +%% { +%% label: '设备事件触发', +%% value: 'trigger/product/event', +%% }, +%% { +%% label: 'mqtt事件触发', +%% value: 'trigger/mqtt/event', +%% }, +%% { +%% label: '定时触发', +%% value: 'trigger/timer', +%% }, +%% ], +%% + Firstfrom = lists:nth(1, maps:get(<<"items">>, Trigger)), + Uri = maps:get(<<"uri">>, Firstfrom), + Params = maps:get(<<"params">>, Firstfrom, #{}), + case Uri of + <<"trigger/mqtt/event">> -> + case Params of + #{<<"mqtt">> := Mqtt} -> <<"payload.event.", Mqtt/binary, " as ", Mqtt/binary>>; + _ -> + <<"payload.event.", "test">> + end; + <<"trigger/product/property">> -> + case Params of + #{<<"propertyName">> := PropertyName} -> + <<"payload.property.", PropertyName/binary, " as ", PropertyName/binary>>; + _ -> + <<"payload.property.", "test">> + end; + <<"trigger/product/event">> -> + case Params of + #{<<"propertyName">> := PropertyName} -> + <<"payload.productevent.", PropertyName/binary, " as ", PropertyName/binary>>; + _ -> + <<"payload.productevent.", "test">> + end; + <<"trigger/timer">> -> <<"payload.cron">>; + _ -> + <<"$dg/user/", "test/#">> + end. generateWhere(Condition, _Trigger, _FROM) -> - io:format("Condition ~p", [Condition]), - io:format("_Trigger ~p", [_Trigger]), - io:format("_FROM ~p", [_FROM]), %% Condition: [ %% { %% label: '状态持续时长判断', @@ -526,7 +569,7 @@ generateWhere(Condition, _Trigger, _FROM) -> case Item of #{<<"uri">> := <<"condition/device/stateContinue">>, <<"params">> := #{ <<"state">> := State, <<"times">> := Times}} -> - Continue = <>, case Acc of <<"">> -> Continue;