From 38c5cf54e34d82ca25facb7a2ef963f464614bd0 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Wed, 22 Dec 2021 16:03:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E4=B8=8A=E6=8A=A5=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=AF=AD=E9=9F=B3=E9=99=84=E4=BB=B6=E3=80=81=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E9=99=84=E4=BB=B6=E8=87=AA=E5=8A=A8=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/task/ResiEventAutoAuditTask.java | 30 +++ .../com/epmet/dto/ResiEventScanTaskDTO.java | 100 ++++++++++ .../com/epmet/dto/form/ResiEventFormDTO.java | 9 +- .../feign/GovProjectOpenFeignClient.java | 7 + .../GovProjectOpenFeignClientFallback.java | 9 + .../com/epmet/constant/EventConstant.java | 21 ++ .../epmet/controller/ResiEventController.java | 11 + .../ResiEventScanTaskController.java | 40 ++++ .../com/epmet/dao/ResiEventScanTaskDao.java | 33 +++ .../entity/ResiEventAttachmentEntity.java | 16 ++ .../com/epmet/entity/ResiEventEntity.java | 16 ++ .../epmet/entity/ResiEventScanTaskEntity.java | 71 +++++++ .../service/ResiEventScanTaskService.java | 38 ++++ .../com/epmet/service/ResiEventService.java | 6 + .../impl/ResiEventScanTaskServiceImpl.java | 53 +++++ .../service/impl/ResiEventServiceImpl.java | 188 +++++++++++++++++- .../resources/mapper/ResiEventScanTaskDao.xml | 8 + 17 files changed, 650 insertions(+), 6 deletions(-) create mode 100644 epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ResiEventAutoAuditTask.java create mode 100644 epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/ResiEventScanTaskDTO.java create mode 100644 epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ResiEventScanTaskController.java create mode 100644 epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ResiEventScanTaskDao.java create mode 100644 epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ResiEventScanTaskEntity.java create mode 100644 epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ResiEventScanTaskService.java create mode 100644 epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ResiEventScanTaskServiceImpl.java create mode 100644 epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ResiEventScanTaskDao.xml diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ResiEventAutoAuditTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ResiEventAutoAuditTask.java new file mode 100644 index 0000000000..1e56204d0f --- /dev/null +++ b/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()); + } + } +} diff --git a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/ResiEventScanTaskDTO.java b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/ResiEventScanTaskDTO.java new file mode 100644 index 0000000000..303159fbdf --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + +} \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/ResiEventFormDTO.java b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/ResiEventFormDTO.java index b0d1f4ff99..0a8929b0dd 100644 --- a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/ResiEventFormDTO.java +++ b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/dto/form/ResiEventFormDTO.java @@ -54,9 +54,9 @@ public class ResiEventFormDTO implements Serializable { private String address; /** - * 附件列表 + * 图片附件列表 */ - private List attachmentList; + private List attachmentList; /** * @的人 */ @@ -82,4 +82,9 @@ public class ResiEventFormDTO implements Serializable { */ @NotBlank(message = "customerId不能为空",groups = AddUserInternalGroup.class) private String customerId; + + /** + * 语音附件列表 + */ + private List voiceList; } diff --git a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/GovProjectOpenFeignClient.java b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/GovProjectOpenFeignClient.java index 7824ba71ee..9eaca9c495 100644 --- a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/GovProjectOpenFeignClient.java +++ b/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}") Result queryResiEventManageRedDot(@PathVariable("agencyId") String agencyId); + + /** + * @Author sun + * @Description 定时任务调用-事件语音附件自动审核 + **/ + @PostMapping("gov/project/resievent/autoAudit") + Result autoAudit(); } diff --git a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/fallback/GovProjectOpenFeignClientFallback.java b/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/fallback/GovProjectOpenFeignClientFallback.java index 41f41664c1..04aed95fa5 100644 --- a/epmet-module/gov-project/gov-project-client/src/main/java/com/epmet/feign/fallback/GovProjectOpenFeignClientFallback.java +++ b/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 queryResiEventManageRedDot(String 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"); + } } diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/EventConstant.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/EventConstant.java index 7daf809615..1b2dceb751 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/constant/EventConstant.java +++ b/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_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"; } diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ResiEventController.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ResiEventController.java index ca48b13304..973bfe0a24 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ResiEventController.java +++ b/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); return new Result().ok(resiEventService.queryResiEventResearchAnalysis(formDTO)); } + + /** + * @Author sun + * @Description 定时任务调用-事件语音附件自动审核 + **/ + @PostMapping("autoAudit") + public Result autoAudit() { + resiEventService.autoAudit(); + return new Result(); + } + } \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ResiEventScanTaskController.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/controller/ResiEventScanTaskController.java new file mode 100644 index 0000000000..bf86dad1de --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + + +} \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ResiEventScanTaskDao.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ResiEventScanTaskDao.java new file mode 100644 index 0000000000..fa2479ba11 --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 { + +} \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ResiEventAttachmentEntity.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ResiEventAttachmentEntity.java index 255c7c465c..b28acf8317 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ResiEventAttachmentEntity.java +++ b/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; + /** + * 附件状态(审核中:auditing; + auto_passed: 自动通过; + review:结果不确定,需要人工审核; + block: 结果违规; + rejected:人工审核驳回; + approved:人工审核通过) + 现在图片是同步审核的,所以图片只有auto_passed一种状态 + */ + private String status; + + /** + * 审核失败原因 + */ + private String reason; + } diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ResiEventEntity.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ResiEventEntity.java index f00dab5a06..ee261096ad 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ResiEventEntity.java +++ b/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; + /** + * 事件审核状态[涉及附件审核需要加的状态] + * (审核中:auditing; + * auto_passed: 自动通过; + * review:结果不确定,需要人工审核; + * block: 结果违规; + * rejected:人工审核驳回; + * approved:人工审核通过) + */ + private String auditStatus; + + /** + * 审核理由 + */ + private String auditReason; + } diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ResiEventScanTaskEntity.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/entity/ResiEventScanTaskEntity.java new file mode 100644 index 0000000000..360174e83d --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + +} diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ResiEventScanTaskService.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ResiEventScanTaskService.java new file mode 100644 index 0000000000..ec29a6beaf --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 { + + /** + * @Author sun + * @Description 获取事件附件待审核列表 + **/ + List getScanTaskList(String draftId, String auditing); +} \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ResiEventService.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ResiEventService.java index c6e52d4cc3..b54bc1dcac 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ResiEventService.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/ResiEventService.java @@ -155,4 +155,10 @@ public interface ResiEventService extends BaseService { * @return */ ResiEventResearchAnalysisResDTO queryResiEventResearchAnalysis(ResiEventResearchAnalysisFormDTO formDTO); + + /** + * @Author sun + * @Description 定时任务调用-事件语音附件自动审核 + **/ + void autoAudit(); } \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ResiEventScanTaskServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ResiEventScanTaskServiceImpl.java new file mode 100644 index 0000000000..53f5c1e53c --- /dev/null +++ b/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 + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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 implements ResiEventScanTaskService { + + /** + * @Author sun + * @Description 获取事件附件待审核列表 + **/ + @Override + public List getScanTaskList(String draftId, String status) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(draftId), "RESI_EVENT_ID", draftId); + wrapper.eq(StringUtils.isNotBlank(status),"STATUS", status); + List entityList = baseDao.selectList(wrapper); + return entityList; + + } + +} \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ResiEventServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ResiEventServiceImpl.java index 67b264d383..0748e862f4 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ResiEventServiceImpl.java +++ b/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.RenException; import com.epmet.commons.tools.page.PageData; -import com.epmet.commons.tools.scan.param.ImgScanParamDTO; -import com.epmet.commons.tools.scan.param.ImgTaskDTO; -import com.epmet.commons.tools.scan.param.TextScanParamDTO; -import com.epmet.commons.tools.scan.param.TextTaskDTO; +import com.epmet.commons.tools.scan.param.*; +import com.epmet.commons.tools.scan.result.AsyncScanResult; +import com.epmet.commons.tools.scan.result.AsyncScanTaskDTO; 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.utils.ConvertUtils; 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.GovIssueOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.resi.group.constant.TopicConstant; import com.epmet.service.ProjectCategoryService; +import com.epmet.service.ResiEventScanTaskService; import com.epmet.service.ResiEventService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -61,6 +63,8 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; /** * 居民报事表 @@ -77,6 +81,10 @@ public class ResiEventServiceImpl extends BaseServiceImpl attachmentEntityList=getAttList(formDTO.getCustomerId(),resiEventEntity.getId(),formDTO.getAttachmentList()); attachmentEntityList.forEach(attachmentEntity->{ resiEventAttachmentDao.insert(attachmentEntity); }); + //5-2.插入语音附件 + if(!org.apache.commons.collections4.CollectionUtils.isEmpty(formDTO.getVoiceList())) { + eventVoiceAttachment(formDTO.getCustomerId(), resiEventEntity.getId(), formDTO.getVoiceList()); + } //6、插入组织表 List orgEntityList=getOrgList(formDTO.getCustomerId(),resiEventEntity.getId(),formDTO.getOrgList()); orgEntityList.forEach(orgEntity->{ @@ -367,6 +394,56 @@ public class ResiEventServiceImpl extends BaseServiceImpl voiceList) { + //1.语音附件存入表中 + List 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 voiceScanResult = ScanContentUtils.voiceAsyncScan(scanApiUrl.concat(voiceAsyncScanMethod), voiceScanParamDTO); + if (!voiceScanResult.success() || !voiceScanResult.getData().isAllSuccess()) { + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + List taskList = voiceScanResult.getData().getSuccessTasks(); + List taskIds = taskList.stream().map(AsyncScanTaskDTO::getTaskId).collect(Collectors.toList()); + //提交记录存入task表 + List 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 attachmentList) { //事件内容 if (StringUtils.isNotBlank(eventContent)) { @@ -804,5 +881,108 @@ public class ResiEventServiceImpl extends BaseServiceImpl taskList = resiEventScanTaskService.getScanTaskList(null, TopicConstant.AUDITING); + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(taskList)) { + Map map = taskList.stream().collect(Collectors.toMap(ResiEventScanTaskEntity::getTaskId, Function.identity())); + List taskIds = taskList.stream().map(ResiEventScanTaskEntity::getTaskId).collect(Collectors.toList()); + List draftIds = taskList.stream().map(ResiEventScanTaskEntity::getResiEventId).collect(Collectors.toList()); + Result> voiceResults = ScanContentUtils.voiceResults(scanApiUrl.concat(voiceResultsMethod), taskIds); + if (!voiceResults.success()) { + return; + } + List 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 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); + } + }); + } + + } + } \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ResiEventScanTaskDao.xml b/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ResiEventScanTaskDao.xml new file mode 100644 index 0000000000..ae523c9093 --- /dev/null +++ b/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ResiEventScanTaskDao.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file