This commit is contained in:
parent
6d0aec6686
commit
564728efc2
|
@ -2,9 +2,12 @@ package io.renren.modules.processForm.listener;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
|
import io.renren.modules.activiti.service.ActTaskService;
|
||||||
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
|
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
|
||||||
|
import io.renren.modules.processForm.service.ApiGatewayService;
|
||||||
import io.renren.modules.processForm.service.TAbilityApplicationService;
|
import io.renren.modules.processForm.service.TAbilityApplicationService;
|
||||||
import io.renren.modules.resource.dto.ResourceDTO;
|
import io.renren.modules.resource.dto.ResourceDTO;
|
||||||
|
import io.renren.modules.resource.entity.ResourceEntity;
|
||||||
import io.renren.modules.resource.service.ResourceService;
|
import io.renren.modules.resource.service.ResourceService;
|
||||||
import io.renren.modules.sys.dto.SysDeptDTO;
|
import io.renren.modules.sys.dto.SysDeptDTO;
|
||||||
import io.renren.modules.sys.dto.SysRoleDTO;
|
import io.renren.modules.sys.dto.SysRoleDTO;
|
||||||
|
@ -13,6 +16,7 @@ import io.renren.modules.sys.service.SysDeptService;
|
||||||
import io.renren.modules.sys.service.SysRoleService;
|
import io.renren.modules.sys.service.SysRoleService;
|
||||||
import io.renren.modules.sys.service.SysRoleUserService;
|
import io.renren.modules.sys.service.SysRoleUserService;
|
||||||
import io.renren.modules.sys.service.SysUserService;
|
import io.renren.modules.sys.service.SysUserService;
|
||||||
|
import org.activiti.engine.ProcessEngines;
|
||||||
import org.activiti.engine.TaskService;
|
import org.activiti.engine.TaskService;
|
||||||
import org.activiti.engine.delegate.*;
|
import org.activiti.engine.delegate.*;
|
||||||
import org.activiti.engine.delegate.event.ActivitiEvent;
|
import org.activiti.engine.delegate.event.ActivitiEvent;
|
||||||
|
@ -25,6 +29,7 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门动态审批人
|
* 部门动态审批人
|
||||||
|
@ -48,6 +53,8 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
|
||||||
private SysRoleUserService sysRoleUserService;
|
private SysRoleUserService sysRoleUserService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysDeptService sysDeptService;
|
private SysDeptService sysDeptService;
|
||||||
|
@Autowired
|
||||||
|
private ApiGatewayService apiGatewayService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ResourceService resourceService;
|
private ResourceService resourceService;
|
||||||
|
@ -62,6 +69,9 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
|
||||||
case EVENTNAME_CREATE:
|
case EVENTNAME_CREATE:
|
||||||
create(delegateTask);
|
create(delegateTask);
|
||||||
break;
|
break;
|
||||||
|
case EVENTNAME_COMPLETE:
|
||||||
|
complete(delegateTask);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
logger.error("-------------------------结束部门动态审批人流程-------------------------------");
|
logger.error("-------------------------结束部门动态审批人流程-------------------------------");
|
||||||
|
@ -173,4 +183,46 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void complete(DelegateTask delegateTask) {
|
||||||
|
Map<String, Object> kv = delegateTask.getVariables();
|
||||||
|
|
||||||
|
//如果有code说明已经注册过了,以及只有通过的流程申请
|
||||||
|
if (kv.get("gatewayCode") != null ||
|
||||||
|
!ActTaskService.Task_HANDLE_STATE_AGREE.equals(kv.get(ActTaskService.Task_HANDLE_STATE))) return;
|
||||||
|
|
||||||
|
Gson gson = new Gson();
|
||||||
|
JsonElement jsonElement = gson.toJsonTree(kv);
|
||||||
|
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
|
||||||
|
applyCode(delegateTask, abilityApplicationDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批通过,申请code
|
||||||
|
*
|
||||||
|
* @param delegateTask
|
||||||
|
* @param abilityApplicationDTO
|
||||||
|
*/
|
||||||
|
private void applyCode(DelegateTask delegateTask, TAbilityApplicationDTO abilityApplicationDTO) {
|
||||||
|
|
||||||
|
logger.info("-------能力申请code-------");
|
||||||
|
ResourceEntity resourceEntity = resourceService.selectById(abilityApplicationDTO.getResourceId());
|
||||||
|
|
||||||
|
//没有groupid当做没有接口,直接跳过
|
||||||
|
if (resourceEntity.getGroupId() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
String code = UUID.randomUUID().toString();
|
||||||
|
apiGatewayService.subscribeCode(String.valueOf(abilityApplicationDTO.getId()), code);
|
||||||
|
|
||||||
|
delegateTask.setVariable("gatewayCode", code);
|
||||||
|
|
||||||
|
String apiPrefix = "/juapi/" + abilityApplicationDTO.getResourceId();
|
||||||
|
TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
|
||||||
|
String msg = String.format("您的能力申请已通过,接口认证code为:%s, 接口公共前缀为:%s", code, apiPrefix);
|
||||||
|
taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), msg);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue