Browse Source

事件上报增加语音附件、语音附件自动审核任务

dev_shibei_match
sunyuchao 4 years ago
parent
commit
38c5cf54e3
  1. 30
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ResiEventAutoAuditTask.java
  2. 100
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/ResiEventScanTaskDTO.java
  3. 7
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/ResiEventFormDTO.java
  4. 7
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/GovProjectOpenFeignClient.java
  5. 9
      epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/fallback/GovProjectOpenFeignClientFallback.java
  6. 21
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/EventConstant.java
  7. 11
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ResiEventController.java
  8. 40
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ResiEventScanTaskController.java
  9. 33
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ResiEventScanTaskDao.java
  10. 16
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ResiEventAttachmentEntity.java
  11. 16
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ResiEventEntity.java
  12. 71
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ResiEventScanTaskEntity.java
  13. 38
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ResiEventScanTaskService.java
  14. 6
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ResiEventService.java
  15. 53
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ResiEventScanTaskServiceImpl.java
  16. 188
      epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ResiEventServiceImpl.java
  17. 8
      epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ResiEventScanTaskDao.xml

30
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ResiEventAutoAuditTask.java

@ -0,0 +1,30 @@
package com.epmet.task;
import com.epmet.commons.tools.utils.Result;
import com.epmet.feign.GovProjectOpenFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author sun
* @dscription 事件语音附件自动审核任务没两分钟执行一次
*/
@Slf4j
@Component("resiEventAutoAuditTask")
public class ResiEventAutoAuditTask implements ITask {
@Autowired
private GovProjectOpenFeignClient govProjectOpenFeignClient;
@Override
public void run(String params) {
log.info("ResiEventAutoAuditTask定时任务正在执行,参数为:{}", params);
Result result = govProjectOpenFeignClient.autoAudit();
if (result.success()) {
log.info("ResiEventAutoAuditTask定时任务执行成功");
} else {
log.error("ResiEventAutoAuditTask定时任务执行失败:" + result.getMsg());
}
}
}

100
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/ResiEventScanTaskDTO.java

@ -0,0 +1,100 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 事件附件安全校验任务表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-12-22
*/
@Data
public class ResiEventScanTaskDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 唯一标识
*/
private String id;
/**
* 客户ID
*/
private String customerId;
/**
* 事件Id关联resi_event的id
*/
private String resiEventId;
/**
* 事件附件表主键对应dataId
*/
private String resiEventAttachmentId;
/**
* 阿里云审核任务Id
*/
private String taskId;
/**
* 审核状态auditing: 审核中
auto_passed: 自动通过
review结果不确定需要人工审核
block: 结果违规
*/
private String status;
/**
* 附件类型视频 - video 语音 - voice 文件 - doc
*/
private String attachmentType;
/**
* 删除标识0.未删除 1.已删除
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
}

7
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/ResiEventFormDTO.java

@ -54,7 +54,7 @@ public class ResiEventFormDTO implements Serializable {
private String address; private String address;
/** /**
* 附件列表 * 图片附件列表
*/ */
private List<FileCommonDTO> attachmentList; private List<FileCommonDTO> attachmentList;
/** /**
@ -82,4 +82,9 @@ public class ResiEventFormDTO implements Serializable {
*/ */
@NotBlank(message = "customerId不能为空",groups = AddUserInternalGroup.class) @NotBlank(message = "customerId不能为空",groups = AddUserInternalGroup.class)
private String customerId; private String customerId;
/**
* 语音附件列表
*/
private List<FileCommonDTO> voiceList;
} }

7
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/GovProjectOpenFeignClient.java

@ -134,4 +134,11 @@ public interface GovProjectOpenFeignClient {
*/ */
@PostMapping("gov/project/resievent/queryResiEventManageRedDot/{agencyId}") @PostMapping("gov/project/resievent/queryResiEventManageRedDot/{agencyId}")
Result<ResiEventManageRedDotRes> queryResiEventManageRedDot(@PathVariable("agencyId") String agencyId); Result<ResiEventManageRedDotRes> queryResiEventManageRedDot(@PathVariable("agencyId") String agencyId);
/**
* @Author sun
* @Description 定时任务调用-事件语音附件自动审核
**/
@PostMapping("gov/project/resievent/autoAudit")
Result autoAudit();
} }

9
epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/fallback/GovProjectOpenFeignClientFallback.java

@ -132,4 +132,13 @@ public class GovProjectOpenFeignClientFallback implements GovProjectOpenFeignCli
public Result<ResiEventManageRedDotRes> queryResiEventManageRedDot(String agencyId) { public Result<ResiEventManageRedDotRes> queryResiEventManageRedDot(String agencyId) {
return ModuleUtils.feignConError(ServiceConstant.GOV_PROJECT_SERVER, "queryResiEventManageRedDot", agencyId); return ModuleUtils.feignConError(ServiceConstant.GOV_PROJECT_SERVER, "queryResiEventManageRedDot", agencyId);
} }
/**
* @Author sun
* @Description 定时任务调用-事件语音附件自动审核
**/
@Override
public Result autoAudit() {
return ModuleUtils.feignConError(ServiceConstant.GOV_PROJECT_SERVER, "autoAudit");
}
} }

21
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/EventConstant.java

@ -49,4 +49,25 @@ public interface EventConstant {
*/ */
String TYPE_GOV = "gov"; String TYPE_GOV = "gov";
String TYPE_RESI = "resi"; String TYPE_RESI = "resi";
/**
* 附件文件类型
* 图片 - image文档 - doc语音 - voice视频 - video
*/
String FILE_IMAGE = "image";
String FILE_DOC = "doc";
String FILE_VOICE = "voice";
String FILE_VIDEO = "video";
String AUDITING = "auditing";
String AUTO_PASSED = "auto_passed";
String REVIEW = "review";
String BLOCK = "block";
String REJECTED = "rejected";
String APPROVED = "approved";
String SUBMIT = "submit";
String IMAGE = "image";
String VIDEO = "video";
String VOICE = "voice";
String DOC = "doc";
} }

