Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
glinfo-api
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
林业通
glinfo-api
Commits
4a67f458
提交
4a67f458
authored
2月 23, 2022
作者:
林业通
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
红外遥控
上级
2342f7dd
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
111 行增加
和
1 行删除
+111
-1
InfraredControlController.java
...odules/infrared/controller/InfraredControlController.java
+109
-0
MqConsumer.java
...rc/main/java/tech/glinfo/enbao/modules/mq/MqConsumer.java
+2
-1
没有找到文件。
appapi/src/main/java/tech/glinfo/enbao/modules/infrared/controller/InfraredControlController.java
浏览文件 @
4a67f458
package
tech
.
glinfo
.
enbao
.
modules
.
infrared
.
controller
;
package
tech
.
glinfo
.
enbao
.
modules
.
infrared
.
controller
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
...
@@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
...
@@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
import
tech.glinfo.enbao.common.annotation.ApiLog
;
import
tech.glinfo.enbao.common.annotation.ApiLog
;
import
tech.glinfo.enbao.common.annotation.Login
;
import
tech.glinfo.enbao.common.annotation.Login
;
import
tech.glinfo.enbao.common.annotation.LoginUser
;
import
tech.glinfo.enbao.common.annotation.LoginUser
;
import
tech.glinfo.enbao.common.utils.ByteUtils
;
import
tech.glinfo.enbao.common.utils.MapUtils
;
import
tech.glinfo.enbao.common.utils.MapUtils
;
import
tech.glinfo.enbao.common.utils.R
;
import
tech.glinfo.enbao.common.utils.R
;
import
tech.glinfo.enbao.common.utils.StringUtils
;
import
tech.glinfo.enbao.common.utils.StringUtils
;
...
@@ -19,8 +21,15 @@ import tech.glinfo.enbao.modules.appuser.entity.AppUserEntity;
...
@@ -19,8 +21,15 @@ import tech.glinfo.enbao.modules.appuser.entity.AppUserEntity;
import
tech.glinfo.enbao.modules.infrared.entity.InfraredControlEntity
;
import
tech.glinfo.enbao.modules.infrared.entity.InfraredControlEntity
;
import
tech.glinfo.enbao.modules.infrared.form.InfraredControlForm
;
import
tech.glinfo.enbao.modules.infrared.form.InfraredControlForm
;
import
tech.glinfo.enbao.modules.infrared.service.OtherInfraredControlService
;
import
tech.glinfo.enbao.modules.infrared.service.OtherInfraredControlService
;
import
tech.glinfo.enbao.modules.infrared.util.ProtocolUtil
;
import
tech.glinfo.enbao.modules.mq.MqProducer
;
import
tech.glinfo.enbao.modules.sh.entity.ShDeviceEntity
;
import
tech.glinfo.enbao.modules.sh.form.ProtocolContent
;
import
tech.glinfo.enbao.modules.sh.service.ShDeviceService
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -41,6 +50,48 @@ public class InfraredControlController {
...
@@ -41,6 +50,48 @@ public class InfraredControlController {
@Autowired
@Autowired
private
OtherInfraredControlService
otherInfraredControlService
;
private
OtherInfraredControlService
otherInfraredControlService
;
@Autowired
private
ShDeviceService
shDeviceService
;
@Autowired
private
MqProducer
mqProducer
;
private
static
Map
<
String
,
String
>
temp
=
new
HashMap
<>();
static
{
temp
.
put
(
"17"
,
"0000"
);
temp
.
put
(
"18"
,
"0001"
);
temp
.
put
(
"19"
,
"0011"
);
temp
.
put
(
"20"
,
"0010"
);
temp
.
put
(
"21"
,
"0110"
);
temp
.
put
(
"22"
,
"0111"
);
temp
.
put
(
"23"
,
"0101"
);
temp
.
put
(
"24"
,
"0100"
);
temp
.
put
(
"25"
,
"1100"
);
temp
.
put
(
"26"
,
"1101"
);
temp
.
put
(
"27"
,
"1001"
);
temp
.
put
(
"28"
,
"1000"
);
temp
.
put
(
"29"
,
"1010"
);
temp
.
put
(
"30"
,
"1011"
);
}
private
static
Map
<
String
,
String
>
model
=
new
HashMap
<>();
static
{
model
.
put
(
"自动"
,
"10"
);
model
.
put
(
"制冷"
,
"00"
);
model
.
put
(
"抽湿"
,
"01"
);
model
.
put
(
"制热"
,
"11"
);
model
.
put
(
"送风"
,
"01"
);
}
private
static
Map
<
String
,
String
>
wind
=
new
HashMap
<>();
static
{
wind
.
put
(
"自动"
,
"101"
);
wind
.
put
(
"低风"
,
"100"
);
wind
.
put
(
"中风"
,
"010"
);
wind
.
put
(
"高风"
,
"001"
);
wind
.
put
(
"固定风"
,
"000"
);
}
@Login
@Login
@GetMapping
(
"list"
)
@GetMapping
(
"list"
)
@ApiOperation
(
"查询用户遥控器"
)
@ApiOperation
(
"查询用户遥控器"
)
...
@@ -128,4 +179,62 @@ public class InfraredControlController {
...
@@ -128,4 +179,62 @@ public class InfraredControlController {
return
otherInfraredControlService
.
removeById
(
id
)?
R
.
ok
()
:
R
.
error
(
"删除失败"
);
return
otherInfraredControlService
.
removeById
(
id
)?
R
.
ok
()
:
R
.
error
(
"删除失败"
);
}
}
@Login
@PostMapping
(
"controllerT"
)
public
R
controllerT
(
@RequestBody
Map
<
String
,
Object
>
params
)
{
String
frequency
=
(
String
)
params
.
get
(
"frequency"
);
//频率
String
datas
=
(
String
)
params
.
get
(
"datas"
);
//数据
Integer
deviceId
=
(
Integer
)
params
.
get
(
"deviceId"
);
//设备Id
if
(
StringUtils
.
isBlank
(
frequency
,
datas
,
deviceId
))
{
return
R
.
error
(
"缺少参数"
);
}
ShDeviceEntity
device
=
shDeviceService
.
getById
(
deviceId
);
if
(
device
==
null
)
{
return
R
.
error
(
"设备不存在,请核实!"
);
}
if
(
device
.
getOnlineStatus
()
!=
2
)
{
return
R
.
error
(
"设备离线,无法发送!"
);
}
//转换
StringBuffer
sb
=
new
StringBuffer
();
StringBuffer
sb1
=
new
StringBuffer
();
String
[]
codes
=
datas
.
split
(
","
);
ProtocolContent
protocol
=
new
ProtocolContent
();
protocol
.
setReceiveId
(
device
.
getNumbering
());
protocol
.
setDeviceType
(
"02"
);
logger
.
info
(
"######数据长度:{}"
,
codes
.
length
);
if
(
codes
.
length
>
300
)
{
//大于300需要走压缩
String
cmds
=
ProtocolUtil
.
getCmds
(
codes
,
frequency
);
logger
.
info
(
"压缩后的数据:{}"
,
cmds
);
protocol
.
setCmd
(
"1B"
);
protocol
.
setContent
(
cmds
);
}
else
{
protocol
.
setCmd
(
"19"
);
for
(
String
in
:
codes
)
{
sb1
.
append
(
in
).
append
(
","
);
sb
.
append
(
ByteUtils
.
int2Hex
(
Integer
.
valueOf
(
in
),
4
));
}
logger
.
info
(
sb1
.
toString
());
logger
.
info
(
sb
.
toString
());
String
content
=
StringUtils
.
appendString
(
sb
.
toString
(),
1200
,
false
,
"0"
);
logger
.
info
(
content
);
// InfraredControlCodeEntity controlCodeEntity = infraredControlCodeService.getOne(new QueryWrapper<InfraredControlCodeEntity>().eq("brand_id", controlUserEntity.getBrandId()).eq("remark", name).last("LIMIT 1"));
// if (controlCodeEntity != null) {
StringBuffer
body
=
new
StringBuffer
();
body
.
append
(
StringUtils
.
appendString
(
ByteUtils
.
int2Hex
(
Integer
.
valueOf
(
frequency
)),
4
,
true
,
"0"
));
body
.
append
(
StringUtils
.
appendString
(
ByteUtils
.
int2Hex
((
sb
.
length
()/
2
)),
4
,
true
,
"0"
));
body
.
append
(
content
);
protocol
.
setContent
(
body
.
toString
());
}
mqProducer
.
sendT
(
JSON
.
toJSONString
(
protocol
));
return
R
.
ok
();
}
}
}
appapi/src/main/java/tech/glinfo/enbao/modules/mq/MqConsumer.java
浏览文件 @
4a67f458
...
@@ -131,6 +131,7 @@ public class MqConsumer {
...
@@ -131,6 +131,7 @@ public class MqConsumer {
logger
.
error
(
"设备不存在 : {}"
,
datas
.
get
(
"receiveId"
));
logger
.
error
(
"设备不存在 : {}"
,
datas
.
get
(
"receiveId"
));
return
;
return
;
}
}
if
(
device
.
getOnlineStatus
()
==
1
||
device
.
getOnlineStatus
()
==
3
)
{
//更新设备状态为在线
//更新设备状态为在线
new
Thread
(()
->
{
new
Thread
(()
->
{
ShDeviceEntity
deviceEntity
=
new
ShDeviceEntity
();
ShDeviceEntity
deviceEntity
=
new
ShDeviceEntity
();
...
@@ -139,7 +140,7 @@ public class MqConsumer {
...
@@ -139,7 +140,7 @@ public class MqConsumer {
deviceEntity
.
setOnlineTime
(
new
Date
());
deviceEntity
.
setOnlineTime
(
new
Date
());
otherShDeviceService
.
updateById
(
deviceEntity
);
otherShDeviceService
.
updateById
(
deviceEntity
);
}).
start
();
}).
start
();
}
String
sendMessage
=
null
;
String
sendMessage
=
null
;
Map
<
String
,
String
>
ws
=
null
;
Map
<
String
,
String
>
ws
=
null
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论