public async Task <AjaxResult> InsertHrHrEvaluationInfo(HrEvaluationDTO vm)
        {
            if (vm.H_users.IsNullOrEmpty() || vm.H_users?.Count == 0)
            {
                return(Error("评审人员不能为空"));
            }
            var userLength = vm.H_users.Select(x => x.user_id).Distinct().Count();

            if (vm.H_users.Count > userLength)
            {
                return(Error("评审人员存在重复"));
            }

            hr_assessment_evaluation evaluation = _mapper.Map <hr_assessment_evaluation>(vm);

            evaluation.id = IdHelper.GetId();
            evaluation.evaluation_code = (await Db.GetIQueryable <hr_assessment_evaluation>().MaxAsync(x => x.evaluation_code) ?? 0) + 1;
            evaluation.completion_time = null;
            evaluation.created_time    = DateTime.Now;
            evaluation.create_user     = _operator.Property?.UserName;
            evaluation.Deleted         = false;
            await Db.InsertAsync(evaluation);

            //测评人
            vm.H_users.ForEach(item =>
            {
                item.id = IdHelper.GetId();
                item.assessment_evaluation_id = evaluation.id;
                item.status = EvaluationStatus.待测评;
            });
            await Db.InsertAsync(vm.H_users);

            return(Success());
        }
        /// <summary>
        /// 查看测评
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <HrEvaluationDTO> GetHrEvaluationInfo(IdInputDTO input)
        {
            //测评记录
            var evaluation = Db.GetEntity <hr_assessment_evaluation>(input.id);

            HrEvaluationDTO vm = new HrEvaluationDTO()
            {
                id = evaluation.id,
                evaluation_code        = evaluation.evaluation_code,
                evaluation_name        = evaluation.evaluation_name,
                assessment_template_id = evaluation.assessment_template_id,
                user_id         = evaluation.user_id,
                user_name       = evaluation.user_name,
                completion_time = evaluation.completion_time,
                create_user     = evaluation.create_user,
                created_time    = evaluation.created_time,
                updated_user    = evaluation.updated_user,
                updated_time    = evaluation.updated_time,
                Sort            = evaluation.Sort,
                Deleted         = evaluation.Deleted
            };

            //测评人信息
            vm.H_users = await Db.GetIQueryable <hr_assessment_user>().Where(x => x.assessment_evaluation_id == vm.id).OrderBy(x => x.user_type).ToListAsync();

            //测评分数
            var templentItemsScore = await Db.GetIQueryable <hr_assessment_score>().Where(x => x.assessment_evaluation_id == vm.id).ToListAsync();

            vm.TemplateInfo = await GetHrTemplateInfo(new IdInputDTO()
            {
                id = vm.assessment_template_id
            });

            vm.TemplateInfo.templatItems.ForEach(items =>
            {
                var _Score = new List <hr_assessment_score>();
                vm.H_users.ForEach(user =>
                {
                    _Score.AddRange(templentItemsScore.FindAll(x => x.assessment_items_id == items.id && x.assessment_user_id == user.user_id));
                });
                items.H_Score = _Score;
            });
            return(vm);
        }
 public async Task <AjaxResult> InsertHrEvaluationInfo(HrEvaluationDTO vm)
 {
     return(await _IHr_assessment_templateService.InsertHrHrEvaluationInfo(vm));
 }
        /// <summary>
        /// 导出测评
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <byte[]> ExportHrEvaluationInfo(string id)
        {
            HrEvaluationDTO vm = await GetHrEvaluationInfo(new IdInputDTO()
            {
                id = id
            });

            DataTable tblDatas = new DataTable();

            var evaluation_name = new List <object> {
                "测评名称", vm.evaluation_name
            };
            var user_name = new List <object> {
                "测评对象", vm.user_name
            };

            tblDatas.Columns.Add("编号");
            tblDatas.Columns.Add("考核项目");

            var totalRow = new List <object> {
                "", "合计"
            };

            //动态添加测评人表头
            vm.TemplateInfo.templatItems?[0].H_Score?.ForEach(user =>
            {
                tblDatas.Columns.Add(user.assessment_user_name);
                totalRow.Add(0);//合计行 默认都是0
            });
            //循环模板项
            int i = 0;

            vm.TemplateInfo.templatItems?.ForEach((template) =>
            {
                i++;
                int j   = 1;
                var row = new List <object> {
                    i, template.item_name
                };
                template.H_Score.ForEach(user =>
                {
                    j++;
                    row.Add(user.score);
                    totalRow[j] = (int)totalRow[j] + user.score;
                });
                tblDatas.Rows.Add(row.ToArray());
            });
            //合计列
            tblDatas.Rows.Add(totalRow.ToArray());
            tblDatas.Rows.Add(tblDatas.NewRow());//空列

            //测评名称和测评对象
            tblDatas.Rows.Add(evaluation_name.ToArray());
            tblDatas.Rows.Add(user_name.ToArray());
            tblDatas.Rows.Add(tblDatas.NewRow());//空列

            //测评人
            vm.H_users.GroupBy(g => new { g.user_type })
            .ForEach(groupItem =>
            {
                var H_User = new List <object>()
                {
                    (AssessmentUserType)groupItem.Key.user_type
                };
                H_User.AddRange(groupItem.Select(x => x.user_name).ToList());
                tblDatas.Rows.Add(H_User.ToArray());
            });
            return(AsposeOfficeHelper.DataTableToExcelBytes(tblDatas));
        }