public List <MonthlyReportDetail> FormatData(List <MonthlyReportDetail> ListMissTargetDetails, VGroup vGroup)
        {
            List <MonthlyReportDetail> lstDetailis = new List <MonthlyReportDetail>();
            ExpressionParser           _parser     = null;

            foreach (MonthlyReportDetail mrd in ListMissTargetDetails)
            {
                foreach (VCounter vcounter in vGroup.CounterList)
                {
                    C_Target cTarget = StaticResource.Instance.TargetList[mrd.SystemID].Where(p => p.ID == mrd.TargetID).FirstOrDefault();
                    if (cTarget != null)
                    {
                        if (cTarget.TargetName == vcounter.Title)
                        {
                            Hashtable bizContext = BizContextEngine.BizContextService.GetBizContext(ListMissTargetDetails.FindAll(p => p.CompanyID == mrd.CompanyID), "MonthlyReportDetail");
                            _parser = new ExpressionParser(bizContext);
                            //区分月累计算式与年累计算式。
                            if (_parser.CacluateCondition(vcounter.Expression))
                            {
                                lstDetailis.Add(mrd);
                            }
                        }
                    }
                }
            }

            return(lstDetailis);
        }
        /// <summary>
        /// 根据未完成公式,获取当月未完成公司的数量
        /// </summary>
        /// <param name="Expression">未完成公式</param>
        /// <param name="TargetIDs">未完成指标ID组合</param>
        /// <returns></returns>
        private int GetCompanyCount(string Expression, List <Guid> TargetIDs, List <MonthlyReportDetail> _CurrMRDList)
        {
            List <Guid> Companys = new List <Guid>();

            //计算本月的
            foreach (MonthlyReportDetail d in _CurrMRDList)
            {
                if (TargetIDs.Contains(d.TargetID)) //上月指标包含当前指标
                {
                    Hashtable        bizContext = BizContextEngine.BizContextService.GetBizContext(_CurrMRDList.FindAll(R => R.CompanyID == d.CompanyID), "A_MonthlyReportDetail");
                    ExpressionParser _parser    = new ExpressionParser(bizContext);

                    //解析这个公式
                    //其中任何一个指标数据满足Counter的条件,此公司的数据都应该归类于该Counter
                    if (_parser.CacluateCondition(Expression))
                    {
                        if (!Companys.Contains(d.CompanyID))
                        {
                            Companys.Add(d.CompanyID);
                        }
                    }
                }
            }
            return(Companys.Count);
        }
