20230627优化选择用户接口 角色不空 账号不空,优化生成卡号方法。
This commit is contained in:
@@ -325,7 +325,7 @@ namespace BLL
|
||||
public static List<Model.SitePerson_Person> GetSitePersonsByProjectIds(List<string> ProjectIds)
|
||||
{
|
||||
return (from x in Funs.DB.SitePerson_Person
|
||||
where ProjectIds.Contains(x.ProjectId) && x.RoleIds != null
|
||||
where ProjectIds.Contains(x.ProjectId) && x.RoleIds.Length > 1
|
||||
select x).ToList();
|
||||
}
|
||||
#endregion
|
||||
@@ -342,7 +342,7 @@ namespace BLL
|
||||
List<Model.SitePerson_Person> returnLists = new List<Model.SitePerson_Person>();
|
||||
var getSitePerson = db.SitePerson_Person.Where(x => x.ProjectId == projectId
|
||||
&& x.States == Const.ProjectPersonStates_1
|
||||
&& x.RoleIds != null);
|
||||
&& x.RoleIds.Length > 1);
|
||||
var uList = Funs.GetStrListByStr(unitTypes, ',');
|
||||
if (!string.IsNullOrEmpty(unitTypes))
|
||||
{
|
||||
@@ -385,7 +385,7 @@ namespace BLL
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
List<Model.SitePerson_Person> returnLists = new List<Model.SitePerson_Person>();
|
||||
var getgetSitePerson = db.SitePerson_Person.Where(x => x.ProjectId == projectId && x.States == Const.ProjectPersonStates_1 && x.RoleIds != null);
|
||||
var getgetSitePerson = db.SitePerson_Person.Where(x => x.ProjectId == projectId && x.States == Const.ProjectPersonStates_1 && x.RoleIds.Length > 1);
|
||||
if (!string.IsNullOrEmpty(unitIds))
|
||||
{
|
||||
var getUnitIdsList = Funs.GetStrListByStr(unitIds, ',');
|
||||
@@ -638,35 +638,49 @@ namespace BLL
|
||||
var getSitePerson = GetSitePersonByProjectIdPersonId(projectId, personId);
|
||||
if (getSitePerson != null && string.IsNullOrEmpty(getSitePerson.CardNo))
|
||||
{
|
||||
string prefix = UnitService.GetUnitCodeByUnitId(getSitePerson.UnitId) + "-";
|
||||
var getMaxCarNo = Funs.DB.SitePerson_Person.Where(x => x.ProjectId == projectId && x.CardNo.Contains(prefix)).Max(x => x.CardNo);
|
||||
if (!string.IsNullOrEmpty(getMaxCarNo) && getMaxCarNo.Length > 5)
|
||||
{
|
||||
var getInt = Funs.GetNewInt(getMaxCarNo.Substring(getMaxCarNo.Length-5));
|
||||
if (getInt.HasValue)
|
||||
{
|
||||
cardNo = SQLHelper.RunProcNewId("SpGetNewNumber", "SitePerson_Person", "CardNo", getSitePerson.ProjectId, prefix);
|
||||
getSitePerson.CardNo = cardNo;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
cardNo= SendCarNobySiteperson(getSitePerson);
|
||||
}
|
||||
|
||||
return cardNo;
|
||||
}
|
||||
|
||||
public static string SendCardNo(string sitepersinId)
|
||||
/// <summary>
|
||||
/// 发卡
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public static string SendCarNobySiteperson(Model.SitePerson_Person item)
|
||||
{
|
||||
string cardNo = string.Empty;
|
||||
var getSitePerson = GetSitePersonById(sitepersinId);
|
||||
if (getSitePerson != null && string.IsNullOrEmpty(getSitePerson.CardNo))
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
cardNo = SQLHelper.RunProcNewId("SpGetNewNumber", "SitePerson_Person", "CardNo", getSitePerson.ProjectId, UnitService.GetUnitCodeByUnitId(getSitePerson.UnitId) +"-");
|
||||
getSitePerson.CardNo = cardNo;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
string carNo = string.Empty;
|
||||
var isNull = db.EduTrain_TrainRecordDetail.FirstOrDefault(x => x.PersonId == item.PersonId && x.CheckResult == true);
|
||||
if (isNull != null) ////参加过培训的人员
|
||||
{
|
||||
string prefix = UnitService.GetUnitCodeByUnitId(item.UnitId) + "-";
|
||||
var getCarPerson = db.SitePerson_Person.Where(x => x.ProjectId == item.ProjectId && x.CardNo.Contains(prefix) && x.CardNo.Length > 5);
|
||||
if (getCarPerson.Count() > 0)
|
||||
{
|
||||
var getMaxCarNo = getCarPerson.Max(x => x.CardNo);
|
||||
if (!string.IsNullOrEmpty(getMaxCarNo) && getMaxCarNo.Length > 5)
|
||||
{
|
||||
var getInt = Funs.GetNewInt(getMaxCarNo.Substring(getMaxCarNo.Length - 5));
|
||||
if (getInt.HasValue)
|
||||
{
|
||||
carNo= item.CardNo = SQLHelper.RunProcNewId("SpGetNewNumber", "SitePerson_Person", "CardNo", item.ProjectId, prefix);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
carNo = item.CardNo = prefix + "00001";
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
return cardNo;
|
||||
return carNo;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user