fix:修复data.get('capacity', 0)取出空字符串导致>=比较失败的问题
This commit is contained in:
@@ -107,25 +107,28 @@ def query_room_info(data: dict, params: dict) -> str:
|
||||
meeting_room = getinfo.query_meetingroom(params)
|
||||
content = json.loads(json.dumps(meeting_room))
|
||||
result = params_filter.filter_params(content['data'], "query_meeting_room")
|
||||
logger.info("query_room_info result => {0}".format(result))
|
||||
new_list = []
|
||||
# 字典中只要key存在,哪怕对应的value是'',也能取出来空字符串 data.get('capacity', 0)可能是空字符串
|
||||
capacity = data.get('capacity', 0)
|
||||
capacity_limit = capacity if capacity not in [None, ''] else 0
|
||||
if data.get('Region') and data.get('Region') != 'None':
|
||||
region = data.get('Region')
|
||||
for b in result:
|
||||
if ((region in b.get('name', 'default') or region in b.get('typeName', 'default'))
|
||||
and b.get('capacity',0) >= data.get('capacity', 0)):
|
||||
if ((region in b.get('name', 'default') or region in b.get('typeName', 'default')) and b.get('capacity', 0) >= capacity_limit):
|
||||
new_list.append(b)
|
||||
if len(new_list) >= DEFAULT_QUERY_SIZE:
|
||||
logger.debug("regin--------------- {0}".format(new_list))
|
||||
return json.dumps(new_list, ensure_ascii=False)
|
||||
else:
|
||||
for b in result:
|
||||
if b.get('capacity', 0) >= data.get('capacity', 0):
|
||||
if b.get('capacity', 0) >= capacity_limit:
|
||||
new_list.append(b)
|
||||
if len(new_list) >= DEFAULT_QUERY_SIZE:
|
||||
return json.dumps(new_list, ensure_ascii=False)
|
||||
return json.dumps(new_list, ensure_ascii=False)
|
||||
except Exception as ex:
|
||||
logger.error("location: query_room_info => {0}".format(str(ex)))
|
||||
logger.exception("location: query_room_info => {0}".format(str(ex)))
|
||||
return error_respones.format("查询会议室信息")
|
||||
|
||||
|
||||
@@ -442,7 +445,7 @@ def build_prompt(params):
|
||||
3. 取消会议
|
||||
当用户表达取消会议意向时:
|
||||
(1) 先检查用户是否提供以下信息:
|
||||
会议Id(该信息禁止从历史对话和上下文中查找,只能由用户提供,注意:会议Id是长度大于15位的纯数字编号)
|
||||
会议Id(该信息禁止从历史对话和上下文中查找,只能由用户提供,如果用户提供了会议室名称,可以尝试从该会议室中找出对应的会议ID,如果不唯一,请询问用户需要取消哪一个,注意:会议Id是长度大于15位的纯数字编号,不要混淆会议室Id和会议Id)
|
||||
(2) 若信息不全,先查询用户所有预定,禁止联想历史上下文数据,直接返回json示例如下:
|
||||
```
|
||||
{qry_user_book_info_for_mart_str}
|
||||
|
||||
Reference in New Issue
Block a user