设备导入卡槽不对的问题

This commit is contained in:
2026-04-30 11:56:09 +08:00
parent 9238eeb56e
commit 8a3c45c577
10 changed files with 478 additions and 32 deletions

View File

@@ -48,7 +48,13 @@ type DeviceRow struct {
DeviceType string
MaxSimSlots int
Manufacturer string
ICCIDs []string
SlotICCIDs []DeviceSlotICCID
}
// DeviceSlotICCID 设备槽位与 ICCID 的映射
type DeviceSlotICCID struct {
SlotPosition int
ICCID string
}
var (
@@ -149,18 +155,21 @@ func ParseDeviceExcel(filePath string) (*DeviceParseResult, error) {
row.Manufacturer = getCol(5)
maxSimSlotsStr := getCol(6)
row.ICCIDs = make([]string, 0, 4)
row.SlotICCIDs = make([]DeviceSlotICCID, 0, 4)
for j := 7; j <= 10; j++ {
iccid := getCol(j)
if iccid != "" {
row.ICCIDs = append(row.ICCIDs, iccid)
row.SlotICCIDs = append(row.SlotICCIDs, DeviceSlotICCID{
SlotPosition: j - 6,
ICCID: iccid,
})
}
}
// 整行目标列皆为空,视为空行跳过,不计入 total
if row.VirtualNo == "" && row.DeviceName == "" && row.DeviceModel == "" &&
row.DeviceType == "" && row.IMEI == "" && row.Manufacturer == "" &&
maxSimSlotsStr == "" && len(row.ICCIDs) == 0 {
maxSimSlotsStr == "" && len(row.SlotICCIDs) == 0 {
continue
}
@@ -192,7 +201,20 @@ func ParseDeviceExcel(filePath string) (*DeviceParseResult, error) {
continue
}
for _, slotICCID := range row.SlotICCIDs {
if slotICCID.SlotPosition > row.MaxSimSlots {
parseResult.ParseErrors = append(parseResult.ParseErrors, CSVParseError{
Line: lineNum,
ICCID: slotICCID.ICCID,
Reason: "卡槽填写超出最大SIM槽数",
})
goto nextDeviceRow
}
}
parseResult.Rows = append(parseResult.Rows, row)
nextDeviceRow:
}
return parseResult, nil