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 4b57722b
authored
Apr 29, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]红外修改
1 parent
1a03e9d3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
21 deletions
src/main/java/com/glsx/smart/pojo/ExecuteTaskVo.java
src/main/java/com/glsx/smart/service/impl/SmartSceneServiceImpl.java
src/main/java/com/glsx/smart/pojo/ExecuteTaskVo.java
View file @
4b57722
...
@@ -2,6 +2,7 @@ package com.glsx.smart.pojo;
...
@@ -2,6 +2,7 @@ package com.glsx.smart.pojo;
import
com.alibaba.nacos.common.utils.MD5Utils
;
import
com.alibaba.nacos.common.utils.MD5Utils
;
import
lombok.Data
;
import
lombok.Data
;
import
scala.Byte
;
import
sun.security.provider.MD5
;
import
sun.security.provider.MD5
;
/**
/**
...
@@ -20,6 +21,6 @@ public class ExecuteTaskVo {
...
@@ -20,6 +21,6 @@ public class ExecuteTaskVo {
private
String
msg
;
private
String
msg
;
private
String
phone
;
private
String
phone
;
private
String
channel
=
"1"
;
private
int
channel
=
1
;
}
}
src/main/java/com/glsx/smart/service/impl/SmartSceneServiceImpl.java
View file @
4b57722
...
@@ -215,12 +215,11 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
...
@@ -215,12 +215,11 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
continue
;
continue
;
}
}
Map
<
String
,
Object
>
objectMap
=
buildOrderIssueParam
(
executeTaskVo
,
order_value
);
Map
<
String
,
Object
>
objectMap
=
buildOrderIssueParam
(
executeTaskVo
,
order_value
);
jsonObject
=
HttpUtil
.
sendPost
(
orderIssueurl
.
replace
(
"{device_id}"
,
executeTaskVo
.
getChannel
().
equals
(
Constants
.
USER_CHANNEL_TUYA
)?
devideId:
executeTaskVo
.
getPhone
()).
replace
(
"{resource}"
,
executeTaskVo
.
getChannel
())
,
JSONObject
.
toJSONString
(
objectMap
),
new
HashMap
<>());
jsonObject
=
HttpUtil
.
sendPost
(
orderIssueurl
,
JSONObject
.
toJSONString
(
objectMap
),
new
HashMap
<>());
}
else
{
}
else
{
// 下发红外遥控指令
// 下发红外遥控指令
Map
<
String
,
Object
>
ordermap
=
new
HashMap
<>();
Map
<
String
,
Object
>
objectMap
=
buildOrderIssueInfParam
(
executeTaskVo
);
ordermap
.
put
(
"key"
,
executeTaskVo
.
getOrderVal
());
jsonObject
=
HttpUtil
.
sendPost
(
instructionInfIssue
,
JSONObject
.
toJSONString
(
objectMap
),
new
HashMap
<>());
jsonObject
=
HttpUtil
.
sendPost
(
instructionInfIssue
.
replace
(
"{remote_id}"
,
remoteId
).
replace
(
"{infrared_id}"
,
devideId
),
JSONObject
.
toJSONString
(
ordermap
),
new
HashMap
<>());
}
}
if
(
jsonObject
!=
null
)
{
if
(
jsonObject
!=
null
)
{
ResponseVo
responseVo
=
JSONObject
.
toJavaObject
(
jsonObject
,
ResponseVo
.
class
);
ResponseVo
responseVo
=
JSONObject
.
toJavaObject
(
jsonObject
,
ResponseVo
.
class
);
...
@@ -255,26 +254,68 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
...
@@ -255,26 +254,68 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
return
orderResponseList
;
return
orderResponseList
;
}
}
/**
* 构建红外指令下发
*
* @param executeTaskVo
* @return
*/
private
Map
<
String
,
Object
>
buildOrderIssueInfParam
(
ExecuteTaskVo
executeTaskVo
)
{
int
channel
=
executeTaskVo
.
getChannel
();
Map
<
String
,
Object
>
requestMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
datamap
=
new
HashMap
<>();
if
(
channel
==
Constants
.
USER_CHANNEL_TUYA
)
{
datamap
.
put
(
"key"
,
executeTaskVo
.
getOrderVal
());
requestMap
.
put
(
"data"
,
datamap
);
requestMap
.
put
(
"channel"
,
executeTaskVo
.
getChannel
());
requestMap
.
put
(
"deviceId"
,
executeTaskVo
.
getSelect
());
requestMap
.
put
(
"remoteId"
,
executeTaskVo
.
getRemoteId
());
log
.
info
(
"涂鸦发送的红外指令{}"
,
JSON
.
toJSONString
(
requestMap
));
}
else
if
(
channel
==
Constants
.
USER_CHANNEL_AQARA
){
datamap
.
put
(
"keyId"
,
executeTaskVo
.
getOrderVal
());
datamap
.
put
(
"acKey"
,
executeTaskVo
.
getOrderVal
());
datamap
.
put
(
"did"
,
executeTaskVo
.
getRemoteId
());
requestMap
.
put
(
"data"
,
datamap
);
requestMap
.
put
(
"channel"
,
executeTaskVo
.
getChannel
());
requestMap
.
put
(
"phone"
,
executeTaskVo
.
getPhone
());
log
.
info
(
"aqara发送的红外指令{}"
,
JSON
.
toJSONString
(
requestMap
));
}
return
requestMap
;
}
/**
* 构建设备指令下发参数
*
* @param executeTaskVo
* @param order_value
* @return
*/
private
Map
<
String
,
Object
>
buildOrderIssueParam
(
ExecuteTaskVo
executeTaskVo
,
String
order_value
)
{
private
Map
<
String
,
Object
>
buildOrderIssueParam
(
ExecuteTaskVo
executeTaskVo
,
String
order_value
)
{
String
channel
=
executeTaskVo
.
getChannel
();
Map
<
String
,
Object
>
mapMap
=
new
HashMap
<>();
String
valueType
=
executeTaskVo
.
getValue
();
int
channel
=
executeTaskVo
.
getChannel
();
String
valueType
=
executeTaskVo
.
getValType
();
Map
<
String
,
Object
>
ordermaps
=
new
HashMap
<>();
Map
<
String
,
Object
>
ordermaps
=
new
HashMap
<>();
List
<
Map
<
String
,
Object
>>
maps
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
maps
=
new
ArrayList
<>();
Map
<
String
,
Object
>
ordermap
=
new
HashMap
<>();
Map
<
String
,
Object
>
ordermap
=
new
HashMap
<>();
if
(
channel
.
equals
(
Constants
.
USER_CHANNEL_TUYA
)
)
{
if
(
channel
==
Constants
.
USER_CHANNEL_TUYA
)
{
ordermap
.
put
(
"code"
,
executeTaskVo
.
getOrder
());
ordermap
.
put
(
"code"
,
executeTaskVo
.
getOrder
());
ordermap
.
put
(
"value"
,
revertType
(
valueType
,
order_value
));
ordermap
.
put
(
"value"
,
revertType
(
valueType
,
order_value
));
maps
.
add
(
ordermap
);
maps
.
add
(
ordermap
);
ordermaps
.
put
(
"commands"
,
maps
);
ordermaps
.
put
(
"commands"
,
maps
);
log
.
info
(
"涂鸦发送的指令{}"
,
JSON
.
toJSONString
(
maps
));
mapMap
.
put
(
"data"
,
ordermaps
);
}
else
if
(
channel
.
equals
(
Constants
.
USER_CHANNEL_AQARA
)){
mapMap
.
put
(
"channel"
,
executeTaskVo
.
getChannel
());
ordermap
.
put
(
executeTaskVo
.
getOrder
(),
revertType
(
valueType
,
order_value
));
mapMap
.
put
(
"deviceId"
,
executeTaskVo
.
getSelect
());
maps
.
add
(
ordermap
);
log
.
info
(
"涂鸦发送的指令{}"
,
JSON
.
toJSONString
(
mapMap
));
ordermaps
.
put
(
"attrs"
,
maps
);
}
else
if
(
channel
==
Constants
.
USER_CHANNEL_AQARA
)
{
ordermap
.
put
(
executeTaskVo
.
getOrder
(),
revertType
(
valueType
,
order_value
));
ordermaps
.
put
(
"attrs"
,
ordermap
);
ordermaps
.
put
(
"did"
,
executeTaskVo
.
getSelect
());
ordermaps
.
put
(
"did"
,
executeTaskVo
.
getSelect
());
log
.
info
(
"aqara发送的指令{}"
,
JSON
.
toJSONString
(
ordermaps
));
mapMap
.
put
(
"data"
,
ordermaps
);
mapMap
.
put
(
"phone"
,
executeTaskVo
.
getPhone
());
mapMap
.
put
(
"channel"
,
executeTaskVo
.
getChannel
());
log
.
info
(
"aqara发送的指令{}"
,
JSON
.
toJSONString
(
mapMap
));
}
}
return
ordermaps
;
return
mapMap
;
}
}
/**
/**
...
@@ -288,18 +329,18 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
...
@@ -288,18 +329,18 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
Map
<
String
,
Object
>
map
=
sceneMapper
.
getBySourceAndUserId
(
scene
.
getId
());
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
<>();
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
String
source
=
map
.
get
(
"source"
)
+
""
;
String
source
=
map
.
get
(
"source"
)
+
""
;
paramMap
.
put
(
"alias"
,
user_id
);
paramMap
.
put
(
"alias"
,
user_id
);
paramMap
.
put
(
"deviceType"
,
map
.
get
(
"source"
)
+
""
);
paramMap
.
put
(
"deviceType"
,
map
.
get
(
"source"
)
+
""
);
paramMap
.
put
(
"title"
,
title
);
paramMap
.
put
(
"title"
,
title
);
paramMap
.
put
(
"body"
,
msg
);
paramMap
.
put
(
"body"
,
msg
);
paramMap
.
put
(
"msgBody"
,
msg
);
paramMap
.
put
(
"msgBody"
,
msg
);
saveMegInfo
(
user_id
,
title
,
msg
);
saveMegInfo
(
user_id
,
title
,
msg
);
if
(
StringUtils
.
isEmpty
(
source
))
{
if
(
StringUtils
.
isEmpty
(
source
))
{
return
;
return
;
}
}
try
{
try
{
log
.
info
(
"通知入参{}"
,
JSONObject
.
toJSONString
(
paramMap
));
log
.
info
(
"通知入参{}"
,
JSONObject
.
toJSONString
(
paramMap
));
JSONObject
jsonObject
=
HttpUtil
.
sendPost
(
infoUrl
,
JSONObject
.
toJSONString
(
paramMap
),
new
HashMap
<>());
JSONObject
jsonObject
=
HttpUtil
.
sendPost
(
infoUrl
,
JSONObject
.
toJSONString
(
paramMap
),
new
HashMap
<>());
if
(
jsonObject
!=
null
)
{
if
(
jsonObject
!=
null
)
{
String
code
=
jsonObject
.
get
(
"code"
)
+
""
;
String
code
=
jsonObject
.
get
(
"code"
)
+
""
;
...
@@ -361,10 +402,10 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
...
@@ -361,10 +402,10 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
content
=
MessageFormat
.
format
(
"您配置的{0}场景未顺利执行,点击可查看详情。"
,
scene_name
);
content
=
MessageFormat
.
format
(
"您配置的{0}场景未顺利执行,点击可查看详情。"
,
scene_name
);
}
}
paramMap
.
put
(
"body"
,
content
);
paramMap
.
put
(
"body"
,
content
);
String
context
=
buildBody
(
collect
,
scene_name
);
String
context
=
buildBody
(
collect
,
scene_name
);
paramMap
.
put
(
"msgBody"
,
context
);
paramMap
.
put
(
"msgBody"
,
context
);
saveMegInfo
(
user_id
,
title
,
context
);
saveMegInfo
(
user_id
,
title
,
context
);
if
(
StringUtils
.
isEmpty
(
source
))
{
if
(
StringUtils
.
isEmpty
(
source
))
{
return
;
return
;
}
}
try
{
try
{
...
@@ -379,7 +420,7 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
...
@@ -379,7 +420,7 @@ public class SmartSceneServiceImpl extends BaseService implements SmartSceneServ
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
log
.
info
(
"下发通知异常{}"
,
e
);
log
.
info
(
"下发通知异常{}"
,
e
);
}
}
}
}
}
}
...
...
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