添加直播推荐,并且发送消息

This commit is contained in:
sh
2026-06-26 21:09:20 +08:00
parent cfff4b62c3
commit 294ee020d0
7 changed files with 131 additions and 0 deletions

View File

@@ -66,4 +66,13 @@ public class LiveApplyController extends BaseController
{
return toAjax(liveApplyService.deleteLiveApplyByIds(ids));
}
@ApiOperation("直播推荐")
@PreAuthorize("@ss.hasPermi('live:apply:liveRecommendNotic')")
@GetMapping("/liveRecommendNotic")
public AjaxResult liveRecommendNotic(@RequestBody LiveApply liveApply)
{
liveApplyService.sendLiveRecommendNotic(liveApply);
return success();
}
}

View File

@@ -41,4 +41,8 @@ public class LiveApply extends BaseEntity {
@ApiModelProperty("状态 1通过2不通过")
private String liveStatus;
@TableField(exist = false)
@ApiModelProperty("期望岗位,逗号分隔")
private String jobTitleId;
}

View File

@@ -58,4 +58,6 @@ public interface AppUserMapper extends BaseMapper<AppUser>
AppUser getAppUserBase(@Param("idCard") String idCard);
Integer getIsJbdUser(@Param("idCard") String idCard);
List<Long> selectUsersNotice(@Param("jobTitles") List<String> jobTitles);
}

View File

@@ -16,4 +16,6 @@ public interface LiveApplyService extends IService<LiveApply> {
int updateLiveApply(LiveApply liveApply);
int deleteLiveApplyByIds(Long[] ids);
public void sendLiveRecommendNotic(LiveApply liveApply);
}

View File

@@ -1,20 +1,34 @@
package com.ruoyi.cms.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.cms.domain.Notice;
import com.ruoyi.cms.domain.liveSteam.LiveApply;
import com.ruoyi.cms.mapper.AppUserMapper;
import com.ruoyi.cms.mapper.JobTitleMapper;
import com.ruoyi.cms.mapper.LiveApplyMapper;
import com.ruoyi.cms.mapper.NoticeMapper;
import com.ruoyi.cms.service.LiveApplyService;
import com.ruoyi.cms.util.notice.NoticeUtils;
import com.ruoyi.common.core.domain.entity.JobTitle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class LiveApplyServiceImpl extends ServiceImpl<LiveApplyMapper, LiveApply> implements LiveApplyService {
@Autowired
private LiveApplyMapper liveApplyMapper;
@Autowired
private AppUserMapper appUserMapper;
@Autowired
private NoticeMapper noticeMapper;
@Autowired
private JobTitleMapper jobTitleMapper;
@Override
public LiveApply selectLiveApplyById(Long id)
@@ -46,4 +60,74 @@ public class LiveApplyServiceImpl extends ServiceImpl<LiveApplyMapper, LiveApply
return liveApplyMapper.deleteBatchIds(Arrays.asList(ids));
}
@Override
public void sendLiveRecommendNotic(LiveApply liveApply) {
if (liveApply == null || liveApply.getId() == null) {
return;
}
LiveApply applyDetail = liveApplyMapper.selectById(liveApply.getId());
if (applyDetail == null) {
return;
}
String jobStr = liveApply.getJobTitleId();
List<String> rawJobIdStrList = new ArrayList<>();
if (jobStr != null && !jobStr.trim().isEmpty()) {
rawJobIdStrList = Arrays.stream(jobStr.split(","))
.map(String::trim)
.filter(s -> !s.trim().isEmpty())
.collect(Collectors.toList());
}
if (rawJobIdStrList.isEmpty()) {
return;
}
List<Long> collect = rawJobIdStrList.stream().map(Long::valueOf).collect(Collectors.toList());
String jobNameText = "";
if (!collect.isEmpty()) {
List<JobTitle> jobTitleList = jobTitleMapper.selectBatchIds(collect);
jobNameText = jobTitleList.stream().map(JobTitle::getJobName).collect(Collectors.joining(","));
}
List<Long> userIdList = appUserMapper.selectUsersNotice(rawJobIdStrList);
if (!userIdList.isEmpty()) {
batchCreateNotice(userIdList, applyDetail,jobNameText);
}
}
/**
* 生成
* @param userIds
* @param liveApply
*/
public void batchCreateNotice(List<Long> userIds,LiveApply liveApply,String jobNameText){
final Long busId = liveApply.getId();
final String isRead = NoticeUtils.NOTICE_WD;
final String title = NoticeUtils.NOTICE_TYPE_ZBTZ;
final String subTitle = NoticeUtils.NOTICE_TYPE_ZBTZ;
final String noticeType = NoticeUtils.NOTICE_TYPE_XTLX;
final String remark = NoticeUtils.NOTICE_REMARK;
final String content = NoticeUtils.zbkbMsg(liveApply,jobNameText);
int batchSize = 500;
int total = userIds.size();
for (int i = 0; i < total; i += batchSize) {
int end = Math.min(i + batchSize, total);
List<Long> subUserIds = userIds.subList(i, end);
List<Notice> noticeList = new ArrayList<>(subUserIds.size());
for (Long uid : subUserIds) {
Notice n = new Notice();
n.setUserId(uid);
n.setBussinessId(busId);
n.setIsRead(isRead);
n.setTitle(title);
n.setSubTitle(subTitle);
n.setNoticeType(noticeType);
n.setRemark(remark);
n.setNoticeContent(content);
noticeList.add(n);
}
noticeMapper.batchInsert(noticeList);
}
}
}

View File

@@ -3,6 +3,7 @@ package com.ruoyi.cms.util.notice;
import com.ruoyi.cms.domain.EmployeeConfirm;
import com.ruoyi.cms.domain.Job;
import com.ruoyi.cms.domain.Notice;
import com.ruoyi.cms.domain.liveSteam.LiveApply;
import com.ruoyi.common.core.domain.entity.AppUser;
import java.util.ArrayList;
@@ -46,6 +47,11 @@ public class NoticeUtils {
/*************面试end*************/
/*************直播start*************/
public static final String NOTICE_TYPE_ZBTZ="直播通知";
public static final String NOTICE_LIVE_STARTMSG = "您可能感兴趣的直播开播啦!\n本次直播岗位%s\n主持人%s\n开播时段%s ~ %s\n请前往首页点击直播按钮观看";
/*************直播end*************/
/**
* 拼装岗位
*/
@@ -133,4 +139,16 @@ public class NoticeUtils {
jbName +NoticeUtils.NOTICE_COMENT_FF + typeText +""+ msgExtra
);
}
/**
* 直播开播
* @return
*/
public static String zbkbMsg(LiveApply liveApply,String jobNameText){
String jobNames = jobNameText == null ? "" : jobNameText.replace(",", "");
String livePerson = liveApply.getLivePerson() == null ? "" : liveApply.getLivePerson();
String start = liveApply.getLiveStartTime() == null ? "" : liveApply.getLiveStartTime();
String end = liveApply.getLiveEndTime() == null ? "" : liveApply.getLiveEndTime();
return String.format(NOTICE_LIVE_STARTMSG, jobNames, livePerson, start, end);
}
}