From 3a62ed22198beaac424c918d3b530d7609df5fae Mon Sep 17 00:00:00 2001 From: yhw0507 Date: Wed, 28 Sep 2022 17:30:05 +0800 Subject: [PATCH] =?UTF-8?q?20220928=E8=80=83=E8=AF=95=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E8=AF=95=E9=A2=98=E7=B1=BB=E5=9E=8B=E5=8A=A0=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SGGL/BLL/API/HSSE/APITestPlanService.cs | 74 +++++++++++++---------- SGGL/BLL/API/HSSE/APITestRecordService.cs | 4 +- 2 files changed, 45 insertions(+), 33 deletions(-) diff --git a/SGGL/BLL/API/HSSE/APITestPlanService.cs b/SGGL/BLL/API/HSSE/APITestPlanService.cs index 18b0cf3f..328c1e5e 100644 --- a/SGGL/BLL/API/HSSE/APITestPlanService.cs +++ b/SGGL/BLL/API/HSSE/APITestPlanService.cs @@ -265,18 +265,22 @@ namespace BLL var trainingType = TestTrainingService.GetTestTrainingById(item.TrainingTypeId); if (trainingType != null) { - Model.Training_TestPlanTraining newPlanItem = new Model.Training_TestPlanTraining + var getT = db.Training_TestPlanTraining.FirstOrDefault(x => x.TestPlanId == newTestPlan.TestPlanId && x.TrainingId == item.TrainingTypeId); + if (getT == null) { - TestPlanTrainingId = SQLHelper.GetNewID(), - TestPlanId = newTestPlan.TestPlanId, - TrainingId = item.TrainingTypeId, - TestType1Count = item.TestType1Count, - TestType2Count = item.TestType2Count, - TestType3Count = item.TestType3Count, - }; + Model.Training_TestPlanTraining newPlanItem = new Model.Training_TestPlanTraining + { + TestPlanTrainingId = SQLHelper.GetNewID(), + TestPlanId = newTestPlan.TestPlanId, + TrainingId = item.TrainingTypeId, + TestType1Count = item.TestType1Count, + TestType2Count = item.TestType2Count, + TestType3Count = item.TestType3Count, + }; - db.Training_TestPlanTraining.InsertOnSubmit(newPlanItem); - db.SubmitChanges(); + db.Training_TestPlanTraining.InsertOnSubmit(newPlanItem); + db.SubmitChanges(); + } } } } @@ -321,18 +325,22 @@ namespace BLL var trainingType = db.Training_TestTraining.FirstOrDefault(e => e.TrainingId == item.TrainingTypeId); if (trainingType != null) { - Model.Training_TestPlanTraining newPlanItem = new Model.Training_TestPlanTraining + var getT = db.Training_TestPlanTraining.FirstOrDefault(x => x.TestPlanId == testPlanId && x.TrainingId == item.TrainingTypeId); + if (getT == null) { - TestPlanTrainingId = SQLHelper.GetNewID(), - TestPlanId = testPlanId, - TrainingId = item.TrainingTypeId, - TestType1Count = item.TestType1Count, - TestType2Count = item.TestType2Count, - TestType3Count = item.TestType3Count, - }; + Model.Training_TestPlanTraining newPlanItem = new Model.Training_TestPlanTraining + { + TestPlanTrainingId = SQLHelper.GetNewID(), + TestPlanId = testPlanId, + TrainingId = item.TrainingTypeId, + TestType1Count = item.TestType1Count, + TestType2Count = item.TestType2Count, + TestType3Count = item.TestType3Count, + }; - db.Training_TestPlanTraining.InsertOnSubmit(newPlanItem); - db.SubmitChanges(); + db.Training_TestPlanTraining.InsertOnSubmit(newPlanItem); + db.SubmitChanges(); + } } } } @@ -459,18 +467,22 @@ namespace BLL { foreach (var item in getTrainTypeItems) { - /////考试题型类别及数量 - Model.Training_TestPlanTraining newTestPlanTraining = new Model.Training_TestPlanTraining + var getT = db.Training_TestPlanTraining.FirstOrDefault(x => x.TestPlanId == testPlanId && x.TrainingId == item.TrainingId); + if (getT == null) { - TestPlanTrainingId = SQLHelper.GetNewID(), - TestPlanId = testPlanId, - TrainingId = item.TrainingId, - TestType1Count = item.SCount, - TestType2Count = item.MCount, - TestType3Count = item.JCount, - }; - db.Training_TestPlanTraining.InsertOnSubmit(newTestPlanTraining); - db.SubmitChanges(); + /////考试题型类别及数量 + Model.Training_TestPlanTraining newTestPlanTraining = new Model.Training_TestPlanTraining + { + TestPlanTrainingId = SQLHelper.GetNewID(), + TestPlanId = testPlanId, + TrainingId = item.TrainingId, + TestType1Count = item.SCount, + TestType2Count = item.MCount, + TestType3Count = item.JCount, + }; + db.Training_TestPlanTraining.InsertOnSubmit(newTestPlanTraining); + db.SubmitChanges(); + } } } } diff --git a/SGGL/BLL/API/HSSE/APITestRecordService.cs b/SGGL/BLL/API/HSSE/APITestRecordService.cs index 499d40eb..2eaa488a 100644 --- a/SGGL/BLL/API/HSSE/APITestRecordService.cs +++ b/SGGL/BLL/API/HSSE/APITestRecordService.cs @@ -151,9 +151,9 @@ namespace BLL int sumTestType2Count = 0; int sumTestType3Count = 0; - var testPlanTrainings = from x in db.Training_TestPlanTraining + var testPlanTrainings =( from x in db.Training_TestPlanTraining where x.TestPlanId == getTestPlan.TestPlanId - select x; + select new { x.TestPlanId,x.TrainingId,x.TestType1Count,x.TestType2Count,x.TestType3Count}).Distinct(); if (testPlanTrainings.Count() > 0) { //// 计划考试中单选、多选、判断题总数