Merge branch 'master' into docker_package
This commit is contained in:
commit
151a34f456
|
@ -265,6 +265,7 @@ public class AbilityCenterControllerV3 {
|
|||
put("id", applyFlag); //申请id
|
||||
put("creator", user == null ? null : user.getId().toString()); // 创建人
|
||||
put("userId", user == null ? null : user.getId().toString()); // 创建人
|
||||
put("userDeptId", user == null ? null : user.getDeptId().toString()); // 发起人部门id
|
||||
put("basic_facilities", basicFacilities); // 是否为基础设施
|
||||
// 以下为V3增加
|
||||
put("city_apply", finalCityApply); // 是否为市级部门发起申请
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
package io.renren.modules.processForm.listener.v3;
|
||||
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
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.sys.dto.SysDeptDTO;
|
||||
import io.renren.modules.sys.dto.SysRoleDTO;
|
||||
import io.renren.modules.sys.dto.SysUserDTO;
|
||||
import io.renren.modules.sys.service.SysDeptService;
|
||||
import io.renren.modules.sys.service.SysRoleService;
|
||||
import io.renren.modules.sys.service.SysUserService;
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 发起人部门负责人
|
||||
*/
|
||||
@Component
|
||||
public class ApplyDeptListener implements TaskListener, ExecutionListener, ActivitiEventListener, JavaDelegate {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ApplyDeptListener.class);
|
||||
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
@Autowired
|
||||
private SysDeptService sysDeptService;
|
||||
@Value("${big_date.assignee_role_name}")
|
||||
private String roleName; // 具备审批的角色名称
|
||||
|
||||
@Override
|
||||
public void execute(DelegateExecution execution) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an event has been fired
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@Override
|
||||
public void onEvent(ActivitiEvent event) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether or not the current operation should fail when this listeners execution
|
||||
* throws an exception.
|
||||
*/
|
||||
@Override
|
||||
public boolean isFailOnException() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notify(DelegateExecution execution) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActivitiNoticeOperation(value = "申请人发起人部门负责人审批", process = "能力申请流程v3")
|
||||
public void notify(DelegateTask delegateTask) {
|
||||
logger.error("事件类型:" + delegateTask.getEventName());
|
||||
final String eventName = delegateTask.getEventName();
|
||||
switch (eventName) {
|
||||
case EVENTNAME_CREATE:
|
||||
create(delegateTask);
|
||||
break;
|
||||
case EVENTNAME_COMPLETE:
|
||||
logger.error("----------------------申请人发起人部门负责人审批-complete------------------------------");
|
||||
break;
|
||||
default:
|
||||
logger.error("未处理该事件:" + eventName);
|
||||
}
|
||||
}
|
||||
|
||||
private void create(DelegateTask delegateTask) {
|
||||
String assignee;
|
||||
Map<String, Object> kv = delegateTask.getVariables();
|
||||
GsonBuilder builder = new GsonBuilder();
|
||||
builder.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong()));
|
||||
|
||||
Gson gson = builder.create();
|
||||
JsonElement jsonElement = gson.toJsonTree(kv);
|
||||
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
|
||||
/**
|
||||
* 获取发起者部门id
|
||||
*/
|
||||
long deptId = Long.parseLong(kv.getOrDefault("userDeptId", sysUserService.get(Long.parseLong(abilityApplicationDTO.getUserId())).getDeptId()).toString());
|
||||
SysDeptDTO deptDTO = sysDeptService.get(deptId);
|
||||
logger.error("deptDTOId:" + deptDTO.getId());
|
||||
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
|
||||
logger.error("roleDTOId:" + roleDTO.getId());
|
||||
SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId());
|
||||
|
||||
if (userDTO != null) {
|
||||
logger.error("审批人id:" + userDTO.getId());
|
||||
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
|
||||
assignee = userDTO.getId().toString();
|
||||
} else {
|
||||
logger.error("未查到 {} 对应 " + roleName, deptDTO.getName());
|
||||
assignee = null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue