|
|
|
|
import requests
|
|
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
|
from config.logger import setup_logging
|
|
|
|
|
from plugins_func.register import register_function, ToolType, ActionResponse, Action
|
|
|
|
|
import json
|
|
|
|
|
import base64
|
|
|
|
|
import urllib.parse
|
|
|
|
|
|
|
|
|
|
TAG = __name__
|
|
|
|
|
logger = setup_logging()
|
|
|
|
|
|
|
|
|
|
APPLY_CAR_FUNCTION_DESC = {
|
|
|
|
|
"type": "function",
|
|
|
|
|
"function": {
|
|
|
|
|
"name": "apply_car",
|
|
|
|
|
"description": (
|
|
|
|
|
"申请用车,用户需要提供车辆名称、出发地、目的地、出发时间和用车事由"
|
|
|
|
|
# "需要根据用户提供的车辆名称,获取对应的车牌号和车id"
|
|
|
|
|
# "如果用户提供的车辆名称为:奥迪,对应的车牌号为:吉JQ1919,对应的车id为:1"
|
|
|
|
|
# "如果用户提供的车辆名称为:奔驰,对应的车牌号为:吉ABN778,对应的车id为:2"
|
|
|
|
|
# "如果用户没有具体的车辆名称,默认使用车辆名称为:奥迪,对应的车牌号为:吉JQ1919,对应的车id为:1"
|
|
|
|
|
"如果用户没有提供具体的车辆名称,默认使用车辆名称为:奥迪"
|
|
|
|
|
"如果用户没有提供具体的用车事由,需要进行分析得出用车事由"
|
|
|
|
|
),
|
|
|
|
|
"parameters": {
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"car_name": {
|
|
|
|
|
"type": "string",
|
|
|
|
|
"description": "车辆名称"
|
|
|
|
|
},
|
|
|
|
|
"car_no": {
|
|
|
|
|
"type": "string",
|
|
|
|
|
"description": "车牌号"
|
|
|
|
|
},
|
|
|
|
|
"car_id": {
|
|
|
|
|
"type": "string",
|
|
|
|
|
"description": "车id"
|
|
|
|
|
},
|
|
|
|
|
"departure_place": {
|
|
|
|
|
"type": "string",
|
|
|
|
|
"description": "出发地"
|
|
|
|
|
},
|
|
|
|
|
"destination_place": {
|
|
|
|
|
"type": "string",
|
|
|
|
|
"description": "目的地"
|
|
|
|
|
},
|
|
|
|
|
"use_car_reason": {
|
|
|
|
|
"type": "string",
|
|
|
|
|
"description": "用车事由"
|
|
|
|
|
},
|
|
|
|
|
"lang": {
|
|
|
|
|
"type": "string",
|
|
|
|
|
"description": "返回用户使用的语言code,例如zh_CN/zh_HK/en_US/ja_JP等,默认zh_CN"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"required": ["lang"]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HEADERS = {
|
|
|
|
|
'User-Agent': (
|
|
|
|
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '
|
|
|
|
|
'(KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36'
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@register_function('apply_car', APPLY_CAR_FUNCTION_DESC, ToolType.SYSTEM_CTL)
|
|
|
|
|
def apply_car(conn, car_name: str = None, car_no: str = None, car_id: str = None, departure_place: str = None, destination_place: str = None, use_car_reason: str = None, lang: str = "zh_CN"):
|
|
|
|
|
# 设置默认车辆信息
|
|
|
|
|
if car_name is None:
|
|
|
|
|
car_name = "奥迪"
|
|
|
|
|
if departure_place is None:
|
|
|
|
|
departure_place = "单位"
|
|
|
|
|
|
|
|
|
|
# 根据车辆名称设置车牌号和车ID
|
|
|
|
|
car_mapping = {
|
|
|
|
|
"奥迪": {"car_no": "吉JQ1919", "car_id": "1"},
|
|
|
|
|
"奔驰": {"car_no": "吉ABN778", "car_id": "2"}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if car_name in car_mapping:
|
|
|
|
|
car_info = car_mapping[car_name]
|
|
|
|
|
car_no = car_info["car_no"]
|
|
|
|
|
car_id = car_info["car_id"]
|
|
|
|
|
|
|
|
|
|
if use_car_reason is None:
|
|
|
|
|
use_car_reason = "外出"
|
|
|
|
|
|
|
|
|
|
print("车辆名称:"+car_name)
|
|
|
|
|
print("车牌号:"+car_no)
|
|
|
|
|
print("车id:"+car_id)
|
|
|
|
|
print("出发地:"+departure_place)
|
|
|
|
|
print("目的地:"+destination_place)
|
|
|
|
|
print("用车事由:"+use_car_reason)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
report = "车辆申请成功"
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
url = "https://www.edusoa.com/dsideal_yy/ypt/intellioa/carManage/carApply/saveCarApply"
|
|
|
|
|
|
|
|
|
|
payload = f'org_id=900008135&person_id=546097&identity_id=5&car_id={car_id}&car_name={car_name}&car_no={car_no}&car_no_type=3&driving_type=1&user_person_id=546097&user_dept_id=900008155&begin_datetime=2025-04-17%2016%3A00&end_datetime=2025-04-17%2016%3A00&departure_place={departure_place}&departure_place_coordinate=125.388035%2C43.776103&destination_place={destination_place}&destination_place_coordinate=125.324812%2C43.911474&use_car_reason={use_car_reason}&rule_id=1&rule_type=20&next_level_id=1&next_person_id=546097&next_person_name=%E8%AE%B8%E5%A6%8D%E5%A6%8D'
|
|
|
|
|
headers = {
|
|
|
|
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:137.0) Gecko/20100101 Firefox/137.0',
|
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
|
'Cookie': 'HWWAFSESID=9e32376ecea1f188cd; HWWAFSESTIME=1744869321310; identity_id=5; person_id=546097; token=ae368e8a2633498a0217c67510668754'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
response = requests.request("POST", url, headers=headers, data=payload)
|
|
|
|
|
|
|
|
|
|
print(response.text)
|
|
|
|
|
|
|
|
|
|
response_data = json.loads(response.text)
|
|
|
|
|
|
|
|
|
|
if response_data.get("code") == 4011:
|
|
|
|
|
print(response_data.get("code"))
|
|
|
|
|
report = "此时间范围该车已被申请,请更换车辆或时间"
|
|
|
|
|
report += (
|
|
|
|
|
"(只回复此时间范围该车已被申请,请更换车辆或时间;其他信息禁止回复)"
|
|
|
|
|
)
|
|
|
|
|
except:
|
|
|
|
|
report = "申请车辆服务异常,请稍后再试"
|
|
|
|
|
report += (
|
|
|
|
|
f"(只回复申请车辆服务异常,请稍后再试,其他信息无需回复)"
|
|
|
|
|
)
|
|
|
|
|
print(report)
|
|
|
|
|
return ActionResponse(Action.REQLLM, report, None)
|