From c645e0f1778ddb740d78839bde71ddf6fe3b3c04 Mon Sep 17 00:00:00 2001 From: lizhicheng Date: Tue, 4 Oct 2022 17:34:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD=EF=BC=9A?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=B6=88=E6=81=AF=E6=94=AF=E6=8C=81=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/db/V6.1__notice_add_col.sql | 3 + .../common/aspect/ActivitiNoticeAspect.java | 96 +++++++++++++++++-- .../activiti/service/ActTaskService.java | 10 +- .../listener/CommentListener.java | 2 +- .../modules/notice/dto/SysNoticeDTO.java | 6 +- .../notice/entity/SysNoticeEntity.java | 8 ++ .../notice/service/SysNoticeService.java | 2 + .../service/impl/SysNoticeServiceImpl.java | 14 +++ .../resources/mapper/notice/SysNoticeDao.xml | 2 +- .../resources/mapper/resource/ResourceDao.xml | 4 +- 10 files changed, 132 insertions(+), 15 deletions(-) create mode 100644 config/db/V6.1__notice_add_col.sql diff --git a/config/db/V6.1__notice_add_col.sql b/config/db/V6.1__notice_add_col.sql new file mode 100644 index 00000000..f2cc0434 --- /dev/null +++ b/config/db/V6.1__notice_add_col.sql @@ -0,0 +1,3 @@ +ALTER TABLE `sys_notice` +ADD COLUMN `apply_id` varchar(255) NULL COMMENT '通知来源id', +ADD COLUMN `apply_state` int NULL COMMENT '通知来源状态'; \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java b/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java index 32dd2ff6..cd51b9c3 100644 --- a/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java +++ b/renren-admin/src/main/java/io/renren/common/aspect/ActivitiNoticeAspect.java @@ -1,11 +1,14 @@ package io.renren.common.aspect; import com.alibaba.fastjson.JSON; +import com.google.common.collect.ImmutableMultimap; import io.renren.common.annotation.ActivitiNoticeOperation; import io.renren.modules.notice.dto.SysNoticeDTO; import io.renren.modules.notice.enums.NoticeStatusEnum; import io.renren.modules.notice.service.SysNoticeService; import io.renren.modules.processForm.dto.TAbilityApplicationDTO; +import io.renren.modules.processForm.service.TAbilityApplicationService; +import io.renren.modules.processForm.service.impl.TAbilityApplicationServiceImpl; import io.renren.modules.resource.service.ResourceService; import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.dto.SysRoleDTO; @@ -17,6 +20,7 @@ import org.activiti.engine.delegate.DelegateExecution; import org.activiti.engine.delegate.DelegateTask; import org.activiti.engine.delegate.ExecutionListener; import org.activiti.engine.delegate.TaskListener; +import org.apache.commons.collections.MultiMap; import org.apache.commons.lang3.StringUtils; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.After; @@ -57,6 +61,8 @@ public class ActivitiNoticeAspect { private SysDeptService sysDeptService; @Autowired private SysRoleService sysRoleService; + @Autowired + private TAbilityApplicationService tAbilityApplicationService; private Set work = new CopyOnWriteArraySet<>(); @@ -136,14 +142,15 @@ public class ActivitiNoticeAspect { } else if (kv.containsKey("_id")) { key = kv.getOrDefault("_id", "").toString(); } + final List tAbilityApplicationDTOList=kv.containsKey("tAbilityApplicationDTOList") ? (List) kv.get("tAbilityApplicationDTOList") : null; final StringBuilder resourceName = new StringBuilder(); if (kv.containsKey("resourceDTO")) { resourceName.append("'"); resourceName.append(((Map) kv.get("resourceDTO")).get("name")); resourceName.append("'"); - } else if (kv.containsKey("tAbilityApplicationDTOList")) { + } else if (tAbilityApplicationDTOList != null) { resourceName.append("'"); - resourceName.append(((List) kv.get("tAbilityApplicationDTOList")).get(0).getTitle()); + resourceName.append(tAbilityApplicationDTOList.get(0).getTitle()); resourceName.append("'"); } final String workKey = TaskListener.EVENTNAME_COMPLETE + key; @@ -186,8 +193,20 @@ public class ActivitiNoticeAspect { CompletableFuture.runAsync(() -> { // 发起人 SysUserDTO userDTO = sysUserService.get(Long.valueOf(finalCreator)); String content = "【通知】" + userDTO.getRealName() + ",您发起的" + resourceName + activitiNoticeOperation.process() + " " + activitiNoticeOperation.value() + "节点" + finalResult; + Integer type=10; + if("能力申请流程".equals(activitiNoticeOperation.process())){ + type=0; + }else if("能力资源上架".equals(activitiNoticeOperation.process())){ + type=2; + }else if("能力资源下架".equals(activitiNoticeOperation.process())){ + type=4; + }else if("能力需求申请".equals(activitiNoticeOperation.process())){ + type=6; + }else if("需求评论审核流程".equals(activitiNoticeOperation.process())){ + type=8; + } SysNoticeDTO dto = new SysNoticeDTO(); - dto.setType(2); + dto.setType(type); dto.setTitle("流程节点系统通知"); dto.setContent(content); // 通知内容 dto.setReceiverType(1); @@ -198,6 +217,8 @@ public class ActivitiNoticeAspect { dto.setCreator(sysUserService.getByUsername("admin").getId()); dto.setCreateDate(new Date()); dto.setFrom("通知"); + dto.setApplyId(tAbilityApplicationDTOList.get(0).getApplyFlag()); + dto.setApplyState(0); sysNoticeService.save(dto); }, EXECUTOR); } catch (Exception e) { @@ -231,14 +252,15 @@ public class ActivitiNoticeAspect { } else if (kv.containsKey("_id")) { key = kv.getOrDefault("_id", "").toString(); } + final List tAbilityApplicationDTOList=kv.containsKey("tAbilityApplicationDTOList") ? (List) kv.get("tAbilityApplicationDTOList") : null; final StringBuilder resourceName = new StringBuilder(); if (kv.containsKey("resourceDTO")) { resourceName.append("'"); resourceName.append(((Map) kv.get("resourceDTO")).get("name")); resourceName.append("'"); - } else if (kv.containsKey("tAbilityApplicationDTOList")) { + } else if (tAbilityApplicationDTOList != null) { resourceName.append("'"); - resourceName.append(((List) kv.get("tAbilityApplicationDTOList")).get(0).getTitle()); + resourceName.append(tAbilityApplicationDTOList.get(0).getTitle()); resourceName.append("'"); } final String workKey = ExecutionListener.EVENTNAME_END + key; @@ -281,8 +303,20 @@ public class ActivitiNoticeAspect { CompletableFuture.runAsync(() -> { // 发起人 SysUserDTO userDTO = sysUserService.get(Long.valueOf(finalCreator)); String content = "【通知】" + userDTO.getRealName() + ",您发起的" + resourceName + activitiNoticeOperation.process() + "已完成,审核结果为:" + finalResult; + Integer type=10; + if("能力申请流程".equals(activitiNoticeOperation.process())){ + type=0; + }else if("能力资源上架".equals(activitiNoticeOperation.process())){ + type=2; + }else if("能力资源下架".equals(activitiNoticeOperation.process())){ + type=4; + }else if("能力需求申请".equals(activitiNoticeOperation.process())){ + type=6; + }else if("需求评论审核流程".equals(activitiNoticeOperation.process())){ + type=8; + } SysNoticeDTO dto = new SysNoticeDTO(); - dto.setType(2); + dto.setType(type); dto.setTitle("流程结束系统通知"); dto.setContent(content); // 通知内容 dto.setReceiverType(1); @@ -293,6 +327,8 @@ public class ActivitiNoticeAspect { dto.setCreator(sysUserService.getByUsername("admin").getId()); dto.setCreateDate(new Date()); dto.setFrom("通知"); + dto.setApplyId(tAbilityApplicationDTOList.get(0).getApplyFlag()); + dto.setApplyState(0); sysNoticeService.save(dto); }, EXECUTOR).thenRunAsync(() -> { LOGGER.error("大数据局名称:{}", bigDateDeptName); @@ -307,6 +343,19 @@ public class ActivitiNoticeAspect { dto.setType(2); dto.setTitle("流程结束系统通知"); String content = "【通知】" + user.getRealName() + "," + creatorDTO.getRealName() + "发起的" + activitiNoticeOperation.process() + "已完成,审核结果为:" + finalResult; + Integer type=10; + if("能力申请流程".equals(activitiNoticeOperation.process())){ + type=1; + }else if("能力资源上架".equals(activitiNoticeOperation.process())){ + type=3; + }else if("能力资源下架".equals(activitiNoticeOperation.process())){ + type=5; + }else if("能力需求申请".equals(activitiNoticeOperation.process())){ + type=7; + }else if("需求评论审核流程".equals(activitiNoticeOperation.process())){ + type=9; + } + dto.setType(type); dto.setContent(content); // 通知内容 dto.setReceiverType(1); dto.setReceiverTypeIds(userDTO.get().getId().toString()); @@ -316,6 +365,8 @@ public class ActivitiNoticeAspect { dto.setCreator(sysUserService.getByUsername("admin").getId()); dto.setCreateDate(new Date()); dto.setFrom("通知"); + dto.setApplyId(execution.getProcessInstanceId()); + dto.setApplyState(1); sysNoticeService.save(dto); }); }, EXECUTOR); @@ -355,6 +406,7 @@ public class ActivitiNoticeAspect { } else if (kv.containsKey("_id")) { key = kv.getOrDefault("_id", "").toString(); } + final List tAbilityApplicationDTOList=kv.containsKey("tAbilityApplicationDTOList") ? (List) kv.get("tAbilityApplicationDTOList") : null; final StringBuilder resourceName = new StringBuilder(); if (kv.containsKey("resourceDTO")) { resourceName.append("'"); @@ -390,8 +442,20 @@ public class ActivitiNoticeAspect { LOGGER.error("审核人:{}", assignee.getId()); String content = "【通知】您发起的流程 " + resourceName + activitiNoticeOperation.process() + " 当前审核节点为:" + activitiNoticeOperation.value() + ";当前审核部门为:\"" + assignee.getDeptName() + "\";审核负责人\"" + assignee.getRealName() + "\""; LOGGER.info("通知内容:{}", content); + Integer type=10; + if("能力申请流程".equals(activitiNoticeOperation.process())){ + type=0; + }else if("能力资源上架".equals(activitiNoticeOperation.process())){ + type=2; + }else if("能力资源下架".equals(activitiNoticeOperation.process())){ + type=4; + }else if("能力需求申请".equals(activitiNoticeOperation.process())){ + type=6; + }else if("需求评论审核流程".equals(activitiNoticeOperation.process())){ + type=8; + } SysNoticeDTO dto = new SysNoticeDTO(); - dto.setType(2); + dto.setType(type); dto.setTitle("流程流转系统通知"); dto.setContent(content); // 通知内容 dto.setReceiverType(1); @@ -402,6 +466,8 @@ public class ActivitiNoticeAspect { dto.setCreator(sysUserService.getByUsername("admin").getId()); dto.setCreateDate(new Date()); dto.setFrom("通知"); + dto.setApplyId(tAbilityApplicationDTOList.get(0).getApplyFlag()); + dto.setApplyState(0); sysNoticeService.save(dto); } catch (Exception exception) { LOGGER.error("通知发起人失败", exception); @@ -410,8 +476,20 @@ public class ActivitiNoticeAspect { try { SysUserDTO owner = sysUserService.get(Long.valueOf(finalCreator)); String content = "【通知】" + owner.getRealName() + "发起的流程" + resourceName + activitiNoticeOperation.process() + " 已进入审核节点:" + activitiNoticeOperation.value() + ";当前审核人指派为您"; + Integer type=10; + if("能力申请流程".equals(activitiNoticeOperation.process())){ + type=1; + }else if("能力资源上架".equals(activitiNoticeOperation.process())){ + type=3; + }else if("能力资源下架".equals(activitiNoticeOperation.process())){ + type=5; + }else if("能力需求申请".equals(activitiNoticeOperation.process())){ + type=7; + }else if("需求评论审核流程".equals(activitiNoticeOperation.process())){ + type=9; + } SysNoticeDTO dto = new SysNoticeDTO(); - dto.setType(2); + dto.setType(type); dto.setTitle("流程流转系统通知"); dto.setContent(content); // 通知内容 dto.setReceiverType(1); @@ -422,6 +500,8 @@ public class ActivitiNoticeAspect { dto.setCreator(sysUserService.getByUsername("admin").getId()); dto.setCreateDate(new Date()); dto.setFrom("通知"); + dto.setApplyId(delegateTask.getProcessInstanceId()); + dto.setApplyState(0); sysNoticeService.save(dto); } catch (Exception exception) { LOGGER.error("通知审批人失败", exception); diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java index d4c62838..0912f227 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java @@ -15,6 +15,7 @@ import io.renren.modules.demanData.dto.TDemandDataDTO; import io.renren.modules.demanData.service.TDemandDataService; import io.renren.modules.demandComment.dto.TDemandCommentDTO; import io.renren.modules.demandComment.service.TDemandCommentService; +import io.renren.modules.notice.service.SysNoticeService; import io.renren.modules.processForm.dto.TAbilityApplicationDTO; import io.renren.modules.processForm.service.TAbilityApplicationService; import io.renren.modules.resource.dao.ResourceDao; @@ -119,6 +120,8 @@ public class ActTaskService extends BaseServiceImpl { private SysDeptDao sysDeptDao; @Autowired private ResourceDao resourceDao; + @Autowired + private SysNoticeService sysNoticeService; /** * 根据参数获取当前运行的任务信息 @@ -401,6 +404,7 @@ public class ActTaskService extends BaseServiceImpl { taskService.setVariable(taskId, Task_HANDLE_STATE, Task_HANDLE_STATE_AGREE); taskService.setVariable(taskId, "backToFirst", Boolean.FALSE); taskService.complete(taskId); + sysNoticeService.updateApplyStateById(task.getProcessInstanceId(), 1); } /** @@ -681,7 +685,7 @@ public class ActTaskService extends BaseServiceImpl { pvmTransitionListC.clear(); pvmTransitionListC.addAll(oriPvmTransitionList); } - + sysNoticeService.updateApplyStateById(task.getProcessInstanceId(), 1); } @Transactional(rollbackFor = Exception.class) @@ -739,7 +743,7 @@ public class ActTaskService extends BaseServiceImpl { pvmTransitionListC.clear(); pvmTransitionListC.addAll(oriPvmTransitionList); } - + sysNoticeService.updateApplyStateById(instanceId, 1); } private ActivityImpl findActivitiImpl(String taskId, String activityId) { @@ -867,6 +871,8 @@ public class ActTaskService extends BaseServiceImpl { currActivity.getOutgoingTransitions().remove(transitionImpl); pvmTransitionList.addAll(originPvmTransitionList); + + sysNoticeService.updateApplyStateById(currTask.getProcessInstanceId(), 1); } public void completeTaskByVariables(TaskDTO taskDTO) { diff --git a/renren-admin/src/main/java/io/renren/modules/demandComment/listener/CommentListener.java b/renren-admin/src/main/java/io/renren/modules/demandComment/listener/CommentListener.java index 5cea246b..b5a0511f 100644 --- a/renren-admin/src/main/java/io/renren/modules/demandComment/listener/CommentListener.java +++ b/renren-admin/src/main/java/io/renren/modules/demandComment/listener/CommentListener.java @@ -99,7 +99,7 @@ public class CommentListener implements TaskListener, ExecutionListener, Activit } @Override - @ActivitiNoticeOperation(value = "评论审核", process = "评论审核流程") + @ActivitiNoticeOperation(value = "评论审核", process = "需求评论审核流程") public void notify(DelegateTask delegateTask) { logger.error("事件类型: {}", delegateTask.getEventName()); final String eventName = delegateTask.getEventName(); diff --git a/renren-admin/src/main/java/io/renren/modules/notice/dto/SysNoticeDTO.java b/renren-admin/src/main/java/io/renren/modules/notice/dto/SysNoticeDTO.java index 860c0d10..7ac4e50f 100644 --- a/renren-admin/src/main/java/io/renren/modules/notice/dto/SysNoticeDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/notice/dto/SysNoticeDTO.java @@ -20,7 +20,7 @@ public class SysNoticeDTO implements Serializable { @ApiModelProperty(value = "id") private Long id; - @ApiModelProperty(value = "通知类型") + @ApiModelProperty(value = "通知类型 0:申请前台 1:申请后台 2:上架前台 3:上架后台 4:下架前台 5:下架后台 6:需求前台 7:需求后台 8:评论前台 9:评论后台 10:其他") private Integer type; @ApiModelProperty(value = "标题") private String title; @@ -50,4 +50,8 @@ public class SysNoticeDTO implements Serializable { private Integer readStatus; @ApiModelProperty(value = "通知来源 (通知、评论、其他)") private String from; + @ApiModelProperty(value = "通知来源id ,跳转使用") + private String applyId; + @ApiModelProperty(value = "通知来源状态 0:待办 1:已办") + private Integer applyState; } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/notice/entity/SysNoticeEntity.java b/renren-admin/src/main/java/io/renren/modules/notice/entity/SysNoticeEntity.java index d5905b8a..94b0910d 100644 --- a/renren-admin/src/main/java/io/renren/modules/notice/entity/SysNoticeEntity.java +++ b/renren-admin/src/main/java/io/renren/modules/notice/entity/SysNoticeEntity.java @@ -89,4 +89,12 @@ public class SysNoticeEntity { */ @TableField(value = "`from`") private String from; + /** + * 通知来源id + */ + private String applyId; + /** + * 通知来源状态 + */ + private Integer applyState; } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/notice/service/SysNoticeService.java b/renren-admin/src/main/java/io/renren/modules/notice/service/SysNoticeService.java index da8da0e0..581cf6cd 100644 --- a/renren-admin/src/main/java/io/renren/modules/notice/service/SysNoticeService.java +++ b/renren-admin/src/main/java/io/renren/modules/notice/service/SysNoticeService.java @@ -21,4 +21,6 @@ public interface SysNoticeService extends CrudService getMyNoticePage(Map params); + + void updateApplyStateById(String id, Integer state); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/notice/service/impl/SysNoticeServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/notice/service/impl/SysNoticeServiceImpl.java index 884ff5fe..32dc6b5f 100644 --- a/renren-admin/src/main/java/io/renren/modules/notice/service/impl/SysNoticeServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/notice/service/impl/SysNoticeServiceImpl.java @@ -73,6 +73,9 @@ public class SysNoticeServiceImpl extends CrudServiceImpl list=this.list(params); + list.stream().filter(it->it.getReceiverTypeIds().contains(SecurityUser.getUserId().toString())).forEach(it->{ + it.setApplyState(state); + this.update(it); + }); + } + @Override @Transactional(rollbackFor = Exception.class) public void save(SysNoticeDTO dto) { diff --git a/renren-admin/src/main/resources/mapper/notice/SysNoticeDao.xml b/renren-admin/src/main/resources/mapper/notice/SysNoticeDao.xml index f1c4ffdb..3fb76a3a 100644 --- a/renren-admin/src/main/resources/mapper/notice/SysNoticeDao.xml +++ b/renren-admin/src/main/resources/mapper/notice/SysNoticeDao.xml @@ -11,7 +11,7 @@ SELECT sd.name AS deptName, tdr.name AS resourceName, tdr.type, tdr.create_date AS createDate, - if(tdr.del_flag=0, '审核通过', '审核中') AS approveStatus, trma.apply_number AS applyNumber + if(tdr.del_flag=0, '审核通过', '审核中') AS approveStatus, trma.instance_id AS applyNumber FROM (SELECT IF(d.type='组件服务', A.attr_value, d.type) AS type, d.id, d.del_flag, d.dept_id, d.create_date, d.name FROM tb_data_resource d LEFT JOIN tb_data_attr a ON d.id=a.data_resource_id AND a.attr_type='组件类型' AND @@ -1819,7 +1819,7 @@