feat: 完善公司看板、菜单配置和项目访问
展示公司焊接统计,支持维护菜单和看板标题,并按用户权限限制项目入口。
This commit is contained in:
@@ -353,29 +353,8 @@
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
IQueryable<Model.Base_Project> getProjects = null;
|
||||
getProjects = from x in db.Base_Project
|
||||
where x.ProjectState == null || x.ProjectState == BLL.Const.ProjectState_1
|
||||
select x;
|
||||
|
||||
if (userId != Const.sysglyId && userId != Const.hfnbdId && userId != Const.sedinId)
|
||||
{
|
||||
var getUser = Person_PersonsService.GetPerson_PersonsById(userId);
|
||||
if (getUser != null && !string.IsNullOrEmpty(getUser.Account))
|
||||
{
|
||||
//List<string> roleidList = Funs.GetStrListByStr(getUser.RoleIds, ',');
|
||||
///// 获取角色类型
|
||||
//var getRoleP = db.Sys_RolePower.FirstOrDefault(x => roleidList.Contains(x.RoleId) && x.IsOffice == false);
|
||||
if (getUser.IsOffice != true)
|
||||
{
|
||||
var getProjectIdList = db.SitePerson_Person.Where(x => x.PersonId == userId && x.RoleIds != null).Select(x => x.ProjectId);
|
||||
if (getProjectIdList.Count() > 0)
|
||||
{
|
||||
getProjects = getProjects.Where(x => getProjectIdList.Contains(x.ProjectId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var getProjects = GetIndexProjectScope(db, userId)
|
||||
.Where(x => x.ProjectState == null || x.ProjectState == Const.ProjectState_1);
|
||||
|
||||
var pcount = (from x in db.Sys_Log
|
||||
where x.ProjectId != null && x.OperationTime > DateTime.Now.AddDays(-1)
|
||||
@@ -383,22 +362,49 @@
|
||||
select new { g.First().ProjectId, count = g.Count() }).Distinct();
|
||||
|
||||
|
||||
if (getProjects.Count() > 0)
|
||||
{
|
||||
var getList = (from x in getProjects
|
||||
join y in pcount on x.ProjectId equals y.ProjectId into PP
|
||||
from p in PP.DefaultIfEmpty()
|
||||
orderby p.count descending
|
||||
select x);
|
||||
return getList.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (from x in getProjects
|
||||
join y in pcount on x.ProjectId equals y.ProjectId into PP
|
||||
from p in PP.DefaultIfEmpty()
|
||||
orderby p.count descending
|
||||
select x).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public static Model.Base_Project GetIndexProjectById(string userId, string projectId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(projectId)) return null;
|
||||
using (var db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
return GetIndexProjectScope(db, userId).FirstOrDefault(x => x.ProjectId == projectId);
|
||||
}
|
||||
}
|
||||
|
||||
private static IQueryable<Model.Base_Project> GetIndexProjectScope(Model.SGGLDB db, string userId)
|
||||
{
|
||||
var projects = from project in db.Base_Project
|
||||
join unit in db.Base_Unit on project.UnitId equals unit.UnitId
|
||||
select project;
|
||||
if (userId == Const.sysglyId || userId == Const.hfnbdId || userId == Const.sedinId) return projects;
|
||||
|
||||
var user = db.Person_Persons.FirstOrDefault(x => x.PersonId == userId);
|
||||
if (user == null) return projects.Where(x => false);
|
||||
|
||||
bool isOffice = user.IsOffice == true;
|
||||
string unitId = user.UnitId;
|
||||
if (isOffice)
|
||||
{
|
||||
string mainUnitId = CommonService.GetThisUnitId();
|
||||
if (!string.IsNullOrEmpty(mainUnitId) && string.Equals(unitId, mainUnitId, StringComparison.OrdinalIgnoreCase)) return projects;
|
||||
if (db.Base_Unit.Any(x => x.UnitId == unitId && x.IsBranch == true)) return projects.Where(x => x.UnitId == unitId);
|
||||
}
|
||||
|
||||
// 项目用户管理通过清空现场人员角色来撤销项目关联。
|
||||
var assignedProjectIds = db.SitePerson_Person
|
||||
.Where(x => x.PersonId == userId && x.RoleIds != null && x.RoleIds != "")
|
||||
.Select(x => x.ProjectId);
|
||||
return projects.Where(x => (isOffice && x.UnitId == unitId) || assignedProjectIds.Contains(x.ProjectId));
|
||||
}
|
||||
|
||||
#region
|
||||
/// <summary>
|
||||
/// 项目表下拉框
|
||||
|
||||
Reference in New Issue
Block a user