Commit b4708b81 by weiss

1

1 parent a608dec0
......@@ -124,7 +124,10 @@ public class FeiShuEventController {
// 推迟 将当前用户放到队列最后 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
String waitUserId = feiShuMsgCardEventDTO.getOpen_id();
painService.waitPain(waitUserId);
//ToDo 更新大群和按摩群的大卡片,异步
//ToDo 没有按摩群的id
massageService.updateMassageMsgCardToPiPiChat(feiShuConfig.getChatId());
//没有按摩群的id
// massageService.updateMassageMsgCardToPiPiChat();
String fileName1 = String.format("/templates/massage-singel-msg-card-end.json.json");
return getInteractiveCardStr(fileName1, "已为你推迟到最后");
} else if ("rob".equals(actionTypeSecond)) {
......@@ -134,7 +137,10 @@ public class FeiShuEventController {
Pain oldPain = painService.findByOpenId(oldUserId);
oldPain.setOpenId(robUserId);
painService.update(oldPain);
//ToDo 更新大群和按摩群的大卡片,异步
//ToDo 没有按摩群的id
massageService.updateMassageMsgCardToPiPiChat(feiShuConfig.getChatId());
//没有按摩群的id
// massageService.updateMassageMsgCardToPiPiChat();
String fileName1 = String.format("/templates/massage-msg-card-rob-end.json.json.json");
return getInteractiveCardStr(fileName1, "已经被抢啦啦啦~");
} else if ("next".equals(actionTypeSecond)) {
......
......@@ -58,7 +58,7 @@ public class SendMsgUseFeiShu {
userList.add(pushPainBO);
userList.add(pushPainBO1);
userList.add(pushPainBO2);
massageService.sendMassageMsgCardToPiPiChat(userList);
massageService.sendMassageMsgCardToPiPiChat(userList,feiShuConfig.getChatId());
return ResultGenerator.genSuccessResult();
}
}
......@@ -5,10 +5,12 @@ import com.pipihelper.project.feishu.bo.PushPainBO;
import com.pipihelper.project.feishu.dto.FeiShuConfig;
import com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO;
import com.pipihelper.project.feishu.entity.Pain;
import com.pipihelper.project.feishu.service.ChatMessageService;
import com.pipihelper.project.feishu.service.FeiShuApiService;
import com.pipihelper.project.feishu.service.PainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -36,7 +38,11 @@ public class MassageService {
@Autowired
private PainService painService;
public void sendMassageMsgCardToPiPiChat(List<PushPainBO> pushPainBOList){
@Autowired
private ChatMessageService chatMessageService;
//给群里发送消息
public void sendMassageMsgCardToPiPiChat(List<PushPainBO> pushPainBOList, String chatId){
List<List<String>> pushUser = new ArrayList<>();
for(PushPainBO pushPainBO:pushPainBOList){
List<String> user = new ArrayList<>();
......@@ -68,7 +74,7 @@ public class MassageService {
FeiShuMsgDTO feiShuMsgDTO = new FeiShuMsgDTO();
feiShuMsgDTO.setMsgType("interactive");
feiShuMsgDTO.setContent(content);
feiShuMsgDTO.setReceiveId(feiShuConfig.getChatId());
feiShuMsgDTO.setReceiveId(chatId);
log.info(feiShuMsgDTO.toString());
feiShuApiService.sendMsg(feiShuMsgDTO, "chat_id");
}
......@@ -80,44 +86,30 @@ public class MassageService {
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");
// }
//更新群消息
@Async
public void updateMassageMsgCardToPiPiChat(String chatId){
List<Pain> pains = painService.findAll();
String messageId = chatMessageService.findListChatAndType(chatId, 1).get(0).getMessageId();
List<List<String>> pushUser = new ArrayList<>();
for(Pain pain:pains){
List<String> user = new ArrayList<>();
//构建给大群发送的名单
user.add(pain.getIndex().toString());
user.add(pain.getName());
user.add(pain.getDepartMentName());
user.add(pain.getTimeRange());
user.add("");
pushUser.add(user);
}
//给大群更新发送消息
String content = massageMsgCardSerivce.genMassageMsgCardForCompany(pushUser);
log.info("给大群发送按摩消息:{}",content);
JSONObject patchMsg = new JSONObject();
patchMsg.put("content", content);
feiShuApiService.patchMsg(messageId, patchMsg);
}
......
......@@ -52,6 +52,9 @@ public class MassageNoticeScheduleService {
for(Pain pain:pains){
String messageId = pain.getMessageId();
massageService.updateSingleMassageMsgCardWhenBegin(messageId);
//1代表正在按
pain.setStatus(1);
painService.update(pain);
JSONObject noticeMsg = new JSONObject();
noticeMsg.put("user_id_list", Arrays.asList(pain.getOpenId()));
//发送应用内提醒
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!