Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
wangliwen 2022-08-30 12:54:56 +08:00
commit b3074d25ad
4 changed files with 94 additions and 14 deletions

View File

@ -4,7 +4,6 @@ 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.sys.dao.SysUserDao;
import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.dto.SysRoleDTO;
@ -15,10 +14,12 @@ import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysRegionService;
import io.renren.modules.sys.service.SysRoleService;
import io.renren.modules.sys.service.SysUserService;
import org.activiti.engine.HistoryService;
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.activiti.engine.history.HistoricActivityInstance;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -27,6 +28,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
/**
* 申请发起人区市管理员审批
@ -39,6 +41,8 @@ public class ApplyDistrictListener implements TaskListener, ExecutionListener, A
@Autowired
private TaskService taskService;
@Autowired
private HistoryService historyService;
@Autowired
private SysDeptService sysDeptService;
@Autowired
private SysUserService sysUserService;
@ -55,7 +59,7 @@ public class ApplyDistrictListener implements TaskListener, ExecutionListener, A
private String defaultAssigneeRoleId; // 当未查到审批人时将使用该用户审批
@Override
@ActivitiNoticeOperation(value = "申请发起人区市管理员审批", process = "能力申请流程")
@ActivitiNoticeOperation(value = "申请发起人区市管理员审批", process = "能力申请流程V3")
public void notify(DelegateTask delegateTask) {
logger.error("事件类型:" + delegateTask.getEventName());
final String eventName = delegateTask.getEventName();
@ -85,8 +89,8 @@ public class ApplyDistrictListener implements TaskListener, ExecutionListener, A
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
List<SysUserEntity> userList = sysUserDao.getList(ImmutableMap.of("role_id", roleDTO.getId()));
Optional<SysUserEntity> userEntityOptional = userList.stream()
List<SysUserEntity> userList = sysUserDao.getList(ImmutableMap.of("role_id", roleDTO.getId(), "status", "1"));
Optional<SysUserEntity> userEntityOptional = userList.stream().sorted(Comparator.comparing(SysUserEntity::getUpdateDate).reversed()).collect(Collectors.toList()).stream()
.filter(user -> Objects.equals(regionEntity.getId(), sysRegionService.getByLevel(sysDeptService.get(user.getDeptId()).getDistrict(), RegionLevelEnum.THREE).getId())).findFirst();
if (userEntityOptional.isPresent()) {
userId = userEntityOptional.get().getId().toString();
@ -112,7 +116,13 @@ public class ApplyDistrictListener implements TaskListener, ExecutionListener, A
}
}
private void mpComplete(DelegateTask delegateTask, final String assignee) { // 处理审批人为申请人
/**
* 审批人去重
* @param delegateTask
* @param assignee
*/
private void mpComplete(DelegateTask delegateTask, final String assignee) {
//规则1审批人为申请人
if (StringUtils.isNotEmpty(assignee)
&& StringUtils.isNotEmpty(delegateTask.getVariable("creator", String.class))
&& delegateTask.getVariable("creator", String.class).equals(assignee)) {
@ -120,6 +130,17 @@ public class ApplyDistrictListener implements TaskListener, ExecutionListener, A
taskService.setVariable(delegateTask.getId(), ActTaskService.Task_HANDLE_STATE, ActTaskService.Task_HANDLE_STATE_AGREE);
taskService.setVariable(delegateTask.getId(), "backToFirst", Boolean.FALSE);
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
return;
}
//规则2同一审批人连续出现时仅保留第一个
List<HistoricActivityInstance> historicActivityInstanceList=historyService.createHistoricActivityInstanceQuery().processInstanceId(delegateTask.getProcessInstanceId())
.activityType("userTask").finished().orderByHistoricActivityInstanceEndTime().desc().list();
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);
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
return;
}
}

View File

