Commit f550f257 by 杨林龙

提交审计脚本

1 parent 65a1dbd1
...@@ -29,7 +29,7 @@ saas_shen_db_cfg = {'host': '192.168.3.222', ...@@ -29,7 +29,7 @@ saas_shen_db_cfg = {'host': '192.168.3.222',
class BaseCreateTable: class BaseCreateTable:
def __init__(self, base_table='temp_device_details_ft', zj_table='temp_device_details_zj'): def __init__(self, base_table='temp_device_details_record_ft', zj_table='temp_device_details_record_zj'):
self.bizConn = MySQL(saas_shen_db_cfg) self.bizConn = MySQL(saas_shen_db_cfg)
self.base_table = base_table self.base_table = base_table
self.zj_table = zj_table self.zj_table = zj_table
......
import logging
from my_utils.MysqlUtility import MySQL
logger = logging.getLogger('deal_equity_data')
logger.setLevel(logging.DEBUG)
fileHandler = logging.FileHandler('../20230404/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.5.77',
# 'port': 3306,
# 'user': 'biz_saas_plus',
# 'passwd': 'lOmEudkc',
# 'db': 'saas_plus',
# 'charset': 'utf8'}
saas_shen_db_cfg = {'host': '192.168.3.222',
'port': 3306,
'user': 'biz_audit',
'passwd': 'hqVIs6jF',
'db': 'saas_shen_ft',
'charset': 'utf8'}
class BaseCreateTable:
def __init__(self, base_table='temp_device_details_ft', zj_table='temp_device_details_zj'):
self.bizConn = MySQL(saas_shen_db_cfg)
self.base_table = base_table
self.zj_table = zj_table
def create_table(self):
drop_table_sql = f'''
drop table if exists {self.base_table};
'''
self.bizConn.query(drop_table_sql)
create_table_sql = f'''
CREATE TABLE `{self.base_table}` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`device_id` int(11) DEFAULT NULL COMMENT '设备表ID',
`apportionment_date` datetime DEFAULT NULL COMMENT '分摊日期',
`apportionment_price` decimal(12,2) DEFAULT NULL COMMENT '分摊金额',
PRIMARY KEY (`id`),
KEY `idx_device_id` (`device_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='基础分摊表';
'''
self.bizConn.query(create_table_sql)
drop_table_sql = f'''
drop table if exists {self.zj_table};
'''
self.bizConn.query(drop_table_sql)
create_table_sql = f'''
CREATE TABLE `{self.zj_table}` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`device_id` int(11) DEFAULT NULL COMMENT '设备表ID',
`order_year` varchar(32) DEFAULT NULL COMMENT '订单年份',
`qichu_num` int(11) DEFAULT NULL COMMENT '期初数量',
`qichu_unit_price` decimal(12,2) DEFAULT NULL COMMENT '期初单价',
`qichu_total_price` decimal(12,2) DEFAULT NULL COMMENT '期初金额',
`zengjia_num` int(11) DEFAULT NULL COMMENT '增加数量',
`zengjia_unit_price` decimal(12,2) DEFAULT NULL COMMENT '增加单价',
`zengjia_total_price` decimal(12,2) DEFAULT NULL COMMENT '增加金额',
`jianshao_num` int(11) DEFAULT NULL COMMENT '减少数量',
`jianshao_unit_price` decimal(12,2) DEFAULT NULL COMMENT '减少单价',
`jianshao_total_price` decimal(12,2) DEFAULT NULL COMMENT '减少金额',
PRIMARY KEY (`id`),
KEY `idx_device_id` (`device_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='增减表';
'''
self.bizConn.query(create_table_sql)
if __name__ == '__main__':
my_base = BaseCreateTable()
my_base.create_table()
...@@ -14,7 +14,7 @@ from decimal import Decimal ...@@ -14,7 +14,7 @@ from decimal import Decimal
import MySQLdb import MySQLdb
from dateutil.relativedelta import * from dateutil.relativedelta import *
from fentan_0519.base_create_table import BaseCreateTable from fentan_0519_2.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")
......
File mode changed
import os,inspect
current_dir=os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
os.chdir(current_dir)
import sys
sys.path.append('../')
from fentan.yang import myfunc
if __name__ == "__main__":
myfunc()
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!