from spire.doc import Document, Paragraph, Table, Comment, CommentMark, CommentMarkType
import json
from loguru import logger
import re
from thefuzz import fuzz
from utils.doc_util import DocBase
from utils.common_util import adjust_single_chunk_size
import os


def extract_table_cells_text(table, joiner="\n"):
    """
    从 Spire.Doc 的 Table 对象中提取每个单元格文本，并按行主序返回扁平列表：
    ["r0c0_text", "r0c1_text", "r1c0_text", ...]
    joiner: 用于连接单元格内多段落或嵌套表行的分隔符（默认换行）
    注意：不对文本做任何清洗或 strip，保持原有格式
    """

    def _para_text(para):
        # 优先使用 para.Text（保留原样），否则尝试从 para.ChildObjects 收集 Text-like 字段
        try:
            if hasattr(para, "Text"):
                return para.Text if para.Text is not None else ""
        except Exception:
            pass

        parts = []
        try:
            for idx in range(para.ChildObjects.Count):
                obj = para.ChildObjects[idx]
                if hasattr(obj, "Text"):
                    parts.append(obj.Text if obj.Text is not None else "")
        except Exception:
            pass
        return "".join(parts)

    def _extract_cell_text(cell):
        parts = []

        # 收集单元格内所有段落文本（保持原样，不做 strip）
        try:
            for p_idx in range(cell.Paragraphs.Count):
                para = cell.Paragraphs[p_idx]
                parts.append(_para_text(para))
        except Exception:
            pass

        # 处理嵌套表格（若存在），把嵌套表每一行合并为一条字符串，并按行加入 parts
        try:
            if hasattr(cell, "Tables") and cell.Tables.Count > 0:
                for t_idx in range(cell.Tables.Count):
                    nested = cell.Tables[t_idx]
                    nested_rows = []
                    for nr in range(nested.Rows.Count):
                        nested_row_cells = []
                        for nc in range(nested.Rows[nr].Cells.Count):
                            try:
                                # 取嵌套单元格的所有段落并用 joiner 连接（保留原样）
                                nc_parts = []
                                for np_idx in range(
                                    nested.Rows[nr].Cells[nc].Paragraphs.Count
                                ):
                                    nc_parts.append(
                                        _para_text(
                                            nested.Rows[nr].Cells[nc].Paragraphs[np_idx]
                                        )
                                    )
                                nested_row_cells.append(joiner.join(nc_parts))
                            except Exception:
                                nested_row_cells.append("")
                        nested_rows.append(joiner.join(nested_row_cells))
                    parts.append(joiner.join(nested_rows))
            else:
                # 有时嵌套表格会放在 cell.ChildObjects 中，兼容处理
                try:
                    for idx in range(cell.ChildObjects.Count):
                        ch = cell.ChildObjects[idx]
                        if hasattr(ch, "Rows") and getattr(ch, "Rows") is not None:
                            nested = ch
                            nested_rows = []
                            for nr in range(nested.Rows.Count):
                                nested_row_cells = []
                                for nc in range(nested.Rows[nr].Cells.Count):
                                    try:
                                        nc_parts = []
                                        for np_idx in range(
                                            nested.Rows[nr].Cells[nc].Paragraphs.Count
                                        ):
                                            nc_parts.append(
                                                _para_text(
                                                    nested.Rows[nr]
                                                    .Cells[nc]
                                                    .Paragraphs[np_idx]
                                                )
                                            )
                                        nested_row_cells.append(joiner.join(nc_parts))
                                    except Exception:
                                        nested_row_cells.append("")
                                nested_rows.append(joiner.join(nested_row_cells))
                            parts.append(joiner.join(nested_rows))
                except Exception:
                    pass
        except Exception:
            pass

        # 把单元格内收集到的片段用 joiner 连接成最终字符串（不做任何 trim/clean）
        return joiner.join(parts)

    flat = []
    for r in range(table.Rows.Count):
        row = table.Rows[r]
        for c in range(row.Cells.Count):
            cell = row.Cells[c]
            cell_text = _extract_cell_text(cell)
            # 保持原样，空单元格返回空字符串
            flat.append(cell_text)

    return flat


