public ActionResult LaunchBranchAssessment(string assessment_name, string start_time, string end_time, string templete_id, string checker_list, string filling_people, string file_name) { if (assessmentApp.IsExists(assessment_name)) { return(Error("考核名称已存在。")); } using (var db = new RepositoryBase().BeginTrans()) { //获取“中安金控集团id” OrganizeEntity org = organizeApp.GetForm(BlocId); //获取所有子公司 List <OrganizeEntity> branchList = organizeApp.GetListByParentIdOrderById(org.F_Id, CompanyId); List <BranchAssessmentCheckerModel> checkerList = KPI.Code.Json.ToObject <List <BranchAssessmentCheckerModel> >(checker_list); #region 插入考核发起表 AssessmentEntity assessmentEntity = new AssessmentEntity(); string assessmentId = Common.GuId(); assessmentEntity.id = assessmentId; assessmentEntity.assessment_name = assessment_name; assessmentEntity.templete_id = templete_id; assessmentEntity.start_time = DateTime.Parse(start_time); assessmentEntity.end_time = DateTime.Parse(end_time); assessmentEntity.assessment_sponsor = OperatorProvider.Provider.GetCurrent().UserId; assessmentEntity.assessment_count = branchList.Count; assessmentEntity.assessment_statue = 0; assessmentEntity.assessment_type = 1; assessmentEntity.filing_people = filling_people; assessmentEntity.creator_user_id = OperatorProvider.Provider.GetCurrent().UserId; assessmentEntity.create_time = DateTime.Now; db.Insert <AssessmentEntity>(assessmentEntity); #endregion #region 插入考核发起详细表 AssessmentDetailEntity assessmentDetailEntity = new AssessmentDetailEntity(); for (int i = 0; i < checkerList.Count; i++) { for (int j = 0; j < branchList.Count; j++) { BranchAssessmentCheckerModel checker = checkerList[i]; OrganizeEntity check_object = branchList[j]; assessmentDetailEntity = new AssessmentDetailEntity(); assessmentDetailEntity.id = Common.GuId(); assessmentDetailEntity.assessment_id = assessmentId; assessmentDetailEntity.check_object = check_object.F_Id; assessmentDetailEntity.checker = checker.checker_id; assessmentDetailEntity.check_order = checker.checker_order; assessmentDetailEntity.finished = 0; assessmentDetailEntity.checker_weight = 0; assessmentDetailEntity.check_total_count = checkerList.Count; assessmentDetailEntity.creator_user_id = OperatorProvider.Provider.GetCurrent().UserId; assessmentDetailEntity.create_time = DateTime.Now; db.Insert <AssessmentDetailEntity>(assessmentDetailEntity); //给所有“考评人”插入考评任务并且激活第一个考评人的任务 SelfTaskDetailEntity selfTaskDetailEntity = new SelfTaskDetailEntity(); selfTaskDetailEntity.id = Common.GuId(); if (checker.checker_order == 1)//第一个人直接激活任务 { selfTaskDetailEntity.task_statue = 1; } else //剩下的人暂时先不激活任务,等待上一个人完成任务后激活下一个人的任务 { selfTaskDetailEntity.task_statue = 0; } selfTaskDetailEntity.task_type = 1; selfTaskDetailEntity.person = checker.checker_id; selfTaskDetailEntity.task_object = check_object.F_Id; selfTaskDetailEntity.attach = assessmentId; selfTaskDetailEntity.creator_user_id = OperatorProvider.Provider.GetCurrent().UserId; selfTaskDetailEntity.create_time = DateTime.Now; db.Insert <SelfTaskDetailEntity>(selfTaskDetailEntity); } } //给“考核结果审核人插入归档任务” SelfTaskDetailEntity fillingSelfTaskDetailEntity = new SelfTaskDetailEntity(); fillingSelfTaskDetailEntity.id = Common.GuId(); fillingSelfTaskDetailEntity.task_statue = 0; fillingSelfTaskDetailEntity.task_type = 4; fillingSelfTaskDetailEntity.person = filling_people; fillingSelfTaskDetailEntity.task_object = assessmentId; fillingSelfTaskDetailEntity.attach = assessmentId; fillingSelfTaskDetailEntity.creator_user_id = OperatorProvider.Provider.GetCurrent().UserId; fillingSelfTaskDetailEntity.create_time = DateTime.Now; db.Insert <SelfTaskDetailEntity>(fillingSelfTaskDetailEntity); //导入考核数据 BranchAssessmentImportApp branchAssessmentImportApp = new BranchAssessmentImportApp(db); var data = branchAssessmentImportApp.Scan(file_name, new string[] { assessmentId }); if (data.Count > 0) { return(Error("导入数据存在未处理的错误!")); } else { branchAssessmentImportApp.Import(file_name, assessmentId); } db.Commit(); } #endregion return(Success("操作成功。", null)); }
public ActionResult ReLaunchBranchAssessment(string assessment_id, string file_name) { AssessmentEntity assessmentEntity = assessmentApp.GetForm(assessment_id); if (assessmentEntity == null) { return(Error("系统未知错误。")); } //if (assessmentEntity.assessment_statue != 1) return Error("只有处于待归档的考核才能重新发起。"); List <AssessmentDetailEntity> assessmentDetailList = assessmentDetailApp.GetListByAssessmentId(assessment_id); if (assessmentDetailList == null || assessmentDetailList.Count <= 0) { return(Error("系统未知错误。")); } List <SelfTaskDetailEntity> selfTaskDetailList = selfTaskDetailApp.GetListByAttach(assessment_id); if (selfTaskDetailList == null || selfTaskDetailList.Count <= 0) { return(Error("系统未知错误。")); } List <AssessmentResultCountEntity> assessmentResultCountList = assessmentResultCountApp.GetByAssessmentId(assessment_id); if (assessmentResultCountList == null || assessmentResultCountList.Count <= 0) { return(Error("系统未知错误。")); } using (var db = new RepositoryBase().BeginTrans()) { //将本次考核状态设置为初始状态 0 assessmentEntity.assessment_statue = 0; assessmentEntity.last_modify_time = DateTime.Now; db.Update <AssessmentEntity>(assessmentEntity); //更新考核发起详细表 assessmentDetailList.ForEach((t) => { t.finished = 0; t.last_modify_time = DateTime.Now; db.Update <AssessmentDetailEntity>(t); }); //1.更新所有任务表状态为未激活 selfTaskDetailList.ForEach((t) => { t.task_statue = 0; t.last_modify_time = DateTime.Now; db.Update <SelfTaskDetailEntity>(t); }); //2.更新check_order为1的任务状态为已激活 selfTaskDetailList.ForEach((t) => { List <AssessmentDetailEntity> list = assessmentDetailApp.GetFirstCheckerList(assessment_id); list.ForEach((tt) => { if (t.person == tt.checker) { t.task_statue = 1; } }); }); //删除上次考核成绩 assessmentResultCountList.ForEach((t) => { db.Delete <AssessmentResultCountEntity>(t); }); //导入考核数据 BranchAssessmentImportApp branchAssessmentImportApp = new BranchAssessmentImportApp(db); var data = branchAssessmentImportApp.Scan(file_name, new string[] { assessment_id }); if (data.Count > 0) { return(Error("导入数据存在未处理的错误!")); } else { branchAssessmentImportApp.Import(file_name, assessment_id); } db.Commit(); } return(Success("操作成功。", null)); }