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.
Files changed (197) hide show
  1. package/CONTRIBUTING.md +51 -47
  2. package/LICENSE.md +37 -37
  3. package/README.en.md +32 -30
  4. package/README.md +90 -88
  5. package/agent-host.cjs +277 -277
  6. package/client.js +199 -92
  7. package/cordis.patch.yml +5 -5
  8. package/docs/enterprise-onboarding.md +10 -10
  9. package/docs/technical-reference.md +223 -223
  10. package/host.cjs +91 -124
  11. package/llm-bridge.cjs +234 -234
  12. package/locale/en.json +5 -5
  13. package/locale/zh.json +5 -5
  14. package/package.json +3 -2
  15. package/public/app.css +3 -0
  16. package/public/app.js +6 -2
  17. package/public/index.html +8 -9
  18. package/public/js/api.js +152 -152
  19. package/public/js/assistant-history.js +62 -62
  20. package/public/js/material-library.js +100 -100
  21. package/public/js/mobile-preview.js +119 -0
  22. package/public/js/pages-company-knowledge.js +9 -32
  23. package/public/js/pages-core.js +232 -232
  24. package/public/js/pages-growth.js +148 -148
  25. package/public/js/pages-qms.js +1 -1
  26. package/public/js/pages-qtools.js +410 -410
  27. package/public/js/pages-thanks.js +71 -71
  28. package/public/js/plugin-updates.js +53 -0
  29. package/public/js/quality-workflow.js +205 -205
  30. package/public/js/survey-dates.js +41 -41
  31. package/public/js/survey-knowledge.js +301 -301
  32. package/public/js/tool-wizards.js +621 -621
  33. package/public/js/ui.js +467 -467
  34. package/public/js/voice-capture-worklet.js +30 -30
  35. package/public/js/xiaozhi-voice.js +264 -264
  36. package/public/js/xiaozhi.js +468 -468
  37. package/public/platform-help.html +426 -426
  38. package/public/platform-site/assets/0468a68574112812.css +10703 -10703
  39. package/public/platform-site/assets/159e086d35adfa1c.css +2094 -2094
  40. package/public/platform-site/assets/169e3159cade0d9f.css +98 -98
  41. package/public/platform-site/assets/22b917c4a3d4ae3d.svg +14 -14
  42. package/public/platform-site/assets/476f9254ccf723e7.css +8265 -8265
  43. package/public/platform-site/assets/85a0a4fb4416ded9.css +120 -120
  44. package/public/platform-site/assets/a3b272383226f6d9.svg +135 -135
  45. package/public/platform-site/assets/fd16dc5f3cc9d97e.svg +104 -104
  46. package/public/platform-site/assets/qip-favicon.svg +5 -5
  47. package/public/platform-site/index.html +279 -279
  48. package/public/platform-site/offline.js +261 -261
  49. package/public/platform-site/qip-brand.css +566 -566
  50. package/public/platform-site/qip-module-guides.js +237 -237
  51. package/public/responsive.css +103 -101
  52. package/public/vendor/markdown-it-15.0.3.LICENSE +22 -22
  53. package/public/vendor/markdown-it-15.0.3.umd.min.js +13 -13
  54. package/public/workbench.css +7 -7
  55. package/public/xiaozhi.css +292 -292
  56. package/resources/qms-templates/019ffb58f24ed48d.docx +0 -0
  57. package/resources/qms-templates/04a69165fc15143a.docx +0 -0
  58. package/resources/qms-templates/09af69358c989a63.docx +0 -0
  59. package/resources/qms-templates/0e7ac77844e45311.docx +0 -0
  60. package/resources/qms-templates/12446a1b5e173c71.docx +0 -0
  61. package/resources/qms-templates/15ae40f67f9a3efc.docx +0 -0
  62. package/resources/qms-templates/18a69bbebf2ece7f.docx +0 -0
  63. package/resources/qms-templates/1978faa989134f02.docx +0 -0
  64. package/resources/qms-templates/1a30e121de752f7b.docx +0 -0
  65. package/resources/qms-templates/1b88907969ea7d4c.docx +0 -0
  66. package/resources/qms-templates/1e92b808722bf90a.docx +0 -0
  67. package/resources/qms-templates/2091cad340dc0e7f.docx +0 -0
  68. package/resources/qms-templates/271ae1002c896ed7.docx +0 -0
  69. package/resources/qms-templates/280ce53e5d3b5fcf.docx +0 -0
  70. package/resources/qms-templates/28ca8e4ede0adf6d.docx +0 -0
  71. package/resources/qms-templates/2ac6675f3cb1f993.docx +0 -0
  72. package/resources/qms-templates/2c3b799389909d8b.docx +0 -0
  73. package/resources/qms-templates/2c51038ba2cc3264.docx +0 -0
  74. package/resources/qms-templates/30c888851d16d764.docx +0 -0
  75. package/resources/qms-templates/3459fc4daaa2743d.docx +0 -0
  76. package/resources/qms-templates/3751dafc335e0e80.docx +0 -0
  77. package/resources/qms-templates/38798cd4298cd2db.docx +0 -0
  78. package/resources/qms-templates/38f551f9d738ab0a.docx +0 -0
  79. package/resources/qms-templates/3c85a23ea17018b4.docx +0 -0
  80. package/resources/qms-templates/3cdb7d14caf1b852.docx +0 -0
  81. package/resources/qms-templates/3f23239bb6b3e1db.docx +0 -0
  82. package/resources/qms-templates/42a5b9efeeaa8007.docx +0 -0
  83. package/resources/qms-templates/47352aafe9b8dac1.docx +0 -0
  84. package/resources/qms-templates/495359b1e3cbb8fe.docx +0 -0
  85. package/resources/qms-templates/4ca6920464785166.docx +0 -0
  86. package/resources/qms-templates/4ce862582a7791be.docx +0 -0
  87. package/resources/qms-templates/54c9a02a10991b9e.docx +0 -0
  88. package/resources/qms-templates/5aeb8fddf5f3693f.docx +0 -0
  89. package/resources/qms-templates/5d7e5576b0e73be7.docx +0 -0
  90. package/resources/qms-templates/5db3a40edac37791.docx +0 -0
  91. package/resources/qms-templates/5ffa21eb78eb6f77.docx +0 -0
  92. package/resources/qms-templates/60d0fbcb709b7161.docx +0 -0
  93. package/resources/qms-templates/63e1d3a166756095.docx +0 -0
  94. package/resources/qms-templates/65c724c080d32f10.docx +0 -0
  95. package/resources/qms-templates/674bd7826c6cbac2.docx +0 -0
  96. package/resources/qms-templates/677e851acca1b879.docx +0 -0
  97. package/resources/qms-templates/6bf15feb1a0d2a8d.docx +0 -0
  98. package/resources/qms-templates/6c3889c7d0918db9.docx +0 -0
  99. package/resources/qms-templates/6c4c349eeb0a96a8.docx +0 -0
  100. package/resources/qms-templates/6c5befbd33f759c1.docx +0 -0
  101. package/resources/qms-templates/6df8367901347508.docx +0 -0
  102. package/resources/qms-templates/71db51997037692b.docx +0 -0
  103. package/resources/qms-templates/78a8ef8c76510c99.docx +0 -0
  104. package/resources/qms-templates/8397bfd1c0a1b013.docx +0 -0
  105. package/resources/qms-templates/84d750cf858b60a1.docx +0 -0
  106. package/resources/qms-templates/880de58a4b334533.docx +0 -0
  107. package/resources/qms-templates/88c37d1b87d9b78c.docx +0 -0
  108. package/resources/qms-templates/88e9cd42f1849462.docx +0 -0
  109. package/resources/qms-templates/8956597403be35b6.docx +0 -0
  110. package/resources/qms-templates/94675c810a233e1f.docx +0 -0
  111. package/resources/qms-templates/94dff59dd7ebec6e.docx +0 -0
  112. package/resources/qms-templates/9670b9cd02141594.docx +0 -0
  113. package/resources/qms-templates/98c373ebd7b5163d.docx +0 -0
  114. package/resources/qms-templates/a4078cf2378a9388.docx +0 -0
  115. package/resources/qms-templates/a5b110c7ef917139.docx +0 -0
  116. package/resources/qms-templates/aec75820e45774be.docx +0 -0
  117. package/resources/qms-templates/b31c085e281d230c.docx +0 -0
  118. package/resources/qms-templates/b7c1c3c72f8ffeef.docx +0 -0
  119. package/resources/qms-templates/b81b82eaa5c8f422.docx +0 -0
  120. package/resources/qms-templates/b92a2fa31f75f137.docx +0 -0
  121. package/resources/qms-templates/b96c54ae9cfffc54.docx +0 -0
  122. package/resources/qms-templates/bc47cfd626c010e7.docx +0 -0
  123. package/resources/qms-templates/be60792734afca69.docx +0 -0
  124. package/resources/qms-templates/c0018d8ae9ad19e1.docx +0 -0
  125. package/resources/qms-templates/c171027c964c8be3.docx +0 -0
  126. package/resources/qms-templates/c4b93d71f5d98b4b.docx +0 -0
  127. package/resources/qms-templates/c531da29fcb3090f.docx +0 -0
  128. package/resources/qms-templates/c88eddd43358d015.docx +0 -0
  129. package/resources/qms-templates/cb978da542f0d892.docx +0 -0
  130. package/resources/qms-templates/ccde4a94532a8d36.docx +0 -0
  131. package/resources/qms-templates/cf3fb1e20ae6f24d.docx +0 -0
  132. package/resources/qms-templates/d231b4982fc8113e.docx +0 -0
  133. package/resources/qms-templates/d3c55aa5ed14055c.docx +0 -0
  134. package/resources/qms-templates/db45c44a00a13349.docx +0 -0
  135. package/resources/qms-templates/db849a41210f54e0.docx +0 -0
  136. package/resources/qms-templates/dba9ce363d83ddc8.docx +0 -0
  137. package/resources/qms-templates/dca3ea4c95eb2225.docx +0 -0
  138. package/resources/qms-templates/dfa4220d2b6b8131.docx +0 -0
  139. package/resources/qms-templates/dfa51222c777734f.docx +0 -0
  140. package/resources/qms-templates/e07ea511507e14f5.docx +0 -0
  141. package/resources/qms-templates/e0a2e00c03458dfa.docx +0 -0
  142. package/resources/qms-templates/e0e802f46b6764d1.docx +0 -0
  143. package/resources/qms-templates/e53fc85717f2852b.docx +0 -0
  144. package/resources/qms-templates/e9dd82d5e54520e5.docx +0 -0
  145. package/resources/qms-templates/ea7bfc22c06d82a9.docx +0 -0
  146. package/resources/qms-templates/ecf0db9f37294536.docx +0 -0
  147. package/resources/qms-templates/f05fcfc87e82ff39.docx +0 -0
  148. package/resources/qms-templates/fb9e56a17c4a4f97.docx +0 -0
  149. package/resources/qms-templates/manifest.json +932 -0
  150. package/src/data/seed-sme.js +317 -317
  151. package/src/data/seed.js +879 -879
  152. package/src/lib/backup-identity.js +57 -57
  153. package/src/lib/chat-answer.js +225 -225
  154. package/src/lib/chat-context.js +99 -99
  155. package/src/lib/company-library.js +28 -19
  156. package/src/lib/data-import.js +217 -217
  157. package/src/lib/data-sources.js +118 -118
  158. package/src/lib/demo-data.js +27 -1
  159. package/src/lib/employee-intake.js +84 -84
  160. package/src/lib/growth.js +53 -53
  161. package/src/lib/intake-packets.js +119 -119
  162. package/src/lib/issue-intake.js +88 -88
  163. package/src/lib/kb-revision.js +214 -214
  164. package/src/lib/llm.js +279 -279
  165. package/src/lib/model-error.js +14 -14
  166. package/src/lib/privacy.js +26 -26
  167. package/src/lib/qms-drafting.js +194 -194
  168. package/src/lib/qms-jobs.js +11 -7
  169. package/src/lib/qms-manual-review.js +185 -185
  170. package/src/lib/qms-procedure-review.js +109 -109
  171. package/src/lib/qms-templates.js +358 -326
  172. package/src/lib/qms.js +369 -369
  173. package/src/lib/quality-priority.js +100 -100
  174. package/src/lib/quality-state.js +92 -92
  175. package/src/lib/quality-workflow.js +65 -65
  176. package/src/lib/retrieval.js +159 -159
  177. package/src/lib/spc.js +127 -127
  178. package/src/lib/voice-hotwords.txt +22 -22
  179. package/src/lib/voice-text.js +13 -13
  180. package/src/lib/voice-worker.js +72 -72
  181. package/src/lib/voice.js +330 -330
  182. package/src/lib/workbench-notices.js +49 -49
  183. package/src/lib/workbench.js +103 -106
  184. package/src/package.json +3 -3
  185. package/src/tools/analysis.js +306 -306
  186. package/src/tools/data.js +596 -596
  187. package/src/tools/docs.js +430 -430
  188. package/src/tools/registry.js +57 -57
  189. package/tools-dsh.cjs +153 -153
  190. package//345/256/211/350/243/205/350/257/264/346/230/216.md +33 -25
  191. 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
  192. package//350/207/252/346/243/200.cjs +88 -88
  193. package/public/js/remote-knowledge.js +0 -165
  194. package/public/js/workbench-notices.js +0 -67
  195. package/public/remote-knowledge-help.html +0 -35
  196. package/public/remote-knowledge.css +0 -40
  197. package/src/lib/remote-knowledge.js +0 -284
