hahagahaha

This commit is contained in:
27942
2026-01-27 01:23:50 +08:00
parent a84da888ce
commit 34286a4d5b

View File

@@ -68,16 +68,31 @@ def get_finance_personincharge_candidates():
"""
获取财务部抄送的负责人标识列表优先使用部门ID其次回退字符串“财务”。
返回按优先级去重的字符串列表,便于 personincharge 匹配和查询。
返回值优先级:
1. 财务部门ID如果数据库中存在财务部门
2. "财务" 字符串(兼容历史数据)
3. "财务部" 字符串(兼容历史数据)
"""
import logging
logger = logging.getLogger(__name__)
candidates = []
try:
finance_dept_ids = Department.objects.filter(
# 查询数据库获取财务部门ID部门名称包含"财务"的部门)
finance_depts = Department.objects.filter(
is_deleted=False,
username__icontains="财务"
).values_list("id", flat=True)
candidates.extend([str(dept_id) for dept_id in finance_dept_ids])
except Exception:
pass
).values_list("id", "username")
for dept_id, dept_name in finance_depts:
candidates.append(str(dept_id))
logger.debug(f"get_finance_personincharge_candidates: 找到财务部门 ID={dept_id}, 名称={dept_name}")
if not candidates:
logger.warning("get_finance_personincharge_candidates: 数据库中未找到财务部门,将使用回退字符串")
except Exception as e:
logger.error(f"get_finance_personincharge_candidates: 查询财务部门失败: {e}")
# 回退保留原有字符串标识,兼容历史数据(包括"财务"和"财务部"两种格式)
candidates.append("财务")
@@ -93,13 +108,30 @@ def get_finance_personincharge_candidates():
if item_str not in seen:
uniq.append(item_str)
seen.add(item_str)
logger.debug(f"get_finance_personincharge_candidates: 返回候选列表={uniq}")
return uniq
def get_finance_personincharge_value():
"""获取优先的财务抄送标识(用于写入 personincharge"""
"""
获取优先的财务抄送标识(用于写入 personincharge 字段)。
返回值:
- 优先返回财务部门ID字符串形式
- 如果数据库中没有财务部门,回退到 "财务" 字符串
"""
import logging
logger = logging.getLogger(__name__)
candidates = get_finance_personincharge_candidates()
return candidates[0] if candidates else "财务"
result = candidates[0] if candidates else "财务"
# 判断返回值是否为部门ID纯数字字符串
is_dept_id = result.isdigit()
logger.info(f"get_finance_personincharge_value: 返回值={result}, 是否为部门ID={is_dept_id}")
return result
def get_law_firm_leader(team_name=None):