fix(attendance): normalize DingTalk match statuses
Store and validate stable English status codes for unmatched, pending, and matched attendance records so import, filtering, and auto-match use the same values.
This commit is contained in:
@@ -228,7 +228,7 @@ export class AttendanceImportService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.matchStatus = '未处理';
|
entity.matchStatus = 'unmatched';
|
||||||
entity.rawData = JSON.stringify(r);
|
entity.rawData = JSON.stringify(r);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -344,14 +344,14 @@ export class AttendanceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
record.matchedStudentId = dto.studentId;
|
record.matchedStudentId = dto.studentId;
|
||||||
record.matchStatus = '已匹配';
|
record.matchStatus = 'matched';
|
||||||
return this.dingRawRepo.save(record);
|
return this.dingRawRepo.save(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Auto-match unmatched dingtalk records via dingUserId → userId mapping chain ──
|
// ── Auto-match unmatched dingtalk records via dingUserId → userId mapping chain ──
|
||||||
async autoMatchDingRecords(): Promise<{ matched: number; total: number }> {
|
async autoMatchDingRecords(): Promise<{ matched: number; total: number }> {
|
||||||
const unmatched = await this.dingRawRepo.find({
|
const unmatched = await this.dingRawRepo.find({
|
||||||
where: { matchStatus: '未处理' },
|
where: { matchStatus: 'unmatched' },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (unmatched.length === 0) return { matched: 0, total: 0 };
|
if (unmatched.length === 0) return { matched: 0, total: 0 };
|
||||||
@@ -369,7 +369,7 @@ export class AttendanceService {
|
|||||||
if (studentId == null) continue;
|
if (studentId == null) continue;
|
||||||
|
|
||||||
record.matchedStudentId = studentId;
|
record.matchedStudentId = studentId;
|
||||||
record.matchStatus = '已匹配';
|
record.matchStatus = 'matched';
|
||||||
await this.dingRawRepo.save(record);
|
await this.dingRawRepo.save(record);
|
||||||
matched++;
|
matched++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export class AttendanceCalendarQueryDto {
|
|||||||
export class QueryDingRawDto {
|
export class QueryDingRawDto {
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsIn(['未处理', '已匹配', '待匹配'])
|
@IsIn(['unmatched', 'pending', 'matched'])
|
||||||
matchStatus?: string;
|
matchStatus?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export class DingAttendanceRaw {
|
|||||||
@Column({ name: 'location_result', length: 20, nullable: true })
|
@Column({ name: 'location_result', length: 20, nullable: true })
|
||||||
locationResult: string;
|
locationResult: string;
|
||||||
|
|
||||||
@Column({ name: 'match_status', length: 20, default: '未处理' })
|
@Column({ name: 'match_status', length: 20, default: 'unmatched' })
|
||||||
matchStatus: string;
|
matchStatus: string;
|
||||||
|
|
||||||
@Column({ name: 'matched_student_id', type: 'integer', nullable: true })
|
@Column({ name: 'matched_student_id', type: 'integer', nullable: true })
|
||||||
|
|||||||
Reference in New Issue
Block a user