コード例 #1
0
        public List <MonthReportSummaryViewModel> GetMonthlyReportDetailSummaryList(bool IsLatestVersion = false)
        {
            List <MonthReportSummaryViewModel> listMonthReportSummaryViewModel = new List <MonthReportSummaryViewModel>();
            MonthReportSummaryViewModel        mrsvm   = null;
            List <MonthlyReportDetail>         MRDList = ReportDetails.Where(p => p.SystemID == _System.ID && (p.Display == true)).ToList();
            List <C_TargetKpi> targetKpiList           = StaticResource.Instance.GetKpiList(_System.ID, FinYear);

            int i = 1;

            foreach (C_Target target in _Target.OrderBy(p => p.Sequence))
            {
                if (target.NeedReport == true)
                {
                    mrsvm                            = new MonthReportSummaryViewModel();
                    mrsvm.ID                         = i;
                    mrsvm.FinYear                    = FinYear;
                    mrsvm.TargetID                   = target.ID;
                    mrsvm.SystemID                   = target.SystemID;
                    mrsvm.TargetName                 = target.TargetName;
                    mrsvm.NPlanAmmount               = (double)(MRDList.Where(p => p.TargetID == target.ID).Sum(e => e.NPlanAmmount));
                    mrsvm.NActualAmmount             = (double)(MRDList.Where(p => p.TargetID == target.ID).Sum(e => e.NActualAmmount));
                    mrsvm.NDifference                = mrsvm.NActualAmmount - mrsvm.NPlanAmmount;
                    mrsvm.NAccumulativePlanAmmount   = (double)(MRDList.Where(p => p.TargetID == target.ID).Sum(e => e.NAccumulativePlanAmmount));
                    mrsvm.NAccumulativeActualAmmount = (double)(MRDList.Where(p => p.TargetID == target.ID).Sum(e => e.NAccumulativeActualAmmount));
                    mrsvm.NAccumulativeDifference    = mrsvm.NAccumulativeActualAmmount - mrsvm.NAccumulativePlanAmmount;
                    if (target.Configuration != null &&
                        target.Configuration.Element("SummaryTargetDisplay") != null &&
                        target.Configuration.Element("SummaryTargetDisplay").Attribute("ShowKpi") != null &&
                        target.Configuration.Element("SummaryTargetDisplay").Attribute("ShowKpi").Value.Trim().ToLower() == "true")
                    {
                        if (targetKpiList.Count > 0 && targetKpiList.Find(p => p.TargetID == target.ID) != null)
                        {
                            mrsvm.MeasureRate = Math.Round(targetKpiList.Find(p => p.TargetID == target.ID).MeasureRate * 100, 0, MidpointRounding.AwayFromZero).ToString() + "%";
                        }
                    }
                    else
                    {
                        mrsvm.MeasureRate1 = (double)Math.Round(StaticResource.Instance.GetTargetPlanList(_System.ID, FinYear).FindAll(P => P.TargetID == target.ID).Sum(P => P.Target), 7, MidpointRounding.AwayFromZero);
                        mrsvm.MeasureRate  = mrsvm.MeasureRate1.ToString();
                    }
                    listMonthReportSummaryViewModel.Add(TargetEvaluationEngine.TargetEvaluationService.SummaryCalculation(mrsvm));
                    i++;
                }
            }
            return(listMonthReportSummaryViewModel);
        }
