Commit ad0a3465 by 裴大威

fix del start live

parent c61f5c80
......@@ -101,6 +101,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
......@@ -184,7 +185,7 @@ public class BookGroupClassifyBizImpl implements BookGroupClassifyBiz {
BookGroupClassify bookGroupClassify = new BookGroupClassify();
BeanUtils.copyProperties(addClassifyVO, bookGroupClassify);
QrcodeNameAndProIdDTO qrcodeNameAndProId = bookGroupBiz.getQrcodeNameAndProId(addClassifyVO.getBookGroupId());
if (qrcodeNameAndProId == null) {
if (Objects.isNull(qrcodeNameAndProId) || Objects.isNull(qrcodeNameAndProId.getProductId())) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "请先填写社群码信息!");
}
bookGroupClassify.setProductId(qrcodeNameAndProId.getProductId());
......
......@@ -57,40 +57,42 @@ public class WxLiveBroadcastReminderListener {
@ParamLog("直播开播提醒")
@RabbitHandler
public void onMessage(LiveCourseDetailInfoDto liveCourse) throws BizException {
if (Objects.isNull(liveCourse) || CollectionUtils.isEmpty(liveCourse.getTableDetailDtos())) {
return;
}
Map<Long, Long> collect = liveCourse.getTableDetailDtos().stream().collect(Collectors.toMap(TableDetailDto::getOriginId, TableDetailDto::getTableId));
final List<GroupQrcodeServerDTO> wxGroups = groupQrcodeBiz.getWxGroupIdByServerId(Lists.newArrayList(collect.keySet()));
log.info("[直播开播提醒] : liveCourse :{} wxGroups:{}", liveCourse, wxGroups);
if (CollectionUtils.isEmpty(wxGroups)) {
return;
}
final Map<Long, AccountSettingDto> accountMap = Maps.newHashMap();
List<String> wxGroupIds = wxGroups.stream().map(GroupQrcodeServerDTO::getWxGroupId).collect(Collectors.toList());
Map<String, BookWxQrcodeDTO> groupVersion = weixinQrcodeBiz.getGroupVersion(wxGroupIds);
final List<GroupQrcodeServerDTO> wxGroups2 = wxGroups.stream().collect(
Collectors. collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(GroupQrcodeServerDTO::getWxGroupId))), ArrayList::new)
);
for (GroupQrcodeServerDTO dto : wxGroups2) {
// 避免重复挂服务调用性能损耗
AccountSettingDto accountSettingDto = accountMap.get(dto.getChannelId());
if (Objects.isNull(accountSettingDto)) {
accountSettingDto = qrcodeSceneConsr.getWechatInfo(dto.getChannelId());
accountMap.put(dto.getChannelId(), accountSettingDto);
}
String linkUrl = SendWeixinRequestTools.splitUrlNew(accountSettingDto, dto.getLinkUrl(), dto.getBookGroupId(), dto.getClassifyId(), dto.getGroupQrcodeId());
// 定位到具体课程
String liveInfo = linkUrl.replace("liveinfo?", "lesson/" + liveCourse.getLessonId() + "?tableId=" + collect.get(dto.getServeId()) + "&");
String shortUrl4Own = UrlUtils.getShortUrl4Own(liveInfo);
SendTextMessageVO vo = new SendTextMessageVO();
vo.setContent("【" + liveCourse.getTitle() + "】即将开播啦,感兴趣的同学们可以开始进入啦。猛戳直播链接:" + shortUrl4Own);
vo.setWxGroupId(dto.getWxGroupId());
// 负载均衡会根据群获取该群活跃小号,所以传什么都不重要,写死为“我为你笑着”
vo.setAltId(Optional.ofNullable(groupVersion.get(dto.getWxGroupId())).orElse(new BookWxQrcodeDTO()).getRobotWxId());
vo.setIp(Optional.ofNullable(groupVersion.get(dto.getWxGroupId())).orElse(new BookWxQrcodeDTO()).getWechatGroupIp());
WxGroupSDK.sendTextMessage(vo);
}
// 20190929 消息量大,重复消息多,导致小号闪退或者崩溃,暂时屏蔽掉
log.info("[直播开播提醒] liveCourse:{}", liveCourse);
// if (Objects.isNull(liveCourse) || CollectionUtils.isEmpty(liveCourse.getTableDetailDtos())) {
// return;
// }
// Map<Long, Long> collect = liveCourse.getTableDetailDtos().stream().collect(Collectors.toMap(TableDetailDto::getOriginId, TableDetailDto::getTableId));
// final List<GroupQrcodeServerDTO> wxGroups = groupQrcodeBiz.getWxGroupIdByServerId(Lists.newArrayList(collect.keySet()));
// log.info("[直播开播提醒] : liveCourse :{} wxGroups:{}", liveCourse, wxGroups);
// if (CollectionUtils.isEmpty(wxGroups)) {
// return;
// }
// final Map<Long, AccountSettingDto> accountMap = Maps.newHashMap();
// List<String> wxGroupIds = wxGroups.stream().map(GroupQrcodeServerDTO::getWxGroupId).collect(Collectors.toList());
// Map<String, BookWxQrcodeDTO> groupVersion = weixinQrcodeBiz.getGroupVersion(wxGroupIds);
// final List<GroupQrcodeServerDTO> wxGroups2 = wxGroups.stream().collect(
// Collectors. collectingAndThen(
// Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(GroupQrcodeServerDTO::getWxGroupId))), ArrayList::new)
// );
// for (GroupQrcodeServerDTO dto : wxGroups2) {
// // 避免重复挂服务调用性能损耗
// AccountSettingDto accountSettingDto = accountMap.get(dto.getChannelId());
// if (Objects.isNull(accountSettingDto)) {
// accountSettingDto = qrcodeSceneConsr.getWechatInfo(dto.getChannelId());
// accountMap.put(dto.getChannelId(), accountSettingDto);
// }
// String linkUrl = SendWeixinRequestTools.splitUrlNew(accountSettingDto, dto.getLinkUrl(), dto.getBookGroupId(), dto.getClassifyId(), dto.getGroupQrcodeId());
// // 定位到具体课程
// String liveInfo = linkUrl.replace("liveinfo?", "lesson/" + liveCourse.getLessonId() + "?tableId=" + collect.get(dto.getServeId()) + "&");
// String shortUrl4Own = UrlUtils.getShortUrl4Own(liveInfo);
// SendTextMessageVO vo = new SendTextMessageVO();
// vo.setContent("【" + liveCourse.getTitle() + "】即将开播啦,感兴趣的同学们可以开始进入啦。猛戳直播链接:" + shortUrl4Own);
// vo.setWxGroupId(dto.getWxGroupId());
// // 负载均衡会根据群获取该群活跃小号,所以传什么都不重要,写死为“我为你笑着”
// vo.setAltId(Optional.ofNullable(groupVersion.get(dto.getWxGroupId())).orElse(new BookWxQrcodeDTO()).getRobotWxId());
// vo.setIp(Optional.ofNullable(groupVersion.get(dto.getWxGroupId())).orElse(new BookWxQrcodeDTO()).getWechatGroupIp());
// WxGroupSDK.sendTextMessage(vo);
// }
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment