
using New_College.IServices;
using New_College.Model.Models;
using New_College.Services.BASE;
using New_College.IRepository.Base;
using System.Collections.Generic;
using New_College.Model.ViewModels;
using System.Linq;
using Newtonsoft.Json;
using System.Threading.Tasks;
using New_College.Common.Helper;
using New_College.IRepository;
using System.Reflection;
using System;
using System.Text;
using New_College.Model;
using New_College.Model.ViewModels.Result;
using New_College.Model.ViewModels.Query;
using Microsoft.Extensions.Logging;

namespace New_College.Services
{
    public class Test_PsychMeasurementInfoServices : BaseServices<Test_PsychMeasurementInfo>, ITest_PsychMeasurementInfoServices
    {
        private readonly IBaseRepository<Test_PsychMeasurementInfo> _dal;
        private readonly ITest_QuestionTypeInfoRepository _QuestionTypeInfoRepository;
        private readonly ITest_MBTIMapResultRepository test_MBTIMapResultRepository;
        private readonly ITest_CycleTimeInfoRepository test_CycleTimeInfoRepository;
        private readonly IV_SubjectSelectRepository v_SubjectSelectRepository;
        private readonly IT_PlanMapTagRepository t_PlanMapTagRepository;
        private readonly IT_EnrollmentPlaneRepository t_EnrollmentPlaneRepository;
        private readonly IT_EnrollmentPlanedescRepository t_EnrollmentPlanedescRepository;

        private readonly ILogger<Test_PsychMeasurementInfoServices> _loggerHelper;
        public Test_PsychMeasurementInfoServices(IBaseRepository<Test_PsychMeasurementInfo> dal
            , ITest_QuestionTypeInfoRepository ITest_QuestionTypeInfoRepository
            , ITest_MBTIMapResultRepository ITest_MBTIMapResultRepository
            , ITest_CycleTimeInfoRepository ITest_CycleTimeInfoRepository
            , IV_SubjectSelectRepository IV_SubjectSelectRepository
            , IT_PlanMapTagRepository IT_PlanMapTagRepository
            , IT_EnrollmentPlaneRepository IT_EnrollmentPlaneRepository
            , IT_EnrollmentPlanedescRepository IT_EnrollmentPlanedescRepository, ILogger<Test_PsychMeasurementInfoServices> loggerHelper)
        {
            this._dal = dal;
            _QuestionTypeInfoRepository = ITest_QuestionTypeInfoRepository;
            test_MBTIMapResultRepository = ITest_MBTIMapResultRepository;
            test_CycleTimeInfoRepository = ITest_CycleTimeInfoRepository;
            v_SubjectSelectRepository = IV_SubjectSelectRepository;
            t_PlanMapTagRepository = IT_PlanMapTagRepository;
            t_EnrollmentPlaneRepository = IT_EnrollmentPlaneRepository;
            t_EnrollmentPlanedescRepository = IT_EnrollmentPlanedescRepository;
            base.BaseDal = dal;
            this._loggerHelper = loggerHelper;
        }
        public List<string> permut = new List<string>();
        /// <summary>
        /// 获取个人某个维度测评结果
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<List<PsychMeasurementListResult>> GetPsychListByCateAndCustomerId(PsychMeasurementQuery query)
        {
            var info = await _dal.Query(x => x.IsDelete == false && x.CategoryId == query.CategoryId && x.StudentId == query.StudentId);
            if (info.Count <= 0)
                return new List<PsychMeasurementListResult>() { };
            var cycids = info.Select(x => x.CycleTimeId).ToList();
            var cycinfo = await test_CycleTimeInfoRepository.Query(x => x.IsDelete == false && cycids.Contains(x.Id));
            List<PsychMeasurementListResult> list = new List<PsychMeasurementListResult>() { };
            foreach (var item in info)
            {
                var cycname = cycinfo.Where(x => x.Id == item.CycleTimeId).Select(x => x.CycleName)?.FirstOrDefault();
                if (!string.IsNullOrWhiteSpace(cycname))
                    list.Add(new PsychMeasurementListResult()
                    {
                        Id = item.Id,
                        CreateTime = item.CreateTime,
                        CycleTimeId = item.CycleTimeId,
                        CycleName = cycname,
                        IsOpen = item.IsOpen
                    });
            }
            return list;
        }

        /// <summary>
        /// 提交
        /// </summary>
        /// <returns></returns>
        public async Task<bool> SavePsych(SavePsychQuery query)
        {
            var IsOpen = 1;
            var result = "";
            //if (query.Type == 2)
            //{
            //    result = JsonConvert.SerializeObject(query.CareerResult);
            //}
            //else 
            if (query.Type == 1)
            {
                if (query.CategoryId == 11)
                {
                    var item = DirectionChangeXXFG(query);
                    result = JsonConvert.SerializeObject(item);
                }
                else
                {
                    var ListType = (await _QuestionTypeInfoRepository.Query(x => x.IsDelete == false)).Select(x => x.Name).ToList();
                    var item = DirectionChange(query, ListType);
                    result = JsonConvert.SerializeObject(item);
                }
            }
            else if (query.Type == 3)
            {
                IsOpen = 0;
                if (query.CategoryId == 15)
                {
                    var item = DirectionChangeMENTAL(query);
                    result = JsonConvert.SerializeObject(item);
                }
                else
                {
                    var item = PshchDirectionChange(query);
                    result = JsonConvert.SerializeObject(item);
                }
            }
            else if (query.CategoryId == 20)
            {
                result = JsonConvert.SerializeObject(query.Result);
            }
            var info = await _dal.Add(new Test_PsychMeasurementInfo()
            {
                StudentId = query.StudentId,
                CategoryId = query.CategoryId,
                CycleTimeId = 109,
                //ClassName = query.ClassName,
                //GradeName = query.GradeName,
                IsOpen = IsOpen,
                Result = result
            });
            if (info > 0)
            {
                ////生涯能力数据处理
                //if (query.Type == 2)
                //{
                //    #region 能力评估
                //    UpdateEval(query.CareerResult, query.CategoryId, query.StudentId);
                //    #endregion

                //    #region 变化反馈
                //    UpdateGrow(query.CareerResult, query.CycleTimeId, query.CategoryId, query.StudentId);
                //    #endregion
                //}
                return true;
            }
            else
            {
                return false;
            }
        }

