Merge branch 'dev' of https://gitee.com/justop/hxops into dev
This commit is contained in:
commit
ac04409e79
12 files changed
+292
-76
No files matched your search
+12
-1
@@ -58,7 +58,7 @@ HR_SQLSERVER_PORT=1433
|
||||
HR_SQLSERVER_DATABASE=NH_N8_HEXIN
|
||||
HR_SQLSERVER_USERNAME=AI_Knowledge_Base_Hr
|
||||
HR_SQLSERVER_PASSWORD=hoo-thai@123_AI_HR
|
||||
HR_SQLSERVER_DRIVER=SQL Server
|
||||
HR_SQLSERVER_DRIVER=ODBC Driver 18 for SQL Server
|
||||
HR_SQLSERVER_ENCRYPT=no
|
||||
HR_SQLSERVER_TRUST_CERT=yes
|
||||
HR_SQLSERVER_TIMEOUT=10
|
||||
@@ -70,3 +70,14 @@ PLM_ORACLE_SID=orcl
|
||||
PLM_ORACLE_USERNAME=PLM
|
||||
PLM_ORACLE_PASSWORD=PLM
|
||||
ORACLE_CLIENT_LIB_DIR=oracle_client\instantclient_19_30
|
||||
|
||||
# SRM SQL Server Configuration
|
||||
SRM_SQLSERVER_HOST=192.168.55.106
|
||||
SRM_SQLSERVER_PORT=1433
|
||||
SRM_SQLSERVER_DATABASE=HX-SRM
|
||||
SRM_SQLSERVER_USERNAME=sa
|
||||
SRM_SQLSERVER_PASSWORD=sa@moreyou456
|
||||
SRM_SQLSERVER_DRIVER=SQL Server
|
||||
SRM_SQLSERVER_ENCRYPT=no
|
||||
SRM_SQLSERVER_TRUST_CERT=yes
|
||||
SRM_SQLSERVER_TIMEOUT=10
|
||||
@@ -69,6 +69,20 @@ def delete_schedule(task_id: int):
|
||||
task = db.session.get(ScheduleTask, task_id)
|
||||
if not task:
|
||||
return jsonify({'error': 'Not found'}), 404
|
||||
|
||||
from app.services.schedule.scheduler_service import request_cancel_run
|
||||
running_runs = db.session.query(ScheduleRun).filter(
|
||||
ScheduleRun.schedule_task_id == task_id,
|
||||
ScheduleRun.status == "running",
|
||||
).all()
|
||||
for rr in running_runs:
|
||||
request_cancel_run(rr.id)
|
||||
rr.status = "failed"
|
||||
rr.error_message = "排程已被删除,执行中断"
|
||||
rr.finished_at = datetime.utcnow()
|
||||
if running_runs:
|
||||
db.session.commit()
|
||||
|
||||
runs = db.session.query(ScheduleRun).filter(ScheduleRun.schedule_task_id == task_id).all()
|
||||
for r in runs:
|
||||
if r.excel_file_path:
|
||||
@@ -122,6 +136,13 @@ def run_schedule(task_id: int):
|
||||
return jsonify({'error': 'Not found'}), 404
|
||||
user = get_current_user()
|
||||
|
||||
existing = db.session.query(ScheduleRun).filter(
|
||||
ScheduleRun.schedule_task_id == task.id,
|
||||
ScheduleRun.status == "running",
|
||||
).first()
|
||||
if existing:
|
||||
return jsonify({'error': '该排程正在执行中,请等待完成后再试', 'run_id': existing.id}), 409
|
||||
|
||||
run = ScheduleRun(
|
||||
run_no=_generate_run_no(),
|
||||
schedule_task_id=task.id,
|
||||
|
||||
@@ -182,8 +182,9 @@ class DifyService:
|
||||
result = evt.get("data") or {}
|
||||
if current_app:
|
||||
current_app.logger.info(
|
||||
"[workflow-streaming] finished status=%s",
|
||||
"[workflow-streaming] finished status=%s error=%s",
|
||||
result.get("status"),
|
||||
result.get("error"),
|
||||
)
|
||||
|
||||
elif event_type == "error":
|
||||
|
||||
@@ -10,7 +10,7 @@ from app import db
|
||||
from app.models import Agent, ScheduleRun, ScheduleTask
|
||||
from app.services.schedule.srm_service import run_rohs_doc_check_dify_job
|
||||
|
||||
ScheduleExecuteResult = tuple[int, int, int, list[dict[str, Any]], list[str]]
|
||||
ScheduleExecuteResult = tuple[int, int, int, int, list[dict[str, Any]], list[str]]
|
||||
ScheduleExecutor = Callable[[ScheduleTask, ScheduleRun], ScheduleExecuteResult]
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ def _run_common_executor(task: ScheduleTask, run: ScheduleRun) -> ScheduleExecut
|
||||
total = int(summary.get("total_count") if summary.get("total_count") is not None else (len(details) or 1))
|
||||
success = int(summary.get("success_count") if summary.get("success_count") is not None else total)
|
||||
failed = int(summary.get("failed_count") if summary.get("failed_count") is not None else max(0, total - success))
|
||||
return total, success, failed, details, [str(e) for e in errors if str(e).strip()]
|
||||
return total, success, failed, 0, details, [str(e) for e in errors if str(e).strip()]
|
||||
|
||||
|
||||
def _run_srm_rohs_doc_check_executor(task: ScheduleTask, run: ScheduleRun) -> ScheduleExecuteResult:
|
||||
@@ -107,6 +107,7 @@ def _run_srm_rohs_doc_check_executor(task: ScheduleTask, run: ScheduleRun) -> Sc
|
||||
agent=agent,
|
||||
user=str(getattr(task.owner, "username", "") or task.owner_user_id or "schedule_system"),
|
||||
wait_seconds=task.wait_seconds or 120,
|
||||
run_id=run.id,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from openpyxl import Workbook
|
||||
|
||||
|
||||
def _flatten_value(v: Any) -> Any:
|
||||
if isinstance(v, (dict, list)):
|
||||
return json.dumps(v, ensure_ascii=False)
|
||||
return v
|
||||
|
||||
|
||||
def export_schedule_result_excel(*, run_no: str, summary: dict, details: list[dict], root_dir: str) -> tuple[str | None, str | None, int]:
|
||||
if not details:
|
||||
return None, None, 0
|
||||
@@ -18,8 +25,8 @@ def export_schedule_result_excel(*, run_no: str, summary: dict, details: list[di
|
||||
output = row.get('dify_output')
|
||||
if not isinstance(output, dict):
|
||||
output = {}
|
||||
entry = dict(output)
|
||||
for k in ('writeback_ok', 'error'):
|
||||
entry = {k: _flatten_value(v) for k, v in output.items()}
|
||||
for k in ('writeback_ok', 'error', 'judgement', 'reason'):
|
||||
if k in row:
|
||||
entry[k] = row[k]
|
||||
rows.append(entry)
|
||||
|
||||
@@ -17,6 +17,23 @@ from app.services.schedule.mail_service import build_schedule_mail_html, send_sc
|
||||
|
||||
_worker_started = False
|
||||
_worker_lock = threading.Lock()
|
||||
_cancelled_runs: set[int] = set()
|
||||
_cancel_lock = threading.Lock()
|
||||
|
||||
|
||||
def request_cancel_run(run_id: int) -> None:
|
||||
with _cancel_lock:
|
||||
_cancelled_runs.add(run_id)
|
||||
|
||||
|
||||
def is_run_cancelled(run_id: int) -> bool:
|
||||
with _cancel_lock:
|
||||
return run_id in _cancelled_runs
|
||||
|
||||
|
||||
def clear_cancelled_run(run_id: int) -> None:
|
||||
with _cancel_lock:
|
||||
_cancelled_runs.discard(run_id)
|
||||
|
||||
|
||||
def _generate_schedule_no() -> str:
|
||||
@@ -108,6 +125,12 @@ def update_task(task: ScheduleTask, *, payload: dict[str, Any], actor_id: int |
|
||||
|
||||
def run_task_now(task: ScheduleTask, *, trigger_type: str, triggered_by_user_id: int | None, run: ScheduleRun | None = None) -> ScheduleRun:
|
||||
if run is None:
|
||||
existing = db.session.query(ScheduleRun).filter(
|
||||
ScheduleRun.schedule_task_id == task.id,
|
||||
ScheduleRun.status == "running",
|
||||
).first()
|
||||
if existing:
|
||||
return existing
|
||||
run = ScheduleRun(
|
||||
run_no=_generate_run_no(),
|
||||
schedule_task_id=task.id,
|
||||
@@ -119,22 +142,47 @@ def run_task_now(task: ScheduleTask, *, trigger_type: str, triggered_by_user_id:
|
||||
db.session.add(run)
|
||||
db.session.commit()
|
||||
|
||||
if task.cron_expr and trigger_type == "cron":
|
||||
try:
|
||||
iter = croniter(task.cron_expr, datetime.utcnow())
|
||||
task.next_run_at = iter.get_next(datetime)
|
||||
except Exception:
|
||||
task.next_run_at = None
|
||||
db.session.commit()
|
||||
|
||||
start_ts = time.time()
|
||||
try:
|
||||
executor = resolve_schedule_executor(task)
|
||||
total_count, success_count, failed_count, details, errors = executor(task, run)
|
||||
total_count, success_count, failed_count, skipped_count, details, errors = executor(task, run)
|
||||
except Exception as exc:
|
||||
total_count, success_count, failed_count, skipped_count, details, errors = 0, 0, 0, 0, [], [str(exc)]
|
||||
|
||||
duration_ms = int((time.time() - start_ts) * 1000)
|
||||
if total_count == 0 and not errors:
|
||||
status = "success"
|
||||
run.error_message = "无待处理数据"
|
||||
elif failed_count == 0:
|
||||
status = "success"
|
||||
elif success_count == 0:
|
||||
status = "failed"
|
||||
else:
|
||||
status = "partial_failed"
|
||||
if is_run_cancelled(run.id):
|
||||
run.finished_at = datetime.utcnow()
|
||||
run.duration_ms = int((time.time() - start_ts) * 1000)
|
||||
run.status = "failed"
|
||||
run.error_message = "排程已被删除,执行中断"
|
||||
db.session.commit()
|
||||
clear_cancelled_run(run.id)
|
||||
return run
|
||||
|
||||
duration_ms = int((time.time() - start_ts) * 1000)
|
||||
if current_app:
|
||||
current_app.logger.info(
|
||||
"[schedule-run] run_no=%s total=%d success=%d failed=%d skipped=%d errors=%d",
|
||||
run.run_no, total_count, success_count, failed_count, skipped_count, len(errors),
|
||||
)
|
||||
if total_count == 0 and not errors:
|
||||
status = "success"
|
||||
run.error_message = "无待处理数据"
|
||||
elif failed_count == 0:
|
||||
status = "success"
|
||||
elif success_count == 0:
|
||||
status = "failed"
|
||||
else:
|
||||
status = "partial_failed"
|
||||
|
||||
try:
|
||||
file_path, file_name, file_size = export_schedule_result_excel(
|
||||
run_no=run.run_no,
|
||||
summary={
|
||||
@@ -147,24 +195,30 @@ def run_task_now(task: ScheduleTask, *, trigger_type: str, triggered_by_user_id:
|
||||
details=details,
|
||||
root_dir=str(current_app.config.get("SCHEDULE_EXCEL_STORAGE_ROOT") or "").strip(),
|
||||
)
|
||||
except Exception as excel_exc:
|
||||
if current_app:
|
||||
current_app.logger.error("[schedule-run] excel export failed: %s", excel_exc)
|
||||
file_path, file_name, file_size = None, None, 0
|
||||
errors.append(f"Excel导出失败: {excel_exc}")
|
||||
|
||||
run.finished_at = datetime.utcnow()
|
||||
run.duration_ms = duration_ms
|
||||
run.status = status
|
||||
run.total_count = total_count
|
||||
run.success_count = success_count
|
||||
run.failed_count = failed_count
|
||||
run.skipped_count = 0
|
||||
run.response_summary_json = {
|
||||
"errors": errors[:20],
|
||||
"schedule_type": task.schedule_type,
|
||||
"platform_api_path": task.platform_api_path,
|
||||
}
|
||||
run.error_message = "; ".join(errors[:3]) if errors else None
|
||||
run.excel_file_path = file_path
|
||||
run.excel_file_name = file_name
|
||||
run.excel_file_size = file_size or 0
|
||||
run.finished_at = datetime.utcnow()
|
||||
run.duration_ms = duration_ms
|
||||
run.status = status
|
||||
run.total_count = total_count
|
||||
run.success_count = success_count
|
||||
run.failed_count = failed_count
|
||||
run.skipped_count = skipped_count
|
||||
run.response_summary_json = {
|
||||
"errors": errors[:20],
|
||||
"schedule_type": task.schedule_type,
|
||||
"platform_api_path": task.platform_api_path,
|
||||
}
|
||||
run.error_message = "; ".join(errors[:3]) if errors else None
|
||||
run.excel_file_path = file_path
|
||||
run.excel_file_name = file_name
|
||||
run.excel_file_size = file_size or 0
|
||||
|
||||
try:
|
||||
if task.notify_enabled:
|
||||
users = db.session.query(User).filter(User.id.in_(task.notify_user_ids_json or [])).all()
|
||||
to_addrs = [u.email for u in users if u.email]
|
||||
@@ -193,17 +247,13 @@ def run_task_now(task: ScheduleTask, *, trigger_type: str, triggered_by_user_id:
|
||||
except Exception as mail_exc:
|
||||
run.mail_sent = False
|
||||
run.mail_error = str(mail_exc)
|
||||
except Exception as mail_exc:
|
||||
if current_app:
|
||||
current_app.logger.error("[schedule-run] mail send failed: %s", mail_exc)
|
||||
|
||||
task.last_run_at = datetime.utcnow()
|
||||
db.session.commit()
|
||||
return run
|
||||
except Exception as exc:
|
||||
run.finished_at = datetime.utcnow()
|
||||
run.duration_ms = int((time.time() - start_ts) * 1000)
|
||||
run.status = "failed"
|
||||
run.error_message = str(exc)
|
||||
db.session.commit()
|
||||
return run
|
||||
task.last_run_at = datetime.utcnow()
|
||||
db.session.commit()
|
||||
return run
|
||||
|
||||
|
||||
def start_scheduler(app):
|
||||
@@ -216,8 +266,45 @@ def start_scheduler(app):
|
||||
if not bool(app.config.get("SCHEDULE_WORKER_ENABLED", True)):
|
||||
return
|
||||
|
||||
import os
|
||||
if os.environ.get('WERKZEUG_RUN_MAIN') == 'true' or not app.debug:
|
||||
pass
|
||||
else:
|
||||
_worker_started = False
|
||||
return
|
||||
|
||||
def _loop():
|
||||
with app.app_context():
|
||||
stale = db.session.query(ScheduleTask).filter(
|
||||
ScheduleTask.enabled.is_(True),
|
||||
ScheduleTask.next_run_at.isnot(None),
|
||||
ScheduleTask.next_run_at <= datetime.utcnow(),
|
||||
).all()
|
||||
for t in stale:
|
||||
if t.cron_expr:
|
||||
try:
|
||||
it = croniter(t.cron_expr, datetime.utcnow())
|
||||
t.next_run_at = it.get_next(datetime)
|
||||
except Exception:
|
||||
t.next_run_at = None
|
||||
t.enabled = False
|
||||
else:
|
||||
t.next_run_at = None
|
||||
if stale:
|
||||
db.session.commit()
|
||||
current_app.logger.info("[schedule-worker] reset %d stale next_run_at on startup", len(stale))
|
||||
|
||||
stuck = db.session.query(ScheduleRun).filter(
|
||||
ScheduleRun.status == "running",
|
||||
).all()
|
||||
for r in stuck:
|
||||
r.status = "failed"
|
||||
r.error_message = "服务重启,执行中断"
|
||||
r.finished_at = datetime.utcnow()
|
||||
if stuck:
|
||||
db.session.commit()
|
||||
current_app.logger.info("[schedule-worker] cleaned %d stuck running runs on startup", len(stuck))
|
||||
|
||||
while True:
|
||||
try:
|
||||
now = datetime.utcnow()
|
||||
@@ -225,8 +312,21 @@ def start_scheduler(app):
|
||||
ScheduleTask.enabled.is_(True),
|
||||
ScheduleTask.next_run_at.isnot(None),
|
||||
ScheduleTask.next_run_at <= now,
|
||||
).limit(5).all()
|
||||
).limit(5).with_for_update(skip_locked=True).all()
|
||||
for task in due_tasks:
|
||||
has_running = db.session.query(ScheduleRun).filter(
|
||||
ScheduleRun.schedule_task_id == task.id,
|
||||
ScheduleRun.status == "running",
|
||||
).first()
|
||||
if has_running:
|
||||
if task.cron_expr:
|
||||
try:
|
||||
iter = croniter(task.cron_expr, datetime.utcnow())
|
||||
task.next_run_at = iter.get_next(datetime)
|
||||
except Exception:
|
||||
task.next_run_at = None
|
||||
db.session.commit()
|
||||
continue
|
||||
try:
|
||||
run_task_now(task, trigger_type="cron", triggered_by_user_id=None)
|
||||
except Exception as e:
|
||||
|
||||
@@ -88,7 +88,7 @@ def _derive_judgement_and_reason(data: dict[str, Any]) -> tuple[str, str]:
|
||||
return judgement, reason
|
||||
|
||||
|
||||
def run_rohs_doc_check_dify_job(*, conn_str: str, run_no: str, agent=None, user: str = "schedule_system", wait_seconds: int = 120) -> tuple[int, int, int, list[dict[str, Any]], list[str]]:
|
||||
def run_rohs_doc_check_dify_job(*, conn_str: str, run_no: str, agent=None, user: str = "schedule_system", wait_seconds: int = 120, run_id: int | None = None) -> tuple[int, int, int, int, list[dict[str, Any]], list[str]]:
|
||||
use_dify = agent is not None
|
||||
if use_dify and not getattr(agent, "dify_api_key", None):
|
||||
raise RuntimeError("dify_agent_id is set, but Dify api key is missing")
|
||||
@@ -98,10 +98,19 @@ def run_rohs_doc_check_dify_job(*, conn_str: str, run_no: str, agent=None, user:
|
||||
details: list[dict[str, Any]] = []
|
||||
success_count = 0
|
||||
failed_count = 0
|
||||
skipped_count = 0
|
||||
errors: list[str] = []
|
||||
|
||||
for row in rows:
|
||||
from app.services.schedule.scheduler_service import is_run_cancelled
|
||||
for idx, row in enumerate(rows):
|
||||
if run_id is not None and is_run_cancelled(run_id):
|
||||
item = dict(row)
|
||||
item.update({"judgement": "人工判定", "reason": "排程已被删除,执行中断", "writeback_ok": False, "error": "排程已被删除,执行中断"})
|
||||
skipped_count += 1
|
||||
details.append(item)
|
||||
continue
|
||||
item = dict(row)
|
||||
dify_ok = False
|
||||
try:
|
||||
if use_dify:
|
||||
dify_res = DifyService.run_workflow_streaming(
|
||||
@@ -110,18 +119,30 @@ def run_rohs_doc_check_dify_job(*, conn_str: str, run_no: str, agent=None, user:
|
||||
user=user,
|
||||
timeout=(5, max(300, int(wait_seconds))),
|
||||
)
|
||||
outputs = (dify_res.get("outputs") or {}).get("output") or dify_res.get("outputs") or dify_res
|
||||
if current_app:
|
||||
current_app.logger.info(
|
||||
"[srm-dify] judgement=%s reason=%s",
|
||||
outputs.get("judgement") if isinstance(outputs, dict) else None,
|
||||
outputs.get("reason") if isinstance(outputs, dict) else None,
|
||||
)
|
||||
judgement, reason = _derive_judgement_and_reason(outputs if isinstance(outputs, dict) else {})
|
||||
item["dify_output"] = outputs if isinstance(outputs, dict) else {}
|
||||
dify_status = dify_res.get("status") if isinstance(dify_res, dict) else None
|
||||
dify_error = dify_res.get("error") if isinstance(dify_res, dict) else None
|
||||
if dify_status == "failed" or (dify_error and not dify_res.get("outputs")):
|
||||
err_detail = str(dify_error) if dify_error else f"Dify status={dify_status}"
|
||||
judgement = "人工判定"
|
||||
reason = f"Dify执行失败:{err_detail}"
|
||||
item.update({"judgement": judgement, "reason": reason, "writeback_ok": False, "error": err_detail, "dify_output": dify_res if isinstance(dify_res, dict) else {}})
|
||||
failed_count += 1
|
||||
errors.append(f"Dify row_id={row.get('id')}: {err_detail}")
|
||||
else:
|
||||
outputs = (dify_res.get("outputs") or {}).get("output") or dify_res.get("outputs") or dify_res
|
||||
if current_app:
|
||||
current_app.logger.info(
|
||||
"[srm-dify] judgement=%s reason=%s",
|
||||
outputs.get("judgement") if isinstance(outputs, dict) else None,
|
||||
outputs.get("reason") if isinstance(outputs, dict) else None,
|
||||
)
|
||||
judgement, reason = _derive_judgement_and_reason(outputs if isinstance(outputs, dict) else {})
|
||||
item["dify_output"] = outputs if isinstance(outputs, dict) else {}
|
||||
dify_ok = True
|
||||
else:
|
||||
judgement = "人工判定"
|
||||
reason = "未配置 Agent ID,跳过 Dify"
|
||||
dify_ok = True
|
||||
|
||||
try:
|
||||
writeback_rohs(
|
||||
@@ -131,18 +152,35 @@ def run_rohs_doc_check_dify_job(*, conn_str: str, run_no: str, agent=None, user:
|
||||
judgement=judgement,
|
||||
reason=reason,
|
||||
)
|
||||
item.update({"judgement": judgement, "reason": reason, "writeback_ok": True, "error": None})
|
||||
success_count += 1
|
||||
item.update({"judgement": judgement, "reason": reason, "writeback_ok": True, "error": item.get("error")})
|
||||
if dify_ok:
|
||||
success_count += 1
|
||||
except Exception as wb_exc:
|
||||
if current_app:
|
||||
current_app.logger.error("[srm-dify] writeback failed row_id=%s error=%s", row.get("id"), wb_exc)
|
||||
item.update({"judgement": judgement, "reason": reason, "writeback_ok": False, "error": str(wb_exc)})
|
||||
failed_count += 1
|
||||
if dify_ok:
|
||||
failed_count += 1
|
||||
errors.append(f"writeback row_id={row.get('id')}: {wb_exc}")
|
||||
except Exception as exc:
|
||||
item.update({"judgement": "人工判定", "reason": f"执行异常:{exc}", "writeback_ok": False, "error": str(exc)})
|
||||
judgement = "人工判定"
|
||||
reason = f"执行异常:{exc}"
|
||||
item.update({"judgement": judgement, "reason": reason, "writeback_ok": False, "error": str(exc)})
|
||||
failed_count += 1
|
||||
errors.append(str(exc))
|
||||
try:
|
||||
writeback_rohs(
|
||||
conn_str,
|
||||
row_id=str(row.get("id")),
|
||||
run_no=run_no,
|
||||
judgement=judgement,
|
||||
reason=reason,
|
||||
)
|
||||
item["writeback_ok"] = True
|
||||
except Exception as wb_exc:
|
||||
item["writeback_ok"] = False
|
||||
item["error"] = f"{item.get('error', '')}; writeback failed: {wb_exc}"
|
||||
details.append(item)
|
||||
|
||||
return total_count, success_count, failed_count, details, errors
|
||||
total_count = success_count + failed_count + skipped_count
|
||||
return total_count, success_count, failed_count, skipped_count, details, errors
|
||||
@@ -0,0 +1,24 @@
|
||||
"""merge chatlog and schedule heads
|
||||
|
||||
Revision ID: c0ae052bd24e
|
||||
Revises: 1ebc0253f9f6, f6d4e5f6a7b8
|
||||
Create Date: 2026-05-18 16:32:50.696073
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c0ae052bd24e'
|
||||
down_revision = ('1ebc0253f9f6', 'f6d4e5f6a7b8')
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
pass
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
Vendored
+5
-6
@@ -10,13 +10,12 @@
|
||||
<meta name="apple-mobile-web-app-title" content="AI工作台" />
|
||||
<link rel="manifest" href="/manifest.webmanifest" />
|
||||
<title>AI工作台</title>
|
||||
<<<<<<< Updated upstream
|
||||
<script type="module" crossorigin src="/assets/index-grYi-CaK.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DvLiupE9.css">
|
||||
<<<<<<< HEAD
|
||||
<script type="module" crossorigin src="/assets/index-CSfNFoqX.js"></script>
|
||||
=======
|
||||
<script type="module" crossorigin src="/assets/index-DOCtY95c.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-BL1tdy0j.css">
|
||||
>>>>>>> Stashed changes
|
||||
<script type="module" crossorigin src="/assets/index-B0LSqDmY.js"></script>
|
||||
>>>>>>> dev
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-XvG2TD5m.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>␍
|
||||
|
||||
@@ -34,7 +34,7 @@ export interface ScheduleRun {
|
||||
total_count: number;
|
||||
success_count: number;
|
||||
failed_count: number;
|
||||
skipped_count: number;
|
||||
|
||||
api_request_json?: Record<string, any> | null;
|
||||
api_response_json?: Record<string, any> | null;
|
||||
response_summary_json?: Record<string, any> | null;
|
||||
|
||||
@@ -20,7 +20,7 @@ import { loadReportLayoutPref, saveReportLayoutPref } from '../composables/useRe
|
||||
import { useGlobalMessageDialog } from '../composables/useGlobalMessageDialog';
|
||||
import { buildWecomAuditMeta, formatWecomAuditReason } from '../utils/wecom';
|
||||
import { getAuthHeaders } from '../utils/auth';
|
||||
import { listAdminSchedules, createAdminSchedule, updateAdminSchedule, deleteAdminSchedule, toggleAdminSchedule, runAdminSchedule, listAdminScheduleRuns, adminRunExcelUrl, type ScheduleTask, type ScheduleRun } from '../api/schedule';
|
||||
import { listAdminSchedules, createAdminSchedule, updateAdminSchedule, deleteAdminSchedule, toggleAdminSchedule, runAdminSchedule, listAdminScheduleRuns, type ScheduleTask, type ScheduleRun } from '../api/schedule';
|
||||
import {
|
||||
ArrowLeft,
|
||||
// Save,
|
||||
@@ -62,12 +62,12 @@ const sidebarItems = computed(() => {
|
||||
{ id: 'users', icon: UserCog, label: t('admin.nav.users') },
|
||||
{ id: 'departments', icon: Building, label: t('admin.nav.departments') },
|
||||
{ id: 'agents', icon: Bot, label: t('admin.nav.agents') },
|
||||
{ id: 'schedules', icon: Settings2, label: '排程管理' },
|
||||
{ id: 'announcements', icon: Megaphone, label: t('admin.nav.announcements') },
|
||||
{ id: 'questions', icon: MessageCircleQuestion, label: t('admin.nav.questions') },
|
||||
{ id: 'wecom', icon: Link2, label: t('admin.nav.wecom') },
|
||||
{ id: 'permissions', icon: Users, label: t('admin.nav.permissions') },
|
||||
{ id: 'requests', icon: ShieldCheck, label: t('admin.nav.requests'), badge: permissionRequests.value.filter(r => r.status === 'pending').length },
|
||||
{ id: 'schedules', icon: Settings2, label: '排程管理' },
|
||||
];
|
||||
|
||||
return items.filter(item => {
|
||||
@@ -489,11 +489,11 @@ const scheduleNextRunPreview = computed(() => {
|
||||
const parts = expr.trim().split(/\s+/);
|
||||
if (parts.length !== 5) return null;
|
||||
const now = new Date();
|
||||
const minuteRaw = parts[0];
|
||||
const hourRaw = parts[1];
|
||||
const dayOfMonth = parts[2];
|
||||
const month = parts[3];
|
||||
const dayOfWeek = parts[4];
|
||||
const minuteRaw = parts[0]!;
|
||||
const hourRaw = parts[1]!;
|
||||
const dayOfMonth = parts[2]!;
|
||||
const month = parts[3]!;
|
||||
const dayOfWeek = parts[4]!;
|
||||
if (month !== '*') return null;
|
||||
if (dayOfMonth !== '*' && dayOfWeek !== '*') return null;
|
||||
const minute = minuteRaw.startsWith('*/') ? undefined : parseInt(minuteRaw, 10);
|
||||
@@ -800,7 +800,12 @@ const backToScheduleOverview = () => {
|
||||
};
|
||||
|
||||
const runScheduleNow = async (taskId: number) => {
|
||||
await runAdminSchedule(taskId);
|
||||
const res = await runAdminSchedule(taskId);
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}));
|
||||
showMessageDialog('error', data?.error || '手动执行失败');
|
||||
return;
|
||||
}
|
||||
await viewScheduleRuns(taskId);
|
||||
await loadSchedules();
|
||||
|
||||
@@ -4155,12 +4160,19 @@ const handlePermissionImport = async (event: Event) => {
|
||||
:class="getScheduleRunStatusBadge(r.status).cls">
|
||||
{{ getScheduleRunStatusBadge(r.status).label }}
|
||||
</span>
|
||||
<span v-if="r.error_message" class="ml-1 text-xs text-slate-400" :title="r.error_message">...</span>
|
||||
</td>
|
||||
<td class="px-4 py-3">{{ r.total_count }}</td>
|
||||
<td class="px-4 py-3">{{ r.success_count }}</td>
|
||||
<td class="px-4 py-3">{{ r.failed_count }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<a v-if="r.total_count > 0" class="cursor-pointer text-brand-600 hover:text-brand-700 hover:underline" @click.prevent="downloadScheduleExcel(r.id)">
|
||||
<a
|
||||
v-if="r.total_count > 0"
|
||||
href="#"
|
||||
@click.prevent="downloadScheduleExcel(r.id)"
|
||||
class="inline-flex items-center gap-1 rounded-lg border border-slate-200 px-2 py-1 text-xs font-medium text-slate-600 transition-colors hover:bg-slate-50"
|
||||
>
|
||||
<Download class="h-3 w-3" />
|
||||
下载
|
||||
</a>
|
||||
<span v-else class="text-slate-300">-</span>
|
||||
|
||||
@@ -1793,6 +1793,7 @@ onMounted(async () => {
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">处理笔数</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">成功笔数</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">失败笔数</th>
|
||||
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600">明细</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -1814,6 +1815,7 @@ onMounted(async () => {
|
||||
<td class="px-4 py-3 text-slate-500">{{ r.total_count || 0 }}</td>
|
||||
<td class="px-4 py-3 text-emerald-600 font-medium">{{ r.success_count ?? 0 }}</td>
|
||||
<td class="px-4 py-3 text-rose-600 font-medium">{{ r.failed_count ?? 0 }}</td>
|
||||
|
||||
<td class="px-4 py-3">
|
||||
<a
|
||||
v-if="r.total_count > 0 && r.excel_file_name"
|
||||
|
||||
Reference in new issue
Block a user