11
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ResiEventController.java

@ -254,4 +254,15 @@ public class ResiEventController {
ValidatorUtils.validateEntity(formDTO,ResiEventResearchAnalysisFormDTO.AddUserInternalGroup.class); ValidatorUtils.validateEntity(formDTO,ResiEventResearchAnalysisFormDTO.AddUserInternalGroup.class);
return new Result<ResiEventResearchAnalysisResDTO>().ok(resiEventService.queryResiEventResearchAnalysis(formDTO)); return new Result<ResiEventResearchAnalysisResDTO>().ok(resiEventService.queryResiEventResearchAnalysis(formDTO));
} }
/**
* @Author sun
* @Description 定时任务调用-事件语音附件自动审核
**/
@PostMapping("autoAudit")
public Result autoAudit() {
resiEventService.autoAudit();
return new Result();
}
} }

40
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ResiEventScanTaskController.java

@ -0,0 +1,40 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.controller;
import com.epmet.service.ResiEventScanTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 事件附件安全校验任务表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-12-22
*/
@RestController
@RequestMapping("resieventscantask")
public class ResiEventScanTaskController {
@Autowired
private ResiEventScanTaskService resiEventScanTaskService;
}

33
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ResiEventScanTaskDao.java

@ -0,0 +1,33 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.ResiEventScanTaskEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 事件附件安全校验任务表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-12-22
*/
@Mapper
public interface ResiEventScanTaskDao extends BaseDao<ResiEventScanTaskEntity> {
}

16
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ResiEventAttachmentEntity.java

@ -73,4 +73,20 @@ public class ResiEventAttachmentEntity extends BaseEpmetEntity {
*/ */
private Integer sort; private Integer sort;
/**
* 附件状态审核中auditing
auto_passed: 自动通过
review结果不确定需要人工审核
block: 结果违规
rejected人工审核驳回;
approved人工审核通过
现在图片是同步审核的所以图片只有auto_passed一种状态
*/
private String status;
/**
* 审核失败原因
*/
private String reason;
} }

16
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ResiEventEntity.java

@ -143,4 +143,20 @@ public class ResiEventEntity extends BaseEpmetEntity {
*/ */
private String closeRemark; private String closeRemark;
/**
* 事件审核状态[涉及附件审核需要加的状态]
* 审核中auditing
* auto_passed: 自动通过
* review结果不确定需要人工审核
* block: 结果违规
* rejected人工审核驳回;
* approved人工审核通过
*/
private String auditStatus;
/**
* 审核理由
*/
private String auditReason;
} }

71
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ResiEventScanTaskEntity.java

@ -0,0 +1,71 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 事件附件安全校验任务表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-12-22
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("resi_event_scan_task")
public class ResiEventScanTaskEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 事件Id关联resi_event的id
*/
private String resiEventId;
/**
* 事件附件表主键对应dataId
*/
private String resiEventAttachmentId;
/**
* 阿里云审核任务Id
*/
private String taskId;
/**
* 审核状态auditing: 审核中
auto_passed: 自动通过
review结果不确定需要人工审核
block: 结果违规
*/
private String status;
/**
* 附件类型视频 - video 语音 - voice 文件 - doc
*/
private String attachmentType;
}

38
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ResiEventScanTaskService.java

@ -0,0 +1,38 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.entity.ResiEventScanTaskEntity;
import java.util.List;
/**
* 事件附件安全校验任务表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-12-22
*/
public interface ResiEventScanTaskService extends BaseService<ResiEventScanTaskEntity> {
/**
* @Author sun
* @Description 获取事件附件待审核列表
**/
List<ResiEventScanTaskEntity> getScanTaskList(String draftId, String auditing);
}

6
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ResiEventService.java

@ -155,4 +155,10 @@ public interface ResiEventService extends BaseService<ResiEventEntity> {
* @return * @return
*/ */
ResiEventResearchAnalysisResDTO queryResiEventResearchAnalysis(ResiEventResearchAnalysisFormDTO formDTO); ResiEventResearchAnalysisResDTO queryResiEventResearchAnalysis(ResiEventResearchAnalysisFormDTO formDTO);
/**
* @Author sun
* @Description 定时任务调用-事件语音附件自动审核
**/
void autoAudit();
} }

53
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ResiEventScanTaskServiceImpl.java

@ -0,0 +1,53 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.dao.ResiEventScanTaskDao;
import com.epmet.entity.ResiEventScanTaskEntity;
import com.epmet.service.ResiEventScanTaskService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 事件附件安全校验任务表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-12-22
*/
@Service
public class ResiEventScanTaskServiceImpl extends BaseServiceImpl<ResiEventScanTaskDao, ResiEventScanTaskEntity> implements ResiEventScanTaskService {
/**
* @Author sun
* @Description 获取事件附件待审核列表
**/
@Override
public List<ResiEventScanTaskEntity> getScanTaskList(String draftId, String status) {
QueryWrapper<ResiEventScanTaskEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(draftId), "RESI_EVENT_ID", draftId);
wrapper.eq(StringUtils.isNotBlank(status),"STATUS", status);
List<ResiEventScanTaskEntity> entityList = baseDao.selectList(wrapper);
return entityList;
}
}

188
epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ResiEventServiceImpl.java

@ -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);
}
});
}
}
} }

8
epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ResiEventScanTaskDao.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.ResiEventScanTaskDao">
</mapper>
Loading…
Cancel
Save