|
@ -27,11 +27,11 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.scan.param.ImgScanParamDTO; |
|
|
import com.epmet.commons.tools.scan.param.*; |
|
|
import com.epmet.commons.tools.scan.param.ImgTaskDTO; |
|
|
import com.epmet.commons.tools.scan.result.AsyncScanResult; |
|
|
import com.epmet.commons.tools.scan.param.TextScanParamDTO; |
|
|
import com.epmet.commons.tools.scan.result.AsyncScanTaskDTO; |
|
|
import com.epmet.commons.tools.scan.param.TextTaskDTO; |
|
|
|
|
|
import com.epmet.commons.tools.scan.result.SyncScanResult; |
|
|
import com.epmet.commons.tools.scan.result.SyncScanResult; |
|
|
|
|
|
import com.epmet.commons.tools.scan.result.VoiceResultDTO; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
@ -48,7 +48,9 @@ import com.epmet.feign.EpmetMessageOpenFeignClient; |
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
import com.epmet.feign.GovIssueOpenFeignClient; |
|
|
import com.epmet.feign.GovIssueOpenFeignClient; |
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
|
|
import com.epmet.resi.group.constant.TopicConstant; |
|
|
import com.epmet.service.ProjectCategoryService; |
|
|
import com.epmet.service.ProjectCategoryService; |
|
|
|
|
|
import com.epmet.service.ResiEventScanTaskService; |
|
|
import com.epmet.service.ResiEventService; |
|
|
import com.epmet.service.ResiEventService; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageInfo; |
|
|
import com.github.pagehelper.PageInfo; |
|
@ -61,6 +63,8 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.function.Function; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 居民报事表 |
|
|
* 居民报事表 |
|
@ -77,6 +81,10 @@ public class ResiEventServiceImpl extends BaseServiceImpl<ResiEventDao, ResiEven |
|
|
private String textSyncScanMethod; |
|
|
private String textSyncScanMethod; |
|
|
@Value("${openapi.scan.method.imgSyncScan}") |
|
|
@Value("${openapi.scan.method.imgSyncScan}") |
|
|
private String imgSyncScanMethod; |
|
|
private String imgSyncScanMethod; |
|
|
|
|
|
@Value("${openapi.scan.method.voiceAsyncScan}") |
|
|
|
|
|
private String voiceAsyncScanMethod; |
|
|
|
|
|
@Value("${openapi.scan.method.voiceResults}") |
|
|
|
|
|
private String voiceResultsMethod; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
@Autowired |
|
|
@Autowired |
|
@ -99,6 +107,8 @@ public class ResiEventServiceImpl extends BaseServiceImpl<ResiEventDao, ResiEven |
|
|
private GovIssueOpenFeignClient govIssueOpenFeignClient; |
|
|
private GovIssueOpenFeignClient govIssueOpenFeignClient; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ResiEventScanTaskService resiEventScanTaskService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -250,6 +260,14 @@ public class ResiEventServiceImpl extends BaseServiceImpl<ResiEventDao, ResiEven |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public ResiEventIdDTO report(ResiEventFormDTO formDTO) { |
|
|
public ResiEventIdDTO report(ResiEventFormDTO formDTO) { |
|
|
|
|
|
if(StringUtils.isBlank(formDTO.getEventContent()) && org.apache.commons.collections4.CollectionUtils.isEmpty(formDTO.getVoiceList())) { |
|
|
|
|
|
//话题内容和语音不能同时为空
|
|
|
|
|
|
log.error("事件内容和语音不能同时为空"); |
|
|
|
|
|
throw new RenException("事件内容和语音不能同时为空"); |
|
|
|
|
|
} |
|
|
|
|
|
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(formDTO.getVoiceList()) && StringUtils.isBlank(formDTO.getEventContent())) { |
|
|
|
|
|
formDTO.setEventContent("语音事件"); |
|
|
|
|
|
} |
|
|
//1、事件内容审核
|
|
|
//1、事件内容审核
|
|
|
//2、图片审核
|
|
|
//2、图片审核
|
|
|
this.scanContent(formDTO.getEventContent(), formDTO.getAttachmentList()); |
|
|
this.scanContent(formDTO.getEventContent(), formDTO.getAttachmentList()); |
|
@ -277,13 +295,22 @@ public class ResiEventServiceImpl extends BaseServiceImpl<ResiEventDao, ResiEven |
|
|
resiEventEntity.setLatestOperatedTime(new Date()); |
|
|
resiEventEntity.setLatestOperatedTime(new Date()); |
|
|
resiEventEntity.setCreatedTime(resiEventEntity.getLatestOperatedTime()); |
|
|
resiEventEntity.setCreatedTime(resiEventEntity.getLatestOperatedTime()); |
|
|
resiEventEntity.setUpdatedTime(resiEventEntity.getLatestOperatedTime()); |
|
|
resiEventEntity.setUpdatedTime(resiEventEntity.getLatestOperatedTime()); |
|
|
|
|
|
resiEventEntity.setAuditStatus("auto_passed"); |
|
|
|
|
|
if(!org.apache.commons.collections4.CollectionUtils.isEmpty(formDTO.getVoiceList())) { |
|
|
|
|
|
resiEventEntity.setAuditStatus("auditing"); |
|
|
|
|
|
} |
|
|
//4、插入主表resi_event
|
|
|
//4、插入主表resi_event
|
|
|
baseDao.insert(resiEventEntity); |
|
|
baseDao.insert(resiEventEntity); |
|
|
//5、插入附件表
|
|
|
//5、插入附件表
|
|
|
|
|
|
//5-1.插入图片附件
|
|
|
List<ResiEventAttachmentEntity> attachmentEntityList=getAttList(formDTO.getCustomerId(),resiEventEntity.getId(),formDTO.getAttachmentList()); |
|
|
List<ResiEventAttachmentEntity> attachmentEntityList=getAttList(formDTO.getCustomerId(),resiEventEntity.getId(),formDTO.getAttachmentList()); |
|
|
attachmentEntityList.forEach(attachmentEntity->{ |
|
|
attachmentEntityList.forEach(attachmentEntity->{ |
|
|
resiEventAttachmentDao.insert(attachmentEntity); |
|
|
resiEventAttachmentDao.insert(attachmentEntity); |
|
|
}); |
|
|
}); |
|
|
|
|
|
//5-2.插入语音附件
|
|
|
|
|
|
if(!org.apache.commons.collections4.CollectionUtils.isEmpty(formDTO.getVoiceList())) { |
|
|
|
|
|
eventVoiceAttachment(formDTO.getCustomerId(), resiEventEntity.getId(), formDTO.getVoiceList()); |
|
|
|
|
|
} |
|
|
//6、插入组织表
|
|
|
//6、插入组织表
|
|
|
List<ResiEventReportOrgEntity> orgEntityList=getOrgList(formDTO.getCustomerId(),resiEventEntity.getId(),formDTO.getOrgList()); |
|
|
List<ResiEventReportOrgEntity> orgEntityList=getOrgList(formDTO.getCustomerId(),resiEventEntity.getId(),formDTO.getOrgList()); |
|
|
orgEntityList.forEach(orgEntity->{ |
|
|
orgEntityList.forEach(orgEntity->{ |
|
@ -367,6 +394,56 @@ public class ResiEventServiceImpl extends BaseServiceImpl<ResiEventDao, ResiEven |
|
|
return list; |
|
|
return list; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Author sun |
|
|
|
|
|
* @Description 事件-语音附件处理【创建审核任务】 |
|
|
|
|
|
**/ |
|
|
|
|
|
private void eventVoiceAttachment(String customerId, String resiEventId, List<FileCommonDTO> voiceList) { |
|
|
|
|
|
//1.语音附件存入表中
|
|
|
|
|
|
List<VoiceTaskDTO> voiceDTOList = new ArrayList<>(); |
|
|
|
|
|
int sort = 0; |
|
|
|
|
|
for (FileCommonDTO file : voiceList) { |
|
|
|
|
|
ResiEventAttachmentEntity entity = new ResiEventAttachmentEntity(); |
|
|
|
|
|
entity.setCustomerId(customerId); |
|
|
|
|
|
entity.setResiEventId(resiEventId); |
|
|
|
|
|
entity.setAttachmentName(file.getName()); |
|
|
|
|
|
entity.setAttachmentFormat(file.getFormat()); |
|
|
|
|
|
entity.setAttachmentType(file.getType()); |
|
|
|
|
|
entity.setAttachmentUrl(file.getUrl()); |
|
|
|
|
|
entity.setSort(sort); |
|
|
|
|
|
sort++; |
|
|
|
|
|
resiEventAttachmentDao.insert(entity); |
|
|
|
|
|
|
|
|
|
|
|
VoiceTaskDTO task = new VoiceTaskDTO(); |
|
|
|
|
|
task.setDataId(entity.getId()); |
|
|
|
|
|
task.setUrl(file.getUrl()); |
|
|
|
|
|
voiceDTOList.add(task); |
|
|
|
|
|
} |
|
|
|
|
|
//2.语音创建审核任务【定时任务会处理待审核语音后修改数据库数据】
|
|
|
|
|
|
VoiceScanParamDTO voiceScanParamDTO = new VoiceScanParamDTO(); |
|
|
|
|
|
voiceScanParamDTO.setTasks(voiceDTOList); |
|
|
|
|
|
voiceScanParamDTO.setOpenCallBack(false); |
|
|
|
|
|
Result<AsyncScanResult> voiceScanResult = ScanContentUtils.voiceAsyncScan(scanApiUrl.concat(voiceAsyncScanMethod), voiceScanParamDTO); |
|
|
|
|
|
if (!voiceScanResult.success() || !voiceScanResult.getData().isAllSuccess()) { |
|
|
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
|
|
} else { |
|
|
|
|
|
List<AsyncScanTaskDTO> taskList = voiceScanResult.getData().getSuccessTasks(); |
|
|
|
|
|
List<String> taskIds = taskList.stream().map(AsyncScanTaskDTO::getTaskId).collect(Collectors.toList()); |
|
|
|
|
|
//提交记录存入task表
|
|
|
|
|
|
List<ResiEventScanTaskEntity> scanTaskEntityList = taskList.stream().map(item -> { |
|
|
|
|
|
ResiEventScanTaskEntity taskEntity = new ResiEventScanTaskEntity(); |
|
|
|
|
|
taskEntity.setCustomerId(customerId); |
|
|
|
|
|
taskEntity.setResiEventId(resiEventId); |
|
|
|
|
|
taskEntity.setResiEventAttachmentId(item.getDataId()); |
|
|
|
|
|
taskEntity.setTaskId(item.getTaskId()); |
|
|
|
|
|
taskEntity.setStatus(TopicConstant.AUDITING); |
|
|
|
|
|
taskEntity.setAttachmentType(TopicConstant.VOICE); |
|
|
|
|
|
return taskEntity; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
resiEventScanTaskService.insertBatch(scanTaskEntityList); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void scanContent(String eventContent, List<FileCommonDTO> attachmentList) { |
|
|
private void scanContent(String eventContent, List<FileCommonDTO> attachmentList) { |
|
|
//事件内容
|
|
|
//事件内容
|
|
|
if (StringUtils.isNotBlank(eventContent)) { |
|
|
if (StringUtils.isNotBlank(eventContent)) { |
|
@ -804,5 +881,108 @@ public class ResiEventServiceImpl extends BaseServiceImpl<ResiEventDao, ResiEven |
|
|
return resultDTO; |
|
|
return resultDTO; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Author sun |
|
|
|
|
|
* @Description 定时任务调用-事件语音附件自动审核 |
|
|
|
|
|
**/ |
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void autoAudit() { |
|
|
|
|
|
//1.查询审核中任务列表
|
|
|
|
|
|
List<ResiEventScanTaskEntity> taskList = resiEventScanTaskService.getScanTaskList(null, TopicConstant.AUDITING); |
|
|
|
|
|
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(taskList)) { |
|
|
|
|
|
Map<String, ResiEventScanTaskEntity> map = taskList.stream().collect(Collectors.toMap(ResiEventScanTaskEntity::getTaskId, Function.identity())); |
|
|
|
|
|
List<String> taskIds = taskList.stream().map(ResiEventScanTaskEntity::getTaskId).collect(Collectors.toList()); |
|
|
|
|
|
List<String> draftIds = taskList.stream().map(ResiEventScanTaskEntity::getResiEventId).collect(Collectors.toList()); |
|
|
|
|
|
Result<List<VoiceResultDTO>> voiceResults = ScanContentUtils.voiceResults(scanApiUrl.concat(voiceResultsMethod), taskIds); |
|
|
|
|
|
if (!voiceResults.success()) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
List<VoiceResultDTO> list = voiceResults.getData(); |
|
|
|
|
|
for (VoiceResultDTO item : list) { |
|
|
|
|
|
ResiEventScanTaskEntity taskEntity = map.get(item.getTaskId()); |
|
|
|
|
|
if (EventConstant.REVIEW.equals(item.getSuggestion())) { |
|
|
|
|
|
//结果不确定
|
|
|
|
|
|
ResiEventAttachmentEntity entity = new ResiEventAttachmentEntity(); |
|
|
|
|
|
entity.setId(taskEntity.getResiEventAttachmentId()); |
|
|
|
|
|
entity.setStatus(EventConstant.REVIEW); |
|
|
|
|
|
entity.setReason(item.getLabelDesc()); |
|
|
|
|
|
resiEventAttachmentDao.updateById(entity); |
|
|
|
|
|
|
|
|
|
|
|
taskEntity.setStatus(EventConstant.REVIEW); |
|
|
|
|
|
resiEventScanTaskService.updateById(taskEntity); |
|
|
|
|
|
|
|
|
|
|
|
} else if (EventConstant.BLOCK.equals(item.getSuggestion())) { |
|
|
|
|
|
//结果违规
|
|
|
|
|
|
ResiEventAttachmentEntity entity = new ResiEventAttachmentEntity(); |
|
|
|
|
|
entity.setId(taskEntity.getResiEventAttachmentId()); |
|
|
|
|
|
entity.setStatus(EventConstant.BLOCK); |
|
|
|
|
|
entity.setReason(item.getLabelDesc()); |
|
|
|
|
|
resiEventAttachmentDao.updateById(entity); |
|
|
|
|
|
|
|
|
|
|
|
taskEntity.setStatus(EventConstant.BLOCK); |
|
|
|
|
|
resiEventScanTaskService.updateById(taskEntity); |
|
|
|
|
|
} else { |
|
|
|
|
|
//审核通过
|
|
|
|
|
|
ResiEventAttachmentEntity entity = new ResiEventAttachmentEntity(); |
|
|
|
|
|
entity.setId(taskEntity.getResiEventAttachmentId()); |
|
|
|
|
|
entity.setStatus(EventConstant.AUTO_PASSED); |
|
|
|
|
|
entity.setReason(item.getLabelDesc()); |
|
|
|
|
|
resiEventAttachmentDao.updateById(entity); |
|
|
|
|
|
|
|
|
|
|
|
taskEntity.setStatus(EventConstant.AUTO_PASSED); |
|
|
|
|
|
resiEventScanTaskService.updateById(taskEntity); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//判断事件对应的所有需要审核的附件是否全部审核完成
|
|
|
|
|
|
draftIds.forEach(draftId -> { |
|
|
|
|
|
List<ResiEventScanTaskEntity> tasks = resiEventScanTaskService.getScanTaskList(draftId, null); |
|
|
|
|
|
String status = EventConstant.AUTO_PASSED; |
|
|
|
|
|
for (ResiEventScanTaskEntity task : tasks) { |
|
|
|
|
|
if (EventConstant.AUDITING.equals(task.getStatus())) { |
|
|
|
|
|
status = EventConstant.AUDITING; |
|
|
|
|
|
break; |
|
|
|
|
|
} else if (EventConstant.BLOCK.equals(task.getStatus())) { |
|
|
|
|
|
status = EventConstant.BLOCK; |
|
|
|
|
|
} else if (EventConstant.REVIEW.equals(task.getStatus())) { |
|
|
|
|
|
if (!EventConstant.BLOCK.equals(status)) { |
|
|
|
|
|
status = EventConstant.REVIEW; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
if (!EventConstant.BLOCK.equals(status) && !EventConstant.REVIEW.equals(status)) { |
|
|
|
|
|
status = EventConstant.AUTO_PASSED; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (EventConstant.BLOCK.equals(status)) { |
|
|
|
|
|
//草稿状态更新为block
|
|
|
|
|
|
ResiEventEntity draftEntity = new ResiEventEntity(); |
|
|
|
|
|
draftEntity.setId(draftId); |
|
|
|
|
|
draftEntity.setAuditStatus(EventConstant.BLOCK); |
|
|
|
|
|
draftEntity.setAuditReason("语音存在违规内容"); |
|
|
|
|
|
baseDao.updateById(draftEntity); |
|
|
|
|
|
|
|
|
|
|
|
} else if (EventConstant.REVIEW.equals(status)) { |
|
|
|
|
|
//草稿状态更新为review
|
|
|
|
|
|
ResiEventEntity draftEntity = new ResiEventEntity(); |
|
|
|
|
|
draftEntity.setId(draftId); |
|
|
|
|
|
draftEntity.setAuditStatus(EventConstant.REVIEW); |
|
|
|
|
|
draftEntity.setAuditReason("需要人工审核"); |
|
|
|
|
|
baseDao.updateById(draftEntity); |
|
|
|
|
|
|
|
|
|
|
|
} else if (EventConstant.AUTO_PASSED.equals(status)) { |
|
|
|
|
|
//草稿状态更新为auto_passed
|
|
|
|
|
|
ResiEventEntity draftEntity = new ResiEventEntity(); |
|
|
|
|
|
draftEntity.setId(draftId); |
|
|
|
|
|
draftEntity.setAuditStatus(EventConstant.REVIEW); |
|
|
|
|
|
baseDao.updateById(draftEntity); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |