using JiepeiWMS.IServices; using JiepeiWMS.Model.Models; using JiepeiWMS.Services.BASE; using JiepeiWMS.IRepository.Base; using System.Threading.Tasks; using JiepeiWMS.Model; using System.Linq.Expressions; using System; using JiepeiWMS.Extends; using SqlSugar; using JiepeiWMS.Common.Enums; using JiepeiWMS.Common.Helper; using JiepeiWMS.Common.HttpContextUser; using System.Security.Claims; namespace JiepeiWMS.Services { public class WMInInventoryServices : BaseServices, IWMInInventoryServices { private readonly IBaseRepository _dal; private readonly ISysUserInfoServices _sysUserInfoServices; readonly IUser _user; public WMInInventoryServices(IBaseRepository dal, ISysUserInfoServices sysUserInfoServices, IUser user) { this._dal = dal; base.BaseDal = dal; _sysUserInfoServices = sysUserInfoServices; _user = user; } /// /// 获取入库单分页 /// /// public async Task> GetWMInInventoryPage(int page, int intPageSize, string department = "", string wareHouse = "", string supplier = "", string outInType = "") { Expression> whereExpression = InInventory => InInventory.Id > 0; //获取角色信息,判断是否数据展示 var role = string.Join(",", _user.GetClaimValueByType(ClaimTypes.Role)); if (role.Contains("SuperAdmin") || role.Contains("超级管理员") || role.Contains("仓库管理员")) { } else { whereExpression = whereExpression.And(InInventory => InInventory.EmployeeId == _user.ID); } //筛选主体Id var userInfoModel = await _sysUserInfoServices.QueryById(_user.ID); if (userInfoModel != null) { whereExpression = whereExpression.And(InInventory => InInventory.SysOrgId == userInfoModel.SysOrgId); } if (!string.IsNullOrWhiteSpace(department)) { whereExpression = whereExpression.And(InInventory => InInventory.DepartmentId == department.ObjToInt()); } if (!string.IsNullOrWhiteSpace(wareHouse)) { whereExpression = whereExpression.And(InInventory => InInventory.WareHouseId == wareHouse.ObjToInt()); } if (!string.IsNullOrWhiteSpace(supplier)) { whereExpression = whereExpression.And(InInventory => InInventory.SupplierId == supplier.ObjToInt()); } if (!string.IsNullOrWhiteSpace(outInType)) { whereExpression = whereExpression.And(InInventory => InInventory.OutInType == outInType.ObjToInt()); } var PageList = await base.QueryTabsPage( (InInventory, Department, Supplier, WareHouse, UserInfo) => new object[] { JoinType.Left,InInventory.DepartmentId==Department.Id, JoinType.Left,InInventory.SupplierId==Supplier.Id, JoinType.Left,InInventory.WareHouseId==WareHouse.Id, JoinType.Left,InInventory.AdminId==UserInfo.uID, }, (InInventory, Department, Supplier, WareHouse, UserInfo) => new WMInInventory() { Id = InInventory.Id, InInventoryCode = InInventory.InInventoryCode, OutInType = InInventory.OutInType, EmployeeId = InInventory.EmployeeId, WareHouseId = InInventory.WareHouseId, DepartmentId = InInventory.DepartmentId, SupplierId = InInventory.SupplierId, InTime = InInventory.InTime, Remark = InInventory.Remark, CreateTime = InInventory.CreateTime, SysOrgId = InInventory.SysOrgId, WareHouseName = WareHouse.Name, DepartmentName = Department.Name, SupplierName = Supplier.Name, AdminName = UserInfo.uRealName, }, whereExpression, page, intPageSize, " InInventory.Id desc" ); foreach (var item in PageList.data) { var dicType = typeof(EnumWMInInventoryType)._GetValueDescriptionDicFromEnumType(); string name; item.OutInTypeName = dicType.TryGetValue((EnumWMInInventoryType)item.OutInType, out name) ? name : string.Empty; var UserInfoModel = await _sysUserInfoServices.QueryById(item.EmployeeId); if (UserInfoModel != null) item.EmployeeName = UserInfoModel.uRealName; } return PageList; } } }