能力申请V3 免批判断

This commit is contained in:
wangliwen 2022-09-01 17:04:09 +08:00
parent f3a155c44d
commit 7865ebbd27
4 changed files with 87 additions and 4 deletions

View File

@ -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<TAbilityApplicationDTO> dtoList = delegateTask.getVariable("tAbilityApplicationDTOList", List.class);
Optional<TAbilityApplicationDTO> tAbilityApplicationDTO = dtoList.stream().filter(index -> {
Optional<ResourceDTO> 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;
}
}
}

View File

@ -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<HistoricActivityInstance> historicActivityInstanceList=historyService.createHistoricActivityInstanceQuery().processInstanceId(delegateTask.getProcessInstanceId())
List<HistoricActivityInstance> 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<TAbilityApplicationDTO> dtoList = delegateTask.getVariable("tAbilityApplicationDTOList", List.class);
Optional<TAbilityApplicationDTO> tAbilityApplicationDTO = dtoList.stream().filter(index -> {
Optional<ResourceDTO> 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

View File

@ -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<HistoricActivityInstance> historicActivityInstanceList=historyService.createHistoricActivityInstanceQuery().processInstanceId(delegateTask.getProcessInstanceId())
List<HistoricActivityInstance> 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<TAbilityApplicationDTO> dtoList = delegateTask.getVariable("tAbilityApplicationDTOList", List.class);
Optional<TAbilityApplicationDTO> tAbilityApplicationDTO = dtoList.stream().filter(index -> {
Optional<ResourceDTO> 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

View File

@ -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<TAbilityApplicationDTO> dtoList = delegateTask.getVariable("tAbilityApplicationDTOList", List.class);
Optional<TAbilityApplicationDTO> tAbilityApplicationDTO = dtoList.stream().filter(index -> {
Optional<ResourceDTO> 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;
}
}