feat: 新增银行卡检查插件及相关依赖与配置文件
@@ -0,0 +1,33 @@
|
||||
# XQ0005 银行卡检查(插件版)
|
||||
|
||||
由影刀版 `workflows/XQ0001-0100/XQ0005 银行卡检查/bank_card_check.py` 移植,业务口径完全一致。
|
||||
|
||||
## 功能
|
||||
|
||||
1. 拉取 HR「在职」+「离职」工资卡全量数据(离职按离职日期区间筛选);
|
||||
2. 剔除员工姓名含 `虚拟 / 人资 / 测试` 的记录;
|
||||
3. 逐行核对:银行卡号 BIN + 位数校验、开户人姓名/身份证比对、现金发放识别、代发识别;
|
||||
4. 输出单工作簿(`工资卡核对结果.xlsx`)三个 sheet:
|
||||
- `工资卡异常名单`(精简列,异常原因排序)
|
||||
- `工资卡完整核对结果`(全量 + 核对列置前)
|
||||
- `工资卡原始数据`(剔除虚拟人员后的原始数据)
|
||||
5. 可选:推送核对摘要到钉钉群机器人(文本,**不含附件**)。
|
||||
|
||||
## 与影刀版的差异
|
||||
|
||||
| 项 | 影刀版 | 插件版 |
|
||||
|---|---|---|
|
||||
| 登录态 | 读 `%LOCALAPPDATA%\37duAutomation\.sessions\hr_cookies.json` | 底座注入 `ctx.get_session("hr")`,不做自动补登 |
|
||||
| 参数 | 根 `.env` 的 `wage_card_output_dir` | `plugin.json.fields`(界面表单 + 插件配置 JSON) |
|
||||
| 推送 | 写影刀全局变量,由「37du钉钉推送」dws 发 xlsx 到群 | 群机器人 Webhook 文本摘要,附件留在本机输出目录 |
|
||||
| 触发 | 影刀流程 | 壳子插件界面「一键执行」,或定时任务绑定方案 |
|
||||
|
||||
离职日期范围自动规则保持一致:每月 8 号及以前 → 上月 1 日 ~ 今天;8 号之后 → 本月 1 日 ~ 今天。
|
||||
补跑历史月份时手填「离职日期起 / 止」两个字段即可。
|
||||
|
||||
## 发布
|
||||
|
||||
```bash
|
||||
d:\work\code\37duAutomation\.venv\Scripts\python.exe "plugins\XQ0001-0100\XQ0005 银行卡检查\_pack.py"
|
||||
# 然后在 desktop/ 下用 agent_cli publish(详见 docs/插件/发版规范.md)
|
||||
```
|
||||
@@ -0,0 +1,100 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0005 银行卡检查 插件入口(由影刀版 workflows/XQ0001-0100/XQ0005 银行卡检查 移植)。
|
||||
|
||||
流程编排:
|
||||
1) 登录态预检:底座注入 HR session → 拉一条工资卡数据验证(失效提示重新登录);
|
||||
2) 在职 + 离职工资卡全量拉取(离职按「每月8号前后」自动范围,可用字段手动覆盖);
|
||||
3) 剔除姓名含 虚拟/人资/测试 的记录 → 逐行核对(银行卡 BIN + 开户人姓名/身份证 + 现金发放);
|
||||
4) 输出单工作簿三 sheet(工资卡异常名单 / 完整核对结果 / 原始数据);
|
||||
5) 配置了钉钉群机器人 Webhook 时推送核对摘要(文本,附件留在本机输出目录)。
|
||||
|
||||
运行上下文:底座注入 HR 会话(config 全局钩子),platform = hr;不使用月份(uses_month = False)。
|
||||
校验规则见 docs/银行卡检查/需求文档.md。
|
||||
"""
|
||||
from webhost.backend.plugins.base import ScenePlugin, PLUGINS
|
||||
|
||||
from . import config
|
||||
from .report.bank_card_report import run_bank_card_check
|
||||
|
||||
|
||||
class BankCardCheckPlugin(ScenePlugin):
|
||||
"""银行卡检查(需求 XQ0005)。"""
|
||||
|
||||
id = "xq0005"
|
||||
name = "银行卡检查"
|
||||
version = "1.0.0"
|
||||
description = ("下载在职 + 离职工资卡数据,按 BIN 规则核对银行卡号并比对员工与开户人姓名/身份证,"
|
||||
"输出单工作簿三 sheet(异常名单 / 完整核对结果 / 原始数据),可选推送摘要到钉钉群。")
|
||||
platform = "hr"
|
||||
uses_month = False
|
||||
capabilities = ["xq0005"]
|
||||
permissions = {"platforms": ["hr"]}
|
||||
fields = {
|
||||
"save_dir": {
|
||||
"type": "string", "title": "输出目录",
|
||||
"default": r"D:\资料\人资\银行卡检查",
|
||||
"description": "结果工作簿(工资卡核对结果.xlsx)输出目录",
|
||||
},
|
||||
"leave_start": {
|
||||
"type": "string", "title": "离职日期起", "default": "",
|
||||
"description": "留空=自动(8号及以前:上月1日~今天;8号之后:本月1日~今天)",
|
||||
},
|
||||
"leave_end": {
|
||||
"type": "string", "title": "离职日期止", "default": "",
|
||||
"description": "留空=今天;与「离职日期起」成对填写才生效",
|
||||
},
|
||||
"push_webhook": {
|
||||
"type": "string", "title": "钉钉群机器人 Webhook", "default": "",
|
||||
"description": "留空=只导出不推送;填写后推送核对摘要文本(不支持发附件)",
|
||||
},
|
||||
"push_secret": {
|
||||
"type": "string", "title": "钉钉机器人加签密钥", "format": "password", "default": "",
|
||||
"description": "机器人安全设置为「加签」时填写,未配置加签留空",
|
||||
},
|
||||
}
|
||||
|
||||
def run(self, fields: dict, ctx):
|
||||
# ---- 注入运行上下文:日志 / HR 会话 ----
|
||||
config.set_log(ctx.log)
|
||||
config.set_session(ctx.get_session("hr"))
|
||||
ctx.progress(2)
|
||||
|
||||
save_dir = (fields.get("save_dir") or "").strip() or config.DEFAULT_SAVE_DIR
|
||||
leave_start = (fields.get("leave_start") or "").strip()
|
||||
leave_end = (fields.get("leave_end") or "").strip()
|
||||
push_webhook = (fields.get("push_webhook") or "").strip()
|
||||
push_secret = fields.get("push_secret") or ""
|
||||
|
||||
ctx.log(f"===== 银行卡检查启动:输出目录 {save_dir} =====", "INFO")
|
||||
|
||||
result = run_bank_card_check(
|
||||
save_dir=save_dir,
|
||||
leave_start=leave_start,
|
||||
leave_end=leave_end,
|
||||
push_webhook=push_webhook,
|
||||
push_secret=push_secret,
|
||||
progress=ctx.progress,
|
||||
)
|
||||
|
||||
stats = result["stats"]
|
||||
summary = ("银行卡检查完成:通过 {passed} / 总计 {total},工资卡异常 {abnormal} 人"
|
||||
"(含无工资卡 {no_bank} 人),代发 {daifa} 人。文件:{path}").format(
|
||||
path=result["path"], **stats)
|
||||
|
||||
return {
|
||||
"summary": summary,
|
||||
"detail": {
|
||||
"核对总数": stats["total"],
|
||||
"通过": stats["passed"],
|
||||
"工资卡异常": stats["abnormal"],
|
||||
"无工资卡": stats["no_bank"],
|
||||
"代发": stats["daifa"],
|
||||
"剔除虚拟测试": result["excluded"],
|
||||
"离职筛选范围": f"{result['leave_range'][0]} ~ {result['leave_range'][1]}",
|
||||
"推送": "成功" if result["push"].get("success") else result["push"].get("message", ""),
|
||||
},
|
||||
"path": result["path"],
|
||||
}
|
||||
|
||||
|
||||
PLUGINS.append(BankCardCheckPlugin())
|
||||
@@ -0,0 +1,53 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0005 银行卡检查 插件打包脚本(统一规范版)。
|
||||
|
||||
打包产物统一输出到仓库根 dist-plugin/<id>_v<版本>.zip(目录不入库),
|
||||
zip 根含 plugin.json,可被 agent_cli publish 直接发布。
|
||||
详见 docs/插件/插件开发规范.md 与 docs/插件/发版规范.md。
|
||||
|
||||
用法(任意 cwd 均可):
|
||||
d:\\work\\code\\37duAutomation\\.venv\\Scripts\\python.exe plugins\\XQ0001-0100\\XQ0005 银行卡检查\\_pack.py
|
||||
随后发布:
|
||||
.venv\\Scripts\\python.exe -m controlplane.tools.agent_cli publish \
|
||||
dist-plugin\\xq0005_v<版本>.zip --id xq0005 --version <版本>
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
_HERE = Path(__file__).resolve().parent
|
||||
# 仓库根 = plugins/XQ0001-0100/<插件目录>/ 的 parents[2],统一出包位置
|
||||
_REPO_ROOT = _HERE.parents[2]
|
||||
_OUT_DIR = _REPO_ROOT / "dist-plugin"
|
||||
|
||||
# 排除项:打包脚本自身 / 前端源码与依赖 / 缓存 / 调试文件
|
||||
_EXCLUDE_DIRS = {"ui-src", "__pycache__", ".git", ".idea", "debug", ".sessions"}
|
||||
_EXCLUDE_FILES = {"_pack.py"}
|
||||
_EXCLUDE_SUFFIXES = (".pyc", ".pyo")
|
||||
|
||||
|
||||
def main():
|
||||
manifest = json.loads((_HERE / "plugin.json").read_text(encoding="utf-8"))
|
||||
pid = manifest["id"]
|
||||
ver = manifest["version"]
|
||||
# 带 UI 插件必须已构建前端产物(ui/ 由底座 /pui/<id>/ 托管)
|
||||
if manifest.get("ui") and not (_HERE / "ui" / "index.html").is_file():
|
||||
sys.exit(f"插件 {pid} 声明 ui=true 但缺少 ui/index.html:请先在 ui-src 下执行 npm install && npm run build")
|
||||
_OUT_DIR.mkdir(exist_ok=True)
|
||||
out = _OUT_DIR / f"{pid}_v{ver}.zip"
|
||||
count = 0
|
||||
with zipfile.ZipFile(out, "w", zipfile.ZIP_DEFLATED) as zf:
|
||||
for p in sorted(_HERE.rglob("*")):
|
||||
rel = p.relative_to(_HERE)
|
||||
if set(rel.parts) & _EXCLUDE_DIRS or p.name in _EXCLUDE_FILES \
|
||||
or p.suffix in _EXCLUDE_SUFFIXES:
|
||||
continue
|
||||
if p.is_file():
|
||||
zf.write(p, str(rel))
|
||||
count += 1
|
||||
print(f"已打包: {out}({count} 个文件,{out.stat().st_size / 1024:.0f} KB)")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,207 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0005 银行卡检查 插件 - 配置常量与全局钩子。
|
||||
|
||||
插件自包含:本包只依赖 Python 标准库 / 第三方库 / 底座注入的 RunContext。
|
||||
所有业务模块统一经 config.logger 输出日志、config.require_session() 取 HR 登录态。
|
||||
HR 登录态由底座注入(platform = hr),插件不做自动补登,失效时提示「请重新登录」。
|
||||
|
||||
校验口径(与影刀版 workflows/XQ0001-0100/XQ0005 银行卡检查/bank_card_check.py 一致,
|
||||
规则详见 docs/银行卡检查/需求文档.md):
|
||||
- 员工姓名含「虚拟/人资/测试」的记录直接剔除,不参与核对;
|
||||
- 员工姓名与开户人姓名、身份证均不一致记为「代发」(不算异常,除非银行卡 BIN 核对错误);
|
||||
- 开卡银行/银行卡号/备注任一含「现金」-> 直接标「现金发放」,其余不再核对;
|
||||
- 银行卡号按 BIN + 位数规则校验,非银联国际信用卡单列「疑似信用卡」。
|
||||
"""
|
||||
import os
|
||||
|
||||
# ==================== 共享目录(与影刀版同路径,银行字典缓存互通) ====================
|
||||
_APP_DATA_DIR = os.path.join(
|
||||
os.getenv('LOCALAPPDATA') or os.getenv('APPDATA') or os.path.expanduser('~'),
|
||||
'37duAutomation', 'BankCardCheck')
|
||||
|
||||
# ==================== HR 系统 ====================
|
||||
HR_BASE_URL = "https://hr.37du.co"
|
||||
|
||||
# ---------- 工资卡接口 ----------
|
||||
WAGE_CARD_URL = f"{HR_BASE_URL}/RedseaPlatform/getPageAjax/HrStaffWageCard.mc"
|
||||
PAGE_MAX_SIZE = 500
|
||||
|
||||
# ---------- 银行字典接口(按 BANK_TYPE 匹配 code -> 开卡银行) ----------
|
||||
BANK_DICT_URL = f"{HR_BASE_URL}/RedseaPlatform/PtCodeTypeValue.mc?method=getCodeValueByCodes"
|
||||
BANK_DICT_CODE_TYPE = "WAGE.BANKTYPE"
|
||||
BANK_DICT_EXPIRE_SEC = 7 * 24 * 60 * 60 # 缓存 7 天过期,自动重新拉取
|
||||
BANK_DICT_LIST_FILE = os.path.join(_APP_DATA_DIR, "bank_dict_list.json")
|
||||
BANK_DICT_MAP_FILE = os.path.join(_APP_DATA_DIR, "bank_dict_map.json")
|
||||
|
||||
# 项目级重试(AGENTS.md):瞬时故障最多重试 3 次,三次仍失败后再记录错误日志
|
||||
MAX_REQUEST_RETRY = 3
|
||||
|
||||
# ==================== 输出 ====================
|
||||
DEFAULT_SAVE_DIR = r"D:\资料\人资\银行卡检查"
|
||||
RESULT_NAME = "工资卡核对结果.xlsx" # 单工作簿输出(含全部 sheet)
|
||||
|
||||
# 单工作簿 sheet 名称(按输出顺序)
|
||||
SHEET_ABNORMAL = "工资卡异常名单" # 异常 + 无工资卡(精简列,第一个 sheet 方便直接看)
|
||||
SHEET_FULL = "工资卡完整核对结果" # 全量 + 核对列(含代发标记)
|
||||
SHEET_DATA = "工资卡原始数据" # 接口原始数据(剔除虚拟人员,未核对)
|
||||
|
||||
# ==================== 剔除规则 ====================
|
||||
# 员工姓名含这些关键字的记录直接剔除,不参与核对(人资/测试账号/虚拟账号等)
|
||||
EXCLUDE_NAME_KEYWORDS = ["虚拟", "人资", "测试"]
|
||||
|
||||
# ==================== 工资卡字段映射 ====================
|
||||
COL_MAP = {
|
||||
"STAFF_NAME": "员工姓名",
|
||||
"STAFF_ID": "员工ID",
|
||||
"IDCARD": "身份证号",
|
||||
"join_date": "入职日期",
|
||||
"leaveOffice_date": "离职日期",
|
||||
"BELONG_UNIT_ORG_NAME": "所属事业部",
|
||||
"DEPT_ORG_NAME": "小组部门",
|
||||
"ORG_FULL_PATH": "组织全路径",
|
||||
"IS_MAIN": "是否主卡",
|
||||
"BANK_TYPE": "银行编码",
|
||||
"BANK_ACCOUNT": "银行卡号",
|
||||
"CARD_ID": "卡片ID",
|
||||
"base_code": "37工号",
|
||||
"BRANCH_BANK": "支行编码",
|
||||
"bank_province": "银行省份",
|
||||
"bank_city": "银行城市",
|
||||
"wage_card_type": "工资卡类型",
|
||||
"branch_bank_name": "支行名称",
|
||||
"bank_no": "银行行号",
|
||||
"CARD_NAME": "开户人姓名",
|
||||
"CARD_IDCARD": "开户人身份证",
|
||||
"ext_remark": "备注",
|
||||
"si_name": "合同签署单位",
|
||||
"operator_name": "操作人",
|
||||
"OPERATE_TIME": "操作时间",
|
||||
"BANK_NUM": "银行卡序号",
|
||||
}
|
||||
SHOW_ORDER = [
|
||||
"人员类型", "员工姓名", "37工号", "员工ID", "身份证号", "入职日期", "离职日期",
|
||||
"所属事业部", "小组部门", "组织全路径", "是否主卡",
|
||||
"银行编码", "开卡银行", "银行卡号", "开户人姓名", "合同签署单位", "操作人", "操作时间",
|
||||
]
|
||||
|
||||
# ---------- 异常 sheet 精简列(异常名单按此输出) ----------
|
||||
ABNORMAL_COL_MAP = {
|
||||
"员工姓名": "员工姓名",
|
||||
"37工号": "37工号",
|
||||
"身份证号": "身份证",
|
||||
"组织全路径": "组织全路径",
|
||||
"入职日期": "入职日期",
|
||||
"离职日期": "离职日期",
|
||||
"开户人姓名": "开户人姓名",
|
||||
"开户人身份证": "开户人身份证",
|
||||
"开卡银行": "银行开户行",
|
||||
"银行卡号": "银行卡号",
|
||||
"备注": "备注",
|
||||
"合同签署单位": "合同签署单位",
|
||||
"操作人": "操作人",
|
||||
"操作时间": "操作时间",
|
||||
}
|
||||
|
||||
# ==================== 核对相关列名 ====================
|
||||
COL_IDCARD = "身份证号"
|
||||
COL_CARD_IDCARD = "开户人身份证"
|
||||
COL_STAFF_NAME = "员工姓名"
|
||||
COL_CARD_NAME = "开户人姓名"
|
||||
COL_BANK_ACCOUNT = "银行卡号"
|
||||
COL_BANK_NAME = "开卡银行"
|
||||
COL_REMARK = "备注"
|
||||
COL_BANK_STATUS = "银行卡状态"
|
||||
COL_BANK_REASON = "银行卡说明"
|
||||
COL_CHECK_RESULT = "核对结果"
|
||||
COL_CHECK_BASIS = "校验依据"
|
||||
|
||||
# ==================== 银行卡校验规则 ====================
|
||||
# 16 位银联卡 BIN(按银行归类,经实际工资卡数据比对核验)
|
||||
BIN_16 = {
|
||||
# 招商银行
|
||||
"621483", "621485", "621486", "622588", "622609",
|
||||
# 民生银行
|
||||
"621691", "622615", "622617", "622619", "622620", "622622",
|
||||
# 民生银行信用卡(16 位贷记卡)
|
||||
"622601",
|
||||
# 重庆农村商业银行
|
||||
"621258", "621465", "621528", "622867",
|
||||
# 浦东发展银行
|
||||
"621792", "621793", "622521",
|
||||
# 其他银行
|
||||
"621499", # 建设银行理财金卡
|
||||
"621755", # 重庆三峡银行
|
||||
"623020", # 华夏银行
|
||||
}
|
||||
# 18 位银联储蓄卡 BIN
|
||||
BIN_18 = {"622908"} # 兴业银行
|
||||
# 非 62 开头但合法的老版储蓄卡 BIN(历史卡仍在使用,标准均为 19 位)
|
||||
NON62_BIN = {
|
||||
"436742", # 建设银行龙卡储蓄卡
|
||||
"601382", # 中国银行长城电子借记卡
|
||||
"955882", # 工商银行牡丹灵通卡
|
||||
}
|
||||
|
||||
# ==================== 全局钩子(run() 启动时注入) ====================
|
||||
_log = None
|
||||
_session = None
|
||||
|
||||
|
||||
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
|
||||
@@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0005 插件 - 数据层:HR 工资卡 / 银行字典接口。"""
|
||||
@@ -0,0 +1,105 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0005 插件 - 银行字典接口(WAGE.BANKTYPE):银行编码 -> 开卡银行名称。
|
||||
|
||||
参考影刀版 bank_card_check.py:
|
||||
- 优先读本机缓存(%LOCALAPPDATA%\\37duAutomation\\BankCardCheck\\bank_dict_*.json),
|
||||
缓存 7 天过期后自动重新拉取;
|
||||
- 拉取失败时降级使用旧缓存;无缓存返回空字典(开卡银行列留空,不影响其他核对)。
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
|
||||
from ..config import (
|
||||
BANK_DICT_CODE_TYPE, BANK_DICT_EXPIRE_SEC, BANK_DICT_LIST_FILE,
|
||||
BANK_DICT_MAP_FILE, BANK_DICT_URL, MAX_REQUEST_RETRY, logger,
|
||||
)
|
||||
from ..config import _APP_DATA_DIR as DICT_CACHE_DIR
|
||||
|
||||
def _ensure_dir(path):
|
||||
os.makedirs(path, exist_ok=True)
|
||||
|
||||
|
||||
def fetch_bank_dict(session):
|
||||
"""远程调用字典接口并写入本地缓存,返回 (list[dict], dict[code->name])。"""
|
||||
payload = {
|
||||
"codeType": BANK_DICT_CODE_TYPE,
|
||||
"inUse": "0,1,2",
|
||||
"platformMode": "redseaPlatform",
|
||||
}
|
||||
resp = session.post(BANK_DICT_URL, data=payload, timeout=30)
|
||||
resp.raise_for_status()
|
||||
resp_json = resp.json()
|
||||
raw_list = resp_json.get(BANK_DICT_CODE_TYPE) or []
|
||||
result_list = [{"code": str(item.get("code", "")), "name": item.get("name", "")}
|
||||
for item in raw_list]
|
||||
result_map = {item["code"]: item["name"] for item in result_list}
|
||||
|
||||
_ensure_dir(DICT_CACHE_DIR)
|
||||
with open(BANK_DICT_LIST_FILE, "w", encoding="utf-8") as f:
|
||||
json.dump(result_list, f, ensure_ascii=False, indent=2)
|
||||
with open(BANK_DICT_MAP_FILE, "w", encoding="utf-8") as f:
|
||||
json.dump(result_map, f, ensure_ascii=False, indent=2)
|
||||
logger.info("银行字典远程拉取完成,共 %d 条", len(result_list))
|
||||
return result_list, result_map
|
||||
|
||||
|
||||
def load_bank_dict_cache():
|
||||
"""读取本地银行字典缓存,失败返回 (None, None)。"""
|
||||
try:
|
||||
with open(BANK_DICT_LIST_FILE, "r", encoding="utf-8") as f:
|
||||
lst = json.load(f)
|
||||
with open(BANK_DICT_MAP_FILE, "r", encoding="utf-8") as f:
|
||||
mp = json.load(f)
|
||||
return lst, mp
|
||||
except Exception as e:
|
||||
logger.warning("银行字典本地缓存读取失败:%s", e)
|
||||
return None, None
|
||||
|
||||
|
||||
def get_bank_dict(session=None, force_refresh=False):
|
||||
"""获取银行字典(优先本地缓存,过期/强制刷新才请求接口),返回 (list, map)。"""
|
||||
need_refresh = force_refresh
|
||||
if not (os.path.exists(BANK_DICT_LIST_FILE) and os.path.exists(BANK_DICT_MAP_FILE)):
|
||||
need_refresh = True
|
||||
else:
|
||||
mtime = os.path.getmtime(BANK_DICT_LIST_FILE)
|
||||
if time.time() - mtime > BANK_DICT_EXPIRE_SEC:
|
||||
need_refresh = True
|
||||
|
||||
if need_refresh:
|
||||
last_err = None
|
||||
for attempt in range(1, MAX_REQUEST_RETRY + 1):
|
||||
try:
|
||||
return fetch_bank_dict(session)
|
||||
except Exception as e:
|
||||
last_err = e
|
||||
logger.warning("银行字典远程拉取第 %d 次失败:%s", attempt, e)
|
||||
time.sleep(1.0 * attempt)
|
||||
logger.error("银行字典远程拉取失败:%s", last_err)
|
||||
lst, mp = load_bank_dict_cache()
|
||||
if lst is not None:
|
||||
logger.warning("降级使用本地银行字典缓存,共 %d 条", len(lst))
|
||||
return lst, mp
|
||||
return [], {}
|
||||
|
||||
lst, mp = load_bank_dict_cache()
|
||||
if lst is None:
|
||||
return fetch_bank_dict(session)
|
||||
logger.info("读取本地银行字典缓存,共 %d 条", len(lst))
|
||||
return lst, mp
|
||||
|
||||
|
||||
def bank_type_to_name(bank_type, bank_map):
|
||||
"""按银行编码(BANK_TYPE)匹配字典 code,返回开卡银行;未命中返回空串。"""
|
||||
if bank_type is None:
|
||||
return ""
|
||||
if isinstance(bank_type, float):
|
||||
if bank_type != bank_type: # NaN
|
||||
return ""
|
||||
bank_type = str(int(bank_type))
|
||||
elif isinstance(bank_type, int):
|
||||
bank_type = str(bank_type)
|
||||
else:
|
||||
bank_type = str(bank_type).strip()
|
||||
return (bank_map or {}).get(bank_type, "")
|
||||
@@ -0,0 +1,136 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0005 插件 - 工资卡接口(HrStaffWageCard)分页拉取。
|
||||
|
||||
接口:POST {HR}/RedseaPlatform/getPageAjax/HrStaffWageCard.mc
|
||||
person_status=1 在职(离职日期不限);person_status=2 离职(按 leaveOffice_date 区间筛选)。
|
||||
登录态由底座注入(config.require_session()),失效抛 RuntimeError 提示重新登录,不做自动补登。
|
||||
"""
|
||||
import time
|
||||
from datetime import date, timedelta
|
||||
|
||||
from ..config import MAX_REQUEST_RETRY, PAGE_MAX_SIZE, WAGE_CARD_URL, logger
|
||||
|
||||
|
||||
class HRSessionExpiredError(Exception):
|
||||
"""HR 登录态失效(接口返回非 JSON,通常被重定向到登录页)。"""
|
||||
|
||||
|
||||
LOGIN_EXPIRED_MSG = "HR 登录态已过期,请先在壳子(工作台)重新登录 HR 平台后重试"
|
||||
|
||||
|
||||
def _request_page(session, status, page_no, page_size, leave_start=None, leave_end=None):
|
||||
"""请求工资卡单页数据(不做重试,由调用方统一重试)。"""
|
||||
params = {
|
||||
"start": (page_no - 1) * page_size,
|
||||
"pageNo": page_no,
|
||||
"pageSize": page_size,
|
||||
"ftl_list_STRU_TREE_CODE": "cq37du",
|
||||
"sortName": "hr_staff_wage_card.STAFF_NAME",
|
||||
"sortType": "asc",
|
||||
"commonQuery": "[]",
|
||||
"person_status": status,
|
||||
}
|
||||
if status == 1:
|
||||
params["leaveOffice_date"] = ""
|
||||
elif leave_start and leave_end:
|
||||
params["leaveOffice_date[0]"] = leave_start
|
||||
params["leaveOffice_date[1]"] = leave_end
|
||||
params["leaveOffice_date_start"] = leave_start
|
||||
params["leaveOffice_date_end"] = leave_end
|
||||
|
||||
resp = session.post(WAGE_CARD_URL, data=params, timeout=20)
|
||||
if resp.status_code != 200:
|
||||
raise RuntimeError(f"工资卡接口状态码异常: {resp.status_code}")
|
||||
text = resp.text or ""
|
||||
if text and not text.lstrip().startswith(("{", "[")):
|
||||
raise HRSessionExpiredError(LOGIN_EXPIRED_MSG)
|
||||
try:
|
||||
return resp.json()
|
||||
except Exception:
|
||||
raise RuntimeError(f"工资卡接口返回非 JSON 数据(状态码 {resp.status_code}): {text[:200]}")
|
||||
|
||||
|
||||
def fetch_wage_card_page(session, status, page_no=1, page_size=PAGE_MAX_SIZE,
|
||||
leave_start=None, leave_end=None):
|
||||
"""请求工资卡单页数据(项目级重试:最多 3 次,登录失效不重试直接抛出)。"""
|
||||
last_err = None
|
||||
for attempt in range(1, MAX_REQUEST_RETRY + 1):
|
||||
try:
|
||||
data = _request_page(session, status, page_no, page_size, leave_start, leave_end)
|
||||
if not isinstance(data, dict):
|
||||
raise RuntimeError(f"工资卡接口返回结构异常: {str(data)[:200]}")
|
||||
return data
|
||||
except HRSessionExpiredError:
|
||||
raise
|
||||
except Exception as e:
|
||||
last_err = e
|
||||
if attempt >= MAX_REQUEST_RETRY:
|
||||
break
|
||||
logger.warning("工资卡第 %d 页第 %d 次请求失败:%s", page_no, attempt, e)
|
||||
time.sleep(1.0 * attempt)
|
||||
raise RuntimeError(f"工资卡第 {page_no} 页连续 {MAX_REQUEST_RETRY} 次请求失败:{last_err}")
|
||||
|
||||
|
||||
def fetch_all_wage_card(session, status, status_name, leave_start=None, leave_end=None):
|
||||
"""分页抓取某人员状态(在职/离职)的工资卡全量数据,返回接口原始记录列表。"""
|
||||
all_rows = []
|
||||
page_no = 1
|
||||
while True:
|
||||
try:
|
||||
data = fetch_wage_card_page(session, status, page_no, PAGE_MAX_SIZE,
|
||||
leave_start, leave_end)
|
||||
except HRSessionExpiredError:
|
||||
raise RuntimeError(f"【{status_name}】{LOGIN_EXPIRED_MSG}")
|
||||
|
||||
if str(data.get("state")) != "1":
|
||||
raise RuntimeError(f"【{status_name}】第 {page_no} 页数据请求失败:{data.get('meg')}")
|
||||
|
||||
page_list = data.get("datas", []) or []
|
||||
if not page_list:
|
||||
logger.info("【%s】无更多数据", status_name)
|
||||
break
|
||||
|
||||
for item in page_list:
|
||||
item["人员类型"] = status_name
|
||||
all_rows.extend(page_list)
|
||||
|
||||
total = data.get("count", 0)
|
||||
total_page = int(data.get("pageCount", 0) or 0)
|
||||
logger.info("【%s】已抓取 %d/%d 页,累计 %d/%d 条",
|
||||
status_name, page_no, total_page, len(all_rows), total)
|
||||
if page_no >= total_page:
|
||||
break
|
||||
page_no += 1
|
||||
time.sleep(0.2)
|
||||
return all_rows
|
||||
|
||||
|
||||
def precheck(session):
|
||||
"""登录态预检:拉一条在职数据,登录失效直接抛错,避免跑完一半才发现。"""
|
||||
try:
|
||||
fetch_wage_card_page(session, status=1, page_no=1, page_size=1)
|
||||
except HRSessionExpiredError:
|
||||
raise RuntimeError(LOGIN_EXPIRED_MSG)
|
||||
logger.info("HR 登录态校验通过")
|
||||
|
||||
|
||||
def get_leave_range(today=None, start_override="", end_override=""):
|
||||
"""计算离职日期筛选范围,返回 (开始日期, 结束日期) 字符串 YYYY-MM-DD。
|
||||
|
||||
自动规则(与影刀版一致):每月 8 号及之前 -> 上月 1 日 ~ 今天;8 号之后 -> 本月 1 日 ~ 今天。
|
||||
两个覆盖值都填写时优先使用覆盖值(补跑历史月份用)。
|
||||
"""
|
||||
start_override = (start_override or "").strip()
|
||||
end_override = (end_override or "").strip()
|
||||
if start_override and end_override:
|
||||
logger.info("离职日期范围使用手动指定:%s ~ %s", start_override, end_override)
|
||||
return start_override, end_override
|
||||
|
||||
today = today or date.today()
|
||||
if today.day <= 8:
|
||||
first_this_month = today.replace(day=1)
|
||||
last_prev_month = first_this_month - timedelta(days=1)
|
||||
start = last_prev_month.replace(day=1)
|
||||
else:
|
||||
start = today.replace(day=1)
|
||||
return start.strftime("%Y-%m-%d"), today.strftime("%Y-%m-%d")
|
||||
@@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0005 插件 - 逻辑层:卡号校验与核对分类规则。"""
|
||||
@@ -0,0 +1,121 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0005 插件 - 核对主逻辑:原始数据成表、剔除、逐行核对、结果视图。
|
||||
|
||||
与影刀版 bank_card_check.py 的 check_wage_card 等价,仅把「读 xlsx / 写 xlsx」拆到报告层。
|
||||
"""
|
||||
import pandas as pd
|
||||
|
||||
from ..config import (
|
||||
ABNORMAL_COL_MAP, COL_BANK_ACCOUNT, COL_BANK_NAME, COL_BANK_REASON,
|
||||
COL_BANK_STATUS, COL_CARD_IDCARD, COL_CARD_NAME, COL_CHECK_BASIS,
|
||||
COL_CHECK_RESULT, COL_IDCARD, COL_MAP, COL_REMARK, COL_STAFF_NAME,
|
||||
EXCLUDE_NAME_KEYWORDS, SHOW_ORDER, logger,
|
||||
)
|
||||
from ..data.bank_dict import bank_type_to_name, get_bank_dict
|
||||
from .card_validate import classify_card_issue, clean_str, is_empty, normalize_id
|
||||
|
||||
PASS_LABEL = "通过"
|
||||
DAIFA_LABEL = "代发"
|
||||
|
||||
# 完整核对结果中置前的核对列
|
||||
CHECK_COLS = [COL_CHECK_RESULT, COL_CHECK_BASIS, COL_BANK_STATUS, COL_BANK_REASON]
|
||||
|
||||
|
||||
def build_wage_card_df(data_on_job, data_leave, session=None):
|
||||
"""合并在职/离职原始数据,字段映射为中文、补充开卡银行并调整列顺序。"""
|
||||
if not (data_on_job or data_leave):
|
||||
raise RuntimeError("未查询到任何工资卡数据,无法构建核对表")
|
||||
total_all = list(data_on_job) + list(data_leave)
|
||||
df = pd.DataFrame(total_all)
|
||||
df.rename(columns=COL_MAP, inplace=True)
|
||||
_ensure_bank_name_col(df, session)
|
||||
exist_cols = [c for c in SHOW_ORDER if c in df.columns]
|
||||
other_cols = [c for c in df.columns if c not in exist_cols]
|
||||
df = df[exist_cols + other_cols]
|
||||
logger.info("在职数据:%d 条", len(data_on_job))
|
||||
logger.info("离职数据:%d 条", len(data_leave))
|
||||
logger.info("合计总数据:%d 条", len(total_all))
|
||||
return df
|
||||
|
||||
|
||||
def _ensure_bank_name_col(df, session=None):
|
||||
"""缺「开卡银行」列时按银行编码(BANK_TYPE)用字典接口补齐(原地修改)。"""
|
||||
if "开卡银行" in df.columns or "银行编码" not in df.columns:
|
||||
return
|
||||
_, bank_map = get_bank_dict(session)
|
||||
df["开卡银行"] = df["银行编码"].apply(lambda c: bank_type_to_name(c, bank_map))
|
||||
logger.info("已按银行字典补齐开卡银行列(字典 %d 条)", len(bank_map or {}))
|
||||
|
||||
|
||||
def exclude_virtual_rows(df):
|
||||
"""剔除员工姓名含「虚拟/人资/测试」的记录(不参与核对),返回 (df, 剔除条数)。"""
|
||||
name_raw = df[COL_STAFF_NAME].astype(str).fillna("")
|
||||
exclude_mask = pd.Series(False, index=df.index)
|
||||
for kw in EXCLUDE_NAME_KEYWORDS:
|
||||
exclude_mask |= name_raw.str.contains(kw, na=False)
|
||||
if exclude_mask.any():
|
||||
logger.info("剔除姓名含 %s 的记录 %d 条(不参与核对)",
|
||||
" / ".join(EXCLUDE_NAME_KEYWORDS), int(exclude_mask.sum()))
|
||||
df = df[~exclude_mask].reset_index(drop=True)
|
||||
return df, int(exclude_mask.sum())
|
||||
return df, 0
|
||||
|
||||
|
||||
def annotate(df, session=None):
|
||||
"""逐行核对并写入核对列(原地修改),返回统计信息 dict。"""
|
||||
_ensure_bank_name_col(df, session)
|
||||
|
||||
no_bank_rows = []
|
||||
for idx, row in df.iterrows():
|
||||
idcard = normalize_id(row.get(COL_IDCARD, ""))
|
||||
card_idcard = normalize_id(row.get(COL_CARD_IDCARD, ""))
|
||||
staff_name = clean_str(row.get(COL_STAFF_NAME, ""))
|
||||
card_name = clean_str(row.get(COL_CARD_NAME, ""))
|
||||
bank_account = row.get(COL_BANK_ACCOUNT, "")
|
||||
|
||||
issues, basis, bk = classify_card_issue(
|
||||
idcard, card_idcard, staff_name, card_name, bank_account,
|
||||
bank_name=row.get(COL_BANK_NAME, ""), remark=row.get(COL_REMARK, ""),
|
||||
)
|
||||
if is_empty(bank_account):
|
||||
no_bank_rows.append(idx)
|
||||
|
||||
df.at[idx, COL_CHECK_RESULT] = "、".join(issues) if issues else PASS_LABEL
|
||||
df.at[idx, COL_CHECK_BASIS] = ";".join(basis) if basis else ""
|
||||
df.at[idx, COL_BANK_STATUS] = bk["status"] if bk else ""
|
||||
df.at[idx, COL_BANK_REASON] = bk["reason"] if bk else ""
|
||||
|
||||
result_counts = df[df[COL_CHECK_RESULT] != PASS_LABEL][COL_CHECK_RESULT].value_counts().to_dict()
|
||||
bank_issues = df[df[COL_BANK_STATUS] != "正常"][COL_BANK_STATUS].value_counts().to_dict()
|
||||
passed = int((df[COL_CHECK_RESULT] == PASS_LABEL).sum())
|
||||
|
||||
logger.info("核对完成:通过 %d / 总计 %d", passed, len(df))
|
||||
if result_counts:
|
||||
logger.info("核对问题分布:%s", result_counts)
|
||||
if bank_issues:
|
||||
logger.info("银行卡问题:%s", bank_issues)
|
||||
|
||||
return {
|
||||
"total": len(df),
|
||||
"passed": passed,
|
||||
"no_bank": len(no_bank_rows),
|
||||
"daifa": int((df[COL_CHECK_RESULT] == DAIFA_LABEL).sum()),
|
||||
}
|
||||
|
||||
|
||||
def build_abnormal_view(df):
|
||||
"""异常名单精简视图:按 ABNORMAL_COL_MAP 取列 + 异常原因,按原因排序便于查看。
|
||||
|
||||
异常 = 核对结果既不是「通过」也不是纯「代发」(代发 + BIN 错误仍纳入)。
|
||||
"""
|
||||
mask = (df[COL_CHECK_RESULT] != PASS_LABEL) & (df[COL_CHECK_RESULT] != DAIFA_LABEL)
|
||||
src = df[mask].sort_values(COL_CHECK_RESULT, kind="stable")
|
||||
view = pd.DataFrame({out: src.get(col) for col, out in ABNORMAL_COL_MAP.items()})
|
||||
view["异常原因"] = src[COL_CHECK_RESULT]
|
||||
return view
|
||||
|
||||
|
||||
def build_full_view(df):
|
||||
"""完整核对结果:核对列置前,其余列保持原顺序。"""
|
||||
other_cols = [c for c in df.columns if c not in CHECK_COLS]
|
||||
return df[CHECK_COLS + other_cols]
|
||||
@@ -0,0 +1,173 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0005 插件 - 银行卡号校验与核对分类(口径照搬影刀版,不改变判定结果)。
|
||||
|
||||
银行卡号校验(check_bank_card):
|
||||
空白 / 非纯数字 / <16 位 -> 无效(附原因)
|
||||
非 62 开头且非老版储蓄卡 BIN -> 16 位且以 53/54/55/4 开头记「疑似信用卡」,其余「无效」
|
||||
62 开头:按 BIN 表判断标准位数(BIN_16=16 位、BIN_18=18 位、其余按 19 位),
|
||||
位数不符 -> 「错误」;位数相符 -> 「正常」
|
||||
|
||||
核对分类(classify_card_issue):
|
||||
1. 开卡银行/银行卡号/备注任一含「现金」-> 「现金发放」,其余不再核对
|
||||
2. 开户人姓名/身份证/银行卡三项全空 -> 「未提供银行卡」;单项空白单独标注
|
||||
3. 姓名与身份证均与开户人不一致 -> 「代发」(不算异常)
|
||||
4. 仅身份证不一致 -> 异常;仅姓名不一致 -> 「姓名不一致身份证一致」
|
||||
5. 银行卡非空但格式/位数错误 -> 「银行卡信息异常(原因)」
|
||||
"""
|
||||
import re
|
||||
|
||||
from ..config import BIN_16, BIN_18, NON62_BIN
|
||||
|
||||
NUM_REG = re.compile(r"^\d+$")
|
||||
|
||||
# 核对结果标签:通过 / 代发 不算异常
|
||||
PASS_LABEL = "通过"
|
||||
DAIFA_LABEL = "代发"
|
||||
|
||||
|
||||
def is_empty(val):
|
||||
"""None / NaN / 空串 / 'nan'/'none'/'null' 视为空。"""
|
||||
if val is None:
|
||||
return True
|
||||
if isinstance(val, float) and val != val:
|
||||
return True
|
||||
s = str(val).strip()
|
||||
return s == "" or s.lower() in ("nan", "none", "null")
|
||||
|
||||
|
||||
def clean_str(val):
|
||||
"""安全转字符串并去首尾空白;None/NaN 返回空串(避免 str(None) 变成 'None' 被误判非空)。"""
|
||||
if val is None:
|
||||
return ""
|
||||
if isinstance(val, float) and val != val:
|
||||
return ""
|
||||
return str(val).strip()
|
||||
|
||||
|
||||
def normalize_id(val):
|
||||
"""身份证/卡号归一化:数值型去 .0,字符串去空格。"""
|
||||
if val is None:
|
||||
return ""
|
||||
if isinstance(val, float):
|
||||
if val != val:
|
||||
return ""
|
||||
return str(int(val))
|
||||
if isinstance(val, int):
|
||||
return str(val)
|
||||
return str(val).strip().replace(" ", "")
|
||||
|
||||
|
||||
def check_bank_card(card_raw):
|
||||
"""校验单个银行卡号,返回 {card, status, reason};status ∈ 正常/错误/无效/疑似信用卡。"""
|
||||
card = str(card_raw).strip()
|
||||
if isinstance(card_raw, float):
|
||||
if card_raw != card_raw:
|
||||
card = ""
|
||||
else:
|
||||
card = str(int(card_raw))
|
||||
elif isinstance(card_raw, int):
|
||||
card = str(card_raw)
|
||||
else:
|
||||
card = str(card_raw).strip().replace(" ", "")
|
||||
|
||||
if not card:
|
||||
return {"card": card, "status": "无效", "reason": "空白,无卡号"}
|
||||
if not NUM_REG.match(card):
|
||||
return {"card": card, "status": "无效", "reason": "非纯数字,属于文字备注/脏数据"}
|
||||
|
||||
card_len = len(card)
|
||||
# 纯数字但位数过短(<16 位):填写错误/卡号截断(如只填了 0、123 等),不再走 BIN 校验
|
||||
if card_len < 16:
|
||||
return {"card": card, "status": "无效", "reason": f"卡号过短仅{card_len}位,填写错误"}
|
||||
|
||||
bin6 = card[:6]
|
||||
if not (card.startswith("62") or bin6 in NON62_BIN):
|
||||
# 非银联卡但属国际信用卡(万事达 53/54/55、Visa 4 开头,标准 16 位)
|
||||
if len(card) == 16 and (card.startswith(("53", "54", "55")) or card.startswith("4")):
|
||||
return {"card": card, "status": "疑似信用卡", "reason": "非银联储蓄卡-疑似信用卡"}
|
||||
return {"card": card, "status": "无效", "reason": "非62开头,非标准银联储蓄卡"}
|
||||
|
||||
if card_len not in (16, 18, 19):
|
||||
return {"card": card, "status": "错误", "reason": f"位数异常{card_len}位,仅支持16/18/19位银行卡"}
|
||||
|
||||
if bin6 in BIN_16:
|
||||
if card_len == 16:
|
||||
return {"card": card, "status": "正常", "reason": "合规16位银联卡"}
|
||||
return {"card": card, "status": "错误", "reason": f"BIN{bin6}标准16位,录入位数错误"}
|
||||
if bin6 in BIN_18:
|
||||
if card_len == 18:
|
||||
return {"card": card, "status": "正常", "reason": "合规18位兴业储蓄卡"}
|
||||
return {"card": card, "status": "错误", "reason": f"BIN{bin6}标准18位,录入位数错误"}
|
||||
if card_len == 19:
|
||||
return {"card": card, "status": "正常", "reason": "合规19位储蓄卡"}
|
||||
return {"card": card, "status": "错误", "reason": f"BIN{bin6}标准19位,录入位数错误,需人工核对"}
|
||||
|
||||
|
||||
def classify_card_issue(idcard, card_idcard, staff_name, card_name, bank_account,
|
||||
bank_name="", remark=""):
|
||||
"""按核对规则对单条工资卡记录分类,返回 (issues, basis, bank_info)。
|
||||
|
||||
issues : 标签列表(写入「核对结果」);代发不算异常,除非银行卡 BIN 核对错误
|
||||
basis : 校验依据列表(写入「校验依据」)
|
||||
bank_info: check_bank_card 结果(无卡时为 None)
|
||||
"""
|
||||
idcard = normalize_id(idcard)
|
||||
card_idcard = normalize_id(card_idcard)
|
||||
staff_name = clean_str(staff_name)
|
||||
card_name = clean_str(card_name)
|
||||
bank_account = clean_str(bank_account)
|
||||
bank_name = clean_str(bank_name)
|
||||
remark = clean_str(remark)
|
||||
|
||||
issues = []
|
||||
basis = []
|
||||
|
||||
# ---- 0. 现金发放优先 ----
|
||||
if any("现金" in str(v) for v in (bank_name, bank_account, remark)):
|
||||
return ["现金发放"], ["开卡银行/银行卡号/备注含「现金」,标记为现金发放"], None
|
||||
|
||||
# ---- 1. 开户人信息 / 银行卡空白 ----
|
||||
blank_id = is_empty(card_idcard)
|
||||
blank_name = is_empty(card_name)
|
||||
blank_bank = is_empty(bank_account)
|
||||
if blank_id and blank_name and blank_bank:
|
||||
issues.append("未提供银行卡")
|
||||
basis.append("未提供银行卡(开户人姓名/身份证/银行卡均空白)")
|
||||
else:
|
||||
if blank_id:
|
||||
issues.append("开户人身份证空白")
|
||||
basis.append("开户人身份证空白")
|
||||
if blank_name:
|
||||
issues.append("开户人姓名空白")
|
||||
basis.append("开户人姓名空白")
|
||||
if blank_bank:
|
||||
issues.append("银行卡空白")
|
||||
basis.append("银行卡空白")
|
||||
|
||||
# ---- 2. 代发 / 身份证、姓名不一致 ----
|
||||
id_inconsistent = (not is_empty(card_idcard)) and idcard != card_idcard
|
||||
name_inconsistent = (not is_empty(card_name)) and staff_name != card_name
|
||||
if id_inconsistent and name_inconsistent:
|
||||
issues.append("代发")
|
||||
basis.append(f"代发(员工:{staff_name}/{idcard} vs 开户人:{card_name}/{card_idcard})")
|
||||
else:
|
||||
if id_inconsistent:
|
||||
issues.append("员工身份证与开户人身份证不一致")
|
||||
basis.append(f"身份证不一致(员工:{idcard} vs 开户人:{card_idcard})")
|
||||
if name_inconsistent:
|
||||
issues.append("姓名不一致身份证一致")
|
||||
basis.append(f"姓名不一致身份证一致(员工:{staff_name} vs 开户人:{card_name})")
|
||||
|
||||
# ---- 3. 银行卡信息异常 / 疑似信用卡 ----
|
||||
bank_info = None
|
||||
if not is_empty(bank_account):
|
||||
bank_info = check_bank_card(bank_account)
|
||||
if bank_info["status"] != "正常":
|
||||
if bank_info["status"] == "疑似信用卡":
|
||||
issues.append("非银联储蓄卡-疑似信用卡")
|
||||
basis.append("非银联储蓄卡-疑似信用卡")
|
||||
else:
|
||||
issues.append(f"银行卡信息异常({bank_info['reason']})")
|
||||
basis.append(f"银行卡信息异常({bank_info['reason']})")
|
||||
|
||||
return issues, basis, bank_info
|
||||
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"id": "xq0005",
|
||||
"name": "银行卡检查",
|
||||
"version": "1.0.0",
|
||||
"description": "下载在职 + 离职工资卡数据,按 BIN 规则核对银行卡号并比对员工与开户人姓名/身份证,输出单工作簿三 sheet(工资卡异常名单 / 完整核对结果 / 原始数据),可选推送结果摘要到钉钉群机器人。",
|
||||
"category": "人事薪酬",
|
||||
"icon": "",
|
||||
"platform": "hr",
|
||||
"uses_month": false,
|
||||
"ui": true,
|
||||
"capabilities": ["xq0005"],
|
||||
"permissions": {
|
||||
"platforms": ["hr"]
|
||||
},
|
||||
"fields": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"save_dir": {
|
||||
"type": "string",
|
||||
"title": "输出目录",
|
||||
"default": "D:\\资料\\人资\\银行卡检查",
|
||||
"description": "结果工作簿(工资卡核对结果.xlsx)输出目录"
|
||||
},
|
||||
"leave_start": {
|
||||
"type": "string",
|
||||
"title": "离职日期起",
|
||||
"default": "",
|
||||
"description": "留空=自动(每月8号及以前:上月1日~今天;8号之后:本月1日~今天);补跑历史月份时手填 YYYY-MM-DD"
|
||||
},
|
||||
"leave_end": {
|
||||
"type": "string",
|
||||
"title": "离职日期止",
|
||||
"default": "",
|
||||
"description": "留空=今天;与「离职日期起」成对填写,只填一个时按自动范围处理"
|
||||
},
|
||||
"push_webhook": {
|
||||
"type": "string",
|
||||
"title": "钉钉群机器人 Webhook",
|
||||
"default": "",
|
||||
"description": "留空=只导出不推送;填写后推送核对摘要(文本,附件需到输出目录自取)"
|
||||
},
|
||||
"push_secret": {
|
||||
"type": "string",
|
||||
"title": "钉钉机器人加签密钥",
|
||||
"format": "password",
|
||||
"default": "",
|
||||
"description": "机器人安全设置为「加签」时填写,未配置加签则留空"
|
||||
}
|
||||
},
|
||||
"required": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0005 插件 - 报告层:工作簿导出、结果推送与流程编排。"""
|
||||
@@ -0,0 +1,137 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0005 插件 - 报告编排层:下载工资卡 → 核对 → 单工作簿三 sheet → 可选群机器人摘要。
|
||||
|
||||
主流程(与影刀版 run_bank_card_check 一致,去掉影刀全局变量/推送指令交接):
|
||||
1) 登录态预检:底座注入 HR session,拉一条数据验证,失效提示重新登录;
|
||||
2) 在职 / 离职工资卡全量拉取(离职按 leave_start~leave_end 筛选);
|
||||
3) 成表 → 剔除虚拟/测试人员 → 逐行核对(BIN + 姓名/身份证);
|
||||
4) 导出单工作簿:工资卡异常名单 / 工资卡完整核对结果 / 工资卡原始数据;
|
||||
5) 配置了群机器人 Webhook 时推送核对摘要(文本,不含附件)。
|
||||
"""
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from ..config import (
|
||||
DEFAULT_SAVE_DIR, RESULT_NAME, SHEET_ABNORMAL, SHEET_DATA, SHEET_FULL, logger,
|
||||
require_session,
|
||||
)
|
||||
from ..data import wage_card_api
|
||||
from ..logic.bank_card_check import (
|
||||
annotate, build_abnormal_view, build_full_view, build_wage_card_df,
|
||||
exclude_virtual_rows,
|
||||
)
|
||||
from .dingtalk_robot import send_markdown
|
||||
|
||||
|
||||
def export_workbook(abnormal_view, full_df, raw_df, output_path):
|
||||
"""导出单工作簿(三个 sheet),返回绝对路径;文件被占用/目录无权限时给出友好提示。"""
|
||||
os.makedirs(os.path.dirname(os.path.abspath(output_path)), exist_ok=True)
|
||||
try:
|
||||
with pd.ExcelWriter(output_path, engine="openpyxl") as writer:
|
||||
abnormal_view.to_excel(writer, sheet_name=SHEET_ABNORMAL, index=False)
|
||||
full_df.to_excel(writer, sheet_name=SHEET_FULL, index=False)
|
||||
raw_df.to_excel(writer, sheet_name=SHEET_DATA, index=False)
|
||||
except PermissionError:
|
||||
raise RuntimeError(
|
||||
f"导出失败:文件正被占用,请先关闭已打开的 Excel"
|
||||
f"「{os.path.basename(output_path)}」后重试。无需重查数据。")
|
||||
except OSError as e:
|
||||
raise RuntimeError(
|
||||
f"导出失败:无法写入文件「{output_path}」({e}),请检查磁盘空间或目录权限")
|
||||
|
||||
logger.info("核对结果已保存(单工作簿):%s", output_path)
|
||||
logger.info(" %s sheet:%d 条", SHEET_ABNORMAL, len(abnormal_view))
|
||||
logger.info(" %s sheet:%d 条(全量)", SHEET_FULL, len(full_df))
|
||||
logger.info(" %s sheet:%d 条", SHEET_DATA, len(raw_df))
|
||||
return os.path.abspath(output_path)
|
||||
|
||||
|
||||
def build_push_text(stats, leave_range, path):
|
||||
"""构造群机器人推送文案(Markdown):核对结论 + 结果文件路径。"""
|
||||
text = (
|
||||
f"### 银行卡检查完成\n"
|
||||
f"- 核对:通过 **{stats['passed']}** / 总计 {stats['total']}\n"
|
||||
f"- 工资卡异常:**{stats['abnormal']}** 人(含无工资卡 {stats['no_bank']} 人)\n"
|
||||
f"- 代发:{stats['daifa']} 人\n"
|
||||
f"- 离职筛选范围:{leave_range[0]} ~ {leave_range[1]}\n"
|
||||
f"- 结果文件:`{path}`\n"
|
||||
f"- 附件请到上述路径自取(群机器人不支持发文件)"
|
||||
)
|
||||
return text
|
||||
|
||||
|
||||
def run_bank_card_check(save_dir=None, leave_start="", leave_end="",
|
||||
push_webhook="", push_secret="", progress=None):
|
||||
"""执行银行卡检查主流程。
|
||||
|
||||
Returns:
|
||||
dict: {
|
||||
path 结果工作簿路径, stats 统计, leave_range 离职筛选范围,
|
||||
excluded 剔除虚拟/测试人数, push 推送结果 {success,message}
|
||||
}
|
||||
"""
|
||||
def _step(pct):
|
||||
if progress:
|
||||
try:
|
||||
progress(pct)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
save_dir = (save_dir or "").strip() or DEFAULT_SAVE_DIR
|
||||
output_path = os.path.join(save_dir, RESULT_NAME)
|
||||
|
||||
# ---- 1. 登录态预检 ----
|
||||
_step(5)
|
||||
session = require_session()
|
||||
wage_card_api.precheck(session)
|
||||
_step(12)
|
||||
|
||||
# ---- 2. 离职筛选范围 + 在职/离职数据拉取 ----
|
||||
leave_range = wage_card_api.get_leave_range(start_override=leave_start, end_override=leave_end)
|
||||
logger.info("===== 开始抓取在职人员工资卡数据 =====")
|
||||
data_on_job = wage_card_api.fetch_all_wage_card(session, status=1, status_name="在职")
|
||||
_step(45)
|
||||
|
||||
logger.info("===== 开始抓取离职人员工资卡数据(%s ~ %s)=====", leave_range[0], leave_range[1])
|
||||
data_leave = wage_card_api.fetch_all_wage_card(
|
||||
session, status=2, status_name="离职",
|
||||
leave_start=leave_range[0], leave_end=leave_range[1],
|
||||
)
|
||||
_step(60)
|
||||
|
||||
# ---- 3. 成表 → 剔除 → 核对 ----
|
||||
df = build_wage_card_df(data_on_job, data_leave, session=session)
|
||||
df, excluded = exclude_virtual_rows(df)
|
||||
raw_df = df.copy() # 未核对的原始数据(工资卡原始数据 sheet)
|
||||
stats = annotate(df, session=session)
|
||||
abnormal_view = build_abnormal_view(df)
|
||||
stats["abnormal"] = len(abnormal_view)
|
||||
_step(78)
|
||||
|
||||
# ---- 4. 导出单工作簿 ----
|
||||
full_df = build_full_view(df)
|
||||
path = export_workbook(abnormal_view, full_df, raw_df, output_path)
|
||||
_step(92)
|
||||
|
||||
# ---- 5. 群机器人摘要推送(可选) ----
|
||||
push_result = {"success": False, "message": "未配置 Webhook,跳过推送"}
|
||||
if (push_webhook or "").strip():
|
||||
text = build_push_text(stats, leave_range, path)
|
||||
push_result = send_markdown(push_webhook, push_secret, "银行卡检查完成", text)
|
||||
if not push_result.get("success"):
|
||||
logger.warning("结果摘要推送失败(不影响导出):%s", push_result.get("message"))
|
||||
_step(100)
|
||||
|
||||
logger.info("=" * 60)
|
||||
logger.info("【银行卡检查完成】")
|
||||
logger.info(" 核对:通过 %d / 总计 %d", stats["passed"], stats["total"])
|
||||
logger.info(" 工资卡异常 %d 人(含无工资卡 %d 人),代发 %d 人",
|
||||
stats["abnormal"], stats["no_bank"], stats["daifa"])
|
||||
logger.info(" 剔除虚拟/测试记录 %d 条", excluded)
|
||||
logger.info(" 结果文件:%s", path)
|
||||
logger.info("=" * 60)
|
||||
|
||||
return {"path": path, "stats": stats, "leave_range": leave_range,
|
||||
"excluded": excluded, "push": push_result}
|
||||
@@ -0,0 +1,70 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0005 插件 - 钉钉群机器人推送(仅标准库,符合插件自包含约束)。
|
||||
|
||||
推送原理(HTTP Webhook):按钉钉加签规则(HMAC-SHA256 + Base64 + URL 编码)生成签名,
|
||||
向机器人 Webhook 推送 Markdown 消息,失败自动重试 3 次(项目级重试约定)。
|
||||
|
||||
限制说明:群机器人只能发文本/Markdown,不能发文件附件——结果工作簿留在本机输出目录,
|
||||
消息里给出绝对路径,由人工自取(与影刀版「发 xlsx 到群」的差异点)。
|
||||
"""
|
||||
import base64
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import time
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
from ..config import logger
|
||||
|
||||
DEFAULT_TIMEOUT = 10
|
||||
DEFAULT_RETRY_TIMES = 3
|
||||
|
||||
|
||||
def _build_sign(secret, timestamp_ms):
|
||||
"""按钉钉加签规则计算签名(HMAC-SHA256 + Base64 + URL 编码)。"""
|
||||
string_to_sign = f"{timestamp_ms}\n{secret}"
|
||||
hmac_code = hmac.new(secret.encode("utf-8"), string_to_sign.encode("utf-8"),
|
||||
digestmod=hashlib.sha256).digest()
|
||||
return urllib.parse.quote_plus(base64.b64encode(hmac_code))
|
||||
|
||||
|
||||
def _build_url(webhook, secret=""):
|
||||
"""拼接最终推送地址:配置了 secret 时追加 timestamp + sign 参数。"""
|
||||
if not secret:
|
||||
return webhook
|
||||
ts = int(round(time.time() * 1000))
|
||||
separator = "&" if "?" in webhook else "?"
|
||||
return f"{webhook}{separator}timestamp={ts}&sign={_build_sign(secret, ts)}"
|
||||
|
||||
|
||||
def send_markdown(webhook, secret, title, text):
|
||||
"""向群机器人推送 Markdown 消息,返回 {success, message};webhook 为空时跳过。"""
|
||||
webhook = (webhook or "").strip()
|
||||
if not webhook:
|
||||
return {"success": False, "message": "未配置 Webhook,跳过推送"}
|
||||
payload = {
|
||||
"msgtype": "markdown",
|
||||
"markdown": {"title": title or "通知", "text": text or ""},
|
||||
}
|
||||
body = json.dumps(payload, ensure_ascii=False).encode("utf-8")
|
||||
url = _build_url(webhook, (secret or "").strip())
|
||||
last_err = ""
|
||||
for attempt in range(1, DEFAULT_RETRY_TIMES + 1):
|
||||
try:
|
||||
req = urllib.request.Request(
|
||||
url, data=body, method="POST",
|
||||
headers={"Content-Type": "application/json; charset=utf-8"})
|
||||
with urllib.request.urlopen(req, timeout=DEFAULT_TIMEOUT) as resp:
|
||||
raw = resp.read().decode("utf-8", errors="replace")
|
||||
data = json.loads(raw) if raw else {}
|
||||
if data.get("errcode") == 0:
|
||||
logger.info("钉钉群消息推送成功")
|
||||
return {"success": True, "message": "ok"}
|
||||
last_err = f"errcode={data.get('errcode')} errmsg={data.get('errmsg')}"
|
||||
except Exception as e:
|
||||
last_err = str(e)
|
||||
logger.warning("钉钉推送第 %d/%d 次失败:%s", attempt, DEFAULT_RETRY_TIMES, last_err)
|
||||
if attempt < DEFAULT_RETRY_TIMES:
|
||||
time.sleep(1.0 * attempt)
|
||||
return {"success": False, "message": last_err}
|
||||
@@ -0,0 +1,2 @@
|
||||
pandas>=2.0
|
||||
openpyxl>=3.1
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>EHR系统离职电子签流程审核</title>
|
||||
<title>银行卡检查</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "xq0005-ui",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.3.2",
|
||||
"element-plus": "^2.14.5",
|
||||
"vue": "^3.5.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.2.1",
|
||||
"vite": "^6.0.3"
|
||||
},
|
||||
"allowScripts": {
|
||||
"esbuild@0.25.12": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,432 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<!-- 未登录 / 结果横幅 -->
|
||||
<transition name="fade-slide">
|
||||
<el-alert v-if="needLogin" type="warning" :closable="false" show-icon
|
||||
title="未登录:请先在壳子(工作台)登录统一账户,再刷新本界面" />
|
||||
<el-alert v-else-if="banner" :type="banner.type" :closable="true" show-icon @close="banner = null">
|
||||
<template #title>{{ banner.text }}</template>
|
||||
</el-alert>
|
||||
</transition>
|
||||
|
||||
<!-- 执行配置(头部含多配置方案:方案供「定时任务」引用,到点自动取方案最新参数) -->
|
||||
<el-card shadow="never" class="panel">
|
||||
<template #header>
|
||||
<div class="panel-head">
|
||||
<div class="panel-title">
|
||||
<span class="title-ico">
|
||||
<svg viewBox="0 0 24 24" width="17" height="17" fill="none" stroke="currentColor"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2" />
|
||||
<rect x="9" y="3" width="6" height="4" rx="1" />
|
||||
<path d="m9 14 2 2 4-4" />
|
||||
</svg>
|
||||
</span>
|
||||
<div class="title-txts">
|
||||
<div class="title-txt">执行配置</div>
|
||||
<div class="title-sub">参数自动保存到本机,方案供定时任务到点引用</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="head-tools">
|
||||
<span v-if="lastSavedAt" class="saved">
|
||||
<i class="dot" />已保存 {{ lastSavedAt }}
|
||||
</span>
|
||||
<el-select v-model="schemeSel" class="scheme-sel" size="small" :disabled="running"
|
||||
@change="onSchemeChange">
|
||||
<el-option v-for="o in schemeOptions" :key="o.value" :label="o.label" :value="o.value" />
|
||||
</el-select>
|
||||
<el-button size="small" :disabled="running" @click="saveSchemeAs">存为方案</el-button>
|
||||
<el-button size="small" text type="danger" :disabled="running || !schemeSel"
|
||||
@click="removeScheme">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-form label-position="top">
|
||||
<!-- 输出 -->
|
||||
<section class="sec">
|
||||
<div class="sec-head">
|
||||
<span class="sec-badge">01</span>
|
||||
<span class="sec-name">输出</span>
|
||||
<span class="sec-line" />
|
||||
</div>
|
||||
<div class="grid">
|
||||
<el-form-item label="输出目录">
|
||||
<el-input v-model="form.save_dir" :disabled="running" clearable
|
||||
placeholder="留空 = D:\资料\人资\银行卡检查" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="tip">
|
||||
结果输出单工作簿《工资卡核对结果.xlsx》,含三个 sheet:
|
||||
工资卡异常名单 / 工资卡完整核对结果 / 工资卡原始数据。
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 离职筛选范围 -->
|
||||
<section class="sec">
|
||||
<div class="sec-head">
|
||||
<span class="sec-badge">02</span>
|
||||
<span class="sec-name">离职筛选范围</span>
|
||||
<span class="sec-line" />
|
||||
</div>
|
||||
<div class="grid">
|
||||
<el-form-item label="离职日期起">
|
||||
<el-date-picker v-model="form.leave_start" type="date" value-format="YYYY-MM-DD"
|
||||
placeholder="留空 = 自动" :disabled="running" clearable class="wide" />
|
||||
</el-form-item>
|
||||
<el-form-item label="离职日期止">
|
||||
<el-date-picker v-model="form.leave_end" type="date" value-format="YYYY-MM-DD"
|
||||
placeholder="留空 = 自动(今天)" :disabled="running" clearable class="wide" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="tip">
|
||||
留空按自动规则:每月 8 号及以前取「上月 1 日 ~ 今天」,8 号之后取「本月 1 日 ~ 今天」;
|
||||
补跑历史月份时两个字段都填(只填一个仍按自动处理)。
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 钉钉推送(可选) -->
|
||||
<section class="sec">
|
||||
<div class="sec-head">
|
||||
<span class="sec-badge">03</span>
|
||||
<span class="sec-name">钉钉推送(可选)</span>
|
||||
<span class="sec-line" />
|
||||
</div>
|
||||
<div class="grid">
|
||||
<el-form-item label="群机器人 Webhook">
|
||||
<el-input v-model="form.push_webhook" :disabled="running" clearable
|
||||
placeholder="留空 = 只导出不推送" />
|
||||
</el-form-item>
|
||||
<el-form-item label="加签密钥">
|
||||
<el-input v-model="form.push_secret" type="password" show-password
|
||||
:disabled="running" clearable placeholder="机器人未开启加签则留空" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="tip">
|
||||
推送内容为核对摘要文本(通过数 / 异常数 / 代发数 / 结果文件路径);
|
||||
群机器人不支持发文件,结果工作簿请到输出目录自取。
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 操作 -->
|
||||
<div class="actions">
|
||||
<el-button type="primary" size="large" class="btn-run" :loading="running" @click="run">
|
||||
{{ running ? '执行中 ' + progress + '%' : '一键执行' }}
|
||||
</el-button>
|
||||
<el-button v-if="running" type="danger" size="large" plain :loading="stopping"
|
||||
@click="forceStop">强制停止</el-button>
|
||||
<span class="spacer" />
|
||||
<el-button size="large" :disabled="running" @click="saveNow(true)">保存配置</el-button>
|
||||
<el-button size="large" text :disabled="running" @click="resetDefaults">恢复默认</el-button>
|
||||
</div>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<!-- 运行状态:进度条 + 日志位置提示(日志实时显示在壳子下方日志区) -->
|
||||
<transition name="fade-slide">
|
||||
<div v-if="running" class="status">
|
||||
<el-progress :percentage="progress" :stroke-width="10" :show-text="false" class="status-bar" />
|
||||
<div class="status-row">
|
||||
<span class="pulse" />
|
||||
<span class="status-txt">正在执行,日志与进度实时显示在工作台下方【运行日志】区</span>
|
||||
<span class="status-pct">{{ progress }}%</span>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { usePluginUI } from './usePluginUI'
|
||||
|
||||
const DEFAULTS = () => ({
|
||||
save_dir: 'D:\\资料\\人资\\银行卡检查',
|
||||
leave_start: '', // 留空 = 自动计算离职筛选范围
|
||||
leave_end: '',
|
||||
push_webhook: '', // 留空 = 只导出不推送
|
||||
push_secret: '',
|
||||
})
|
||||
|
||||
const {
|
||||
form, needLogin, banner, lastSavedAt, running, progress, stopping,
|
||||
saveNow, resetDefaults,
|
||||
schemeSel, schemeOptions, onSchemeChange, saveSchemeAs, removeScheme,
|
||||
run, forceStop,
|
||||
} = usePluginUI({
|
||||
defaults: DEFAULTS,
|
||||
validate() {
|
||||
if (!!form.leave_start !== !!form.leave_end) {
|
||||
ElMessage.warning('离职日期起 / 止 需同时填写;留空则按自动范围'); return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
// 仅提交后端 run() 读取的字段
|
||||
buildPayload(f) {
|
||||
return {
|
||||
save_dir: f.save_dir,
|
||||
leave_start: f.leave_start,
|
||||
leave_end: f.leave_end,
|
||||
push_webhook: f.push_webhook,
|
||||
push_secret: f.push_secret,
|
||||
}
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* ---------- 页面骨架 ---------- */
|
||||
.page {
|
||||
width: 100%;
|
||||
padding: 6px 4px 28px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.fade-slide-enter-active,
|
||||
.fade-slide-leave-active {
|
||||
transition: opacity 0.25s ease, transform 0.25s ease;
|
||||
}
|
||||
.fade-slide-enter-from,
|
||||
.fade-slide-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(-6px);
|
||||
}
|
||||
|
||||
/* ---------- 主容器(无边框平铺:外层由壳子 iframe 的边框统一包裹) ---------- */
|
||||
.panel {
|
||||
background: transparent;
|
||||
border-radius: 0;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
.panel :deep(.el-card__header) {
|
||||
padding: 6px 2px 16px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
background: transparent;
|
||||
}
|
||||
.panel :deep(.el-card__body) {
|
||||
padding: 16px 2px 2px;
|
||||
}
|
||||
|
||||
/* ---------- 卡片头部 ---------- */
|
||||
.panel-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.panel-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
.title-ico {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--el-color-primary);
|
||||
background: linear-gradient(135deg, var(--el-color-primary-light-8), var(--el-color-primary-light-6));
|
||||
box-shadow: inset 0 0 0 1px var(--el-color-primary-light-5);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.title-txts {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
.title-txt {
|
||||
font-weight: 700;
|
||||
font-size: 15px;
|
||||
line-height: 1.2;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
.title-sub {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
line-height: 1.3;
|
||||
}
|
||||
.head-tools {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.scheme-sel {
|
||||
width: 200px;
|
||||
}
|
||||
.saved {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
color: #2ea44f;
|
||||
background: rgba(46, 164, 79, 0.1);
|
||||
border: 1px solid rgba(46, 164, 79, 0.25);
|
||||
padding: 2px 10px;
|
||||
border-radius: 999px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.saved .dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: #2ea44f;
|
||||
}
|
||||
|
||||
/* ---------- 表单分区 ---------- */
|
||||
.sec {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.sec:last-of-type {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.sec-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.sec-badge {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 7px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--el-color-primary);
|
||||
background: var(--el-color-primary-light-9);
|
||||
border: 1px solid var(--el-color-primary-light-7);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.sec-name {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.sec-line {
|
||||
flex: 1;
|
||||
height: 1px;
|
||||
background: linear-gradient(90deg, var(--el-border-color-lighter), transparent);
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: 0 18px;
|
||||
}
|
||||
.grid :deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.grid :deep(.el-form-item__label) {
|
||||
padding-bottom: 6px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.grid :deep(.el-date-editor) {
|
||||
width: 100%;
|
||||
}
|
||||
.wide {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tip {
|
||||
width: 100%;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
line-height: 1.6;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
/* ---------- 操作区 ---------- */
|
||||
.actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
border-top: 1px dashed var(--el-border-color);
|
||||
padding-top: 18px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
.spacer {
|
||||
flex: 1;
|
||||
}
|
||||
.btn-run {
|
||||
min-width: 150px;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
letter-spacing: 2px;
|
||||
background: linear-gradient(135deg, var(--el-color-primary), var(--el-color-primary-dark-2));
|
||||
box-shadow: 0 6px 16px var(--el-color-primary-light-6);
|
||||
transition: filter 0.2s, box-shadow 0.2s, transform 0.15s;
|
||||
}
|
||||
.btn-run:hover {
|
||||
filter: brightness(1.06);
|
||||
box-shadow: 0 8px 20px var(--el-color-primary-light-5);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
.btn-run:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
.btn-run.is-loading {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* ---------- 运行状态 ---------- */
|
||||
.status {
|
||||
padding: 14px 16px;
|
||||
border-radius: 12px;
|
||||
background: linear-gradient(135deg, var(--el-color-primary-light-9), var(--el-color-primary-light-8));
|
||||
border: 1px solid var(--el-color-primary-light-6);
|
||||
box-shadow: 0 2px 10px var(--el-color-primary-light-7);
|
||||
}
|
||||
.status-bar :deep(.el-progress-bar__outer) {
|
||||
background: rgba(64, 158, 255, 0.15);
|
||||
}
|
||||
.status-bar :deep(.el-progress-bar__inner) {
|
||||
background: linear-gradient(90deg, var(--el-color-primary), var(--el-color-primary-dark-2));
|
||||
}
|
||||
.status-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
.pulse {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--el-color-primary);
|
||||
animation: pulse 1.4s ease-out infinite;
|
||||
}
|
||||
@keyframes pulse {
|
||||
0% {
|
||||
box-shadow: 0 0 0 0 var(--el-color-primary-light-6);
|
||||
}
|
||||
70% {
|
||||
box-shadow: 0 0 0 8px transparent;
|
||||
}
|
||||
100% {
|
||||
box-shadow: 0 0 0 0 transparent;
|
||||
}
|
||||
}
|
||||
.status-txt {
|
||||
flex: 1;
|
||||
font-size: 12.5px;
|
||||
color: var(--el-text-color-regular);
|
||||
line-height: 1.5;
|
||||
}
|
||||
.status-pct {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: var(--el-color-primary);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,2 @@
|
||||
// 插件身份声明(API 实现收敛在 usePluginUI.js 公共 kit,各插件 ui-src 只需声明自己的 id)
|
||||
export const PLUGIN_ID = 'xq0005'
|
||||
@@ -0,0 +1,340 @@
|
||||
// 插件 UI 公共 kit(vendored 进各插件 ui-src,构建期内联进产物,运行零外部依赖)。
|
||||
// 收敛三块通用逻辑,App.vue 只保留各插件差异部分(表单字段/校验/布局):
|
||||
// 1. 本机当前配置:加载、防抖自动保存、恢复默认(/api/plugin-config/<id>)
|
||||
// 2. 多配置方案:列表/应用/存为方案/删除(/api/plugin-configs,同名覆盖、密码明文保存;
|
||||
// 供壳子「定时任务」按 config_id 引用,到点自动取方案最新参数)
|
||||
// 3. 执行状态机:一键执行、强制停止、WS 实时进度 + 轮询兜底、未登录重试
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { PLUGIN_ID } from './api'
|
||||
|
||||
async function j(url, opts) {
|
||||
const res = await fetch(url, opts)
|
||||
if (res.status === 401) {
|
||||
throw Object.assign(new Error('未登录:请先在壳子登录统一账户再打开本界面'), { code: 401 })
|
||||
}
|
||||
if (!res.ok) {
|
||||
let msg = `HTTP ${res.status}`
|
||||
try { msg = (await res.json()).detail || msg } catch (_) { /* 保留默认 */ }
|
||||
throw new Error(msg)
|
||||
}
|
||||
return res.json()
|
||||
}
|
||||
|
||||
// ---- 后端 API(同源,统一账户会话 cookie 自动携带)----
|
||||
function loadConfig() {
|
||||
return j(`/api/plugin-config/${PLUGIN_ID}`)
|
||||
}
|
||||
|
||||
function saveConfig(data) {
|
||||
return j(`/api/plugin-config/${PLUGIN_ID}`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
}
|
||||
|
||||
function listSchemes() {
|
||||
return j(`/api/plugin-configs?plugin_id=${encodeURIComponent(PLUGIN_ID)}`)
|
||||
}
|
||||
|
||||
function saveScheme(name, fields) {
|
||||
return j('/api/plugin-configs', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ plugin_id: PLUGIN_ID, name, fields }),
|
||||
})
|
||||
}
|
||||
|
||||
function deleteScheme(cfgId) {
|
||||
return j(`/api/plugin-configs/${encodeURIComponent(PLUGIN_ID)}/${encodeURIComponent(cfgId)}`, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
}
|
||||
|
||||
function startRun(fields) {
|
||||
return j('/api/runs', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ plugin_id: PLUGIN_ID, fields }),
|
||||
})
|
||||
}
|
||||
|
||||
function getRun(runId) {
|
||||
return j(`/api/runs/${runId}`)
|
||||
}
|
||||
|
||||
function stopRun(runId) {
|
||||
return j(`/api/runs/${runId}/stop`, { method: 'POST' })
|
||||
}
|
||||
|
||||
function connectWS(onEvent) {
|
||||
const ws = new WebSocket((location.protocol === 'https:' ? 'wss://' : 'ws://')
|
||||
+ location.host + '/ws')
|
||||
ws.onmessage = (e) => { try { onEvent(JSON.parse(e.data)) } catch (_) { /* 忽略脏帧 */ } }
|
||||
return ws
|
||||
}
|
||||
|
||||
// ---- 工具 ----
|
||||
const clone = (o) => JSON.parse(JSON.stringify(o))
|
||||
|
||||
// 保存字段合并规则:标量空值(''/null/undefined)不覆盖;数组照原样应用——
|
||||
// 空数组可能是有意配置(如 xq0031 仓库留空 = 全部不筛选),必须还原
|
||||
function mergeSaved(form, saved) {
|
||||
Object.keys(form).forEach((k) => {
|
||||
const v = saved ? saved[k] : undefined
|
||||
if (v === undefined || v === null || v === '') return
|
||||
form[k] = Array.isArray(v) ? [...v] : v
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件 UI 公共状态机
|
||||
* @param {Object} opts
|
||||
* @param {Function} opts.defaults 默认表单工厂;恢复默认时传入当前表单作参考
|
||||
* (如 xq0031 按当前 erp_system 带出对应默认组织/仓库)
|
||||
* @param {Function} [opts.validate] 执行前校验,失败自行 ElMessage 提示并返回 false
|
||||
* @param {Function} [opts.buildPayload] 定制提交参数(缺省 = 表单全量深拷贝)
|
||||
*/
|
||||
export function usePluginUI(opts = {}) {
|
||||
const { defaults, validate, buildPayload } = opts
|
||||
|
||||
const form = reactive(defaults ? defaults() : {})
|
||||
const loaded = ref(false)
|
||||
const needLogin = ref(false)
|
||||
const banner = ref(null)
|
||||
const lastSavedAt = ref('')
|
||||
const running = ref(false)
|
||||
const progress = ref(0)
|
||||
const stopping = ref(false)
|
||||
|
||||
let ws = null
|
||||
let runId = ''
|
||||
let pollTimer = null
|
||||
let saveTimer = null
|
||||
|
||||
// ---------- 当前配置:加载 / 防抖自动保存 ----------
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const saved = await loadConfig()
|
||||
mergeSaved(form, saved)
|
||||
} catch (e) {
|
||||
if (e.code === 401) needLogin.value = true
|
||||
else ElMessage.warning('读取本机配置失败,已用默认值:' + e.message)
|
||||
}
|
||||
loaded.value = true
|
||||
refreshSchemes() // 方案列表一并加载:重开界面/切插件回来(iframe 重挂载)后,下拉仍列出全部已存方案
|
||||
})
|
||||
|
||||
// 配置变更自动保存(防抖 800ms),执行中不保存
|
||||
watch(form, () => {
|
||||
if (!loaded.value || running.value) return
|
||||
clearTimeout(saveTimer)
|
||||
saveTimer = setTimeout(() => saveNow(false), 800)
|
||||
}, { deep: true })
|
||||
|
||||
async function saveNow(explicit) {
|
||||
try {
|
||||
await saveConfig(clone(form))
|
||||
lastSavedAt.value = new Date().toLocaleTimeString('zh-CN', { hour12: false })
|
||||
if (explicit) ElMessage.success('配置已保存到本机')
|
||||
} catch (e) {
|
||||
if (e.code === 401) needLogin.value = true
|
||||
else ElMessage.error('配置保存失败:' + e.message)
|
||||
}
|
||||
}
|
||||
|
||||
function resetDefaults() {
|
||||
Object.assign(form, defaults ? defaults(form) : {})
|
||||
ElMessage.info('已恢复默认配置')
|
||||
}
|
||||
|
||||
// ---------- 多配置方案(定时任务引用的参数快照,在插件界面维护) ----------
|
||||
const schemes = ref([]) // [{id, name, fields, at}]
|
||||
const schemeSel = ref('') // '' = 当前配置(即表单本身)
|
||||
const schemeOptions = computed(() => [
|
||||
{ value: '', label: '当前配置(自动保存)' },
|
||||
...schemes.value.map((s) => ({ value: s.id, label: s.name })),
|
||||
])
|
||||
|
||||
async function refreshSchemes() {
|
||||
try {
|
||||
const r = await listSchemes()
|
||||
schemes.value = r.configs || []
|
||||
} catch (_) {
|
||||
/* 方案是辅助能力,加载失败静默(下拉仅剩当前配置) */
|
||||
}
|
||||
}
|
||||
|
||||
// 应用方案:载入方案字段(密码随方案明文保存)→ 防抖自动保存固化为当前配置;
|
||||
// 执行永远提交表单当前值,方案本身只作为定时任务的参数快照源
|
||||
function onSchemeChange(id) {
|
||||
if (!id) return // 切回「当前配置」:表单即当前配置,无需动作
|
||||
const s = schemes.value.find((x) => x.id === id)
|
||||
if (!s) return
|
||||
mergeSaved(form, s.fields)
|
||||
ElMessage.success(`已应用方案「${s.name}」`)
|
||||
}
|
||||
|
||||
async function saveSchemeAs() {
|
||||
const cur = schemes.value.find((x) => x.id === schemeSel.value)
|
||||
let name = ''
|
||||
try {
|
||||
({ value: name } = await ElMessageBox.prompt(
|
||||
'方案保存到本机(同名覆盖,密码明文保存,每套方案可绑定不同账号),供「定时任务」引用:到点自动取该方案的最新参数执行。',
|
||||
'存为配置方案',
|
||||
{
|
||||
inputValue: cur ? cur.name : '',
|
||||
confirmButtonText: '保存方案',
|
||||
cancelButtonText: '取消',
|
||||
inputPattern: /\S/,
|
||||
inputErrorMessage: '请输入方案名称',
|
||||
}
|
||||
))
|
||||
} catch (_) {
|
||||
return // 用户取消
|
||||
}
|
||||
name = String(name).trim()
|
||||
if (!name) return
|
||||
const dup = schemes.value.find((x) => x.name === name)
|
||||
if (dup) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`已存在同名方案「${dup.name}」,保存将覆盖它的参数(多套不同配置请用不同名称)。`,
|
||||
'覆盖已有方案',
|
||||
{ type: 'warning', confirmButtonText: '覆盖保存', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch (_) {
|
||||
return // 用户取消覆盖
|
||||
}
|
||||
}
|
||||
try {
|
||||
const r = await saveScheme(name, clone(form))
|
||||
await refreshSchemes()
|
||||
schemeSel.value = r.config ? r.config.id : ''
|
||||
ElMessage.success(`方案「${name}」已保存`)
|
||||
} catch (e) {
|
||||
if (e.code === 401) needLogin.value = true
|
||||
else ElMessage.error('方案保存失败:' + e.message)
|
||||
}
|
||||
}
|
||||
|
||||
async function removeScheme() {
|
||||
const s = schemes.value.find((x) => x.id === schemeSel.value)
|
||||
if (!s) return
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`删除配置方案「${s.name}」?引用它的定时任务到点会跳过触发并提示重选。`,
|
||||
'删除方案',
|
||||
{ type: 'warning', confirmButtonText: '删除', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch (_) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await deleteScheme(s.id)
|
||||
schemeSel.value = ''
|
||||
await refreshSchemes()
|
||||
ElMessage.success('方案已删除')
|
||||
} catch (e) {
|
||||
ElMessage.error('方案删除失败:' + e.message)
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 执行 ----------
|
||||
async function run() {
|
||||
if (running.value) return
|
||||
// 未登录不再静默返回:先重试一次配置读取(会话可能在打开后已恢复),仍失败则明确提示
|
||||
if (needLogin.value) {
|
||||
try {
|
||||
await loadConfig()
|
||||
needLogin.value = false
|
||||
ElMessage.success('登录态已恢复,请再次点击执行')
|
||||
return
|
||||
} catch (_) { /* 仍未登录 */ }
|
||||
ElMessage.warning('未登录:请先在壳子登录统一账户,再打开本界面')
|
||||
return
|
||||
}
|
||||
if (validate && !validate()) return
|
||||
await saveNow(false)
|
||||
running.value = true
|
||||
progress.value = 0
|
||||
banner.value = null
|
||||
try {
|
||||
const r = await startRun(buildPayload ? buildPayload(form) : clone(form))
|
||||
runId = r.run_id
|
||||
connect() // runId 就绪后再连 WS,避免早到的运行事件被过滤掉
|
||||
startPolling()
|
||||
} catch (e) {
|
||||
running.value = false
|
||||
stopPolling()
|
||||
if (e.code === 401) needLogin.value = true
|
||||
banner.value = { type: 'error', text: '启动执行失败:' + e.message }
|
||||
}
|
||||
}
|
||||
|
||||
// 强制停止(整树强杀执行子进程,含浏览器)
|
||||
async function forceStop() {
|
||||
if (!runId || stopping.value) return
|
||||
stopping.value = true
|
||||
try {
|
||||
await stopRun(runId)
|
||||
ElMessage.warning('已发出强制停止指令,正在终止执行进程…')
|
||||
} catch (e) {
|
||||
ElMessage.error('停止失败:' + e.message)
|
||||
} finally {
|
||||
stopping.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 实时进度 + 完成(WS 只取进度/结束事件,日志由壳子下方日志区展示;断开后轮询兜底)
|
||||
function connect() {
|
||||
if (ws && ws.readyState <= 1) return
|
||||
ws = connectWS((ev) => {
|
||||
if (ev.run_id && ev.run_id !== runId) return // 只看本次运行
|
||||
if (ev.t === 'progress') progress.value = Math.max(progress.value, ev.pct || 0)
|
||||
else if (ev.t === 'run_done') ev.ok ? finished() : failed(ev.error || '执行失败')
|
||||
})
|
||||
ws.onclose = () => { ws = null }
|
||||
}
|
||||
|
||||
function startPolling() {
|
||||
stopPolling()
|
||||
pollTimer = setInterval(async () => {
|
||||
if (!runId) return
|
||||
try {
|
||||
const r = await getRun(runId)
|
||||
if (r.status === 'done') finished(r.result?.summary || '执行完成')
|
||||
else if (r.status === 'error') failed(r.error || '执行失败')
|
||||
} catch (_) { /* 下轮再试 */ }
|
||||
}, 5000)
|
||||
}
|
||||
|
||||
function stopPolling() {
|
||||
if (pollTimer) { clearInterval(pollTimer); pollTimer = null }
|
||||
}
|
||||
|
||||
function finished(summary) {
|
||||
stopPolling()
|
||||
running.value = false
|
||||
progress.value = 100
|
||||
banner.value = { type: 'success', text: summary || '执行完成' }
|
||||
}
|
||||
|
||||
function failed(err) {
|
||||
stopPolling()
|
||||
running.value = false
|
||||
banner.value = { type: 'error', text: '执行失败:' + err }
|
||||
}
|
||||
|
||||
return {
|
||||
// 状态
|
||||
form, loaded, needLogin, banner, lastSavedAt, running, progress, stopping,
|
||||
// 当前配置
|
||||
saveNow, resetDefaults,
|
||||
// 多配置方案
|
||||
schemes, schemeSel, schemeOptions, onSchemeChange, saveSchemeAs, removeScheme,
|
||||
// 执行
|
||||
run, forceStop,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
// 插件 UI 由壳子后端托管在 /pui/xq0005/ 下,
|
||||
// 构建产物直接输出到插件包 ui/ 目录(随插件 zip 发布,壳子零改动)。
|
||||
// dev 模式经代理访问本机壳子后端,便于联调。
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
base: '/pui/xq0005/',
|
||||
build: {
|
||||
outDir: '../ui',
|
||||
emptyOutDir: true,
|
||||
},
|
||||
server: {
|
||||
port: 5183,
|
||||
proxy: {
|
||||
'/api': 'http://127.0.0.1:8799',
|
||||
'/ws': { target: 'ws://127.0.0.1:8799', ws: true },
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>银行卡检查</title>
|
||||
<script type="module" crossorigin src="/pui/xq0005/assets/index-DGZu9_gw.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/pui/xq0005/assets/index-BEGkJ9zj.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,81 @@
|
||||
# XQ0013 社保费用申报导出并汇总(插件版)
|
||||
|
||||
迁移自影刀工程(16 个流程,见 `docs/需求单/XQ0001-0100/XQ0013 社保费用申报导出并汇总/`)。
|
||||
目标:按月批量登录重庆社保客户端(`EPEvenue_SB.exe`),完成日常/特殊申报、申报记录导出,并合并汇总。
|
||||
|
||||
## 当前进度(v0.1.0)
|
||||
|
||||
| 能力 | 影刀来源 | 状态 |
|
||||
|---|---|---|
|
||||
| 图像模板库(45 个) | `imagesV2.xml` + `resources/images/*.png` | ✅ 已导入 `images/`(含 `manifest.json`:threshold/gray/scales) |
|
||||
| Win32 元素库(22 个) | `selectorsV2.xml` | ✅ 已导入 `selectors/selectors.xml`,`data/selectors.py` 用 FindWindowEx 逐层定位 |
|
||||
| 账户列表读取/回写 | 自定义指令 `mjqywawyv` / `m8k8hi9j8` | ✅ `data/accounts.py` |
|
||||
| 客户端启动 | process1 | ✅ `logic/client.start_client`(重试 3 次 + 等窗口) |
|
||||
| 登录 | process2 | ✅ `logic/client.login`(元素填税号 → 滑块 → 图像点登录 → 输密码 → 等菜单栏) |
|
||||
| 弹窗清理 | process3 | ✅ `logic/client.clean_popups` |
|
||||
| 添加单位 | process6 | ⏳ 未迁移(新账户首次登录会明确报错提示) |
|
||||
| 日常申报导出 | process4 / 9 / 10 | ⏳ 未迁移 |
|
||||
| 特殊申报导出 | process5 / 13 | ⏳ 未迁移 |
|
||||
| 申报记录识别 | process8 | ⏳ 未迁移 |
|
||||
| 征集信息导出 | process12 | ⏳ 未迁移 |
|
||||
| 明细合并(19 列去重) | merge | ⏳ 未迁移 |
|
||||
| PDF 金额汇总 | process14 | ⏳ 未迁移(依赖 camelot + pymupdf,影刀版也缺依赖) |
|
||||
|
||||
## 运行方式
|
||||
|
||||
插件界面选择 **执行模式 = check**:启动客户端 → 登录账户列表里第一家待执行门店 → 清弹窗 → 关闭。
|
||||
用于验证「客户端路径 / 元素库 / 模板」在当前机器是否可用,不会做任何申报动作。
|
||||
|
||||
`full` 模式目前会明确抛出「尚未迁移完成」,避免半成品误操作生产数据。
|
||||
|
||||
## 账户列表约定
|
||||
|
||||
`账户列表.xlsx`(默认 `输出目录/账户列表.xlsx`):
|
||||
|
||||
| 列 | 含义 |
|
||||
|---|---|
|
||||
| A | 门店 |
|
||||
| B | 税号 |
|
||||
| C | 密码 |
|
||||
| E | 执行标记:`0`=待执行,`1`=跳过;其他值(含空)跳过 |
|
||||
|
||||
## 目录结构
|
||||
|
||||
```
|
||||
XQ0013 社保费用申报导出并汇总/
|
||||
├── __init__.py ScenePlugin 入口(mode=check/full)
|
||||
├── plugin.json 元数据与参数表单
|
||||
├── config/__init__.py 路径常量、模板名/元素名、manifest 参数读取、日志钩子
|
||||
├── data/
|
||||
│ ├── accounts.py 账户列表读/写(A门店 B税号 C密码 E标记)
|
||||
│ └── selectors.py 影刀 Win32 元素库解析与操作(查找/赋值/点击/截图/拖动)
|
||||
├── logic/
|
||||
│ └── client.py 启动 / 登录 / 弹窗清理 / 关闭
|
||||
├── report/__init__.py 编排与汇总(待补)
|
||||
├── images/ 45 个影刀模板 + manifest.json
|
||||
├── selectors/selectors.xml 22 个 Win32 元素选择器
|
||||
├── _pack.py 打包到 dist-plugin/xq0013_v<版本>.zip
|
||||
└── requirements.txt
|
||||
```
|
||||
|
||||
## 依赖
|
||||
|
||||
执行机需预装(`requirements.txt` 声明):
|
||||
|
||||
```
|
||||
pandas openpyxl pywin32 ddddocr
|
||||
```
|
||||
|
||||
以及仓库内桌面自动化库(不从 PyPI 装):
|
||||
|
||||
```powershell
|
||||
python-env\<版本>\python.exe -m pip install wheel
|
||||
python-env\<版本>\python.exe -m pip install -e <仓库>\libs\desktopauto
|
||||
```
|
||||
|
||||
## 迁移注意
|
||||
|
||||
- 影刀登录用的是 **Win32 元素**(税号框 / 滑动栏)而不是图像——老 Delphi 客户端没有 UIA 树,
|
||||
但 Win32 控件层次完整,`FindWindowEx` 逐层找比图像稳,优先走 `data/selectors.py`。
|
||||
- 图像只用于「视觉判断」的位置:登录按钮、菜单栏、错误弹窗、申报页签等。
|
||||
- 影刀 `process14`(PDF 汇总)在影刀里就缺 `camelot`/`pymupdf` 依赖,迁移时一并补。
|
||||
@@ -0,0 +1,110 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0013 社保费用申报导出并汇总 插件入口(迁移自影刀工程 16 个流程)。
|
||||
|
||||
当前进度(v0.1.0,分阶段迁移):
|
||||
✅ 影刀 45 个图像模板 + 22 个 Win32 元素库已导入插件包(images/、selectors/)
|
||||
✅ 账户列表读取/回写(对应自定义指令 mjqywawyv / m8k8hi9j8)
|
||||
✅ 客户端启动、登录(元素填税号 + 滑块 + 图像点登录 + OCR 判账户)、弹窗清理
|
||||
⏳ 待迁移:日常申报导出(process4/9/10)、特殊申报导出(process5/13)、申报记录识别(process8)、
|
||||
征集信息导出(process12)、添加单位(process6)、明细合并(merge)、PDF 金额汇总(process14)
|
||||
|
||||
因此 run() 目前只提供 `check` 模式(启动 → 登录第一家有账户 → 清弹窗 → 关闭),
|
||||
用于验证客户端路径、元素库、模板在当前机器上是否可用;`full` 模式会明确提示未完成。
|
||||
"""
|
||||
from webhost.backend.plugins.base import ScenePlugin, PLUGINS
|
||||
|
||||
from . import config
|
||||
from .data import accounts
|
||||
from .logic import client
|
||||
|
||||
|
||||
class SocialDeclarePlugin(ScenePlugin):
|
||||
"""社保费用申报导出并汇总(需求 XQ0013)。"""
|
||||
|
||||
id = "xq0013"
|
||||
name = "社保费用申报导出并汇总"
|
||||
version = "0.1.0"
|
||||
description = ("按月批量登录重庆社保客户端完成日常/特殊申报与记录导出并汇总。"
|
||||
"当前版本已迁移:账户列表读写、客户端启动、登录(Win32 元素+图像+OCR)、弹窗清理;"
|
||||
"申报导出与汇总流程待迁移,run 请使用 check 模式验证环境。")
|
||||
platform = "" # 客户端本地登录,不依赖底座平台登录态
|
||||
uses_month = False
|
||||
capabilities = ["xq0013"]
|
||||
permissions = {"platforms": []}
|
||||
fields = {
|
||||
"mode": {
|
||||
"type": "string", "title": "执行模式", "default": "check",
|
||||
"enum": ["check", "full"],
|
||||
"description": "check=只验证环境(启动→登录第一家有账户→清弹窗→关闭);"
|
||||
"full=完整批量申报(申报导出流程尚未迁移,会提示未完成)",
|
||||
},
|
||||
"client_exe": {
|
||||
"type": "string", "title": "社保客户端程序",
|
||||
"default": r"D:\Program Files (x86)\EPPortal_SB1.0\EPEvenue_SB.exe",
|
||||
"description": "EPEvenue_SB.exe 的完整路径",
|
||||
},
|
||||
"save_dir": {
|
||||
"type": "string", "title": "输出目录",
|
||||
"default": r"D:\资料\人资\社保费用申报导出汇总",
|
||||
"description": "账户列表、申报结果、职工未申报明细、截图等统一根目录",
|
||||
},
|
||||
"account_file": {
|
||||
"type": "string", "title": "账户列表文件", "default": "",
|
||||
"description": "留空 = 输出目录/账户列表.xlsx(A门店 B税号 C密码 E执行标记:0待执行/1跳过)",
|
||||
},
|
||||
}
|
||||
|
||||
def run(self, fields: dict, ctx):
|
||||
config.set_log(ctx.log)
|
||||
config.configure(
|
||||
client_exe=fields.get("client_exe") or "",
|
||||
save_dir=fields.get("save_dir") or "",
|
||||
account_file=fields.get("account_file") or "",
|
||||
)
|
||||
mode = (fields.get("mode") or "check").strip().lower()
|
||||
dirs = config.ensure_dirs()
|
||||
ctx.progress(2)
|
||||
ctx.log(f"===== 社保费用申报({mode}):输出目录 {dirs['base']} =====", "INFO")
|
||||
|
||||
acct_file = config.account_file()
|
||||
accts = accounts.load_accounts(acct_file)
|
||||
ctx.progress(8)
|
||||
|
||||
if mode == "full":
|
||||
raise RuntimeError(
|
||||
"完整申报流程尚未迁移完成(日常/特殊申报导出、申报记录识别、合并与汇总)。\n"
|
||||
"请先用「执行模式 = check」验证客户端路径、元素库与模板可用性。")
|
||||
|
||||
# ---- check 模式:启动 → 登录第一个账户 → 清弹窗 → 关闭 ----
|
||||
acct = accts[0]
|
||||
ctx.log(f"待执行账户 {len(accts)} 家,本次验证门店:{acct['store']}", "INFO")
|
||||
win = None
|
||||
try:
|
||||
win, sel = client.start_client(config.client_exe())
|
||||
ctx.progress(35)
|
||||
ok = client.login(acct["tax_no"], acct["password"], sel, store=acct["store"])
|
||||
ctx.progress(75)
|
||||
client.clean_popups()
|
||||
ctx.progress(90)
|
||||
summary = (f"环境验证通过:门店「{acct['store']}」登录成功"
|
||||
f"(窗口 {win.title},元素库 {len(sel.names())} 个元素,"
|
||||
f"模板 {len(config.manifest())} 个)" if ok else "登录未成功")
|
||||
finally:
|
||||
client.close_client()
|
||||
ctx.progress(100)
|
||||
|
||||
return {
|
||||
"summary": summary,
|
||||
"detail": {
|
||||
"模式": mode,
|
||||
"验证门店": acct["store"],
|
||||
"待执行账户数": len(accts),
|
||||
"账户列表": acct_file,
|
||||
"元素库元素数": 22,
|
||||
"模板数": len(config.manifest()),
|
||||
},
|
||||
"path": dirs["base"],
|
||||
}
|
||||
|
||||
|
||||
PLUGINS.append(SocialDeclarePlugin())
|
||||
@@ -0,0 +1,47 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0013 社保费用申报导出并汇总 插件打包脚本(统一规范版)。
|
||||
|
||||
打包产物统一输出到仓库根 dist-plugin/<id>_v<版本>.zip(目录不入库),
|
||||
zip 根含 plugin.json,可被 agent_cli publish 直接发布。
|
||||
images/(影刀模板 45 个 + manifest.json)与 selectors/(Win32 元素库)随包发布。
|
||||
|
||||
用法(任意 cwd 均可):
|
||||
d:\\work\\code\\37duAutomation\\.venv\\Scripts\\python.exe "plugins\\XQ0001-0100\\XQ0013 社保费用申报导出并汇总\\_pack.py"
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
_HERE = Path(__file__).resolve().parent
|
||||
_REPO_ROOT = _HERE.parents[2]
|
||||
_OUT_DIR = _REPO_ROOT / "dist-plugin"
|
||||
|
||||
_EXCLUDE_DIRS = {"ui-src", "__pycache__", ".git", ".idea", "debug", ".sessions"}
|
||||
_EXCLUDE_FILES = {"_pack.py"}
|
||||
_EXCLUDE_SUFFIXES = (".pyc", ".pyo")
|
||||
|
||||
|
||||
def main():
|
||||
manifest = json.loads((_HERE / "plugin.json").read_text(encoding="utf-8"))
|
||||
pid = manifest["id"]
|
||||
ver = manifest["version"]
|
||||
if manifest.get("ui") and not (_HERE / "ui" / "index.html").is_file():
|
||||
sys.exit(f"插件 {pid} 声明 ui=true 但缺少 ui/index.html:请先在 ui-src 下执行 npm install && npm run build")
|
||||
_OUT_DIR.mkdir(exist_ok=True)
|
||||
out = _OUT_DIR / f"{pid}_v{ver}.zip"
|
||||
count = 0
|
||||
with zipfile.ZipFile(out, "w", zipfile.ZIP_DEFLATED) as zf:
|
||||
for p in sorted(_HERE.rglob("*")):
|
||||
rel = p.relative_to(_HERE)
|
||||
if set(rel.parts) & _EXCLUDE_DIRS or p.name in _EXCLUDE_FILES \
|
||||
or p.suffix in _EXCLUDE_SUFFIXES:
|
||||
continue
|
||||
if p.is_file():
|
||||
zf.write(p, str(rel))
|
||||
count += 1
|
||||
print(f"已打包: {out}({count} 个文件,{out.stat().st_size / 1024:.0f} KB)")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,216 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0013 社保费用申报导出并汇总 插件 - 配置常量与全局钩子。
|
||||
|
||||
插件自包含:只依赖 标准库 / pandas / openpyxl / pywin32 / ddddocr / desktopauto(执行机预装)。
|
||||
模板图与 Win32 元素库随插件包发布:
|
||||
images/*.png + images/manifest.json 影刀图像库导出(45 个)
|
||||
selectors/selectors.xml 影刀 Win32 元素库(22 个)
|
||||
|
||||
运行期参数(客户端路径、账户列表路径、输出目录)由 plugin.json.fields 注入,
|
||||
经 configure() 覆盖默认值;未注入时用下面的默认常量(与影刀版一致)。
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
|
||||
# ==================== 插件内资源路径 ====================
|
||||
PLUGIN_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
IMAGES_DIR = os.path.join(PLUGIN_ROOT, "images")
|
||||
MANIFEST_FILE = os.path.join(IMAGES_DIR, "manifest.json")
|
||||
SELECTORS_XML = os.path.join(PLUGIN_ROOT, "selectors", "selectors.xml")
|
||||
|
||||
# ==================== 默认业务配置(与影刀版全局变量一致) ====================
|
||||
DEFAULT_CLIENT_EXE = r"D:\Program Files (x86)\EPPortal_SB1.0\EPEvenue_SB.exe"
|
||||
CLIENT_TITLE = "社保费管理客户端"
|
||||
CLIENT_CLASS = "TfrmCompMgrMerge"
|
||||
CLIENT_PROCESS = "EPPortalSB.exe" # 实际进程名(启动后)
|
||||
CLIENT_PROCESS_ALT = "EPEvenue_SB.exe" # 可执行文件名
|
||||
DEFAULT_SAVE_DIR = r"D:\资料\人资\社保费用申报导出汇总"
|
||||
ACCOUNT_FILE_NAME = "账户列表.xlsx"
|
||||
|
||||
# 账户列表列约定(影刀版:A=门店 B=税号 C=密码 E=执行标记)
|
||||
COL_STORE = 0
|
||||
COL_TAX_NO = 1
|
||||
COL_PASSWORD = 2
|
||||
COL_FLAG = 4
|
||||
FLAG_PENDING = "0" # E 列 = 0 → 待执行
|
||||
FLAG_DONE = "1" # E 列 = 1 → 已完成/跳过
|
||||
|
||||
# ==================== 模板名(images/manifest.json 的 key) ====================
|
||||
TPL = {
|
||||
"image": "图像",
|
||||
"login_btn": "登录按钮",
|
||||
"login_confirm": "确定登录按钮",
|
||||
"menu_bar": "菜单栏",
|
||||
"error_msg": "错误信息",
|
||||
"error_confirm": "错误处理确认",
|
||||
"social_declare": "社保费申报",
|
||||
"daily_declare": "日常申报",
|
||||
"special_declare": "特殊缴费申报",
|
||||
"view_detail": "查看职工未申报明细",
|
||||
"detail_query_area": "职工未申报明细导出查询区域",
|
||||
"detail_export": "职工未申报明细导出按钮",
|
||||
"export_ok_confirm": "导出成功确定按钮",
|
||||
"detail_close": "职工未申报明细关闭按钮",
|
||||
"select_all": "全选复选框",
|
||||
"submit_declare": "提交申报按钮",
|
||||
"tip_msg": "提示信息",
|
||||
"tip_confirm": "提示信息确定按钮",
|
||||
"server_error": "服务器连接异常",
|
||||
"server_error_confirm": "服务器连接异常确定按钮",
|
||||
"refresh_btn": "刷新按钮",
|
||||
"big_data": "明细数据量大",
|
||||
"submit_confirm": "提交申报确认",
|
||||
"submit": "提交申报",
|
||||
"declare_ok": "申报成功",
|
||||
"record_query": "申报结果查询",
|
||||
"add_unit": "添加单位",
|
||||
"next_step": "下一步",
|
||||
"confirm_unit": "确认单位",
|
||||
"security_auth": "安全认证",
|
||||
"cancel_btn": "取消按钮",
|
||||
"add_btn": "添加按钮",
|
||||
"multi_source": "多数据来源",
|
||||
"data_source": "数据来源",
|
||||
"tax_generated": "税务生成",
|
||||
"collect_info": "征集信息",
|
||||
"query_btn": "查询按钮",
|
||||
"declare_record": "申报记录",
|
||||
"latest_status": "申报数据最新状态",
|
||||
"record_query_btn": "申报结果查询按钮",
|
||||
"view_btn": "查看按钮",
|
||||
"export_btn": "导出按钮",
|
||||
"collect_serial": "征集通知流水号",
|
||||
"tax_selected": "税务生成选中",
|
||||
"reset_btn": "重置按钮",
|
||||
}
|
||||
|
||||
# ==================== Win32 元素名(selectors/selectors.xml) ====================
|
||||
ELE = {
|
||||
"tax_no_input": "税号输入框",
|
||||
"password_input": "密码框",
|
||||
"slider_bar": "滑动栏",
|
||||
"slider_pos": "位置",
|
||||
"pending_account": "待选账户",
|
||||
}
|
||||
|
||||
# ==================== 运行期配置(configure 注入) ====================
|
||||
_client_exe = DEFAULT_CLIENT_EXE
|
||||
_save_dir = DEFAULT_SAVE_DIR
|
||||
_account_file = ""
|
||||
|
||||
|
||||
def configure(client_exe: str = "", save_dir: str = "", account_file: str = "") -> None:
|
||||
"""由插件 run() 注入本次运行的业务配置(空值保持默认)。"""
|
||||
global _client_exe, _save_dir, _account_file
|
||||
if (client_exe or "").strip():
|
||||
_client_exe = client_exe.strip()
|
||||
if (save_dir or "").strip():
|
||||
_save_dir = save_dir.strip()
|
||||
_account_file = (account_file or "").strip()
|
||||
|
||||
|
||||
def client_exe() -> str:
|
||||
return _client_exe
|
||||
|
||||
|
||||
def save_dir() -> str:
|
||||
return _save_dir
|
||||
|
||||
|
||||
def account_file() -> str:
|
||||
"""账户列表路径:未指定则取 输出目录/账户列表.xlsx。"""
|
||||
return _account_file or os.path.join(_save_dir, ACCOUNT_FILE_NAME)
|
||||
|
||||
|
||||
def dirs() -> dict:
|
||||
"""各输出子目录(按需创建)。"""
|
||||
base = _save_dir
|
||||
return {
|
||||
"base": base,
|
||||
"screenshots": os.path.join(base, "截图"),
|
||||
"declare": os.path.join(base, "申报结果"),
|
||||
"detail": os.path.join(base, "职工未申报明细"),
|
||||
"summary": os.path.join(base, "汇总"),
|
||||
}
|
||||
|
||||
|
||||
def ensure_dirs() -> dict:
|
||||
d = dirs()
|
||||
for key, path in d.items():
|
||||
if key != "base":
|
||||
os.makedirs(path, exist_ok=True)
|
||||
os.makedirs(d["base"], exist_ok=True)
|
||||
return d
|
||||
|
||||
|
||||
def template_path(name_key: str) -> str:
|
||||
"""按 TPL 的 key 取模板图绝对路径(配合 manifest 里的阈值使用)。"""
|
||||
name = TPL.get(name_key, name_key)
|
||||
return os.path.join(IMAGES_DIR, f"{name}.png")
|
||||
|
||||
|
||||
# ==================== 图像模板参数(manifest 里的 threshold/gray/scales) ====================
|
||||
_manifest = None
|
||||
|
||||
|
||||
def manifest() -> dict:
|
||||
"""读取 images/manifest.json(影刀 similarity/graying/adaptive 转换结果),失败返回空。"""
|
||||
global _manifest
|
||||
if _manifest is None:
|
||||
try:
|
||||
with open(MANIFEST_FILE, encoding="utf-8") as f:
|
||||
_manifest = json.load(f)
|
||||
except Exception: # noqa: BLE001
|
||||
_manifest = {}
|
||||
return _manifest
|
||||
|
||||
|
||||
def image_opt(name_key: str) -> dict:
|
||||
"""取某模板的匹配参数:{path, threshold, gray, scales}。"""
|
||||
name = TPL.get(name_key, name_key)
|
||||
meta = manifest().get(name, {})
|
||||
return {
|
||||
"path": os.path.join(IMAGES_DIR, meta.get("file") or f"{name}.png"),
|
||||
"threshold": float(meta.get("threshold", 0.8)),
|
||||
"gray": bool(meta.get("gray", False)),
|
||||
"scales": tuple(meta.get("scales") or (1.0,)),
|
||||
}
|
||||
|
||||
|
||||
# ==================== 日志钩子(run 时注入 ctx.log) ====================
|
||||
_log = None
|
||||
|
||||
|
||||
def set_log(fn) -> None:
|
||||
global _log
|
||||
_log = fn
|
||||
|
||||
|
||||
def log(msg, level="INFO") -> None:
|
||||
if _log:
|
||||
_log(str(msg), level)
|
||||
else:
|
||||
print(f"[{level}] {msg}")
|
||||
|
||||
|
||||
class _ModuleLogger:
|
||||
"""模块级 logger 适配:保留 logger.info(...) 调用点,统一转发到 ctx.log。"""
|
||||
|
||||
@staticmethod
|
||||
def debug(msg, *args):
|
||||
log(msg % args if args else msg, "DEBUG")
|
||||
|
||||
@staticmethod
|
||||
def info(msg, *args):
|
||||
log(msg % args if args else msg, "INFO")
|
||||
|
||||
@staticmethod
|
||||
def warning(msg, *args):
|
||||
log(msg % args if args else msg, "WARN")
|
||||
|
||||
@staticmethod
|
||||
def error(msg, *args):
|
||||
log(msg % args if args else msg, "ERROR")
|
||||
|
||||
|
||||
logger = _ModuleLogger()
|
||||
@@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0013 插件 - 数据层:账户列表、Win32 元素库(后续:PDF 汇总解析)。"""
|
||||
@@ -0,0 +1,123 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""账户列表读写(对应影刀自定义指令 mjqywawyv「读取账户列表」与 m8k8hi9j8「按门店+列名写单元格」)。
|
||||
|
||||
账户列表.xlsx 约定(与影刀版一致):
|
||||
A列=门店 B列=税号 C列=密码 E列=执行标记(0=待执行,1=已完成/跳过)
|
||||
只处理 E 列为 "0" 的行;E 列既非 0 也非 1(含空)→ 跳过。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import List
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from ..config import (
|
||||
COL_FLAG, COL_PASSWORD, COL_STORE, COL_TAX_NO, FLAG_DONE, FLAG_PENDING, logger,
|
||||
)
|
||||
|
||||
|
||||
def _is_empty(val) -> bool:
|
||||
if pd.isna(val):
|
||||
return True
|
||||
return str(val).strip() == ""
|
||||
|
||||
|
||||
def load_accounts(file_path: str) -> List[dict]:
|
||||
"""读取账户列表,返回待执行账户 [{"store","tax_no","password","row"}]。
|
||||
|
||||
数据不一致(E列=0 但门店/税号/密码为空)直接报错,避免跑错账户。
|
||||
"""
|
||||
if not os.path.isfile(file_path):
|
||||
raise RuntimeError(f"未找到账户列表:{file_path}")
|
||||
try:
|
||||
df = pd.read_excel(file_path, engine="openpyxl", dtype=str)
|
||||
except PermissionError as e:
|
||||
raise RuntimeError(f"账户列表被占用,请先关闭 Excel:{file_path}") from e
|
||||
except Exception as e: # noqa: BLE001
|
||||
raise RuntimeError(f"读取账户列表失败:{file_path}({e})") from e
|
||||
|
||||
if len(df.columns) <= COL_FLAG:
|
||||
raise RuntimeError(
|
||||
f"账户列表列数不完整:需要至少 {COL_FLAG + 1} 列(A门店/B税号/C密码/E执行标记),"
|
||||
f"当前 {len(df.columns)} 列")
|
||||
|
||||
out: List[dict] = []
|
||||
for idx, row in df.iterrows():
|
||||
flag = "" if pd.isna(row.iloc[COL_FLAG]) else str(row.iloc[COL_FLAG]).strip()
|
||||
if flag == FLAG_DONE:
|
||||
continue
|
||||
if flag != FLAG_PENDING:
|
||||
continue # 非 0/1 一律跳过(含空值与历史脏数据)
|
||||
store = str(row.iloc[COL_STORE]).strip() if not _is_empty(row.iloc[COL_STORE]) else ""
|
||||
tax_no = str(row.iloc[COL_TAX_NO]).strip() if not _is_empty(row.iloc[COL_TAX_NO]) else ""
|
||||
password = str(row.iloc[COL_PASSWORD]).strip() if not _is_empty(row.iloc[COL_PASSWORD]) else ""
|
||||
excel_row = idx + 2 # 表头占 1 行
|
||||
if not (store and tax_no and password):
|
||||
raise RuntimeError(
|
||||
f"账户列表第 {excel_row} 行 E 列标记为待执行,但门店/税号/密码存在空值")
|
||||
out.append({"store": store, "tax_no": tax_no, "password": password, "row": excel_row})
|
||||
|
||||
if not out:
|
||||
raise RuntimeError(f"账户列表筛选后没有待执行账户(E 列没有值为 {FLAG_PENDING} 的行):{file_path}")
|
||||
logger.info("账户列表读取完成:待执行 %d 家门店", len(out))
|
||||
return out
|
||||
|
||||
|
||||
def update_cell(file_path: str, store: str, column_name: str, content) -> None:
|
||||
"""按门店(A列)与列名(表头)写入单元格;列或行不存在则自动新增(影刀同款行为)。"""
|
||||
from openpyxl import Workbook, load_workbook # 延迟导入,减少不用时的开销
|
||||
|
||||
if not column_name or not store:
|
||||
raise ValueError("门店名称与列名不能为空")
|
||||
if not str(file_path).lower().endswith(".xlsx"):
|
||||
raise ValueError(f"账户列表必须是 .xlsx:{file_path}")
|
||||
|
||||
parent = os.path.dirname(os.path.abspath(file_path))
|
||||
if parent:
|
||||
os.makedirs(parent, exist_ok=True)
|
||||
|
||||
if os.path.exists(file_path):
|
||||
wb = load_workbook(file_path)
|
||||
ws = wb.active
|
||||
else:
|
||||
wb = Workbook()
|
||||
ws = wb.active
|
||||
ws.cell(row=1, column=1).value = "门店"
|
||||
|
||||
# 定位列
|
||||
target_col = None
|
||||
for col in range(1, ws.max_column + 1):
|
||||
if ws.cell(row=1, column=col).value == column_name:
|
||||
target_col = col
|
||||
break
|
||||
if target_col is None:
|
||||
target_col = ws.max_column + 1
|
||||
ws.cell(row=1, column=target_col).value = column_name
|
||||
|
||||
# 定位行
|
||||
target_row = None
|
||||
for row in range(2, ws.max_row + 1):
|
||||
if str(ws.cell(row=row, column=1).value) == str(store):
|
||||
target_row = row
|
||||
break
|
||||
if target_row is None:
|
||||
target_row = ws.max_row + 1
|
||||
ws.cell(row=target_row, column=1).value = store
|
||||
|
||||
ws.cell(row=target_row, column=target_col).value = content
|
||||
try:
|
||||
wb.save(file_path)
|
||||
except PermissionError as e:
|
||||
raise RuntimeError(f"账户列表被占用,无法写入,请先关闭 Excel:{file_path}") from e
|
||||
logger.info("已回写账户列表:%s | %s = %s", store, column_name, content)
|
||||
|
||||
|
||||
def mark_done(file_path: str, store: str, column_name: str = "执行状态") -> None:
|
||||
"""标记门店执行完成(默认写「执行状态」列=1)。"""
|
||||
update_cell(file_path, store, column_name, FLAG_DONE)
|
||||
|
||||
|
||||
def mark_failed(file_path: str, store: str, reason: str, column_name: str = "失败原因") -> None:
|
||||
"""记录失败原因(不写执行状态,便于人工重跑)。"""
|
||||
update_cell(file_path, store, column_name, reason)
|
||||
@@ -0,0 +1,254 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Win32 元素定位:解析影刀 selectors.xml,按「类名 + 同类序号」逐层查找控件。
|
||||
|
||||
影刀 Win32 选择器本质就是控件树路径(用 Inspect 抓的),例如:
|
||||
Window(cls=TfrmCompMgrMerge, title=社保费管理客户端)
|
||||
> Pane(cls=TJdlsPanel, index=2)
|
||||
> ... > Edit(cls=TITSEdit, index=0)
|
||||
|
||||
用 FindWindow / FindWindowEx 逐层下钻即可定位,**不需要 UIA**(老 Delphi/VB 客户端
|
||||
根本没有 UIA 树,但 Win32 控件层次是完整的),稳定性和速度都优于图像识别。
|
||||
|
||||
接口:
|
||||
lib = Selectors(xml_path)
|
||||
lib.names() # 全部元素名
|
||||
lib.find("税号输入框") # → hwnd(找不到抛 RuntimeError)
|
||||
lib.exists("滑动栏") # → bool
|
||||
lib.set_value("税号输入框", "91500...") # WM_SETTEXT,失败自动回退 点击+粘贴
|
||||
lib.get_value("密码框") # → str
|
||||
lib.click("确认单位") # 鼠标点控件中心
|
||||
lib.screenshot("待选账户", path) # 控件截图(给 OCR 用)
|
||||
lib.drag("滑动栏", dx=280) # 滑块拖动(验证码)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ctypes
|
||||
import os
|
||||
import time
|
||||
import xml.etree.ElementTree as ET
|
||||
from typing import Dict, List, Optional, Union
|
||||
|
||||
try:
|
||||
import win32con
|
||||
import win32gui
|
||||
except ImportError as _e: # pragma: no cover
|
||||
raise RuntimeError("缺少依赖 pywin32,请安装:pip install pywin32") from _e
|
||||
|
||||
from ..config import logger
|
||||
|
||||
WM_SETTEXT = win32con.WM_SETTEXT
|
||||
WM_GETTEXT = win32con.WM_GETTEXT
|
||||
WM_GETTEXTLENGTH = win32con.WM_GETTEXTLENGTH
|
||||
|
||||
|
||||
class Selectors:
|
||||
"""影刀元素库(selectors.xml)的 Win32 实现。"""
|
||||
|
||||
def __init__(self, xml_path: str):
|
||||
self.xml_path = xml_path
|
||||
self._items: Dict[str, dict] = self._parse(xml_path)
|
||||
|
||||
# ---------- 解析 ----------
|
||||
@staticmethod
|
||||
def _parse(xml_path: str) -> Dict[str, dict]:
|
||||
if not os.path.isfile(xml_path):
|
||||
raise RuntimeError(f"元素库文件不存在:{xml_path}")
|
||||
tree = ET.parse(xml_path)
|
||||
items: Dict[str, dict] = {}
|
||||
for el in tree.getroot().iter("selector"):
|
||||
name = (el.get("name") or "").strip()
|
||||
if not name:
|
||||
continue
|
||||
steps: List[dict] = []
|
||||
for wnd in el.findall("wnd"):
|
||||
opt = wnd.find("{*}optional")
|
||||
index = None
|
||||
raw_index = wnd.get("index")
|
||||
if raw_index is not None:
|
||||
try:
|
||||
index = int(raw_index)
|
||||
except ValueError:
|
||||
index = None
|
||||
if opt is not None and opt.get("index") is not None:
|
||||
try:
|
||||
index = int(opt.get("index"))
|
||||
except ValueError:
|
||||
pass
|
||||
steps.append({
|
||||
"cls": (wnd.get("cls") or "").strip(),
|
||||
"title": (wnd.get("title") or "").strip(),
|
||||
"index": index,
|
||||
"optional": opt is not None,
|
||||
})
|
||||
items[name] = {
|
||||
"name": name,
|
||||
"win_title": (el.get("winTitle") or "").strip(),
|
||||
"process": (el.get("processName") or "").strip(),
|
||||
"steps": steps,
|
||||
}
|
||||
logger.info("元素库加载完成:%d 个元素(%s)", len(items), os.path.basename(xml_path))
|
||||
return items
|
||||
|
||||
def names(self) -> List[str]:
|
||||
return list(self._items.keys())
|
||||
|
||||
def describe(self, name: str) -> dict:
|
||||
return dict(self._items.get(name) or {})
|
||||
|
||||
def _get(self, name: str) -> dict:
|
||||
item = self._items.get(name)
|
||||
if not item:
|
||||
raise KeyError(f"元素库里没有「{name}」,可用元素:{', '.join(self.names())}")
|
||||
return item
|
||||
|
||||
# ---------- 定位 ----------
|
||||
@staticmethod
|
||||
def _find_child(parent: int, cls: str, index: Optional[int]) -> int:
|
||||
"""在 parent 下找第 index 个类名为 cls 的子窗口。"""
|
||||
want = 0 if index is None else int(index)
|
||||
seen = 0
|
||||
after = 0
|
||||
while True:
|
||||
child = win32gui.FindWindowEx(parent, after, cls or None, None)
|
||||
if not child:
|
||||
return 0
|
||||
if seen == want:
|
||||
return child
|
||||
seen += 1
|
||||
after = child
|
||||
|
||||
def _resolve(self, item: dict, top_window: Optional[int] = None) -> int:
|
||||
steps = item["steps"]
|
||||
if not steps:
|
||||
return 0
|
||||
first = steps[0]
|
||||
parent = int(top_window or 0)
|
||||
if not parent:
|
||||
parent = win32gui.FindWindow(first["cls"] or None, first["title"] or None)
|
||||
if not parent and (first["title"] or item["win_title"]):
|
||||
title = first["title"] or item["win_title"]
|
||||
try:
|
||||
from desktopauto import find_windows # 执行机预装依赖
|
||||
cands = find_windows(title=title)
|
||||
if not cands and item["process"]:
|
||||
cands = find_windows(process=item["process"])
|
||||
parent = int(cands[0]["hwnd"]) if cands else 0
|
||||
except Exception: # noqa: BLE001
|
||||
parent = 0
|
||||
if not parent:
|
||||
return 0
|
||||
|
||||
for step in steps[1:]:
|
||||
child = self._find_child(parent, step["cls"], step["index"])
|
||||
if not child:
|
||||
if step["optional"]:
|
||||
continue # 影刀语义:该层可选,找不到就跳过这一层继续下钻
|
||||
return 0
|
||||
parent = child
|
||||
return parent
|
||||
|
||||
def find(self, name: str, top_window: Optional[int] = None,
|
||||
timeout: float = 0.0, interval: float = 0.2) -> int:
|
||||
"""定位元素,返回 hwnd;timeout>0 时轮询等待,超时抛错。"""
|
||||
item = self._get(name)
|
||||
deadline = time.time() + max(0.0, float(timeout))
|
||||
while True:
|
||||
hwnd = self._resolve(item, top_window)
|
||||
if hwnd:
|
||||
return hwnd
|
||||
if time.time() >= deadline:
|
||||
raise RuntimeError(
|
||||
f"未定位到元素「{name}」(客户端是否已启动/界面是否已切到目标页?)")
|
||||
time.sleep(max(0.05, interval))
|
||||
|
||||
def exists(self, name: str, top_window: Optional[int] = None) -> bool:
|
||||
try:
|
||||
return bool(self._resolve(self._get(name), top_window))
|
||||
except KeyError:
|
||||
return False
|
||||
|
||||
# ---------- 操作 ----------
|
||||
@staticmethod
|
||||
def _rect(hwnd: int):
|
||||
left, top, right, bottom = win32gui.GetWindowRect(hwnd)
|
||||
return left, top, right, bottom
|
||||
|
||||
def center(self, name: str, top_window: Optional[int] = None) -> tuple:
|
||||
left, top, right, bottom = self._rect(self.find(name, top_window))
|
||||
return (left + right) // 2, (top + bottom) // 2
|
||||
|
||||
def get_value(self, name: str, top_window: Optional[int] = None) -> str:
|
||||
"""读控件文本(WM_GETTEXT)。"""
|
||||
hwnd = self.find(name, top_window)
|
||||
length = int(win32gui.SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0) or 0)
|
||||
buf = ctypes.create_unicode_buffer(max(1, length + 1))
|
||||
win32gui.SendMessage(hwnd, WM_GETTEXT, max(1, length + 1), buf)
|
||||
return buf.value
|
||||
|
||||
def set_value(self, name: str, text: str, top_window: Optional[int] = None,
|
||||
timeout: float = 5.0, verify: bool = True) -> bool:
|
||||
"""给输入框赋值:优先 WM_SETTEXT(快、不受焦点影响),无效时回退 点击+粘贴。
|
||||
|
||||
Returns:
|
||||
True=WM_SETTEXT 成功;False=走了回退路径(点击+粘贴)。
|
||||
"""
|
||||
hwnd = self.find(name, top_window, timeout=timeout)
|
||||
text = "" if text is None else str(text)
|
||||
try:
|
||||
win32gui.SendMessage(hwnd, WM_SETTEXT, 0, text)
|
||||
except Exception as e: # noqa: BLE001
|
||||
logger.warning("WM_SETTEXT 失败(%s),改用点击+粘贴", e)
|
||||
self._type_into(hwnd, text)
|
||||
return False
|
||||
if verify:
|
||||
got = self.get_value(name, top_window)
|
||||
if got.strip() != text.strip():
|
||||
logger.warning("WM_SETTEXT 未生效(读到「%s」),改用点击+粘贴", got)
|
||||
self._type_into(hwnd, text)
|
||||
return False
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def _type_into(hwnd: int, text: str) -> None:
|
||||
"""回退方案:点控件中心 → Ctrl+A → 粘贴(中文/长文本安全)。"""
|
||||
from desktopauto import click_at, hotkey, paste
|
||||
left, top, right, bottom = Selectors._rect(hwnd)
|
||||
cx, cy = (left + right) // 2, (top + bottom) // 2
|
||||
try:
|
||||
win32gui.SetForegroundWindow(hwnd)
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
click_at(cx, cy)
|
||||
time.sleep(0.15)
|
||||
hotkey("ctrl", "a")
|
||||
paste(text)
|
||||
|
||||
def click(self, name: str, top_window: Optional[int] = None,
|
||||
timeout: float = 5.0, delay_after: float = 0.3) -> None:
|
||||
"""点击控件中心(鼠标真实点击,兼容自绘控件)。"""
|
||||
from desktopauto import click_at
|
||||
hwnd = self.find(name, top_window, timeout=timeout)
|
||||
left, top, right, bottom = self._rect(hwnd)
|
||||
cx, cy = (left + right) // 2, (top + bottom) // 2
|
||||
click_at(cx, cy)
|
||||
if delay_after:
|
||||
time.sleep(float(delay_after))
|
||||
logger.debug("点击元素「%s」→ (%d, %d)", name, cx, cy)
|
||||
|
||||
def screenshot(self, name: str, path: str = "",
|
||||
top_window: Optional[int] = None) -> str:
|
||||
"""截控件区域(给 OCR / 元素识别留档用),返回图片路径。"""
|
||||
from desktopauto import screenshot as _shot
|
||||
hwnd = self.find(name, top_window)
|
||||
left, top, right, bottom = self._rect(hwnd)
|
||||
return _shot(path, region=(left, top, right, bottom))
|
||||
|
||||
def drag(self, name: str, dx: int = 0, dy: int = 0, duration: float = 0.8,
|
||||
top_window: Optional[int] = None) -> None:
|
||||
"""拖动控件(滑块验证码:对「滑动栏」向右拖 dx 像素)。"""
|
||||
from desktopauto import drag as _drag
|
||||
hwnd = self.find(name, top_window)
|
||||
left, top, right, bottom = self._rect(hwnd)
|
||||
sx, sy = (left + right) // 2, (top + bottom) // 2
|
||||
_drag((sx, sy), (sx + int(dx), sy + int(dy)), duration=duration)
|
||||
logger.debug("拖动元素「%s」→ 偏移 (%d, %d)", name, dx, dy)
|
||||
@@ -0,0 +1,448 @@
|
||||
{
|
||||
"图像": {
|
||||
"file": "图像.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"登录按钮": {
|
||||
"file": "登录按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"确定登录按钮": {
|
||||
"file": "确定登录按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"菜单栏": {
|
||||
"file": "菜单栏.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"错误信息": {
|
||||
"file": "错误信息.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"错误处理确认": {
|
||||
"file": "错误处理确认.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"社保费申报": {
|
||||
"file": "社保费申报.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"日常申报": {
|
||||
"file": "日常申报.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"特殊缴费申报": {
|
||||
"file": "特殊缴费申报.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"查看职工未申报明细": {
|
||||
"file": "查看职工未申报明细.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"职工未申报明细导出查询区域": {
|
||||
"file": "职工未申报明细导出查询区域.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"职工未申报明细导出按钮": {
|
||||
"file": "职工未申报明细导出按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"导出成功确定按钮": {
|
||||
"file": "导出成功确定按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"职工未申报明细关闭按钮": {
|
||||
"file": "职工未申报明细关闭按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"全选复选框": {
|
||||
"file": "全选复选框.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"提交申报按钮": {
|
||||
"file": "提交申报按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"提示信息": {
|
||||
"file": "提示信息.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"提示信息确定按钮": {
|
||||
"file": "提示信息确定按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"服务器连接异常": {
|
||||
"file": "服务器连接异常.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"服务器连接异常确定按钮": {
|
||||
"file": "服务器连接异常确定按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"刷新按钮": {
|
||||
"file": "刷新按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"明细数据量大": {
|
||||
"file": "明细数据量大.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"提交申报确认": {
|
||||
"file": "提交申报确认.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"提交申报": {
|
||||
"file": "提交申报.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"申报成功": {
|
||||
"file": "申报成功.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"申报结果查询": {
|
||||
"file": "申报结果查询.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"添加单位": {
|
||||
"file": "添加单位.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"下一步": {
|
||||
"file": "下一步.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"确认单位": {
|
||||
"file": "确认单位.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"安全认证": {
|
||||
"file": "安全认证.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"取消按钮": {
|
||||
"file": "取消按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"添加按钮": {
|
||||
"file": "添加按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"多数据来源": {
|
||||
"file": "多数据来源.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"数据来源": {
|
||||
"file": "数据来源.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"税务生成": {
|
||||
"file": "税务生成.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
1.0
|
||||
]
|
||||
},
|
||||
"征集信息": {
|
||||
"file": "征集信息.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
1.0
|
||||
]
|
||||
},
|
||||
"查询按钮": {
|
||||
"file": "查询按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"申报记录": {
|
||||
"file": "申报记录.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"申报数据最新状态": {
|
||||
"file": "申报数据最新状态.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"申报结果查询按钮": {
|
||||
"file": "申报结果查询按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"查看按钮": {
|
||||
"file": "查看按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"导出按钮": {
|
||||
"file": "导出按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"征集通知流水号": {
|
||||
"file": "征集通知流水号.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"税务生成选中": {
|
||||
"file": "税务生成选中.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
},
|
||||
"重置按钮": {
|
||||
"file": "重置按钮.png",
|
||||
"threshold": 0.8,
|
||||
"gray": false,
|
||||
"scales": [
|
||||
0.9,
|
||||
1.0,
|
||||
1.1
|
||||
]
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 468 B |
|
After Width: | Height: | Size: 262 B |
|
After Width: | Height: | Size: 484 B |
|
After Width: | Height: | Size: 520 B |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 468 B |
|
After Width: | Height: | Size: 376 B |
|
After Width: | Height: | Size: 732 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 689 B |
|
After Width: | Height: | Size: 644 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 878 B |
|
After Width: | Height: | Size: 468 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 498 B |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 468 B |
|
After Width: | Height: | Size: 369 B |
|
After Width: | Height: | Size: 929 B |
|
After Width: | Height: | Size: 465 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 466 B |
|
After Width: | Height: | Size: 832 B |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 756 B |
|
After Width: | Height: | Size: 547 B |
|
After Width: | Height: | Size: 526 B |
|
After Width: | Height: | Size: 522 B |
|
After Width: | Height: | Size: 7.8 KiB |
|
After Width: | Height: | Size: 674 B |
|
After Width: | Height: | Size: 839 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 324 B |
|
After Width: | Height: | Size: 382 B |
|
After Width: | Height: | Size: 7.8 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 392 B |
|
After Width: | Height: | Size: 901 B |
|
After Width: | Height: | Size: 468 B |
@@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0013 插件 - 逻辑层:客户端启动/登录/弹窗清理(后续:日常/特殊申报导出、申报记录识别)。"""
|
||||
@@ -0,0 +1,236 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""客户端生命周期:启动 → 登录(元素填税号 + 滑块 + 图像点登录)→ 弹窗清理 → 关闭。
|
||||
|
||||
对应影刀 process1(社保客户端启动流程)、process2(社保账户登录流程)、process3(弹窗清理)。
|
||||
定位策略:能用 Win32 元素就走元素(税号框、滑动栏),拿不到元素/需要视觉判断的(登录按钮、
|
||||
菜单栏、错误弹窗)走图像 + OCR,与影刀版一致。
|
||||
|
||||
阶段说明:首个账户首次登录需要「添加单位」流程(影刀 process6),当前版本在
|
||||
OCR 判断"账户列表为空"时会明确报错并提示,待补 process6 迁移。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
from desktopauto import Screen, find_windows, get_window, hotkey, sleep
|
||||
|
||||
from ..config import (
|
||||
CLIENT_PROCESS, CLIENT_PROCESS_ALT, CLIENT_TITLE, ELE, client_exe,
|
||||
image_opt, logger,
|
||||
)
|
||||
from ..data.selectors import Selectors
|
||||
|
||||
# 登录后判定成功的锚点图与错误弹窗
|
||||
_LOGIN_OK_TPL = "menu_bar"
|
||||
_ERROR_TPL = "error_msg"
|
||||
_ERROR_CONFIRM_TPL = "error_confirm"
|
||||
|
||||
|
||||
def _wait_tpl(screen: Screen, key: str, timeout: float = 5.0):
|
||||
"""按模板名等待出现(自动带 manifest 里的阈值/灰度/多尺度)。"""
|
||||
opt = image_opt(key)
|
||||
return screen.wait(opt["path"], timeout=timeout, interval=0.5,
|
||||
threshold=opt["threshold"], gray=opt["gray"], scales=opt["scales"])
|
||||
|
||||
|
||||
def _shot_click(screen: Screen, key: str, timeout: float = 5.0,
|
||||
delay_after: float = 1.0) -> bool:
|
||||
"""按模板名点击(自动带 manifest 里的阈值/灰度/多尺度)。"""
|
||||
opt = image_opt(key)
|
||||
return screen.click(opt["path"], threshold=opt["threshold"], gray=opt["gray"],
|
||||
scales=opt["scales"], timeout=timeout, delay_after=delay_after)
|
||||
|
||||
|
||||
def _shot_exists(screen: Screen, key: str) -> bool:
|
||||
opt = image_opt(key)
|
||||
return screen.exists(opt["path"], threshold=opt["threshold"],
|
||||
gray=opt["gray"], scales=opt["scales"])
|
||||
|
||||
|
||||
# ==================== 启动 / 关闭 ====================
|
||||
def start_client(exe_path: str = "", retries: int = 3, ready_timeout: float = 30.0):
|
||||
"""启动社保客户端并等窗口就绪(影刀「运行或打开」+「等待图像」)。
|
||||
|
||||
Returns:
|
||||
(Window, Selectors):窗口对象 + 元素库。
|
||||
|
||||
Raises:
|
||||
RuntimeError:启动失败或超时(已重试)。
|
||||
"""
|
||||
exe_path = (exe_path or client_exe()).strip()
|
||||
if not os.path.isfile(exe_path):
|
||||
raise RuntimeError(f"社保客户端程序不存在:{exe_path}(请在插件配置里修正路径)")
|
||||
|
||||
sel = Selectors(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
|
||||
"selectors", "selectors.xml"))
|
||||
last_err = None
|
||||
for attempt in range(1, max(1, retries) + 1):
|
||||
logger.info("第 %d/%d 次启动社保客户端:%s", attempt, retries, exe_path)
|
||||
try:
|
||||
_launch(exe_path)
|
||||
win = _wait_client_window(ready_timeout)
|
||||
if win is not None:
|
||||
win.activate()
|
||||
logger.info("社保客户端启动成功:%s", win.title)
|
||||
return win, sel
|
||||
last_err = RuntimeError("等待窗口超时")
|
||||
except Exception as e: # noqa: BLE001
|
||||
last_err = e
|
||||
logger.warning("第 %d 次启动失败:%s", attempt, e)
|
||||
_kill_client()
|
||||
time.sleep(1.5)
|
||||
raise RuntimeError(f"社保客户端连续 {retries} 次启动失败:{last_err}")
|
||||
|
||||
|
||||
def _launch(exe_path: str) -> None:
|
||||
"""启动客户端(已在运行则跳过)。"""
|
||||
if find_windows(process=CLIENT_PROCESS) or find_windows(process=CLIENT_PROCESS_ALT):
|
||||
logger.info("社保客户端已在运行,跳过启动")
|
||||
return
|
||||
from desktopauto import run_or_open
|
||||
run_or_open(exe_path, wait=1.0)
|
||||
|
||||
|
||||
def _wait_client_window(timeout: float):
|
||||
"""等主窗口出现(按标题,元素库里的 cls 也参与匹配)。"""
|
||||
deadline = time.time() + max(1.0, float(timeout))
|
||||
while time.time() < deadline:
|
||||
cands = find_windows(title=CLIENT_TITLE)
|
||||
if cands:
|
||||
return get_window(cands[0]["hwnd"])
|
||||
time.sleep(0.5)
|
||||
return None
|
||||
|
||||
|
||||
def _kill_client() -> None:
|
||||
"""结束客户端进程(影刀每轮结束都会强杀,避免状态残留)。"""
|
||||
from desktopauto import kill_process
|
||||
for proc in (CLIENT_PROCESS, CLIENT_PROCESS_ALT):
|
||||
try:
|
||||
if find_windows(process=proc):
|
||||
kill_process(proc, wait=0.5)
|
||||
logger.info("已结束进程:%s", proc)
|
||||
except Exception as e: # noqa: BLE001
|
||||
logger.warning("结束进程 %s 失败:%s", proc, e)
|
||||
|
||||
|
||||
def close_client() -> None:
|
||||
"""关闭窗口(软关闭),失败再强杀。"""
|
||||
wins = find_windows(title=CLIENT_TITLE)
|
||||
if wins:
|
||||
try:
|
||||
w = get_window(wins[0]["hwnd"])
|
||||
w.close(wait=0.5)
|
||||
if w.wait_closed(timeout=5):
|
||||
logger.info("社保客户端已关闭")
|
||||
return
|
||||
except Exception as e: # noqa: BLE001
|
||||
logger.warning("软关闭失败:%s", e)
|
||||
_kill_client()
|
||||
|
||||
|
||||
# ==================== 登录 ====================
|
||||
def login(tax_no: str, password: str, sel: Selectors, store: str = "",
|
||||
login_timeout: float = 60.0) -> bool:
|
||||
"""登录单个社保账户(影刀 process2)。
|
||||
|
||||
流程:激活窗口 → 元素填税号 + Enter → 滑块验证 → 点击「登录按钮」→ 输入密码
|
||||
→ 点击「确定登录按钮」→ 循环等「菜单栏」出现(期间处理错误弹窗)。
|
||||
|
||||
Raises:
|
||||
RuntimeError:登录失败或超时(调用方据此回写失败原因)。
|
||||
"""
|
||||
win = _wait_client_window(10.0)
|
||||
if win is None:
|
||||
raise RuntimeError("未找到社保费管理客户端窗口")
|
||||
win.activate()
|
||||
|
||||
screen = Screen(window=win.hwnd, threshold=0.8, debug_dir="")
|
||||
|
||||
# 1. 填税号(元素通道,比图像稳)
|
||||
logger.info("填入税号:%s(门店:%s)", tax_no, store or "-")
|
||||
sel.set_value(ELE["tax_no_input"], tax_no, timeout=15.0)
|
||||
sleep(0.5)
|
||||
hotkey("enter")
|
||||
sleep(1.0)
|
||||
|
||||
# 2. 判断是否已有可选账户:对「待选账户」元素截图后 OCR 数文字行
|
||||
account_count = _count_pending_accounts(sel)
|
||||
logger.info("可选账户文字行数:%d", account_count)
|
||||
if account_count < 3:
|
||||
raise RuntimeError(
|
||||
"该税号在客户端里没有可登录账户(首次使用需先「添加单位」,"
|
||||
"影刀 process6 尚未迁移;请先在客户端手动添加一次该账户后重跑)")
|
||||
|
||||
# 3. 拖动滑块(验证码)——滑块条元素拖动,位移取控件宽度的一半以上
|
||||
_drag_slider(sel)
|
||||
|
||||
# 4. 点击「登录按钮」→ 输密码 → 点击「确定登录按钮」
|
||||
_shot_click(screen, "login_btn", timeout=5.0)
|
||||
sleep(1.0)
|
||||
screen.paste(password)
|
||||
sleep(0.5)
|
||||
_shot_click(screen, "login_confirm", timeout=5.0)
|
||||
|
||||
# 5. 循环等菜单栏出现(期间处理错误提示)
|
||||
deadline = time.time() + max(5.0, float(login_timeout))
|
||||
while time.time() < deadline:
|
||||
if _shot_exists(screen, _ERROR_TPL):
|
||||
logger.warning("检测到登录错误提示,点确认后继续等待")
|
||||
_shot_click(screen, _ERROR_CONFIRM_TPL, timeout=3.0)
|
||||
if _wait_tpl(screen, _LOGIN_OK_TPL, timeout=2.0) is not None:
|
||||
logger.info("门店 %s 登录成功(已见菜单栏)", store or tax_no)
|
||||
return True
|
||||
sleep(1.0)
|
||||
raise RuntimeError(f"登录超时:{store or tax_no}({login_timeout:.0f}s 内未出现主菜单)")
|
||||
|
||||
|
||||
def _count_pending_accounts(sel: Selectors) -> int:
|
||||
"""对「待选账户」元素截图后 OCR,返回识别到的文字段数(影刀 process2 同款判断)。"""
|
||||
try:
|
||||
from desktopauto import ocr
|
||||
shot = sel.screenshot(ELE["pending_account"])
|
||||
items = ocr.recognize(shot, min_score=0.5)
|
||||
return len(items)
|
||||
except Exception as e: # noqa: BLE001
|
||||
logger.warning("账户列表识别失败(按无账户处理):%s", e)
|
||||
return 0
|
||||
|
||||
|
||||
def _drag_slider(sel: Selectors) -> None:
|
||||
"""拖滑块(验证码):拖动「滑动栏」控件,距离取控件宽度(拖到最右)。"""
|
||||
try:
|
||||
hwnd = sel.find(ELE["slider_bar"], timeout=5.0)
|
||||
import win32gui
|
||||
left, top, right, bottom = win32gui.GetWindowRect(hwnd)
|
||||
distance = max(60, right - left)
|
||||
sel.drag(ELE["slider_bar"], dx=distance, duration=0.8)
|
||||
sleep(0.8)
|
||||
logger.info("滑块拖动完成(距离 %d px)", distance)
|
||||
except Exception as e: # noqa: BLE001
|
||||
logger.warning("滑块拖动失败(继续尝试登录):%s", e)
|
||||
|
||||
|
||||
# ==================== 弹窗清理 ====================
|
||||
_POPUP_TITLES = ("确认单位", "待办事项提醒")
|
||||
|
||||
|
||||
def clean_popups(max_rounds: int = 3) -> None:
|
||||
"""关闭「确认单位」「待办事项提醒」等弹窗(影刀 process3:最多 3 轮,两个都清掉即退出)。"""
|
||||
for round_no in range(1, max(1, max_rounds) + 1):
|
||||
cleaned = False
|
||||
for title in _POPUP_TITLES:
|
||||
wins = find_windows(title=title)
|
||||
if not wins:
|
||||
continue
|
||||
try:
|
||||
w = get_window(wins[0]["hwnd"])
|
||||
w.close(wait=0.3)
|
||||
cleaned = True
|
||||
logger.info("已关闭弹窗:%s", title)
|
||||
except Exception as e: # noqa: BLE001
|
||||
logger.warning("关闭弹窗「%s」失败:%s", title, e)
|
||||
if not cleaned:
|
||||
return
|
||||
sleep(1.0)
|
||||
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"id": "xq0013",
|
||||
"name": "社保费用申报导出并汇总",
|
||||
"version": "0.1.0",
|
||||
"description": "按月批量登录重庆社保客户端完成日常/特殊申报与申报记录导出并汇总。当前版本已迁移:账户列表读写、客户端启动、登录(Win32 元素+图像+OCR 验证)、弹窗清理;申报导出与汇总流程待迁移。",
|
||||
"category": "社保公积金",
|
||||
"icon": "",
|
||||
"platform": "",
|
||||
"uses_month": false,
|
||||
"ui": true,
|
||||
"capabilities": ["xq0013"],
|
||||
"permissions": {
|
||||
"platforms": []
|
||||
},
|
||||
"fields": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"mode": {
|
||||
"type": "string",
|
||||
"title": "执行模式",
|
||||
"default": "check",
|
||||
"enum": ["check", "full"],
|
||||
"description": "check=只验证环境(启动→登录第一家有账户→清弹窗→关闭);full=完整批量申报(尚未迁移完成)"
|
||||
},
|
||||
"client_exe": {
|
||||
"type": "string",
|
||||
"title": "社保客户端程序",
|
||||
"default": "D:\\Program Files (x86)\\EPPortal_SB1.0\\EPEvenue_SB.exe",
|
||||
"description": "EPEvenue_SB.exe 的完整路径"
|
||||
},
|
||||
"save_dir": {
|
||||
"type": "string",
|
||||
"title": "输出目录",
|
||||
"default": "D:\\资料\\人资\\社保费用申报导出汇总",
|
||||
"description": "账户列表、申报结果、职工未申报明细、截图等统一根目录"
|
||||
},
|
||||
"account_file": {
|
||||
"type": "string",
|
||||
"title": "账户列表文件",
|
||||
"default": "",
|
||||
"description": "留空 = 输出目录/账户列表.xlsx(A门店 B税号 C密码 E执行标记:0待执行/1跳过)"
|
||||
}
|
||||
},
|
||||
"required": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0013 插件 - 报告层:流程编排、明细合并(19 列)、PDF 金额汇总。"""
|
||||
@@ -0,0 +1,7 @@
|
||||
pandas>=2.0
|
||||
openpyxl>=3.1
|
||||
pywin32>=306
|
||||
# desktopauto(桌面自动化库,仓库 libs/desktopauto)由执行机环境包预装,不从 PyPI 装:
|
||||
# python-env\<版本>\python.exe -m pip install -e <仓库>\libs\desktopauto
|
||||
# 验证码识别(后续 process6/登录兜底用)
|
||||
ddddocr>=1.5
|
||||
@@ -0,0 +1,580 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<repository xmlns:x="rpa://selector/core" xmlns:regex="rpa://selector/operator/regex" xmlns:wildcard="rpa://selector/operator/wildcard" xmlns:contains="rpa://selector/operator/contains" xmlns:notContains="rpa://selector/operator/notContains" xmlns:startsWith="rpa://selector/operator/startsWith" xmlns:notStartsWith="rpa://selector/operator/notStartsWith" xmlns:endsWith="rpa://selector/operator/endsWith" xmlns:notEndsWith="rpa://selector/operator/notEndsWith" xmlns:notEquals="rpa://selector/operator/notEquals" xmlns:greaterThan="rpa://selector/operator/greaterThan" xmlns:greaterThanOrEqual="rpa://selector/operator/greaterThanOrEqual" xmlns:lessThan="rpa://selector/operator/lessThan" xmlns:lessThanOrEqual="rpa://selector/operator/lessThanOrEqual">
|
||||
<group id="ffe28e37-18cb-40fb-b152-179389c7dd6d" name="社保费管理客户端" type="Win32" processName="EPPortalSB" icon=".dev\icon\cd5a290a-85d8-4bfb-838b-5764eae701eb.png" criteria="" selectorOringin="Inspect">
|
||||
<selector id="251903e9-9f74-44a5-ac67-5b20693c18a1" name="税号输入框" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\ef4b7654-d057-4046-8368-11039c4bcb26.jpg">
|
||||
<wnd x:name="Window" cls="TfrmCompMgrMerge" title="社保费管理客户端" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="2" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="2" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Edit" cls="TITSEdit" index="0">
|
||||
<optional />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="17cfc16f-faa2-4112-8ec1-de924d851c9c" name="滑动栏" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\329a65cd-8d0f-4b9a-8836-666d4b5d9bcb.jpg">
|
||||
<wnd x:name="Window" cls="TfrmCompMgrMerge" title="社保费管理客户端" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="2" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="2" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TVirtualStringTree">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<uia x:name="ScrollBar" uia-name="水平滚动条" uia-id="NonClientHorizontalScrollBar">
|
||||
<optional index="0" />
|
||||
</uia>
|
||||
<uia x:name="Thumb" uia-name="位置" uia-id="ScrollbarThumb">
|
||||
<optional index="2" />
|
||||
</uia>
|
||||
</selector>
|
||||
<selector id="ff9ff24b-74b5-4853-ae76-f6ad51b21744" name="密码框" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\0101d22e-d3fb-47e7-90df-be05c2c489cb.jpg">
|
||||
<wnd x:name="Window" cls="TfrmRegister" title="注册" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="2" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TfrmCheckPwd" uia-name="安全认证">
|
||||
<optional title="安全认证" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Tab" cls="TPageControl">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TTabSheet" uia-name="sheetPwdLogin">
|
||||
<optional title="sheetPwdLogin" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Edit" index="1">
|
||||
<optional cls="TXPFamerEditEx" />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="b6a57b48-7e81-4be6-a83b-054cbf1d21bb" name="确定登录按钮" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\ae9f3cb5-6121-4326-beeb-d789329f396e.jpg">
|
||||
<wnd x:name="Window" cls="TfrmRegister" title="注册" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TITSSpeedButton">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="4662bc28-9195-45c0-8169-c87473dc5805" name="日常申报表单" type="simple" framework="acc" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\52f6790c-a44e-422b-9615-9baa8dc00cf7.jpg">
|
||||
<wnd x:name="Window" cls="Tfrm_MainFrame" title="社保费管理客户端" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel" uia-name="pnl_all">
|
||||
<optional title="pnl_all" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TFrmView" uia-name="视图基类">
|
||||
<optional title="视图基类" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="Tfrm_DKDJWarpedCustom" uia-name="代扣代缴封装窗体">
|
||||
<optional title="代扣代缴封装窗体" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TfrmHdsbbbtx" uia-name="frmHdsbbbtx">
|
||||
<optional title="frmHdsbbbtx" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TAdvStringGrid">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<acc x:name="Client">
|
||||
<optional index="0" />
|
||||
</acc>
|
||||
</selector>
|
||||
<selector id="340bbe48-8044-4364-821b-4a7455e7dc0c" name="查看职工未申报明细按钮" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\c1684f70-926e-43db-8fb3-525256187419.jpg">
|
||||
<wnd x:name="Window" cls="Tfrm_MainFrame" title="社保费管理客户端" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel" uia-name="pnl_all">
|
||||
<optional title="pnl_all" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TFrmView" uia-name="视图基类">
|
||||
<optional title="视图基类" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="Tfrm_DKDJWarpedCustom" uia-name="代扣代缴封装窗体">
|
||||
<optional title="代扣代缴封装窗体" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TfrmHdsbbbtx" uia-name="frmHdsbbbtx">
|
||||
<optional title="frmHdsbbbtx" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel" index="1">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TITSSpeedButton" index="2">
|
||||
<optional />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="070d3b83-1ac7-412a-a888-05d73be3da73" name="文件名输入框" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\5e4efc49-600c-4c64-b03a-cad887cdbd34.jpg">
|
||||
<wnd x:name="Window" cls="#32770" title="另存为" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="ComboBoxEx32" uia-name="职工未申报明细.xlsx">
|
||||
<optional title="职工未申报明细.xlsx" index="8" />
|
||||
</wnd>
|
||||
<wnd x:name="ComboBox" cls="ComboBox" uia-name="文件名(N):">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Edit" cls="Edit" uia-name="文件名(N):">
|
||||
<optional title="职工未申报明细.xlsx" index="0" />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="88f46da1-fd1a-44ed-a7b8-c15a1c72fef5" name="导出成功确定按钮" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\d58702ea-ba47-459a-baa7-1364facafd34.jpg">
|
||||
<wnd x:name="Window" cls="Tfrm_MainFrame" title="社保费管理客户端" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Window" cls="Tfrm_MsgDlgRich" title="提示信息">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel" uia-name="pnl_body">
|
||||
<optional title="pnl_body" index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TITSSpeedButton">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="5652ad55-f008-4011-81e8-66b1b6361902" name="职工未申报明细窗口" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\a780f1eb-d005-4c2a-a1c3-fda3c2c0435f.jpg">
|
||||
<wnd x:name="Window" cls="Tfrm_MainFrame" title="社保费管理客户端" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Window" cls="TFrmAllYclZgmx" title="FrmAllYclZgmx">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="3" />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="9eacdf74-583b-4d35-851a-ff640dffc4dd" name="窗格" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\338ca785-bc21-478f-af15-db7e704edc9b.jpg">
|
||||
<wnd x:name="Window" cls="Tfrm_MainFrame" title="社保费管理客户端" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Window" cls="TFrmAllYclZgmx" title="FrmAllYclZgmx">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel" index="3">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel" index="0">
|
||||
<optional />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="e000db32-fd18-42c8-9446-9a8a2f5933b0" name="特殊缴费申报表单" type="simple" framework="acc" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\ca3eb728-fe24-4a7b-a898-69b2296f312e.jpg">
|
||||
<wnd x:name="Window" cls="Tfrm_MainFrame" title="社保费管理客户端" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel" uia-name="pnl_all">
|
||||
<optional title="pnl_all" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TFrmView" uia-name="视图基类">
|
||||
<optional title="视图基类" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="Tfrm_DKDJWarpedCustom" uia-name="代扣代缴封装窗体">
|
||||
<optional title="代扣代缴封装窗体" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TfrmHdsbbbtx" uia-name="frmHdsbbbtx">
|
||||
<optional title="frmHdsbbbtx" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TAdvStringGrid">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<acc x:name="Client">
|
||||
<optional index="0" />
|
||||
</acc>
|
||||
</selector>
|
||||
<selector id="2e9ff061-ddb9-465a-b0cb-37003daf59aa" name="添加按钮" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\9906cecb-3327-4612-a3d8-cd4949e3ffee.jpg">
|
||||
<wnd x:name="Window" cls="TfrmCompMgrMerge" title="社保费管理客户端" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="2" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="2" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TITSSpeedButton">
|
||||
<optional index="2" />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="c70d98e0-0f8d-4d2b-be9e-2aed7ae6444a" name="纳税人识别号" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\82cb0a51-3bef-4872-8f58-ba38af87bad5.jpg">
|
||||
<wnd x:name="Window" cls="TfrmRegister" title="注册" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="2" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TfrmAddCompany" uia-name="添加单位">
|
||||
<optional title="添加单位" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Edit" cls="TXPFamerEditEx">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="e4defcfc-9f12-40a0-9520-f1240e416fa8" name="待选账户" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\19eb6a5a-d94f-4193-83e8-2b3d32f1590c.jpg">
|
||||
<wnd x:name="Window" cls="TfrmCompMgrMerge" title="社保费管理客户端" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="2" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="2" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TVirtualStringTree">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="cb97fca3-ac30-4866-9a4a-01c6df2a2fd2" name="确认单位表单" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\810f3e3e-5ad3-44d9-9170-422431681920.jpg">
|
||||
<wnd x:name="Window" cls="TfrmRegister" title="注册" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="2" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TfrmQrdw" uia-name="确认参保登记信息">
|
||||
<optional title="确认参保登记信息" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="3" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TVirtualStringTree">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="067b4aa7-1103-49c4-b253-e2699f5d3ec7" name="确认单位窗格" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\192ae534-5aaf-4cec-9d6e-60d928d7e189.jpg">
|
||||
<wnd x:name="Window" cls="TfrmRegister" title="注册" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="2" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TfrmQrdw" uia-name="确认参保登记信息">
|
||||
<optional title="确认参保登记信息" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="3" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TVirtualStringTree">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="37471326-08a9-4208-b9f3-a52ec9599d75" name="缴费金额" type="simple" framework="acc" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\1d650081-8eb0-4bfc-9e5f-4e902917cac9.jpg">
|
||||
<wnd x:name="Window" cls="Tfrm_MainFrame" title="社保费管理客户端" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel" uia-name="pnl_all">
|
||||
<optional title="pnl_all" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TFrmView" uia-name="视图基类">
|
||||
<optional title="视图基类" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="Tfrm_DKDJWarpedCustom" uia-name="代扣代缴封装窗体">
|
||||
<optional title="代扣代缴封装窗体" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TfrmHdsbbbtx" uia-name="frmHdsbbbtx">
|
||||
<optional title="frmHdsbbbtx" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TXPFarmerFlowPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<acc x:name="Client">
|
||||
<optional index="0" />
|
||||
</acc>
|
||||
</selector>
|
||||
<selector id="037a2a29-055f-47c1-972c-64a218b71ea9" name="金额窗格" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\46831717-7e82-43df-a0a5-9d75e8ef021e.jpg">
|
||||
<wnd x:name="Window" cls="Tfrm_MainFrame" title="社保费管理客户端" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel" uia-name="pnl_all">
|
||||
<optional title="pnl_all" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TFrmView" uia-name="视图基类">
|
||||
<optional title="视图基类" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="Tfrm_DKDJWarpedCustom" uia-name="代扣代缴封装窗体">
|
||||
<optional title="代扣代缴封装窗体" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TfrmHdsbbbtx" uia-name="frmHdsbbbtx">
|
||||
<optional title="frmHdsbbbtx" index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TXPFarmerFlowPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="7bbbc4fd-4130-434c-9376-3a16b10edc81" name="申报结果表单" type="simple" framework="acc" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\140599fa-233b-4b1c-a2b5-bf337ab2ea70.jpg">
|
||||
<wnd x:name="Window" cls="Tfrm_MainFrame" title="社保费管理客户端" app="EPPortalSB">
|
||||
<optional />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel" uia-name="pnl_all">
|
||||
<optional title="pnl_all" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TFrmView" uia-name="视图基类">
|
||||
<optional title="视图基类" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="Tfrm_DKDJWarpedCustom" uia-name="代扣代缴封装窗体">
|
||||
<optional title="代扣代缴封装窗体" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TFrmHdsbsbjl" uia-name="FrmHdsbsbjl">
|
||||
<optional title="FrmHdsbsbjl" index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="1" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TJdlsPanel">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="TAdvStringGrid">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<acc x:name="Client">
|
||||
<optional index="0" />
|
||||
</acc>
|
||||
</selector>
|
||||
<selector id="10a2f2ca-d407-48b8-92ed-4463b763ab5c" name="申报记录文件名输入框" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\c7a117ea-fa56-4a62-a9c4-6176c9e4a908.jpg">
|
||||
<wnd x:name="Window" title="另存为" app="EPPortalSB">
|
||||
<optional cls="#32770" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="ComboBoxEx32">
|
||||
<optional index="8" />
|
||||
</wnd>
|
||||
<wnd x:name="ComboBox" cls="ComboBox" uia-name="文件名(N):">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Edit" cls="Edit" uia-name="文件名(N):">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="4fae1940-3b27-4be4-979c-0c6aa21252af" name="征集信息文件名输入框" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\e8244860-015e-4053-aa2f-09735e9a3dc0.jpg">
|
||||
<wnd x:name="Window" title="另存为" app="EPPortalSB">
|
||||
<optional cls="#32770" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="ComboBoxEx32" uia-name="社保费未申报汇总信息.xls">
|
||||
<optional title="社保费未申报汇总信息.xls" index="8" />
|
||||
</wnd>
|
||||
<wnd x:name="ComboBox" cls="ComboBox" uia-name="文件名(N):">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Edit" cls="Edit" uia-name="文件名(N):">
|
||||
<optional title="社保费未申报汇总信息.xls" index="0" />
|
||||
</wnd>
|
||||
</selector>
|
||||
<selector id="487ba707-eb37-41cb-bf48-3e0049d447cb" name="特殊申报文件名输入框" type="simple" framework="win32" selectorOringin="Inspect" processName="EPPortalSB" productName="" winTitle="社保费管理客户端" screenshot=".dev\screenshot\8b7235ee-7481-41a7-90bf-e39720cca4c5.jpg">
|
||||
<wnd x:name="Window" title="另存为" app="EPPortalSB">
|
||||
<optional cls="#32770" />
|
||||
</wnd>
|
||||
<wnd x:name="Pane" cls="ComboBoxEx32" uia-name="社保费未申报汇总信息.xls">
|
||||
<optional title="社保费未申报汇总信息.xls" index="8" />
|
||||
</wnd>
|
||||
<wnd x:name="ComboBox" cls="ComboBox" uia-name="文件名(N):">
|
||||
<optional index="0" />
|
||||
</wnd>
|
||||
<wnd x:name="Edit" cls="Edit" uia-name="文件名(N):">
|
||||
<optional title="社保费未申报汇总信息.xls" index="0" />
|
||||
</wnd>
|
||||
</selector>
|
||||
</group>
|
||||
</repository>
|
||||
@@ -1,11 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0020 EHR系统离职电子签流程审核 插件打包脚本(统一规范版)。
|
||||
"""XQ0020 EHR系统改签离职电子签流程审核 插件打包脚本(统一规范版)。
|
||||
|
||||
打包产物统一输出到仓库根 dist-plugin/<id>_v<版本>.zip(目录不入库),
|
||||
zip 根含 plugin.json,可被 agent_cli publish 直接发布。详见 docs/插件/插件开发规范.md 与 docs/插件/发版规范.md。
|
||||
|
||||
用法(任意 cwd 均可):
|
||||
d:\\work\\code\\37duAutomation\\.venv\\Scripts\\python.exe "plugins\\XQ0001-0100\\XQ0020 EHR系统离职电子签流程审核\\_pack.py"
|
||||
d:\\work\\code\\37duAutomation\\.venv\\Scripts\\python.exe "plugins\\XQ0001-0100\\XQ0020 EHR系统改签离职电子签流程审核\\_pack.py"
|
||||
随后发布:
|
||||
.venv\\Scripts\\python.exe -m controlplane.tools.agent_cli publish \
|
||||
dist-plugin\\xq0020_v<版本>.zip --id xq0020 --version <版本>
|
||||
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"id": "xq0020",
|
||||
"name": "EHR系统改签离职电子签流程审核",
|
||||
"version": "1.0.1",
|
||||
"description": "自动审核 EHR 离职电子签待办:拉取待办与表单,按是否已发起电子签、员工/企业签署状态三态校验;三态均已完成则下载签章附件(解除确认书/报酬支付确认)并核验日期与离职原因是否与表单一致,全部通过自动提交审批;同时检查「完善信息(操作人)」节点超期名单,并生成审批报告与钉钉群推送。",
|
||||
"category": "人事考勤",
|
||||
"platform": "hr",
|
||||
"uses_month": false,
|
||||
"ui": true,
|
||||
"capabilities": ["xq0020"],
|
||||
"permissions": {"platforms": ["hr"]},
|
||||
"fields": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"save_dir": {
|
||||
"type": "string",
|
||||
"title": "输出目录",
|
||||
"default": "D:\\资料\\人资\\离职电子签流程审核",
|
||||
"description": "审批报告与签章附件(附件/ 子目录)统一存放目录"
|
||||
},
|
||||
"approve_enabled": {
|
||||
"type": "boolean",
|
||||
"title": "自动提交审批",
|
||||
"default": true,
|
||||
"description": "开启后,校验结论为「通过」的单据会在流程详情页自动点击同意;关闭则只校验不提交"
|
||||
},
|
||||
"push_enabled": {
|
||||
"type": "boolean",
|
||||
"title": "钉钉群推送",
|
||||
"default": true,
|
||||
"description": "开启后把汇总、提交失败与超期名单推送到钉钉群机器人"
|
||||
},
|
||||
"push_env": {
|
||||
"type": "string",
|
||||
"title": "推送环境",
|
||||
"default": "dev",
|
||||
"description": "dev=内置测试群,prod=内置生产群;填写自定义 Webhook 时以自定义为准"
|
||||
},
|
||||
"dingtalk_webhook": {
|
||||
"type": "string",
|
||||
"title": "钉钉 Webhook",
|
||||
"default": "",
|
||||
"description": "留空使用内置默认机器人;需要发到其他群时填写完整 webhook 地址"
|
||||
},
|
||||
"dingtalk_secret": {
|
||||
"type": "string",
|
||||
"title": "钉钉加签密钥",
|
||||
"default": "",
|
||||
"description": "机器人启用加签安全设置时填写,留空表示不加签"
|
||||
},
|
||||
"debug_mode": {
|
||||
"type": "boolean",
|
||||
"title": "调试日志",
|
||||
"default": false,
|
||||
"description": "开启后输出接口返回等调试信息"
|
||||
}
|
||||
},
|
||||
"required": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>EHR系统改签离职电子签流程审核</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||