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 569e7f46
authored
Jun 14, 2023
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加脚本
1 parent
555fc82a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
0 deletions
.gitignore
fentan_0530/deal_device_login_num.py
.gitignore
View file @
569e7f4
...
...
@@ -6,3 +6,5 @@
/*.txt
*/*.csv
*/*.log
*/__pycache__
*/*.xlsx
fentan_0530/deal_device_login_num.py
0 → 100644
View file @
569e7f4
import
logging
import
time
from
datetime
import
datetime
from
decimal
import
Decimal
import
MySQLdb
import
calendar
import
random
from
dateutil.relativedelta
import
*
from
my_utils.MysqlUtility
import
MySQL
import
pandas
as
pd
import
numpy
as
np
logger
=
logging
.
getLogger
(
"deal_device_login_data"
)
logger
.
setLevel
(
logging
.
DEBUG
)
fileHandler
=
logging
.
FileHandler
(
"./import.log"
)
fileHandler
.
setLevel
(
logging
.
DEBUG
)
formatter
=
logging
.
Formatter
(
"
%(asctime)
s -
%(name)
s -
%(levelname)
s -
%(message)
s"
)
cnslhandler
=
logging
.
StreamHandler
()
cnslhandler
.
setLevel
(
logging
.
DEBUG
)
cnslhandler
.
setFormatter
(
formatter
)
logger
.
addHandler
(
cnslhandler
)
saas_shen_db_cfg
=
{
"host"
:
"192.168.3.222"
,
"port"
:
3306
,
"user"
:
"biz_audit"
,
"passwd"
:
"hqVIs6jF"
,
"db"
:
"saas_shen_ft"
,
"charset"
:
"utf8"
,
}
def
deal_caiwu_xufei_data
():
# 读取 xlsx 文件
data
=
pd
.
read_excel
(
"D://data//5月续费数据汇总_result.xlsx"
,
sheet_name
=
"Sheet1"
)
# 打印表格内容
print
(
data
[
"设备号"
])
my_map
=
getMySqlData
()
for
key
,
sn
in
enumerate
(
data
[
"设备号"
]):
if
pd
.
isnull
(
sn
):
continue
print
(
"key:"
,
key
,
"sn:"
,
sn
)
print
(
data
.
loc
[
key
,
"卡号01"
]
.
astype
(
str
))
print
(
data
.
loc
[
key
,
"嘀嘀号"
])
print
(
data
.
loc
[
key
,
"续费套餐"
])
print
(
data
.
loc
[
key
,
"当前套餐到期时间"
])
print
(
data
.
loc
[
key
,
"最后一次续费时间"
])
col
=
my_map
.
get
(
sn
)
if
col
is
None
:
continue
if
col
[
1
]
is
not
None
:
data
.
loc
[
key
,
"嘀嘀号"
]
=
col
[
1
]
if
col
[
5
]
is
not
None
:
data
.
loc
[
key
,
"续费套餐"
]
=
col
[
5
]
if
col
[
3
]
is
not
None
:
data
.
loc
[
key
,
"当前套餐到期时间"
]
=
col
[
3
]
if
col
[
6
]
is
not
None
:
data
.
loc
[
key
,
"最后一次续费时间"
]
=
col
[
6
]
data
.
to_excel
(
"./续费数据汇总.xlsx"
)
print
(
"end==="
)
def
getMySqlData
():
bizConn
=
MySQL
(
saas_shen_db_cfg
)
sql
=
f
"""
SELECT id,protocol_id,sn,max_end_time,renewal_product_id,renewal_product_name,max_renewal_time
FROM temp_platform_protocol_service WHERE sn IS NOT NULL ;
"""
logger
.
info
(
sql
)
if
not
bizConn
.
query
(
sql
):
logger
.
error
(
"deal_equity_data fail, sql=
%
s"
,
sql
)
return
result
=
bizConn
.
fetchAllRows
()
my_map
=
{
i
[
2
]:
i
for
i
in
result
}
print
(
"my_map:"
,
my_map
)
return
my_map
if
__name__
==
"__main__"
:
# 处理设备登陆数据
deal_caiwu_xufei_data
()
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