From 06085b9eea03b97c16a8f4b2927ce25b56aa2edb Mon Sep 17 00:00:00 2001 From: huangweixiong Date: Wed, 11 May 2022 16:26:06 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=BD=91=E5=85=B3=E5=AF=B9=E6=8E=A5?= =?UTF-8?q?=E3=80=91=E4=BF=AE=E6=94=B9=E7=94=B3=E8=AF=B7=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E6=B5=81=E7=A8=8B=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activiti/service/ActTaskService.java | 11 ++++ .../entity/TAbilityApplicationEntity.java | 1 + .../listener/CorrectionListener.java | 43 +++++++++++--- .../listener/ResourceOwnerListener.java | 6 +- .../src/main/resources/application-hwx.yml | 58 +++++++++++++++++++ .../java/io/renren/ApiGatewayServiceTest.java | 2 +- 6 files changed, 110 insertions(+), 11 deletions(-) create mode 100644 renren-admin/src/main/resources/application-hwx.yml diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java index 3b3137a2..d4f86be8 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java @@ -53,6 +53,13 @@ import java.util.*; */ @Service public class ActTaskService extends BaseServiceImpl { + + public static String Task_HANDLE_STATE = "handleState"; //任务节点处理状态key + public static String Task_HANDLE_STATE_AGREE = "agree"; //同意 + public static String Task_HANDLE_STATE_REJECTED = "rejected"; //驳回 + public static String Task_HANDLE_STATE_BACK = "back"; //回退 + public static String Task_HANDLE_STATE_STOP = "stop"; //终止 + @Autowired protected TaskService taskService; @Autowired @@ -210,6 +217,7 @@ public class ActTaskService extends BaseServiceImpl { if (StringUtils.isNotEmpty(comment)) { taskService.addComment(taskId, task.getProcessInstanceId(), comment); } + taskService.setVariable(taskId, Task_HANDLE_STATE, Task_HANDLE_STATE_AGREE); taskService.complete(taskId); } @@ -374,6 +382,7 @@ public class ActTaskService extends BaseServiceImpl { if (StringUtils.isNotEmpty(comment)) { commentMode += "[" + comment + "]"; } + taskService.setVariable(task.getId(), Task_HANDLE_STATE, Task_HANDLE_STATE_BACK); taskService.addComment(task.getId(), task.getProcessInstanceId(), commentMode); taskService.complete(task.getId(), variables); } @@ -461,6 +470,7 @@ public class ActTaskService extends BaseServiceImpl { String message = MessageUtils.getMessage(ErrorCode.END_PROCESS_MESSAGE); comment = message + "[" + comment + "]"; taskService.addComment(task.getId(), task.getProcessInstanceId(), comment); + taskService.setVariable(task.getId(), Task_HANDLE_STATE, Task_HANDLE_STATE_STOP); taskService.complete(taskId); pointActivity.getIncomingTransitions().remove(newTransition); List pvmTransitionListC = currActivity.getOutgoingTransitions(); @@ -590,6 +600,7 @@ public class ActTaskService extends BaseServiceImpl { this.setTaskVariable(taskDTO.getTaskId(), key, taskDTO.getParams().get(key)); } } + taskService.setVariable(taskDTO.getTaskId(), Task_HANDLE_STATE, Task_HANDLE_STATE_REJECTED); this.completeTask(taskDTO.getTaskId(), taskDTO.getComment()); } 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 6ed5f847..d43307cd 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 @@ -37,6 +37,7 @@ public class TAbilityApplicationEntity { /** * 申请应用系统 */ + @TableField("`system`") private String system; /** * 申请场景 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 5b6de29d..df762354 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 @@ -2,6 +2,7 @@ package io.renren.modules.processForm.listener; import com.google.gson.Gson; import com.google.gson.JsonElement; +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; @@ -15,19 +16,24 @@ 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.HistoryService; import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngines; 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.activiti.engine.history.HistoricTaskInstance; +import org.activiti.engine.task.Task; +import org.activiti.engine.task.TaskQuery; +import org.apache.commons.lang.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.Map; +import java.util.*; /** * 部门动态审批人 @@ -46,6 +52,8 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti @Autowired private TaskService taskService; @Autowired + private HistoryService historyService; + @Autowired private SysUserService sysUserService; @Autowired private SysRoleUserService sysRoleUserService; @@ -68,6 +76,9 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti case EVENTNAME_CREATE: create(delegateTask); break; + case EVENTNAME_COMPLETE: + complete(delegateTask); + break; default: } logger.error("-------------------------结束部门动态审批人流程-------------------------------"); @@ -80,7 +91,7 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti final String eventName = delegateExecution.getEventName(); switch (eventName) { case EVENTNAME_END: - endTake(delegateExecution.getVariables()); + endTake(delegateExecution); break; } } @@ -105,9 +116,10 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti /** * 结束审批 * - * @param kv + * @param delegateExecution */ - private void endTake(Map kv) { // 进入最后结束节点 + private void endTake(DelegateExecution delegateExecution) { // 进入最后结束节点 + Map kv = delegateExecution.getVariables(); Gson gson = new Gson(); JsonElement jsonElement = gson.toJsonTree(kv); TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class); @@ -169,16 +181,27 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti } } - /** - * 审批通过,申请code - * @param delegateTask - */ private void complete(DelegateTask delegateTask) { Map 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当做没有接口,直接跳过 @@ -192,7 +215,9 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti String apiPrefix = "/juapi/" + abilityApplicationDTO.getResourceId(); TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService(); - String msg = String.format("您的能力申请已通过,接口认证code为:%s, 接口公共前缀为:%s",code, apiPrefix) ; + String msg = String.format("您的能力申请已通过,接口认证code为:%s, 接口公共前缀为:%s",code, apiPrefix); taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), msg); + + } } diff --git a/renren-admin/src/main/java/io/renren/modules/resourceMountApply/listener/ResourceOwnerListener.java b/renren-admin/src/main/java/io/renren/modules/resourceMountApply/listener/ResourceOwnerListener.java index 6472dddf..b5b4dbd5 100644 --- a/renren-admin/src/main/java/io/renren/modules/resourceMountApply/listener/ResourceOwnerListener.java +++ b/renren-admin/src/main/java/io/renren/modules/resourceMountApply/listener/ResourceOwnerListener.java @@ -3,6 +3,7 @@ package io.renren.modules.resourceMountApply.listener; import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.google.gson.JsonElement; +import io.renren.modules.activiti.service.ActTaskService; import io.renren.modules.processForm.service.ApiGatewayService; import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.service.ResourceService; @@ -137,7 +138,10 @@ public class ResourceOwnerListener implements TaskListener, ExecutionListener, A JsonElement jsonElement = gson.toJsonTree(kv); TResourceMountApplyDTO resourceMountApplyDTO = gson.fromJson(jsonElement, TResourceMountApplyDTO.class); Long resourceID = resourceMountApplyDTO.getResourceDTO().getId(); - apiGatewayService.registerApi2Gateway(String.valueOf(resourceID)); + + if (ActTaskService.Task_HANDLE_STATE_AGREE.equals(kv.get(ActTaskService.Task_HANDLE_STATE))) { + apiGatewayService.registerApi2Gateway(String.valueOf(resourceID)); + } ResourceDTO re = resourceMountApplyDTO.getResourceDTO(); if (re != null) { diff --git a/renren-admin/src/main/resources/application-hwx.yml b/renren-admin/src/main/resources/application-hwx.yml new file mode 100644 index 00000000..c6b8b9a3 --- /dev/null +++ b/renren-admin/src/main/resources/application-hwx.yml @@ -0,0 +1,58 @@ +server: + port: 8000 +spring: + datasource: + druid: + #MySQL + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true + username: root + password: 123456 + initial-size: 10 + max-active: 100 + min-idle: 10 + max-wait: 3000 + pool-prepared-statements: true + max-pool-prepared-statement-per-connection-size: 20 + time-between-eviction-runs-millis: 60000 + min-evictable-idle-time-millis: 300000 + #Oracle需要打开注释 + validation-query: SELECT 1 + test-while-idle: true + test-on-borrow: false + test-on-return: false + stat-view-servlet: + enabled: true + url-pattern: /druid/* + #login-username: admin + #login-password: admin + filter: + stat: + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: false + wall: + config: + multi-statement-allow: true +#上传的静态资源配置 +resource: + root_url: 15.2.21.238 + path: /data/services/nengli/files/ + devModelFilePath: /data/services/nengli/files/devModelFile +# 大数据部门相关配置 +big_date: + name: 青岛市大数据发展管理局 + assignee_role_name: 部门审批人 + +hisense: + gateway: +# url: http://15.72.184.7:8080 + url: http://devtest-security-app.hismarttv.com:8080 +logging: + level: + org: + activiti: + engine: + impl: + persistence: + entity: debug \ No newline at end of file diff --git a/renren-admin/src/test/java/io/renren/ApiGatewayServiceTest.java b/renren-admin/src/test/java/io/renren/ApiGatewayServiceTest.java index a783dd71..6bb4f9d7 100644 --- a/renren-admin/src/test/java/io/renren/ApiGatewayServiceTest.java +++ b/renren-admin/src/test/java/io/renren/ApiGatewayServiceTest.java @@ -25,7 +25,7 @@ public class ApiGatewayServiceTest { @Test public void registerCode2Group() { String code = UUID.randomUUID().toString(); - apiGatewayService.subscribeCode("1522550733273112577", code); + apiGatewayService.subscribeCode("1523913824099762177", code); } } \ No newline at end of file