Files
37duAutomation/plugins/XQ0001-0100/XQ0033 门店管理及服务岗出勤积分更新/logic/state_store.py
T

28 lines
813 B
Python

# -*- coding: utf-8 -*-
"""XQ0033 插件 - 新增段历史记录(_xq0033_state.json)。
结构:{数据文件名: {"new_dates": ["YYYY-MM-DD", ...]}}
删除旧修正行时跳过这些日期,防止误删历轮新增段。
"""
import json
import os
from .. import config
def load_state(path):
"""读取状态文件(不存在或损坏时按空处理并告警)。"""
if not path or not os.path.exists(path):
return {}
try:
with open(path, encoding="utf-8") as f:
return json.load(f) or {}
except Exception as e:
config.logger.warning("状态文件读取失败(按空历史处理):%s", e)
return {}
def save_state(path, state):
with open(path, "w", encoding="utf-8") as f:
json.dump(state, f, ensure_ascii=False, indent=2)