From 7865ebbd277e653301982ec0a78692757f6c0f4c Mon Sep 17 00:00:00 2001 From: wangliwen Date: Thu, 1 Sep 2022 17:04:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=BD=E5=8A=9B=E7=94=B3=E8=AF=B7V3=20?= =?UTF-8?q?=E5=85=8D=E6=89=B9=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listener/v3/ApplyDeptListener.java | 21 ++++++++++++++++ .../listener/v3/ApplyDistrictListener.java | 25 +++++++++++++++++-- .../processForm/listener/v3/CityListener.java | 25 +++++++++++++++++-- .../listener/v3/OwnerDistrictListener.java | 20 +++++++++++++++ 4 files changed, 87 insertions(+), 4 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/ApplyDeptListener.java b/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/ApplyDeptListener.java index d2d05a52..ddf69aad 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/ApplyDeptListener.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/ApplyDeptListener.java @@ -7,6 +7,8 @@ import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import io.renren.common.annotation.ActivitiNoticeOperation; import io.renren.modules.processForm.dto.TAbilityApplicationDTO; +import io.renren.modules.resource.dto.ResourceDTO; +import io.renren.modules.resource.service.ResourceService; import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.dto.SysRoleDTO; import io.renren.modules.sys.dto.SysUserDTO; @@ -17,6 +19,7 @@ import org.activiti.engine.TaskService; import org.activiti.engine.delegate.*; import org.activiti.engine.delegate.event.ActivitiEvent; import org.activiti.engine.delegate.event.ActivitiEventListener; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -24,7 +27,9 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.util.Date; +import java.util.List; import java.util.Map; +import java.util.Optional; /** * 发起人部门负责人 @@ -42,6 +47,8 @@ public class ApplyDeptListener implements TaskListener, ExecutionListener, Activ private SysRoleService sysRoleService; @Autowired private SysDeptService sysDeptService; + @Autowired + private ResourceService resourceService; @Value("${big_date.assignee_role_name}") private String roleName; // 具备审批的角色名称 @@ -123,5 +130,19 @@ public class ApplyDeptListener implements TaskListener, ExecutionListener, Activ assignee = defaultAssigneeRoleId; } logger.error("分配的用户id为:{}", assignee); + List dtoList = delegateTask.getVariable("tAbilityApplicationDTOList", List.class); + Optional tAbilityApplicationDTO = dtoList.stream().filter(index -> { + Optional resourceDTOOptional = Optional.ofNullable(resourceService.get(Long.valueOf(index.getResourceId()))); + if (resourceDTOOptional.isPresent()) { + return !StringUtils.contains(resourceDTOOptional.get().getShareCondition(), "免批"); // 存在非免批 + } else { + return false; + } + }).findAny(); + if (!tAbilityApplicationDTO.isPresent()) { // 全是免批 + taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "免批资源申请默认通过"); + taskService.complete(delegateTask.getId(), delegateTask.getVariables()); + return; + } } } diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/ApplyDistrictListener.java b/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/ApplyDistrictListener.java index 42911dd1..c1d7e60e 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/ApplyDistrictListener.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/ApplyDistrictListener.java @@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSON; import com.google.common.collect.ImmutableMap; import io.renren.common.annotation.ActivitiNoticeOperation; import io.renren.modules.activiti.service.ActTaskService; +import io.renren.modules.processForm.dto.TAbilityApplicationDTO; +import io.renren.modules.resource.dto.ResourceDTO; +import io.renren.modules.resource.service.ResourceService; import io.renren.modules.sys.dao.SysUserDao; import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.dto.SysRoleDTO; @@ -52,6 +55,8 @@ public class ApplyDistrictListener implements TaskListener, ExecutionListener, A private SysRoleService sysRoleService; @Autowired private SysRegionService sysRegionService; + @Autowired + private ResourceService resourceService; @Value("${big_date.assignee_district_role_name}") private String roleName; // 具备审批的角色名称 @@ -118,6 +123,7 @@ public class ApplyDistrictListener implements TaskListener, ExecutionListener, A /** * 审批人去重 + * * @param delegateTask * @param assignee */ @@ -134,9 +140,9 @@ public class ApplyDistrictListener implements TaskListener, ExecutionListener, A return; } //规则2:同一审批人连续出现时(仅保留第一个) - List historicActivityInstanceList=historyService.createHistoricActivityInstanceQuery().processInstanceId(delegateTask.getProcessInstanceId()) + List historicActivityInstanceList = historyService.createHistoricActivityInstanceQuery().processInstanceId(delegateTask.getProcessInstanceId()) .activityType("userTask").finished().orderByHistoricActivityInstanceEndTime().desc().list(); - if(!historicActivityInstanceList.isEmpty() && historicActivityInstanceList.get(0).getAssignee().equals(assignee)){ + if (!historicActivityInstanceList.isEmpty() && historicActivityInstanceList.get(0).getAssignee().equals(assignee)) { taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "审批人重复,默认通过"); taskService.setVariable(delegateTask.getId(), ActTaskService.Task_HANDLE_STATE, ActTaskService.Task_HANDLE_STATE_AGREE); taskService.setVariable(delegateTask.getId(), "backToFirst", Boolean.FALSE); @@ -144,6 +150,21 @@ public class ApplyDistrictListener implements TaskListener, ExecutionListener, A taskService.complete(delegateTask.getId(), delegateTask.getVariables()); return; } + + List dtoList = delegateTask.getVariable("tAbilityApplicationDTOList", List.class); + Optional tAbilityApplicationDTO = dtoList.stream().filter(index -> { + Optional resourceDTOOptional = Optional.ofNullable(resourceService.get(Long.valueOf(index.getResourceId()))); + if (resourceDTOOptional.isPresent()) { + return !StringUtils.contains(resourceDTOOptional.get().getShareCondition(), "免批"); // 存在非免批 + } else { + return false; + } + }).findAny(); + if (!tAbilityApplicationDTO.isPresent()) { // 全是免批 + taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "免批资源申请默认通过"); + taskService.complete(delegateTask.getId(), delegateTask.getVariables()); + return; + } } @Override diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/CityListener.java b/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/CityListener.java index 01ff940d..ae69fa42 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/CityListener.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/CityListener.java @@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSON; import com.google.common.collect.ImmutableMap; import io.renren.common.annotation.ActivitiNoticeOperation; import io.renren.modules.activiti.service.ActTaskService; +import io.renren.modules.processForm.dto.TAbilityApplicationDTO; +import io.renren.modules.resource.dto.ResourceDTO; +import io.renren.modules.resource.service.ResourceService; import io.renren.modules.sys.dao.SysUserDao; import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.dto.SysRoleDTO; @@ -52,6 +55,8 @@ public class CityListener implements TaskListener, ExecutionListener, ActivitiEv private SysRoleService sysRoleService; @Autowired private SysRegionService sysRegionService; + @Autowired + private ResourceService resourceService; @Value("${big_date.assignee_city_role_name}") private String roleName; // 具备审批的角色名称 @@ -119,6 +124,7 @@ public class CityListener implements TaskListener, ExecutionListener, ActivitiEv /** * 审批人去重 + * * @param delegateTask * @param assignee */ @@ -135,9 +141,9 @@ public class CityListener implements TaskListener, ExecutionListener, ActivitiEv return; } //规则2:同一审批人连续出现时(仅保留第一个) - List historicActivityInstanceList=historyService.createHistoricActivityInstanceQuery().processInstanceId(delegateTask.getProcessInstanceId()) + List historicActivityInstanceList = historyService.createHistoricActivityInstanceQuery().processInstanceId(delegateTask.getProcessInstanceId()) .activityType("userTask").finished().orderByHistoricActivityInstanceEndTime().desc().list(); - if(!historicActivityInstanceList.isEmpty() && historicActivityInstanceList.get(0).getAssignee().equals(assignee)){ + if (!historicActivityInstanceList.isEmpty() && historicActivityInstanceList.get(0).getAssignee().equals(assignee)) { taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "审批人重复,默认通过"); taskService.setVariable(delegateTask.getId(), ActTaskService.Task_HANDLE_STATE, ActTaskService.Task_HANDLE_STATE_AGREE); taskService.setVariable(delegateTask.getId(), "backToFirst", Boolean.FALSE); @@ -145,6 +151,21 @@ public class CityListener implements TaskListener, ExecutionListener, ActivitiEv taskService.complete(delegateTask.getId(), delegateTask.getVariables()); return; } + + List dtoList = delegateTask.getVariable("tAbilityApplicationDTOList", List.class); + Optional tAbilityApplicationDTO = dtoList.stream().filter(index -> { + Optional resourceDTOOptional = Optional.ofNullable(resourceService.get(Long.valueOf(index.getResourceId()))); + if (resourceDTOOptional.isPresent()) { + return !StringUtils.contains(resourceDTOOptional.get().getShareCondition(), "免批"); // 存在非免批 + } else { + return false; + } + }).findAny(); + if (!tAbilityApplicationDTO.isPresent()) { // 全是免批 + taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "免批资源申请默认通过"); + taskService.complete(delegateTask.getId(), delegateTask.getVariables()); + return; + } } @Override diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/OwnerDistrictListener.java b/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/OwnerDistrictListener.java index c31b454c..ccb40225 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/OwnerDistrictListener.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/listener/v3/OwnerDistrictListener.java @@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSON; import com.google.common.collect.ImmutableMap; import io.renren.common.annotation.ActivitiNoticeOperation; import io.renren.modules.activiti.service.ActTaskService; +import io.renren.modules.processForm.dto.TAbilityApplicationDTO; +import io.renren.modules.resource.dto.ResourceDTO; +import io.renren.modules.resource.service.ResourceService; import io.renren.modules.sys.dao.SysUserDao; import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.dto.SysRoleDTO; @@ -49,6 +52,8 @@ public class OwnerDistrictListener implements TaskListener, ExecutionListener, A private SysRegionService sysRegionService; @Autowired private SysDeptService sysDeptService; + @Autowired + private ResourceService resourceService; @Value("${big_date.assignee_district_role_name}") private String roleName; // 具备审批的角色名称 @@ -141,6 +146,21 @@ public class OwnerDistrictListener implements TaskListener, ExecutionListener, A taskService.complete(delegateTask.getId(), delegateTask.getVariables()); return; } + + List dtoList = delegateTask.getVariable("tAbilityApplicationDTOList", List.class); + Optional tAbilityApplicationDTO = dtoList.stream().filter(index -> { + Optional resourceDTOOptional = Optional.ofNullable(resourceService.get(Long.valueOf(index.getResourceId()))); + if (resourceDTOOptional.isPresent()) { + return !StringUtils.contains(resourceDTOOptional.get().getShareCondition(), "免批"); // 存在非免批 + } else { + return false; + } + }).findAny(); + if (!tAbilityApplicationDTO.isPresent()) { // 全是免批 + taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "免批资源申请默认通过"); + taskService.complete(delegateTask.getId(), delegateTask.getVariables()); + return; + } }