|
|
|
@ -17,6 +17,7 @@ namespace DS.WMS.Core.HangfireJob.Method
|
|
|
|
|
ISqlSugarClient? db;
|
|
|
|
|
IConfiguration configuration;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static FeeCustTemplateJobService()
|
|
|
|
|
{
|
|
|
|
|
api = new ApiFox();
|
|
|
|
@ -40,48 +41,39 @@ namespace DS.WMS.Core.HangfireJob.Method
|
|
|
|
|
{
|
|
|
|
|
db.QueryFilter.Clear();
|
|
|
|
|
var dbLinks = await db.Queryable<Module.SqlSugar.SysTenantLink>().ToListAsync();
|
|
|
|
|
SqlSugarClient? tenantDb = null;
|
|
|
|
|
try
|
|
|
|
|
foreach (var dbLink in dbLinks)
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"未能获取租户系统管理员,租户ID:{dbLink.TenantId}");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
x.Id,
|
|
|
|
|
x.UserName,
|
|
|
|
|
x.Password,
|
|
|
|
|
x.DefaultOrgId,
|
|
|
|
|
x.DefaultOrgName,
|
|
|
|
|
x.TenantId,
|
|
|
|
|
x.TenantName
|
|
|
|
|
}).FirstAsync();
|
|
|
|
|
|
|
|
|
|
var tokenModel = new JwtHelper.JwtTokenModel
|
|
|
|
|
{
|
|
|
|
|
Uid = adminUser.Id.ToString(),
|
|
|
|
|
Name = adminUser.UserName,
|
|
|
|
|
OrgId = adminUser.DefaultOrgId.ToString(),
|
|
|
|
|
TenantId = adminUser.TenantId.ToString(),
|
|
|
|
|
TenantName = adminUser.TenantName
|
|
|
|
|
};
|
|
|
|
|
var token = JwtHelper.Encrypt(tokenModel, false, true);
|
|
|
|
|
await SendRequestAsync(token);
|
|
|
|
|
if (adminUser == null)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"未能获取租户系统管理员,租户ID:{dbLink.TenantId}");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
tenantDb?.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var tokenModel = new JwtHelper.JwtTokenModel
|
|
|
|
|
{
|
|
|
|
|
Uid = adminUser.Id.ToString(),
|
|
|
|
|
Name = adminUser.UserName,
|
|
|
|
|
OrgId = adminUser.DefaultOrgId.ToString(),
|
|
|
|
|
TenantId = adminUser.TenantId.ToString(),
|
|
|
|
|
TenantName = adminUser.TenantName
|
|
|
|
|
};
|
|
|
|
|
var token = JwtHelper.Encrypt(tokenModel, false, true);
|
|
|
|
|
await SendRequestAsync(token);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal async Task SendRequestAsync(string token)
|
|
|
|
|