py-zkhb-sdk 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- py_zkhb_sdk-1.0.0/.env.example +6 -0
- py_zkhb_sdk-1.0.0/.gitee/ISSUE_TEMPLATE.zh-CN.md +13 -0
- py_zkhb_sdk-1.0.0/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md +12 -0
- py_zkhb_sdk-1.0.0/.gitignore +146 -0
- py_zkhb_sdk-1.0.0/.trae/skills/release-publish/SKILL.md +146 -0
- py_zkhb_sdk-1.0.0/LICENSE +21 -0
- py_zkhb_sdk-1.0.0/PKG-INFO +204 -0
- py_zkhb_sdk-1.0.0/README.en.md +36 -0
- py_zkhb_sdk-1.0.0/README.md +190 -0
- py_zkhb_sdk-1.0.0/pyproject.toml +162 -0
- py_zkhb_sdk-1.0.0/src/py_zkhb_sdk/__init__.py +19 -0
- py_zkhb_sdk-1.0.0/src/py_zkhb_sdk/_version.py +18 -0
- py_zkhb_sdk-1.0.0/src/py_zkhb_sdk/core/__init__.py +6 -0
- py_zkhb_sdk-1.0.0/src/py_zkhb_sdk/core/_models.py +17 -0
- py_zkhb_sdk-1.0.0/src/py_zkhb_sdk/core/_utils.py +153 -0
- py_zkhb_sdk-1.0.0/src/py_zkhb_sdk/core/_web_service.py +72 -0
- py_zkhb_sdk-1.0.0/src/py_zkhb_sdk/provider.py +26 -0
- py_zkhb_sdk-1.0.0/tests/conftest.py +23 -0
- py_zkhb_sdk-1.0.0/tests/test_web_service.py +458 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
98
|
+
__pypackages__/
|
|
99
|
+
|
|
100
|
+
# Celery stuff
|
|
101
|
+
celerybeat-schedule
|
|
102
|
+
celerybeat.pid
|
|
103
|
+
|
|
104
|
+
# SageMath parsed files
|
|
105
|
+
*.sage.py
|
|
106
|
+
|
|
107
|
+
# Environments
|
|
108
|
+
.env
|
|
109
|
+
.venv
|
|
110
|
+
env/
|
|
111
|
+
venv/
|
|
112
|
+
ENV/
|
|
113
|
+
env.bak/
|
|
114
|
+
venv.bak/
|
|
115
|
+
|
|
116
|
+
# Spyder project settings
|
|
117
|
+
.spyderproject
|
|
118
|
+
.spyproject
|
|
119
|
+
|
|
120
|
+
# Rope project settings
|
|
121
|
+
.ropeproject
|
|
122
|
+
|
|
123
|
+
# mkdocs documentation
|
|
124
|
+
/site
|
|
125
|
+
|
|
126
|
+
# mypy
|
|
127
|
+
.mypy_cache/
|
|
128
|
+
.dmypy.json
|
|
129
|
+
dmypy.json
|
|
130
|
+
|
|
131
|
+
# Pyre type checker
|
|
132
|
+
.pyre/
|
|
133
|
+
|
|
134
|
+
# pytype static type analyzer
|
|
135
|
+
.pytype/
|
|
136
|
+
|
|
137
|
+
# Cython debug symbols
|
|
138
|
+
cython_debug/
|
|
139
|
+
.env
|
|
140
|
+
dist/
|
|
141
|
+
uv.lock
|
|
142
|
+
.ruff_cache/
|
|
143
|
+
.screenshot/
|
|
144
|
+
.DS_Store
|
|
145
|
+
.ruff_cache/
|
|
146
|
+
uv.lock
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: release-publish
|
|
3
|
+
description: 一站式发布 py-zkhb-sdk 到 PyPI 并同步 Gitee 三分支. Use when the user asks to release, publish, bump version, tag, or deploy a new version of py_zkhb_sdk. Do not use for non-release git operations or packages other than this SDK.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Release Publish
|
|
7
|
+
|
|
8
|
+
将当前仓库的所有改动打包发布到 PyPI, 并将 develop/release/master 三个 Git 分支和 tag 同步到 Gitee. 整个流程必须在 develop 分支上完成.
|
|
9
|
+
|
|
10
|
+
## 触发条件
|
|
11
|
+
|
|
12
|
+
用户说"发布 X.X.X"、"release"、"发版"、"打 tag"、"推到 PyPI" 时触发. 用户必须提供目标版本号 (major.minor.patch).
|
|
13
|
+
|
|
14
|
+
## 仓库特定信息
|
|
15
|
+
|
|
16
|
+
| 项目 | 值 |
|
|
17
|
+
|---|---|
|
|
18
|
+
| 仓库 | `https://gitee.com/guolei19850528/py_zkhb_sdk` |
|
|
19
|
+
| 远程 origin | `git@gitee.com:guolei19850528/py_zkhb_sdk.git` |
|
|
20
|
+
| PyPI 项目名 | `py-zkhb-sdk` |
|
|
21
|
+
| 包 import 名 | `py_zkhb_sdk` |
|
|
22
|
+
| 版本文件 | `src/py_zkhb_sdk/_version.py` |
|
|
23
|
+
| 主分支 | `master` |
|
|
24
|
+
| 开发分支 | `develop` |
|
|
25
|
+
| 发布分支 | `release` |
|
|
26
|
+
| 构建后端 | hatchling (pyproject.toml 的 `[tool.hatch.version]` 动态读取 `_version.py`) |
|
|
27
|
+
| 虚拟环境 | `.venv` |
|
|
28
|
+
|
|
29
|
+
## 前置检查 (必须全部通过)
|
|
30
|
+
|
|
31
|
+
1. **当前分支 = develop**: `git branch --show-current` 输出必须是 `develop`, 否则先 `git checkout develop && git pull origin develop`
|
|
32
|
+
2. **工作区干净**: `git status --short` 只能有 `M`/`A`/`D` (本次要发布的改动), 不能有 `??` (未追踪文件), 不能有 `UU`/`AA` (冲突)
|
|
33
|
+
3. **PyPI 凭据可用**: 检查 `~/.pypirc` 存在且 `[pypi]` 段有 `username = __token__` 和非空 `password`
|
|
34
|
+
4. **构建工具就绪**: `.venv/bin/python -m build` 和 `.venv/bin/twine` 可执行; 若不可执行, 先 `.venv/bin/python -m pip install build twine`
|
|
35
|
+
5. **ruff check + format 通过**: 先 `.venv/bin/ruff check --fix src/ tests/` 自动修复, 然后 `.venv/bin/ruff format src/ tests/`; 最后 `.venv/bin/ruff check src/ tests/` 和 `.venv/bin/ruff format --check src/ tests/` 退出码都为 0
|
|
36
|
+
6. **mypy 静态检查通过**: `.venv/bin/mypy src/` 退出码 0. 若有 `# type: ignore[...]` 残留, 优先修正代码而非忽略; 仅在第三方库 stub 缺失时允许 `# type: ignore[import-untyped]`
|
|
37
|
+
|
|
38
|
+
## 执行流程 (严格按顺序)
|
|
39
|
+
|
|
40
|
+
### Step 1 — 版本号 bump
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# 读取当前版本确认
|
|
44
|
+
.venv/bin/python -c "from py_zkhb_sdk._version import __version__; print(__version__)"
|
|
45
|
+
# 确认用户要求的新版本号 >= 当前版本 (SemVer 递增)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
修改 `src/py_zkhb_sdk/_version.py` 中的 `__version__ = "X.Y.Z"`.
|
|
49
|
+
|
|
50
|
+
### Step 2 — Commit + Tag
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
git add -A
|
|
54
|
+
git commit -m "chore: bump version to X.Y.Z"
|
|
55
|
+
git tag -a vX.Y.Z -m "Release vX.Y.Z — <简短说明>"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
commit message 格式:
|
|
59
|
+
|
|
60
|
+
- 若有功能/修复改动: `feat|fix(module): <简要描述> + bump vX.Y.Z`
|
|
61
|
+
- 仅版本 bump: `chore: bump version to X.Y.Z`
|
|
62
|
+
|
|
63
|
+
### Step 3 — 构建
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
.venv/bin/python -m build
|
|
67
|
+
# 验证产物
|
|
68
|
+
ls dist/py_zkhb_sdk-X.Y.Z.tar.gz dist/py_zkhb_sdk-X.Y.Z-py3-none-any.whl
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Step 4 — PyPI 上传
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
.venv/bin/twine upload dist/py_zkhb_sdk-X.Y.Z*
|
|
75
|
+
# 成功后会输出 https://pypi.org/project/py-zkhb-sdk/X.Y.Z/
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
如果遇到 `HTTP 400 File already exists`, 说明 PyPI 上已有该版本 (重复发布), 让用户确认是否版本号写错了.
|
|
79
|
+
|
|
80
|
+
### Step 5 — 合并到 release 分支
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
git checkout release && git merge --no-ff develop -m "merge: develop → release (vX.Y.Z)" && git push origin release
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Step 6 — 合并到 master 分支
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
git checkout master && git merge --no-ff develop -m "merge: develop → master (vX.Y.Z)" && git push origin master
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Step 7 — 回到 develop + 推送 develop + 推送 tag
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
git checkout develop && git push origin develop && git push origin vX.Y.Z
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Step 8 — 最终验证
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
git branch -a --verbose | grep -E "develop|release|master"
|
|
102
|
+
git tag -l "vX.Y.Z" -n3
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
三个远端分支必须指向同一组改动 (release 和 master 显示 merge commit, develop 显示原始 feat/fix commit), tag 必须存在且是 annotated tag.
|
|
106
|
+
|
|
107
|
+
## 完成报告模板
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
vX.Y.Z 发布完成 ✅
|
|
111
|
+
|
|
112
|
+
| 步骤 | 状态 |
|
|
113
|
+
|---|---|
|
|
114
|
+
| ruff check src/ tests/ | ✅ passed |
|
|
115
|
+
| ruff format src/ tests/ | ✅ passed |
|
|
116
|
+
| mypy src/ | ✅ passed |
|
|
117
|
+
| _version.py bump 旧版 → X.Y.Z | ✅ |
|
|
118
|
+
| Git commit (hash) + annotated tag vX.Y.Z | ✅ |
|
|
119
|
+
| python -m build | ✅ wheel + sdist |
|
|
120
|
+
| twine upload → https://pypi.org/project/py-zkhb-sdk/X.Y.Z/ | ✅ |
|
|
121
|
+
| develop → release merge + push | ✅ |
|
|
122
|
+
| develop → master merge + push | ✅ |
|
|
123
|
+
| 三分支 + tag 全部推送到 Gitee | ✅ |
|
|
124
|
+
|
|
125
|
+
三分支对齐:
|
|
126
|
+
origin/develop <hash> <commit msg>
|
|
127
|
+
origin/release <hash> merge: develop → release (vX.Y.Z)
|
|
128
|
+
origin/master <hash> merge: develop → master (vX.Y.Z)
|
|
129
|
+
|
|
130
|
+
在线地址:
|
|
131
|
+
📦 PyPI: https://pypi.org/project/py-zkhb-sdk/X.Y.Z/
|
|
132
|
+
🏷️ Tag vX.Y.Z
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## 错误处理
|
|
136
|
+
|
|
137
|
+
| 失败点 | 处理 |
|
|
138
|
+
|---|---|
|
|
139
|
+
| `ruff check` 返回非 0 | 可自动修复的先 `.venv/bin/ruff check --fix`; 不可修复的停下让用户手动解决. 修复后必须重新 run 确认退出码 0 |
|
|
140
|
+
| `ruff format --check` 返回非 0 | 运行 `.venv/bin/ruff format src/ tests/` 写入格式化, 然后 `git add -A` 暂存, 最后再次 `ruff format --check` 确认通过 |
|
|
141
|
+
| `mypy` 返回非 0 | 停下, 展示具体错误行, 让用户修正代码. 严禁在未说明原因的情况下新增 `# type: ignore` |
|
|
142
|
+
| `git status` 显示冲突/未追踪文件 | 停下, 让用户清理工作区后再继续 |
|
|
143
|
+
| `python -m build` 失败 | 检查错误日志, 修复代码后回到 Step 1 (版本号不变, 只需追加 commit) |
|
|
144
|
+
| `twine upload` 返回 400 | 版本号已在 PyPI 存在 → 版本号写错了, 重新 bump |
|
|
145
|
+
| `git merge` 冲突 | 停下, 手动解决冲突后用户确认再继续 |
|
|
146
|
+
| `git push` 认证失败 | 检查 Gitee SSH key 凭据 |
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 郭磊
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: py-zkhb-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: zkhb WebService 平台 Python SDK - 同步接口调用(官方文档: 待补充)
|
|
5
|
+
Project-URL: Homepage, https://gitee.com/guolei19850528/py_zkhb_sdk
|
|
6
|
+
Project-URL: Repository, https://gitee.com/guolei19850528/py_zkhb_sdk.git
|
|
7
|
+
Project-URL: Issues, https://gitee.com/guolei19850528/py_zkhb_sdk/issues
|
|
8
|
+
Author-email: guolei <174000902@qq.com>
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Requires-Dist: pydantic>=2.7
|
|
12
|
+
Requires-Dist: zeep[async,xmlsec]>=4.3.3
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# py_zkhb_sdk
|
|
16
|
+
|
|
17
|
+
zkhb 平台 SOAP Web Service Python SDK,基于 `zeep` 封装,提供收费明细查询、响应解析与对冲过滤等高层能力。
|
|
18
|
+
|
|
19
|
+
## 功能概览
|
|
20
|
+
|
|
21
|
+
- **SOAP 便捷封装**:`ZkhbWebServiceAPI` 自动创建 zeep 客户端,一行调用 `GetDataSet`
|
|
22
|
+
- **收费明细查询 SQL 生成**:`build_zkhb_web_service_api_query_charge_fee_item_list_sql` 封装多表 join
|
|
23
|
+
- **SOAP 响应解析**:`extract_zkhb_web_service_api_charge_fee_item_list` 从 `GetDataSetResult` 中抽取行数据
|
|
24
|
+
- **对冲过滤**:`hedging_zkhb_web_service_api_charge_fee_item_list` 同一收款周期内正/负金额配对抵消
|
|
25
|
+
- **类型安全**:全部公开符号带类型注解 + Google 风格 docstring,mypy strict 通过
|
|
26
|
+
- **代码风格**:PEP 8 + ruff + Google Python Style Guide
|
|
27
|
+
|
|
28
|
+
## 目录结构
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
py_zkhb_sdk/
|
|
32
|
+
├── src/py_zkhb_sdk/
|
|
33
|
+
│ ├── __init__.py # 包入口, 暴露 __version__
|
|
34
|
+
│ ├── _version.py # 唯一维护的版本号
|
|
35
|
+
│ ├── provider.py # 门面模块, 所有公共符号从此导出
|
|
36
|
+
│ └── core/
|
|
37
|
+
│ ├── _models.py # ZkhbWebServiceAPIConfig (pydantic)
|
|
38
|
+
│ ├── _web_service.py # ZkhbWebServiceAPI 主入口类
|
|
39
|
+
│ └── _utils.py # SQL 构造 / 响应解析 / 对冲过滤
|
|
40
|
+
├── tests/ # pytest 集成测试 (真实 SOAP 请求)
|
|
41
|
+
└── pyproject.toml # hatchling + ruff + mypy 配置
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 安装
|
|
45
|
+
|
|
46
|
+
### PyPI
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install py-zkhb-sdk
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 本地开发
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# 克隆并进入
|
|
56
|
+
git clone https://gitee.com/guolei19850528/py_zkhb_sdk.git
|
|
57
|
+
cd py_zkhb_sdk
|
|
58
|
+
|
|
59
|
+
# 推荐用 uv
|
|
60
|
+
uv sync --dev
|
|
61
|
+
|
|
62
|
+
# 或使用 pip editable 安装
|
|
63
|
+
pip install -e .
|
|
64
|
+
pip install pytest python-dotenv ruff mypy # 开发工具
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
要求:Python ≥ 3.10
|
|
68
|
+
|
|
69
|
+
## 快速开始
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from py_zkhb_sdk.provider import (
|
|
73
|
+
ZkhbWebServiceAPI,
|
|
74
|
+
ZkhbWebServiceAPIConfig,
|
|
75
|
+
build_zkhb_web_service_api_query_charge_fee_item_list_sql,
|
|
76
|
+
extract_zkhb_web_service_api_charge_fee_item_list,
|
|
77
|
+
hedging_zkhb_web_service_api_charge_fee_item_list,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# 1) 配置 WSDL
|
|
81
|
+
cfg = ZkhbWebServiceAPIConfig(
|
|
82
|
+
wsdl="http://host/estate/webService/ForcelandEstateService.asmx?WSDL"
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# 2) 创建客户端
|
|
86
|
+
api = ZkhbWebServiceAPI(config=cfg)
|
|
87
|
+
|
|
88
|
+
# 3) 构造查询 SQL
|
|
89
|
+
sql = build_zkhb_web_service_api_query_charge_fee_item_list_sql(
|
|
90
|
+
conditions="and cml.EstateID=51",
|
|
91
|
+
order_by="order by cml.ChargeTime desc",
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
# 4) 调用封装方法 (自动抽取 Table)
|
|
95
|
+
rows = api.query_charge_fee_item_list(sql=sql)
|
|
96
|
+
|
|
97
|
+
# 5) 对冲过滤 (同周期正/负金额配对抵消)
|
|
98
|
+
cleaned = hedging_zkhb_web_service_api_charge_fee_item_list(rows)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 直接使用原始 SOAP 操作
|
|
102
|
+
|
|
103
|
+
封装方法之外, `api.client.service` 直接暴露 WSDL 上所有 SOAP 操作:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
# 直接调用 GetDataSet
|
|
107
|
+
result = api.client.service.GetDataSet(sql="select top 10 * from chargeMasterList", url="")
|
|
108
|
+
|
|
109
|
+
# 手动从返回体抽取行数据
|
|
110
|
+
from zeep.helpers import serialize_object
|
|
111
|
+
data = serialize_object(result, dict)
|
|
112
|
+
rows = extract_zkhb_web_service_api_charge_fee_item_list(data)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## 门面导出清单
|
|
116
|
+
|
|
117
|
+
全部公共符号从 `py_zkhb_sdk.provider` 导入即可, 无需关心内部路径:
|
|
118
|
+
|
|
119
|
+
| 名称 | 类型 | 说明 |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `ZkhbWebServiceAPI` | class | SOAP 主入口, 封装 zeep 客户端 |
|
|
122
|
+
| `ZkhbWebServiceAPIConfig` | class | 运行配置 (pydantic), 含必填的 `wsdl` 字段 |
|
|
123
|
+
| `build_zkhb_web_service_api_query_charge_fee_item_list_sql` | function | 生成收费明细全链路 SQL |
|
|
124
|
+
| `extract_zkhb_web_service_api_charge_fee_item_list` | function | 从 SOAP 返回体抽取 `Table` 列表 |
|
|
125
|
+
| `hedging_zkhb_web_service_api_charge_fee_item_list` | function | 同一收款周期正/负金额配对抵消 |
|
|
126
|
+
|
|
127
|
+
## 测试
|
|
128
|
+
|
|
129
|
+
### 运行
|
|
130
|
+
|
|
131
|
+
测试分为两部分:
|
|
132
|
+
|
|
133
|
+
- `TestBuildZkhbWebServiceApiQueryChargeFeeItemListSql` / `TestExtractZkhbWebServiceApiChargeFeeItemList` / `TestHedgingZkhbWebServiceApiChargeFeeItemList` — 纯函数, 自生成合成数据, **不发网络请求**, 可直接跑
|
|
134
|
+
- `TestZkhbWebServiceAPIInit` / `TestGetDataSetRaw` / `TestEndToEndPipeline` — **真实 SOAP 调用**, 需要 `.env` 里的 WSDL
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# 1) 复制环境变量模板
|
|
138
|
+
cp .env.example .env
|
|
139
|
+
# 填入你的 zkhb WSDL 地址
|
|
140
|
+
# ZKHB_WEB_SERVICE_WSDL=http://host/estate/webService/ForcelandEstateService.asmx?WSDL
|
|
141
|
+
|
|
142
|
+
# 2) 跑全部测试 (含真实 SOAP 请求)
|
|
143
|
+
pytest tests/ -v
|
|
144
|
+
|
|
145
|
+
# 3) 只跑单元测试 (不需要网络)
|
|
146
|
+
pytest tests/ -v -k "Build or Extract or Hedging"
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
当前测试覆盖: **40 个用例 / 32 个通过 (含真实 SOAP) / 单元测试全过**
|
|
150
|
+
|
|
151
|
+
### 规则
|
|
152
|
+
|
|
153
|
+
- 没有配置 `ZKHB_WEB_SERVICE_WSDL` 时, 集成测试类自动 skip
|
|
154
|
+
- `Hedging` 测试全部使用自生成合成数据, 不依赖外部环境
|
|
155
|
+
|
|
156
|
+
## 代码规范
|
|
157
|
+
|
|
158
|
+
本项目遵循 Google Python Style Guide + PEP 8:
|
|
159
|
+
|
|
160
|
+
| 工具 | 配置 | 用途 |
|
|
161
|
+
|---|---|---|
|
|
162
|
+
| ruff | pyproject.toml `[tool.ruff]` | Lint + 格式化 + isort |
|
|
163
|
+
| mypy | pyproject.toml `[tool.mypy]` (strict) | 静态类型检查 |
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# 自动修复 + 格式化
|
|
167
|
+
ruff check --fix src/ tests/
|
|
168
|
+
ruff format src/ tests/
|
|
169
|
+
|
|
170
|
+
# 只检查, 不改文件
|
|
171
|
+
ruff check src/ tests/
|
|
172
|
+
ruff format --check src/ tests/
|
|
173
|
+
mypy src/
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## 构建 & 发布 (仅维护者)
|
|
177
|
+
|
|
178
|
+
发布流程封装在项目级 Skill `release-publish` 中, 触发词: "发布 X.Y.Z" / "release" / "推到 PyPI". 执行前先确认:
|
|
179
|
+
|
|
180
|
+
- 当前分支 = `develop`, 工作区干净
|
|
181
|
+
- `.venv` 里装了 `build` / `twine`, `~/.pypirc` 有 PyPI token
|
|
182
|
+
- `ruff check` / `ruff format --check` / `mypy` 全部通过
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# 最终产物位于 dist/
|
|
186
|
+
.venv/bin/python -m build
|
|
187
|
+
.venv/bin/twine upload dist/py_zkhb-sdk-X.Y.Z*
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
发布后自动合并 `develop → release → master`, 打 annotated tag, 三分支推送到 Gitee.
|
|
191
|
+
|
|
192
|
+
## 版本
|
|
193
|
+
|
|
194
|
+
遵循 SemVer. 版本号只在一处维护: [`src/py_zkhb_sdk/_version.py`](./src/py_zkhb_sdk/_version.py) 中的 `__version__`, hatchling 构建时自动读取.
|
|
195
|
+
|
|
196
|
+
## 社区
|
|
197
|
+
|
|
198
|
+
- **Gitee**: <https://gitee.com/guolei19850528/py_zkhb_sdk>
|
|
199
|
+
- **Issues**: <https://gitee.com/guolei19850528/py_zkhb_sdk/issues>
|
|
200
|
+
- **作者**: guolei <174000902@qq.com>
|
|
201
|
+
|
|
202
|
+
## License
|
|
203
|
+
|
|
204
|
+
MIT License
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# py_zkhb_sdk
|
|
2
|
+
|
|
3
|
+
#### Description
|
|
4
|
+
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
|
|
5
|
+
|
|
6
|
+
#### Software Architecture
|
|
7
|
+
Software architecture description
|
|
8
|
+
|
|
9
|
+
#### Installation
|
|
10
|
+
|
|
11
|
+
1. xxxx
|
|
12
|
+
2. xxxx
|
|
13
|
+
3. xxxx
|
|
14
|
+
|
|
15
|
+
#### Instructions
|
|
16
|
+
|
|
17
|
+
1. xxxx
|
|
18
|
+
2. xxxx
|
|
19
|
+
3. xxxx
|
|
20
|
+
|
|
21
|
+
#### Contribution
|
|
22
|
+
|
|
23
|
+
1. Fork the repository
|
|
24
|
+
2. Create Feat_xxx branch
|
|
25
|
+
3. Commit your code
|
|
26
|
+
4. Create Pull Request
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
#### Gitee Feature
|
|
30
|
+
|
|
31
|
+
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
|
|
32
|
+
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
|
|
33
|
+
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
|
|
34
|
+
4. The most valuable open source project [GVP](https://gitee.com/gvp)
|
|
35
|
+
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
|
|
36
|
+
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|