public ActionResult LaunchPersonalAssessment(string assessment_name, string start_time, string end_time, string templete_id, string checker_object_list, int?need_self_check, double?self_check_weight, string checker_list, string filling_people, string file_name)
        {
            if (assessmentApp.IsExists(assessment_name))
            {
                return(Error("考核名称已存在。"));
            }
            using (var db = new RepositoryBase().BeginTrans())
            {
                List <string> checkerObjectList = KPI.Code.Json.ToObject <List <string> >(checker_object_list);
                FileLog.Debug(checker_object_list);
                List <PersonalAssessmentCheckerModel> checkerList = KPI.Code.Json.ToObject <List <PersonalAssessmentCheckerModel> >(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   = checkerObjectList.Count;
                assessmentEntity.need_self_check    = need_self_check.HasValue ? need_self_check.Value : 0;
                assessmentEntity.assessment_statue  = 0;
                assessmentEntity.assessment_type    = 0;
                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 = null;
                //如果需要自评
                if (assessmentEntity.need_self_check == 1)
                {
                    for (int i = 0; i < checkerObjectList.Count; i++)
                    {
                        string checkObject = checkerObjectList[i];
                        assessmentDetailEntity                   = new AssessmentDetailEntity();
                        assessmentDetailEntity.id                = Common.GuId();
                        assessmentDetailEntity.assessment_id     = assessmentId;
                        assessmentDetailEntity.check_object      = checkObject;
                        assessmentDetailEntity.checker           = checkObject;
                        assessmentDetailEntity.check_order       = 1;
                        assessmentDetailEntity.finished          = 0;
                        assessmentDetailEntity.checker_weight    = self_check_weight;
                        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();
                        selfTaskDetailEntity.task_statue     = 1;
                        selfTaskDetailEntity.task_type       = 3;
                        selfTaskDetailEntity.person          = checkObject;
                        selfTaskDetailEntity.task_object     = checkObject;
                        selfTaskDetailEntity.attach          = assessmentId;
                        selfTaskDetailEntity.creator_user_id = OperatorProvider.Provider.GetCurrent().UserId;
                        selfTaskDetailEntity.create_time     = DateTime.Now;
                        db.Insert <SelfTaskDetailEntity>(selfTaskDetailEntity);
                    }
                }
                for (int i = 0; i < checkerList.Count; i++)
                {
                    for (int j = 0; j < checkerObjectList.Count; j++)
                    {
                        PersonalAssessmentCheckerModel checker = checkerList[i];
                        string checkObject = checkerObjectList[j];
                        assessmentDetailEntity                   = new AssessmentDetailEntity();
                        assessmentDetailEntity.id                = Common.GuId();
                        assessmentDetailEntity.assessment_id     = assessmentId;
                        assessmentDetailEntity.check_object      = checkObject;
                        assessmentDetailEntity.checker           = checker.checker_id;
                        assessmentDetailEntity.check_order       = checker.checker_order;
                        assessmentDetailEntity.finished          = 0;
                        assessmentDetailEntity.checker_weight    = checker.checker_weight;
                        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     = checkObject;
                        selfTaskDetailEntity.attach          = assessmentId;
                        selfTaskDetailEntity.creator_user_id = OperatorProvider.Provider.GetCurrent().UserId;
                        selfTaskDetailEntity.create_time     = DateTime.Now;
                        db.Insert <SelfTaskDetailEntity>(selfTaskDetailEntity);
                    }
                }
                #endregion

                //给“考核结果审核人插入归档任务”
                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);

                PersonalAssessmentImportApp personalAssessmentImportApp = new PersonalAssessmentImportApp(db);
                var data = personalAssessmentImportApp.Scan(file_name, new string[] { assessmentId });
                if (data.Count > 0)
                {
                    return(Error("导入数据存在未处理的错误!"));
                }
                else
                {
                    personalAssessmentImportApp.Import(file_name, assessmentId);
                }
                db.Commit();
            }
            return(Success("操作成功。", null));
        }
        public ActionResult ReLaunchPersonalAssessment(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;
                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);
                });

                //导入考核数据
                PersonalAssessmentImportApp personalAssessmentImportApp = new PersonalAssessmentImportApp(db);
                var data = personalAssessmentImportApp.Scan(file_name, new string[] { assessment_id });
                if (data.Count > 0)
                {
                    return(Error("导入数据存在未处理的错误!"));
                }
                else
                {
                    personalAssessmentImportApp.Import(file_name, assessment_id);
                }

                db.Commit();
            }
            return(Success("操作成功。", null));
        }