feat: 新增多插件 UI 支持及运行日志集中回传功能

本次提交包含多项功能更新:
1. 为多个插件(xq0002/0003/0004/0008/0010/0011/0020/0031_xq0032/0033/0035/0037/0045_xq0046/0047/0048)新增 UI 界面及配置支持
2. 新增运行日志集中回传功能,客户端自动上传运行日志到中心机集中存储
3. 新增插件分类字段支持,用于场景库分组管理
4. 优化 xq0034/0037/0048 等插件的功能及描述
5. 修复控制面响应兼容问题,支持新旧版本数据格式
6. 新增 xq0033 插件的状态存储模块,用于历史记录管理
7. 优化 CRM 登录窗口模式,支持全屏置顶
This commit is contained in:
2026-10-26 15:42:50 +08:00
parent 8bf33b65cd
commit c73c113721
453 changed files with 243002 additions and 4493 deletions
+145
View File
@@ -0,0 +1,145 @@
# -*- coding: utf-8 -*-
"""XQ0033 插件 - HR 台账实时查询参数构造。
HR 台账(queryRealTimeData.mc)要求 commonQuery 为前端加密串:
encodeURIComponent(JSON) → 自定义字符表 Base64 → 拼接盐值 → 首尾重排。
本模块只负责参数构造,实际请求由 hr_client.HRClient 发起。
"""
import json
import time
import urllib.parse
from datetime import date, timedelta
from .. import config
# 自定义字符表(与 HR 前端一致,逆向自页面脚本)
_CUSTOM_CHARS = "y!89(*z02BCcdD_bEeGHIJKLmnNOPQopRMSTqrUklVstWXYZafgh3ij1uvwx456A7"
_CQ_SALT = "yyryrtweasdasd"
def custom_base64_encode(data):
"""使用自定义字符表进行 Base64 编码(data 为 UTF-8 字节序列)。"""
result = []
for i in range(0, len(data), 3):
chunk = data[i:i + 3]
b1 = chunk[0] if len(chunk) > 0 else 0
b2 = chunk[1] if len(chunk) > 1 else 0
b3 = chunk[2] if len(chunk) > 2 else 0
enc1 = (b1 >> 2) & 0x3F
enc2 = ((b1 << 4) | (b2 >> 4)) & 0x3F
enc3 = ((b2 << 2) | (b3 >> 6)) & 0x3F
enc4 = b3 & 0x3F
if len(chunk) == 1:
enc3 = 64
enc4 = 64
elif len(chunk) == 2:
enc4 = 64
result.append(_CUSTOM_CHARS[enc1])
result.append(_CUSTOM_CHARS[enc2])
result.append(_CUSTOM_CHARS[enc3])
result.append(_CUSTOM_CHARS[enc4])
return ''.join(result)
def build_condition(query_field, query_type, query_value,
left_bracket="", right_bracket="", input_type="text"):
"""构造一条符合前端格式的查询条件。"""
return {
"queryField": query_field,
"leftBracket": left_bracket,
"queryType": query_type,
"queryValue": query_value,
"queryText": "",
"rightBracket": right_bracket,
"logic": "AND",
"inputType": input_type,
}
def encode_common_query(query_list):
"""将查询条件列表加密为 commonQuery(encodeURIComponent + 自定义 Base64 + 盐值 + 首尾重排)。"""
json_str = json.dumps(query_list, ensure_ascii=False, separators=(',', ':'))
uri_encoded = urllib.parse.quote(json_str, safe="-_.~!*'()")
en_str = custom_base64_encode(uri_encoded.encode('utf-8')) + _CQ_SALT
return en_str[:2] + en_str[-3:] + en_str[2:-3]
def build_roster_query_params(roster_id, table_id, menu_name, common_query, today):
"""构造 HR 台账实时查询(queryRealTimeData.mc)完整参数。
roster/table/menu/commonQuery 按调用方传入,其余为通用固定参数(与页面抓包一致)。"""
month_first = date(today.year, today.month, 1)
now_ms = str(int(time.time() * 1000))
return {
"menuName": menu_name,
"useSealTreeData": "0",
"treePermitType": "permit",
"_t": now_ms,
"in_use": "1",
"commonQuery": common_query,
"newCondition": "",
"urlConditions": f"_t:{now_ms}#treePermitType:permit#useSealTreeData:0#"
f"menuName:{menu_name}#_t:{now_ms}#",
"exportConfig": "",
"tableId": table_id,
"rosterId": roster_id,
"includeChildrenSetting": "",
"struTreeCode": "cq37du",
"djStruTreeCode": "",
"djStruId": "",
"djOrgName": "",
"struId": config.COMPANY_STRU_ID,
"belongUnitStruId": config.COMPANY_STRU_ID,
"rootId": "cq37du",
"isVirtual": "0",
"currentUserRootId": "cq37du",
"currentUserId": "178b0efa-8a65-11f1-a7d9-000c296f9469",
"currentRoleIds": config.REJOIN_ROLE_IDS,
"currentStaffId": "1342173e-36cf-4160-8826-6b17d7d084a4",
"baseHrefPath": "http:hr.37du.co:80RedseaPlatform",
"qrCodeUrl": "jspresumepage-01.jsp",
"orgName": "集团",
"belongUnitOrgName": "集团",
"currentDate": today.strftime("%Y-%m-%d"),
"currentMonth": today.strftime("%Y%m"),
"currentMonthBar": today.strftime("%Y-%m"),
"lastMonth": (month_first - timedelta(days=1)).strftime("%Y%m"),
"lastMonFirstDay": (month_first - timedelta(days=1)).replace(day=1).strftime("%Y-%m-%d"),
"lastMonLastDay": (month_first - timedelta(days=1)).strftime("%Y-%m-%d"),
"curYearFirstMon": f"{today.year}01",
"curYearFirstMonBar": f"{today.year}-01",
"throughParam": "",
"start": "0",
"sortType": "",
"sortName": "",
"pageNo": "1",
"pageSize": "15",
}
def build_rejoin_query_params(today):
"""「离职当月再入职人员算薪台账」实时查询参数。
查询条件 = 离职日期 ∈ [本月1日, 今天](只取本月数据)。"""
month_first = date(today.year, today.month, 1)
common_query = encode_common_query([
build_condition(f"`{config.REJOIN_FIELD_PREFIX}.leave_date`", ">=",
month_first.strftime("%Y-%m-%d"), left_bracket="(",
input_type="date"),
build_condition(f"`{config.REJOIN_FIELD_PREFIX}.leave_date`", "<=",
today.strftime("%Y-%m-%d"), right_bracket=")",
input_type="date"),
])
params = build_roster_query_params(config.REJOIN_ROSTER_ID, config.REJOIN_TABLE_ID,
config.REJOIN_MENU, common_query, today)
params["pageSize"] = str(config.REJOIN_PAGE_SIZE)
return params
def build_leave_query_params(today, idc):
"""「离职台账」按身份证查历史工号的实时查询参数。"""
common_query = encode_common_query([
build_condition("`hr_staff_base.idCard`", "like", idc, input_type="text"),
])
params = build_roster_query_params(config.LEAVE_ROSTER_ID, config.LEAVE_TABLE_ID,
config.LEAVE_MENU, common_query, today)
params["pageSize"] = str(config.LEAVE_PAGE_SIZE)
return params