#!/usr/bin/env python3
import json
import datetime

json_file = "/app/config/ems_user_cfg.json"

month = datetime.datetime.now().month
key = f"DemandThreshold{month}"

with open(json_file, "r", encoding="utf-8") as f:
    data = json.load(f)

value = data.get(key, None)
if value is not None:
    data["MaxDemand"] = value
    with open(json_file, "w", encoding="utf-8") as f:
        json.dump(data, f, ensure_ascii=False, indent=4)
else:
    print(f"字段 {key} 不存在，未修改 MaxDemand")