        #region 提交 数据处理
        /// <summary>
        /// 普通 学生发展用
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<IntellectJson> DirectionChange(SavePsychQuery query, List<string> ListType)
        {
            var Result = new List<IntellectJson>();
            var QuestionType = query.second.Select(p => p.Tag).Distinct().ToList();
            foreach (var item in QuestionType)
            {
                if (item != "null" && ListType.Contains(item))
                {
                    var seconddto = new IntellectJson();
                    seconddto.value = query.second.Where(m => m.Tag == item).Sum(p => p.Status);
                    seconddto.name = item;
                    Result.Add(seconddto);
                }
            }
            return Result;
        }
        /// <summary>
        /// 普通 心理测量用
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<IntellectJson> PshchDirectionChange(SavePsychQuery query)
        {
            var Result = new List<IntellectJson>();
            var QuestionType = query.second.Select(p => p.Tag).Distinct().ToList();
            foreach (var item in QuestionType)
            {
                if (item != "null")
                {
                    var seconddto = new IntellectJson();
                    seconddto.value = query.second.Where(m => m.Tag == item).Sum(p => p.Status);
                    seconddto.name = item;
                    Result.Add(seconddto);
                }
            }
            return Result;
        }
        /// <summary>
        /// 学习风格专用
        /// </summary>
        /// <param name="requestDTO"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        private List<IntellectJson> DirectionChangeXXFG(SavePsychQuery requestDTO)
        {
            List<IntellectJson> list = new List<IntellectJson>() { };
            var json = new IntellectJson();
            var A = 0;
            var P = 0;
            var R = 0;
            var T = 0;
            int[] styleA = { 2, 5, 8, 15, 19, 23, 26, 35, 36, 40 };
            int[] styleP = { 4, 7, 9, 14, 20, 24, 27, 31, 34, 37 };
            int[] styleR = { 11, 12, 16, 18, 21, 25, 29, 30, 32, 33 };
            int[] styleT = { 1, 3, 6, 10, 13, 17, 22, 28, 38, 39 };
            foreach (var item in requestDTO.second)
            {
                if (styleA.Contains(item.Id))
                {
                    A += item.Status;
                }
                else if (styleP.Contains(item.Id))
                {
                    P += item.Status;
                }
                else if (styleR.Contains(item.Id))
                {
                    R += item.Status;
                }
                else if (styleT.Contains(item.Id))
                {
                    T += item.Status;
                }

            }
            list.AddRange(new List<IntellectJson>{new IntellectJson
            {
                name = "冲动型",
                value = A
            }, new IntellectJson
            {
                name = "务实型",
                value = P
            }, new IntellectJson
            {
                name = "反思型",
                value = R
            }, new IntellectJson
            {
                name = "理论型",
                value = T
            } });

            return list;//JsonConvert.SerializeObject(list);
            //  return "[{\"name\":\"冲动型\",\"value\":" + A + "},{\"name\":\"务实型\",\"value\":" + P + "},{\"name\":\"反思型\",\"value\":" + R + "},{\"name\":\"理论型\",\"value\":" + T + "}]";
        }
        /// <summary>
        /// mht专用
        /// </summary>
        /// <param name="requestDTO"></param>
        /// <param name="list"></param>
        /// <param name="valid"></param>
        /// <returns></returns>
        private List<IntellectJson> DirectionChangeMENTAL(SavePsychQuery requestDTO)
        {
            List<IntellectJson> list = new List<IntellectJson>() { };
            var xxjl = 0;
            var drjl = 0;
            var gdqx = 0;
            var zzqx = 0;
            var gmqx = 0;
            var stzz = 0;
            var kbqx = 0;
            var cdqx = 0;

            int[] xuexijiaolv = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };//学习焦虑
            int[] duirenjiaolv = { 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 };//对人焦虑
            int[] guduqingxiang = { 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 };//孤独倾向
            int[] zizeqingxiang = { 36, 37, 38, 39, 40, 41, 42, 43, 44, 45 };//自责倾向
            int[] guomingqingxiang = { 46, 47, 48, 49, 50, 51, 52, 53, 54, 55 };//过敏倾向
            int[] shentizhengzhuang = { 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70 };//身体症状
            int[] kongbuqingxiang = { 71, 72, 73, 74, 75, 76, 77, 78, 79, 80 };//恐怖倾向
            int[] chongdongqingxiang = { 81, 83, 85, 87, 89, 91, 93, 95, 97, 99 };//冲动倾向
            int[] valids = { 82, 84, 86, 88, 90, 92, 94, 96, 98, 100 }; //测谎题

            foreach (var item in requestDTO.second)
            {
                if (xuexijiaolv.Contains(item.Id))
                {
                    xxjl += item.Status;
                }
                else if (duirenjiaolv.Contains(item.Id))
                {
                    drjl += item.Status;
                }
                else if (guduqingxiang.Contains(item.Id))
                {
                    gdqx += item.Status;
                }
                else if (zizeqingxiang.Contains(item.Id))
                {
                    zzqx += item.Status;
                }
                else if (guomingqingxiang.Contains(item.Id))
                {
                    gmqx += item.Status;
                }
                else if (shentizhengzhuang.Contains(item.Id))
                {
                    stzz += item.Status;
                }

                else if (kongbuqingxiang.Contains(item.Id))
                {
                    kbqx += item.Status;
                }
                else if (chongdongqingxiang.Contains(item.Id))
                {
                    cdqx += item.Status;
                }

            }
            list.AddRange(new List<IntellectJson> {
                new IntellectJson{ name="学习焦虑" , value=xxjl},
                new IntellectJson{ name="对人焦虑" , value=drjl},
                new IntellectJson{ name="孤独倾向" , value=gdqx },
                new IntellectJson{ name="自责倾向" , value=zzqx},
                new IntellectJson{ name="过敏倾向" , value=gmqx},
                new IntellectJson{ name="身体症状" , value=stzz},
                new IntellectJson{ name="恐怖倾向" , value=kbqx},
                new IntellectJson{ name="冲动倾向" , value=cdqx},
            });

            return list;//"[{\"name\":\"学习焦虑\",\"value\":" + xxjl + "},{\"name\":\"对人焦虑\",\"value\":" + drjl + "},{\"name\":\"孤独倾向\",\"value\":" + gdqx + "},{\"name\":\"自责倾向\",\"value\":" + zzqx + "},{\"name\":\"过敏倾向\",\"value\":" + gmqx + "},{\"name\":\"身体症状\",\"value\":" + stzz + "},{\"name\":\"恐怖倾向\",\"value\":" + kbqx + "},{\"name\":\"冲动倾向\",\"value\":" + cdqx + "}]";
        }

