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 4fa5f249
authored
Oct 15, 2022
by
weiss
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
ed7607dd
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
153 additions
and
4 deletions
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
src/main/java/com/pipihelper/project/feishu/dao/PainDao.java
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
src/main/java/com/pipihelper/project/feishu/service/massage/MassageMsgCardSerivce.java
src/main/java/com/pipihelper/project/feishu/service/massage/MassageService.java
src/main/java/com/pipihelper/project/scheduled/MassageNoticeScheduleService.java
src/main/resources/mybatis/PainMapper.xml
src/main/resources/templates/massage-singel-msg-card.json
src/main/resources/templates/massage-single-msg-card-start.json
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
View file @
4fa5f24
...
...
@@ -118,6 +118,7 @@ public class FeiShuEventController {
// 推迟 将当前用户放到队列最后 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
String
waitUserId
=
feiShuMsgCardEventDTO
.
getOpen_id
();
painService
.
waitPain
(
waitUserId
);
//ToDo 更新大群和按摩群的大卡片,异步
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json.json"
);
return
getInteractiveCardStr
(
fileName1
,
"已为你推迟到最后"
);
}
else
if
(
"rob"
.
equals
(
actionTypeSecond
))
{
...
...
@@ -127,8 +128,13 @@ public class FeiShuEventController {
Pain
oldPain
=
painService
.
findByOpenId
(
oldUserId
);
oldPain
.
setOpenId
(
robUserId
);
painService
.
update
(
oldPain
);
//ToDo 更新大群和按摩群的大卡片,异步
String
fileName1
=
String
.
format
(
"/templates/massage-msg-card-rob-end.json.json.json"
);
return
getInteractiveCardStr
(
fileName1
,
"已经被抢啦啦啦~"
);
}
else
if
(
"next"
.
equals
(
actionTypeSecond
))
{
// 当前按完,有请下一位
}
default
:
}
...
...
src/main/java/com/pipihelper/project/feishu/dao/PainDao.java
View file @
4fa5f24
...
...
@@ -25,5 +25,5 @@ public interface PainDao {
List
<
Pain
>
findListAsc
(
int
limit
);
List
<
Pain
>
findBackIndex
(
@Param
(
value
=
"openId"
)
String
openId
,
@Param
(
value
=
"limit"
)
int
limit
);
List
<
Pain
>
findBackIndex
(
@Param
(
value
=
"openId"
)
String
openId
,
@Param
(
value
=
"limit"
)
int
limit
);
}
src/main/java/com/pipihelper/project/feishu/service/FeiShuApiService.java
View file @
4fa5f24
...
...
@@ -134,7 +134,6 @@ public class FeiShuApiService {
}
}
@Async
public
JSONObject
patchMsg
(
String
message_id
,
JSONObject
content
)
{
String
api
=
"/im/v1/messages/"
;
OkHttpClient
client
=
new
OkHttpClient
();
...
...
src/main/java/com/pipihelper/project/feishu/service/massage/MassageMsgCardSerivce.java
View file @
4fa5f24
...
...
@@ -38,6 +38,13 @@ public class MassageMsgCardSerivce {
}
public
String
genMassageMsgCardForSingleStart
(){
String
fileName
=
String
.
format
(
"/templates/massage-single-msg-card-start.json"
);
String
msgCardContent
=
String
.
format
(
getInteractiveCardStr
(
fileName
));
return
msgCardContent
;
}
public
String
genMassageMsgCardForCompany
(
List
<
List
<
String
>>
pushUser
){
try
{
List
<
String
>
title
=
Arrays
.
asList
(
"序号"
,
"姓名"
,
"部门"
,
"时间段"
,
"签到"
);
...
...
src/main/java/com/pipihelper/project/feishu/service/massage/MassageService.java
View file @
4fa5f24
...
...
@@ -62,6 +62,7 @@ public class MassageService {
user
.
add
(
""
);
pushUser
.
add
(
user
);
}
//给大群发送消息
String
content
=
massageMsgCardSerivce
.
genMassageMsgCardForCompany
(
pushUser
);
log
.
info
(
"给大群发送按摩消息:{}"
,
content
);
FeiShuMsgDTO
feiShuMsgDTO
=
new
FeiShuMsgDTO
();
...
...
@@ -73,5 +74,52 @@ public class MassageService {
}
public
void
updateSingleMassageMsgCardWhenBegin
(
String
messageId
){
JSONObject
patchMsg
=
new
JSONObject
();
String
msgCardContent
=
massageMsgCardSerivce
.
genMassageMsgCardForSingleStart
();
patchMsg
.
put
(
"content"
,
msgCardContent
);
feiShuApiService
.
patchMsg
(
messageId
,
patchMsg
);
}
//
// public void updateMassageMsgCardToPiPiChat(){
// List<PushPainBO> pushPainBOList =
// List<List<String>> pushUser = new ArrayList<>();
// for(PushPainBO pushPainBO:pushPainBOList){
// List<String> user = new ArrayList<>();
// //给单个用户发送
// String singleContent = massageMsgCardSerivce.genMassageMsgCardForSingle();
// log.info("给单个用户发送按摩消息:{}",singleContent);
// FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO();
// feiShuMsgDTO.setMsgType("interactive");
// feiShuMsgDTO.setContent(singleContent);
// feiShuMsgDTO.setReceiveId(pushPainBO.getOpenId());
// log.info(feiShuMsgDTO.toString());
// JSONObject sendMsgResponse = feiShuApiService.sendMsg(feiShuMsgDTO, "open_id");
// String messageId = sendMsgResponse.getJSONObject("data").getString("message_id");
// //更新按摩记录表中的messageId
// Pain pain = painService.findByOpenId(pushPainBO.getOpenId());
// pain.setMessageId(messageId);
// painService.update(pain);
// //构建给大群发送的名单
// user.add(pushPainBO.getIndex().toString());
// user.add(pushPainBO.getName());
// user.add(pushPainBO.getDepartMentName());
// user.add(pushPainBO.getTimeRange());
// user.add("");
// pushUser.add(user);
// }
// //给大群发送消息
// String content = massageMsgCardSerivce.genMassageMsgCardForCompany(pushUser);
// log.info("给大群发送按摩消息:{}",content);
// FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO();
// feiShuMsgDTO.setMsgType("interactive");
// feiShuMsgDTO.setContent(content);
// feiShuMsgDTO.setReceiveId(feiShuConfig.getChatId());
// log.info(feiShuMsgDTO.toString());
// feiShuApiService.sendMsg(feiShuMsgDTO, "chat_id");
// }
}
src/main/java/com/pipihelper/project/scheduled/MassageNoticeScheduleService.java
View file @
4fa5f24
package
com
.
pipihelper
.
project
.
scheduled
;
import
com.alibaba.fastjson.JSONObject
;
import
com.pipihelper.project.feishu.entity.Pain
;
import
com.pipihelper.project.feishu.service.FeiShuApiService
;
import
com.pipihelper.project.feishu.service.PainService
;
import
com.pipihelper.project.feishu.service.massage.MassageService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* @Description: TODO
* @author: charles
* @date: 2022年10月15日 17:26
*/
@Slf4j
@Component
public
class
MassageNoticeScheduleService
{
@Autowired
private
PainService
painService
;
@Autowired
private
MassageService
massageService
;
@Autowired
private
FeiShuApiService
feiShuApiService
;
/**
* 每周四定时生成要按摩的人员名单,并发送大群和单人消息
*/
...
...
@@ -18,4 +40,24 @@ public class MassageNoticeScheduleService {
public
void
sendMsgCardToPipiChat
(){
}
/**
* 当天时间2:55,给第一波三个人更新卡片,并发送应用内提醒
*/
@Async
@Scheduled
(
cron
=
"0 0 10 * * ?"
)
public
void
massageStart
(){
List
<
Pain
>
pains
=
painService
.
findListAsc
(
3
);
for
(
Pain
pain:
pains
){
String
messageId
=
pain
.
getMessageId
();
massageService
.
updateSingleMassageMsgCardWhenBegin
(
messageId
);
JSONObject
noticeMsg
=
new
JSONObject
();
noticeMsg
.
put
(
"user_id_list"
,
Arrays
.
asList
(
pain
.
getOpenId
()));
//发送应用内提醒
log
.
info
(
"发送应用内容消息提醒"
);
feiShuApiService
.
patchUrgentApp
(
messageId
,
noticeMsg
);
}
}
}
src/main/resources/mybatis/PainMapper.xml
View file @
4fa5f24
...
...
@@ -10,7 +10,7 @@
<result
column=
"status"
property=
"status"
/>
<result
column=
"floor"
property=
"floor"
/>
<result
column=
"messageId"
property=
"messageId"
/>
<result
column=
"index"
property=
"index"
/>
</resultMap>
<!-- <resultMap id="BuffConfigResultBOMap" type="com.pipihelper.project.feishu.entity.Deployee"
...
...
@@ -60,6 +60,15 @@
</where>
</select>
<select
id=
"findByIndex"
parameterType=
"java.lang.String"
resultMap=
"PainResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_pain
<where>
index = #{index}
</where>
</select>
<select
id=
"findAll"
resultMap=
"PainResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
...
...
src/main/resources/templates/massage-singel-msg-card.json
View file @
4fa5f24
...
...
@@ -7,7 +7,7 @@
{
"tag"
:
"div"
,
"text"
:
{
"content"
:
"
%s
"
,
"content"
:
"
欢呼吧,你排到了按摩哦!
"
,
"tag"
:
"lark_md"
}
},
...
...
src/main/resources/templates/massage-single-msg-card-start.json
0 → 100644
View file @
4fa5f24
{
"config"
:
{
"wide_screen_mode"
:
true
,
"update_multi"
:
true
},
"elements"
:
[
{
"tag"
:
"div"
,
"text"
:
{
"content"
:
"欢呼吧,你排到了按摩哦!"
,
"tag"
:
"lark_md"
}
},
{
"actions"
:
[
{
"tag"
:
"button"
,
"text"
:
{
"content"
:
"按完了,有请下一位!"
,
"tag"
:
"plain_text"
},
"type"
:
"default"
,
"value"
:
{
"key1"
:
"massage-singel.next"
}
}
],
"tag"
:
"action"
}
],
"header"
:
{
"template"
:
"turquoise"
,
"title"
:
{
"content"
:
"👻 按摩提醒请查收!"
,
"tag"
:
"plain_text"
}
}
}
\ No newline at end of file
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