コード例 #2
0
        /// <summary>
        /// Initial the Data Source of MonthReport and MonthlyReportDetail.
        /// if IsLatestVersion is true, the data source will be B_ table  and WFStatus == Progress.
        /// otherwise, the data source is A_ atble
        /// </summary>
        /// <param name="IsLatestVersion">if the data source should be  B_ Table</param>
        void InitialData(bool IsLatestVersion, bool IsAll)
        {
            if (IsLatestVersion)
            {
                if (LastestMonthlyReport != null)
                {
                    Report = LastestMonthlyReport.ToVModel();
                    if (_MonthReportID == Guid.Empty)
                    {
                        _MonthReportID = Report.ID;
                    }
                }
                ReportDetails = new List <MonthlyReportDetail>();

                if (DataSource == "Draft")
                {
                    ReportDetails = B_MonthlyreportdetailOperator.Instance.GetMonthlyReportDetailList_Draft(_System.ID, FinYear, FinMonth, _MonthReportID, TargetPlanID, _SystemBatchID, IsAll);
                }
                else
                {
                    ReportDetails = B_MonthlyreportdetailOperator.Instance.GetMonthlyReportDetailList_Approve(_System.ID, FinYear, FinMonth, _MonthReportID, TargetPlanID, _SystemBatchID, IsAll);
                }

                //LastestMonthlyReportDetails.ForEach(P => ReportDetails.Add(P.ToVModel()));
            }
            else
            {
                if (ValidatedMonthlyReport != null)
                {
                    Report = ValidatedMonthlyReport.ToVModel();
                    if (_MonthReportID == Guid.Empty)
                    {
                        _MonthReportID = Report.ID;
                    }
                }
                ReportDetails = new List <MonthlyReportDetail>();
                ReportDetails = A_MonthlyreportdetailOperator.Instance.GetMonthlyReportDetailList_Result(_System.ID, FinYear, FinMonth, TargetPlanID);

                //ValidatedMonthlyReportDetails.ForEach(P => ReportDetails.Add(P.ToVModel()));
            }

            if (UserPermission)
            {
                //筛选当前用户有权限的项目公司信息(因为权限数据缺失暂时注释)
                var companyIDArray = BLL.BizBLL.S_OrganizationalActionOperator.Instance.GetUserCompanyDataNoIsDelete(_System.ID, CurrentLoginName).Select(m => m.ID).ToArray();
                if (companyIDArray.Length > 0)
                {
                    ReportDetails = ReportDetails.Where(m => companyIDArray.Contains(m.CompanyID)).ToList();
                    if (ReportDetails.Any())
                    {
                        _MonthReportID = ReportDetails[0].MonthlyReportID;
                        if (IsLatestVersion)
                        {
                            _LastestMonthlyReport = B_MonthlyreportOperator.Instance.GetMonthlyreport(ReportDetails[0].MonthlyReportID);
                            Report = LastestMonthlyReport.ToVModel();
                        }
                        else
                        {
                            _ValidatedMonthlyReport = A_MonthlyreportOperator.Instance.GetMonthlyreport(ReportDetails[0].MonthlyReportID);
                            Report = ValidatedMonthlyReport.ToVModel();
                        }
                    }
                }
                else
                {
                    ReportDetails = new List <MonthlyReportDetail>();
                }
            }
        }
