Commit 50605749 by 杨林龙

优化审计脚本

1 parent 28b2edfa
......@@ -266,6 +266,7 @@ def match_direct_settlement_delivery_order(startTime, devType=8, findmode=0):
paddnum(unitCost),
paddnum(findmode),
paddstr(saleType),
paddnum(unitCost),
)
)
values.append(strValue)
......@@ -294,7 +295,7 @@ def match_direct_settlement_delivery_order(startTime, devType=8, findmode=0):
+ " (sn,device_type,material_code,delivery_order,"
"delivery_time,delivery_merchant,pk_name,pk_period,"
"settle_merchant,settle_order,settle_time,pk_price,pk_price_tax,hw_price,hw_price_tax,"
"install_price,install_price_tax,cost,flag,channel) values %s"
"install_price,install_price_tax,cost,flag,channel,hw_cost) values %s"
% ",".join(values)
)
if not bizConn.insert(insertSql):
......@@ -611,6 +612,7 @@ def match_not_direct_settlement_delivery_order(startTime, devType=8, mode=0):
paddstr(activeMerchant),
paddnum(mode),
paddstr(saleType),
paddnum(unitCost),
)
)
values.append(strValue)
......@@ -639,7 +641,7 @@ def match_not_direct_settlement_delivery_order(startTime, devType=8, mode=0):
+ " (sn,device_type,material_code,delivery_order,"
"delivery_time,delivery_merchant,pk_name,pk_period,"
"settle_merchant,settle_order,settle_time,pk_price,pk_price_tax,hw_price,hw_price_tax,"
"install_price,install_price_tax,cost,active_time,active_merchant,flag,channel) values %s"
"install_price,install_price_tax,cost,active_time,active_merchant,flag,channel,hw_cost) values %s"
% ",".join(values)
)
if not bizConn.insert(insertSql):
......@@ -1501,6 +1503,7 @@ def handle_return_device(channel, data, devType, matchPrice=0):
paddnum(0),
paddnum(1),
paddstr(saleType),
paddnum(unitCost),
)
)
values.append(strValue)
......@@ -1520,7 +1523,7 @@ def handle_return_device(channel, data, devType, matchPrice=0):
+ " (sn,device_type,material_code,delivery_order,"
"delivery_time,delivery_merchant,pk_name,pk_period,"
"settle_merchant,settle_order,settle_time,pk_price,pk_price_tax,hw_price,hw_price_tax,"
"install_price,install_price_tax,cost,flag, `return`, channel) values %s"
"install_price,install_price_tax,cost,flag, `return`, channel, hw_cost) values %s"
% ",".join(values)
)
if not bizConn.insert(insertSql):
......
......@@ -738,6 +738,7 @@ def match_gen_sn_settlement_delivery_order(startTime, devType, prefix):
paddstr(activeMerchant),
paddnum(mode),
paddstr(saleType),
paddnum(unitCost),
)
)
values.append(strValue)
......@@ -749,7 +750,7 @@ def match_gen_sn_settlement_delivery_order(startTime, devType, prefix):
+ " (sn,is_virtual,device_type,material_code,delivery_order,"
"delivery_time,delivery_merchant,pk_name,pk_period,"
"settle_merchant,settle_order,settle_time,pk_price,pk_price_tax,hw_price,hw_price_tax,"
"install_price,install_price_tax,cost,active_time,active_merchant,flag,channel) values %s"
"install_price,install_price_tax,cost,active_time,active_merchant,flag,channel,hw_cost) values %s"
% ",".join(values)
)
if not bizConn.insert(insertSql):
......
......@@ -10,20 +10,20 @@ def merge():
# 记录仪&车充合并
updateSql = """
insert into dj_2021_settle_details (`channel`,`is_virtual`,`sn`,`iccid`,`device_type`,`material_code`,`delivery_order`,`delivery_time`,`delivery_merchant`,`active_time`,`active_merchant`,`pk_name`,
`pk_period`,`settle_merchant`,`settle_order`,`settle_time`,`pk_price`,`pk_price_tax`,`hw_price`,`hw_price_tax`,`install_price`,`install_price_tax`,`cost`,`flag`,`return`)
`pk_period`,`settle_merchant`,`settle_order`,`settle_time`,`pk_price`,`pk_price_tax`,`hw_price`,`hw_price_tax`,`install_price`,`install_price_tax`,`cost`,`flag`,`return`,`hw_cost`,`install_cost`)
SELECT `channel`,`is_virtual`,`sn`,`iccid`,`device_type`,`material_code`,`delivery_order`,`delivery_time`,`delivery_merchant`,`active_time`,`active_merchant`,`pk_name`,
`pk_period`,`settle_merchant`,`settle_order`,`settle_time`,`pk_price`,`pk_price_tax`,`hw_price`,`hw_price_tax`,`install_price`,`install_price_tax`,`cost`,`flag`,`return` from
dj_2023_settle_details_record where settle_time >='2023-01-01';
`pk_period`,`settle_merchant`,`settle_order`,`settle_time`,`pk_price`,`pk_price_tax`,`hw_price`,`hw_price_tax`,`install_price`,`install_price_tax`,`cost`,`flag`,`return`,`hw_cost`,`install_cost`
from dj_2023_settle_details_record where settle_time >='2023-01-01';
"""
sqlList.append(updateSql)
# 追踪器合并
updateSql01 = """
insert into dj_2021_settle_details (`channel`,`is_virtual`,`sn`,`iccid`,`device_type`,`material_code`,`delivery_order`,`delivery_time`,`delivery_merchant`,`active_time`,`active_merchant`,`pk_name`,
`pk_period`,`settle_merchant`,`settle_order`,`settle_time`,`pk_price`,`pk_price_tax`,`hw_price`,`hw_price_tax`,`install_price`,`install_price_tax`,`cost`,`flag`,`return`)
`pk_period`,`settle_merchant`,`settle_order`,`settle_time`,`pk_price`,`pk_price_tax`,`hw_price`,`hw_price_tax`,`install_price`,`install_price_tax`,`cost`,`flag`,`return`,`hw_cost`,`install_cost`)
SELECT `channel`,`is_virtual`,`sn`,`iccid`,`device_type`,`material_code`,`delivery_order`,`delivery_time`,`delivery_merchant`,`active_time`,`active_merchant`,`pk_name`,
`pk_period`,`settle_merchant`,`settle_order`,`settle_time`,`pk_price`,`pk_price_tax`,`hw_price`,`hw_price_tax`,`install_price`,`install_price_tax`,`cost`,`flag`,`return` from
dj_2023_settle_details where settle_time >='2023-01-01';
`pk_period`,`settle_merchant`,`settle_order`,`settle_time`,`pk_price`,`pk_price_tax`,`hw_price`,`hw_price_tax`,`install_price`,`install_price_tax`,`cost`,`flag`,`return`,`hw_cost`,`install_cost`
from dj_2023_settle_details where settle_time >='2023-01-01';
"""
sqlList.append(updateSql01)
......@@ -100,34 +100,35 @@ def rollback(startTime, endTime):
update_device_alloc(6, startTime, endTime)
bizConn = MySQL(g_pro_biz_dbcfg)
sqlList = []
updateSql = """
update dj_2021_settle_details set `return` = 0 where sn in (SELECT sn from dj_2023_settle_details_return where settle_time >= '2023-01-01');
updateSql = f"""
update dj_2021_settle_details set `return` = 0 where sn in (SELECT sn from dj_2023_settle_details_return where settle_time >= '{startTime}');
"""
sqlList.append(updateSql)
updateSql01 = """
DELETE from dj_2021_settle_details where settle_time >= '2023-01-01';
updateSql01 = f"""
DELETE from dj_2021_settle_details where settle_time >= '{startTime}';
"""
sqlList.append(updateSql01)
updateSql02 = """
DELETE from dj_2023_settle_details where settle_time >= '2023-01-01';
updateSql02 = f"""
DELETE from dj_2023_settle_details where settle_time >= '{startTime}';
"""
sqlList.append(updateSql02)
updateSql03 = """
updateSql03 = f"""
DELETE from dj_2023_settle_details_record where settle_time >= '2023-01-01' ;
"""
sqlList.append(updateSql03)
updateSql04 = """
DELETE from dj_2023_settle_details_return where settle_time >= '2023-01-01' ;
updateSql04 = f"""
DELETE from dj_2023_settle_details_return where settle_time >= '{startTime}' ;
"""
sqlList.append(updateSql04)
updateSql05 = """
update dj_2023_settlment_order set match_total=NULL,`status`=0 where finance_time >= '2023-01-01' and finance_time <= '2023-05-31';
updateSql05 = f"""
update dj_2023_settlment_order set match_total=NULL,`status`=0 where finance_time >= '{startTime}' and finance_time <= '{endTime}';
"""
print("updateSql05==" + updateSql05)
sqlList.append(updateSql05)
updateSql06 = """
......@@ -145,15 +146,15 @@ def rollback(startTime, endTime):
"""
sqlList.append(updateSql08)
updateSql09 = """
truncate TABLE dj_2023_settlment_order;
"""
sqlList.append(updateSql09)
# updateSql09 = """
# truncate TABLE dj_2023_settlment_order;
# """
# sqlList.append(updateSql09)
updateSql10 = """
truncate TABLE dj_2023_settlment_order_finance;
"""
sqlList.append(updateSql10)
# updateSql10 = """
# truncate TABLE dj_2023_settlment_order_finance;
# """
# sqlList.append(updateSql10)
if not bizConn.updateList(sqlList):
logger.error("handle_return_device fail, sql=%s", ",".join(sqlList))
......
import time
def getCsvname():
local_time = time.localtime()
# %04d-%02d-%02d %02d:%02d:%02d
strTime = "%04d%02d%02d%02d%02d%02d" % (
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
if __name__ == "__main__":
if ' - '== '-':
print('true')
# end main
\ No newline at end of file
if " - " == "-":
print("true")
strTime = getCsvname()
print("strTime", strTime)
# end main
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!