@ -14,10 +14,12 @@ import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysRegionService;
import io.renren.modules.sys.service.SysRoleService;
import io.renren.modules.sys.service.SysUserService;
import org.activiti.engine.HistoryService;
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.activiti.engine.history.HistoricActivityInstance;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -26,6 +28,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
/**
* 市级区市管理员审批
@ -38,6 +41,8 @@ public class CityListener implements TaskListener, ExecutionListener, ActivitiEv
@Autowired
private TaskService taskService;
@Autowired
private HistoryService historyService;
@Autowired
private SysDeptService sysDeptService;
@Autowired
private SysUserService sysUserService;
@ -54,7 +59,7 @@ public class CityListener implements TaskListener, ExecutionListener, ActivitiEv
private String defaultAssigneeRoleId; // 当未查到审批人时将使用该用户审批
@Override
@ActivitiNoticeOperation(value = "市级区市管理员审批", process = "能力申请流程")
@ActivitiNoticeOperation(value = "市级区市管理员审批", process = "能力申请流程V3")
public void notify(DelegateTask delegateTask) {
logger.error("事件类型:" + delegateTask.getEventName());
final String eventName = delegateTask.getEventName();
@ -85,8 +90,8 @@ public class CityListener implements TaskListener, ExecutionListener, ActivitiEv
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
List<SysUserEntity> userList = sysUserDao.getList(ImmutableMap.of("role_id", roleDTO.getId()));
Optional<SysUserEntity> userEntityOptional = userList.stream()
List<SysUserEntity> userList = sysUserDao.getList(ImmutableMap.of("role_id", roleDTO.getId(), "status", "1"));
Optional<SysUserEntity> userEntityOptional = userList.stream().sorted(Comparator.comparing(SysUserEntity::getUpdateDate).reversed()).collect(Collectors.toList()).stream()
.filter(user -> Objects.equals(regionEntity.getId(), sysRegionService.getByLevel(sysDeptService.get(user.getDeptId()).getDistrict(), RegionLevelEnum.TWO).getId())).findFirst();
if (userEntityOptional.isPresent()) {
userId = userEntityOptional.get().getId().toString();
@ -112,7 +117,13 @@ public class CityListener implements TaskListener, ExecutionListener, ActivitiEv
}
}
private void mpComplete(DelegateTask delegateTask, final String assignee) { // 处理审批人为申请人
/**
* 审批人去重
* @param delegateTask
* @param assignee
*/
private void mpComplete(DelegateTask delegateTask, final String assignee) {
//规则1审批人为申请人
if (StringUtils.isNotEmpty(assignee)
&& StringUtils.isNotEmpty(delegateTask.getVariable("creator", String.class))
&& delegateTask.getVariable("creator", String.class).equals(assignee)) {
@ -120,6 +131,17 @@ public class CityListener implements TaskListener, ExecutionListener, ActivitiEv
taskService.setVariable(delegateTask.getId(), ActTaskService.Task_HANDLE_STATE, ActTaskService.Task_HANDLE_STATE_AGREE);
taskService.setVariable(delegateTask.getId(), "backToFirst", Boolean.FALSE);
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
return;
}
//规则2同一审批人连续出现时仅保留第一个
List<HistoricActivityInstance> historicActivityInstanceList=historyService.createHistoricActivityInstanceQuery().processInstanceId(delegateTask.getProcessInstanceId())
.activityType("userTask").finished().orderByHistoricActivityInstanceEndTime().desc().list();
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);
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
return;
}
}

View File

@ -21,11 +21,13 @@ import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysRoleService;
import io.renren.modules.sys.service.SysRoleUserService;
import io.renren.modules.sys.service.SysUserService;
import org.activiti.engine.HistoryService;
import org.activiti.engine.ProcessEngines;
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.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.task.Task;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -56,6 +58,8 @@ public class CorrectionListenerV3 implements TaskListener, ExecutionListener, Ac
@Autowired
private TaskService taskService;
@Autowired
private HistoryService historyService;
@Autowired
private SysUserService sysUserService;
@Autowired
private SysRoleUserService sysRoleUserService;
@ -72,7 +76,7 @@ public class CorrectionListenerV3 implements TaskListener, ExecutionListener, Ac
private TAbilityApplicationService tAbilityApplicationService;
@Override
@ActivitiNoticeOperation(value = "流程结束", process = "能力申请流程v2", type = 2)
@ActivitiNoticeOperation(value = "流程结束", process = "能力申请流程v3", type = 2)
public void notify(DelegateExecution delegateExecution) throws Exception {
logger.error("----------------------进入部门审批结束节点---------------------------");
delegateExecution.getProcessBusinessKey();
@ -222,6 +226,16 @@ public class CorrectionListenerV3 implements TaskListener, ExecutionListener, Ac
return;
}
List<HistoricActivityInstance> historicActivityInstanceList=historyService.createHistoricActivityInstanceQuery().processInstanceId(delegateTask.getProcessInstanceId())
.activityType("userTask").unfinished().orderByHistoricActivityInstanceEndTime().desc().list();
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);
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())));

