| | |
| | | extractTimeRange(text) |
| | | ); |
| | | } |
| | | if (containsAny(text, "流转", "进度", "节点", "日志")) { |
| | | if (containsAny(text, "流转", "进度", "节点", "日志", "卡在", "卡到", "当前审批人", "处理记录")) { |
| | | return StringUtils.hasText(approveId) |
| | | ? approveTodoTools.getTodoProgress(memoryId, approveId) |
| | | : missingApproveId("todo_progress", "查询审批进度需要提供流程编号。"); |
| | |
| | | ? approveTodoTools.getTodoDetail(memoryId, approveId) |
| | | : missingApproveId("todo_detail", "查询审批详情需要提供流程编号。"); |
| | | } |
| | | if (containsAny(text, "取消审核", "撤销审核", "回退审核")) { |
| | | if (containsAny(text, "取消审核", "撤销审核", "回退审核", "撤销审批", "撤回审批") |
| | | || (containsAny(text, "撤销", "撤回") && containsAny(text, "审批操作", "审核操作"))) { |
| | | return StringUtils.hasText(approveId) |
| | | ? approveTodoTools.cancelReviewTodo(memoryId, approveId, extractTail(text, "原因")) |
| | | ? approveTodoTools.cancelReviewTodo(memoryId, approveId, firstNonBlank(extractTail(text, "原因"), extractTail(text, "备注"))) |
| | | : missingApproveId("cancel_review_action", "取消审核需要提供流程编号。"); |
| | | } |
| | | if (containsAny(text, "删除")) { |
| | | if (containsAny(text, "删除", "移除")) { |
| | | return StringUtils.hasText(approveId) |
| | | ? approveTodoTools.deleteTodo(memoryId, approveId) |
| | | : missingApproveId("delete_action", "删除审批单需要提供流程编号。"); |
| | | } |
| | | if (containsAny(text, "驳回", "拒绝")) { |
| | | return StringUtils.hasText(approveId) |
| | | ? approveTodoTools.reviewTodo(memoryId, approveId, "reject", extractTail(text, "原因")) |
| | | ? approveTodoTools.reviewTodo(memoryId, approveId, "reject", firstNonBlank(extractTail(text, "原因"), extractTail(text, "备注"))) |
| | | : missingApproveId("review_action", "驳回审批需要提供流程编号。"); |
| | | } |
| | | if (containsAny(text, "审核通过", "审批通过", "通过审批", "同意审批", "审批同意")) { |
| | |
| | | && !containsAny(text, "未通过", "通过率", "审批通过率", "审核通过率")) { |
| | | return approveTodoTools.reviewTodo(memoryId, approveId, "approve", extractTail(text, "备注")); |
| | | } |
| | | if (containsAny(text, "修改")) { |
| | | if (containsAny(text, "修改", "更新", "变更")) { |
| | | return StringUtils.hasText(approveId) |
| | | ? approveTodoTools.updateTodo( |
| | | memoryId, |
| | |
| | | extractValue(text, "备注")) |
| | | : missingApproveId("update_action", "修改审批单需要提供流程编号。"); |
| | | } |
| | | if (containsAny(text, "列表", "待办", "查询审批")) { |
| | | if (containsAny(text, "列表", "待办", "查询审批", "单据", "流程", "审批批")) { |
| | | return approveTodoTools.listTodos( |
| | | memoryId, |
| | | extractStatus(text), |
| | | extractApproveType(text), |
| | | extractKeyword(text), |
| | | extractLimit(text)); |
| | | extractLimit(text), |
| | | extractScope(text)); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private boolean isStatsIntent(String text) { |
| | | if (containsAny(text, "统计", "分析", "图表", "趋势", "占比", "汇总", "总量")) { |
| | | if (containsAny(text, "统计", "分析", "图表", "趋势", "占比", "汇总", "总量", "分布", "各有多少", "有多少")) { |
| | | return true; |
| | | } |
| | | boolean hasQueryWord = containsAny(text, "查询", "查看", "看下", "看看", "获取"); |
| | |
| | | if (containsAny(text, "待审核", "待审批")) { |
| | | return "pending"; |
| | | } |
| | | if (containsAny(text, "审核中")) { |
| | | if (containsAny(text, "审核中", "处理中", "处理中的", "办理中")) { |
| | | return "processing"; |
| | | } |
| | | if (containsAny(text, "已通过", "审核完成")) { |
| | | if (containsAny(text, "已通过", "通过", "审核完成", "审批完成")) { |
| | | return "approved"; |
| | | } |
| | | if (containsAny(text, "未通过", "驳回")) { |
| | | if (containsAny(text, "未通过", "驳回", "已驳回", "拒绝")) { |
| | | return "rejected"; |
| | | } |
| | | if (containsAny(text, "重新提交")) { |
| | |
| | | private String extractKeyword(String text) { |
| | | String cleaned = text |
| | | .replace("查询", "") |
| | | .replace("查看", "") |
| | | .replace("列出", "") |
| | | .replace("帮我", "") |
| | | .replace("审批", "") |
| | | .replace("单据", "") |
| | | .replace("待办", "") |
| | | .replace("列表", "") |
| | | .replace("前10条", "") |
| | |
| | | return matcher.find() ? matcher.group(2).trim() : null; |
| | | } |
| | | |
| | | private String extractScope(String text) { |
| | | if (containsAny(text, "我发起", "我提交", "我申请", "申请人是我")) { |
| | | return "applicant"; |
| | | } |
| | | if (containsAny(text, "待我审批", "待我审核", "我处理", "我审批", "当前待我", "需要我处理")) { |
| | | return "approver"; |
| | | } |
| | | return "related"; |
| | | } |
| | | |
| | | private String firstNonBlank(String first, String second) { |
| | | return StringUtils.hasText(first) ? first : second; |
| | | } |
| | | |
| | | private String missingApproveId(String type, String description) { |
| | | Map<String, Object> result = new LinkedHashMap<>(); |
| | | result.put("success", false); |