Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
zhangshaowu
/
pipi-helper
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 ffbb75a2
authored
Oct 16, 2022
by
weiss
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
3d68f4e2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
9 deletions
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
src/main/java/com/pipihelper/project/feishu/service/massage/MassageService.java
src/main/java/com/pipihelper/project/scheduled/MassageNoticeScheduleService.java
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
View file @
ffbb75a
...
@@ -125,16 +125,14 @@ public class FeiShuEventController {
...
@@ -125,16 +125,14 @@ public class FeiShuEventController {
// 推迟 将当前用户放到队列最后 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
// 推迟 将当前用户放到队列最后 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
String
waitUserId
=
feiShuMsgCardEventDTO
.
getOpen_id
();
String
waitUserId
=
feiShuMsgCardEventDTO
.
getOpen_id
();
painService
.
waitPain
(
waitUserId
);
painService
.
waitPain
(
waitUserId
);
//
ToDo 没有按摩群的id
//
更新大群
massageService
.
updateMassageMsgCardToPiPiChat
(
feiShuConfig
.
getChatId
());
massageService
.
updateMassageMsgCardToPiPiChat
(
feiShuConfig
.
getChatId
());
//
没有按摩群的id
//
更新按摩群
// massageService.updateMassageMsgCardToPiPiChat(
);
massageService
.
updateMassageMsgCardToPiPiChat
((
String
)
CacheUtil
.
get
(
"chatId"
)
);
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json"
);
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json"
);
return
getInteractiveCardStr
(
fileName1
,
"已为你推迟到最后"
);
return
getInteractiveCardStr
(
fileName1
,
"已为你推迟到最后"
);
}
else
if
(
"rob"
.
equals
(
actionTypeSecond
))
{
}
else
if
(
"rob"
.
equals
(
actionTypeSecond
))
{
// 抢名额 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
// 抢名额 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
massageService
.
updateMassageMsgCardToPiPiChat
(
feiShuConfig
.
getChatId
());
return
rob
(
feiShuMsgCardEventDTO
);
return
rob
(
feiShuMsgCardEventDTO
);
}
else
if
(
"next"
.
equals
(
actionTypeSecond
))
{
}
else
if
(
"next"
.
equals
(
actionTypeSecond
))
{
// 当前按完,有请下一位
// 当前按完,有请下一位
...
@@ -148,6 +146,15 @@ public class FeiShuEventController {
...
@@ -148,6 +146,15 @@ public class FeiShuEventController {
noticePain
.
setStatus
(
1
);
noticePain
.
setStatus
(
1
);
painService
.
update
(
noticePain
);
painService
.
update
(
noticePain
);
massageService
.
updateSingleMassageMsgCardWhenBegin
(
noticePain
.
getMessageId
());
massageService
.
updateSingleMassageMsgCardWhenBegin
(
noticePain
.
getMessageId
());
//按摩群中同步发送按摩进度信息
FeiShuMsgDTO
feiShuMsgDTO
=
new
FeiShuMsgDTO
();
String
msg
=
"当前按摩进度:"
+
String
.
format
(
"<at user_id=\\\"%s\\\">%s</at>"
,
noticePain
.
getOpenId
(),
noticePain
.
getName
());
JSONObject
content
=
new
JSONObject
();
content
.
put
(
"text"
,
msg
);
feiShuMsgDTO
.
setMsgType
(
"text"
);
feiShuMsgDTO
.
setContent
(
content
.
toString
());
feiShuMsgDTO
.
setReceiveId
((
String
)
CacheUtil
.
get
(
"chatId"
));
feiShuApiService
.
sendMsg
(
feiShuMsgDTO
,
"chat_id"
);
}
}
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json"
);
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json"
);
return
getInteractiveCardStr
(
fileName1
,
"欢迎下次光临~"
);
return
getInteractiveCardStr
(
fileName1
,
"欢迎下次光临~"
);
...
@@ -167,7 +174,12 @@ public class FeiShuEventController {
...
@@ -167,7 +174,12 @@ public class FeiShuEventController {
feiShuChatDTO
.
setChatId
((
String
)
CacheUtil
.
get
(
"chatId"
));
feiShuChatDTO
.
setChatId
((
String
)
CacheUtil
.
get
(
"chatId"
));
feiShuChatDTO
.
setIdList
(
new
String
[]{
feiShuMsgCardEventDTO
.
getOpen_id
()});
feiShuChatDTO
.
setIdList
(
new
String
[]{
feiShuMsgCardEventDTO
.
getOpen_id
()});
feiShuApiService
.
joinChatList
(
feiShuChatDTO
);
feiShuApiService
.
joinChatList
(
feiShuChatDTO
);
//ToDo 更新大群和按摩群的大卡片,异步
// 更新大群和按摩群的大卡片,异步
// 大群
massageService
.
updateMassageMsgCardToPiPiChat
(
feiShuConfig
.
getChatId
());
//按摩群
massageService
.
updateMassageMsgCardToPiPiChat
((
String
)
CacheUtil
.
get
(
"chatId"
));
String
fileName1
=
String
.
format
(
"/templates/massage-msg-card-rob-end.json"
);
String
fileName1
=
String
.
format
(
"/templates/massage-msg-card-rob-end.json"
);
return
getInteractiveCardStr
(
fileName1
,
"已经被抢啦啦啦~"
);
return
getInteractiveCardStr
(
fileName1
,
"已经被抢啦啦啦~"
);
}
}
...
@@ -322,4 +334,16 @@ public class FeiShuEventController {
...
@@ -322,4 +334,16 @@ public class FeiShuEventController {
return
ResultGenerator
.
genSuccessResult
();
return
ResultGenerator
.
genSuccessResult
();
}
}
@PostMapping
(
"/send-msg"
)
public
Result
sendMsg
(
String
receiveId
,
String
msg
,
String
receiveIdType
){
FeiShuMsgDTO
feiShuMsgDTO
=
new
FeiShuMsgDTO
();
JSONObject
content
=
new
JSONObject
();
content
.
put
(
"text"
,
msg
);
feiShuMsgDTO
.
setMsgType
(
"text"
);
feiShuMsgDTO
.
setContent
(
content
.
toString
());
feiShuMsgDTO
.
setReceiveId
(
receiveId
);
feiShuApiService
.
sendMsg
(
feiShuMsgDTO
,
receiveIdType
);
return
ResultGenerator
.
genSuccessResult
();
}
}
}
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
View file @
ffbb75a
...
@@ -156,7 +156,7 @@ public class FeiShuApiService {
...
@@ -156,7 +156,7 @@ public class FeiShuApiService {
@Async
@Async
public
JSONObject
patchUrgentApp
(
String
message_id
,
JSONObject
content
)
{
public
JSONObject
patchUrgentApp
(
String
message_id
,
JSONObject
content
)
{
String
api
=
"/im/v1/messages/"
+
message_id
+
"/urgent_
sms?user_id_type=user
_id"
;
String
api
=
"/im/v1/messages/"
+
message_id
+
"/urgent_
app?user_id_type=open
_id"
;
OkHttpClient
client
=
new
OkHttpClient
();
OkHttpClient
client
=
new
OkHttpClient
();
String
url
=
feiShuConfig
.
getFeiShuOpenApiHost
()
+
api
;
String
url
=
feiShuConfig
.
getFeiShuOpenApiHost
()
+
api
;
RequestBody
requestBody
=
RequestBody
.
create
(
content
.
toString
(),
MediaType
.
parse
(
"application/json"
));
RequestBody
requestBody
=
RequestBody
.
create
(
content
.
toString
(),
MediaType
.
parse
(
"application/json"
));
...
@@ -180,7 +180,7 @@ public class FeiShuApiService {
...
@@ -180,7 +180,7 @@ public class FeiShuApiService {
@Async
@Async
public
JSONObject
patchUrgentSms
(
String
message_id
,
JSONObject
content
)
{
public
JSONObject
patchUrgentSms
(
String
message_id
,
JSONObject
content
)
{
String
api
=
"/im/v1/messages/"
+
message_id
+
"/urgent_
app?user_id_type=open
_id"
;
String
api
=
"/im/v1/messages/"
+
message_id
+
"/urgent_
sms?user_id_type=user
_id"
;
OkHttpClient
client
=
new
OkHttpClient
();
OkHttpClient
client
=
new
OkHttpClient
();
String
url
=
feiShuConfig
.
getFeiShuOpenApiHost
()
+
api
;
String
url
=
feiShuConfig
.
getFeiShuOpenApiHost
()
+
api
;
RequestBody
requestBody
=
RequestBody
.
create
(
content
.
toString
(),
MediaType
.
parse
(
"application/json"
));
RequestBody
requestBody
=
RequestBody
.
create
(
content
.
toString
(),
MediaType
.
parse
(
"application/json"
));
...
...
src/main/java/com/pipihelper/project/feishu/service/massage/MassageService.java
View file @
ffbb75a
...
@@ -47,6 +47,7 @@ public class MassageService {
...
@@ -47,6 +47,7 @@ public class MassageService {
List
<
List
<
String
>>
pushUser
=
new
ArrayList
<>();
List
<
List
<
String
>>
pushUser
=
new
ArrayList
<>();
for
(
PushPainBO
pushPainBO
:
pushPainBOList
)
{
for
(
PushPainBO
pushPainBO
:
pushPainBOList
)
{
List
<
String
>
user
=
new
ArrayList
<>();
List
<
String
>
user
=
new
ArrayList
<>();
if
(
chatId
.
equals
(
feiShuConfig
.
getChatId
())){
//给单个用户发送
//给单个用户发送
String
singleContent
=
massageMsgCardSerivce
.
genMassageMsgCardForSingle
();
String
singleContent
=
massageMsgCardSerivce
.
genMassageMsgCardForSingle
();
log
.
info
(
"给单个用户发送按摩消息:{}"
,
singleContent
);
log
.
info
(
"给单个用户发送按摩消息:{}"
,
singleContent
);
...
@@ -61,6 +62,7 @@ public class MassageService {
...
@@ -61,6 +62,7 @@ public class MassageService {
Pain
pain
=
painService
.
findByOpenId
(
pushPainBO
.
getOpenId
());
Pain
pain
=
painService
.
findByOpenId
(
pushPainBO
.
getOpenId
());
pain
.
setMessageId
(
messageId
);
pain
.
setMessageId
(
messageId
);
painService
.
update
(
pain
);
painService
.
update
(
pain
);
}
//构建给大群发送的名单
//构建给大群发送的名单
user
.
add
(
pushPainBO
.
getIndex
().
toString
());
user
.
add
(
pushPainBO
.
getIndex
().
toString
());
user
.
add
(
pushPainBO
.
getName
());
user
.
add
(
pushPainBO
.
getName
());
...
...
src/main/java/com/pipihelper/project/scheduled/MassageNoticeScheduleService.java
View file @
ffbb75a
package
com
.
pipihelper
.
project
.
scheduled
;
package
com
.
pipihelper
.
project
.
scheduled
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO
;
import
com.pipihelper.project.feishu.entity.Pain
;
import
com.pipihelper.project.feishu.entity.Pain
;
import
com.pipihelper.project.feishu.service.FeiShuApiService
;
import
com.pipihelper.project.feishu.service.FeiShuApiService
;
import
com.pipihelper.project.feishu.service.PainService
;
import
com.pipihelper.project.feishu.service.PainService
;
import
com.pipihelper.project.feishu.service.massage.MassageService
;
import
com.pipihelper.project.feishu.service.massage.MassageService
;
import
com.pipihelper.project.utils.CacheUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Async
;
...
@@ -49,18 +51,31 @@ public class MassageNoticeScheduleService {
...
@@ -49,18 +51,31 @@ public class MassageNoticeScheduleService {
// @Scheduled(cron = "0 0 10 * * ?")
// @Scheduled(cron = "0 0 10 * * ?")
public
void
massageStart
(){
public
void
massageStart
(){
List
<
Pain
>
pains
=
painService
.
findListAsc
(
3
);
List
<
Pain
>
pains
=
painService
.
findListAsc
(
3
);
// String msg = "{\"text\":\"当前按摩进度:<at user_id=\\\"%s\\\">%s</at> <at user_id=\\\"%s\\\">%s</at> <at user_id=\\\"%s\\\">%s</at>\"}";
StringBuilder
userString
=
new
StringBuilder
();
for
(
Pain
pain:
pains
){
for
(
Pain
pain:
pains
){
String
messageId
=
pain
.
getMessageId
();
String
messageId
=
pain
.
getMessageId
();
massageService
.
updateSingleMassageMsgCardWhenBegin
(
messageId
);
massageService
.
updateSingleMassageMsgCardWhenBegin
(
messageId
);
userString
.
append
(
String
.
format
(
"<at user_id=\\\"%s\\\">%s</at>"
,
pain
.
getOpenId
(),
pain
.
getName
()));
//1代表正在按
//1代表正在按
pain
.
setStatus
(
1
);
pain
.
setStatus
(
1
);
painService
.
update
(
pain
);
painService
.
update
(
pain
);
//发送应用内提醒
JSONObject
noticeMsg
=
new
JSONObject
();
JSONObject
noticeMsg
=
new
JSONObject
();
noticeMsg
.
put
(
"user_id_list"
,
Arrays
.
asList
(
pain
.
getOpenId
()));
noticeMsg
.
put
(
"user_id_list"
,
Arrays
.
asList
(
pain
.
getOpenId
()));
//发送应用内提醒
log
.
info
(
"发送应用内容消息提醒"
);
log
.
info
(
"发送应用内容消息提醒"
);
feiShuApiService
.
patchUrgentApp
(
messageId
,
noticeMsg
);
feiShuApiService
.
patchUrgentApp
(
messageId
,
noticeMsg
);
}
}
//按摩群中同步发送按摩进度信息
FeiShuMsgDTO
feiShuMsgDTO
=
new
FeiShuMsgDTO
();
String
msg
=
"当前按摩进度:"
+
userString
;
JSONObject
content
=
new
JSONObject
();
content
.
put
(
"text"
,
msg
);
feiShuMsgDTO
.
setMsgType
(
"text"
);
feiShuMsgDTO
.
setContent
(
content
.
toString
());
feiShuMsgDTO
.
setReceiveId
((
String
)
CacheUtil
.
get
(
"chatId"
));
feiShuApiService
.
sendMsg
(
feiShuMsgDTO
,
"chat_id"
);
}
}
...
...
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