1622 lines
69 KiB
C#
1622 lines
69 KiB
C#
using FineUIPro;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.IO;
|
||
using System.Linq;
|
||
|
||
namespace BLL
|
||
{
|
||
/// <summary>
|
||
/// 人员信息
|
||
/// </summary>
|
||
public static class Person_PersonsService
|
||
{
|
||
#region 获取人员列表信息
|
||
/// <summary>
|
||
/// 记录数
|
||
/// </summary>
|
||
public static int count
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 定义变量
|
||
/// </summary>
|
||
private static IQueryable<Model.Person_Persons> getDataLists = from x in Funs.DB.Person_Persons
|
||
where x.PersonId != Const.sysglyId && x.PersonId != Const.hfnbdId
|
||
select x;
|
||
|
||
/// <summary>
|
||
/// 数据列表
|
||
/// </summary>
|
||
/// <param name="unitId">单位ID</param>
|
||
/// <param name="departId">部门id</param>
|
||
/// <param name="projetcId">项目id</param>
|
||
/// <param name="name">姓名</param>
|
||
/// <param name="idCard">身份证号码</param>
|
||
/// <param name="isPost">是否在岗</param>
|
||
/// <param name="personType">人员类型</param>
|
||
/// <param name="Grid1"></param>
|
||
/// <returns></returns>
|
||
public static IEnumerable getListData(string unitId, string departId, string projetcId, string name, string idCard, string isPost, string personType, string account, string[] workPostIds, Grid Grid1)
|
||
{
|
||
|
||
var db1 = Funs.DB;
|
||
var getDataLists = from x in db1.Person_Persons
|
||
where x.PersonId != Const.sysglyId && x.PersonId != Const.hfnbdId
|
||
select x;
|
||
IQueryable<Model.Person_Persons> getDataList = getDataLists.OrderBy(x => x.UnitId).ThenBy(x => x.DepartId);
|
||
if (!string.IsNullOrEmpty(unitId) && unitId != Const._Null)
|
||
{
|
||
getDataList = getDataList.Where(e => e.UnitId == unitId);
|
||
}
|
||
if (!string.IsNullOrEmpty(departId) && departId != Const._Null)
|
||
{
|
||
getDataList = getDataList.Where(e => e.DepartId == departId);
|
||
}
|
||
if (!string.IsNullOrEmpty(projetcId) && projetcId != Const._Null)
|
||
{
|
||
var idLists = (from x in db1.SitePerson_PersonItem
|
||
where x.ProjectId == projetcId && !x.OutTime.HasValue
|
||
select x.PersonId).Distinct().ToList();
|
||
getDataList = getDataList.Where(x => idLists.Contains(x.PersonId));
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(personType) && personType != Const._Null)
|
||
{
|
||
getDataList = getDataList.Where(e => e.PersonType == personType);
|
||
}
|
||
if (!string.IsNullOrEmpty(name))
|
||
{
|
||
getDataList = getDataList.Where(e => e.PersonName.Contains(name));
|
||
}
|
||
if (!string.IsNullOrEmpty(account))
|
||
{
|
||
getDataList = getDataList.Where(e => e.Account.Contains(account));
|
||
}
|
||
if (!string.IsNullOrEmpty(idCard))
|
||
{
|
||
getDataList = getDataList.Where(e => e.IdentityCard.Contains(idCard));
|
||
}
|
||
|
||
if (!string.IsNullOrEmpty(isPost) && isPost != "-1" && isPost != Const._Null)
|
||
{
|
||
if (isPost == Const._True)
|
||
{
|
||
getDataList = getDataList.Where(e => !e.IsPost.HasValue || e.IsPost == true);
|
||
}
|
||
else
|
||
{
|
||
getDataList = getDataList.Where(e => e.IsPost == false);
|
||
}
|
||
}
|
||
|
||
if (workPostIds != null && workPostIds.Count() > 0)
|
||
{
|
||
getDataList = getDataList.Where(e => workPostIds.Contains(e.WorkPostId));
|
||
}
|
||
count = getDataList.Count();
|
||
if (count == 0)
|
||
{
|
||
return null;
|
||
}
|
||
getDataList = SortConditionHelper.SortingAndPaging(getDataList, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
||
return from x in getDataList
|
||
select new
|
||
{
|
||
x.PersonId,
|
||
x.PersonName,
|
||
x.JobNum,
|
||
x.Account,
|
||
x.IdentityCard,
|
||
Sex = x.Sex ?? "1",
|
||
x.Birthday,
|
||
x.UnitId,
|
||
db1.Base_Unit.First(u => u.UnitId == x.UnitId).UnitName,
|
||
x.DepartId,
|
||
db1.Base_Depart.First(u => u.DepartId == x.DepartId).DepartName,
|
||
x.WorkPostId,
|
||
WorkPostName = WorkPostService.getWorkPostNamesWorkPostIds(x.WorkPostId),
|
||
x.PostTitleId,
|
||
PostTitleName = PostTitleService.getPostTitleNameById(x.PostTitleId),
|
||
x.PostTitleDate,
|
||
x.IsOffice,
|
||
x.RoleIds,
|
||
RoleName = RoleService.getRoleNamesRoleIds(x.RoleIds),
|
||
x.CurrentProjectId,
|
||
CurrentProjectName = getCurrentProjectName(x.PersonId),
|
||
x.CurrentProjectWorkPostId,
|
||
CurrentProjectWorkPostName = getCurrentProjectWorkPostName(x.PersonId),
|
||
IsPost = x.IsPost ?? true,
|
||
x.SignatureUrl,
|
||
x.Address,
|
||
x.Telephone,
|
||
x.EduLevel,
|
||
EduLevelName = BasicDataService.GetDictNameByDictCode(x.EduLevel),
|
||
x.Major,
|
||
x.PersonType,
|
||
PersonTypeName = DropListService.getPersonTypeNameByValue(x.PersonType),
|
||
x.ValidityDate,
|
||
x.IntoDate,
|
||
x.WorkDate,
|
||
x.RetirementDate,
|
||
PositionName = PositionService.GetPositionNameById(x.PositionId),
|
||
x.Graduate,
|
||
x.ForeignLanguage,
|
||
NationName = BasicDataService.GetDictNameByDictCode(x.Nation),
|
||
PoliticsStatusName = BasicDataService.GetDictNameByDictCode(x.PoliticsStatus),
|
||
MaritalStatusName = BasicDataService.GetDictNameByDictCode(x.MaritalStatus),
|
||
x.RelativeName,
|
||
x.RelativeTel,
|
||
};
|
||
}
|
||
#endregion
|
||
|
||
#region 获取当前项目及岗位
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="ProjectId"></param>
|
||
/// <param name="PersonId"></param>
|
||
/// <returns></returns>
|
||
public static string getCurrentProjectName(string PersonId)
|
||
{
|
||
string name = string.Empty;
|
||
var getItem = Funs.DB.SitePerson_PersonItem.Where(u => u.PersonId == PersonId && !u.OutTime.HasValue);
|
||
if (getItem.Count() > 0)
|
||
{
|
||
foreach (var item in getItem)
|
||
{
|
||
string pname = ProjectService.GetShortNameByProjectId(item.ProjectId);
|
||
if (string.IsNullOrEmpty(name))
|
||
{
|
||
name = pname;
|
||
}
|
||
else
|
||
{
|
||
if (!name.Contains(pname))
|
||
{
|
||
name += "," + pname;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return name;
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="WorkPostId"></param>
|
||
/// <param name="PersonId"></param>
|
||
/// <returns></returns>
|
||
public static string getCurrentProjectWorkPostName(string PersonId)
|
||
{
|
||
string name = string.Empty;
|
||
var getItem = Funs.DB.SitePerson_PersonItem.Where(u => u.PersonId == PersonId && !u.OutTime.HasValue);
|
||
if (getItem.Count() > 0)
|
||
{
|
||
foreach (var item in getItem)
|
||
{
|
||
string pname = WorkPostService.getWorkPostNamesWorkPostIds(item.WorkPostId);
|
||
if (string.IsNullOrEmpty(name))
|
||
{
|
||
name = pname;
|
||
}
|
||
else
|
||
{
|
||
if (!name.Contains(pname))
|
||
{
|
||
name += "," + pname;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return name;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据主键获取人员信息
|
||
/// <summary>
|
||
/// 根据主键获取人员信息
|
||
/// </summary>
|
||
/// <param name="PersonId"></param>
|
||
/// <returns></returns>
|
||
public static Model.Person_Persons GetPerson_PersonsById(string PersonId)
|
||
{
|
||
return Funs.DB.Person_Persons.FirstOrDefault(x => x.PersonId == PersonId);
|
||
}
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 根据主键,项目id判断当前人单位是否是总包单位
|
||
/// </summary>
|
||
/// <param name="PersonId"></param>
|
||
/// <param name="ProjectId"></param>
|
||
/// <returns></returns>
|
||
public static bool IsGeneralUnitByPersonId(string PersonId, string ProjectId)
|
||
{
|
||
bool result = false;
|
||
var PersonEntity = GetPerson_PersonsById(PersonId);
|
||
if (PersonEntity != null)
|
||
{
|
||
var pUnit = Funs.DB.Project_ProjectUnit.FirstOrDefault(e => e.ProjectId == ProjectId && e.UnitId == PersonEntity.UnitId);
|
||
if (pUnit != null)
|
||
{
|
||
if (pUnit.UnitType == Const.ProjectUnitType_1 || pUnit.UnitType == Const.ProjectUnitType_2)
|
||
{
|
||
result = true;
|
||
}
|
||
}
|
||
}
|
||
return result;
|
||
|
||
|
||
}
|
||
|
||
#region 根据身份证号码获取人员信息
|
||
/// <summary>
|
||
/// 根据身份证号码获取人员信息
|
||
/// </summary>
|
||
/// <param name="PersonId"></param>
|
||
/// <returns></returns>
|
||
public static Model.Person_Persons GetPerson_PersonsByIdCard(string idCard)
|
||
{
|
||
return Funs.DB.Person_Persons.FirstOrDefault(x => x.IdentityCard == idCard);
|
||
}
|
||
#endregion
|
||
|
||
#region 根据工号获取人员信息
|
||
/// <summary>
|
||
/// 根据工号获取人员信息
|
||
/// </summary>
|
||
/// <param name="PersonId"></param>
|
||
/// <returns></returns>
|
||
public static Model.Person_Persons GetPerson_PersonsByJobNum(string jobNum)
|
||
{
|
||
return Funs.DB.Person_Persons.FirstOrDefault(x => x.JobNum == jobNum);
|
||
}
|
||
#endregion
|
||
|
||
#region 根据账号获取人员信息 --在岗
|
||
/// <summary>
|
||
/// 根据账号获取人员信息
|
||
/// </summary>
|
||
/// <param name="PersonId"></param>
|
||
/// <returns></returns>
|
||
public static Model.Person_Persons GetPerson_PersonsByAccount(string account)
|
||
{
|
||
return Funs.DB.Person_Persons.FirstOrDefault(x => x.Account == account && (x.IsPost == true || !x.IsPost.HasValue));
|
||
}
|
||
#endregion
|
||
|
||
#region 根据主键获取人员名称
|
||
/// <summary>
|
||
/// 根据主键获取人员名称
|
||
/// </summary>
|
||
/// <param name="PersonId"></param>
|
||
/// <returns></returns>
|
||
public static string GetPersonsNameById(string personId)
|
||
{
|
||
string name = string.Empty;
|
||
if (!string.IsNullOrEmpty(personId))
|
||
{
|
||
var getPerson = Funs.DB.Person_Persons.FirstOrDefault(x => x.PersonId == personId);
|
||
if (getPerson != null)
|
||
{
|
||
name = getPerson.PersonName;
|
||
}
|
||
}
|
||
return name;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据姓名获取人员名称 ?? todo
|
||
/// <summary>
|
||
/// 根据主键获取人员名称
|
||
/// </summary>
|
||
/// <param name="PersonId"></param>
|
||
/// <returns></returns>
|
||
public static Model.Person_Persons GetPersonsByName(string name)
|
||
{
|
||
return Funs.DB.Person_Persons.FirstOrDefault(x => x.PersonName == name);
|
||
}
|
||
#endregion
|
||
|
||
#region 根据多用户ID得到用户名称字符串
|
||
/// <summary>
|
||
/// 根据多用户ID得到用户名称字符串
|
||
/// </summary>
|
||
/// <param name="bigType"></param>
|
||
/// <returns></returns>
|
||
public static string getPersonsNamesPersonIds(object personIds)
|
||
{
|
||
string name = string.Empty;
|
||
if (personIds != null)
|
||
{
|
||
string[] ids = personIds.ToString().Split(',');
|
||
foreach (string id in ids)
|
||
{
|
||
var q = GetPersonsNameById(id);
|
||
if (q != null)
|
||
{
|
||
name += q + ",";
|
||
}
|
||
}
|
||
if (name != string.Empty)
|
||
{
|
||
name = name.Substring(0, name.Length - 1); ;
|
||
}
|
||
}
|
||
|
||
return name;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据项目人员id 获取人员库人员信息
|
||
/// <summary>
|
||
/// 根据项目人员id 获取人员库人员信息
|
||
/// </summary>
|
||
/// <param name="projectPersonId"></param>
|
||
/// <returns></returns>
|
||
public static Model.Person_Persons GetPerson_PersonsByProjectPersonId(string projectPersonId)
|
||
{
|
||
var getProjectPerson = SitePerson_PersonService.GetSitePersonById(projectPersonId);
|
||
if (getProjectPerson != null)
|
||
{
|
||
return GetPerson_PersonsByIdCard(getProjectPerson.IdentityCard);
|
||
}
|
||
else
|
||
{
|
||
return GetPerson_PersonsById(projectPersonId);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 根据角色获取角色下用户
|
||
/// <summary>
|
||
/// 根据角色获取角色下用户
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static List<Model.Person_Persons> GetPerson_PersonsListByRoleId(string roleId)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
return (from x in db.Person_Persons
|
||
where x.RoleIds.Contains(roleId)
|
||
select x).ToList();
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 根据人员ID 获取 本部及项目上所有角色集合List
|
||
/// <summary>
|
||
/// 根据人员ID 获取 本部及项目上所有角色集合List
|
||
/// </summary>
|
||
/// <param name="personId">用户Id</param>
|
||
/// <returns>用户信息</returns>
|
||
public static List<string> GetRoleListByProjectIdPersonId(string projectId, string personId)
|
||
{
|
||
List<string> roleList = new List<string>();
|
||
var getUser = GetPerson_PersonsById(personId);
|
||
if (getUser != null)
|
||
{
|
||
string rolesStr = string.Empty;
|
||
if (!string.IsNullOrEmpty(getUser.RoleIds))
|
||
{
|
||
rolesStr = getUser.RoleIds;
|
||
}
|
||
var pUser = SitePerson_PersonService.GetSitePersonByProjectIdPersonId(projectId, personId); ////用户
|
||
if (pUser != null && !string.IsNullOrEmpty(pUser.RoleIds))
|
||
{
|
||
if (string.IsNullOrEmpty(rolesStr))
|
||
{
|
||
rolesStr = pUser.RoleIds;
|
||
}
|
||
else
|
||
{
|
||
if (!rolesStr.Contains(pUser.RoleIds))
|
||
{
|
||
rolesStr += "," + pUser.RoleIds;
|
||
}
|
||
}
|
||
}
|
||
|
||
roleList = Funs.GetStrListByStr(rolesStr, ',');
|
||
}
|
||
return roleList;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 根据人员ID获取签名
|
||
/// <summary>
|
||
/// 根据人员ID获取签名
|
||
/// </summary>
|
||
/// <param name="userId"></param>
|
||
/// <returns></returns>
|
||
public static string getSignatureName(string personId)
|
||
{
|
||
string userName = string.Empty;
|
||
var getUser = Person_PersonsService.GetPerson_PersonsById(personId);
|
||
if (getUser != null)
|
||
{
|
||
userName = getUser.PersonName;
|
||
if (!string.IsNullOrEmpty(getUser.SignatureUrl))
|
||
{
|
||
string url = Funs.RootPath + getUser.SignatureUrl;
|
||
FileInfo info = new FileInfo(url);
|
||
if (info.Exists)
|
||
{
|
||
userName = "<img width='90' height='35' src='" + (Funs.SGGLUrl + getUser.SignatureUrl).Replace('\\', '/') + "'></img>";
|
||
}
|
||
}
|
||
}
|
||
return userName;
|
||
}
|
||
public static string getSignatureUrl(string personId)
|
||
{
|
||
string Url = string.Empty;
|
||
var getUser = Person_PersonsService.GetPerson_PersonsById(personId);
|
||
if (getUser != null)
|
||
{
|
||
Url = getUser.PersonName;
|
||
if (!string.IsNullOrEmpty(getUser.SignatureUrl))
|
||
{
|
||
Url = Funs.RootPath + getUser.SignatureUrl;
|
||
|
||
}
|
||
}
|
||
return Url;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据项目ID单位ID 获取人员下拉框 (项目角色 且可审批)
|
||
/// <summary>
|
||
/// 根据项目ID单位ID 获取人员下拉框 (项目角色 且可审批)
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static List<Model.SpSysUserItem> GetProjectRoleUserListByProjectId(string projectId, string unitId)
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
IQueryable<Model.SpSysUserItem> users = null;
|
||
if (!string.IsNullOrEmpty(projectId))
|
||
{
|
||
var getSitepersons = from x in db.SitePerson_Person
|
||
join p in db.Person_Persons on x.PersonId equals p.PersonId
|
||
where x.ProjectId == projectId && x.States == Const.State_1 && x.RoleIds != null && p.Account != null
|
||
select x;
|
||
List<Model.SpSysUserItem> returUsers = new List<Model.SpSysUserItem>();
|
||
List<Model.SitePerson_Person> getPUser = new List<Model.SitePerson_Person>();
|
||
if (!string.IsNullOrEmpty(unitId))
|
||
{
|
||
/// 为啥 有单位id 还判断单位类型
|
||
/// (u.UnitId == unitId || u.UnitType == BLL.Const.ProjectUnitType_1 || u.UnitType == BLL.Const.ProjectUnitType_3 || u.UnitType == BLL.Const.ProjectUnitType_4)
|
||
getPUser = (from x in getSitepersons
|
||
join u in db.Project_ProjectUnit on new { x.ProjectId, x.UnitId } equals new { u.ProjectId, u.UnitId }
|
||
where x.UnitId == unitId
|
||
select x).ToList();
|
||
}
|
||
else
|
||
{
|
||
getPUser = getSitepersons.ToList();
|
||
}
|
||
|
||
if (getPUser.Count() > 0)
|
||
{
|
||
foreach (var item in getPUser)
|
||
{
|
||
List<string> roleIdList = Funs.GetStrListByStr(item.RoleIds, ',');
|
||
var getRoles = db.Sys_Role.FirstOrDefault(x => roleIdList.Contains(x.RoleId));
|
||
if (getRoles != null)
|
||
{
|
||
string userName = RoleService.getRoleNamesRoleIds(item.RoleIds) + "-" + Person_PersonsService.GetPersonsNameById(item.PersonId);
|
||
Model.SpSysUserItem newsysUser = new Model.SpSysUserItem
|
||
{
|
||
PersonId = item.PersonId,
|
||
PersonName = userName,
|
||
};
|
||
returUsers.Add(newsysUser);
|
||
}
|
||
}
|
||
}
|
||
return returUsers;
|
||
}
|
||
else
|
||
{
|
||
if (!string.IsNullOrEmpty(unitId))
|
||
{
|
||
users = (from x in db.Person_Persons
|
||
join z in db.Sys_Role on x.RoleIds equals z.RoleId
|
||
where (x.IsPost == true || !x.IsPost.HasValue) && x.UnitId == unitId && x.Account != null && x.RoleIds != null
|
||
orderby x.JobNum
|
||
select new Model.SpSysUserItem
|
||
{
|
||
PersonName = z.RoleName + "- " + x.PersonName,
|
||
PersonId = x.PersonId,
|
||
});
|
||
}
|
||
else
|
||
{
|
||
users = (from x in db.Person_Persons
|
||
join z in db.Sys_Role on x.RoleIds equals z.RoleId
|
||
where (x.IsPost == true || !x.IsPost.HasValue) && x.Account != null && x.RoleIds != null
|
||
orderby x.JobNum
|
||
select new Model.SpSysUserItem
|
||
{
|
||
PersonName = z.RoleName + "- " + x.PersonName,
|
||
PersonId = x.PersonId,
|
||
});
|
||
}
|
||
}
|
||
return users.ToList();
|
||
}
|
||
#endregion
|
||
|
||
#region 根据项目ID角色Id获取用户下拉选项
|
||
/// <summary>
|
||
/// 根据项目ID角色Id获取用户下拉选项
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static List<Model.Person_Persons> GetUserListByProjectIdUnitIdRoleId(string projectId, string unitIds, string roleIds)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
List<string> listRoles = Funs.GetStrListByStr(roleIds, ',');
|
||
List<string> listUnitIds = Funs.GetStrListByStr(unitIds, ',');
|
||
List<Model.Person_Persons> list = new List<Model.Person_Persons>();
|
||
if (!string.IsNullOrEmpty(projectId))
|
||
{
|
||
var getProjectPersons = from x in db.SitePerson_Person
|
||
where x.ProjectId == projectId && x.States == Const.State_1 && x.RoleIds != null && x.RoleIds != ""
|
||
select x;
|
||
if (listUnitIds.Count() > 0)
|
||
{
|
||
getProjectPersons = getProjectPersons.Where(x => listUnitIds.Contains(x.UnitId)).OrderBy(x => x.PersonName);
|
||
}
|
||
if (listRoles.Count() > 0)
|
||
{
|
||
foreach (var item in listRoles)
|
||
{
|
||
var getNewlist = getProjectPersons.Where(x => x.RoleIds.Contains(item));
|
||
if (getNewlist.Count() > 0)
|
||
{
|
||
var getPersonIdList = getNewlist.Select(p => p.PersonId).ToList();
|
||
var getPerson = db.Person_Persons.Where(x => getPersonIdList.Contains(x.PersonId));
|
||
list.AddRange(getPerson);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
list = (from x in getProjectPersons
|
||
join y in db.Person_Persons on x.PersonId equals y.PersonId
|
||
orderby x.PersonName
|
||
select y).ToList();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
var getPersons = from x in db.Person_Persons
|
||
where x.PersonId != Const.hfnbdId && x.PersonId != Const.sedinId
|
||
&& (x.IsPost == true || !x.IsPost.HasValue) && x.Account != null
|
||
select x;
|
||
if (listUnitIds.Count() > 0)
|
||
{
|
||
getPersons = getPersons.Where(x => listUnitIds.Contains(x.UnitId)).OrderBy(x => x.PersonName);
|
||
}
|
||
if (listRoles.Count() > 0)
|
||
{
|
||
foreach (var item in listRoles)
|
||
{
|
||
var getNewlist = getPersons.Where(x => x.RoleIds.Contains(item));
|
||
if (getNewlist.Count() > 0)
|
||
{
|
||
list.AddRange(getNewlist);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
list = getPersons.OrderBy(x => x.PersonName).ToList();
|
||
}
|
||
}
|
||
|
||
return list;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 根据项目ID单位ID获取 用户ListItem
|
||
/// <summary>
|
||
/// 根据项目ID单位ID获取 用户ListItem
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <param name="unitId"></param>
|
||
/// <returns></returns>
|
||
public static System.Web.UI.WebControls.ListItem[] GetUserByUnitId(string projectId, string unitId)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
var getUser = GetUserListByProjectIdUnitIdRoleId(projectId, unitId, null);
|
||
System.Web.UI.WebControls.ListItem[] lis = new System.Web.UI.WebControls.ListItem[getUser.Count()];
|
||
for (int i = 0; i < getUser.Count(); i++)
|
||
{
|
||
lis[i] = new System.Web.UI.WebControls.ListItem(getUser[i].PersonName ?? "", getUser[i].PersonId.ToString());
|
||
}
|
||
return lis;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 根据单位Id部门获取用户下拉选项
|
||
/// <summary>
|
||
/// 根据单位Id部门获取用户下拉选项
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static List<Model.Person_Persons> GetUserListByUnitIdDepartId(string unitId, string DepartId)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
List<Model.Person_Persons> list = new List<Model.Person_Persons>();
|
||
var getPersons = from x in db.Person_Persons
|
||
where x.IsPost == true
|
||
select x;
|
||
if (!string.IsNullOrEmpty(unitId))
|
||
{
|
||
getPersons = getPersons.Where(x => x.UnitId == unitId);
|
||
}
|
||
if (!string.IsNullOrEmpty(DepartId))
|
||
{
|
||
getPersons = getPersons.Where(x => x.DepartId == DepartId);
|
||
}
|
||
list = getPersons.OrderBy(x => x.UnitId).OrderBy(x => x.PersonName).ToList();
|
||
return list;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 人员信息 增删改
|
||
/// <summary>
|
||
/// 增加人员信息
|
||
/// </summary>
|
||
/// <param name="person">人员实体</param>
|
||
public static void AddPerson(Model.Person_Persons person)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
string password = Funs.getInitialPassword(person.UnitId, person.IdentityCard);
|
||
Model.Person_Persons newPerson = new Model.Person_Persons
|
||
{
|
||
PersonId = person.PersonId,
|
||
UnitId = person.UnitId,
|
||
DepartId = person.DepartId,
|
||
WorkPostId = person.WorkPostId,
|
||
JobNum = person.JobNum,
|
||
PersonName = person.PersonName,
|
||
Account = person.Account,
|
||
RawPassword = password,
|
||
Password = Funs.EncryptionPassword(password),
|
||
IsOffice = person.IsOffice,
|
||
RoleIds = person.RoleIds,
|
||
IdentityCard = person.IdentityCard,
|
||
IdcardType = person.IdcardType,
|
||
IdcardStartDate = person.IdcardStartDate,
|
||
IdcardEndDate = person.IdcardEndDate,
|
||
IdcardForever = person.IdcardForever,
|
||
IdcardAddress = person.IdcardAddress,
|
||
Telephone = person.Telephone,
|
||
Sex = person.Sex,
|
||
Birthday = person.Birthday,
|
||
Address = person.Address,
|
||
PhotoUrl = person.PhotoUrl,
|
||
HeadImage = person.HeadImage,
|
||
QRCodeAttachUrl = person.QRCodeAttachUrl,
|
||
IDCardUrl = person.IDCardUrl,
|
||
IDCardBackUrl = person.IDCardBackUrl,
|
||
IsForeign = person.IsForeign,
|
||
PersonType = person.PersonType,
|
||
MaritalStatus = person.MaritalStatus,
|
||
PoliticsStatus = person.PoliticsStatus,
|
||
PostTitleId = person.PostTitleId,
|
||
PostTitleDate = person.PostTitleDate,
|
||
PositionId = person.PositionId,
|
||
Nation = person.Nation,
|
||
EduLevel = person.EduLevel,
|
||
ForeignLanguage = person.ForeignLanguage,
|
||
CountryCode = person.CountryCode,
|
||
ProvinceCode = person.ProvinceCode,
|
||
IsPost = person.IsPost ?? true,
|
||
Graduate = person.Graduate,
|
||
Major = person.Major,
|
||
IntoDate = person.IntoDate,
|
||
ValidityDate = person.ValidityDate,
|
||
OpenId = person.OpenId,
|
||
CurrentProjectId = person.CurrentProjectId,
|
||
CurrentProjectRoleId = person.CurrentProjectRoleId,
|
||
CurrentProjectWorkPostId = person.CurrentProjectWorkPostId,
|
||
LastMenuType = person.LastMenuType,
|
||
LastIsOffice = person.LastIsOffice,
|
||
LastProjectId = person.LastProjectId,
|
||
DataFrom = person.DataFrom,
|
||
OldDataId = person.OldDataId,
|
||
IsCardNoOK = IDCardValid.CheckIDCard(person.IdentityCard),
|
||
WorkDate = person.WorkDate,
|
||
RetirementDate = person.RetirementDate,
|
||
RelativeName = person.RelativeName,
|
||
RelativeTel = person.RelativeTel,
|
||
MultiProject = person.MultiProject,
|
||
HomePageType = person.HomePageType,
|
||
IsInspectionBrigade = person.IsInspectionBrigade,
|
||
};
|
||
|
||
if (string.IsNullOrEmpty(person.QRCodeAttachUrl))
|
||
{
|
||
///生成二维码
|
||
newPerson.QRCodeAttachUrl = BLL.CreateQRCodeService.CreateCode_Simple("person$" + person.IdentityCard);
|
||
}
|
||
if (!string.IsNullOrEmpty(person.SignatureUrl))
|
||
{
|
||
newPerson.SignatureUrl = person.SignatureUrl;
|
||
|
||
|
||
}
|
||
db.Person_Persons.InsertOnSubmit(newPerson);
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改人员信息
|
||
/// </summary>
|
||
/// <param name="person">人员实体</param>
|
||
public static void UpdatePerson(Model.Person_Persons person)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
bool isChange = false;
|
||
Model.Person_Persons newPerson = db.Person_Persons.FirstOrDefault(e => e.PersonId == person.PersonId);
|
||
if (newPerson != null)
|
||
{
|
||
if (newPerson.UnitId != person.UnitId)
|
||
{
|
||
newPerson.UnitId = person.UnitId;
|
||
isChange = true;
|
||
}
|
||
|
||
newPerson.DepartId = person.DepartId;
|
||
newPerson.WorkPostId = person.WorkPostId;
|
||
newPerson.JobNum = person.JobNum;
|
||
if (newPerson.PersonName != person.PersonName)
|
||
{
|
||
newPerson.PersonName = person.PersonName;
|
||
isChange = true;
|
||
}
|
||
|
||
newPerson.Account = person.Account;
|
||
newPerson.IsOffice = person.IsOffice;
|
||
newPerson.RoleIds = person.RoleIds;
|
||
if (newPerson.IdentityCard != person.IdentityCard)
|
||
{
|
||
newPerson.IdentityCard = person.IdentityCard;
|
||
newPerson.IsCardNoOK = IDCardValid.CheckIDCard(person.IdentityCard);
|
||
isChange = true;
|
||
}
|
||
newPerson.IdcardType = person.IdcardType;
|
||
newPerson.IdcardStartDate = person.IdcardStartDate;
|
||
newPerson.IdcardEndDate = person.IdcardEndDate;
|
||
newPerson.IdcardForever = person.IdcardForever;
|
||
newPerson.IdcardAddress = person.IdcardAddress;
|
||
if (!string.IsNullOrEmpty(person.Telephone) && newPerson.Telephone != person.Telephone)
|
||
{
|
||
newPerson.Telephone = person.Telephone;
|
||
}
|
||
newPerson.Birthday = person.Birthday;
|
||
newPerson.Sex = person.Sex;
|
||
newPerson.Address = person.Address;
|
||
newPerson.PhotoUrl = person.PhotoUrl;
|
||
newPerson.HeadImage = person.HeadImage;
|
||
newPerson.IDCardUrl = person.IDCardUrl;
|
||
newPerson.IDCardBackUrl = person.IDCardBackUrl;
|
||
if (!string.IsNullOrEmpty(person.SignatureUrl))
|
||
{
|
||
newPerson.SignatureUrl = person.SignatureUrl;
|
||
|
||
}
|
||
newPerson.IsForeign = person.IsForeign;
|
||
newPerson.PersonType = person.PersonType;
|
||
newPerson.MaritalStatus = person.MaritalStatus;
|
||
newPerson.PoliticsStatus = person.PoliticsStatus;
|
||
newPerson.PostTitleId = person.PostTitleId;
|
||
newPerson.PostTitleDate = person.PostTitleDate;
|
||
newPerson.PositionId = person.PositionId;
|
||
newPerson.Nation = person.Nation;
|
||
newPerson.EduLevel = person.EduLevel;
|
||
newPerson.ForeignLanguage = person.ForeignLanguage;
|
||
newPerson.CountryCode = person.CountryCode;
|
||
newPerson.ProvinceCode = person.ProvinceCode;
|
||
newPerson.IsPost = person.IsPost ?? true;
|
||
newPerson.Graduate = person.Graduate;
|
||
newPerson.Major = person.Major;
|
||
newPerson.IntoDate = person.IntoDate;
|
||
newPerson.ValidityDate = person.ValidityDate;
|
||
newPerson.OpenId = person.OpenId;
|
||
newPerson.CurrentProjectId = person.CurrentProjectId;
|
||
newPerson.CurrentProjectRoleId = person.CurrentProjectRoleId;
|
||
newPerson.CurrentProjectWorkPostId = person.CurrentProjectWorkPostId;
|
||
newPerson.LastMenuType = person.LastMenuType;
|
||
newPerson.LastIsOffice = person.LastIsOffice;
|
||
newPerson.LastProjectId = person.LastProjectId;
|
||
newPerson.DataFrom = person.DataFrom;
|
||
newPerson.OldDataId = person.OldDataId;
|
||
newPerson.WorkDate = person.WorkDate;
|
||
newPerson.RetirementDate = person.RetirementDate;
|
||
newPerson.RelativeName = person.RelativeName;
|
||
newPerson.RelativeTel = person.RelativeTel;
|
||
newPerson.MultiProject = person.MultiProject;
|
||
newPerson.HomePageType = person.HomePageType;
|
||
newPerson.LogWorkPostId = person.LogWorkPostId;
|
||
newPerson.LogMachineId = person.LogMachineId;
|
||
newPerson.IsInspectionBrigade = person.IsInspectionBrigade;
|
||
newPerson.IsCardNoOK = IDCardValid.CheckIDCard(person.IdentityCard);
|
||
if (string.IsNullOrEmpty(person.QRCodeAttachUrl))
|
||
{
|
||
///生成二维码
|
||
newPerson.QRCodeAttachUrl = BLL.CreateQRCodeService.CreateCode_Simple("person$" + newPerson.IdentityCard);
|
||
}
|
||
else
|
||
{
|
||
newPerson.QRCodeAttachUrl = person.QRCodeAttachUrl;
|
||
}
|
||
db.SubmitChanges();
|
||
if (isChange)
|
||
{
|
||
SetProjectPersonUnit(person);
|
||
}
|
||
/// 人员不在职位,当前人所在项目 都出场
|
||
if (person.IsPost == false)
|
||
{
|
||
var getSitePersons = from x in db.SitePerson_Person where x.PersonId == person.PersonId && x.States != Const.ProjectPersonStates_2 select x;
|
||
foreach (var item in getSitePersons)
|
||
{
|
||
SitePerson_PersonService.SetSitePerson_PersonStates(item.SitePersonId, Const.ProjectPersonStates_2, DateTime.Now);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
public static void UpdatePerson_Persons(Model.Person_Persons newtable)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
Model.Person_Persons table = db.Person_Persons.FirstOrDefault(x => x.PersonId == newtable.PersonId);
|
||
if (table != null)
|
||
{
|
||
table.PersonId = newtable.PersonId;
|
||
table.UnitId = newtable.UnitId;
|
||
table.DepartId = newtable.DepartId;
|
||
table.WorkPostId = newtable.WorkPostId;
|
||
table.JobNum = newtable.JobNum;
|
||
table.PersonName = newtable.PersonName;
|
||
table.Account = newtable.Account;
|
||
table.IsOffice = newtable.IsOffice;
|
||
table.RoleIds = newtable.RoleIds;
|
||
table.IdentityCard = newtable.IdentityCard;
|
||
table.IdcardType = newtable.IdcardType;
|
||
table.IdcardStartDate = newtable.IdcardStartDate;
|
||
table.IdcardEndDate = newtable.IdcardEndDate;
|
||
table.IdcardForever = newtable.IdcardForever;
|
||
table.IdcardAddress = newtable.IdcardAddress;
|
||
table.Telephone = newtable.Telephone;
|
||
table.Sex = newtable.Sex;
|
||
table.Birthday = newtable.Birthday;
|
||
table.Address = newtable.Address;
|
||
table.PhotoUrl = newtable.PhotoUrl;
|
||
table.HeadImage = newtable.HeadImage;
|
||
table.QRCodeAttachUrl = newtable.QRCodeAttachUrl;
|
||
table.IDCardUrl = newtable.IDCardUrl;
|
||
table.IDCardBackUrl = newtable.IDCardBackUrl;
|
||
if (!string.IsNullOrEmpty(newtable.SignatureUrl))
|
||
{
|
||
table.SignatureUrl = newtable.SignatureUrl;
|
||
|
||
|
||
}
|
||
table.IsForeign = newtable.IsForeign;
|
||
table.MaritalStatus = newtable.MaritalStatus;
|
||
table.PoliticsStatus = newtable.PoliticsStatus;
|
||
table.PostTitleId = newtable.PostTitleId;
|
||
table.PostTitleDate = newtable.PostTitleDate;
|
||
table.PositionId = newtable.PositionId;
|
||
table.Nation = newtable.Nation;
|
||
table.EduLevel = newtable.EduLevel;
|
||
table.ForeignLanguage = newtable.ForeignLanguage;
|
||
table.CountryCode = newtable.CountryCode;
|
||
table.ProvinceCode = newtable.ProvinceCode;
|
||
table.IsPost = newtable.IsPost;
|
||
table.Graduate = newtable.Graduate;
|
||
table.Major = newtable.Major;
|
||
table.IntoDate = newtable.IntoDate;
|
||
table.WorkDate = newtable.WorkDate;
|
||
table.RetirementDate = newtable.RetirementDate;
|
||
table.ValidityDate = newtable.ValidityDate;
|
||
table.OpenId = newtable.OpenId;
|
||
table.CurrentProjectId = newtable.CurrentProjectId;
|
||
table.CurrentProjectRoleId = newtable.CurrentProjectRoleId;
|
||
table.CurrentProjectWorkPostId = newtable.CurrentProjectWorkPostId;
|
||
table.LoginProjectId = newtable.LoginProjectId;
|
||
table.LastMenuType = newtable.LastMenuType;
|
||
table.LastIsOffice = newtable.LastIsOffice;
|
||
table.LastProjectId = newtable.LastProjectId;
|
||
table.DataFrom = newtable.DataFrom;
|
||
table.OldDataId = newtable.OldDataId;
|
||
table.IsCardNoOK = newtable.IsCardNoOK;
|
||
table.RelativeName = newtable.RelativeName;
|
||
table.RelativeTel = newtable.RelativeTel;
|
||
table.Email = newtable.Email;
|
||
table.CertificateId = newtable.CertificateId;
|
||
table.PersonType = newtable.PersonType;
|
||
table.MultiProject = newtable.MultiProject;
|
||
table.HomePageType = newtable.HomePageType;
|
||
if (string.IsNullOrEmpty(newtable.QRCodeAttachUrl))
|
||
{
|
||
///生成二维码
|
||
table.QRCodeAttachUrl = BLL.CreateQRCodeService.CreateCode_Simple("person$" + newtable.IdentityCard);
|
||
}
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
|
||
|
||
|
||
}
|
||
public static void DeletePerson_PersonsById(string PersonId)
|
||
{
|
||
var db1 = Funs.DB;
|
||
Model.Person_Persons table = db1.Person_Persons.FirstOrDefault(x => x.PersonId == PersonId);
|
||
if (table != null)
|
||
{
|
||
db1.Person_Persons.DeleteOnSubmit(table);
|
||
db1.SubmitChanges();
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// 更新项目人员单位
|
||
/// </summary>
|
||
/// <param name="personId"></param>
|
||
/// <param name="unitId"></param>
|
||
public static void SetProjectPersonUnit(Model.Person_Persons person)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
var getSitepersons = from x in db.SitePerson_Person
|
||
where x.PersonId == person.PersonId
|
||
select x;
|
||
if (getSitepersons.Count() > 0)
|
||
{
|
||
foreach (var item in getSitepersons)
|
||
{
|
||
item.UnitId = person.UnitId;
|
||
item.IdentityCard = person.IdentityCard;
|
||
item.PersonName = person.PersonName;
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改人员信息
|
||
/// </summary>
|
||
/// <param name="person">人员实体</param>
|
||
public static void UpdatePerson_User(Model.Person_Persons person)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
Model.Person_Persons newPerson = db.Person_Persons.FirstOrDefault(e => e.PersonId == person.PersonId);
|
||
if (newPerson != null)
|
||
{
|
||
newPerson.UnitId = person.UnitId;
|
||
newPerson.DepartId = person.DepartId;
|
||
newPerson.Telephone = person.Telephone;
|
||
newPerson.JobNum = person.JobNum;
|
||
newPerson.PersonName = person.PersonName;
|
||
newPerson.Account = person.Account;
|
||
newPerson.IsOffice = person.IsOffice;
|
||
newPerson.RoleIds = person.RoleIds;
|
||
newPerson.IsCardNoOK = IDCardValid.CheckIDCard(person.IdentityCard);
|
||
if (string.IsNullOrEmpty(person.QRCodeAttachUrl))
|
||
{
|
||
///生成二维码
|
||
newPerson.QRCodeAttachUrl = BLL.CreateQRCodeService.CreateCode_Simple("person$" + newPerson.IdentityCard);
|
||
}
|
||
else
|
||
{
|
||
newPerson.QRCodeAttachUrl = person.QRCodeAttachUrl;
|
||
}
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据项目人员修改人员信息
|
||
/// </summary>
|
||
/// <param name="person">人员实体</param>
|
||
public static void UpdatePersonByProject(Model.Person_Persons person)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
Model.Person_Persons newPerson = db.Person_Persons.FirstOrDefault(e => e.PersonId == person.PersonId);
|
||
if (newPerson != null)
|
||
{
|
||
newPerson.UnitId = person.UnitId;
|
||
//newPerson.DepartId = person.DepartId;
|
||
// newPerson.WorkPostId = person.WorkPostId;
|
||
// newPerson.JobNum = person.JobNum;
|
||
newPerson.PersonName = person.PersonName;
|
||
newPerson.Account = person.Account;
|
||
//newPerson.IsOffice = person.IsOffice;
|
||
// newPerson.RoleIds = person.RoleIds;
|
||
//if (newPerson.IdentityCard != person.IdentityCard)
|
||
//{
|
||
// newPerson.IdentityCard = person.IdentityCard;
|
||
// newPerson.IsCardNoOK = IDCardValid.CheckIDCard(person.IdentityCard);
|
||
//}
|
||
newPerson.IdcardType = person.IdcardType;
|
||
newPerson.IdcardStartDate = person.IdcardStartDate;
|
||
newPerson.IdcardEndDate = person.IdcardEndDate;
|
||
newPerson.IdcardForever = person.IdcardForever;
|
||
newPerson.IdcardAddress = person.IdcardAddress;
|
||
newPerson.Telephone = person.Telephone;
|
||
newPerson.Birthday = person.Birthday;
|
||
newPerson.Sex = person.Sex;
|
||
newPerson.Address = person.Address;
|
||
newPerson.PhotoUrl = person.PhotoUrl;
|
||
newPerson.HeadImage = person.HeadImage;
|
||
newPerson.IDCardUrl = person.IDCardUrl;
|
||
newPerson.IDCardBackUrl = person.IDCardBackUrl;
|
||
if (!string.IsNullOrEmpty(person.SignatureUrl))
|
||
{
|
||
newPerson.SignatureUrl = person.SignatureUrl;
|
||
|
||
}
|
||
newPerson.IsForeign = person.IsForeign;
|
||
newPerson.PersonType = person.PersonType;
|
||
newPerson.MaritalStatus = person.MaritalStatus;
|
||
newPerson.PoliticsStatus = person.PoliticsStatus;
|
||
newPerson.PostTitleId = person.PostTitleId;
|
||
newPerson.PostTitleDate = person.PostTitleDate;
|
||
newPerson.PositionId = person.PositionId;
|
||
newPerson.Nation = person.Nation;
|
||
newPerson.EduLevel = person.EduLevel;
|
||
newPerson.ForeignLanguage = person.ForeignLanguage;
|
||
newPerson.CountryCode = person.CountryCode;
|
||
newPerson.ProvinceCode = person.ProvinceCode;
|
||
// newPerson.IsPost = person.IsPost;
|
||
newPerson.Graduate = person.Graduate;
|
||
newPerson.Major = person.Major;
|
||
newPerson.IntoDate = person.IntoDate;
|
||
newPerson.ValidityDate = person.ValidityDate;
|
||
newPerson.OpenId = person.OpenId;
|
||
newPerson.CurrentProjectId = person.CurrentProjectId;
|
||
newPerson.CurrentProjectRoleId = person.CurrentProjectRoleId;
|
||
newPerson.CurrentProjectWorkPostId = person.CurrentProjectWorkPostId;
|
||
//newPerson.LastMenuType = person.LastMenuType;
|
||
//newPerson.LastIsOffice = person.LastIsOffice;
|
||
//newPerson.LastProjectId = person.LastProjectId;
|
||
newPerson.DataFrom = person.DataFrom;
|
||
newPerson.OldDataId = person.OldDataId;
|
||
newPerson.WorkDate = person.WorkDate;
|
||
newPerson.RetirementDate = person.RetirementDate;
|
||
newPerson.RelativeName = person.RelativeName;
|
||
newPerson.RelativeTel = person.RelativeTel;
|
||
// newPerson.IsCardNoOK = IDCardValid.CheckIDCard(person.IdentityCard);
|
||
if (string.IsNullOrEmpty(person.QRCodeAttachUrl))
|
||
{
|
||
///生成二维码
|
||
newPerson.QRCodeAttachUrl = BLL.CreateQRCodeService.CreateCode_Simple("person$" + newPerson.IdentityCard);
|
||
}
|
||
else
|
||
{
|
||
newPerson.QRCodeAttachUrl = person.QRCodeAttachUrl;
|
||
}
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
}
|
||
|
||
#region 人员密码
|
||
/// <summary>
|
||
/// 修改密码
|
||
/// </summary>
|
||
/// <param name="personId"></param>
|
||
/// <param name="password"></param>
|
||
public static void UpdatePassword(string personId, string password)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
var m = db.Person_Persons.FirstOrDefault(e => e.PersonId == personId);
|
||
if (m != null)
|
||
{
|
||
m.RawPassword = password;
|
||
m.Password = Funs.EncryptionPassword(password);
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 删除人员信息
|
||
/// <summary>
|
||
/// 删除人员信息
|
||
/// </summary>
|
||
/// <param name="personIds"></param>
|
||
/// <returns></returns>
|
||
public static string DeletePersons(string[] personIds, Model.Person_Persons CurrUser)
|
||
{
|
||
string returnInfo = string.Empty;
|
||
foreach (var rowID in personIds)
|
||
{
|
||
var getData = GetPerson_PersonsById(rowID);
|
||
if (getData != null)
|
||
{
|
||
string cont = JudgementDelete(getData);
|
||
if (string.IsNullOrEmpty(cont))
|
||
{
|
||
LogService.AddSys_Log(CurrUser, getData.IdentityCard, getData.PersonId, BLL.Const.PersonLibMenuId, BLL.Const.BtnDelete);
|
||
DeletePersonsById(rowID);
|
||
}
|
||
else
|
||
{
|
||
returnInfo += "人员:" + getData.PersonName + cont;
|
||
}
|
||
}
|
||
}
|
||
|
||
return returnInfo;
|
||
}
|
||
|
||
#region 判断是否可删除
|
||
/// <summary>
|
||
/// 判断是否可以删除
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static string JudgementDelete(Model.Person_Persons getData)
|
||
{
|
||
string content = string.Empty;
|
||
if (Funs.DB.SitePerson_Person.FirstOrDefault(x => x.PersonId == getData.PersonId) != null)
|
||
{
|
||
content += "已在【现场人员】中使用,不能删除!";
|
||
}
|
||
|
||
return content;
|
||
}
|
||
#endregion
|
||
|
||
#region 根据人员Id删除一个人员信息
|
||
/// <summary>
|
||
/// 根据人员Id删除一个人员信息
|
||
/// </summary>
|
||
/// <param name="personId"></param>
|
||
public static void DeletePersonsById(string personId)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
var getDeletePerson = db.Person_Persons.FirstOrDefault(e => e.PersonId == personId);
|
||
if (getDeletePerson != null)
|
||
{
|
||
var logs = from x in db.Sys_Log where x.UserId == personId select x;
|
||
if (logs.Count() > 0)
|
||
{
|
||
db.Sys_Log.DeleteAllOnSubmit(logs);
|
||
}
|
||
///人员
|
||
var PersonItem = from x in db.SitePerson_PersonItem where x.PersonId == personId select x;
|
||
if (PersonItem.Count() > 0)
|
||
{
|
||
db.SitePerson_PersonItem.DeleteAllOnSubmit(PersonItem);
|
||
}
|
||
///人员证书
|
||
var PersonsCertificate = from x in db.QualityAudit_PersonQuality where x.PersonId == personId select x;
|
||
if (PersonsCertificate.Count() > 0)
|
||
{
|
||
db.QualityAudit_PersonQuality.DeleteAllOnSubmit(PersonsCertificate);
|
||
}
|
||
db.Person_Persons.DeleteOnSubmit(getDeletePerson);
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
#endregion
|
||
#endregion
|
||
|
||
#region 更新最后一次登陆系统 信息
|
||
/// <summary>
|
||
/// 更新最后一次登陆系统 信息
|
||
/// </summary>
|
||
/// <param name="userId"></param>
|
||
/// <param name="LastMenuType"></param>
|
||
/// <param name="LastIsOffice"></param>
|
||
/// <param name="LastProjectId"></param>
|
||
public static void UpdateLastUserInfo(string personId, string LastMenuType, bool LastIsOffice, string LastProjectId)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
var uU = db.Person_Persons.FirstOrDefault(e => e.PersonId == personId);
|
||
if (uU != null)
|
||
{
|
||
uU.LastMenuType = LastMenuType;
|
||
uU.LastIsOffice = LastIsOffice;
|
||
uU.LastMenuType = LastMenuType;
|
||
uU.LastProjectId = LastProjectId;
|
||
db.SubmitChanges();
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 验证人员信息是否合格
|
||
/// <summary>
|
||
/// 验证人员信息
|
||
/// </summary>
|
||
/// <param name="person"></param>
|
||
/// <returns></returns>
|
||
public static string ValidPersonInfo(Model.Person_Persons person)
|
||
{
|
||
string info = string.Empty;
|
||
if (!IDCardValid.CheckIDCard(person.IdentityCard) && person.UnitId != Const.UnitId_SEDIN)
|
||
{
|
||
info += "身份证号码不正确!";
|
||
}
|
||
if (!string.IsNullOrEmpty(person.Account))
|
||
{
|
||
var getAcc = Funs.DB.Person_Persons.FirstOrDefault(x => x.Account == person.Account && (x.PersonId != person.PersonId || (person.PersonId == null && x.PersonId != null)));
|
||
if (getAcc != null)
|
||
{
|
||
info += "输入的账号已存在已存在!";
|
||
}
|
||
}
|
||
var getIdCard = Funs.DB.Person_Persons.FirstOrDefault(x => x.IdentityCard == person.IdentityCard && (x.PersonId != person.PersonId || (person.PersonId == null && x.PersonId != null)));
|
||
if (getIdCard != null)
|
||
{
|
||
info += "输入的身份证号码人员库已存在!";
|
||
}
|
||
if (person.UnitId != Const.UnitId_SEDIN && (string.IsNullOrEmpty(person.PhotoUrl) || person.PhotoUrl == "~/res/images/blank.png"))
|
||
{
|
||
info += "照片不能为空!";
|
||
}
|
||
//if (string.IsNullOrEmpty(person.WorkPostId))
|
||
//{
|
||
// info += "请选择所属岗位!";
|
||
//}
|
||
return info;
|
||
}
|
||
#endregion
|
||
|
||
#region 验证人员工号是否存在
|
||
/// <summary>
|
||
/// 验证人员工号是否存在
|
||
/// </summary>
|
||
/// <param name="userId">用户id</param>
|
||
/// <param name="usercode">工号</param>
|
||
/// <returns>是否存在</returns>
|
||
public static bool IsExistUsercode(string personId, string jobNum)
|
||
{
|
||
bool isExist = false;
|
||
var role = Funs.DB.Person_Persons.FirstOrDefault(x => x.JobNum == jobNum && (x.PersonId != personId || (personId == null && x.PersonId != null)));
|
||
if (role != null)
|
||
{
|
||
isExist = true;
|
||
}
|
||
return isExist;
|
||
}
|
||
#endregion
|
||
|
||
#region API CommenInfoController
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <param name="name"></param>
|
||
/// <returns></returns>
|
||
public static List<Model.Person_Persons> GetProjectUserListByProjectIdForApi(string projectId, string name)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
var users = (from x in db.Person_Persons
|
||
where (x.IsPost == true || !x.IsPost.HasValue) && x.PersonId != BLL.Const.hfnbdId
|
||
where name == "" || x.PersonName.Contains(name)
|
||
orderby x.PersonName
|
||
select x).ToList();
|
||
if (!string.IsNullOrEmpty(projectId))
|
||
{
|
||
users = (from x in users
|
||
join y in db.SitePerson_Person on x.PersonId equals y.PersonId
|
||
where y.ProjectId == projectId && y.States == Const.State_1
|
||
orderby x.PersonName
|
||
select x).ToList();
|
||
}
|
||
|
||
return users;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <param name="unitId"></param>
|
||
/// <param name="unitType"></param>
|
||
/// <param name="name"></param>
|
||
/// <returns></returns>
|
||
public static List<Model.Person_Persons> GetProjectUserListByProjectIdForApi(string projectId, string unitId, string unitType, string name)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
List<Model.Person_Persons> list = new List<Model.Person_Persons>();
|
||
if (!string.IsNullOrEmpty(projectId))
|
||
{
|
||
string[] unitTypes = { };
|
||
string[] unitIds = { };
|
||
|
||
if (!string.IsNullOrEmpty(unitType))
|
||
{
|
||
unitTypes = unitType.Split(',');
|
||
}
|
||
if (!string.IsNullOrEmpty(unitId))
|
||
{
|
||
unitIds = unitId.Split(',');
|
||
}
|
||
list = (from x in db.Person_Persons
|
||
join y in db.SitePerson_Person on x.PersonId equals y.PersonId
|
||
join z in db.Project_ProjectUnit on x.UnitId equals z.UnitId
|
||
where name == "" || x.PersonName.Contains(name)
|
||
where y.ProjectId == projectId && z.ProjectId == projectId
|
||
where unitType == "" || unitTypes.Contains(z.UnitType)
|
||
where unitId == "" || unitIds.Contains(z.UnitId)
|
||
where y.States == Const.State_1 && y.RoleIds != null
|
||
orderby z.UnitType descending, x.PersonName
|
||
select x).ToList();
|
||
}
|
||
return list;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 用户下拉框
|
||
/// <summary>
|
||
/// 带角色用户下拉框
|
||
/// </summary>
|
||
/// <param name="dropName">下拉框名字</param>
|
||
/// <param name="projectId">项目id</param>
|
||
/// <param name="isShowPlease">是否显示请选择</param>
|
||
public static void InitFlowOperateControlUserDropDownList(FineUIPro.DropDownList dropName, string projectId, string unitId, bool isShowPlease)
|
||
{
|
||
dropName.DataValueField = "PersonId";
|
||
dropName.DataTextField = "PersonName";
|
||
dropName.DataSource = Person_PersonsService.GetProjectRoleUserListByProjectId(projectId, unitId);
|
||
dropName.DataBind();
|
||
if (isShowPlease)
|
||
{
|
||
Funs.FineUIPleaseSelect(dropName);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 用户下拉框
|
||
/// </summary>
|
||
/// <param name="dropName">下拉框名字</param>
|
||
/// <param name="projectId">项目id</param>
|
||
/// <param name="roleIds">角色id</param>
|
||
/// <param name="isShowPlease">是否显示请选择</param>
|
||
public static void InitUserProjectIdUnitIdRoleIdDropDownList(FineUIPro.DropDownList dropName, string projectId, string unitId, string roleIds, bool isShowPlease)
|
||
{
|
||
dropName.Items.Clear();
|
||
dropName.DataValueField = "PersonId";
|
||
dropName.DataTextField = "PersonName";
|
||
dropName.DataSource = Person_PersonsService.GetUserListByProjectIdUnitIdRoleId(projectId, unitId, roleIds);
|
||
dropName.DataBind();
|
||
if (isShowPlease)
|
||
{
|
||
Funs.FineUIPleaseSelect(dropName);
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 用户下拉框
|
||
/// </summary>
|
||
/// <param name="dropName">下拉框名字</param>
|
||
/// <param name="isShowPlease">是否显示请选择</param>
|
||
public static void InitUserUnitIdDepartIdDropDownList(FineUIPro.DropDownList dropName, string unitId, string DepartId, bool isShowPlease)
|
||
{
|
||
dropName.DataValueField = "PersonId";
|
||
dropName.DataTextField = "PersonName";
|
||
dropName.DataSource = Person_PersonsService.GetUserListByUnitIdDepartId(unitId, DepartId);
|
||
dropName.DataBind();
|
||
if (isShowPlease)
|
||
{
|
||
Funs.FineUIPleaseSelect(dropName);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 用户下拉框
|
||
/// </summary>
|
||
/// <param name="dropName">下拉框名字</param>
|
||
/// <param name="isShowPlease">是否显示请选择</param>
|
||
public static void InitUserUnitIdDropDownList(FineUIPro.DropDownList dropName, string unitId, bool isShowPlease)
|
||
{
|
||
dropName.DataValueField = "PersonId";
|
||
dropName.DataTextField = "PersonName";
|
||
dropName.DataSource = Person_PersonsService.GetUserListByUnitId(unitId);
|
||
dropName.DataBind();
|
||
if (isShowPlease)
|
||
{
|
||
Funs.FineUIPleaseSelect(dropName);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 根据单位Id获取用户下拉选项
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static List<Model.Person_Persons> GetUserListByUnitId(string unitId)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
List<Model.Person_Persons> list = new List<Model.Person_Persons>();
|
||
list = (from x in db.Person_Persons
|
||
where x.UnitId == unitId && x.Account != null && x.Account != ""
|
||
orderby x.PersonName
|
||
select x).ToList();
|
||
return list;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 用户下拉框
|
||
/// </summary>
|
||
/// <param name="dropName">下拉框名字</param>
|
||
/// <param name="projectId">项目id</param>
|
||
/// <param name="isShowPlease">是否显示请选择</param>
|
||
public static void InitUserDropDownList(FineUIPro.DropDownList dropName, string projectId, bool isShowPlease, string UnitId)
|
||
{
|
||
dropName.DataValueField = "Value";
|
||
dropName.DataTextField = "Text";
|
||
if (!string.IsNullOrWhiteSpace(UnitId))
|
||
{
|
||
dropName.DataSource = GetUserByUnitId(projectId, UnitId);
|
||
}
|
||
else
|
||
{
|
||
dropName.DataSource = GetMainUserList(projectId);
|
||
}
|
||
|
||
dropName.DataBind();
|
||
if (isShowPlease)
|
||
{
|
||
Funs.FineUIPleaseSelect(dropName);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取项目总包用户
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
/// <returns></returns>
|
||
public static ListItem[] GetMainUserList(string projectId)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
//var user = (from x in db.Sys_User
|
||
// join y in db.Project_ProjectUser on x.UserId equals y.UserId
|
||
// join z in db.Project_ProjectUnit on x.UnitId equals z.UnitId
|
||
// where x.IsPost == true && y.ProjectId == projectId && z.ProjectId == projectId && z.UnitType == Const.ProjectUnitType_1
|
||
// orderby x.UserId
|
||
// select x).ToList();
|
||
var user = (from x in db.SitePerson_Person
|
||
join y in db.Person_Persons on x.PersonId equals y.PersonId
|
||
join z in db.Project_ProjectUnit on x.UnitId equals z.UnitId
|
||
where y.IsPost == true && x.ProjectId == projectId && z.ProjectId == projectId && z.UnitType == Const.ProjectUnitType_1 && x.RoleIds != null && x.RoleIds != string.Empty
|
||
orderby x.PersonId
|
||
select new
|
||
{
|
||
UserName = y.PersonName,
|
||
UserId = x.PersonId
|
||
}).Distinct().ToList();
|
||
ListItem[] lis = new ListItem[user.Count()];
|
||
for (int i = 0; i < user.Count(); i++)
|
||
{
|
||
lis[i] = new ListItem(user[i].UserName ?? "", user[i].UserId.ToString());
|
||
}
|
||
return lis;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取在岗用户下拉选项
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static List<Model.Person_Persons> GetProjectUserListByProjectId(string projectId)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
var users = (from x in db.Person_Persons
|
||
where x.IsPost == true && x.PersonId != Const.hfnbdId && x.PersonId != Const.sedinId && x.RoleIds != null && x.RoleIds != string.Empty
|
||
orderby x.PersonName
|
||
select x).ToList();
|
||
if (!string.IsNullOrEmpty(projectId))
|
||
{
|
||
users = (from x in users
|
||
join y in db.SitePerson_Person on x.PersonId equals y.PersonId
|
||
where y.ProjectId == projectId
|
||
orderby x.PersonName
|
||
select x).ToList();
|
||
}
|
||
|
||
return users;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据单位Id获取用户下拉选项【单位本部在职人员】
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static List<Model.Person_Persons> GetIsOfficeUserListByUnitId(string unitId)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
List<Model.Person_Persons> list = new List<Model.Person_Persons>();
|
||
list = (from x in db.Person_Persons
|
||
where x.UnitId == unitId && x.IsOffice == true && x.IsPost == true
|
||
orderby x.PersonName
|
||
select x).ToList();
|
||
return list;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 用户下拉框
|
||
/// </summary>
|
||
/// <param name="dropName">下拉框名字</param>
|
||
/// <param name="isShowPlease">是否显示请选择</param>
|
||
public static void InitIsOfficeUserUnitIdDropDownList(FineUIPro.DropDownList dropName, string unitId, bool isShowPlease)
|
||
{
|
||
dropName.DataValueField = "PersonId";
|
||
dropName.DataTextField = "PersonName";
|
||
dropName.DataSource = GetIsOfficeUserListByUnitId(unitId);
|
||
dropName.DataBind();
|
||
if (isShowPlease)
|
||
{
|
||
Funs.FineUIPleaseSelect(dropName);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据用户获取用户名称
|
||
/// </summary>
|
||
/// <param name="userId"></param>
|
||
/// <returns></returns>
|
||
public static string GetUserNameByUserId(string userId)
|
||
{
|
||
string userName = string.Empty;
|
||
Model.Person_Persons user = Funs.DB.Person_Persons.FirstOrDefault(e => e.PersonId == userId);
|
||
if (user != null)
|
||
{
|
||
userName = user.PersonName;
|
||
}
|
||
|
||
return userName;
|
||
}
|
||
}
|
||
} |