feat: 新增数据库迁移,重命名 device_no 为 virtual_no,新增 iot_card.virtual_no 和 package.virtual_ratio 字段
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m3s

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-03-14 18:27:28 +08:00
parent b5147d1acb
commit b9c3875c08
77 changed files with 5832 additions and 2393 deletions

View File

@@ -180,7 +180,7 @@ func (h *DeviceImportHandler) processBatch(ctx context.Context, task *model.Devi
allICCIDs := make([]string, 0)
for _, row := range batch {
deviceNos = append(deviceNos, row.DeviceNo)
deviceNos = append(deviceNos, row.VirtualNo)
allICCIDs = append(allICCIDs, row.ICCIDs...)
}
@@ -190,7 +190,7 @@ func (h *DeviceImportHandler) processBatch(ctx context.Context, task *model.Devi
for _, row := range batch {
result.failedItems = append(result.failedItems, model.ImportResultItem{
Line: row.Line,
ICCID: row.DeviceNo,
ICCID: row.VirtualNo,
Reason: "数据库查询失败",
})
result.failCount++
@@ -218,10 +218,10 @@ func (h *DeviceImportHandler) processBatch(ctx context.Context, task *model.Devi
}
for _, row := range batch {
if existingDevices[row.DeviceNo] {
if existingDevices[row.VirtualNo] {
result.skippedItems = append(result.skippedItems, model.ImportResultItem{
Line: row.Line,
ICCID: row.DeviceNo,
ICCID: row.VirtualNo,
Reason: "设备号已存在",
})
result.skipCount++
@@ -251,7 +251,7 @@ func (h *DeviceImportHandler) processBatch(ctx context.Context, task *model.Devi
if len(row.ICCIDs) > 0 && len(cardIssues) > 0 {
result.failedItems = append(result.failedItems, model.ImportResultItem{
Line: row.Line,
ICCID: row.DeviceNo,
ICCID: row.VirtualNo,
Reason: "卡验证失败: " + strings.Join(cardIssues, ", "),
})
result.failCount++
@@ -263,7 +263,7 @@ func (h *DeviceImportHandler) processBatch(ctx context.Context, task *model.Devi
txBindingStore := postgres.NewDeviceSimBindingStore(tx, nil)
device := &model.Device{
DeviceNo: row.DeviceNo,
VirtualNo: row.VirtualNo,
DeviceName: row.DeviceName,
DeviceModel: row.DeviceModel,
DeviceType: row.DeviceType,
@@ -298,12 +298,12 @@ func (h *DeviceImportHandler) processBatch(ctx context.Context, task *model.Devi
if err != nil {
h.logger.Error("创建设备失败",
zap.String("device_no", row.DeviceNo),
zap.String("virtual_no", row.VirtualNo),
zap.Error(err),
)
result.failedItems = append(result.failedItems, model.ImportResultItem{
Line: row.Line,
ICCID: row.DeviceNo,
ICCID: row.VirtualNo,
Reason: "数据库写入失败: " + err.Error(),
})
result.failCount++
@@ -320,4 +320,4 @@ func (h *DeviceImportHandler) processBatch(ctx context.Context, task *model.Devi
}
}
var ErrMissingDeviceNoColumn = stderrors.New("CSV 缺少 device_no 列")
var ErrMissingDeviceNoColumn = stderrors.New("CSV 缺少 virtual_no 列")