feat: 2026-07-11 全量更新 - 代办集成+会议室预定+知识迭代修复+UI统一+Bug修复
== 已部署上线 (9项) == - 代办事项真实数据源集成 (企微审批API 8bug修复链) - H5/坐席端 Logo样式统一+绿色背景 - 视频引导页修复 (localStorage key v2) - 坐席端 v9 Vue版本修复 (ElMessage._context) - 截图按钮 v10 修复 (getDisplayMedia user gesture) - 扫码样式恢复+H5扫码登录跳转修复 - H5截图快捷键提示 == 代码完成待部署 (3项) == - 知识迭代3Bug修复 (#8 POST端点/#7 MERGE幂等/#6 过期检查) - 会议室预定-小鱼易联终端 (40文件, 40/40测试通过) - IT资产升级审批推送 (asset_service.py) == 需求文档 (2项) == - 坐席端AI辅助消息框-PRD (4项新功能确认) - 坐席端布局优化建议 v2.0 (7天计划) == 新增文档 == - 日报-2026-07-11.md - 知识迭代Bug修复报告-20260711.md - 会议室预定-部署指南.md - CHANGELOG.md 更新 == 测试 == - test_todo_integration.py: 40/40 - test_meetingroom.py: 40/40 - test_bugfix_ki_suggestions.py: 21/21
This commit is contained in:
@@ -61,11 +61,30 @@ async def get_org_directory(
|
||||
wecom = WecomService(redis_client=redis)
|
||||
try:
|
||||
members = await wecom.get_department_members(1, 1)
|
||||
|
||||
# 获取部门列表,构建 {部门ID: 部门名称} 映射,用于将成员的 department ID 列表
|
||||
# 转换为可读的部门名称(企微 user/list 返回的 department 字段是 ID 列表如 [1,2])
|
||||
dept_map: Dict[int, str] = {}
|
||||
try:
|
||||
departments = await wecom.get_department_list()
|
||||
dept_map = {
|
||||
dept.get("id"): dept.get("name", "")
|
||||
for dept in departments
|
||||
if dept.get("id") is not None
|
||||
}
|
||||
logger.info(f"部门列表获取成功,共 {len(dept_map)} 个部门")
|
||||
except Exception as e:
|
||||
# 获取部门列表失败(权限不足等)时降级:使用原来的 ID 字符串,不阻塞主流程
|
||||
logger.warning(f"获取部门列表失败,降级使用部门ID字符串: {e}")
|
||||
|
||||
directory = [
|
||||
{
|
||||
"employee_id": m.get("userid", ""),
|
||||
"name": m.get("name", "") or "",
|
||||
"department": ",".join(str(d) for d in (m.get("department") or [])),
|
||||
# 优先用部门名映射,映射不到时降级为 ID 字符串
|
||||
"department": ",".join(
|
||||
dept_map.get(d, str(d)) for d in (m.get("department") or [])
|
||||
),
|
||||
}
|
||||
for m in members
|
||||
if m.get("userid")
|
||||
@@ -90,14 +109,36 @@ async def get_org_directory(
|
||||
logger.warning(f"企微通讯录获取失败,降级本地: {err_text}")
|
||||
|
||||
# 3. 降级:本地 employees 表(仅登录过的员工)
|
||||
# 注意:department 字段存储的是部门ID JSON数组(如 "[1,2]"),降级时无法解析为部门名;
|
||||
# 但在 DEV_MODE 下可直接存部门名(如 "研发一部"),使组织架构树在本地开发时也有数据
|
||||
try:
|
||||
result = await db.execute(
|
||||
select(Employee.employee_id, Employee.name).where(Employee.employee_id != "")
|
||||
select(Employee.employee_id, Employee.name, Employee.department).where(Employee.employee_id != "")
|
||||
)
|
||||
rows = result.all()
|
||||
directory = [
|
||||
{"employee_id": r[0], "name": r[1] or "", "department": ""} for r in rows
|
||||
]
|
||||
directory = []
|
||||
for r in rows:
|
||||
dept_raw = r[2] or ""
|
||||
# 尝试解析 JSON 数组格式(生产环境企微返回的是部门ID列表如 "[1,2]")
|
||||
# 如果不是 JSON 格式(DEV_MODE 下直接存部门名),则原样使用
|
||||
dept_name = ""
|
||||
if dept_raw:
|
||||
try:
|
||||
import json as _json
|
||||
parsed = _json.loads(dept_raw)
|
||||
if isinstance(parsed, list) and parsed:
|
||||
# 部门ID列表:取第一个ID(降级时无法解析ID为名称,留空)
|
||||
dept_name = ""
|
||||
else:
|
||||
dept_name = str(parsed)
|
||||
except (ValueError, TypeError):
|
||||
# 不是 JSON 格式,直接作为部门名使用(DEV_MODE 场景)
|
||||
dept_name = dept_raw
|
||||
directory.append({
|
||||
"employee_id": r[0],
|
||||
"name": r[1] or "",
|
||||
"department": dept_name,
|
||||
})
|
||||
logger.info(f"组织目录降级到本地 employees 表,共 {len(directory)} 人")
|
||||
return directory, False
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user