From 8a594d2180ab10ade0129c6b61b64a2eb32ccdd6 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Thu, 21 Apr 2022 18:00:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A4=A7=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=AE=A1=E6=89=B9=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AbilityCenterController.java | 2 + .../dto/TAbilityApplicationDTO.java | 15 ++- .../dto/TAbilityBatchApplicationDTO.java | 5 + .../entity/TAbilityApplicationEntity.java | 91 +++++++++++-------- .../listener/CorrectionListener.java | 37 +++++--- .../listener/DataCenterListener.java | 73 +++++++++++++++ .../src/main/resources/logback-spring.xml | 2 +- 7 files changed, 168 insertions(+), 57 deletions(-) create mode 100644 renren-admin/src/main/java/io/renren/modules/processForm/listener/DataCenterListener.java diff --git a/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java b/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java index 1e30a7ea..abbd9d5c 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/AbilityCenterController.java @@ -76,6 +76,8 @@ public class AbilityCenterController { tAbilityApplicationDTO.setInstanceId(abilityBatchApplicationDTO.getInstanceId()); tAbilityApplicationDTO.setUnit(abilityBatchApplicationDTO.getUnit()); tAbilityApplicationDTO.setUser(abilityBatchApplicationDTO.getUser()); + tAbilityApplicationDTO.setResourceId(abilityBatchApplicationDTO.getResourceId()); + tAbilityApplicationDTO.setUser(abilityBatchApplicationDTO.getUser()); tAbilityApplicationDTO.setSystem(index); // 仿照请求接口 /processForm/tabilityapplication ValidatorUtils.validateEntity(tAbilityApplicationDTO, AddGroup.class, DefaultGroup.class); diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityApplicationDTO.java b/renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityApplicationDTO.java index ceaaac56..fcb3ad84 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityApplicationDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityApplicationDTO.java @@ -7,11 +7,11 @@ import lombok.Data; import java.io.Serializable; /** -* 能力申请表单 -* -* @author Mark sunlightcs@gmail.com -* @since 3.0 2022-04-13 -*/ + * 能力申请表单 + * + * @author Mark sunlightcs@gmail.com + * @since 3.0 2022-04-13 + */ @Data @ApiModel(value = "能力申请表单") public class TAbilityApplicationDTO implements Serializable { @@ -37,4 +37,9 @@ public class TAbilityApplicationDTO implements Serializable { @ApiModelProperty(value = "实例ID") private String instanceId; + @ApiModelProperty(value = "资源id") + private String resourceId; + @ApiModelProperty(value = "用户id") + private String userId; + } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityBatchApplicationDTO.java b/renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityBatchApplicationDTO.java index 7647ddf2..0da0d475 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityBatchApplicationDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/dto/TAbilityBatchApplicationDTO.java @@ -32,4 +32,9 @@ public class TAbilityBatchApplicationDTO implements Serializable { private String attachment; @ApiModelProperty(value = "实例ID") private String instanceId; + + @ApiModelProperty(value = "资源id") + private String resourceId; + @ApiModelProperty(value = "用户id") + private String userId; } diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/entity/TAbilityApplicationEntity.java b/renren-admin/src/main/java/io/renren/modules/processForm/entity/TAbilityApplicationEntity.java index 340afccb..77a093b6 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/entity/TAbilityApplicationEntity.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/entity/TAbilityApplicationEntity.java @@ -11,48 +11,59 @@ import com.baomidou.mybatisplus.annotation.*; * @since 3.0 2022-04-13 */ @Data -@EqualsAndHashCode(callSuper=false) +@EqualsAndHashCode(callSuper = false) @TableName("t_ability_application") public class TAbilityApplicationEntity { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - @TableId - private Long id; - /** - * 申请人 - */ - private String user; - /** - * 申请人电话 - */ - private String phone; - /** - * 申请人单位 - */ - private String unit; - /** - * 申请人所在地区 - */ - private String area; - /** - * 申请应用系统 - */ - private String system; - /** - * 申请场景 - */ - private String scene; - /** - * 申请依据 - */ - private String basis; - /** - * 申请附件 - */ - private String attachment; + @TableId + private Long id; + /** + * 申请人 + */ + private String user; + /** + * 申请人电话 + */ + private String phone; + /** + * 申请人单位 + */ + private String unit; + /** + * 申请人所在地区 + */ + private String area; + /** + * 申请应用系统 + */ + private String system; + /** + * 申请场景 + */ + private String scene; + /** + * 申请依据 + */ + private String basis; + /** + * 申请附件 + */ + private String attachment; - /** - * 实例ID - */ - private String instanceId; + /** + * 实例ID + */ + private String instanceId; + + + /** + * 资源id + */ + private String resourceId; + + /** + * 用户id + */ + private String userId; } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/listener/CorrectionListener.java b/renren-admin/src/main/java/io/renren/modules/processForm/listener/CorrectionListener.java index eac5d665..9e681ff5 100644 --- a/renren-admin/src/main/java/io/renren/modules/processForm/listener/CorrectionListener.java +++ b/renren-admin/src/main/java/io/renren/modules/processForm/listener/CorrectionListener.java @@ -3,6 +3,8 @@ package io.renren.modules.processForm.listener; import com.google.gson.Gson; import com.google.gson.JsonElement; import io.renren.modules.processForm.dto.TAbilityApplicationDTO; +import io.renren.modules.resource.dto.ResourceDTO; +import io.renren.modules.resource.service.ResourceService; import io.renren.modules.sys.dto.SysDeptDTO; import io.renren.modules.sys.dto.SysRoleDTO; import io.renren.modules.sys.dto.SysUserDTO; @@ -38,20 +40,33 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti @Autowired private SysDeptService sysDeptService; + @Autowired + private ResourceService resourceService; + @Override public void notify(DelegateTask delegateTask) { Map kv = delegateTask.getVariables(); Gson gson = new Gson(); JsonElement jsonElement = gson.toJsonTree(kv); TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class); - logger.info(abilityApplicationDTO.toString()); - logger.info("表单内单位名称:" + abilityApplicationDTO.getUnit()); - SysDeptDTO deptDTO = sysDeptService.getByName(abilityApplicationDTO.getUnit()); - logger.info("deptDTOId:" + deptDTO.getId()); + SysRoleDTO roleDTO = sysRoleService.getByName(roleName); logger.info("roleDTOId:" + roleDTO.getId()); + + logger.info("abilityApplicationDTO:" + abilityApplicationDTO.toString()); + ResourceDTO resourceEntityDto = resourceService.get(Long.valueOf(abilityApplicationDTO.getResourceId())); + Long deptId = null; + if (resourceEntityDto != null && resourceEntityDto.getDeptId() != null) { + deptId = resourceEntityDto.getDeptId(); + } else { + logger.info("表单内单位名称:" + abilityApplicationDTO.getUnit()); + SysDeptDTO deptDTO = sysDeptService.getByName(abilityApplicationDTO.getUnit()); + logger.info("deptDTOId:" + deptDTO.getId()); + deptId = deptDTO.getId(); + } + SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptId, roleDTO.getId()); // 搜出审批人 + delegateTask.setAssignee("1513432847327199233"); - SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId()); if (userDTO != null) { logger.info("审批人id:" + userDTO.getId()); taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString()); @@ -62,12 +77,12 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti @Override public void notify(DelegateExecution delegateExecution) throws Exception { - logger.info("事件:" + delegateExecution.getEventName()); - delegateExecution.getVariableNames().stream().forEach(index -> logger.info("variable:" + index)); - delegateExecution.getVariables().values().stream().filter(index -> index != null).forEach(value -> logger.info(value.toString())); - // taskService.setAssignee(delegateExecution.getProcessInstanceId(), "1516307964617076737");// 可以设置 - - logger.info("修改审批人成功!" + delegateExecution.getCurrentActivityId() + " " + delegateExecution.getProcessInstanceId() + " " + delegateExecution.getProcessBusinessKey()); +// logger.info("事件:" + delegateExecution.getEventName()); +// delegateExecution.getVariableNames().stream().forEach(index -> logger.info("variable:" + index)); +// delegateExecution.getVariables().values().stream().filter(index -> index != null).forEach(value -> logger.info(value.toString())); +// // taskService.setAssignee(delegateExecution.getProcessInstanceId(), "1516307964617076737");// 可以设置 +// +// logger.info("修改审批人成功!" + delegateExecution.getCurrentActivityId() + " " + delegateExecution.getProcessInstanceId() + " " + delegateExecution.getProcessBusinessKey()); } @Override diff --git a/renren-admin/src/main/java/io/renren/modules/processForm/listener/DataCenterListener.java b/renren-admin/src/main/java/io/renren/modules/processForm/listener/DataCenterListener.java new file mode 100644 index 00000000..4b2881cc --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/processForm/listener/DataCenterListener.java @@ -0,0 +1,73 @@ +package io.renren.modules.processForm.listener; + +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.SysRoleUserService; +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.stereotype.Component; + + +@Component +public class DataCenterListener implements TaskListener, ExecutionListener, ActivitiEventListener, JavaDelegate { + private static Logger logger = LoggerFactory.getLogger(DataCenterListener.class); + + private static String deptName = "青岛市大数据发展管理局"; + private static String roleName = "部门审批人"; + + @Autowired + private SysRoleService sysRoleService; + @Autowired + private TaskService taskService; + @Autowired + private SysUserService sysUserService; + @Autowired + private SysRoleUserService sysRoleUserService; + @Autowired + private SysDeptService sysDeptService; + + @Override + public void notify(DelegateExecution delegateExecution) throws Exception { + + } + + @Override + public void execute(DelegateExecution delegateExecution) throws Exception { + + } + + @Override + public void notify(DelegateTask delegateTask) { + SysDeptDTO deptDTO = sysDeptService.getByName(deptName); + logger.info("deptDTOId:" + deptDTO.getId()); + SysRoleDTO roleDTO = sysRoleService.getByName(roleName); + logger.info("roleDTOId:" + roleDTO.getId()); + SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId()); + delegateTask.setAssignee("1513432847327199233"); + if (userDTO != null) { + logger.info("审批人id:" + userDTO.getId()); + taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString()); + } else { + logger.info("未查到该部门对应 " + roleName); + } + } + + @Override + public void onEvent(ActivitiEvent activitiEvent) { + + } + + @Override + public boolean isFailOnException() { + return false; + } +} diff --git a/renren-admin/src/main/resources/logback-spring.xml b/renren-admin/src/main/resources/logback-spring.xml index e129ed6a..e6097eff 100644 --- a/renren-admin/src/main/resources/logback-spring.xml +++ b/renren-admin/src/main/resources/logback-spring.xml @@ -14,7 +14,7 @@ ${LOG_HOME}/info.%d{yyyy-MM-dd}.%i.log 120 - 500MB + 50MB