bugfix
This commit is contained in:
parent
2635d22cc9
commit
db43d5aca3
@ -26,31 +26,14 @@ from discount.init import load_discount
|
|||||||
from dapi.init import load_dapi
|
from dapi.init import load_dapi
|
||||||
from product_management import get_manager
|
from product_management import get_manager
|
||||||
|
|
||||||
# 初始化配置
|
|
||||||
p = ProgramPath()
|
|
||||||
config = getConfig(NS={'workdir': os.getcwd(), 'ProgramPath': p})
|
|
||||||
db = DBPools(config.databases)
|
|
||||||
# 生产环境 get_business_date 内直接 db=DBPools() 创建空实例 → sqlorFactory(None)
|
|
||||||
# 替换为使用已初始化的 db
|
|
||||||
import appbase.businessdate as _bd
|
|
||||||
_orig_gbd = _bd.get_business_date
|
|
||||||
async def _patched_get_business_date(sor=None):
|
|
||||||
async def _f(sor):
|
|
||||||
sql = "select * from params where params_name = 'business_date'"
|
|
||||||
recs = await sor.sqlExe(sql, {})
|
|
||||||
if len(recs) > 0:
|
|
||||||
return recs[0]['params_value']
|
|
||||||
raise Exception('BusinessDateParamsError')
|
|
||||||
if sor:
|
|
||||||
return await _f(sor)
|
|
||||||
async with db.sqlorContext(get_module_dbname('appbase')) as sor:
|
|
||||||
return await _f(sor)
|
|
||||||
_bd.get_business_date = _patched_get_business_date
|
|
||||||
|
|
||||||
def get_module_dbname(m):
|
def get_module_dbname(m):
|
||||||
return 'sage'
|
return 'sage'
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
# 初始化配置
|
||||||
|
p = ProgramPath()
|
||||||
|
config = getConfig(NS={'workdir': os.getcwd(), 'ProgramPath': p})
|
||||||
|
db = DBPools(config.databases)
|
||||||
logger = MyLogger('backend_accounting', levelname='info',
|
logger = MyLogger('backend_accounting', levelname='info',
|
||||||
logfile=os.path.join(os.getcwd(), 'logs', 'backend_accounting.log'))
|
logfile=os.path.join(os.getcwd(), 'logs', 'backend_accounting.log'))
|
||||||
info(f'Backend accounting process started (PID: {os.getpid()})')
|
info(f'Backend accounting process started (PID: {os.getpid()})')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user