From 9b050c9dc55e438bb050fe7467ace75e6daacb82 Mon Sep 17 00:00:00 2001 From: "weicw1996@qq.com" Date: Wed, 9 Sep 2026 10:59:00 +0800 Subject: [PATCH] =?UTF-8?q?test(hjc):=20=E4=B8=80=E7=AB=99=E5=BC=8F?= =?UTF-8?q?=E5=85=A5=E5=90=91=E6=8E=A8=E9=80=81=E6=B5=8B=E8=AF=95=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=EF=BC=88POST=20/api/hjc/push/project=EF=BC=8CappKey+t?= =?UTF-8?q?imestamp+sign=20=E9=89=B4=E6=9D=83=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/hjc_test_push.py | 101 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 scripts/hjc_test_push.py diff --git a/scripts/hjc_test_push.py b/scripts/hjc_test_push.py new file mode 100644 index 0000000..858f88f --- /dev/null +++ b/scripts/hjc_test_push.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +汇吉采 <-- 一站式:推送标书项目测试脚本(入向 POST /api/hjc/push/project) + +用法: + python hjc_test_push.py # 默认 http://uk.frp.one:62335 + python hjc_test_push.py http://uk.frp.one:62335 + python hjc_test_push.py --base http://uk.frp.one:62335 --project-no TEST-xxx + +无第三方依赖,仅标准库(hashlib + urllib)。时间用北京时间(UTC+8)。 +签名 sign = MD5(appKey + password + timestamp),timestamp = yyyyMMddHHmm。 +""" +import sys +import json +import hashlib +import urllib.request +import urllib.error +import datetime + +APP_KEY = "HJC_Official_Website" +PASSWORD = "vQ8$kR3#mW6@xP2!nF" +DEFAULT_BASE = "http://uk.frp.one:62335" + +DEFAULT_PAYLOAD = { + "projectNo": "TEST-HJC-20260801", + "projectName": "测试标书项目·服务器采购", + "category": "货物类", + "tenderPrice": 500.00, + "files": "[{\"name\":\"招标文件.pdf\",\"url\":\"https://file.example.com/t.pdf\"}]", + "tenderOnsaleTime": "2026-08-01 09:00:00", + "tenderOffsaleTime": "2026-08-10 17:00:00", + "bulletinName": "中标公告-测试", + "customerName": "某招标单位", + "supplierName": "某中标公司", + "bidAmount": 128000.00, + "content": "测试公告正文。中标供应商:某中标公司,中标金额 128000 元。", + "fileList": "[{\"name\":\"中标通知书.pdf\",\"url\":\"https://file.example.com/n.pdf\"}]", + "needSellTender": 1, + "sellingMethod": 2 +} + + +def bj_now() -> str: + """北京时间 yyyyMMddHHmm""" + return (datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(hours=8)).strftime("%Y%m%d%H%M") + + +def main(): + base = DEFAULT_BASE + payload = dict(DEFAULT_PAYLOAD) + args = sys.argv[1:] + i = 0 + while i < len(args): + a = args[i] + if a in ("--base", "-b"): + base = args[i + 1] + i += 2 + elif a in ("--project-no", "-p"): + payload["projectNo"] = args[i + 1] + i += 2 + elif a == "--json": + with open(args[i + 1], encoding="utf-8") as f: + payload = json.load(f) + i += 2 + else: + base = a # 位置参数作为 baseUrl + i += 1 + + url = base.rstrip("/") + "/api/hjc/push/project" + ts = bj_now() + sign = hashlib.md5((APP_KEY + PASSWORD + ts).encode("utf-8")).hexdigest() + body = json.dumps(payload, ensure_ascii=False).encode("utf-8") + + req = urllib.request.Request(url, data=body, method="POST", headers={ + "Content-Type": "application/json; charset=utf-8", + "appKey": APP_KEY, + "timestamp": ts, + "sign": sign, + "tenantId": "10626" + }) + + print("== 请求 ==") + print("URL:", url) + print("timestamp:", ts, "| sign:", sign) + print("body:", body.decode("utf-8")) + print() + print("== 响应 ==") + try: + with urllib.request.urlopen(req, timeout=20) as resp: + print("HTTP", resp.status) + print(resp.read().decode("utf-8")) + except urllib.error.HTTPError as e: + print("HTTP", e.code) + print(e.read().decode("utf-8")) + except Exception as e: + print("ERROR:", type(e).__name__, e) + + +if __name__ == "__main__": + main()