|
@@ -1,5 +1,6 @@
|
|
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;
|
|
@@ -12,6 +13,7 @@ import com.tzld.piaoquan.wecom.model.po.MessageAttachment;
|
|
import com.tzld.piaoquan.wecom.model.po.MessageAttachmentExample;
|
|
import com.tzld.piaoquan.wecom.model.po.MessageAttachmentExample;
|
|
import com.tzld.piaoquan.wecom.model.po.User;
|
|
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.utils.DateUtil;
|
|
import com.tzld.piaoquan.wecom.utils.DateUtil;
|
|
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;
|
|
@@ -35,6 +37,9 @@ public class WeComMessageDataJob {
|
|
@Autowired
|
|
@Autowired
|
|
private RedisTemplate<String, Object> redisTemplate;
|
|
private RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private MessageService messageService;
|
|
|
|
+
|
|
private static final int sum = 3;
|
|
private static final int sum = 3;
|
|
|
|
|
|
List<PushMessage> goodList = new ArrayList<>();
|
|
List<PushMessage> goodList = new ArrayList<>();
|
|
@@ -82,6 +87,7 @@ public class WeComMessageDataJob {
|
|
init();
|
|
init();
|
|
Map<String, List<String>> res = new HashMap<>();
|
|
Map<String, List<String>> res = new HashMap<>();
|
|
UserExample example = new UserExample();
|
|
UserExample example = new UserExample();
|
|
|
|
+ example.createCriteria().andExternalUserId3rdPartyEqualTo("wmgizUDQAAYdFWt1hts2fU6P2h84fPvQ");
|
|
long count = userMapper.countByExample(example);
|
|
long count = userMapper.countByExample(example);
|
|
int page = 1;
|
|
int page = 1;
|
|
int pageSize = 1000;
|
|
int pageSize = 1000;
|
|
@@ -143,9 +149,13 @@ 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<>();
|
|
|
|
+ staffExtIdList.add("wogizUDQAAk5Z_5nLRD-XTAPU9poaRCw");
|
|
|
|
+ staffExtIdList.add("wogizUDQAAzM5HbqIyA4k3KR6D8vKp3w");
|
|
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", "群发名称");
|
|
|
|
|
|
+ jsonObject.put("name", "日常push-0926-推荐官");
|
|
|
|
+ jsonObject.put("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) {
|
|
@@ -169,15 +179,25 @@ public class WeComMessageDataJob {
|
|
jsonObject.put("attachments", attachments);
|
|
jsonObject.put("attachments", attachments);
|
|
List<List<String>> lists = Lists.partition(entry.getValue(), 10000);
|
|
List<List<String>> lists = Lists.partition(entry.getValue(), 10000);
|
|
for (List<String> list : lists) {
|
|
for (List<String> list : lists) {
|
|
|
|
+ List<JSONObject> staffEuList = new ArrayList<>();
|
|
JSONObject newJSONObject = new JSONObject();
|
|
JSONObject newJSONObject = new JSONObject();
|
|
newJSONObject.putAll(jsonObject);
|
|
newJSONObject.putAll(jsonObject);
|
|
- JSONObject staff_eu_list = new JSONObject();
|
|
|
|
- staff_eu_list.put("staff_ext_id", "员工id");
|
|
|
|
- staff_eu_list.put("eu_ext_ids", list);
|
|
|
|
- newJSONObject.put("staff_eu_list", staff_eu_list);
|
|
|
|
|
|
+ for (String staffExtId : staffExtIdList) {
|
|
|
|
+ JSONObject staff_eu = new JSONObject();
|
|
|
|
+ staff_eu.put("staff_ext_id", staffExtId);
|
|
|
|
+ staff_eu.put("eu_ext_ids", list);
|
|
|
|
+ staffEuList.add(staff_eu);
|
|
|
|
+ }
|
|
|
|
+ newJSONObject.put("staff_eu_list", staffEuList);
|
|
pushList.add(newJSONObject);
|
|
pushList.add(newJSONObject);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (CollectionUtils.isEmpty(pushList)) {
|
|
|
|
+ throw new RuntimeException("推送视频生成失败");
|
|
|
|
+ }
|
|
|
|
+ for (JSONObject jsonObject : pushList) {
|
|
|
|
+ messageService.pushMessage(jsonObject);
|
|
|
|
+ }
|
|
System.out.println(pushList.get(0));
|
|
System.out.println(pushList.get(0));
|
|
}
|
|
}
|
|
}
|
|
}
|