#!/usr/bin/env python3 import json import urllib.request from gmssl import sm2 BASE = "http://127.0.0.1:5005" TENANT = 797403760988229 pk = "84C7466D950E120E5ECE5DD85D0C90EAA85081A3A2BD7C57AE6DC822EFCCBD66620C67B0103FC8DD280E36C3B282977B722AAEC3C56518EDCEBAFB72C5A05312" crypt = sm2.CryptSM2(public_key=pk, private_key=None, mode=1) pwd = crypt.encrypt(b"1234567890dop").hex() def http(method, path, body=None, token=None): headers = {"Content-Type": "application/json", "Accept": "application/json"} if token: headers["Authorization"] = f"Bearer {token}" data = None if body is None else json.dumps(body).encode() req = urllib.request.Request(BASE + path, data=data, headers=headers, method=method) try: with urllib.request.urlopen(req, timeout=120) as r: raw = r.read().decode() return r.status, json.loads(raw) if raw else {} except Exception as e: if hasattr(e, "read"): raw = e.read().decode("utf-8", "replace") try: return e.code, json.loads(raw) except Exception: return getattr(e, "code", 0), {"raw": raw[:500]} return 0, {"error": str(e)} st, body = http( "POST", "/api/sysAuth/login", {"account": "AIDOPDemo", "password": pwd, "tenantId": str(TENANT)}, ) token = (body.get("result") or {}).get("accessToken") assert token, body domain = str(TENANT) apis = [ ("GET", "/api/Order/seorder/list?billNo=SO202607120001&page=1&pageSize=5", None), ("GET", "/api/Order/delivery/list?billNo=SO202607120001&page=1&pageSize=10", None), ("GET", f"/api/Production/scheduling/list?page=1&pageSize=5&domain={domain}", None), ("POST", "/api/Production/scheduling/sync-routing", {"workOrd": "M000000005", "domain": domain}), ("GET", f"/api/Production/scheduling/materials?workOrd=M000000005&domain={domain}", None), ("GET", f"/api/Production/scheduling/routings?workOrd=M000000005&domain={domain}", None), ("GET", "/api/Supply/demand-schedule/list?page=1&pageSize=5", None), ("GET", "/api/Supply/purchase-request/list?page=1&pageSize=5", None), ("GET", "/api/Supply/purchase-order/list?page=1&pageSize=5", None), ("POST", "/api/WorkOrder/dispatch/kitting-check", {"workOrd": "M000000005", "tenantId": TENANT}), ("GET", "/api/ProcurementExecution/supplier-shipment/list?page=1&pageSize=5", None), ("POST", f"/api/Production/scheduling/generate?domain={domain}", None), ] out = [] for method, path, body in apis: st, b = http(method, path, body, token) res = b.get("result", b) if isinstance(b, dict) else b brief = {} if isinstance(res, dict): for k in ("total", "message", "Message", "list", "workOrd", "count", "enabled", "scheduleRowCount", "workOrderCount"): if k in res: brief[k] = len(res[k]) if k == "list" and isinstance(res[k], list) else res[k] if not brief: brief = {"keys": list(res.keys())[:8], "code": b.get("code"), "msg": b.get("message")} else: brief = {"value": str(res)[:200]} out.append( { "api": f"{method} {path.split('?')[0]}", "http": st, "ok": st == 200 and b.get("code", 200) in (200, None), "brief": brief, "err": b.get("message") or b.get("raw") or b.get("error"), } ) path = r"d:\Projects\Ai-DOP\SourceCode\ZZYDOP\doc\_verify_s1_s4_extra_smoke_result.json" with open(path, "w", encoding="utf-8") as f: json.dump(out, f, ensure_ascii=False, indent=2, default=str) print(json.dumps(out, ensure_ascii=False, indent=2, default=str))