dsh-total-quality 2.0.55 → 2.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +51 -47
- package/LICENSE.md +37 -37
- package/README.en.md +32 -30
- package/README.md +90 -88
- package/agent-host.cjs +277 -277
- package/client.js +199 -92
- package/cordis.patch.yml +5 -5
- package/docs/enterprise-onboarding.md +10 -10
- package/docs/technical-reference.md +223 -223
- package/host.cjs +91 -124
- package/llm-bridge.cjs +234 -234
- package/locale/en.json +5 -5
- package/locale/zh.json +5 -5
- package/package.json +3 -2
- package/public/app.css +3 -0
- package/public/app.js +6 -2
- package/public/index.html +8 -9
- package/public/js/api.js +152 -152
- package/public/js/assistant-history.js +62 -62
- package/public/js/material-library.js +100 -100
- package/public/js/mobile-preview.js +119 -0
- package/public/js/pages-company-knowledge.js +9 -32
- package/public/js/pages-core.js +232 -232
- package/public/js/pages-growth.js +148 -148
- package/public/js/pages-qms.js +1 -1
- package/public/js/pages-qtools.js +410 -410
- package/public/js/pages-thanks.js +71 -71
- package/public/js/plugin-updates.js +53 -0
- package/public/js/quality-workflow.js +205 -205
- package/public/js/survey-dates.js +41 -41
- package/public/js/survey-knowledge.js +301 -301
- package/public/js/tool-wizards.js +621 -621
- package/public/js/ui.js +467 -467
- package/public/js/voice-capture-worklet.js +30 -30
- package/public/js/xiaozhi-voice.js +264 -264
- package/public/js/xiaozhi.js +468 -468
- package/public/platform-help.html +426 -426
- package/public/platform-site/assets/0468a68574112812.css +10703 -10703
- package/public/platform-site/assets/159e086d35adfa1c.css +2094 -2094
- package/public/platform-site/assets/169e3159cade0d9f.css +98 -98
- package/public/platform-site/assets/22b917c4a3d4ae3d.svg +14 -14
- package/public/platform-site/assets/476f9254ccf723e7.css +8265 -8265
- package/public/platform-site/assets/85a0a4fb4416ded9.css +120 -120
- package/public/platform-site/assets/a3b272383226f6d9.svg +135 -135
- package/public/platform-site/assets/fd16dc5f3cc9d97e.svg +104 -104
- package/public/platform-site/assets/qip-favicon.svg +5 -5
- package/public/platform-site/index.html +279 -279
- package/public/platform-site/offline.js +261 -261
- package/public/platform-site/qip-brand.css +566 -566
- package/public/platform-site/qip-module-guides.js +237 -237
- package/public/responsive.css +103 -101
- package/public/vendor/markdown-it-15.0.3.LICENSE +22 -22
- package/public/vendor/markdown-it-15.0.3.umd.min.js +13 -13
- package/public/workbench.css +7 -7
- package/public/xiaozhi.css +292 -292
- package/resources/qms-templates/019ffb58f24ed48d.docx +0 -0
- package/resources/qms-templates/04a69165fc15143a.docx +0 -0
- package/resources/qms-templates/09af69358c989a63.docx +0 -0
- package/resources/qms-templates/0e7ac77844e45311.docx +0 -0
- package/resources/qms-templates/12446a1b5e173c71.docx +0 -0
- package/resources/qms-templates/15ae40f67f9a3efc.docx +0 -0
- package/resources/qms-templates/18a69bbebf2ece7f.docx +0 -0
- package/resources/qms-templates/1978faa989134f02.docx +0 -0
- package/resources/qms-templates/1a30e121de752f7b.docx +0 -0
- package/resources/qms-templates/1b88907969ea7d4c.docx +0 -0
- package/resources/qms-templates/1e92b808722bf90a.docx +0 -0
- package/resources/qms-templates/2091cad340dc0e7f.docx +0 -0
- package/resources/qms-templates/271ae1002c896ed7.docx +0 -0
- package/resources/qms-templates/280ce53e5d3b5fcf.docx +0 -0
- package/resources/qms-templates/28ca8e4ede0adf6d.docx +0 -0
- package/resources/qms-templates/2ac6675f3cb1f993.docx +0 -0
- package/resources/qms-templates/2c3b799389909d8b.docx +0 -0
- package/resources/qms-templates/2c51038ba2cc3264.docx +0 -0
- package/resources/qms-templates/30c888851d16d764.docx +0 -0
- package/resources/qms-templates/3459fc4daaa2743d.docx +0 -0
- package/resources/qms-templates/3751dafc335e0e80.docx +0 -0
- package/resources/qms-templates/38798cd4298cd2db.docx +0 -0
- package/resources/qms-templates/38f551f9d738ab0a.docx +0 -0
- package/resources/qms-templates/3c85a23ea17018b4.docx +0 -0
- package/resources/qms-templates/3cdb7d14caf1b852.docx +0 -0
- package/resources/qms-templates/3f23239bb6b3e1db.docx +0 -0
- package/resources/qms-templates/42a5b9efeeaa8007.docx +0 -0
- package/resources/qms-templates/47352aafe9b8dac1.docx +0 -0
- package/resources/qms-templates/495359b1e3cbb8fe.docx +0 -0
- package/resources/qms-templates/4ca6920464785166.docx +0 -0
- package/resources/qms-templates/4ce862582a7791be.docx +0 -0
- package/resources/qms-templates/54c9a02a10991b9e.docx +0 -0
- package/resources/qms-templates/5aeb8fddf5f3693f.docx +0 -0
- package/resources/qms-templates/5d7e5576b0e73be7.docx +0 -0
- package/resources/qms-templates/5db3a40edac37791.docx +0 -0
- package/resources/qms-templates/5ffa21eb78eb6f77.docx +0 -0
- package/resources/qms-templates/60d0fbcb709b7161.docx +0 -0
- package/resources/qms-templates/63e1d3a166756095.docx +0 -0
- package/resources/qms-templates/65c724c080d32f10.docx +0 -0
- package/resources/qms-templates/674bd7826c6cbac2.docx +0 -0
- package/resources/qms-templates/677e851acca1b879.docx +0 -0
- package/resources/qms-templates/6bf15feb1a0d2a8d.docx +0 -0
- package/resources/qms-templates/6c3889c7d0918db9.docx +0 -0
- package/resources/qms-templates/6c4c349eeb0a96a8.docx +0 -0
- package/resources/qms-templates/6c5befbd33f759c1.docx +0 -0
- package/resources/qms-templates/6df8367901347508.docx +0 -0
- package/resources/qms-templates/71db51997037692b.docx +0 -0
- package/resources/qms-templates/78a8ef8c76510c99.docx +0 -0
- package/resources/qms-templates/8397bfd1c0a1b013.docx +0 -0
- package/resources/qms-templates/84d750cf858b60a1.docx +0 -0
- package/resources/qms-templates/880de58a4b334533.docx +0 -0
- package/resources/qms-templates/88c37d1b87d9b78c.docx +0 -0
- package/resources/qms-templates/88e9cd42f1849462.docx +0 -0
- package/resources/qms-templates/8956597403be35b6.docx +0 -0
- package/resources/qms-templates/94675c810a233e1f.docx +0 -0
- package/resources/qms-templates/94dff59dd7ebec6e.docx +0 -0
- package/resources/qms-templates/9670b9cd02141594.docx +0 -0
- package/resources/qms-templates/98c373ebd7b5163d.docx +0 -0
- package/resources/qms-templates/a4078cf2378a9388.docx +0 -0
- package/resources/qms-templates/a5b110c7ef917139.docx +0 -0
- package/resources/qms-templates/aec75820e45774be.docx +0 -0
- package/resources/qms-templates/b31c085e281d230c.docx +0 -0
- package/resources/qms-templates/b7c1c3c72f8ffeef.docx +0 -0
- package/resources/qms-templates/b81b82eaa5c8f422.docx +0 -0
- package/resources/qms-templates/b92a2fa31f75f137.docx +0 -0
- package/resources/qms-templates/b96c54ae9cfffc54.docx +0 -0
- package/resources/qms-templates/bc47cfd626c010e7.docx +0 -0
- package/resources/qms-templates/be60792734afca69.docx +0 -0
- package/resources/qms-templates/c0018d8ae9ad19e1.docx +0 -0
- package/resources/qms-templates/c171027c964c8be3.docx +0 -0
- package/resources/qms-templates/c4b93d71f5d98b4b.docx +0 -0
- package/resources/qms-templates/c531da29fcb3090f.docx +0 -0
- package/resources/qms-templates/c88eddd43358d015.docx +0 -0
- package/resources/qms-templates/cb978da542f0d892.docx +0 -0
- package/resources/qms-templates/ccde4a94532a8d36.docx +0 -0
- package/resources/qms-templates/cf3fb1e20ae6f24d.docx +0 -0
- package/resources/qms-templates/d231b4982fc8113e.docx +0 -0
- package/resources/qms-templates/d3c55aa5ed14055c.docx +0 -0
- package/resources/qms-templates/db45c44a00a13349.docx +0 -0
- package/resources/qms-templates/db849a41210f54e0.docx +0 -0
- package/resources/qms-templates/dba9ce363d83ddc8.docx +0 -0
- package/resources/qms-templates/dca3ea4c95eb2225.docx +0 -0
- package/resources/qms-templates/dfa4220d2b6b8131.docx +0 -0
- package/resources/qms-templates/dfa51222c777734f.docx +0 -0
- package/resources/qms-templates/e07ea511507e14f5.docx +0 -0
- package/resources/qms-templates/e0a2e00c03458dfa.docx +0 -0
- package/resources/qms-templates/e0e802f46b6764d1.docx +0 -0
- package/resources/qms-templates/e53fc85717f2852b.docx +0 -0
- package/resources/qms-templates/e9dd82d5e54520e5.docx +0 -0
- package/resources/qms-templates/ea7bfc22c06d82a9.docx +0 -0
- package/resources/qms-templates/ecf0db9f37294536.docx +0 -0
- package/resources/qms-templates/f05fcfc87e82ff39.docx +0 -0
- package/resources/qms-templates/fb9e56a17c4a4f97.docx +0 -0
- package/resources/qms-templates/manifest.json +932 -0
- package/src/data/seed-sme.js +317 -317
- package/src/data/seed.js +879 -879
- package/src/lib/backup-identity.js +57 -57
- package/src/lib/chat-answer.js +225 -225
- package/src/lib/chat-context.js +99 -99
- package/src/lib/company-library.js +28 -19
- package/src/lib/data-import.js +217 -217
- package/src/lib/data-sources.js +118 -118
- package/src/lib/demo-data.js +27 -1
- package/src/lib/employee-intake.js +84 -84
- package/src/lib/growth.js +53 -53
- package/src/lib/intake-packets.js +119 -119
- package/src/lib/issue-intake.js +88 -88
- package/src/lib/kb-revision.js +214 -214
- package/src/lib/llm.js +279 -279
- package/src/lib/model-error.js +14 -14
- package/src/lib/privacy.js +26 -26
- package/src/lib/qms-drafting.js +194 -194
- package/src/lib/qms-jobs.js +11 -7
- package/src/lib/qms-manual-review.js +185 -185
- package/src/lib/qms-procedure-review.js +109 -109
- package/src/lib/qms-templates.js +358 -326
- package/src/lib/qms.js +369 -369
- package/src/lib/quality-priority.js +100 -100
- package/src/lib/quality-state.js +92 -92
- package/src/lib/quality-workflow.js +65 -65
- package/src/lib/retrieval.js +159 -159
- package/src/lib/spc.js +127 -127
- package/src/lib/voice-hotwords.txt +22 -22
- package/src/lib/voice-text.js +13 -13
- package/src/lib/voice-worker.js +72 -72
- package/src/lib/voice.js +330 -330
- package/src/lib/workbench-notices.js +49 -49
- package/src/lib/workbench.js +103 -106
- package/src/package.json +3 -3
- package/src/tools/analysis.js +306 -306
- package/src/tools/data.js +596 -596
- package/src/tools/docs.js +430 -430
- package/src/tools/registry.js +57 -57
- package/tools-dsh.cjs +153 -153
- package//345/256/211/350/243/205/350/257/264/346/230/216.md +33 -25
- package//346/234/254/346/234/272/347/213/254/347/253/213/345/256/211/350/243/205/350/257/264/346/230/216.md +17 -17
- package//350/207/252/346/243/200.cjs +88 -88
- package/public/js/remote-knowledge.js +0 -165
- package/public/js/workbench-notices.js +0 -67
- package/public/remote-knowledge-help.html +0 -35
- package/public/remote-knowledge.css +0 -40
- package/src/lib/remote-knowledge.js +0 -284
|
@@ -1,185 +1,185 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const normalize = (text) => String(text ?? '').normalize('NFKC').replace(/\s+/g,'');
|
|
4
|
-
const singleLine = (text) => String(text ?? '').trim().replace(/[\r\n]+/g,';').replace(/[。;;]+$/,'');
|
|
5
|
-
const qualityTerms = /(?:合格率|不良率|及时率|满意度|通过率|PPM|达成率|交付率|质量损失)/i;
|
|
6
|
-
const attachmentTitle = /^\s*附件\s*([一二三四五六七八九十百\d]+)\s*(?:[、::..))\-]\s*|\s+)(.+?)\s*$/;
|
|
7
|
-
const processRelation = /(?:过程.{0,12}(?:顺序|相互|分类关系|关联)|过程关系|流程(?:顺序|关系))/;
|
|
8
|
-
const dateOnly = /^\s*[\d\s]*年\s*[\d\s]*月\s*[\d\s]*日\s*$/;
|
|
9
|
-
const filledDate = /^\d{4}年\d{1,2}月\d{1,2}日$/;
|
|
10
|
-
const processLabel = /^\s*[CMS]\d+\s*[^;。]{1,25}过程\s*$/;
|
|
11
|
-
const processList = /^\s*[CMS]\d+\s*[^。;]*过程(?:[;;]\s*[CMS]\d+\s*[^。;]*过程)+[。;;\s]*$/;
|
|
12
|
-
const c2Design = /\bC2\s*(?:产品)?设计(?:与|和|及)?开发(?:管理|控制)?过程/g;
|
|
13
|
-
const designLabel = /^\s*(?:产品)?设计(?:与|和|及)?开发(?:管理|控制)?过程\s*$/;
|
|
14
|
-
const processName = '制造过程设计';
|
|
15
|
-
|
|
16
|
-
function hasProcessName(unit) {
|
|
17
|
-
return processLabel.test(unit.text) || processList.test(unit.text) ||
|
|
18
|
-
unit.kind === '表格' && /(?:^|\|)\s*C2\s*\|/.test(unit.context || '') && designLabel.test(unit.text);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function profileText(facts) {
|
|
22
|
-
const summary = [
|
|
23
|
-
facts.company,
|
|
24
|
-
facts.addr && '公司地址为' + singleLine(facts.addr),
|
|
25
|
-
!facts.addr && facts.geo && singleLine(facts.geo),
|
|
26
|
-
facts.products && '质量管理体系覆盖' + singleLine(facts.products),
|
|
27
|
-
facts.area && '占地面积' + singleLine(facts.area) + '平方米',
|
|
28
|
-
facts.building && '建筑面积' + singleLine(facts.building) + '平方米',
|
|
29
|
-
].filter(Boolean);
|
|
30
|
-
const capability = [
|
|
31
|
-
facts.staff && '现有正式员工' + singleLine(facts.staff) + '人',
|
|
32
|
-
facts.techStaff && (facts.staff ? '其中' : '') + '管理技术人员' + singleLine(facts.techStaff) + '人',
|
|
33
|
-
facts.equipment && '主要生产和检验设备包括' + singleLine(facts.equipment),
|
|
34
|
-
].filter(Boolean);
|
|
35
|
-
return [summary,capability].filter(row => row.length).map(row => row.join(',') + '。').join('');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function goalItems(input) {
|
|
39
|
-
return String(input || '').split(/[\r\n;;。]+/).flatMap(section => section.split(
|
|
40
|
-
/[,,、](?=\s*(?!(?:由|按|每|统计|责任|周期|适用))(?:(?:管理评审|内部审核)|[^,,、]{0,21}(?:合格率|不良率|及时率|通过率|满意度|PPM|达成率|交付率|质量损失)\s*(?:[≥≤<>==]|\d)))/i,
|
|
41
|
-
)).map(text => text.trim()).filter(Boolean);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function qualifyTarget(text) {
|
|
45
|
-
const meta = [];
|
|
46
|
-
const cadence = /每(?:批|日|周|月|季|半?年)|(?:日|周|月|季|年度|半年)(?:度|统计|汇总|考核|评审)|按(?:批次|日|周|月|季|半年|年)|(?:年内|年度|季度|月度)\s*[一二三四五六七八九十\d]+\s*次/;
|
|
47
|
-
const ownership = /由[^,。;]{1,40}(?:负责|统计|汇总|复核|跟踪|考核|组织|记录|执行)|(?:责任部门|责任人|负责部门|统计部门|统计人)\s*[::]?\s*\S/;
|
|
48
|
-
if (/管理评审|内部审核/.test(text) && !qualityTerms.test(text)) {
|
|
49
|
-
if (!cadence.test(text)) meta.push('执行周期');
|
|
50
|
-
if (!ownership.test(text)) meta.push('责任部门');
|
|
51
|
-
} else if (qualityTerms.test(text)) {
|
|
52
|
-
const unclear = /^(?:\d+[、..))]\s*)?(?:一次(?:合格率|通过率|通过合格率|交验合格率)|通过合格率)/.test(text);
|
|
53
|
-
if (unclear && !/(?:适用|工序|对象|产品|范围|环节)/.test(text)) meta.push('适用工序或统计对象');
|
|
54
|
-
if (!cadence.test(text)) meta.push('统计周期');
|
|
55
|
-
if (!ownership.test(text)) meta.push('责任部门');
|
|
56
|
-
}
|
|
57
|
-
return meta.length ? text + '(' + meta.join('、') + '待确认)' : text;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function reviewManual(units, edits, facts, {date, certification}) {
|
|
61
|
-
const unresolved = [];
|
|
62
|
-
const textOf = (unit) => edits.get(unit.id) ?? unit.text;
|
|
63
|
-
const set = (unit, value) => {
|
|
64
|
-
if (value === unit.text) edits.delete(unit.id);
|
|
65
|
-
else edits.set(unit.id,value);
|
|
66
|
-
};
|
|
67
|
-
const body = units.filter(unit => unit.direct || (unit.kind === '正文' && unit.direct === undefined));
|
|
68
|
-
const has = (text,value) => Boolean(value) && normalize(text).includes(normalize(value));
|
|
69
|
-
|
|
70
|
-
const profile = body.find(unit => unit.manualRole === 'profile');
|
|
71
|
-
const profileTitle = body.find(unit => unit.manualRole === 'profileTitle');
|
|
72
|
-
if (profileTitle) set(profileTitle,profileTitle.text);
|
|
73
|
-
if (profile) {
|
|
74
|
-
const summary = profileText(facts);
|
|
75
|
-
if (summary) set(profile,summary);
|
|
76
|
-
}
|
|
77
|
-
if (profileTitle && (!profile || !textOf(profile).trim())) unresolved.push('企业概况未写入原章节');
|
|
78
|
-
|
|
79
|
-
const goals = body.filter(unit => unit.manualRole === 'goal');
|
|
80
|
-
const goalsTitle = body.find(unit => unit.manualRole === 'goalsTitle');
|
|
81
|
-
if (goalsTitle) set(goalsTitle,goalsTitle.text);
|
|
82
|
-
if (goals.length) {
|
|
83
|
-
const targets = goalItems(facts.objective).map(qualifyTarget);
|
|
84
|
-
if (!targets.length) {
|
|
85
|
-
targets.push('质量目标、统计口径和责任部门待企业确认。');
|
|
86
|
-
unresolved.push('质量目标未填写');
|
|
87
|
-
}
|
|
88
|
-
goals.forEach((unit,index) => set(unit,index === goals.length-1 ? targets.slice(index).join(';') : (targets[index] || '')));
|
|
89
|
-
if (targets.some(text => text.endsWith('待确认)'))) unresolved.push('质量目标的适用对象、统计周期或责任部门');
|
|
90
|
-
}
|
|
91
|
-
if (goalsTitle && facts.objective && !goals.length) unresolved.push('质量目标尚需核对模板中的填写位置');
|
|
92
|
-
|
|
93
|
-
const quality = !/ISO\s*(?:14001|45001)/i.test(certification || '');
|
|
94
|
-
const excludesProduct = quality && /^(?:无|不承担|不适用|否)$/.test(String(facts.design || '').trim());
|
|
95
|
-
const designDetails = '本公司不承担产品设计和开发,相关产品设计要求不适用。制造过程设计、评审、验证及变更控制仍纳入本体系。';
|
|
96
|
-
const applicability = body.find(unit => /^\s*(?:无删减|无排除|本标准的所有条款均适用|全部条款适用)[。\s]*$/.test(unit.text) ||
|
|
97
|
-
/^(?:\d+(?:\.\d+)*\s*)?(?:适用性(?:说明)?|覆盖的体系要求)[::]/.test(unit.text.trim()));
|
|
98
|
-
if (excludesProduct && applicability) {
|
|
99
|
-
const label = /^\s*((?:\d+(?:\.\d+)*\s*)?(?:适用性(?:说明)?|覆盖的体系要求)[::])/.exec(applicability.text);
|
|
100
|
-
set(applicability,(label?.[1] || '') + designDetails);
|
|
101
|
-
}
|
|
102
|
-
if (quality && !facts.design && applicability) unresolved.push('产品设计责任及体系条款适用性');
|
|
103
|
-
if (excludesProduct) {
|
|
104
|
-
for (const unit of units) {
|
|
105
|
-
const splitLabel = unit.kind === '表格' && /(?:^|\|)\s*C2\s*\|/.test(unit.context || '') &&
|
|
106
|
-
designLabel.test(unit.text);
|
|
107
|
-
const text = hasProcessName(unit) ? unit.text : textOf(unit);
|
|
108
|
-
const next = splitLabel ? processName : text.replace(c2Design,'C2 ' + processName);
|
|
109
|
-
if (next !== textOf(unit)) set(unit,next);
|
|
110
|
-
}
|
|
111
|
-
const start = body.findIndex(unit => /^\s*C2\s*(?:产品)?设计(?:与|和|及)?开发(?:管理|控制)?过程\s*$/.test(unit.text));
|
|
112
|
-
const next = start < 0 ? -1 : body.findIndex((unit,index) => index > start && /^\s*[CMS]\d+\s*[^;;]{1,26}过程\s*$/.test(unit.text));
|
|
113
|
-
const process = start < 0 ? [] : body.slice(start+1,next < 0 ? start+75 : next);
|
|
114
|
-
const description = process.find(unit => /过程定义了.{0,55}(?:工艺设计|过程设计开发).{0,45}管理要求/.test(unit.text));
|
|
115
|
-
if (description) {
|
|
116
|
-
set(description,designDetails + '本过程覆盖工艺分析、工艺设计、评审、验证及适用的工装设计。');
|
|
117
|
-
}
|
|
118
|
-
const owner = process.find(unit => /^\s*过程所有者\s*[::]/.test(unit.text));
|
|
119
|
-
if (owner) {
|
|
120
|
-
const department = (facts.orgs || []).find(row => row.dept && /工艺|工程|技术|研发/.test(row.duty || row.dept));
|
|
121
|
-
const current = textOf(owner);
|
|
122
|
-
if (department) {
|
|
123
|
-
const duty = department.owner ? department.dept + '(' + department.owner + ')' : department.dept + '负责人';
|
|
124
|
-
if (!has(current,department.dept)) set(owner,'过程所有者:' + duty);
|
|
125
|
-
} else if (!(facts.orgs || []).some(row => has(current,row.dept) && has(facts.roles,row.dept))) {
|
|
126
|
-
set(owner,'过程所有者:待确认制造过程设计的责任部门');
|
|
127
|
-
unresolved.push('制造过程设计的责任部门');
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (!applicability && !description) unresolved.push('产品设计不适用的说明未定位到原章节');
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const scope = body.find(unit => /^\s*位于.{0,160}的所有(?:办公|制造现场|生产)/.test(unit.text) ||
|
|
134
|
-
/^\s*(?:体系适用范围|体系覆盖范围)[::]/.test(unit.text));
|
|
135
|
-
if (scope && facts.scope && !has(textOf(scope),facts.scope)) set(scope,'体系适用范围:' + singleLine(facts.scope) + '。');
|
|
136
|
-
|
|
137
|
-
for (const [field,label,pattern] of [
|
|
138
|
-
['externalSupport','外部支持职能',/^\s*(?:无外部支持职能|外部支持职能\s*[::])/],
|
|
139
|
-
['externalSites','外部生产场所',/^\s*(?:无外部生产场所|外部生产场所\s*[::])/],
|
|
140
|
-
['outsourced','外包过程',/^\s*(?:2\.4\s*)?(?:本公司|公司的?)?外包过程(?:为)?\s*[::]/],
|
|
141
|
-
]) {
|
|
142
|
-
const slot = body.find((unit) => pattern.test(unit.text));
|
|
143
|
-
if (!slot) continue;
|
|
144
|
-
const section = /^\s*(\d+(?:\.\d+)*\s*)/.exec(slot.text)?.[1] || '';
|
|
145
|
-
const fact = singleLine(facts[field]);
|
|
146
|
-
set(slot,section + (section && !/\s$/.test(section) ? ' ' : '') + label + ':' + (fact || '待企业确认') + '。');
|
|
147
|
-
if (!fact) unresolved.push(label + '待确认');
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const attachments = body.flatMap(unit => {
|
|
151
|
-
const match = attachmentTitle.exec(unit.text);
|
|
152
|
-
return match ? [{number:match[1],title:match[2].trim(),unit}] : [];
|
|
153
|
-
});
|
|
154
|
-
for (const item of attachments) set(item.unit,item.unit.text);
|
|
155
|
-
const relationAttachment = attachments.find(item => processRelation.test(item.title));
|
|
156
|
-
const relation = body.find(unit => !attachmentTitle.test(unit.text) &&
|
|
157
|
-
/确定过程顺序及相互作用|过程顺序及相互关系|过程顺序及其相互作用/.test(unit.text));
|
|
158
|
-
if (relation) {
|
|
159
|
-
const original = textOf(relation).trim();
|
|
160
|
-
const listPrefix = /^(?:[a-zA-Z][)).、]|[①②③④⑤]|\d+(?:\.\d+)*[、.))])\s*/.exec(original)?.[0] || '';
|
|
161
|
-
const references = [...original.matchAll(/附件\s*([一二三四五六七八九十百\d]+)/g)].map(match => match[1]);
|
|
162
|
-
const title = relationAttachment ? '附件' + relationAttachment.number + '《' + relationAttachment.title.replace(/^《|》$/g,'') + '》' : '';
|
|
163
|
-
const correct = title && normalize(original).includes(normalize(title)) && references.every(number => number === relationAttachment.number);
|
|
164
|
-
let value = correct ? original : listPrefix + '确定质量管理体系各过程的顺序及相互作用' +
|
|
165
|
-
(title ? ',过程分类及相互关系见' + title : '') + '。';
|
|
166
|
-
if (facts.processFlow && !has(value,facts.processFlow)) value = singleLine(value) + '。主要过程:' + singleLine(facts.processFlow) + '。';
|
|
167
|
-
const roles = facts.roles || (facts.orgs || []).filter(row => row.dept && row.duty).map(row => row.dept + '(' + row.duty + ')').join('、');
|
|
168
|
-
if (roles && !has(value,roles)) value = singleLine(value) + '。相关职责与交接:' + singleLine(roles) + '。';
|
|
169
|
-
set(relation,value);
|
|
170
|
-
if (references.length && !relationAttachment) unresolved.push('原模板中的过程关系附件未找到对应标题');
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
for (const unit of body) {
|
|
174
|
-
if (unit.manualRole === 'managerSignature') {
|
|
175
|
-
const original = textOf(unit).trim();
|
|
176
|
-
edits.set(unit.id,facts.gm ? '总经理:' + singleLine(facts.gm) : original);
|
|
177
|
-
}
|
|
178
|
-
if (!dateOnly.test(unit.text)) continue;
|
|
179
|
-
const target = (date || textOf(unit)).replace(/\s+/g,'');
|
|
180
|
-
if (filledDate.test(target)) set(unit,target);
|
|
181
|
-
}
|
|
182
|
-
return unresolved;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
module.exports = { reviewManual, hasProcessName };
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const normalize = (text) => String(text ?? '').normalize('NFKC').replace(/\s+/g,'');
|
|
4
|
+
const singleLine = (text) => String(text ?? '').trim().replace(/[\r\n]+/g,';').replace(/[。;;]+$/,'');
|
|
5
|
+
const qualityTerms = /(?:合格率|不良率|及时率|满意度|通过率|PPM|达成率|交付率|质量损失)/i;
|
|
6
|
+
const attachmentTitle = /^\s*附件\s*([一二三四五六七八九十百\d]+)\s*(?:[、::..))\-]\s*|\s+)(.+?)\s*$/;
|
|
7
|
+
const processRelation = /(?:过程.{0,12}(?:顺序|相互|分类关系|关联)|过程关系|流程(?:顺序|关系))/;
|
|
8
|
+
const dateOnly = /^\s*[\d\s]*年\s*[\d\s]*月\s*[\d\s]*日\s*$/;
|
|
9
|
+
const filledDate = /^\d{4}年\d{1,2}月\d{1,2}日$/;
|
|
10
|
+
const processLabel = /^\s*[CMS]\d+\s*[^;。]{1,25}过程\s*$/;
|
|
11
|
+
const processList = /^\s*[CMS]\d+\s*[^。;]*过程(?:[;;]\s*[CMS]\d+\s*[^。;]*过程)+[。;;\s]*$/;
|
|
12
|
+
const c2Design = /\bC2\s*(?:产品)?设计(?:与|和|及)?开发(?:管理|控制)?过程/g;
|
|
13
|
+
const designLabel = /^\s*(?:产品)?设计(?:与|和|及)?开发(?:管理|控制)?过程\s*$/;
|
|
14
|
+
const processName = '制造过程设计';
|
|
15
|
+
|
|
16
|
+
function hasProcessName(unit) {
|
|
17
|
+
return processLabel.test(unit.text) || processList.test(unit.text) ||
|
|
18
|
+
unit.kind === '表格' && /(?:^|\|)\s*C2\s*\|/.test(unit.context || '') && designLabel.test(unit.text);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function profileText(facts) {
|
|
22
|
+
const summary = [
|
|
23
|
+
facts.company,
|
|
24
|
+
facts.addr && '公司地址为' + singleLine(facts.addr),
|
|
25
|
+
!facts.addr && facts.geo && singleLine(facts.geo),
|
|
26
|
+
facts.products && '质量管理体系覆盖' + singleLine(facts.products),
|
|
27
|
+
facts.area && '占地面积' + singleLine(facts.area) + '平方米',
|
|
28
|
+
facts.building && '建筑面积' + singleLine(facts.building) + '平方米',
|
|
29
|
+
].filter(Boolean);
|
|
30
|
+
const capability = [
|
|
31
|
+
facts.staff && '现有正式员工' + singleLine(facts.staff) + '人',
|
|
32
|
+
facts.techStaff && (facts.staff ? '其中' : '') + '管理技术人员' + singleLine(facts.techStaff) + '人',
|
|
33
|
+
facts.equipment && '主要生产和检验设备包括' + singleLine(facts.equipment),
|
|
34
|
+
].filter(Boolean);
|
|
35
|
+
return [summary,capability].filter(row => row.length).map(row => row.join(',') + '。').join('');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function goalItems(input) {
|
|
39
|
+
return String(input || '').split(/[\r\n;;。]+/).flatMap(section => section.split(
|
|
40
|
+
/[,,、](?=\s*(?!(?:由|按|每|统计|责任|周期|适用))(?:(?:管理评审|内部审核)|[^,,、]{0,21}(?:合格率|不良率|及时率|通过率|满意度|PPM|达成率|交付率|质量损失)\s*(?:[≥≤<>==]|\d)))/i,
|
|
41
|
+
)).map(text => text.trim()).filter(Boolean);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function qualifyTarget(text) {
|
|
45
|
+
const meta = [];
|
|
46
|
+
const cadence = /每(?:批|日|周|月|季|半?年)|(?:日|周|月|季|年度|半年)(?:度|统计|汇总|考核|评审)|按(?:批次|日|周|月|季|半年|年)|(?:年内|年度|季度|月度)\s*[一二三四五六七八九十\d]+\s*次/;
|
|
47
|
+
const ownership = /由[^,。;]{1,40}(?:负责|统计|汇总|复核|跟踪|考核|组织|记录|执行)|(?:责任部门|责任人|负责部门|统计部门|统计人)\s*[::]?\s*\S/;
|
|
48
|
+
if (/管理评审|内部审核/.test(text) && !qualityTerms.test(text)) {
|
|
49
|
+
if (!cadence.test(text)) meta.push('执行周期');
|
|
50
|
+
if (!ownership.test(text)) meta.push('责任部门');
|
|
51
|
+
} else if (qualityTerms.test(text)) {
|
|
52
|
+
const unclear = /^(?:\d+[、..))]\s*)?(?:一次(?:合格率|通过率|通过合格率|交验合格率)|通过合格率)/.test(text);
|
|
53
|
+
if (unclear && !/(?:适用|工序|对象|产品|范围|环节)/.test(text)) meta.push('适用工序或统计对象');
|
|
54
|
+
if (!cadence.test(text)) meta.push('统计周期');
|
|
55
|
+
if (!ownership.test(text)) meta.push('责任部门');
|
|
56
|
+
}
|
|
57
|
+
return meta.length ? text + '(' + meta.join('、') + '待确认)' : text;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function reviewManual(units, edits, facts, {date, certification}) {
|
|
61
|
+
const unresolved = [];
|
|
62
|
+
const textOf = (unit) => edits.get(unit.id) ?? unit.text;
|
|
63
|
+
const set = (unit, value) => {
|
|
64
|
+
if (value === unit.text) edits.delete(unit.id);
|
|
65
|
+
else edits.set(unit.id,value);
|
|
66
|
+
};
|
|
67
|
+
const body = units.filter(unit => unit.direct || (unit.kind === '正文' && unit.direct === undefined));
|
|
68
|
+
const has = (text,value) => Boolean(value) && normalize(text).includes(normalize(value));
|
|
69
|
+
|
|
70
|
+
const profile = body.find(unit => unit.manualRole === 'profile');
|
|
71
|
+
const profileTitle = body.find(unit => unit.manualRole === 'profileTitle');
|
|
72
|
+
if (profileTitle) set(profileTitle,profileTitle.text);
|
|
73
|
+
if (profile) {
|
|
74
|
+
const summary = profileText(facts);
|
|
75
|
+
if (summary) set(profile,summary);
|
|
76
|
+
}
|
|
77
|
+
if (profileTitle && (!profile || !textOf(profile).trim())) unresolved.push('企业概况未写入原章节');
|
|
78
|
+
|
|
79
|
+
const goals = body.filter(unit => unit.manualRole === 'goal');
|
|
80
|
+
const goalsTitle = body.find(unit => unit.manualRole === 'goalsTitle');
|
|
81
|
+
if (goalsTitle) set(goalsTitle,goalsTitle.text);
|
|
82
|
+
if (goals.length) {
|
|
83
|
+
const targets = goalItems(facts.objective).map(qualifyTarget);
|
|
84
|
+
if (!targets.length) {
|
|
85
|
+
targets.push('质量目标、统计口径和责任部门待企业确认。');
|
|
86
|
+
unresolved.push('质量目标未填写');
|
|
87
|
+
}
|
|
88
|
+
goals.forEach((unit,index) => set(unit,index === goals.length-1 ? targets.slice(index).join(';') : (targets[index] || '')));
|
|
89
|
+
if (targets.some(text => text.endsWith('待确认)'))) unresolved.push('质量目标的适用对象、统计周期或责任部门');
|
|
90
|
+
}
|
|
91
|
+
if (goalsTitle && facts.objective && !goals.length) unresolved.push('质量目标尚需核对模板中的填写位置');
|
|
92
|
+
|
|
93
|
+
const quality = !/ISO\s*(?:14001|45001)/i.test(certification || '');
|
|
94
|
+
const excludesProduct = quality && /^(?:无|不承担|不适用|否)$/.test(String(facts.design || '').trim());
|
|
95
|
+
const designDetails = '本公司不承担产品设计和开发,相关产品设计要求不适用。制造过程设计、评审、验证及变更控制仍纳入本体系。';
|
|
96
|
+
const applicability = body.find(unit => /^\s*(?:无删减|无排除|本标准的所有条款均适用|全部条款适用)[。\s]*$/.test(unit.text) ||
|
|
97
|
+
/^(?:\d+(?:\.\d+)*\s*)?(?:适用性(?:说明)?|覆盖的体系要求)[::]/.test(unit.text.trim()));
|
|
98
|
+
if (excludesProduct && applicability) {
|
|
99
|
+
const label = /^\s*((?:\d+(?:\.\d+)*\s*)?(?:适用性(?:说明)?|覆盖的体系要求)[::])/.exec(applicability.text);
|
|
100
|
+
set(applicability,(label?.[1] || '') + designDetails);
|
|
101
|
+
}
|
|
102
|
+
if (quality && !facts.design && applicability) unresolved.push('产品设计责任及体系条款适用性');
|
|
103
|
+
if (excludesProduct) {
|
|
104
|
+
for (const unit of units) {
|
|
105
|
+
const splitLabel = unit.kind === '表格' && /(?:^|\|)\s*C2\s*\|/.test(unit.context || '') &&
|
|
106
|
+
designLabel.test(unit.text);
|
|
107
|
+
const text = hasProcessName(unit) ? unit.text : textOf(unit);
|
|
108
|
+
const next = splitLabel ? processName : text.replace(c2Design,'C2 ' + processName);
|
|
109
|
+
if (next !== textOf(unit)) set(unit,next);
|
|
110
|
+
}
|
|
111
|
+
const start = body.findIndex(unit => /^\s*C2\s*(?:产品)?设计(?:与|和|及)?开发(?:管理|控制)?过程\s*$/.test(unit.text));
|
|
112
|
+
const next = start < 0 ? -1 : body.findIndex((unit,index) => index > start && /^\s*[CMS]\d+\s*[^;;]{1,26}过程\s*$/.test(unit.text));
|
|
113
|
+
const process = start < 0 ? [] : body.slice(start+1,next < 0 ? start+75 : next);
|
|
114
|
+
const description = process.find(unit => /过程定义了.{0,55}(?:工艺设计|过程设计开发).{0,45}管理要求/.test(unit.text));
|
|
115
|
+
if (description) {
|
|
116
|
+
set(description,designDetails + '本过程覆盖工艺分析、工艺设计、评审、验证及适用的工装设计。');
|
|
117
|
+
}
|
|
118
|
+
const owner = process.find(unit => /^\s*过程所有者\s*[::]/.test(unit.text));
|
|
119
|
+
if (owner) {
|
|
120
|
+
const department = (facts.orgs || []).find(row => row.dept && /工艺|工程|技术|研发/.test(row.duty || row.dept));
|
|
121
|
+
const current = textOf(owner);
|
|
122
|
+
if (department) {
|
|
123
|
+
const duty = department.owner ? department.dept + '(' + department.owner + ')' : department.dept + '负责人';
|
|
124
|
+
if (!has(current,department.dept)) set(owner,'过程所有者:' + duty);
|
|
125
|
+
} else if (!(facts.orgs || []).some(row => has(current,row.dept) && has(facts.roles,row.dept))) {
|
|
126
|
+
set(owner,'过程所有者:待确认制造过程设计的责任部门');
|
|
127
|
+
unresolved.push('制造过程设计的责任部门');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (!applicability && !description) unresolved.push('产品设计不适用的说明未定位到原章节');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const scope = body.find(unit => /^\s*位于.{0,160}的所有(?:办公|制造现场|生产)/.test(unit.text) ||
|
|
134
|
+
/^\s*(?:体系适用范围|体系覆盖范围)[::]/.test(unit.text));
|
|
135
|
+
if (scope && facts.scope && !has(textOf(scope),facts.scope)) set(scope,'体系适用范围:' + singleLine(facts.scope) + '。');
|
|
136
|
+
|
|
137
|
+
for (const [field,label,pattern] of [
|
|
138
|
+
['externalSupport','外部支持职能',/^\s*(?:无外部支持职能|外部支持职能\s*[::])/],
|
|
139
|
+
['externalSites','外部生产场所',/^\s*(?:无外部生产场所|外部生产场所\s*[::])/],
|
|
140
|
+
['outsourced','外包过程',/^\s*(?:2\.4\s*)?(?:本公司|公司的?)?外包过程(?:为)?\s*[::]/],
|
|
141
|
+
]) {
|
|
142
|
+
const slot = body.find((unit) => pattern.test(unit.text));
|
|
143
|
+
if (!slot) continue;
|
|
144
|
+
const section = /^\s*(\d+(?:\.\d+)*\s*)/.exec(slot.text)?.[1] || '';
|
|
145
|
+
const fact = singleLine(facts[field]);
|
|
146
|
+
set(slot,section + (section && !/\s$/.test(section) ? ' ' : '') + label + ':' + (fact || '待企业确认') + '。');
|
|
147
|
+
if (!fact) unresolved.push(label + '待确认');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const attachments = body.flatMap(unit => {
|
|
151
|
+
const match = attachmentTitle.exec(unit.text);
|
|
152
|
+
return match ? [{number:match[1],title:match[2].trim(),unit}] : [];
|
|
153
|
+
});
|
|
154
|
+
for (const item of attachments) set(item.unit,item.unit.text);
|
|
155
|
+
const relationAttachment = attachments.find(item => processRelation.test(item.title));
|
|
156
|
+
const relation = body.find(unit => !attachmentTitle.test(unit.text) &&
|
|
157
|
+
/确定过程顺序及相互作用|过程顺序及相互关系|过程顺序及其相互作用/.test(unit.text));
|
|
158
|
+
if (relation) {
|
|
159
|
+
const original = textOf(relation).trim();
|
|
160
|
+
const listPrefix = /^(?:[a-zA-Z][)).、]|[①②③④⑤]|\d+(?:\.\d+)*[、.))])\s*/.exec(original)?.[0] || '';
|
|
161
|
+
const references = [...original.matchAll(/附件\s*([一二三四五六七八九十百\d]+)/g)].map(match => match[1]);
|
|
162
|
+
const title = relationAttachment ? '附件' + relationAttachment.number + '《' + relationAttachment.title.replace(/^《|》$/g,'') + '》' : '';
|
|
163
|
+
const correct = title && normalize(original).includes(normalize(title)) && references.every(number => number === relationAttachment.number);
|
|
164
|
+
let value = correct ? original : listPrefix + '确定质量管理体系各过程的顺序及相互作用' +
|
|
165
|
+
(title ? ',过程分类及相互关系见' + title : '') + '。';
|
|
166
|
+
if (facts.processFlow && !has(value,facts.processFlow)) value = singleLine(value) + '。主要过程:' + singleLine(facts.processFlow) + '。';
|
|
167
|
+
const roles = facts.roles || (facts.orgs || []).filter(row => row.dept && row.duty).map(row => row.dept + '(' + row.duty + ')').join('、');
|
|
168
|
+
if (roles && !has(value,roles)) value = singleLine(value) + '。相关职责与交接:' + singleLine(roles) + '。';
|
|
169
|
+
set(relation,value);
|
|
170
|
+
if (references.length && !relationAttachment) unresolved.push('原模板中的过程关系附件未找到对应标题');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
for (const unit of body) {
|
|
174
|
+
if (unit.manualRole === 'managerSignature') {
|
|
175
|
+
const original = textOf(unit).trim();
|
|
176
|
+
edits.set(unit.id,facts.gm ? '总经理:' + singleLine(facts.gm) : original);
|
|
177
|
+
}
|
|
178
|
+
if (!dateOnly.test(unit.text)) continue;
|
|
179
|
+
const target = (date || textOf(unit)).replace(/\s+/g,'');
|
|
180
|
+
if (filledDate.test(target)) set(unit,target);
|
|
181
|
+
}
|
|
182
|
+
return unresolved;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
module.exports = { reviewManual, hasProcessName };
|
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function line(value) { return String(value || '').trim().replace(/[\r\n]+/g,';').replace(/[。;;]+$/,''); }
|
|
4
|
-
function contains(text,value) { return text.replace(/\s+/g,'').includes(value.replace(/\s+/g,'')); }
|
|
5
|
-
const bareTitle = (title) => title.replace(/^(?:AAA|BBB|CCC|DDD)[--_\s]+/i,'').trim();
|
|
6
|
-
function referenceKey(title) {
|
|
7
|
-
return bareTitle(title).normalize('NFKC').replace(/\s+/g,'').replace(/[与及]/g,'和')
|
|
8
|
-
.replace(/^产品质量先期策划控制程序$/,'产品实现策划控制程序');
|
|
9
|
-
}
|
|
10
|
-
function procedureReferences(text) {
|
|
11
|
-
return [...text.matchAll(/《([^《》\r\n]{2,65}程序)》/g)].map(match => match[1]);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function supportingReferences(text) {
|
|
15
|
-
return [...text.matchAll(/[《“]([^《》“”\r\n]{2,48}(?:程序|管理办法|实施办法|作业指导书|记录单|表))[》”]/g)]
|
|
16
|
-
.map(match=>match[1]);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function safeguardRisk(text, facts) {
|
|
20
|
-
const evidence = [facts.risks,facts.controls,facts.documents].filter(Boolean).join('\n');
|
|
21
|
-
if (/量具校准台账|过程能力记录/.test(text) && /尚待补充|尚不齐全|缺少|未建立/.test(text) &&
|
|
22
|
-
!/(?:当前|目前|尚未)[^。;\n]{0,25}(?:量具校准台账|过程能力记录)[^。;\n]{0,18}(?:不齐全|尚未建立|缺失)|(?:缺少|尚未建立)[^。;\n]{0,8}(?:量具校准台账|过程能力记录)/.test(evidence)) {
|
|
23
|
-
const plan=/试行后[^。;\n]{0,35}(?:量具校准台账|过程能力记录)/.test(evidence)
|
|
24
|
-
? '调研计划在试行后补充相关记录,' : '';
|
|
25
|
-
return text.replace(/部分记录(?:如|,如)?\s*(?:量具校准台账与过程能力记录|量具校准台账及过程能力记录)\s*(?:尚待补充完善|尚不齐全|缺少|未建立)/,
|
|
26
|
-
plan+'量具校准台账与过程能力记录的完整性待企业确认');
|
|
27
|
-
}
|
|
28
|
-
if (/质量管理体系尚在建立与试行阶段/.test(text) && !/试行阶段|体系.{0,5}建立中/.test(evidence)) {
|
|
29
|
-
return text.replace(/质量管理体系尚在建立与试行阶段[,,]管理经验有待积累/, '质量管理体系的运行阶段和运行记录待企业确认');
|
|
30
|
-
}
|
|
31
|
-
return text;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function reviewProcedure(units, edits, facts, document) {
|
|
35
|
-
const {title = '', relatedProcedures = []} = document;
|
|
36
|
-
const body = units.filter((unit) => unit.direct);
|
|
37
|
-
const chart = units.filter((unit) => unit.flowChart);
|
|
38
|
-
const pending = [];
|
|
39
|
-
const text = (unit) => edits.get(unit.id) ?? unit.text;
|
|
40
|
-
const set = (unit,value) => value === unit.text ? edits.delete(unit.id) : edits.set(unit.id,value);
|
|
41
|
-
if (/风险和机遇|组织环境/.test(title)) {
|
|
42
|
-
for (const unit of body) {
|
|
43
|
-
const before=text(unit), after=safeguardRisk(before,facts);
|
|
44
|
-
if (after!==before) {
|
|
45
|
-
set(unit,after);
|
|
46
|
-
pending.push('体系运行阶段、校准台账及过程能力记录按实际情况核实');
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (/产品防护|生产过程|检验和试验|产品标识|标识和可追溯|不合格品|交付与服务/.test(title) && facts.products) {
|
|
51
|
-
const scope = body.find((unit) => /^\s*(?:(?:[一二三四五]+[、.]|\d+(?:\.\d+)*[.、\s]?)\s*)?(?:适用)?范围(?:\s*[::]|[\s ]*$)/.test(unit.text));
|
|
52
|
-
if (scope) {
|
|
53
|
-
const paragraph = /\S.{0,10}[::]\s*\S/.test(text(scope)) ? scope : body[body.indexOf(scope)+1];
|
|
54
|
-
if (paragraph && !contains(text(paragraph),facts.products)) {
|
|
55
|
-
set(paragraph,line(text(paragraph)) + '。本程序适用的企业产品包括' + line(facts.products) + '。');
|
|
56
|
-
}
|
|
57
|
-
} else if (!body.some((unit) => contains(text(unit),facts.products))) pending.push('适用产品请结合已保存的调研核对');
|
|
58
|
-
}
|
|
59
|
-
if (/产品防护|产品包装/.test(title)) {
|
|
60
|
-
const controls = String(facts.processFlow || '').split(/→|->|⇒|;|\r?\n/).map(line)
|
|
61
|
-
.filter((step) => /防护|防锈|封存|包装|交付|发货|运输|贮存|仓储/.test(step));
|
|
62
|
-
const paragraph = body.find((unit) => /产品包装时|产品应在包装|产品贮存要做好|包装过程/.test(unit.text));
|
|
63
|
-
if (controls.length && paragraph) {
|
|
64
|
-
const missing = controls.filter((step) => !body.some((unit) => contains(text(unit),step)));
|
|
65
|
-
if (missing.length) set(paragraph,line(text(paragraph))+'。本企业经调研确认的防护和交付工序包括:'+missing.join('、')+'。');
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (/生产过程控制程序/.test(title) && facts.processFlow) {
|
|
69
|
-
const steps = String(facts.processFlow).split(/→|->|⇒|;|\r?\n/).map(line).filter(Boolean);
|
|
70
|
-
const chartText = chart.map(text).join(' ');
|
|
71
|
-
const valid = (source) => steps.every(step => contains(source,step));
|
|
72
|
-
const details = body.find(unit => /根据.{0,30}评审.{0,12}订单.{0,15}制定.{0,12}生产计划/.test(unit.text));
|
|
73
|
-
if (steps.length >= 2 && !body.some(unit => valid(text(unit)))) {
|
|
74
|
-
if (details) {
|
|
75
|
-
const content=line(text(details));
|
|
76
|
-
set(details,content+(/[::]$/.test(content)?'':'。')+'本企业调研确认的生产顺序为:'+steps.join(' → ')+'。');
|
|
77
|
-
}
|
|
78
|
-
else pending.push('请核对正文所述生产步骤是否覆盖调研工序');
|
|
79
|
-
}
|
|
80
|
-
if (chart.length && !valid(chartText)) pending.push('流程图保留模板的判断与回退关系,请与正文的实际工序核对后发放');
|
|
81
|
-
}
|
|
82
|
-
if (/检验和试验/.test(title) && !/委托.{0,18}(?:产品|样品).{0,12}(?:检测|检验|试验)|外包.{0,12}(?:产品|样品).{0,12}(?:检测|检验|试验)/.test(facts.outsourced || '')) {
|
|
83
|
-
const paragraph = body.find((unit) => /公司无法检[测验].{0,45}(?:委托|供方)/.test(unit.text));
|
|
84
|
-
if (paragraph) {
|
|
85
|
-
const prefix = /^\s*\d+(?:\.\d+)*[.、\s]*/.exec(paragraph.text)?.[0] || '';
|
|
86
|
-
const none = /^(?:无|没有|不外包)$/.test(line(facts.outsourced));
|
|
87
|
-
set(paragraph,prefix + (none ? '本企业当前无外包过程。新增委托前须确认委托范围、机构资质和所需报告。'
|
|
88
|
-
: '企业内部无法完成的检验和试验项目,实施前须确认委托范围、机构资质和所需报告。具体委托情况待企业确认。'));
|
|
89
|
-
if (!none) pending.push('外部检验或试验的委托情况待确认');
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (relatedProcedures.length) {
|
|
93
|
-
const known = new Set(relatedProcedures.map(referenceKey));
|
|
94
|
-
const unknown = new Set();
|
|
95
|
-
for (const unit of units) {
|
|
96
|
-
const original = text(unit);
|
|
97
|
-
if (!unit.flowChart) {
|
|
98
|
-
const corrected = original.replace(/《([^《》\r\n]{2,65}程序)》\s*待确认[((]模板引用[,,][^))]{1,65}[))]/g,
|
|
99
|
-
(match,name) => known.has(referenceKey(name)) ? '《'+name+'》' : match);
|
|
100
|
-
if (corrected!==original) set(unit,corrected);
|
|
101
|
-
}
|
|
102
|
-
for (const name of procedureReferences(text(unit))) if (!known.has(referenceKey(name))) unknown.add(name);
|
|
103
|
-
}
|
|
104
|
-
if (unknown.size) pending.push('请核对关联企业文件是否适用:'+[...unknown].join('、'));
|
|
105
|
-
}
|
|
106
|
-
return [...new Set(pending)];
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
module.exports = {reviewProcedure, bareTitle, procedureReferences, supportingReferences, referenceKey};
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function line(value) { return String(value || '').trim().replace(/[\r\n]+/g,';').replace(/[。;;]+$/,''); }
|
|
4
|
+
function contains(text,value) { return text.replace(/\s+/g,'').includes(value.replace(/\s+/g,'')); }
|
|
5
|
+
const bareTitle = (title) => title.replace(/^(?:AAA|BBB|CCC|DDD)[--_\s]+/i,'').trim();
|
|
6
|
+
function referenceKey(title) {
|
|
7
|
+
return bareTitle(title).normalize('NFKC').replace(/\s+/g,'').replace(/[与及]/g,'和')
|
|
8
|
+
.replace(/^产品质量先期策划控制程序$/,'产品实现策划控制程序');
|
|
9
|
+
}
|
|
10
|
+
function procedureReferences(text) {
|
|
11
|
+
return [...text.matchAll(/《([^《》\r\n]{2,65}程序)》/g)].map(match => match[1]);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function supportingReferences(text) {
|
|
15
|
+
return [...text.matchAll(/[《“]([^《》“”\r\n]{2,48}(?:程序|管理办法|实施办法|作业指导书|记录单|表))[》”]/g)]
|
|
16
|
+
.map(match=>match[1]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function safeguardRisk(text, facts) {
|
|
20
|
+
const evidence = [facts.risks,facts.controls,facts.documents].filter(Boolean).join('\n');
|
|
21
|
+
if (/量具校准台账|过程能力记录/.test(text) && /尚待补充|尚不齐全|缺少|未建立/.test(text) &&
|
|
22
|
+
!/(?:当前|目前|尚未)[^。;\n]{0,25}(?:量具校准台账|过程能力记录)[^。;\n]{0,18}(?:不齐全|尚未建立|缺失)|(?:缺少|尚未建立)[^。;\n]{0,8}(?:量具校准台账|过程能力记录)/.test(evidence)) {
|
|
23
|
+
const plan=/试行后[^。;\n]{0,35}(?:量具校准台账|过程能力记录)/.test(evidence)
|
|
24
|
+
? '调研计划在试行后补充相关记录,' : '';
|
|
25
|
+
return text.replace(/部分记录(?:如|,如)?\s*(?:量具校准台账与过程能力记录|量具校准台账及过程能力记录)\s*(?:尚待补充完善|尚不齐全|缺少|未建立)/,
|
|
26
|
+
plan+'量具校准台账与过程能力记录的完整性待企业确认');
|
|
27
|
+
}
|
|
28
|
+
if (/质量管理体系尚在建立与试行阶段/.test(text) && !/试行阶段|体系.{0,5}建立中/.test(evidence)) {
|
|
29
|
+
return text.replace(/质量管理体系尚在建立与试行阶段[,,]管理经验有待积累/, '质量管理体系的运行阶段和运行记录待企业确认');
|
|
30
|
+
}
|
|
31
|
+
return text;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function reviewProcedure(units, edits, facts, document) {
|
|
35
|
+
const {title = '', relatedProcedures = []} = document;
|
|
36
|
+
const body = units.filter((unit) => unit.direct);
|
|
37
|
+
const chart = units.filter((unit) => unit.flowChart);
|
|
38
|
+
const pending = [];
|
|
39
|
+
const text = (unit) => edits.get(unit.id) ?? unit.text;
|
|
40
|
+
const set = (unit,value) => value === unit.text ? edits.delete(unit.id) : edits.set(unit.id,value);
|
|
41
|
+
if (/风险和机遇|组织环境/.test(title)) {
|
|
42
|
+
for (const unit of body) {
|
|
43
|
+
const before=text(unit), after=safeguardRisk(before,facts);
|
|
44
|
+
if (after!==before) {
|
|
45
|
+
set(unit,after);
|
|
46
|
+
pending.push('体系运行阶段、校准台账及过程能力记录按实际情况核实');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (/产品防护|生产过程|检验和试验|产品标识|标识和可追溯|不合格品|交付与服务/.test(title) && facts.products) {
|
|
51
|
+
const scope = body.find((unit) => /^\s*(?:(?:[一二三四五]+[、.]|\d+(?:\.\d+)*[.、\s]?)\s*)?(?:适用)?范围(?:\s*[::]|[\s ]*$)/.test(unit.text));
|
|
52
|
+
if (scope) {
|
|
53
|
+
const paragraph = /\S.{0,10}[::]\s*\S/.test(text(scope)) ? scope : body[body.indexOf(scope)+1];
|
|
54
|
+
if (paragraph && !contains(text(paragraph),facts.products)) {
|
|
55
|
+
set(paragraph,line(text(paragraph)) + '。本程序适用的企业产品包括' + line(facts.products) + '。');
|
|
56
|
+
}
|
|
57
|
+
} else if (!body.some((unit) => contains(text(unit),facts.products))) pending.push('适用产品请结合已保存的调研核对');
|
|
58
|
+
}
|
|
59
|
+
if (/产品防护|产品包装/.test(title)) {
|
|
60
|
+
const controls = String(facts.processFlow || '').split(/→|->|⇒|;|\r?\n/).map(line)
|
|
61
|
+
.filter((step) => /防护|防锈|封存|包装|交付|发货|运输|贮存|仓储/.test(step));
|
|
62
|
+
const paragraph = body.find((unit) => /产品包装时|产品应在包装|产品贮存要做好|包装过程/.test(unit.text));
|
|
63
|
+
if (controls.length && paragraph) {
|
|
64
|
+
const missing = controls.filter((step) => !body.some((unit) => contains(text(unit),step)));
|
|
65
|
+
if (missing.length) set(paragraph,line(text(paragraph))+'。本企业经调研确认的防护和交付工序包括:'+missing.join('、')+'。');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (/生产过程控制程序/.test(title) && facts.processFlow) {
|
|
69
|
+
const steps = String(facts.processFlow).split(/→|->|⇒|;|\r?\n/).map(line).filter(Boolean);
|
|
70
|
+
const chartText = chart.map(text).join(' ');
|
|
71
|
+
const valid = (source) => steps.every(step => contains(source,step));
|
|
72
|
+
const details = body.find(unit => /根据.{0,30}评审.{0,12}订单.{0,15}制定.{0,12}生产计划/.test(unit.text));
|
|
73
|
+
if (steps.length >= 2 && !body.some(unit => valid(text(unit)))) {
|
|
74
|
+
if (details) {
|
|
75
|
+
const content=line(text(details));
|
|
76
|
+
set(details,content+(/[::]$/.test(content)?'':'。')+'本企业调研确认的生产顺序为:'+steps.join(' → ')+'。');
|
|
77
|
+
}
|
|
78
|
+
else pending.push('请核对正文所述生产步骤是否覆盖调研工序');
|
|
79
|
+
}
|
|
80
|
+
if (chart.length && !valid(chartText)) pending.push('流程图保留模板的判断与回退关系,请与正文的实际工序核对后发放');
|
|
81
|
+
}
|
|
82
|
+
if (/检验和试验/.test(title) && !/委托.{0,18}(?:产品|样品).{0,12}(?:检测|检验|试验)|外包.{0,12}(?:产品|样品).{0,12}(?:检测|检验|试验)/.test(facts.outsourced || '')) {
|
|
83
|
+
const paragraph = body.find((unit) => /公司无法检[测验].{0,45}(?:委托|供方)/.test(unit.text));
|
|
84
|
+
if (paragraph) {
|
|
85
|
+
const prefix = /^\s*\d+(?:\.\d+)*[.、\s]*/.exec(paragraph.text)?.[0] || '';
|
|
86
|
+
const none = /^(?:无|没有|不外包)$/.test(line(facts.outsourced));
|
|
87
|
+
set(paragraph,prefix + (none ? '本企业当前无外包过程。新增委托前须确认委托范围、机构资质和所需报告。'
|
|
88
|
+
: '企业内部无法完成的检验和试验项目,实施前须确认委托范围、机构资质和所需报告。具体委托情况待企业确认。'));
|
|
89
|
+
if (!none) pending.push('外部检验或试验的委托情况待确认');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (relatedProcedures.length) {
|
|
93
|
+
const known = new Set(relatedProcedures.map(referenceKey));
|
|
94
|
+
const unknown = new Set();
|
|
95
|
+
for (const unit of units) {
|
|
96
|
+
const original = text(unit);
|
|
97
|
+
if (!unit.flowChart) {
|
|
98
|
+
const corrected = original.replace(/《([^《》\r\n]{2,65}程序)》\s*待确认[((]模板引用[,,][^))]{1,65}[))]/g,
|
|
99
|
+
(match,name) => known.has(referenceKey(name)) ? '《'+name+'》' : match);
|
|
100
|
+
if (corrected!==original) set(unit,corrected);
|
|
101
|
+
}
|
|
102
|
+
for (const name of procedureReferences(text(unit))) if (!known.has(referenceKey(name))) unknown.add(name);
|
|
103
|
+
}
|
|
104
|
+
if (unknown.size) pending.push('请核对关联企业文件是否适用:'+[...unknown].join('、'));
|
|
105
|
+
}
|
|
106
|
+
return [...new Set(pending)];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
module.exports = {reviewProcedure, bareTitle, procedureReferences, supportingReferences, referenceKey};
|