def process_string(s):
    # 统计换行符数量
    newline_count = s.count("\n")

    # 情况1：没有换行符
    if newline_count == 0:
        return s

    # 情况2：只有一个换行符
    elif newline_count == 1:
        # 分割成两部分
        parts = s.split("\n", 1)
        # 比较前后部分长度
        return parts[0] if len(parts[0]) >= len(parts[1]) else parts[1]

    # 情况3：多个换行符
    else:
        # 分割所有部分
        parts = s.split("\n")
        # 找出中间部分（排除首尾）
        middle_parts = parts[1:-1] if len(parts) > 2 else []

        # 如果没有有效中间部分
        if not middle_parts:
            # 返回最长的一段（排除空字符串）
            non_empty_parts = [p for p in parts if p]
            return max(non_empty_parts, key=len) if non_empty_parts else ""

        # 返回最长的中间部分
        return max(middle_parts, key=len, default="")


def build_mapping(original: str):
    """构造规范化文本和原文索引映射"""
    normalized = []
    mapping = []
    for m in re.finditer(r"\S+", original):
        word = m.group()
        if normalized:
            normalized.append(" ")
            mapping.append(m.start())  # 空格映射
        for j, ch in enumerate(word):
            normalized.append(ch)
            mapping.append(m.start() + j)
    return "".join(normalized), mapping


def extract_match(big_text: str, small_text: str, threshold=20):
    """
    简化版文本匹配函数
    核心逻辑：优先整个文本块匹配，次优子句匹配
    """
    # 1. 精确匹配整个文本块
    if small_text in big_text:
        return small_text, 100

    # 2. 整个文本块模糊匹配
    full_score = fuzz.ratio(big_text, small_text)
    if full_score >= threshold:
        return big_text, full_score

    # 3. 子句匹配（简单分割）
    best_score = 0
    best_clause = None

    # 简单分割：按句号、分号、逗号分割
    for clause in big_text.replace("。", ";").replace("，", ";").split(";"):
        if not clause.strip():
            continue

        clause_score = fuzz.ratio(clause, small_text)
        if clause_score > best_score:
            best_score = clause_score
            best_clause = clause

    # 4. 返回最佳匹配
    if best_score >= threshold:
        return best_clause, best_score

    # 5. 无有效匹配
    return None, max(full_score, best_score)


def find_best_match(sub_chunks, comment):
    """
    在给定的文本块中查找与原始评论最匹配的文本

    参数:
    sub_chunks -- 包含Text属性的对象列表
    comment -- 包含"original_text"的字典

    返回:
    best_match -- 匹配度最高的文本
    best_score -- 最高匹配度
    all_results -- 所有匹配结果列表(匹配文本, 相似度)
    """
    all_results = []  # 存储所有(匹配文本, 相似度)的元组
    best_match = None  # 存储最佳匹配的结果
    best_score = -1  # 存储最高相似度（初始化为-1）

    # print(f"开始处理评论: {comment['original_text'][:30]}...")  # 显示简化的原始评论

    for obj in sub_chunks:
        if isinstance(obj, Paragraph):

            target_text = obj.Text
            original_text = comment["original_text"]
            match_text, score = extract_match(target_text, original_text)

            # 打印当前结果（保持原格式）
            # print("匹配到：\n", match_text)
            # print("相似度：", score)

            # 存储所有结果
            all_results.append((match_text, score))

            # 更新最佳匹配 - 只更新分数更高的结果
            if score > best_score:
                best_match = match_text
                best_score = score

    # 打印最终的最佳匹配结果
    # print("\n" + "=" * 40)
    # print("\n处理完成 - 最佳匹配结果：")
    # print("匹配到：\n", best_match)
    # print("相似度：", best_score)
    # print("=" * 40 + "\n")

    return best_match, best_score


