Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
audit_2021
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 acff06fa
authored
Jul 11, 2023
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
完善审计脚本
1 parent
50605749
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
880 additions
and
1 deletions
main.py
yangll/calc_month_share_yangll_20230706.py
main.py
View file @
acff06f
...
@@ -198,7 +198,7 @@ if __name__ == "__main__":
...
@@ -198,7 +198,7 @@ if __name__ == "__main__":
# 处理数据
# 处理数据
# deal_data(startTime, endTime)
# deal_data(startTime, endTime)
# 激活数据
# 激活数据
active
()
#
active()
# 回滚数据
# 回滚数据
# rollback(startTime, endTime)
# rollback(startTime, endTime)
...
...
yangll/calc_month_share_yangll_20230706.py
0 → 100644
View file @
acff06f
from
MysqlUtility
import
MySQL
,
paddstr
,
paddnum
import
datetime
from
dateutil.relativedelta
import
relativedelta
import
logging
from
init.base_create_table
import
BaseCreateTable
from
init.StringBuilder
import
StringBuilder
from
init.Utils
import
*
import
time
g_pro_biz_dbcfg
=
{
"host"
:
"192.168.5.2"
,
"port"
:
3306
,
"user"
:
"biz_glsx_data"
,
"passwd"
:
"unEKczDc"
,
"db"
:
"glsx_biz_data"
,
"charset"
:
"utf8"
,
}
"""
g_pro_biz_dbcfg = {'host': '192.168.5.25', 'port': 3310, 'user': 'biz_device_detail', 'passwd': 'M6khz3CQ',
'db': 'device_detail',
'charset': 'utf8'}
"""
# 设置全局参数
base_table
=
"temp_ft_table"
def
get_months
(
begin
,
end
):
begin_year
,
end_year
=
begin
.
year
,
end
.
year
begin_month
,
end_month
=
begin
.
month
,
end
.
month
if
begin_year
==
end_year
:
months
=
end_month
-
begin_month
else
:
months
=
(
end_year
-
begin_year
)
*
12
+
end_month
-
begin_month
return
months
+
1
def
calc_gap_month_of_year
(
year
,
pk_start
,
pk_end
,
price
,
device_id
):
yearStart
=
datetime
.
datetime
.
strptime
(
f
"{year}-01-01"
,
"
%
Y-
%
m-
%
d"
)
yearEnd
=
datetime
.
datetime
.
strptime
(
f
"{year}-12-31"
,
"
%
Y-
%
m-
%
d"
)
gap_month
=
0
my_fentan_detail_map
=
{}
if
pk_start
<
yearStart
<
pk_end
:
calcStartTime
=
yearStart
elif
yearStart
<=
pk_start
<=
yearEnd
:
calcStartTime
=
pk_start
else
:
calcStartTime
=
None
if
pk_end
<
yearStart
:
calcEndTime
=
None
elif
yearStart
<=
pk_end
<=
yearEnd
:
calcEndTime
=
pk_end
else
:
calcEndTime
=
yearEnd
if
calcStartTime
is
not
None
and
calcEndTime
is
not
None
:
gap_month
=
get_months
(
calcStartTime
,
calcEndTime
)
# 将分摊明细写入分摊表中
# insertDataToFt(device_id, calcStartTime, calcEndTime, price)
# 建立分摊map 在内存中处理分摊明细
buildFenTanDetailMap
(
calcStartTime
,
calcEndTime
,
price
,
my_fentan_detail_map
)
return
gap_month
,
my_fentan_detail_map
def
buildFenTanDetailMap
(
calcStartTime
,
calcEndTime
,
price
,
my_fentan_detail_map
):
calcStartTime
=
calcStartTime
.
replace
(
day
=
1
,
hour
=
0
,
minute
=
0
,
second
=
0
,
microsecond
=
0
)
for
i
in
range
(
12
):
# 添加一个月的日期
calculate_time
=
add_one_month
(
calcStartTime
,
i
)
if
calcStartTime
<=
calculate_time
<
calcEndTime
:
fentan_detail_time
=
calculate_time
.
strftime
(
"
%
Y-
%
m-
%
d"
)
my_fentan_detail_map
[
fentan_detail_time
]
=
price
return
my_fentan_detail_map
def
buildApportionment
(
device_id
,
calcStartTime
,
calcEndTime
,
price
):
# 将业务日期开始时间设置为 1号 方便比较
calcStartTime
=
calcStartTime
.
replace
(
day
=
1
,
hour
=
0
,
minute
=
0
,
second
=
0
,
microsecond
=
0
)
sb
=
StringBuilder
()
for
i
in
range
(
12
):
# 添加一个月的日期
calculate_time
=
add_one_month
(
calcStartTime
,
i
)
if
calcStartTime
<=
calculate_time
<
calcEndTime
:
sb
.
append
(
f
"({device_id},'{calculate_time}',{price}),"
)
return
str
(
sb
)[
0
:
len
(
str
(
sb
))
-
1
]
def
insertDataToFt
(
device_id
,
calcStartTime
,
calcEndTime
,
price
):
"""
calcStartTime 开始分摊时间
calcEndTime 结束分摊时间
price 每月分摊金额
"""
values
=
buildApportionment
(
device_id
,
calcStartTime
,
calcEndTime
,
price
)
bizConn
=
MySQL
(
g_pro_biz_dbcfg
)
sql01
=
f
"""
INSERT INTO {base_table} (device_id,apportionment_date,apportionment_price) values {values};
"""
bizConn
.
insert
(
sql01
)
def
getMonthPriceByYear
(
my_fentan_detail_map
,
year
):
sb
=
StringBuilder
()
yearStart
=
datetime
.
datetime
.
strptime
(
f
"{year}-01-01"
,
"
%
Y-
%
m-
%
d"
)
.
date
()
yearEnd
=
datetime
.
datetime
.
strptime
(
f
"{year}-12-31"
,
"
%
Y-
%
m-
%
d"
)
.
date
()
d_str
=
f
"{year}-01-01"
first_month
=
datetime
.
datetime
.
strptime
(
d_str
,
"
%
Y-
%
m-
%
d"
)
.
date
()
for
i
in
range
(
12
):
# 添加一个月的日期
calculate_time
=
add_one_month
(
first_month
,
i
)
if
yearStart
<=
calculate_time
<
yearEnd
:
fentan_detail_time
=
calculate_time
.
strftime
(
"
%
Y-
%
m-
%
d"
)
# print("fentan_detail_time==", fentan_detail_time)
price
=
my_fentan_detail_map
.
get
(
fentan_detail_time
,
0
)
sb
.
append
(
str
(
price
)
+
","
)
return
str
(
sb
)
def
calc_remain_year
(
year
,
start_share_month
,
end_share_month
,
price
,
remainTotal
,
amount
,
device_id
):
"""
price 每月分摊金额
计算每年余额
:param year:
:return:
"""
gap_months
,
my_fentan_detail_map
=
calc_gap_month_of_year
(
year
,
start_share_month
,
end_share_month
,
price
,
device_id
)
if
gap_months
>
0
:
share
=
gap_months
*
price
#
remainShare
=
remainTotal
-
share
#
else
:
share
=
0
remainShare
=
0
if
remainShare
>
1.0
:
remainTotal
=
remainShare
else
:
remainTotal
=
amount
remainShare
=
0
return
share
,
remainShare
,
remainTotal
,
my_fentan_detail_map
def
getCsvname
():
local_time
=
time
.
localtime
()
# %04d-%02d-%02d %02d:%02d:%02d
strTime
=
"
%04
d
%02
d
%02
d
%02
d
%02
d
%02
d"
%
(
local_time
.
tm_year
,
local_time
.
tm_mon
,
local_time
.
tm_mday
,
local_time
.
tm_hour
,
local_time
.
tm_min
,
local_time
.
tm_sec
,
)
return
strTime
def
calc_income_share
(
calcType
=
"收入"
):
"""
计算收入的分摊
:return:
"""
# tblName = "dj_device_details"
tblName
=
"dj_2021_settle_details"
fileName
=
calcType
+
getCsvname
()
+
".csv"
fileHandle
=
open
(
file
=
fileName
,
mode
=
"w"
,
encoding
=
"utf-8"
)
bizConn
=
MySQL
(
g_pro_biz_dbcfg
)
if
calcType
==
"收入"
:
# and settle_merchant='重庆卡达能汽车用品有限公司'
sql
=
(
f
"select settle_merchant,case when device_type=8 then '追踪器' when device_type=6 then '记录仪' when device_type=12501 then '车充' end,"
f
"pk_period,DATE_FORMAT(settle_time, '
%
Y-
%
m') as settle_month,"
f
"DATE_FORMAT(active_time,'
%
Y-
%
m') as active_month,COUNT(1) as count,"
f
"sum(IFNULL(pk_price,0) + IFNULL(hw_price, 0) + IFNULL(install_price, 0)) as amount, channel,"
f
"case when `return`=1 then '退货' else '正常' end ,id "
f
"from {tblName} where settle_time < '2023-05-01 00:00:00' and device_type in (6,12501) "
f
"GROUP BY settle_merchant,device_type,pk_period,DATE_FORMAT(settle_time, '
%
Y-
%
m'),DATE_FORMAT(active_time,'
%
Y-
%
m'),channel,`return` "
f
"order by settle_merchant,settle_month"
)
elif
calcType
==
"成本"
:
sql
=
(
f
"select settle_merchant,case when device_type=8 then '追踪器' when device_type=6 then '记录仪' when device_type=12501 then '车充' end,"
f
"pk_period,DATE_FORMAT(settle_time, '
%
Y-
%
m') as settle_month,"
f
"DATE_FORMAT(active_time,'
%
Y-
%
m') as active_month,COUNT(1) as count,"
f
"sum(IFNULL(hw_cost,0) + IFNULL(install_cost, 0) ) as amount, channel, "
f
"case when `return`=1 then '退货' else '正常' end ,id "
f
"from {tblName} where settle_time < '2023-05-01 00:00:00' and device_type in (6,12501) "
f
"GROUP BY settle_merchant,device_type,pk_period,DATE_FORMAT(settle_time, '
%
Y-
%
m'),DATE_FORMAT(active_time,'
%
Y-
%
m'),channel,`return` "
f
"order by settle_merchant,settle_month"
)
if
not
bizConn
.
query
(
sql
):
return
result
=
bizConn
.
fetchAllRows
()
# datetime_2017_end = datetime.datetime.strptime("2017-12-31", '%Y-%m-%d')
headName
=
f
"客户名称,渠道,服务期限,数量,结算月份,不含税收入,开始计费月份,结束计费月份,不含税单价,月摊收入,"
year_list
=
[
2017
,
2018
,
2019
,
2020
,
2021
,
2022
,
2023
,
2024
,
2025
,
2026
,
2027
,
2028
,
2029
,
2030
,
]
for
year
in
year_list
:
# headName += f"{year}年摊销金额,{year}年末累计摊销余额,"
headName
+=
f
"{year}-01月分摊,{year}-02月分摊,{year}-03月分摊,{year}-04月分摊,{year}-05月分摊,{year}-06月分摊,{year}-07月分摊,{year}-08月分摊,{year}-09月分摊,{year}-10月分摊,{year}-11月分摊,{year}-12月分摊,"
headName
+=
f
"产品分类,激活开始月份,激活结束月份,是否退货,研发开始分摊月份"
headName
+=
"
\n
"
fileHandle
.
write
(
headName
)
for
row
in
result
:
settleMer
=
row
[
0
]
devName
=
row
[
1
]
period
=
row
[
2
]
if
period
==
0
or
period
is
None
:
period
=
12
settle_start_month
=
row
[
3
]
settle_end_month
=
(
datetime
.
datetime
.
strptime
(
settle_start_month
,
"
%
Y-
%
m"
)
+
relativedelta
(
months
=
period
)
-
relativedelta
(
days
=
1
)
)
active_month
=
row
[
4
]
total
=
row
[
5
]
amount
=
row
[
6
]
channel
=
row
[
7
]
returnFlag
=
row
[
8
]
device_id
=
row
[
9
]
if
active_month
is
None
:
start_share
=
"2025-12"
active_start_month
=
""
active_end_month
=
""
else
:
start_share
=
active_month
active_start_month
=
datetime
.
datetime
.
strptime
(
start_share
,
"
%
Y-
%
m"
)
active_end_month
=
(
active_start_month
+
relativedelta
(
months
=
period
)
-
relativedelta
(
days
=
1
)
)
# 代销从结算时间开始
if
(
channel
==
"代销"
or
channel
==
"广汇"
)
and
(
active_start_month
==
""
or
active_start_month
<
settle_end_month
):
start_share
=
settle_start_month
#
elif
(
channel
==
"直销"
and
settle_start_month
>=
"2022-01"
)
and
(
active_start_month
==
""
or
active_start_month
<
settle_end_month
):
start_share
=
settle_start_month
start_share_month
=
datetime
.
datetime
.
strptime
(
start_share
,
"
%
Y-
%
m"
)
end_share_month
=
(
start_share_month
+
relativedelta
(
months
=
period
)
-
relativedelta
(
days
=
1
)
)
# 每个的单价
price
=
amount
/
total
# 每月分摊金额
share_per_month
=
amount
/
period
# share_per_month: 每年每月摊销多少
"""
gap_2018_months = get_months(start_share_month, datetime_2017_end)
if gap_2018_months > 0:
remainShare2018 = amount - gap_2018_months * share_per_month #2018年末摊销余额
else:
remainShare2018 = 0
if remainShare2018 > 0:
remainTotal = remainShare2018
else:
remainTotal = amount
"""
remainTotal
=
amount
(
share_2017
,
remainShare2017
,
remainTotal
,
my_fentan_detail_map_2017
,
)
=
calc_remain_year
(
2017
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2018
,
remainShare2018
,
remainTotal
,
my_fentan_detail_map_2018
,
)
=
calc_remain_year
(
2018
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2019
,
remainShare2019
,
remainTotal
,
my_fentan_detail_map_2019
,
)
=
calc_remain_year
(
2019
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2020
,
remainShare2020
,
remainTotal
,
my_fentan_detail_map_2020
,
)
=
calc_remain_year
(
2020
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2021
,
remainShare2021
,
remainTotal
,
my_fentan_detail_map_2021
,
)
=
calc_remain_year
(
2021
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2022
,
remainShare2022
,
remainTotal
,
my_fentan_detail_map_2022
,
)
=
calc_remain_year
(
2022
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2023
,
remainShare2023
,
remainTotal
,
my_fentan_detail_map_2023
,
)
=
calc_remain_year
(
2023
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2024
,
remainShare2024
,
remainTotal
,
my_fentan_detail_map_2024
,
)
=
calc_remain_year
(
2024
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2025
,
remainShare2025
,
remainTotal
,
my_fentan_detail_map_2025
,
)
=
calc_remain_year
(
2025
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2026
,
remainShare2026
,
remainTotal
,
my_fentan_detail_map_2026
,
)
=
calc_remain_year
(
2026
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2027
,
remainShare2027
,
remainTotal
,
my_fentan_detail_map_2027
,
)
=
calc_remain_year
(
2027
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2028
,
remainShare2028
,
remainTotal
,
my_fentan_detail_map_2028
,
)
=
calc_remain_year
(
2028
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2029
,
remainShare2029
,
remainTotal
,
my_fentan_detail_map_2029
,
)
=
calc_remain_year
(
2029
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2030
,
remainShare2030
,
remainTotal
,
my_fentan_detail_map_2030
,
)
=
calc_remain_year
(
2030
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
lineName
=
f
"{settleMer},{channel},{period},{total},{settle_start_month},{amount},{settle_start_month},{settle_end_month},{price},{share_per_month},"
# lineName += f"{share_2017},{remainShare2017},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2017
,
2017
)
# lineName += f"{share_2018},{remainShare2018},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2018
,
2018
)
# lineName += f"{share_2019},{remainShare2019},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2019
,
2019
)
# lineName += f"{share_2020},{remainShare2020},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2020
,
2020
)
# lineName += f"{share_2021},{remainShare2021},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2021
,
2021
)
# lineName += f"{share_2022},{remainShare2022},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2022
,
2022
)
# lineName += f"{share_2023},{remainShare2023},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2023
,
2023
)
# lineName += f"{share_2024},{remainShare2024},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2024
,
2024
)
# lineName += f"{share_2025},{remainShare2025},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2025
,
2025
)
# lineName += f"{share_2026},{remainShare2026},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2026
,
2026
)
# lineName += f"{share_2027},{remainShare2027},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2027
,
2027
)
# lineName += f"{share_2028},{remainShare2028},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2028
,
2028
)
# lineName += f"{share_2029},{remainShare2029},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2029
,
2029
)
# lineName += f"{share_2030},{remainShare2030},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2030
,
2030
)
lineName
+=
f
"{devName},{active_start_month},{active_end_month},{returnFlag},{start_share_month}"
lineName
+=
"
\n
"
fileHandle
.
write
(
lineName
)
fileHandle
.
close
()
def
calc_return_share
(
calcType
):
"""
退货
:return:
"""
tblName
=
"dj_2021_settle_details_return"
fileName
=
calcType
+
getCsvname
()
+
".csv"
fileHandle
=
open
(
file
=
fileName
,
mode
=
"w"
,
encoding
=
"utf-8"
)
bizConn
=
MySQL
(
g_pro_biz_dbcfg
)
if
calcType
==
"退货成本"
:
sql
=
(
f
"select settle_merchant,case when device_type=8 then '追踪器' when device_type=6 then '记录仪' when device_type=12501 then '车充' end,"
f
"pk_period,DATE_FORMAT(settle_time, '
%
Y-
%
m') as settle_month,COUNT(1) as count,"
f
"sum(IFNULL(hw_cost,0) + IFNULL(install_cost, 0) ) as amount, channel ,id "
f
"from {tblName} where settle_time < '2023-05-01 00:00:00' and device_type in (6,12501) "
f
"GROUP BY settle_merchant,device_type,pk_period,DATE_FORMAT(settle_time, '
%
Y-
%
m'),channel "
f
"order by settle_merchant,settle_month"
)
elif
calcType
==
"退货收入"
:
sql
=
(
f
"select settle_merchant,case when device_type=8 then '追踪器' when device_type=6 then '记录仪' when device_type=12501 then '车充' end,"
f
"pk_period,DATE_FORMAT(settle_time, '
%
Y-
%
m') as settle_month,COUNT(1) as count,"
f
"sum(IFNULL(pk_price, 0) + IFNULL(hw_price, 0) + IFNULL(install_price, 0)) as amount, channel ,id "
f
"from {tblName} where settle_time < '2023-05-01 00:00:00' and device_type in (6,12501) "
f
"GROUP BY settle_merchant,device_type,pk_period,DATE_FORMAT(settle_time, '
%
Y-
%
m'),channel "
f
"order by settle_merchant,settle_month"
)
if
not
bizConn
.
query
(
sql
):
return
result
=
bizConn
.
fetchAllRows
()
headName
=
f
"客户名称,渠道,服务期限,数量,结算月份,不含税收入,开始计费月份,结束计费月份,不含税单价,月摊收入,"
year_list
=
[
2017
,
2018
,
2019
,
2020
,
2021
,
2022
,
2023
,
2024
,
2025
,
2026
,
2027
,
2028
,
2029
,
2030
,
]
for
year
in
year_list
:
# headName += f"{year}年摊销金额,{year}年末累计摊销余额,"
headName
+=
f
"{year}-01月分摊,{year}-02月分摊,{year}-03月分摊,{year}-04月分摊,{year}-05月分摊,{year}-06月分摊,{year}-07月分摊,{year}-08月分摊,{year}-09月分摊,{year}-10月分摊,{year}-11月分摊,{year}-12月分摊,"
headName
+=
f
"产品分类"
headName
+=
"
\n
"
fileHandle
.
write
(
headName
)
for
row
in
result
:
settleMer
=
row
[
0
]
devName
=
row
[
1
]
period
=
row
[
2
]
if
period
==
0
or
period
is
None
:
period
=
12
settle_start_month
=
row
[
3
]
settle_end_month
=
(
datetime
.
datetime
.
strptime
(
settle_start_month
,
"
%
Y-
%
m"
)
+
relativedelta
(
months
=
period
)
-
relativedelta
(
days
=
1
)
)
total
=
row
[
4
]
amount
=
row
[
5
]
channel
=
row
[
6
]
device_id
=
row
[
7
]
start_share_month
=
datetime
.
datetime
.
strptime
(
settle_start_month
,
"
%
Y-
%
m"
)
end_share_month
=
settle_end_month
price
=
amount
/
total
share_per_month
=
amount
/
period
remainTotal
=
amount
(
share_2017
,
remainShare2017
,
remainTotal
,
my_fentan_detail_map_2017
,
)
=
calc_remain_year
(
2017
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2018
,
remainShare2018
,
remainTotal
,
my_fentan_detail_map_2018
,
)
=
calc_remain_year
(
2018
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2019
,
remainShare2019
,
remainTotal
,
my_fentan_detail_map_2019
,
)
=
calc_remain_year
(
2019
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2020
,
remainShare2020
,
remainTotal
,
my_fentan_detail_map_2020
,
)
=
calc_remain_year
(
2020
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2021
,
remainShare2021
,
remainTotal
,
my_fentan_detail_map_2021
,
)
=
calc_remain_year
(
2021
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2022
,
remainShare2022
,
remainTotal
,
my_fentan_detail_map_2022
,
)
=
calc_remain_year
(
2022
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2023
,
remainShare2023
,
remainTotal
,
my_fentan_detail_map_2023
,
)
=
calc_remain_year
(
2023
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2024
,
remainShare2024
,
remainTotal
,
my_fentan_detail_map_2024
,
)
=
calc_remain_year
(
2024
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2025
,
remainShare2025
,
remainTotal
,
my_fentan_detail_map_2025
,
)
=
calc_remain_year
(
2025
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2026
,
remainShare2026
,
remainTotal
,
my_fentan_detail_map_2026
,
)
=
calc_remain_year
(
2026
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2027
,
remainShare2027
,
remainTotal
,
my_fentan_detail_map_2027
,
)
=
calc_remain_year
(
2027
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2028
,
remainShare2028
,
remainTotal
,
my_fentan_detail_map_2028
,
)
=
calc_remain_year
(
2028
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2029
,
remainShare2029
,
remainTotal
,
my_fentan_detail_map_2029
,
)
=
calc_remain_year
(
2029
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
(
share_2030
,
remainShare2030
,
remainTotal
,
my_fentan_detail_map_2030
,
)
=
calc_remain_year
(
2030
,
start_share_month
,
end_share_month
,
share_per_month
,
remainTotal
,
amount
,
device_id
,
)
# lineName = (
# f"{settleMer},{channel},{period},{total},{settle_start_month},{amount},{settle_start_month},"
# f"{settle_end_month},{price},{share_per_month},{share_2017},{remainShare2017},{share_2018},"
# f"{remainShare2018},{share_2019},{remainShare2019},{share_2020},{remainShare2020},"
# f"{share_2021},{remainShare2021},{share_2022},{remainShare2022},{devName}\n"
# )
lineName
=
f
"{settleMer},{channel},{period},{total},{settle_start_month},{amount},{settle_start_month},{settle_end_month},{price},{share_per_month},"
# lineName += f"{share_2017},{remainShare2017},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2017
,
2017
)
# lineName += f"{share_2018},{remainShare2018},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2018
,
2018
)
# lineName += f"{share_2019},{remainShare2019},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2019
,
2019
)
# lineName += f"{share_2020},{remainShare2020},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2020
,
2020
)
# lineName += f"{share_2021},{remainShare2021},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2021
,
2021
)
# lineName += f"{share_2022},{remainShare2022},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2022
,
2022
)
# lineName += f"{share_2023},{remainShare2023},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2023
,
2023
)
# lineName += f"{share_2024},{remainShare2024},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2024
,
2024
)
# lineName += f"{share_2025},{remainShare2025},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2025
,
2025
)
# lineName += f"{share_2026},{remainShare2026},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2026
,
2026
)
# lineName += f"{share_2027},{remainShare2027},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2027
,
2027
)
# lineName += f"{share_2028},{remainShare2028},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2028
,
2028
)
# lineName += f"{share_2029},{remainShare2029},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2029
,
2029
)
# lineName += f"{share_2030},{remainShare2030},"
lineName
+=
getMonthPriceByYear
(
my_fentan_detail_map_2030
,
2030
)
lineName
+=
f
"{devName}"
lineName
+=
"
\n
"
fileHandle
.
write
(
lineName
)
fileHandle
.
close
()
"""
计算分摊数据
"""
if
__name__
==
"__main__"
:
# BaseCreateTable(base_table).create_table()
calc_income_share
(
calcType
=
"收入"
)
calc_income_share
(
calcType
=
"成本"
)
calc_return_share
(
"退货收入"
)
calc_return_share
(
"退货成本"
)
print
(
"end==="
)
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