合并最新

This commit is contained in:
2022-12-20 09:32:32 +08:00
parent 844e9f1488
commit 1abdaa9476
654 changed files with 73563 additions and 9746 deletions
+19 -2
View File
@@ -435,6 +435,23 @@ namespace BLL
}
#endregion
#region
/// <summary>
/// 获取部门信息
/// </summary>
/// <returns></returns>
public static List<Model.BaseInfoItem> getBaseDepart(string strParam)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var getDataLists = (from x in db.Base_Depart
where strParam == null || x.DepartName.Contains(strParam)
orderby x.DepartName
select new Model.BaseInfoItem { BaseInfoId = x.DepartId, BaseInfoCode = x.DepartCode, BaseInfoName = x.DepartName }).ToList();
return getDataLists;
}
}
#endregion
#region
/// <summary>
/// 获取岗位信息
@@ -459,12 +476,12 @@ namespace BLL
var getDataLists = (from x in db.Base_WorkPost
where strParam == null || x.WorkPostName.Contains(strParam)
orderby x.WorkPostName
select new Model.BaseInfoItem { BaseInfoId = x.WorkPostId, BaseInfoCode = x.WorkPostCode, BaseInfoName = x.WorkPostName }).ToList();
select new Model.BaseInfoItem { BaseInfoId = x.WorkPostId.ToUpper(), BaseInfoCode = x.WorkPostCode, BaseInfoName = x.WorkPostName }).ToList();
if (!string.IsNullOrEmpty(projectId))
{
var user = from u in db.SitePerson_Person
where u.ProjectId == projectId
select u.WorkPostId;
select u.WorkPostId.ToUpper();
var postIds = user.Distinct();
foreach (var item in getDataLists)
+5 -3
View File
@@ -82,6 +82,7 @@ namespace BLL
{
miniprogram_state = "formal";
}
//miniprogram_state = "developer";
string contenttype = "application/json;charset=utf-8";
string url = $"https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token={access_token}";
var tempData = new
@@ -89,7 +90,7 @@ namespace BLL
access_token,
touser = getUser.OpenId,
template_id = Const.WX_TemplateID,
page = "pages/index/main",
page = "pages/index/index",
data = new
{
thing2 = new { value = thing2 },
@@ -100,9 +101,10 @@ namespace BLL
miniprogram_state,
lang = "zh_CN",
};
string messages= APIGetHttpService.Http(url, "POST", contenttype, null, JsonConvert.SerializeObject(tempData));
string joson = JsonConvert.SerializeObject(tempData);
string messages= APIGetHttpService.Http(url, "POST", contenttype, null, joson);
//// 记录
SaveSysHttpLog(getUser.UserName, url, messages);
SaveSysHttpLog(getUser.UserName, url+ "$joson$" + joson , messages);
return messages;
}
else
+119 -20
View File
@@ -23,7 +23,7 @@ namespace BLL
var getUser = from x in db.SitePerson_Person
where (x.Telephone == userInfo.Account || x.PersonName == userInfo.Account)
&& (x.Password == Funs.EncryptionPassword(userInfo.Password) || (x.IdentityCard != null && x.IdentityCard.Substring(x.IdentityCard.Length - 4) == userInfo.Password))
&& x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime >= DateTime.Now) && x.IsUsed == true
&& x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime >= DateTime.Now) && x.IsUsed == 1
select x;
if (!string.IsNullOrEmpty(userInfo.LoginProjectId))
{
@@ -95,8 +95,8 @@ namespace BLL
Telephone = x.Telephone,
PhotoUrl = x.PhotoUrl,
DepartName = x.DepartName,
IsUsed = x.IsUsed,
IsUsedName = x.IsUsed == false ? "不启用" : "启用",
IsUsed = x.IsUsed == 1 ? true : false,
IsUsedName = x.IsUsed == 0 ? "不启用" : "启用",
AuditorId = x.AuditorId,
AuditorName = db.Sys_User.First(z => z.UserId == x.AuditorId).UserName,
IsForeign = x.IsForeign.HasValue ? x.IsForeign : false,
@@ -202,8 +202,8 @@ namespace BLL
Telephone = x.Telephone,
PhotoUrl = x.PhotoUrl,
DepartName = x.DepartName,
IsUsed = x.IsUsed,
IsUsedName = x.IsUsed == false ? "不启用" : "启用",
IsUsed = x.IsUsed==1?true:false,
IsUsedName = x.IsUsed == 0 ? "不启用" : "启用",
AuditorId = x.AuditorId,
AuditorName = db.Sys_User.First(z => z.UserId == x.AuditorId).UserName,
IsForeign = x.IsForeign.HasValue ? x.IsForeign : false,
@@ -257,7 +257,7 @@ namespace BLL
var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.PersonId == personId);
if (getPerson != null)
{
getPerson.IsUsed = false;
getPerson.IsUsed = 0;
getPerson.AuditorId = userId;
getPerson.AuditorDate = DateTime.Now;
db.SubmitChanges();
@@ -277,7 +277,7 @@ namespace BLL
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var persons = from x in db.View_SitePerson_Person
where x.ProjectId == projectId && (x.UnitId == unitId || unitId == null) && x.IsUsed == true
where x.ProjectId == projectId && (x.UnitId == unitId || unitId == null) && x.IsUsed == 1
&& x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime >= DateTime.Now)
orderby x.CardNo descending
select new Model.PersonItem
@@ -354,19 +354,19 @@ namespace BLL
}
if (states == "0")
{
getViews = getViews.Where(x => x.IsUsed == false && !x.AuditorDate.HasValue);
getViews = getViews.Where(x => x.IsUsed == 0 && !x.AuditorDate.HasValue);
}
else if (states == "1")
{
getViews = getViews.Where(x => x.IsUsed == true && x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime >= DateTime.Now));
getViews = getViews.Where(x => x.IsUsed == 1 && x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime >= DateTime.Now));
}
else if (states == "2")
{
getViews = getViews.Where(x => x.IsUsed == true && x.OutTime <= DateTime.Now);
getViews = getViews.Where(x => x.IsUsed == 1 && x.OutTime <= DateTime.Now);
}
else if (states == "-1")
{
getViews = getViews.Where(x => x.IsUsed == false && x.AuditorDate.HasValue);
getViews = getViews.Where(x => x.IsUsed == 0 && x.AuditorDate.HasValue);
}
getPersonListCount = getViews.Count();
@@ -400,8 +400,8 @@ namespace BLL
OutResult = x.OutResult,
Telephone = x.Telephone,
PhotoUrl = x.PhotoUrl,
IsUsed = x.IsUsed,
IsUsedName = (x.IsUsed == true ? "启用" : "未启用"),
IsUsed = x.IsUsed==1?true:false,
IsUsedName = (x.IsUsed == 1 ? "启用" : "未启用"),
WorkAreaId = x.WorkAreaId,
WorkAreaName = UnitWorkService.GetUnitWorkName(x.WorkAreaId),
PostType = ReturnQuality(x.PersonId, x.WorkPostId),
@@ -464,6 +464,100 @@ namespace BLL
}
#endregion
#region
/// <summary>
/// 根据培训类型获取项目培训人员信息
/// </summary>
/// <param name="projectId">项目ID</param>
/// <param name="unitIds">培训单位ID</param>
/// <param name="departIds">培训岗位ID</param>
/// <param name="trainTypeId">培训类型ID</param>
/// <returns></returns>
public static List<Model.PersonItem> getTrainingPersonListByDepartAndTrainTypeId( string unitIds, string departIds, string trainTypeId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<string> unitIdList = Funs.GetStrListByStr(unitIds, ',');
var getPersons = from x in db.Sys_User
where unitIdList.Contains(x.UnitId)
select new Model.PersonItem
{
PersonId = x.UserId,
PersonName = x.UserName,
SexName = x.Sex,
IdentityCard = x.IdentityCard,
UnitId = x.UnitId,
WorkPostId = x.WorkPostId,
Telephone = x.Telephone,
PhotoUrl = x.PhotoUrl,
DepartId = x.DepartId
};
if (!string.IsNullOrEmpty(departIds))
{
List<string> departIdList = Funs.GetStrListByStr(departIds, ',');
getPersons = getPersons.Where(x => departIdList.Contains(x.DepartId));
}
foreach (var item in getPersons)
{
Model.Base_Unit unit = db.Base_Unit.FirstOrDefault(x => x.UnitId == item.UnitId);
if (!string.IsNullOrEmpty(item.UnitId))
{
if (unit != null)
{
item.UnitCode = unit.UnitCode;
item.UnitName = unit.UnitName;
}
}
if (!string.IsNullOrEmpty(item.DepartId))
{
Model.Base_Depart depart = db.Base_Depart.FirstOrDefault(x => x.DepartId == item.DepartId);
if (depart != null)
{
item.DepartName = depart.DepartName;
}
}
}
//List<Model.PersonItem> getTrainPersonList = new List<Model.PersonItem>();
//var getTrainType = db.Base_TrainType.FirstOrDefault(e => e.TrainTypeId == trainTypeId);
//if (getTrainType != null && (!getTrainType.IsRepeat.HasValue || getTrainType.IsRepeat == false))
//{
// foreach (var item in getPersons)
// {
// var getTrainPersonIdList1 = (from x in db.EduTrain_TrainRecordDetail
// join y in db.EduTrain_TrainRecord on x.TrainingId equals y.TrainingId
// where y.ProjectId ==null && y.TrainTypeId == trainTypeId && x.CheckResult == true && x.PersonId == item.PersonId
// select x).FirstOrDefault();
// if (getTrainPersonIdList1 == null)
// {
// var getTrainPersonIdList2 = (from x in db.Training_Task
// join y in db.Training_Plan on x.PlanId equals y.PlanId
// where y.ProjectId == null && y.TrainTypeId == trainTypeId && y.States != "3" && x.UserId == item.PersonId
// select x).FirstOrDefault();
// if (getTrainPersonIdList2 == null)
// {
// getTrainPersonList.Add(item);
// }
// }
// }
// return getTrainPersonList;
//}
//else
{
return getPersons.ToList();
}
}
}
#endregion
#region
/// <summary>
/// 根据培训类型获取项目培训人员信息
@@ -473,13 +567,13 @@ namespace BLL
/// <param name="workPostIds">培训岗位ID</param>
/// <param name="trainTypeId">培训类型ID</param>
/// <returns></returns>
public static List<Model.PersonItem> getTrainingPersonListByTrainTypeId(string projectId, string unitIds, string workPostIds, string trainTypeId)
public static List<Model.PersonItem> getTrainingPersonListByTrainTypeId(string projectId, string unitIds, string workPostIds, string departIds, string trainTypeId)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
List<string> unitIdList = Funs.GetStrListByStr(unitIds, ',');
var getPersons = from x in db.View_SitePerson_Person
where x.ProjectId == projectId && unitIdList.Contains(x.UnitId) && x.IsUsed == true
where x.ProjectId == projectId && unitIdList.Contains(x.UnitId) && x.IsUsed == 1
&& x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime >= DateTime.Now)
select new Model.PersonItem
{
@@ -542,6 +636,11 @@ namespace BLL
}
}
}
#endregion
#region
@@ -626,11 +725,11 @@ namespace BLL
}
if (person.IsUsed == true)
{
newPerson.IsUsed = true;
newPerson.IsUsed = 1;
}
else
{
newPerson.IsUsed = false;
newPerson.IsUsed = 0;
}
newPerson.Password = PersonService.GetPersonPassWord(person.IdentityCard);
string rootUrl = ConfigurationManager.AppSettings["localRoot"];
@@ -703,13 +802,13 @@ namespace BLL
{
getPerson.WorkAreaId = person.WorkAreaId;
}
if (getPerson.AuditorDate.HasValue && getPerson.IsUsed == false)
if (getPerson.AuditorDate.HasValue && getPerson.IsUsed == 0)
{
getPerson.AuditorDate = null;
}
else
{
getPerson.IsUsed = person.IsUsed;
getPerson.IsUsed = person.IsUsed?1:0;
getPerson.AuditorDate = DateTime.Now;
}
getPerson.AuditorId = person.AuditorId;
@@ -1449,7 +1548,7 @@ namespace BLL
else message = "识别不到人脸";
if (isOK)
{
var faceResult = FaceClass.add(person.PersonId, person.IdentityCard, System.Configuration.ConfigurationManager.AppSettings["CEMS_IMG_URL"].ToString() + person.PhotoUrl, AccessToken.getAccessToken());
var faceResult = FaceClass.add(person.PersonId, person.IdentityCard, System.Configuration.ConfigurationManager.AppSettings["SGGLUrl"].ToString() + person.PhotoUrl, AccessToken.getAccessToken());
var face = JsonConvert.DeserializeObject<dynamic>(faceResult);
// JsonConvert.DeserializeObject<dynamic>(myPunishItem);
if (face.error_code == 0 || face.error_code == 223105)
+3 -3
View File
@@ -168,7 +168,7 @@ namespace BLL
join z in db.Base_WorkPost on x.WorkPostId equals z.WorkPostId
join y in db.QualityAudit_PersonQuality on x.PersonId equals y.PersonId into jonPerson
from y in jonPerson.DefaultIfEmpty()
where x.ProjectId == projectId && z.PostType == Const.PostType_2 && x.IsUsed == true && (!x.OutTime.HasValue || x.OutTime > DateTime.Now)
where x.ProjectId == projectId && z.PostType == Const.PostType_2 && x.IsUsed == 1 && (!x.OutTime.HasValue || x.OutTime > DateTime.Now)
orderby x.CardNo
select new Model.PersonQualityItem
{
@@ -210,7 +210,7 @@ namespace BLL
join z in db.Base_WorkPost on x.WorkPostId equals z.WorkPostId
join y in db.QualityAudit_SafePersonQuality on x.PersonId equals y.PersonId into jonPerson
from y in jonPerson.DefaultIfEmpty()
where x.ProjectId == projectId && z.IsHsse == true && x.IsUsed == true && (!x.OutTime.HasValue || x.OutTime > DateTime.Now)
where x.ProjectId == projectId && z.IsHsse == true && x.IsUsed == 1 && (!x.OutTime.HasValue || x.OutTime > DateTime.Now)
orderby y.LimitDate
select new Model.PersonQualityItem
{
@@ -252,7 +252,7 @@ namespace BLL
join z in db.Base_WorkPost on x.WorkPostId equals z.WorkPostId
join y in db.QualityAudit_EquipmentPersonQuality on x.PersonId equals y.PersonId into jonPerson
from y in jonPerson.DefaultIfEmpty()
where x.ProjectId == projectId && z.PostType == Const.PostType_5 && x.IsUsed == true && (!x.OutTime.HasValue || x.OutTime > DateTime.Now)
where x.ProjectId == projectId && z.PostType == Const.PostType_5 && x.IsUsed == 1 && (!x.OutTime.HasValue || x.OutTime > DateTime.Now)
orderby y.LimitDate
select new Model.PersonQualityItem
{
+88 -26
View File
@@ -24,24 +24,53 @@ namespace BLL
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var getDataLists = (from x in db.Training_TestPlan
where x.ProjectId == projectId && (x.States == states || states == null)
orderby x.TestStartTime descending
select new Model.TestPlanItem
{
TestPlanId = x.TestPlanId,
TestPlanCode = x.PlanCode,
TestPlanName = x.PlanName,
ProjectId = x.ProjectId,
TestPlanManId = x.PlanManId,
TestPlanManName = db.Sys_User.First(y => y.UserId == x.PlanManId).UserName,
TestPalce = x.TestPalce,
TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime),
TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestEndTime),
States = x.States,
QRCodeUrl = x.QRCodeUrl.Replace('\\', '/'),
}).ToList();
return getDataLists;
if (string.IsNullOrEmpty(projectId))
{
var getDataLists = (from x in db.Training_TestPlan
where x.ProjectId ==null && (x.States == states || states == null)
orderby x.TestStartTime descending
select new Model.TestPlanItem
{
TestPlanId = x.TestPlanId,
TestPlanCode = x.PlanCode,
TestPlanName = x.PlanName,
ProjectId = x.ProjectId,
DepartIds = x.DepartIds,
DepartNames = WorkPostService.getDepartNamesByIds(x.DepartIds),
TestPlanManId = x.PlanManId,
TestPlanManName = db.Sys_User.First(y => y.UserId == x.PlanManId).UserName,
TestPalce = x.TestPalce,
TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime),
TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestEndTime),
States = x.States,
QRCodeUrl = x.QRCodeUrl.Replace('\\', '/'),
}).ToList();
return getDataLists;
}
else
{
var getDataLists = (from x in db.Training_TestPlan
where x.ProjectId == projectId && (x.States == states || states == null)
orderby x.TestStartTime descending
select new Model.TestPlanItem
{
TestPlanId = x.TestPlanId,
TestPlanCode = x.PlanCode,
TestPlanName = x.PlanName,
ProjectId = x.ProjectId,
TestPlanManId = x.PlanManId,
DepartIds = x.DepartIds,
DepartNames = WorkPostService.getDepartNamesByIds(x.DepartIds),
TestPlanManName = db.Sys_User.First(y => y.UserId == x.PlanManId).UserName,
TestPalce = x.TestPalce,
TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime),
TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestEndTime),
States = x.States,
QRCodeUrl = x.QRCodeUrl.Replace('\\', '/'),
}).ToList();
return getDataLists;
}
}
}
#endregion
@@ -56,7 +85,7 @@ namespace BLL
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var getDataLists = from x in db.Training_TestPlan
var getDataLists = (from x in db.Training_TestPlan
where x.TestPlanId == testPlanId
select new Model.TestPlanItem
{
@@ -65,7 +94,6 @@ namespace BLL
TestPlanCode = x.PlanCode,
TestPlanName = x.PlanName,
TestPlanManId = x.PlanManId,
TestPlanManName = db.Sys_User.First(y => y.UserId == x.TestPlanId).UserName,
TestPlanDate = string.Format("{0:yyyy-MM-dd HH:mm}", x.PlanDate),
TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime),
TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestEndTime),
@@ -80,11 +108,36 @@ namespace BLL
UnitNames = UnitService.getUnitNamesUnitIds(x.UnitIds),
WorkPostIds = x.WorkPostIds,
WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIds(x.WorkPostIds),
DepartIds = x.DepartIds,
DepartNames = WorkPostService.getDepartNamesByIds(x.DepartIds),
States = x.States,
QRCodeUrl = x.QRCodeUrl.Replace('\\', '/'),
TrainingPlanId = x.PlanId,
};
return getDataLists.FirstOrDefault();
}).FirstOrDefault();
if (getDataLists != null)
{
var user = db.Sys_User.FirstOrDefault(y => y.UserId == getDataLists.TestPlanManId);
if (user != null)
getDataLists.TestPlanManName = user.UserName;
if (!string.IsNullOrEmpty(getDataLists.UnitIds))
{
string[] uids = getDataLists.UnitIds.Split(',');
var units = db.Base_Unit.Where(x => uids.Contains(x.UnitId)).ToList();
string unitName = "";
foreach(var u in units)
{
unitName += u.UnitName + ",";
}
if (!string.IsNullOrEmpty(unitName))
{
getDataLists.UnitNames = unitName;
}
}
}
return getDataLists;
}
}
#endregion
@@ -102,7 +155,7 @@ namespace BLL
Model.Training_TestPlan newTestPlan = new Model.Training_TestPlan
{
TestPlanId = getTestPlan.TestPlanId,
ProjectId = getTestPlan.ProjectId,
PlanCode = getTestPlan.TestPlanCode,
PlanName = getTestPlan.TestPlanName,
PlanManId = getTestPlan.TestPlanManId,
@@ -118,10 +171,14 @@ namespace BLL
TestPalce = getTestPlan.TestPalce,
UnitIds = getTestPlan.UnitIds,
WorkPostIds = getTestPlan.WorkPostIds,
DepartIds = getTestPlan.DepartIds,
States = getTestPlan.States,
PlanDate = DateTime.Now,
};
if (!string.IsNullOrEmpty(getTestPlan.ProjectId))
{
newTestPlan.ProjectId = getTestPlan.ProjectId;
}
if (!string.IsNullOrEmpty(getTestPlan.TrainingPlanId))
{
newTestPlan.PlanId = getTestPlan.TrainingPlanId;
@@ -162,6 +219,7 @@ namespace BLL
isUpdate.TestPalce = newTestPlan.TestPalce;
isUpdate.UnitIds = newTestPlan.UnitIds;
isUpdate.WorkPostIds = newTestPlan.WorkPostIds;
isUpdate.DepartIds = newTestPlan.DepartIds;
////删除 考生记录
var deleteRecords = from x in db.Training_TestRecord
where x.TestPlanId == isUpdate.TestPlanId
@@ -230,8 +288,9 @@ namespace BLL
////新增考试人员明细
foreach (var item in getTestPlan.TestRecordItems)
{
var person = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == item.TestManId);
if (person != null)
var user = db.Sys_User.FirstOrDefault(e => e.UserId == item.TestManId);
var person = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == item.TestManId);
if (user != null || person != null)
{
Model.Training_TestRecord newTrainDetail = new Model.Training_TestRecord
{
@@ -245,6 +304,7 @@ namespace BLL
db.Training_TestRecord.InsertOnSubmit(newTrainDetail);
db.SubmitChanges();
}
}
}
if (getTestPlan.TestPlanTrainingItems.Count() > 0)
@@ -357,6 +417,8 @@ namespace BLL
UnitNames = UnitService.getUnitNamesUnitIds(getTrainingPlan.UnitIds),
WorkPostIds = getTrainingPlan.WorkPostId,
WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIds(getTrainingPlan.WorkPostId),
DepartIds=getTrainingPlan.DepartIds,
DepartNames = WorkPostService.getDepartNamesByIds(getTrainingPlan.DepartIds),
PlanId = getTrainingPlan.PlanId,
States = "0",
};
+318 -39
View File
@@ -36,6 +36,27 @@ namespace BLL
TestType = x.TestType,
TemporaryUser = x.TemporaryUser,
}).ToList();
foreach(var item in getDataLists)
{
var user = db.Sys_User.FirstOrDefault(p => p.UserId == item.TestManId);
if (user != null)
{
item.TestManName = user.UserName;
}
else
{
var person = db.SitePerson_Person.FirstOrDefault(p => p.PersonId == item.TestManId);
if (person != null)
{
item.TestManName = person.PersonName;
}
}
}
return getDataLists;
}
}
@@ -70,7 +91,24 @@ namespace BLL
TestType = x.TestType,
TemporaryUser = x.TemporaryUser,
};
return getDataLists.FirstOrDefault();
var res = getDataLists.FirstOrDefault();
if (res != null)
{
var user = db.Sys_User.FirstOrDefault(x => x.UserId == res.TestManId);
if (user != null)
{
res.TestManName = user.UserName;
}
else
{
var person = db.SitePerson_Person.First(u => u.PersonId == res.TestManId);
if (person != null)
{
res.TestManName = person.PersonName;
}
}
}
return res;
}
}
#endregion
@@ -81,7 +119,152 @@ namespace BLL
/// </summary>
/// <param name="testPlanId"></param>
/// <returns></returns>
public static string CreateTestRecordItem(Model.Training_TestPlan getTestPlan, string testRecordId, Model.SitePerson_Person person)
public static string CreateTestRecordItem(Model.Training_TestPlan getTestPlan, string testRecordId, Model.SitePerson_Person person,Model.Sys_User user)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var getTestRecord = db.Training_TestRecord.FirstOrDefault(x => x.TestRecordId == testRecordId);
if (getTestRecord != null && !getTestRecord.TestStartTime.HasValue)
{
////考试时长
getTestRecord.Duration = getTestPlan.Duration;
getTestRecord.TestStartTime = DateTime.Now;
db.SubmitChanges();
}
////当前人考试记录 未加入考试计划的 当考试开始扫码时 不允许再参与考试
var item = db.Training_TestRecordItem.FirstOrDefault(x => x.TestRecordId == getTestRecord.TestRecordId);
if (item == null)
{
List<Model.Training_TestTrainingItem> getTestTrainingItemList = new List<Model.Training_TestTrainingItem>();
var testPlanTrainings = from x in db.Training_TestPlanTraining
where x.TestPlanId == getTestPlan.TestPlanId
select x;
//// 计划考试中单选、多选、判断题总数
int sumTestType1Count = testPlanTrainings.Sum(x => x.TestType1Count) ?? 0;
int sumTestType2Count = testPlanTrainings.Sum(x => x.TestType2Count) ?? 0;
int sumTestType3Count = testPlanTrainings.Sum(x => x.TestType3Count) ?? 0;
////获取类型下适合岗位试题集合
List<Model.Training_TestTrainingItem> getTestTrainingItemALLs;
string WorkPostId = "";
string DepartId = "";
if (person != null)
{
WorkPostId = person.WorkPostId;
}
if (user != null)
{
DepartId = user.DepartId;
}
getTestTrainingItemALLs = (from x in db.Training_TestTrainingItem
where x.TrainingId != null && (x.WorkPostIds == null || string.IsNullOrEmpty( WorkPostId ) || x.WorkPostIds.Contains(WorkPostId))||(x.DepartIds == null || string.IsNullOrEmpty(DepartId ) || x.DepartIds.Contains(DepartId))
select x).ToList();
foreach (var itemT in testPlanTrainings)
{
//// 获取类型下的题目
var getTestTrainingItems = getTestTrainingItemALLs.Where(x => x.TrainingId == itemT.TrainingId).ToList();
if (getTestTrainingItems.Count() > 0)
{
////单选题
var getSItem = getTestTrainingItems.Where(x => x.TestType == "1").OrderBy(x => Guid.NewGuid()).Take(itemT.TestType1Count ?? 1);
if (getSItem.Count() > 0)
{
getTestTrainingItemList.AddRange(getSItem);
}
///多选题
var getMItem = getTestTrainingItems.Where(x => x.TestType == "2").OrderBy(x => Guid.NewGuid()).Take(itemT.TestType2Count ?? 1);
if (getMItem.Count() > 0)
{
getTestTrainingItemList.AddRange(getMItem);
}
///判断题
var getJItem = getTestTrainingItems.Where(x => x.TestType == "3").OrderBy(x => Guid.NewGuid()).Take(itemT.TestType3Count ?? 1);
if (getJItem.Count() > 0)
{
getTestTrainingItemList.AddRange(getJItem);
}
}
}
//// 获取得到的单选题、多选题、判断题 数量
int getDiffTestType1Count = sumTestType1Count - getTestTrainingItemList.Where(x => x.TestType == "1").Count();
int getDiffTestType2Count = sumTestType2Count - getTestTrainingItemList.Where(x => x.TestType == "2").Count();
int getDiffTestType3Count = sumTestType3Count - getTestTrainingItemList.Where(x => x.TestType == "3").Count();
if (getDiffTestType1Count > 0 || getDiffTestType2Count > 0 || getDiffTestType3Count > 0)
{
var getTestTrainingItemNulls = getTestTrainingItemALLs.Where(x => x.WorkPostIds == null).ToList();
if (getTestTrainingItemNulls.Count() > 0)
{
/// 通用且未选择的题目
var getTestTrainingItemDiffs = getTestTrainingItemNulls.Except(getTestTrainingItemList).ToList();
////单选题
if (getDiffTestType1Count > 0)
{
var getSItemD = getTestTrainingItemDiffs.Where(x => x.TestType == "1").OrderBy(x => Guid.NewGuid()).Take(getDiffTestType1Count);
if (getSItemD.Count() > 0)
{
getTestTrainingItemList.AddRange(getSItemD);
}
}
///多选题
if (getDiffTestType2Count > 0)
{
var getMItemD = getTestTrainingItemDiffs.Where(x => x.TestType == "2").OrderBy(x => Guid.NewGuid()).Take(getDiffTestType2Count);
if (getMItemD.Count() > 0)
{
getTestTrainingItemList.AddRange(getMItemD);
}
}
///判断题
if (getDiffTestType3Count > 0)
{
var getJItemD = getTestTrainingItemDiffs.Where(x => x.TestType == "3").OrderBy(x => Guid.NewGuid()).Take(getDiffTestType3Count);
if (getJItemD.Count() > 0)
{
getTestTrainingItemList.AddRange(getJItemD);
}
}
}
}
if (getTestTrainingItemList.Count() > 0)
{
var getItems = from x in getTestTrainingItemList
select new Model.Training_TestRecordItem
{
TestRecordItemId = SQLHelper.GetNewID(),
TestRecordId = getTestRecord.TestRecordId,
TrainingItemName = x.TrainingItemName,
TrainingItemCode = x.TrainingItemCode,
Abstracts = x.Abstracts,
AttachUrl = x.AttachUrl,
TestType = x.TestType,
AItem = x.AItem,
BItem = x.BItem,
CItem = x.CItem,
DItem = x.DItem,
EItem = x.EItem,
AnswerItems = x.AnswerItems,
Score = x.TestType == "1" ? getTestPlan.SValue : (x.TestType == "2" ? getTestPlan.MValue : getTestPlan.JValue),
};
db.Training_TestRecordItem.InsertAllOnSubmit(getItems);
db.SubmitChanges();
}
}
}
return testRecordId;
}
#endregion
#region PersonIdTestPlanId生成试卷
/// <summary>
/// 根据PersonId、TestPlanId生成试卷 扫码生成试卷
/// </summary>
/// <param name="testPlanId"></param>
/// <returns></returns>
public static string CreateFixTestRecordItem(Model.Training_TestPlan getTestPlan, string testRecordId, Model.SitePerson_Person person)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
@@ -207,7 +390,6 @@ namespace BLL
return testRecordId;
}
#endregion
#region ProjectIdPersonId获取试卷列表
/// <summary>
/// 根据ProjectId、PersonId获取试卷列表
@@ -219,29 +401,48 @@ namespace BLL
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var getDataLists = (from x in db.Training_TestRecord
join y in db.Training_TestPlan on x.TestPlanId equals y.TestPlanId
where x.ProjectId == projectId && x.TestManId == personId && x.TestStartTime.HasValue
orderby x.TestStartTime descending
select new Model.TestRecordItem
{
TestRecordId = x.TestRecordId,
ProjectId = x.ProjectId,
TestPlanId = x.TestPlanId,
TestPlanName = y.PlanName,
TestManId = x.TestManId,
TestManName = db.SitePerson_Person.FirstOrDefault(p => p.PersonId == x.TestManId).PersonName,
TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime),
TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestEndTime),
Duration = x.Duration,
TestPlanEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime.Value.AddMinutes(x.Duration)),
TotalScore = y.TotalScore ?? 0,
TestScores = x.TestScores ?? 0,
TestType = x.TestType,
TemporaryUser = x.TemporaryUser,
}).ToList();
return getDataLists;
}
var getDataLists = (from x in db.Training_TestRecord
join y in db.Training_TestPlan on x.TestPlanId equals y.TestPlanId
where ((string.IsNullOrEmpty(projectId) && x.ProjectId == null) || (!string.IsNullOrEmpty(projectId) && x.ProjectId == projectId)) && x.TestManId == personId && x.TestStartTime.HasValue
orderby x.TestStartTime descending
select new Model.TestRecordItem
{
TestRecordId = x.TestRecordId,
ProjectId = x.ProjectId,
TestPlanId = x.TestPlanId,
TestPlanName = y.PlanName,
TestManId = x.TestManId,
TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime),
TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestEndTime),
Duration = x.Duration,
TestPlanEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime.Value.AddMinutes(x.Duration)),
TotalScore = y.TotalScore ?? 0,
TestScores = x.TestScores ?? 0,
TestType = x.TestType,
TemporaryUser = x.TemporaryUser,
}).ToList();
foreach(var item in getDataLists)
{
var user = db.Sys_User.FirstOrDefault(x=>x.UserId==item.TestManId);
if (user != null)
{
item.TestManName = user.UserName;
}
else
{
var person = db.SitePerson_Person.FirstOrDefault(p => p.PersonId == item.TestManId);
item.TestManName = person.PersonName;
}
}
return getDataLists;
}
}
#endregion
@@ -258,7 +459,7 @@ namespace BLL
var getDataLists = (from x in db.Training_TestRecord
join y in db.Training_TestPlan on x.TestPlanId equals y.TestPlanId
join z in db.SitePerson_Person on x.TestManId equals z.PersonId
where x.ProjectId == projectId && x.TestStartTime.HasValue && x.TestEndTime.HasValue
where ((string.IsNullOrEmpty(projectId) && x.ProjectId ==null) || (!string.IsNullOrEmpty(projectId) && x.ProjectId == projectId)) && x.TestStartTime.HasValue && x.TestEndTime.HasValue
orderby x.TestStartTime descending
select new Model.TestRecordItem
{
@@ -308,6 +509,73 @@ namespace BLL
return getDataLists.ToList();
}
}
public static List<Model.TestRecordItem> getTrainingTestRecordListByDepartId( string unitId, string departId, string strPass, string strParam)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var getDataLists = (from x in db.Training_TestRecord
join y in db.Training_TestPlan on x.TestPlanId equals y.TestPlanId
join z in db.Sys_User on x.TestManId equals z.UserId
where x.ProjectId == null && x.TestStartTime.HasValue && x.TestEndTime.HasValue
orderby x.TestStartTime descending
select new Model.TestRecordItem
{
TestRecordId = x.TestRecordId,
ProjectId = x.ProjectId,
TestPlanId = x.TestPlanId,
TestPlanName = y.PlanName,
UnitId = z.UnitId,
UnitName = getUnitName(z.UnitId),
WorkPostId = z.WorkPostId,
WorkPostName = db.Base_WorkPost.FirstOrDefault(p => p.WorkPostId == z.WorkPostId).WorkPostName,
DepartId = z.DepartId,
TestManId = x.TestManId,
TestManName = db.SitePerson_Person.FirstOrDefault(p => p.PersonId == x.TestManId).PersonName,
TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime),
TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestEndTime),
Duration = x.Duration,
TestPlanEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime.Value.AddMinutes(x.Duration)),
TotalScore = y.TotalScore ?? 0,
TestScores = x.TestScores ?? 0,
TestType = x.TestType,
TemporaryUser = x.TemporaryUser,
});
if (!string.IsNullOrEmpty(unitId))
{
getDataLists = getDataLists.Where(x => x.UnitId == unitId);
}
if (!string.IsNullOrEmpty(departId))
{
getDataLists = getDataLists.Where(x => x.DepartId == departId);
}
if (!string.IsNullOrEmpty(strParam))
{
getDataLists = getDataLists.Where(x => x.TestManName.Contains(strParam));
}
if (!string.IsNullOrEmpty(strPass))
{
int PassingScore = SysConstSetService.getPassScore();
if (strPass == "0")
{
getDataLists = getDataLists.Where(x => x.TestScores < PassingScore);
}
else
{
getDataLists = getDataLists.Where(x => x.TestScores >= PassingScore);
}
}
foreach(var item in getDataLists)
{
var depart = db.Base_Depart.FirstOrDefault(x => x.DepartId == item.DepartId);
if (depart != null)
{
item.DepartName = depart.DepartName;
}
}
return getDataLists.ToList();
}
}
/// <summary>
///
@@ -319,10 +587,18 @@ namespace BLL
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
string name = string.Empty;
var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.PersonId == testManId);
if (getPerson != null)
var user = db.Sys_User.FirstOrDefault(x => x.UserId == testManId);
if (user != null)
{
name = UnitService.GetUnitNameByUnitId(getPerson.UnitId);
name = UnitService.GetUnitNameByUnitId(user.UnitId);
}
else
{
var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.PersonId == testManId);
if (getPerson != null)
{
name = UnitService.GetUnitNameByUnitId(getPerson.UnitId);
}
}
return name;
}
@@ -542,7 +818,8 @@ namespace BLL
/// <param name="testRecord"></param>
public static string getResitTestRecord(Model.Training_TestRecord getTestRecord)
{
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
using (var db = new Model.SGGLDB(Funs.ConnString))
{ Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
{
TestRecordId = SQLHelper.GetNewID(),
ProjectId = getTestRecord.ProjectId,
@@ -554,16 +831,18 @@ namespace BLL
// TestStartTime = DateTime.Now,
};
Funs.DB.Training_TestRecord.InsertOnSubmit(newTestRecord);
Funs.DB.SubmitChanges();
db.Training_TestRecord.InsertOnSubmit(newTestRecord);
db.SubmitChanges();
var getTestPlan = Funs.DB.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == newTestRecord.TestPlanId);
var person = PersonService.GetPersonByUserId(newTestRecord.TestManId, getTestPlan.ProjectId);
if (getTestPlan != null && person != null)
{
CreateTestRecordItem(getTestPlan, newTestRecord.TestRecordId, person);
var getTestPlan = db.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == newTestRecord.TestPlanId);
var user = db.Sys_User.FirstOrDefault(x => x.UserId == newTestRecord.TestManId);
var person = PersonService.GetPersonByUserId(newTestRecord.TestManId, getTestPlan.ProjectId);
if (getTestPlan != null && person != null)
{
CreateTestRecordItem(getTestPlan, newTestRecord.TestRecordId, person, user);
}
return newTestRecord.TestRecordId;
}
return newTestRecord.TestRecordId;
}
#endregion
}
+1 -1
View File
@@ -21,7 +21,7 @@ namespace BLL
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var getDataLists = (from x in db.EduTrain_TrainRecord
where x.ProjectId == projectId && x.TrainTypeId == trainTypeId
where ((string.IsNullOrEmpty(projectId) && x.ProjectId == null) || (!string.IsNullOrEmpty(projectId) && x.ProjectId == projectId)) && x.TrainTypeId == trainTypeId
orderby x.TrainStartDate descending
select new Model.TrainRecordItem
{
@@ -22,7 +22,7 @@ namespace BLL
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var getDataLists = (from x in db.Training_TrainTestRecord
where x.ProjectId == projectId
where ((string.IsNullOrEmpty(projectId) && x.ProjectId == null) || (!string.IsNullOrEmpty(projectId) && x.ProjectId == projectId))
orderby x.DateA descending
select new Model.HSSE.TrainTestRecordItem
{
+11 -3
View File
@@ -21,7 +21,7 @@ namespace BLL
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var getDataLists = (from x in db.Training_Plan
where x.ProjectId == projectId && (x.States == states || states == null) && x.TrainTypeId == trainTypeId
where ((string.IsNullOrEmpty(projectId) && x.ProjectId == null) || (!string.IsNullOrEmpty(projectId) && x.ProjectId == projectId)) && (x.States == states || states == null) && x.TrainTypeId == trainTypeId
orderby x.TrainStartDate descending
select new Model.TrainingPlanItem
{
@@ -76,9 +76,11 @@ namespace BLL
TeachMan = x.TeachMan,
UnitIds = x.UnitIds,
WorkPostId = x.WorkPostId,
DepartIds = x.DepartIds,
DepartNames = WorkPostService.getDepartNamesByIds(x.DepartIds),
TrainContent = x.TrainContent,
UnitNames = UnitService.getUnitNamesUnitIds(x.UnitIds),
WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIds(x.WorkPostId),
WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIds(x.WorkPostId),
DesignerId = x.DesignerId,
DesignerName = db.Sys_User.First(y => y.UserId == x.DesignerId).UserName,
DesignerDate = string.Format("{0:yyyy-MM-dd HH:mm}", x.TrainStartDate),
@@ -136,7 +138,7 @@ namespace BLL
{
PlanId = trainingPlan.PlanId,
PlanCode = trainingPlan.PlanCode,
ProjectId = trainingPlan.ProjectId,
DesignerId = trainingPlan.DesignerId,
PlanName = trainingPlan.PlanName,
TrainContent = trainingPlan.TrainContent,
@@ -147,9 +149,15 @@ namespace BLL
TrainTypeId = trainingPlan.TrainTypeId,
UnitIds = trainingPlan.UnitIds,
WorkPostId = trainingPlan.WorkPostId,
DepartIds = trainingPlan.DepartIds,
DepartNames = trainingPlan.DepartNames,
States = trainingPlan.States,
};
if (!string.IsNullOrEmpty(trainingPlan.ProjectId))
{
newTrainingPlan.ProjectId = trainingPlan.ProjectId;
}
if (!string.IsNullOrEmpty(trainingPlan.TrainLevelId))
{
newTrainingPlan.TrainLevelId = trainingPlan.TrainLevelId;
+41 -6
View File
@@ -21,7 +21,7 @@ namespace BLL
personId = PersonService.GetPersonIdByUserId(personId);
var getDataLists = (from x in db.Training_Task
join y in db.Training_Plan on x.PlanId equals y.PlanId
where x.ProjectId == projectId && x.UserId == personId && y.States != "0"
where ((string.IsNullOrEmpty(projectId) && x.ProjectId == null) || (!string.IsNullOrEmpty(projectId) && x.ProjectId == projectId)) && x.UserId == personId && y.States != "0"
orderby x.TaskDate descending
select new Model.TrainingTaskItem
{
@@ -31,13 +31,27 @@ namespace BLL
PlanName = y.PlanName,
TrainStartDate = string.Format("{0:yyyy-MM-dd HH:mm}", y.TrainStartDate),
TeachAddress = y.TeachAddress,
//PersonId = x.UserId,
PersonName = db.SitePerson_Person.FirstOrDefault(p => p.PersonId == x.UserId).PersonName,
PersonId = x.UserId,
TaskDate = string.Format("{0:yyyy-MM-dd HH:mm}", x.TaskDate),
TrainTypeName = db.Base_TrainType.FirstOrDefault(b => b.TrainTypeId == y.TrainTypeId).TrainTypeName,
TrainLevelName = db.Base_TrainLevel.FirstOrDefault(b => b.TrainLevelId == y.TrainLevelId).TrainLevelName,
PlanStatesName = y.States == "3" ? "已完成" : "培训中",
}).ToList();
foreach(var item in getDataLists)
{
var user = db.Sys_User.FirstOrDefault(x=>x.UserId==item.PersonId);
if (user != null)
{
item.PersonName = user.UserName;
}
else
{
var person = db.SitePerson_Person.FirstOrDefault(p => p.PersonId == item.PersonId);
item.PersonName = person.PersonName ;
}
}
return getDataLists;
}
}
@@ -102,9 +116,11 @@ namespace BLL
}
else
{
var user = db.Sys_User.FirstOrDefault(e => e.UserId == personId);
var person = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId);
if (person != null && plan.ProjectId == person.ProjectId && plan.UnitIds.Contains(person.UnitId)
&& (string.IsNullOrEmpty(plan.WorkPostId) || plan.WorkPostId.Contains(person.WorkPostId)))
if ((person != null && plan.ProjectId == person.ProjectId && plan.UnitIds.Contains(person.UnitId)
&& (string.IsNullOrEmpty(plan.WorkPostId) || plan.WorkPostId.Contains(person.WorkPostId)))|| (user != null && plan.UnitIds.Contains(person.UnitId)
&& (string.IsNullOrEmpty(plan.DepartIds) || plan.DepartIds.Contains(person.DepartId))))
{
var trainType = db.Base_TrainType.FirstOrDefault(e => e.TrainTypeId == plan.TrainTypeId);
if (trainType != null)
@@ -205,10 +221,29 @@ namespace BLL
TaskId = x.TaskId,
PlanId = x.PlanId,
PersonId = x.UserId,
PersonName = db.SitePerson_Person.FirstOrDefault(p => p.PersonId == x.UserId).PersonName,
TaskDate = string.Format("{0:yyyy-MM-dd HH:mm}", x.TaskDate),
States = x.States,
}).ToList();
foreach(var item in getDataLists)
{
var person = db.SitePerson_Person.FirstOrDefault(p => p.PersonId == item.PersonId);
if (person != null)
{
item.PersonName = person.PersonName;
}
else
{
var sysUser = db.Sys_User.FirstOrDefault(p => p.UserId == item.PersonId);
if (sysUser != null)
{
item.PersonName = sysUser.UserName;
}
}
}
return getDataLists;
}
}