|
@@ -3,6 +3,7 @@ package com.tzld.piaoquan.api.job.wecom.thirdpart;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
|
|
|
|
+import com.tzld.piaoquan.api.component.VideoApiService;
|
|
|
import com.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformPlanMapperExt;
|
|
import com.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformPlanMapperExt;
|
|
|
import com.tzld.piaoquan.api.dao.mapper.wecom.thirdpart.ThirdPartWeComMsgMapper;
|
|
import com.tzld.piaoquan.api.dao.mapper.wecom.thirdpart.ThirdPartWeComMsgMapper;
|
|
|
import com.tzld.piaoquan.api.model.param.wecom.thirdpart.CdnUploadImgLinkRequest;
|
|
import com.tzld.piaoquan.api.model.param.wecom.thirdpart.CdnUploadImgLinkRequest;
|
|
@@ -13,22 +14,27 @@ import com.tzld.piaoquan.api.model.po.wecom.thirdpart.ThirdPartWeComMsg;
|
|
|
import com.tzld.piaoquan.api.model.po.wecom.thirdpart.ThirdPartWeComMsgExample;
|
|
import com.tzld.piaoquan.api.model.po.wecom.thirdpart.ThirdPartWeComMsgExample;
|
|
|
import com.tzld.piaoquan.api.model.po.wecom.thirdpart.ThirdPartWeComRoom;
|
|
import com.tzld.piaoquan.api.model.po.wecom.thirdpart.ThirdPartWeComRoom;
|
|
|
import com.tzld.piaoquan.api.model.po.wecom.thirdpart.ThirdPartWeComStaff;
|
|
import com.tzld.piaoquan.api.model.po.wecom.thirdpart.ThirdPartWeComStaff;
|
|
|
|
|
+import com.tzld.piaoquan.api.model.vo.contentplatform.WxVideoV2VO;
|
|
|
import com.tzld.piaoquan.api.service.WeComThirdPartyService;
|
|
import com.tzld.piaoquan.api.service.WeComThirdPartyService;
|
|
|
import com.tzld.piaoquan.api.util.CdnUtil;
|
|
import com.tzld.piaoquan.api.util.CdnUtil;
|
|
|
import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
|
|
import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
|
|
|
import com.tzld.piaoquan.growth.common.model.po.Staff;
|
|
import com.tzld.piaoquan.growth.common.model.po.Staff;
|
|
|
import com.tzld.piaoquan.growth.common.service.MessageAttachmentService;
|
|
import com.tzld.piaoquan.growth.common.service.MessageAttachmentService;
|
|
|
import com.tzld.piaoquan.growth.common.utils.DateUtil;
|
|
import com.tzld.piaoquan.growth.common.utils.DateUtil;
|
|
|
|
|
+import com.tzld.piaoquan.growth.common.utils.LarkRobotUtil;
|
|
|
import com.tzld.piaoquan.growth.common.utils.MessageUtil;
|
|
import com.tzld.piaoquan.growth.common.utils.MessageUtil;
|
|
|
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.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
@@ -44,6 +50,8 @@ public class WeComSendMsgJob {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
MessageAttachmentService messageAttachmentService;
|
|
MessageAttachmentService messageAttachmentService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
|
+ VideoApiService videoApiService;
|
|
|
|
|
+ @Autowired
|
|
|
ContentPlatformPlanMapperExt planMapperExt;
|
|
ContentPlatformPlanMapperExt planMapperExt;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
ThirdPartWeComMsgMapper thirdPartWeComMsgMapper;
|
|
ThirdPartWeComMsgMapper thirdPartWeComMsgMapper;
|
|
@@ -56,6 +64,8 @@ public class WeComSendMsgJob {
|
|
|
private Integer videoNum;
|
|
private Integer videoNum;
|
|
|
@ApolloJsonValue("${send.room.msg.test.roomList:[]}")
|
|
@ApolloJsonValue("${send.room.msg.test.roomList:[]}")
|
|
|
private List<String> testRoomList;
|
|
private List<String> testRoomList;
|
|
|
|
|
+ @ApolloJsonValue("${send.room.msg.video.source.staff.config:{}}")
|
|
|
|
|
+ private Map<Long, JSONObject> videoSourceStaffConfig;
|
|
|
|
|
|
|
|
private final static ExecutorService pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.SECONDS,
|
|
private final static ExecutorService pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.SECONDS,
|
|
|
new LinkedBlockingQueue<>(1000),
|
|
new LinkedBlockingQueue<>(1000),
|
|
@@ -129,7 +139,9 @@ public class WeComSendMsgJob {
|
|
|
return coverUrl;
|
|
return coverUrl;
|
|
|
}
|
|
}
|
|
|
String waterMark = "?x-oss-process=image/resize,m_fill,w_600,h_480,limit_0/format,jpg/watermark,image_eXNoL3BpYy93YXRlcm1hcmtlci9pY29uX3BsYXlfd2hpdGUucG5nP3gtb3NzLXByb2Nlc3M9aW1hZ2UvcmVzaXplLHdfMTQ0,g_center";
|
|
String waterMark = "?x-oss-process=image/resize,m_fill,w_600,h_480,limit_0/format,jpg/watermark,image_eXNoL3BpYy93YXRlcm1hcmtlci9pY29uX3BsYXlfd2hpdGUucG5nP3gtb3NzLXByb2Nlc3M9aW1hZ2UvcmVzaXplLHdfMTQ0,g_center";
|
|
|
- coverUrl = coverUrl.substring(0, coverUrl.indexOf("?"));
|
|
|
|
|
|
|
+ if (coverUrl.contains("?")) {
|
|
|
|
|
+ coverUrl = coverUrl.substring(0, coverUrl.indexOf("?"));
|
|
|
|
|
+ }
|
|
|
return coverUrl + waterMark;
|
|
return coverUrl + waterMark;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -142,11 +154,17 @@ public class WeComSendMsgJob {
|
|
|
String sort = "datastat.fission_rate desc, video.score desc";
|
|
String sort = "datastat.fission_rate desc, video.score desc";
|
|
|
String type = "企微-社群";
|
|
String type = "企微-社群";
|
|
|
String channel = "sum";
|
|
String channel = "sum";
|
|
|
- List<ContentPlatformVideo> videoList = planMapperExt.getVideoMinDatastatScoreList(dt, datastatDt,
|
|
|
|
|
- type, channel, videoMinScore, sentVideoIds, 0, 100, sort);
|
|
|
|
|
- // 行业数量不足,按平台推荐top选取视频
|
|
|
|
|
- sort = "video.score desc";
|
|
|
|
|
- videoList.addAll(planMapperExt.getVideoMinScoreList(dt, videoMinScore, sentVideoIds, 0, 100, sort));
|
|
|
|
|
|
|
+ List<ContentPlatformVideo> videoList = getVideoByStrategy(thirdPartWeComStaff.getThirdStaffId(), dt, datastatDt, type, channel, videoMinScore,
|
|
|
|
|
+ sentVideoIds, 1, 100, sort);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(videoList)) {
|
|
|
|
|
+ LarkRobotUtil.sendWeComThirdPartMessage(
|
|
|
|
|
+ "【账号发送群消息,视频数量不足通知】\n" +
|
|
|
|
|
+ "账号名称:" + thirdPartWeComStaff.getName() + "\n" +
|
|
|
|
|
+ "账号VID:" + thirdPartWeComStaff.getThirdStaffId() + "\n" +
|
|
|
|
|
+ "群ID:" + roomId + "\n" +
|
|
|
|
|
+ "账号配置:" + videoSourceStaffConfig.get(thirdPartWeComStaff.getId()));
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
List<CgiReplyBucketData> result = new ArrayList<>();
|
|
List<CgiReplyBucketData> result = new ArrayList<>();
|
|
|
for (int i = 0; i < videoNum; i++) {
|
|
for (int i = 0; i < videoNum; i++) {
|
|
|
ContentPlatformVideo video = videoList.get(i);
|
|
ContentPlatformVideo video = videoList.get(i);
|
|
@@ -165,6 +183,64 @@ public class WeComSendMsgJob {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private List<ContentPlatformVideo> getVideoByStrategy(Long staffId,
|
|
|
|
|
+ String dt,
|
|
|
|
|
+ String datastatDt,
|
|
|
|
|
+ String type,
|
|
|
|
|
+ String channel,
|
|
|
|
|
+ Double videoMinScore,
|
|
|
|
|
+ List<Long> sentVideoIds,
|
|
|
|
|
+ int pageNum,
|
|
|
|
|
+ int pageSize,
|
|
|
|
|
+ String sort) {
|
|
|
|
|
+ List<ContentPlatformVideo> result = new ArrayList<>();
|
|
|
|
|
+ JSONObject staffConfig = videoSourceStaffConfig.get(staffId);
|
|
|
|
|
+ if (staffConfig == null) {
|
|
|
|
|
+ staffConfig = new JSONObject();
|
|
|
|
|
+ }
|
|
|
|
|
+ List<ContentPlatformVideo> videoList;
|
|
|
|
|
+ String source = (String) staffConfig.getOrDefault("source", "");
|
|
|
|
|
+ switch (source) {
|
|
|
|
|
+ case "user":
|
|
|
|
|
+ Long uid = staffConfig.getLong("uid");
|
|
|
|
|
+ List<WxVideoV2VO> list = videoApiService.getUserVideoList(uid, sentVideoIds, pageNum, pageSize);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ videoList = convertWxVideoV2VOToVideo(list);
|
|
|
|
|
+ result.addAll(videoList);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "tag":
|
|
|
|
|
+ String tagName = staffConfig.getString("tagName");
|
|
|
|
|
+ list = videoApiService.getTagVideoList(tagName, sentVideoIds, pageNum, pageSize);
|
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ videoList = convertWxVideoV2VOToVideo(list);
|
|
|
|
|
+ result.addAll(videoList);
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ result = planMapperExt.getVideoMinDatastatScoreList(dt, datastatDt,
|
|
|
|
|
+ type, channel, videoMinScore, sentVideoIds, 0, 100, sort);
|
|
|
|
|
+ // 行业数量不足,按平台推荐top选取视频
|
|
|
|
|
+ sort = "video.score desc";
|
|
|
|
|
+ result.addAll(planMapperExt.getVideoMinScoreList(dt, videoMinScore, sentVideoIds, 0, 100, sort));
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<ContentPlatformVideo> convertWxVideoV2VOToVideo(List<WxVideoV2VO> list) {
|
|
|
|
|
+ List<ContentPlatformVideo> result = new ArrayList<>();
|
|
|
|
|
+ for (WxVideoV2VO vo : list) {
|
|
|
|
|
+ ContentPlatformVideo video = new ContentPlatformVideo();
|
|
|
|
|
+ video.setVideoId(vo.getId());
|
|
|
|
|
+ video.setTitle(vo.getTitle());
|
|
|
|
|
+ video.setCover(vo.getVideoCoverSnapshotPath());
|
|
|
|
|
+ result.add(video);
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private List<Long> getSentVideoIds(Long roomId) {
|
|
private List<Long> getSentVideoIds(Long roomId) {
|
|
|
ThirdPartWeComMsgExample msgExample = new ThirdPartWeComMsgExample();
|
|
ThirdPartWeComMsgExample msgExample = new ThirdPartWeComMsgExample();
|
|
|
msgExample.createCriteria().andSendUseridEqualTo(roomId)
|
|
msgExample.createCriteria().andSendUseridEqualTo(roomId)
|