fix data type

This commit is contained in:
anlicheng 2025-01-21 01:08:47 +08:00
parent 8391ace302
commit 848d183c5b
2 changed files with 3 additions and 3 deletions

View File

@ -101,7 +101,7 @@ handle_cast({handle_data, DeviceUUID, Fields, Timestamp}, State = #state{build_l
{noreply, NewState :: #state{}} | {noreply, NewState :: #state{}} |
{noreply, NewState :: #state{}, timeout() | hibernate} | {noreply, NewState :: #state{}, timeout() | hibernate} |
{stop, Reason :: term(), NewState :: #state{}}). {stop, Reason :: term(), NewState :: #state{}}).
handle_info({timeout, _, report_ticker}, State = #state{build_location_code = LocationCode, build_location_code = LocationCode}) -> handle_info({timeout, _, report_ticker}, State = #state{build_location_code = LocationCode}) ->
%% keys: total_power, total_runtime, use_times; key的值是可以直接累加的 %% keys: total_power, total_runtime, use_times; key的值是可以直接累加的
%% props的格式为#{key0 => props0, key1 => Props1} %% props的格式为#{key0 => props0, key1 => Props1}

View File

@ -26,7 +26,7 @@ create_table() ->
]). ]).
-spec insert(LocationCode :: binary(), DeviceUUID :: binary(), Fields :: list(), Timestamp :: integer()) -> ok | {error, Reason :: any()}. -spec insert(LocationCode :: binary(), DeviceUUID :: binary(), Fields :: list(), Timestamp :: integer()) -> ok | {error, Reason :: any()}.
insert(LocationCode, DeviceUUID, Fields, Timestamp) when is_integer(LocationCode), is_integer(DeviceUUID), is_list(Fields), is_integer(Timestamp) -> insert(LocationCode, DeviceUUID, Fields, Timestamp) when is_binary(LocationCode), is_binary(DeviceUUID), is_list(Fields), is_integer(Timestamp) ->
Fun = fun() -> Fun = fun() ->
Q = qlc:q([E || E <- mnesia:table(?TAB), E#build_data.location_code =:= LocationCode, E#build_data.device_uuid =:= DeviceUUID]), Q = qlc:q([E || E <- mnesia:table(?TAB), E#build_data.location_code =:= LocationCode, E#build_data.device_uuid =:= DeviceUUID]),
case qlc:e(Q) of case qlc:e(Q) of
@ -48,7 +48,7 @@ insert(LocationCode, DeviceUUID, Fields, Timestamp) when is_integer(LocationCode
end. end.
-spec get_build_dataset(LocationCode :: binary()) -> [#build_data{}]. -spec get_build_dataset(LocationCode :: binary()) -> [#build_data{}].
get_build_dataset(LocationCode) when is_integer(LocationCode) -> get_build_dataset(LocationCode) when is_binary(LocationCode) ->
Fun = fun() -> Fun = fun() ->
Q = qlc:q([E || E <- mnesia:table(?TAB), E#build_data.location_code =:= LocationCode]), Q = qlc:q([E || E <- mnesia:table(?TAB), E#build_data.location_code =:= LocationCode]),
qlc:e(Q) qlc:e(Q)