Exemplo n.º 3
0
 private void test(string str)
 {
     try
     {
         ExpressionParser tesdt = new ExpressionParser("a");
         bool             s     = tesdt.CacluateCondition(str);
     }
     catch (Exception)
     {
         error = str;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <param name="counter"></param>
        /// <param name="TargetIDs"></param>
        /// <returns></returns>
        private List <MonthlyReportDetail> Calclatedata(VCounter counter, List <Guid> TargetIDs, ref List <MonthlyReportDetail> Source)
        {
            List <Guid> Companys = new List <Guid>();

            List <Guid> targets = new List <Guid>();

            List <MonthlyReportDetail> Result = new List <MonthlyReportDetail>();
            List <MonthlyReportDetail> Filter = new List <MonthlyReportDetail>();

            foreach (MonthlyReportDetail d in Source)
            {
                if (TargetIDs.Contains(d.TargetID)) //上月指标包含当前指标
                {
                    d.TargetGroupCount = 1;
                    Filter.Add(d); //添加

                    Hashtable        bizContext = BizContextEngine.BizContextService.GetBizContext(Source.FindAll(R => R.TargetID == d.TargetID), "A_MonthlyReportDetail");
                    ExpressionParser _parser    = new ExpressionParser(bizContext);

                    //解析这个公式
                    //一个公司多个指标数据属于同一个Group
                    //其中任何一个指标数据满足Counter的条件,此公司的数据都应该归类于该Counter

                    if (_parser.CacluateCondition(counter.Expression))
                    {
                        if (!targets.Contains(d.TargetID))
                        {
                            targets.Add(d.TargetID);
                        }
                    }
                }
            }


            foreach (Guid itemtarget in targets)
            {
                //将筛选出来的值,添加到结果后,马上移除
                Result.AddRange(Filter.FindAll(R => R.TargetID == itemtarget)); ///

                //从总数据中移除已经分类的数据
                Source.RemoveAll(Re => Result.Exists(R => R.ID == Re.ID));
            }

            List <MonthlyReportDetail> returnList = SequenceEngine.SequenceService.GetSequence(_System.ID, "Return", Result, JsonHelper.Serialize(TargetIDs));

            return(returnList);
        }
        /// <summary>
        /// 获取上月的未完成公司
        /// </summary>
        /// <param name="Expression">未完成公式</param>
        /// <param name="TargetIDs">未完成指标ID组合</param>
        /// <returns></returns>
        private int GetLastMonthCompanyCount(string Expression, List <Guid> TargetIDs, List <MonthlyReportDetail> _LastMissTargetList)
        {
            List <Guid> Companys = new List <Guid>();

            //计算上月的
            foreach (MonthlyReportDetail d in _LastMissTargetList)
            {
                if (TargetIDs.Contains(d.TargetID)) //上月指标包含当前指标
                {
                    Hashtable        bizContext = BizContextEngine.BizContextService.GetBizContext(_LastMissTargetList.FindAll(R => R.CompanyID == d.CompanyID), "A_MonthlyReportDetail");
                    ExpressionParser _parser    = new ExpressionParser(bizContext);

                    //解析这个公式
                    //其中任何一个指标数据满足Counter的条件,此公司的数据都应该归类于该Counter
                    if (_parser.CacluateCondition(Expression))
                    {
                        if (!Companys.Contains(d.CompanyID))
                        {
                            Companys.Add(d.CompanyID);
                        }
                    }
                }
            }

            //---Update 2015-5-13  这里只有单个指标不用理会公司(商管,物管)

            string MissTargetSystemName = AppSettingConfig.GetSetting("MissTargetSystemName", "");

            if (MissTargetSystemName.Contains(_System.SystemName) == false)
            {
                if (!IsSingleTarget)
                {
                    //将补回的数据从总的数据中移除掉
                    MissTargetTextList.RemoveAll(Re => Companys.Exists(R => R == Re.CompanyID));
                }
            }
            //--Update 2015-5-13  End


            return(Companys.Count);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <param name="counter"></param>
        /// <param name="TargetIDs"></param>
        /// <returns></returns>
        private List <MonthlyReportDetail> Calclatedata(VCounter counter, List <Guid> TargetIDs, ref List <MonthlyReportDetail> Source)
        {
            List <Guid> Companys = new List <Guid>();

            List <MonthlyReportDetail> Result = new List <MonthlyReportDetail>();
            List <MonthlyReportDetail> Filter = new List <MonthlyReportDetail>();

            foreach (MonthlyReportDetail d in Source)
            {
                if (TargetIDs.Contains(d.TargetID)) //上月指标包含当前指标
                {
                    d.TargetGroupCount = TargetIDs.Count();
                    Filter.Add(d); //添加

                    Hashtable        bizContext = BizContextEngine.BizContextService.GetBizContext(Source.FindAll(R => R.CompanyID == d.CompanyID), "A_MonthlyReportDetail");
                    ExpressionParser _parser    = new ExpressionParser(bizContext);

                    //解析这个公式
                    //一个公司多个指标数据属于同一个Group
                    //其中任何一个指标数据满足Counter的条件,此公司的数据都应该归类于该Counter
                    if (_parser.CacluateCondition(counter.Expression))
                    {
                        if (!Companys.Contains(d.CompanyID))
                        {
                            Companys.Add(d.CompanyID);
                        }
                    }
                }
            }

            foreach (Guid CompanyID in Companys)
            {
                //判断当前公司的数量,是否相同
                if (Filter.Where(r => r.CompanyID == CompanyID).Count() == TargetIDs.Count())
                {
                    //将筛选出来的值,添加到结果后,马上移除
                    Result.AddRange(Filter.FindAll(R => R.CompanyID == CompanyID)); ///
                }
                else
                {
                    //xml定义的指标数比数据库里的指标多
                    int rowCount = TargetIDs.Count() - Filter.Where(r => r.CompanyID == CompanyID).Count();

                    MonthlyReportDetail model = Filter.Where(p => p.CompanyID == CompanyID).FirstOrDefault();

                    List <MonthlyReportDetail> NewDetail = new List <MonthlyReportDetail>();

                    //根据相差指标数目,补齐这些数据
                    for (int i = 0; i < rowCount; i++)
                    {
                        NewDetail.Add(new MonthlyReportDetail()
                        {
                            GroupTile  = model.GroupTile, TargetGroupCount = model.TargetGroupCount,
                            Title      = model.Title, CompanyName = model.CompanyName,
                            CompanyID  = model.CompanyID, TargetID = model.TargetID,      //
                            ReturnType = model.ReturnType, Counter = 0,
                            NAccumulativeActualAmmount = 0, NAccumulativeDifference = 0,
                            AddDifference = 0, NAccumulativePlanAmmount = 0,
                            LastNAccumulativeActualAmmount = 0, LastNAccumulativeDifference = 0,
                            LastNAccumulativePlanAmmount   = 0, TargetName = "--",
                            SystemID = model.SystemID, CreateTime = model.CreateTime
                        });
                    }

                    //将筛选出来的值,添加到结果后,马上移除
                    Result.AddRange(Filter.FindAll(R => R.CompanyID == CompanyID));
                    Result.AddRange(NewDetail);
                }

                //从总数据中移除已经分类的数据
                Source.RemoveAll(Re => Result.Exists(R => R.ID == Re.ID));
            }

            List <MonthlyReportDetail> returnList = SequenceEngine.SequenceService.GetSequence(_System.ID, "Return", Result, JsonHelper.Serialize(TargetIDs));

            return(returnList);
        }
        /// <summary>
        /// 未完成说明
        /// </summary>
        /// <param name="counter"></param>
        /// <param name="TargetIDs"></param>
        /// <returns></returns>
        private List <MonthlyReportDetail> CalclateMissTargetdata(VCounter counter, List <Guid> TargetIDs)
        {
            // List<Guid> Companys = new List<Guid>();

            Hashtable CompanyHt = new Hashtable();

            List <MonthlyReportDetail> Result = new List <MonthlyReportDetail>();
            List <MonthlyReportDetail> Filter = new List <MonthlyReportDetail>();

            foreach (MonthlyReportDetail d in MissTargetList)
            {
                if (TargetIDs.Contains(d.TargetID)) //上月指标包含当前指标
                {
                    d.TargetGroupCount = TargetIDs.Count();
                    Filter.Add(d); //添加

                    Hashtable        bizContext = BizContextEngine.BizContextService.GetBizContext(MissTargetList.FindAll(R => R.CompanyID == d.CompanyID), "A_MonthlyReportDetail");
                    ExpressionParser _parser    = new ExpressionParser(bizContext);

                    //解析这个公式
                    //一个公司多个指标数据属于同一个Group
                    //其中任何一个指标数据满足Counter的条件,此公司的数据都应该归类于该Counter
                    if (_parser.CacluateCondition(counter.Expression))
                    {
                        //if (!Companys.Contains(d.CompanyID))
                        //{
                        //    Companys.Add(d.CompanyID);
                        //}

                        if (!CompanyHt.ContainsKey(d.CompanyID))
                        {
                            CompanyHt.Add(d.CompanyID, counter.TextExpression);
                        }
                    }
                }
            }


            foreach (Guid CompanyID in CompanyHt.Keys)
            {
                //判断当前公司的数量
                if (Filter.Where(r => r.CompanyID == CompanyID).Count() == TargetIDs.Count())
                {
                    //将筛选出来的值,添加到结果后,马上移除
                    Result.AddRange(Filter.FindAll(R => R.CompanyID == CompanyID));

                    if (CompanyHt[CompanyID].ToString() == "Return") // 针对的是补回项的数据,如果是补回数据,则未完成原因和采取措施清空 by dubiao 2015/4/15
                    {
                        foreach (var item in Result)
                        {
                            item.MIssTargetReason      = "";
                            item.MIssTargetDescription = "";
                        }
                    }
                }
                else
                {
                    //xml定义的指标数比数据库里的指标多
                    int rowCount = TargetIDs.Count() - Filter.Where(r => r.CompanyID == CompanyID).Count();

                    MonthlyReportDetail model = Filter.Where(p => p.CompanyID == CompanyID).FirstOrDefault();

                    List <MonthlyReportDetail> NewDetail = new List <MonthlyReportDetail>();

                    //根据相差指标数目,补齐这些数据
                    for (int i = 0; i < rowCount; i++)
                    {
                        NewDetail.Add(new MonthlyReportDetail()
                        {
                            GroupTile                      = model.GroupTile,
                            TargetGroupCount               = model.TargetGroupCount,
                            Title                          = model.Title,
                            CompanyName                    = model.CompanyName,
                            CompanyID                      = model.CompanyID,
                            TargetID                       = Guid.Empty,
                            ReturnType                     = 0,
                            Counter                        = 0,
                            NAccumulativeActualAmmount     = 0,
                            NAccumulativeDifference        = 0,
                            AddDifference                  = 0,
                            NAccumulativePlanAmmount       = 0,
                            LastNAccumulativeActualAmmount = 0,
                            LastNAccumulativeDifference    = 0,
                            LastNAccumulativePlanAmmount   = 0,
                            TargetName                     = "--",
                            SystemID                       = model.SystemID,
                            ReturnDescription              = "",
                            MIssTargetDescription          = "",
                            MIssTargetReason               = ""
                        });
                    }

                    Result.AddRange(Filter.FindAll(R => R.CompanyID == CompanyID));
                    Result.AddRange(NewDetail);
                }

                //从Group的总数据中移除已经分类的数据
                MissTargetList.RemoveAll(Re => Result.Exists(R => R.ID == Re.ID));
            }


            List <MonthlyReportDetail> ResultTempSum = new List <MonthlyReportDetail>();

            //SystemEngine 对商管做了特殊处理,其它系统直接调用排序的Engine
            object NewModel = SystemEngine.SystemEngineService.GetSystem(Result, _System.ID, TargetIDs);

            ResultTempSum = (List <MonthlyReportDetail>)NewModel;



            #region  这里只有项目系统需要单独处理,其它系统都是需要合并的
            //if (_System.GroupType != "ProSystem")
            //{
            //    //未完成说明的合并
            //    for (int i = TargetIDs.Count; i <= ResultTempSum.Count; i = i + TargetIDs.Count)
            //    {
            //        if (TargetIDs.Count > 1)
            //        {
            //            string StrDescription = ResultTempSum[i - TargetIDs.Count].MIssTargetDescription;

            //            string SrtReason = ResultTempSum[i - TargetIDs.Count].MIssTargetReason;

            //            for (int j = 1; j < TargetIDs.Count; j++)
            //            {
            //                StrDescription = StrDescription + ResultTempSum[i - j].MIssTargetDescription; ;

            //                SrtReason = SrtReason + ResultTempSum[i - j].MIssTargetReason;
            //            }

            //            ResultTempSum[i - TargetIDs.Count].MIssTargetDescription = StrDescription;

            //            ResultTempSum[i - TargetIDs.Count].MIssTargetReason = SrtReason;
            //        }
            //    }
            //}
            # endregion

            return(ResultTempSum);
Exemplo n.º 8
0
        /// <summary>
        /// 数据筛选
        /// </summary>
        /// <param name="strCP">公司类型Item</param>
        /// <param name="listMRDetail">数据</param>
        /// <param name="vt">指标项</param>
        /// <returns></returns>

        private List <DictionaryVmodel> EditData(List <MonthlyReportDetail> listMRD, VTarget vt, C_Target CTarget, List <C_Company> listCompany, VItemCompanyProperty vcp)
        {
            #region 声明变量
            List <DictionaryVmodel>    lstDVM = new List <DictionaryVmodel>();
            List <MonthlyReportDetail> VCounterListMonthlyReportDetailViewModel = null;
            ExpressionParser           _parser = null;
            int rowSpanCount                   = 0;
            B_MonthlyReportDetail bmrd         = null;
            List <VCounter>       listVCounter = null;
            #endregion

            #region 数据判断与拼装
            //判断当前指标是否存在模板,如果存在使用指标模板,如果不存在使用当前系统的模板。
            if (CTarget.Configuration.Elements("ComplateTargetDetail").Elements("Target").ToList().Count > 0)
            {
                listVCounter = SplitCompleteTargetDetailXml(CTarget.Configuration)[0].CounterList;
            }
            else
            {
                listVCounter = vt.CounterList;
            }
            for (int i = 0; listVCounter.Count > i; i++)
            {
                DictionaryVmodel dv = dv = new DictionaryVmodel();
                VCounterListMonthlyReportDetailViewModel = new List <MonthlyReportDetail>();
                foreach (MonthlyReportDetail mrd in listMRD)
                {
                    Hashtable bizContext = BizContextEngine.BizContextService.GetBizContext(listMRD.FindAll(p => p.CompanyID == mrd.CompanyID), "MonthlyReportDetail");
                    _parser = new ExpressionParser(bizContext);
                    //区分月累计算式与年累计算式。
                    string Expression = strMonthReportOrderType == "DetailMonthly" ? listVCounter.ToList()[i].DetailMonthlyExpression : listVCounter.ToList()[i].DetailExpression;
                    if (_parser.CacluateCondition(Expression))
                    {
                        VCounterListMonthlyReportDetailViewModel.Add(mrd);
                    }
                }
                //明细项数据排序
                VCounterListMonthlyReportDetailViewModel = SequenceEngine.SequenceService.GetSequence(_System.ID, strMonthReportOrderType, VCounterListMonthlyReportDetailViewModel);
                dv.Name = listVCounter.ToList()[i].Title;

                //判断是否隐藏Counter明细项中数据
                if (listVCounter[i].Display.ToLower() == "true")
                {
                    dv.Mark = "DetailShow";
                    //计算隐藏的行数
                    rowSpanCount = rowSpanCount + VCounterListMonthlyReportDetailViewModel.Count;
                }
                else
                {
                    dv.Mark = "DetailHide";
                }
                //判断Counter明细项中是否存在该数据。
                if (listVCounter[i].HaveDetail.ToLower() == "false")
                {
                    dv.Mark = "DetailDelete";
                }
                //判断是否存在公司属性
                if (vcp != null && i == 0)
                {
                    dv.Value        = vcp.ItemCompanyPropertyName;
                    dv.RowSpanCount = 0;
                }


                #region 计算明细项项合计和小计

                if (!listVCounter.ToList()[i].Title.Contains("小计") && !listVCounter.ToList()[i].Title.Contains("合计"))
                {
                    bmrd = SummaryData(VCounterListMonthlyReportDetailViewModel, bmrd, CTarget);
                }
                else
                {
                    bmrd = SummaryData(listMRD, bmrd, CTarget);
                }
                #endregion

                //调用计算完成率的方法
                bmrd = TargetEvaluationEngine.TargetEvaluationService.Calculation(bmrd, false);
                dv.BMonthReportDetail = bmrd;
                dv.ObjValue           = VCounterListMonthlyReportDetailViewModel;
                lstDVM.Add(dv);
            }
            //计算页面要通行数
            if (vcp != null)
            {
                lstDVM[0].RowSpanCount = rowSpanCount + listVCounter.ToList().Count;
            }
            #endregion

            return(lstDVM);
        }