1.新增gitignore文件

2.新启动脚本制作
This commit is contained in:
2026-01-30 11:41:05 +08:00
parent 838453b88f
commit f0fcea03bb
4 changed files with 245 additions and 14 deletions
+179
View File
@@ -0,0 +1,179 @@
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
### 默认 template
# IntelliJ 文件
.idea
*.iml
out
gen
# 数据文件
*.csv
*.xlsx
*.xls
# 环境文件
.vscode
.conda
+10 -12
View File
@@ -81,7 +81,7 @@ def batch_disable_projects(data: Dict[str, Any], cookies: Dict[str, str], df: pd
cookies=cookies, cookies=cookies,
json=json_data, json=json_data,
) )
time.sleep(3.5) time.sleep(1)
response.raise_for_status() response.raise_for_status()
all_project_list = [] all_project_list = []
total_pages = response.json().get("data", {}).get("totalPages", 0) total_pages = response.json().get("data", {}).get("totalPages", 0)
@@ -101,7 +101,7 @@ def batch_disable_projects(data: Dict[str, Any], cookies: Dict[str, str], df: pd
cookies=cookies, cookies=cookies,
json=json_data, json=json_data,
) )
time.sleep(3.5) time.sleep(1)
response.raise_for_status() response.raise_for_status()
project_list = response.json().get("data", {}).get("records", []) project_list = response.json().get("data", {}).get("records", [])
all_project_list.extend(project_list) all_project_list.extend(project_list)
@@ -159,7 +159,7 @@ def batch_disable_projects(data: Dict[str, Any], cookies: Dict[str, str], df: pd
cookies=cookies, cookies=cookies,
json=json_data, json=json_data,
) )
time.sleep(3.5) time.sleep(2)
response.raise_for_status() # 抛出HTTP错误 response.raise_for_status() # 抛出HTTP错误
# 检查业务响应码 # 检查业务响应码
resp_data = response.json() resp_data = response.json()
@@ -287,7 +287,6 @@ def batch_modify_materials(data: Dict[str, Any], cookies: Dict[str, str], df: pd
cookies=cookies, cookies=cookies,
json=json_data, json=json_data,
) )
time.sleep(3.5)
response.raise_for_status() response.raise_for_status()
total_pages = response.json().get("data", {}).get("totalPages", 0) total_pages = response.json().get("data", {}).get("totalPages", 0)
logger.info(f"材料列表页数: {total_pages}") logger.info(f"材料列表页数: {total_pages}")
@@ -302,7 +301,7 @@ def batch_modify_materials(data: Dict[str, Any], cookies: Dict[str, str], df: pd
cookies=cookies, cookies=cookies,
json=json_data, json=json_data,
) )
time.sleep(3.5) time.sleep(1)
resp.raise_for_status() resp.raise_for_status()
records = resp.json().get("data", {}).get("records", []) records = resp.json().get("data", {}).get("records", [])
all_materials_list.extend(records) all_materials_list.extend(records)
@@ -369,7 +368,7 @@ def batch_modify_materials(data: Dict[str, Any], cookies: Dict[str, str], df: pd
params=params, params=params,
cookies=cookies, cookies=cookies,
) )
time.sleep(3.5) time.sleep(1)
if materials_response.status_code != 200: if materials_response.status_code != 200:
error_msg = f'获取明细失败: {materials_response.status_code}' error_msg = f'获取明细失败: {materials_response.status_code}'
results.append({'材料编码': custom_code, '状态': error_msg}) results.append({'材料编码': custom_code, '状态': error_msg})
@@ -423,7 +422,7 @@ def batch_modify_materials(data: Dict[str, Any], cookies: Dict[str, str], df: pd
cookies=cookies, cookies=cookies,
json=detail json=detail
) )
time.sleep(3.5) time.sleep(2)
if update_resp.status_code == 200 and update_resp.json().get("code") == 200: if update_resp.status_code == 200 and update_resp.json().get("code") == 200:
results.append({'材料编码': custom_code, '状态': '修改成功'}) results.append({'材料编码': custom_code, '状态': '修改成功'})
@@ -572,7 +571,7 @@ def batch_modify_projects(data: Dict[str, Any], cookies: Dict[str, str], df: pd.
cookies=cookies, cookies=cookies,
data={'idOwnOrg': org_id} data={'idOwnOrg': org_id}
) )
time.sleep(3.5) time.sleep(1)
init_add_resp.raise_for_status() init_add_resp.raise_for_status()
service_category_list = init_add_resp.json().get("data", {}).get("serviceCategory", []) service_category_list = init_add_resp.json().get("data", {}).get("serviceCategory", [])
category_name_to_pk = {item["name"]: item["pkId"] for item in service_category_list} category_name_to_pk = {item["name"]: item["pkId"] for item in service_category_list}
@@ -600,7 +599,6 @@ def batch_modify_projects(data: Dict[str, Any], cookies: Dict[str, str], df: pd.
cookies=cookies, cookies=cookies,
json=json_data, json=json_data,
) )
time.sleep(3.5)
response.raise_for_status() response.raise_for_status()
total_pages = response.json().get("data", {}).get("totalPages", 0) total_pages = response.json().get("data", {}).get("totalPages", 0)
logger.info(f"项目列表总页数: {total_pages}") logger.info(f"项目列表总页数: {total_pages}")
@@ -615,7 +613,7 @@ def batch_modify_projects(data: Dict[str, Any], cookies: Dict[str, str], df: pd.
cookies=cookies, cookies=cookies,
json=json_data, json=json_data,
) )
time.sleep(3.5) time.sleep(1)
resp.raise_for_status() resp.raise_for_status()
records = resp.json().get("data", {}).get("records", []) records = resp.json().get("data", {}).get("records", [])
all_project_list.extend(records) all_project_list.extend(records)
@@ -742,7 +740,7 @@ def batch_modify_projects(data: Dict[str, Any], cookies: Dict[str, str], df: pd.
params=params, params=params,
cookies=cookies, cookies=cookies,
) )
time.sleep(3.5) time.sleep(1)
if detail_resp.status_code != 200: if detail_resp.status_code != 200:
error_msg = f'获取明细失败: {detail_resp.status_code}' error_msg = f'获取明细失败: {detail_resp.status_code}'
results.append({'项目编码': custom_code, '状态': error_msg}) results.append({'项目编码': custom_code, '状态': error_msg})
@@ -816,7 +814,7 @@ def batch_modify_projects(data: Dict[str, Any], cookies: Dict[str, str], df: pd.
cookies=cookies, cookies=cookies,
json=detail json=detail
) )
time.sleep(3.5) time.sleep(2)
if update_resp.status_code == 200 and update_resp.json().get("code") == 200: if update_resp.status_code == 200 and update_resp.json().get("code") == 200:
results.append({'项目编码': custom_code, '状态': '修改成功'}) results.append({'项目编码': custom_code, '状态': '修改成功'})
+2 -2
View File
@@ -217,8 +217,8 @@ if __name__ == '__main__':
当直接运行此文件时,启动 uvicorn 服务器。 当直接运行此文件时,启动 uvicorn 服务器。
默认配置: 默认配置:
- 主机: 0.0.0.0 (监听所有网络接口) - 主机: 0.0.0.0 (监听所有网络接口)
- 端口: 5003 - 端口: 5000
- 热重载: 关闭 (生产环境建议关闭) - 热重载: 关闭 (生产环境建议关闭)
""" """
import uvicorn import uvicorn
uvicorn.run(app, host="0.0.0.0", port=5003, reload=False) uvicorn.run(app, host="0.0.0.0", port=5000, reload=False)
+54
View File
@@ -0,0 +1,54 @@
@echo off
title 简道云监听服务 端口5000
:: 切换到应用所在目录(与原始脚本一致)
cd /d "C:\Users\Administrator\Desktop\简道云\简道云"
:: 激活Anaconda基础环境(或你指定的环境)
call C:\ProgramData\anaconda3\Scripts\activate.bat
if %errorlevel% neq 0 (
echo 激活Anaconda环境失败,请检查环境配置。
pause
exit /b 1
)
:: 验证Python是否可用
python --version >nul 2>&1
if %errorlevel% neq 0 (
echo 无法找到Python,请检查Anaconda环境是否正确安装。
pause
exit /b 1
)
:: 验证uvicorn是否已安装(可选但推荐)
python -c "import uvicorn" >nul 2>&1
if %errorlevel% neq 0 (
echo 错误:未检测到 uvicorn。请运行以下命令安装:
echo conda install -c conda-forge uvicorn fastapi
echo
echo pip install "uvicorn[standard]" fastapi
pause
exit /b 1
)
:: 设置默认参数(允许通过环境变量覆盖)
if "%HOST%"=="" set HOST=0.0.0.0
if "%PORT%"=="" set PORT=5000
if "%WORKERS%"=="" set WORKERS=1
if "%LOG_LEVEL%"=="" set LOG_LEVEL=info
set APP_MODULE=main:app
echo.
echo 启动简道云 FastAPI 服务...
echo 模块: %APP_MODULE%
echo 地址: http://%HOST%:%PORT%
echo 进程数: %WORKERS% Windows建议设为1
echo 日志级别: %LOG_LEVEL%
echo.
:: 使用 python -m uvicorn 确保调用当前环境中的 uvicorn
python -m uvicorn %APP_MODULE% --host %HOST% --port %PORT% --workers %WORKERS% --log-level %LOG_LEVEL%
:: 服务退出后暂停,便于查看日志
pause