Browse Source

话题语音审核结果查询定时任务

dev_shibei_match
zhaoqifeng 5 years ago
parent
commit
de697933b3
  1. 6
      epmet-module/epmet-job/epmet-job-server/pom.xml
  2. 12
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/TopicAutoAuditService.java
  3. 22
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/TopicAutoAuditServiceImpl.java
  4. 31
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/TopicAutoAuditTask.java
  5. 10
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java
  6. 12
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java
  7. 12
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/TopicDraftController.java
  8. 10
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/TopicDraftScanTaskService.java
  9. 9
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/TopicDraftService.java
  10. 18
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftScanTaskServiceImpl.java
  11. 256
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftServiceImpl.java

6
epmet-module/epmet-job/epmet-job-server/pom.xml

@ -79,6 +79,12 @@
<artifactId>feign-httpclient</artifactId>
<version>10.3.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>resi-group-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

12
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/TopicAutoAuditService.java

@ -0,0 +1,12 @@
package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/12/29 17:45
*/
public interface TopicAutoAuditService {
Result autoAudit();
}

22
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/TopicAutoAuditServiceImpl.java

@ -0,0 +1,22 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.utils.Result;
import com.epmet.resi.group.feign.ResiGroupOpenFeignClient;
import com.epmet.service.TopicAutoAuditService;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/12/29 17:46
*/
public class TopicAutoAuditServiceImpl implements TopicAutoAuditService {
@Autowired
private ResiGroupOpenFeignClient resiGroupOpenFeignClient;
@Override
public Result autoAudit() {
return resiGroupOpenFeignClient.autoAudit();
}
}

31
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/TopicAutoAuditTask.java

@ -0,0 +1,31 @@
package com.epmet.task;
import com.epmet.commons.tools.utils.Result;
import com.epmet.service.TopicAutoAuditService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/12/29 17:43
*/
@Slf4j
@Component("topicAutoAuditTask")
public class TopicAutoAuditTask implements ITask {
@Autowired
private TopicAutoAuditService topicAutoAuditService;
@Override
public void run(String params) {
log.info("TopicAutoAuditTask定时任务正在执行,参数为:{}", params);
Result result = topicAutoAuditService.autoAudit();
if (result.success()) {
log.info("TopicAutoAuditTask定时任务执行成功");
} else {
log.error("TopicAutoAuditTask定时任务执行失败:" + result.getMsg());
}
}
}

10
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java

@ -164,4 +164,14 @@ public interface ResiGroupOpenFeignClient {
*/
@PostMapping("resi/group/topicsharelinkvisitrecord/checkinviterelationship")
Result<String> checkInviteRelationship(@RequestBody SharableTopicAndInviteeFormDTO param);
/**
* 自动审核
* @author zhaoqifeng
* @date 2020/12/30 10:11
* @return com.epmet.commons.tools.utils.Result
*/
@PostMapping("resi/group/topicdraft/autoAudit")
Result autoAudit();
}

12
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java

@ -110,4 +110,16 @@ public class ResiGroupOpenFeignClientFallback implements ResiGroupOpenFeignClien
public Result<String> checkInviteRelationship(SharableTopicAndInviteeFormDTO param) {
return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "selectTopicBelongGroup", param);
}
/**
* 自动审核
*
* @return com.epmet.commons.tools.utils.Result
* @author zhaoqifeng
* @date 2020/12/30 10:11
*/
@Override
public Result autoAudit() {
return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "autoAudit");
}
}

12
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/TopicDraftController.java

@ -180,4 +180,16 @@ public class TopicDraftController {
formDTO.setUserId(tokenDto.getUserId());
return new Result<List<MyAuditingListResultDTO>>().ok(topicDraftService.myAuditingList(formDTO));
}
/**
* 自动审核
* @author zhaoqifeng
* @date 2020/12/30 10:11
* @return com.epmet.commons.tools.utils.Result
*/
@PostMapping("autoAudit")
public Result autoAudit() {
topicDraftService.autoAudit();
return new Result();
}
}

10
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/TopicDraftScanTaskService.java

@ -96,4 +96,14 @@ public interface TopicDraftScanTaskService extends BaseService<TopicDraftScanTas
void updateByTask(TopicDraftScanTaskDTO dto);
TopicDraftScanTaskDTO getScanByTask(String taskId);
/**
* 获取审核中的数据
* @author zhaoqifeng
* @date 2020/12/29 17:57
* @param draftId
* @param status
* @return java.util.List<com.epmet.resi.group.dto.topic.TopicDraftScanTaskDTO>
*/
List<TopicDraftScanTaskDTO> getScanTaskList(String draftId, String status);
}

9
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/TopicDraftService.java

@ -153,4 +153,13 @@ public interface TopicDraftService extends BaseService<TopicDraftEntity> {
* @Description 个人中心-我发表的话题-审核中列表
**/
List<MyAuditingListResultDTO> myAuditingList(MyAuditingListFormDTO formDTO);
/**
* 自动审核
* @author zhaoqifeng
* @date 2020/12/29 17:51
* @param
* @return void
*/
void autoAudit();
}

18
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftScanTaskServiceImpl.java

@ -26,6 +26,7 @@ import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.modules.topic.dao.TopicDraftScanTaskDao;
import com.epmet.modules.topic.entity.TopicDraftScanTaskEntity;
import com.epmet.modules.topic.service.TopicDraftScanTaskService;
import com.epmet.resi.group.constant.TopicConstant;
import com.epmet.resi.group.dto.topic.TopicDraftScanTaskDTO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -107,4 +108,21 @@ public class TopicDraftScanTaskServiceImpl extends BaseServiceImpl<TopicDraftSca
return baseDao.selectScanByTask(taskId);
}
/**
* 获取审核中的数据
*
* @return java.util.List<com.epmet.resi.group.dto.topic.TopicDraftScanTaskDTO>
* @author zhaoqifeng
* @date 2020/12/29 17:57
*/
@Override
public List<TopicDraftScanTaskDTO> getScanTaskList(String draftId, String status) {
QueryWrapper<TopicDraftScanTaskEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(draftId), "TOPIC_DRAFT_ID", draftId);
wrapper.eq(StringUtils.isNotBlank(status),"STATUS", status);
List<TopicDraftScanTaskEntity> entityList = baseDao.selectList(wrapper);
return ConvertUtils.sourceToTarget(entityList, TopicDraftScanTaskDTO.class);
}
}

256
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftServiceImpl.java

@ -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,16 +739,21 @@ 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
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));
}
}
//发送积分
@ -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);

Loading…
Cancel
Save