feat: freeze and recover independent Huizhou notifications

This commit is contained in:
abaishu0730 committed 2026-10-21 15:18:20 +08:00
1 parent d903252807
commit d8aa14d855
14 files changed
+294 -48

No files matched your search

+14 -2
View File
@@ -7,7 +7,7 @@ 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;
const orders=[],factoryHints=[],issues=[];let current=null,pendingMode=null,pendingAmbiguous=false;
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:'待核实额外通知'});
@@ -15,9 +15,21 @@ function extractTitle(title){
// Unknown labels and pipe-separated titles still delimit the identifier.
// Keep their original content in the notification paragraph below.
const identifier=/^([A-Za-z0-9][A-Za-z0-9._/-]*)(?=$|\s|[\p{Script=Han}|,,;;])/u.exec(value)?.[1]||value;
current={orderNo:identifier,text:''};orders.push(current);
current={orderNo:identifier,text:''};if(pendingMode){current.businessMode=pendingMode;if(pendingAmbiguous)current.businessModeAmbiguous=true;pendingMode=null;pendingAmbiguous=false;}orders.push(current);
if(!value)issues.push('标题中的订单号为空,不能遗漏该订单段落');
}
if(label==='业务模式'){
const nextOrder=matches.findIndex((m,index)=>index>i&&m[1]==='订单号');
const between=nextOrder<0?[]:matches.slice(i+1,nextOrder).map(m=>m[1]);
// BPM starts the next paragraph with business mode + margin before its order number.
// Ordinary summary text remains byte-for-byte compatible with the existing extractor.
const startsParagraph=/[\n|]\s*$/.test(text.slice(0,match.index));
if(!current||nextOrder>=0&&(between.includes('毛利')||startsParagraph)){
if(pendingMode&&pendingMode!==value)pendingAmbiguous=true;
pendingMode=value;
}
else if(current){if(current.businessMode&&current.businessMode!==value)current.businessModeAmbiguous=true;current.businessMode=value;}
}
if(current&&retained.has(label)){current.text+=`${label}:${value}`;if(summaryKeys[label])current[summaryKeys[label]]=value;}
}
if(!orders.length)issues.push('标题中没有可识别的“订单号:”段落');