From 2a81b29b8f26f71ac32413200de9699ba3d211cb Mon Sep 17 00:00:00 2001 From: wen-hemin <39549317+wen-hemin@users.noreply.github.com> Date: Mon, 19 Apr 2021 16:22:17 +0800 Subject: [PATCH] fix: process instance version page bug (#5319) Co-authored-by: wen-hemin --- .../api/controller/ProcessDefinitionController.java | 12 ++++++------ .../api/service/ProcessDefinitionService.java | 6 +++--- .../service/impl/ProcessDefinitionServiceImpl.java | 8 ++++---- .../api/service/impl/ProcessInstanceServiceImpl.java | 6 +++++- .../src/js/conf/home/pages/dag/_source/dag.vue | 4 ++-- .../pages/definition/pages/list/_source/versions.vue | 5 +++-- .../src/js/conf/home/store/dag/actions.js | 10 ++++++++-- .../src/js/conf/home/store/dag/state.js | 4 ++++ 8 files changed, 35 insertions(+), 20 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java index d2cbe78029..6c73e2ad2a 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java @@ -275,14 +275,14 @@ public class ProcessDefinitionController extends BaseController { * @param projectName the process definition project name * @param pageNo the process definition version list current page number * @param pageSize the process definition version list page size - * @param processDefinitionId the process definition id + * @param processDefinitionCode the process definition code * @return the process definition version list */ @ApiOperation(value = "queryProcessDefinitionVersions", notes = "QUERY_PROCESS_DEFINITION_VERSIONS_NOTES") @ApiImplicitParams({ @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", required = true, dataType = "Int", example = "100"), - @ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100") + @ApiImplicitParam(name = "processDefinitionCode", value = "PROCESS_DEFINITION_CODE", required = true, dataType = "Long", example = "1") }) @GetMapping(value = "/versions") @ResponseStatus(HttpStatus.OK) @@ -291,11 +291,11 @@ public class ProcessDefinitionController extends BaseController { @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, @RequestParam(value = "pageNo") int pageNo, @RequestParam(value = "pageSize") int pageSize, - @RequestParam(value = "processDefinitionId") int processDefinitionId) { - logger.info("login user {}, query process versions, project name: {}, pageNo: {}, pageSize: {}, processDefinitionId: {}", - loginUser.getUserName(), projectName, pageNo, pageSize, processDefinitionId); + @RequestParam(value = "processDefinitionCode") long processDefinitionCode) { + logger.info("login user {}, query process versions, project name: {}, pageNo: {}, pageSize: {}, processDefinitionCode: {}", + loginUser.getUserName(), projectName, pageNo, pageSize, processDefinitionCode); Map result = processDefinitionService.queryProcessDefinitionVersions(loginUser - , projectName, pageNo, pageSize, processDefinitionId); + , projectName, pageNo, pageSize, processDefinitionCode); return returnDataList(result); } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java index eaa73e8999..acaab97c6a 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java @@ -276,17 +276,17 @@ public interface ProcessDefinitionService { , int processDefinitionId, long version); /** - * query the pagination versions info by one certain process definition id + * query the pagination versions info by one certain process definition code * * @param loginUser login user info to check auth * @param projectName process definition project name * @param pageNo page number * @param pageSize page size - * @param processDefinitionId process definition id + * @param processDefinitionCode process definition code * @return the pagination process definition versions info of the certain process definition */ Map queryProcessDefinitionVersions(User loginUser, String projectName, - int pageNo, int pageSize, int processDefinitionId); + int pageNo, int pageSize, long processDefinitionCode); /** * delete one certain process definition by version number and process definition id diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java index 6dabcb22bc..396d59ce7b 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java @@ -1726,17 +1726,17 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro } /** - * query the pagination versions info by one certain process definition id + * query the pagination versions info by one certain process definition code * * @param loginUser login user info to check auth * @param projectName process definition project name * @param pageNo page number * @param pageSize page size - * @param processDefinitionId process definition id + * @param processDefinitionCode process definition code * @return the pagination process definition versions info of the certain process definition */ @Override - public Map queryProcessDefinitionVersions(User loginUser, String projectName, int pageNo, int pageSize, int processDefinitionId) { + public Map queryProcessDefinitionVersions(User loginUser, String projectName, int pageNo, int pageSize, long processDefinitionCode) { Map result = new HashMap<>(); @@ -1758,7 +1758,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro return checkResult; } - ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineId(processDefinitionId); + ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefinitionCode); PageInfo pageInfo = new PageInfo<>(pageNo, pageSize); Page page = new Page<>(pageNo, pageSize); diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java index 21c79bd043..67d6183571 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java @@ -463,12 +463,16 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce processDefinition.getUserId()); setProcessInstance(processInstance, tenant, scheduleTime, locations, connects, processInstanceJson, processData); - int update = processService.updateProcessInstance(processInstance); int updateDefine = 1; if (Boolean.TRUE.equals(syncDefine)) { updateDefine = syncDefinition(loginUser, project, locations, connects, processInstance, processDefinition, processData); + + processInstance.setProcessDefinitionVersion(processDefinitionLogMapper. + queryMaxVersionForDefinition(processInstance.getProcessDefinitionCode())); } + + int update = processService.updateProcessInstance(processInstance); if (update > 0 && updateDefine > 0) { putMsg(result, Status.SUCCESS); } else { diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.vue index 860de1c00c..a1cef107ee 100755 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/dag.vue @@ -153,7 +153,7 @@ :visible.sync="drawer" size="" :with-header="false"> - + { let processDefinitionVersions = res.data.lists let total = res.data.totalCount diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/versions.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/versions.vue index f1e10b3aa2..7fa8bb30c1 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/versions.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/versions.vue @@ -50,7 +50,7 @@ :title="$t('Confirm Switch To This Version?')" @onConfirm="_mVersionSwitchProcessDefinitionVersion(scope.row)" > - + @@ -62,7 +62,7 @@ :title="$t('Delete?')" @onConfirm="_mVersionDeleteProcessDefinitionVersion(scope.row,scope.row.id)" > - + @@ -110,6 +110,7 @@ } }, props: { + isInstance: Boolean, versionData: Object }, methods: { diff --git a/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js b/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js index 841fd1825b..3cda9e311a 100644 --- a/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js +++ b/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js @@ -158,6 +158,10 @@ export default { io.get(`projects/${state.projectName}/process/select-by-id`, { processId: payload }, res => { + // process definition code + state.code = res.data.code + // version + state.version = res.data.version // name state.name = res.data.name // description @@ -166,8 +170,6 @@ export default { state.connects = JSON.parse(res.data.connects) // locations state.locations = JSON.parse(res.data.locations) - // version - state.version = res.data.version // Process definition const processDefinitionJson = JSON.parse(res.data.processDefinitionJson) // tasks info @@ -243,6 +245,10 @@ export default { io.get(`projects/${state.projectName}/instance/select-by-id`, { processInstanceId: payload }, res => { + // code + state.code = res.data.processDefinitionCode + // version + state.version = res.data.processDefinitionVersion // name state.name = res.data.name // desc diff --git a/dolphinscheduler-ui/src/js/conf/home/store/dag/state.js b/dolphinscheduler-ui/src/js/conf/home/store/dag/state.js index 1d5a06d5b5..486611a8ae 100644 --- a/dolphinscheduler-ui/src/js/conf/home/store/dag/state.js +++ b/dolphinscheduler-ui/src/js/conf/home/store/dag/state.js @@ -21,6 +21,10 @@ import localStore from '@/module/util/localStorage' const projectName = localStore.getItem('projectName') export default { + // process definition code + code: '', + // process definition version + version: '', // name name: '', // description