|
|
@ -72,6 +72,7 @@ import com.epmet.resi.group.dto.topic.form.*; |
|
|
|
import com.epmet.resi.group.dto.topic.result.DraftDetailResultDTO; |
|
|
|
import com.epmet.resi.group.dto.topic.result.MyAuditingListResultDTO; |
|
|
|
import com.epmet.resi.group.dto.topic.result.TopicAuditResultDTO; |
|
|
|
import com.google.common.base.CharMatcher; |
|
|
|
import com.google.common.util.concurrent.ThreadFactoryBuilder; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
@ -239,6 +240,110 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 自动审核 |
|
|
|
* |
|
|
|
* @return void |
|
|
|
* @author zhaoqifeng |
|
|
|
* @date 2020/12/29 17:51 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void autoAudit() { |
|
|
|
List<TopicDraftScanTaskDTO> taskList = topicDraftScanTaskService.getScanTaskList(null, TopicConstant.AUDITING); |
|
|
|
if (CollectionUtils.isNotEmpty(taskList)) { |
|
|
|
List<String> taskIds = taskList.stream().map(TopicDraftScanTaskDTO :: getTaskId).collect(Collectors.toList()); |
|
|
|
List<String> draftIds = taskList.stream().map(TopicDraftScanTaskDTO :: getTopicDraftId).collect(Collectors.toList()); |
|
|
|
Result<List<VoiceResultDTO>> voiceResults = ScanContentUtils.voiceResults(scanApiUrl.concat(voiceResultsMethod), taskIds); |
|
|
|
if (voiceResults.success()) { |
|
|
|
List<VoiceResultDTO> list = voiceResults.getData(); |
|
|
|
for (VoiceResultDTO item : list) { |
|
|
|
TopicDraftScanTaskDTO taskDTO = topicDraftScanTaskService.getScanByTask(item.getTaskId()); |
|
|
|
if (TopicConstant.REVIEW.equals(item.getSuggestion())) { |
|
|
|
//结果不确定
|
|
|
|
TopicDraftAttachmentDTO dto = new TopicDraftAttachmentDTO(); |
|
|
|
dto.setId(taskDTO.getTopicDraftAttachmentId()); |
|
|
|
dto.setStatus(TopicConstant.REVIEW); |
|
|
|
dto.setReason(item.getLabelDesc()); |
|
|
|
topicDraftAttachmentService.update(dto); |
|
|
|
|
|
|
|
taskDTO.setStatus(TopicConstant.REVIEW); |
|
|
|
topicDraftScanTaskService.update(taskDTO); |
|
|
|
|
|
|
|
} else if (TopicConstant.BLOCK.equals(item.getSuggestion())) { |
|
|
|
//结果违规
|
|
|
|
TopicDraftAttachmentDTO dto = new TopicDraftAttachmentDTO(); |
|
|
|
dto.setId(taskDTO.getTopicDraftAttachmentId()); |
|
|
|
dto.setStatus(TopicConstant.BLOCK); |
|
|
|
dto.setReason(item.getLabelDesc()); |
|
|
|
topicDraftAttachmentService.update(dto); |
|
|
|
|
|
|
|
taskDTO.setStatus(TopicConstant.BLOCK); |
|
|
|
topicDraftScanTaskService.update(taskDTO); |
|
|
|
} else { |
|
|
|
//审核通过
|
|
|
|
TopicDraftAttachmentDTO dto = new TopicDraftAttachmentDTO(); |
|
|
|
dto.setId(taskDTO.getTopicDraftAttachmentId()); |
|
|
|
dto.setStatus(TopicConstant.AUTO_PASSED); |
|
|
|
dto.setReason(item.getLabelDesc()); |
|
|
|
topicDraftAttachmentService.update(dto); |
|
|
|
|
|
|
|
taskDTO.setStatus(TopicConstant.AUTO_PASSED); |
|
|
|
topicDraftScanTaskService.update(taskDTO); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//判断草稿是否审核完成
|
|
|
|
draftIds.forEach(draftId -> { |
|
|
|
List<TopicDraftScanTaskDTO> tasks = topicDraftScanTaskService.getScanTaskList(draftId, null); |
|
|
|
String status = TopicConstant.AUTO_PASSED; |
|
|
|
for (TopicDraftScanTaskDTO task : tasks) { |
|
|
|
if (TopicConstant.AUDITING.equals(task.getStatus())) { |
|
|
|
status = TopicConstant.AUDITING; |
|
|
|
break; |
|
|
|
} else if(TopicConstant.BLOCK.equals(task.getStatus())) { |
|
|
|
status = TopicConstant.BLOCK; |
|
|
|
} else if(TopicConstant.REVIEW.equals(task.getStatus())) { |
|
|
|
if (!TopicConstant.BLOCK.equals(status)) { |
|
|
|
status = TopicConstant.REVIEW; |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (!TopicConstant.BLOCK.equals(status) && !TopicConstant.REVIEW.equals(status)) { |
|
|
|
status = TopicConstant.AUTO_PASSED; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (TopicConstant.BLOCK.equals(status)) { |
|
|
|
//草稿状态更新为block
|
|
|
|
TopicDraftEntity draftEntity = new TopicDraftEntity(); |
|
|
|
draftEntity.setId(draftId); |
|
|
|
draftEntity.setDraftStatus(TopicConstant.BLOCK); |
|
|
|
draftEntity.setDraftReason("语音存在违规内容"); |
|
|
|
baseDao.updateById(draftEntity); |
|
|
|
|
|
|
|
} else if(TopicConstant.REVIEW.equals(status)) { |
|
|
|
//草稿状态更新为review
|
|
|
|
TopicDraftEntity draftEntity = new TopicDraftEntity(); |
|
|
|
draftEntity.setId(draftId); |
|
|
|
draftEntity.setDraftStatus(TopicConstant.REVIEW); |
|
|
|
draftEntity.setDraftReason("需要人工审核"); |
|
|
|
baseDao.updateById(draftEntity); |
|
|
|
|
|
|
|
} else if(TopicConstant.AUTO_PASSED.equals(status)) { |
|
|
|
//草稿状态更新为auto_passed
|
|
|
|
AuditDraftTopicFormDTO formDTO = new AuditDraftTopicFormDTO(); |
|
|
|
formDTO.setTopicDraftId(draftId); |
|
|
|
formDTO.setAuditType(TopicConstant.AUTO_PASSED); |
|
|
|
audit(null, formDTO); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 发布话题 |
|
|
|
* |
|
|
@ -251,7 +356,7 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void createTopic(TokenDto tokenDto, CreateTopicFormDTO formDTO) { |
|
|
|
if(StringUtils.isEmpty(formDTO.getTopicContent()) && CollectionUtils.isEmpty(formDTO.getVideoList())) { |
|
|
|
if(StringUtils.isBlank(formDTO.getTopicContent()) && CollectionUtils.isEmpty(formDTO.getVoiceList())) { |
|
|
|
//话题内容和语音不能同时为空
|
|
|
|
log.error(ModuleConstant.TOPIC_CONTENT_AND_VOICE_IS_NULL); |
|
|
|
throw new RenException(ModuleConstant.TOPIC_CONTENT_AND_VOICE_IS_NULL); |
|
|
@ -265,6 +370,9 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
} |
|
|
|
|
|
|
|
TopicDraftEntity topic = ConvertUtils.sourceToTarget(formDTO,TopicDraftEntity.class); |
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getVoiceList()) && StringUtils.isBlank(formDTO.getTopicContent())) { |
|
|
|
topic.setTopicContent("语音话题"); |
|
|
|
} |
|
|
|
topic.setCreatedBy(tokenDto.getUserId()); |
|
|
|
topic.setDraftStatus(TopicConstant.AUDITING); |
|
|
|
topic.setIsSee(NumConstant.ZERO_STR); |
|
|
@ -278,9 +386,9 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
} |
|
|
|
List<ImgTaskDTO> imageDTOList = new ArrayList<>(); |
|
|
|
if(CollectionUtils.isNotEmpty(formDTO.getImageList())){ |
|
|
|
TopicDraftAttachmentDTO attachment = new TopicDraftAttachmentDTO(); |
|
|
|
int sort = 0; |
|
|
|
for(String url : formDTO.getImageList()){ |
|
|
|
TopicDraftAttachmentDTO attachment = new TopicDraftAttachmentDTO(); |
|
|
|
attachment.setCustomerId(formDTO.getCustomerId()); |
|
|
|
attachment.setAttachmentUrl(url); |
|
|
|
attachment.setTopicDraftId(topic.getId()); |
|
|
@ -298,10 +406,10 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
} |
|
|
|
} |
|
|
|
List<VoiceTaskDTO> voiceDTOList = new ArrayList<>(); |
|
|
|
if(CollectionUtils.isNotEmpty(formDTO.getVideoList())){ |
|
|
|
TopicDraftAttachmentDTO attachment = new TopicDraftAttachmentDTO(); |
|
|
|
if(CollectionUtils.isNotEmpty(formDTO.getVoiceList())){ |
|
|
|
int sort = 0; |
|
|
|
for(FileDTO file : formDTO.getVideoList()){ |
|
|
|
for(FileDTO file : formDTO.getVoiceList()){ |
|
|
|
TopicDraftAttachmentDTO attachment = new TopicDraftAttachmentDTO(); |
|
|
|
attachment.setCustomerId(formDTO.getCustomerId()); |
|
|
|
attachment.setAttachmentUrl(file.getUrl()); |
|
|
|
attachment.setTopicDraftId(topic.getId()); |
|
|
@ -309,6 +417,7 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
attachment.setAttachmentFormat(file.getUrl().substring(file.getUrl().lastIndexOf(".") + NumConstant.ONE).toLowerCase()); |
|
|
|
attachment.setSort(sort++); |
|
|
|
attachment.setAttachmentType("voice"); |
|
|
|
attachment.setDuration(file.getDuration()); |
|
|
|
attachment.setStatus(TopicConstant.AUDITING); |
|
|
|
topicDraftAttachmentService.save(attachment); |
|
|
|
|
|
|
@ -428,68 +537,67 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
return taskEntity; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
topicDraftScanTaskService.insertBatch(scanTaskEntityList); |
|
|
|
|
|
|
|
//轮询
|
|
|
|
threadPool.submit(() -> { |
|
|
|
while (true) { |
|
|
|
Result<List<VoiceResultDTO>> voiceResults = ScanContentUtils.voiceResults(scanApiUrl.concat(voiceResultsMethod), taskIds); |
|
|
|
if (voiceResults.success()) { |
|
|
|
boolean isAllPass = true; |
|
|
|
List<VoiceResultDTO> list = voiceResults.getData(); |
|
|
|
for (VoiceResultDTO item : list) { |
|
|
|
if (TopicConstant.REVIEW.equals(item.getSuggestion())) { |
|
|
|
//结果不确定
|
|
|
|
TopicDraftAttachmentDTO dto = new TopicDraftAttachmentDTO(); |
|
|
|
dto.setId(item.getDataId()); |
|
|
|
dto.setStatus(TopicConstant.REVIEW); |
|
|
|
dto.setReason(item.getLabelDesc()); |
|
|
|
topicDraftAttachmentService.update(dto); |
|
|
|
|
|
|
|
TopicDraftScanTaskDTO taskDTO = new TopicDraftScanTaskDTO(); |
|
|
|
taskDTO.setTaskId(item.getTaskId()); |
|
|
|
taskDTO.setStatus(TopicConstant.REVIEW); |
|
|
|
topicDraftScanTaskService.updateByTask(taskDTO); |
|
|
|
isAllPass = false; |
|
|
|
} else if (TopicConstant.BLOCK.equals(item.getSuggestion())) { |
|
|
|
//结果违规
|
|
|
|
TopicDraftAttachmentDTO dto = new TopicDraftAttachmentDTO(); |
|
|
|
dto.setId(item.getDataId()); |
|
|
|
dto.setStatus(TopicConstant.BLOCK); |
|
|
|
dto.setReason(item.getLabelDesc()); |
|
|
|
topicDraftAttachmentService.update(dto); |
|
|
|
|
|
|
|
TopicDraftScanTaskDTO taskDTO = new TopicDraftScanTaskDTO(); |
|
|
|
taskDTO.setTaskId(item.getTaskId()); |
|
|
|
taskDTO.setStatus(TopicConstant.BLOCK); |
|
|
|
topicDraftScanTaskService.updateByTask(taskDTO); |
|
|
|
isAllPass = false; |
|
|
|
} else { |
|
|
|
//审核通过
|
|
|
|
TopicDraftAttachmentDTO dto = new TopicDraftAttachmentDTO(); |
|
|
|
dto.setId(item.getDataId()); |
|
|
|
dto.setStatus(TopicConstant.AUTO_PASSED); |
|
|
|
dto.setReason(item.getLabelDesc()); |
|
|
|
topicDraftAttachmentService.update(dto); |
|
|
|
|
|
|
|
TopicDraftScanTaskDTO taskDTO = new TopicDraftScanTaskDTO(); |
|
|
|
taskDTO.setTaskId(item.getTaskId()); |
|
|
|
taskDTO.setStatus(TopicConstant.AUTO_PASSED); |
|
|
|
topicDraftScanTaskService.updateByTask(taskDTO); |
|
|
|
} |
|
|
|
//审核通过,发布话题
|
|
|
|
if(isAllPass) { |
|
|
|
saveTopic(tokenDto, formDTO, topic.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
try { |
|
|
|
Thread.sleep(600000); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
// Result<List<VoiceResultDTO>> voiceResults = ScanContentUtils.voiceResults(scanApiUrl.concat(voiceResultsMethod), taskIds);
|
|
|
|
// if (voiceResults.success()) {
|
|
|
|
// boolean isAllPass = true;
|
|
|
|
// List<VoiceResultDTO> list = voiceResults.getData();
|
|
|
|
// for (VoiceResultDTO item : list) {
|
|
|
|
// TopicDraftScanTaskDTO taskDTO = topicDraftScanTaskService.getScanByTask(item.getTaskId());
|
|
|
|
// if (TopicConstant.REVIEW.equals(item.getSuggestion())) {
|
|
|
|
// //结果不确定
|
|
|
|
// TopicDraftAttachmentDTO dto = new TopicDraftAttachmentDTO();
|
|
|
|
// dto.setId(taskDTO.getTopicDraftAttachmentId());
|
|
|
|
// dto.setStatus(TopicConstant.REVIEW);
|
|
|
|
// dto.setReason(item.getLabelDesc());
|
|
|
|
// topicDraftAttachmentService.update(dto);
|
|
|
|
//
|
|
|
|
// taskDTO.setStatus(TopicConstant.REVIEW);
|
|
|
|
// topicDraftScanTaskService.update(taskDTO);
|
|
|
|
//
|
|
|
|
// TopicDraftEntity draftEntity = new TopicDraftEntity();
|
|
|
|
// draftEntity.setId(topic.getId());
|
|
|
|
// draftEntity.setDraftStatus(TopicConstant.REVIEW);
|
|
|
|
// draftEntity.setDraftReason("需要人工审核");
|
|
|
|
// baseDao.updateById(draftEntity);
|
|
|
|
//
|
|
|
|
// isAllPass = false;
|
|
|
|
// } else if (TopicConstant.BLOCK.equals(item.getSuggestion())) {
|
|
|
|
// //结果违规
|
|
|
|
// TopicDraftAttachmentDTO dto = new TopicDraftAttachmentDTO();
|
|
|
|
// dto.setId(taskDTO.getTopicDraftAttachmentId());
|
|
|
|
// dto.setStatus(TopicConstant.BLOCK);
|
|
|
|
// dto.setReason(item.getLabelDesc());
|
|
|
|
// topicDraftAttachmentService.update(dto);
|
|
|
|
//
|
|
|
|
// taskDTO.setStatus(TopicConstant.BLOCK);
|
|
|
|
// topicDraftScanTaskService.update(taskDTO);
|
|
|
|
//
|
|
|
|
// TopicDraftEntity draftEntity = new TopicDraftEntity();
|
|
|
|
// draftEntity.setId(topic.getId());
|
|
|
|
// draftEntity.setDraftStatus(TopicConstant.BLOCK);
|
|
|
|
// draftEntity.setDraftReason(item.getLabelDesc());
|
|
|
|
// baseDao.updateById(draftEntity);
|
|
|
|
//
|
|
|
|
// isAllPass = false;
|
|
|
|
// } else {
|
|
|
|
// //审核通过
|
|
|
|
// TopicDraftAttachmentDTO dto = new TopicDraftAttachmentDTO();
|
|
|
|
// dto.setId(taskDTO.getTopicDraftAttachmentId());
|
|
|
|
// dto.setStatus(TopicConstant.AUTO_PASSED);
|
|
|
|
// dto.setReason(item.getLabelDesc());
|
|
|
|
// topicDraftAttachmentService.update(dto);
|
|
|
|
//
|
|
|
|
// taskDTO.setStatus(TopicConstant.AUTO_PASSED);
|
|
|
|
// topicDraftScanTaskService.update(taskDTO);
|
|
|
|
// }
|
|
|
|
// //审核通过,发布话题
|
|
|
|
// if (isAllPass) {
|
|
|
|
// saveTopic(tokenDto, formDTO, topic.getId());
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
@ -560,6 +668,7 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
result.setReleaseTime(new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN_END_WITH_MINUTE).format(entity.getCreatedTime())); |
|
|
|
result.setTopicContent(entity.getTopicContent()); |
|
|
|
result.setReleaseAddress(entity.getAddress()); |
|
|
|
result.setReason(entity.getDraftReason()); |
|
|
|
if (TopicConstant.AUDITING.equals(entity.getDraftStatus()) || TopicConstant.REVIEW.equals(entity.getDraftStatus())) { |
|
|
|
result.setStatus(TopicConstant.AUDITING); |
|
|
|
} else if (TopicConstant.BLOCK.equals(entity.getDraftStatus()) || TopicConstant.REJECTED.equals(entity.getDraftStatus())) { |
|
|
@ -571,7 +680,13 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
result.setImageList(imageUrls); |
|
|
|
|
|
|
|
//3.查询话题音频附件
|
|
|
|
List<String> voiceUrls = topicDraftAttachmentService.getFileList(formDTO.getTopicDraftId(), TopicConstant.VOICE).stream().map(TopicDraftAttachmentDTO::getAttachmentUrl).collect(Collectors.toList()); |
|
|
|
List<FileDTO> voiceUrls = |
|
|
|
topicDraftAttachmentService.getFileList(formDTO.getTopicDraftId(), TopicConstant.VOICE).stream().map(item ->{ |
|
|
|
FileDTO fileDTO = new FileDTO(); |
|
|
|
fileDTO.setUrl(item.getAttachmentUrl()); |
|
|
|
fileDTO.setDuration(item.getDuration()); |
|
|
|
return fileDTO; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
result.setVoiceList(voiceUrls); |
|
|
|
|
|
|
|
//3.拿取用户信息
|
|
|
@ -594,6 +709,7 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
* @date 2020/12/18 14:58 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void deleteDraft(DraftDetailFormDTO formDTO) { |
|
|
|
TopicDraftEntity entity = new TopicDraftEntity(); |
|
|
|
entity.setId(formDTO.getTopicDraftId()); |
|
|
@ -610,35 +726,58 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
* @date 2020/12/18 15:06 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void audit(TokenDto tokenDto, AuditDraftTopicFormDTO formDTO) { |
|
|
|
TopicDraftEntity entity = new TopicDraftEntity(); |
|
|
|
entity.setId(formDTO.getTopicDraftId()); |
|
|
|
entity.setDraftReason(formDTO.getReason()); |
|
|
|
entity.setDraftStatus(formDTO.getAuditType()); |
|
|
|
baseDao.updateById(entity); |
|
|
|
if (TopicConstant.APPROVED.equals(formDTO.getAuditType())) { |
|
|
|
if (TopicConstant.APPROVED.equals(formDTO.getAuditType()) || TopicConstant.AUTO_PASSED.equals(formDTO.getAuditType())) { |
|
|
|
TopicDraftEntity draft = baseDao.selectById(formDTO.getTopicDraftId()); |
|
|
|
//将草稿存入话题表
|
|
|
|
ResiTopicEntity resiTopic = ConvertUtils.sourceToTarget(entity, ResiTopicEntity.class); |
|
|
|
ResiTopicEntity resiTopic = ConvertUtils.sourceToTarget(draft, ResiTopicEntity.class); |
|
|
|
resiTopic.setId(null); |
|
|
|
resiTopic.setStatus(TopicConstant.PUBLISHMENT); |
|
|
|
resiTopic.setCreatedTime(null); |
|
|
|
resiTopic.setUpdatedBy(draft.getCreatedBy()); |
|
|
|
resiTopic.setUpdatedTime(null); |
|
|
|
resiTopicDao.insert(resiTopic); |
|
|
|
entity = new TopicDraftEntity(); |
|
|
|
entity.setId(formDTO.getTopicDraftId()); |
|
|
|
entity.setTopicId(resiTopic.getId()); |
|
|
|
baseDao.updateById(entity); |
|
|
|
//将草稿附件存入附件表
|
|
|
|
List<TopicDraftAttachmentDTO> attachmentList = topicDraftAttachmentService.getFileList(formDTO.getTopicDraftId(), null); |
|
|
|
List<ResiTopicAttachmentEntity> topicAttachments = ConvertUtils.sourceToTarget(attachmentList, ResiTopicAttachmentEntity.class); |
|
|
|
topicAttachments.forEach(item -> { |
|
|
|
item.setId(null); |
|
|
|
item.setTopicId(resiTopic.getId()); |
|
|
|
item.setCreatedBy(draft.getCreatedBy()); |
|
|
|
item.setUpdatedBy(draft.getCreatedBy()); |
|
|
|
}); |
|
|
|
resiTopicAttachmentDao.insertBatch(topicAttachments); |
|
|
|
//将音频状态改为approved
|
|
|
|
List<TopicDraftAttachmentDTO> voiceList = |
|
|
|
attachmentList.stream().filter(item -> TopicConstant.VOICE.equals(item.getAttachmentType()) && TopicConstant.REVIEW.equals(item.getStatus())).collect(Collectors.toList()); |
|
|
|
if (CollectionUtils.isNotEmpty(voiceList)) { |
|
|
|
voiceList.forEach(item -> item.setStatus(TopicConstant.APPROVED)); |
|
|
|
topicDraftAttachmentService.updateBatchById(ConvertUtils.sourceToTarget(voiceList, TopicDraftAttachmentEntity.class)); |
|
|
|
if (TopicConstant.APPROVED.equals(formDTO.getAuditType())) { |
|
|
|
List<TopicDraftAttachmentDTO> voiceList = |
|
|
|
attachmentList.stream().filter(item -> TopicConstant.VOICE.equals(item.getAttachmentType()) && TopicConstant.REVIEW.equals(item.getStatus())).collect(Collectors.toList()); |
|
|
|
if (CollectionUtils.isNotEmpty(voiceList)) { |
|
|
|
voiceList.forEach(item -> item.setStatus(TopicConstant.APPROVED)); |
|
|
|
topicDraftAttachmentService.updateBatchById(ConvertUtils.sourceToTarget(voiceList, TopicDraftAttachmentEntity.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//发送积分
|
|
|
|
sendMqMsg(draft.getCreatedBy(), draft.getCustomerId()); |
|
|
|
StringBuilder breviary = new StringBuilder(); |
|
|
|
String content = CharMatcher.WHITESPACE.trimFrom(draft.getTopicContent()); |
|
|
|
if(!StringUtils.isBlank(content)){ |
|
|
|
breviary.append("\""); |
|
|
|
breviary.append(content.length() > NumConstant.TEN ? (content.substring(NumConstant.TEN) + "…") : content); |
|
|
|
breviary.append("\""); |
|
|
|
}else { |
|
|
|
breviary.append("话题"); |
|
|
|
} |
|
|
|
sendMqMsg(draft.getCreatedBy(), draft.getCustomerId(),draft.getCreatedTime(),resiGroupRedis.get(draft.getGroupId()).getGroupName(),breviary.toString()); |
|
|
|
} |
|
|
|
//记录操作记录
|
|
|
|
entity = baseDao.selectById(formDTO.getTopicDraftId()); |
|
|
@ -646,7 +785,7 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
operationDTO.setCustomerId(entity.getCustomerId()); |
|
|
|
operationDTO.setTopicDraftId(formDTO.getTopicDraftId()); |
|
|
|
operationDTO.setOperateType(formDTO.getAuditType()); |
|
|
|
operationDTO.setCreatedBy(tokenDto.getUserId()); |
|
|
|
operationDTO.setCreatedBy(null != tokenDto ? tokenDto.getUserId() : "APP_USER"); |
|
|
|
topicDraftOperationService.save(operationDTO); |
|
|
|
} |
|
|
|
|
|
|
@ -671,6 +810,9 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
Date currentTime = new Date(); |
|
|
|
//2.创建话题
|
|
|
|
ResiTopicEntity topic = ConvertUtils.sourceToTarget(formDTO,ResiTopicEntity.class); |
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getVoiceList()) && StringUtils.isBlank(formDTO.getTopicContent())) { |
|
|
|
topic.setTopicContent("语音话题"); |
|
|
|
} |
|
|
|
topic.setCreatedBy(tokenDto.getUserId()); |
|
|
|
topic.setStatus(TopicConstant.PUBLISHMENT); |
|
|
|
resiTopicDao.insertOne(topic); |
|
|
@ -680,9 +822,9 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
throw new RenException(ModuleConstant.NO_PRIMARY_KEY_RETURNED); |
|
|
|
} |
|
|
|
if(CollectionUtils.isNotEmpty(formDTO.getImageList())){ |
|
|
|
ResiTopicAttachmentEntity attachment = new ResiTopicAttachmentEntity(); |
|
|
|
int sort = 0; |
|
|
|
for(String url : formDTO.getImageList()){ |
|
|
|
ResiTopicAttachmentEntity attachment = new ResiTopicAttachmentEntity(); |
|
|
|
attachment.setAttachmentUrl(url); |
|
|
|
attachment.setTopicId(topic.getId()); |
|
|
|
attachment.setCreatedBy(tokenDto.getUserId()); |
|
|
@ -694,14 +836,15 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
} |
|
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(formDTO.getVoiceList())){ |
|
|
|
ResiTopicAttachmentEntity attachment = new ResiTopicAttachmentEntity(); |
|
|
|
int sort = 0; |
|
|
|
for(FileDTO file : formDTO.getVoiceList()){ |
|
|
|
ResiTopicAttachmentEntity attachment = new ResiTopicAttachmentEntity(); |
|
|
|
attachment.setAttachmentUrl(file.getUrl()); |
|
|
|
attachment.setTopicId(topic.getId()); |
|
|
|
attachment.setCreatedBy(tokenDto.getUserId()); |
|
|
|
attachment.setAttachmentFormat(file.getUrl().substring(file.getUrl().lastIndexOf(".") + NumConstant.ONE).toLowerCase()); |
|
|
|
attachment.setSort(sort++); |
|
|
|
attachment.setDuration(file.getDuration()); |
|
|
|
attachment.setAttachmentType("voice"); |
|
|
|
resiTopicAttachmentDao.insertOne(attachment); |
|
|
|
} |
|
|
@ -747,12 +890,33 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
TopicDraftEntity draftEntity = new TopicDraftEntity(); |
|
|
|
draftEntity.setId(draftId); |
|
|
|
draftEntity.setTopicId(topic.getId()); |
|
|
|
draftEntity.setDraftStatus(TopicConstant.AUTO_PASSED); |
|
|
|
baseDao.updateById(draftEntity); |
|
|
|
sendMqMsg(tokenDto.getUserId(), formDTO.getCustomerId()); |
|
|
|
|
|
|
|
TopicDraftEntity draft = baseDao.selectById(draftId); |
|
|
|
StringBuilder breviary = new StringBuilder(); |
|
|
|
String content = CharMatcher.WHITESPACE.trimFrom(draft.getTopicContent()); |
|
|
|
if(!StringUtils.isBlank(content) && !StringUtils.equals("语音话题",content)){ |
|
|
|
breviary.append("话题\""); |
|
|
|
breviary.append(content.length() > NumConstant.TEN ? (content.substring(NumConstant.ZERO,NumConstant.TEN) + "…") : content); |
|
|
|
breviary.append("\""); |
|
|
|
}else breviary.append("语音话题"); |
|
|
|
sendMqMsg(tokenDto.getUserId(), formDTO.getCustomerId(),draft.getCreatedTime(),resiGroupRedis.get(draft.getGroupId()).getGroupName(),breviary.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void sendMqMsg(String userId, String customerId) { |
|
|
|
/** |
|
|
|
* @Description 发送积分事件 |
|
|
|
* @param userId |
|
|
|
* @param customerId |
|
|
|
* @param targetDate 可为空 |
|
|
|
* @param groupName |
|
|
|
* @param topicBreviary 话题内容摘要"内容…" 如果没有文字则是"语音话题" |
|
|
|
* @return void |
|
|
|
* @author wangc |
|
|
|
* @date 2020.12.25 15:45 |
|
|
|
*/ |
|
|
|
private void sendMqMsg(String userId, String customerId, Date targetDate, String groupName, String topicBreviary) { |
|
|
|
//6.发送积分
|
|
|
|
MqBaseMsgDTO mqBaseMsgDTO=new MqBaseMsgDTO(); |
|
|
|
//mq的事件类型
|
|
|
@ -765,6 +929,9 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
actPointEventMsg.setUserId(userId); |
|
|
|
actPointEventMsg.setActionFlag(MqConstant.PLUS); |
|
|
|
actPointEventMsg.setIsCommon(false); |
|
|
|
actPointEventMsg.setRemark(new StringBuilder(groupName).append("小组中发布").append(topicBreviary).toString()); |
|
|
|
actPointEventMsg.setTargetDate(targetDate); |
|
|
|
actPointEventMsg.setEventTag(EventEnum.PUBLISH_ONE_TOPIC.getEventTag()); |
|
|
|
actPointEventMsgList.add(actPointEventMsg); |
|
|
|
|
|
|
|
mqBaseMsgDTO.setMsg(JSON.toJSONString(actPointEventMsgList)); |
|
|
@ -838,5 +1005,4 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |