合并最新

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
+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;
}
}