From 7ec0fb611f578370b378b885ce4a3e32617578b4 Mon Sep 17 00:00:00 2001 From: ymq Date: Tue, 18 Aug 2026 14:05:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20create=5Ftask=20=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=BD=92=E5=BD=93=E5=89=8D=E8=BF=AD=E4=BB=A3=EF=BC=88=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E8=BF=AD=E4=BB=A3=EF=BC=89=EF=BC=9B=5Fresolve=5Fitera?= =?UTF-8?q?tion=5Fid=20=E5=8F=96=E5=BD=93=E5=89=8D=E8=BF=AD=E4=BB=A3?= =?UTF-8?q?=E8=80=8C=E9=9D=9E=E7=AC=AC=E4=B8=80=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pipeline_service/sdlc_ability.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/pipeline_service/sdlc_ability.py b/pipeline_service/sdlc_ability.py index a3c3d67..597e649 100644 --- a/pipeline_service/sdlc_ability.py +++ b/pipeline_service/sdlc_ability.py @@ -34,6 +34,7 @@ SDL_TOOLS = [ "title": "任务标题", "role": "目标角色(requirement/design/develop/test/deploy)", "description": "任务详细描述", + "iteration_id": "归属迭代(可选,默认当前迭代)", }, category="task", ), @@ -320,13 +321,27 @@ async def _h_create_task(sor, p, ctx): role = _normalize_role(role) tid = getID() + # 迭代归属:显式指定 > 当前迭代(该 project 最新创建的迭代)。 + # 「当前迭代」概念:新建迭代后当前迭代即新建的那个,任务默认归到它。 + iteration_name = (p.get("iteration_id", "") or "").strip() + if not iteration_name: + irecs = await sor.sqlExe( + "SELECT iteration_name FROM sd_iterations WHERE project_id=${pid}$ ORDER BY created_at DESC LIMIT 1", + {"pid": pid}) + if irecs: + iteration_name = getattr(irecs[0], 'iteration_name', '') or '' + + params = {"description": desc} + if iteration_name: + params["iteration_id"] = iteration_name + await sor.C("pipeline_tasks", { "id": tid, "tenant_id": pid, "pipeline_id": "role_task", "owner_id": ctx.get("user_id") or "user", "title": title, "state": "submitted", "role": role, - "params": json.dumps({"description": desc}, ensure_ascii=False), + "params": json.dumps(params, ensure_ascii=False), }) - return f"OK: 已创建任务 {title}(角色: {role})" + return f"OK: 已创建任务 {title}(角色: {role},迭代: {iteration_name or '未分配'})" async def _h_list_tasks(sor, p, ctx): @@ -819,7 +834,7 @@ async def _resolve_iteration_id(sor, pid, iteration_id): return full, "" return "", f"迭代不存在: {iteration_id}" recs = await sor.sqlExe( - "SELECT id FROM sd_iterations WHERE project_id=${pid}$ ORDER BY created_at ASC LIMIT 1", + "SELECT id FROM sd_iterations WHERE project_id=${pid}$ ORDER BY created_at DESC LIMIT 1", {"pid": pid}) if recs: return getattr(recs[0], "id", ""), ""