Commit 5a54caa4 authored by 邱阿朋's avatar 邱阿朋

refactor(vc): 优化供应商中心相关模块

- 修改 Makefile,更新 all 目标依赖
- 在 payment.py、return_goods.py 和 spa.py 中捕获更广泛的异常类型
- 优化 spa.py 中的数据处理逻辑
parent 9d7cb84d
......@@ -11,7 +11,7 @@ PYI_FLAGS := -F --noconsole
.PHONY: all install build clean
all: install build
all: install build clean
install:
uv pip install -i $(PIP_INDEX) -r $(REQ_FILE)
......
......@@ -9,7 +9,7 @@ from decimal import Decimal
import pandas as pd
from DrissionPage import ChromiumPage as Page
from DrissionPage.errors import ElementNotFoundError
from DrissionPage.errors import BaseError
from lxml import etree
from app.helper import domain, excel, file
......@@ -104,7 +104,7 @@ class Payment(AutoInterface):
file.wait_for_downloads(file_name)
excel.remove_last_comma(file_name)
break
except ElementNotFoundError:
except BaseError:
if count == 3: return None
count += 1
self.logger.warning("导出按钮不存在刷新网页")
......
......@@ -5,7 +5,7 @@ from datetime import datetime
import pandas as pd
from DrissionPage import ChromiumPage as Page
from DrissionPage.errors import ElementNotFoundError
from DrissionPage.errors import BaseError
from app.helper import domain, api, excel, file
from app.logger.logger import Logger
......@@ -42,7 +42,7 @@ class ReturnGoods(AutoInterface):
self.page.ele("#file-download-button").click.to_download(rename=file_name)
file.wait_for_downloads(file_name)
break
except ElementNotFoundError:
except BaseError:
self.logger.warning("元素未找到,刷新网页")
self.page.refresh()
......
......@@ -6,7 +6,7 @@ from datetime import datetime
import pandas as pd
from DrissionPage import ChromiumPage as Page
from DrissionPage.errors import ElementNotFoundError
from DrissionPage.errors import BaseError
from lxml import etree
from app.helper import domain, file, excel, api, helper
......@@ -37,7 +37,7 @@ class Spa(AutoInterface):
while True:
if retry_count > 5:
self.logger.warning(f"{invoice_id} 获取报表链接重试次数超过{retry_count}次,请检查发票号")
return None
return list()
try:
self.__page_get(f"hz/vendor/members/coop?searchText={invoice_id}")
......@@ -64,7 +64,7 @@ class Spa(AutoInterface):
continue
return links
except ElementNotFoundError:
except BaseError:
self.logger.warning(f"{invoice_id} 元素未找到,刷新网页")
self.page.refresh()
......@@ -282,7 +282,7 @@ class Spa(AutoInterface):
df['Original balance'] = (df['Original balance'].
astype(str).
str.
replace(r'[\$,]', '',regex=True))
replace(r'[\$,]', '', regex=True))
# 转换为数值型,处理非数值数据
df['Original balance'] = pd.to_numeric(df['Original balance'], errors='coerce')
# 计算总和,忽略NaN
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment