|
|
@@ -0,0 +1,93 @@
|
|
|
+package com.tzld.piaoquan.sde.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.tzld.piaoquan.sde.common.enums.ContentProfileStageEnum;
|
|
|
+import com.tzld.piaoquan.sde.common.enums.ContentTypeEnum;
|
|
|
+import com.tzld.piaoquan.sde.common.enums.IsDeleteEnum;
|
|
|
+import com.tzld.piaoquan.sde.mapper.ContentProfileMapper;
|
|
|
+import com.tzld.piaoquan.sde.mapper.SdExecutionTaskContentMapper;
|
|
|
+import com.tzld.piaoquan.sde.model.dto.deconstruction.QueryResponseDataDTO;
|
|
|
+import com.tzld.piaoquan.sde.model.entity.ContentProfile;
|
|
|
+import com.tzld.piaoquan.sde.model.entity.SdExecutionTask;
|
|
|
+import com.tzld.piaoquan.sde.model.entity.SdExecutionTaskContent;
|
|
|
+import com.tzld.piaoquan.sde.service.ContentProfileService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class ContentProfileServiceImpl implements ContentProfileService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ContentProfileMapper contentProfileMapper;
|
|
|
+ @Autowired
|
|
|
+ private SdExecutionTaskContentMapper sdExecutionTaskContentMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ContentProfile findContentProfileByIdAndStage(String contentId, ContentProfileStageEnum stageEnum) {
|
|
|
+ if (StringUtils.isEmpty(contentId) || Objects.isNull(stageEnum)) {
|
|
|
+ throw new RuntimeException("contentId and stageEnum must not null");
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<ContentProfile> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(ContentProfile::getContentId, contentId);
|
|
|
+ wrapper.eq(ContentProfile::getStage, stageEnum.getValue());
|
|
|
+ wrapper.eq(ContentProfile::getIsDeleted, IsDeleteEnum.NORMAL.getValue());
|
|
|
+ return contentProfileMapper.selectOne(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void insertOrUpdate(ContentProfile contentProfile) {
|
|
|
+ if (StringUtils.isEmpty(contentProfile.getContentId()) || Objects.isNull(contentProfile.getStage())) {
|
|
|
+ throw new RuntimeException("contentId and stageEnum must not null");
|
|
|
+ }
|
|
|
+ ContentProfile profile = this.findContentProfileByIdAndStage(contentProfile.getContentId(), ContentProfileStageEnum.getByValue(contentProfile.getStage()));
|
|
|
+ if (Objects.isNull(profile)) {
|
|
|
+ contentProfile.setIsDeleted(IsDeleteEnum.NORMAL.getValue());
|
|
|
+ contentProfileMapper.insert(contentProfile);
|
|
|
+ } else {
|
|
|
+ contentProfile.setId(profile.getId());
|
|
|
+ contentProfile.setIsDeleted(IsDeleteEnum.NORMAL.getValue());
|
|
|
+ contentProfileMapper.updateById(contentProfile);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void deconstructSelectTopicResultSync(SdExecutionTask sdExecutionTask, QueryResponseDataDTO queryResponseDataDTO) {
|
|
|
+ try {
|
|
|
+
|
|
|
+ if (Objects.isNull(sdExecutionTask) || Objects.isNull(queryResponseDataDTO)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ SdExecutionTaskContent content = this.findByExecutionTaskId(sdExecutionTask.getId());
|
|
|
+ if (Objects.isNull(content)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ ContentProfile contentProfile = new ContentProfile();
|
|
|
+ contentProfile.setContentId(content.getContentId());
|
|
|
+ contentProfile.setContentType(content.getContentType());
|
|
|
+ contentProfile.setStage(ContentProfileStageEnum.DECONSTRUCTION_SELECT_TOPIC.getValue());
|
|
|
+ contentProfile.setRawResult(queryResponseDataDTO.getResult());
|
|
|
+ contentProfile.setRawUrl(queryResponseDataDTO.getUrl());
|
|
|
+
|
|
|
+ this.insertOrUpdate(contentProfile);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("解构任务状态同步异常: ", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private SdExecutionTaskContent findByExecutionTaskId(Long executionTaskId) {
|
|
|
+ if (Objects.isNull(executionTaskId)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<SdExecutionTaskContent> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(SdExecutionTaskContent::getExecutionTaskId, executionTaskId);
|
|
|
+ wrapper.eq(SdExecutionTaskContent::getContentType, ContentTypeEnum.VIDEO.getValue());
|
|
|
+ return sdExecutionTaskContentMapper.selectOne(wrapper);
|
|
|
+ }
|
|
|
+}
|