Commit d8478402 by weiyudumei

feat: 删除工单第二次自动调用,与策略分析保持一致;有历史记录时第一次自动调用不传workFlowSessionId

parent cf47d227
...@@ -62,7 +62,7 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ ...@@ -62,7 +62,7 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({
setDocUrl(fileBlobUrl) // 传递 blob URL setDocUrl(fileBlobUrl) // 传递 blob URL
setPreviewModalOpen(true) setPreviewModalOpen(true)
} }
catch (error) { catch (error) {
console.error('获取文档链接失败:', error) console.error('获取文档链接失败:', error)
} }
} }
...@@ -105,7 +105,7 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ ...@@ -105,7 +105,7 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({
<> <>
<div className="cardList flex flex-col gap-[20px]"> <div className="cardList flex flex-col gap-[20px]">
{answer.cardList {answer.cardList
&& answer.cardList.map((attachment, index) => { && answer.cardList.map((attachment, index) => {
if (attachment?.type) { if (attachment?.type) {
// 使用唯一标识符而不是索引作为 key // 使用唯一标识符而不是索引作为 key
const key = `${attachment.type}_${attachment.id || index}` const key = `${attachment.type}_${attachment.id || index}`
...@@ -123,8 +123,8 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({ ...@@ -123,8 +123,8 @@ export const ChatAnswerAttachment: React.FC<ChatAnswerAttachmentProps> = ({
)} )}
{/* 附件:引用文件 */} {/* 附件:引用文件 */}
{attachment.type === 'reference' {attachment.type === 'reference'
&& attachment.content?.docList && attachment.content?.docList
&& attachment.content.docList.length !== 0 && ( && attachment.content.docList.length !== 0 && (
<div> <div>
<p className="text-[14px] text-[#8D9795] mb-[12px]"> <p className="text-[14px] text-[#8D9795] mb-[12px]">
已为您找到 已为您找到
......
...@@ -517,10 +517,12 @@ export const TacticsChat: React.FC = () => { ...@@ -517,10 +517,12 @@ export const TacticsChat: React.FC = () => {
// workFlowSessionId 的传递逻辑: // workFlowSessionId 的传递逻辑:
// 1. 如果是重新分析(isReanalyze === true),不传递 workFlowSessionId // 1. 如果是重新分析(isReanalyze === true),不传递 workFlowSessionId
// 2. 优先使用 extra 中的值 // 2. 如果有历史记录且是第一次自动调用(question 为空且 includeQuestion === false),不传递 workFlowSessionId
// 3. 如果都没有,从会话历史中找到最后一个有 workFlowSessionId 的答案 // 3. 优先使用 extra 中的值
// 4. 如果都没有,从会话历史中找到最后一个有 workFlowSessionId 的答案
// 注意:isReanalyze 已在上面声明(第 366 行),这里直接使用 // 注意:isReanalyze 已在上面声明(第 366 行),这里直接使用
if (!isReanalyze) { const isFirstAutoCallWithHistory = hasHistory === true && !question && extra?.includeQuestion === false
if (!isReanalyze && !isFirstAutoCallWithHistory) {
if (extra?.workFlowSessionId) { if (extra?.workFlowSessionId) {
requestBody.workFlowSessionId = extra.workFlowSessionId requestBody.workFlowSessionId = extra.workFlowSessionId
} }
...@@ -913,14 +915,11 @@ export const TacticsChat: React.FC = () => { ...@@ -913,14 +915,11 @@ export const TacticsChat: React.FC = () => {
const hasAutoSubmittedRef = useRef(false) const hasAutoSubmittedRef = useRef(false)
// 记录上次调用时的 searchParams,用于 orderMeta 场景检测参数变化 // 记录上次调用时的 searchParams,用于 orderMeta 场景检测参数变化
const lastSearchParamsRef = useRef<string>('') const lastSearchParamsRef = useRef<string>('')
// 记录 orderMeta 场景下第二次调用是否已执行
const hasOrderMetaSecondCallRef = useRef(false)
useEffect(() => { useEffect(() => {
if (id) { if (id) {
// 当 id 变化时,重置自动提交标志 // 当 id 变化时,重置自动提交标志
hasAutoSubmittedRef.current = false hasAutoSubmittedRef.current = false
lastSearchParamsRef.current = '' lastSearchParamsRef.current = ''
hasOrderMetaSecondCallRef.current = false
} }
}, [id]) }, [id])
useEffect(() => { useEffect(() => {
...@@ -933,7 +932,6 @@ export const TacticsChat: React.FC = () => { ...@@ -933,7 +932,6 @@ export const TacticsChat: React.FC = () => {
if (isOrderMetaScenario && lastSearchParamsRef.current !== currentSearchParams) { if (isOrderMetaScenario && lastSearchParamsRef.current !== currentSearchParams) {
hasAutoSubmittedRef.current = false hasAutoSubmittedRef.current = false
lastSearchParamsRef.current = currentSearchParams lastSearchParamsRef.current = currentSearchParams
hasOrderMetaSecondCallRef.current = false
} }
const shouldTriggerForOrderMeta = isOrderMetaScenario && hasHistoryLoaded && !isLoading const shouldTriggerForOrderMeta = isOrderMetaScenario && hasHistoryLoaded && !isLoading
const shouldTriggerForNormal = !isOrderMetaScenario && hasHistory === false && !isLoading const shouldTriggerForNormal = !isOrderMetaScenario && hasHistory === false && !isLoading
...@@ -1025,49 +1023,14 @@ export const TacticsChat: React.FC = () => { ...@@ -1025,49 +1023,14 @@ export const TacticsChat: React.FC = () => {
hasHistory, hasHistory,
lastSentQuestion: lastSentQuestionRef.current, lastSentQuestion: lastSentQuestionRef.current,
orderMeta: !!orderMeta, orderMeta: !!orderMeta,
hasOrderMetaSecondCall: hasOrderMetaSecondCallRef.current,
}) })
// 关键约束:必须等历史记录查询完成(hasHistory !== null)后,才允许触发任何“自动发送/自动二次调用” // 关键约束:必须等历史记录查询完成(hasHistory !== null)后,才允许触发任何"自动发送"
// 这样可以保证进入页面时的时序为:先 query_user_qa_record_list,再 submit_question_stream。 // 这样可以保证进入页面时的时序为:先 query_user_qa_record_list,再 submit_question_stream。
if (hasHistory === null) { if (hasHistory === null) {
return return
} }
// orderMeta 场景下,即使没有 shouldSendQuestion,也触发第二次调用(用于第三方嵌入场景)
// 复用 shouldSendQuestion 存在时的调用逻辑,保证参数传递完全一致
if (
orderMeta
&& currentIdRef.current
&& !isLoading
&& !hasOrderMetaSecondCallRef.current
&& !shouldSendQuestion
) {
hasOrderMetaSecondCallRef.current = true
// orderMeta 场景下第二次自动调用:仅透传 workOrderIds 到 paramMap
// 需求:第一次自动调用不需要 paramMap;第二次自动调用的 paramMap 取路由内的 workOrderIds 值
const paramMap: Record<string, string> | undefined = typeof orderMeta.workOrderIds === 'string'
? { workOrderIds: orderMeta.workOrderIds }
: undefined
setTimeout(() => {
// 完全复用 shouldSendQuestion 存在时的调用逻辑(第 1063-1074 行),只是 question 为 undefined
// 这样保证参数传递完全一致,包括 paramMap 等参数的处理逻辑
handleSubmitQuestion(
undefined,
undefined,
undefined,
{
includeQuestion: true, // 与 shouldSendQuestion 存在时保持一致
includeTacticsMeta: false,
includeOrderMeta: true,
recordType: 'A11',
...(paramMap ? { paramMap } : {}),
},
)
}, 100)
return
}
if ( if (
shouldSendQuestion shouldSendQuestion
&& currentIdRef.current && currentIdRef.current
...@@ -1076,10 +1039,6 @@ export const TacticsChat: React.FC = () => { ...@@ -1076,10 +1039,6 @@ export const TacticsChat: React.FC = () => {
) { ) {
lastSentQuestionRef.current = shouldSendQuestion lastSentQuestionRef.current = shouldSendQuestion
dispatch(clearTacticsShouldSendQuestion()) dispatch(clearTacticsShouldSendQuestion())
// orderMeta 场景下,标记第二次调用已执行
if (orderMeta) {
hasOrderMetaSecondCallRef.current = true
}
setTimeout(() => { setTimeout(() => {
if (orderMeta) { if (orderMeta) {
handleSubmitQuestion( handleSubmitQuestion(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment