|
@@ -1,11 +1,9 @@
|
|
package com.tzld.piaoquan.wecom.job;
|
|
package com.tzld.piaoquan.wecom.job;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.aliyun.odps.data.Record;
|
|
import com.aliyun.odps.data.Record;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
-import com.tzld.piaoquan.wecom.common.constant.MiniprogramConstant;
|
|
|
|
import com.tzld.piaoquan.wecom.dao.mapper.MessageAttachmentMapper;
|
|
import com.tzld.piaoquan.wecom.dao.mapper.MessageAttachmentMapper;
|
|
import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
|
|
import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
|
|
import com.tzld.piaoquan.wecom.model.bo.PushMessage;
|
|
import com.tzld.piaoquan.wecom.model.bo.PushMessage;
|
|
@@ -15,6 +13,7 @@ import com.tzld.piaoquan.wecom.model.po.User;
|
|
import com.tzld.piaoquan.wecom.model.po.UserExample;
|
|
import com.tzld.piaoquan.wecom.model.po.UserExample;
|
|
import com.tzld.piaoquan.wecom.service.MessageService;
|
|
import com.tzld.piaoquan.wecom.service.MessageService;
|
|
import com.tzld.piaoquan.wecom.utils.DateUtil;
|
|
import com.tzld.piaoquan.wecom.utils.DateUtil;
|
|
|
|
+import com.tzld.piaoquan.wecom.utils.MessageUtil;
|
|
import com.tzld.piaoquan.wecom.utils.OdpsUtil;
|
|
import com.tzld.piaoquan.wecom.utils.OdpsUtil;
|
|
import com.tzld.piaoquan.wecom.utils.page.Page;
|
|
import com.tzld.piaoquan.wecom.utils.page.Page;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -25,6 +24,8 @@ import org.springframework.util.CollectionUtils;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
+import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.GUARANTEED_MINIPROGRAM_KEY;
|
|
|
|
+
|
|
@Component
|
|
@Component
|
|
public class WeComMessageDataJob {
|
|
public class WeComMessageDataJob {
|
|
|
|
|
|
@@ -48,8 +49,6 @@ public class WeComMessageDataJob {
|
|
//初始化操作
|
|
//初始化操作
|
|
void init() {
|
|
void init() {
|
|
String sql = String.format("SELECT * FROM loghubods.history_good_video_can_push_user_list where dt = %s;", DateUtil.getBeforeDayDateString());
|
|
String sql = String.format("SELECT * FROM loghubods.history_good_video_can_push_user_list where dt = %s;", DateUtil.getBeforeDayDateString());
|
|
-// String sql = String.format("SELECT * FROM loghubods.history_good_video_can_push_user_list where dt = %s;", "20240922");
|
|
|
|
-
|
|
|
|
List<Record> recordList = OdpsUtil.getOdpsData(sql);
|
|
List<Record> recordList = OdpsUtil.getOdpsData(sql);
|
|
if (CollectionUtils.isEmpty(recordList)) {
|
|
if (CollectionUtils.isEmpty(recordList)) {
|
|
return;
|
|
return;
|
|
@@ -64,7 +63,7 @@ public class WeComMessageDataJob {
|
|
list.add(pushMessage);
|
|
list.add(pushMessage);
|
|
}
|
|
}
|
|
goodList = list;
|
|
goodList = list;
|
|
- List<Long> saveVideoIds = Objects.requireNonNull(redisTemplate.opsForList().range(MiniprogramConstant.GUARANTEED_MINIPROGRAM_KEY, 0, 2))
|
|
|
|
|
|
+ List<Long> saveVideoIds = Objects.requireNonNull(redisTemplate.opsForList().range(GUARANTEED_MINIPROGRAM_KEY, 0, 2))
|
|
.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(saveVideoIds)) {
|
|
if (CollectionUtils.isEmpty(saveVideoIds)) {
|
|
throw new RuntimeException("保底数据为空");
|
|
throw new RuntimeException("保底数据为空");
|
|
@@ -106,8 +105,6 @@ public class WeComMessageDataJob {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- System.out.println(res.size());
|
|
|
|
pushMessage(res);
|
|
pushMessage(res);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -148,13 +145,16 @@ public class WeComMessageDataJob {
|
|
|
|
|
|
public void pushMessage(Map<String, List<String>> map) {
|
|
public void pushMessage(Map<String, List<String>> map) {
|
|
List<JSONObject> pushList = new ArrayList<>();
|
|
List<JSONObject> pushList = new ArrayList<>();
|
|
|
|
+ //发送人员 暂时写死 只有两个
|
|
List<String> staffExtIdList = new ArrayList<>();
|
|
List<String> staffExtIdList = new ArrayList<>();
|
|
staffExtIdList.add("wogizUDQAAk5Z_5nLRD-XTAPU9poaRCw");
|
|
staffExtIdList.add("wogizUDQAAk5Z_5nLRD-XTAPU9poaRCw");
|
|
staffExtIdList.add("wogizUDQAAzM5HbqIyA4k3KR6D8vKp3w");
|
|
staffExtIdList.add("wogizUDQAAzM5HbqIyA4k3KR6D8vKp3w");
|
|
|
|
+ String text = messageService.getMessageText();
|
|
|
|
+ String name = MessageUtil.getName();
|
|
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
|
|
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
- jsonObject.put("name", "日常push-0926-推荐官");
|
|
|
|
- jsonObject.put("text", "- 晚上好!愿这宁静的夜晚带给你心灵的放松与安宁,以下是大家都在看的爆款视频!");
|
|
|
|
|
|
+ jsonObject.put("name", name);
|
|
|
|
+ jsonObject.put("text", text);
|
|
JSONArray attachments = new JSONArray();
|
|
JSONArray attachments = new JSONArray();
|
|
List<Long> videoIdList = Arrays.stream(entry.getKey().split("_")).map(Long::parseLong).collect(Collectors.toList());
|
|
List<Long> videoIdList = Arrays.stream(entry.getKey().split("_")).map(Long::parseLong).collect(Collectors.toList());
|
|
for (Long videoId : videoIdList) {
|
|
for (Long videoId : videoIdList) {
|
|
@@ -197,6 +197,5 @@ public class WeComMessageDataJob {
|
|
for (JSONObject jsonObject : pushList) {
|
|
for (JSONObject jsonObject : pushList) {
|
|
messageService.pushMessage(jsonObject);
|
|
messageService.pushMessage(jsonObject);
|
|
}
|
|
}
|
|
- System.out.println(pushList.get(0));
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|