|
|
@@ -417,7 +417,8 @@ QUERY_FLOW_NODES = """
|
|
|
ai.ASSIGNEE_ AS assignee,
|
|
|
u.account AS assignee_account,
|
|
|
u.real_name AS assignee_name,
|
|
|
- d.full_name AS org_name,
|
|
|
+ u.dept_id AS assignee_dept_id,
|
|
|
+ d.dept_name AS org_name,
|
|
|
(SELECT v.TEXT_
|
|
|
FROM ACT_HI_VARINST v
|
|
|
WHERE v.TASK_ID_ = ai.TASK_ID_
|
|
|
@@ -431,13 +432,41 @@ QUERY_FLOW_NODES = """
|
|
|
LIMIT 1) AS comment_msg
|
|
|
FROM ACT_HI_ACTINST ai
|
|
|
LEFT JOIN blade_user u ON u.id = ai.ASSIGNEE_ AND u.is_deleted = 0
|
|
|
- LEFT JOIN blade_dept d ON FIND_IN_SET(d.id, u.dept_id) AND d.is_deleted = 0
|
|
|
+ LEFT JOIN blade_dept d ON d.id = CAST(SUBSTRING_INDEX(u.dept_id, ',', 1) AS CHAR)
|
|
|
WHERE ai.PROC_INST_ID_ = %s
|
|
|
AND ai.ACT_TYPE_ = 'userTask'
|
|
|
ORDER BY IFNULL(ai.END_TIME_, NOW()), ai.START_TIME_
|
|
|
"""
|
|
|
|
|
|
|
|
|
+def _resolve_dept_name(cursor, dept_id, cache):
|
|
|
+ """按部门 id 取部门名(对应 dept/list 接口的 deptName,即 dept_name);逐级向上直到找到有效部门。"""
|
|
|
+ dept_id = str(dept_id or '').strip()
|
|
|
+ if not dept_id:
|
|
|
+ return ''
|
|
|
+ if dept_id in cache:
|
|
|
+ return cache[dept_id]
|
|
|
+ name = ''
|
|
|
+ seen = set()
|
|
|
+ current = dept_id
|
|
|
+ while current and current not in seen:
|
|
|
+ seen.add(current)
|
|
|
+ cursor.execute(
|
|
|
+ "SELECT dept_name, full_name, parent_id, is_deleted FROM blade_dept WHERE id = %s LIMIT 1",
|
|
|
+ (current,)
|
|
|
+ )
|
|
|
+ drow = cursor.fetchone()
|
|
|
+ if not drow:
|
|
|
+ break
|
|
|
+ if not drow.get('is_deleted'):
|
|
|
+ name = drow.get('dept_name') or drow.get('full_name') or ''
|
|
|
+ if name:
|
|
|
+ break
|
|
|
+ current = str(drow.get('parent_id') or '').strip() or None
|
|
|
+ cache[dept_id] = name or ''
|
|
|
+ return name or ''
|
|
|
+
|
|
|
+
|
|
|
def fetch_flow_nodes(cursor, flow_process_inst_id):
|
|
|
"""获取计量单审核过程节点列表 (等价于 /api/flow/process/flow/detail 的 flow 数据)。
|
|
|
|
|
|
@@ -459,6 +488,8 @@ def fetch_flow_nodes(cursor, flow_process_inst_id):
|
|
|
cursor.execute(QUERY_FLOW_NODES, (inst_row['proc_inst_id'],))
|
|
|
rows = cursor.fetchall()
|
|
|
|
|
|
+ dept_cache = {}
|
|
|
+
|
|
|
def fmt_time(value):
|
|
|
if not value:
|
|
|
return ''
|
|
|
@@ -480,11 +511,18 @@ def fetch_flow_nodes(cursor, flow_process_inst_id):
|
|
|
except Exception:
|
|
|
comment = ''
|
|
|
|
|
|
+ # 组织机构:优先 SQL 关联结果;为空时按用户主部门逐级向上解析
|
|
|
+ org_name = row.get('org_name')
|
|
|
+ if not org_name:
|
|
|
+ first_dept = str(row.get('assignee_dept_id') or '').split(',')[0].strip()
|
|
|
+ org_name = _resolve_dept_name(cursor, first_dept, dept_cache)
|
|
|
+ org_name = org_name or ARCHIVE_UNIT
|
|
|
+
|
|
|
nodes.append({
|
|
|
'id': row.get('node_id') or '',
|
|
|
'name': row.get('task_name') or '',
|
|
|
'type': '计量支付',
|
|
|
- 'orgName': row.get('org_name') or ARCHIVE_UNIT,
|
|
|
+ 'orgName': org_name,
|
|
|
'operatorId': str(row.get('assignee') or row.get('assignee_account') or ''),
|
|
|
'operatorName': row.get('assignee_name') or '',
|
|
|
'createdTime': fmt_time(row.get('create_time')),
|
|
|
@@ -624,7 +662,8 @@ def build_metadata_entities(order_data, file_id):
|
|
|
tabulator_org,
|
|
|
tabulation_date,
|
|
|
'制表',
|
|
|
- f"{tabulator_name or ''}文件制表提交".strip(),
|
|
|
+ f"制表;{tabulator_name or ''}文件制表提交;制表时间:{format_datetime(tabulation_date)}".strip(';'),
|
|
|
+ '计量支付',
|
|
|
business_id=stable_guid(f"{file_id}:tabulator")
|
|
|
)
|
|
|
|
|
|
@@ -632,9 +671,18 @@ def build_metadata_entities(order_data, file_id):
|
|
|
operator_id = node.get('operatorId') or node.get('assignee')
|
|
|
operator_name = node.get('operatorName')
|
|
|
org_name = node.get('orgName') or ARCHIVE_UNIT
|
|
|
- conclusion = node.get('conclusion') or '通过'
|
|
|
- action = '审批通过' if conclusion == '通过' else f"审批{conclusion}"
|
|
|
- description = f"{node.get('name') or '审批节点'}-{operator_name or ''}{action}".strip('-')
|
|
|
+ conclusion = node.get('conclusion') or ''
|
|
|
+ # 行为依据 = 节点类型(计量支付)
|
|
|
+ basis = node.get('type') or '计量支付'
|
|
|
+ # 行为描述 = 节点名称 | 意见 | 结论 | 办理时间 | 创建时间(空值自动跳过)
|
|
|
+ desc_parts = [
|
|
|
+ node.get('name') or '审批节点',
|
|
|
+ node.get('opinion') or '',
|
|
|
+ f"结论:{conclusion}" if conclusion else '',
|
|
|
+ f"办理时间:{format_datetime(node.get('operateTime'))}" if node.get('operateTime') else '',
|
|
|
+ f"创建时间:{format_datetime(node.get('createdTime'))}" if node.get('createdTime') else '',
|
|
|
+ ]
|
|
|
+ description = ';'.join(p for p in desc_parts if p)
|
|
|
add_entity(
|
|
|
operator_id,
|
|
|
operator_name,
|
|
|
@@ -642,7 +690,7 @@ def build_metadata_entities(order_data, file_id):
|
|
|
node.get('operateTime'),
|
|
|
'审批',
|
|
|
description,
|
|
|
- node.get('id') or node.get('taskId') or '',
|
|
|
+ basis,
|
|
|
stable_guid(f"{file_id}:{node.get('id') or node.get('taskId') or node.get('operatorId')}")
|
|
|
)
|
|
|
|