From 9f5fbdacfc1e63035c05099d79cbef7514d7eb50 Mon Sep 17 00:00:00 2001 From: ymq Date: Fri, 4 Sep 2026 15:58:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(todo):=20=E7=9F=A5=E8=AF=86=E5=BA=93?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=BB=BA=E8=AE=AE=E5=BE=85=E5=8A=9E=E2=80=94?= =?UTF-8?q?=E2=80=94todo=5Fdetail=E6=B8=B2=E6=9F=93kb=5Fingest=5Fconfirm+k?= =?UTF-8?q?b=5Fingest=5Fdecide=E7=AB=AF=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/load_path.py | 1 + wwwroot/api/kb_ingest_decide.dspy | 17 ++++++++ wwwroot/api/todo_detail.dspy | 69 +++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 wwwroot/api/kb_ingest_decide.dspy diff --git a/scripts/load_path.py b/scripts/load_path.py index 079b684..65d18bb 100644 --- a/scripts/load_path.py +++ b/scripts/load_path.py @@ -130,6 +130,7 @@ PATHS_LOGINED = [ f"/{MOD}/api/human_task_create.dspy", f"/{MOD}/api/human_task_complete.dspy", f"/{MOD}/api/bug_accept.dspy", + f"/{MOD}/api/kb_ingest_decide.dspy", f"/{MOD}/api/fix_stuck.dspy", # 工作环境 / 部署账号(普通用户可用) f"/{MOD}/api/work_env.dspy", diff --git a/wwwroot/api/kb_ingest_decide.dspy b/wwwroot/api/kb_ingest_decide.dspy new file mode 100644 index 0000000..ed797ff --- /dev/null +++ b/wwwroot/api/kb_ingest_decide.dspy @@ -0,0 +1,17 @@ +# kb_ingest_decide.dspy - owner 批准/驳回「知识库入库建议」(待办内完成) + +user_id = await get_user() +if not user_id: + return json.dumps({"success": False, "error": "未登录"}, ensure_ascii=False) + +suggestion_id = params_kw.get('suggestion_id', '').strip() +approve = params_kw.get('approve', '').strip().lower() in ('1', 'true', 'yes', '批准') +comment = params_kw.get('comment', '') + +if not suggestion_id: + return json.dumps({"success": False, "error": "缺少 suggestion_id"}, ensure_ascii=False) + +ok, msg = await decide_kb_ingest(suggestion_id, approve, user_id, comment=comment) +if ok: + return json.dumps({"success": True, "message": msg}, ensure_ascii=False) +return json.dumps({"success": False, "error": msg}, ensure_ascii=False) diff --git a/wwwroot/api/todo_detail.dspy b/wwwroot/api/todo_detail.dspy index 506ac5f..9607a1e 100644 --- a/wwwroot/api/todo_detail.dspy +++ b/wwwroot/api/todo_detail.dspy @@ -21,11 +21,13 @@ TYPE_LABEL = { 'requirement_confirmation': '需求确认', 'design_confirmation': '设计确认', 'bug_acceptance': 'Bug 验收', + 'kb_ingest_confirm': '知识库入库建议', } TYPE_COLOR = { 'requirement_confirmation': '#2563eb', 'design_confirmation': '#2563eb', 'bug_acceptance': '#f0a040', + 'kb_ingest_confirm': '#10b981', } @@ -525,6 +527,73 @@ async with DBPools().sqlorContext(dbname) as sor: md.append('未找到该项目的标书文件记录。') md.append('') + elif task_type == 'kb_ingest_confirm': + # PM 建议文件入知识库:展示建议详情 + 文件(打开/下载)+ 批准/驳回 + _sg = None + try: + _fsj = _s(getattr(h, 'form_schema', '')) + if _fsj: + _sg = (_json.loads(_fsj) or {}).get('suggestion_id') or '' + except Exception: + _sg = '' + sgrecs = [] + if _sg: + sgrecs = await sor.sqlExe( + "SELECT kb_id, file_path, file_name, reason, status FROM " + "pipeline_kb_suggestions WHERE id=${i}$", {"i": _sg}) + await sor.sqlExe("COMMIT", {}) + if sgrecs: + sg0 = sgrecs[0] + _fname = _s(getattr(sg0, 'file_name', '')) or '-' + _fpath = _s(getattr(sg0, 'file_path', '')) + _reason = _s(getattr(sg0, 'reason', '')) or '(未填写理由)' + _kbid = _s(getattr(sg0, 'kb_id', '')) + _kbname = _kbid + if _kbid: + krecs = await sor.sqlExe( + "SELECT name FROM rag_knowledge_bases WHERE id=${k}$", {"k": _kbid}) + await sor.sqlExe("COMMIT", {}) + if krecs: + _kbname = _s(getattr(krecs[0], 'name', '')) or _kbid + md.append('## 入库建议') + md.append('') + md.append('- 文件:`' + _fname + '`') + md.append('- 目标知识库:' + _kbname + '(ID: ' + _kbid + ')') + md.append('') + md.append('### PM 给出的理由') + md.append('') + md.append(_reason) + md.append('') + md.append('批准后系统将以项目 owner 身份把该文件上传入库(后台解析,稍后可检索)。') + md.append('') + if _fpath: + _file_rows.append(_file_link_row(_fname, project_id, _fpath)) + else: + md.append('## 入库建议') + md.append('') + md.append('未找到对应的建议记录。') + md.append('') + kbi_url = entire_url("/pipeline-sdlc/api/kb_ingest_decide.dspy") + ok_script = (_post_js(kbi_url, [('suggestion_id', _json.dumps(_sg or '')), + ('human_task_id', _json.dumps(oid)), + ('approve', "'1'")]) + _tail) + no_script = (_read_input_js('kb_ingest_comment') + + _post_js(kbi_url, [('suggestion_id', _json.dumps(_sg or '')), + ('human_task_id', _json.dumps(oid)), + ('approve', "'0'"), ('comment', 'cv')]) + + _tail) + action_widgets.append(_input_box('kb_ingest_comment', '驳回意见(驳回时填写)', '可选:驳回原因')) + action_widgets.append({ + "widgettype": "HBox", + "options": {"width": "100%", "gap": "8px", "padding": "12px 14px", "halign": "right"}, + "subwidgets": [ + _btn('批准入库', 'primary', ok_script, + conform={"title": "批准入库", "message": "确认将该文件上传到目标知识库?", + "conform": {"label": "批准"}, "discard": {"label": "再看看"}}), + _btn('驳回', 'small', no_script) + ] + }) + else: if not desc: md.append('## 待办说明')