Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
deal_mysql_data
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c6b091d2
authored
Apr 11, 2023
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加数据处理脚本--分摊
1 parent
ecd46641
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
fentan/deal02.py
fentan/deal02.py
View file @
c6b091d
...
@@ -6,7 +6,6 @@ from decimal import Decimal
...
@@ -6,7 +6,6 @@ from decimal import Decimal
import
MySQLdb
import
MySQLdb
from
dateutil.relativedelta
import
*
from
dateutil.relativedelta
import
*
from
fentan.base_create_table
import
BaseCreateTable
from
my_utils.MysqlUtility
import
MySQL
from
my_utils.MysqlUtility
import
MySQL
logger
=
logging
.
getLogger
(
'deal_equity_data'
)
logger
=
logging
.
getLogger
(
'deal_equity_data'
)
...
@@ -218,7 +217,7 @@ def export_csv(fileName):
...
@@ -218,7 +217,7 @@ def export_csv(fileName):
headName
+=
f
",{year}期初数,{year}期初单价,{year}期初金额,{year}增加数,{year}增加单价,{year}增加金额,{year}减少数,{year}减少单价,{year}减少金额"
headName
+=
f
",{year}期初数,{year}期初单价,{year}期初金额,{year}增加数,{year}增加单价,{year}增加金额,{year}减少数,{year}减少单价,{year}减少金额"
headName
+=
"
\n
"
headName
+=
"
\n
"
fileHandle
.
write
(
headName
)
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
'''
sql
=
f
'''
SELECT teo.id ,teo.order_code, teo.order_time, teo.service_period, teo.total_price,
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,
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):
...
@@ -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]}"
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]}"
lineValue
+=
f
",{row[0]},{row[1]},{row[2]},{row[3]},{row[4]}"
for
year
in
yearList
:
for
year
in
yearList
:
logger
.
info
(
"order_id"
+
str
(
row
[
0
])
+
";year"
+
str
(
year
))
sql
=
f
'''
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
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
):
if
not
bizConn
.
query
(
sql
):
logger
.
error
(
"deal_equity_data fail, sql=
%
s"
,
sql
)
logger
.
error
(
"deal_equity_data fail, sql=
%
s"
,
sql
)
return
return
...
@@ -249,9 +250,9 @@ def export_csv(fileName):
...
@@ -249,9 +250,9 @@ def export_csv(fileName):
logger
.
debug
(
row
)
logger
.
debug
(
row
)
lineValue
+=
f
",0,0,0,0,0,0,0,0,0"
lineValue
+=
f
",0,0,0,0,0,0,0,0,0"
else
:
else
:
for
row
in
result
:
for
row
01
in
result
:
logger
.
info
(
row
)
logger
.
info
(
row
01
)
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])}"
lineValue
+=
f
",{paddnum_price(row
01[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
"
lineValue
+=
"
\n
"
logger
.
debug
(
lineValue
)
logger
.
debug
(
lineValue
)
...
@@ -279,17 +280,17 @@ def my_func_test():
...
@@ -279,17 +280,17 @@ def my_func_test():
if
__name__
==
'__main__'
:
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的数据
# 处理为NULL的数据
deal_null_equity_data
()
#
deal_null_equity_data()
# 导出 csv
# 导出 csv
export_csv
(
"分摊汇总-20230411.csv"
)
export_csv
(
"分摊汇总-20230411.csv"
)
# 自测方法
# 自测方法
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment