mirror of
https://gitee.com/dgiiot/dgiot.git
synced 2024-12-02 12:18:30 +08:00
fix: parse
This commit is contained in:
parent
8a717a5130
commit
01de1f15e9
@ -354,6 +354,38 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "密度单位",
|
||||
"options": [
|
||||
{
|
||||
"symbol": "mg/l",
|
||||
"name": "毫克每升",
|
||||
"description": "密度单位:毫克每升(mg/l)",
|
||||
"id": "milligraml",
|
||||
"text": "毫克每升(mg/l)",
|
||||
"type": "密度单位",
|
||||
"value": "milligraml"
|
||||
},
|
||||
{
|
||||
"symbol": "g/l",
|
||||
"name": "克每升",
|
||||
"description": "密度单位:克每升(g/l)",
|
||||
"id": "grammel",
|
||||
"text": "克每升(g/l)",
|
||||
"type": "密度单位",
|
||||
"value": "grammel"
|
||||
},
|
||||
{
|
||||
"symbol": "kg/l",
|
||||
"name": "千克每升",
|
||||
"description": "密度单位:千克每升(kg/l)",
|
||||
"id": "kilograml",
|
||||
"text": "千克每升(kg/l)",
|
||||
"type": "密度单位",
|
||||
"value": "kilograml"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "力单位",
|
||||
"options": [
|
||||
@ -501,6 +533,14 @@
|
||||
{
|
||||
"label": "速度单位",
|
||||
"options": [
|
||||
{
|
||||
"symbol": "m³/s",
|
||||
"typeText": "速度单位",
|
||||
"name": "立方米每秒",
|
||||
"description": "速度单位:立方米每秒(m³/s)",
|
||||
"id": "lifangmPerSec",
|
||||
"type": "speed"
|
||||
},
|
||||
{
|
||||
"symbol": "m/s",
|
||||
"typeText": "速度单位",
|
||||
@ -766,6 +806,15 @@
|
||||
"text": "千瓦·时(kW·h)",
|
||||
"type": "电力单位",
|
||||
"value": "kWattsHour"
|
||||
},
|
||||
{
|
||||
"symbol": "us/cm",
|
||||
"name": "微西门/厘米",
|
||||
"description": "电导率单位:微西门/厘米(us/cm)",
|
||||
"id": "weiximenlimi",
|
||||
"text": "微西门/厘米(us/cm)",
|
||||
"type": "电力单位",
|
||||
"value": "weiximenlimi"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -125,49 +125,6 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/import_reportTemp": {
|
||||
"post": {
|
||||
"summary": "导库",
|
||||
"description": "json文件导库",
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "className",
|
||||
"in": "formData",
|
||||
"description": "表名",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "file",
|
||||
"in": "formData",
|
||||
"description": "数据文件",
|
||||
"type": "file"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Returns operation status"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request"
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized"
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden"
|
||||
},
|
||||
"500": {
|
||||
"description": "Server Internal error"
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"Data"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/reportTemp": {
|
||||
"put": {
|
||||
"description": "新增报告子模版",
|
||||
|
@ -31,7 +31,6 @@
|
||||
add_notification/3,
|
||||
save_notification/4,
|
||||
update_notification/2,
|
||||
sendSubscribe/3,
|
||||
create_maintenance/2,
|
||||
get_operations/0,
|
||||
send_message_to3D/3,
|
||||
@ -554,53 +553,6 @@ send_msg(#{<<"send_alarm_status">> := <<"stop">>, <<"_productid">> := ProductId}
|
||||
send_msg(_) ->
|
||||
pass.
|
||||
|
||||
sendSubscribe(Type, Content, _UserId) ->
|
||||
DeviceId = maps:get(<<"_deviceid">>, Content, <<"">>),
|
||||
{Devaddr, _Address} =
|
||||
case dgiot_parse:get_object(<<"Device">>, DeviceId) of
|
||||
{ok, #{<<"devaddr">> := Devaddr1, <<"detail">> := Detail}} ->
|
||||
Address1 = maps:get(<<"address">>, Detail, <<"无位置"/utf8>>),
|
||||
{Devaddr1, Address1};
|
||||
_ ->
|
||||
{<<"">>, <<"无位置"/utf8>>}
|
||||
end,
|
||||
case binary:split(Type, <<$_>>, [global, trim]) of
|
||||
[ProductId, AlertId] ->
|
||||
%% Productname =
|
||||
%% case dgiot_parse:get_object(<<"Product">>, ProductId) of
|
||||
%% {ok, #{<<"name">> := Productname1}} ->
|
||||
%% Productname1;
|
||||
%% _ ->
|
||||
%% <<" ">>
|
||||
%% end,
|
||||
dgiot_datetime:now_secs(),
|
||||
case dgiot_parse:get_object(<<"Product">>, ProductId) of
|
||||
{ok, #{<<"config">> := #{<<"parser">> := Parse}}} ->
|
||||
lists:foldl(fun(P, Par) ->
|
||||
case P of
|
||||
#{<<"uid">> := AlertId, <<"config">> := #{<<"formDesc">> := FormDesc}} ->
|
||||
maps:fold(fun(Key, Value1, Form) ->
|
||||
case maps:find(Key, Content) of
|
||||
{ok, Value} ->
|
||||
BinValue = dgiot_utils:to_binary(Value),
|
||||
Form#{<<"thing15">> => #{<<"value">> => BinValue}};
|
||||
_ ->
|
||||
Default = maps:get(<<"default">>, Value1, <<>>),
|
||||
Form#{Key => #{<<"value">> => Default}}
|
||||
end
|
||||
end, #{<<"thing1">> => #{<<"value">> => Devaddr}, <<"date4">> => #{<<"value">> => dgiot_datetime:format("YYYY-MM-DD HH:NN:SS")}}, FormDesc);
|
||||
_Oth ->
|
||||
Par
|
||||
end
|
||||
end, #{}, Parse);
|
||||
_Other ->
|
||||
#{}
|
||||
end;
|
||||
_Other1 ->
|
||||
#{}
|
||||
end.
|
||||
%% dgiot_wechat:sendSubscribe(UserId, Result).
|
||||
|
||||
%% 触发 小程序通知
|
||||
sendSubscribe(#{<<"send_alarm_status">> := <<"start">>, <<"alarm_createdAt">> := Alarm_createdAt, <<"alarm_message">> := Alarm_message, <<"_deviceid">> := DeviceId, <<"_productid">> := ProductId, <<"dgiot_alarmkey">> := Alarmkey, <<"dgiot_alarmvalue">> := Alarmvalue}) ->
|
||||
case dgiot_parse:get_object(<<"Product">>, ProductId) of
|
||||
@ -645,7 +597,7 @@ sendSubscribe(_O) ->
|
||||
%% 变量名称:%DATAPOINTNAME%
|
||||
%% 当前值:%NOWVALUE%
|
||||
%% 触发描述:%TRIGGERDESCRIPTION%
|
||||
replace_param(Param, ProductName, ProductId, DeviceId, Key, Value, Alarm_createdAt, TriggerdeScription) ->
|
||||
replace_param(Param, ProductName, ProductId, DeviceId, Key, Value, Alarm_createdAt, TriggerdeScription, Alarm_message) ->
|
||||
Date = dgiot_datetime:format("YYYY-MM-DD"),
|
||||
DateTime = dgiot_datetime:format("YYYY-MM-DD HH:NN:SS"),
|
||||
{DeviceName, DeviceAddr, OldACL, UserToken} =
|
||||
@ -697,7 +649,8 @@ replace_param(Param, ProductName, ProductId, DeviceId, Key, Value, Alarm_created
|
||||
Str8 = re:replace(Str7, "%TRIGGERTIME%", Alarm_createdAt, [global, {return, list}]),
|
||||
Str9 = re:replace(Str8, "%DATAPOINTNAME%", DataPointname, [global, {return, list}]),
|
||||
Str10 = re:replace(Str9, "%TRIGGERDESCRIPTION%", TriggerdeScription, [global, {return, list}]),
|
||||
re:replace(Str10, "%NOWVALUE%", dgiot_utils:to_list(Value), [global, {return, binary}]).
|
||||
Str11 = re:replace(Str10, "%TRIGGERCONTENT%", Alarm_message, [global, {return, list}]),
|
||||
re:replace(Str11, "%NOWVALUE%", dgiot_utils:to_list(Value), [global, {return, binary}]).
|
||||
|
||||
|
||||
%% 产品名称:%PRODUCTNAME%
|
||||
@ -785,11 +738,11 @@ replace_miniparam(Acc, _, Value, _Alarm_createdAt, _Alarmkey, _Alarmvalue, _Devi
|
||||
|
||||
send_mode(#{<<"sms">> := #{<<"issend">> := <<"true">>, <<"params">> := Params, <<"tplid">> := TplId, <<"roleid">> := RoleId} = Sms},
|
||||
ProductName,
|
||||
#{<<"roleid">> := NotifRoleid, <<"alarm_createdAt">> := Alarm_createdAt, <<"_deviceid">> := DeviceId, <<"_productid">> := ProductId, <<"dgiot_alarmkey">> := Key, <<"dgiot_alarmvalue">> := Value},
|
||||
#{<<"roleid">> := NotifRoleid, <<"alarm_createdAt">> := Alarm_createdAt, <<"alarm_message">> := Alarm_message, <<"_deviceid">> := DeviceId, <<"_productid">> := ProductId, <<"dgiot_alarmkey">> := Key, <<"dgiot_alarmvalue">> := Value},
|
||||
TriggerdeScription) when is_list(Params) ->
|
||||
NewParams =
|
||||
lists:foldl(fun(Param, Acc) ->
|
||||
Acc ++ [replace_param(Param, ProductName, ProductId, DeviceId, Key, Value, Alarm_createdAt, TriggerdeScription)]
|
||||
Acc ++ [replace_param(Param, ProductName, ProductId, DeviceId, Key, Value, Alarm_createdAt, TriggerdeScription, Alarm_message)]
|
||||
end, [], Params),
|
||||
Mobile =
|
||||
case maps:find(<<"users">>, Sms) of
|
||||
@ -816,7 +769,7 @@ send_mode(#{<<"sms">> := #{<<"issend">> := <<"true">>, <<"params">> := Params, <
|
||||
|
||||
send_mode(#{<<"email">> := #{<<"issend">> := <<"true">>, <<"params">> := Params} = Email},
|
||||
ProductName,
|
||||
#{<<"roleid">> := NotifRoleid, <<"alarm_createdAt">> := Alarm_createdAt, <<"_deviceid">> := DeviceId, <<"_productid">> := ProductId, <<"dgiot_alarmkey">> := Key, <<"dgiot_alarmvalue">> := Value},
|
||||
#{<<"roleid">> := NotifRoleid, <<"alarm_createdAt">> := Alarm_createdAt, <<"alarm_message">> := Alarm_message, <<"_deviceid">> := DeviceId, <<"_productid">> := ProductId, <<"dgiot_alarmkey">> := Key, <<"dgiot_alarmvalue">> := Value},
|
||||
TriggerdeScription) when is_binary(Params) ->
|
||||
Subject = maps:get(<<"subject">>, Email, <<>>),
|
||||
Todes = maps:get(<<"todes">>, Email, <<>>),
|
||||
@ -826,10 +779,10 @@ send_mode(#{<<"email">> := #{<<"issend">> := <<"true">>, <<"params">> := Params}
|
||||
|
||||
Data = #{
|
||||
<<"to">> => Emails,
|
||||
<<"fromdes">> => replace_param(Fromdes, ProductName, ProductId, DeviceId, Key, Value, Alarm_createdAt, TriggerdeScription),
|
||||
<<"todes">> => replace_param(Todes, ProductName, ProductId, DeviceId, Key, Value, Alarm_createdAt, TriggerdeScription),
|
||||
<<"subject">> => replace_param(Subject, ProductName, ProductId, DeviceId, Key, Value, Alarm_createdAt, TriggerdeScription),
|
||||
<<"data">> => replace_param(Params, ProductName, ProductId, DeviceId, Key, Value, Alarm_createdAt, TriggerdeScription)
|
||||
<<"fromdes">> => replace_param(Fromdes, ProductName, ProductId, DeviceId, Key, Value, Alarm_createdAt, TriggerdeScription, Alarm_message),
|
||||
<<"todes">> => replace_param(Todes, ProductName, ProductId, DeviceId, Key, Value, Alarm_createdAt, TriggerdeScription, Alarm_message),
|
||||
<<"subject">> => replace_param(Subject, ProductName, ProductId, DeviceId, Key, Value, Alarm_createdAt, TriggerdeScription, Alarm_message),
|
||||
<<"data">> => replace_param(Params, ProductName, ProductId, DeviceId, Key, Value, Alarm_createdAt, TriggerdeScription, Alarm_message)
|
||||
},
|
||||
dgiot_notification:send_email(Data);
|
||||
|
||||
|
@ -501,88 +501,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/schema/{{className}}": {
|
||||
"get": {
|
||||
"summary": "获取{{tag}}表的权限级别和结构",
|
||||
"description": "获取{{tag}}表的权限级别和结构",
|
||||
"tags": [
|
||||
"{{className}}"
|
||||
],
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "获取成功"
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Error"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Error"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden"
|
||||
},
|
||||
"500": {
|
||||
"description": "Server Internal error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/level/{{className}}": {
|
||||
"put": {
|
||||
"summary": "设置{{tag}}表级别",
|
||||
"description": "设置{{tag}}表的级别",
|
||||
"tags": [
|
||||
"{{className}}"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
"name": "Permissions",
|
||||
"description": "表操作权限.",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ClassLevel"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "设置{{tag}}表成功"
|
||||
},
|
||||
"400": {
|
||||
"description": "服务器错误",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Error"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Error"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Forbidden"
|
||||
},
|
||||
"500": {
|
||||
"description": "Server Internal error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,13 +206,13 @@ do_request(post_login, #{<<"username">> := UserName, <<"password">> := Password}
|
||||
%% iot_hub 概要: 用户管理 描述: 用户管理
|
||||
%% OperationId:post_logout
|
||||
%% 请求:POST /iotapi/post_logout
|
||||
do_request(post_logout, #{<<"sessionToken">> := SessionToken}, _Context, _Req) ->
|
||||
do_request(post_logout, #{<<"sessionToken">> := SessionToken}, _Context, _Req) ->
|
||||
dgiot_auth:delete_session(SessionToken),
|
||||
SessionId = dgiot_parse_id:get_sessionId(SessionToken),
|
||||
dgiot_parse:del_object(<<"_Session">>, SessionId),
|
||||
dgiot_mqtt:unsubscribe_route_key(SessionToken),
|
||||
dgiot_parse_auth:del_usersession(SessionToken),
|
||||
dgiot_parse_auth:del_cookie(SessionToken);
|
||||
dgiot_parse_auth:del_cookie(SessionToken),
|
||||
dgiot_parse:del_object(<<"_Session">>, SessionId);
|
||||
|
||||
%% RoleUser 概要: 导库 描述:json文件导库
|
||||
%% OperationId:get_roleuser
|
||||
|
@ -45,7 +45,7 @@ check_parse(Tables, I) ->
|
||||
Acc
|
||||
end
|
||||
end,
|
||||
lists:foldl(Fun, dgiot_parse_utils:default_schemas(), Schemas);
|
||||
lists:foldl(Fun, #{}, Schemas);
|
||||
{error, Reason} ->
|
||||
{error, Reason}
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user