fix host
This commit is contained in:
parent
740e35833b
commit
04254def4b
@ -418,36 +418,41 @@ code_change(_OldVsn, StateName, State = #state{}, _Extra) ->
|
||||
%%%===================================================================
|
||||
|
||||
%% 处理相关数据
|
||||
handle_data(#data{device_uuid = DeviceUUID, service_name = ServiceName, at = Timestamp, fields = FieldsList, tags = Tags}, #state{uuid = UUID})
|
||||
when is_binary(DeviceUUID), DeviceUUID /= <<>> ->
|
||||
|
||||
case iot_device:get_pid(DeviceUUID) of
|
||||
undefined ->
|
||||
lager:warning("[iot_host] host uuid: ~p, device uuid: ~p not found, fields: ~p, tags: ~p", [UUID, DeviceUUID, FieldsList, Tags]),
|
||||
ok;
|
||||
DevicePid when is_pid(DevicePid) ->
|
||||
case iot_device:is_activated(DevicePid) of
|
||||
true ->
|
||||
%% 查找终端设备对应的点位信息
|
||||
iot_router:route_uuid(DeviceUUID, FieldsList, Timestamp),
|
||||
|
||||
%% 数据写入influxdb
|
||||
NTags = Tags#{<<"uuid">> => UUID, <<"service_name">> => ServiceName, <<"device_uuid">> => DeviceUUID},
|
||||
influx_client:write_data(DeviceUUID, NTags, FieldsList, Timestamp),
|
||||
|
||||
iot_device:change_status(DevicePid, ?DEVICE_ONLINE);
|
||||
false ->
|
||||
lager:warning("[iot_host] host uuid: ~p, device_uuid: ~p not activated, fields: ~p, tags: ~p", [UUID, DeviceUUID, FieldsList, Tags])
|
||||
end
|
||||
end;
|
||||
|
||||
handle_data(#data{service_name = ServiceName, at = Timestamp, fields = FieldsList, tags = Tags}, #state{uuid = UUID}) ->
|
||||
%% 查找终端设备对应的点位信息
|
||||
iot_router:route_uuid(UUID, FieldsList, Timestamp),
|
||||
|
||||
%% 数据写入influxdb
|
||||
NTags = Tags#{<<"uuid">> => UUID, <<"service_name">> => ServiceName},
|
||||
influx_client:write_data(UUID, NTags, FieldsList, Timestamp).
|
||||
%handle_data(#data{device_uuid = DeviceUUID, service_name = ServiceName, at = Timestamp, fields = FieldsList, tags = Tags}, #state{uuid = UUID, device_map = DeviceMap})
|
||||
% when is_binary(DeviceUUID), DeviceUUID /= <<>> ->
|
||||
%
|
||||
% case maps:find(DeviceUUID, DeviceMap) of
|
||||
%
|
||||
% end,
|
||||
%
|
||||
%
|
||||
% case iot_device:get_pid(DeviceUUID) of
|
||||
% undefined ->
|
||||
% lager:warning("[iot_host] host uuid: ~p, device uuid: ~p not found, fields: ~p, tags: ~p", [UUID, DeviceUUID, FieldsList, Tags]),
|
||||
% ok;
|
||||
% DevicePid when is_pid(DevicePid) ->
|
||||
% case iot_device:is_activated(DevicePid) of
|
||||
% true ->
|
||||
% %% 查找终端设备对应的点位信息
|
||||
% iot_router:route_uuid(DeviceUUID, FieldsList, Timestamp),
|
||||
%
|
||||
% %% 数据写入influxdb
|
||||
% NTags = Tags#{<<"uuid">> => UUID, <<"service_name">> => ServiceName, <<"device_uuid">> => DeviceUUID},
|
||||
% influx_client:write_data(DeviceUUID, NTags, FieldsList, Timestamp),
|
||||
%
|
||||
% iot_device:change_status(DevicePid, ?DEVICE_ONLINE);
|
||||
% false ->
|
||||
% lager:warning("[iot_host] host uuid: ~p, device_uuid: ~p not activated, fields: ~p, tags: ~p", [UUID, DeviceUUID, FieldsList, Tags])
|
||||
% end
|
||||
% end;
|
||||
%
|
||||
%handle_data(#data{service_name = ServiceName, at = Timestamp, fields = FieldsList, tags = Tags}, #state{uuid = UUID}) ->
|
||||
% %% 查找终端设备对应的点位信息
|
||||
% iot_router:route_uuid(UUID, FieldsList, Timestamp),
|
||||
%
|
||||
% %% 数据写入influxdb
|
||||
% NTags = Tags#{<<"uuid">> => UUID, <<"service_name">> => ServiceName},
|
||||
% influx_client:write_data(UUID, NTags, FieldsList, Timestamp).
|
||||
|
||||
-spec report_event(UUID :: binary(), NewStatus :: integer()) -> no_return().
|
||||
report_event(UUID, NewStatus) when is_binary(UUID), is_integer(NewStatus) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user