forked from wangziqi/gongxue-base
fix: 修复多处边界条件问题
- rooms: parseRoomNumber 未知格式返回默认 capacity=4,防止 undefined 绕过入住容量检查 - rooms: 修复 parseInt() || undefined 导致楼层 0 被吞掉 - rooms: batchImport 中 capacity 使用 ?? 代替 ||,显式 0 不被覆盖 - occupancies: 所有 capacity 比较加 ?? 0 防守兜底,fail closed - schedules: assertValidScheduleRange 增加 startTime > endTime 校验 - attendance: 时段重叠检查改为按 startTime 排序后再比较,消除漏检 - attendance: 移除 getScheduleOptionsForAttendance 中不可靠的 raw[index] fallback - expenses: 个人附加费批量导入增加 assertPositiveAmount 校验 - expenses: 水电费导入增加 periodEnd >= periodStart 校验
This commit is contained in:
@@ -349,7 +349,7 @@ export class RoomsController {
|
||||
rows.push({
|
||||
roomNumber: String(row.getCell(1).value || ''),
|
||||
building: String(row.getCell(2).value || '') || undefined,
|
||||
floor: Number(row.getCell(3).value) || undefined,
|
||||
floor: (n => Number.isNaN(n) ? undefined : n)(Number(row.getCell(3).value)),
|
||||
capacity: Number(row.getCell(4).value) || 4,
|
||||
roomType: String(row.getCell(5).value || '').trim() || undefined,
|
||||
rentalCategory,
|
||||
|
||||
@@ -50,7 +50,8 @@ export class RoomsService {
|
||||
if (familyMatch) {
|
||||
const bldg = `${familyMatch[1]}-${familyMatch[2]}栋`;
|
||||
const roomPart = familyMatch[3];
|
||||
const floor = parseInt(roomPart.charAt(0), 10) || undefined;
|
||||
const rawFloor = parseInt(roomPart.charAt(0), 10);
|
||||
const floor = Number.isNaN(rawFloor) ? undefined : rawFloor;
|
||||
return { building: bldg, floor, roomType: '家庭房', capacity: 4 };
|
||||
}
|
||||
// 标准: X-YZZ 格式
|
||||
@@ -58,7 +59,8 @@ export class RoomsService {
|
||||
if (stdMatch) {
|
||||
const bldgNum = stdMatch[1];
|
||||
const roomPart = stdMatch[2];
|
||||
const floor = parseInt(roomPart.charAt(0), 10) || undefined;
|
||||
const rawFloor = parseInt(roomPart.charAt(0), 10);
|
||||
const floor = Number.isNaN(rawFloor) ? undefined : rawFloor;
|
||||
const building = `${bldgNum}号楼`;
|
||||
let roomType = '四人间';
|
||||
let capacity = 4;
|
||||
@@ -71,7 +73,7 @@ export class RoomsService {
|
||||
}
|
||||
return { building, floor, roomType, capacity };
|
||||
}
|
||||
return {};
|
||||
return { capacity: 4, roomType: '四人间' };
|
||||
}
|
||||
|
||||
async findAll(query?: { building?: string; includeArchived?: boolean }) {
|
||||
@@ -374,7 +376,7 @@ export class RoomsService {
|
||||
roomNumber: row.roomNumber.trim(),
|
||||
building: row.building?.trim() || parsed.building || undefined,
|
||||
floor: row.floor ?? parsed.floor,
|
||||
capacity: row.capacity || parsed.capacity || 4,
|
||||
capacity: row.capacity ?? parsed.capacity ?? 4,
|
||||
roomType: row.roomType || parsed.roomType || undefined,
|
||||
rentalCategory: row.rentalCategory || undefined,
|
||||
monthlyRate: row.monthlyRate ?? undefined,
|
||||
|
||||
Reference in New Issue
Block a user