48 lines
2.1 KiB
Plaintext
48 lines
2.1 KiB
Plaintext
async def get_kyy_supply(ns={}):
|
|
import traceback
|
|
db = DBPools()
|
|
async with db.sqlorContext('kboss') as sor:
|
|
try:
|
|
res_li = []
|
|
if ns.get('id'):
|
|
res_supply = await sor.R('kyy_supply', {'id': ns.get('id'), 'del_flg': '0'})
|
|
return {
|
|
'status': True,
|
|
'msg': '获取供应产品成功',
|
|
'data': res_supply
|
|
}
|
|
# res_supply = await sor.R('kyy_supply', {'orgid': ns.get('orgid'), 'del_flg': '0'})
|
|
res_supply_sql = """select * from kyy_supply where orgid = '%s' and del_flg = '0' order by create_at desc;""" % ns.get('orgid')
|
|
res_supply = await sor.sqlExe(res_supply_sql, {})
|
|
if not ns.get('find_key'):
|
|
return {
|
|
'status': True,
|
|
'msg': '获取供应产品成功',
|
|
'data': res_supply
|
|
}
|
|
# find_key = ns['find_key'].replace("'", '"') if isinstance(ns.get('find_key'), str) else ns.get('find_key')
|
|
# find_key = json.loads(find_key) if isinstance(find_key, str) else find_key
|
|
find_key = ns.get('find_key')
|
|
for res in res_supply:
|
|
# basic_info = res['basic_info'].replace("'", '"') if isinstance(res['basic_info'], str) else res['basic_info']
|
|
# is_subset = all(item in basic_info for item in find_key)
|
|
basic_info_dic = json.loads(res['basic_info'])
|
|
for info_detail in basic_info_dic:
|
|
info_value = info_detail['value']
|
|
if find_key in info_value:
|
|
res_li.append(res)
|
|
break
|
|
return {
|
|
'status': True,
|
|
'msg': '获取供应产品成功',
|
|
'data': res_li
|
|
}
|
|
except Exception as e:
|
|
await sor.rollback()
|
|
return {
|
|
'status': False,
|
|
'msg': '获取供应产品失败, %s, %s' % (str(e), traceback.format_exc())
|
|
}
|
|
|
|
ret = await get_kyy_supply(params_kw)
|
|
return ret |