// bizInMkt를 계산하기위한 function
        public async Task <double> GetTechMng(int questionSn, ScFinancialIndexT sboFinancialIndexT)
        {
            double totalPoint    = 0;   // 리턴할 총점
            double preReserchAmt = 0.0; // 전기 연구개발비

            var rpt = _rptMasterRepository.GetRptMasterByQuestionSn(rm => rm.QuestionSn == questionSn);
            var pre = _scCompanyFinanceRepository.getScCompanyFinance(scf => scf.CompSn == rpt.CompSn && scf.FnYear == int.Parse(sboFinancialIndexT.Year) - 1);

            if (pre != null)
            {
                preReserchAmt = Convert.ToDouble(pre.CiOrdevexp + pre.CiResearch + pre.McRndexp);
            }

            {
                double avg         = 0D;
                double numerator   = (Convert.ToDouble(sboFinancialIndexT.ReserchAmt) + preReserchAmt) / 2.0;
                double denominator = Convert.ToDouble(sboFinancialIndexT.CurrentSale);

                if (denominator != 0)   // 매출액 있을 때
                {
                    if (numerator == 0) // 연구개발비가 0이면
                    {
                        avg = 0;
                    }
                    else // 연구개발비가 0이 아니면
                    {
                        avg = (numerator / denominator) * 100;
                    }
                }
                else // 매출액이 0일 때
                {
                    if (numerator != 0) // 연구개발비가 있으면
                    {
                        avg = 3D;   // 최고점
                    }
                    else // 연구개발비가 0이면
                    {
                        avg = 0;
                    }
                }
                totalPoint = totalPoint + ReportHelper.CalcPoint(ReportHelper.GetCodeTypeM(avg), 2);
            }

            //연구개발 인력의 비율
            var quesResult2sEmpRate = (await _quesResult2Repository.GetQuesResult2sAsync(qrt => qrt.QuestionSn == questionSn &&
                                                                                         qrt.QuesCheckList.CurrentUseYn == "Y" &&
                                                                                         qrt.QuesCheckList.SmallClassCd == "A1B102"))
                                      .OrderBy(qr => qr.QuesCheckList.SmallClassCd)
                                      .ToList();
            //전체임직원수
            var TotalEmp = quesResult2sEmpRate.SingleOrDefault(i => i.QuesCheckList.DetailCd == "A1B10202");
            //연구개발인력
            var RndEmp = quesResult2sEmpRate.SingleOrDefault(i => i.QuesCheckList.DetailCd == "A1B10201");

            if (TotalEmp != null)
            {
                if (int.Parse(TotalEmp.D) != 0)
                {
                    double avg = (int.Parse(RndEmp.D) / double.Parse(TotalEmp.D)) * 100;
                    totalPoint = totalPoint + ReportHelper.CalcPoint(ReportHelper.GetCodeTypeE(avg), 1);
                }
            }

            //연구개발 인력의 능력
            var quesResult2sEmpCapa = (await _quesResult2Repository.GetQuesResult2sAsync(qrt => qrt.QuestionSn == questionSn &&
                                                                                         qrt.QuesCheckList.CurrentUseYn == "Y" &&
                                                                                         qrt.QuesCheckList.SmallClassCd == "A1B103"))
                                      .OrderBy(qr => qr.QuesCheckList.SmallClassCd)
                                      .ToList();
            //박사급
            var DoctorEmp = quesResult2sEmpCapa.SingleOrDefault(i => i.QuesCheckList.DetailCd == "A1B10301");
            //석사급
            var MasterEmp = quesResult2sEmpCapa.SingleOrDefault(i => i.QuesCheckList.DetailCd == "A1B10302");
            //학사급
            var CollegeEmp = quesResult2sEmpCapa.SingleOrDefault(i => i.QuesCheckList.DetailCd == "A1B10303");
            //기능사급
            var TechEmp = quesResult2sEmpCapa.SingleOrDefault(i => i.QuesCheckList.DetailCd == "A1B10304");
            //고졸이하급
            var HighEmp = quesResult2sEmpCapa.SingleOrDefault(i => i.QuesCheckList.DetailCd == "A1B10305");

            if ((int.Parse(DoctorEmp.D) + int.Parse(MasterEmp.D) + int.Parse(CollegeEmp.D) + int.Parse(TechEmp.D) + int.Parse(HighEmp.D)) != 0)
            {
                double avg = ((int.Parse(DoctorEmp.D) * 5) + (int.Parse(MasterEmp.D) * 4) + (int.Parse(CollegeEmp.D) * 3) + (int.Parse(TechEmp.D) * 2) + (int.Parse(HighEmp.D) * 1)) / (double.Parse(DoctorEmp.D) + double.Parse(MasterEmp.D) + double.Parse(CollegeEmp.D) + double.Parse(TechEmp.D) + double.Parse(HighEmp.D));
                totalPoint = totalPoint + ReportHelper.CalcPoint(ReportHelper.GetCodeTypeE(avg), 3);
            }


            // A1B104 : 사업화역량
            var quesResult1sBizCapa = (await _quesResult1Repository.GetQuesResult1sAsync(qro => qro.QuestionSn == questionSn &&
                                                                                         qro.QuesCheckList.CurrentUseYn == "Y" &&
                                                                                         qro.QuesCheckList.SmallClassCd == "A1B104"))
                                      .OrderBy(qr => qr.QuesCheckList.SmallClassCd)
                                      .ToList();

            totalPoint = totalPoint + ReportHelper.CalcPoint(ReportHelper.GetCodeTypeC(ReportHelper.CalcCheckCount(quesResult1sBizCapa)), 5);

            // A1B105 : 사업화실적
            var quesResult2sBizResult = (await _quesResult2Repository.GetQuesResult2sAsync(qrt => qrt.QuestionSn == questionSn &&
                                                                                           qrt.QuesCheckList.CurrentUseYn == "Y" &&
                                                                                           qrt.QuesCheckList.SmallClassCd == "A1B105"))
                                        .OrderBy(qr => qr.QuesCheckList.SmallClassCd)
                                        .ToList();
            //사업화실적 총 건수
            var BizResultCnt = quesResult2sBizResult.SingleOrDefault(i => i.QuesCheckList.DetailCd == "A1B10502");
            {
                double avg = (int.Parse(BizResultCnt.D) + int.Parse(BizResultCnt.D451) + int.Parse(BizResultCnt.D452)) / 3.0;
                totalPoint = totalPoint + ReportHelper.CalcPoint(ReportHelper.GetCodeTypeE(avg), 4);
            }

            // A1B106 : 생산설비의 운영체제 및 관리
            var quesResult1sFacMng = (await _quesResult1Repository.GetQuesResult1sAsync(qro => qro.QuestionSn == questionSn &&
                                                                                        qro.QuesCheckList.CurrentUseYn == "Y" &&
                                                                                        qro.QuesCheckList.SmallClassCd == "A1B106"))
                                     .OrderBy(qr => qr.QuesCheckList.SmallClassCd)
                                     .ToList();

            totalPoint = totalPoint + ReportHelper.CalcPoint(ReportHelper.GetCodeTypeA(ReportHelper.CalcCheckCount(quesResult1sFacMng)), 2);

            // A1B107 : 공정관리
            var quesResult1sProcess = (await _quesResult1Repository.GetQuesResult1sAsync(qro => qro.QuestionSn == questionSn &&
                                                                                         qro.QuesCheckList.CurrentUseYn == "Y" &&
                                                                                         qro.QuesCheckList.SmallClassCd == "A1B107"))
                                      .OrderBy(qr => qr.QuesCheckList.SmallClassCd)
                                      .ToList();

            totalPoint = totalPoint + ReportHelper.CalcPoint(ReportHelper.GetCodeTypeC(ReportHelper.CalcCheckCount(quesResult1sProcess)), 2);

            // A1B108 : 품질관리
            var quesResult1sQaMng = (await _quesResult1Repository.GetQuesResult1sAsync(qro => qro.QuestionSn == questionSn &&
                                                                                       qro.QuesCheckList.CurrentUseYn == "Y" &&
                                                                                       qro.QuesCheckList.SmallClassCd == "A1B108"))
                                    .OrderBy(qr => qr.QuesCheckList.SmallClassCd)
                                    .ToList();

            totalPoint = totalPoint + ReportHelper.CalcPoint(ReportHelper.GetCodeTypeC(ReportHelper.CalcCheckCount(quesResult1sQaMng)), 3);

            // A1C101 : 마케팅 전략의 수립 및 실행
            var quesResult1sMarketing = (await _quesResult1Repository.GetQuesResult1sAsync(qro => qro.QuestionSn == questionSn &&
                                                                                           qro.QuesCheckList.CurrentUseYn == "Y" &&
                                                                                           qro.QuesCheckList.SmallClassCd == "A1C101"))
                                        .OrderBy(qr => qr.QuesCheckList.SmallClassCd)
                                        .ToList();

            totalPoint = totalPoint + ReportHelper.CalcPoint(ReportHelper.GetCodeTypeG(ReportHelper.CalcCheckCount(quesResult1sMarketing)), 8);

            // A1C102 : 고객관리
            var quesResult1sCustMng = (await _quesResult1Repository.GetQuesResult1sAsync(qro => qro.QuestionSn == questionSn &&
                                                                                         qro.QuesCheckList.CurrentUseYn == "Y" &&
                                                                                         qro.QuesCheckList.SmallClassCd == "A1C102"))
                                      .OrderBy(qr => qr.QuesCheckList.SmallClassCd)
                                      .ToList();

            totalPoint = totalPoint + ReportHelper.CalcPoint(ReportHelper.GetCodeTypeA(ReportHelper.CalcCheckCount(quesResult1sCustMng)), 9);

            return(totalPoint);
        }
 public RptMaster GetRptMasterByQuestionSn(int questionSn)
 {
     return(rptMasterRepository.GetRptMasterByQuestionSn(sc => sc.QuestionSn == questionSn));
 }