fix: 精简盘点钉钉通知格式
This commit is contained in:
parent
e1eb946506
commit
963dcc06af
@ -0,0 +1,22 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { formatInventoryTaskDingTalkContent } from '../inventoryService'
|
||||
|
||||
test('盘点钉钉通知按任务、截止和待办分块展示', () => {
|
||||
const content = formatInventoryTaskDingTalkContent({
|
||||
title: '盘点测试999',
|
||||
deadlineAt: new Date('2026-07-22T08:59:00.000Z'),
|
||||
itemCount: 11
|
||||
})
|
||||
|
||||
assert.equal(
|
||||
content,
|
||||
[
|
||||
'**任务:** 盘点测试999',
|
||||
'**截止:** 2026年7月22日 16:59',
|
||||
'**待办:** 扫描本人名下 11 件资产',
|
||||
'未找到或不在本人处,直接标记异常。'
|
||||
].join('\n\n')
|
||||
)
|
||||
assert.doesNotMatch(content, /责任人|部门|操作要求/)
|
||||
})
|
||||
@ -111,6 +111,17 @@ const INVENTORY_PARTICIPANT_STATUS = {
|
||||
|
||||
const EXCLUDED_EQUIPMENT_STATUSES = ['已报废']
|
||||
|
||||
export const formatInventoryTaskDingTalkContent = (input: {
|
||||
title: string
|
||||
deadlineAt: Date | null
|
||||
itemCount: number
|
||||
}) => [
|
||||
`**任务:** ${input.title}`,
|
||||
`**截止:** ${input.deadlineAt ? formatBeijingDateTime(input.deadlineAt) : '未设置'}`,
|
||||
`**待办:** 扫描本人名下 ${input.itemCount} 件资产`,
|
||||
'未找到或不在本人处,直接标记异常。'
|
||||
].join('\n\n')
|
||||
|
||||
const buildScopeWhere = ({ departmentIds }: NormalizedInventoryScopeInput) => {
|
||||
const where: Record<string, any> = {
|
||||
status: {
|
||||
@ -1019,15 +1030,13 @@ export const createInventoryTask = async (
|
||||
dingTalkRecipients,
|
||||
dingTalk: {
|
||||
title: '资产盘点待完成',
|
||||
content: [
|
||||
`盘点任务:${title}`,
|
||||
`责任人:${participant.person_nickname}|${participant.department_name || '未归属部门'}`,
|
||||
`待盘资产:${participantItemCount} 件`,
|
||||
`截止时间:${deadlineAt ? formatBeijingDateTime(deadlineAt) : '未设置'}`,
|
||||
'操作要求:打开任务后使用手机摄像头扫描资产二维码;未找到或不在本人处的资产请直接上报异常。'
|
||||
].join('\n'),
|
||||
actionTitle: '打开并开始盘点',
|
||||
messageVersion: 'v1'
|
||||
content: formatInventoryTaskDingTalkContent({
|
||||
title,
|
||||
deadlineAt,
|
||||
itemCount: participantItemCount
|
||||
}),
|
||||
actionTitle: '开始盘点',
|
||||
messageVersion: 'structured-v2'
|
||||
},
|
||||
rollout: notificationRollout
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user