修复批量订购
This commit is contained in:
@@ -141,9 +141,24 @@ func run(ctx context.Context) error {
|
||||
if err := collectAfterCleanup(ctx, db, monthStart, monthEnd, &summary); err != nil {
|
||||
return err
|
||||
}
|
||||
if summary.TargetRowsAfterCleanup != 0 || summary.BoundaryRowsAfterCleanup != 6 || summary.CleanupMarkersAfter != int64(summary.Days*2) {
|
||||
if summary.TargetRowsAfterCleanup != 1 || summary.BoundaryRowsAfterCleanup != 6 || summary.CleanupMarkersAfter != int64(summary.Days*2) {
|
||||
return fmt.Errorf("清理范围复核失败: target=%d boundary=%d markers=%d", summary.TargetRowsAfterCleanup, summary.BoundaryRowsAfterCleanup, summary.CleanupMarkersAfter)
|
||||
}
|
||||
if err := db.WithContext(ctx).Model(&model.IntegrationLog{}).
|
||||
Where("integration_id = ?", "int_"+simulationPrefix+"-"+monthStart.Format("20060102")).
|
||||
Updates(map[string]any{"result": constants.IntegrationResultSuccess, "updated_at": time.Now()}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := service.RetainDate(ctx, monthStart, true); err != nil {
|
||||
return fmt.Errorf("pending 终结后的续跑清理演练失败: %w", err)
|
||||
}
|
||||
var remaining int64
|
||||
if err := db.WithContext(ctx).Model(&model.IntegrationLog{}).Where("created_at >= ? AND created_at < ?", monthStart, monthEnd).Count(&remaining).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if remaining != 0 {
|
||||
return fmt.Errorf("pending 终结后的续跑清理未完成,剩余 %d 条记录", remaining)
|
||||
}
|
||||
if err := syncRetentionLogger(); err != nil {
|
||||
return fmt.Errorf("刷新日留存仿真日志失败: %w", err)
|
||||
}
|
||||
@@ -270,16 +285,6 @@ func archiveMonth(ctx context.Context, db *gorm.DB, service *auditarchive.Servic
|
||||
if err := service.ArchiveDate(ctx, start); err != nil {
|
||||
return fmt.Errorf("Audit 故障重试演练失败: %w", err)
|
||||
}
|
||||
if err := db.WithContext(ctx).Model(&model.IntegrationLog{}).
|
||||
Where("integration_id = ?", "int_"+simulationPrefix+"-"+start.Format("20060102")).
|
||||
Updates(map[string]any{"result": constants.IntegrationResultSuccess, "updated_at": time.Now()}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
for date := start; date.Before(end); date = date.AddDate(0, 0, 1) {
|
||||
if err := service.FinalizeIntegrationDate(ctx, date); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user