feat(validation): add source number validation checks with localized error messages
Add validation to detect and report when no order numbers are found from Production IDs (either from shared inputs or file). Provides clear Chinese error messages to guide users when their inputs don't match any database records. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -291,12 +291,38 @@ export function registerValidationHandlers(): void {
|
|||||||
|
|
||||||
sourceNumbers = await getSourceNumbersFromInputs(sharedIds, dbService)
|
sourceNumbers = await getSourceNumbersFromInputs(sharedIds, dbService)
|
||||||
log.info(`Got ${sourceNumbers.length} source numbers from shared Production IDs`)
|
log.info(`Got ${sourceNumbers.length} source numbers from shared Production IDs`)
|
||||||
|
|
||||||
|
// Check if we got any order numbers from the shared Production IDs
|
||||||
|
if (sourceNumbers.length === 0) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: '共享的 Production ID 没有找到对应的订单数据。请确保在数据提取页面输入了有效的 Production ID 并成功获取了订单数据。',
|
||||||
|
stats: {
|
||||||
|
totalRecords: 0,
|
||||||
|
matchedCount: 0,
|
||||||
|
markedCount: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (request.productionIdFile) {
|
} else if (request.productionIdFile) {
|
||||||
// Read from file
|
// Read from file
|
||||||
const inputs = readProductionIds(request.productionIdFile)
|
const inputs = readProductionIds(request.productionIdFile)
|
||||||
log.info(`Read ${inputs.length} inputs from file`)
|
log.info(`Read ${inputs.length} inputs from file`)
|
||||||
sourceNumbers = await getSourceNumbersFromInputs(inputs, dbService)
|
sourceNumbers = await getSourceNumbersFromInputs(inputs, dbService)
|
||||||
log.info(`Got ${sourceNumbers.length} source numbers`)
|
log.info(`Got ${sourceNumbers.length} source numbers`)
|
||||||
|
|
||||||
|
// Check if we got any order numbers from the file
|
||||||
|
if (sourceNumbers.length === 0) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: '文件中的 Production ID 没有找到对应的订单数据。请检查 Production ID 是否正确,或确保数据库中有对应的订单数据。',
|
||||||
|
stats: {
|
||||||
|
totalRecords: 0,
|
||||||
|
matchedCount: 0,
|
||||||
|
markedCount: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +342,7 @@ export function registerValidationHandlers(): void {
|
|||||||
if (materialRecords.length === 0) {
|
if (materialRecords.length === 0) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
error: 'No material records found',
|
error: '未找到物料记录。请检查数据库中是否有对应订单的物料数据。',
|
||||||
stats: {
|
stats: {
|
||||||
totalRecords: 0,
|
totalRecords: 0,
|
||||||
matchedCount: 0,
|
matchedCount: 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user