Commit 569e7f46 by 杨林龙

添加脚本

1 parent 555fc82a
...@@ -6,3 +6,5 @@ ...@@ -6,3 +6,5 @@
/*.txt /*.txt
*/*.csv */*.csv
*/*.log */*.log
*/__pycache__
*/*.xlsx
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()
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!