feat: add category order rules and read-only sent mail history

This commit is contained in:
abaishu0730 committed 2026-10-19 10:36:32 +08:00
1 parent 388805a8a6
commit efa982a8a1
41 files changed
+1828 -28

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
'use strict';
// Fixed field boundaries keep extraction deterministic; raw title stays on the event.
const retained=new Set(['订单号','机芯号','产品型号','客户简称','总数量','订单类别']);
function extractTitle(title){
const raw=typeof title==='string'?title:'';
const text=raw.replace(/<br\s*\/?\s*>/gi,'\n').replace(/&nbsp;|&#160;|&#x20;/gi,' ');
const matches=[...text.matchAll(/(客户等级|毛利|订单号|机芯号|产品型号|客户简称|总数量|订单类别|订单类型|业务模式)\s*[::]/gu)];
const orders=[],factoryHints=[],issues=[];let current=null;
for(let i=0;i<matches.length;i++){
const match=matches[i],label=match[1],value=text.slice(match.index+match[0].length,matches[i+1]?.index??text.length).trim();
if(['业务模式','客户简称'].includes(label)&&value.includes('惠州'))factoryHints.push({source:label,value,status:'待核实额外通知'});
if(label==='订单号'){
current={orderNo:value,text:''};orders.push(current);
if(!value)issues.push('标题中的订单号为空,不能遗漏该订单段落');
}
if(current&&retained.has(label))current.text+=`${label}:${value}`;
}
if(!orders.length)issues.push('标题中没有可识别的“订单号:”段落');
return {rawTitle:raw,orders,brief:orders.map(order=>order.text).join('\n'),factoryHints,issues};
}
module.exports={extractTitle};