        /// <summary>
        /// 根据最大值获取职业标签名称
        /// </summary>
        /// <param name="model"></param>
        /// <param name="maxnumb"></param>
        /// <returns></returns>
        public string GetFieldName(HollandModel model, int maxnumb, string first, string second)
        {
            string FieldName = string.Empty;
            Type t = typeof(HollandModel);
            foreach (PropertyInfo finfo in t.GetProperties())
            {
                if (finfo.Name != "Target" && Convert.ToInt32(finfo.GetValue(model)) == maxnumb)
                {
                    if (finfo.Name != first && finfo.Name != second)
                    {
                        FieldName = finfo.Name;
                        break;
                    }
                }
            }
            return FieldName;
        }
        /// <summary>
        /// 获取标签数量
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Tuple<List<string>, List<serie>> GetCategoriesByHoolandModel(HollandModel model)
        {

            var FieldNames = new List<string>();
            var series = new List<serie>();
            var serieint = new List<int>();

            Type t = typeof(HollandModel);
            foreach (PropertyInfo finfo in t.GetProperties())
            {
                FieldNames.Add(finfo.Name);
                serieint.Add(Convert.ToInt32(finfo.GetValue(model)));
            }
            series.Add(new serie() { data = serieint, name = "霍兰德" });
            return new Tuple<List<string>, List<serie>>(FieldNames, series);
        }
        #endregion


        #region  提交/获取 霍兰德和MBTI
        /// <summary>
        /// 提交  霍兰德和MBTI
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<bool> SaveHolland(SaveHollandQuery query)
        {
            StringBuilder tagname = new StringBuilder();
            if (query.CategoryId == 18)
            {
                var model = JsonConvert.DeserializeObject<HollandModel>(query.Tags);
                int[] Num = new int[] { model.A, model.C, model.E, model.I, model.R, model.S };
                List<int> Numbers = Num.ToList();
                int first = Numbers.Max();
                Numbers.Remove(first);
                int second = Numbers.Max();
                Numbers.Remove(second);
                int third = Numbers.Max();
                string firstname = GetFieldName(model, first, "", "");
                string secondname = GetFieldName(model, second, firstname, "");
                string thirdname = GetFieldName(model, third, firstname, secondname);
                var result = new TagtestingHollandResult();
                var radars = new Radar();
                var temp = GetCategoriesByHoolandModel(model);
                radars.categories = temp.Item1;
                radars.series = temp.Item2;
                result.TagName = firstname + secondname + thirdname;
                result.radar = radars;
                tagname.Append(JsonConvert.SerializeObject(result));

                var info = await _dal.Add(new Test_PsychMeasurementInfo()
                {
                    StudentId = query.StudentId,
                    CategoryId = query.CategoryId,
                    CycleTimeId = 87,//需要动态获取---CycleTimeId
                    //ClassName = query.ClassName,
                    //GradeName = query.GradeName,
                    IsOpen = 1,
                    Result = tagname.ToString()
                });
                return info > 0 ? true : false;
            }
            else if (query.CategoryId == 19)
            {
                var model = JsonConvert.DeserializeObject<MBTICalcModel>(query.Tags);
                tagname.Append(model.E > model.I ? "E" : "I");
                tagname.Append(model.S > model.N ? "S" : "N");
                tagname.Append(model.T > model.F ? "T" : "F");
                tagname.Append(model.J > model.P ? "J" : "P");
                var info = await _dal.Add(new Test_PsychMeasurementInfo()
                {
                    StudentId = query.StudentId,
                    CategoryId = query.CategoryId,
                    CycleTimeId = 87,
                    //ClassName = query.ClassName,
                    //GradeName = query.GradeName,
                    IsOpen = 1,
                    Result = tagname.ToString()
                });
                return info > 0 ? true : false;
            }
            return false;
        }

        /// <summary>
        /// 获取霍兰德测评结果
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<TagtestingHollandResult> GetHollandResult(ResultLookQuery query)
        {
            Test_PsychMeasurementInfo info = new Test_PsychMeasurementInfo() { };
            if (query.CycleTimeId > 0)
            {
                info = (await _dal.Query(x => x.CategoryId == query.CategoryId && x.StudentId == query.StudentId && x.CycleTimeId == query.CycleTimeId)).FirstOrDefault();
            }
            else
            {
                info = (await _dal.Query(x => x.CategoryId == query.CategoryId && x.StudentId == query.StudentId)).OrderByDescending(x => x.CreateTime).FirstOrDefault();
            }
            if (info == null || string.IsNullOrEmpty(info.Result))
                return new TagtestingHollandResult() { };
            return JsonConvert.DeserializeObject<TagtestingHollandResult>(info.Result);
        }

        /// <summary>
        /// 获取MBTI测评结果
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<UserResult> GetMBTIResult(ResultLookQuery query)
        {
            var info = await _dal.Query(x => x.CategoryId == query.CategoryId && x.StudentId == query.StudentId && x.CycleTimeId == query.CycleTimeId);
            if (info.Count() <= 0 || string.IsNullOrEmpty(info?.FirstOrDefault()?.Result))
                return new UserResult() { };
            var mbtiresult = (await test_MBTIMapResultRepository.Query(x => x.Tag == info.FirstOrDefault().Result))?.FirstOrDefault();
            if (mbtiresult == null)
                return new UserResult() { };
            return new UserResult()
            {
                Advantage = mbtiresult.Advantage,
                BlindSpot = mbtiresult.BlindSpot,
                Disadvantage = mbtiresult.Disadvantage,
                Domain = mbtiresult.Domain,
                Feature = mbtiresult.Feature,
                Interpretation = mbtiresult.Interpretation,
                Recommend = mbtiresult.Recommend,
                Tag = mbtiresult.Tag
            };
        }
        #endregion

