fix: rewrite all create dspy files to use pre-loaded functions
- Removed all imports (json, ServerEnv, datetime, getID) - Replaced datetime.now().strftime with timestampstr() - Added id=getID(), created_at=timestampstr(), updated_at=timestampstr() - Added resellerid from user org context - Used DBPools().sqlorContext pattern - Pass data dict directly to sor.C() without field filtering - Fixed: suppliers, sub_distributors, sub_resellers, distribution_agreements, distribution_agreement_items, supply_contracts, supply_contract_items, platform_supply_products, platform_supply_relations, product_supplier_mapping, sales_ledger, supplychain_accounting
This commit is contained in:
parent
047ec1800a
commit
2dd2953757
@ -1,2 +1,23 @@
|
||||
result = await create_distribution_agreement_items(request, params_kw)
|
||||
return json.loads(result) if isinstance(result, str) else result
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||
|
||||
try:
|
||||
user_id = await get_user()
|
||||
user_orgid = (await get_userorgid()) or '0'
|
||||
dbname = get_module_dbname('supplychain')
|
||||
|
||||
data = dict(params_kw)
|
||||
data['id'] = getID()
|
||||
data['resellerid'] = user_orgid
|
||||
data['created_by'] = user_id
|
||||
data['created_at'] = timestampstr()
|
||||
data['updated_at'] = timestampstr()
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
await sor.C('distribution_agreement_items', data)
|
||||
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '分销协议项目创建成功', 'type': 'success'}}
|
||||
|
||||
except Exception as e:
|
||||
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
|
||||
|
||||
return json.dumps(result, ensure_ascii=False)
|
||||
|
||||
@ -1,2 +1,23 @@
|
||||
result = await create_distribution_agreements(request, params_kw)
|
||||
return json.loads(result) if isinstance(result, str) else result
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||
|
||||
try:
|
||||
user_id = await get_user()
|
||||
user_orgid = (await get_userorgid()) or '0'
|
||||
dbname = get_module_dbname('supplychain')
|
||||
|
||||
data = dict(params_kw)
|
||||
data['id'] = getID()
|
||||
data['resellerid'] = user_orgid
|
||||
data['created_by'] = user_id
|
||||
data['created_at'] = timestampstr()
|
||||
data['updated_at'] = timestampstr()
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
await sor.C('distribution_agreements', data)
|
||||
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '分销协议创建成功', 'type': 'success'}}
|
||||
|
||||
except Exception as e:
|
||||
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
|
||||
|
||||
return json.dumps(result, ensure_ascii=False)
|
||||
|
||||
@ -1,5 +1,23 @@
|
||||
create_func = create_platform_supply_products
|
||||
if create_func is None:
|
||||
return json.dumps({"status": "error", "message": "create_platform_supply_products not registered"})
|
||||
result = await create_func(request, params_kw)
|
||||
return result
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||
|
||||
try:
|
||||
user_id = await get_user()
|
||||
user_orgid = (await get_userorgid()) or '0'
|
||||
dbname = get_module_dbname('supplychain')
|
||||
|
||||
data = dict(params_kw)
|
||||
data['id'] = getID()
|
||||
data['resellerid'] = user_orgid
|
||||
data['created_by'] = user_id
|
||||
data['created_at'] = timestampstr()
|
||||
data['updated_at'] = timestampstr()
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
await sor.C('platform_supply_products', data)
|
||||
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '平台供应产品创建成功', 'type': 'success'}}
|
||||
|
||||
except Exception as e:
|
||||
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
|
||||
|
||||
return json.dumps(result, ensure_ascii=False)
|
||||
|
||||
@ -1,5 +1,23 @@
|
||||
create_func = create_platform_supply_relations
|
||||
if create_func is None:
|
||||
return json.dumps({"status": "error", "message": "create_platform_supply_relations not registered"})
|
||||
result = await create_func(request, params_kw)
|
||||
return result
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||
|
||||
try:
|
||||
user_id = await get_user()
|
||||
user_orgid = (await get_userorgid()) or '0'
|
||||
dbname = get_module_dbname('supplychain')
|
||||
|
||||
data = dict(params_kw)
|
||||
data['id'] = getID()
|
||||
data['resellerid'] = user_orgid
|
||||
data['created_by'] = user_id
|
||||
data['created_at'] = timestampstr()
|
||||
data['updated_at'] = timestampstr()
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
await sor.C('platform_supply_relations', data)
|
||||
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '平台供应关系创建成功', 'type': 'success'}}
|
||||
|
||||
except Exception as e:
|
||||
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
|
||||
|
||||
return json.dumps(result, ensure_ascii=False)
|
||||
|
||||
@ -1,5 +1,23 @@
|
||||
create_func = create_product_supplier_mapping
|
||||
if create_func is None:
|
||||
return json.dumps({"status": "error", "message": "create_product_supplier_mapping not registered"})
|
||||
result = await create_func(request, params_kw)
|
||||
return result
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||
|
||||
try:
|
||||
user_id = await get_user()
|
||||
user_orgid = (await get_userorgid()) or '0'
|
||||
dbname = get_module_dbname('supplychain')
|
||||
|
||||
data = dict(params_kw)
|
||||
data['id'] = getID()
|
||||
data['resellerid'] = user_orgid
|
||||
data['created_by'] = user_id
|
||||
data['created_at'] = timestampstr()
|
||||
data['updated_at'] = timestampstr()
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
await sor.C('product_supplier_mapping', data)
|
||||
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '产品供应商映射创建成功', 'type': 'success'}}
|
||||
|
||||
except Exception as e:
|
||||
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
|
||||
|
||||
return json.dumps(result, ensure_ascii=False)
|
||||
|
||||
@ -1,9 +1,23 @@
|
||||
import json
|
||||
from ahserver.serverenv import ServerEnv
|
||||
env = ServerEnv()
|
||||
create_func = getattr(env, 'create_sales_ledger', None)
|
||||
if create_func is None:
|
||||
print(json.dumps({"status": "error", "message": "create_sales_ledger function not found"}))
|
||||
else:
|
||||
result = await create_func(request, params_kw)
|
||||
print(result)
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||
|
||||
try:
|
||||
user_id = await get_user()
|
||||
user_orgid = (await get_userorgid()) or '0'
|
||||
dbname = get_module_dbname('supplychain')
|
||||
|
||||
data = dict(params_kw)
|
||||
data['id'] = getID()
|
||||
data['resellerid'] = user_orgid
|
||||
data['created_by'] = user_id
|
||||
data['created_at'] = timestampstr()
|
||||
data['updated_at'] = timestampstr()
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
await sor.C('sales_ledger', data)
|
||||
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '销售台账创建成功', 'type': 'success'}}
|
||||
|
||||
except Exception as e:
|
||||
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
|
||||
|
||||
return json.dumps(result, ensure_ascii=False)
|
||||
|
||||
@ -1,2 +1,23 @@
|
||||
result = await create_sub_distributors(request, params_kw)
|
||||
return json.loads(result) if isinstance(result, str) else result
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||
|
||||
try:
|
||||
user_id = await get_user()
|
||||
user_orgid = (await get_userorgid()) or '0'
|
||||
dbname = get_module_dbname('supplychain')
|
||||
|
||||
data = dict(params_kw)
|
||||
data['id'] = getID()
|
||||
data['resellerid'] = user_orgid
|
||||
data['created_by'] = user_id
|
||||
data['created_at'] = timestampstr()
|
||||
data['updated_at'] = timestampstr()
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
await sor.C('sub_distributors', data)
|
||||
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '分销商创建成功', 'type': 'success'}}
|
||||
|
||||
except Exception as e:
|
||||
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
|
||||
|
||||
return json.dumps(result, ensure_ascii=False)
|
||||
|
||||
@ -1,9 +1,23 @@
|
||||
import json
|
||||
from ahserver.serverenv import ServerEnv
|
||||
env = ServerEnv()
|
||||
create_func = getattr(env, 'create_sub_resellers', None)
|
||||
if create_func is None:
|
||||
print(json.dumps({"status": "error", "message": "create_sub_resellers function not found"}))
|
||||
else:
|
||||
result = await create_func(request, params_kw)
|
||||
print(result)
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||
|
||||
try:
|
||||
user_id = await get_user()
|
||||
user_orgid = (await get_userorgid()) or '0'
|
||||
dbname = get_module_dbname('supplychain')
|
||||
|
||||
data = dict(params_kw)
|
||||
data['id'] = getID()
|
||||
data['resellerid'] = user_orgid
|
||||
data['created_by'] = user_id
|
||||
data['created_at'] = timestampstr()
|
||||
data['updated_at'] = timestampstr()
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
await sor.C('sub_resellers', data)
|
||||
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '经销商创建成功', 'type': 'success'}}
|
||||
|
||||
except Exception as e:
|
||||
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
|
||||
|
||||
return json.dumps(result, ensure_ascii=False)
|
||||
|
||||
@ -1,9 +1,23 @@
|
||||
import json
|
||||
from ahserver.serverenv import ServerEnv
|
||||
env = ServerEnv()
|
||||
create_func = getattr(env, 'create_suppliers', None)
|
||||
if create_func is None:
|
||||
print(json.dumps({"status": "error", "message": "create_suppliers function not found"}))
|
||||
else:
|
||||
result = await create_func(request, params_kw)
|
||||
print(result)
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||
|
||||
try:
|
||||
user_id = await get_user()
|
||||
user_orgid = (await get_userorgid()) or '0'
|
||||
dbname = get_module_dbname('supplychain')
|
||||
|
||||
data = dict(params_kw)
|
||||
data['id'] = getID()
|
||||
data['resellerid'] = user_orgid
|
||||
data['created_by'] = user_id
|
||||
data['created_at'] = timestampstr()
|
||||
data['updated_at'] = timestampstr()
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
await sor.C('suppliers', data)
|
||||
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '供应商创建成功', 'type': 'success'}}
|
||||
|
||||
except Exception as e:
|
||||
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
|
||||
|
||||
return json.dumps(result, ensure_ascii=False)
|
||||
|
||||
@ -1,2 +1,23 @@
|
||||
result = await create_supply_contract_items(request, params_kw)
|
||||
return json.loads(result) if isinstance(result, str) else result
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||
|
||||
try:
|
||||
user_id = await get_user()
|
||||
user_orgid = (await get_userorgid()) or '0'
|
||||
dbname = get_module_dbname('supplychain')
|
||||
|
||||
data = dict(params_kw)
|
||||
data['id'] = getID()
|
||||
data['resellerid'] = user_orgid
|
||||
data['created_by'] = user_id
|
||||
data['created_at'] = timestampstr()
|
||||
data['updated_at'] = timestampstr()
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
await sor.C('supply_contract_items', data)
|
||||
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '供应合同项目创建成功', 'type': 'success'}}
|
||||
|
||||
except Exception as e:
|
||||
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
|
||||
|
||||
return json.dumps(result, ensure_ascii=False)
|
||||
|
||||
@ -1,2 +1,23 @@
|
||||
result = await create_supply_contracts(request, params_kw)
|
||||
return json.loads(result) if isinstance(result, str) else result
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||
|
||||
try:
|
||||
user_id = await get_user()
|
||||
user_orgid = (await get_userorgid()) or '0'
|
||||
dbname = get_module_dbname('supplychain')
|
||||
|
||||
data = dict(params_kw)
|
||||
data['id'] = getID()
|
||||
data['resellerid'] = user_orgid
|
||||
data['created_by'] = user_id
|
||||
data['created_at'] = timestampstr()
|
||||
data['updated_at'] = timestampstr()
|
||||
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
await sor.C('supply_contracts', data)
|
||||
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '供应合同创建成功', 'type': 'success'}}
|
||||
|
||||
except Exception as e:
|
||||
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
|
||||
|
||||
return json.dumps(result, ensure_ascii=False)
|
||||
|
||||
@ -1,24 +1,23 @@
|
||||
import json
|
||||
from appPublic.uniqueID import getID
|
||||
from datetime import datetime
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||
|
||||
async def main(request, params_kw):
|
||||
"""Create a new supplychain_accounting record."""
|
||||
try:
|
||||
user_id = await get_user()
|
||||
user_orgid = await get_userorgid()
|
||||
user_orgid = (await get_userorgid()) or '0'
|
||||
dbname = get_module_dbname('supplychain')
|
||||
|
||||
data = params_kw.get("data", "{}")
|
||||
if isinstance(data, str):
|
||||
data = json.loads(data)
|
||||
data = dict(params_kw)
|
||||
data['id'] = getID()
|
||||
data['resellerid'] = user_orgid
|
||||
data['created_by'] = user_id
|
||||
data['created_at'] = timestampstr()
|
||||
data['updated_at'] = timestampstr()
|
||||
|
||||
data["id"] = getID()
|
||||
data["resellerid"] = user_orgid
|
||||
data["created_by"] = user_id
|
||||
data["created_at"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
async with DBPools().sqlorContext(dbname) as sor:
|
||||
await sor.C('supplychain_accounting', data)
|
||||
|
||||
config = getConfig(".")
|
||||
DBPools(config.databases)
|
||||
async with db.sqlorContext(dbname) as sor:
|
||||
await sor.C("supplychain_accounting", data)
|
||||
return json.dumps({"status": "ok", "data": data})
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '供应链记账创建成功', 'type': 'success'}}
|
||||
|
||||
except Exception as e:
|
||||
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
|
||||
|
||||
return json.dumps(result, ensure_ascii=False)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user