feat(签署方式): 扩展为手写板/短信/Pad/公众号四种并集中口径

This commit is contained in:
yelan
2026-09-25 12:09:58 +08:00
parent bd89a4d31a
commit 8ec55e48c9
26 changed files with 1864 additions and 688 deletions
@@ -182,6 +182,36 @@ function pickStatus(random: () => number): SigningTaskStatus {
return 'signed'
}
/**
* 四种签署方式的抽样权重。
*
* 现场两种(手写板 / Pad)占比高,线上两种(短信 / 公众号)略低 —— 四种都要出现,
* 否则「签署方式分布」这个报表维度会缺行,演示时看不到新方式。
* 权重和不必是 100,`pickMethod` 会自己算总和。
*/
const METHOD_WEIGHTS: readonly { method: SigningMethod; weight: number }[] = [
{ method: 'pad', weight: 38 },
{ method: 'ipad', weight: 24 },
{ method: 'sms', weight: 26 },
{ method: 'wx', weight: 12 },
]
const METHOD_TOTAL_WEIGHT = METHOD_WEIGHTS.reduce((sum, item) => sum + item.weight, 0)
function pickMethod(random: () => number): SigningMethod {
let roll = random() * METHOD_TOTAL_WEIGHT
for (const item of METHOD_WEIGHTS) {
roll -= item.weight
if (roll <= 0) {
return item.method
}
}
return 'pad'
}
function pad(value: number): string {
return String(value).padStart(2, '0')
}
@@ -219,7 +249,8 @@ function buildTasks(): ReportTaskRow[] {
const patient = pick(random, DEMO_PATIENTS)
const document = pick(random, mockDocumentCatalog)
const status = pickStatus(random)
const method: SigningMethod = random() < 0.45 ? 'pad' : 'sms'
// 四种方式按现场/线上偏重的权重抽,保证「签署方式分布」四个维度都有量
const method = pickMethod(random)
// 越靠近今天的任务越少:真实签署量不会是均匀分布,均匀分布的趋势图一眼假
const daysAgo = Math.floor(DEMO_SPAN_DAYS * Math.pow(random(), 1.35))