        /// <summary>
        /// 获取学生发展
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<ShowPsychologicalResult> GetPsychDetail(ResultLookQuery query)
        {
            ShowPsychologicalResult result = new ShowPsychologicalResult() { };
            List<int> BillDatas = new List<int>() { };
            List<EvBillcator> Billcators = new List<EvBillcator>() { };
            List<PsyTagDetail> Result = new List<PsyTagDetail>() { };
            List<NameValue> List = new List<NameValue>() { };
            Test_PsychMeasurementInfo info = new Test_PsychMeasurementInfo() { };
            if (query.CycleTimeId > 0)
            {
                info = (await _dal.Query(x => x.IsDelete == false && x.StudentId == query.StudentId && x.CategoryId == query.CategoryId && x.CycleTimeId == query.CycleTimeId)).FirstOrDefault();
            }
            else
            {
                info = (await _dal.Query(x => x.IsDelete == false && x.StudentId == query.StudentId && x.CategoryId == query.CategoryId)).OrderByDescending(x => x.CreateTime).FirstOrDefault();
            }

            var Json = JsonConvert.DeserializeObject<List<IntellectJson>>(info.Result).Where(w => w.name != null).ToList();
            if (query.CategoryId == 7)
            {
                var Psyintellectags = ShowPsychological.Psyintellectags;
                var Psysuggesttypes = ShowPsychological.Psysuggesttypes;
                Json.ForEach(m =>
                {
                    BillDatas.Add(m.value);
                    Billcators.Add(new EvBillcator() { max = 65, text = m.name });
                    List.Add(new NameValue() { Name = m.name, Value = m.value });
                    var info = Psyintellectags.Where(x => x.name == m.name)?.FirstOrDefault();
                    if (info != null)
                    {
                        var Suggess = "";
                        if (m.value <= 35)
                        {
                            Suggess = Psysuggesttypes.Where(x => x.name == m.name).Select(x => x.suggest)?.FirstOrDefault();
                        }
                        Result.Add(new PsyTagDetail()
                        {
                            MaxScore = 65,
                            Score = m.value,
                            Name = m.name,
                            Title = info.title,
                            Content = info.content,
                            Suggess = Suggess
                        });
                    }
                });
                return new ShowPsychologicalResult()
                {
                    Name = "多元智能",
                    BillDatas = BillDatas,
                    Billcators = Billcators,
                    List = List,
                    Result = Result
                };
            }
            else if (query.CategoryId == 8)
            {
                var showsuggesttaggests = ShowMultiDimension.showsuggesttaggests;
                Json.ForEach(m =>
                {
                    BillDatas.Add(m.value);
                    Billcators.Add(new EvBillcator() { max = 12, text = m.name });
                    List.Add(new NameValue() { Name = m.name, Value = m.value });
                    var info = showsuggesttaggests.Where(x => x.name == m.name)?.FirstOrDefault();
                    if (info != null)
                    {
                        var Suggess = "";
                        var Taggess = "";
                        if (info.score == 17)
                        {
                            if (m.value > info.score)
                            {
                                Suggess = info.suggest;
                                Taggess = info.truetaggest;
                            }
                            Taggess = info.falsetaggest;
                        }
                        else
                        {
                            if (m.value < info.score)
                            {
                                Suggess = info.suggest;
                                Taggess = info.truetaggest;
                            }
                            Taggess = info.falsetaggest;
                        }
                        Result.Add(new PsyTagDetail()
                        {
                            MaxScore = 12,
                            Score = m.value,
                            Name = m.name,
                            //Title = info.title,
                            Content = Taggess,
                            Suggess = Suggess
                        });
                    }
                });
                return new ShowPsychologicalResult()
                {
                    Name = "学习多维分析",
                    BillDatas = BillDatas,
                    Billcators = Billcators,
                    List = List,
                    Result = Result
                };
            }
            else if (query.CategoryId == 9)
            {
                Json.ForEach(m =>
                {
                    Result.Add(new PsyTagDetail()
                    {
                        MaxScore = 37,
                        Score = m.value,
                        Content = "得分12分以下考试焦虑属较低水平，13分至20分属中等程度，21以上属较高水平。21分以上者的考试焦虑程度较高，建议掌握一些考试减压技巧和应试技巧",
                        Name = m.name
                    });
                });
                return new ShowPsychologicalResult()
                {
                    Name = "考试焦虑测试",
                    Result = Result
                };
            }
            else if (query.CategoryId == 10)
            {
                Json.ForEach(m =>
                {
                    Result.Add(new PsyTagDetail()
                    {
                        MaxScore = 200,
                        Score = m.value,
                        Name = m.name,
                        Title = "任何一个学习者，都有必要培养和提高自己的学习技能。要想提高自己的学习技能，必须全面掌握各个学习环节的具体方法。对于在校学生来说，也就是要掌握预习、听课、复习、作业和应考方法。分数越高，学习技能越强。",
                        Content = m.value >= 137 ? "学习技能较好（或优秀），建议再接再厉，全面发展！" : "学习技能水平较差（或一般），注意改进学习方法",
                        Suggess = m.value >= 137 ? "" : "<p><span style='color:#333333;font-family:&quot;font-size:14px;'>(一)预习：用快速略读法事先预习极多次，但不要求完全懂。</span><br/><span style='color:#333333;font-family:&quot;font-size:14px;'>(二)上课(a)用专心放轻松的方法听讲，保持灵敏的心去听，不主动要求自己全部听懂。(b)除非特殊状况，一定要作笔记，笔记愈整洁明晰愈好(不要为了省钱将笔记记得密密麻麻的)，以利日后快、慢速的复习。(c)在老师停顿或转身抄黑板的时候，迅速回想(最好口中默念出来)老师刚刚讲的重点，此种回想又可以叫潜意识迅速转极多次以消化之。</span><br/><span style='color:#333333;font-family:&quot;font-size:14px;'>(三)家中复习：复习功课的第一步骤，也是先快速略读多次，有空的时候作一次详读之后(此时要在课本、笔记上划出重点)，再多花一点时间回想上课的重点。若因为晚上补习没有足够时间，虽可以省掉详读，但略读和回想一定要作。记住不论如何忙，最多三、五天一定要将老师教过的部份，作过一次详读(没有时间的话，至少要作快速详读)。</span><br/><span style='color:#333333;font-family:&quot;font-size:14px;'>(四)做作业：做作业之前（必要时可以找一本比较完整的参考书来做，其作业题通常比课本多很多），要确定有没有先回想重点。</span><br/><span style='color:#333333;font-family:&quot;font-size:14px;'>(五)复习以前的功课：每隔三五天最好翻开笔记本，迅速的略读前一两个星期的功课。有空的话，将笔记本上划重点的部份出声念一遍。<br/><span style='color:#333333;font-family:&quot;font-size:14px;'>(六)考前复习：和家中复习那一项差不多，但要找出时间，针对笔记上的重点发出声音教给一个假想的人或同学。同时也要找一些例题和具有代表性的习题，教一教这个假想人。</span><br/><span style='color:#333333;font-family:&quot;font-size:14px;'>(七)考前猜题：想象自己是老师，出一些与重点有关的题目。不一定要真的去作出来(因为是自己出的题目，若题目合理则本来就会做)，但可以将这一些题目和课本互相印证，找出某几课中的真正重点和如何应用这些重点。</span><br/><span style='color:#333333;font-family:&quot;font-size:14px;'>(八)考前保持感觉最佳状态有二种方式：(a)考前做一些有代表性的例题和习题，从这一些题目中回想重点，回想时若发现忘了重点，翻开笔记看一看那一部份重点就可。(b)将笔记上的重点(或整理出的重点)重复多次地看，虽然不耐烦了还要再看，过度50%。</span></span></p><p><br/></p>"
                    });
                });
                return new ShowPsychologicalResult()
                {
                    Name = "学习技能测试",
                    Result = Result
                };
            }
            else if (query.CategoryId == 11)
            {
                Json.ForEach(m =>
                {
                    BillDatas.Add(m.value);
                    Billcators.Add(new EvBillcator() { max = 50, text = m.name });
                    List.Add(new NameValue() { Name = m.name, Value = m.value });
                });
                return new ShowPsychologicalResult()
                {
                    Name = "学习风格测评",
                    BillDatas = BillDatas,
                    Billcators = Billcators,
                    List = List,
                };
            }
            else if (query.CategoryId == 13)
            {
                var anxietyInfos = ShowSelfofAnxiety.anxietyInfos;
                Json.ForEach(m =>
                {
                    var score = 0;
                    if (m.value >= 70)
                    {
                        score = 1;
                    }
                    else if (m.value >= 60)
                    {
                        score = 2;
                    }
                    else if (m.value >= 50)
                    {
                        score = 3;
                    }
                    else
                    {
                        score = 4;
                    }
                    var nowinfo = anxietyInfos.Where(x => x.score == score)?.FirstOrDefault();
                    if (nowinfo != null)
                    {
                        Result.Add(new PsyTagDetail()
                        {
                            Score = m.value,
                            Title = nowinfo.title,
                            Suggess = nowinfo.suggess
                        });
                    }
                });
                return new ShowPsychologicalResult()
                {
                    Name = "SAS测试",
                    Result = Result
                };
            }
            else if (query.CategoryId == 14)
            {
                //sds
                var selfofDepressionInfos = ShowSelfofDepression.selfofDepressionInfos;
                Json.ForEach(m =>
                {
                    var score = 0;
                    if (m.value < 53)
                    {
                        score = 1;
                    }
                    else if (m.value <= 62)
                    {
                        score = 2;
                    }
                    else if (m.value <= 72)
                    {
                        score = 3;
                    }
                    else
                    {
                        score = 4;
                    }
                    var nowinfo = selfofDepressionInfos.Where(x => x.score == score)?.FirstOrDefault();
                    if (nowinfo != null)
                    {
                        Result.Add(new PsyTagDetail()
                        {
                            Score = m.value,
                            Title = nowinfo.title,
                            Suggess = nowinfo.suggess,
                            Content = nowinfo.result
                        });
                    }
                });
                return new ShowPsychologicalResult()
                {
                    Name = "SDS测试",
                    Result = Result
                };
            }
            else if (query.CategoryId == 15)
            {
                var mentalHealthInfos = ShowMentalHealth.mentalHealthInfos;
                Json.ForEach(m =>
                {
                    List.Add(new NameValue() { Name = m.name, Value = m.value });
                    var nowinfo = mentalHealthInfos.Where(x => x.title == m.name)?.FirstOrDefault();
                    var Suggess = "";
                    if (nowinfo != null)
                    {
                        if (m.value > 8)
                        {
                            Suggess = nowinfo.maxsuggest;
                        }
                        else if (m.value < 3)
                        {
                            Suggess = nowinfo.minsuggest;
                        }
                        Result.Add(new PsyTagDetail()
                        {
                            Score = m.value,
                            Title = nowinfo.title,
                            Suggess = Suggess
                        });
                    }
                });
                return new ShowPsychologicalResult()
                {
                    Name = "MHT测试",
                    Result = Result,
                    List = List
                };
            }
            return new ShowPsychologicalResult() { };
        }

