/// <summary> /// 根据类型获取图型数据 /// </summary> /// <param name="type"></param> /// <returns></returns> public static List <Model.ChartAnalysisItem> getChartAnalysisByType(string projectId, string type, string startDate, string endDate) { List <Model.ChartAnalysisItem> getDataLists = new List <Model.ChartAnalysisItem>(); var getHazardRegister = from x in Funs.DB.HSSE_Hazard_HazardRegister where x.ProjectId == projectId select x; if (!string.IsNullOrEmpty(startDate)) { var sDate = Funs.GetNewDateTime(startDate); getHazardRegister = getHazardRegister.Where(x => x.RegisterDate >= sDate); } if (!string.IsNullOrEmpty(endDate)) { var eDate = Funs.GetNewDateTime(endDate); getHazardRegister = getHazardRegister.Where(x => x.RegisterDate <= eDate); } if (type == "1") { var getUnitlistIds = getHazardRegister.Select(x => x.ResponsibleUnit).Distinct().ToList(); foreach (var unitItem in getUnitlistIds) { var getUnitRegister = getHazardRegister.Where(x => x.ResponsibleUnit == unitItem); Model.ChartAnalysisItem newItem = new Model.ChartAnalysisItem { DataId = unitItem, Type = type, DataName = UnitService.GetUnitCodeByUnitId(unitItem), DataSumCount = getUnitRegister.Count(), DataCount1 = getUnitRegister.Where(x => x.States == "2" || x.States == "3").Count(), }; getDataLists.Add(newItem); } } else if (type == "2") { var getRegisterTypesIds = getHazardRegister.Select(x => x.RegisterTypesId).Distinct().ToList(); foreach (var typeItem in getRegisterTypesIds) { var getUnitRegister = getHazardRegister.Where(x => x.RegisterTypesId == typeItem); Model.ChartAnalysisItem newItem = new Model.ChartAnalysisItem { DataId = typeItem, Type = type, DataName = Funs.DB.HSSE_Hazard_HazardRegisterTypes.First(y => y.RegisterTypesId == typeItem).RegisterTypesName, DataSumCount = getUnitRegister.Count(), DataCount1 = getUnitRegister.Where(x => x.States == "2" || x.States == "3").Count(), }; getDataLists.Add(newItem); } } return(getDataLists); }
/// <summary> /// 增加教育培训明细信息 /// </summary> /// <param name="trainDetail">教育培训明细信息实体</param> public static void AddTrainDetail(Model.EduTrain_TrainRecordDetail trainDetail) { Model.SUBHSSEDB db = Funs.DB; string newKeyID = SQLHelper.GetNewID(typeof(Model.EduTrain_TrainRecordDetail)); Model.EduTrain_TrainRecordDetail newTrainDetail = new Model.EduTrain_TrainRecordDetail { TrainDetailId = newKeyID, TrainingId = trainDetail.TrainingId, PersonId = trainDetail.PersonId, CheckScore = trainDetail.CheckScore, CheckResult = trainDetail.CheckResult }; db.EduTrain_TrainRecordDetail.InsertOnSubmit(newTrainDetail); db.SubmitChanges(); var rainRecord = EduTrain_TrainRecordService.GetTrainingByTrainingId(trainDetail.TrainingId); if (rainRecord != null) { rainRecord.TrainPersonNum += 1; EduTrain_TrainRecordService.UpdateTraining(rainRecord); } ///// 培训考试 通过 更新卡号 if (newTrainDetail.CheckResult) { var getPerson = PersonService.GetPersonById(trainDetail.PersonId); if (getPerson != null && string.IsNullOrEmpty(getPerson.CardNo)) { getPerson.CardNo = SQLHelper.RunProcNewId("SpGetNewNumber", "SitePerson_Person", "CardNo", rainRecord.ProjectId, UnitService.GetUnitCodeByUnitId(getPerson.UnitId)); } } }
/// <summary> /// 根据考生计划结束时 将相关培训考生内容 写培训记录归档 /// </summary> /// <param name="getTestPlan"></param> public static void InsertTrainRecord(Model.Training_TestPlan getTestPlan) { using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString)) { ////获取培训计划 var getTrainingPlan = db.Training_Plan.FirstOrDefault(e => e.PlanId == getTestPlan.PlanId); var getTrainRecord = db.EduTrain_TrainRecord.FirstOrDefault(x => x.PlanId == getTestPlan.PlanId); if (getTrainingPlan != null && getTrainRecord == null) { getTrainingPlan.States = "3"; db.SubmitChanges(); Model.EduTrain_TrainRecord newTrainRecord = new Model.EduTrain_TrainRecord { TrainingId = SQLHelper.GetNewID(), TrainingCode = getTrainingPlan.PlanCode, ProjectId = getTrainingPlan.ProjectId, TrainTitle = getTrainingPlan.PlanName, TrainContent = getTrainingPlan.TrainContent, TrainStartDate = getTrainingPlan.TrainStartDate, TeachHour = getTrainingPlan.TeachHour, TrainEndDate = getTrainingPlan.TrainEndDate, TeachMan = getTrainingPlan.TeachMan, TeachAddress = getTrainingPlan.TeachAddress, Remark = "来源:培训计划", TrainTypeId = getTrainingPlan.TrainTypeId, TrainLevelId = getTrainingPlan.TrainLevelId, UnitIds = getTrainingPlan.UnitIds, States = Const.State_2, WorkPostIds = getTrainingPlan.WorkPostId, PlanId = getTrainingPlan.PlanId, }; newTrainRecord.CompileMan = UserService.GetUserNameByUserId(getTrainingPlan.DesignerId); ///获取培训人员 var getTrainingTasks = from x in db.Training_Task where x.PlanId == getTrainingPlan.PlanId select x; newTrainRecord.TrainPersonNum = getTrainingTasks.Count(); ///新增培训记录 db.EduTrain_TrainRecord.InsertOnSubmit(newTrainRecord); db.SubmitChanges(); ////及格分数 int passScore = 80; var testRule = db.Sys_TestRule.FirstOrDefault(); if (testRule != null) { passScore = testRule.PassingScore; } foreach (var item in getTrainingTasks) { decimal gScores = 0; bool result = false; ////获取 考生试卷 var getTestRecord = db.Training_TestRecord.Where(x => x.TestPlanId == getTestPlan.TestPlanId && x.TestManId == item.UserId); foreach (var itemR in getTestRecord) { if (itemR.TestScores > gScores) { gScores = itemR.TestScores ?? 0; } } if (gScores >= passScore) { result = true; } Model.EduTrain_TrainRecordDetail newDetail = new Model.EduTrain_TrainRecordDetail { TrainDetailId = SQLHelper.GetNewID(), TrainingId = newTrainRecord.TrainingId, PersonId = item.UserId, CheckScore = gScores, CheckResult = result, }; db.EduTrain_TrainRecordDetail.InsertOnSubmit(newDetail); db.SubmitChanges(); ///// 培训考试 通过 更新卡号 if (result) { var getPerson = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == newDetail.PersonId); if (getPerson != null && string.IsNullOrEmpty(getPerson.CardNo)) { getPerson.CardNo = SQLHelper.RunProcNewId("SpGetNewNumber", "SitePerson_Person", "CardNo", getPerson.ProjectId, UnitService.GetUnitCodeByUnitId(getPerson.UnitId)); db.SubmitChanges(); } } } ////增加一条编码记录 CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectTrainRecordMenuId, newTrainRecord.ProjectId, null, newTrainRecord.TrainingId, newTrainRecord.TrainStartDate); CommonService.btnSaveData(newTrainRecord.ProjectId, Const.ProjectTrainRecordMenuId, newTrainRecord.TrainingId, getTrainingPlan.DesignerId, true, newTrainRecord.TrainTitle, "../EduTrain/TrainRecordView.aspx?TrainingId={0}"); } } }