@@ -1,317 +1,317 @@
1
- 'use strict';
2
- /**
3
- * 中小型企业版初始数据
4
- * ------------------------------------------------------------------
5
- * 与「大中型企业版」不是同一套数据的缩小版,而是按中小制造企业的真实约束重做:
6
- * · 组织:两个车间(冲压 / 装配)+ 3 人质量部,质量主管兼检验、工艺
7
- * · 产品:2 个(1 内销 + 1 代工),无多平台车型矩阵
8
- * · 数据量:特征 2 个(I-MR,60 点)、问题 48 起、课题 5 个、知识 16 条
9
- * · 关注点:一次合格率、客户投诉、返工损失、点检与 QRQC 日清——而不是 Cpk 全套
10
- */
11
- const { defaultSettings } = require('./seed');
12
-
13
- const WS = ['一车间', '二车间'];
14
- const PD = ['产品甲', '产品乙'];
15
-
16
- const MEMBERS = [
17
- ['周建国', '质量主管', '质量管理', 12],
18
- ['陈立', '检验员(兼计量)', '来料检验', 8],
19
- ['刘畅', '巡检员', '过程巡检', 5],
20
- ['赵大勇', '一车间班长', '冲压', 15],
21
- ['孙鹏', '二车间班长', '装配', 11],
22
- ['王芳', '工艺工程师(兼质量)', '工艺', 9],
23
- ['李军', '设备维修', '设备', 14],
24
- ['钱伟', '采购员', '采购', 7],
25
- ['吴倩', '客服兼跟单', '客户', 4],
26
- ['郑小虎', '仓储', '来料仓储', 6],
27
- ['何静', '生产计划', '计划', 5],
28
- ['郭亮', '冲压操作工(兼改善提案)', '冲压', 3],
29
- ];
30
-
31
- // 两个特征:I-MR,每个 60 点
32
- const CHARS = [
33
- { id: 'CT-A01', name: '产品甲 外径尺寸', model: '产品甲', workshop: '一车间', station: '一车间·冲压线', nominal: 12.0, usl: 12.12, lsl: 11.88, unit: 'mm', mu: 12.004, sd: 0.021, seed: 20261001 },
34
- { id: 'CT-B02', name: '产品乙 螺纹扭矩', model: '产品乙', workshop: '二车间', station: '二车间·装配线', nominal: 18.0, usl: 22.0, lsl: 14.0, unit: 'N·m', mu: 17.8, sd: 1.15, seed: 20261002 },
35
- ];
36
-
37
- // 问题:来源以现场与来料为主,客户投诉单列
38
- const ISSUE_TPL = [
39
- ['产品甲', '一车间', '一车间·冲压线', '外径超上限(12.14mm)', '现场', 'B', '零件与模具导柱间隙偏大,换模后首件未全检'],
40
- ['产品甲', '一车间', '一车间·冲压线', '冲压件毛刺超标', '现场', 'C', '模具刃口磨损,未按 5000 件周期刃磨'],
41
- ['产品甲', '一车间', '一车间·去毛刺工位', '去毛刺漏工序', '巡检', 'C', '工序卡未随流转箱,操作工凭经验判断'],
42
- ['产品乙', '二车间', '二车间·装配线', '螺纹扭矩低于 14N·m', '现场', 'B', '电动扳手扭矩未班前校验,电池衰减导致偏低'],
43
- ['产品乙', '二车间', '二车间·装配线', '装配漏装定位销', '现场', 'A', '定位销混料,工位缺防错与首件确认'],
44
- ['产品乙', '二车间', '二车间·终检', '终检漏检外观划伤', '巡检', 'C', '终检照明不足,抽检比例 10% 偏低'],
45
- ['产品甲', '一车间', '一车间·来料区', '钢板来料厚度公差偏薄', '来料', 'B', '供应商换轧机未报备,入厂只测硬度未测厚度'],
46
- ['产品乙', '二车间', '二车间·来料区', '外购螺栓强度不足', '来料', 'A', '供应商更换材料批次,未做材质证明复核'],
47
- ['产品乙', '二车间', '二车间·来料区', '包装破损导致件表面划伤', '来料', 'C', '长途运输未加隔板,供应商包装标准陈旧'],
48
- ['产品甲', '一车间', '一车间·成品仓', '客户投诉外径装配过盈', '客户', 'A', '出货前未按客户图纸核对关键尺寸'],
49
- ['产品乙', '二车间', '二车间·成品仓', '客户反馈装配后异响', '客户', 'A', '螺栓扭矩下限波动,装机后松动'],
50
- ['产品甲', '一车间', '一车间·成品仓', '客户投诉表面氧化', '客户', 'B', '梅雨季节成品库存防潮措施缺失'],
51
- ];
52
-
53
- const PROJECTS = [
54
- ['#QP-S001', '产品乙 装配漏装定位销(A 级流出)', '产品乙', '二车间', '孙鹏', 'A', 'D5', 6, '定位销工位加装光电防错,首件双人确认'],
55
- ['#QP-S002', '产品乙 螺纹扭矩波动治理', '产品乙', '二车间', '陈立', 'B', 'D4', 12, '扳手每班校验 + 扭矩在线记录,抽检提至 20%'],
56
- ['#QP-S003', '产品甲 外径超上限(客户过盈)', '产品甲', '一车间', '赵大勇', 'A', 'D6', -2, '模具导柱更换,首件全检纳入作业指导书'],
57
- ['#QP-S004', '钢板来料厚度未检', '产品甲', '一车间', '钱伟', 'B', 'D7', 9, '入厂检验增加厚度千分尺测点,供应商换料须报备'],
58
- ['#QP-S005', '成品仓防潮改善(QC 小组课题)', '产品甲', '一车间', '王芳', 'C', 'D8', 3, '加装除湿机 + 库存先进先出看板,月度点检'],
59
- ];
60
-
61
- const KNOWLEDGE = [
62
- ['经验卡', '冲压件毛刺快速判定与刃磨周期', '一车间', ['一车间', '模具'], 41],
63
- ['经验卡', '电动扳手扭矩班前校验三步法', '二车间', ['二车间', '装配'], 58],
64
- ['经验卡', '来料钢板厚度快检手法', '来料', ['来料', '检验'], 33],
65
- ['经验卡', '小批量多品种的首件确认清单', '工艺', ['工艺', '标准'], 76],
66
- ['历史案例', '定位销漏装的防错改造(低成本方案)', '二车间', ['二车间', '防错'], 64],
67
- ['历史案例', '客户投诉外径过盈的闭环复盘', '客户', ['客户', '冲压'], 29],
68
- ['历史案例', '梅雨季成品氧化处理', '一车间', ['一车间', '库存'], 22],
69
- ['标准', 'GB/T 2828.1 抽样检验速查(小批量)', '标准', ['标准'], 88],
70
- ['标准', '紧固件扭矩验收要求(客户特殊要求摘编)', '标准', ['标准', '客户'], 51],
71
- ['标准', '冲压件外观检验标准(自定)', '标准', ['标准', '一车间'], 47],
72
- ['方法', 'QC 七大手法在本厂的用法', '方法', ['方法', '培训'], 95],
73
- ['方法', '5Why + 鱼骨图做单件问题的根因', '方法', ['方法', '改进'], 72],
74
- ['方法', 'PDCA 周循环:班前 10 分钟碰头会', '方法', ['方法', '管理'], 61],
75
- ['方法', '改善提案一页纸模板', '方法', ['方法', '提案'], 39],
76
- ['培训', '新员工三日上岗培训(含安全)', '培训', ['培训', '上手'], 55],
77
- ['培训', '一人多岗矩阵与替岗演练', '培训', ['培训', '人员'], 26],
78
- ];
79
-
80
- function rng(seed) {
81
- let t = seed >>> 0;
82
- return function () {
83
- t += 0x6d2b79f5;
84
- let r = Math.imul(t ^ (t >>> 15), 1 | t);
85
- r ^= r + Math.imul(r ^ (r >>> 7), 61 | r);
86
- return ((r ^ (r >>> 14)) >>> 0) / 4294967296;
87
- };
88
- }
89
-
90
- function gauss(rand) {
91
- let u = 0;
92
- let v = 0;
93
- while (u === 0) u = rand();
94
- while (v === 0) v = rand();
95
- return Math.sqrt(-2 * Math.log(u)) * Math.cos(2 * Math.PI * v);
96
- }
97
-
98
- function seedSme(store, now = new Date()) {
99
- const iso = (d) => d.toISOString();
100
- const dayAgo = (n, h) => new Date(now.getTime() - n * 86400000 + (h || 0) * 3600000);
101
- const stamp = (n) => String(n).padStart(4, '0');
102
-
103
- store.db.counters = { issue: 48, project: 5, qrqc: 18, workflow: 26, todo: 14, benefit: 6, report: 12, knowledge: 16, chat: 0, audit: 96, measurement: 0, spcChar: 2, member: 12, defect: 12 };
104
- store.db.settings = defaultSettings();
105
- const st = store.db.settings;
106
- st.org = Object.assign({}, st.org, {
107
- company: '某某精密制造有限公司',
108
- dept: '质量部',
109
- plant: '本厂(冲压 + 装配两个车间)',
110
- headcount: 12,
111
- contact: '周建国 · 质量主管',
112
- });
113
- st.naming = { company: '某某精密制造有限公司', dept: '质量部', workshops: WS.slice(), products: PD.slice() };
114
- store.db.meta.createdAt = iso(now);
115
- store.db.meta.scale = 'sme';
116
-
117
- // 人员
118
- MEMBERS.forEach((m, i) => {
119
- store.db.members.push({
120
- id: 'U-' + String(i + 1).padStart(3, '0'),
121
- name: m[0], role: m[1], dept: '质量部',
122
- group: m[2], years: m[3], avatar: m[0].slice(-2),
123
- skills: { '8D': 3 + (i % 3), '数据分析': 2 + (i % 3), '现场工艺': 4 + (i % 3), '沟通协调': 3, '标准法规': 2, 'AI应用': 2 },
124
- createdAt: iso(dayAgo(300)), updatedAt: iso(dayAgo(60)),
125
- });
126
- });
127
-
128
- // 特征与测量值(300 点 / 特征:每班 5 件、一天两班,近 30 天)
129
- let seq = 0;
130
- CHARS.forEach((c, ci) => {
131
- const rand = rng(c.seed);
132
- const values = [];
133
- const rows = [];
134
- const N = 300;
135
- for (let k = 0; k < N; k++) {
136
- seq++;
137
- let v = c.mu + gauss(rand) * c.sd + (k / N) * c.sd * 0.35; // 轻微趋势(刀具/夹具磨损)
138
- if (k === 270) v = ci === 0 ? c.usl + c.sd * 1.3 : c.lsl - c.sd * 1.1; // 同一天各出现 1 个超差点
139
- const value = Number(v.toFixed(c.unit === 'mm' ? 3 : 2));
140
- values.push(value);
141
- const ts = new Date(now.getTime() - (N - k) * 2.4 * 3600000); // 每 2.4 小时一点(≈ 每班 5 件)
142
- rows.push({
143
- id: 'MS-' + stamp(seq + 1),
144
- charId: c.id, charName: c.name, model: c.model, workshop: c.workshop, station: c.station,
145
- ts: ts.toISOString(), shift: k % 2 ? '夜班' : '白班',
146
- value, unit: c.unit, batch: 'B' + (20261000 + Math.floor(k / 20)),
147
- supplier: ci === 0 ? '宁波钢联' : '本地紧固件厂', operator: k % 2 ? '刘畅' : '陈立',
148
- vin: '', subgroup: k + 1, source: '人工录入',
149
- });
150
- }
151
- store.db.measurements.push(...rows);
152
- store.db.spcChars.push({
153
- id: c.id, name: c.name, model: c.model, workshop: c.workshop, station: c.station,
154
- nominal: c.nominal, usl: c.usl, lsl: c.lsl, unit: c.unit,
155
- subgroupSize: 1, ctq: true, controlMethod: 'I-MR',
156
- freq: '每班 5 件 / 手工录入', createdAt: iso(dayAgo(120)), updatedAt: iso(now),
157
- sampleCount: rows.length,
158
- series: values.map((v, k) => ({ ts: rows[k].ts, shift: rows[k].shift, values: [v], batch: rows[k].batch })),
159
- });
160
- });
161
-
162
- // 问题:48 起(模板循环 + 序号),A 5 / B 18 / C 25
163
- const sevPlan = [];
164
- for (let i = 0; i < 48; i++) sevPlan.push(i < 5 ? 'A' : i < 23 ? 'B' : 'C');
165
- let ai = 0;
166
- for (let i = 0; i < 48; i++) {
167
- const t = ISSUE_TPL[i % ISSUE_TPL.length];
168
- const sev = sevPlan[i];
169
- const closed = i % 5 !== 0;
170
- const created = dayAgo(closed ? 20 + (i % 40) : 1 + (i % 9), 9);
171
- const owner = MEMBERS[i % MEMBERS.length][0];
172
- store.db.issues.push({
173
- id: '#QI-S-' + stamp(101 + i),
174
- model: t[0], workshop: t[1], station: t[2], title: t[3],
175
- source: t[4], severity: sev, owner, aiSimilarity: 0.6 + ((i % 9) / 100),
176
- status: closed ? '已关闭' : (i % 7 === 0 ? '监控中' : '整改中'),
177
- description: t[6],
178
- createdAt: iso(created), updatedAt: iso(created),
179
- closedAt: closed ? iso(dayAgo(Math.max(1, 14 + (i % 20)), 16)) : null,
180
- projectId: null, tags: [], quantity: 1 + (i % 6),
181
- detectMethod: t[4] === '客户' ? '客户投诉转办(客服)' : t[4] === '来料' ? '来料检验记录' : '现场确认 / 巡检',
182
- rootCause: closed ? '已确认为' + t[6].slice(0, 12) + '…' : '',
183
- containment: closed ? '已实施临时措施并验证' : '',
184
- verifyResult: closed ? '连续两周无复发' : '',
185
- history: [{ ts: iso(created), user: owner, action: '发现问题', note: '来源:' + t[4] }],
186
- });
187
- ai++;
188
- }
189
-
190
- // 课题:5 个
191
- const stageOrder = ['D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8'];
192
- PROJECTS.forEach((p, i) => {
193
- const [id, title, model, ws, owner, sev, stage, scheduleDays, desc] = p;
194
- const issue = store.db.issues.find((x) => x.workshop === ws && x.model === model);
195
- if (issue) issue.projectId = id;
196
- const idx = stageOrder.indexOf(stage);
197
- const created = dayAgo(20 + i * 3, 10);
198
- const stages = {};
199
- stageOrder.forEach((s2, k) => {
200
- stages[s2] = { done: stage === 'D8' ? k <= idx : k < idx, at: k <= idx ? iso(dayAgo(Math.max(1, 20 + i * 3 - k * 2), 15)) : null, content: '' };
201
- });
202
- store.db.projects.push({
203
- id, title, issueId: issue ? issue.id : '', model, workshop: ws, owner, severity: sev, stage,
204
- stageIndex: idx, description: desc,
205
- createdAt: iso(created), updatedAt: iso(now),
206
- dueAt: iso(dayAgo(-scheduleDays, 17)),
207
- closedAt: stage === 'D8' ? iso(dayAgo(4, 11)) : null,
208
- overdue: scheduleDays < 0, overdueDays: Math.max(0, -scheduleDays),
209
- progress: Math.round(((idx + 0.5) / 8) * 100),
210
- team: [owner, '周建国', '王芳'],
211
- stages, d1: '', d2: '', d3: '', d4: '', d5: '', d6: '', d7: '', d8: '',
212
- verifyCount: 1, verifyTotal: 2,
213
- benefitEstimate: sev === 'A' ? 12 + i * 3 : 4 + i * 2,
214
- history: [{ ts: iso(created), user: owner, action: '立项', note: '来源问题 ' + (issue ? issue.id : '') }],
215
- aiDrafted: true, aiDraftRatio: 0.55,
216
- });
217
- });
218
-
219
- // QRQC:8 场(中小厂以班前会为主)
220
- for (let i = 0; i < 8; i++) {
221
- const d = dayAgo(i, 8);
222
- store.db.qrqc.push({
223
- id: 'QR-S-' + stamp(11 + i),
224
- level: i % 3 === 0 ? '厂级' : '车间级', workshop: WS[i % 2], model: PD[i % 2],
225
- topic: '昨日问题日清:' + ISSUE_TPL[i % ISSUE_TPL.length][3],
226
- attendees: 5 + (i % 4), problem: ISSUE_TPL[i % ISSUE_TPL.length][6],
227
- tempAction: '当班隔离 + 100% 复检', owner: MEMBERS[i % MEMBERS.length][0],
228
- responseHours: 1, dueHours: 24, status: i % 4 === 0 ? 'closed' : 'open',
229
- createdAt: iso(d), updatedAt: iso(d), location: WS[i % 2] + ' 班前会区',
230
- minutes: '', tasks: [], responseAt: iso(new Date(d.getTime() + 3600000)),
231
- closedAt: i % 4 === 0 ? iso(new Date(d.getTime() + 8 * 3600000)) : null,
232
- });
233
- }
234
-
235
- // 待办
236
- [['外径超上限首件确认', '赵大勇', 'A', 0], ['扳手扭矩校验记录补录', '陈立', 'B', 0],
237
- ['客户异响投诉回复草稿', '吴倩', 'A', 1], ['来料厚度测点新增确认', '钱伟', 'B', -1],
238
- ['QC 小组活动记录(本周)', '王芳', 'C', 0]].forEach((t, i) => {
239
- store.db.todos.push({
240
- id: 'TD-S-' + stamp(1 + i), user: t[1], title: t[0], priority: t[2], link: '',
241
- dueAt: iso(dayAgo(-t[3], 17)), done: false, createdAt: iso(dayAgo(1)), source: '本平台',
242
- });
243
- });
244
-
245
- // 审批(中小厂审批链短:质量主管 + 厂长)
246
- [['永久对策审批', '#QP-S002 扭矩波动 - 扳手校验纳入日常', '陈立', 'pending', '费用 ¥0.3 万,月度节省返工 ¥1.1 万。'],
247
- ['客户投诉闭环', '#QP-S001 定位销漏装 - 客户 8D 回复', '孙鹏', 'pending', '已回复客户,等待关闭确认。'],
248
- ['改善提案奖励', '郭亮:冲压废料分类回收提案', '赵大勇', 'approved', '月省废料处理费 ¥0.18 万,奖励 ¥300。']].forEach((w, i) => {
249
- const d = dayAgo(i, 10);
250
- store.db.workflows.push({
251
- id: 'OA-S-' + stamp(1 + i), type: w[0], title: w[1], applicant: w[2], status: w[3],
252
- relatedId: i === 0 ? '#QP-S002' : i === 1 ? '#QP-S001' : '', content: w[4],
253
- approvers: [{ name: '周建国', role: '质量主管', status: w[3] === 'pending' ? 'pending' : 'approved', at: w[3] === 'pending' ? null : iso(d) },
254
- { name: '厂长', role: '厂长', status: w[3] === 'approved' ? 'approved' : 'pending', at: w[3] === 'approved' ? iso(new Date(d.getTime() + 5400000)) : null }],
255
- createdAt: iso(d), updatedAt: iso(d), urgent: i === 0,
256
- aiSummary: '投入小、回收快,建议批准。',
257
- });
258
- });
259
-
260
- // 收益台账
261
- [['#QP-S005', '质量成本', 3.6, '2026-10', 'verified', '防潮改善后报废率由 2.1% 降至 0.6%'],
262
- ['#QP-S003', '报废降损', 9.4, '2026-11', 'pending', '外径过盈返工减少,按 12 个月摊销'],
263
- ['#QP-S002', '返工工时', 1.1, '2026-11', 'pending', '扭矩复检工时下降'],
264
- ['#QP-S004', '来料索赔', 2.2, '2026-10', 'verified', '供应商厚度超差索赔回收']].forEach((b, i) => {
265
- const p = store.db.projects.find((x) => x.id === b[0]) || {};
266
- store.db.benefits.push({
267
- id: 'BN-S-' + stamp(1 + i), projectId: b[0], projectTitle: p.title || '', type: b[1],
268
- amount: b[2], period: b[3], status: b[4], note: b[5],
269
- createdAt: iso(dayAgo(10 + i * 4)), updatedAt: iso(dayAgo(1)),
270
- formula: '收益 =(改善前损失 - 改善后损失)× 月产量', verifiedBy: b[4] === 'verified' ? '财务(兼)' : '',
271
- verifiedAt: b[4] === 'verified' ? iso(dayAgo(3)) : null, aiDriven: false,
272
- });
273
- });
274
-
275
- // 知识库
276
- KNOWLEDGE.forEach((k, i) => {
277
- store.db.knowledge.push({
278
- id: '#C-S-' + stamp(1 + i), type: k[0], title: k[1], category: k[2], tags: k[3], views: k[4],
279
- summary: k[1], content: '【' + k[0] + '】' + k[1] + ':本厂实操做法,详见现场作业指导书与点检表。',
280
- author: MEMBERS[i % MEMBERS.length][0], source: '本厂经验沉淀',
281
- createdAt: iso(dayAgo(20 + i * 3)), updatedAt: iso(dayAgo(2)), attachments: [], status: 'published',
282
- });
283
- });
284
-
285
- // AI 质检缺陷(中小厂用低成本视觉检测,量小)
286
- for (let i = 0; i < 12; i++) {
287
- store.db.defects.push({
288
- id: 'DF-S-' + stamp(1 + i), ts: iso(dayAgo(i % 6, 10 + i)),
289
- model: PD[i % 2], workshop: WS[i % 2], station: (i % 2 ? '二车间·装配线' : '一车间·冲压线'),
290
- type: i % 3 === 0 ? '外观-划伤' : i % 3 === 1 ? '尺寸-超差' : '装配-漏装',
291
- confidence: 0.81 + (i % 8) / 100, image: '', status: i % 4 === 0 ? '已确认' : '待复核',
292
- reviewer: MEMBERS[i % MEMBERS.length][0], note: 'AI 初判,需人工复核',
293
- });
294
- }
295
-
296
- // 审计
297
- for (let i = 0; i < 8; i++) {
298
- store.db.audit.push({
299
- id: 'AU-S-' + stamp(1 + i), ts: iso(dayAgo(i, 8)), user: ['周建国', '陈立', '刘畅', '王芳'][i % 4],
300
- plugin: ['本平台', '@MES', '知识库'][i % 3],
301
- action: ['查询测量数据', '控制图判异', '案例检索', '发起审批'][i % 4],
302
- params: {}, resultSummary: '初始审计记录', purpose: '初始数据初始化',
303
- });
304
- }
305
-
306
- store.saveSync(true);
307
- return {
308
- scale: 'sme',
309
- issues: store.db.issues.length,
310
- projects: store.db.projects.length,
311
- measurements: store.db.measurements.length,
312
- knowledge: store.db.knowledge.length,
313
- members: store.db.members.length,
314
- };
315
- }
316
-
317
- module.exports = { seedSme, SME_WORKSHOPS: WS, SME_PRODUCTS: PD };
1
+ 'use strict';
2
+ /**
3
+ * 中小型企业版初始数据
4
+ * ------------------------------------------------------------------
5
+ * 与「大中型企业版」不是同一套数据的缩小版,而是按中小制造企业的真实约束重做:
6
+ * · 组织:两个车间(冲压 / 装配)+ 3 人质量部,质量主管兼检验、工艺
7
+ * · 产品:2 个(1 内销 + 1 代工),无多平台车型矩阵
8
+ * · 数据量:特征 2 个(I-MR,60 点)、问题 48 起、课题 5 个、知识 16 条
9
+ * · 关注点:一次合格率、客户投诉、返工损失、点检与 QRQC 日清——而不是 Cpk 全套
10
+ */
11
+ const { defaultSettings } = require('./seed');
12
+
13
+ const WS = ['一车间', '二车间'];
14
+ const PD = ['产品甲', '产品乙'];
15
+
16
+ const MEMBERS = [
17
+ ['周建国', '质量主管', '质量管理', 12],
18
+ ['陈立', '检验员(兼计量)', '来料检验', 8],
19
+ ['刘畅', '巡检员', '过程巡检', 5],
20
+ ['赵大勇', '一车间班长', '冲压', 15],
21
+ ['孙鹏', '二车间班长', '装配', 11],
22
+ ['王芳', '工艺工程师(兼质量)', '工艺', 9],
23
+ ['李军', '设备维修', '设备', 14],
24
+ ['钱伟', '采购员', '采购', 7],
25
+ ['吴倩', '客服兼跟单', '客户', 4],
26
+ ['郑小虎', '仓储', '来料仓储', 6],
27
+ ['何静', '生产计划', '计划', 5],
28
+ ['郭亮', '冲压操作工(兼改善提案)', '冲压', 3],
29
+ ];
30
+
31
+ // 两个特征:I-MR,每个 60 点
32
+ const CHARS = [
33
+ { id: 'CT-A01', name: '产品甲 外径尺寸', model: '产品甲', workshop: '一车间', station: '一车间·冲压线', nominal: 12.0, usl: 12.12, lsl: 11.88, unit: 'mm', mu: 12.004, sd: 0.021, seed: 20261001 },
34
+ { id: 'CT-B02', name: '产品乙 螺纹扭矩', model: '产品乙', workshop: '二车间', station: '二车间·装配线', nominal: 18.0, usl: 22.0, lsl: 14.0, unit: 'N·m', mu: 17.8, sd: 1.15, seed: 20261002 },
35
+ ];
36
+
37
+ // 问题:来源以现场与来料为主,客户投诉单列
38
+ const ISSUE_TPL = [
39
+ ['产品甲', '一车间', '一车间·冲压线', '外径超上限(12.14mm)', '现场', 'B', '零件与模具导柱间隙偏大,换模后首件未全检'],
40
+ ['产品甲', '一车间', '一车间·冲压线', '冲压件毛刺超标', '现场', 'C', '模具刃口磨损,未按 5000 件周期刃磨'],
41
+ ['产品甲', '一车间', '一车间·去毛刺工位', '去毛刺漏工序', '巡检', 'C', '工序卡未随流转箱,操作工凭经验判断'],
42
+ ['产品乙', '二车间', '二车间·装配线', '螺纹扭矩低于 14N·m', '现场', 'B', '电动扳手扭矩未班前校验,电池衰减导致偏低'],
43
+ ['产品乙', '二车间', '二车间·装配线', '装配漏装定位销', '现场', 'A', '定位销混料,工位缺防错与首件确认'],
44
+ ['产品乙', '二车间', '二车间·终检', '终检漏检外观划伤', '巡检', 'C', '终检照明不足,抽检比例 10% 偏低'],
45
+ ['产品甲', '一车间', '一车间·来料区', '钢板来料厚度公差偏薄', '来料', 'B', '供应商换轧机未报备,入厂只测硬度未测厚度'],
46
+ ['产品乙', '二车间', '二车间·来料区', '外购螺栓强度不足', '来料', 'A', '供应商更换材料批次,未做材质证明复核'],
47
+ ['产品乙', '二车间', '二车间·来料区', '包装破损导致件表面划伤', '来料', 'C', '长途运输未加隔板,供应商包装标准陈旧'],
48
+ ['产品甲', '一车间', '一车间·成品仓', '客户投诉外径装配过盈', '客户', 'A', '出货前未按客户图纸核对关键尺寸'],
49
+ ['产品乙', '二车间', '二车间·成品仓', '客户反馈装配后异响', '客户', 'A', '螺栓扭矩下限波动,装机后松动'],
50
+ ['产品甲', '一车间', '一车间·成品仓', '客户投诉表面氧化', '客户', 'B', '梅雨季节成品库存防潮措施缺失'],
51
+ ];
52
+
53
+ const PROJECTS = [
54
+ ['#QP-S001', '产品乙 装配漏装定位销(A 级流出)', '产品乙', '二车间', '孙鹏', 'A', 'D5', 6, '定位销工位加装光电防错,首件双人确认'],
55
+ ['#QP-S002', '产品乙 螺纹扭矩波动治理', '产品乙', '二车间', '陈立', 'B', 'D4', 12, '扳手每班校验 + 扭矩在线记录,抽检提至 20%'],
56
+ ['#QP-S003', '产品甲 外径超上限(客户过盈)', '产品甲', '一车间', '赵大勇', 'A', 'D6', -2, '模具导柱更换,首件全检纳入作业指导书'],
57
+ ['#QP-S004', '钢板来料厚度未检', '产品甲', '一车间', '钱伟', 'B', 'D7', 9, '入厂检验增加厚度千分尺测点,供应商换料须报备'],
58
+ ['#QP-S005', '成品仓防潮改善(QC 小组课题)', '产品甲', '一车间', '王芳', 'C', 'D8', 3, '加装除湿机 + 库存先进先出看板,月度点检'],
59
+ ];
60
+
61
+ const KNOWLEDGE = [
62
+ ['经验卡', '冲压件毛刺快速判定与刃磨周期', '一车间', ['一车间', '模具'], 41],
63
+ ['经验卡', '电动扳手扭矩班前校验三步法', '二车间', ['二车间', '装配'], 58],
64
+ ['经验卡', '来料钢板厚度快检手法', '来料', ['来料', '检验'], 33],
65
+ ['经验卡', '小批量多品种的首件确认清单', '工艺', ['工艺', '标准'], 76],
66
+ ['历史案例', '定位销漏装的防错改造(低成本方案)', '二车间', ['二车间', '防错'], 64],
67
+ ['历史案例', '客户投诉外径过盈的闭环复盘', '客户', ['客户', '冲压'], 29],
68
+ ['历史案例', '梅雨季成品氧化处理', '一车间', ['一车间', '库存'], 22],
69
+ ['标准', 'GB/T 2828.1 抽样检验速查(小批量)', '标准', ['标准'], 88],
70
+ ['标准', '紧固件扭矩验收要求(客户特殊要求摘编)', '标准', ['标准', '客户'], 51],
71
+ ['标准', '冲压件外观检验标准(自定)', '标准', ['标准', '一车间'], 47],
72
+ ['方法', 'QC 七大手法在本厂的用法', '方法', ['方法', '培训'], 95],
73
+ ['方法', '5Why + 鱼骨图做单件问题的根因', '方法', ['方法', '改进'], 72],
74
+ ['方法', 'PDCA 周循环:班前 10 分钟碰头会', '方法', ['方法', '管理'], 61],
75
+ ['方法', '改善提案一页纸模板', '方法', ['方法', '提案'], 39],
76
+ ['培训', '新员工三日上岗培训(含安全)', '培训', ['培训', '上手'], 55],
77
+ ['培训', '一人多岗矩阵与替岗演练', '培训', ['培训', '人员'], 26],
78
+ ];
79
+
80
+ function rng(seed) {
81
+ let t = seed >>> 0;
82
+ return function () {
83
+ t += 0x6d2b79f5;
84
+ let r = Math.imul(t ^ (t >>> 15), 1 | t);
85
+ r ^= r + Math.imul(r ^ (r >>> 7), 61 | r);
86
+ return ((r ^ (r >>> 14)) >>> 0) / 4294967296;
87
+ };
88
+ }
89
+
90
+ function gauss(rand) {
91
+ let u = 0;
92
+ let v = 0;
93
+ while (u === 0) u = rand();
94
+ while (v === 0) v = rand();
95
+ return Math.sqrt(-2 * Math.log(u)) * Math.cos(2 * Math.PI * v);
96
+ }
97
+
98
+ function seedSme(store, now = new Date()) {
99
+ const iso = (d) => d.toISOString();
100
+ const dayAgo = (n, h) => new Date(now.getTime() - n * 86400000 + (h || 0) * 3600000);
101
+ const stamp = (n) => String(n).padStart(4, '0');
102
+
103
+ store.db.counters = { issue: 48, project: 5, qrqc: 18, workflow: 26, todo: 14, benefit: 6, report: 12, knowledge: 16, chat: 0, audit: 96, measurement: 0, spcChar: 2, member: 12, defect: 12 };
104
+ store.db.settings = defaultSettings();
105
+ const st = store.db.settings;
106
+ st.org = Object.assign({}, st.org, {
107
+ company: '某某精密制造有限公司',
108
+ dept: '质量部',
109
+ plant: '本厂(冲压 + 装配两个车间)',
110
+ headcount: 12,
111
+ contact: '周建国 · 质量主管',
112
+ });
113
+ st.naming = { company: '某某精密制造有限公司', dept: '质量部', workshops: WS.slice(), products: PD.slice() };
114
+ store.db.meta.createdAt = iso(now);
115
+ store.db.meta.scale = 'sme';
116
+
117
+ // 人员
118
+ MEMBERS.forEach((m, i) => {
119
+ store.db.members.push({
120
+ id: 'U-' + String(i + 1).padStart(3, '0'),
121
+ name: m[0], role: m[1], dept: '质量部',
122
+ group: m[2], years: m[3], avatar: m[0].slice(-2),
123
+ skills: { '8D': 3 + (i % 3), '数据分析': 2 + (i % 3), '现场工艺': 4 + (i % 3), '沟通协调': 3, '标准法规': 2, 'AI应用': 2 },
124
+ createdAt: iso(dayAgo(300)), updatedAt: iso(dayAgo(60)),
125
+ });
126
+ });
127
+
128
+ // 特征与测量值(300 点 / 特征:每班 5 件、一天两班,近 30 天)
129
+ let seq = 0;
130
+ CHARS.forEach((c, ci) => {
131
+ const rand = rng(c.seed);
132
+ const values = [];
133
+ const rows = [];
134
+ const N = 300;
135
+ for (let k = 0; k < N; k++) {
136
+ seq++;
137
+ let v = c.mu + gauss(rand) * c.sd + (k / N) * c.sd * 0.35; // 轻微趋势(刀具/夹具磨损)
138
+ if (k === 270) v = ci === 0 ? c.usl + c.sd * 1.3 : c.lsl - c.sd * 1.1; // 同一天各出现 1 个超差点
139
+ const value = Number(v.toFixed(c.unit === 'mm' ? 3 : 2));
140
+ values.push(value);
141
+ const ts = new Date(now.getTime() - (N - k) * 2.4 * 3600000); // 每 2.4 小时一点(≈ 每班 5 件)
142
+ rows.push({
143
+ id: 'MS-' + stamp(seq + 1),
144
+ charId: c.id, charName: c.name, model: c.model, workshop: c.workshop, station: c.station,
145
+ ts: ts.toISOString(), shift: k % 2 ? '夜班' : '白班',
146
+ value, unit: c.unit, batch: 'B' + (20261000 + Math.floor(k / 20)),
147
+ supplier: ci === 0 ? '宁波钢联' : '本地紧固件厂', operator: k % 2 ? '刘畅' : '陈立',
148
+ vin: '', subgroup: k + 1, source: '人工录入',
149
+ });
150
+ }
151
+ store.db.measurements.push(...rows);
152
+ store.db.spcChars.push({
153
+ id: c.id, name: c.name, model: c.model, workshop: c.workshop, station: c.station,
154
+ nominal: c.nominal, usl: c.usl, lsl: c.lsl, unit: c.unit,
155
+ subgroupSize: 1, ctq: true, controlMethod: 'I-MR',
156
+ freq: '每班 5 件 / 手工录入', createdAt: iso(dayAgo(120)), updatedAt: iso(now),
157
+ sampleCount: rows.length,
158
+ series: values.map((v, k) => ({ ts: rows[k].ts, shift: rows[k].shift, values: [v], batch: rows[k].batch })),
159
+ });
160
+ });
161
+
162
+ // 问题:48 起(模板循环 + 序号),A 5 / B 18 / C 25
163
+ const sevPlan = [];
164
+ for (let i = 0; i < 48; i++) sevPlan.push(i < 5 ? 'A' : i < 23 ? 'B' : 'C');
165
+ let ai = 0;
166
+ for (let i = 0; i < 48; i++) {
167
+ const t = ISSUE_TPL[i % ISSUE_TPL.length];
168
+ const sev = sevPlan[i];
169
+ const closed = i % 5 !== 0;
170
+ const created = dayAgo(closed ? 20 + (i % 40) : 1 + (i % 9), 9);
171
+ const owner = MEMBERS[i % MEMBERS.length][0];
172
+ store.db.issues.push({
173
+ id: '#QI-S-' + stamp(101 + i),
174
+ model: t[0], workshop: t[1], station: t[2], title: t[3],
175
+ source: t[4], severity: sev, owner, aiSimilarity: 0.6 + ((i % 9) / 100),
176
+ status: closed ? '已关闭' : (i % 7 === 0 ? '监控中' : '整改中'),
177
+ description: t[6],
178
+ createdAt: iso(created), updatedAt: iso(created),
179
+ closedAt: closed ? iso(dayAgo(Math.max(1, 14 + (i % 20)), 16)) : null,
180
+ projectId: null, tags: [], quantity: 1 + (i % 6),
181
+ detectMethod: t[4] === '客户' ? '客户投诉转办(客服)' : t[4] === '来料' ? '来料检验记录' : '现场确认 / 巡检',
182
+ rootCause: closed ? '已确认为' + t[6].slice(0, 12) + '…' : '',
183
+ containment: closed ? '已实施临时措施并验证' : '',
184
+ verifyResult: closed ? '连续两周无复发' : '',
185
+ history: [{ ts: iso(created), user: owner, action: '发现问题', note: '来源:' + t[4] }],
186
+ });
187
+ ai++;
188
+ }
189
+
190
+ // 课题:5 个
191
+ const stageOrder = ['D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8'];
192
+ PROJECTS.forEach((p, i) => {
193
+ const [id, title, model, ws, owner, sev, stage, scheduleDays, desc] = p;
194
+ const issue = store.db.issues.find((x) => x.workshop === ws && x.model === model);
195
+ if (issue) issue.projectId = id;
196
+ const idx = stageOrder.indexOf(stage);
197
+ const created = dayAgo(20 + i * 3, 10);
198
+ const stages = {};
199
+ stageOrder.forEach((s2, k) => {
200
+ stages[s2] = { done: stage === 'D8' ? k <= idx : k < idx, at: k <= idx ? iso(dayAgo(Math.max(1, 20 + i * 3 - k * 2), 15)) : null, content: '' };
201
+ });
202
+ store.db.projects.push({
203
+ id, title, issueId: issue ? issue.id : '', model, workshop: ws, owner, severity: sev, stage,
204
+ stageIndex: idx, description: desc,
205
+ createdAt: iso(created), updatedAt: iso(now),
206
+ dueAt: iso(dayAgo(-scheduleDays, 17)),
207
+ closedAt: stage === 'D8' ? iso(dayAgo(4, 11)) : null,
208
+ overdue: scheduleDays < 0, overdueDays: Math.max(0, -scheduleDays),
209
+ progress: Math.round(((idx + 0.5) / 8) * 100),
210
+ team: [owner, '周建国', '王芳'],
211
+ stages, d1: '', d2: '', d3: '', d4: '', d5: '', d6: '', d7: '', d8: '',
212
+ verifyCount: 1, verifyTotal: 2,
213
+ benefitEstimate: sev === 'A' ? 12 + i * 3 : 4 + i * 2,
214
+ history: [{ ts: iso(created), user: owner, action: '立项', note: '来源问题 ' + (issue ? issue.id : '') }],
215
+ aiDrafted: true, aiDraftRatio: 0.55,
216
+ });
217
+ });
218
+
219
+ // QRQC:8 场(中小厂以班前会为主)
220
+ for (let i = 0; i < 8; i++) {
221
+ const d = dayAgo(i, 8);
222
+ store.db.qrqc.push({
223
+ id: 'QR-S-' + stamp(11 + i),
224
+ level: i % 3 === 0 ? '厂级' : '车间级', workshop: WS[i % 2], model: PD[i % 2],
225
+ topic: '昨日问题日清:' + ISSUE_TPL[i % ISSUE_TPL.length][3],
226
+ attendees: 5 + (i % 4), problem: ISSUE_TPL[i % ISSUE_TPL.length][6],
227
+ tempAction: '当班隔离 + 100% 复检', owner: MEMBERS[i % MEMBERS.length][0],
228
+ responseHours: 1, dueHours: 24, status: i % 4 === 0 ? 'closed' : 'open',
229
+ createdAt: iso(d), updatedAt: iso(d), location: WS[i % 2] + ' 班前会区',
230
+ minutes: '', tasks: [], responseAt: iso(new Date(d.getTime() + 3600000)),
231
+ closedAt: i % 4 === 0 ? iso(new Date(d.getTime() + 8 * 3600000)) : null,
232
+ });
233
+ }
234
+
235
+ // 待办
236
+ [['外径超上限首件确认', '赵大勇', 'A', 0], ['扳手扭矩校验记录补录', '陈立', 'B', 0],
237
+ ['客户异响投诉回复草稿', '吴倩', 'A', 1], ['来料厚度测点新增确认', '钱伟', 'B', -1],
238
+ ['QC 小组活动记录(本周)', '王芳', 'C', 0]].forEach((t, i) => {
239
+ store.db.todos.push({
240
+ id: 'TD-S-' + stamp(1 + i), user: t[1], title: t[0], priority: t[2], link: '',
241
+ dueAt: iso(dayAgo(-t[3], 17)), done: false, createdAt: iso(dayAgo(1)), source: '本平台',
242
+ });
243
+ });
244
+
245
+ // 审批(中小厂审批链短:质量主管 + 厂长)
246
+ [['永久对策审批', '#QP-S002 扭矩波动 - 扳手校验纳入日常', '陈立', 'pending', '费用 ¥0.3 万,月度节省返工 ¥1.1 万。'],
247
+ ['客户投诉闭环', '#QP-S001 定位销漏装 - 客户 8D 回复', '孙鹏', 'pending', '已回复客户,等待关闭确认。'],
248
+ ['改善提案奖励', '郭亮:冲压废料分类回收提案', '赵大勇', 'approved', '月省废料处理费 ¥0.18 万,奖励 ¥300。']].forEach((w, i) => {
249
+ const d = dayAgo(i, 10);
250
+ store.db.workflows.push({
251
+ id: 'OA-S-' + stamp(1 + i), type: w[0], title: w[1], applicant: w[2], status: w[3],
252
+ relatedId: i === 0 ? '#QP-S002' : i === 1 ? '#QP-S001' : '', content: w[4],
253
+ approvers: [{ name: '周建国', role: '质量主管', status: w[3] === 'pending' ? 'pending' : 'approved', at: w[3] === 'pending' ? null : iso(d) },
254
+ { name: '厂长', role: '厂长', status: w[3] === 'approved' ? 'approved' : 'pending', at: w[3] === 'approved' ? iso(new Date(d.getTime() + 5400000)) : null }],
255
+ createdAt: iso(d), updatedAt: iso(d), urgent: i === 0,
256
+ aiSummary: '投入小、回收快,建议批准。',
257
+ });
258
+ });
259
+
260
+ // 收益台账
261
+ [['#QP-S005', '质量成本', 3.6, '2026-10', 'verified', '防潮改善后报废率由 2.1% 降至 0.6%'],
262
+ ['#QP-S003', '报废降损', 9.4, '2026-11', 'pending', '外径过盈返工减少,按 12 个月摊销'],
263
+ ['#QP-S002', '返工工时', 1.1, '2026-11', 'pending', '扭矩复检工时下降'],
264
+ ['#QP-S004', '来料索赔', 2.2, '2026-10', 'verified', '供应商厚度超差索赔回收']].forEach((b, i) => {
265
+ const p = store.db.projects.find((x) => x.id === b[0]) || {};
266
+ store.db.benefits.push({
267
+ id: 'BN-S-' + stamp(1 + i), projectId: b[0], projectTitle: p.title || '', type: b[1],
268
+ amount: b[2], period: b[3], status: b[4], note: b[5],
269
+ createdAt: iso(dayAgo(10 + i * 4)), updatedAt: iso(dayAgo(1)),
270
+ formula: '收益 =(改善前损失 - 改善后损失)× 月产量', verifiedBy: b[4] === 'verified' ? '财务(兼)' : '',
271
+ verifiedAt: b[4] === 'verified' ? iso(dayAgo(3)) : null, aiDriven: false,
272
+ });
273
+ });
274
+
275
+ // 知识库
276
+ KNOWLEDGE.forEach((k, i) => {
277
+ store.db.knowledge.push({
278
+ id: '#C-S-' + stamp(1 + i), type: k[0], title: k[1], category: k[2], tags: k[3], views: k[4],
279
+ summary: k[1], content: '【' + k[0] + '】' + k[1] + ':本厂实操做法,详见现场作业指导书与点检表。',
280
+ author: MEMBERS[i % MEMBERS.length][0], source: '本厂经验沉淀',
281
+ createdAt: iso(dayAgo(20 + i * 3)), updatedAt: iso(dayAgo(2)), attachments: [], status: 'published',
282
+ });
283
+ });
284
+
285
+ // AI 质检缺陷(中小厂用低成本视觉检测,量小)
286
+ for (let i = 0; i < 12; i++) {
287
+ store.db.defects.push({
288
+ id: 'DF-S-' + stamp(1 + i), ts: iso(dayAgo(i % 6, 10 + i)),
289
+ model: PD[i % 2], workshop: WS[i % 2], station: (i % 2 ? '二车间·装配线' : '一车间·冲压线'),
290
+ type: i % 3 === 0 ? '外观-划伤' : i % 3 === 1 ? '尺寸-超差' : '装配-漏装',
291
+ confidence: 0.81 + (i % 8) / 100, image: '', status: i % 4 === 0 ? '已确认' : '待复核',
292
+ reviewer: MEMBERS[i % MEMBERS.length][0], note: 'AI 初判,需人工复核',
293
+ });
294
+ }
295
+
296
+ // 审计
297
+ for (let i = 0; i < 8; i++) {
298
+ store.db.audit.push({
299
+ id: 'AU-S-' + stamp(1 + i), ts: iso(dayAgo(i, 8)), user: ['周建国', '陈立', '刘畅', '王芳'][i % 4],
300
+ plugin: ['本平台', '@MES', '知识库'][i % 3],
301
+ action: ['查询测量数据', '控制图判异', '案例检索', '发起审批'][i % 4],
302
+ params: {}, resultSummary: '初始审计记录', purpose: '初始数据初始化',
303
+ });
304
+ }
305
+
306
+ store.saveSync(true);
307
+ return {
308
+ scale: 'sme',
309
+ issues: store.db.issues.length,
310
+ projects: store.db.projects.length,
311
+ measurements: store.db.measurements.length,
312
+ knowledge: store.db.knowledge.length,
313
+ members: store.db.members.length,
314
+ };
315
+ }
316
+
317
+ module.exports = { seedSme, SME_WORKSHOPS: WS, SME_PRODUCTS: PD };