dsh-total-quality 2.0.56 → 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/README.en.md +2 -2
- package/README.md +3 -3
- package/host.cjs +32 -24
- package/package.json +3 -2
- package/public/js/pages-company-knowledge.js +8 -31
- package/public/js/pages-qms.js +1 -1
- 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/lib/company-library.js +28 -19
- package/src/lib/qms-jobs.js +11 -7
- package/src/lib/qms-templates.js +42 -10
- package//345/256/211/350/243/205/350/257/264/346/230/216.md +2 -2
|
@@ -14,7 +14,9 @@ const expertScope = (slug) => 'expert:' + slug;
|
|
|
14
14
|
const versionColumns = ['documentNumber', 'revision', 'effectiveFrom', 'product', 'process', 'supersedes', 'revisionState'];
|
|
15
15
|
const fileFields = 'id,folderId,name,size,sha,createdAt,indexStatus,chunkCount,legacyOriginal,' + versionColumns.join(',');
|
|
16
16
|
const today = () => new Date().toLocaleDateString('en-CA');
|
|
17
|
-
const
|
|
17
|
+
const companyVisible = `NOT (d.legacyOriginal=1 AND d.legacySource<>'' AND d.revisionState='uncontrolled'
|
|
18
|
+
AND d.sha IN (SELECT sha FROM hidden_platform_templates))`;
|
|
19
|
+
const effective = `(d.purgedAt='' AND ${companyVisible} AND ((d.revisionState='uncontrolled' AND NOT EXISTS (
|
|
18
20
|
SELECT 1 FROM documents newer WHERE newer.supersedes=d.id AND
|
|
19
21
|
newer.revisionState IN ('released','withdrawn') AND newer.effectiveFrom<=?
|
|
20
22
|
)) OR
|
|
@@ -69,7 +71,7 @@ function validateName(value, max) {
|
|
|
69
71
|
return name;
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
function open(root) {
|
|
74
|
+
function open(root, { hiddenTemplateDigests = [] } = {}) {
|
|
73
75
|
const originals = path.join(root, 'enterprise-knowledge-files');
|
|
74
76
|
fs.mkdirSync(originals, { recursive: true });
|
|
75
77
|
const db = new DatabaseSync(path.join(root, 'enterprise-knowledge.db'));
|
|
@@ -172,8 +174,12 @@ function open(root) {
|
|
|
172
174
|
db.exec('CREATE INDEX IF NOT EXISTS document_versions ON documents(documentNumber,product,process,effectiveFrom)');
|
|
173
175
|
db.exec('CREATE INDEX IF NOT EXISTS document_replacements ON documents(supersedes,effectiveFrom)');
|
|
174
176
|
});
|
|
177
|
+
db.exec('CREATE TEMP TABLE hidden_platform_templates (sha TEXT PRIMARY KEY)');
|
|
178
|
+
const hideTemplate = db.prepare('INSERT INTO hidden_platform_templates VALUES (?)');
|
|
179
|
+
for (const digest of hiddenTemplateDigests) hideTemplate.run(digest);
|
|
175
180
|
const stored = (id, suffix = '.original') => path.join(originals, id + suffix);
|
|
176
181
|
const row = db.prepare('SELECT ' + fileFields + ',purgedAt FROM documents WHERE id=?');
|
|
182
|
+
const hiddenTemplate = db.prepare('SELECT 1 FROM documents d WHERE id=? AND NOT ' + companyVisible);
|
|
177
183
|
const active = db.prepare('SELECT ' + fileFields + ' FROM documents d WHERE id=? AND ' + effective);
|
|
178
184
|
const previewRow = db.prepare('SELECT * FROM revision_previews WHERE id=? AND owner=?');
|
|
179
185
|
const remove = (filename) => {
|
|
@@ -614,21 +620,28 @@ function open(root) {
|
|
|
614
620
|
return {
|
|
615
621
|
searchableCount() {
|
|
616
622
|
return db.prepare(`SELECT count(*) AS count FROM documents d JOIN folders f ON f.id=d.folderId
|
|
617
|
-
WHERE
|
|
623
|
+
WHERE f.scope='company' AND d.chunkCount>0 AND ${effective}`)
|
|
618
624
|
.get(today(), today(), today()).count;
|
|
619
625
|
},
|
|
620
|
-
list() {
|
|
621
|
-
const folders = db.prepare('SELECT id,parentId,name,scope,pinned FROM folders ORDER BY position, name COLLATE NOCASE').all()
|
|
626
|
+
list(scope) {
|
|
627
|
+
const folders = db.prepare('SELECT id,parentId,name,scope,pinned FROM folders ORDER BY position, name COLLATE NOCASE').all()
|
|
628
|
+
.filter(folder => !scope || folder.scope===scope);
|
|
629
|
+
const ids = new Set(folders.map(folder=>folder.id));
|
|
622
630
|
const files = db.prepare('SELECT ' + fileFields + ', ' + effective + ' AS effective, ' +
|
|
623
|
-
'(SELECT state FROM matter_intake WHERE documentId=d.id) AS matterState FROM documents d WHERE purgedAt=\'\'
|
|
631
|
+
'(SELECT state FROM matter_intake WHERE documentId=d.id) AS matterState FROM documents d WHERE purgedAt=\'\' AND ' +
|
|
632
|
+
companyVisible + ' ORDER BY createdAt DESC,rowid DESC').all(today(), today(), today())
|
|
633
|
+
.filter(file=>ids.has(file.folderId));
|
|
624
634
|
return { folders, files };
|
|
625
635
|
},
|
|
636
|
+
requireCompanyFolder(id) {
|
|
637
|
+
if (folder(id).scope!=='company') fail(404, '目录不存在,请刷新后重试');
|
|
638
|
+
},
|
|
626
639
|
saveFolder, removeFolder, upload, removeDocument, setVersion, search, passages, documentText,
|
|
627
640
|
remoteDocuments,remoteDocument,remoteSearch,
|
|
628
641
|
revisionSource, createRevisionPreview, revisionPreview, rejectRevision, excessRevisions, pruneRevisions,migrateRevisionOwners,
|
|
629
|
-
document(id) {
|
|
642
|
+
document(id, scope) {
|
|
630
643
|
const found = row.get(id);
|
|
631
|
-
if (!found) fail(404, '文件不存在');
|
|
644
|
+
if (!found || hiddenTemplate.get(id) || scope && folder(found.folderId).scope!==scope) fail(404, '文件不存在');
|
|
632
645
|
if (found.purgedAt) fail(410, '旧版已按保留规则清理');
|
|
633
646
|
return { ...found, filename: stored(id) };
|
|
634
647
|
},
|
|
@@ -733,32 +746,28 @@ async function answer(library, llm, input, signal, progress = {}) {
|
|
|
733
746
|
const followUp = /^(?:那|那么|这个|这种|刚才|上面|它|继续|展开|再说|进一步|具体呢|举个例)/.test(question);
|
|
734
747
|
const query = followUp && priorQuestions.length ? question + '\n' + priorQuestions.at(-1) : question;
|
|
735
748
|
const hits = casual ? [] : library.search(query, scope);
|
|
736
|
-
const sources = hits.map(({ id, name, folderId, folderName, text, part, documentNumber, revision, effectiveFrom, scope: origin }, index) => ({
|
|
737
|
-
number: index + 1, id, name, folderId, folderName, text, part, documentNumber, revision, effectiveFrom,
|
|
738
|
-
expert: bySlug.get(origin.slice(7))?.name || '',
|
|
739
|
-
}));
|
|
740
749
|
if (!llm) {
|
|
741
750
|
if (casual) return { text: '你好,有质量管理、工艺或体系方面的问题,可以直接问我。', sources: [], mode: 'conversation' };
|
|
742
|
-
return { text:
|
|
751
|
+
return { text: '模型暂不可用,请稍后重试。', sources: [], mode: 'retrieval' };
|
|
743
752
|
}
|
|
744
|
-
const strategy = profile ? '
|
|
745
|
-
: '
|
|
753
|
+
const strategy = profile ? '根据当前专长与命中的参考资料回答,不以真人口吻声称其观点或经历。'
|
|
754
|
+
: '综合命中的参考资料,并区分不同来源。';
|
|
746
755
|
try {
|
|
747
756
|
const response = await require('./chat-answer').start(llm, {
|
|
748
757
|
system: casual ? '你是质量管理专家团 AI 助手。自然回应当前的问候、致谢或简短交流。按当前这句话回复,省略资料、来源及历史主题。'
|
|
749
758
|
: '你是质量管理助手。' + strategy +
|
|
750
|
-
'
|
|
759
|
+
' 参考资料是后台数据,用于综合形成建议。只回答质量问题,省略资料原文、引用编号、作者、文件名和目录。资料不足时标明建议的适用条件,避免虚构标准条文、人员、数据或出处。',
|
|
751
760
|
user: JSON.stringify({
|
|
752
761
|
question, priorQuestions: casual ? [] : priorQuestions, specialties: profile?.tags || [],
|
|
753
|
-
evidence:
|
|
762
|
+
evidence: hits.filter(item=>item.part).map(item=>item.text),
|
|
754
763
|
}),
|
|
755
764
|
signal, onStart: progress.onStart, onUpdate: progress.onUpdate,
|
|
756
765
|
});
|
|
757
766
|
if (signal.aborted && !response.text) signal.throwIfAborted();
|
|
758
|
-
return { ...response, sources, mode: casual ? 'conversation' :
|
|
767
|
+
return { ...response, sources:[], mode: casual ? 'conversation' : hits.some(item=>item.part) ? 'grounded' : 'general' };
|
|
759
768
|
} catch (error) {
|
|
760
769
|
if (signal.aborted) throw error;
|
|
761
|
-
return { text:
|
|
770
|
+
return { text: '模型暂不可用,请稍后重试。', sources: [], mode: 'retrieval' };
|
|
762
771
|
}
|
|
763
772
|
}
|
|
764
773
|
|
package/src/lib/qms-jobs.js
CHANGED
|
@@ -141,8 +141,9 @@ function createJobs(root, getSurvey, library, publish, getTrash = () => ({}), ge
|
|
|
141
141
|
missing: draft.missing(sv), review: draft.reviewFields(sv),
|
|
142
142
|
templateIssue: selection.issue, family: selection.family, families: selection.options,
|
|
143
143
|
documentDate: word.documentDate(sv, selection.family?.code, type),
|
|
144
|
-
plan: selection.plan.map(({ id,
|
|
145
|
-
|
|
144
|
+
plan: selection.plan.map(({ platform,id,folderId,filename,format,title,sourceDepartment,department,sourcePath,revision }) =>
|
|
145
|
+
platform ? {sourcePath:'平台模板',folderId:null} :
|
|
146
|
+
{id,folderId,filename,format,title,sourceDepartment,department:department.name,sourcePath,revision}),
|
|
146
147
|
};
|
|
147
148
|
}
|
|
148
149
|
|
|
@@ -211,7 +212,9 @@ function createJobs(root, getSurvey, library, publish, getTrash = () => ({}), ge
|
|
|
211
212
|
? editor.applyEdits(parts,template,compiled.edits,{manual:job.type === 'manual',procedure:job.type === 'procedure',aligned:compiled.aligned})
|
|
212
213
|
: prefilled.count ? prefilled.bytes : source;
|
|
213
214
|
if (isWord) editor.validateSectionStructure(template,output);
|
|
214
|
-
const
|
|
215
|
+
const templateName = item.platform ? '平台模板' : item.filename;
|
|
216
|
+
const review = ['生成原件:' + (item.platform ? templateName :
|
|
217
|
+
[item.sourcePath,item.filename,item.revision && '版次 '+item.revision].filter(Boolean).join(' / '))];
|
|
215
218
|
const reference = count === 0;
|
|
216
219
|
review.push('检查原文 ' + compiled.checked + ' 处,按字段填入 ' + prefilled.count +
|
|
217
220
|
' 处,按原文位置调整 ' + compiled.edits.size + ' 处。');
|
|
@@ -230,8 +233,9 @@ function createJobs(root, getSurvey, library, publish, getTrash = () => ({}), ge
|
|
|
230
233
|
const state = !compiled.complete ? 'partial' : reference ? 'reference' : 'edited';
|
|
231
234
|
const doc = {
|
|
232
235
|
id:'QMS-' + job.id + '-' + item.code, type:job.type, code:item.code, jobId:job.id, version:job.version,
|
|
233
|
-
title:item.title, source:state, reference, template:
|
|
234
|
-
templateDigest:item.digest, templateSource:
|
|
236
|
+
title:item.title, source:state, reference, template:templateName, model:compiled.model,
|
|
237
|
+
templateDigest:item.digest, templateSource:item.platform ? {path:'平台模板'} :
|
|
238
|
+
{id:item.id,path:item.sourcePath,revision:item.revision}, format:item.outputFormat,
|
|
235
239
|
department:item.department.name, sourceFolders:item.sourceFolders,
|
|
236
240
|
createdAt:job.startedAt, surveyUpdatedAt:job.surveyUpdatedAt, review, reviewItems:compiled.unresolved,
|
|
237
241
|
validationIssues:compiled.failures, manualRef,
|
|
@@ -248,11 +252,11 @@ function createJobs(root, getSurvey, library, publish, getTrash = () => ({}), ge
|
|
|
248
252
|
for (let offset = 0; offset < plan.length; offset += 3) {
|
|
249
253
|
signal.throwIfAborted();
|
|
250
254
|
const batch = plan.slice(offset, offset + 3);
|
|
251
|
-
job.current = '正在编制 ' + (offset + 1) + '–' + (offset + batch.length) + ' 份 · ' + batch[0].
|
|
255
|
+
job.current = '正在编制 ' + (offset + 1) + '–' + (offset + batch.length) + ' 份 · ' + batch[0].title;
|
|
252
256
|
save(job);
|
|
253
257
|
const pending = batch.map(async (item) => {
|
|
254
258
|
const reportProgress = (done,total,label) => {
|
|
255
|
-
job.current = item.
|
|
259
|
+
job.current = item.title + ' · ' + (label || '检查原文 ' + done + '/' + total);
|
|
256
260
|
save(job);
|
|
257
261
|
};
|
|
258
262
|
return build(item, signal, reportProgress);
|
package/src/lib/qms-templates.js
CHANGED
|
@@ -10,7 +10,11 @@ const { pathToFileURL } = require('node:url');
|
|
|
10
10
|
const office = require('./office');
|
|
11
11
|
const word = require('./qms-word');
|
|
12
12
|
const { referenceKey } = require('./qms-procedure-review');
|
|
13
|
-
const exec = promisify(execFile);
|
|
13
|
+
const exec = promisify(execFile);
|
|
14
|
+
const platformRoot = path.join(__dirname, '../../resources/qms-templates');
|
|
15
|
+
const platformTemplates = require('../../resources/qms-templates/manifest.json');
|
|
16
|
+
const platformById = new Map(platformTemplates.map(item => [item.id, item]));
|
|
17
|
+
const platformOriginalDigests = new Set(platformTemplates.map(item => item.originalDigest));
|
|
14
18
|
|
|
15
19
|
const maxPackBytes = 96 * 1024 * 1024;
|
|
16
20
|
const families = [
|
|
@@ -151,6 +155,7 @@ function createTemplateLibrary(root, getKnowledge) {
|
|
|
151
155
|
catch (error) { if (error.code!=='ENOENT') throw error; }
|
|
152
156
|
if (pack) {
|
|
153
157
|
for (const item of pack.items) {
|
|
158
|
+
if (platformOriginalDigests.has(item.digest)) continue;
|
|
154
159
|
const dir=path.join(root,pack.id);
|
|
155
160
|
const original=path.join(dir,item.id+'.'+item.format);
|
|
156
161
|
if (hashBuffer(original)!==item.digest) throw new Error('原模板校验失败:'+item.filename);
|
|
@@ -190,7 +195,7 @@ function createTemplateLibrary(root, getKnowledge) {
|
|
|
190
195
|
}
|
|
191
196
|
|
|
192
197
|
function candidates(type,survey) {
|
|
193
|
-
const {folders,files}=getKnowledge().list();
|
|
198
|
+
const {folders,files}=getKnowledge().list('company');
|
|
194
199
|
const map=new Map(folders.map(folder=>[folder.id,folder]));
|
|
195
200
|
const [branchId,branchName]=rootFolders[type];
|
|
196
201
|
const rows=[];
|
|
@@ -245,17 +250,36 @@ function createTemplateLibrary(root, getKnowledge) {
|
|
|
245
250
|
function select(type,survey,target) {
|
|
246
251
|
const rows=candidates(type,survey);
|
|
247
252
|
const supported=familiesFor(survey);
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
+
const entries = supported.map(({code,label}) => {
|
|
254
|
+
const company = choose(rows,type,code);
|
|
255
|
+
const platform = platformTemplates.filter(item => item.category===type && item.family===code);
|
|
256
|
+
return {code,label,company,platform};
|
|
257
|
+
});
|
|
258
|
+
const options = entries.map(({code,label,company,platform}) => ({code,label,available:company.length+platform.length>0}));
|
|
259
|
+
const family = target ? entries.find(item=>item.code===target) :
|
|
260
|
+
entries.find(item=>item.company.length) || entries.find(item=>item.platform.length);
|
|
261
|
+
const selected = target && !family ? [] : family?.company || choose(rows,type);
|
|
253
262
|
const plan=selected.map(({file,format,ancestry,sourceDepartment,department:owner})=>({
|
|
254
263
|
id:file.id, folderId:file.folderId, code:'T-'+hash(file.id).slice(0,16), filename:file.name, title:file.name.slice(0,-format.length-1),
|
|
255
264
|
digest:file.sha, format, outputFormat:format==='doc'?'docx':format, sourceDepartment, department:owner,
|
|
256
265
|
sourceFolders: type==='procedure'?ancestry.slice(1):[], sourcePath:['体系文件',rootFolders[type][1],...ancestry].join(' / '),
|
|
257
266
|
revision:file.revision, documentNumber:file.documentNumber,
|
|
258
|
-
}))
|
|
267
|
+
}));
|
|
268
|
+
if (!plan.length && family) {
|
|
269
|
+
for (const item of family.platform) {
|
|
270
|
+
const {id,filename,digest,sourceDepartment,sourceFolders} = item;
|
|
271
|
+
plan.push({
|
|
272
|
+
id:'platform-'+id, folderId:null, code:'T-'+hash('platform/'+id).slice(0,16), filename,
|
|
273
|
+
title:filename.slice(0,-5).replace(/^(?:AAA|BBB|CCC|DDD)[-_-]+/,'').replace(/^9001(?=质量手册)/,'ISO 9001 '),
|
|
274
|
+
digest,format:'docx',outputFormat:'docx',platform:true,sourceDepartment,sourceFolders,
|
|
275
|
+
department:department(sourceDepartment,survey),sourcePath:['平台模板',rootFolders[type][1],sourceDepartment].filter(Boolean).join(' / '),
|
|
276
|
+
revision:'',documentNumber:'',
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const issue=target && !family ? '目标体系不在已保存的调研中。' :
|
|
281
|
+
!plan.length ? '请选择受支持的体系,或在企业知识库「体系文件 / '+rootFolders[type][1]+'」上传适用文件。' : '';
|
|
282
|
+
plan.sort((a,b)=>a.sourceDepartment.localeCompare(b.sourceDepartment,'zh-CN') || a.filename.localeCompare(b.filename,'zh-CN') ||
|
|
259
283
|
a.id.localeCompare(b.id));
|
|
260
284
|
return {options,family: family && {code:family.code,label:family.label},issue,plan,
|
|
261
285
|
key:hash(JSON.stringify(plan.map(({id,digest,revision,sourcePath})=>[id,digest,revision,sourcePath])))};
|
|
@@ -263,6 +287,14 @@ function createTemplateLibrary(root, getKnowledge) {
|
|
|
263
287
|
|
|
264
288
|
async function read(item) {
|
|
265
289
|
try {
|
|
290
|
+
if (item.id.startsWith('platform-')) {
|
|
291
|
+
const template=platformById.get(item.id.slice('platform-'.length));
|
|
292
|
+
if (!template || template.digest!==item.digest) throw new Error('平台模板版本已变更,请重新生成');
|
|
293
|
+
const bytes=fs.readFileSync(path.join(platformRoot,template.id+'.docx'));
|
|
294
|
+
if (hash(bytes)!==item.digest) throw new Error('平台模板校验失败,请重新安装插件');
|
|
295
|
+
checkedTemplate(item,bytes);
|
|
296
|
+
return bytes;
|
|
297
|
+
}
|
|
266
298
|
const original=getKnowledge().document(item.id);
|
|
267
299
|
const maxSize=(item.format==='xlsx'?48:10)*1024*1024;
|
|
268
300
|
if (original.size>maxSize) throw new Error('原件超过 '+maxSize/(1024*1024)+' MB');
|
|
@@ -289,7 +321,7 @@ function createTemplateLibrary(root, getKnowledge) {
|
|
|
289
321
|
|
|
290
322
|
function findSupporting(titles,survey,family) {
|
|
291
323
|
const knowledge=getKnowledge();
|
|
292
|
-
const {folders,files}=knowledge.list();
|
|
324
|
+
const {folders,files}=knowledge.list('company');
|
|
293
325
|
const directories=new Map(folders.map(folder=>[folder.id,folder]));
|
|
294
326
|
const wanted=new Set(titles.map(referenceKey));
|
|
295
327
|
const found=new Map();
|
|
@@ -324,4 +356,4 @@ function createTemplateLibrary(root, getKnowledge) {
|
|
|
324
356
|
return {select,install,migrateLegacy,read,mapDepartments,findSupporting};
|
|
325
357
|
}
|
|
326
358
|
|
|
327
|
-
module.exports = { createTemplateLibrary, maxPackBytes, knowledgeMigrationMarker:migrated };
|
|
359
|
+
module.exports = { createTemplateLibrary, maxPackBytes, platformOriginalDigests, knowledgeMigrationMarker:migrated };
|
|
@@ -12,14 +12,14 @@ dsh plugin --profile web add dsh-total-quality
|
|
|
12
12
|
|
|
13
13
|
## 从 GitHub 安装
|
|
14
14
|
|
|
15
|
-
1. 从 [发布页](https://github.com/total-quality/dsh-total-quality/releases/latest) 下载 `qip-real-workbench-2.0.
|
|
15
|
+
1. 从 [发布页](https://github.com/total-quality/dsh-total-quality/releases/latest) 下载 `qip-real-workbench-2.0.57.tgz`,在 DSH 当前 Web profile 的插件管理器添加该包。
|
|
16
16
|
2. 打开侧栏「全质开源质量平台」。安装后入口暂时未出现时,刷新 DSH Web 页面或重新启动 DSH。
|
|
17
17
|
3. 首次打开选择「开始使用」建立空白业务台账。试用时可以在单独的数据环境选择「体验示例」。
|
|
18
18
|
|
|
19
19
|
可在命令行直接添加发布包:
|
|
20
20
|
|
|
21
21
|
```sh
|
|
22
|
-
dsh plugin --profile web add https://github.com/total-quality/dsh-total-quality/releases/download/v2.0.
|
|
22
|
+
dsh plugin --profile web add https://github.com/total-quality/dsh-total-quality/releases/download/v2.0.57/qip-real-workbench-2.0.57.tgz
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
如果手头已有安装包,可把上面命令中的网址换成本地 `.tgz` 路径。需要从源码目录安装时,见 [本机独立安装说明](本机独立安装说明.md)。
|