        /// <summary>
        /// 学科探索 结果
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<MessageModel<SubjectEvBillDTO>> SubjectChartRadar(ResultLookQuery query)
        {
            SubjectEvBillDTO dTO = new SubjectEvBillDTO() { };
            var info = (await _dal.Query(x => x.IsDelete == false && x.StudentId == query.StudentId && x.CategoryId == query.CategoryId)).FirstOrDefault();
            if (info == null)
                return new MessageModel<SubjectEvBillDTO>() { success = false, msg = "未测试" };
            List<IntellectJson> newlist = new List<IntellectJson>() { };
            newlist.Add(new IntellectJson() { name = "物理", value = 0 });
            newlist.Add(new IntellectJson() { name = "化学", value = 0 });
            newlist.Add(new IntellectJson() { name = "生物", value = 0 });
            newlist.Add(new IntellectJson() { name = "政治", value = 0 });
            newlist.Add(new IntellectJson() { name = "历史", value = 0 });
            newlist.Add(new IntellectJson() { name = "地理", value = 0 });

            EvBillDTO subjectinterest = new EvBillDTO() { };
            var chartsinterestvalue = new List<decimal>();
            var evbillinterest = new List<EvBillcator>();

            EvBillDTO subjectability = new EvBillDTO() { };
            var chartsabilitvalue = new List<decimal>();
            var evbillabilit = new List<EvBillcator>();
            var result = JsonConvert.DeserializeObject<List<SubjectSelectJson>>(info.Result);

            var xqinfo = result.Where(w => w.name == "学科兴趣");
            if (xqinfo.Any())
            {
                var xq = xqinfo.FirstOrDefault().value;
                foreach (var item in xq)
                {
                    switch (item.name)
                    {
                        case "物理":
                            chartsinterestvalue.Add(item.value);
                            newlist.Where(x => x.name == "物理").FirstOrDefault().value += item.value;
                            break;
                        case "化学":
                            chartsinterestvalue.Add(item.value);
                            newlist.Where(x => x.name == "化学").FirstOrDefault().value += item.value;
                            break;
                        case "生物":
                            chartsinterestvalue.Add(item.value);
                            newlist.Where(x => x.name == "生物").FirstOrDefault().value += item.value;
                            break;
                        case "政治":
                            chartsinterestvalue.Add(item.value);
                            newlist.Where(x => x.name == "政治").FirstOrDefault().value += item.value;
                            break;
                        case "历史":
                            chartsinterestvalue.Add(item.value);
                            newlist.Where(x => x.name == "历史").FirstOrDefault().value += item.value;
                            break;
                        case "地理":
                            chartsinterestvalue.Add(item.value);
                            newlist.Where(x => x.name == "地理").FirstOrDefault().value += item.value;
                            break;
                    }
                }
                subjectinterest.BillDatas = chartsinterestvalue;

                var subjectinterestnewsort = xq.OrderByDescending(x => x.value);
                subjectinterest.Name = string.Join("|", subjectinterestnewsort.Take(3).Select(x => x.name).ToList());
            }
            evbillinterest.Add(new EvBillcator() { max = 32, text = "物理" });
            evbillinterest.Add(new EvBillcator() { max = 32, text = "化学" });
            evbillinterest.Add(new EvBillcator() { max = 32, text = "生物" });
            evbillinterest.Add(new EvBillcator() { max = 32, text = "政治" });
            evbillinterest.Add(new EvBillcator() { max = 32, text = "历史" });
            evbillinterest.Add(new EvBillcator() { max = 32, text = "地理" });

            var nlinfo = result.Where(w => w.name == "学科能力");
            if (nlinfo.Any())
            {
                var nl = nlinfo.FirstOrDefault().value;
                foreach (var item in nl)
                {
                    switch (item.name)
                    {
                        case "物理":
                            chartsabilitvalue.Add(item.value);
                            newlist.Where(x => x.name == "物理").FirstOrDefault().value += item.value;
                            break;
                        case "化学":
                            chartsabilitvalue.Add(item.value);
                            newlist.Where(x => x.name == "化学").FirstOrDefault().value += item.value;
                            break;
                        case "生物":
                            chartsabilitvalue.Add(item.value);
                            newlist.Where(x => x.name == "生物").FirstOrDefault().value += item.value;
                            break;
                        case "政治":
                            chartsabilitvalue.Add(item.value);
                            newlist.Where(x => x.name == "政治").FirstOrDefault().value += item.value;
                            break;
                        case "历史":
                            chartsabilitvalue.Add(item.value);
                            newlist.Where(x => x.name == "历史").FirstOrDefault().value += item.value;
                            break;
                        case "地理":
                            chartsabilitvalue.Add(item.value);
                            newlist.Where(x => x.name == "地理").FirstOrDefault().value += item.value;
                            break;
                    }
                    subjectability.BillDatas = chartsabilitvalue;

                    var subjectabilitynewsort = nl.OrderByDescending(x => x.value);
                    subjectability.Name = string.Join("|", subjectabilitynewsort.Take(3).Select(x => x.name).ToList());

                }
            }

            evbillabilit.Add(new EvBillcator() { max = 32, text = "物理" });
            evbillabilit.Add(new EvBillcator() { max = 32, text = "化学" });
            evbillabilit.Add(new EvBillcator() { max = 32, text = "生物" });
            evbillabilit.Add(new EvBillcator() { max = 32, text = "政治" });
            evbillabilit.Add(new EvBillcator() { max = 32, text = "历史" });
            evbillabilit.Add(new EvBillcator() { max = 32, text = "地理" });

            var namelist = newlist.OrderByDescending(x => x.value).Take(3).Select(x => x.name).ToList();
            var Name = string.Join("|", namelist);
            return new MessageModel<SubjectEvBillDTO>()
            {
                success = true,
                msg = "获取成功",
                response = new SubjectEvBillDTO()
                {
                    Name = Name,
                    subjectability = subjectability,
                    subjectinterest = subjectinterest
                }
            };
        }

