Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ee5b9ba6
authored
Apr 16, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]产品名称修改
1 parent
7d09c0b4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
35 deletions
src/main/java/com/glsx/smart/service/impl/SmartSceneServiceImpl.java
src/main/java/com/glsx/smart/service/impl/SmartSceneServiceImpl.java
View file @
ee5b9ba
...
...
@@ -214,14 +214,14 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
if
(
StringUtils
.
isBlank
(
remoteId
))
{
// 如果设备状态已经是设置的,不重复下发
String
order_value
=
executeTaskVo
.
getOrderVal
()
==
null
?
executeTaskVo
.
getValue
()
:
executeTaskVo
.
getOrderVal
();
SmartDeviceStatus
smartDevideStatus
=
smartDeviceStatusMapper
.
findDevStatusByIdAndCode
(
devideId
,
executeTaskVo
.
getOrder
());
if
(
smartDevideStatus
!=
null
&&
smartDevideStatus
.
getDeviceOrderValue
().
equals
(
order_value
))
{
log
.
info
(
"该设备已经设置成当前需要的状态,设备id{}"
,
devideId
);
SmartDeviceStatus
smartDevideStatus
=
smartDeviceStatusMapper
.
findDevStatusByIdAndCode
(
devideId
,
executeTaskVo
.
getOrder
());
if
(
smartDevideStatus
!=
null
&&
smartDevideStatus
.
getDeviceOrderValue
().
equals
(
order_value
))
{
log
.
info
(
"该设备已经设置成当前需要的状态,设备id{}"
,
devideId
);
continue
;
}
String
valueType
=
executeTaskVo
.
getValType
();
ordermap
.
put
(
"code"
,
executeTaskVo
.
getOrder
());
ordermap
.
put
(
"value"
,
revertType
(
valueType
,
order_value
));
ordermap
.
put
(
"value"
,
revertType
(
valueType
,
order_value
));
maps
.
add
(
ordermap
);
ordermaps
.
put
(
"commands"
,
maps
);
log
.
info
(
"发送的指令{}"
,
JSON
.
toJSONString
(
maps
));
...
...
@@ -256,15 +256,12 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
// 下发推送通知(Android设备和ios设备)
issueNotice
(
scene
,
orderResponseList
);
// 下发系统消息
List
<
OrderResponse
>
collect
=
orderResponseList
.
stream
().
filter
(
index
->
!
index
.
isResult
()).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
orderResponseList
)||
CollectionUtils
.
isEmpty
(
collect
))
{
List
<
SmartSceneData
>
scene_content_system
=
smartTemplateParamList
.
stream
().
filter
(
index
->
index
.
getParamKey
().
equals
(
"scene_content_system"
)).
collect
(
Collectors
.
toList
());
scene_content_system
.
forEach
(
index
->
{
String
paramValue
=
index
.
getParamValue
();
ExecuteTaskVo
executeTaskVo
=
JSONObject
.
parseObject
(
paramValue
,
ExecuteTaskVo
.
class
);
issueSystemNotice
(
scene
,
executeTaskVo
.
getMsg
());
});
}
List
<
SmartSceneData
>
scene_content_system
=
smartTemplateParamList
.
stream
().
filter
(
index
->
index
.
getParamKey
().
equals
(
"scene_content_system"
)).
collect
(
Collectors
.
toList
());
scene_content_system
.
forEach
(
index
->
{
String
paramValue
=
index
.
getParamValue
();
ExecuteTaskVo
executeTaskVo
=
JSONObject
.
parseObject
(
paramValue
,
ExecuteTaskVo
.
class
);
issueSystemNotice
(
scene
,
executeTaskVo
.
getMsg
());
});
return
orderResponseList
;
}
...
...
@@ -272,15 +269,15 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
* 下发系统通知
*
* @param scene 场景
* @param msg 信息
* @param msg
信息
*/
private
void
issueSystemNotice
(
SmartScene
scene
,
String
msg
)
{
String
title
=
"收到一条智能消息"
;
Map
<
String
,
Object
>
map
=
sceneMapper
.
getBySourceAndUserId
(
scene
.
getId
());
String
user_id
=
map
.
get
(
"user_id"
)
+
""
;
String
user_id
=
map
.
get
(
"user_id"
)
+
""
;
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"alias"
,
user_id
);
paramMap
.
put
(
"deviceType"
,
map
.
get
(
"source"
)
+
""
);
paramMap
.
put
(
"deviceType"
,
map
.
get
(
"source"
)
+
""
);
paramMap
.
put
(
"title"
,
title
);
paramMap
.
put
(
"body"
,
msg
);
paramMap
.
put
(
"msgBody"
,
msg
);
...
...
@@ -304,11 +301,11 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
* 保存消息通知
*
* @param user_id 用户id
* @param title 标题
* @param msg 消息
* @param title
标题
* @param msg
消息
*/
private
void
saveMegInfo
(
String
user_id
,
String
title
,
String
msg
)
{
CarAssistantInfo
carAssistantInfo
=
new
CarAssistantInfo
();
CarAssistantInfo
carAssistantInfo
=
new
CarAssistantInfo
();
carAssistantInfo
.
setUserId
(
Integer
.
parseInt
(
user_id
));
carAssistantInfo
.
setCreateBy
(
Integer
.
parseInt
(
user_id
));
carAssistantInfo
.
setContent
(
msg
);
...
...
@@ -328,19 +325,19 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
String
content
=
""
;
String
title
=
"收到一条智能消息"
;
Map
<
String
,
Object
>
map
=
sceneMapper
.
getBySourceAndUserId
(
scene
.
getId
());
String
user_id
=
map
.
get
(
"user_id"
)
+
""
;
String
scene_name
=
map
.
get
(
"scene_name"
)
+
""
;
String
user_id
=
map
.
get
(
"user_id"
)
+
""
;
String
scene_name
=
map
.
get
(
"scene_name"
)
+
""
;
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"alias"
,
user_id
);
paramMap
.
put
(
"deviceType"
,
map
.
get
(
"source"
)
+
""
);
paramMap
.
put
(
"deviceType"
,
map
.
get
(
"source"
)
+
""
);
paramMap
.
put
(
"title"
,
title
);
List
<
OrderResponse
>
collect
=
orderResponseList
.
stream
().
filter
(
index
->
!
index
.
isResult
()).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
collect
))
{
content
=
MessageFormat
.
format
(
"您配置的{0}场景已执行,点击可查看详情。"
,
scene_name
);
}
else
{
boolean
flag
=
repeatNotification
(
scene
.
getId
());
if
(
flag
)
{
log
.
info
(
"场景下发不成功,不允许持续发消息,场景id{}"
,
scene
.
getId
());
boolean
flag
=
repeatNotification
(
scene
.
getId
());
if
(
flag
)
{
log
.
info
(
"场景下发不成功,不允许持续发消息,场景id{}"
,
scene
.
getId
());
return
;
}
content
=
MessageFormat
.
format
(
"您配置的{0}场景未顺利执行,点击可查看详情。"
,
scene_name
);
...
...
@@ -348,7 +345,7 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
paramMap
.
put
(
"body"
,
content
);
String
context
=
buildBody
(
user_id
,
title
,
collect
,
scene
.
getId
(),
scene_name
);
paramMap
.
put
(
"msgBody"
,
context
);
saveMegInfo
(
user_id
,
title
,
context
);
saveMegInfo
(
user_id
,
title
,
context
);
try
{
JSONObject
jsonObject
=
HttpUtil
.
sendPost
(
infoUrl
,
JSONObject
.
toJSONString
(
paramMap
),
new
HashMap
<>());
if
(
jsonObject
!=
null
)
{
...
...
@@ -366,13 +363,13 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
}
private
boolean
repeatNotification
(
Long
id
)
{
String
key
=
"senceId_"
+
id
;
String
key
=
"senceId_"
+
id
;
Object
o
=
redisService
.
get
(
key
);
log
.
info
(
"{}从redis查询出来的数据为{}"
,
key
,
o
);
if
(
o
==
null
)
{
redisService
.
setOutTime
(
key
,
key
,
infotimeout
,
TimeUnit
.
MINUTES
);
log
.
info
(
"{}从redis查询出来的数据为{}"
,
key
,
o
);
if
(
o
==
null
)
{
redisService
.
setOutTime
(
key
,
key
,
infotimeout
,
TimeUnit
.
MINUTES
);
return
false
;
}
else
{
}
else
{
return
true
;
}
}
...
...
@@ -390,15 +387,15 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
String
context
=
""
;
if
(
CollectionUtils
.
isEmpty
(
orderResponseList
))
{
context
=
MessageFormat
.
format
(
"您配置的{0}场景已在{1} 成功执行"
,
scene_name
,
new
Date
());
}
else
{
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
orderResponseList
.
size
();
i
++)
{
}
else
{
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
orderResponseList
.
size
();
i
++)
{
OrderResponse
orderResponse
=
orderResponseList
.
get
(
i
);
String
deviceName
=
orderResponse
.
getDeviceName
();
String
message
=
orderResponse
.
getMessage
();
sb
.
append
(
deviceName
).
append
(
message
).
append
(
","
);
}
context
=
MessageFormat
.
format
(
"您配置的{0}场景已在{1}触发执行,但因以下设备{2}未能执行成功,请关注以上设备状态"
,
scene_name
,
new
Date
(),
sb
.
toString
().
substring
(
0
,
sb
.
toString
().
length
()-
1
));
context
=
MessageFormat
.
format
(
"您配置的{0}场景已在{1}触发执行,但因以下设备{2}未能执行成功,请关注以上设备状态"
,
scene_name
,
new
Date
(),
sb
.
toString
().
substring
(
0
,
sb
.
toString
().
length
()
-
1
));
}
return
context
;
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment