From 5e48a4ad9159b650eb92cb71b3da031007cbf11c Mon Sep 17 00:00:00 2001 From: 10191 <506754232@qq.com> Date: Mon, 5 Jun 2023 16:26:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=B9=E8=AE=AD=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SGGL/BLL/API/APIPersonService.cs | 71 +++++++++++-------- SGGL/BLL/API/HSSE/APITestPlanService.cs | 7 +- SGGL/BLL/Common/Const.cs | 4 ++ SGGL/FineUIPro.Web/ErrLog.txt | 18 +++++ .../HSSE/EduTrain/TestTrainingItemIn.aspx.cs | 56 ++++----------- SGGL/Model/APIItem/HSSE/TestPlanItem.cs | 14 ++++ SGGL/Model/Model.cs | 24 +++++++ 7 files changed, 121 insertions(+), 73 deletions(-) diff --git a/SGGL/BLL/API/APIPersonService.cs b/SGGL/BLL/API/APIPersonService.cs index 29138bf6..7271a710 100644 --- a/SGGL/BLL/API/APIPersonService.cs +++ b/SGGL/BLL/API/APIPersonService.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using Model; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SgManager.AI; using System; @@ -518,33 +519,43 @@ namespace BLL item.DepartName = depart.DepartName; } } - + } - //List getTrainPersonList = new List(); - //var getTrainType = db.Base_TrainType.FirstOrDefault(e => e.TrainTypeId == trainTypeId); - //if (getTrainType != null && (!getTrainType.IsRepeat.HasValue || getTrainType.IsRepeat == false)) - //{ - // foreach (var item in getPersons) - // { - // var getTrainPersonIdList1 = (from x in db.EduTrain_TrainRecordDetail - // join y in db.EduTrain_TrainRecord on x.TrainingId equals y.TrainingId - // where y.ProjectId ==null && y.TrainTypeId == trainTypeId && x.CheckResult == true && x.PersonId == item.PersonId - // select x).FirstOrDefault(); - // if (getTrainPersonIdList1 == null) - // { - // var getTrainPersonIdList2 = (from x in db.Training_Task - // join y in db.Training_Plan on x.PlanId equals y.PlanId - // where y.ProjectId == null && y.TrainTypeId == trainTypeId && y.States != "3" && x.UserId == item.PersonId - // select x).FirstOrDefault(); - // if (getTrainPersonIdList2 == null) - // { - // getTrainPersonList.Add(item); - // } - // } - // } - // return getTrainPersonList; - //} - //else + if (!string.IsNullOrEmpty(trainTypeId) && trainTypeId == Const.SpecialSafeTrainId)//专项安全培训 + { + var ids = db.Base_WorkPost.Where(x => x.PostType == "2").Select(x => x.WorkPostId).ToList(); + getPersons = getPersons.Where(x => ids.Contains(x.DepartId)); + } + + List getTrainPersonList = new List(); + var getTrainType = db.Base_TrainType.FirstOrDefault(e => e.TrainTypeId == trainTypeId); + + + + + if (getTrainType != null && (!getTrainType.IsRepeat.HasValue || getTrainType.IsRepeat == false)) + { + foreach (var item in getPersons) + { + var getTrainPersonIdList1 = (from x in db.EduTrain_TrainRecordDetail + join y in db.EduTrain_TrainRecord on x.TrainingId equals y.TrainingId + where y.ProjectId == null && y.TrainTypeId == trainTypeId && x.CheckResult == true && x.PersonId == item.PersonId + select x).FirstOrDefault(); + if (getTrainPersonIdList1 == null) + { + var getTrainPersonIdList2 = (from x in db.Training_Task + join y in db.Training_Plan on x.PlanId equals y.PlanId + where y.ProjectId == null && y.TrainTypeId == trainTypeId && y.States != "3" && x.UserId == item.PersonId + select x).FirstOrDefault(); + if (getTrainPersonIdList2 == null) + { + getTrainPersonList.Add(item); + } + } + } + return getTrainPersonList; + } + else { return getPersons.ToList(); } @@ -611,7 +622,11 @@ namespace BLL List workPostIdList = Funs.GetStrListByStr(workPostIds, ','); getPersons = getPersons.Where(x => workPostIdList.Contains(x.WorkPostId)); } - + if (!string.IsNullOrEmpty(trainTypeId) &&trainTypeId == Const.SpecialSafeTrainId)//专项安全培训 + { + var ids = db.Base_WorkPost.Where(x => x.PostType == "2").Select(x => x.WorkPostId).ToList(); + getPersons = getPersons.Where(x => ids.Contains(x.DepartId)); + } List getTrainPersonList = new List(); var getTrainType = TrainTypeService.GetTrainTypeById(trainTypeId); if (getTrainType != null && (!getTrainType.IsRepeat.HasValue || getTrainType.IsRepeat == false)) diff --git a/SGGL/BLL/API/HSSE/APITestPlanService.cs b/SGGL/BLL/API/HSSE/APITestPlanService.cs index 06dc746d..928eabf8 100644 --- a/SGGL/BLL/API/HSSE/APITestPlanService.cs +++ b/SGGL/BLL/API/HSSE/APITestPlanService.cs @@ -113,6 +113,8 @@ namespace BLL States = x.States, QRCodeUrl = x.QRCodeUrl.Replace('\\', '/'), TrainingPlanId = x.PlanId, + TrainTypeId= x.TrainTypeId, + TrainTypeName = db.Base_TrainType.Where(xx=>xx.TrainTypeId==x.TrainTypeId).Select(xx=>xx.TrainTypeName).FirstOrDefault() }).FirstOrDefault(); if (getDataLists != null) @@ -174,6 +176,7 @@ namespace BLL DepartIds = getTestPlan.DepartIds, States = getTestPlan.States, PlanDate = DateTime.Now, + TrainTypeId=getTestPlan.TrainTypeId }; if (!string.IsNullOrEmpty(getTestPlan.ProjectId)) { @@ -200,7 +203,6 @@ namespace BLL db.Training_TestPlan.InsertOnSubmit(newTestPlan); db.SubmitChanges(); - CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectTestPlanMenuId, newTestPlan.ProjectId, null, newTestPlan.TestPlanId, newTestPlan.PlanDate); } else @@ -220,6 +222,7 @@ namespace BLL isUpdate.UnitIds = newTestPlan.UnitIds; isUpdate.WorkPostIds = newTestPlan.WorkPostIds; isUpdate.DepartIds = newTestPlan.DepartIds; + isUpdate.TrainTypeId = newTestPlan.TrainTypeId; ////删除 考生记录 var deleteRecords = from x in db.Training_TestRecord where x.TestPlanId == isUpdate.TestPlanId @@ -239,7 +242,7 @@ namespace BLL } db.Training_TestRecord.DeleteAllOnSubmit(deleteRecords); - db.SubmitChanges(); + db.SubmitChanges(); } ////删除 考试题目类型 diff --git a/SGGL/BLL/Common/Const.cs b/SGGL/BLL/Common/Const.cs index c0847a3d..cf09f359 100644 --- a/SGGL/BLL/Common/Const.cs +++ b/SGGL/BLL/Common/Const.cs @@ -5954,6 +5954,10 @@ namespace BLL /// 实业数据 /// public const string Project_SYHSEData_SYHSEMenuId = ""; + /// + /// 专项安全培训 id + /// + public static string SpecialSafeTrainId = "0e7fdf78-eaa0-4d00-a60b-490040bbea18"; #endregion } } \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/ErrLog.txt b/SGGL/FineUIPro.Web/ErrLog.txt index 522266e0..affdef98 100644 --- a/SGGL/FineUIPro.Web/ErrLog.txt +++ b/SGGL/FineUIPro.Web/ErrLog.txt @@ -1511,3 +1511,21 @@ IP地址:::1 出错时间:05/25/2023 07:44:21 + +错误信息开始=====> +错误类型:NullReferenceException +错误信息:未将对象引用设置到对象的实例。 +错误堆栈: + 在 FineUIPro.Web.HSSE.EduTrain.TestTraining.GetButtonPower() 位置 D:\project\vs\sggl_cd\SGGL\FineUIPro.Web\HSSE\EduTrain\TestTraining.aspx.cs:行号 345 + 在 FineUIPro.Web.HSSE.EduTrain.TestTraining.Page_Load(Object sender, EventArgs e) 位置 D:\project\vs\sggl_cd\SGGL\FineUIPro.Web\HSSE\EduTrain\TestTraining.aspx.cs:行号 22 + 在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) + 在 System.EventHandler.Invoke(Object sender, EventArgs e) + 在 System.Web.UI.Control.OnLoad(EventArgs e) + 在 System.Web.UI.Control.LoadRecursive() + 在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +出错时间:05/25/2023 16:49:49 +出错文件:http://localhost:1295/HSSE/EduTrain/TestTraining.aspx +IP地址:::1 + +出错时间:05/25/2023 16:49:49 + diff --git a/SGGL/FineUIPro.Web/HSSE/EduTrain/TestTrainingItemIn.aspx.cs b/SGGL/FineUIPro.Web/HSSE/EduTrain/TestTrainingItemIn.aspx.cs index 2d6f5092..2bfd4830 100644 --- a/SGGL/FineUIPro.Web/HSSE/EduTrain/TestTrainingItemIn.aspx.cs +++ b/SGGL/FineUIPro.Web/HSSE/EduTrain/TestTrainingItemIn.aspx.cs @@ -10,7 +10,6 @@ namespace FineUIPro.Web.HSSE.EduTrain { public partial class TestTrainingItemIn : PageBase { - #region 定义变量 /// /// 上传预设的虚拟路径 @@ -162,16 +161,15 @@ namespace FineUIPro.Web.HSSE.EduTrain var trainings = from x in Funs.DB.Training_TestTraining select x; ///岗位 var workPosts = from x in Funs.DB.Base_WorkPost select x; - var departs = from x in Funs.DB.Base_Depart select x; for (int i = 0; i < ir; i++) { Model.View_Training_TestTrainingItem newViewTrainingItem = new Model.View_Training_TestTrainingItem { TrainingCode = pds.Rows[i][0].ToString().Trim(), TrainingItemCode = pds.Rows[i][2].ToString().Trim(), - Abstracts = pds.Rows[i][6].ToString().Trim(), - AItem = pds.Rows[i][7].ToString().Trim(), - BItem = pds.Rows[i][8].ToString().Trim(), + Abstracts = pds.Rows[i][5].ToString().Trim(), + AItem = pds.Rows[i][6].ToString().Trim(), + BItem = pds.Rows[i][7].ToString().Trim(), }; ////试题类型 @@ -211,8 +209,8 @@ namespace FineUIPro.Web.HSSE.EduTrain { newViewTrainingItem.TestType = "1"; //newViewTrainingItem.Score = SValue; - newViewTrainingItem.CItem = pds.Rows[i][9].ToString().Trim(); - newViewTrainingItem.DItem = pds.Rows[i][10].ToString().Trim(); + newViewTrainingItem.CItem = pds.Rows[i][8].ToString().Trim(); + newViewTrainingItem.DItem = pds.Rows[i][9].ToString().Trim(); //if (string.IsNullOrEmpty(newViewTrainingItem.AItem) || string.IsNullOrEmpty(newViewTrainingItem.BItem) || string.IsNullOrEmpty(newViewTrainingItem.CItem) || string.IsNullOrEmpty(newViewTrainingItem.DItem)) //{ // result += "第" + (i + 2).ToString() + "行," + "单选题ABCD都不能为空!" + "|"; @@ -223,9 +221,9 @@ namespace FineUIPro.Web.HSSE.EduTrain { newViewTrainingItem.TestType = "2"; //newViewTrainingItem.Score = MValue; - newViewTrainingItem.CItem = pds.Rows[i][9].ToString().Trim(); - newViewTrainingItem.DItem = pds.Rows[i][10].ToString().Trim(); - newViewTrainingItem.EItem = pds.Rows[i][11].ToString().Trim(); + newViewTrainingItem.CItem = pds.Rows[i][8].ToString().Trim(); + newViewTrainingItem.DItem = pds.Rows[i][9].ToString().Trim(); + newViewTrainingItem.EItem = pds.Rows[i][10].ToString().Trim(); //if (string.IsNullOrEmpty(newViewTrainingItem.AItem) || string.IsNullOrEmpty(newViewTrainingItem.BItem) || string.IsNullOrEmpty(newViewTrainingItem.CItem) || string.IsNullOrEmpty(newViewTrainingItem.DItem)) //{ // result += "第" + (i + 2).ToString() + "行," + "多选题ABCD都不能为空!" + "|"; @@ -268,46 +266,18 @@ namespace FineUIPro.Web.HSSE.EduTrain newViewTrainingItem.WorkPostIds = ids.Substring(0, ids.LastIndexOf(",")); } } - } ////适合部门 - string col5 = pds.Rows[i][5].ToString().Trim(); - if (!string.IsNullOrEmpty(col5)) - { - - List DepartSels = Funs.GetStrListByStr(col5, ','); - if (DepartSels.Count() > 0) - { - string ids = string.Empty; - foreach (var item in DepartSels) - { - var wp = departs.FirstOrDefault(x => x.DepartName == item); - if (wp != null) - { - ids += wp.DepartId + ","; - } - else - { - result += "第" + (i + 2).ToString() + "行," + "导入适合部门" + item + "," + "此项基础表不存在!" + "|"; - } - } - if (!string.IsNullOrEmpty(ids)) - { - newViewTrainingItem.DepartNames = col5; - newViewTrainingItem.DepartIds = ids.Substring(0, ids.LastIndexOf(",")); - } - } } - ////正确答案 - string col12 = pds.Rows[i][12].ToString().Trim(); - if (string.IsNullOrEmpty(col12)) + string col11 = pds.Rows[i][11].ToString().Trim(); + if (string.IsNullOrEmpty(col11)) { result += "第" + (i + 2).ToString() + "行," + "导入正确答案项" + "," + "为必填项!" + "|"; } else { int icount = 0; - List selecItem = Funs.GetStrListByStr(col12, ','); + List selecItem = Funs.GetStrListByStr(col11, ','); foreach (var item in selecItem) { if (item != "A" && item != "a" && item != "B" && item != "b" && item != "C" && item != "c" && item != "D" && item != "d" && item != "E" && item != "e") @@ -317,7 +287,7 @@ namespace FineUIPro.Web.HSSE.EduTrain } if (icount == 0) { - newViewTrainingItem.AnswerItems = col12.Replace("a", "A").Replace("b", "B").Replace("c", "C").Replace("d", "D").Replace("e", "E"); + newViewTrainingItem.AnswerItems = col11.Replace("a", "A").Replace("b", "B").Replace("c", "C").Replace("d", "D").Replace("e", "E"); } else { @@ -471,4 +441,4 @@ namespace FineUIPro.Web.HSSE.EduTrain } #endregion } -} +} \ No newline at end of file diff --git a/SGGL/Model/APIItem/HSSE/TestPlanItem.cs b/SGGL/Model/APIItem/HSSE/TestPlanItem.cs index 5427c84c..91fb91b4 100644 --- a/SGGL/Model/APIItem/HSSE/TestPlanItem.cs +++ b/SGGL/Model/APIItem/HSSE/TestPlanItem.cs @@ -245,5 +245,19 @@ namespace Model get; set; } + + /// + /// 培训类型ID + /// + public string TrainTypeId + { + get; + set; + } + public string TrainTypeName + { + get; + set; + } } } diff --git a/SGGL/Model/Model.cs b/SGGL/Model/Model.cs index 12faa65c..d7fcca7e 100644 --- a/SGGL/Model/Model.cs +++ b/SGGL/Model/Model.cs @@ -360387,6 +360387,8 @@ namespace Model private int _JValue; + private string _TrainTypeId; + private EntityRef _Sys_User; private EntityRef _Training_Plan; @@ -360447,6 +360449,8 @@ namespace Model partial void OnMValueChanged(); partial void OnJValueChanging(int value); partial void OnJValueChanged(); + partial void OnTrainTypeIdChanging(string value); + partial void OnTrainTypeIdChanged(); #endregion public Training_TestPlan() @@ -360946,6 +360950,26 @@ namespace Model } } + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_TrainTypeId", DbType="NVarChar(50)")] + public string TrainTypeId + { + get + { + return this._TrainTypeId; + } + set + { + if ((this._TrainTypeId != value)) + { + this.OnTrainTypeIdChanging(value); + this.SendPropertyChanging(); + this._TrainTypeId = value; + this.SendPropertyChanged("TrainTypeId"); + this.OnTrainTypeIdChanged(); + } + } + } + [global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_Training_TestPlan_Sys_User", Storage="_Sys_User", ThisKey="PlanManId", OtherKey="UserId", IsForeignKey=true)] public Sys_User Sys_User {