def table_contract(target_texts, comment):
    """
    在给定的文本块中查找与原始评论最匹配的文本

    参数:
    sub_chunks -- 待对比文本
    comment -- 包含"original_text"的字典

    返回:
    best_match -- 匹配度最高的文本
    best_score -- 最高匹配度
    all_results -- 所有匹配结果列表(匹配文本, 相似度)
    """
    all_results = []  # 存储所有(匹配文本, 相似度)的元组
    best_match = None  # 存储最佳匹配的结果
    best_score = -1  # 存储最高相似度（初始化为-1）

    # print(f"开始处理评论: {comment['original_text'][:30]}...")  # 显示简化的原始评论

    original_text = comment["original_text"]
    for target_text in target_texts:

        match_text, score = extract_match(target_text, original_text)

        # 打印当前结果（保持原格式）
        # print("匹配到：\n", match_text)
        # print("相似度：", score)

        # 存储所有结果
        all_results.append((match_text, score))

        # 更新最佳匹配 - 只更新分数更高的结果
        if score > best_score:
            best_match = match_text
            best_score = score

    # 打印最终的最佳匹配结果
    # print("\n" + "=" * 40)
    # print("\n处理完成 - 最佳匹配结果：")
    # print("匹配到：\n", best_match)
    # print("相似度：", best_score)
    # print("=" * 40 + "\n")

    return best_match, best_score


