|
|
@ -239,6 +239,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.REVIEW); |
|
|
|
draftEntity.setDraftReason("需要人工审核"); |
|
|
|
baseDao.updateById(draftEntity); |
|
|
|
|
|
|
|
} else if(TopicConstant.REVIEW.equals(status)) { |
|
|
|
//草稿状态更新为review
|
|
|
|
TopicDraftEntity draftEntity = new TopicDraftEntity(); |
|
|
|
draftEntity.setId(draftId); |
|
|
|
draftEntity.setDraftStatus(TopicConstant.BLOCK); |
|
|
|
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); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 发布话题 |
|
|
|
* |
|
|
@ -429,77 +533,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) { |
|
|
|
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()); |
|
|
|
} |
|
|
|
} |
|
|
|
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 { |
|
|
@ -611,6 +705,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()); |
|
|
@ -627,13 +722,14 @@ 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(draft, ResiTopicEntity.class); |
|
|
@ -643,17 +739,22 @@ public class TopicDraftServiceImpl extends BaseServiceImpl<TopicDraftDao, TopicD |
|
|
|
//将草稿附件存入附件表
|
|
|
|
List<TopicDraftAttachmentDTO> attachmentList = topicDraftAttachmentService.getFileList(formDTO.getTopicDraftId(), null); |
|
|
|
List<ResiTopicAttachmentEntity> topicAttachments = ConvertUtils.sourceToTarget(attachmentList, ResiTopicAttachmentEntity.class); |
|
|
|
topicAttachments.forEach(item -> { |
|
|
|
item.setTopicId(resiTopic.getId()); |
|
|
|
}); |
|
|
|
topicAttachments.forEach(item -> { |
|
|
|
item.setId(null); |
|
|
|
}); |
|
|
|
resiTopicAttachmentDao.insertBatch(topicAttachments); |
|
|
|
//将音频状态改为approved
|
|
|
|
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)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//发送积分
|
|
|
|
StringBuilder breviary = new StringBuilder(); |
|
|
@ -672,7 +773,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); |
|
|
|
} |
|
|
|
|
|
|
@ -774,6 +875,7 @@ 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); |
|
|
|
|
|
|
|
TopicDraftEntity draft = baseDao.selectById(draftId); |
|
|
|