コード例 #3
0
        //public List<DictionaryVmodel> GetDetailRptDataSource(out string HtmlTemplate, string strCompanyProperty, string strOrderType, bool IncludeHaveDetail)
        //{
        //    this.IncludeHaveDetail = IncludeHaveDetail;
        //    strMonthReportOrderType = strOrderType;
        //    if (!string.IsNullOrEmpty(strCompanyProperty))
        //        strCompanyPropertys = strCompanyProperty;
        //    List<VTarget> lstVTarget = SplitCompleteTargetDetailXml(StaticResource.Instance[_System.ID].Configuration);
        //    List<VItemCompanyProperty> lstVItemCompanyProperty = null;
        //    if (SpliteCompanyPropertyXml("List",_System.Configuration).Count > 0)
        //    {
        //        lstVItemCompanyProperty = SpliteCompanyPropertyXml("List",_System.Configuration)[0].listCP.ToList();
        //    }
        //    List<DictionaryVmodel> listvmodel = FromatData(lstVTarget, lstVItemCompanyProperty);
        //    HtmlTemplate = "";
        //    return listvmodel;
        //}
        /// <summary>
        /// 拼装数据
        /// </summary>
        /// <param name="lstVTarget">模型</param>
        /// <param name="lstVCompanyProperty">公司类型</param>
        /// <returns>ViewModel</returns>
        private List <DictionaryVmodel> FromatData(List <VTarget> lstVTarget, List <VItemCompanyProperty> lstVCompanyProperty)
        {
            List <C_Company>        listCompany                  = SearchCompanyData();//根据条件获取公司
            List <DictionaryVmodel> listDictionaryVModel         = new List <DictionaryVmodel>();
            List <DictionaryVmodel> ItemCompanyPropertyViewModel = null;
            List <C_Target>         listTempC_target             = _Target;
            string strHtmlTemplate = string.Empty;

            if (IncludeHaveDetail == false)
            {
                listTempC_target = _Target.Where(p => p.HaveDetail == true).ToList();
            }
            foreach (VTarget vtarget in lstVTarget)
            {
                List <MonthlyReportDetail> listMRD      = new List <MonthlyReportDetail>();
                List <C_Target>            listC_target = listTempC_target.Where(c => c.TargetName == vtarget.TargetName).ToList();
                if (listC_target.Count > 0)
                {
                    C_Target CurrentTarget = listC_target[0];
                    ItemCompanyPropertyViewModel = new List <DictionaryVmodel>();
                    List <MonthlyReportDetail> listm = ReportDetails.Where(p => p.TargetID == CurrentTarget.ID && (p.Display == true)).ToList();

                    //判断是否是明细项数据
                    if (CurrentTarget.HaveDetail == true)
                    {
                        //是否有公司属性
                        if (SpliteCompanyPropertyXml("List", CurrentTarget.Configuration).Count > 0)
                        {
                            lstVCompanyProperty = SpliteCompanyPropertyXml("List", CurrentTarget.Configuration)[0].listCP.ToList();
                        }
                        if (lstVCompanyProperty != null)
                        {
                            foreach (VItemCompanyProperty vcp in lstVCompanyProperty)
                            {
                                List <C_Company>           lstCompany          = listCompany.Where(p => p.CompanyProperty1 == vcp.ItemCompanyPropertyValue).ToList();
                                List <MonthlyReportDetail> listCompanyPertyMRD = SetMonthlyReportDetail(listm, lstCompany);
                                listMRD.AddRange(listCompanyPertyMRD);
                                if (listCompanyPertyMRD.Count == 0)
                                {
                                    continue;
                                }
                                ItemCompanyPropertyViewModel.Add(new DictionaryVmodel(vcp.ItemCompanyPropertyName, EditData(listCompanyPertyMRD, vtarget, listC_target[0], listCompany, vcp), "CompanyProperty"));
                            }
                            if (SpliteCompanyPropertyXml("List", CurrentTarget.Configuration).Count > 0)
                            {
                                lstVCompanyProperty = null;
                            }
                        }
                        else
                        {
                            listMRD = SetMonthlyReportDetail(listm, listCompany);
                            ItemCompanyPropertyViewModel.Add(new DictionaryVmodel("", EditData(listMRD, vtarget, listC_target[0], listCompany, null), "CompanyProperty"));
                        }
                    }
                    else
                    {
                        listMRD = SetMonthlyReportDetail(listm, listCompany);
                        ItemCompanyPropertyViewModel.Add(new DictionaryVmodel("HaveDetail", listMRD, "Counter"));
                    }
                    ItemCompanyPropertyViewModel.Add(new DictionaryVmodel("SummaryData", GetSummaryDate(listMRD, listC_target[0]), "Counter"));

                    #region 判断当前指标是否存在自己的表头、Tmpl模板、Excle模板
                    if (CurrentTarget.Configuration.Elements("ComplateTargetDetail").Elements("TableTemplate").ToList().Count > 0)
                    {
                        strHtmlTemplate = GetComplateMonthReportDetailHtmlTemplate(CurrentTarget.Configuration);
                    }
                    else
                    {
                        //如果当前指标不存在表头、Tmpl模板、Excle模板,则使用系统的。
                        if (_System.Configuration.Elements("ComplateTargetDetail").Elements("TableTemplate").ToList().Count > 0)
                        {
                            strHtmlTemplate = GetComplateMonthReportDetailHtmlTemplate(_System.Configuration);
                        }
                    }
                    listDictionaryVModel.Add(new DictionaryVmodel(vtarget.TargetName, ItemCompanyPropertyViewModel, "Target", strHtmlTemplate));
                    #endregion
                }
            }
            return(listDictionaryVModel);
        }