You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
using DS.Module.Core ;
using DS.WMS.Core.Sys.Entity ;
using Microsoft.AspNetCore.Hosting ;
using Microsoft.Extensions.Configuration ;
using Microsoft.Extensions.DependencyInjection ;
using SqlSugar ;
namespace DS.WMS.Core.HangfireJob.Method
{
/// <summary>
/// WSL报表服务
/// </summary>
public class WSLReportJobService
{
static readonly ApiFox api ;
ISqlSugarClient ? db ;
IConfiguration configuration ;
IWebHostEnvironment hostEnvironment ;
static WSLReportJobService ( )
{
api = new ApiFox ( ) ;
}
/// <summary>
/// 初始化
/// </summary>
/// <param name="serviceProvider"></param>
public WSLReportJobService ( IServiceProvider serviceProvider )
{
db = serviceProvider . GetRequiredService < ISqlSugarClient > ( ) ;
configuration = serviceProvider . GetRequiredService < IConfiguration > ( ) ;
hostEnvironment = serviceProvider . GetRequiredService < IWebHostEnvironment > ( ) ;
}
/// <summary>
/// 生成报表
/// </summary>
/// <returns></returns>
public async Task GeneratReportAsync ( )
{
db . QueryFilter . Clear ( ) ;
var dbLinks = await db . Queryable < Module . SqlSugar . SysTenantLink > ( ) . ToListAsync ( ) ;
SqlSugarClient ? tenantDb = null ;
try
{
foreach ( var dbLink in dbLinks )
{
var adminUser = await db . Queryable < SysUser > ( )
. Where ( x = > x . TenantId = = dbLink . TenantId & & x . Status = = 0 & & x . UserType = = 1 )
. OrderByDescending ( x = > x . CreateTime )
. Select ( x = > new
{
x . Id ,
x . UserName ,
x . Password ,
x . DefaultOrgId ,
x . DefaultOrgName ,
x . TenantId ,
x . TenantName
} ) . FirstAsync ( ) ;
if ( adminUser = = null )
{
Console . WriteLine ( $"未能获取租户系统管理员, 租户ID: {dbLink.TenantId}" ) ;
continue ;
}
}
}
finally
{
tenantDb ? . Dispose ( ) ;
}
}
}
}