feat: LICA 部门独立实例 — 组织隔离与端口/标识改造
派生自 IRIS 实例的 feature/ai-audit-update @ 192c8ee,在同一台机器上独立运行。 隔离机制(开关集中在 app/core/config.py 的 ORG_DEPARTMENT / MATERIAL_CATEGORY_PREFIX): - 登录:sys_user 查询增加 department 条件,非本部门账号一律 401 - 人员列表:服务端钉死部门、忽略客户端传参;删除「异常退回全表」的降级分支 - 物料:groups 与 items 都增加 category LIKE 'LICA/%' 前缀过滤 - 人员操作统计:把硬编码的 department='IRIS' 改为配置项 物料为什么用前缀而不是 LIKE '%LICA%': MOM 里存在 171 条 IRIS/成品/LICA/...(无人机/野外便携/高塔监测等), 模糊匹配会把这些 IRIS 物料漏给 LICA。实测前缀匹配命中 795 条 / 5 个分组。 部署隔离: - 端口 8030/8031/8032,容器名 lica_*,卷 lica_pgdata(与 IRIS 完全独立) - 服务名改为 lica_backend,避免在 projects_default 网络上与 IRIS 的 backend 重名 —— 否则将来任何一方写 http://backend:8000 会随机打到另一个部门 - SECRET_KEY 重新生成:实测两边 token 互不通用(双向 401) 客户端标识(不改会导致两个部门的客户端互相覆盖): - Tauri identifier 改 com.lica.production(否则桌面端互相覆盖安装,且共用 WebView 数据目录会让 track_admin_token 串号) - uni-app appid 改 __UNI__D2F4A19(否则同机 APK 互相覆盖、wgt 热更新串号) - uni-app 地址端口 8011 → 8031(收敛在 utils/config.js 单一来源) - sync-watch.sh 的 DST 指向 LICA 专属 HBuilderX 目录(否则会把源码灌进 IRIS 工程) 排除项:未复制 deploy.sh / deploy_full.sh / docker-compose.prod.yml —— 它们写死了 IRIS 的生产服务器,误跑会覆盖线上系统。
This commit is contained in:
@ -4,6 +4,7 @@ from sqlalchemy import select, func, or_
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.core.config import settings
|
||||
from app.core.lifecycle import normalize_after_sales_step
|
||||
|
||||
|
||||
@ -791,8 +792,8 @@ async def get_user_operations(
|
||||
) -> list[UserOperation]:
|
||||
"""上帝视角 — 统计**全部人员**的操作次数(按时段过滤)。
|
||||
|
||||
返回所有 IRIS 部门人员(该时段无操作的计 0),并追加有操作记录但不在
|
||||
人员清单中的账号(如历史/已离职)。
|
||||
返回本部门(ORG_DEPARTMENT)全部人员(该时段无操作的计 0),并追加有操作
|
||||
记录但不在人员清单中的账号(如历史/已离职)。
|
||||
|
||||
操作口径(均不修改数据库):
|
||||
- 接收: task_logs.action_type='receive'(按操作人)
|
||||
@ -840,20 +841,20 @@ async def get_user_operations(
|
||||
rcd_rows = (await db.execute(rcd_stmt)).all()
|
||||
record_map = {r[0]: r[1] or 0 for r in rcd_rows}
|
||||
|
||||
# ── 3. 获取全部 MOM 用户清单(IRIS 部门)──
|
||||
# ── 3. 获取全部 MOM 用户清单(本部门)──
|
||||
# 部门由 ORG_DEPARTMENT 钉死;刻意不保留「查询失败退回全表」的降级 ——
|
||||
# 那会把另一个部门的人员也列进本部门的统计表。
|
||||
users: list[dict] = []
|
||||
try:
|
||||
dbm = MomSessionLocal()
|
||||
try:
|
||||
rows = dbm.execute(text("""
|
||||
SELECT username, SPLIT_PART(username, '/', 1) AS full_name
|
||||
FROM sys_user WHERE department = 'IRIS'
|
||||
""")).fetchall()
|
||||
except Exception:
|
||||
rows = dbm.execute(text("""
|
||||
SELECT username, SPLIT_PART(username, '/', 1) AS full_name
|
||||
FROM sys_user
|
||||
""")).fetchall()
|
||||
rows = dbm.execute(
|
||||
text("""
|
||||
SELECT username, SPLIT_PART(username, '/', 1) AS full_name
|
||||
FROM sys_user WHERE department = :dept
|
||||
"""),
|
||||
{"dept": settings.ORG_DEPARTMENT},
|
||||
).fetchall()
|
||||
finally:
|
||||
dbm.close()
|
||||
for row in rows:
|
||||
|
||||
Reference in New Issue
Block a user