|
@@ -206,11 +206,14 @@ public class WeComMessageDataJob {
|
|
|
if (CollectionUtils.isEmpty(corps)) {
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
+ List<Long> staffIds = new ArrayList<>();
|
|
|
+ if (xxlJobParam.getStaffId() != null) {
|
|
|
+ staffIds.add(xxlJobParam.getStaffId());
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(xxlJobParam.getStaffIds())) {
|
|
|
+ staffIds.addAll(xxlJobParam.getStaffIds());
|
|
|
+ }
|
|
|
for (Corp corp : corps) {
|
|
|
- Long staffId = null;
|
|
|
- if (xxlJobParam.getStaffId() != null) {
|
|
|
- staffId = xxlJobParam.getStaffId();
|
|
|
- }
|
|
|
UserExample userExample = new UserExample();
|
|
|
userExample.createCriteria().andExternalUserIdIsNotNull().andCorpIdEqualTo(corp.getId());
|
|
|
if (xxlJobParam.getUserId() != null) {
|
|
@@ -229,7 +232,7 @@ public class WeComMessageDataJob {
|
|
|
//落库逻辑
|
|
|
List<SendMessage> allSeneMessageList = new ArrayList<>();
|
|
|
for (User user : userList) {
|
|
|
- List<SendMessage> sendMessageList = getSendMessage(user, staffId, corp.getId());
|
|
|
+ List<SendMessage> sendMessageList = getSendMessage(user, staffIds, corp.getId());
|
|
|
if (CollectionUtils.isEmpty(sendMessageList)) {
|
|
|
continue;
|
|
|
}
|
|
@@ -241,40 +244,54 @@ public class WeComMessageDataJob {
|
|
|
sendMessageMapper.insertList(allSeneMessageList);
|
|
|
}
|
|
|
}
|
|
|
- //组装好当天要发送的消息后 记录时间 删除保底数据
|
|
|
- saveGuaranteedVideoIdList();
|
|
|
+ //组装好当天要发送的消息后 记录时间
|
|
|
+ saveGuaranteedVideoIdList(staffIds);
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
|
|
|
- private void saveGuaranteedVideoIdList() {
|
|
|
+ private void saveGuaranteedVideoIdList(List<Long> staffIds) {
|
|
|
String key = String.format(GUARANTEED_MINI_PROGRAM_KEY, DateUtil.getThatDayDateString());
|
|
|
GuaranteedParam guaranteedParam = (GuaranteedParam) redisTemplate.opsForValue().get(key);
|
|
|
if (guaranteedParam == null || CollectionUtils.isEmpty(guaranteedParam.getVideoParamList())) {
|
|
|
return;
|
|
|
}
|
|
|
- Set<Long> videoIdSet = new HashSet<>();
|
|
|
- for (VideoParam videoParam : guaranteedParam.getVideoParamList()) {
|
|
|
- if (CollectionUtils.isEmpty(videoParam.getVideoIds())) {
|
|
|
- continue;
|
|
|
+ if (CollectionUtils.isEmpty(staffIds)) {
|
|
|
+ Set<Long> videoIdSet = new HashSet<>();
|
|
|
+ for (VideoParam videoParam : guaranteedParam.getVideoParamList()) {
|
|
|
+ if (CollectionUtils.isEmpty(videoParam.getVideoIds())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ videoIdSet.addAll(videoParam.getVideoIds());
|
|
|
}
|
|
|
- videoIdSet.addAll(videoParam.getVideoIds());
|
|
|
- }
|
|
|
- List<Long> videoIdList = new ArrayList<>(videoIdSet);
|
|
|
- MessageAttachmentExample example = new MessageAttachmentExample();
|
|
|
- example.createCriteria().andMiniprogramVideoIdIn(videoIdList);
|
|
|
- MessageAttachment updateMessageAttachment = new MessageAttachment();
|
|
|
- updateMessageAttachment.setSendTime(new Date());
|
|
|
- messageAttachmentMapper.updateByExampleSelective(updateMessageAttachment, example);
|
|
|
- redisTemplate.delete(key);
|
|
|
+ List<Long> videoIdList = new ArrayList<>(videoIdSet);
|
|
|
+ MessageAttachmentExample example = new MessageAttachmentExample();
|
|
|
+ example.createCriteria().andMiniprogramVideoIdIn(videoIdList).andSendTimeIsNull();
|
|
|
+ MessageAttachment updateMessageAttachment = new MessageAttachment();
|
|
|
+ updateMessageAttachment.setSendTime(new Date());
|
|
|
+ messageAttachmentMapper.updateByExampleSelective(updateMessageAttachment, example);
|
|
|
+ } else {
|
|
|
+ for (VideoParam videoParam : guaranteedParam.getVideoParamList()) {
|
|
|
+ if (!CollectionUtils.isEmpty(staffIds) && staffIds.contains(videoParam.getStaffId())) {
|
|
|
+ if (CollectionUtils.isEmpty(videoParam.getVideoIds())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ MessageAttachmentExample example = new MessageAttachmentExample();
|
|
|
+ example.createCriteria().andMiniprogramVideoIdIn(videoParam.getVideoIds()).andStaffIdEqualTo(videoParam.getStaffId());
|
|
|
+ MessageAttachment updateMessageAttachment = new MessageAttachment();
|
|
|
+ updateMessageAttachment.setSendTime(new Date());
|
|
|
+ messageAttachmentMapper.updateByExampleSelective(updateMessageAttachment, example);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private List<SendMessage> getSendMessage(User user, Long staffId, Long corpId) {
|
|
|
+ private List<SendMessage> getSendMessage(User user, List<Long> staffIds, Long corpId) {
|
|
|
StaffWithUserExample example = new StaffWithUserExample();
|
|
|
StaffWithUserExample.Criteria criteria = example.createCriteria();
|
|
|
criteria.andUserIdEqualTo(user.getId());
|
|
|
criteria.andIsDeleteEqualTo(0);
|
|
|
- if (staffId != null) {
|
|
|
- criteria.andStaffIdEqualTo(staffId);
|
|
|
+ if (!CollectionUtils.isEmpty(staffIds)) {
|
|
|
+ criteria.andStaffIdIn(staffIds);
|
|
|
}
|
|
|
List<StaffWithUser> staffWithUserList = staffWithUserMapper.selectByExample(example);
|
|
|
if (CollectionUtils.isEmpty(staffWithUserList)) {
|