fix 部门数移除厂区节点
This commit is contained in:
@@ -1,20 +1,16 @@
|
|||||||
using Dlhis.Basic.Organization.Response;
|
using Dlhis.Basic.Organization.Response;
|
||||||
using Dlhis.Entity.Basic.Entity;
|
using Dlhis.Entity.Basic.Entity;
|
||||||
using Dlhis.Sys.Api;
|
|
||||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||||
using Mapster;
|
|
||||||
|
|
||||||
namespace Dlhis.Basic.Organization.Services.Implements;
|
namespace Dlhis.Basic.Organization.Services.Implements;
|
||||||
|
|
||||||
public class DepartmentService : IDepartmentService
|
public class DepartmentService : IDepartmentService
|
||||||
{
|
{
|
||||||
private readonly IDbContext _dbContext;
|
private readonly IDbContext _dbContext;
|
||||||
private readonly ITenantApi _tenantApi;
|
|
||||||
|
|
||||||
public DepartmentService(IDbContext dbContext, ITenantApi tenantApi)
|
public DepartmentService(IDbContext dbContext)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_tenantApi = tenantApi;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<DepartmentTreeResponse>> GetTreeAsync()
|
public async Task<List<DepartmentTreeResponse>> GetTreeAsync()
|
||||||
@@ -23,29 +19,8 @@ public class DepartmentService : IDepartmentService
|
|||||||
//00001000 一定是这个开头的
|
//00001000 一定是这个开头的
|
||||||
var tops = departments.Where(x => x.PNo == "00001000").ToList();
|
var tops = departments.Where(x => x.PNo == "00001000").ToList();
|
||||||
|
|
||||||
tops.ForEach(x =>
|
tops.ForEach(x => { RecursionGetNext(x, departments); });
|
||||||
{
|
return tops;
|
||||||
RecursionGetNext(x, departments);
|
|
||||||
});
|
|
||||||
|
|
||||||
var myTenantResult = await _tenantApi.GetMyTenantsAsync();
|
|
||||||
var tenants = myTenantResult.Data;
|
|
||||||
|
|
||||||
return tenants.Select(x => new DepartmentTreeResponse
|
|
||||||
{
|
|
||||||
Name = x.Name,
|
|
||||||
No = x.Code,
|
|
||||||
PNo = null,
|
|
||||||
Tenant = x.Code,
|
|
||||||
CurrentNext = tops.Select(item =>
|
|
||||||
{
|
|
||||||
var i = item.Adapt<DepartmentTreeResponse>();
|
|
||||||
i.PNo = x.Code;
|
|
||||||
return i;
|
|
||||||
|
|
||||||
}).ToList()
|
|
||||||
})
|
|
||||||
.ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//***************************************************** help methods ****************************************************************
|
//***************************************************** help methods ****************************************************************
|
||||||
@@ -53,13 +28,10 @@ public class DepartmentService : IDepartmentService
|
|||||||
private static void RecursionGetNext(DepartmentTreeResponse current, List<DepartmentTreeResponse> data)
|
private static void RecursionGetNext(DepartmentTreeResponse current, List<DepartmentTreeResponse> data)
|
||||||
{
|
{
|
||||||
var next = data.Where(x => x.PNo == current.No).ToList();
|
var next = data.Where(x => x.PNo == current.No).ToList();
|
||||||
if (next.Any())
|
current.CurrentNext = next;
|
||||||
|
foreach (var item in next)
|
||||||
{
|
{
|
||||||
current.CurrentNext = next;
|
RecursionGetNext(item, data);
|
||||||
foreach (var item in next)
|
|
||||||
{
|
|
||||||
RecursionGetNext(item, data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,17 +59,17 @@ public class SqlSugarPack : BaseAppPack
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
using var scope = app.ApplicationServices.CreateScope();
|
// using var scope = app.ApplicationServices.CreateScope();
|
||||||
var db = scope.ServiceProvider.GetService<IDbContext>();
|
// var db = scope.ServiceProvider.GetService<IDbContext>();
|
||||||
var tables = App.ActiveTypes.Where(x => x.IsDefined(typeof(SugarTable), false))
|
// var tables = App.ActiveTypes.Where(x => x.IsDefined(typeof(SugarTable), false))
|
||||||
.Where(x => !x.IsDefined(typeof(SkipScanAttribute), false))
|
// .Where(x => !x.IsDefined(typeof(SkipScanAttribute), false))
|
||||||
.ToArray();
|
// .ToArray();
|
||||||
|
//
|
||||||
db.Client.DbMaintenance.CreateDatabase();
|
// db.Client.DbMaintenance.CreateDatabase();
|
||||||
db.Client.CodeFirst.InitTables(tables);
|
// db.Client.CodeFirst.InitTables(tables);
|
||||||
|
//
|
||||||
var faceDb = db.ChangeDb("face");
|
// var faceDb = db.ChangeDb("face");
|
||||||
faceDb.Client.DbMaintenance.CreateDatabase();
|
// faceDb.Client.DbMaintenance.CreateDatabase();
|
||||||
faceDb.Client.CodeFirst.InitTables<GainfoFaceEntity>();
|
// faceDb.Client.CodeFirst.InitTables<GainfoFaceEntity>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user