feat: merge yuhang

This commit is contained in:
dawnwinterLiu 2022-08-29 10:52:08 +08:00
parent b10cd2bfa6
commit 7f1d042028
3 changed files with 10 additions and 29 deletions

View File

@ -198,12 +198,10 @@
"example": "dasssd54"
},
"department": {
"required": true,
"type": "string",
"example": "部门"
},
"dailyWorksId": {
"required": true,
"type": "string",
"example": "每天工单编号"
},
@ -228,7 +226,6 @@
"example": "张三"
},
"workshop": {
"required": true,
"type": "string",
"example": "车间1-1"
},
@ -238,12 +235,10 @@
"example": "1"
},
"desc": {
"required": true,
"type": "string",
"example": "desc"
},
"file": {
"required": true,
"type": "string",
"example": "img"
}

View File

@ -128,7 +128,7 @@ do_request(post_sendsms_deviceid, #{<<"deviceid">> := DeviceId, <<"tplid">> := T
dgiot_notification:send_sms(Mobile, TplId, Params);
%
do_request(post_warnsendsms, #{<<"objectId">> := DeviceId, <<"department">> := Department, <<"dailyWorksId">> := DailyWorksId, <<"branchId">> := BranchId, <<"datetimes">> := DateTimes, <<"docnumber">> := Docnumber, <<"username">> := UserName, <<"workshop">> := Workshop, <<"level">> := Level, <<"desc">> := Desc, <<"file">> := FileInfo}, _Context, _Req) ->
do_request(post_warnsendsms, #{<<"objectId">> := DeviceId, <<"branchId">> := BranchId, <<"datetimes">> := DateTimes, <<"docnumber">> := Docnumber, <<"username">> := UserName, <<"workshop">> := Workshop, <<"level">> := Level} = _Args, _Context, _Req) ->
case Level of
<<"1">> ->
Warn = <<"待首检"/utf8>>,
@ -137,8 +137,7 @@ do_request(post_warnsendsms, #{<<"objectId">> := DeviceId, <<"department">> := D
Warn = <<"待尾检"/utf8>>,
dgiot_parse:update_object(<<"Device">>, DeviceId, #{<<"realstatus">> => 5});
_ ->
Warn = <<"告警"/utf8>>,
{error, #{code => 1, error => ("level错误")}}
Warn = <<"告警"/utf8>>
end,
Warns = Warn,
case dgiot_parse:get_object(<<"_Role">>, BranchId) of
@ -146,38 +145,25 @@ do_request(post_warnsendsms, #{<<"objectId">> := DeviceId, <<"department">> := D
Map = #{
<<"type">> => DeviceId,
<<"name">> => <<"Manual alarm">>,
<<"name">> => Workshop,
<<"status">> => 0,
<<"content">> => #{
<<"alarm">> => #{
<<"deviceId"/utf8>> => DeviceId,
<<"department"/utf8>> => Department,
<<"dailyWorksId"/utf8>> => DailyWorksId,
<<"docnumber"/utf8>> => Docnumber,
<<"datetimes"/utf8>> => DateTimes,
<<"username"/utf8>> => UserName,
<<"workshop"/utf8>> => Workshop,
<<"level"/utf8>> => Level,
<<"desc"/utf8>> => Desc,
<<"imgurl"/utf8>> => FileInfo
},
<<"alarm">> => _Args#{<<"deviceId">> => DeviceId},
<<"alertstatus">> => 1
},
<<"ACL">> => Acl
},
#{<<"objectId">> := ObjectId} = dgiot_parse_id:get_objectid(<<"Notification">>, Map),
NewMap = Map#{
<<"objectId">> => ObjectId
},
dgiot_parse:create_object(<<"Notification">>, NewMap),
dgiot_parse:create_object(<<"Notification">>, Map),
%
Users = dgiot_parse_auth:get_UserIds(unicode:characters_to_binary(RolesId)),
UsersQuery = #{<<"where">> => #{<<"objectId">> => #{<<"$in">> => Users}}},
{ok, #{<<"results">> := Row}} = dgiot_parse:query_object(<<"_User">>, UsersQuery),
PhoneList = lists:foldl(fun(X, Acc) ->
Phone = unicode:characters_to_binary(dgiot_utils:to_list(maps:get(<<"phone">>, X))),
Data = dgiot_notification:send_sms(Phone, <<"">>, [DateTimes, <<"-">>, UserName, Docnumber, Workshop, Warns]),
Acc ++ [Data]
dgiot_notification:send_sms("+86", Phone, "1473069",
[DateTimes, <<"-">>, UserName, Docnumber, Workshop, Warns],
"1400635630", "40d9609b9e6212cbff051b4f1d4cabfc", <<"质云科技"/utf8>>),
Acc ++ [Phone]
end, [], Row),
% {1} {2}{3}{4}{5},:{6}
Json = #{<<"phones">> => PhoneList},

View File

@ -6,7 +6,7 @@ parse.delete_field = ACL,objectId,updatedAt,createdAt
##--------------------------------------------------------------------
## parse config
##--------------------------------------------------------------------
parse.parse_server = http://127.0.0.1:1337
parse.parse_server = http://prod.dgiotcloud.cn:1337
parse.timescale_server = http://127.0.0.1:1338
parse.parse_path = /parse/
parse.parse_appid = d3300b6f53d7ee7da766142f2f7050eb