chat聊天OA请假优化
This commit is contained in:
1 parent
3b31867319
commit
05abffc5f0
5 files changed
+67
-25
No files matched your search
@@ -24,6 +24,13 @@ RUN set -eux; \
|
|||||||
libxext6 \
|
libxext6 \
|
||||||
libreoffice \
|
libreoffice \
|
||||||
fonts-noto-cjk \
|
fonts-noto-cjk \
|
||||||
|
curl \
|
||||||
|
gnupg2 \
|
||||||
|
unixodbc-dev \
|
||||||
|
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
|
||||||
|
&& curl https://packages.microsoft.com/config/debian/12/prod.list > /etc/apt/sources.list.d/mssql-release.list \
|
||||||
|
&& apt-get update \
|
||||||
|
&& ACCEPT_EULA=Y apt-get install -y msodbcsql18 \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install Python dependencies
|
# Install Python dependencies
|
||||||
|
|||||||
@@ -198,22 +198,14 @@ WHERE c002001 = ?
|
|||||||
return str(datetime.now().year)
|
return str(datetime.now().year)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _render_section(cls, title: str, record: dict | None, requested_year: int | None) -> str:
|
def _render_table_row(cls, index: int, title: str, record: dict | None, requested_year: int | None) -> str:
|
||||||
response_year = cls._resolve_response_year(record, requested_year)
|
response_year = cls._resolve_response_year(record, requested_year)
|
||||||
if not record:
|
if not record:
|
||||||
return (
|
return f"| {index} | {title} | {response_year} | 暂无数据 | 暂无数据 | 暂无数据 |"
|
||||||
f"### {title}\n\n"
|
total = cls._format_quota(record.get('total_hours'))
|
||||||
f"暂未查询到您 {response_year} 年度的{title}记录。"
|
used = cls._format_quota(record.get('used_hours'))
|
||||||
)
|
remaining = cls._format_quota(record.get('remaining_hours'))
|
||||||
remaining = cls._format_quota(record.get("remaining_hours"))
|
return f"| {index} | {title} | {response_year} | {total} | {used} | {remaining} |"
|
||||||
return (
|
|
||||||
f"### {title}\n\n"
|
|
||||||
f"您当前{title}剩余额度为 {remaining}。\n"
|
|
||||||
f"- 年度:{response_year}\n"
|
|
||||||
f"- 年度可休:{cls._format_quota(record.get('total_hours'))}\n"
|
|
||||||
f"- 已休:{cls._format_quota(record.get('used_hours'))}\n"
|
|
||||||
f"- 当前剩余:{remaining}"
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _build_result_text(cls, leave_type: str, requested_year: int | None, annual_result, childcare_result):
|
def _build_result_text(cls, leave_type: str, requested_year: int | None, annual_result, childcare_result):
|
||||||
@@ -235,11 +227,19 @@ WHERE c002001 = ?
|
|||||||
)
|
)
|
||||||
sections = [
|
sections = [
|
||||||
f"您好,已为您查询到 {intro_year} 年度假期情况:",
|
f"您好,已为您查询到 {intro_year} 年度假期情况:",
|
||||||
|
"",
|
||||||
|
"| 序号 | 假别 | 年度 | 可休 | 已休 | 当前剩余 |",
|
||||||
|
"| :---: | :---: | :---: | :---: | :---: | :---: |",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
index = 1
|
||||||
if leave_type in ("annual", "all"):
|
if leave_type in ("annual", "all"):
|
||||||
sections.extend(["", cls._render_section("年假", annual_record, requested_year)])
|
sections.append(cls._render_table_row(index, "年假", annual_record, requested_year))
|
||||||
|
index += 1
|
||||||
if leave_type in ("childcare", "all"):
|
if leave_type in ("childcare", "all"):
|
||||||
sections.extend(["", cls._render_section("育儿假", childcare_record, requested_year)])
|
sections.append(cls._render_table_row(index, "育儿假", childcare_record, requested_year))
|
||||||
|
index += 1
|
||||||
|
|
||||||
sections.extend(
|
sections.extend(
|
||||||
[
|
[
|
||||||
"",
|
"",
|
||||||
|
|||||||
@@ -215,6 +215,13 @@ class OALeaveWorkflowService:
|
|||||||
show_node = ET.SubElement(field, f'{{{WORKFLOW_NS}}}fieldShowValue')
|
show_node = ET.SubElement(field, f'{{{WORKFLOW_NS}}}fieldShowValue')
|
||||||
show_node.text = str(show_value)
|
show_node.text = str(show_value)
|
||||||
|
|
||||||
|
# 强制将字段设为可编辑和可见,防止OA流程节点中被配置为只读导致无法写入
|
||||||
|
for tag in ['edit', 'view']:
|
||||||
|
node = field.find(f'wf:{tag}', NS)
|
||||||
|
if node is None:
|
||||||
|
node = ET.SubElement(field, f'{{{WORKFLOW_NS}}}{tag}')
|
||||||
|
node.text = 'true'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _set_text(cls, parent: ET.Element, xpath: str, value: str) -> None:
|
def _set_text(cls, parent: ET.Element, xpath: str, value: str) -> None:
|
||||||
node = parent.find(xpath, NS)
|
node = parent.find(xpath, NS)
|
||||||
@@ -290,11 +297,11 @@ class OALeaveWorkflowService:
|
|||||||
cls._set_text(request_info, './/wf:workflowBaseInfo/wf:workflowId', workflow_id)
|
cls._set_text(request_info, './/wf:workflowBaseInfo/wf:workflowId', workflow_id)
|
||||||
|
|
||||||
cls._set_field(request_info, 'requestname', value=request_name, show_value=request_name)
|
cls._set_field(request_info, 'requestname', value=request_name, show_value=request_name)
|
||||||
cls._set_field(request_info, 'tdrgh', value=filler['employee_id'], show_value=filler['employee_id'])
|
cls._set_field(request_info, 'tdrgh', value=filler['employee_id'])
|
||||||
cls._set_field(request_info, 'sqrgh', value=applicant['employee_id'], show_value=applicant['employee_id'])
|
cls._set_field(request_info, 'sqrgh', value=applicant['employee_id'])
|
||||||
cls._set_field(request_info, 'tdrxm', value=filler['user_id'], show_value=filler['name'])
|
cls._set_field(request_info, 'tdrxm', value=filler['user_id'], show_value=filler['name'])
|
||||||
cls._set_field(request_info, 'sqrxm', value=applicant['user_id'], show_value=applicant['name'])
|
cls._set_field(request_info, 'sqrxm', value=applicant['user_id'], show_value=applicant['name'])
|
||||||
cls._set_field(request_info, 'dlrgh', value=agent['employee_id'], show_value=agent['employee_id'])
|
cls._set_field(request_info, 'dlrgh', value=agent['employee_id'])
|
||||||
cls._set_field(request_info, 'dlrxm', value=agent['user_id'], show_value=agent['name'])
|
cls._set_field(request_info, 'dlrxm', value=agent['user_id'], show_value=agent['name'])
|
||||||
cls._set_field(request_info, 'dlrlogid', value=agent['user_id'], show_value=agent['user_id'])
|
cls._set_field(request_info, 'dlrlogid', value=agent['user_id'], show_value=agent['user_id'])
|
||||||
cls._set_field(request_info, 'jb', value=leave_type_code, show_value=leave_type_label)
|
cls._set_field(request_info, 'jb', value=leave_type_code, show_value=leave_type_label)
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ cryptography
|
|||||||
oracledb
|
oracledb
|
||||||
jaydebeapi
|
jaydebeapi
|
||||||
JPype1
|
JPype1
|
||||||
pyodbc
|
pyodbc>=5.1.0
|
||||||
|
zeep>=4.2.1
|
||||||
pywin32; sys_platform == "win32"
|
pywin32; sys_platform == "win32"
|
||||||
|
|
||||||
# File Parsing & edkb_system dependencies from xinxin2
|
# File Parsing & edkb_system dependencies from xinxin2
|
||||||
|
|||||||
@@ -666,11 +666,38 @@ const formatDurationLabel = (hours: number) => {
|
|||||||
return `${hours} 小时`;
|
return `${hours} 小时`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const createLeaveFormData = (): LeaveRequestFormData => {
|
const extractLeaveTypeFromIntent = (content: string) => {
|
||||||
|
if (!content) return '';
|
||||||
|
const map: Record<string, string> = {
|
||||||
|
'事假': '005',
|
||||||
|
'病假': '006',
|
||||||
|
'丧假': '007',
|
||||||
|
'年假': '010',
|
||||||
|
'因公出差': '021',
|
||||||
|
'出差': '021',
|
||||||
|
'调休': '025',
|
||||||
|
'产假': '401',
|
||||||
|
'陪产假': '402',
|
||||||
|
'婚假': '403',
|
||||||
|
'住院': '405',
|
||||||
|
'工伤': '406',
|
||||||
|
'育儿假': '408',
|
||||||
|
'返乡': 'ZZ01',
|
||||||
|
};
|
||||||
|
for (const [key, val] of Object.entries(map)) {
|
||||||
|
if (content.includes(key)) {
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
};
|
||||||
|
|
||||||
|
const createLeaveFormData = (content?: string): LeaveRequestFormData => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const oneHourLater = new Date(now.getTime() + 60 * 60 * 1000);
|
const oneHourLater = new Date(now.getTime() + 60 * 60 * 1000);
|
||||||
const startTime = formatDateTime(now);
|
const startTime = formatDateTime(now);
|
||||||
const endTime = formatDateTime(oneHourLater);
|
const endTime = formatDateTime(oneHourLater);
|
||||||
|
const initialLeaveType = extractLeaveTypeFromIntent(content || '');
|
||||||
return {
|
return {
|
||||||
applicantName: currentUserDisplayName.value,
|
applicantName: currentUserDisplayName.value,
|
||||||
employeeId: currentUserEmployeeId.value,
|
employeeId: currentUserEmployeeId.value,
|
||||||
@@ -680,7 +707,7 @@ const createLeaveFormData = (): LeaveRequestFormData => {
|
|||||||
agentUid: '',
|
agentUid: '',
|
||||||
agentEmployeeId: '',
|
agentEmployeeId: '',
|
||||||
agentName: '',
|
agentName: '',
|
||||||
leaveType: '',
|
leaveType: initialLeaveType,
|
||||||
startTime,
|
startTime,
|
||||||
endTime,
|
endTime,
|
||||||
durationHours: calculateDurationHours(startTime, endTime),
|
durationHours: calculateDurationHours(startTime, endTime),
|
||||||
@@ -705,8 +732,8 @@ const isStrongLeaveIntent = (content: string) => {
|
|||||||
// 弱意图(咨询流程/步骤)应走正常问答,不触发表单分流。
|
// 弱意图(咨询流程/步骤)应走正常问答,不触发表单分流。
|
||||||
const weakConsultationIntent = /(请假流程|请假怎么走|请假步骤|请假如何申请|请假如何走流程|请假怎么办|请假需要什么|请假规定)/;
|
const weakConsultationIntent = /(请假流程|请假怎么走|请假步骤|请假如何申请|请假如何走流程|请假怎么办|请假需要什么|请假规定)/;
|
||||||
if (weakConsultationIntent.test(normalized)) return false;
|
if (weakConsultationIntent.test(normalized)) return false;
|
||||||
if (/^(请假|休假)$/.test(normalized)) return true;
|
if (/^(请假|休假|年假|事假|病假|调休)$/.test(normalized)) return true;
|
||||||
return /(我要请假|申请请假|发起请假|请假申请|我要休假|申请休假|我要请个假|想请假|帮我请假|代我请假|提交请假)/.test(normalized);
|
return /(我要请|申请请|发起请|请假申请|我要休|申请休|想请|帮我请|代我请|提交请)/.test(normalized);
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveLocalMessageToBackend = async (msg: any, userQuery: string = '') => {
|
const saveLocalMessageToBackend = async (msg: any, userQuery: string = '') => {
|
||||||
@@ -744,7 +771,7 @@ const startLocalLeaveFlow = async (content: string) => {
|
|||||||
const formId = newLocalMessageId('leave-form');
|
const formId = newLocalMessageId('leave-form');
|
||||||
const payload: LeaveFormPayload = {
|
const payload: LeaveFormPayload = {
|
||||||
formId,
|
formId,
|
||||||
form: createLeaveFormData(),
|
form: createLeaveFormData(content),
|
||||||
submitting: false,
|
submitting: false,
|
||||||
confirmationGenerated: false,
|
confirmationGenerated: false,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user