        /// <summary>
        /// 传入用户Id 获取霍兰德测评状态
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<MessageModel<string>> GetHollandStatus(IdQuery query)
        {
            var info = await _dal.Query(x => x.StudentId == query.Id && x.CategoryId == 18 && x.IsDelete == false);
            if (info.Count <= 0)
                return new MessageModel<string>() { success = false, msg = "暂未测试霍兰德" };
            var result = info.OrderByDescending(x => x.CreateTime).Select(x => x.Result)?.FirstOrDefault();
            var tag = JsonConvert.DeserializeObject<TagtestingHollandResult>(result).TagName;
            return new MessageModel<string>()
            {
                success = true,
                msg = "获取成功",
                response = tag
            };
        }

        /// <summary>
        /// 传入用户Id 获取学科探索测评状态
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<MessageModel<bool>> GetSubjectSelectStatus(IdQuery query)
        {
            var info = await _dal.Query(x => x.StudentId == query.Id && x.CategoryId == 20 && x.IsDelete == false);
            if (info.Count <= 0)
                return new MessageModel<bool>() { success = false, msg = "暂未测试学科探索" };
            return new MessageModel<bool>() { success = true, msg = "已测试学科探索" };
        }

        /// <summary>
        /// 获取测评最新周期Id
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<MessageModel<CycleInfoResult>> GetReportCycleInfo(IdQuery query)
        {
            var info = await _dal.Query(x => x.IsDelete == false && x.StudentId == query.Id);
            if (info.Count <= 0)
                return new MessageModel<CycleInfoResult>() { success = false, msg = "未测评" };
            var nengli = info.Where(x => x.CategoryId == 7).OrderByDescending(x => x.CreateTime).FirstOrDefault();
            if (nengli == null)
                return new MessageModel<CycleInfoResult>() { success = false, msg = "未测评完全，请先去测试多元智能" };
            var duowei = info.Where(x => x.CategoryId == 8).OrderByDescending(x => x.CreateTime).FirstOrDefault();
            if (duowei == null)
                return new MessageModel<CycleInfoResult>() { success = false, msg = "未测评完全，请先去测试多维分析" };
            var jiaolv = info.Where(x => x.CategoryId == 9).OrderByDescending(x => x.CreateTime).FirstOrDefault();
            if (jiaolv == null)
                return new MessageModel<CycleInfoResult>() { success = false, msg = "未测评完全，请先去测试考试焦虑" };
            var jineng = info.Where(x => x.CategoryId == 10).OrderByDescending(x => x.CreateTime).FirstOrDefault();
            if (jineng == null)
                return new MessageModel<CycleInfoResult>() { success = false, msg = "未测评完全，请先去测评学习技能" };
            var fengge = info.Where(x => x.CategoryId == 11).OrderByDescending(x => x.CreateTime).FirstOrDefault();
            if (fengge == null)
                return new MessageModel<CycleInfoResult>() { success = false, msg = "未测评完全，请先去测评学习风格" };
            return new MessageModel<CycleInfoResult>()
            {
                success = true,
                msg = "获取成功",
                response = new CycleInfoResult()
                {
                    nengliCycleId = nengli.CycleTimeId,
                    duoweiCycleId = duowei.CycleTimeId,
                    fenggeCycleId = fengge.CycleTimeId,
                    jiaolvCycleId = jiaolv.CycleTimeId,
                    jinengCycleId = jineng.CycleTimeId
                }
            };
        }



