Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
314e480a
Commit
314e480a
authored
Apr 02, 2022
by
tianbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
特种设备公众号添加测试接口
parent
8cae9bbf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
8 deletions
+97
-8
IWechatService.java
...join/amos/boot/module/tzs/api/service/IWechatService.java
+13
-0
WechatController.java
...amos/boot/module/tzs/biz/controller/WechatController.java
+17
-4
WechatServiceImpl.java
...s/boot/module/tzs/biz/service/impl/WechatServiceImpl.java
+67
-4
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/service/IWechatService.java
View file @
314e480a
...
...
@@ -42,4 +42,17 @@ public interface IWechatService {
*/
String
getWechatPicByMediaId
(
String
mediaId
);
/**
* 发送测试公众号督查整改模板消息
*
* @return
*/
Boolean
sendTestTemplateMsgSupervise
();
/**
* 发送测试公众号预警模板消息
*
* @return
*/
Boolean
sendTestTemplateMsgWarning
();
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/controller/WechatController.java
View file @
314e480a
...
...
@@ -41,6 +41,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
...
@@ -339,8 +340,6 @@ public class WechatController extends BaseController {
return
ResponseHelper
.
buildResponse
(
dto
);
}
public
String
login
(
String
tel
)
{
String
token
=
""
;
IdPasswordAuthModel
loninData
=
new
IdPasswordAuthModel
();
...
...
@@ -356,7 +355,6 @@ public class WechatController extends BaseController {
return
token
;
}
/**
* 根据微信code获取openId和手机号接口
*
...
...
@@ -378,7 +376,7 @@ public class WechatController extends BaseController {
WechatRelation
temp
=
wechatRelationServiceImpl
.
getOne
(
new
LambdaQueryWrapper
<
WechatRelation
>().
eq
(
WechatRelation:
:
getOpenId
,
openId
));
if
(
temp
!=
null
)
{
wechatAccessDto
.
setTel
(
temp
.
getPhone
());
if
(
redisUtils
.
hasKey
(
temp
.
getPhone
()
+
"_token"
))
{
if
(
redisUtils
.
hasKey
(
temp
.
getPhone
()
+
"_token"
)
&&
redisUtils
.
getExpire
(
temp
.
getPhone
()
+
"_token"
)
>
1
)
{
wechatAccessDto
.
setToken
(
redisUtils
.
get
(
temp
.
getPhone
()
+
"_token"
).
toString
());
}
else
{
wechatAccessDto
.
setToken
(
this
.
login
(
temp
.
getPhone
()));
...
...
@@ -662,4 +660,19 @@ public class WechatController extends BaseController {
String
url
=
HttpUtils
.
doPostWithFile
(
getPicUrl
,
file
,
"media"
,
accessToken
,
"image"
);
return
ResponseHelper
.
buildResponse
(
url
);
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/test/templateMsg/warning"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"测试发送公众号预警消息"
,
notes
=
"测试发送公众号预警消息"
)
public
ResponseModel
testSendTemplateMsgWarning
()
{
return
ResponseHelper
.
buildResponse
(
wechatService
.
sendTestTemplateMsgWarning
());
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/test/templateMsg/supervise"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"测试发送公众号督查整改消息"
,
notes
=
"测试发送公众号督查整改消息"
)
public
ResponseModel
testSendTemplateMsgSupervise
()
{
return
ResponseHelper
.
buildResponse
(
wechatService
.
sendTestTemplateMsgSupervise
());
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/service/impl/WechatServiceImpl.java
View file @
314e480a
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.google.common.base.Joiner
;
import
com.google.common.collect.Maps
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.WechatMessageDto
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.WechatRelation
;
import
com.yeejoin.amos.boot.module.tzs.api.service.IWechatService
;
import
com.yeejoin.amos.boot.module.tzs.biz.utils.HttpUtils
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
...
...
@@ -15,7 +20,10 @@ import org.springframework.stereotype.Service;
import
org.springframework.web.multipart.MultipartFile
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -41,6 +49,15 @@ public class WechatServiceImpl implements IWechatService {
@Value
(
"${tzs.wechat.url}"
)
private
String
wechatUrl
;
@Autowired
WechatRelationServiceImpl
wechatRelationService
;
@Value
(
"${tzs.wechat.tempId.warning}"
)
private
String
templateId_Warning
;
@Value
(
"${tzs.wechat.tempId.supervise}"
)
private
String
templateId_Supervise
;
@Value
(
"${tzs.wechat.test.userId}"
)
private
String
testUserId
;
@Override
public
String
getAccessToken
()
{
if
(
redisUtils
.
hasKey
(
RedisKey
.
WECHAT_TOKEN
)){
...
...
@@ -118,15 +135,13 @@ public class WechatServiceImpl implements IWechatService {
}
}
@Override
public
JSONObject
sendWechatModelMessage
(
String
openId
,
WechatMessageDto
wechatMessageDto
)
{
String
accessToken
=
this
.
getAccessToken
();
String
modelMessageUrl
=
wechatUrl
+
"/cgi-bin/message/template/send?access_token="
+
accessToken
;
JSONObject
messageBody
=
new
JSONObject
();
messageBody
.
put
(
"touser"
,
openId
);
messageBody
.
put
(
"template_id"
,
wechatMessageDto
.
getTemplateId
());
messageBody
.
put
(
"touser"
,
openId
);
messageBody
.
put
(
"template_id"
,
wechatMessageDto
.
getTemplateId
());
if
(
wechatMessageDto
.
getUrl
()
!=
null
)
{
messageBody
.
put
(
"url"
,
wechatMessageDto
.
getUrl
());
}
...
...
@@ -172,5 +187,52 @@ public class WechatServiceImpl implements IWechatService {
return
urlString
;
}
@Override
public
Boolean
sendTestTemplateMsgWarning
()
{
List
<
WechatRelation
>
wechatRelationList
=
wechatRelationService
.
list
(
new
LambdaQueryWrapper
<
WechatRelation
>().
in
(
WechatRelation:
:
getUserId
,
Arrays
.
asList
(
testUserId
.
split
(
","
))));
wechatRelationList
.
forEach
(
i
->
{
WechatMessageDto
wechatMessageDto1
=
new
WechatMessageDto
();
wechatMessageDto1
.
setTemplateId
(
templateId_Warning
);
Map
<
String
,
String
>
data1
=
Maps
.
newHashMap
();
data1
.
put
(
"first"
,
"【陕西省特种设备安全监察局】监督检查提醒"
);
data1
.
put
(
"keyword1"
,
"西安市碑林区市场监督管理局,系统发现您辖区内西安荣昌电梯有限公司2022年1月份应急救援时间合规率为66.96%,低于基准线90%,已自动为您制定监督检查任务,请按照要求进行监督检查后在系统进行信息登记。"
);
data1
.
put
(
"keyword2"
,
DateUtils
.
date2LongStr
(
new
Date
()));
wechatMessageDto1
.
setData
(
data1
);
sendWechatModelMessage
(
i
.
getOpenId
(),
wechatMessageDto1
);
WechatMessageDto
wechatMessageDto2
=
new
WechatMessageDto
();
wechatMessageDto2
.
setTemplateId
(
templateId_Warning
);
Map
<
String
,
String
>
data2
=
Maps
.
newHashMap
();
data2
.
put
(
"first"
,
"【陕西省特种设备安全监察局】监督检查提醒"
);
data2
.
put
(
"keyword1"
,
"西安荣昌电梯有限公司,系统发现贵公司2022年1月份应急救援时间合规度为66.96%,低于基准线90%,西安市碑林区市场监督管理局将于近期进行监督检查,请做好准备。"
);
data2
.
put
(
"keyword2"
,
DateUtils
.
date2LongStr
(
new
Date
()));
wechatMessageDto2
.
setData
(
data2
);
sendWechatModelMessage
(
i
.
getOpenId
(),
wechatMessageDto2
);
});
return
true
;
}
@Override
public
Boolean
sendTestTemplateMsgSupervise
()
{
List
<
WechatRelation
>
wechatRelationList
=
wechatRelationService
.
list
(
new
LambdaQueryWrapper
<
WechatRelation
>().
in
(
WechatRelation:
:
getUserId
,
Arrays
.
asList
(
testUserId
.
split
(
","
))));
wechatRelationList
.
forEach
(
i
->
{
WechatMessageDto
wechatMessageDto
=
new
WechatMessageDto
();
wechatMessageDto
.
setTemplateId
(
templateId_Supervise
);
Map
<
String
,
String
>
data
=
Maps
.
newHashMap
();
data
.
put
(
"first"
,
"【陕西省特种设备安全监察局】西安荣昌电梯有限公司,经西安市碑林区市场监督管理局监督检查,发现以下问题,请安排人员落实整改。"
);
data
.
put
(
"keyword1"
,
"西安荣昌电梯有限公司"
);
data
.
put
(
"keyword2"
,
"监管问题:2022年1月份应急救援时间合规度为66.96%,低于基准线90%;现场监督检查发现:没有建立事故应急措施和救援预案,无演练记录。"
);
data
.
put
(
"keyword3"
,
DateUtils
.
date2LongStr
(
new
Date
()));
data
.
put
(
"keyword4"
,
"李静"
);
wechatMessageDto
.
setData
(
data
);
sendWechatModelMessage
(
i
.
getOpenId
(),
wechatMessageDto
);
});
return
true
;
}
}
\ No newline at end of file
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