/// <summary> /// 根据考试ID获取考试计划详细 /// </summary> /// <param name="testPlanId"></param> /// <returns></returns> public static Model.TestPlanItem getTestPlanByTestPlanId(string testPlanId) { var getDataLists = from x in Funs.DB.Training_TestPlan where x.TestPlanId == testPlanId select new Model.TestPlanItem { TestPlanId = x.TestPlanId, ProjectId = x.ProjectId, TestPlanCode = x.PlanCode, TestPlanName = x.PlanName, TestPlanManId = x.PlanManId, TestPlanManName = Funs.DB.Sys_User.First(y => y.UserId == x.TestPlanId).UserName, TestPlanDate = string.Format("{0:yyyy-MM-dd HH:mm}", x.PlanDate), TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime), TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestEndTime), Duration = x.Duration, SValue = x.SValue, MValue = x.MValue, JValue = x.JValue, TotalScore = x.TotalScore ?? 0, QuestionCount = x.QuestionCount ?? 0, TestPalce = x.TestPalce, UnitIds = x.UnitIds, UnitNames = UnitService.getUnitNamesUnitIds(x.UnitIds), WorkPostIds = x.WorkPostIds, WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIds(x.WorkPostIds), States = x.States, QRCodeUrl = x.QRCodeUrl.Replace('\\', '/'), TrainingPlanId = x.PlanId, }; return(getDataLists.FirstOrDefault()); }
/// <summary> /// 根据ReceiveFileManagerId获取来文详细信息 /// </summary> /// <param name="receiveFileManagerId">来文ID</param> /// <param name="fileType">来文类型(0-项目发文;1-公司来文)</param> /// <returns>来文详细</returns> public static Model.ReceiveFileManagerItem getReceiveFileManagerById(string receiveFileManagerId, string fileType) { var getReceiveFileManagerItem = (from x in Funs.DB.InformationProject_ReceiveFileManager where x.ReceiveFileManagerId == receiveFileManagerId && x.FileType == fileType select new Model.ReceiveFileManagerItem { ReceiveFileManagerId = x.ReceiveFileManagerId, ProjectId = x.ProjectId, ReceiveFileCode = x.ReceiveFileCode, ReceiveFileName = x.ReceiveFileName, Version = x.Version, FileUnitId = x.FileUnitId, FileUnitName = Funs.DB.Base_Unit.First(u => u.UnitId == x.FileUnitId).UnitName, FileCode = x.FileCode, FilePageNum = x.FilePageNum, GetFileDate = string.Format("{0:yyyy-MM-dd}", x.GetFileDate), SendPersonId = x.SendPersonId, SendPersonName = Funs.DB.Sys_User.First(u => u.UserId == x.SendPersonId).UserName, MainContent = x.MainContent, UnitIds = x.UnitIds, UnitNames = UnitService.getUnitNamesUnitIds(x.UnitIds), FileAttachUrl = APIUpLoadFileService.getFileUrl(x.ReceiveFileManagerId, null), ReplyFileAttachUrl = APIUpLoadFileService.getFileUrl(x.ReceiveFileManagerId + "#1", null), }).FirstOrDefault(); return(getReceiveFileManagerItem); }
/// <summary> /// 获取专项检查列表信息 /// </summary> /// <param name="projectId"></param> /// <param name="states"></param> /// <returns></returns> public static List <Model.CheckSpecialItem> getCheckSpecialList(string projectId, string states) { var getCheckSpecial = from x in Funs.DB.Check_CheckSpecial where x.ProjectId == projectId && (states == null || (states == "0" && (x.States == "0" || x.States == null)) || (states == "1" && (x.States == "1" || x.States == "2"))) orderby x.CheckSpecialCode descending select new Model.CheckSpecialItem { CheckSpecialId = x.CheckSpecialId, ProjectId = x.ProjectId, CheckSpecialCode = Funs.DB.Sys_CodeRecords.First(y => y.DataId == x.CheckSpecialId).Code ?? x.CheckSpecialCode, CheckType = x.CheckType == "0" ? "周检" : (x.CheckType == "1" ? "月检" : "其他"), CheckItemSetId = x.CheckItemSetId, CheckItemSetName = Funs.DB.Technique_CheckItemSet.First(y => y.CheckItemSetId == x.CheckItemSetId).CheckItemName, CheckPersonId = x.CheckPerson, CheckPersonName = Funs.DB.Sys_User.First(u => u.UserId == x.CheckPerson).UserName, CheckTime = string.Format("{0:yyyy-MM-dd}", x.CheckTime), DaySummary = x.DaySummary, PartInUnitIds = x.PartInUnits, PartInUnitNames = UnitService.getUnitNamesUnitIds(x.PartInUnits), PartInPersonIds = x.PartInPersonIds, PartInPersonNames = UserService.getUserNamesUserIds(x.PartInPersonIds), PartInPersonNames2 = x.PartInPersonNames, CompileManId = x.CompileMan, CompileManName = Funs.DB.Sys_User.First(u => u.UserId == x.CompileMan).UserName, States = x.States, AttachUrl1 = APIUpLoadFileService.getFileUrl(x.CheckSpecialId, null), }; return(getCheckSpecial.ToList()); }
/// <summary> /// 获取专项检查详细 /// </summary> /// <param name="CheckSpecialId"></param> /// <returns></returns> public static Model.CheckSpecialItem getCheckSpecialById(string CheckSpecialId) { var getInfo = from x in Funs.DB.Check_CheckSpecial where x.CheckSpecialId == CheckSpecialId select new Model.CheckSpecialItem { CheckSpecialId = x.CheckSpecialId, ProjectId = x.ProjectId, CheckSpecialCode = x.CheckSpecialCode, CheckType = x.CheckType == "0"? "周检":(x.CheckType == "1" ? "月检" :"其他"), CheckItemSetId = x.CheckItemSetId, CheckItemSetName = Funs.DB.Technique_CheckItemSet.First(y => y.CheckItemSetId == x.CheckItemSetId).CheckItemName, CheckPersonId = x.CheckPerson, CheckPersonName = Funs.DB.Sys_User.First(u => u.UserId == x.CheckPerson).UserName, CheckTime = string.Format("{0:yyyy-MM-dd}", x.CheckTime), DaySummary = x.DaySummary, PartInUnitIds = x.PartInUnits, PartInUnitNames = UnitService.getUnitNamesUnitIds(x.PartInUnits), PartInPersonIds = x.PartInPersonIds, PartInPersonNames = UserService.getUserNamesUserIds(x.PartInPersonIds), PartInPersonNames2 = x.PartInPersonNames, CompileManId = x.CompileMan, CompileManName = Funs.DB.Sys_User.First(u => u.UserId == x.CompileMan).UserName, States = x.States, AttachUrl1 = APIUpLoadFileService.getFileUrl(x.CheckSpecialId, null), CheckSpecialDetailItems = getCheckSpecialDetailList(x.CheckSpecialId), }; return(getInfo.FirstOrDefault()); }
/// <summary> /// 根据培训ID获取培训计划详细 /// </summary> /// <param name="planId"></param> /// <returns></returns> public static Model.TrainingPlanItem getTrainingPlanByTrainingId(string planId) { var getDataLists = from x in Funs.DB.Training_Plan where x.PlanId == planId select new Model.TrainingPlanItem { PlanId = x.PlanId, PlanCode = x.PlanCode, PlanName = x.PlanName, ProjectId = x.ProjectId, TrainTypeId = x.TrainTypeId, TrainTypeName = Funs.DB.Base_TrainType.First(y => y.TrainTypeId == x.TrainTypeId).TrainTypeName, TrainLevelId = x.TrainLevelId, TrainLevelName = Funs.DB.Base_TrainLevel.First(y => y.TrainLevelId == x.TrainLevelId).TrainLevelName, TeachHour = x.TeachHour ?? 0, TeachAddress = x.TeachAddress, TrainStartDate = string.Format("{0:yyyy-MM-dd HH:mm}", x.TrainStartDate), TeachMan = x.TeachMan, UnitIds = x.UnitIds, WorkPostId = x.WorkPostId, TrainContent = x.TrainContent, UnitNames = UnitService.getUnitNamesUnitIds(x.UnitIds), WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIds(x.WorkPostId), DesignerId = x.DesignerId, DesignerName = Funs.DB.Sys_User.First(y => y.UserId == x.DesignerId).UserName, DesignerDate = string.Format("{0:yyyy-MM-dd HH:mm}", x.TrainStartDate), States = x.States, QRCodeUrl = x.QRCodeUrl.Replace('\\', '/'), }; return(getDataLists.FirstOrDefault()); }
/// <summary> /// 根据培训ID获取培训记录详细 /// </summary> /// <param name="trainRecordId"></param> /// <returns></returns> public static Model.TrainRecordItem getTrainRecordByTrainingId(string trainRecordId) { var getDataLists = from x in Funs.DB.EduTrain_TrainRecord where x.TrainingId == trainRecordId select new Model.TrainRecordItem { TrainRecordId = x.TrainingId, TrainingCode = x.TrainingCode, TrainTitle = x.TrainTitle, ProjectId = x.ProjectId, TrainTypeId = x.TrainTypeId, TrainTypeName = Funs.DB.Base_TrainType.First(y => y.TrainTypeId == x.TrainTypeId).TrainTypeName, TrainLevelId = x.TrainLevelId, TrainLevelName = Funs.DB.Base_TrainLevel.First(y => y.TrainLevelId == x.TrainLevelId).TrainLevelName, TeachHour = x.TeachHour ?? 0, TeachAddress = x.TeachAddress, TrainStartDate = string.Format("{0:yyyy-MM-dd HH:mm}", x.TrainStartDate), UnitIds = x.UnitIds, WorkPostIds = x.WorkPostIds, TrainContent = x.TrainContent, AttachUrl = Funs.DB.AttachFile.First(y => y.ToKeyId == x.TrainingId).AttachUrl.Replace('\\', '/'), UnitNames = UnitService.getUnitNamesUnitIds(x.UnitIds), WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIds(x.WorkPostIds), }; return(getDataLists.FirstOrDefault()); }
/// <summary> /// 根据projectId、fileType获取来文列表 /// </summary> /// <param name="projectId"></param> /// <param name="fileType">来文类型(0-项目发文;1-公司来文)</param> /// <param name="unitId">单位ID</param> /// <param name="states">状态(0待提交;1-已提交;2:已回复)</param> /// <returns></returns> public static List <Model.ReceiveFileManagerItem> getReceiveFileManagerList(string projectId, string fileType, string unitId, string states) { var getReceiveFileManagerItem = (from x in Funs.DB.InformationProject_ReceiveFileManager where x.ProjectId == projectId && x.FileType == fileType select new Model.ReceiveFileManagerItem { ReceiveFileManagerId = x.ReceiveFileManagerId, ProjectId = x.ProjectId, FileType = x.FileType, ReceiveFileCode = x.ReceiveFileCode, ReceiveFileName = x.ReceiveFileName, Version = x.Version, FileUnitId = x.FileUnitId, FileUnitName = Funs.DB.Base_Unit.First(u => u.UnitId == x.FileUnitId).UnitName, FileCode = x.FileCode, FilePageNum = x.FilePageNum, GetFileDate = string.Format("{0:yyyy-MM-dd}", x.GetFileDate), SendPersonId = x.SendPersonId, SendPersonName = Funs.DB.Sys_User.First(u => u.UserId == x.SendPersonId).UserName, MainContent = x.MainContent, UnitIds = x.UnitIds, UnitNames = UnitService.getUnitNamesUnitIds(x.UnitIds), FileAttachUrl = APIUpLoadFileService.getFileUrl(x.ReceiveFileManagerId, null), ReplyFileAttachUrl = APIUpLoadFileService.getFileUrl(x.ReceiveFileManagerId + "#1", null), States = x.States, }).AsEnumerable(); if (getReceiveFileManagerItem.Count() > 0) { if (!string.IsNullOrEmpty(unitId) && !CommonService.GetIsThisUnit(unitId)) { getReceiveFileManagerItem = getReceiveFileManagerItem.Where(x => x.FileUnitId == unitId || (x.UnitIds != null && x.UnitIds.Contains(unitId))); } if (states == Const.State_0) { getReceiveFileManagerItem = getReceiveFileManagerItem.Where(x => x.States == Const.State_0 || x.States == null); } else if (states == Const.State_1) { getReceiveFileManagerItem = getReceiveFileManagerItem.Where(x => x.States == Const.State_2 && (x.ReplyFileAttachUrl == null || x.ReplyFileAttachUrl == "")); } else if (states == Const.State_2) { getReceiveFileManagerItem = getReceiveFileManagerItem.Where(x => x.States == Const.State_2 && x.ReplyFileAttachUrl != null && x.ReplyFileAttachUrl != ""); } } return(getReceiveFileManagerItem.OrderByDescending(x => x.ReceiveFileCode).ToList()); }
/// <summary> /// 根据培训计划ID生成 考试计划信息 /// </summary> /// <param name="getTestPlan"></param> public static string SaveTestPlanByTrainingPlanId(string trainingPlanId, string userId) { string testPlanId = string.Empty; using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString)) { ////培训计划 var getTrainingPlan = db.Training_Plan.FirstOrDefault(x => x.PlanId == trainingPlanId);; if (getTrainingPlan != null && getTrainingPlan.States == "1") { testPlanId = SQLHelper.GetNewID(); Model.Training_TestPlan newTestPlan = new Model.Training_TestPlan { TestPlanId = testPlanId, ProjectId = getTrainingPlan.ProjectId, //PlanCode = getTrainingPlan.PlanCode, PlanName = getTrainingPlan.PlanName, PlanManId = userId, PlanDate = DateTime.Now, TestStartTime = DateTime.Now, TestPalce = getTrainingPlan.TeachAddress, UnitIds = getTrainingPlan.UnitIds, UnitNames = UnitService.getUnitNamesUnitIds(getTrainingPlan.UnitIds), WorkPostIds = getTrainingPlan.WorkPostId, WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIds(getTrainingPlan.WorkPostId), PlanId = getTrainingPlan.PlanId, States = "0", }; string unitId = string.Empty; var user = db.Sys_User.FirstOrDefault(e => e.UserId == userId); if (user != null) { unitId = user.UnitId; } newTestPlan.PlanCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectTestPlanMenuId, newTestPlan.ProjectId, unitId); int Duration = 90; int SValue = 1; int MValue = 2; int JValue = 1; int testType1Count = 40; int testType2Count = 10; int testType3Count = 40; ////获取考试规则设置数据 var getTestRule = db.Sys_TestRule.FirstOrDefault(); ////考试数据设置 if (getTestRule != null) { Duration = getTestRule.Duration; SValue = getTestRule.SValue; MValue = getTestRule.MValue; JValue = getTestRule.JValue; testType1Count = getTestRule.SCount; testType2Count = getTestRule.MCount; testType3Count = getTestRule.JCount; } ////按照培训类型获取试题类型及题型数量 var getTrainTypeItems = from x in db.Base_TrainTypeItem where x.TrainTypeId == getTrainingPlan.TrainTypeId select x; if (getTrainTypeItems.Count() > 0) { testType1Count = getTrainTypeItems.Sum(x => x.SCount); testType2Count = getTrainTypeItems.Sum(x => x.MCount); testType3Count = getTrainTypeItems.Sum(x => x.JCount); } newTestPlan.Duration = getTestRule.Duration; newTestPlan.SValue = getTestRule.SValue; newTestPlan.MValue = getTestRule.MValue; newTestPlan.JValue = getTestRule.JValue; newTestPlan.TotalScore = testType1Count * SValue + testType2Count * MValue + testType3Count * JValue; newTestPlan.QuestionCount = testType1Count + testType2Count + testType3Count; newTestPlan.TestEndTime = newTestPlan.TestStartTime.AddMinutes(newTestPlan.Duration); ////新增考试计划记录 var getIsTestPlan = db.Training_TestPlan.FirstOrDefault(x => x.PlanId == newTestPlan.PlanId); if (getIsTestPlan == null) { db.Training_TestPlan.InsertOnSubmit(newTestPlan); db.SubmitChanges(); CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectTestPlanMenuId, newTestPlan.ProjectId, null, testPlanId, newTestPlan.PlanDate); ///培训人员 var getTrainingTask = (from x in db.Training_Task where x.PlanId == trainingPlanId select x).ToList(); foreach (var itemTask in getTrainingTask) { Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord { TestRecordId = SQLHelper.GetNewID(), ProjectId = getTrainingPlan.ProjectId, TestPlanId = testPlanId, TestManId = itemTask.UserId, TestType = db.Base_TrainType.First(z => z.TrainTypeId == getTrainingPlan.TrainTypeId).TrainTypeName, }; db.Training_TestRecord.InsertOnSubmit(newTestRecord); db.SubmitChanges(); } if (getTrainTypeItems.Count() == 0) { /////考试题型类别及数量 Model.Training_TestPlanTraining newTestPlanTraining = new Model.Training_TestPlanTraining { TestPlanTrainingId = SQLHelper.GetNewID(), TestPlanId = testPlanId, TestType1Count = testType1Count, TestType2Count = testType2Count, TestType3Count = testType3Count, }; db.Training_TestPlanTraining.InsertOnSubmit(newTestPlanTraining); db.SubmitChanges(); } else { foreach (var item in getTrainTypeItems) { /////考试题型类别及数量 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(); } } } ////回写培训计划状态 getTrainingPlan.States = "2"; db.SubmitChanges(); } } return(testPlanId); }