        /// <summary>
        /// 获取三种推荐选科
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<MessageModel<List<SubjectSelectResult>>> GetSubjectSelectResult(NewSubjectQuery query)
        {
            List<SubjectSelectResult> list = new List<SubjectSelectResult>() { };
            #region   学科探索
            var info = (await _dal.Query(x => x.IsDelete == false && x.StudentId == query.CustomerId && x.CategoryId == 20 && x.CycleTimeId == 1)).FirstOrDefault();
            if (info == null)
                return new MessageModel<List<SubjectSelectResult>>() { success = false, msg = "未测试" };
            List<IntellectJson> newlist = new List<IntellectJson>() { };
            newlist.Add(new IntellectJson() { name = "物", value = 0 });
            newlist.Add(new IntellectJson() { name = "化", value = 0 });
            newlist.Add(new IntellectJson() { name = "生", value = 0 });
            newlist.Add(new IntellectJson() { name = "政", value = 0 });
            newlist.Add(new IntellectJson() { name = "史", value = 0 });
            newlist.Add(new IntellectJson() { name = "地", value = 0 });
            var result = JsonConvert.DeserializeObject<List<SubjectSelectJson>>(info.Result).FirstOrDefault().value;
            foreach (var item in result)
            {
                switch (item.name)
                {
                    case "物理":
                        newlist.Where(x => x.name == "物").FirstOrDefault().value += item.value;
                        break;
                    case "化学":
                        newlist.Where(x => x.name == "化").FirstOrDefault().value += item.value;
                        break;
                    case "生物":
                        newlist.Where(x => x.name == "生").FirstOrDefault().value += item.value;
                        break;
                    case "政治":
                        newlist.Where(x => x.name == "政").FirstOrDefault().value += item.value;
                        break;
                    case "历史":
                        newlist.Where(x => x.name == "史").FirstOrDefault().value += item.value;
                        break;
                    case "地理":
                        newlist.Where(x => x.name == "地").FirstOrDefault().value += item.value;
                        break;
                }
            }
            var namelist = newlist.OrderByDescending(x => x.value).Take(3).Select(x => x.name).ToList();
            var subjectName = string.Join("+", namelist);
            #endregion
            #region 霍兰德
            var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId);
            if (planinfo == null)
                return new MessageModel<List<SubjectSelectResult>>() { success = false, msg = "所选省份年份的招生计划，正在完善中..." };
            var planid = planinfo.FirstOrDefault().Id;
            if (string.IsNullOrWhiteSpace(query.Tag))
                return new MessageModel<List<SubjectSelectResult>>() { success = false, msg = "标签传入为空,请去测试" };
            var newTags = GetTag(query.Tag);
            var planmaptag = await t_PlanMapTagRepository.Query(x => x.IsDelete == false);
            List<string> majorlists = new List<string>() { };
            foreach (var item in newTags)
            {
                majorlists.AddRange(planmaptag.Where(x => x.Tag.Contains(item)).Select(x => x.Name).ToList());
            }
            majorlists = majorlists.Distinct().ToList();
            var descinfo = await t_EnrollmentPlanedescRepository.Query(x => x.IsDelete == false && x.PlanId == planid && majorlists.Contains(x.MajorName) && x.UniversityId > 0);
            List<IdNameResult> hollandlist = new List<IdNameResult>() { };
            hollandlist.Add(new IdNameResult() { Name = "物", Id = descinfo.Count(x => x.Subjectclaim.Contains("物")) });
            hollandlist.Add(new IdNameResult() { Name = "化", Id = descinfo.Count(x => x.Subjectclaim.Contains("化")) });
            hollandlist.Add(new IdNameResult() { Name = "生", Id = descinfo.Count(x => x.Subjectclaim.Contains("生")) });
            hollandlist.Add(new IdNameResult() { Name = "政", Id = descinfo.Count(x => x.Subjectclaim.Contains("政")) });
            hollandlist.Add(new IdNameResult() { Name = "史", Id = descinfo.Count(x => x.Subjectclaim.Contains("史")) });
            hollandlist.Add(new IdNameResult() { Name = "地", Id = descinfo.Count(x => x.Subjectclaim.Contains("地")) });
            var hollandresult = hollandlist.OrderByDescending(x => x.Id).Select(x => x.Name).Take(3).ToList();
            var HollandName = string.Join("+", hollandresult);
            #endregion
            #region 自选
            var Optional = await v_SubjectSelectRepository.Query(x => x.IsDelete == false && x.CustomerId == query.CustomerId && x.Status == 1);
            var Optionalresult = Optional.Select(x => x.SubjectSelect).FirstOrDefault().Split(",").ToList();
            var OptionalName = Optional.Select(x => x.SubjectSelect).FirstOrDefault().Replace(",", "+");
            #endregion
            // namelist.Contains() hollandresult
            #region  first
            var firstholl = 0;
            var firstoptional = 0;
            foreach (var item in namelist)
            {
                if (hollandresult.Count(x => x == item) > 0)
                {
                    firstholl += 33;
                }
            }
            foreach (var item in namelist)
            {
                if (Optionalresult.Count(x => x == item) > 0)
                {
                    firstoptional += 33;
                }
            }
            list.Add(new SubjectSelectResult()
            {
                Select = subjectName,
                SubjectResult = 100,
                HollResult = firstholl == 99 ? 100 : firstholl,
                OptionalResult = firstoptional == 99 ? 100 : firstoptional
            });
            #endregion

            #region second
            var secondsubject = 0;
            var secondoptional = 0;
            foreach (var item in hollandresult)
            {
                if (namelist.Count(x => x == item) > 0)
                {
                    secondsubject += 33;
                }
            }
            foreach (var item in hollandresult)
            {
                if (Optionalresult.Count(x => x == item) > 0)
                {
                    secondoptional += 33;
                }
            }
            list.Add(new SubjectSelectResult()
            {
                Select = HollandName,
                SubjectResult = secondsubject == 99 ? 100 : secondsubject,
                HollResult = 100,
                OptionalResult = secondoptional == 99 ? 100 : secondoptional
            });
            #endregion

