Commit c6b091d2 by 杨林龙

添加数据处理脚本--分摊

1 parent ecd46641
......@@ -6,7 +6,6 @@ from decimal import Decimal
import MySQLdb
from dateutil.relativedelta import *
from fentan.base_create_table import BaseCreateTable
from my_utils.MysqlUtility import MySQL
logger = logging.getLogger('deal_equity_data')
......@@ -218,7 +217,7 @@ def export_csv(fileName):
headName += f",{year}期初数,{year}期初单价,{year}期初金额,{year}增加数,{year}增加单价,{year}增加金额,{year}减少数,{year}减少单价,{year}减少金额"
headName += "\n"
fileHandle.write(headName)
# SELECT teo.id ,teo.order_code, teo.order_time, teo.service_period, teo.total_price FROM temp_eq_order;
# SELECT teo.id ,teo.order_code, teo.order_time, teo.service_period, teo.total_price FROM temp_eq_order; where teo.id = 251
sql = f'''
SELECT teo.id ,teo.order_code, teo.order_time, teo.service_period, teo.total_price,
eo.customer_name,eo.customer_phone,eo.contract_no,eo.success_date,eo.billing_date,eo.merchant_id,
......@@ -237,10 +236,12 @@ def export_csv(fileName):
f"{row[16]},{row[17]},{row[18]},{row[19]},{row[20]},{row[21]},{row[22]},{row[23]},{row[24]},{row[25]},{row[26]},{row[27]},{row[28]}"
lineValue += f",{row[0]},{row[1]},{row[2]},{row[3]},{row[4]}"
for year in yearList:
logger.info("order_id" + str(row[0]) + ";year" + str(year))
sql = f'''
SELECT id,order_id,order_year,qichu_num,qichu_unit_price,qichu_total_price,zengjia_num,zengjia_unit_price,zengjia_total_price,jianshao_num, jianshao_unit_price,jianshao_total_price
FROM temp_eq_order_zj teoz WHERE teoz.order_id = {row[0]} AND teoz.order_year = {year};
FROM temp_eq_order_zj teoz WHERE teoz.order_id = {row[0]} AND teoz.order_year = '{year}';
'''
logger.info(sql)
if not bizConn.query(sql):
logger.error("deal_equity_data fail, sql=%s", sql)
return
......@@ -249,9 +250,9 @@ def export_csv(fileName):
logger.debug(row)
lineValue += f",0,0,0,0,0,0,0,0,0"
else:
for row in result:
logger.info(row)
lineValue += f",{paddnum_price(row[3])},{paddnum_price(row[4])},{paddnum_price(row[5])},{paddnum_price(row[6])},{paddnum_price(row[7])},{paddnum_price(row[8])},{paddnum_price(row[9])},{paddnum_price(row[10])},{paddnum_price(row[11])}"
for row01 in result:
logger.info(row01)
lineValue += f",{paddnum_price(row01[3])},{paddnum_price(row01[4])},{paddnum_price(row01[5])},{paddnum_price(row01[6])},{paddnum_price(row01[7])},{paddnum_price(row01[8])},{paddnum_price(row01[9])},{paddnum_price(row01[10])},{paddnum_price(row01[11])}"
# 写入一行数据
lineValue += "\n"
logger.debug(lineValue)
......@@ -279,17 +280,17 @@ def my_func_test():
if __name__ == '__main__':
# 创建数据表
BaseCreateTable().create_table()
# BaseCreateTable().create_table()
# 处理基础数据
deal_equity_data()
# deal_equity_data()
# 处理减少数据
deal_jianshao_equity_data()
# deal_jianshao_equity_data()
# 处理增加数据
deal_zengjia_equity_data()
# deal_zengjia_equity_data()
# 处理期初数据
deal_qichu_equity_data()
# deal_qichu_equity_data()
# 处理为NULL的数据
deal_null_equity_data()
# deal_null_equity_data()
# 导出 csv
export_csv("分摊汇总-20230411.csv")
# 自测方法
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!