1
This commit is contained in:
@@ -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.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,
|
||||
DepartIds = x.DepartIds,
|
||||
DepartNames = WorkPostService.getDepartNamesByIdsForApi(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.getDepartNamesByIdsForApi(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
|
||||
|
||||
@@ -389,7 +389,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
|
||||
{
|
||||
@@ -697,5 +697,73 @@ namespace BLL
|
||||
return newTestRecord.TestRecordId;
|
||||
}
|
||||
#endregion
|
||||
|
||||
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.getPassScoreForApi();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,8 @@ 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 == null || x.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 || x.ProjectId == "")) || (!string.IsNullOrEmpty(projectId) && x.ProjectId == projectId))
|
||||
orderby x.DateA descending
|
||||
select new Model.HSSE.TrainTestRecordItem
|
||||
{
|
||||
|
||||
@@ -21,7 +21,15 @@ 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 || x.ProjectId == ""))
|
||||
||
|
||||
(!string.IsNullOrEmpty(projectId) && x.ProjectId == projectId)
|
||||
)
|
||||
|
||||
&& (x.States == states || states == null)
|
||||
&& x.TrainTypeId == trainTypeId
|
||||
orderby x.TrainStartDate descending
|
||||
select new Model.TrainingPlanItem
|
||||
{
|
||||
@@ -76,14 +84,18 @@ namespace BLL
|
||||
TeachMan = x.TeachMan,
|
||||
UnitIds = x.UnitIds,
|
||||
WorkPostId = x.WorkPostId,
|
||||
DepartIds = x.DepartIds,
|
||||
DepartNames = WorkPostService.getDepartNamesByIdsForApi(x.DepartIds),
|
||||
TrainContent = x.TrainContent,
|
||||
UnitNames = UnitService.getUnitNamesUnitIds(x.UnitIds),
|
||||
WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIds(x.WorkPostId),
|
||||
UnitNames = UnitService.getUnitNamesUnitIdsForApi(x.UnitIds),
|
||||
WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIdsForApi(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),
|
||||
States = x.States,
|
||||
QRCodeUrl = x.QRCodeUrl.Replace('\\', '/'),
|
||||
|
||||
TrainingTasks = getTrainingTasks(x.PlanId)
|
||||
};
|
||||
return getDataLists.FirstOrDefault();
|
||||
}
|
||||
@@ -136,7 +148,7 @@ namespace BLL
|
||||
{
|
||||
PlanId = trainingPlan.PlanId,
|
||||
PlanCode = trainingPlan.PlanCode,
|
||||
ProjectId = trainingPlan.ProjectId,
|
||||
|
||||
DesignerId = trainingPlan.DesignerId,
|
||||
PlanName = trainingPlan.PlanName,
|
||||
TrainContent = trainingPlan.TrainContent,
|
||||
@@ -147,9 +159,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;
|
||||
@@ -200,6 +218,8 @@ namespace BLL
|
||||
isUpdate.UnitIds = newTrainingPlan.UnitIds;
|
||||
isUpdate.WorkPostId = newTrainingPlan.WorkPostId;
|
||||
isUpdate.States = newTrainingPlan.States;
|
||||
isUpdate.DepartIds = newTrainingPlan.DepartIds;
|
||||
isUpdate.DepartNames = newTrainingPlan.DepartNames;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
////删除培训任务
|
||||
@@ -275,6 +295,24 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Model.TrainingTaskItem> getTrainingTasks(string planId) {
|
||||
var list = new List<Model.TrainingTaskItem>();
|
||||
var taskList = Funs.DB.Training_Task.Where(x => x.PlanId == planId);
|
||||
if (taskList.Count()>0)
|
||||
{
|
||||
foreach (var item in taskList)
|
||||
{
|
||||
var model = new Model.TrainingTaskItem();
|
||||
model.TaskId = item.TaskId;
|
||||
model.PlanId = item.PlanId;
|
||||
model.PersonId = item.UserId;
|
||||
model.PersonName = UserService.GetUserNameByUserId(item.UserId);
|
||||
list.Add(model);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增 培训人员明细
|
||||
/// </summary>
|
||||
|
||||
@@ -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 || x.ProjectId == "")) || (!string.IsNullOrEmpty(projectId) && x.ProjectId == projectId)) && x.UserId == personId && y.States != "0"
|
||||
orderby x.TaskDate descending
|
||||
select new Model.TrainingTaskItem
|
||||
{
|
||||
@@ -31,17 +31,30 @@ namespace BLL
|
||||
PlanName = y.PlanName,
|
||||
TrainStartDate = string.Format("{0:yyyy-MM-dd HH:mm}", y.TrainStartDate),
|
||||
TeachAddress = y.TeachAddress,
|
||||
//PersonId = x.UserId,
|
||||
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),
|
||||
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();
|
||||
TaskStatesName = x.States == "2" ? "已完成" : "培训中",
|
||||
TrainingItemCode = getTrainingItemCode(y.PlanId)
|
||||
}).ToList();
|
||||
return getDataLists;
|
||||
}
|
||||
}
|
||||
|
||||
public static string getTrainingItemCode(string PlanId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var ids = db.Training_PlanItem.Where(xx => xx.PlanId == PlanId).Select(x => x.CompanyTrainingItemId).ToList();
|
||||
var codes = db.Training_CompanyTrainingItem.Where(x => ids.Contains(x.CompanyTrainingItemId)).Select(x => x.CompanyTrainingItemCode);
|
||||
string res = string.Join(",", codes);
|
||||
return res;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 根据TaskId获取培训任务教材明细列表
|
||||
@@ -210,10 +223,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,
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user