fix 处理同步时间,调整到5点
This commit is contained in:
@@ -48,7 +48,7 @@ public class BalanceRecordUploadBackgroundService : BackgroundService
|
||||
var balanceRecords = await db.Queryable<LocalBalanceRecordEntity>()
|
||||
.Where(x => x.TenantId == factory)
|
||||
.Where(x => !x.IsSync).ToListAsync(stoppingToken);
|
||||
|
||||
|
||||
if (balanceRecords.Any())
|
||||
{
|
||||
_logger.LogInformation("上传离线订单");
|
||||
@@ -104,24 +104,12 @@ public class BalanceRecordUploadBackgroundService : BackgroundService
|
||||
|
||||
try
|
||||
{
|
||||
if (now is { Hour: 4, Minute: 1 }
|
||||
if (now is { Hour: 5, 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 }
|
||||
&& !_healthCheckService.GetIsOffline()
|
||||
&& !await db.Queryable<LocalBalanceRecordEntity>().Where(x => !x.IsSync).AnyAsync())
|
||||
{
|
||||
await ds.InitAsync(factories);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
// }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user