diff --git a/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterControllerV2.java b/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterControllerV2.java index e149adc5..0c6c3a1f 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterControllerV2.java +++ b/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterControllerV2.java @@ -19,6 +19,7 @@ import io.renren.modules.processForm.service.TAbilityApplicationService; import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.service.ResourceService; import io.renren.modules.security.user.SecurityUser; +import io.renren.modules.sys.service.SysDeptService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -32,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.time.LocalDateTime; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -57,6 +59,8 @@ public class AbilityCenterControllerV2 { private ResourceService resourceService; @Autowired private JdbcTemplate jdbcTemplate; + @Autowired + private SysDeptService sysDeptService; private static String key = "abilityprocess_v2"; private static Map params = new HashMap() { @@ -121,11 +125,14 @@ public class AbilityCenterControllerV2 { return resourceDTO.getDeptId(); })); // 按部门分组 temp.keySet().stream().distinct().forEach(deptId -> { - if (deptId == 0L) { // 部门不存在时 + if (deptId == 0L) { // 部门id不存在时 + return; + } + if (sysDeptService.get(deptId) == null) { // 部门不存在 return; } List dtoList = temp.get(deptId); - List ids = dtoList.stream().map(index -> index.getId()).collect(Collectors.toList()); + List ids = dtoList.stream().map(index -> index.getId()).collect(Collectors.toList()); // 发起申请的表单id // 仿照请求接口 /act/running/startOfBusinessKey ProcessStartDTO processStartDTO = new ProcessStartDTO(); processStartDTO.setBusinessKey(JSON.toJSONString(ids)); // 申请的id列表 json字符 做businesskey @@ -148,7 +155,7 @@ public class AbilityCenterControllerV2 { // 仿照请求接口 /processForm/tabilityapplication/updateInstanceId CompletableFuture.runAsync(() -> { - if (Long.valueOf(dto.getBusinessKey()) != null) { + if (dto.getBusinessKey() != null) { String[] sqls = dtoList.stream().map(i -> String.format("UPDATE t_ability_application SET instance_id = %s WHERE id = %s", dto.getProcessInstanceId(), i.getId())) .collect(Collectors.toList()).toArray(new String[dtoList.size()]); @@ -157,6 +164,6 @@ public class AbilityCenterControllerV2 { }); }); } - return new Result().ok(""); + return new Result().ok(LocalDateTime.now().toString()); } } diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/listener/v2/CorrectionListenerV2.java b/renren-admin/src/main/java/io/renren/modules/processForm/listener/v2/CorrectionListenerV2.java index 21a28711..93e8e559 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/listener/v2/CorrectionListenerV2.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/listener/v2/CorrectionListenerV2.java @@ -1,15 +1,16 @@ package io.renren.modules.processForm.listener.v2; +import com.alibaba.fastjson.JSON; 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.common.dto.AuditingBaseDTO; import io.renren.modules.activiti.service.ActTaskService; 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.resource.dto.ResourceDTO; import io.renren.modules.resource.entity.ResourceEntity; import io.renren.modules.resource.service.ResourceService; import io.renren.modules.sys.dto.SysDeptDTO; @@ -24,17 +25,13 @@ 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; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -import java.util.Date; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; +import java.util.*; /** * 部门动态审批人 v2 @@ -122,6 +119,23 @@ public class CorrectionListenerV2 implements TaskListener, ExecutionListener, Ac GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(Date.class, (JsonDeserializer) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong())); + Gson gson = builder.create(); + JsonElement jsonElement = gson.toJsonTree(kv); + AuditingBaseDTO auditingBaseDTO = gson.fromJson(jsonElement, AuditingBaseDTO.class); + if (auditingBaseDTO != null) { + List dtoList = new ArrayList<>(); + if (kv.containsKey("tAbilityApplicationDTOList")) { + dtoList = (List) kv.get("tAbilityApplicationDTOList"); + } + if (auditingBaseDTO.getReject() != null && auditingBaseDTO.getReject() == Boolean.TRUE) { // 存在被拒绝的节点 + + } else { + + } + } + + builder.registerTypeAdapter(Date.class, (JsonDeserializer) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong())); + Gson gson = builder.create(); JsonElement jsonElement = gson.toJsonTree(kv); TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class); @@ -147,26 +161,13 @@ public class CorrectionListenerV2 implements TaskListener, ExecutionListener, Ac */ private void create(DelegateTask delegateTask) { Map kv = delegateTask.getVariables(); - GsonBuilder builder = new GsonBuilder(); - builder.registerTypeAdapter(Date.class, (JsonDeserializer) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong())); - - Gson gson = builder.create(); - JsonElement jsonElement = gson.toJsonTree(kv); - TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class); - SysRoleDTO roleDTO = sysRoleService.getByName(roleName); logger.error("roleDTOId:" + roleDTO.getId()); - ResourceDTO resourceEntityDto = 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) { - deptId = resourceEntityDto.getDeptId(); - SysDeptDTO deptDTO = - sysDeptService.get(resourceEntityDto.getDeptId()); - if (deptDTO != null && deptDTO.getName().equals(bigDateDeptName)) { + if (kv.containsKey("deptId")) { // 存在部门id + deptId = Long.valueOf(kv.get("deptId").toString()); + SysDeptDTO deptDTO = sysDeptService.get(deptId); + if (deptDTO != null && deptDTO.getName().equals(bigDateDeptName)) { // 二级审批依然为大数据局,默认审核通过 logger.error("第二级别审批仍然为 " + bigDateDeptName); SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptId, roleDTO.getId()); // 搜出审批人 if (userDTO != null) { @@ -175,39 +176,38 @@ public class CorrectionListenerV2 implements TaskListener, ExecutionListener, Ac taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "默认通过"); taskService.complete(delegateTask.getId(), delegateTask.getVariables()); return; - } - } else { - logger.error("表单内单位名称:" + abilityApplicationDTO.getUnit()); - SysDeptDTO deptDTO = sysDeptService.getByName(abilityApplicationDTO.getUnit()); - if (deptDTO != null) { - logger.error("deptDTOId:" + deptDTO.getId()); - deptId = deptDTO.getId(); - } + } // 二级审批依然为大数据局 - } - SysUserDTO userDTO = null; - if (deptId != null) { - userDTO = sysUserService.getByDeptIdAndRoleId(deptId, roleDTO.getId()); // 搜出审批人 - } - if (userDTO != null) { - logger.error("审批人id:" + userDTO.getId()); - taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString()); + SysUserDTO userDTO = null; + if (deptId != null) { + userDTO = sysUserService.getByDeptIdAndRoleId(deptId, roleDTO.getId()); // 搜出审批人 + } + if (userDTO != null) { + logger.error("审批人id:" + userDTO.getId()); + taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString()); + delegateTask.setAssignee(userDTO.getId().toString()); + } else { + logger.error("未查到该部门 {} 对应的 " + roleName, deptId); + taskService.setAssignee(delegateTask.getId(), "1516728698224427010"); + delegateTask.setAssignee("1516728698224427010"); + } + if (kv.containsKey("tAbilityApplicationDTOList")) { + List dtoList = (List) kv.get("tAbilityApplicationDTOList"); + mpComplete(dtoList, delegateTask); + } } else { - logger.error("未查到该部门对应的 " + roleName); - taskService.setAssignee(delegateTask.getId(), "1516728698224427010"); + try { + logger.error("流程参数异常" + JSON.toJSONString(kv)); + } catch (Exception exception) { + logger.error("", exception); + } } - mpComplete(abilityApplicationDTO, delegateTask); } - private void mpComplete(TAbilityApplicationDTO abilityApplicationDTO, DelegateTask delegateTask) { - Optional resourceDTOOptional = Optional.ofNullable(resourceService.get(Long.valueOf(abilityApplicationDTO.getResourceId()))); - resourceDTOOptional.ifPresent(resource -> { - if (StringUtils.contains(resource.getShareCondition(), "免批")) { // 针对免批资源申请 - taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "免批资源申请默认通过"); - taskService.complete(delegateTask.getId(), delegateTask.getVariables()); - return; - } - if (abilityApplicationDTO.getUserId().equals(delegateTask.getAssignee())) { + private void mpComplete(List abilityApplicationDTO, DelegateTask delegateTask) { // 处理免批或申请人为资源提供方部门审批人 + Optional abilityApplicationDTOOptional = abilityApplicationDTO.stream().findAny(); + abilityApplicationDTOOptional.ifPresent(index -> { + if (abilityApplicationDTOOptional.get().getUserId().equals(delegateTask.getAssignee())) { taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "申请人为资源提供方部门审批人,默认通过"); taskService.complete(delegateTask.getId(), delegateTask.getVariables()); return; diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/listener/v2/DataCenterListenerV2.java b/renren-admin/src/main/java/io/renren/modules/processForm/listener/v2/DataCenterListenerV2.java index 7dfae881..2affad4c 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/listener/v2/DataCenterListenerV2.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/listener/v2/DataCenterListenerV2.java @@ -1,9 +1,5 @@ package io.renren.modules.processForm.listener.v2; -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.resource.service.ResourceService; import io.renren.modules.sys.dto.SysDeptDTO; @@ -23,9 +19,6 @@ 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; - /** * 大数据局动态审批人 v2 */ @@ -105,16 +98,16 @@ public class DataCenterListenerV2 implements TaskListener, ExecutionListener, Ac logger.error("审批人id:" + userDTO.getId()); taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString()); } else { - delegateTask.setAssignee("1516728698224427010"); - logger.error("未查到该部门对应 " + roleName); + logger.error("未查到 {} 对应 " + roleName, bigDateDeptName); } + // TODO 批量里存在免批?或全为免批的情况? - Map kv = delegateTask.getVariables(); - GsonBuilder builder = new GsonBuilder(); - builder.registerTypeAdapter(Date.class, (JsonDeserializer) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong())); - - Gson gson = builder.create(); - JsonElement jsonElement = gson.toJsonTree(kv); +// Map kv = delegateTask.getVariables(); +// GsonBuilder builder = new GsonBuilder(); +// builder.registerTypeAdapter(Date.class, (JsonDeserializer) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong())); +// +// Gson gson = builder.create(); +// JsonElement jsonElement = gson.toJsonTree(kv); // TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class); // Optional resourceDTOOptional = Optional.ofNullable(resourceService.get(Long.valueOf(abilityApplicationDTO.getResourceId()))); // resourceDTOOptional.ifPresent(resource -> {