|
@@ -15,6 +15,7 @@ import com.tzld.piaoquan.wecom.utils.OdpsUtil;
|
|
import com.tzld.piaoquan.wecom.utils.page.Page;
|
|
import com.tzld.piaoquan.wecom.utils.page.Page;
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -28,6 +29,7 @@ import java.util.stream.Collectors;
|
|
import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.GUARANTEED_MINIPROGRAM_KEY;
|
|
import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.GUARANTEED_MINIPROGRAM_KEY;
|
|
import static com.tzld.piaoquan.wecom.common.constant.TimeConstant.MILLISECOND_DAY;
|
|
import static com.tzld.piaoquan.wecom.common.constant.TimeConstant.MILLISECOND_DAY;
|
|
|
|
|
|
|
|
+@Log4j2
|
|
@Component
|
|
@Component
|
|
public class WeComMessageDataJob {
|
|
public class WeComMessageDataJob {
|
|
|
|
|
|
@@ -92,6 +94,7 @@ public class WeComMessageDataJob {
|
|
List<Long> videoIdList = Objects.requireNonNull(redisTemplate.opsForList().range(GUARANTEED_MINIPROGRAM_KEY, 0, -1))
|
|
List<Long> videoIdList = Objects.requireNonNull(redisTemplate.opsForList().range(GUARANTEED_MINIPROGRAM_KEY, 0, -1))
|
|
.stream().map(o -> (Integer) o).map(String::valueOf).map(Long::parseLong).collect(Collectors.toList());
|
|
.stream().map(o -> (Integer) o).map(String::valueOf).map(Long::parseLong).collect(Collectors.toList());
|
|
if (CollectionUtils.isEmpty(videoIdList)) {
|
|
if (CollectionUtils.isEmpty(videoIdList)) {
|
|
|
|
+ log.error("推送消息初始化失败,保底数据为空");
|
|
throw new RuntimeException("保底数据为空");
|
|
throw new RuntimeException("保底数据为空");
|
|
}
|
|
}
|
|
List<Long> saveVideoIds = new ArrayList<>();
|
|
List<Long> saveVideoIds = new ArrayList<>();
|
|
@@ -114,6 +117,7 @@ public class WeComMessageDataJob {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (saveVideoIds.size() < MAX_VIDEO_NUM) {
|
|
if (saveVideoIds.size() < MAX_VIDEO_NUM) {
|
|
|
|
+ log.error("推送消息初始化失败,保底数据不足");
|
|
throw new RuntimeException("保底数据不足");
|
|
throw new RuntimeException("保底数据不足");
|
|
}
|
|
}
|
|
guaranteedVideoIdList = saveVideoIds;
|
|
guaranteedVideoIdList = saveVideoIds;
|
|
@@ -161,6 +165,7 @@ public class WeComMessageDataJob {
|
|
updateMessageAttachment.setSendTime(new Date());
|
|
updateMessageAttachment.setSendTime(new Date());
|
|
messageAttachmentMapper.updateByPrimaryKeySelective(updateMessageAttachment);
|
|
messageAttachmentMapper.updateByPrimaryKeySelective(updateMessageAttachment);
|
|
}
|
|
}
|
|
|
|
+ log.info("getGuaranteedVideoIdNum={}", getGuaranteedVideoIdNum);
|
|
//移除从redis中获取的保底数据
|
|
//移除从redis中获取的保底数据
|
|
for (int i = 0; i < getGuaranteedVideoIdNum; i++) {
|
|
for (int i = 0; i < getGuaranteedVideoIdNum; i++) {
|
|
redisTemplate.opsForList().leftPop(GUARANTEED_MINIPROGRAM_KEY);
|
|
redisTemplate.opsForList().leftPop(GUARANTEED_MINIPROGRAM_KEY);
|
|
@@ -207,7 +212,8 @@ public class WeComMessageDataJob {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (n < MAX_VIDEO_NUM) {
|
|
if (n < MAX_VIDEO_NUM) {
|
|
- throw new RuntimeException("保底数据异常");
|
|
|
|
|
|
+ log.error("组装数据失败 user={}", user);
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
StaffWithUserExample example = new StaffWithUserExample();
|
|
StaffWithUserExample example = new StaffWithUserExample();
|
|
example.createCriteria().andUserIdEqualTo(user.getId());
|
|
example.createCriteria().andUserIdEqualTo(user.getId());
|
|
@@ -317,11 +323,11 @@ public class WeComMessageDataJob {
|
|
newJSONObject.put("staff_eu_list", staffEuList);
|
|
newJSONObject.put("staff_eu_list", staffEuList);
|
|
pushList.add(newJSONObject);
|
|
pushList.add(newJSONObject);
|
|
}
|
|
}
|
|
-
|
|
|
|
if (CollectionUtils.isEmpty(pushList)) {
|
|
if (CollectionUtils.isEmpty(pushList)) {
|
|
- throw new RuntimeException("推送视频生成失败");
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
for (JSONObject pushJsonObject : pushList) {
|
|
for (JSONObject pushJsonObject : pushList) {
|
|
|
|
+ log.info("pushMessage pushJsonObject={}", pushJsonObject);
|
|
boolean flag = messageService.pushMessage(pushJsonObject);
|
|
boolean flag = messageService.pushMessage(pushJsonObject);
|
|
if (!flag) {
|
|
if (!flag) {
|
|
return flag;
|
|
return flag;
|