Skip to content

Commit

Permalink
数据类型空值处理
Browse files Browse the repository at this point in the history
  • Loading branch information
redgreat committed Aug 27, 2024
1 parent ea02fdf commit 12d9c3a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
%% Release profiles
%% To create a release just run
%% rebar3 as prod release
{relx, [{release, {eadm, "0.1.41"},
{relx, [{release, {eadm, "0.1.42"},
[eadm, nova, epgsql, poolboy, lager, sasl, inets, observer, runtime_tools]},
{mode, minimal},
{extended_start_script, true},
Expand Down
15 changes: 8 additions & 7 deletions src/apis/api_watch.erl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ index(#{params := Params}) ->
<<"10">> ->
% 血糖
try
BloodSugar = erlang:binary_to_float(maps:get(<<"bloodSugar">>, Params, <<"0">>)),
BloodSugar = erlang:list_to_float(erlang:binary_to_list(
maps:get(<<"bloodSugar">>, Params, <<"0">>))),
BTUtcTime = eadm_utils:parse_date_time(maps:get(<<"BTUtcTime">>, Params, <<"1970/1/1 00:00:00">>)),
eadm_pgpool:equery(pool_pg, "insert into lc_watchbs(ptime, bloodsugar)
values($1, $2) on conflict (ptime)
Expand All @@ -128,10 +129,10 @@ index(#{params := Params}) ->
<<"12">> ->
% 体温数据
try
BodyTemperature = erlang:binary_to_float(maps:get(<<"bodyTemperature">>, Params, <<"0">>)),
BodyTemperature = maps:get(<<"bodyTemperature">>, Params, <<"0">>),
BTUtcTime = eadm_utils:parse_date_time(maps:get(<<"BTUtcTime">>, Params, <<"1970/1/1 00:00:00">>)),
eadm_pgpool:equery(pool_pg, "insert into lc_watchbt(ptime, bodytemperature)
values($1, $2) on conflict (ptime)
values($1, $2::real) on conflict (ptime)
do update set bodytemperature=excluded.bodytemperature;", [BTUtcTime, BodyTemperature]),
#{<<"success">> => true}
catch
Expand All @@ -141,11 +142,11 @@ index(#{params := Params}) ->
<<"14">> ->
% 体温数据
try
BodyTemperature = erlang:binary_to_float(maps:get(<<"bodyTemperature">>, Params, <<"0">>)),
WristTemperature = erlang:binary_to_float(maps:get(<<"wristTemperature">>, Params, <<"0">>)),
BodyTemperature = maps:get(<<"bodyTemperature">>, Params, <<"0">>),
WristTemperature = maps:get(<<"wristTemperature">>, Params, <<"0">>),
BTUtcTime = eadm_utils:parse_date_time(maps:get(<<"BTUtcTime">>, Params, <<"1970/1/1 00:00:00">>)),
eadm_pgpool:equery(pool_pg, "insert into lc_watchbt(ptime, bodytemperature, wristtemperature)
values($1, $2, $3) on conflict (ptime)
values($1, $2::real, $3::real) on conflict (ptime)
do update set bodytemperature=excluded.bodytemperature,
wristtemperature=excluded.wristtemperature;",
[BTUtcTime, BodyTemperature, WristTemperature]),
Expand Down Expand Up @@ -180,7 +181,7 @@ index(#{params := Params}) ->
values($1, $2, $3) on conflict (ptime)
do update set signal=excluded.signal, battery=excluded.battery;",
[BTUtcTime, Signal, Battery]),
Steps = maps:get(<<"steps">>, Params, <<"0">>),
Steps = erlang:binary_to_integer(maps:get(<<"steps">>, Params, <<"0">>)),
eadm_pgpool:equery(pool_pg, "insert into lc_watchstep(ptime, steps)
values($1, $2) on conflict (ptime)
do update set steps=excluded.steps;", [BTUtcTime, Steps]),
Expand Down
2 changes: 1 addition & 1 deletion src/eadm.app.src
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
{application, eadm,
[{description, "RG管理平台"},
{vsn, "0.1.41"},
{vsn, "0.1.42"},
{registered, []},
{mod, {eadm_app, []}},
{included_applications, []},
Expand Down

0 comments on commit 12d9c3a

Please sign in to comment.