Commit cf70e9da authored by 邱阿朋's avatar 邱阿朋

payment 优化

parent 8bc14769
import pandas as pd
def compare_po_and_amount(file1, file2):
# 读取两个 Excel 文件
df1 = pd.read_excel(file1)
df2 = pd.read_excel(file2)
# 确保两个表格中都存在 'PO' 和 'Amount' 列
if 'PO' not in df1.columns or 'Amount' not in df1.columns:
raise ValueError("File 1 is missing required columns: 'PO' or 'Amount'")
if 'PO' not in df2.columns or 'Amount' not in df2.columns:
raise ValueError("File 2 is missing required columns: 'PO' or 'Amount'")
# 聚合数据,按照 'PO' 进行分组,并对 'Amount' 进行求和
df1_grouped = df1.groupby('PO', as_index=False)['Amount'].sum()
df2_grouped = df2.groupby('PO', as_index=False)['Amount'].sum()
# 合并两个数据框,使用 'PO' 列进行比较
merged_df = pd.merge(df1_grouped, df2_grouped, on='PO', how='outer', suffixes=('_file1', '_file2'))
# 找出两列 'Amount' 不相同的行
diff_df = merged_df[merged_df['Amount_file1'] != merged_df['Amount_file2']]
# 如果没有差异,输出消息
if diff_df.empty:
print("The PO amounts are identical in both files.")
else:
print("The following POs have different amounts:")
print(diff_df)
# 使用示例
compare_po_and_amount('file1.xlsx', 'file2.xlsx')
# coding: utf-8
import redis
class RedisClient:
_instance = None
def __new__(cls, *args, **kwargs):
if not cls._instance:
cls._instance = super(RedisClient, cls).__new__(cls)
cls._instance._initialize(*args, **kwargs)
return cls._instance
def _initialize(self, host='39.108.185.244', port=6379, db=12, password="khd2022!", decode_responses=True):
self.client = redis.StrictRedis(host=host, port=port, db=db, password=password,
decode_responses=decode_responses)
def get_client(self):
return self.client
\ No newline at end of file
...@@ -304,16 +304,15 @@ def main(): ...@@ -304,16 +304,15 @@ def main():
if last_three == "PCR" or last_two == "PC": if last_three == "PCR" or last_two == "PC":
cache_key = "price_data" cache_key = "price_data"
price_data = rdb.get_client().hget(cache_key, invoice_number) price_data = rdb.get_client().hget(cache_key, invoice_number)
if price_data is None: if price_data:
price_data = json.loads(price_data)
else:
# 进入详情页 # 进入详情页
invoice_details(invoice_number, last_two, last_three) invoice_details(invoice_number, last_two, last_three)
# 获取争议数据 # 获取争议数据
price_data = click_get_price_data() price_data = click_get_price_data()
# 缓存数据 # 缓存数据
rdb.get_client().hset(cache_key, invoice_number, json.dumps(price_data)) rdb.get_client().hset(cache_key, invoice_number, json.dumps(price_data))
else:
price_data = json.loads(price_data)
# 争议回款 # 争议回款
handle_after_price_data = handle_price_data(price_data, invoice_amount) handle_after_price_data = handle_price_data(price_data, invoice_amount)
format_price_data = handle_data(handle_after_price_data, vendor, deduction_points) format_price_data = handle_data(handle_after_price_data, vendor, deduction_points)
......
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