Skip to content

Commit 2697e42

Browse files
feat(validators): checkTestDate
1 parent afb2d8d commit 2697e42

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { CheckResult } from '../lithium/shared/types'
2+
3+
export function checkTestDate(
4+
test_date: string,
5+
): CheckResult[] {
6+
// 解析输入的日期
7+
if(test_date === null) {
8+
return []
9+
}
10+
const inputDate = new Date(test_date)
11+
const today = new Date()
12+
today.setHours(23, 59, 59, 999)
13+
const diffTime = inputDate.getTime() - today.getTime()
14+
15+
const result: CheckResult[] = []
16+
if (diffTime > 0) {
17+
result.push({
18+
ok: false,
19+
result: '签发日期晚于今天',
20+
})
21+
}
22+
return result
23+
}

packages/validators/src/summary/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { PekSodiumData, SekSodiumData } from '../sodium/shared/types'
4343
import { checkTests } from './checkTests'
4444
import { checkT1_6 } from './checkT1_6'
4545
import { checkContactInfo } from './checkContactInfo'
46+
import { checkTestDate } from './checkTestDate'
4647

4748
export function checkSekAttachment(
4849
currentData: SekData | SekSodiumData,
@@ -297,6 +298,7 @@ function checkSummaryFromLLM(
297298
summaryData.consignorInfo === '' ? summaryData.consignor : summaryData.consignorInfo,
298299
summaryData.manufacturerInfo === '' ? summaryData.manufacturer : summaryData.manufacturerInfo,
299300
))
301+
results.push(...checkTestDate(summaryData.testDate))
300302
results.push(...checkMarket(market, summaryData.testReportNo))
301303
// @ts-ignore
302304
results.push(...checkUN38fg(summaryData.un38F ?? summaryData.un38f, summaryData.un38G ?? summaryData.un38g))

0 commit comments

Comments
 (0)