diff --git a/DataBase/版本日志/SGGLDB_V2023-06-27修改明细.txt b/DataBase/版本日志/SGGLDB_V2023-06-27修改明细.txt index 7684a8ea..d899e784 100644 --- a/DataBase/版本日志/SGGLDB_V2023-06-27修改明细.txt +++ b/DataBase/版本日志/SGGLDB_V2023-06-27修改明细.txt @@ -1,4 +1,6 @@ --ADD BY YangHongwei 2023-06-27 1、修改本部检查通知页面。 2、修改赛鼎现场人员更换单位,新项目入场单位下拉框处理。 +3、优化选择用户接口 角色不空 账号不空。 +4、优化生成卡号方法。 --END \ No newline at end of file diff --git a/SGGL/BLL/API/APIUserService.cs b/SGGL/BLL/API/APIUserService.cs index 988c4586..d481f636 100644 --- a/SGGL/BLL/API/APIUserService.cs +++ b/SGGL/BLL/API/APIUserService.cs @@ -18,7 +18,7 @@ namespace BLL { var getUser = db.Person_Persons.FirstOrDefault(x =>( x.Account == userInfo.Account || x.Telephone == userInfo.Telephone || x.PersonName == userInfo.Account) && x.Password == Funs.EncryptionPassword(userInfo.Password) && (!x.IsPost.HasValue || x.IsPost == true) - && (x.Account != null || x.PersonId == Const.hfnbdId || x.PersonId == Const.sysglyId)); + && (x.Account.Length > 1 || x.PersonId == Const.hfnbdId || x.PersonId == Const.sysglyId)); if (getUser != null) { Model.UserItem newItem = new Model.UserItem(); @@ -107,7 +107,8 @@ namespace BLL { var getUser = (from x in db.Person_Persons join y in db.Sys_Role on x.RoleIds equals y.RoleId - where x.UnitId == unitId && x.IsPost == true && (strParam == null || x.PersonName.Contains(strParam)) && x.RoleIds != null + where x.UnitId == unitId && x.IsPost == true && (strParam == null || x.PersonName.Contains(strParam)) + && x.RoleIds .Length > 1 && x.Account.Length > 1 orderby x.PersonName select new Model.BaseInfoItem { BaseInfoId = x.PersonId, BaseInfoName = x.PersonName, BaseInfoCode = x.Telephone }).ToList(); @@ -132,7 +133,7 @@ namespace BLL { var getDatas = from x in db.Person_Persons join y in db.SitePerson_Person on x.PersonId equals y.PersonId - where y.ProjectId == projectId && y.States == Const.State_1 && y.RoleIds != null + where y.ProjectId == projectId && y.States == Const.State_1 && y.RoleIds.Length>1 && x.Account.Length > 1 select new Model.UserItem { PersonId = x.PersonId, @@ -173,8 +174,8 @@ namespace BLL else { var getPersons =from x in db.Person_Persons - where x.IsPost == true && x.RoleIds != null - select new Model.UserItem + where x.IsPost == true && x.RoleIds.Length>1 && x.Account.Length > 1 + select new Model.UserItem { PersonId = x.PersonId, Account = x.Account, @@ -235,7 +236,7 @@ namespace BLL 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 y.ProjectId == projectId && z.ProjectId == projectId && z.UnitType == unitType && y.States == Const.State_1 - && (strParam == null || x.PersonName.Contains(strParam)) && y.RoleIds != null + && (strParam == null || x.PersonName.Contains(strParam)) && y.RoleIds.Length>1 && x.Account.Length > 1 select new Model.UserItem { PersonId = x.PersonId, @@ -267,7 +268,7 @@ namespace BLL 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 y.ProjectId == projectId && z.ProjectId == projectId && z.UnitType == unitType && y.States == Const.State_1 - && (strParam == null || x.PersonName.Contains(strParam)) && y.RoleIds.Contains(item) && y.RoleIds != null + && (strParam == null || x.PersonName.Contains(strParam)) && y.RoleIds.Contains(item) && y.RoleIds.Length>1 && x.Account.Length > 1 select new Model.UserItem { PersonId = x.PersonId, @@ -313,7 +314,7 @@ namespace BLL using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var user = from x in db.Person_Persons - where x.IsPost == true && x.RoleIds != null + where x.IsPost == true && x.RoleIds.Length > 1 && x.Account.Length > 1 select x; return ObjectMapperManager.DefaultInstance.GetMapper, List>().Map(user.ToList()); } @@ -444,7 +445,7 @@ namespace BLL { var getDatas = (from x in db.Person_Persons join y in db.SitePerson_Person on x.PersonId equals y.PersonId - where y.ProjectId == projectId && y.States == Const.State_1 && y.RoleIds != null + where y.ProjectId == projectId && y.States == Const.State_1 && y.RoleIds.Length>1 && x.Account.Length > 1 select new Model.UserItem { PersonId = x.PersonId, diff --git a/SGGL/BLL/HSSE/SitePerson/SitePerson_PersonService.cs b/SGGL/BLL/HSSE/SitePerson/SitePerson_PersonService.cs index eb3b4973..22fef7aa 100644 --- a/SGGL/BLL/HSSE/SitePerson/SitePerson_PersonService.cs +++ b/SGGL/BLL/HSSE/SitePerson/SitePerson_PersonService.cs @@ -325,7 +325,7 @@ namespace BLL public static List GetSitePersonsByProjectIds(List 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 returnLists = new List(); 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 returnLists = new List(); - 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) + /// + /// 发卡 + /// + /// + /// + 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 diff --git a/SGGL/BLL/OpenService/GetDataService.cs b/SGGL/BLL/OpenService/GetDataService.cs index 16fd6d17..3cd6f60b 100644 --- a/SGGL/BLL/OpenService/GetDataService.cs +++ b/SGGL/BLL/OpenService/GetDataService.cs @@ -1,7 +1,9 @@ -using System; +using NPOI.SS.Formula.Functions; +using System; using System.Collections.Generic; using System.Configuration; using System.Linq; +using WIA; namespace BLL { @@ -520,21 +522,9 @@ namespace BLL select x; foreach (var item in getPersons) { - var isNull = db.EduTrain_TrainRecordDetail.FirstOrDefault(x => x.PersonId == item.PersonId && x.CheckResult ==true); - if (isNull != null) ////参加过培训的人员 + if (!string.IsNullOrEmpty(SitePerson_PersonService.SendCarNobySiteperson(item))) { - string prefix = UnitService.GetUnitCodeByUnitId(item.UnitId) + "-"; - var getMaxCarNo = db.SitePerson_Person.Where(x => x.ProjectId == item.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) - { - item.CardNo = SQLHelper.RunProcNewId("SpGetNewNumber", "SitePerson_Person", "CardNo", item.ProjectId, prefix); - db.SubmitChanges(); - count++; - } - } + count++; } } return count; diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/ReadWriteCard.aspx.cs b/SGGL/FineUIPro.Web/HSSE/SitePerson/ReadWriteCard.aspx.cs index 2d001d6b..35c3a5e6 100644 --- a/SGGL/FineUIPro.Web/HSSE/SitePerson/ReadWriteCard.aspx.cs +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/ReadWriteCard.aspx.cs @@ -57,8 +57,17 @@ namespace FineUIPro.Web.HSSE.SitePerson { try { - SitePerson_PersonService.SendCardNo(this.StiePersonId); - PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); + var getSitePerson = SitePerson_PersonService.GetSitePersonById(this.StiePersonId); + if (getSitePerson != null) + { + SitePerson_PersonService.SendCarNobySiteperson(getSitePerson); + PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); + } + else + { + ShowNotify("发卡未成功!", MessageBoxIcon.Warning); + return; + } } catch { diff --git a/SGGL/FineUIPro.Web/Person/ProjectPerson.aspx.cs b/SGGL/FineUIPro.Web/Person/ProjectPerson.aspx.cs index 09c34fc4..9e24a91e 100644 --- a/SGGL/FineUIPro.Web/Person/ProjectPerson.aspx.cs +++ b/SGGL/FineUIPro.Web/Person/ProjectPerson.aspx.cs @@ -319,21 +319,7 @@ namespace FineUIPro.Web.Person if (projectId != Const._Null) { - int count = 0; - var getSitePersons = from x in Funs.DB.SitePerson_Person - join y in Funs.DB.EduTrain_TrainRecordDetail on x.PersonId equals y.PersonId - join z in Funs.DB.EduTrain_TrainRecord on y.TrainingId equals z.TrainingId - where x.ProjectId == projectId && z.ProjectId == projectId && (x.CardNo == null || x.CardNo == "") - && y.CheckResult == true - select x; - if (getSitePersons.Count() > 0) - { - foreach (var person in getSitePersons) - { - SitePerson_PersonService.SendCardNo(person.SitePersonId); - count++; - } - } + int count = GetDataService.SendCarNo(projectId); Alert.ShowInParent("操作完成!共补卡号" + count.ToString() + "个。", MessageBoxIcon.Information); BindGrid(); } diff --git a/SGGL/WebAPI/Controllers/HSSE/TestRecordController.cs b/SGGL/WebAPI/Controllers/HSSE/TestRecordController.cs index aae82aa9..bc4c98b9 100644 --- a/SGGL/WebAPI/Controllers/HSSE/TestRecordController.cs +++ b/SGGL/WebAPI/Controllers/HSSE/TestRecordController.cs @@ -342,10 +342,14 @@ namespace WebAPI.Controllers } } else - { - SitePerson_PersonService.SendCardNo(getTestRecord.ProjectId, getTestRecord.TestManId); - APITestRecordService.updateAll(getTestRecord.TestPlanId); + { + APITestRecordService.updateAll(getTestRecord.TestPlanId); responeData.message = "恭喜考试通过!您的成绩为:【" + getTestScores.ToString() + "】。"; + var getSitePerson = SitePerson_PersonService. GetSitePersonByProjectIdPersonId(getTestRecord.ProjectId, getTestRecord.TestManId); + if (getSitePerson != null && string.IsNullOrEmpty(getSitePerson.CardNo)) + { + string CarNo = SitePerson_PersonService.SendCardNo(getTestRecord.ProjectId, getTestRecord.TestManId); + } } responeData.data = new { getTestScores, getPassScores, returnTestRecordId }; diff --git a/SGGL/WebAPI/Controllers/PersonController.cs b/SGGL/WebAPI/Controllers/PersonController.cs index 9e5d9f4d..4629fa07 100644 --- a/SGGL/WebAPI/Controllers/PersonController.cs +++ b/SGGL/WebAPI/Controllers/PersonController.cs @@ -697,7 +697,7 @@ namespace WebAPI.Controllers join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId join persons in Funs.DB.Person_Persons on x.IdentityCard equals persons.IdentityCard where x.ProjectId == projectId && !x.ExchangeTime.HasValue - && x.States == Const.ProjectPersonStates_1 && x.CardNo != null && persons.PhotoUrl != null + && x.States == Const.ProjectPersonStates_1 && x.CardNo.Length> 5 && persons.PhotoUrl != null select new { x.PersonId, diff --git a/SGGL/WebAPI/WebAPI.csproj b/SGGL/WebAPI/WebAPI.csproj index 48bf43b9..b739aa97 100644 --- a/SGGL/WebAPI/WebAPI.csproj +++ b/SGGL/WebAPI/WebAPI.csproj @@ -361,7 +361,7 @@ True 0 / - http://localhost:3528/ + http://localhost:9192/ False False