fix 处理同步时间,调整到5点

This commit is contained in:
2025-05-24 20:29:49 +08:00
parent 55f68d2009
commit ac88ae7a3b
2 changed files with 17 additions and 29 deletions

View File

@@ -104,19 +104,7 @@ public class BalanceRecordUploadBackgroundService : BackgroundService
try
{
if (now is { Hour: 4, Minute: 1 }
&& !_healthCheckService.GetIsOffline()
&& !await db.Queryable<LocalBalanceRecordEntity>().Where(x => !x.IsSync).AnyAsync())
{
await ds.InitAsync(factories);
}
else if (now is { Hour: 15, Minute: 1 }
&& !_healthCheckService.GetIsOffline()
&& !await db.Queryable<LocalBalanceRecordEntity>().Where(x => !x.IsSync).AnyAsync())
{
await ds.InitAsync(factories);
}
else if (now is { Hour: 20, Minute: 1 }
if (now is { Hour: 5, Minute: 1 }
&& !_healthCheckService.GetIsOffline()
&& !await db.Queryable<LocalBalanceRecordEntity>().Where(x => !x.IsSync).AnyAsync())
{

View File

@@ -39,20 +39,20 @@ public class Startup : DefaultStartup
{
base.Configure(app, env);
var healthCheckService = app.ApplicationServices.GetService<IHealthCheckService>();
if (healthCheckService.DoHealthCheckAsync().GetAwaiter().GetResult())
{
using var scope = app.ApplicationServices.CreateScope();
var db = scope.ServiceProvider.GetService<IDbContext>();
db.Client.DbMaintenance.CreateDatabase();
db.Client.CodeFirst.InitTables<LocalBalanceRecordEntity, LocalGainfoEntity, LocalGainfoMealEntity, LocalBusinessPlaceEntity>();
db.Client.CodeFirst.InitTables<LocalBusinessShiftEntity, LocalDeviceRegistryEntity, LocalDeviceEntity, LocalBusinessPlaceShiftRelationshipEntity, LocalBusinessShiftMealRelationshipEntity>();
db.Client.CodeFirst.InitTables<LocalCanteenSettingEntity, LocalDepartmentEntity>();
var factories = scope.ServiceProvider.GetService<ISettingService>().GetFactories();
var ds = scope.ServiceProvider.GetService<IDataDownloadService>();
ds.InitAsync(factories).Wait();
}
// var healthCheckService = app.ApplicationServices.GetService<IHealthCheckService>();
// if (healthCheckService.DoHealthCheckAsync().GetAwaiter().GetResult())
// {
// using var scope = app.ApplicationServices.CreateScope();
// var db = scope.ServiceProvider.GetService<IDbContext>();
//
// db.Client.DbMaintenance.CreateDatabase();
// db.Client.CodeFirst.InitTables<LocalBalanceRecordEntity, LocalGainfoEntity, LocalGainfoMealEntity, LocalBusinessPlaceEntity>();
// db.Client.CodeFirst.InitTables<LocalBusinessShiftEntity, LocalDeviceRegistryEntity, LocalDeviceEntity, LocalBusinessPlaceShiftRelationshipEntity, LocalBusinessShiftMealRelationshipEntity>();
// db.Client.CodeFirst.InitTables<LocalCanteenSettingEntity, LocalDepartmentEntity>();
//
// var factories = scope.ServiceProvider.GetService<ISettingService>().GetFactories();
// var ds = scope.ServiceProvider.GetService<IDataDownloadService>();
// ds.InitAsync(factories).Wait();
// }
}
}