# spire doc解析
class SpireWordDoc(DocBase):

    def load(self, doc_path, **kwargs):
        # License.SetLicenseFileFullPath(f"{root_path}/license.elic.python.xml")
        self._doc_path = doc_path
        self._doc_name = os.path.basename(doc_path)
        self._doc = Document()
        self._doc.LoadFromFile(doc_path)
        self._chunk_list = self._resolve_doc_chunk()
        return self

    def _ensure_loaded(self):
        if not self._doc:
            raise RuntimeError("Document not loaded. Call load() first.")

    def adjust_chunk_size(self):
        self._ensure_loaded()
        all_text_len = len(self.get_all_text())
        self._max_single_chunk_size = adjust_single_chunk_size(all_text_len)
        logger.info(
            f"SpireWordDoc adjust _max_single_chunk_size to {self._max_single_chunk_size}"
        )
        self._chunk_list = self._resolve_doc_chunk()
        return self._max_single_chunk_size

    async def get_from_ocr(self):
        pass

    # 把文档分割成chunk
    def _resolve_doc_chunk(self):
        self._ensure_loaded()
        chunk_list = []
        # 单个chunk
        single_chunk = ""
        # 单个chunk的位置信息
        single_chunk_location = []
        # 遍历每个节
        for section_idx in range(self._doc.Sections.Count):
            current_section = self._doc.Sections.get_Item(section_idx)
            # 遍历节里面每个子对象
            for section_child_idx in range(current_section.Body.ChildObjects.Count):
                # 获取子对象
                child_obj = current_section.Body.ChildObjects.get_Item(
                    section_child_idx
                )
                # 段落处理
                current_child_text = ""
                if isinstance(child_obj, Paragraph):
                    paragraph = child_obj
                    current_child_text = paragraph.Text
                # 表格处理
                elif isinstance(child_obj, Table):
                    table = child_obj
                    current_child_text = self._resolve_table(table)
                # 跳过其他非文本子对象
                else:
                    continue
                # 添加新对象
                if (
                    len(single_chunk) + len(current_child_text)
                    > self._max_single_chunk_size
                ):
                    chunk_list.append(
                        {
                            "chunk_content": single_chunk,
                            "chunk_location": single_chunk_location,
                        }
                    )
                    single_chunk = ""
                    single_chunk_location = []
                single_chunk += current_child_text + "\n"
                single_chunk_location.append(
                    {"section_idx": section_idx, "section_child_idx": section_child_idx}
                )
        if len(single_chunk):
            chunk_list.append(
                {"chunk_content": single_chunk, "chunk_location": single_chunk_location}
            )
        return chunk_list

    # 表格解析为markdown
    def _resolve_table(self, table):
        table_data = ""
        for i in range(0, table.Rows.Count):
            # 遍历行的单元格(cells)
            cell_list = []
            for j in range(0, table.Rows.get_Item(i).Cells.Count):
                # 获取每一个单元格(cell)
                cell = table.Rows.get_Item(i).Cells.get_Item(j)
                cell_content = ""
                for para_idx in range(cell.Paragraphs.Count):
                    paragraph_text = cell.Paragraphs.get_Item(para_idx).Text
                    cell_content += paragraph_text
                cell_list.append(cell_content)
            # table_data += "|" + "|".join(cell_list) + "|"
            # table_data += "\n"
            table_data += ' '.join(cell_list) + '\n'
            if i == 0:
                # table_data += "|" + "|".join(["--- " for _ in cell_list]) + "|\n"
                table_data= ' '.join(cell_list) + '\n'
        return table_data

    def get_chunk_info(self, chunk_id):
        chunk = self._chunk_list[chunk_id]
        chunk_content = chunk["chunk_content"]
        chunk_location = chunk["chunk_location"]
        from_location = f"[第{chunk_location[0]['section_idx'] + 1}节的第{chunk_location[0]['section_child_idx'] + 1}段落]"
        to_location = f"[第{chunk_location[-1]['section_idx'] + 1}节的第{chunk_location[-1]['section_child_idx'] + 1}段落]"
        chunk_content_tips = (
            "[" + chunk_content[:20] + "]...到...[" + chunk_content[-20:] + "]"
        )
        return f"文件块id: {chunk_id + 1}\n文件块位置: 从{from_location}到{to_location}\n文件块简述: {chunk_content_tips}\n"

    def get_chunk_location(self, chunk_id):
        return self.get_chunk_info(chunk_id)

    def get_chunk_num(self):
        self._ensure_loaded()
        return len(self._chunk_list)

    def get_chunk_item(self, chunk_id):
        self._ensure_loaded()
        return self._chunk_list[chunk_id]["chunk_content"]

    # 根据locations获取数据
    def get_sub_chunks(self, chunk_id):
        if chunk_id >= len(self._chunk_list):
            logger.error(f"get_sub_chunks_error:{chunk_id}")
            return []
        chunk = self._chunk_list[chunk_id]
        chunk_locations = chunk["chunk_location"]
        return [
            self._doc.Sections.get_Item(loc["section_idx"]).Body.ChildObjects.get_Item(
                loc["section_child_idx"]
            )
            for loc in chunk_locations
        ]

    def format_comment_author(self, comment):
        return "{}|{}".format(str(comment["id"]), comment["key_points"])

    def remove_comment_prefix(
        self,
    ):
        for i in range(self._doc.Comments.Count):
            current_comment = self._doc.Comments.get_Item(i)
            comment_author = current_comment.Format.Author
            split_author = comment_author.split("|")
            if len(split_author) == 2:
                current_comment.Format.Author = comment_author.split("|")[1]

    # 根据text_selection批注
    def set_comment_by_text_selection(self, text_sel, author, comment_content):
        if text_sel is None:
            return False
        # 将找到的文本作为文本范围，并获取其所属的段落
        range = text_sel.GetAsOneRange()
        paragraph = range.OwnerParagraph
        if paragraph is None:
            return False
        # 创建一个评论对象并设置评论的内容和作者
        comment = Comment(self._doc)
        comment.Body.AddParagraph().Text = comment_content
        comment.Format.Author = author
        # logger.info(author)
        # 将评论添加到段落中
        paragraph.ChildObjects.Insert(
            paragraph.ChildObjects.IndexOf(range) + 1, comment
        )
        # 创建评论起始标记和结束标记，并将它们设置为创建的评论的起始标记和结束标记
        commentStart = CommentMark(self._doc, CommentMarkType.CommentStart)
        commentEnd = CommentMark(self._doc, CommentMarkType.CommentEnd)
        commentStart.CommentId = comment.Format.CommentId
        commentEnd.CommentId = comment.Format.CommentId
        # 在找到的文本之前和之后插入创建的评论起始和结束标记
        paragraph.ChildObjects.Insert(
            paragraph.ChildObjects.IndexOf(range), commentStart
        )
        paragraph.ChildObjects.Insert(
            paragraph.ChildObjects.IndexOf(range) + 1, commentEnd
        )
        return True

    # 根据段落批注
    def set_comment_by_paragraph(self, paragraph, author, comment_content):
        comment = Comment(self._doc)
        comment.Body.AddParagraph().Text = comment_content
        # 设置注释的作者
        comment.Format.Author = author
        paragraph.ChildObjects.Add(comment)
        # 创建注释开始标记和结束标记，并将它们设置为创建的注释的开始和结束标记
        commentStart = CommentMark(self._doc, CommentMarkType.CommentStart)
        commentEnd = CommentMark(self._doc, CommentMarkType.CommentEnd)
        commentStart.CommentId = comment.Format.CommentId
        commentEnd.CommentId = comment.Format.CommentId
        # 在段落结尾插入注释开始标记和结束标记
        # paragraph.ChildObjects.Add(commentStart)
        paragraph.ChildObjects.Add(commentEnd)
        # 也可以考虑在段落开始处插入标记
        paragraph.ChildObjects.Insert(0, commentStart)

    # 设置chunk批注
    def add_table_comment(
        self, table, target_text, comment_text, author="审阅助手", initials="AI"
    ):
        """
        在表格中添加批注
        返回是否成功添加
        """
        added = False

        # 遍历表格所有单元格
        for i in range(table.Rows.Count):
            row = table.Rows[i]
            for j in range(row.Cells.Count):
                cell = row.Cells[j]

                # 遍历单元格中的段落
                for k in range(cell.Paragraphs.Count):
                    para = cell.Paragraphs[k]

                    # 在段落中查找目标文本
                    selection = para.Find(target_text, False, True)
                    if selection:
                        # 获取文本范围
                        text_range = selection.GetAsOneRange()
                        if text_range is None:
                            continue

                        # 获取所属段落
                        paragraph = text_range.OwnerParagraph
                        if paragraph is None:
                            continue

                        # 创建一个评论对象并设置评论的内容和作者
                        comment = Comment(self._doc)
                        comment.Body.AddParagraph().Text = comment_text
                        comment.Format.Author = author

                        # 将评论添加到段落中
                        paragraph.ChildObjects.Insert(
                            paragraph.ChildObjects.IndexOf(text_range) + 1, comment
                        )

                        # 创建评论起始标记和结束标记
                        commentStart = CommentMark(
                            self._doc, CommentMarkType.CommentStart
                        )
                        commentEnd = CommentMark(self._doc, CommentMarkType.CommentEnd)
                        commentStart.CommentId = comment.Format.CommentId
                        commentEnd.CommentId = comment.Format.CommentId

                        # 在找到的文本之前和之后插入创建的评论起始和结束标记
                        paragraph.ChildObjects.Insert(
                            paragraph.ChildObjects.IndexOf(text_range), commentStart
                        )
                        paragraph.ChildObjects.Insert(
                            paragraph.ChildObjects.IndexOf(text_range) + 1, commentEnd
                        )

                        added = True
                        # print(f"表格批注添加成功: '{target_text[:20]}...'")

                        # 添加成功后跳出内层循环
                        break

                # 如果已经添加，跳出单元格循环
                if added:
                    break

            # 如果已经添加，跳出行循环
            if added:
                break

        return added

    def add_chunk_comment(self, chunk_id, comments):
        """
        为chunk添加批注（保证每条评论只批注一次）
        """
        if chunk_id is not None:
            sub_chunks = self.get_sub_chunks(chunk_id)

        for comment in comments:
            if comment.get("result") != "不合格":
                continue
            # update chunk_id
            chunk_id = comment.get("chunk_id", -1)
            if chunk_id is not None and chunk_id != -1:
                sub_chunks = self.get_sub_chunks(chunk_id)
            author = self.format_comment_author(comment)
            suggest = comment.get("suggest", "")
            find_key = comment["original_text"].strip() or comment["key_points"]

            # 先检查是否已经有批注
            existing_comment_idx = self.find_comment(author)
            if existing_comment_idx is not None:
                # 已存在批注，则更新内容
                self._doc.Comments.get_Item(
                    existing_comment_idx
                ).Body.Paragraphs.get_Item(0).Text = suggest
                # print(f"批注已存在，更新内容: '{find_key[:20]}...'")
                continue

            matched = False

            # ---------- 1. 精确匹配（段落 + 表格） ----------
            for obj in sub_chunks:
                if isinstance(obj, Paragraph):
                    try:
                        text_sel = obj.Find(find_key, False, True)
                        if text_sel and self.set_comment_by_text_selection(
                                text_sel, author, suggest
                            ):
                                # print(f"段落批注添加成功: '{find_key[:20]}...'")
                                matched = True
                                # 第一个找到的作为标注对象
                                break
                    except Exception as e:
                        print(f"段落批注添加失败: {str(e)}")

                elif isinstance(obj, Table):
                    try:
                        if self.add_table_comment(obj, find_key, suggest, author):
                            # 第一个找到的表格对象作为批注对象
                            matched = True
                            break
                    except Exception as e:
                        print(f"表格批注添加失败: {str(e)}")

            # ---------- 2. 模糊匹配 ----------
            if not matched:
                try:
                    paragraphs_only = [
                        obj for obj in sub_chunks if isinstance(obj, Paragraph)
                    ]
                    match_text, _ = find_best_match(paragraphs_only, comment)
                    if match_text:
                        for obj in paragraphs_only:
                            text_sel = obj.Find(match_text, False, True)
                            if text_sel and self.set_comment_by_text_selection(
                                text_sel, author, suggest
                            ):
                                # print(f"模糊批注添加成功: '{match_text[:20]}...'")
                                matched = True
                                break

                        if not matched:
                            processed_text = process_string(match_text)
                            for obj in paragraphs_only:
                                text_sel = obj.Find(processed_text, False, True)
                                if text_sel and self.set_comment_by_text_selection(
                                    text_sel, author, suggest
                                ):
                                    # print(f"处理后批注添加成功: '{processed_text[:20]}...'")
                                    matched = True
                                    break

                    # 表格模糊匹配（仅段落模糊匹配失败才跑）
                    if not matched:
                        for obj in sub_chunks:
                            if isinstance(obj, Table):
                                table_data = extract_table_cells_text(obj)
                                best_table_match, _ = table_contract(
                                    table_data, comment
                                )
                                if best_table_match and self.add_table_comment(
                                    obj, best_table_match, suggest, author
                                ):
                                    # print(f"表格批注添加成功: '{best_table_match[:20]}...'")
                                    matched = True
                                    break
                except Exception as e:
                    print(f"模糊匹配失败: {str(e)}")

            # ---------- 3. 匹配最终失败 ----------
            if not matched:
                logger.error(f"未找到可批注位置: '{find_key[:20]}...'")

    # 根据作者名称查找批注
    def find_comment(self, author):
        for i in range(self._doc.Comments.Count):
            current_comment = self._doc.Comments.get_Item(i)
            comment_author = current_comment.Format.Author
            if comment_author == author:
                return i
        return None

    def delete_chunk_comment(self, comments):
        """
        删除指定作者批注
        """
        for comment in comments:
            author = self.format_comment_author(comment)
            author_comment_idx = self.find_comment(author)
            if author_comment_idx is not None:
                self._doc.Comments.RemoveAt(author_comment_idx)
                print(f"删除批注: '{author}'")

    def edit_chunk_comment(self, comments):
        """
        编辑chunk批注：删除已合格的批注，修改存在的批注，不存在则新增
        """
        for comment in comments:
            author = self.format_comment_author(comment)
            review_answer = comment["result"]

            existing_comment_idx = self.find_comment(author)

            if review_answer == "合格":
                # 删除批注
                if existing_comment_idx is not None:
                    self._doc.Comments.RemoveAt(existing_comment_idx)
                    # print(f"已删除合格批注: '{author}'")
            else:
                # 不合格，更新或新增
                suggest = comment.get("suggest", "")
                if existing_comment_idx is not None:
                    self._doc.Comments.get_Item(
                        existing_comment_idx
                    ).Body.Paragraphs.get_Item(0).Text = suggest
                    # print(f"更新已有批注: '{author}'")
                else:
                    # chunk_id要从comment中获取
                    self.add_chunk_comment(comment["chunk_id"] - 1, [comment])

    def get_chunk_id_list(self, step=1):
        self._ensure_loaded()
        return [idx for idx in range(0, self.get_chunk_num(), step)]

    def get_all_text(self):
        self._ensure_loaded()
        return self._doc.GetText()

    def to_file(self, path, remove_prefix=False):
        self._ensure_loaded()
        if remove_prefix:
            self.remove_comment_prefix()
        self._doc.SaveToFile(path)

    def release(self):
        # 关闭文件
        if self._doc:
            self._doc.Close()
        super().release()

    def __del__(self):
        pass
        # self.release()


if __name__ == "__main__":
    doc = SpireWordDoc()
    doc.load(
        r"/home/ccran/lufa-contract/demo/今麦郎合同审核.docx"
    )
    print(doc._doc_name)
    doc.add_chunk_comment(
        0,
        [
            {
                "id": "1",
                "key_points": "日期审查",
                "original_text": "承诺",
                "details": "1111",
                "chunk_id": 0,
                "result": "不合格",
                "suggest": "这是测试建议",
            }
        ],
    )
    doc.to_file("/home/ccran/lufa-contract/demo/今麦郎合同审核_test.docx", True)