kboss/b/hpc/sync_status_search.dspy
2025-07-16 14:27:17 +08:00

80 lines
3.6 KiB
Plaintext

async def sync_status_search(ns={}):
"""
绑定济南超算ldap账号
:param ns:
:return:
"""
db = DBPools()
async with db.sqlorContext('kboss') as sor:
try:
eff_users = []
# 查找userid下所有客户
custos = await sor.R('customer', {'salemanid': await get_user(), 'del_flg': '0'})
custos_ids = [item.get('customerid') for item in custos]
# 获取jncs_syncinfo下的对应客户
syncinfos = await sor.R('jncs_syncinfo', {'del_flg': '0'})
for sy in syncinfos:
cusid = sy.get('customerid')
if cusid in custos_ids:
syncinfo = {
'syncinfoid': sy.get('id'),
'sync_date': sy.get('sync_date') or '',
'customerid': sy.get('customerid'),
'productid': sy.get('productid'),
# 'clustercode': None,
# 'queuecode': None,
'orderid': sy.get('orderid'),
'quantity': sy.get('quantity'),
'sync_status': sy.get('sync_status'),
'create_at': sy.get('create_at')
}
map_res_li = await sor.R('jncs_usermapping', {'orgid': cusid, 'del_flg': '0'})
if map_res_li:
map_info = {
'ldapuid': map_res_li[0].get('ldapuid'),
'clustercode': map_res_li[0].get('clustercode'),
'queuecode': map_res_li[0].get('queuecode'),
'last_access': map_res_li[0].get('last_access')
}
else:
map_info = {
'ldapuid': '',
'clustercode': '',
'queuecode': '',
'last_access': ''
}
org_res_li = await sor.R('organization', {'id': cusid, 'del_flg': '0'})
org_info = {
'orgid': org_res_li[0]['id'],
'orgname': org_res_li[0]['orgname'],
'contactor': org_res_li[0]['contactor'],
'contactor_phone': org_res_li[0]['contactor_phone'],
'province_id': org_res_li[0]['province_id'],
'city_id': org_res_li[0]['city_id'],
'distinct_id': org_res_li[0]['distinct_id'],
'emailaddress': org_res_li[0]['emailaddress'],
'address': org_res_li[0]['address'],
'main_business': org_res_li[0]['main_business'],
'orgcode': org_res_li[0]['orgcode'],
'parentid': org_res_li[0]['parentid'],
'org_type': org_res_li[0]['org_type']
}
syncinfo.update(map_info)
syncinfo.update(org_info)
eff_users.append(syncinfo)
# 结果排序
sort_eff_users = sorted(eff_users,key = lambda e: e['create_at'], reverse=True)
return {
'status': True,
'msg': '查找济南超算绑定过的用户成功',
'data': sort_eff_users
}
except Exception as e:
raise e
return {
'status': False,
'msg': '查找济南超算客户失败'
}
ret = await sync_status_search(params_kw)
return ret