- scripts/expand_keywords.js: 扩展 15 品类关键词至 27 个,匹配 58 条 - scripts/assign_remaining.js: 10 条剩余线索合理分配 (消毒剂→涂料, 重水→仪表, 光伏支架→钢材等) - scripts/CATEGORY_CLEANUP.md: AdminPage 品类清理建议 (保留核心 15 + 7 个扩展, 合并/删除 24 个 AI 新建细分类) 最终状态: 761 条线索 100% 已分配品类, 42 个品类 (15 主类目 + 27 扩展/AI 新建)
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
const { PrismaClient } = require('@prisma/client')
|
|
const prisma = new PrismaClient()
|
|
|
|
const ASSIGNMENTS = [
|
|
{ keyword: '消毒剂', category: '涂料' },
|
|
{ keyword: '重水供应', category: '仪表' },
|
|
{ keyword: '拦污网', category: '杂品' },
|
|
{ keyword: '110kV变电站施工材料', category: '电线电缆' },
|
|
{ keyword: '线路金具', category: '电线电缆' },
|
|
{ keyword: '弱电材料', category: '电线电缆' },
|
|
{ keyword: '弱电智能化', category: '电线电缆' },
|
|
{ keyword: '引气剂', category: '涂料' },
|
|
{ keyword: '光伏支架', category: '钢材' },
|
|
{ keyword: '淋浴隔断', category: '杂品' },
|
|
]
|
|
|
|
async function main() {
|
|
const emptyLeads = await prisma.lead.findMany({
|
|
where: { OR: [{ category: null }, { category: '' }] },
|
|
select: { id: true, title: true },
|
|
})
|
|
console.log(`剩余空品类线索: ${emptyLeads.length} 条`)
|
|
|
|
let assigned = 0
|
|
for (const lead of emptyLeads) {
|
|
for (const a of ASSIGNMENTS) {
|
|
if (lead.title.includes(a.keyword)) {
|
|
await prisma.lead.update({ where: { id: lead.id }, data: { category: a.category } })
|
|
assigned++
|
|
console.log(`✓ ${lead.title.slice(0, 60)} → ${a.category}`)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
const stillEmpty = await prisma.lead.count({
|
|
where: { OR: [{ category: null }, { category: '' }] },
|
|
})
|
|
console.log(`\n已分配: ${assigned}, 剩余空品类: ${stillEmpty}`)
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e)
|
|
process.exit(1)
|
|
})
|
|
.finally(() => prisma.$disconnect())
|