# 决策链批量导入

## 方法：飞书项目 Excel 导出

飞书项目中有决策链的客户可以直接导出为 Excel，解析后批量写入 JSON。

### 导出步骤

1. 飞书项目 → 客户视图 → 筛选「决策链URL链接」不为空
2. 导出为 Excel（`.xlsx`）
3. 用 `read_file` 读取文件（Hermes 自动提取为制表符分隔文本）
4. Python 解析：每行按 `\t` 分割 → `[0]=客户名, [2]=决策链URL`
5. 更新 `_key_customers.json` 和 `customer_360.json`

### 解析代码

```python
mapping = {}
for line in text.split('\n'):
    parts = line.split('\t')
    if len(parts) >= 3:
        name = parts[0].strip()
        url = parts[2].strip()
        if name and 'i16l6v9noru.feishu.cn' in url:
            mapping[name] = url

# 更新两个数据文件
for fp in ['_key_customers.json', 'customer_360.json']:
    data = json.load(open(fp))
    items = data if isinstance(data, list) else data.get('customers', [])
    for c in items:
        if c.get('name') in mapping:
            c['decision_url'] = mapping[c['name']]
    json.dump(data, open(fp, 'w'), ensure_ascii=False, indent=2)
```

### 部署

```bash
tcb hosting deploy 数据/pricing/_key_customers.json 数据/pricing/_key_customers.json -e bier-sales-d0gatbvlx288724e9
tcb hosting deploy 数据/customer_360.json /数据/customer_360.json -e bier-sales-d0gatbvlx288724e9
```

## MCP 查询备选方案

Excel 导出更快更全，MCP 逐个查询仅作补充：

```python
MQL = f'SELECT `客户名称`, `决策链URL链接` FROM `销售管理`.`客户` WHERE `客户名称` LIKE "%{name}%" LIMIT 1'
```
