diff --git a/SGGL/BLL/API/HSSE/APITestRecordService.cs b/SGGL/BLL/API/HSSE/APITestRecordService.cs index 7ca05b2a..ae3ec864 100644 --- a/SGGL/BLL/API/HSSE/APITestRecordService.cs +++ b/SGGL/BLL/API/HSSE/APITestRecordService.cs @@ -266,19 +266,19 @@ namespace BLL public static string CreateTestRecordItem(Model.Training_CompanyTrainingItem getCompanyTraining, string testRecordId, Model.SitePerson_Person person, Model.Sys_User user) { - - + + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var trainingIds = getCompanyTraining.TestTrainingIds.Split(','); - var testTrainings= db.Training_TestTraining.Where(x => trainingIds.Contains(x.TrainingId)); + var testTrainings = db.Training_TestTraining.Where(x => trainingIds.Contains(x.TrainingId)); var getTestRecord = db.Training_TestRecord.FirstOrDefault(x => x.TestRecordId == testRecordId); if (getTestRecord != null && !getTestRecord.TestStartTime.HasValue) { ////考试时长 - getTestRecord.Duration =120; + getTestRecord.Duration = 120; getTestRecord.TestStartTime = DateTime.Now; db.SubmitChanges(); } @@ -293,16 +293,16 @@ namespace BLL // select x; //// 计划考试中单选、多选、判断题总数 var sysTestRule = Funs.DB.Sys_TestRule.FirstOrDefault(); - + int sumTestType1Count = 0;// testPlanTrainings.Sum(x => x.TestType1Count) ?? 0; int sumTestType2Count = 0;//testPlanTrainings.Sum(x => x.TestType2Count) ?? 0; int sumTestType3Count = 0;//testPlanTrainings.Sum(x => x.TestType3Count) ?? 0; if (sysTestRule != null) { - + sumTestType1Count = sysTestRule.SCount; sumTestType2Count = sysTestRule.MCount; - sumTestType3Count = sysTestRule.JCount; + sumTestType3Count = sysTestRule.JCount; } ////获取类型下适合岗位试题集合 List getTestTrainingItemALLs; @@ -318,7 +318,7 @@ namespace BLL } 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)) + 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 testTrainings) { @@ -347,9 +347,9 @@ namespace BLL } } //// 获取得到的单选题、多选题、判断题 数量 - 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(); + 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(); @@ -365,7 +365,7 @@ namespace BLL { getTestTrainingItemList.AddRange(getSItemD); } - } + } ///多选题 if (getDiffTestType2Count > 0) { diff --git a/SGGL/BLL/API/HSSE/APITrainingTaskService.cs b/SGGL/BLL/API/HSSE/APITrainingTaskService.cs index 096baf8c..fd88f7cb 100644 --- a/SGGL/BLL/API/HSSE/APITrainingTaskService.cs +++ b/SGGL/BLL/API/HSSE/APITrainingTaskService.cs @@ -85,6 +85,8 @@ namespace BLL GetDataService.CreateTrainingTaskItemByTaskId(taskId); var getDataLists = (from x in db.Training_TaskItem + join y in db.Training_CompanyTrainingItem on x.TrainingItemCode equals y.CompanyTrainingItemCode into temp + from y in temp.DefaultIfEmpty() where x.TaskId == taskId orderby x.TrainingItemCode select new Model.TrainingTaskItemItem @@ -94,7 +96,8 @@ namespace BLL PlanId = x.PlanId, StartTime = x.StartTime, EndTime =x.EndTime, - LearningTime=x.LearnTime, + LearningTime= x.LearnTime, + AttachTime= y.LearningTime, VideoProgress = x.VideoProgress, PersonId = x.PersonId, TrainingItemCode = x.TrainingItemCode, @@ -305,21 +308,23 @@ namespace BLL { item.LearnTime = 0; } - item.LearnTime = item.LearnTime.Value + (int)span.TotalMinutes; - + item.LearnTime = item.LearnTime.Value + (int)span.TotalSeconds; item.EndTime = endTime; db.SubmitChanges(); + var companyTrainingItem = db.Training_CompanyTrainingItem.FirstOrDefault(x => x.CompanyTrainingItemCode == item.TrainingItemCode); + int companyTrainingItemLearnTime = companyTrainingItem?.LearningTime ?? 0; //培训教材时长(秒) + + //如果学习时长大于培训教材时长,则关闭状态 - if (item.VideoProgress > item.LearnTime) + if (item.LearnTime > companyTrainingItemLearnTime) { var taskModel = db.Training_Task.FirstOrDefault(x => x.TaskId == item.TaskId); taskModel.States = "2"; db.SubmitChanges(); - } - - + } + return item; } } diff --git a/SGGL/BLL/OpenService/GetDataService.cs b/SGGL/BLL/OpenService/GetDataService.cs index 981e0671..6b4f8b31 100644 --- a/SGGL/BLL/OpenService/GetDataService.cs +++ b/SGGL/BLL/OpenService/GetDataService.cs @@ -39,7 +39,8 @@ namespace BLL PersonId = item.UserId, TrainingItemCode = dataItem.TrainingItemCode, TrainingItemName = dataItem.TrainingItemName, - LearnTime = dataItem.LearningTime, + // LearnTime = dataItem.LearningTime,//秒 注释原因(2024-5-24):存储过程LearningTime是教材时长培训任务教材明细表中的学习时间字段LearnTime,不能复用) + LearnTime =0, AttachUrl = dataItem.AttachUrl, }; diff --git a/SGGL/Model/APIItem/HSSE/TrainingTaskItemItem.cs b/SGGL/Model/APIItem/HSSE/TrainingTaskItemItem.cs index 1e290bfa..9f058f82 100644 --- a/SGGL/Model/APIItem/HSSE/TrainingTaskItemItem.cs +++ b/SGGL/Model/APIItem/HSSE/TrainingTaskItemItem.cs @@ -87,22 +87,38 @@ namespace Model get; set; } - + /// + /// 开始时间 + /// public DateTime? StartTime { get; set; } + /// + /// 学习时长(秒) + /// public int? LearningTime { get; set; } - public DateTime? EndTime + /// + /// 教材时长(秒) + /// + public int? AttachTime + { + get; + set; + } + public DateTime? EndTime { get; set; } + /// + /// 视频进度(秒) + /// public int? VideoProgress { get; diff --git a/SGGL/WebAPI/Controllers/HSSE/TrainingTaskController.cs b/SGGL/WebAPI/Controllers/HSSE/TrainingTaskController.cs index 0c10ebf7..babde184 100644 --- a/SGGL/WebAPI/Controllers/HSSE/TrainingTaskController.cs +++ b/SGGL/WebAPI/Controllers/HSSE/TrainingTaskController.cs @@ -128,7 +128,14 @@ namespace WebAPI.Controllers } #endregion - + /// + /// 修改培训任务教材明细学习时间 + /// + /// + /// + /// + /// + /// [HttpGet] public Model.ResponeData updateTaskItemLearnTime(string taskItemId, DateTime startTime, DateTime endTime,string VideoProgress) {