View File

@ -13,10 +13,12 @@ import io.renren.modules.sys.enums.RegionLevelEnum;
import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysRegionService;
import io.renren.modules.sys.service.SysRoleService;
import org.activiti.engine.HistoryService;
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.activiti.engine.history.HistoricActivityInstance;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -25,6 +27,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
/**
* 资源所属区市管理员审批
@ -37,6 +40,8 @@ public class OwnerDistrictListener implements TaskListener, ExecutionListener, A
@Autowired
private TaskService taskService;
@Autowired
private HistoryService historyService;
@Autowired
private SysUserDao sysUserDao;
@Autowired
private SysRoleService sysRoleService;
@ -51,7 +56,7 @@ public class OwnerDistrictListener implements TaskListener, ExecutionListener, A
private String defaultAssigneeRoleId; // 当未查到审批人时将使用该用户审批
@Override
@ActivitiNoticeOperation(value = "资源所属区市管理员审批", process = "能力申请流程")
@ActivitiNoticeOperation(value = "资源所属区市管理员审批", process = "能力申请流程V3")
public void notify(DelegateTask delegateTask) {
logger.error("事件类型:" + delegateTask.getEventName());
final String eventName = delegateTask.getEventName();
@ -81,8 +86,8 @@ public class OwnerDistrictListener implements TaskListener, ExecutionListener, A
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
List<SysUserEntity> userList = sysUserDao.getList(ImmutableMap.of("role_id", roleDTO.getId()));
Optional<SysUserEntity> userEntityOptional = userList.stream()
List<SysUserEntity> userList = sysUserDao.getList(ImmutableMap.of("role_id", roleDTO.getId(), "status", "1"));
Optional<SysUserEntity> userEntityOptional = userList.stream().sorted(Comparator.comparing(SysUserEntity::getUpdateDate).reversed()).collect(Collectors.toList()).stream()
.filter(user -> Objects.equals(regionEntity.getId(), sysRegionService.getByLevel(sysDeptService.get(user.getDeptId()).getDistrict(), RegionLevelEnum.THREE).getId())).findFirst();
if (userEntityOptional.isPresent()) {
userId = userEntityOptional.get().getId().toString();
@ -107,7 +112,14 @@ public class OwnerDistrictListener implements TaskListener, ExecutionListener, A
}
}
}
private void mpComplete(DelegateTask delegateTask, final String assignee) { // 处理审批人为申请人
/**
* 审批人去重
* @param delegateTask
* @param assignee
*/
private void mpComplete(DelegateTask delegateTask, final String assignee) {
//规则1审批人为申请人
if (StringUtils.isNotEmpty(assignee)
&& StringUtils.isNotEmpty(delegateTask.getVariable("creator", String.class))
&& delegateTask.getVariable("creator", String.class).equals(assignee)) {
@ -115,6 +127,17 @@ public class OwnerDistrictListener implements TaskListener, ExecutionListener, A
taskService.setVariable(delegateTask.getId(), ActTaskService.Task_HANDLE_STATE, ActTaskService.Task_HANDLE_STATE_AGREE);
taskService.setVariable(delegateTask.getId(), "backToFirst", Boolean.FALSE);
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
return;
}
//规则2同一审批人连续出现时仅保留第一个
List<HistoricActivityInstance> historicActivityInstanceList=historyService.createHistoricActivityInstanceQuery().processInstanceId(delegateTask.getProcessInstanceId())
.activityType("userTask").finished().orderByHistoricActivityInstanceEndTime().desc().list();
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);
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
return;
}
}