Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄嘉阳
/
iot-platform-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7206b73a
authored
Nov 10, 2023
by
huangjy
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
parents
948c25e5
13275c8e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
274 additions
and
1 deletions
pom.xml
server-common/pom.xml
server-common/src/main/java/com/makeit/utils/msg/config/WxConfig.java
server-common/src/main/java/com/makeit/utils/msg/sender/WxSpSender.java
server-web/src/main/java/com/makeit/mqtt/TestAlarmRecordController.java
server-web/src/main/resources/application-dev.yml
server-web/src/main/resources/application-test.yml
pom.xml
View file @
7206b73a
...
...
@@ -222,6 +222,13 @@
<version>
${weixin-java.version}
</version>
</dependency>
<dependency>
<groupId>
com.github.binarywang
</groupId>
<artifactId>
weixin-java-mp
</artifactId>
<version>
${weixin-java.version}
</version>
</dependency>
<!--工作流模块使用-->
<dependency>
<groupId>
com.alibaba.fastjson2
</groupId>
...
...
server-common/pom.xml
View file @
7206b73a
...
...
@@ -173,6 +173,12 @@
<artifactId>
weixin-java-miniapp
</artifactId>
</dependency>
<!--微信公众号-->
<dependency>
<groupId>
com.github.binarywang
</groupId>
<artifactId>
weixin-java-mp
</artifactId>
</dependency>
</dependencies>
<profiles>
...
...
server-common/src/main/java/com/makeit/utils/msg/config/WxConfig.java
0 → 100644
View file @
7206b73a
package
com
.
makeit
.
utils
.
msg
.
config
;
import
cn.binarywang.wx.miniapp.api.WxMaService
;
import
cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl
;
import
cn.binarywang.wx.miniapp.config.WxMaConfig
;
import
cn.binarywang.wx.miniapp.config.impl.WxMaRedissonConfigImpl
;
import
me.chanjar.weixin.mp.api.WxMpService
;
import
me.chanjar.weixin.mp.api.impl.WxMpServiceImpl
;
import
me.chanjar.weixin.mp.config.WxMpConfigStorage
;
import
me.chanjar.weixin.mp.config.impl.WxMpRedissonConfigImpl
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
WxConfig
{
@Value
(
"${wx.miniapp.config.appid}"
)
private
String
appId
;
@Value
(
"${wx.miniapp.config.secret}"
)
private
String
appSecret
;
@Value
(
"${wx.mp.config.appid}"
)
private
String
mpAppId
;
@Value
(
"${wx.mp.config.secret}"
)
private
String
mpSecret
;
@Autowired
private
RedissonClient
redissonClient
;
@Bean
public
WxMaService
wxMaService
(){
WxMaServiceImpl
wxMaService
=
new
WxMaServiceImpl
();
wxMaService
.
setWxMaConfig
(
wxMaConfig
());
return
wxMaService
;
}
public
WxMaConfig
wxMaConfig
(){
WxMaRedissonConfigImpl
wxMaRedissonConfig
=
new
WxMaRedissonConfigImpl
(
redissonClient
);
wxMaRedissonConfig
.
setAppid
(
appId
);
wxMaRedissonConfig
.
setSecret
(
appSecret
);
return
wxMaRedissonConfig
;
}
@Bean
public
WxMpService
wxMpService
(){
WxMpServiceImpl
wxMpService
=
new
WxMpServiceImpl
();
wxMpService
.
setWxMpConfigStorage
(
wxMpConfigStorage
());
return
wxMpService
;
}
public
WxMpConfigStorage
wxMpConfigStorage
(){
WxMpRedissonConfigImpl
wxMpRedissonConfig
=
new
WxMpRedissonConfigImpl
(
redissonClient
);
wxMpRedissonConfig
.
setAppId
(
mpAppId
);
wxMpRedissonConfig
.
setSecret
(
mpSecret
);
return
wxMpRedissonConfig
;
}
}
server-common/src/main/java/com/makeit/utils/msg/sender/WxSpSender.java
0 → 100644
View file @
7206b73a
package
com
.
makeit
.
utils
.
msg
.
sender
;
import
cn.binarywang.wx.miniapp.api.WxMaService
;
import
cn.hutool.core.date.DateUtil
;
import
com.makeit.utils.msg.SendTypeEnum
;
import
com.makeit.utils.msg.dto.MsgSendDTO
;
import
lombok.extern.slf4j.Slf4j
;
import
me.chanjar.weixin.common.error.WxErrorException
;
import
me.chanjar.weixin.mp.api.WxMpService
;
import
me.chanjar.weixin.mp.bean.template.WxMpTemplateData
;
import
me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
@Component
@Slf4j
public
class
WxSpSender
implements
IMsgSender
{
@Autowired
private
WxMaService
wxMaService
;
@Autowired
private
WxMpService
wxMpService
;
/**
* 小程序公众号消息
* zn5fBS9cqjnN5UB78tAbm53M3dXufR2b5K1a8mkhXCY
*
* 告警对象{{thing2.DATA}}
* 告警时间{{time3.DATA}}
* 告警地点{{thing4.DATA}}
* 事件类型{{thing8.DATA}}
* 跳转文案点击查看详情
*
* @param msgDTO
*/
@Override
public
void
send
(
MsgSendDTO
msgDTO
)
{
List
<
WxMpTemplateData
>
mpData
=
Arrays
.
asList
(
new
WxMpTemplateData
(
"thing8"
,
"报警内容"
),
new
WxMpTemplateData
(
"thing4"
,
"固定值"
),
new
WxMpTemplateData
(
"thing2"
,
"老人姓名"
),
new
WxMpTemplateData
(
"time3"
,
DateUtil
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
))
);
try
{
//oBmPb5o9T3q-EMsxfhPg_9OjO5k4 lixl公众号openid
//oM2OI67H11zTZL88X99PxL6rAS3Y
//WxMpUser wxMpUser = wxMpService.getUserService().userInfo("oM2OI6zZQBB-kL6_0kaMM6adVb1E");
//oM2OI6zZQBB-kL6_0kaMM6adVb1E 小程序openId
// WxMpUserList wxMpUserList = wxMpService.getUserService().userList();
//WxMpUser wxMpUser = wxMpService.getUserService().userInfo("oM2OI67H11zTZL88X99PxL6rAS3Y");
WxMpTemplateMessage
wxMpTemplateMessage
=
WxMpTemplateMessage
.
builder
().
toUser
(
"oM2OI67H11zTZL88X99PxL6rAS3Y"
)
.
templateId
(
"zn5fBS9cqjnN5UB78tAbm53M3dXufR2b5K1a8mkhXCY"
)
.
data
(
mpData
)
.
build
();
wxMpService
.
getTemplateMsgService
().
sendTemplateMsg
(
wxMpTemplateMessage
);
log
.
info
(
"发送小程序消息成功"
);
}
catch
(
WxErrorException
e
)
{
log
.
error
(
"发送小程序消息失败:"
,
e
);
}
}
@Override
public
boolean
support
(
SendTypeEnum
sendTypeEnum
)
{
return
false
;
}
}
server-web/src/main/java/com/makeit/mqtt/TestAlarmRecordController.java
0 → 100644
View file @
7206b73a
package
com
.
makeit
.
mqtt
;
import
com.makeit.common.dto.BaseIdDTO
;
import
com.makeit.common.response.ApiResponseEntity
;
import
com.makeit.common.response.ApiResponseUtils
;
import
com.makeit.global.annotation.AuthIgnore
;
import
com.makeit.utils.msg.dto.MsgSendDTO
;
import
com.makeit.utils.msg.sender.WxSpSender
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Collections
;
@Api
(
tags
=
"告警记录2"
)
@RestController
@RequestMapping
(
"/plat/test"
)
public
class
TestAlarmRecordController
{
// @Autowired
// private MailMsgSender mailMsgSender;
// @Autowired
// private SmsMsgSender smsMsgSender;
// @Autowired
// private SmsVoiceSender smsVoiceSender;
//
// @ApiOperation("测试邮箱")
// @PostMapping("testMail")
// public ApiResponseEntity<Void> testMail(@RequestBody BaseIdDTO dto) {
// MsgSendDTO msgDTO = new MsgSendDTO();
// msgDTO.setSubject("测试消息");
// msgDTO.setReceiverList(Collections.singletonList("994997968@qq.com"));
// msgDTO.setOriContent("测试发送邮箱");
// mailMsgSender.send(msgDTO);
// return ApiResponseUtils.success();
// }
//
// @ApiOperation("测试短信")
// @PostMapping("testMsg")
// public ApiResponseEntity<Void> testMsg(@RequestBody BaseIdDTO dto) throws Exception {
// MsgSendDTO msgDTO = new MsgSendDTO();
// msgDTO.setReceiverList(Collections.singletonList("18850503603"));
// msgDTO.setOriContent("测试短信test");
// smsMsgSender.send(msgDTO);
// return ApiResponseUtils.success();
// }
//
// @ApiOperation("测试语音短信")
// @PostMapping("testVoice")
// @AuthIgnore
// public ApiResponseEntity<Void> testVoice(@RequestBody BaseIdDTO dto) throws Exception {
// MsgSendDTO msgDTO = new MsgSendDTO();
// msgDTO.setReceiverList(Collections.singletonList("18850503603"));
// msgDTO.setOriContent("测试短信test");
// smsVoiceSender.send(msgDTO);
// return ApiResponseUtils.success();
// }
@Autowired
private
WxSpSender
wxSpSender
;
// @ApiOperation("测试公众号消息")
// @PostMapping("testSp")
// @AuthIgnore
// public ApiResponseEntity<Void> testVoice(@RequestBody BaseIdDTO dto) throws Exception {
// MsgSendDTO msgDTO = new MsgSendDTO();
// msgDTO.setReceiverList(Collections.singletonList("18850503603"));
// msgDTO.setOriContent("测试短信test");
// wxSpSender.send(msgDTO);
// return ApiResponseUtils.success();
// }
@ApiOperation
(
"测试公众号消息"
)
@PostMapping
(
"testSp"
)
@AuthIgnore
public
ApiResponseEntity
<
Void
>
testSpVoice
(
@RequestBody
BaseIdDTO
dto
)
throws
Exception
{
MsgSendDTO
msgDTO
=
new
MsgSendDTO
();
msgDTO
.
setReceiverList
(
Collections
.
singletonList
(
"18850503603"
));
msgDTO
.
setOriContent
(
"测试短信test"
);
wxSpSender
.
send
(
msgDTO
);
return
ApiResponseUtils
.
success
();
}
// @Autowired
// private PushCallback pushCallback;
//
// @ApiOperation("测试跌倒")
// @PostMapping("testFall")
// @AuthIgnore
// public ApiResponseEntity<Void> testVoice(@RequestBody DeviceInfo info) throws Exception {
//
// pushCallback.checkAlarm(info);
// return ApiResponseUtils.success();
// }
//
//
// @Autowired
// private PlatDayDurationRecordService platDayDurationRecordService;
//
// @ApiOperation("测试")
// @PostMapping("test")
// @AuthIgnore
// public ApiResponseEntity<List<PlatDayDurationRecord>> test(@RequestBody DeviceInfo info) throws Exception {
// PlatDayDurationRecord platDayDurationRecord = new PlatDayDurationRecord();
// platDayDurationRecord.setDay(new Date());
// LambdaQueryWrapper<PlatDayDurationRecord> platDayDurationRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
// platDayDurationRecordLambdaQueryWrapper.eq(PlatDayDurationRecord::getDay,platDayDurationRecord.getDay());
// List<PlatDayDurationRecord> list = platDayDurationRecordService.list();
// return ApiResponseUtils.success(list);
// }
}
server-web/src/main/resources/application-dev.yml
View file @
7206b73a
...
...
@@ -134,7 +134,10 @@ wx:
token
:
#微信小程序消息服务器配置的token
aesKey
:
#微信小程序消息服务器配置的EncodingAESKey
msgDataFormat
:
JSON
mp
:
config
:
appid
:
wx5c73cad7aeb788c6
secret
:
7c3a0665bf2adbe67a58a4d6c8017243
sms
:
send
:
url
:
http://www.aozoneyun.com/message/message/send
...
...
server-web/src/main/resources/application-test.yml
View file @
7206b73a
...
...
@@ -130,6 +130,10 @@ wx:
token
:
#微信小程序消息服务器配置的token
aesKey
:
#微信小程序消息服务器配置的EncodingAESKey
msgDataFormat
:
JSON
mp
:
config
:
appid
:
wx5c73cad7aeb788c6
secret
:
7c3a0665bf2adbe67a58a4d6c8017243
sms
:
send
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment