optimize
wet 1 year ago
parent b945057789
commit 5c84fc6ce0

@ -380,7 +380,12 @@ namespace Myshipping.Application
.WhereIF(!string.IsNullOrWhiteSpace(input.ZhanCangFlag), u => u.ZhanCangFlag == input.ZhanCangFlag)
.WhereIF(saleUserList != null && saleUserList.Count > 0, o => saleUserList.Contains(o.SALEID))
.WhereIF(opUserList != null && opUserList.Count > 0, o => opUserList.Contains(o.OPID))
.WhereIF(userlist != null && userlist.Count() > 0, u => userlist.Contains((long)u.CreatedUserId) || UserManager.UserId.ToString() == u.ROUTEID || UserManager.Name.ToString() == u.ROUTE || UserManager.UserId.ToString() == u.SALEID || UserManager.Name.ToString() == u.SALE || UserManager.UserId.ToString() == u.OPID || UserManager.Name.ToString() == u.OP || UserManager.UserId.ToString() == u.DOCID || UserManager.Name.ToString() == u.DOC || UserManager.UserId.ToString() == u.CUSTSERVICEID || UserManager.Name.ToString() == u.CUSTSERVICE);
.WhereIF(userlist != null && userlist.Count() > 0, u => userlist.Contains((long)u.CreatedUserId)
|| UserManager.UserId.ToString() == u.ROUTEID || UserManager.Name.ToString() == u.ROUTE ||
UserManager.UserId.ToString() == u.SALEID || UserManager.Name.ToString() == u.SALE ||
UserManager.UserId.ToString() == u.OPID || UserManager.Name.ToString() == u.OP ||
UserManager.UserId.ToString() == u.DOCID || UserManager.Name.ToString() == u.DOC ||
UserManager.UserId.ToString() == u.CUSTSERVICEID || UserManager.Name.ToString() == u.CUSTSERVICE);
if (!string.IsNullOrEmpty(input.SortField) || input.MultiSort == null || input.MultiSort.Count == 0)
{
@ -426,15 +431,17 @@ namespace Myshipping.Application
}).ToList();
var statusloglist = _repStatuslog.AsQueryable().Filter(null, true).Where(x => (x.Status == "提箱" || x.Status == "返场") && x.IsDeleted == false).ToList();
var statuslogdetaillist = _statuslogdetail.AsQueryable().ToList();
var BookingStatusList= _repBookingStatus.AsQueryable().Filter(null, true).ToList();
var bookingremarkList = _bookingremark.AsQueryable().Filter(null, true).ToList();
foreach (var item in list.Items)
{
var sta = _repBookingStatus.AsQueryable().Filter(null, true).Where(x => x.BookingId == item.Id).ToList();
var sta = BookingStatusList.Where(x => x.BookingId == item.Id).ToList();
if (sta != null)
{
item.bookstatus = sta;
}
var st = _bookingremark.AsQueryable().Filter(null, true).Where(x => x.PId == item.Id).ToList();
var st = bookingremarkList.Where(x => x.PId == item.Id).ToList();
if (st != null)
{
item.bookremark = st;
@ -534,7 +541,6 @@ namespace Myshipping.Application
{
if (d.Status == "提箱")
{
CNTRNODtolist.Add(new CNTRNODto
{
BookingId = item.Id,

@ -50,7 +50,10 @@ public class CommonConst
/// </summary>
public const string CACHE_KEY_USERDATASCOPEZDY = "userdatascopezdy";
/// <summary>
/// 新 用户数据权限缓存(自定义)
/// </summary>
public const string CACHE_KEY_USERDATASCOPEZDY = "userdatascopezdy";
#region 公共数据库
/// <summary>

@ -1,6 +1,4 @@

using Furion.DependencyInjection;
using Furion.DependencyInjection;
using Myshipping.Core.Entity;
using SqlSugar;
using System.Collections.Generic;

@ -9,7 +9,6 @@ using SqlSugar;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Myshipping.Core.Service;
/// <summary>

@ -27,7 +27,7 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
private readonly SqlSugarRepository<SysOrg> _sysOrgRep; // 组织机构表仓储
private readonly SqlSugarRepository<SysEmp> _sysEmpRep; // 员工表仓储
private readonly SqlSugarRepository<SysUser> _sysuser; // 员工表
private readonly SqlSugarRepository<SysUserDataScope> _sysUserDataScopeRep; // 用户数据范围表仓储
private readonly SqlSugarRepository<SysUserDataScope> _sysUserDataScopeRep; // 自定义范围
public SysDataUserMenuService(SqlSugarRepository<SysDataUserMenu> rep, ISysCacheService sysCache, SqlSugarRepository<SysUser> sysuser, SqlSugarRepository<SysUserDataScope> sysUserDataScopeRep, SqlSugarRepository<SysEmp> sysEmpRep, SqlSugarRepository<SysOrg> sysOrgRep)
{
_rep = rep;
@ -157,6 +157,7 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
public async Task<List<long>> GetDataScopeList(long menuid,bool IsEdit=false)
{
List<SysDataUserMenu> list = new List<SysDataUserMenu>();
List<SysUserDataScope> zdylist = new List<SysUserDataScope>();
List<long> datascope = new List<long>();
if (_sysCache.Exists(CommonConst.CACHE_KEY_USERDATASCOPE))
{
@ -167,6 +168,16 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
list = await _rep.AsQueryable().ToListAsync();
_sysCache.Set(CommonConst.CACHE_KEY_USERDATASCOPE, list);
}
if (_sysCache.Exists(CommonConst.CACHE_KEY_USERDATASCOPEZDY))
{
zdylist = await _sysCache.GetAsync<List<SysUserDataScope>>(CommonConst.CACHE_KEY_USERDATASCOPEZDY);
}
else
{
zdylist = await _sysUserDataScopeRep.AsQueryable().ToListAsync();
_sysCache.Set(CommonConst.CACHE_KEY_USERDATASCOPEZDY, list);
}
DataScopeType _dataScopeType = list.Where(x => x.SysMenuId == menuid && x.SysUserId == UserManager.UserId).WhereIF(IsEdit == true, x => x.IsEdit == true).Select(x => x.DataScopeType).FirstOrDefault();
if (_dataScopeType == DataScopeType.ALL)
{
@ -191,8 +202,15 @@ public class SysDataUserMenuService : ISysDataUserMenu, IDynamicApiController, I
}
else if (_dataScopeType == DataScopeType.DEFINE)
{
datascope = await _sysUserDataScopeRep.AsQueryable().InnerJoin<SysEmp>((d, t) => d.SysOrgId == t.OrgId && d.SysMenuId == menuid && d.SysUserId == UserManager.UserId)
.WhereIF(IsEdit == true, (d, t) => d.IsEdit == true).Select((d, t) => t.Id).ToListAsync();
var sysorg= zdylist.Where(x => x.SysUserId == UserManager.UserId).Select(x => x.SysOrgId).ToList();
List<long> orglist=new List<long>();
foreach (var orgId in sysorg)
{
var o= _sysOrgRep.AsQueryable().Where(x => x.Pids.Contains(orgId.ToString())).Select(x => x.Id).ToList();
orglist = orglist.Union(o).ToList();
}
var useridlist = _sysEmpRep.AsQueryable().Where(x => orglist.Contains(x.OrgId)).Select(x => x.Id).ToList();
datascope = useridlist;
}
else
{

Loading…
Cancel
Save