From dd5dd16184db94a854fcf9454d5ed345bac99b8d Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 25 Nov 2022 12:05:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E5=88=87=E6=8D=A2=E4=B8=8D=E5=88=B7=E6=96=B0=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E7=8A=B6=E6=80=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1019596 --user=赵勇 【任务中心】开源版的任务中场景测试任务统计数量不更新 https://www.tapd.cn/55049933/s/1305073 --- framework/sdk-parent/frontend/src/api/task.js | 5 +-- .../src/components/task/TaskCenter.vue | 13 ++++++-- .../websocket/TaskCenterWebSocket.java | 31 +++++++++++-------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/framework/sdk-parent/frontend/src/api/task.js b/framework/sdk-parent/frontend/src/api/task.js index 3d970bd66a..741786d00b 100644 --- a/framework/sdk-parent/frontend/src/api/task.js +++ b/framework/sdk-parent/frontend/src/api/task.js @@ -5,8 +5,9 @@ import packageInfo from '@/../package.json' const currentModuleName = packageInfo.name; -export function getTaskSocket(hasLicense) { - return socket("/websocket/task/running/" + getCurrentProjectID() + "/" + getCurrentUser().id + "/" + hasLicense) +export function getTaskSocket(userId,triggerMode,hasLicense) { + triggerMode = triggerMode || 'ALL'; + return socket(`/websocket/task/running/${userId}/${triggerMode}/${hasLicense}`) } export function getCaseData(id) { diff --git a/framework/sdk-parent/frontend/src/components/task/TaskCenter.vue b/framework/sdk-parent/frontend/src/components/task/TaskCenter.vue index 8d48398d0f..305d8afaa6 100644 --- a/framework/sdk-parent/frontend/src/components/task/TaskCenter.vue +++ b/framework/sdk-parent/frontend/src/components/task/TaskCenter.vue @@ -44,7 +44,7 @@ - @@ -64,7 +64,7 @@ + style="margin-right: 10px" @change="changeInit" :disabled="isDebugHistory"> refreshTasks = new ConcurrentHashMap<>(); + private final static String ALL = "ALL"; @Resource public void setTaskService(TaskService taskService) { @@ -30,9 +33,11 @@ public class TaskCenterWebSocket { * 开启连接的操作 */ @OnOpen - public void onOpen(@PathParam("projectId") String projectId, @PathParam("userId") String userId, @PathParam("hasLicense") boolean hasLicense, Session session) { + public void onOpen(@PathParam("userId") String userId, + @PathParam("triggerMode") String triggerMode, + @PathParam("hasLicense") boolean hasLicense, Session session) { Timer timer = new Timer(true); - TaskCenter task = new TaskCenter(session, projectId, userId, hasLicense); + TaskCenter task = new TaskCenter(session, userId, triggerMode, hasLicense); timer.schedule(task, 0, 10 * 1000); refreshTasks.putIfAbsent(session, timer); } @@ -53,18 +58,15 @@ public class TaskCenterWebSocket { * 推送消息 */ @OnMessage - public void onMessage(@PathParam("projectId") String projectId, @PathParam("userId") String userId, @PathParam("hasLicense") boolean hasLicense, Session session, String message) { - int refreshTime = 10; - try { - refreshTime = Integer.parseInt(message); - } catch (Exception e) { - } + public void onMessage(@PathParam("userId") String userId, + @PathParam("triggerMode") String triggerMode, + @PathParam("hasLicense") boolean hasLicense, Session session, String message) { try { Timer timer = refreshTasks.get(session); timer.cancel(); - + int refreshTime = IntegerUtils.parseInt(message, 10); Timer newTimer = new Timer(true); - newTimer.schedule(new TaskCenter(session, projectId, userId, hasLicense), 0, refreshTime * 1000L); + newTimer.schedule(new TaskCenter(session, userId, triggerMode, hasLicense), 0, refreshTime * 1000L); refreshTasks.put(session, newTimer); } catch (Exception e) { LogUtil.error(e.getMessage(), e); @@ -84,11 +86,14 @@ public class TaskCenterWebSocket { private Session session; private TaskCenterRequest request; - TaskCenter(Session session, String projectId, String userId, boolean hasLicense) { + TaskCenter(Session session, String userId, String triggerMode, boolean hasLicense) { this.session = session; TaskCenterRequest request = new TaskCenterRequest(); - request.setProjectId(projectId); + if (!StringUtils.equals(triggerMode, ALL)) { + request.setTriggerMode(triggerMode); + } request.setUserId(userId); + request.setExecutor(userId); request.setHasLicense(hasLicense); this.request = request; }