智慧照明设备的数据按照建筑物合并

This commit is contained in:
anlicheng 2025-01-09 14:55:55 +08:00
parent efdf503103
commit e6c7771ce1
2 changed files with 3 additions and 7 deletions

View File

@ -111,8 +111,7 @@ handle_info({timeout, _, report_ticker}, State = #state{accumulators = Accumulat
Props0 = lists:map(fun(Key) -> merge(Key, L) end, [<<"total_power">>, <<"total_runtime">>, <<"use_times">>]), Props0 = lists:map(fun(Key) -> merge(Key, L) end, [<<"total_power">>, <<"total_runtime">>, <<"use_times">>]),
Fields = lists:flatten(Props0), Fields = lists:flatten(Props0),
lager:debug("[iot_build] merged fileds is: ~p", [Fields]), iot_zd_endpoint:forward(LocationCode, LocationCode, Fields, Timestamp),
%iot_zd_endpoint:forward(LocationCode, LocationCode, Fields, Timestamp),
iot_build_logger:write([LocationCode, jiffy:encode(Fields, [force_utf8])]), iot_build_logger:write([LocationCode, jiffy:encode(Fields, [force_utf8])]),
erlang:start_timer(?REPORT_INTERVAL, self(), report_ticker), erlang:start_timer(?REPORT_INTERVAL, self(), report_ticker),

View File

@ -293,14 +293,11 @@ handle_cast({handle_data, Fields, Timestamp}, State = #state{device_uuid = Devic
case ModelId =:= 20 of case ModelId =:= 20 of
true -> true ->
NLocationCode = extract_build_location_code(LocationCode), NLocationCode = extract_build_location_code(LocationCode),
lager:debug("[iot_device] light device: ~p, build location_code: ~p", [DeviceUUID, NLocationCode]),
{ok, BuildPid} = iot_build_sup:ensured_build_started(NLocationCode), {ok, BuildPid} = iot_build_sup:ensured_build_started(NLocationCode),
iot_build:handle_data(BuildPid, DeviceUUID, Fields, Timestamp); iot_build:handle_data(BuildPid, DeviceUUID, Fields, Timestamp);
false -> false ->
ok iot_zd_endpoint:forward(LocationCode, DynamicLocationCode, Fields, Timestamp)
%iot_zd_endpoint:forward(LocationCode, DynamicLocationCode, Fields, Timestamp) end;
end,
iot_zd_endpoint:forward(LocationCode, DynamicLocationCode, Fields, Timestamp);
{ok, _} -> {ok, _} ->
lager:warning("[iot_device] the north_data hget location_code, uuid: ~p, not found, fields: ~p", [DeviceUUID, Fields]); lager:warning("[iot_device] the north_data hget location_code, uuid: ~p, not found, fields: ~p", [DeviceUUID, Fields]);
{error, Reason} -> {error, Reason} ->