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 653e4ec4
authored
Apr 23, 2023
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改审计脚本
1 parent
ecaa251a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
187 additions
and
83 deletions
.gitignore
loadExcelData.py
.gitignore
View file @
653e4ec
/.idea
/.idea
/.vscode
loadExcelData.py
View file @
653e4ec
import
pandas
as
pd
import
pandas
as
pd
import
pymysql
import
pymysql
g_pro_biz_dbcfg
=
{
'host'
:
'192.168.5.20'
,
'port'
:
3306
,
'user'
:
'biz_glsx_data'
,
'passwd'
:
'unEKczDc'
,
g_pro_biz_dbcfg
=
{
'db'
:
'glsx_biz_data'
,
'charset'
:
'utf8'
}
"host"
:
"192.168.5.2"
,
"port"
:
3306
,
"user"
:
"biz_glsx_data"
,
"passwd"
:
"unEKczDc"
,
"db"
:
"glsx_biz_data"
,
"charset"
:
"utf8"
,
}
def
loadFinnanceExcelToMysql
(
fileName
,
sheetName
):
def
loadFinnanceExcelToMysql
(
fileName
,
sheetName
):
tableName
=
"dj_2022_settlment_order_finance_06plus"
# tableName = "dj_2022_settlment_order_finance_06plus"
tableName
=
"dj_2023_settlment_order_finance"
'''将Excel表数据导入mysql'''
"""将Excel表数据导入mysql"""
conn_updata
=
pymysql
.
Connect
(
host
=
'192.168.5.20'
,
port
=
3306
,
user
=
'biz_glsx_data'
,
conn_updata
=
pymysql
.
Connect
(
passwd
=
'unEKczDc'
,
db
=
'glsx_biz_data'
,
charset
=
'utf8'
)
host
=
"192.168.5.2"
,
port
=
3306
,
user
=
"biz_glsx_data"
,
passwd
=
"unEKczDc"
,
db
=
"glsx_biz_data"
,
charset
=
"utf8"
,
)
#pd.set_option('display.max_columns', 40)
#
pd.set_option('display.max_columns', 40)
data
=
pd
.
read_excel
(
fileName
,
sheet_name
=
sheetName
,
header
=
0
)
data
=
pd
.
read_excel
(
fileName
,
sheet_name
=
sheetName
,
header
=
0
)
newData
=
data
[[
'单据类型'
,
'单据编号'
,
'业务日期'
,
'客户'
,
'渠道'
,
'物料编码'
,
'物料名称'
,
'产品类型'
,
'设备类型'
,
'计价数量'
,
newData
=
data
[
'含税单价'
,
'单价'
,
'收入'
,
'业务类型'
,
'分摊期限'
]]
[
'''
"单据类型"
,
"单据编号"
,
"业务日期"
,
"客户"
,
"渠道"
,
"物料编码"
,
"物料名称"
,
"产品类型"
,
"设备类型"
,
"计价数量"
,
"含税单价"
,
"单价"
,
"收入"
,
"业务类型"
,
"分摊期限"
,
]
]
"""
newData.rename(columns={'单据类型': 'order_type', '单据编号':'order_no', '业务日期':'finance_time',
newData.rename(columns={'单据类型': 'order_type', '单据编号':'order_no', '业务日期':'finance_time',
'客户':'cus_name', '渠道':'sale_type', '物料编码':'product_code',
'客户':'cus_name', '渠道':'sale_type', '物料编码':'product_code',
'物料名称':'product_name', '产品类型':'product_type', '设备类型':'device_type',
'物料名称':'product_name', '产品类型':'product_type', '设备类型':'device_type',
'计价数量':'total', '含税单价':'hw_unit_price_tax', '单价':'hw_unit_price',
'计价数量':'total', '含税单价':'hw_unit_price_tax', '单价':'hw_unit_price',
'收入':'income', '业务类型':'business_type', '分摊期限':'hw_term'})
'收入':'income', '业务类型':'business_type', '分摊期限':'hw_term'})
'''
"""
newData
[
'含税单价'
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
"含税单价"
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
'单价'
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
"单价"
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
'收入'
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
"收入"
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
'分摊期限'
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
"分摊期限"
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
'设备类型'
]
.
fillna
(
''
,
inplace
=
True
)
newData
[
"设备类型"
]
.
fillna
(
""
,
inplace
=
True
)
newData
[
'产品类型'
]
.
fillna
(
''
,
inplace
=
True
)
newData
[
"产品类型"
]
.
fillna
(
""
,
inplace
=
True
)
newData
[
'计价数量'
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
"计价数量"
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
'业务类型'
]
.
fillna
(
''
,
inplace
=
True
)
newData
[
"业务类型"
]
.
fillna
(
""
,
inplace
=
True
)
print
(
newData
.
head
())
print
(
newData
.
head
())
valueArr
=
[]
valueArr
=
[]
for
idx
in
newData
.
index
:
for
idx
in
newData
.
index
:
hwPriceTax
=
newData
.
loc
[
idx
,
'含税单价'
]
hwPriceTax
=
newData
.
loc
[
idx
,
"含税单价"
]
hwPrice
=
newData
.
loc
[
idx
,
'单价'
]
hwPrice
=
newData
.
loc
[
idx
,
"单价"
]
value
=
(
newData
.
loc
[
idx
,
'单据类型'
],
newData
.
loc
[
idx
,
'单据编号'
],
newData
.
loc
[
idx
,
'业务日期'
],
newData
.
loc
[
idx
,
'客户'
],
value
=
(
newData
.
loc
[
idx
,
'渠道'
],
newData
.
loc
[
idx
,
'物料编码'
],
newData
.
loc
[
idx
,
'物料名称'
],
newData
.
loc
[
idx
,
'产品类型'
],
newData
.
loc
[
idx
,
"单据类型"
],
newData
.
loc
[
idx
,
'设备类型'
],
newData
.
loc
[
idx
,
'计价数量'
],
hwPriceTax
,
hwPrice
,
newData
.
loc
[
idx
,
"单据编号"
],
newData
.
loc
[
idx
,
'收入'
],
newData
.
loc
[
idx
,
'业务类型'
],
newData
.
loc
[
idx
,
'分摊期限'
])
newData
.
loc
[
idx
,
"业务日期"
],
newData
.
loc
[
idx
,
"客户"
],
newData
.
loc
[
idx
,
"渠道"
],
newData
.
loc
[
idx
,
"物料编码"
],
newData
.
loc
[
idx
,
"物料名称"
],
newData
.
loc
[
idx
,
"产品类型"
],
newData
.
loc
[
idx
,
"设备类型"
],
newData
.
loc
[
idx
,
"计价数量"
],
hwPriceTax
,
hwPrice
,
newData
.
loc
[
idx
,
"收入"
],
newData
.
loc
[
idx
,
"业务类型"
],
newData
.
loc
[
idx
,
"分摊期限"
],
)
# print(value)
# print(value)
valueArr
.
append
(
value
)
valueArr
.
append
(
value
)
cs
=
conn_updata
.
cursor
()
cs
=
conn_updata
.
cursor
()
sql
=
"insert into "
+
tableName
+
"(order_type,order_no,finance_time,cus_name,sale_type,product_code,"
\
sql
=
(
"product_name,product_type,device_type,total,hw_unit_price_tax,"
\
"insert into "
"hw_unit_price,income,business_type,hw_term) values "
\
+
tableName
"(
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s)"
+
"(order_type,order_no,finance_time,cus_name,sale_type,product_code,"
"product_name,product_type,device_type,total,hw_unit_price_tax,"
"hw_unit_price,income,business_type,hw_term) values "
"(
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s)"
)
cs
.
executemany
(
sql
,
valueArr
)
cs
.
executemany
(
sql
,
valueArr
)
conn_updata
.
commit
()
conn_updata
.
commit
()
cs
.
close
()
cs
.
close
()
def
loadDjExcelToMysql
(
fileName
,
sheetName
):
def
loadDjExcelToMysql
(
fileName
,
sheetName
):
tableName
=
"dj_2022_settlment_order_06plus"
# tableName = "dj_2022_settlment_order_06plus"
'''将Excel表数据导入mysql'''
tableName
=
"dj_2023_settlment_order"
conn_updata
=
pymysql
.
Connect
(
host
=
'192.168.5.20'
,
port
=
3306
,
user
=
'biz_glsx_data'
,
"""将Excel表数据导入mysql"""
passwd
=
'unEKczDc'
,
db
=
'glsx_biz_data'
,
charset
=
'utf8'
)
conn_updata
=
pymysql
.
Connect
(
host
=
"192.168.5.2"
,
port
=
3306
,
user
=
"biz_glsx_data"
,
passwd
=
"unEKczDc"
,
db
=
"glsx_biz_data"
,
charset
=
"utf8"
,
)
data
=
pd
.
read_excel
(
fileName
,
sheet_name
=
sheetName
,
header
=
0
)
data
=
pd
.
read_excel
(
fileName
,
sheet_name
=
sheetName
,
header
=
0
)
newData
=
data
[[
'单据类型'
,
'单据编号'
,
'业务日期'
,
'客户'
,
'渠道'
,
'物料编码'
,
'物料名称'
,
'产品类型'
,
'设备类型'
,
'计价数量'
,
newData
=
data
[
'含税单价'
,
'单价'
,
'硬件(总)(不含税)'
,
'硬件税率'
,
'服务(不含税)'
,
'服务税率'
,
'服务套餐'
,
'收入'
,
'业务类型'
,
[
'分摊期限'
,
'安装'
,
'安装税率'
]]
"单据类型"
,
newData
[
'含税单价'
]
.
fillna
(
0
,
inplace
=
True
)
"单据编号"
,
newData
[
'单价'
]
.
fillna
(
0
,
inplace
=
True
)
"业务日期"
,
newData
[
'收入'
]
.
fillna
(
0
,
inplace
=
True
)
"客户"
,
newData
[
'分摊期限'
]
.
fillna
(
0
,
inplace
=
True
)
"渠道"
,
newData
[
'硬件(总)(不含税)'
]
.
fillna
(
0
,
inplace
=
True
)
"物料编码"
,
newData
[
'硬件税率'
]
.
fillna
(
0
,
inplace
=
True
)
"物料名称"
,
newData
[
'服务(不含税)'
]
.
fillna
(
0
,
inplace
=
True
)
"产品类型"
,
newData
[
'服务税率'
]
.
fillna
(
0
,
inplace
=
True
)
"设备类型"
,
newData
[
'服务套餐'
]
.
fillna
(
''
,
inplace
=
True
)
"计价数量"
,
newData
[
'产品类型'
]
.
fillna
(
''
,
inplace
=
True
)
"含税单价"
,
newData
[
'设备类型'
]
.
fillna
(
''
,
inplace
=
True
)
"单价"
,
newData
[
'安装'
]
.
fillna
(
0
,
inplace
=
True
)
"硬件(总)(不含税)"
,
newData
[
'安装税率'
]
.
fillna
(
0
,
inplace
=
True
)
"硬件税率"
,
"服务(不含税)"
,
#print(newData)
"服务税率"
,
"服务套餐"
,
"收入"
,
"业务类型"
,
"分摊期限"
,
"安装"
,
"安装税率"
,
]
]
newData
[
"含税单价"
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
"单价"
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
"收入"
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
"分摊期限"
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
"硬件(总)(不含税)"
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
"硬件税率"
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
"服务(不含税)"
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
"服务税率"
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
"服务套餐"
]
.
fillna
(
""
,
inplace
=
True
)
newData
[
"产品类型"
]
.
fillna
(
""
,
inplace
=
True
)
newData
[
"设备类型"
]
.
fillna
(
""
,
inplace
=
True
)
newData
[
"安装"
]
.
fillna
(
0
,
inplace
=
True
)
newData
[
"安装税率"
]
.
fillna
(
0
,
inplace
=
True
)
# print(newData)
valueArr
=
[]
valueArr
=
[]
for
idx
in
newData
.
index
:
for
idx
in
newData
.
index
:
hwPriceTax
=
newData
.
loc
[
idx
,
'含税单价'
]
hwPriceTax
=
newData
.
loc
[
idx
,
"含税单价"
]
hwPrice
=
newData
.
loc
[
idx
,
'单价'
]
hwPrice
=
newData
.
loc
[
idx
,
"单价"
]
newHwPrice
=
newData
.
loc
[
idx
,
'硬件(总)(不含税)'
]
newHwPrice
=
newData
.
loc
[
idx
,
"硬件(总)(不含税)"
]
newHwTaxRate
=
newData
.
loc
[
idx
,
'硬件税率'
]
newHwTaxRate
=
newData
.
loc
[
idx
,
"硬件税率"
]
if
newHwPrice
!=
0
:
if
newHwPrice
!=
0
:
hwPrice
=
newHwPrice
hwPrice
=
newHwPrice
hwPriceTax
=
newHwTaxRate
hwPriceTax
=
newHwTaxRate
pkPrice
=
newData
.
loc
[
idx
,
'服务(不含税)'
]
pkPrice
=
newData
.
loc
[
idx
,
"服务(不含税)"
]
pkPriceRate
=
newData
.
loc
[
idx
,
'服务税率'
]
pkPriceRate
=
newData
.
loc
[
idx
,
"服务税率"
]
client
=
newData
.
loc
[
idx
,
'客户'
]
.
strip
()
client
=
newData
.
loc
[
idx
,
"客户"
]
.
strip
()
value
=
(
newData
.
loc
[
idx
,
'单据类型'
],
newData
.
loc
[
idx
,
'单据编号'
],
newData
.
loc
[
idx
,
'业务日期'
],
client
,
value
=
(
newData
.
loc
[
idx
,
'渠道'
],
newData
.
loc
[
idx
,
'物料编码'
],
newData
.
loc
[
idx
,
'物料名称'
],
newData
.
loc
[
idx
,
'产品类型'
],
newData
.
loc
[
idx
,
"单据类型"
],
newData
.
loc
[
idx
,
'设备类型'
],
newData
.
loc
[
idx
,
'计价数量'
],
hwPriceTax
,
hwPrice
,
pkPrice
,
pkPriceRate
,
newData
.
loc
[
idx
,
"单据编号"
],
newData
.
loc
[
idx
,
'服务套餐'
],
newData
.
loc
[
idx
,
"业务日期"
],
newData
.
loc
[
idx
,
'收入'
],
newData
.
loc
[
idx
,
'业务类型'
],
newData
.
loc
[
idx
,
'分摊期限'
],
client
,
newData
.
loc
[
idx
,
'分摊期限'
],
newData
.
loc
[
idx
,
'安装'
],
newData
.
loc
[
idx
,
'安装税率'
])
newData
.
loc
[
idx
,
"渠道"
],
newData
.
loc
[
idx
,
"物料编码"
],
newData
.
loc
[
idx
,
"物料名称"
],
newData
.
loc
[
idx
,
"产品类型"
],
newData
.
loc
[
idx
,
"设备类型"
],
newData
.
loc
[
idx
,
"计价数量"
],
hwPriceTax
,
hwPrice
,
pkPrice
,
pkPriceRate
,
newData
.
loc
[
idx
,
"服务套餐"
],
newData
.
loc
[
idx
,
"收入"
],
newData
.
loc
[
idx
,
"业务类型"
],
newData
.
loc
[
idx
,
"分摊期限"
],
newData
.
loc
[
idx
,
"分摊期限"
],
newData
.
loc
[
idx
,
"安装"
],
newData
.
loc
[
idx
,
"安装税率"
],
)
print
(
value
)
print
(
value
)
valueArr
.
append
(
value
)
valueArr
.
append
(
value
)
cs
=
conn_updata
.
cursor
()
cs
=
conn_updata
.
cursor
()
sql
=
"insert into "
+
tableName
+
"(order_type,order_no,finance_time,cus_name,sale_type,product_code,"
\
sql
=
(
"product_name,product_type,device_type,total,hw_unit_price_tax,"
\
"insert into "
"hw_unit_price,pk_unit_price,pk_unit_price_tax,pk_name,income,"
\
+
tableName
"business_type,hw_term,pk_term,install_unit_price,install_unit_price_tax) "
\
+
"(order_type,order_no,finance_time,cus_name,sale_type,product_code,"
"values "
\
"product_name,product_type,device_type,total,hw_unit_price_tax,"
"(
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s)"
"hw_unit_price,pk_unit_price,pk_unit_price_tax,pk_name,income,"
"business_type,hw_term,pk_term,install_unit_price,install_unit_price_tax) "
"values "
"(
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s,
%
s)"
)
cs
.
executemany
(
sql
,
valueArr
)
cs
.
executemany
(
sql
,
valueArr
)
conn_updata
.
commit
()
conn_updata
.
commit
()
def
updateCustomerChannel
():
def
updateCustomerChannel
():
'''更新客户的渠道'''
"""更新客户的渠道"""
dbConn
=
pymysql
.
Connect
(
host
=
'192.168.5.20'
,
port
=
3306
,
user
=
'biz_glsx_data'
,
dbConn
=
pymysql
.
Connect
(
passwd
=
'unEKczDc'
,
db
=
'glsx_biz_data'
,
charset
=
'utf8'
)
host
=
"192.168.5.2"
,
port
=
3306
,
user
=
"biz_glsx_data"
,
passwd
=
"unEKczDc"
,
db
=
"glsx_biz_data"
,
charset
=
"utf8"
,
)
querySql
=
"SELECT cus_name,sale_type,count(1) from dj_2022_settlment_order_finance group by cus_name,sale_type"
querySql
=
"SELECT cus_name,sale_type,count(1) from dj_2022_settlment_order_finance group by cus_name,sale_type"
dbCursor
=
dbConn
.
cursor
()
dbCursor
=
dbConn
.
cursor
()
dbCursor
.
execute
(
querySql
)
dbCursor
.
execute
(
querySql
)
...
@@ -146,24 +250,23 @@ def updateCustomerChannel():
...
@@ -146,24 +250,23 @@ def updateCustomerChannel():
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
# 财务原表
# 财务原表
filePath
=
"
C:
\\
Users
\\
333
\\
Desktop
\\
2022审计
\\
应收拆分数据-2022年12月
\\
"
filePath
=
"
G:
\\
财务审计
\\
EXCEL文档
\\
应收拆分数据3月份
\\
"
# fileName = filePath + "
【数据源】-应收单12
月.xlsx"
# fileName = filePath + "
数据源-激活调整用23年2-3
月.xlsx"
# sheetName = "Sheet1"
# sheetName = "Sheet1"
# loadFinnanceExcelToMysql(fileName, sheetName)
# loadFinnanceExcelToMysql(fileName, sheetName)
# E盾
# E盾
# fileName = filePath + "
1.拆分数据-虎哥E盾结算单与明细数据12
月-陈冰恋.xlsx"
# fileName = filePath + "
4.数据源-激活调整用23年3
月-陈冰恋.xlsx"
# sheetName =
'3.虎哥E盾--渠道应收单原表'
# sheetName =
"3.虎哥E盾--渠道应收单原表"
# loadDjExcelToMysql(fileName, sheetName)
# loadDjExcelToMysql(fileName, sheetName)
# # 渠道嘀加
# # 渠道嘀加
# fileName = filePath + "
3.拆分数据-渠道2022年12月滴
加数据-柳云飞.xlsx"
# fileName = filePath + "
2.拆分数据-渠道2023年3月嘀
加数据-柳云飞.xlsx"
# sheetName =
'Sheet2'
# sheetName =
"Sheet2"
# loadDjExcelToMysql(fileName, sheetName)
# loadDjExcelToMysql(fileName, sheetName)
# # # 直销
# # # 直销
# fileName = filePath + "4.拆分数据-广汇2022年12
月-廖敏玲.xlsx"
fileName
=
filePath
+
"1.数据源-激活调整用2023年3
月-廖敏玲.xlsx"
# sheetName = '廖敏玲'
sheetName
=
"廖敏玲"
#
loadDjExcelToMysql(fileName, sheetName)
loadDjExcelToMysql
(
fileName
,
sheetName
)
print
(
"done"
)
print
(
"done"
)
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