feat(plugin): XQ0052 0.6.9 台账维护与钉钉推送拆成两步,台账支持跨月换表
- 执行方式新增「只推送台账」:不取数、不改表,定位当天台账后直接推钉钉; 其余执行方式不再自动推送,维护表与推送可分成两个定时任务 - 钉钉推送改企业内部应用工作通知(actionCard + 下载台账按钮),台账先传文件服务器拿直链 - 台账定位支持跨月换表:营业日月份的表不在时按文件名年月取最新一份,同月多份仍报错不猜 - 新增 logic/push.py,界面/配置/README/_selftest 同步
This commit is contained in:
@@ -126,6 +126,7 @@ def _check_mode(config) -> list:
|
||||
"导出+维护台账": "导出+维护台账",
|
||||
"只导出": "只导出",
|
||||
"只维护台账": "只维护台账",
|
||||
"只推送台账": "只推送台账",
|
||||
"导表+维护台账": "导出+维护台账",
|
||||
"只导表": "只导出",
|
||||
"": "导出+维护台账",
|
||||
@@ -138,6 +139,27 @@ def _check_mode(config) -> list:
|
||||
return problems
|
||||
|
||||
|
||||
def _check_push() -> list:
|
||||
"""接收人解析:姓名/工号各种写法与分隔符(不发消息、不读凭证)。"""
|
||||
from logic import push
|
||||
|
||||
problems = []
|
||||
cases = {
|
||||
"张三/37036361": [("张三", "37036361")],
|
||||
" 张三/37036361 、李四(37012345);王五(37099999) ": [
|
||||
("张三", "37036361"), ("李四", "37012345"), ("王五", "37099999")],
|
||||
"张三/37036361,李四/37012345\n王五": [
|
||||
("张三", "37036361"), ("李四", "37012345"), ("王五", "")],
|
||||
"": [],
|
||||
"、 , ;": [],
|
||||
}
|
||||
for raw, want in cases.items():
|
||||
got = push.parse_recipients(raw)
|
||||
if got != want:
|
||||
problems.append("parse_recipients(%r) = %r,应为 %r" % (raw, got, want))
|
||||
return problems
|
||||
|
||||
|
||||
def _check_ledger() -> list:
|
||||
"""台账维护的纯逻辑(不碰 Excel):Excel 日期序列、待补日期窗口与数据归属日。"""
|
||||
from datetime import datetime
|
||||
@@ -232,14 +254,25 @@ def _check_ledger_path() -> list:
|
||||
if ledger_path.resolve(got, day) != got:
|
||||
problems.append("填完整文件路径时应原样使用")
|
||||
|
||||
# 多份且都没当月年月 → 报错(不猜)
|
||||
# 目标月份的表不在:有年月信息 → 取最新月份那份(切月换表)
|
||||
touch("2026年10月会员卡统计.xlsx")
|
||||
touch("2026年12月会员卡统计.xlsx")
|
||||
got = ledger_path.resolve(root, day)
|
||||
if os.path.basename(got) != "2026年12月会员卡统计.xlsx":
|
||||
problems.append(f"跨月应取最新月份台账:{got}")
|
||||
|
||||
# 全都没年月又多份 → 报错(不猜)
|
||||
sub = os.path.join(root, "无年月")
|
||||
os.mkdir(sub)
|
||||
for n in ("会员卡统计.xlsx", "储值卡统计.xlsx"):
|
||||
with open(os.path.join(sub, n), "wb"):
|
||||
pass
|
||||
try:
|
||||
ledger_path.resolve(root, day)
|
||||
ledger_path.resolve(sub, day)
|
||||
except ledger_path.LedgerPathError:
|
||||
pass
|
||||
else:
|
||||
problems.append("多份台账分不清时应抛 LedgerPathError")
|
||||
problems.append("都没年月又多份时应抛 LedgerPathError")
|
||||
|
||||
# 有当月年月 → 用它
|
||||
touch("2026年11月会员卡统计-模版调整-新会员卡.xlsx")
|
||||
@@ -266,7 +299,7 @@ def main() -> int:
|
||||
import config
|
||||
from logic import period
|
||||
|
||||
problems = (_check_period(period) + _check_mode(config)
|
||||
problems = (_check_period(period) + _check_mode(config) + _check_push()
|
||||
+ _check_ledger() + _check_ledger_path())
|
||||
if problems:
|
||||
print("口径异常:\n- " + "\n- ".join(problems), file=sys.stderr)
|
||||
|
||||
Reference in New Issue
Block a user