Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
d70cb67c06
|
@ -8,6 +8,8 @@ import io.renren.modules.activiti.dto.ProcessActivityDTO;
|
||||||
import io.renren.modules.activiti.dto.ProcessInstanceDTO;
|
import io.renren.modules.activiti.dto.ProcessInstanceDTO;
|
||||||
import io.renren.modules.activiti.service.ActHistoryService;
|
import io.renren.modules.activiti.service.ActHistoryService;
|
||||||
import io.renren.modules.activiti.service.ActivitiService;
|
import io.renren.modules.activiti.service.ActivitiService;
|
||||||
|
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
|
||||||
|
import io.renren.modules.processForm.service.TAbilityApplicationService;
|
||||||
import io.renren.modules.sys.dto.SysUserDTO;
|
import io.renren.modules.sys.dto.SysUserDTO;
|
||||||
import io.renren.modules.sys.service.SysUserService;
|
import io.renren.modules.sys.service.SysUserService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
@ -42,6 +44,9 @@ public class HistoryController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserService sysUserService;
|
private SysUserService sysUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TAbilityApplicationService abilityApplicationService;
|
||||||
|
|
||||||
@GetMapping("getInstImage")
|
@GetMapping("getInstImage")
|
||||||
@ApiOperation(value = "获取流程活动图", produces = "application/octet-stream")
|
@ApiOperation(value = "获取流程活动图", produces = "application/octet-stream")
|
||||||
@ApiImplicitParam(name = "processInstanceId", value = "流程实例ID", paramType = "query", dataType = "String")
|
@ApiImplicitParam(name = "processInstanceId", value = "流程实例ID", paramType = "query", dataType = "String")
|
||||||
|
@ -113,6 +118,11 @@ public class HistoryController {
|
||||||
SysUserDTO userDTO = sysUserService.get(Long.valueOf(activityDTO.getAssignee()));
|
SysUserDTO userDTO = sysUserService.get(Long.valueOf(activityDTO.getAssignee()));
|
||||||
activityDTO.setAssigneeName(userDTO != null ? userDTO.getRealName() : "");
|
activityDTO.setAssigneeName(userDTO != null ? userDTO.getRealName() : "");
|
||||||
}
|
}
|
||||||
|
TAbilityApplicationDTO abilityApplicationDTO =
|
||||||
|
abilityApplicationService.get(Long.valueOf(activityDTO.getBusinessKey()));
|
||||||
|
if (abilityApplicationDTO != null) {
|
||||||
|
activityDTO.setResourceName(abilityApplicationDTO.getSystem());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return new Result().ok(page);
|
return new Result().ok(page);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class HistoryDetailDTO {
|
||||||
@ApiModelProperty(value = "执行ID")
|
@ApiModelProperty(value = "执行ID")
|
||||||
private String executionId;
|
private String executionId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "受理人")
|
@ApiModelProperty(value = "受理人id")
|
||||||
private String assignee;
|
private String assignee;
|
||||||
|
|
||||||
@ApiModelProperty(value = "开始时间")
|
@ApiModelProperty(value = "开始时间")
|
||||||
|
@ -50,4 +50,7 @@ public class HistoryDetailDTO {
|
||||||
|
|
||||||
@ApiModelProperty(value = "审批意见")
|
@ApiModelProperty(value = "审批意见")
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "受理人姓名")
|
||||||
|
private String assigneeName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,4 +47,7 @@ public class ProcessActivityDTO {
|
||||||
@ApiModelProperty(value = "受理人姓名")
|
@ApiModelProperty(value = "受理人姓名")
|
||||||
private String assigneeName;
|
private String assigneeName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "申请资源名称")
|
||||||
|
private String resourceName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.util.Date;
|
||||||
* @author Jone
|
* @author Jone
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper=false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class HistoryDetailEntity {
|
public class HistoryDetailEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -37,4 +37,6 @@ public class HistoryDetailEntity {
|
||||||
|
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
|
private String assigneeName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,14 @@ import io.renren.common.page.PageData;
|
||||||
import io.renren.common.service.impl.BaseServiceImpl;
|
import io.renren.common.service.impl.BaseServiceImpl;
|
||||||
import io.renren.common.utils.MessageUtils;
|
import io.renren.common.utils.MessageUtils;
|
||||||
import io.renren.modules.activiti.dto.TaskDTO;
|
import io.renren.modules.activiti.dto.TaskDTO;
|
||||||
|
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
|
||||||
|
import io.renren.modules.processForm.service.TAbilityApplicationService;
|
||||||
import io.renren.modules.security.user.SecurityUser;
|
import io.renren.modules.security.user.SecurityUser;
|
||||||
import io.renren.modules.sys.service.SysRoleUserService;
|
import io.renren.modules.sys.service.SysRoleUserService;
|
||||||
import org.activiti.engine.*;
|
import org.activiti.engine.HistoryService;
|
||||||
|
import org.activiti.engine.RepositoryService;
|
||||||
|
import org.activiti.engine.RuntimeService;
|
||||||
|
import org.activiti.engine.TaskService;
|
||||||
import org.activiti.engine.delegate.Expression;
|
import org.activiti.engine.delegate.Expression;
|
||||||
import org.activiti.engine.history.HistoricActivityInstance;
|
import org.activiti.engine.history.HistoricActivityInstance;
|
||||||
import org.activiti.engine.history.HistoricProcessInstance;
|
import org.activiti.engine.history.HistoricProcessInstance;
|
||||||
|
@ -30,6 +35,7 @@ import org.activiti.engine.task.Task;
|
||||||
import org.activiti.engine.task.TaskInfo;
|
import org.activiti.engine.task.TaskInfo;
|
||||||
import org.activiti.engine.task.TaskQuery;
|
import org.activiti.engine.task.TaskQuery;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.codehaus.jackson.map.ObjectMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -54,6 +60,9 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysRoleUserService sysRoleUserService;
|
private SysRoleUserService sysRoleUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TAbilityApplicationService tAbilityApplicationService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据参数获取当前运行的任务信息
|
* 根据参数获取当前运行的任务信息
|
||||||
*
|
*
|
||||||
|
@ -74,17 +83,17 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
if (StringUtils.isNotEmpty(userId)) {
|
if (StringUtils.isNotEmpty(userId)) {
|
||||||
taskQuery.taskAssignee(userId);
|
taskQuery.taskAssignee(userId);
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty((String)params.get("taskName"))){
|
if (StringUtils.isNotEmpty((String) params.get("taskName"))) {
|
||||||
taskQuery.taskNameLike("%"+(String)params.get("taskName")+"%");
|
taskQuery.taskNameLike("%" + (String) params.get("taskName") + "%");
|
||||||
}
|
}
|
||||||
if(StringUtils.isNotEmpty((String)params.get("isRoleGroup"))&&"1".equals(params.get("isRoleGroup"))){
|
if (StringUtils.isNotEmpty((String) params.get("isRoleGroup")) && "1".equals(params.get("isRoleGroup"))) {
|
||||||
List<Long> listRoles = sysRoleUserService.getRoleIdList(SecurityUser.getUserId());
|
List<Long> listRoles = sysRoleUserService.getRoleIdList(SecurityUser.getUserId());
|
||||||
List<String> listStr = new ArrayList<>();
|
List<String> listStr = new ArrayList<>();
|
||||||
for(Long role : listRoles){
|
for (Long role : listRoles) {
|
||||||
listStr.add(role.toString());
|
listStr.add(role.toString());
|
||||||
}
|
}
|
||||||
listStr.add(SecurityUser.getUserId().toString());
|
listStr.add(SecurityUser.getUserId().toString());
|
||||||
if(!listStr.isEmpty()){
|
if (!listStr.isEmpty()) {
|
||||||
taskQuery.taskCandidateGroupIn(listStr);
|
taskQuery.taskCandidateGroupIn(listStr);
|
||||||
} else {
|
} else {
|
||||||
return new PageData<>(new ArrayList<>(), 0);
|
return new PageData<>(new ArrayList<>(), 0);
|
||||||
|
@ -96,6 +105,13 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
for (Task task : list) {
|
for (Task task : list) {
|
||||||
TaskDTO dto = new TaskDTO();
|
TaskDTO dto = new TaskDTO();
|
||||||
this.convertTaskInfo(task, dto);
|
this.convertTaskInfo(task, dto);
|
||||||
|
TAbilityApplicationDTO abilityApplicationDTO =
|
||||||
|
tAbilityApplicationService.get(Long.valueOf(dto.getBusinessKey()));
|
||||||
|
if (abilityApplicationDTO != null) {
|
||||||
|
ObjectMapper oMapper = new ObjectMapper();
|
||||||
|
Map<String, Object> variables = oMapper.convertValue(abilityApplicationDTO, Map.class);
|
||||||
|
dto.setParams(variables);
|
||||||
|
}
|
||||||
listDto.add(dto);
|
listDto.add(dto);
|
||||||
}
|
}
|
||||||
return new PageData<>(listDto, (int) taskQuery.count());
|
return new PageData<>(listDto, (int) taskQuery.count());
|
||||||
|
@ -122,7 +138,7 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
public void claimTask(String taskId) {
|
public void claimTask(String taskId) {
|
||||||
String userId = SecurityUser.getUserId().toString();
|
String userId = SecurityUser.getUserId().toString();
|
||||||
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||||
if(StringUtils.isNotEmpty(task.getAssignee())){
|
if (StringUtils.isNotEmpty(task.getAssignee())) {
|
||||||
throw new RenException(ErrorCode.TASK_CLIME_FAIL);
|
throw new RenException(ErrorCode.TASK_CLIME_FAIL);
|
||||||
}
|
}
|
||||||
taskService.claim(taskId, userId);
|
taskService.claim(taskId, userId);
|
||||||
|
@ -152,7 +168,7 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(lstGroupId.isEmpty()){
|
if (lstGroupId.isEmpty()) {
|
||||||
throw new RenException(ErrorCode.UNCLAIM_ERROR_MESSAGE);
|
throw new RenException(ErrorCode.UNCLAIM_ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
taskService.unclaim(taskId);
|
taskService.unclaim(taskId);
|
||||||
|
@ -167,10 +183,10 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
public void completeTask(String taskId, String comment) {
|
public void completeTask(String taskId, String comment) {
|
||||||
String userId = SecurityUser.getUserId().toString();
|
String userId = SecurityUser.getUserId().toString();
|
||||||
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||||
if(StringUtils.isNotEmpty(task.getAssignee())){
|
if (StringUtils.isNotEmpty(task.getAssignee())) {
|
||||||
taskService.setAssignee(taskId, userId);
|
taskService.setAssignee(taskId, userId);
|
||||||
}
|
}
|
||||||
if(StringUtils.isNotEmpty(comment)){
|
if (StringUtils.isNotEmpty(comment)) {
|
||||||
taskService.addComment(taskId, task.getProcessInstanceId(), comment);
|
taskService.addComment(taskId, task.getProcessInstanceId(), comment);
|
||||||
}
|
}
|
||||||
taskService.complete(taskId);
|
taskService.complete(taskId);
|
||||||
|
@ -199,7 +215,7 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
Map<String, Object> map = null;
|
Map<String, Object> map = null;
|
||||||
if (StringUtils.isNotBlank(variableName)) {
|
if (StringUtils.isNotBlank(variableName)) {
|
||||||
Object value = taskService.getVariable(taskId, variableName);
|
Object value = taskService.getVariable(taskId, variableName);
|
||||||
if(null != value){
|
if (null != value) {
|
||||||
map = new HashMap<>();
|
map = new HashMap<>();
|
||||||
map.put(variableName, value);
|
map.put(variableName, value);
|
||||||
}
|
}
|
||||||
|
@ -211,6 +227,7 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新任务变量
|
* 更新任务变量
|
||||||
|
*
|
||||||
* @param taskDTO
|
* @param taskDTO
|
||||||
*/
|
*/
|
||||||
public void updateTaskVariable(TaskDTO taskDTO) {
|
public void updateTaskVariable(TaskDTO taskDTO) {
|
||||||
|
@ -220,21 +237,22 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据任务ID判断是否为多实例任务
|
* 根据任务ID判断是否为多实例任务
|
||||||
|
*
|
||||||
* @param taskId
|
* @param taskId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean isMultiInstance(String taskId) {
|
private boolean isMultiInstance(String taskId) {
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
Task task=taskService.createTaskQuery().taskId(taskId).singleResult();
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||||
if(task != null){
|
if (task != null) {
|
||||||
// 获取流程定义id
|
// 获取流程定义id
|
||||||
String processDefinitionId=task.getProcessDefinitionId();
|
String processDefinitionId = task.getProcessDefinitionId();
|
||||||
ProcessDefinitionEntity processDefinitionEntity=(ProcessDefinitionEntity) repositoryService.getProcessDefinition(processDefinitionId);
|
ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(processDefinitionId);
|
||||||
// 根据活动id获取活动实例
|
// 根据活动id获取活动实例
|
||||||
ActivityImpl activityImpl=processDefinitionEntity.findActivity(task.getTaskDefinitionKey());
|
ActivityImpl activityImpl = processDefinitionEntity.findActivity(task.getTaskDefinitionKey());
|
||||||
if((activityImpl).getActivityBehavior() instanceof ParallelMultiInstanceBehavior){
|
if ((activityImpl).getActivityBehavior() instanceof ParallelMultiInstanceBehavior) {
|
||||||
ParallelMultiInstanceBehavior behavior = (ParallelMultiInstanceBehavior)activityImpl.getActivityBehavior();
|
ParallelMultiInstanceBehavior behavior = (ParallelMultiInstanceBehavior) activityImpl.getActivityBehavior();
|
||||||
if(behavior != null && behavior.getCollectionExpression() != null){
|
if (behavior != null && behavior.getCollectionExpression() != null) {
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,6 +287,7 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务回退至上一用户任务节点
|
* 任务回退至上一用户任务节点
|
||||||
|
*
|
||||||
* @param taskId
|
* @param taskId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -276,7 +295,7 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
public void doBackPreviousTask(String taskId, String comment) {
|
public void doBackPreviousTask(String taskId, String comment) {
|
||||||
Map<String, Object> variables = null;
|
Map<String, Object> variables = null;
|
||||||
HistoricTaskInstance currTask = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
|
HistoricTaskInstance currTask = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
|
||||||
if(this.isMultiInstance(taskId)){
|
if (this.isMultiInstance(taskId)) {
|
||||||
throw new RenException(ErrorCode.BACK_PROCESS_PARALLEL_ERROR);
|
throw new RenException(ErrorCode.BACK_PROCESS_PARALLEL_ERROR);
|
||||||
}
|
}
|
||||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(currTask.getProcessInstanceId()).singleResult();
|
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(currTask.getProcessInstanceId()).singleResult();
|
||||||
|
@ -285,7 +304,7 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
ActivityImpl currActivity = processDefinitionEntity.findActivity(currTask.getTaskDefinitionKey());
|
ActivityImpl currActivity = processDefinitionEntity.findActivity(currTask.getTaskDefinitionKey());
|
||||||
List<ActivityImpl> canBackActivitys = new ArrayList<>();
|
List<ActivityImpl> canBackActivitys = new ArrayList<>();
|
||||||
this.getCanBackUpActivitys(currActivity, canBackActivitys);
|
this.getCanBackUpActivitys(currActivity, canBackActivitys);
|
||||||
if(canBackActivitys.isEmpty()) {
|
if (canBackActivitys.isEmpty()) {
|
||||||
throw new RenException(ErrorCode.SUPERIOR_NOT_EXIST);
|
throw new RenException(ErrorCode.SUPERIOR_NOT_EXIST);
|
||||||
}
|
}
|
||||||
List<PvmTransition> originPvmTransitionList = new ArrayList<PvmTransition>();
|
List<PvmTransition> originPvmTransitionList = new ArrayList<PvmTransition>();
|
||||||
|
@ -299,28 +318,28 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
.processInstanceId(processInstance.getId())
|
.processInstanceId(processInstance.getId())
|
||||||
.finished().orderByHistoricActivityInstanceEndTime().desc().list();
|
.finished().orderByHistoricActivityInstanceEndTime().desc().list();
|
||||||
List<ActivityImpl> backActivitys = new ArrayList<>();
|
List<ActivityImpl> backActivitys = new ArrayList<>();
|
||||||
for(HistoricActivityInstance historicActivityInstance: historicActivityInstances){
|
for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) {
|
||||||
for(ActivityImpl activity : canBackActivitys){
|
for (ActivityImpl activity : canBackActivitys) {
|
||||||
if(historicActivityInstance.getActivityId().equals(activity.getId())){
|
if (historicActivityInstance.getActivityId().equals(activity.getId())) {
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
for(ActivityImpl activity1 : backActivitys){
|
for (ActivityImpl activity1 : backActivitys) {
|
||||||
if(activity.getId().equals(activity1.getId())){
|
if (activity.getId().equals(activity1.getId())) {
|
||||||
flag = true;
|
flag = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!flag){
|
if (!flag) {
|
||||||
backActivitys.add(activity);
|
backActivitys.add(activity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(backActivitys.isEmpty()){
|
if (backActivitys.isEmpty()) {
|
||||||
throw new RenException(ErrorCode.SUPERIOR_NOT_EXIST);
|
throw new RenException(ErrorCode.SUPERIOR_NOT_EXIST);
|
||||||
}
|
}
|
||||||
List<TransitionImpl> transitionList = new ArrayList<>();
|
List<TransitionImpl> transitionList = new ArrayList<>();
|
||||||
for(ActivityImpl activity : backActivitys) {
|
for (ActivityImpl activity : backActivitys) {
|
||||||
TransitionImpl transition = currActivity.createOutgoingTransition(IdWorker.get32UUID());
|
TransitionImpl transition = currActivity.createOutgoingTransition(IdWorker.get32UUID());
|
||||||
transition.setDestination(activity);
|
transition.setDestination(activity);
|
||||||
transitionList.add(transition);
|
transitionList.add(transition);
|
||||||
|
@ -331,8 +350,8 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
.taskDefinitionKey(currTask.getTaskDefinitionKey()).list();
|
.taskDefinitionKey(currTask.getTaskDefinitionKey()).list();
|
||||||
for (Task task : tasks) {
|
for (Task task : tasks) {
|
||||||
String commentMode = MessageUtils.getMessage(ErrorCode.ROLLBACK_MESSAGE);
|
String commentMode = MessageUtils.getMessage(ErrorCode.ROLLBACK_MESSAGE);
|
||||||
if(StringUtils.isNotEmpty(comment)){
|
if (StringUtils.isNotEmpty(comment)) {
|
||||||
commentMode += "[" +comment+"]";
|
commentMode += "[" + comment + "]";
|
||||||
}
|
}
|
||||||
taskService.addComment(task.getId(), task.getProcessInstanceId(), commentMode);
|
taskService.addComment(task.getId(), task.getProcessInstanceId(), commentMode);
|
||||||
taskService.complete(task.getId(), variables);
|
taskService.complete(task.getId(), variables);
|
||||||
|
@ -341,13 +360,13 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
for (PvmTransition pvmTransition : originPvmTransitionList) {
|
for (PvmTransition pvmTransition : originPvmTransitionList) {
|
||||||
currActivity.getOutgoingTransitions().add(pvmTransition);
|
currActivity.getOutgoingTransitions().add(pvmTransition);
|
||||||
}
|
}
|
||||||
for(ActivityImpl activity : backActivitys) {
|
for (ActivityImpl activity : backActivitys) {
|
||||||
List<PvmTransition> incomingTransitions = activity.getIncomingTransitions();
|
List<PvmTransition> incomingTransitions = activity.getIncomingTransitions();
|
||||||
Iterator<PvmTransition> iterator = incomingTransitions.iterator();
|
Iterator<PvmTransition> iterator = incomingTransitions.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
PvmTransition pvmTransition = iterator.next();
|
PvmTransition pvmTransition = iterator.next();
|
||||||
for(TransitionImpl transition : transitionList) {
|
for (TransitionImpl transition : transitionList) {
|
||||||
if(transition.getId().equals(pvmTransition.getId())){
|
if (transition.getId().equals(pvmTransition.getId())) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -357,13 +376,13 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
|
|
||||||
private void getCanBackUpActivitys(ActivityImpl currActivity, List<ActivityImpl> rtnList) {
|
private void getCanBackUpActivitys(ActivityImpl currActivity, List<ActivityImpl> rtnList) {
|
||||||
List<PvmTransition> incomingTransitions = currActivity.getIncomingTransitions();
|
List<PvmTransition> incomingTransitions = currActivity.getIncomingTransitions();
|
||||||
for(PvmTransition pvmTransition : incomingTransitions){
|
for (PvmTransition pvmTransition : incomingTransitions) {
|
||||||
TransitionImpl transitionImpl = (TransitionImpl) pvmTransition;
|
TransitionImpl transitionImpl = (TransitionImpl) pvmTransition;
|
||||||
ActivityImpl activityImpl = transitionImpl.getSource();
|
ActivityImpl activityImpl = transitionImpl.getSource();
|
||||||
String type = (String) activityImpl.getProperty("type");
|
String type = (String) activityImpl.getProperty("type");
|
||||||
if ("parallelGateway".equals(type)){
|
if ("parallelGateway".equals(type)) {
|
||||||
// 并行路线
|
// 并行路线
|
||||||
if(activityImpl.getOutgoingTransitions().size() > 1){
|
if (activityImpl.getOutgoingTransitions().size() > 1) {
|
||||||
throw new RenException(ErrorCode.BACK_PROCESS_HANDLEING_ERROR);
|
throw new RenException(ErrorCode.BACK_PROCESS_HANDLEING_ERROR);
|
||||||
}
|
}
|
||||||
this.getCanBackUpActivitys(activityImpl, rtnList);
|
this.getCanBackUpActivitys(activityImpl, rtnList);
|
||||||
|
@ -373,8 +392,8 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
rtnList.add(activityImpl);
|
rtnList.add(activityImpl);
|
||||||
} else if ("exclusiveGateway".equals(type)) {
|
} else if ("exclusiveGateway".equals(type)) {
|
||||||
this.getCanBackUpActivitys(activityImpl, rtnList);
|
this.getCanBackUpActivitys(activityImpl, rtnList);
|
||||||
} else if("inclusiveGateway".equals(type)) {
|
} else if ("inclusiveGateway".equals(type)) {
|
||||||
if(activityImpl.getOutgoingTransitions().size() > 1){
|
if (activityImpl.getOutgoingTransitions().size() > 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.getCanBackUpActivitys(activityImpl, rtnList);
|
this.getCanBackUpActivitys(activityImpl, rtnList);
|
||||||
|
@ -384,13 +403,13 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void endProcess(String taskId, String comment) {
|
public void endProcess(String taskId, String comment) {
|
||||||
if(isMultiInstance(taskId)){
|
if (isMultiInstance(taskId)) {
|
||||||
throw new RenException(ErrorCode.END_PROCESS_PARALLEL_ERROR);
|
throw new RenException(ErrorCode.END_PROCESS_PARALLEL_ERROR);
|
||||||
}
|
}
|
||||||
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||||
List<Task> tasks = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId())
|
List<Task> tasks = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId())
|
||||||
.taskDefinitionKey(task.getTaskDefinitionKey()).list();
|
.taskDefinitionKey(task.getTaskDefinitionKey()).list();
|
||||||
if(tasks.size() > 1){
|
if (tasks.size() > 1) {
|
||||||
throw new RenException(ErrorCode.END_PROCESS_HANDLEING_ERROR);
|
throw new RenException(ErrorCode.END_PROCESS_HANDLEING_ERROR);
|
||||||
}
|
}
|
||||||
ActivityImpl endActivity = findActivitiImpl(taskId, "end");
|
ActivityImpl endActivity = findActivitiImpl(taskId, "end");
|
||||||
|
@ -418,8 +437,8 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
if (StringUtils.isNotEmpty(task.getOwner())) {
|
if (StringUtils.isNotEmpty(task.getOwner())) {
|
||||||
taskService.resolveTask(task.getId());
|
taskService.resolveTask(task.getId());
|
||||||
}
|
}
|
||||||
String message =MessageUtils.getMessage(ErrorCode.END_PROCESS_MESSAGE);
|
String message = MessageUtils.getMessage(ErrorCode.END_PROCESS_MESSAGE);
|
||||||
comment = message + "["+ comment+ "]";
|
comment = message + "[" + comment + "]";
|
||||||
taskService.addComment(task.getId(), task.getProcessInstanceId(), comment);
|
taskService.addComment(task.getId(), task.getProcessInstanceId(), comment);
|
||||||
taskService.complete(taskId);
|
taskService.complete(taskId);
|
||||||
pointActivity.getIncomingTransitions().remove(newTransition);
|
pointActivity.getIncomingTransitions().remove(newTransition);
|
||||||
|
@ -446,8 +465,8 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
}
|
}
|
||||||
if ("END".equals(activityId.toUpperCase())) {
|
if ("END".equals(activityId.toUpperCase())) {
|
||||||
for (ActivityImpl activityImpl : processDefinition.getActivities()) {
|
for (ActivityImpl activityImpl : processDefinition.getActivities()) {
|
||||||
String type = (String)activityImpl.getProperty("type");
|
String type = (String) activityImpl.getProperty("type");
|
||||||
if("endEvent".equals(type)){
|
if ("endEvent".equals(type)) {
|
||||||
return activityImpl;
|
return activityImpl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -458,6 +477,7 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换Task对象
|
* 转换Task对象
|
||||||
|
*
|
||||||
* @param task
|
* @param task
|
||||||
* @param dto
|
* @param dto
|
||||||
*/
|
*/
|
||||||
|
@ -481,11 +501,12 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 驳回至第一个用户任务
|
* 驳回至第一个用户任务
|
||||||
|
*
|
||||||
* @param taskId
|
* @param taskId
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void backToFirst(String taskId, String comment) {
|
public void backToFirst(String taskId, String comment) {
|
||||||
if(this.isMultiInstance(taskId)){
|
if (this.isMultiInstance(taskId)) {
|
||||||
throw new RenException(ErrorCode.REJECT_PROCESS_PARALLEL_ERROR);
|
throw new RenException(ErrorCode.REJECT_PROCESS_PARALLEL_ERROR);
|
||||||
}
|
}
|
||||||
Map variables = null;
|
Map variables = null;
|
||||||
|
@ -498,7 +519,7 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
}
|
}
|
||||||
List<Task> tasks = taskService.createTaskQuery().processInstanceId(currTask.getProcessInstanceId())
|
List<Task> tasks = taskService.createTaskQuery().processInstanceId(currTask.getProcessInstanceId())
|
||||||
.taskDefinitionKey(currTask.getTaskDefinitionKey()).list();
|
.taskDefinitionKey(currTask.getTaskDefinitionKey()).list();
|
||||||
if(tasks.size() > 1){
|
if (tasks.size() > 1) {
|
||||||
throw new RenException(ErrorCode.REJECT_PROCESS_HANDLEING_ERROR);
|
throw new RenException(ErrorCode.REJECT_PROCESS_HANDLEING_ERROR);
|
||||||
}
|
}
|
||||||
ActivityImpl currActivity = processDefinitionEntity.findActivity(currTask.getTaskDefinitionKey());
|
ActivityImpl currActivity = processDefinitionEntity.findActivity(currTask.getTaskDefinitionKey());
|
||||||
|
@ -523,8 +544,8 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
variables = processInstance.getProcessVariables();
|
variables = processInstance.getProcessVariables();
|
||||||
for (Task task : tasks) {
|
for (Task task : tasks) {
|
||||||
String commentMode = MessageUtils.getMessage(ErrorCode.REJECT_MESSAGE);
|
String commentMode = MessageUtils.getMessage(ErrorCode.REJECT_MESSAGE);
|
||||||
if(StringUtils.isNotEmpty(comment)){
|
if (StringUtils.isNotEmpty(comment)) {
|
||||||
commentMode += "[" + comment+"]";
|
commentMode += "[" + comment + "]";
|
||||||
}
|
}
|
||||||
taskService.addComment(task.getId(), task.getProcessInstanceId(), commentMode);
|
taskService.addComment(task.getId(), task.getProcessInstanceId(), commentMode);
|
||||||
taskService.complete(task.getId(), variables);
|
taskService.complete(task.getId(), variables);
|
||||||
|
@ -537,18 +558,18 @@ public class ActTaskService extends BaseServiceImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void completeTaskByVariables(TaskDTO taskDTO) {
|
public void completeTaskByVariables(TaskDTO taskDTO) {
|
||||||
if(null != taskDTO.getParams()){
|
if (null != taskDTO.getParams()) {
|
||||||
Set keySet = taskDTO.getParams().keySet();
|
Set keySet = taskDTO.getParams().keySet();
|
||||||
Iterator iterator = keySet.iterator();
|
Iterator iterator = keySet.iterator();
|
||||||
while(iterator.hasNext()){
|
while (iterator.hasNext()) {
|
||||||
String key = (String)iterator.next();
|
String key = (String) iterator.next();
|
||||||
this.setTaskVariable(taskDTO.getTaskId(),key , taskDTO.getParams().get(key));
|
this.setTaskVariable(taskDTO.getTaskId(), key, taskDTO.getParams().get(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.completeTask(taskDTO.getTaskId(), taskDTO.getComment());
|
this.completeTask(taskDTO.getTaskId(), taskDTO.getComment());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTaskVariable(String taskId, String key, Object value){
|
private void setTaskVariable(String taskId, String key, Object value) {
|
||||||
TaskInfo taskInfo = taskService.createTaskQuery().taskId(taskId).singleResult();
|
TaskInfo taskInfo = taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||||
runtimeService.setVariable(taskInfo.getExecutionId(), key, value);
|
runtimeService.setVariable(taskInfo.getExecutionId(), key, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,24 +48,33 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notify(DelegateTask delegateTask) {
|
public void notify(DelegateTask delegateTask) {
|
||||||
|
logger.error("-------------------------进入部门动态审批人流程-------------------------------");
|
||||||
Map<String, Object> kv = delegateTask.getVariables();
|
Map<String, Object> kv = delegateTask.getVariables();
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
JsonElement jsonElement = gson.toJsonTree(kv);
|
JsonElement jsonElement = gson.toJsonTree(kv);
|
||||||
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
|
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
|
||||||
|
|
||||||
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
|
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
|
||||||
logger.info("roleDTOId:" + roleDTO.getId());
|
logger.error("roleDTOId:" + roleDTO.getId());
|
||||||
|
ResourceDTO resourceEntityDto = null;
|
||||||
logger.info("abilityApplicationDTO:" + abilityApplicationDTO.toString());
|
|
||||||
ResourceDTO resourceEntityDto = resourceService.get(Long.valueOf(abilityApplicationDTO.getResourceId()));
|
|
||||||
Long deptId = null;
|
Long deptId = null;
|
||||||
|
if (abilityApplicationDTO != null) {
|
||||||
|
logger.error("abilityApplicationDTO:" + abilityApplicationDTO.toString());
|
||||||
|
resourceEntityDto = resourceService.get(Long.valueOf(abilityApplicationDTO.getResourceId()));
|
||||||
|
}
|
||||||
if (resourceEntityDto != null && resourceEntityDto.getDeptId() != null) {
|
if (resourceEntityDto != null && resourceEntityDto.getDeptId() != null) {
|
||||||
deptId = resourceEntityDto.getDeptId();
|
deptId = resourceEntityDto.getDeptId();
|
||||||
|
SysDeptDTO deptDTO =
|
||||||
|
sysDeptService.get(resourceEntityDto.getDeptId());
|
||||||
|
if (deptDTO != null && deptDTO.getName().equals("青岛市大数据发展管理局")) {
|
||||||
|
logger.error("第二级别审批仍然为 青岛市大数据发展管理局");
|
||||||
|
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.info("表单内单位名称:" + abilityApplicationDTO.getUnit());
|
logger.error("表单内单位名称:" + abilityApplicationDTO.getUnit());
|
||||||
SysDeptDTO deptDTO = sysDeptService.getByName(abilityApplicationDTO.getUnit());
|
SysDeptDTO deptDTO = sysDeptService.getByName(abilityApplicationDTO.getUnit());
|
||||||
if (deptDTO != null) {
|
if (deptDTO != null) {
|
||||||
logger.info("deptDTOId:" + deptDTO.getId());
|
logger.error("deptDTOId:" + deptDTO.getId());
|
||||||
deptId = deptDTO.getId();
|
deptId = deptDTO.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,14 +83,14 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
|
||||||
if (deptId != null) {
|
if (deptId != null) {
|
||||||
userDTO = sysUserService.getByDeptIdAndRoleId(deptId, roleDTO.getId()); // 搜出审批人
|
userDTO = sysUserService.getByDeptIdAndRoleId(deptId, roleDTO.getId()); // 搜出审批人
|
||||||
}
|
}
|
||||||
|
|
||||||
delegateTask.setAssignee("1513432847327199233");
|
|
||||||
if (userDTO != null) {
|
if (userDTO != null) {
|
||||||
logger.info("审批人id:" + userDTO.getId());
|
logger.error("审批人id:" + userDTO.getId());
|
||||||
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
|
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
|
||||||
} else {
|
} else {
|
||||||
logger.info("未查到该部门对应 " + roleName);
|
logger.error("未查到该部门对应的 " + roleName);
|
||||||
|
taskService.setAssignee(delegateTask.getId(), "1513432847327199233");
|
||||||
}
|
}
|
||||||
|
logger.error("-------------------------结束部门动态审批人流程-------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -56,13 +56,28 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getTaskHandleDetailInfo" resultMap="HistoryDetail">
|
<select id="getTaskHandleDetailInfo" resultMap="HistoryDetail">
|
||||||
SELECT ahc.ID_, ahc.TYPE_, aht.ID_ as TASK_ID_, aht.PROC_INST_ID_, ahc.MESSAGE_,
|
SELECT
|
||||||
aht.PROC_DEF_ID_, aht.EXECUTION_ID_, aht.NAME_, aht.ASSIGNEE_, aht.START_TIME_,
|
ahc.ID_,
|
||||||
aht.END_TIME_ from ACT_HI_TASKINST aht
|
ahc.TYPE_,
|
||||||
left join ACT_HI_COMMENT ahc on ahc.TASK_ID_ = aht.ID_ and ahc.TYPE_ = 'comment'
|
aht.ID_ AS TASK_ID_,
|
||||||
where aht.PROC_INST_ID_ = #{processInstanceId}
|
aht.PROC_INST_ID_,
|
||||||
and aht.end_time_ is not null
|
ahc.MESSAGE_,
|
||||||
order by aht.START_TIME_ desc
|
aht.PROC_DEF_ID_,
|
||||||
|
aht.EXECUTION_ID_,
|
||||||
|
aht.NAME_,
|
||||||
|
aht.ASSIGNEE_,
|
||||||
|
aht.START_TIME_,
|
||||||
|
aht.END_TIME_,
|
||||||
|
( SELECT user1.real_name FROM sys_user user1 WHERE user1.id = aht.ASSIGNEE_ ) ASSIGNEE_NAME_
|
||||||
|
FROM
|
||||||
|
ACT_HI_TASKINST aht
|
||||||
|
LEFT JOIN ACT_HI_COMMENT ahc ON ahc.TASK_ID_ = aht.ID_
|
||||||
|
AND ahc.TYPE_ = 'comment'
|
||||||
|
WHERE
|
||||||
|
aht.PROC_INST_ID_ = #{processInstanceId}
|
||||||
|
AND aht.end_time_ IS NOT NULL
|
||||||
|
ORDER BY
|
||||||
|
aht.START_TIME_ DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue