合并最新
This commit is contained in:
@@ -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 根据PersonId、TestPlanId生成试卷 扫码生成试卷
|
||||
/// <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 根据ProjectId、PersonId获取试卷列表
|
||||
/// <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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user