Commit 4fa5f249 by weiss

1

1 parent ed7607dd
...@@ -118,6 +118,7 @@ public class FeiShuEventController { ...@@ -118,6 +118,7 @@ public class FeiShuEventController {
// 推迟 将当前用户放到队列最后 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片 // 推迟 将当前用户放到队列最后 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
String waitUserId = feiShuMsgCardEventDTO.getOpen_id(); String waitUserId = feiShuMsgCardEventDTO.getOpen_id();
painService.waitPain(waitUserId); painService.waitPain(waitUserId);
//ToDo 更新大群和按摩群的大卡片,异步
String fileName1 = String.format("/templates/massage-singel-msg-card-end.json.json"); String fileName1 = String.format("/templates/massage-singel-msg-card-end.json.json");
return getInteractiveCardStr(fileName1, "已为你推迟到最后"); return getInteractiveCardStr(fileName1, "已为你推迟到最后");
} else if ("rob".equals(actionTypeSecond)) { } else if ("rob".equals(actionTypeSecond)) {
...@@ -127,8 +128,13 @@ public class FeiShuEventController { ...@@ -127,8 +128,13 @@ public class FeiShuEventController {
Pain oldPain = painService.findByOpenId(oldUserId); Pain oldPain = painService.findByOpenId(oldUserId);
oldPain.setOpenId(robUserId); oldPain.setOpenId(robUserId);
painService.update(oldPain); painService.update(oldPain);
//ToDo 更新大群和按摩群的大卡片,异步
String fileName1 = String.format("/templates/massage-msg-card-rob-end.json.json.json"); String fileName1 = String.format("/templates/massage-msg-card-rob-end.json.json.json");
return getInteractiveCardStr(fileName1, "已经被抢啦啦啦~"); return getInteractiveCardStr(fileName1, "已经被抢啦啦啦~");
} else if ("next".equals(actionTypeSecond)) {
// 当前按完,有请下一位
} }
default: default:
} }
......
...@@ -25,5 +25,5 @@ public interface PainDao { ...@@ -25,5 +25,5 @@ public interface PainDao {
List<Pain> findListAsc(int limit); 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);
} }
...@@ -134,7 +134,6 @@ public class FeiShuApiService { ...@@ -134,7 +134,6 @@ public class FeiShuApiService {
} }
} }
@Async
public JSONObject patchMsg(String message_id, JSONObject content) { public JSONObject patchMsg(String message_id, JSONObject content) {
String api = "/im/v1/messages/"; String api = "/im/v1/messages/";
OkHttpClient client = new OkHttpClient(); OkHttpClient client = new OkHttpClient();
......
...@@ -38,6 +38,13 @@ public class MassageMsgCardSerivce { ...@@ -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){ public String genMassageMsgCardForCompany(List<List<String>> pushUser){
try { try {
List<String> title = Arrays.asList("序号","姓名","部门","时间段","签到"); List<String> title = Arrays.asList("序号","姓名","部门","时间段","签到");
......
...@@ -62,6 +62,7 @@ public class MassageService { ...@@ -62,6 +62,7 @@ public class MassageService {
user.add(""); user.add("");
pushUser.add(user); pushUser.add(user);
} }
//给大群发送消息
String content = massageMsgCardSerivce.genMassageMsgCardForCompany(pushUser); String content = massageMsgCardSerivce.genMassageMsgCardForCompany(pushUser);
log.info("给大群发送按摩消息:{}",content); log.info("给大群发送按摩消息:{}",content);
FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO(); FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO();
...@@ -73,5 +74,52 @@ public class MassageService { ...@@ -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");
// }
} }
package com.pipihelper.project.scheduled; 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.Async;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
/** /**
* @Description: TODO * @Description: TODO
* @author: charles * @author: charles
* @date: 2022年10月15日 17:26 * @date: 2022年10月15日 17:26
*/ */
@Slf4j
@Component
public class MassageNoticeScheduleService { public class MassageNoticeScheduleService {
@Autowired
private PainService painService;
@Autowired
private MassageService massageService;
@Autowired
private FeiShuApiService feiShuApiService;
/** /**
* 每周四定时生成要按摩的人员名单,并发送大群和单人消息 * 每周四定时生成要按摩的人员名单,并发送大群和单人消息
*/ */
...@@ -18,4 +40,24 @@ public class MassageNoticeScheduleService { ...@@ -18,4 +40,24 @@ public class MassageNoticeScheduleService {
public void sendMsgCardToPipiChat(){ 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);
}
}
} }
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<result column="status" property="status"/> <result column="status" property="status"/>
<result column="floor" property="floor"/> <result column="floor" property="floor"/>
<result column="messageId" property="messageId"/> <result column="messageId" property="messageId"/>
<result column="index" property="index"/>
</resultMap> </resultMap>
<!-- <resultMap id="BuffConfigResultBOMap" type="com.pipihelper.project.feishu.entity.Deployee" <!-- <resultMap id="BuffConfigResultBOMap" type="com.pipihelper.project.feishu.entity.Deployee"
...@@ -60,6 +60,15 @@ ...@@ -60,6 +60,15 @@
</where> </where>
</select> </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 id="findAll" resultMap="PainResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
{ {
"tag": "div", "tag": "div",
"text": { "text": {
"content": "%s", "content": "欢呼吧,你排到了按摩哦!",
"tag": "lark_md" "tag": "lark_md"
} }
}, },
......
{
"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 \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!