---
title: "公文智能校对服务选择钩子（2025.05.01基线以上支持）"
publicId: "ca702c6b-e369-4a28-9a40-e278bf90c37e"
source: "https://weapp.eteams.cn/build/techdoc/wdoc/index.html#/public/doc/ca702c6b-e369-4a28-9a40-e278bf90c37e"
---
**二开接口标识：**ODOC_AI_PROOFREAD_001

**参数：**

| 参数名 |  | 必选 | 类型 | 说明 |
| --- | --- | --- | --- | --- |
| tenantKey |  | 是 | String | 租户Key |

**返回值：**

| 参数名 |  | 必选 | 类型 | 说明 |
| --- | --- | --- | --- | --- |
| proofreadServerType |  | 是 | String | 金山黑马:wps  <br>千里聆:weaver  <br>AI连接器提示词工程:prompt |

示例：

```
@Slf4j
@WeaHookReg(code = "ODOC_AI_PROOFREAD_001", order = 0)
public class AiProofreadHook extends RegHookEvent {

    @Autowired
    private DataSetService dataSetService;
    @Override
    public WeaHookResponse handle(WeaHookRequest request, WeaHookResponse response, AppInfo appInfo) throws Exception {
        Map<String, Object> params = request.getParams();

        Map<String, Object> resultMap = new HashMap<>();
        String serverType = "";
        String tenantKey = AiCommonUtil.null2String(params.get("tenantKey"));
        String sql = "select server_type from uf_proofread where tenant_key = '" + tenantKey + "' and delete_type = 0";
        Map<String, Object> map = dataSetService.executeSql(getExecuteSqlEntity(sql, "weaver-ebuilder-form-service"));
        List<Map<String, Object>> entities = getDataSourceList(map);

        if (entities != null && entities.size() > 0) {
            Map<String, Object> ebatchResult = entities.get(0);
            serverType = AiCommonUtil.null2String(ebatchResult.get("server_type"));
        }
        resultMap.put("proofreadServerType", serverType);

        response.setResult(resultMap);

        return response;
    }

    @Override
    public void rollBack(WeaHookRequest request, WeaHookResponse response, AppInfo appInfo) throws Exception {
    }


    public ExecuteSqlEntity getExecuteSqlEntity(String sql, String groupId) {
        log.error("sql=>{}", sql);
        ExecuteSqlEntity executeSqlEntity = new ExecuteSqlEntity();
        executeSqlEntity.setSql(this.base64(sql));
        executeSqlEntity.setGroupId(groupId);
        executeSqlEntity.setSourceType(SourceType.LOGIC);
        executeSqlEntity.setGroupKey("0");
        return executeSqlEntity;
    }
    public String base64(String sql) {
        return Base64.encode(sql);
    }
    public List<Map<String, Object>> getDataSourceList(Map<String, Object> map) {
        List<Map<String, Object>> entity = new ArrayList();
        if ("OK".equals(AiCommonUtil.null2String(map.get("status")).toUpperCase(Locale.ROOT)) && map.get("count") != null && AiCommonUtil.getIntValue(map.get("count")) > 0) {
            entity = (List)map.get("records");
        }

        return this.keyToLowerCase((List)entity);
    }

    public List<Map<String, Object>> keyToLowerCase(List<Map<String, Object>> orgMapList) {
        List<Map<String, Object>> resultList = new ArrayList();
        Iterator var2 = orgMapList.iterator();

        while(var2.hasNext()) {
            Map<String, Object> stringObjectMap = (Map)var2.next();
            resultList.add(this.keyToLowerCase(stringObjectMap));
        }

        return resultList;
    }

    public Map<String, Object> keyToLowerCase(Map<String, Object> orgMap) {
        Map<String, Object> resultMap = new HashMap();
        if (orgMap != null && !orgMap.isEmpty()) {
            Set<Map.Entry<String, Object>> entrySet = orgMap.entrySet();
            Iterator var3 = entrySet.iterator();

            while(var3.hasNext()) {
                Map.Entry<String, Object> entry = (Map.Entry)var3.next();
                String key = (String)entry.getKey();
                Object value = entry.getValue();
                resultMap.put(key.toLowerCase(), value);
            }

            return resultMap;
        } else {
            return resultMap;
        }
    }
}
```
