diff --git a/SGGL/BLL/API/HSSE/APITrainingTaskService.cs b/SGGL/BLL/API/HSSE/APITrainingTaskService.cs index f027876..7601e20 100644 --- a/SGGL/BLL/API/HSSE/APITrainingTaskService.cs +++ b/SGGL/BLL/API/HSSE/APITrainingTaskService.cs @@ -98,6 +98,54 @@ namespace BLL return getDataLists; } } + + #endregion + + #region 根据ProjectId、PersonId获取培训任务列表 + + /// + /// 根据ProjectId、PersonId获取培训任务列表 + /// + /// + /// + /// + /// + public static List getTrainingRecordItemListByProjectIdPersonId(string projectId, string personId, string isRetakeCourse) + { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + var getDataLists = (from x in db.Training_TaskItem + join t in db.Training_Task on x.TaskId equals t.TaskId + join p in db.Training_Plan on x.PlanId equals p.PlanId + join y in db.Training_CompanyTrainingItem on x.TrainingItemCode equals y.CompanyTrainingItemCode into temp + //join z in db.Training_CompanyTraining on y.CompanyTrainingId equals z.CompanyTrainingId into temp + from y in temp.DefaultIfEmpty() + where t.ProjectId == projectId && t.UserId == personId + orderby x.TrainingItemCode + select new Model.TrainingRecordItemItem + { + TaskItemId = x.TaskItemId, + TaskId = x.TaskId, + PlanId = x.PlanId, + StartTime = x.StartTime, + EndTime = x.EndTime, + LearningTime = x.LearnTime, + AttachTime = y.LearningTime, + VideoProgress = x.VideoProgress, + PersonId = x.PersonId, + TrainingItemCode = x.TrainingItemCode, + TrainingItemName = x.TrainingItemName, + AttachUrl = x.AttachUrl.Replace('\\', '/'), + IsRetakeCourse = p.IsRetakeCourse == 1 ? 1 : 0, + }).ToList(); + if (!string.IsNullOrWhiteSpace(isRetakeCourse)) + { + getDataLists = getDataLists.Where(x => x.IsRetakeCourse == int.Parse(isRetakeCourse)).ToList(); + } + return getDataLists; + } + } + #endregion #region 根据PlanId、PersonId将人员加入培训任务条件 diff --git a/SGGL/Model/APIItem/HSSE/TrainingRecordItemItem.cs b/SGGL/Model/APIItem/HSSE/TrainingRecordItemItem.cs new file mode 100644 index 0000000..8ecfdbf --- /dev/null +++ b/SGGL/Model/APIItem/HSSE/TrainingRecordItemItem.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Model +{ + public class TrainingRecordItemItem + { + /// + /// 培训任务教材明细ID + /// + public string TaskItemId + { + get; + set; + } + /// + /// 项目ID + /// + public string ProjectId + { + get; + set; + } + /// + /// 培训任务ID + /// + public string TaskId + { + get; + set; + } + /// + /// 培训计划ID + /// + public string PlanId + { + get; + set; + } + /// + /// 培训计划名称 + /// + public string PlanName + { + get; + set; + } + /// + /// 培训计划编号 + /// + public string PlanCode + { + get; + set; + } + /// + /// 培训人员ID + /// + public string PersonId + { + get; + set; + } + /// + /// 教材编号 + /// + public string TrainingItemCode + { + get; + set; + } + /// + /// 教材名称 + /// + public string TrainingItemName + { + get; + set; + } + ///// + ///// 培训类型名称 + ///// + //public string TrainTypeName + //{ + // get; + // set; + //} + /// + /// 教材附件 + /// + public string AttachUrl + { + get; + set; + } + /// + /// 开始时间 + /// + public DateTime? StartTime + { + get; + set; + } + /// + /// 学习时长(秒) + /// + public int? LearningTime + { + get; + set; + } + /// + /// 教材时长(秒) + /// + public int? AttachTime + { + get; + set; + } + public DateTime? EndTime + { + get; + set; + } + /// + /// 视频进度(秒) + /// + public int? VideoProgress + { + get; + set; + } + /// + /// 是否是重修任务 + /// + public int IsRetakeCourse + { + get; + set; + } + + } +} diff --git a/SGGL/Model/Model.csproj b/SGGL/Model/Model.csproj index 9399d61..2bde60c 100644 --- a/SGGL/Model/Model.csproj +++ b/SGGL/Model/Model.csproj @@ -133,6 +133,7 @@ + diff --git a/SGGL/WebAPI/Controllers/HSSE/TrainingRecordController.cs b/SGGL/WebAPI/Controllers/HSSE/TrainingRecordController.cs new file mode 100644 index 0000000..4cd6d7e --- /dev/null +++ b/SGGL/WebAPI/Controllers/HSSE/TrainingRecordController.cs @@ -0,0 +1,48 @@ +using System; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using BLL; + +namespace WebAPI.Controllers +{ + /// + /// 培训记录 + /// + public class TrainingRecordController : ApiController + { + #region 根据ProjectId、PersonId获取培训记录列表 + /// + /// 根据ProjectId、PersonId获取培训记录列表 + /// + /// + /// + /// 是否重修:1:重修任务 + /// 页码 + /// + public Model.ResponeData getTrainingRecordListByProjectIdPersonId(string projectId, string personId, string isRetakeCourse, int pageIndex) + { + var responeData = new Model.ResponeData(); + try + { + var getQualityLists = APITrainingTaskService.getTrainingRecordItemListByProjectIdPersonId(projectId, personId, isRetakeCourse); + int pageCount = getQualityLists.Count; + if (pageCount > 0 && pageIndex > 0) + { + var getdata = from x in getQualityLists.OrderBy(u => u.TrainingItemCode).Skip(BLL.Funs.PageSize * (pageIndex - 1)).Take(BLL.Funs.PageSize) + select x; + responeData.data = new { pageCount, getdata }; + } + } + catch (Exception ex) + { + responeData.code = 0; + responeData.message = ex.Message; + } + return responeData; + } + #endregion + + } +} diff --git a/SGGL/WebAPI/WebAPI.csproj b/SGGL/WebAPI/WebAPI.csproj index f0fd3ca..ae5a4a6 100644 --- a/SGGL/WebAPI/WebAPI.csproj +++ b/SGGL/WebAPI/WebAPI.csproj @@ -176,6 +176,7 @@ +