build(desktop): 升级 electron-shell 版本至 1.6.3 并调整插件执行超时配置
- 插件执行超时默认延长至 6 小时,支持插件单独配置超时时间 - 新增插件根目录迁移逻辑,解决旧版权限问题 - 新增多个服务端实体、DTO、配置模块等基础代码 - 新增插件 UI 模板及相关静态资源
This commit is contained in:
@@ -1,184 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0011 考勤月报封存检查 插件 - 配置常量与全局钩子。
|
||||
|
||||
插件自包含:本包只依赖 Python 标准库 / 第三方库 / 底座注入的 RunContext。
|
||||
所有业务模块统一经 config.log() 输出日志、config.get_session()/get_user_id() 取登录态。
|
||||
"""
|
||||
import os
|
||||
|
||||
# ==================== 共享目录(登录态/缓存,与影刀版同路径) ====================
|
||||
_APP_DATA_DIR = os.path.join(
|
||||
os.getenv('LOCALAPPDATA') or os.getenv('APPDATA') or os.path.expanduser('~'),
|
||||
'37duAutomation')
|
||||
SESSIONS_DIR = os.path.join(_APP_DATA_DIR, '.sessions')
|
||||
CACHE_DIR = os.path.join(_APP_DATA_DIR, 'cache') # 应勤天方案 1 天文件缓存
|
||||
|
||||
# ==================== HR 接口 ====================
|
||||
HR_BASE_URL = "https://hr.37du.co"
|
||||
GET_CUR_USER_INFO_URL = f"{HR_BASE_URL}/RedseaPlatform/PtUsers.mc?method=getCurUserInfo"
|
||||
SEAL_URL = f"{HR_BASE_URL}/RedseaPlatform/kqController/getPageAjaxList.mc"
|
||||
SEAL_SQL_ID = "kq_count_leave_wage_SelectV2"
|
||||
STAT_URL = f"{HR_BASE_URL}/RedseaPlatform/getPageAjax/kq_count_leave_StatV2/CoreRequest.mc"
|
||||
SHIFT_URL = f"{HR_BASE_URL}/RedseaPlatform/redmagicapi/rf_p_kq_count_SelectBanci/getExecutePageResult.mc"
|
||||
TEAM_LIST_URL = f"{HR_BASE_URL}/RedseaPlatform/redmagicapi/rf_p_kq_team_ajax_list/redApiExec.mc"
|
||||
TEAM_EXTEND_URL = f"{HR_BASE_URL}/RedseaPlatform/redmagicapi/rf_s_kq_team_extend_table_select/redApiExec.mc"
|
||||
TEAM_PLAN_URL = f"{HR_BASE_URL}/RedseaPlatform/redmagicapi/rf_s_kq_team_minyq_plan_up_query_all/redApiExec.mc"
|
||||
PAGE_MAX_SIZE = 500
|
||||
|
||||
# ==================== 输出目录与文件(默认与影刀版一致) ====================
|
||||
DEFAULT_SAVE_DIR = r"D:\资料\人资\考勤月报封存检查"
|
||||
|
||||
|
||||
def _default_roster(save_dir):
|
||||
return os.path.join(save_dir, "员工花名册.xlsx")
|
||||
|
||||
|
||||
def _default_transfer(save_dir):
|
||||
return os.path.join(save_dir, "调动台账.xlsx")
|
||||
|
||||
|
||||
# ==================== 口径常量 ====================
|
||||
# 所属单位白名单(预处理口径:封存表仅保留以下单位员工)
|
||||
SEAL_UNIT_WHITELIST = (
|
||||
"财务管理部",
|
||||
"集团管理中心",
|
||||
"集团营建中心",
|
||||
"金色印象事业部",
|
||||
"金色湖畔事业部",
|
||||
)
|
||||
# 封存记录工号字段
|
||||
SEAL_CODE_FIELDS = ("base_code", "seal_base_code")
|
||||
# 花名册剔除口径
|
||||
EXCLUDE_FIRST_DEPT = "职业技术培训学校" # 一级部门等于该值不参与检查
|
||||
EXCLUDE_EMPTY_FIRST_DEPT = True # 一级部门为空(直属根节点高管)不参与检查
|
||||
ROSTER_DEPT_COLS = ("一级部门", "二级部门", "三级部门", "四级部门", "五级部门")
|
||||
ROSTER_CODE_COL = "工号"
|
||||
ROSTER_NAME_COL = "姓名"
|
||||
ROSTER_UNIT_COL = "所属单位"
|
||||
ROSTER_JOIN_COL = "入职时间"
|
||||
ROSTER_LEAVE_COL = "离职时间"
|
||||
ROSTER_SEQ_COL = "职位序列"
|
||||
|
||||
# ==================== 全局钩子(run() 启动时注入) ====================
|
||||
_log = None
|
||||
_session = None
|
||||
_user_id = ""
|
||||
_roster_path = ""
|
||||
|
||||
|
||||
def set_log(fn):
|
||||
"""注入 ctx.log(RunContext.log),各模块经 log()/logger 输出。"""
|
||||
global _log
|
||||
_log = fn
|
||||
|
||||
|
||||
def log(msg, level="INFO"):
|
||||
if _log:
|
||||
_log(str(msg), level)
|
||||
else:
|
||||
print(f"[{level}] {msg}")
|
||||
|
||||
|
||||
class _ModuleLogger:
|
||||
"""模块级 logger 适配:保留影刀版 logger.info(...) 调用点,统一转发到 ctx.log。"""
|
||||
|
||||
@staticmethod
|
||||
def debug(msg, *args):
|
||||
if args:
|
||||
msg = msg % args
|
||||
log(msg, "DEBUG")
|
||||
|
||||
@staticmethod
|
||||
def info(msg, *args):
|
||||
if args:
|
||||
msg = msg % args
|
||||
log(msg, "INFO")
|
||||
|
||||
@staticmethod
|
||||
def warning(msg, *args):
|
||||
if args:
|
||||
msg = msg % args
|
||||
log(msg, "WARN")
|
||||
|
||||
@staticmethod
|
||||
def error(msg, *args):
|
||||
if args:
|
||||
msg = msg % args
|
||||
log(msg, "ERROR")
|
||||
|
||||
|
||||
logger = _ModuleLogger()
|
||||
|
||||
|
||||
def set_session(session):
|
||||
global _session
|
||||
_session = session
|
||||
|
||||
|
||||
def get_session():
|
||||
return _session
|
||||
|
||||
|
||||
def require_session():
|
||||
"""取插件运行期注入的 HR session(缺失抛错,提示先在插件界面登录 HR)。"""
|
||||
if _session is None:
|
||||
raise RuntimeError("未注入 HR 登录态,请先在插件界面完成 HR 登录")
|
||||
return _session
|
||||
|
||||
|
||||
def set_user_id(uid):
|
||||
global _user_id
|
||||
_user_id = str(uid or "")
|
||||
|
||||
|
||||
def get_user_id():
|
||||
return _user_id
|
||||
|
||||
|
||||
def require_user_id():
|
||||
uid = _user_id
|
||||
if not uid:
|
||||
raise RuntimeError("获取当前用户 userId 失败")
|
||||
return uid
|
||||
|
||||
|
||||
def set_roster_path(path):
|
||||
"""花名册路径全局配置(run() 解析后注入,部门回填/剔除默认使用)。"""
|
||||
global _roster_path
|
||||
_roster_path = str(path or "")
|
||||
|
||||
|
||||
def get_roster_path():
|
||||
return _roster_path or _default_roster(DEFAULT_SAVE_DIR)
|
||||
|
||||
|
||||
# 排班预处理结果(run() 预处理阶段一次拉取,检查1/2 直接消费,不再各自请求)
|
||||
_earliest_shift_map: dict = {} # 工号 → 检查月最早排班日期(ISO 字符串,检查1 二次入职识别)
|
||||
_staff_team_map: dict = {} # 工号 → 当月出现最多的排班方案名(检查2)
|
||||
|
||||
|
||||
def set_shift_data(earliest_map: dict, staff_team_map: dict):
|
||||
"""注入排班预处理结果(seal_data_export.load_shift_data 产出)。"""
|
||||
global _earliest_shift_map, _staff_team_map
|
||||
_earliest_shift_map = dict(earliest_map or {})
|
||||
_staff_team_map = dict(staff_team_map or {})
|
||||
|
||||
|
||||
def get_shift_data():
|
||||
"""返回 (工号→最早排班日期映射, 工号→排班方案名映射);未预处理时为空 dict。"""
|
||||
return _earliest_shift_map, _staff_team_map
|
||||
|
||||
|
||||
# 预处理封存行缓存(run() 预读一次,检查1~6 复用,避免各自重复读大文件)
|
||||
_seal_rows_cache: list = None
|
||||
|
||||
|
||||
def set_seal_rows(rows: list):
|
||||
"""注入预处理封存行(seal_data_export.load_seal_rows 产出的最终行列表,含剔除)。"""
|
||||
global _seal_rows_cache
|
||||
_seal_rows_cache = rows
|
||||
|
||||
|
||||
def get_seal_rows():
|
||||
"""返回预处理的封存行列表;未预读时返回 None。"""
|
||||
return _seal_rows_cache
|
||||
Reference in New Issue
Block a user