            #region three
            var threesubject = 0;
            var threeholl = 0;
            foreach (var item in Optionalresult)
            {
                if (namelist.Count(x => x == item) > 0)
                {
                    threesubject += 33;
                }
            }
            foreach (var item in Optionalresult)
            {
                if (hollandresult.Count(x => x == item) > 0)
                {
                    threeholl += 33;
                }
            }
            list.Add(new SubjectSelectResult()
            {
                Select = OptionalName,
                SubjectResult = threesubject == 99 ? 100 : threesubject,
                HollResult = threeholl == 99 ? 100 : threeholl,
                OptionalResult = 100
            });
            #endregion
            return new MessageModel<List<SubjectSelectResult>>() { success = true, msg = "获取成功", response = list };
        }

        /// <summary>
        /// 根绝霍兰德获取推荐选科
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public async Task<MessageModel<string>> GetHollandSubject(HollandSubjectQuery query)
        {
            var planinfo = await t_EnrollmentPlaneRepository.Query(w => w.Years == query.Year && w.Area_Id == query.AreaId);
            if (planinfo == null)
                return new MessageModel<string>() { success = false, msg = "所选省份年份的招生计划，正在完善中..." };
            var planid = planinfo.FirstOrDefault().Id;
            if (string.IsNullOrWhiteSpace(query.Tag))
                return new MessageModel<string>() { success = false, msg = "标签传入为空,请去测试" };
            var newTags = GetTag(query.Tag);
            var planmaptag = await t_PlanMapTagRepository.Query(x => x.IsDelete == false);
            List<string> majorlists = new List<string>() { };
            foreach (var item in newTags)
            {
                majorlists.AddRange(planmaptag.Where(x => x.Tag.Contains(item)).Select(x => x.Name).ToList());
            }
            majorlists = majorlists.Distinct().ToList();
            var descinfo = await t_EnrollmentPlanedescRepository.Query(x => x.IsDelete == false && x.PlanId == planid && majorlists.Contains(x.MajorName) && x.UniversityId > 0);
            List<IdNameResult> hollandlist = new List<IdNameResult>() { };
            hollandlist.Add(new IdNameResult() { Name = "物", Id = descinfo.Count(x => x.Subjectclaim.Contains("物")) });
            hollandlist.Add(new IdNameResult() { Name = "化", Id = descinfo.Count(x => x.Subjectclaim.Contains("化")) });
            hollandlist.Add(new IdNameResult() { Name = "生", Id = descinfo.Count(x => x.Subjectclaim.Contains("生")) });
            hollandlist.Add(new IdNameResult() { Name = "政", Id = descinfo.Count(x => x.Subjectclaim.Contains("政")) });
            hollandlist.Add(new IdNameResult() { Name = "史", Id = descinfo.Count(x => x.Subjectclaim.Contains("史")) });
            hollandlist.Add(new IdNameResult() { Name = "地", Id = descinfo.Count(x => x.Subjectclaim.Contains("地")) });
            var hollandresult = hollandlist.OrderByDescending(x => x.Id).Select(x => x.Name).Take(3).ToList();
            var HollandName = string.Join("+", hollandresult);
            return new MessageModel<string>() { success = true, msg = "获取成功", response = HollandName };
        }



        /// <summary>
        /// 转化出标签所有可能
        /// </summary>
        /// <param name="tag"></param>
        /// <returns></returns>
        public List<string> GetTag(string tag)
        {
            var Nums = new List<string>();
            for (int i = 0; i < tag.Length; i++)
            {
                Nums.Add(tag[i].ToString());
            }
            Permutation(Nums.ToArray(), 0, Nums.ToArray().Length);

            //permut = GetTagExtened(tag, permut);
            return permut;
        }

        /// <summary>
        /// 递归实现全排序并输出
        /// </summary>
        /// <param name="nums">待排序的字符数组</param>
        /// <param name="m">输出字符数组的起始位置</param>
        /// <param name="n">输出字符数组的长度</param>
        public void Permutation(string[] nums, int m, int n)
        {
            int i;
            string t;
            if (m < n - 1)
            {
                Permutation(nums, m + 1, n);
                for (i = m + 1; i < n; i++)
                {
                    t = nums[m];
                    nums[m] = nums[i];
                    nums[i] = t;
                    Permutation(nums, m + 1, n);
                    t = nums[m];
                    nums[m] = nums[i];
                    nums[i] = t;
                }
            }
            else
            {
                string kk = string.Empty;
                for (int j = 0; j < nums.Length; j++)
                {
                    kk += nums[j];
                }
                permut.Add(kk);
            }
        }

        public async Task<List<EvaluationResponse>> GetEvaluations(EvaluationRequest request)
        {
            var lists = new List<EvaluationResponse>();
            var categoryids = new List<int>();
            categoryids.Add(18);
            categoryids.Add(19);
            categoryids.Add(21);
            var querys = await _dal.Query(e => e.StudentId == request.CustomerId && categoryids.Contains(e.CategoryId));

            lists.Add(new EvaluationResponse()
            {
                Title = "Holland"
            });
            lists.Add(new EvaluationResponse()
            {
                Title = "MBTI"
            });
            lists.Add(new EvaluationResponse()
            {
                Title = "DISC"
            });
            try
            {
                lists.ForEach(a =>
                {
                    switch (a.Title)
                    {
                        case "Holland":
                            var holland = querys.Where(e => e.CategoryId == 18).FirstOrDefault();
                            a.Message = JsonConvert.DeserializeObject<TagtestingHollandResult>(holland.Result).TagName;
                            a.PId = holland.Id;
                            a.Status = 1;
                            break;
                        case "MBTI":
                            var mbti = querys.Where(e => e.CategoryId == 19).FirstOrDefault();
                            a.Message = mbti.Result;
                            a.PId = mbti.Id;
                            a.Status = 1;
                            break;
                        case "DISC":
                            var disc = querys.Where(e => e.CategoryId == 20);
                            if (disc.Any())
                            {
                                a.PId = disc.FirstOrDefault().Id;
                            }
                            a.Message = "有魅力的、自信的、有说服力的、热情的、鼓舞人心的、乐观的、令人信服的、受欢迎的、好交际的、可信赖的";
                            a.Status = 1;
                            break;
                    }
                });
            }
            catch (Exception ex)
            {
                this._loggerHelper.LogError(ex.ToString());
            }

            return lists;
        }



        ///// <summary>                                                                            
        ///// 判断是否为不常见标签，若是则匹配相关联标签
        ///// </summary>
        ///// <param name="tag"></param>
        ///// <returns></returns>
        //public List<string> GetTagExtened(string tag, List<string> taglist)
        //{
        //    var list = new List<TagExTend>();
        //    var query = yd_tagExInfo.Get(a => a.YD_Enabled == 1 && a.YD_Tags.Equals(tag)).FirstOrDefault();
        //    if (query != null)
        //    {
        //        list = JsonConvert.DeserializeObject<List<TagExTend>>(query.YD_tagEx);
        //    }
        //    if (list.Any() && list.Count() > 0)
        //    {
        //        taglist.AddRange(list.Select(s => s.tag).ToList());
        //    }
        //    return taglist;
        //}
    }
}