|
|
@@ -0,0 +1,457 @@
|
|
|
+package com.fs.tag.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.course.domain.FsCourseWatchLog;
|
|
|
+import com.fs.course.domain.FsUserCourse;
|
|
|
+import com.fs.course.domain.FsUserCourseVideo;
|
|
|
+import com.fs.course.mapper.FsUserCourseMapper;
|
|
|
+import com.fs.course.mapper.FsUserCourseVideoMapper;
|
|
|
+import com.fs.qw.cache.IQwUserCacheService;
|
|
|
+import com.fs.qw.domain.QwExternalContact;
|
|
|
+import com.fs.qw.domain.QwTag;
|
|
|
+import com.fs.qw.domain.QwTagGroup;
|
|
|
+import com.fs.qw.mapper.QwExternalContactMapper;
|
|
|
+import com.fs.qw.mapper.QwTagGroupMapper;
|
|
|
+import com.fs.qw.mapper.QwTagMapper;
|
|
|
+import com.fs.qw.mapper.QwUserMapper;
|
|
|
+import com.fs.qw.service.IQwTagGroupService;
|
|
|
+import com.fs.qw.vo.QwTagGroupAddParam;
|
|
|
+import com.fs.qw.vo.QwTagVO;
|
|
|
+import com.fs.qwApi.domain.QwAddTagResult;
|
|
|
+import com.fs.qwApi.domain.QwResult;
|
|
|
+import com.fs.qwApi.domain.inner.InTag;
|
|
|
+import com.fs.qwApi.domain.inner.TagData;
|
|
|
+import com.fs.qwApi.param.QwAddTagParam;
|
|
|
+import com.fs.qwApi.param.QwEditUserTagParam;
|
|
|
+import com.fs.qwApi.service.QwApiService;
|
|
|
+import com.fs.tag.domain.FsTagUpdateQueue;
|
|
|
+import com.fs.tag.mapper.FsTagUpdateQueueMapper;
|
|
|
+import com.fs.tag.service.FsTagUpdateService;
|
|
|
+import com.google.common.util.concurrent.RateLimiter;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.lang.exception.ExceptionUtils;
|
|
|
+import org.apache.http.util.Asserts;
|
|
|
+import org.checkerframework.checker.signature.qual.PolySignature;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
+import java.time.temporal.TemporalUnit;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.*;
|
|
|
+import java.util.concurrent.locks.ReentrantLock;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Service("fsTagUpdateService")
|
|
|
+public class FsTagUpdateServiceImpl implements FsTagUpdateService {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsTagUpdateQueueMapper fsTagUpdateQueueMapper;
|
|
|
+ @Autowired
|
|
|
+ private FsUserCourseVideoMapper fsUserCourseVideoMapper;
|
|
|
+ @Autowired
|
|
|
+ private IQwUserCacheService qwUserCacheService;
|
|
|
+ @Autowired
|
|
|
+ private QwApiService qwApiService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QwTagMapper qwTagMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QwTagGroupMapper qwTagGroupMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IQwTagGroupService qwTagGroupService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsUserCourseMapper fsUserCourseMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QwExternalContactMapper qwExternalContactMapper;
|
|
|
+
|
|
|
+ @Value("${tag.thread.num:5}")
|
|
|
+ private Integer TAG_THREAD_NUM;
|
|
|
+
|
|
|
+ @Value("${tag.rate.limit:30}")
|
|
|
+ private Integer RATE_LIMIT_NUM;
|
|
|
+ /**
|
|
|
+ * 标签组最大数量
|
|
|
+ */
|
|
|
+ private static final Integer TAG_MAX_NUM = 100;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 接口限流
|
|
|
+ */
|
|
|
+ private RateLimiter rateLimiter;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 看课自动打标签开关
|
|
|
+ */
|
|
|
+ @Value("${qw.enableAutoTag:0}")
|
|
|
+ private Integer enableAutoTag;
|
|
|
+
|
|
|
+ @PostConstruct
|
|
|
+ public void init(){
|
|
|
+ this.rateLimiter = RateLimiter.create(RATE_LIMIT_NUM);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
|
|
|
+ public void onCourseWatchingBatch(List<FsCourseWatchLog> logs) {
|
|
|
+
|
|
|
+ if(ObjectUtil.equal(enableAutoTag,0)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<Long, FsUserCourseVideo> courseVideoMap = fsUserCourseVideoMapper.selectAllMap();
|
|
|
+ // 用户(这里用户用的是企微外部联系人ID)+videoId+status 唯一
|
|
|
+
|
|
|
+ // 先导课看课记录
|
|
|
+ List<FsTagUpdateQueue> batchData = new ArrayList<>();
|
|
|
+ for (FsCourseWatchLog item : logs) {
|
|
|
+ FsTagUpdateQueue task = new FsTagUpdateQueue();
|
|
|
+ task.setCourseId(item.getCourseId());
|
|
|
+ task.setVideoId(item.getVideoId());
|
|
|
+ task.setCourseLogId(item.getLogId());
|
|
|
+ task.setTagId(null);
|
|
|
+ task.setTagName(null);
|
|
|
+
|
|
|
+ task.setLogType(0);
|
|
|
+ task.setOperationType(0);
|
|
|
+ task.setStatus(0);
|
|
|
+ task.setRetryCount(0);
|
|
|
+ task.setQwExternalContactId(item.getQwExternalContactId());
|
|
|
+ task.setQwUserId(item.getQwUserId());
|
|
|
+
|
|
|
+ String corpId = qwUserCacheService.queryCorpIdByQwUserId(item.getQwUserId());
|
|
|
+ if(StringUtils.isNotNull(corpId)){
|
|
|
+ task.setCorpId(corpId);
|
|
|
+ }
|
|
|
+
|
|
|
+ FsUserCourseVideo fsUserCourseVideo = courseVideoMap.get(task.getVideoId());
|
|
|
+
|
|
|
+ if(ObjectUtils.isNull(fsUserCourseVideo)) {
|
|
|
+ String errorMsg = String.format("该条记录 %d 找不到对应的课堂视频", task.getVideoId());
|
|
|
+ log.error(errorMsg);
|
|
|
+ task.setStatus(3);
|
|
|
+ task.setRetryCount(3);
|
|
|
+ task.setFailMsg(errorMsg);
|
|
|
+ batchData.add(task);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(ObjectUtil.equal(fsUserCourseVideo.getIsFirst(),1)) {
|
|
|
+ task.setIsFirst(1);
|
|
|
+ } else {
|
|
|
+ task.setIsFirst(0);
|
|
|
+ }
|
|
|
+ task.setSort(fsUserCourseVideo.getCourseSort());
|
|
|
+ batchData.add(task);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ fsTagUpdateQueueMapper.batchInsert(batchData);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
|
|
|
+ public void onCourseWatchFinishedBatch(List<FsCourseWatchLog> logs) {
|
|
|
+ if(ObjectUtil.equal(enableAutoTag,0)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<Long, FsUserCourseVideo> courseVideoMap = fsUserCourseVideoMapper.selectAllMap();
|
|
|
+
|
|
|
+ // 先导课看课记录
|
|
|
+ List<FsTagUpdateQueue> batchData = new ArrayList<>();
|
|
|
+ for (FsCourseWatchLog item : logs) {
|
|
|
+ FsTagUpdateQueue task = new FsTagUpdateQueue();
|
|
|
+ task.setCourseId(item.getCourseId());
|
|
|
+ task.setVideoId(item.getVideoId());
|
|
|
+ task.setCourseLogId(item.getLogId());
|
|
|
+ task.setTagId(null);
|
|
|
+ task.setTagName(null);
|
|
|
+ task.setOperationType(0);
|
|
|
+ task.setStatus(0);
|
|
|
+ task.setRetryCount(0);
|
|
|
+ task.setQwExternalContactId(item.getQwExternalContactId());
|
|
|
+ task.setQwUserId(item.getQwUserId());
|
|
|
+ task.setLogType(1);
|
|
|
+
|
|
|
+ String corpId = qwUserCacheService.queryCorpIdByQwUserId(item.getQwUserId());
|
|
|
+ if(StringUtils.isNotNull(corpId)){
|
|
|
+ task.setCorpId(corpId);
|
|
|
+ }
|
|
|
+
|
|
|
+ FsUserCourseVideo fsUserCourseVideo = courseVideoMap.get(task.getVideoId());
|
|
|
+ if(ObjectUtils.isNull(fsUserCourseVideo)) {
|
|
|
+ String errorMsg = String.format("该条记录 %d 找不到对应的课堂视频", task.getVideoId());
|
|
|
+ log.error(errorMsg);
|
|
|
+ task.setStatus(3);
|
|
|
+ task.setRetryCount(3);
|
|
|
+ task.setFailMsg(errorMsg);
|
|
|
+ batchData.add(task);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(ObjectUtil.equal(fsUserCourseVideo.getIsFirst(),1)) {
|
|
|
+ task.setIsFirst(1);
|
|
|
+ } else {
|
|
|
+ task.setIsFirst(0);
|
|
|
+ }
|
|
|
+ task.setSort(fsUserCourseVideo.getCourseSort());
|
|
|
+ batchData.add(task);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ fsTagUpdateQueueMapper.batchInsert(batchData);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void handleData() {
|
|
|
+ List<FsTagUpdateQueue> tasks = fsTagUpdateQueueMapper.selectPending();
|
|
|
+ if(CollectionUtils.isEmpty(tasks)){
|
|
|
+ log.info("找不到可处理的任务,已跳过!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ConcurrentHashMap<String, ReentrantLock> lockMap = new ConcurrentHashMap<>();
|
|
|
+ ExecutorService executor = Executors.newFixedThreadPool(TAG_THREAD_NUM);
|
|
|
+ CountDownLatch latch = new CountDownLatch(tasks.size());
|
|
|
+
|
|
|
+ for (FsTagUpdateQueue task : tasks) {
|
|
|
+ executor.submit(() -> {
|
|
|
+ String lockKey = task.getCourseId() + "_" + task.getVideoId();
|
|
|
+ ReentrantLock lock = lockMap.computeIfAbsent(lockKey, k -> new ReentrantLock());
|
|
|
+ lock.lock();
|
|
|
+ try {
|
|
|
+ processSingleTask(task);
|
|
|
+ } finally {
|
|
|
+ lock.unlock();
|
|
|
+ latch.countDown();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ latch.await();
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ executor.shutdown();
|
|
|
+ if (!executor.awaitTermination(1, TimeUnit.MINUTES)) {
|
|
|
+ executor.shutdownNow();
|
|
|
+ // 再次等待确保已经关闭
|
|
|
+ if (!executor.awaitTermination(10, TimeUnit.SECONDS)) {
|
|
|
+ log.warn("线程池未能在预期时间内关闭");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ executor.shutdownNow();
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CollectionUtils.isNotEmpty(tasks)){
|
|
|
+ fsTagUpdateQueueMapper.batchUpdateSelective(tasks);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void processSingleTask(FsTagUpdateQueue fsTagUpdateQueue) {
|
|
|
+ try {
|
|
|
+ String courseName = getCourseName(fsTagUpdateQueue.getCourseId());
|
|
|
+ String tagGroupName = String.format("%s-看课标签组(自动创建)",courseName);
|
|
|
+ String tagName01 = String.format("%d上", fsTagUpdateQueue.getVideoId());
|
|
|
+ String tagName02 = String.format("%d完", fsTagUpdateQueue.getVideoId());
|
|
|
+ String corpId = fsTagUpdateQueue.getCorpId();
|
|
|
+
|
|
|
+ // 是否存在该标签
|
|
|
+ QwTagVO qwTagVO = qwTagMapper.selectQwTagByName(tagName01, corpId);
|
|
|
+ if(ObjectUtil.isNull(qwTagVO)){
|
|
|
+ // 是否存在标签组
|
|
|
+ QwTagGroup qwTagGroup = qwTagGroupMapper.selectQwTagGroupByName(tagGroupName, corpId);
|
|
|
+ // 创建标签组 & 标签
|
|
|
+ if(ObjectUtil.isNull(qwTagGroup)) {
|
|
|
+ log.info("当前标签组不存在 建标签组 & 标签");
|
|
|
+ QwTagGroupAddParam qwTagGroupAddParam = buildQwTagGroupAndTags(tagGroupName, fsTagUpdateQueue);
|
|
|
+ qwTagGroupService.insertQwTagGroupParam(qwTagGroupAddParam);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // 这个标签组满了吗?
|
|
|
+ List<QwTagVO> qwTags = getQwTags(qwTagGroup);
|
|
|
+ // 如果满了,找下一个标签
|
|
|
+ if(CollectionUtils.isNotEmpty(qwTags) && qwTags.size() >= TAG_MAX_NUM){
|
|
|
+ log.info("标签组1 {}满了,查找标签组2",tagGroupName);
|
|
|
+ tagGroupName = String.format("%s-看课标签组2(自动创建)",courseName);
|
|
|
+ qwTagGroup = qwTagGroupMapper.selectQwTagGroupByName(tagGroupName, corpId);
|
|
|
+ // 判断是否满了
|
|
|
+ if(ObjectUtil.isNotNull(qwTagGroup)) {
|
|
|
+ List<QwTagVO> qwTags1 = getQwTags(qwTagGroup);
|
|
|
+ if(CollectionUtils.isNotEmpty(qwTags1) && qwTags1.size() >= TAG_MAX_NUM){
|
|
|
+ log.info("标签组2 {} 满了,查找标签组3",courseName);
|
|
|
+ tagGroupName = String.format("%s-看课标签组3(自动创建)",courseName);
|
|
|
+ qwTagGroup = qwTagGroupMapper.selectQwTagGroupByName(tagGroupName, corpId);
|
|
|
+ List<QwTagVO> qwTags2 = getQwTags(qwTagGroup);
|
|
|
+ if(CollectionUtils.isNotEmpty(qwTags2) && qwTags2.size() >= TAG_MAX_NUM){
|
|
|
+ log.error("最大支持3个标签组! tagGroupName={}",tagGroupName);
|
|
|
+ throw new UnsupportedOperationException("最大支持分成3个组!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 创建标签
|
|
|
+ log.info("当前标签 {}、{} 在标签组 {}不存在,正在创建标签",tagName01,tagName02,qwTagGroup);
|
|
|
+ createNotExistLabel(fsTagUpdateQueue, qwTagGroup, tagName01, tagName02);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ QwTagVO qwTagVO1 = qwTagMapper.selectQwTagByName(tagName01, corpId);
|
|
|
+ QwTagVO qwTagVO2 = qwTagMapper.selectQwTagByName(tagName02, corpId);
|
|
|
+
|
|
|
+ if(ObjectUtil.isNull(qwTagVO1)){
|
|
|
+ throw new IllegalArgumentException(String.format("标签 %s-%s 未添加成功!",tagName01,corpId));
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNull(qwTagVO2)){
|
|
|
+ throw new IllegalArgumentException(String.format("标签 %s-%s 未添加成功!",tagName02,corpId));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 调用企微API更新标签
|
|
|
+ QwEditUserTagParam qwEditUserTagParam = new QwEditUserTagParam();
|
|
|
+ QwExternalContact qwExternalContact = qwExternalContactMapper
|
|
|
+ .selectQwExternalContactById(fsTagUpdateQueue.getQwExternalContactId());
|
|
|
+ if(qwExternalContact == null) {
|
|
|
+ throw new IllegalArgumentException(String.format("企微外部联系人 %s 未找到!", fsTagUpdateQueue.getQwExternalContactId()));
|
|
|
+ }
|
|
|
+ qwEditUserTagParam.setUserid(qwExternalContact.getUserId());
|
|
|
+ qwEditUserTagParam.setExternal_userid(qwExternalContact.getExternalUserId());
|
|
|
+
|
|
|
+ rateLimiter.acquire();
|
|
|
+
|
|
|
+ // 如果是看课中
|
|
|
+ if(ObjectUtil.equal(fsTagUpdateQueue.getLogType(),0)){
|
|
|
+ qwEditUserTagParam.setAdd_tag(Collections.singletonList(qwTagVO1.getTagId()));
|
|
|
+ } else {
|
|
|
+ // 已完课
|
|
|
+ qwEditUserTagParam.setAdd_tag(Collections.singletonList(qwTagVO2.getTagId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ QwResult qwResult = qwApiService.editUserTag(qwEditUserTagParam, fsTagUpdateQueue.getCorpId());
|
|
|
+ fsTagUpdateQueue.setPayload(JSON.toJSONString(qwEditUserTagParam));
|
|
|
+ fsTagUpdateQueue.setResponse(JSON.toJSONString(qwResult));
|
|
|
+ fsTagUpdateQueue.setTagName(tagGroupName);
|
|
|
+ fsTagUpdateQueue.setTagId(qwTagVO1.getGroupId());
|
|
|
+ // 打标签成功
|
|
|
+ if(ObjectUtil.equal(qwResult.getErrcode(),0)) {
|
|
|
+ fsTagUpdateQueue.setStatus(2);
|
|
|
+ fsTagUpdateQueue.setRetryCount(0);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException(String.format("打标签失败 原因: %s", JSON.toJSONString(qwResult)));
|
|
|
+ }
|
|
|
+ } catch (Exception e){
|
|
|
+ fsTagUpdateQueue.setStatus(3);
|
|
|
+ fsTagUpdateQueue.setRetryCount(fsTagUpdateQueue.getRetryCount()+1);
|
|
|
+ fsTagUpdateQueue.setFailMsg(ExceptionUtils.getFullStackTrace(e));
|
|
|
+ fsTagUpdateQueue.setNextExecuteTime(LocalDateTime.now().plusHours(1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void createNotExistLabel(FsTagUpdateQueue fsTagUpdateQueue, QwTagGroup qwTagGroup, String tagName01, String tagName02) {
|
|
|
+ QwAddTagParam qwAddTagParam = buildQwTagGroupAndTags(qwTagGroup, tagName01, tagName02);
|
|
|
+ QwAddTagResult qwAddTagResult = qwApiService.addTag(qwAddTagParam, fsTagUpdateQueue.getCorpId());
|
|
|
+ if(ObjectUtil.equal(qwAddTagResult.getErrcode(),0)){
|
|
|
+ List<InTag> addTag = qwAddTagResult.getTag_group().getTag();
|
|
|
+ if (CollectionUtils.isNotEmpty(addTag)) {
|
|
|
+ for (InTag inTag : addTag) {
|
|
|
+ QwTag addQwTag = new QwTag();
|
|
|
+ addQwTag.setGroupId(qwTagGroup.getGroupId());
|
|
|
+ addQwTag.setTagId(inTag.getId());
|
|
|
+ addQwTag.setOrder(inTag.getOrder());
|
|
|
+ addQwTag.setName(inTag.getName());
|
|
|
+ addQwTag.setCorpId(qwTagGroup.getCorpId());
|
|
|
+ addQwTag.setCreateTime(new Date(inTag.getCreate_time()));
|
|
|
+ addQwTag.setTagFrom(1);
|
|
|
+ qwTagMapper.insertQwTag(addQwTag);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("创建标签完成 {}",JSON.toJSON(qwAddTagResult));
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException(String.format("创建标签失败!%s",JSON.toJSONString(qwAddTagResult)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<QwTagVO> getQwTags(QwTagGroup qwTagGroup) {
|
|
|
+ QwTag qwTag = new QwTag();
|
|
|
+ qwTag.setGroupId(qwTagGroup.getGroupId());
|
|
|
+ qwTag.setCompanyId(qwTagGroup.getCompanyId());
|
|
|
+ List<QwTagVO> qwTags = qwTagMapper.selectQwTagListVO(qwTag);
|
|
|
+ return qwTags;
|
|
|
+ }
|
|
|
+
|
|
|
+ private QwAddTagParam buildQwTagGroupAndTags(QwTagGroup qwTagGroup, String tagName01, String tagName02) {
|
|
|
+ QwAddTagParam qwTagGroupAddParam = new QwAddTagParam();
|
|
|
+ qwTagGroupAddParam.setGroup_name(qwTagGroup.getName());
|
|
|
+ qwTagGroupAddParam.setOrder(qwTagGroup.getOrder());
|
|
|
+ qwTagGroupAddParam.setStrategy_id(1);
|
|
|
+ qwTagGroupAddParam.setGroup_id(qwTagGroup.getGroupId());
|
|
|
+ List<TagData> tags = new ArrayList<>();
|
|
|
+
|
|
|
+ TagData qwTag1 = new TagData();
|
|
|
+ qwTag1.setName(tagName01);
|
|
|
+ qwTag1.setOrder(0);
|
|
|
+ tags.add(qwTag1);
|
|
|
+
|
|
|
+ TagData qwTag2 = new TagData();
|
|
|
+ qwTag2.setName(tagName02);
|
|
|
+ qwTag2.setOrder(0);
|
|
|
+ tags.add(qwTag2);
|
|
|
+
|
|
|
+ qwTagGroupAddParam.setTag(tags);
|
|
|
+
|
|
|
+ return qwTagGroupAddParam;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private QwTagGroupAddParam buildQwTagGroupAndTags(String tagGroupName, FsTagUpdateQueue fsTagUpdateQueue) {
|
|
|
+ QwTagGroupAddParam qwTagGroupAddParam = new QwTagGroupAddParam();
|
|
|
+ qwTagGroupAddParam.setCorpId(fsTagUpdateQueue.getCorpId());
|
|
|
+ qwTagGroupAddParam.setName(tagGroupName);
|
|
|
+ qwTagGroupAddParam.setOrder(0);
|
|
|
+
|
|
|
+
|
|
|
+ List<QwTag> tags = new ArrayList<>();
|
|
|
+ QwTag qwTag = new QwTag();
|
|
|
+ qwTag.setName(String.format("%d上",fsTagUpdateQueue.getVideoId()));
|
|
|
+ qwTag.setTagFrom(1);
|
|
|
+ qwTag.setOrder(0);
|
|
|
+ tags.add(qwTag);
|
|
|
+
|
|
|
+ QwTag qwTagFinish = new QwTag();
|
|
|
+ qwTagFinish.setName(String.format("%d完",fsTagUpdateQueue.getVideoId()));
|
|
|
+ qwTagFinish.setTagFrom(1);
|
|
|
+ qwTagFinish.setOrder(0);
|
|
|
+ tags.add(qwTagFinish);
|
|
|
+
|
|
|
+ qwTagGroupAddParam.setTag(tags);
|
|
|
+ return qwTagGroupAddParam;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取课程名称
|
|
|
+ * @param courseId 课程id
|
|
|
+ * @return 课程名称
|
|
|
+ */
|
|
|
+ private String getCourseName(Long courseId){
|
|
|
+ FsUserCourse course = fsUserCourseMapper.selectFsUserCourseByCourseId(courseId);
|
|
|
+ if(ObjectUtil.isNotNull(course)){
|
|
|
+ return course.getCourseName();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|