Commit b4708b81 by weiss

1

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